From f89a5a10d8b02af1a63a93f788639f14e9eb5485 Mon Sep 17 00:00:00 2001 From: Katarina Valalikova Date: Mon, 17 Feb 2020 15:36:24 +0100 Subject: [PATCH 01/97] schema for MID-6019 --- .../xml/ns/public/common/common-core-3.xsd | 61 + .../provisioning/impl/ResourceManager.java | 2986 ++++++++--------- 2 files changed, 1553 insertions(+), 1494 deletions(-) diff --git a/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd b/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd index fd50d0b3ce4..b55490052dc 100755 --- a/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd +++ b/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd @@ -6242,6 +6242,16 @@ + + + + Holds the information when the change of availabilityStatus was made. + + + 4.1 + + + @@ -6356,6 +6366,57 @@ + + + + Describes the reason for chanign availability status of the resource. + + + 4.1 + + + + + + + Holds the information when the change of availabilityStatus was made. + + + 4.1 + + + + + + + Holds the information when the change of availabilityStatus was made. + + + 4.1 + + + + + + + + + + + Structure containing metadata history about operational state of the resource. + E.g. if resource is up or down, when it was last checked, etc. + It should not contain configuration, just the operational state. + + + + + 4.1 + + + + + + diff --git a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ResourceManager.java b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ResourceManager.java index 49089ebeb88..ff8de0db549 100644 --- a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ResourceManager.java +++ b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ResourceManager.java @@ -1,1494 +1,1492 @@ -/* - * Copyright (c) 2010-2018 Evolveum and contributors - * - * This work is dual-licensed under the Apache License 2.0 - * and European Union Public License. See LICENSE file for details. - */ - -package com.evolveum.midpoint.provisioning.impl; - -import java.util.*; - -import javax.xml.namespace.QName; - -import com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition; -import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl; -import com.evolveum.midpoint.prism.*; -import com.evolveum.midpoint.prism.delta.*; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.prism.schema.MutablePrismSchema; -import com.evolveum.midpoint.schema.processor.*; -import com.evolveum.prism.xml.ns._public.types_3.SchemaDefinitionType; - -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.Validate; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Component; -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -import com.evolveum.midpoint.prism.query.ObjectQuery; -import com.evolveum.midpoint.prism.schema.PrismSchema; -import com.evolveum.midpoint.provisioning.api.GenericConnectorException; -import com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance; -import com.evolveum.midpoint.provisioning.ucf.api.ExecuteProvisioningScriptOperation; -import com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException; -import com.evolveum.midpoint.provisioning.util.ProvisioningUtil; -import com.evolveum.midpoint.repo.api.RepositoryService; -import com.evolveum.midpoint.repo.common.expression.Expression; -import com.evolveum.midpoint.repo.common.expression.ExpressionEvaluationContext; -import com.evolveum.midpoint.repo.common.expression.ExpressionFactory; -import com.evolveum.midpoint.repo.common.expression.ExpressionVariables; -import com.evolveum.midpoint.schema.CapabilityUtil; -import com.evolveum.midpoint.schema.GetOperationOptions; -import com.evolveum.midpoint.schema.constants.ConnectorTestOperation; -import com.evolveum.midpoint.schema.constants.SchemaConstants; -import com.evolveum.midpoint.schema.internals.InternalCounters; -import com.evolveum.midpoint.schema.internals.InternalMonitor; -import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus; -import com.evolveum.midpoint.schema.util.ConnectorTypeUtil; -import com.evolveum.midpoint.schema.util.MiscSchemaUtil; -import com.evolveum.midpoint.schema.util.ObjectTypeUtil; -import com.evolveum.midpoint.schema.util.ResourceTypeUtil; -import com.evolveum.midpoint.task.api.StateReporter; -import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.DebugUtil; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; -import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SecurityViolationException; -import com.evolveum.midpoint.util.exception.SystemException; -import com.evolveum.midpoint.util.exception.TunnelException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.common_3.AvailabilityStatusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.CachingMetadataType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilitiesType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorConfigurationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorInstanceSpecificationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ProvisioningScriptType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaGenerationConstraintsType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.XmlSchemaType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.SchemaCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ScriptCapabilityType; - -import static java.util.Collections.singletonList; - -@Component -public class ResourceManager { - - @Autowired @Qualifier("cacheRepositoryService") - private RepositoryService repositoryService; - - @Autowired private ResourceCache resourceCache; - @Autowired private ConnectorManager connectorManager; - @Autowired private PrismContext prismContext; - @Autowired private ExpressionFactory expressionFactory; - - private static final Trace LOGGER = TraceManager.getTrace(ResourceManager.class); - - private static final String OP_COMPLETE_RESOURCE = ResourceManager.class.getName() + ".completeResource"; - - /** - * Completes a resource that has been - we expect - just retrieved from the repository, usually by a search operation. - */ - PrismObject completeResource(PrismObject repositoryObject, GetOperationOptions options, Task task, - OperationResult parentResult) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, - ConfigurationException, CommunicationException { - - String oid = repositoryObject.getOid(); - boolean readonly = GetOperationOptions.isReadOnly(options); - - PrismObject cachedResource = resourceCache.get(oid, repositoryObject.getVersion(), readonly); - if (cachedResource != null) { - return cachedResource; - } else { - LOGGER.debug("Storing fetched resource {}, version {} to cache (previously cached version {})", - oid, repositoryObject.getVersion(), resourceCache.getVersion(oid)); - PrismObject mutableRepositoryObject = repositoryObject.cloneIfImmutable(); - return completeAndCacheResource(mutableRepositoryObject, options, task, parentResult); - } - } - - /** - * Gets a resource. - */ - public PrismObject getResource(String oid, GetOperationOptions options, Task task, OperationResult parentResult) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, ConfigurationException, CommunicationException { - boolean readonly = GetOperationOptions.isReadOnly(options); - PrismObject cachedResource = resourceCache.getIfLatest(oid, readonly, parentResult); - if (cachedResource != null) { - LOGGER.trace("Returning resource from cache:\n{}", cachedResource.debugDumpLazily()); - return cachedResource; - } else { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Fetching resource {} and storing to cache (previously cached version {})", - oid, resourceCache.getVersion(oid)); - } - // We must obviously NOT fetch resource from repo as read-only. We are going to modify it. - PrismObject repositoryObject = readResourceFromRepository(oid, parentResult); - return completeAndCacheResource(repositoryObject, options, task, parentResult); - } - } - - private PrismObject readResourceFromRepository(String oid, OperationResult parentResult) - throws ObjectNotFoundException, SchemaException { - InternalMonitor.recordCount(InternalCounters.RESOURCE_REPOSITORY_READ_COUNT); - return repositoryService.getObject(ResourceType.class, oid, null, parentResult); - } - - /** - * Here we complete the resource and cache it. - * - * @param repositoryObject Up-to-date repository object. Must be mutable. - */ - private PrismObject completeAndCacheResource(PrismObject repositoryObject, - GetOperationOptions options, Task task, OperationResult parentResult) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, - ConfigurationException, CommunicationException { - - checkMutable(repositoryObject); - - PrismObject completedResource = completeResourceInternal(repositoryObject, null, - false, null, options, task, parentResult); - - logResourceAfterCompletion(completedResource); - if (!isComplete(completedResource)) { - // No not cache non-complete resources (e.g. those retrieved with noFetch) - LOGGER.trace("Not putting {} into cache because it's not complete", repositoryObject); - } else { - OperationResult completeResourceResult = parentResult.findSubresult(OP_COMPLETE_RESOURCE); - if (!completeResourceResult.isSuccess()) { - LOGGER.trace("Not putting {} into cache because the completeResource operation status is {}", - ObjectTypeUtil.toShortString(repositoryObject), completeResourceResult.getStatus()); - } else { - // Cache only resources that are completely OK - resourceCache.put(completedResource); - } - } - return completedResource; - } - - private void logResourceAfterCompletion(PrismObject completedResource) { - if (LOGGER.isTraceEnabled()) { - LOGGER.trace("Resource after completion, before putting into cache:\n{}", completedResource.debugDump()); - Element xsdSchemaElement = ResourceTypeUtil.getResourceXsdSchema(completedResource); - if (xsdSchemaElement == null) { - LOGGER.trace("Schema: null"); - } else { - LOGGER.trace("Schema:\n{}", - DOMUtil.serializeDOMToString(ResourceTypeUtil.getResourceXsdSchema(completedResource))); - } - } - } - - void deleteResource(String oid, OperationResult parentResult) throws ObjectNotFoundException { - resourceCache.remove(oid); - repositoryService.deleteObject(ResourceType.class, oid, parentResult); - } - - /** - * Make sure that the resource is complete. - * - * It will check if the resource has a sufficiently fresh schema, etc. - * - * Returned resource may be the same or may be a different instance, but it - * is guaranteed that it will be "fresher" and will correspond to the - * repository state (assuming that the provided resource also corresponded - * to the repository state). - * - * The connector schema that was fetched before can be supplied to this - * method. This is just an optimization. It comes handy e.g. in test - * connection case. - * - * Note: This is not really the best place for this method. Need to figure - * out correct place later. - * - * @param repoResource - * Resource to check - * @param resourceSchema - * schema that was freshly pre-fetched (or null) - * - * @return completed resource - */ - private PrismObject completeResourceInternal(PrismObject repoResource, ResourceSchema resourceSchema, - boolean fetchedSchema, Map> capabilityMap, GetOperationOptions options, Task task, OperationResult parentResult) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException { - - checkMutable(repoResource); - - OperationResult result = parentResult.createMinorSubresult(OP_COMPLETE_RESOURCE); - try { - try { - applyConnectorSchemasToResource(repoResource, task, result); - } catch (Throwable t) { - String message = - "An error occurred while applying connector schema to connector configuration of " + repoResource + ": " - + t.getMessage(); - result.recordPartialError(message, t); - LOGGER.warn(message, t); - return repoResource; - } - - PrismObject newResource; - - if (isComplete(repoResource)) { - // The resource is complete. - newResource = repoResource; - - } else { - // The resource is NOT complete. Try to fetch schema and capabilities - - if (GetOperationOptions.isNoFetch(options)) { - // We need to fetch schema, but the noFetch option is specified. Therefore return whatever we have. - result.recordSuccessIfUnknown(); - return repoResource; - } - - try { - - completeSchemaAndCapabilities(repoResource, resourceSchema, fetchedSchema, capabilityMap, task, result); - - } catch (Exception ex) { - // Catch the exceptions. There are not critical. We need to catch them all because the connector may - // throw even undocumented runtime exceptions. - // Even non-complete resource may still be usable. The fetchResult indicates that there was an error - result.recordPartialError("Cannot complete resource schema and capabilities: " + ex.getMessage(), ex); - return repoResource; - } - - try { - // Now we need to re-read the resource from the repository and re-apply the schemas. This ensures that we will - // cache the correct version and that we avoid race conditions, etc. - - newResource = readResourceFromRepository(repoResource.getOid(), result); - applyConnectorSchemasToResource(newResource, task, result); - - } catch (SchemaException | ObjectNotFoundException | RuntimeException e) { - result.recordFatalError(e); - throw e; - } - } - - try { - // make sure it has parsed resource and refined schema. We are going to cache - // it, so we want to cache it with the parsed schemas - RefinedResourceSchemaImpl.getResourceSchema(newResource, prismContext); - RefinedResourceSchemaImpl.getRefinedSchema(newResource); - - } catch (SchemaException e) { - String message = "Schema error while processing schemaHandling section of " + newResource + ": " + e.getMessage(); - result.recordPartialError(message, e); - LOGGER.warn(message, e); - return newResource; - } catch (RuntimeException e) { - String message = - "Unexpected error while processing schemaHandling section of " + newResource + ": " + e.getMessage(); - result.recordPartialError(message, e); - LOGGER.warn(message, e); - return newResource; - } - - result.recordSuccessIfUnknown(); - - return newResource; - } catch (Throwable t) { - result.recordFatalError(t); - throw t; - } finally { - result.computeStatusIfUnknown(); - } - } - - private boolean isComplete(PrismObject resource) { - ResourceType resourceType = resource.asObjectable(); - if (ResourceTypeUtil.getResourceXsdSchema(resource) == null) { - return false; - } - CapabilitiesType capabilitiesType = resourceType.getCapabilities(); - return capabilitiesType != null && capabilitiesType.getCachingMetadata() != null; - } - - - private void completeSchemaAndCapabilities(PrismObject resource, ResourceSchema resourceSchema, boolean fetchedSchema, - Map> capabilityMap, Task task, OperationResult result) - throws SchemaException, CommunicationException, ObjectNotFoundException, GenericFrameworkException, ConfigurationException { - - Collection> modifications = new ArrayList<>(); - - // Capabilities - // we need to process capabilities first. Schema is one of the connector capabilities. - // We need to determine this capability to select the right connector for schema retrieval. - completeCapabilities(resource, capabilityMap != null, capabilityMap, modifications, result); - - if (resourceSchema == null) { - // Try to get existing schema from resource. We do not want to override this if it exists - // (but we still want to refresh the capabilities, that happens below) - resourceSchema = RefinedResourceSchemaImpl.getResourceSchema(resource, prismContext); - } - - if (resourceSchema == null || resourceSchema.isEmpty()) { - - LOGGER.trace("Fetching resource schema for {}", resource); - - resourceSchema = fetchResourceSchema(resource, capabilityMap, task, result); - - if (resourceSchema == null) { - LOGGER.warn("No resource schema fetched from {}", resource); - } else if (resourceSchema.isEmpty()) { - LOGGER.warn("Empty resource schema fetched from {}", resource); - } else { - LOGGER.debug("Fetched resource schema for {}: {} definitions", resource, resourceSchema.getDefinitions().size()); - fetchedSchema = true; - } - } - - if (fetchedSchema) { - adjustSchemaForSimulatedCapabilities(resource, resourceSchema); - modifications.add(createSchemaUpdateDelta(resource, resourceSchema)); - - // We have successfully fetched the resource schema. Therefore the resource must be up. - modifications.add(createResourceAvailabilityStatusDelta(AvailabilityStatusType.UP)); - } else { - if (resourceSchema != null) { - CachingMetadataType schemaCachingMetadata = resource.asObjectable().getSchema().getCachingMetadata(); - if (schemaCachingMetadata == null) { - schemaCachingMetadata = MiscSchemaUtil.generateCachingMetadata(); - modifications.add( - prismContext.deltaFactory().property().createModificationReplaceProperty( - ItemPath.create(ResourceType.F_SCHEMA, CapabilitiesType.F_CACHING_METADATA), - resource.getDefinition(), - schemaCachingMetadata) - ); - } - } - } - - if (!modifications.isEmpty()) { - try { - LOGGER.trace("Completing {}:\n{}", resource, DebugUtil.debugDumpLazily(modifications, 1)); - repositoryService.modifyObject(ResourceType.class, resource.getOid(), modifications, result); - InternalMonitor.recordCount(InternalCounters.RESOURCE_REPOSITORY_MODIFY_COUNT); - } catch (ObjectAlreadyExistsException ex) { - // This should not happen - throw new SystemException(ex); - } - } - } - - private void completeCapabilities(PrismObject resource, boolean forceRefresh, Map> capabilityMap, Collection> modifications, - OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException { - ResourceType resourceType = resource.asObjectable(); - ConnectorSpec defaultConnectorSpec = getDefaultConnectorSpec(resource); - CapabilitiesType resourceCapType = resourceType.getCapabilities(); - if (resourceCapType == null) { - resourceCapType = new CapabilitiesType(); - resourceType.setCapabilities(resourceCapType); - } - completeConnectorCapabilities(defaultConnectorSpec, resourceCapType, ResourceType.F_CAPABILITIES, forceRefresh, - capabilityMap==null?null:capabilityMap.get(null), - modifications, result); - - for (ConnectorInstanceSpecificationType additionalConnectorType: resource.asObjectable().getAdditionalConnector()) { - ConnectorSpec connectorSpec = getConnectorSpec(resource, additionalConnectorType); - CapabilitiesType connectorCapType = additionalConnectorType.getCapabilities(); - if (connectorCapType == null) { - connectorCapType = new CapabilitiesType(); - additionalConnectorType.setCapabilities(connectorCapType); - } - ItemPath itemPath = additionalConnectorType.asPrismContainerValue().getPath().append(ConnectorInstanceSpecificationType.F_CAPABILITIES); - completeConnectorCapabilities(connectorSpec, connectorCapType, itemPath, forceRefresh, - capabilityMap==null?null:capabilityMap.get(additionalConnectorType.getName()), - modifications, result); - } - } - - private void completeConnectorCapabilities(ConnectorSpec connectorSpec, CapabilitiesType capType, ItemPath itemPath, boolean forceRefresh, - Collection retrievedCapabilities, Collection> modifications, OperationResult result) - throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException { - - if (capType.getNative() != null && !capType.getNative().getAny().isEmpty()) { - if (!forceRefresh) { - CachingMetadataType cachingMetadata = capType.getCachingMetadata(); - if (cachingMetadata == null) { - cachingMetadata = MiscSchemaUtil.generateCachingMetadata(); - modifications.add( - prismContext.deltaFactory().property().createModificationReplaceProperty( - ItemPath.create(ResourceType.F_CAPABILITIES, CapabilitiesType.F_CACHING_METADATA), - connectorSpec.getResource().getDefinition(), - cachingMetadata) - ); - } - return; - } - } - - if (retrievedCapabilities == null) { - try { - - InternalMonitor.recordCount(InternalCounters.CONNECTOR_CAPABILITIES_FETCH_COUNT); - - ConnectorInstance connector = connectorManager.getConfiguredConnectorInstance(connectorSpec, false, result); - retrievedCapabilities = connector.fetchCapabilities(result); - - } catch (GenericFrameworkException e) { - throw new GenericConnectorException("Generic error in connector " + connectorSpec + ": " - + e.getMessage(), e); - } - } - - CapabilityCollectionType nativeCapType = new CapabilityCollectionType(); - capType.setNative(nativeCapType); - nativeCapType.getAny().addAll(retrievedCapabilities); - - CachingMetadataType cachingMetadata = MiscSchemaUtil.generateCachingMetadata(); - capType.setCachingMetadata(cachingMetadata); - - ObjectDelta capabilitiesReplaceDelta = prismContext.deltaFactory().object() - .createModificationReplaceContainer(ResourceType.class, connectorSpec.getResource().getOid(), - itemPath, capType.asPrismContainerValue().clone()); - - modifications.addAll(capabilitiesReplaceDelta.getModifications()); - } - - private ContainerDelta createSchemaUpdateDelta(PrismObject resource, ResourceSchema resourceSchema) throws SchemaException { - Document xsdDoc; - try { - xsdDoc = resourceSchema.serializeToXsd(); - if (LOGGER.isTraceEnabled()) { - LOGGER.trace("Serialized XSD resource schema for {}:\n{}", resource, DOMUtil.serializeDOMToString(xsdDoc)); - } - } catch (SchemaException e) { - throw new SchemaException("Error processing resource schema for " + resource + ": " + e.getMessage(), e); - } - - Element xsdElement = DOMUtil.getFirstChildElement(xsdDoc); - if (xsdElement == null) { - throw new SchemaException("No schema was generated for " + resource); - } - CachingMetadataType cachingMetadata = MiscSchemaUtil.generateCachingMetadata(); - - ContainerDelta schemaContainerDelta = prismContext.deltaFactory().container().createDelta( - ResourceType.F_SCHEMA, ResourceType.class); - PrismContainerValue cval = prismContext.itemFactory().createContainerValue(); - schemaContainerDelta.setValueToReplace(cval); - PrismProperty cachingMetadataProperty = cval - .createProperty(XmlSchemaType.F_CACHING_METADATA); - cachingMetadataProperty.setRealValue(cachingMetadata); - List objectClasses = ResourceTypeUtil.getSchemaGenerationConstraints(resource); - if (objectClasses != null) { - PrismProperty generationConstraints = cval - .createProperty(XmlSchemaType.F_GENERATION_CONSTRAINTS); - SchemaGenerationConstraintsType constraints = new SchemaGenerationConstraintsType(); - constraints.getGenerateObjectClass().addAll(objectClasses); - generationConstraints.setRealValue(constraints); - } - PrismProperty definitionProperty = cval.createProperty(XmlSchemaType.F_DEFINITION); - ObjectTypeUtil.setXsdSchemaDefinition(definitionProperty, xsdElement); - - return schemaContainerDelta; - } - - /** - * Apply proper definition (connector schema) to the resource. - */ - private void applyConnectorSchemasToResource(PrismObject resource, Task task, OperationResult result) - throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException { - checkMutable(resource); - PrismObjectDefinition newResourceDefinition = resource.getDefinition().clone(); - for (ConnectorSpec connectorSpec : getAllConnectorSpecs(resource)) { - try { - applyConnectorSchemaToResource(connectorSpec, newResourceDefinition, resource, task, result); - } catch (CommunicationException | ConfigurationException | SecurityViolationException e) { - throw new IllegalStateException("Unexpected exception: " + e.getMessage(), e); // fixme temporary solution - } - } - resource.setDefinition(newResourceDefinition); - } - - /** - * Apply proper definition (connector schema) to the resource. - */ - private void applyConnectorSchemaToResource(ConnectorSpec connectorSpec, PrismObjectDefinition resourceDefinition, - PrismObject resource, Task task, OperationResult result) - throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { - - ConnectorType connectorType = connectorManager.getConnector(connectorSpec, result); - PrismSchema connectorSchema = connectorManager.getAttachedConnectorSchema(connectorType); - PrismContainerDefinition configurationContainerDefinition = ConnectorTypeUtil - .findConfigurationContainerDefinition(connectorType, connectorSchema); - if (configurationContainerDefinition == null) { - throw new SchemaException("No configuration container definition in schema of " + connectorType); - } - - configurationContainerDefinition = configurationContainerDefinition.clone(); - PrismContainer configurationContainer = connectorSpec.getConnectorConfiguration(); - // We want element name, minOccurs/maxOccurs and similar definition to be taken from the original, not the schema - // the element is global in the connector schema. therefore it does not have correct maxOccurs - if (configurationContainer != null) { - configurationContainerDefinition.adoptElementDefinitionFrom(configurationContainer.getDefinition()); - configurationContainer.applyDefinition(configurationContainerDefinition, true); - - try { - configurationContainer.accept(visitable -> { - if ((visitable instanceof PrismProperty)) { - try { - evaluateExpression((PrismProperty)visitable, resource, task, result); - } catch (SchemaException | ObjectNotFoundException | ExpressionEvaluationException | CommunicationException | ConfigurationException | SecurityViolationException e) { - throw new TunnelException(e); - } - } - }); - } catch (TunnelException te) { - Throwable e = te.getCause(); - if (e instanceof SchemaException) { - throw (SchemaException)e; - } else if (e instanceof ObjectNotFoundException) { - throw (ObjectNotFoundException)e; - } else if (e instanceof ExpressionEvaluationException) { - throw (ExpressionEvaluationException)e; - } else if (e instanceof CommunicationException) { - throw (CommunicationException)e; - } else if (e instanceof ConfigurationException) { - throw (ConfigurationException)e; - } else if (e instanceof SecurityViolationException) { - throw (SecurityViolationException)e; - } else if (e instanceof RuntimeException) { - throw (RuntimeException)e; - } else if (e instanceof Error) { - throw (Error)e; - } else { - throw new SystemException(e); - } - } - - } else { - configurationContainerDefinition.adoptElementDefinitionFrom( - resourceDefinition.findContainerDefinition(ResourceType.F_CONNECTOR_CONFIGURATION)); - } - - if (connectorSpec.getConnectorName() == null) { - // Default connector, for compatibility - // It does not make sense to update this for any other connectors. - // We cannot have one definition for addiitionalConnector[1]/connectorConfiguraiton and - // different definition for addiitionalConnector[2]/connectorConfiguraiton in the object definition. - // The way to go is to set up definitions on the container level. - resourceDefinition.replaceDefinition(ResourceType.F_CONNECTOR_CONFIGURATION, configurationContainerDefinition); - } - - } - - private void evaluateExpression(PrismProperty configurationProperty, PrismObject resource, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { - PrismPropertyDefinition propDef = configurationProperty.getDefinition(); - String shortDesc = "connector configuration property "+configurationProperty+" in "+resource; - List> extraValues = new ArrayList<>(); - for (PrismPropertyValue configurationPropertyValue: configurationProperty.getValues()) { - ExpressionWrapper expressionWrapper = configurationPropertyValue.getExpression(); - if (expressionWrapper == null) { - return; - } - Object expressionObject = expressionWrapper.getExpression(); - if (!(expressionObject instanceof ExpressionType)) { - throw new IllegalStateException("Expected that expression in "+configurationPropertyValue+" will be ExpressionType, but it was "+expressionObject); - } - ExpressionType expressionType = (ExpressionType) expressionWrapper.getExpression(); - - Expression, PrismPropertyDefinition> expression = expressionFactory.makeExpression(expressionType, propDef, MiscSchemaUtil.getExpressionProfile(), shortDesc, task, result); - ExpressionVariables variables = new ExpressionVariables(); - - // TODO: populate variables - - ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(null, variables, shortDesc, task); - PrismValueDeltaSetTriple> expressionOutputTriple = expression.evaluate(expressionContext, - result); - Collection> expressionOutputValues = expressionOutputTriple.getNonNegativeValues(); - if (expressionOutputValues != null && !expressionOutputValues.isEmpty()) { - Iterator> iterator = expressionOutputValues.iterator(); - PrismPropertyValue firstValue = iterator.next(); - configurationPropertyValue.setValue(firstValue.getValue()); - while (iterator.hasNext()) { - extraValues.add(iterator.next()); - } - } - } - for (PrismPropertyValue extraValue: extraValues) { - configurationProperty.add(extraValue); - } - } - - private ResourceSchema fetchResourceSchema(PrismObject resource, Map> capabilityMap, Task task, OperationResult parentResult) - throws CommunicationException, GenericFrameworkException, ConfigurationException, ObjectNotFoundException, SchemaException { - ConnectorSpec connectorSpec = selectConnectorSpec(resource, capabilityMap, SchemaCapabilityType.class); - if (connectorSpec == null) { - LOGGER.debug("No connector has schema capability, cannot fetch resource schema"); - return null; - } - InternalMonitor.recordCount(InternalCounters.RESOURCE_SCHEMA_FETCH_COUNT); - List generateObjectClasses = ResourceTypeUtil.getSchemaGenerationConstraints(resource); - ConnectorInstance connectorInstance = connectorManager.getConfiguredConnectorInstance(connectorSpec, false, parentResult); - - LOGGER.debug("Trying to get schema from {}, objectClasses to generate: {}", connectorSpec, generateObjectClasses); - ResourceSchema resourceSchema = connectorInstance.fetchResourceSchema(parentResult); - - if (ResourceTypeUtil.isValidateSchema(resource.asObjectable())) { - ResourceTypeUtil.validateSchema(resourceSchema, resource); - } - return resourceSchema; - - } - - /** - * Test the connection. - * - * @param resource Resource object as fetched from the repository. Must NOT be immutable! - * - * @throws ObjectNotFoundException If the resource object cannot be found in repository (e.g. when trying to set its - * availability status). - */ - public void testConnection(PrismObject resource, Task task, OperationResult parentResult) - throws ObjectNotFoundException { - - checkMutable(resource); - - String resourceOid = resource.getOid(); - - String operationCtx = "test resource " + resourceOid + "connection"; - - List allConnectorSpecs; - try { - allConnectorSpecs = getAllConnectorSpecs(resource); - } catch (SchemaException e) { - operationCtx += ", getting all connectors failed: " + e.getMessage(); - if (LOGGER.isTraceEnabled()) { - LOGGER.error("Configuration error: {}", e.getMessage(), e); - } - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); - parentResult.recordFatalError("Configuration error: " + e.getMessage(), e); - return; - } - - Map> capabilityMap = new HashMap<>(); - for (ConnectorSpec connectorSpec: allConnectorSpecs) { - - OperationResult connectorTestResult = parentResult - .createSubresult(ConnectorTestOperation.CONNECTOR_TEST.getOperation()); - connectorTestResult.addParam(OperationResult.PARAM_NAME, connectorSpec.getConnectorName()); - connectorTestResult.addParam(OperationResult.PARAM_OID, connectorSpec.getConnectorOid()); - - testConnectionConnector(connectorSpec, capabilityMap, task, connectorTestResult); - - connectorTestResult.computeStatus(); - - if (!connectorTestResult.isAcceptable()) { - //nothing more to do.. if it failed while testing connection, status is set. - // we do not need to continue and waste the time. - return; - } - } - - // === test SCHEMA === - - OperationResult schemaResult = parentResult.createSubresult(ConnectorTestOperation.RESOURCE_SCHEMA.getOperation()); - - ResourceSchema schema; - try { - - schema = fetchResourceSchema(resource, capabilityMap, task, schemaResult); - - } catch (CommunicationException e) { - operationCtx += " failed while fetching schema: " + e.getMessage(); - if (LOGGER.isTraceEnabled()) { - LOGGER.error("Communication error: {}", e.getMessage(), e); - } - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.DOWN, operationCtx, task, parentResult, true); - schemaResult.recordFatalError("Communication error: " + e.getMessage(), e); - return; - } catch (GenericFrameworkException | ConfigurationException | ObjectNotFoundException | SchemaException | RuntimeException e) { - operationCtx += " failed while fetching schema: " + e.getMessage(); - if (LOGGER.isTraceEnabled()) { - LOGGER.error("Error: {}", e.getMessage(), e); - } - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); - schemaResult.recordFatalError("Error: " + e.getMessage(), e); - return; - } - - if (schema == null || schema.isEmpty()) { - // Resource does not support schema - // If there is a static schema in resource definition this may still be OK - try { - schema = RefinedResourceSchemaImpl.getResourceSchema(resource, prismContext); - } catch (SchemaException e) { - operationCtx += " failed while parsing refined schema: " + e.getMessage(); - if (LOGGER.isTraceEnabled()) { - LOGGER.error("Error: {}", e.getMessage(), e); - } - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); - schemaResult.recordFatalError(e); - return; - } - - if (schema == null || schema.isEmpty()) { - String msg = "Connector does not support schema and no static schema available"; - operationCtx += ". " + msg; - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); - schemaResult.recordFatalError(msg); - return; - } - } - - // Invoke completeResource(). This will store the fetched schema to the ResourceType if there is no - // definition already. Therefore the testResource() can be used to generate the resource schema - until we - // have full schema caching capability. - PrismObject completedResource; - try { - completedResource = completeResourceInternal(resource, schema, true, capabilityMap, null, task, schemaResult); - } catch (ObjectNotFoundException e) { - String msg = "Object not found (unexpected error, probably a bug): " + e.getMessage(); - operationCtx += " failed while completing resource. " + msg; - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); - schemaResult.recordFatalError(msg, e); - return; - } catch (SchemaException e) { - String msg = "Schema processing error (probably connector bug): " + e.getMessage(); - operationCtx += " failed while completing resource. " + msg; - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); - schemaResult.recordFatalError(msg, e); - return; - } catch (ExpressionEvaluationException e) { - String msg = "Expression error: " + e.getMessage(); - operationCtx += " failed while completing resource. " + msg; - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); - schemaResult.recordFatalError(msg, e); - return; - } catch (RuntimeException e) { - String msg = "Unspecified exception: " + e.getMessage(); - operationCtx += " failed while completing resource. " + msg; - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); - schemaResult.recordFatalError(msg, e); - return; - } - - schemaResult.recordSuccess(); - - try { - updateResourceSchema(allConnectorSpecs, parentResult, completedResource); - } catch (SchemaException | ObjectNotFoundException | CommunicationException | ConfigurationException | RuntimeException e) { - operationCtx += " failed while updating resource schema: " + e.getMessage(); - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); - parentResult.recordFatalError("Couldn't update resource schema: " + e.getMessage(), e); - return; - } - - // TODO: connector sanity (e.g. refined schema, at least one account type, identifiers - // in schema, etc.) - - } - - private void checkMutable(PrismObject resource) { - if (resource.isImmutable()) { - throw new IllegalArgumentException("Got immutable resource object, while expecting mutable one: " + resource); - } - } - - private void updateResourceSchema(List allConnectorSpecs, OperationResult parentResult, - PrismObject resource) - throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException { - ResourceSchema resourceSchema = RefinedResourceSchemaImpl.getResourceSchema(resource, prismContext); - if (resourceSchema != null) { - for (ConnectorSpec connectorSpec : allConnectorSpecs) { - ConnectorInstance instance = connectorManager.getConfiguredConnectorInstance(connectorSpec, false, parentResult); - instance.updateSchema(resourceSchema); - } - } - } - - private void testConnectionConnector(ConnectorSpec connectorSpec, Map> capabilityMap, Task task, - OperationResult parentResult) throws ObjectNotFoundException { - - // === test INITIALIZATION === - - OperationResult initResult = parentResult - .createSubresult(ConnectorTestOperation.CONNECTOR_INITIALIZATION.getOperation()); - - LOGGER.debug("Testing connection using {}", connectorSpec); - String resourceOid = connectorSpec.getResource().getOid(); - - String operationCtx = "testing connection using " + connectorSpec; - - ConfiguredConnectorInstanceEntry connectorInstanceCacheEntry; - try { - // Make sure we are getting non-configured instance. - connectorInstanceCacheEntry = connectorManager.getConnectorInstanceCacheEntry(connectorSpec, initResult); - initResult.recordSuccess(); - } catch (ObjectNotFoundException e) { - // The connector was not found. The resource definition is either - // wrong or the connector is not installed. - String msg = "The connector was not found: "+e.getMessage(); - operationCtx += " failed while getting connector instance. " + msg; - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); - initResult.recordFatalError(msg, e); - return; - } catch (SchemaException e) { - String msg = "Schema error while dealing with the connector definition: "+e.getMessage(); - operationCtx += " failed while getting connector instance. " + msg; - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); - initResult.recordFatalError(msg, e); - return; - } catch (RuntimeException | Error e) { - String msg = "Unexpected runtime error: "+e.getMessage(); - operationCtx += " failed while getting connector instance. " + msg; - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); - initResult.recordFatalError(msg, e); - return; - } catch (CommunicationException e) { - String msg = "Communication error: "+e.getMessage(); - operationCtx += " failed while getting connector instance. " + msg; - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.DOWN, operationCtx, task, parentResult, true); - initResult.recordFatalError(msg, e); - return; - } catch (ConfigurationException e) { - String msg = "Configuration error: "+e.getMessage(); - operationCtx += " failed while getting connector instance. " + msg; - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); - initResult.recordFatalError(msg, e); - return; - } - - ConnectorInstance connector = connectorInstanceCacheEntry.getConnectorInstance(); - - - // === test CONFIGURATION === - - OperationResult configResult = parentResult - .createSubresult(ConnectorTestOperation.CONNECTOR_CONFIGURATION.getOperation()); - - try { - PrismObject resource = connectorSpec.getResource(); - PrismObjectDefinition newResourceDefinition = resource.getDefinition().clone(); - applyConnectorSchemaToResource(connectorSpec, newResourceDefinition, resource, task, configResult); - PrismContainerValue connectorConfiguration = connectorSpec.getConnectorConfiguration().getValue(); - - InternalMonitor.recordCount(InternalCounters.CONNECTOR_INSTANCE_CONFIGURATION_COUNT); - - connector.configure(connectorConfiguration, ResourceTypeUtil.getSchemaGenerationConstraints(resource), configResult); - - // We need to explicitly initialize the instance, e.g. in case that the schema and capabilities - // cannot be detected by the connector and therefore are provided in the resource - // - // NOTE: the capabilities and schema that are used here are NOT necessarily those that are detected by the resource. - // The detected schema will come later. The schema here is the one that is stored in the resource - // definition (ResourceType). This may be schema that was detected previously. But it may also be a schema - // that was manually defined. This is needed to be passed to the connector in case that the connector - // cannot detect the schema and needs schema/capabilities definition to establish a connection. - // Most connectors will just ignore the schema and capabilities that are provided here. - // But some connectors may need it (e.g. CSV connector working with CSV file without a header). - // - ResourceSchema previousResourceSchema = RefinedResourceSchemaImpl.getResourceSchema(connectorSpec.getResource(), prismContext); - Collection previousCapabilities = ResourceTypeUtil.getNativeCapabilitiesCollection(connectorSpec.getResource().asObjectable()); - connector.initialize(previousResourceSchema, previousCapabilities, - ResourceTypeUtil.isCaseIgnoreAttributeNames(connectorSpec.getResource().asObjectable()), configResult); - - configResult.recordSuccess(); - } catch (CommunicationException e) { - operationCtx += " failed while testing configuration: " + e.getMessage(); - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.DOWN, operationCtx, task, parentResult, true); - configResult.recordFatalError("Communication error", e); - return; - } catch (GenericFrameworkException e) { - operationCtx += " failed while testing configuration: " + e.getMessage(); - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); - configResult.recordFatalError("Generic error", e); - return; - } catch (SchemaException e) { - operationCtx += " failed while testing configuration: " + e.getMessage(); - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); - configResult.recordFatalError("Schema error", e); - return; - } catch (ConfigurationException e) { - operationCtx += " failed while testing configuration: " + e.getMessage(); - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); - configResult.recordFatalError("Configuration error", e); - return; - } catch (ObjectNotFoundException e) { - operationCtx += " failed while testing configuration: " + e.getMessage(); - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); - configResult.recordFatalError("Object not found", e); - return; - } catch (ExpressionEvaluationException e) { - operationCtx += " failed while testing configuration: " + e.getMessage(); - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); - configResult.recordFatalError("Expression error", e); - return; - } catch (SecurityViolationException e) { - operationCtx += " failed while testing configuration: " + e.getMessage(); - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); - configResult.recordFatalError("Security violation", e); - return; - } catch (RuntimeException | Error e) { - operationCtx += " failed while testing configuration: " + e.getMessage(); - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); - configResult.recordFatalError("Unexpected runtime error", e); - return; - } - - // === test CONNECTION === - - // delegate the main part of the test to the connector - connector.test(parentResult); - - parentResult.computeStatus(); - if (!parentResult.isAcceptable()) { - operationCtx += ". Connector test failed: " + parentResult.getMessage(); - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.DOWN, operationCtx, task, parentResult, true); - // No point in going on. Following tests will fail anyway, they will - // just produce misleading - // messages. - return; - } else { - operationCtx += ". Connector test successful."; - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.UP, operationCtx, task, parentResult, false); - } - - // === test CAPABILITIES === - - OperationResult capabilitiesResult = parentResult - .createSubresult(ConnectorTestOperation.CONNECTOR_CAPABILITIES.getOperation()); - try { - InternalMonitor.recordCount(InternalCounters.CONNECTOR_CAPABILITIES_FETCH_COUNT); - Collection retrievedCapabilities = connector.fetchCapabilities(capabilitiesResult); - - capabilityMap.put(connectorSpec.getConnectorName(), retrievedCapabilities); - capabilitiesResult.recordSuccess(); - } catch (CommunicationException e) { - operationCtx += " failed while testing capabilities: " + e.getMessage(); - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.DOWN, operationCtx, task, parentResult, true); - capabilitiesResult.recordFatalError("Communication error", e); - return; - } catch (GenericFrameworkException e) { - operationCtx += " failed while testing capabilities: " + e.getMessage(); - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); - capabilitiesResult.recordFatalError("Generic error", e); - return; - } catch (ConfigurationException e) { - operationCtx += " failed while testing capabilities: " + e.getMessage(); - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); - capabilitiesResult.recordFatalError("Configuration error", e); - return; - } catch (SchemaException e) { - operationCtx += " failed while testing capabilities: " + e.getMessage(); - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); - capabilitiesResult.recordFatalError("Schema error", e); - return; - } catch (RuntimeException | Error e) { - operationCtx += " failed while testing capabilities: " + e.getMessage(); - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); - capabilitiesResult.recordFatalError("Unexpected runtime error", e); - return; - } - - // Connector instance is fully configured at this point. - // But the connector cache entry may not be set up properly and it is not yet placed into the cache. - // Therefore make sure the caching bit is completed. - // Place the connector to cache even if it was configured at the beginning. The connector is reconfigured now. - connectorManager.cacheConfiguredConnector(connectorInstanceCacheEntry, connectorSpec); - } - - /** - * Modifies resource availability status in the repository (if needed). - * - * The necessity of status modification is determined against the current version of the resource - unless "skipGetResource" - * is set. The resource is hopefully cached ResourceCache, so the performance impact should be almost ponone. - * - * Also note that in-memory representation of the resource is not modified. As a side effect, the cached resource - * is invalidated because of the modification. But it will be loaded on the next occasion. This should be quite harmless, - * as we do not expect availability changes to occur frequently. - * - * - * @param operationCtx - * @param skipGetResource True if we want to skip "getResource" operation and therefore apply the change regardless of - * the current resource availability status. This is to be used in situations where we expect that - * the resource might not be successfully retrievable (e.g. if it's broken). - * - * @throws ObjectNotFoundException If the resource object does not exist in repository. - */ - public void modifyResourceAvailabilityStatus(String resourceOid, AvailabilityStatusType newStatus, String operationCtx, Task task, OperationResult result, boolean skipGetResource) throws ObjectNotFoundException { - - AvailabilityStatusType currentStatus; - String description; - if (skipGetResource) { - currentStatus = null; - description = "resource " + resourceOid; - } else { - PrismObject resource; - try { - resource = getResource(resourceOid, GetOperationOptions.createNoFetch(), task, result); - } catch (SchemaException | ExpressionEvaluationException | ConfigurationException | CommunicationException e) { - // We actually do not expect any of these exceptions here. The resource is most probably in use - throw new SystemException("Unexpected exception: " + e.getMessage(), e); - } - ResourceType resourceBean = resource.asObjectable(); - currentStatus = ResourceTypeUtil.getLastAvailabilityStatus(resourceBean); - description = resource.toString(); - } - - if (newStatus != currentStatus) { - //info becasue it's for diagnosing the issues with resource availability - LOGGER.info("Availability status changed from {} to {} for {} because {}", currentStatus, newStatus, description, operationCtx); - try { - List> modifications = singletonList(createResourceAvailabilityStatusDelta(newStatus)); - repositoryService.modifyObject(ResourceType.class, resourceOid, modifications, result); - InternalMonitor.recordCount(InternalCounters.RESOURCE_REPOSITORY_MODIFY_COUNT); - } catch (SchemaException | ObjectAlreadyExistsException e) { - throw new SystemException("Unexpected exception: " + e.getMessage(), e); - } - } - } - - private ItemDelta createResourceAvailabilityStatusDelta(AvailabilityStatusType status) throws SchemaException { - return prismContext.deltaFor(ResourceType.class) - .item(SchemaConstants.PATH_OPERATIONAL_STATE_LAST_AVAILABILITY_STATUS).replace(status) - .asItemDelta(); - } - - /** - * Adjust scheme with respect to capabilities. E.g. disable attributes that - * are used for special purpose (such as account activation simulation). - * - * TODO treat also objectclass-specific capabilities here - */ - private void adjustSchemaForSimulatedCapabilities(PrismObject resource, ResourceSchema resourceSchema) { - ResourceType resourceType = resource.asObjectable(); - if (resourceType.getCapabilities() == null || resourceType.getCapabilities().getConfigured() == null) { - return; - } - ActivationCapabilityType activationCapability = CapabilityUtil.getCapability(resourceType - .getCapabilities().getConfigured().getAny(), ActivationCapabilityType.class); - if (CapabilityUtil.getEffectiveActivationStatus(activationCapability) != null) { - QName attributeName = activationCapability.getStatus().getAttribute(); - Boolean ignore = activationCapability.getStatus().isIgnoreAttribute(); - if (attributeName != null) { - // The attribute used for enable/disable simulation should be ignored in the schema - // otherwise strange things may happen, such as changing the same attribute both from - // activation/enable and from the attribute using its native name. - for (ObjectClassComplexTypeDefinition objectClassDefinition : resourceSchema - .getDefinitions(ObjectClassComplexTypeDefinition.class)) { - ResourceAttributeDefinition attributeDefinition = objectClassDefinition - .findAttributeDefinition(attributeName); - if (attributeDefinition != null) { - if (ignore == null || ignore.booleanValue()) { - ((MutableItemDefinition) attributeDefinition).setProcessing(ItemProcessing.IGNORE); - } - } else { - // simulated activation attribute points to something that is not in the schema - // technically, this is an error. But it looks to be quite common in connectors. - // The enable/disable is using operational attributes that are not exposed in the - // schema, but they work if passed to the connector. - // Therefore we don't want to break anything. We could log an warning here, but the - // warning would be quite frequent. Maybe a better place to warn user would be import - // of the object. - LOGGER.debug("Simulated activation attribute " - + attributeName - + " for objectclass " - + objectClassDefinition.getTypeName() - + " in " - + resource - + " does not exist in the resource schema. This may work well, but it is not clean. Connector exposing such schema should be fixed."); - } - } - } - } - } - - private void checkSchema(PrismSchema schema) throws SchemaException { - // This is resource schema, it should contain only - // ResourceObjectDefinitions - for (Definition def : schema.getDefinitions()) { - if (def instanceof ComplexTypeDefinition) { - // This is OK - } else if (def instanceof ResourceAttributeContainerDefinition) { - checkResourceObjectDefinition((ResourceAttributeContainerDefinition) def); - } else { - throw new SchemaException("Unexpected definition in resource schema: " + def); - } - } - } - - private void checkResourceObjectDefinition(ResourceAttributeContainerDefinition rod) - throws SchemaException { - for (ItemDefinition def : rod.getDefinitions()) { - if (!(def instanceof ResourceAttributeDefinition)) { - throw new SchemaException("Unexpected definition in resource schema object " + rod + ": " - + def); - } - } - } - - public void applyDefinition(ObjectDelta delta, ResourceType resourceWhenNoOid, GetOperationOptions options, Task task, OperationResult objectResult) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - - if (delta.isAdd()) { - PrismObject resource = delta.getObjectToAdd(); - applyConnectorSchemasToResource(resource, task, objectResult); - return; - - } else if (delta.isModify()) { - // Go on - } else { - return; - } - - if (delta.hasCompleteDefinition()){ - //nothing to do, all modifications has definitions..just aplly this deltas.. - return; - } - - - PrismObject resource; - String resourceOid = delta.getOid(); - if (resourceOid == null) { - Validate.notNull(resourceWhenNoOid, "Resource oid not specified in the object delta, and resource is not specified as well. Could not apply definition."); - resource = resourceWhenNoOid.asPrismObject(); - } else { - resource = getResource(resourceOid, options, task, objectResult); - } - - ResourceType resourceType = resource.asObjectable(); -// ResourceType resourceType = completeResource(resource.asObjectable(), null, objectResult); - //TODO TODO TODO FIXME FIXME FIXME copied from ObjectImprted..union this two cases - PrismContainer configurationContainer = ResourceTypeUtil.getConfigurationContainer(resourceType); - if (configurationContainer == null || configurationContainer.isEmpty()) { - // Nothing to check - objectResult.recordWarning("The resource has no configuration"); - return; - } - - // Check the resource configuration. The schema is in connector, so fetch the connector first - String connectorOid = resourceType.getConnectorRef().getOid(); - if (StringUtils.isBlank(connectorOid)) { - objectResult.recordFatalError("The connector reference (connectorRef) is null or empty"); - return; - } - - //ItemDelta.findItemDelta(delta.getModifications(), ResourceType.F_SCHEMA, ContainerDelta.class) == null || - - ReferenceDelta connectorRefDelta = ItemDeltaCollectionsUtil.findReferenceModification(delta.getModifications(), ResourceType.F_CONNECTOR_REF); - if (connectorRefDelta != null){ - Item connectorRefNew = connectorRefDelta.getItemNewMatchingPath(null); - if (connectorRefNew.getValues().size() == 1){ - PrismReferenceValue connectorRefValue = connectorRefNew.getValues().iterator().next(); - if (connectorRefValue.getOid() != null && !connectorOid.equals(connectorRefValue.getOid())){ - connectorOid = connectorRefValue.getOid(); - } - } - } - - PrismObject connector = null; - ConnectorType connectorType = null; - try { - connector = repositoryService.getObject(ConnectorType.class, connectorOid, null, objectResult); - connectorType = connector.asObjectable(); - } catch (ObjectNotFoundException e) { - // No connector, no fun. We can't check the schema. But this is referential integrity problem. - // Mark the error ... there is nothing more to do - objectResult.recordFatalError("Connector (OID:" + connectorOid + ") referenced from the resource is not in the repository", e); - return; - } catch (SchemaException e) { - // Probably a malformed connector. To be kind of robust, lets allow the import. - // Mark the error ... there is nothing more to do - objectResult.recordPartialError("Connector (OID:" + connectorOid + ") referenced from the resource has schema problems: " + e.getMessage(), e); - LOGGER.error("Connector (OID:{}) referenced from the imported resource \"{}\" has schema problems: {}-{}", - new Object[]{connectorOid, resourceType.getName(), e.getMessage(), e}); - return; - } - - Element connectorSchemaElement = ConnectorTypeUtil.getConnectorXsdSchema(connector); - MutablePrismSchema connectorSchema; - if (connectorSchemaElement == null) { - // No schema to validate with - return; - } - try { - connectorSchema = prismContext.schemaFactory().createPrismSchema(DOMUtil.getSchemaTargetNamespace(connectorSchemaElement)); - connectorSchema.parseThis(connectorSchemaElement, true, "schema for " + connector, prismContext); - } catch (SchemaException e) { - objectResult.recordFatalError("Error parsing connector schema for " + connector + ": "+e.getMessage(), e); - return; - } - QName configContainerQName = new QName(connectorType.getNamespace(), ResourceType.F_CONNECTOR_CONFIGURATION.getLocalPart()); - PrismContainerDefinition configContainerDef = - connectorSchema.findContainerDefinitionByElementName(configContainerQName); - if (configContainerDef == null) { - objectResult.recordFatalError("Definition of configuration container " + configContainerQName + " not found in the schema of of " + connector); - return; - } - - try { - configurationContainer.applyDefinition(configContainerDef); - } catch (SchemaException e) { - objectResult.recordFatalError("Configuration error in " + resource + ": "+e.getMessage(), e); - return; - } - - PrismContainer configContainer = resourceType.asPrismObject().findContainer(ResourceType.F_CONNECTOR_CONFIGURATION); - configContainer.applyDefinition(configContainerDef); - - for (ItemDelta itemDelta : delta.getModifications()){ - applyItemDefinition(itemDelta, configContainerDef, objectResult); - } - } - - private void applyItemDefinition(ItemDelta itemDelta, - PrismContainerDefinition configContainerDef, OperationResult objectResult) throws SchemaException { - if (itemDelta.getParentPath() == null){ - LOGGER.trace("No parent path defined for item delta {}", itemDelta); - return; - } - - QName first = itemDelta.getParentPath().firstToNameOrNull(); - if (first == null) { - return; - } - - if (itemDelta.getDefinition() == null && (ResourceType.F_CONNECTOR_CONFIGURATION.equals(first) || ResourceType.F_SCHEMA.equals(first))){ - ItemPath path = itemDelta.getPath().rest(); - D itemDef = configContainerDef.findItemDefinition(path); - if (itemDef == null){ - LOGGER.warn("No definition found for item {}. Check your namespaces?", path); - objectResult.recordWarning("No definition found for item delta: " + itemDelta +". Check your namespaces?" ); -// throw new SchemaException("No definition found for item " + path+ ". Check your namespaces?" ); - return; - } - itemDelta.applyDefinition(itemDef); - - } - } - - public void applyDefinition(PrismObject resource, Task task, OperationResult parentResult) - throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, - ExpressionEvaluationException { - applyConnectorSchemasToResource(resource, task, parentResult); - } - - public void applyDefinition(ObjectQuery query, OperationResult result) { - // TODO: not implemented yet - } - - public Object executeScript(String resourceOid, ProvisioningScriptType script, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - PrismObject resource = getResource(resourceOid, null, task, result); - ConnectorSpec connectorSpec = selectConnectorSpec(resource, ScriptCapabilityType.class); - if (connectorSpec == null) { - throw new UnsupportedOperationException("No connector supports script capability"); - } - ConnectorInstance connectorInstance = connectorManager.getConfiguredConnectorInstance(connectorSpec, false, result); - ExecuteProvisioningScriptOperation scriptOperation = ProvisioningUtil.convertToScriptOperation(script, "script on "+resource, prismContext); - try { - StateReporter reporter = new StateReporter(resourceOid, task); - return connectorInstance.executeScript(scriptOperation, reporter, result); - } catch (GenericFrameworkException e) { - // Not expected. Transform to system exception - result.recordFatalError("Generic provisioning framework error", e); - throw new SystemException("Generic provisioning framework error: " + e.getMessage(), e); - } - } - - public List getConnectorOperationalStatus(PrismObject resource, OperationResult result) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException { - List statuses = new ArrayList<>(); - for (ConnectorSpec connectorSpec: getAllConnectorSpecs(resource)) { - ConnectorInstance connectorInstance = connectorManager.getConfiguredConnectorInstance(connectorSpec, false, result); - ConnectorOperationalStatus operationalStatus = connectorInstance.getOperationalStatus(); - if (operationalStatus != null) { - operationalStatus.setConnectorName(connectorSpec.getConnectorName()); - statuses.add(operationalStatus); - } - } - return statuses; - } - - private List getAllConnectorSpecs(PrismObject resource) throws SchemaException { - List connectorSpecs = new ArrayList<>(); - connectorSpecs.add(getDefaultConnectorSpec(resource)); - for (ConnectorInstanceSpecificationType additionalConnectorType: resource.asObjectable().getAdditionalConnector()) { - connectorSpecs.add(getConnectorSpec(resource, additionalConnectorType)); - } - return connectorSpecs; - } - - // Should be used only internally (private). But it is public, because it is accessed from the tests. - public ConnectorInstance getConfiguredConnectorInstance(PrismObject resource, - Class operationCapabilityClass, boolean forceFresh, OperationResult parentResult) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException { - ConnectorSpec connectorSpec = selectConnectorSpec(resource, operationCapabilityClass); - if (connectorSpec == null) { - return null; - } - return connectorManager.getConfiguredConnectorInstance(connectorSpec, forceFresh, parentResult); - } - - // Used by the tests. Does not change anything. - ConnectorInstance getConfiguredConnectorInstanceFromCache(PrismObject resource, - Class operationCapabilityClass) throws SchemaException { - ConnectorSpec connectorSpec = selectConnectorSpec(resource, operationCapabilityClass); - return connectorSpec != null ? connectorManager.getConfiguredConnectorInstanceFromCache(connectorSpec) : null; - } - - public CapabilitiesType getConnectorCapabilities(ResourceType resource, - RefinedObjectClassDefinition objectClassDefinition, Class operationCapabilityClass) { - if (resource == null) { - return null; - } - - CapabilitiesType connectorCapabilities = null; - for (ConnectorInstanceSpecificationType additionalConnectorType : resource.getAdditionalConnector()) { - if (supportsCapability(additionalConnectorType, operationCapabilityClass)) { - connectorCapabilities = additionalConnectorType.getCapabilities(); - } - } - - if (connectorCapabilities == null) { - connectorCapabilities = resource.getCapabilities(); - } - - - CapabilitiesType finalCapabilities = applyObjectClassCapabilities(connectorCapabilities, objectClassDefinition); - LOGGER.trace("Returning final capabilities:\n{} ", finalCapabilities); - return finalCapabilities; - - } - - private CapabilitiesType applyObjectClassCapabilities(CapabilitiesType connectorCapabilities, RefinedObjectClassDefinition objectClassDefinition) { - - if (objectClassDefinition == null) { - return connectorCapabilities; - } - - CapabilitiesType objectClassCapabilities = objectClassDefinition.getCapabilities(); - if (objectClassCapabilities == null) { - LOGGER.trace("No capabilities for {} specified, skipping merge.", objectClassDefinition); - return connectorCapabilities; - } - - CapabilityCollectionType configured = objectClassCapabilities.getConfigured(); - if (configured == null) { - LOGGER.trace("Empty capabilities in {} specified, skipping merge", objectClassDefinition); - return connectorCapabilities; - } - - CapabilitiesType finalCapabilities = new CapabilitiesType(); - if (connectorCapabilities.getNative() != null) { - finalCapabilities.setNative(connectorCapabilities.getNative()); - } - - if (!hasConfiguredCapabilities(connectorCapabilities)) { - LOGGER.trace("No configured capabilities found for connector, replacing with capabilities defined for {}", objectClassDefinition); - finalCapabilities.setConfigured(configured); - return finalCapabilities; - } - - for (Object capability : connectorCapabilities.getConfigured().getAny()) { - - if (!CapabilityUtil.containsCapabilityWithSameElementName(configured.getAny(), capability)) { - configured.getAny().add(capability); - } - } - - finalCapabilities.setConfigured(configured); - return finalCapabilities; - } - - private boolean hasConfiguredCapabilities(CapabilitiesType supportedCapabilities) { - if (supportedCapabilities.getConfigured() == null) { - return false; - } - - if (supportedCapabilities.getConfigured().getAny().isEmpty()) { - return false; - - } - return true; - } - - private ConnectorSpec selectConnectorSpec(PrismObject resource, Map> capabilityMap, Class capabilityClass) throws SchemaException { - if (capabilityMap == null) { - return selectConnectorSpec(resource, capabilityClass); - } - for (ConnectorInstanceSpecificationType additionalConnectorType: resource.asObjectable().getAdditionalConnector()) { - if (supportsCapability(additionalConnectorType, capabilityMap.get(additionalConnectorType.getName()), capabilityClass)) { - return getConnectorSpec(resource, additionalConnectorType); - } - } - return getDefaultConnectorSpec(resource); - } - - private ConnectorSpec selectConnectorSpec(PrismObject resource, Class operationCapabilityClass) throws SchemaException { - for (ConnectorInstanceSpecificationType additionalConnectorType: resource.asObjectable().getAdditionalConnector()) { - if (supportsCapability(additionalConnectorType, operationCapabilityClass)) { - return getConnectorSpec(resource, additionalConnectorType); - } - } - return getDefaultConnectorSpec(resource); - } - - private boolean supportsCapability(ConnectorInstanceSpecificationType additionalConnectorType, Class capabilityClass) { - T cap = CapabilityUtil.getEffectiveCapability(additionalConnectorType.getCapabilities(), capabilityClass); - if (cap == null) { - return false; - } - return CapabilityUtil.isCapabilityEnabled(cap); - } - - private boolean supportsCapability(ConnectorInstanceSpecificationType additionalConnectorType, Collection nativeCapabilities, Class capabilityClass) { - CapabilitiesType specifiedCapabilitiesType = additionalConnectorType.getCapabilities(); - if (specifiedCapabilitiesType != null) { - CapabilityCollectionType configuredCapCollectionType = specifiedCapabilitiesType.getConfigured(); - if (configuredCapCollectionType != null) { - T configuredCap = CapabilityUtil.getCapability(configuredCapCollectionType.getAny(), capabilityClass); - if (configuredCap != null && !CapabilityUtil.isCapabilityEnabled(configuredCap)) { - return false; - } - } - - } - T cap = CapabilityUtil.getCapability(nativeCapabilities, capabilityClass); - if (cap == null) { - return false; - } - return CapabilityUtil.isCapabilityEnabled(cap); - } - - private ConnectorSpec getDefaultConnectorSpec(PrismObject resource) { - PrismContainer connectorConfiguration = resource.findContainer(ResourceType.F_CONNECTOR_CONFIGURATION); - return new ConnectorSpec(resource, null, ResourceTypeUtil.getConnectorOid(resource), connectorConfiguration); - } - - private ConnectorSpec getConnectorSpec(PrismObject resource, ConnectorInstanceSpecificationType additionalConnectorType) throws SchemaException { - if (additionalConnectorType.getConnectorRef() == null) { - throw new SchemaException("No connector reference in additional connector in "+resource); - } - String connectorOid = additionalConnectorType.getConnectorRef().getOid(); - if (StringUtils.isBlank(connectorOid)) { - throw new SchemaException("No connector OID in additional connector in "+resource); - } - PrismContainer connectorConfiguration = additionalConnectorType.asPrismContainerValue().findContainer(ConnectorInstanceSpecificationType.F_CONNECTOR_CONFIGURATION); - String connectorName = additionalConnectorType.getName(); - if (StringUtils.isBlank(connectorName)) { - throw new SchemaException("No connector name in additional connector in "+resource); - } - return new ConnectorSpec(resource, connectorName, connectorOid, connectorConfiguration); - } - - public PrismContext getPrismContext() { - return prismContext; - } -} +/* + * Copyright (c) 2010-2018 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ + +package com.evolveum.midpoint.provisioning.impl; + +import java.util.*; + +import javax.xml.namespace.QName; + +import com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition; +import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl; +import com.evolveum.midpoint.prism.*; +import com.evolveum.midpoint.prism.delta.*; +import com.evolveum.midpoint.prism.path.ItemPath; +import com.evolveum.midpoint.prism.schema.MutablePrismSchema; +import com.evolveum.midpoint.schema.processor.*; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; +import com.evolveum.prism.xml.ns._public.types_3.SchemaDefinitionType; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.Validate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Component; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +import com.evolveum.midpoint.prism.query.ObjectQuery; +import com.evolveum.midpoint.prism.schema.PrismSchema; +import com.evolveum.midpoint.provisioning.api.GenericConnectorException; +import com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance; +import com.evolveum.midpoint.provisioning.ucf.api.ExecuteProvisioningScriptOperation; +import com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException; +import com.evolveum.midpoint.provisioning.util.ProvisioningUtil; +import com.evolveum.midpoint.repo.api.RepositoryService; +import com.evolveum.midpoint.repo.common.expression.Expression; +import com.evolveum.midpoint.repo.common.expression.ExpressionEvaluationContext; +import com.evolveum.midpoint.repo.common.expression.ExpressionFactory; +import com.evolveum.midpoint.repo.common.expression.ExpressionVariables; +import com.evolveum.midpoint.schema.CapabilityUtil; +import com.evolveum.midpoint.schema.GetOperationOptions; +import com.evolveum.midpoint.schema.constants.ConnectorTestOperation; +import com.evolveum.midpoint.schema.constants.SchemaConstants; +import com.evolveum.midpoint.schema.internals.InternalCounters; +import com.evolveum.midpoint.schema.internals.InternalMonitor; +import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus; +import com.evolveum.midpoint.schema.util.ConnectorTypeUtil; +import com.evolveum.midpoint.schema.util.MiscSchemaUtil; +import com.evolveum.midpoint.schema.util.ObjectTypeUtil; +import com.evolveum.midpoint.schema.util.ResourceTypeUtil; +import com.evolveum.midpoint.task.api.StateReporter; +import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.util.DOMUtil; +import com.evolveum.midpoint.util.DebugUtil; +import com.evolveum.midpoint.util.exception.CommunicationException; +import com.evolveum.midpoint.util.exception.ConfigurationException; +import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; +import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; +import com.evolveum.midpoint.util.exception.ObjectNotFoundException; +import com.evolveum.midpoint.util.exception.SchemaException; +import com.evolveum.midpoint.util.exception.SecurityViolationException; +import com.evolveum.midpoint.util.exception.SystemException; +import com.evolveum.midpoint.util.exception.TunnelException; +import com.evolveum.midpoint.util.logging.Trace; +import com.evolveum.midpoint.util.logging.TraceManager; +import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType; +import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CapabilityType; +import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.SchemaCapabilityType; +import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ScriptCapabilityType; + +import static java.util.Collections.singletonList; + +@Component +public class ResourceManager { + + @Autowired @Qualifier("cacheRepositoryService") + private RepositoryService repositoryService; + + @Autowired private ResourceCache resourceCache; + @Autowired private ConnectorManager connectorManager; + @Autowired private PrismContext prismContext; + @Autowired private ExpressionFactory expressionFactory; + + private static final Trace LOGGER = TraceManager.getTrace(ResourceManager.class); + + private static final String OP_COMPLETE_RESOURCE = ResourceManager.class.getName() + ".completeResource"; + + /** + * Completes a resource that has been - we expect - just retrieved from the repository, usually by a search operation. + */ + PrismObject completeResource(PrismObject repositoryObject, GetOperationOptions options, Task task, + OperationResult parentResult) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, + ConfigurationException, CommunicationException { + + String oid = repositoryObject.getOid(); + boolean readonly = GetOperationOptions.isReadOnly(options); + + PrismObject cachedResource = resourceCache.get(oid, repositoryObject.getVersion(), readonly); + if (cachedResource != null) { + return cachedResource; + } else { + LOGGER.debug("Storing fetched resource {}, version {} to cache (previously cached version {})", + oid, repositoryObject.getVersion(), resourceCache.getVersion(oid)); + PrismObject mutableRepositoryObject = repositoryObject.cloneIfImmutable(); + return completeAndCacheResource(mutableRepositoryObject, options, task, parentResult); + } + } + + /** + * Gets a resource. + */ + public PrismObject getResource(String oid, GetOperationOptions options, Task task, OperationResult parentResult) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, ConfigurationException, CommunicationException { + boolean readonly = GetOperationOptions.isReadOnly(options); + PrismObject cachedResource = resourceCache.getIfLatest(oid, readonly, parentResult); + if (cachedResource != null) { + LOGGER.trace("Returning resource from cache:\n{}", cachedResource.debugDumpLazily()); + return cachedResource; + } else { + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Fetching resource {} and storing to cache (previously cached version {})", + oid, resourceCache.getVersion(oid)); + } + // We must obviously NOT fetch resource from repo as read-only. We are going to modify it. + PrismObject repositoryObject = readResourceFromRepository(oid, parentResult); + return completeAndCacheResource(repositoryObject, options, task, parentResult); + } + } + + private PrismObject readResourceFromRepository(String oid, OperationResult parentResult) + throws ObjectNotFoundException, SchemaException { + InternalMonitor.recordCount(InternalCounters.RESOURCE_REPOSITORY_READ_COUNT); + return repositoryService.getObject(ResourceType.class, oid, null, parentResult); + } + + /** + * Here we complete the resource and cache it. + * + * @param repositoryObject Up-to-date repository object. Must be mutable. + */ + private PrismObject completeAndCacheResource(PrismObject repositoryObject, + GetOperationOptions options, Task task, OperationResult parentResult) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, + ConfigurationException, CommunicationException { + + checkMutable(repositoryObject); + + PrismObject completedResource = completeResourceInternal(repositoryObject, null, + false, null, options, task, parentResult); + + logResourceAfterCompletion(completedResource); + if (!isComplete(completedResource)) { + // No not cache non-complete resources (e.g. those retrieved with noFetch) + LOGGER.trace("Not putting {} into cache because it's not complete", repositoryObject); + } else { + OperationResult completeResourceResult = parentResult.findSubresult(OP_COMPLETE_RESOURCE); + if (!completeResourceResult.isSuccess()) { + LOGGER.trace("Not putting {} into cache because the completeResource operation status is {}", + ObjectTypeUtil.toShortString(repositoryObject), completeResourceResult.getStatus()); + } else { + // Cache only resources that are completely OK + resourceCache.put(completedResource); + } + } + return completedResource; + } + + private void logResourceAfterCompletion(PrismObject completedResource) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Resource after completion, before putting into cache:\n{}", completedResource.debugDump()); + Element xsdSchemaElement = ResourceTypeUtil.getResourceXsdSchema(completedResource); + if (xsdSchemaElement == null) { + LOGGER.trace("Schema: null"); + } else { + LOGGER.trace("Schema:\n{}", + DOMUtil.serializeDOMToString(ResourceTypeUtil.getResourceXsdSchema(completedResource))); + } + } + } + + void deleteResource(String oid, OperationResult parentResult) throws ObjectNotFoundException { + resourceCache.remove(oid); + repositoryService.deleteObject(ResourceType.class, oid, parentResult); + } + + /** + * Make sure that the resource is complete. + * + * It will check if the resource has a sufficiently fresh schema, etc. + * + * Returned resource may be the same or may be a different instance, but it + * is guaranteed that it will be "fresher" and will correspond to the + * repository state (assuming that the provided resource also corresponded + * to the repository state). + * + * The connector schema that was fetched before can be supplied to this + * method. This is just an optimization. It comes handy e.g. in test + * connection case. + * + * Note: This is not really the best place for this method. Need to figure + * out correct place later. + * + * @param repoResource + * Resource to check + * @param resourceSchema + * schema that was freshly pre-fetched (or null) + * + * @return completed resource + */ + private PrismObject completeResourceInternal(PrismObject repoResource, ResourceSchema resourceSchema, + boolean fetchedSchema, Map> capabilityMap, GetOperationOptions options, Task task, OperationResult parentResult) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException { + + checkMutable(repoResource); + + OperationResult result = parentResult.createMinorSubresult(OP_COMPLETE_RESOURCE); + try { + try { + applyConnectorSchemasToResource(repoResource, task, result); + } catch (Throwable t) { + String message = + "An error occurred while applying connector schema to connector configuration of " + repoResource + ": " + + t.getMessage(); + result.recordPartialError(message, t); + LOGGER.warn(message, t); + return repoResource; + } + + PrismObject newResource; + + if (isComplete(repoResource)) { + // The resource is complete. + newResource = repoResource; + + } else { + // The resource is NOT complete. Try to fetch schema and capabilities + + if (GetOperationOptions.isNoFetch(options)) { + // We need to fetch schema, but the noFetch option is specified. Therefore return whatever we have. + result.recordSuccessIfUnknown(); + return repoResource; + } + + try { + + completeSchemaAndCapabilities(repoResource, resourceSchema, fetchedSchema, capabilityMap, task, result); + + } catch (Exception ex) { + // Catch the exceptions. There are not critical. We need to catch them all because the connector may + // throw even undocumented runtime exceptions. + // Even non-complete resource may still be usable. The fetchResult indicates that there was an error + result.recordPartialError("Cannot complete resource schema and capabilities: " + ex.getMessage(), ex); + return repoResource; + } + + try { + // Now we need to re-read the resource from the repository and re-apply the schemas. This ensures that we will + // cache the correct version and that we avoid race conditions, etc. + + newResource = readResourceFromRepository(repoResource.getOid(), result); + applyConnectorSchemasToResource(newResource, task, result); + + } catch (SchemaException | ObjectNotFoundException | RuntimeException e) { + result.recordFatalError(e); + throw e; + } + } + + try { + // make sure it has parsed resource and refined schema. We are going to cache + // it, so we want to cache it with the parsed schemas + RefinedResourceSchemaImpl.getResourceSchema(newResource, prismContext); + RefinedResourceSchemaImpl.getRefinedSchema(newResource); + + } catch (SchemaException e) { + String message = "Schema error while processing schemaHandling section of " + newResource + ": " + e.getMessage(); + result.recordPartialError(message, e); + LOGGER.warn(message, e); + return newResource; + } catch (RuntimeException e) { + String message = + "Unexpected error while processing schemaHandling section of " + newResource + ": " + e.getMessage(); + result.recordPartialError(message, e); + LOGGER.warn(message, e); + return newResource; + } + + result.recordSuccessIfUnknown(); + + return newResource; + } catch (Throwable t) { + result.recordFatalError(t); + throw t; + } finally { + result.computeStatusIfUnknown(); + } + } + + private boolean isComplete(PrismObject resource) { + ResourceType resourceType = resource.asObjectable(); + if (ResourceTypeUtil.getResourceXsdSchema(resource) == null) { + return false; + } + CapabilitiesType capabilitiesType = resourceType.getCapabilities(); + return capabilitiesType != null && capabilitiesType.getCachingMetadata() != null; + } + + + private void completeSchemaAndCapabilities(PrismObject resource, ResourceSchema resourceSchema, boolean fetchedSchema, + Map> capabilityMap, Task task, OperationResult result) + throws SchemaException, CommunicationException, ObjectNotFoundException, GenericFrameworkException, ConfigurationException { + + Collection> modifications = new ArrayList<>(); + + // Capabilities + // we need to process capabilities first. Schema is one of the connector capabilities. + // We need to determine this capability to select the right connector for schema retrieval. + completeCapabilities(resource, capabilityMap != null, capabilityMap, modifications, result); + + if (resourceSchema == null) { + // Try to get existing schema from resource. We do not want to override this if it exists + // (but we still want to refresh the capabilities, that happens below) + resourceSchema = RefinedResourceSchemaImpl.getResourceSchema(resource, prismContext); + } + + if (resourceSchema == null || resourceSchema.isEmpty()) { + + LOGGER.trace("Fetching resource schema for {}", resource); + + resourceSchema = fetchResourceSchema(resource, capabilityMap, task, result); + + if (resourceSchema == null) { + LOGGER.warn("No resource schema fetched from {}", resource); + } else if (resourceSchema.isEmpty()) { + LOGGER.warn("Empty resource schema fetched from {}", resource); + } else { + LOGGER.debug("Fetched resource schema for {}: {} definitions", resource, resourceSchema.getDefinitions().size()); + fetchedSchema = true; + } + } + + if (fetchedSchema) { + adjustSchemaForSimulatedCapabilities(resource, resourceSchema); + modifications.add(createSchemaUpdateDelta(resource, resourceSchema)); + + // We have successfully fetched the resource schema. Therefore the resource must be up. + modifications.add(createResourceAvailabilityStatusDelta(AvailabilityStatusType.UP)); + } else { + if (resourceSchema != null) { + CachingMetadataType schemaCachingMetadata = resource.asObjectable().getSchema().getCachingMetadata(); + if (schemaCachingMetadata == null) { + schemaCachingMetadata = MiscSchemaUtil.generateCachingMetadata(); + modifications.add( + prismContext.deltaFactory().property().createModificationReplaceProperty( + ItemPath.create(ResourceType.F_SCHEMA, CapabilitiesType.F_CACHING_METADATA), + resource.getDefinition(), + schemaCachingMetadata) + ); + } + } + } + + if (!modifications.isEmpty()) { + try { + LOGGER.trace("Completing {}:\n{}", resource, DebugUtil.debugDumpLazily(modifications, 1)); + repositoryService.modifyObject(ResourceType.class, resource.getOid(), modifications, result); + InternalMonitor.recordCount(InternalCounters.RESOURCE_REPOSITORY_MODIFY_COUNT); + } catch (ObjectAlreadyExistsException ex) { + // This should not happen + throw new SystemException(ex); + } + } + } + + private void completeCapabilities(PrismObject resource, boolean forceRefresh, Map> capabilityMap, Collection> modifications, + OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException { + ResourceType resourceType = resource.asObjectable(); + ConnectorSpec defaultConnectorSpec = getDefaultConnectorSpec(resource); + CapabilitiesType resourceCapType = resourceType.getCapabilities(); + if (resourceCapType == null) { + resourceCapType = new CapabilitiesType(); + resourceType.setCapabilities(resourceCapType); + } + completeConnectorCapabilities(defaultConnectorSpec, resourceCapType, ResourceType.F_CAPABILITIES, forceRefresh, + capabilityMap==null?null:capabilityMap.get(null), + modifications, result); + + for (ConnectorInstanceSpecificationType additionalConnectorType: resource.asObjectable().getAdditionalConnector()) { + ConnectorSpec connectorSpec = getConnectorSpec(resource, additionalConnectorType); + CapabilitiesType connectorCapType = additionalConnectorType.getCapabilities(); + if (connectorCapType == null) { + connectorCapType = new CapabilitiesType(); + additionalConnectorType.setCapabilities(connectorCapType); + } + ItemPath itemPath = additionalConnectorType.asPrismContainerValue().getPath().append(ConnectorInstanceSpecificationType.F_CAPABILITIES); + completeConnectorCapabilities(connectorSpec, connectorCapType, itemPath, forceRefresh, + capabilityMap==null?null:capabilityMap.get(additionalConnectorType.getName()), + modifications, result); + } + } + + private void completeConnectorCapabilities(ConnectorSpec connectorSpec, CapabilitiesType capType, ItemPath itemPath, boolean forceRefresh, + Collection retrievedCapabilities, Collection> modifications, OperationResult result) + throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException { + + if (capType.getNative() != null && !capType.getNative().getAny().isEmpty()) { + if (!forceRefresh) { + CachingMetadataType cachingMetadata = capType.getCachingMetadata(); + if (cachingMetadata == null) { + cachingMetadata = MiscSchemaUtil.generateCachingMetadata(); + modifications.add( + prismContext.deltaFactory().property().createModificationReplaceProperty( + ItemPath.create(ResourceType.F_CAPABILITIES, CapabilitiesType.F_CACHING_METADATA), + connectorSpec.getResource().getDefinition(), + cachingMetadata) + ); + } + return; + } + } + + if (retrievedCapabilities == null) { + try { + + InternalMonitor.recordCount(InternalCounters.CONNECTOR_CAPABILITIES_FETCH_COUNT); + + ConnectorInstance connector = connectorManager.getConfiguredConnectorInstance(connectorSpec, false, result); + retrievedCapabilities = connector.fetchCapabilities(result); + + } catch (GenericFrameworkException e) { + throw new GenericConnectorException("Generic error in connector " + connectorSpec + ": " + + e.getMessage(), e); + } + } + + CapabilityCollectionType nativeCapType = new CapabilityCollectionType(); + capType.setNative(nativeCapType); + nativeCapType.getAny().addAll(retrievedCapabilities); + + CachingMetadataType cachingMetadata = MiscSchemaUtil.generateCachingMetadata(); + capType.setCachingMetadata(cachingMetadata); + + ObjectDelta capabilitiesReplaceDelta = prismContext.deltaFactory().object() + .createModificationReplaceContainer(ResourceType.class, connectorSpec.getResource().getOid(), + itemPath, capType.asPrismContainerValue().clone()); + + modifications.addAll(capabilitiesReplaceDelta.getModifications()); + } + + private ContainerDelta createSchemaUpdateDelta(PrismObject resource, ResourceSchema resourceSchema) throws SchemaException { + Document xsdDoc; + try { + xsdDoc = resourceSchema.serializeToXsd(); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Serialized XSD resource schema for {}:\n{}", resource, DOMUtil.serializeDOMToString(xsdDoc)); + } + } catch (SchemaException e) { + throw new SchemaException("Error processing resource schema for " + resource + ": " + e.getMessage(), e); + } + + Element xsdElement = DOMUtil.getFirstChildElement(xsdDoc); + if (xsdElement == null) { + throw new SchemaException("No schema was generated for " + resource); + } + CachingMetadataType cachingMetadata = MiscSchemaUtil.generateCachingMetadata(); + + ContainerDelta schemaContainerDelta = prismContext.deltaFactory().container().createDelta( + ResourceType.F_SCHEMA, ResourceType.class); + PrismContainerValue cval = prismContext.itemFactory().createContainerValue(); + schemaContainerDelta.setValueToReplace(cval); + PrismProperty cachingMetadataProperty = cval + .createProperty(XmlSchemaType.F_CACHING_METADATA); + cachingMetadataProperty.setRealValue(cachingMetadata); + List objectClasses = ResourceTypeUtil.getSchemaGenerationConstraints(resource); + if (objectClasses != null) { + PrismProperty generationConstraints = cval + .createProperty(XmlSchemaType.F_GENERATION_CONSTRAINTS); + SchemaGenerationConstraintsType constraints = new SchemaGenerationConstraintsType(); + constraints.getGenerateObjectClass().addAll(objectClasses); + generationConstraints.setRealValue(constraints); + } + PrismProperty definitionProperty = cval.createProperty(XmlSchemaType.F_DEFINITION); + ObjectTypeUtil.setXsdSchemaDefinition(definitionProperty, xsdElement); + + return schemaContainerDelta; + } + + /** + * Apply proper definition (connector schema) to the resource. + */ + private void applyConnectorSchemasToResource(PrismObject resource, Task task, OperationResult result) + throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException { + checkMutable(resource); + PrismObjectDefinition newResourceDefinition = resource.getDefinition().clone(); + for (ConnectorSpec connectorSpec : getAllConnectorSpecs(resource)) { + try { + applyConnectorSchemaToResource(connectorSpec, newResourceDefinition, resource, task, result); + } catch (CommunicationException | ConfigurationException | SecurityViolationException e) { + throw new IllegalStateException("Unexpected exception: " + e.getMessage(), e); // fixme temporary solution + } + } + resource.setDefinition(newResourceDefinition); + } + + /** + * Apply proper definition (connector schema) to the resource. + */ + private void applyConnectorSchemaToResource(ConnectorSpec connectorSpec, PrismObjectDefinition resourceDefinition, + PrismObject resource, Task task, OperationResult result) + throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { + + ConnectorType connectorType = connectorManager.getConnector(connectorSpec, result); + PrismSchema connectorSchema = connectorManager.getAttachedConnectorSchema(connectorType); + PrismContainerDefinition configurationContainerDefinition = ConnectorTypeUtil + .findConfigurationContainerDefinition(connectorType, connectorSchema); + if (configurationContainerDefinition == null) { + throw new SchemaException("No configuration container definition in schema of " + connectorType); + } + + configurationContainerDefinition = configurationContainerDefinition.clone(); + PrismContainer configurationContainer = connectorSpec.getConnectorConfiguration(); + // We want element name, minOccurs/maxOccurs and similar definition to be taken from the original, not the schema + // the element is global in the connector schema. therefore it does not have correct maxOccurs + if (configurationContainer != null) { + configurationContainerDefinition.adoptElementDefinitionFrom(configurationContainer.getDefinition()); + configurationContainer.applyDefinition(configurationContainerDefinition, true); + + try { + configurationContainer.accept(visitable -> { + if ((visitable instanceof PrismProperty)) { + try { + evaluateExpression((PrismProperty)visitable, resource, task, result); + } catch (SchemaException | ObjectNotFoundException | ExpressionEvaluationException | CommunicationException | ConfigurationException | SecurityViolationException e) { + throw new TunnelException(e); + } + } + }); + } catch (TunnelException te) { + Throwable e = te.getCause(); + if (e instanceof SchemaException) { + throw (SchemaException)e; + } else if (e instanceof ObjectNotFoundException) { + throw (ObjectNotFoundException)e; + } else if (e instanceof ExpressionEvaluationException) { + throw (ExpressionEvaluationException)e; + } else if (e instanceof CommunicationException) { + throw (CommunicationException)e; + } else if (e instanceof ConfigurationException) { + throw (ConfigurationException)e; + } else if (e instanceof SecurityViolationException) { + throw (SecurityViolationException)e; + } else if (e instanceof RuntimeException) { + throw (RuntimeException)e; + } else if (e instanceof Error) { + throw (Error)e; + } else { + throw new SystemException(e); + } + } + + } else { + configurationContainerDefinition.adoptElementDefinitionFrom( + resourceDefinition.findContainerDefinition(ResourceType.F_CONNECTOR_CONFIGURATION)); + } + + if (connectorSpec.getConnectorName() == null) { + // Default connector, for compatibility + // It does not make sense to update this for any other connectors. + // We cannot have one definition for addiitionalConnector[1]/connectorConfiguraiton and + // different definition for addiitionalConnector[2]/connectorConfiguraiton in the object definition. + // The way to go is to set up definitions on the container level. + resourceDefinition.replaceDefinition(ResourceType.F_CONNECTOR_CONFIGURATION, configurationContainerDefinition); + } + + } + + private void evaluateExpression(PrismProperty configurationProperty, PrismObject resource, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { + PrismPropertyDefinition propDef = configurationProperty.getDefinition(); + String shortDesc = "connector configuration property "+configurationProperty+" in "+resource; + List> extraValues = new ArrayList<>(); + for (PrismPropertyValue configurationPropertyValue: configurationProperty.getValues()) { + ExpressionWrapper expressionWrapper = configurationPropertyValue.getExpression(); + if (expressionWrapper == null) { + return; + } + Object expressionObject = expressionWrapper.getExpression(); + if (!(expressionObject instanceof ExpressionType)) { + throw new IllegalStateException("Expected that expression in "+configurationPropertyValue+" will be ExpressionType, but it was "+expressionObject); + } + ExpressionType expressionType = (ExpressionType) expressionWrapper.getExpression(); + + Expression, PrismPropertyDefinition> expression = expressionFactory.makeExpression(expressionType, propDef, MiscSchemaUtil.getExpressionProfile(), shortDesc, task, result); + ExpressionVariables variables = new ExpressionVariables(); + + // TODO: populate variables + + ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(null, variables, shortDesc, task); + PrismValueDeltaSetTriple> expressionOutputTriple = expression.evaluate(expressionContext, + result); + Collection> expressionOutputValues = expressionOutputTriple.getNonNegativeValues(); + if (expressionOutputValues != null && !expressionOutputValues.isEmpty()) { + Iterator> iterator = expressionOutputValues.iterator(); + PrismPropertyValue firstValue = iterator.next(); + configurationPropertyValue.setValue(firstValue.getValue()); + while (iterator.hasNext()) { + extraValues.add(iterator.next()); + } + } + } + for (PrismPropertyValue extraValue: extraValues) { + configurationProperty.add(extraValue); + } + } + + private ResourceSchema fetchResourceSchema(PrismObject resource, Map> capabilityMap, Task task, OperationResult parentResult) + throws CommunicationException, GenericFrameworkException, ConfigurationException, ObjectNotFoundException, SchemaException { + ConnectorSpec connectorSpec = selectConnectorSpec(resource, capabilityMap, SchemaCapabilityType.class); + if (connectorSpec == null) { + LOGGER.debug("No connector has schema capability, cannot fetch resource schema"); + return null; + } + InternalMonitor.recordCount(InternalCounters.RESOURCE_SCHEMA_FETCH_COUNT); + List generateObjectClasses = ResourceTypeUtil.getSchemaGenerationConstraints(resource); + ConnectorInstance connectorInstance = connectorManager.getConfiguredConnectorInstance(connectorSpec, false, parentResult); + + LOGGER.debug("Trying to get schema from {}, objectClasses to generate: {}", connectorSpec, generateObjectClasses); + ResourceSchema resourceSchema = connectorInstance.fetchResourceSchema(parentResult); + + if (ResourceTypeUtil.isValidateSchema(resource.asObjectable())) { + ResourceTypeUtil.validateSchema(resourceSchema, resource); + } + return resourceSchema; + + } + + /** + * Test the connection. + * + * @param resource Resource object as fetched from the repository. Must NOT be immutable! + * + * @throws ObjectNotFoundException If the resource object cannot be found in repository (e.g. when trying to set its + * availability status). + */ + public void testConnection(PrismObject resource, Task task, OperationResult parentResult) + throws ObjectNotFoundException { + + checkMutable(resource); + + String resourceOid = resource.getOid(); + + String operationCtx = "test resource " + resourceOid + "connection"; + + List allConnectorSpecs; + try { + allConnectorSpecs = getAllConnectorSpecs(resource); + } catch (SchemaException e) { + operationCtx += ", getting all connectors failed: " + e.getMessage(); + if (LOGGER.isTraceEnabled()) { + LOGGER.error("Configuration error: {}", e.getMessage(), e); + } + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); + parentResult.recordFatalError("Configuration error: " + e.getMessage(), e); + return; + } + + Map> capabilityMap = new HashMap<>(); + for (ConnectorSpec connectorSpec: allConnectorSpecs) { + + OperationResult connectorTestResult = parentResult + .createSubresult(ConnectorTestOperation.CONNECTOR_TEST.getOperation()); + connectorTestResult.addParam(OperationResult.PARAM_NAME, connectorSpec.getConnectorName()); + connectorTestResult.addParam(OperationResult.PARAM_OID, connectorSpec.getConnectorOid()); + + testConnectionConnector(connectorSpec, capabilityMap, task, connectorTestResult); + + connectorTestResult.computeStatus(); + + if (!connectorTestResult.isAcceptable()) { + //nothing more to do.. if it failed while testing connection, status is set. + // we do not need to continue and waste the time. + return; + } + } + + // === test SCHEMA === + + OperationResult schemaResult = parentResult.createSubresult(ConnectorTestOperation.RESOURCE_SCHEMA.getOperation()); + + ResourceSchema schema; + try { + + schema = fetchResourceSchema(resource, capabilityMap, task, schemaResult); + + } catch (CommunicationException e) { + operationCtx += " failed while fetching schema: " + e.getMessage(); + if (LOGGER.isTraceEnabled()) { + LOGGER.error("Communication error: {}", e.getMessage(), e); + } + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.DOWN, operationCtx, task, parentResult, true); + schemaResult.recordFatalError("Communication error: " + e.getMessage(), e); + return; + } catch (GenericFrameworkException | ConfigurationException | ObjectNotFoundException | SchemaException | RuntimeException e) { + operationCtx += " failed while fetching schema: " + e.getMessage(); + if (LOGGER.isTraceEnabled()) { + LOGGER.error("Error: {}", e.getMessage(), e); + } + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); + schemaResult.recordFatalError("Error: " + e.getMessage(), e); + return; + } + + if (schema == null || schema.isEmpty()) { + // Resource does not support schema + // If there is a static schema in resource definition this may still be OK + try { + schema = RefinedResourceSchemaImpl.getResourceSchema(resource, prismContext); + } catch (SchemaException e) { + operationCtx += " failed while parsing refined schema: " + e.getMessage(); + if (LOGGER.isTraceEnabled()) { + LOGGER.error("Error: {}", e.getMessage(), e); + } + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); + schemaResult.recordFatalError(e); + return; + } + + if (schema == null || schema.isEmpty()) { + String msg = "Connector does not support schema and no static schema available"; + operationCtx += ". " + msg; + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); + schemaResult.recordFatalError(msg); + return; + } + } + + // Invoke completeResource(). This will store the fetched schema to the ResourceType if there is no + // definition already. Therefore the testResource() can be used to generate the resource schema - until we + // have full schema caching capability. + PrismObject completedResource; + try { + completedResource = completeResourceInternal(resource, schema, true, capabilityMap, null, task, schemaResult); + } catch (ObjectNotFoundException e) { + String msg = "Object not found (unexpected error, probably a bug): " + e.getMessage(); + operationCtx += " failed while completing resource. " + msg; + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); + schemaResult.recordFatalError(msg, e); + return; + } catch (SchemaException e) { + String msg = "Schema processing error (probably connector bug): " + e.getMessage(); + operationCtx += " failed while completing resource. " + msg; + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); + schemaResult.recordFatalError(msg, e); + return; + } catch (ExpressionEvaluationException e) { + String msg = "Expression error: " + e.getMessage(); + operationCtx += " failed while completing resource. " + msg; + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); + schemaResult.recordFatalError(msg, e); + return; + } catch (RuntimeException e) { + String msg = "Unspecified exception: " + e.getMessage(); + operationCtx += " failed while completing resource. " + msg; + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); + schemaResult.recordFatalError(msg, e); + return; + } + + schemaResult.recordSuccess(); + + try { + updateResourceSchema(allConnectorSpecs, parentResult, completedResource); + } catch (SchemaException | ObjectNotFoundException | CommunicationException | ConfigurationException | RuntimeException e) { + operationCtx += " failed while updating resource schema: " + e.getMessage(); + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); + parentResult.recordFatalError("Couldn't update resource schema: " + e.getMessage(), e); + return; + } + + // TODO: connector sanity (e.g. refined schema, at least one account type, identifiers + // in schema, etc.) + + } + + private void checkMutable(PrismObject resource) { + if (resource.isImmutable()) { + throw new IllegalArgumentException("Got immutable resource object, while expecting mutable one: " + resource); + } + } + + private void updateResourceSchema(List allConnectorSpecs, OperationResult parentResult, + PrismObject resource) + throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException { + ResourceSchema resourceSchema = RefinedResourceSchemaImpl.getResourceSchema(resource, prismContext); + if (resourceSchema != null) { + for (ConnectorSpec connectorSpec : allConnectorSpecs) { + ConnectorInstance instance = connectorManager.getConfiguredConnectorInstance(connectorSpec, false, parentResult); + instance.updateSchema(resourceSchema); + } + } + } + + private void testConnectionConnector(ConnectorSpec connectorSpec, Map> capabilityMap, Task task, + OperationResult parentResult) throws ObjectNotFoundException { + + // === test INITIALIZATION === + + OperationResult initResult = parentResult + .createSubresult(ConnectorTestOperation.CONNECTOR_INITIALIZATION.getOperation()); + + LOGGER.debug("Testing connection using {}", connectorSpec); + String resourceOid = connectorSpec.getResource().getOid(); + + String operationCtx = "testing connection using " + connectorSpec; + + ConfiguredConnectorInstanceEntry connectorInstanceCacheEntry; + try { + // Make sure we are getting non-configured instance. + connectorInstanceCacheEntry = connectorManager.getConnectorInstanceCacheEntry(connectorSpec, initResult); + initResult.recordSuccess(); + } catch (ObjectNotFoundException e) { + // The connector was not found. The resource definition is either + // wrong or the connector is not installed. + String msg = "The connector was not found: "+e.getMessage(); + operationCtx += " failed while getting connector instance. " + msg; + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); + initResult.recordFatalError(msg, e); + return; + } catch (SchemaException e) { + String msg = "Schema error while dealing with the connector definition: "+e.getMessage(); + operationCtx += " failed while getting connector instance. " + msg; + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); + initResult.recordFatalError(msg, e); + return; + } catch (RuntimeException | Error e) { + String msg = "Unexpected runtime error: "+e.getMessage(); + operationCtx += " failed while getting connector instance. " + msg; + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); + initResult.recordFatalError(msg, e); + return; + } catch (CommunicationException e) { + String msg = "Communication error: "+e.getMessage(); + operationCtx += " failed while getting connector instance. " + msg; + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.DOWN, operationCtx, task, parentResult, true); + initResult.recordFatalError(msg, e); + return; + } catch (ConfigurationException e) { + String msg = "Configuration error: "+e.getMessage(); + operationCtx += " failed while getting connector instance. " + msg; + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); + initResult.recordFatalError(msg, e); + return; + } + + ConnectorInstance connector = connectorInstanceCacheEntry.getConnectorInstance(); + + + // === test CONFIGURATION === + + OperationResult configResult = parentResult + .createSubresult(ConnectorTestOperation.CONNECTOR_CONFIGURATION.getOperation()); + + try { + PrismObject resource = connectorSpec.getResource(); + PrismObjectDefinition newResourceDefinition = resource.getDefinition().clone(); + applyConnectorSchemaToResource(connectorSpec, newResourceDefinition, resource, task, configResult); + PrismContainerValue connectorConfiguration = connectorSpec.getConnectorConfiguration().getValue(); + + InternalMonitor.recordCount(InternalCounters.CONNECTOR_INSTANCE_CONFIGURATION_COUNT); + + connector.configure(connectorConfiguration, ResourceTypeUtil.getSchemaGenerationConstraints(resource), configResult); + + // We need to explicitly initialize the instance, e.g. in case that the schema and capabilities + // cannot be detected by the connector and therefore are provided in the resource + // + // NOTE: the capabilities and schema that are used here are NOT necessarily those that are detected by the resource. + // The detected schema will come later. The schema here is the one that is stored in the resource + // definition (ResourceType). This may be schema that was detected previously. But it may also be a schema + // that was manually defined. This is needed to be passed to the connector in case that the connector + // cannot detect the schema and needs schema/capabilities definition to establish a connection. + // Most connectors will just ignore the schema and capabilities that are provided here. + // But some connectors may need it (e.g. CSV connector working with CSV file without a header). + // + ResourceSchema previousResourceSchema = RefinedResourceSchemaImpl.getResourceSchema(connectorSpec.getResource(), prismContext); + Collection previousCapabilities = ResourceTypeUtil.getNativeCapabilitiesCollection(connectorSpec.getResource().asObjectable()); + connector.initialize(previousResourceSchema, previousCapabilities, + ResourceTypeUtil.isCaseIgnoreAttributeNames(connectorSpec.getResource().asObjectable()), configResult); + + configResult.recordSuccess(); + } catch (CommunicationException e) { + operationCtx += " failed while testing configuration: " + e.getMessage(); + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.DOWN, operationCtx, task, parentResult, true); + configResult.recordFatalError("Communication error", e); + return; + } catch (GenericFrameworkException e) { + operationCtx += " failed while testing configuration: " + e.getMessage(); + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); + configResult.recordFatalError("Generic error", e); + return; + } catch (SchemaException e) { + operationCtx += " failed while testing configuration: " + e.getMessage(); + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); + configResult.recordFatalError("Schema error", e); + return; + } catch (ConfigurationException e) { + operationCtx += " failed while testing configuration: " + e.getMessage(); + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); + configResult.recordFatalError("Configuration error", e); + return; + } catch (ObjectNotFoundException e) { + operationCtx += " failed while testing configuration: " + e.getMessage(); + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); + configResult.recordFatalError("Object not found", e); + return; + } catch (ExpressionEvaluationException e) { + operationCtx += " failed while testing configuration: " + e.getMessage(); + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); + configResult.recordFatalError("Expression error", e); + return; + } catch (SecurityViolationException e) { + operationCtx += " failed while testing configuration: " + e.getMessage(); + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); + configResult.recordFatalError("Security violation", e); + return; + } catch (RuntimeException | Error e) { + operationCtx += " failed while testing configuration: " + e.getMessage(); + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); + configResult.recordFatalError("Unexpected runtime error", e); + return; + } + + // === test CONNECTION === + + // delegate the main part of the test to the connector + connector.test(parentResult); + + parentResult.computeStatus(); + if (!parentResult.isAcceptable()) { + operationCtx += ". Connector test failed: " + parentResult.getMessage(); + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.DOWN, operationCtx, task, parentResult, true); + // No point in going on. Following tests will fail anyway, they will + // just produce misleading + // messages. + return; + } else { + operationCtx += ". Connector test successful."; + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.UP, operationCtx, task, parentResult, false); + } + + // === test CAPABILITIES === + + OperationResult capabilitiesResult = parentResult + .createSubresult(ConnectorTestOperation.CONNECTOR_CAPABILITIES.getOperation()); + try { + InternalMonitor.recordCount(InternalCounters.CONNECTOR_CAPABILITIES_FETCH_COUNT); + Collection retrievedCapabilities = connector.fetchCapabilities(capabilitiesResult); + + capabilityMap.put(connectorSpec.getConnectorName(), retrievedCapabilities); + capabilitiesResult.recordSuccess(); + } catch (CommunicationException e) { + operationCtx += " failed while testing capabilities: " + e.getMessage(); + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.DOWN, operationCtx, task, parentResult, true); + capabilitiesResult.recordFatalError("Communication error", e); + return; + } catch (GenericFrameworkException e) { + operationCtx += " failed while testing capabilities: " + e.getMessage(); + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); + capabilitiesResult.recordFatalError("Generic error", e); + return; + } catch (ConfigurationException e) { + operationCtx += " failed while testing capabilities: " + e.getMessage(); + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); + capabilitiesResult.recordFatalError("Configuration error", e); + return; + } catch (SchemaException e) { + operationCtx += " failed while testing capabilities: " + e.getMessage(); + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); + capabilitiesResult.recordFatalError("Schema error", e); + return; + } catch (RuntimeException | Error e) { + operationCtx += " failed while testing capabilities: " + e.getMessage(); + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); + capabilitiesResult.recordFatalError("Unexpected runtime error", e); + return; + } + + // Connector instance is fully configured at this point. + // But the connector cache entry may not be set up properly and it is not yet placed into the cache. + // Therefore make sure the caching bit is completed. + // Place the connector to cache even if it was configured at the beginning. The connector is reconfigured now. + connectorManager.cacheConfiguredConnector(connectorInstanceCacheEntry, connectorSpec); + } + + /** + * Modifies resource availability status in the repository (if needed). + * + * The necessity of status modification is determined against the current version of the resource - unless "skipGetResource" + * is set. The resource is hopefully cached ResourceCache, so the performance impact should be almost ponone. + * + * Also note that in-memory representation of the resource is not modified. As a side effect, the cached resource + * is invalidated because of the modification. But it will be loaded on the next occasion. This should be quite harmless, + * as we do not expect availability changes to occur frequently. + * + * + * @param operationCtx + * @param skipGetResource True if we want to skip "getResource" operation and therefore apply the change regardless of + * the current resource availability status. This is to be used in situations where we expect that + * the resource might not be successfully retrievable (e.g. if it's broken). + * + * @throws ObjectNotFoundException If the resource object does not exist in repository. + */ + public void modifyResourceAvailabilityStatus(String resourceOid, AvailabilityStatusType newStatus, String operationCtx, Task task, OperationResult result, boolean skipGetResource) throws ObjectNotFoundException { + + AvailabilityStatusType currentStatus; + String description; + if (skipGetResource) { + currentStatus = null; + description = "resource " + resourceOid; + } else { + PrismObject resource; + try { + resource = getResource(resourceOid, GetOperationOptions.createNoFetch(), task, result); + } catch (SchemaException | ExpressionEvaluationException | ConfigurationException | CommunicationException e) { + // We actually do not expect any of these exceptions here. The resource is most probably in use + throw new SystemException("Unexpected exception: " + e.getMessage(), e); + } + ResourceType resourceBean = resource.asObjectable(); + currentStatus = ResourceTypeUtil.getLastAvailabilityStatus(resourceBean); + description = resource.toString(); + } + + if (newStatus != currentStatus) { + //info becasue it's for diagnosing the issues with resource availability + LOGGER.info("Availability status changed from {} to {} for {} because {}", currentStatus, newStatus, description, operationCtx); + try { + List> modifications = singletonList(createResourceAvailabilityStatusDelta(newStatus)); + repositoryService.modifyObject(ResourceType.class, resourceOid, modifications, result); + InternalMonitor.recordCount(InternalCounters.RESOURCE_REPOSITORY_MODIFY_COUNT); + } catch (SchemaException | ObjectAlreadyExistsException e) { + throw new SystemException("Unexpected exception: " + e.getMessage(), e); + } + } + } + + private ContainerDelta createOperationalStateDelta(AvailabilityStatusType status, String message) { + OperationalStateType state = new OperationalStateType(prismContext); + state.setMessage(message); + state.setLastAvailabilityStatus(status); +// state.setNodeId(); +// state.setTimestamp(); + return null; + } + + private ItemDelta createResourceAvailabilityStatusDelta(AvailabilityStatusType status) throws SchemaException { + return prismContext.deltaFor(ResourceType.class) + .item(SchemaConstants.PATH_OPERATIONAL_STATE_LAST_AVAILABILITY_STATUS).replace(status) + .asItemDelta(); + } + + /** + * Adjust scheme with respect to capabilities. E.g. disable attributes that + * are used for special purpose (such as account activation simulation). + * + * TODO treat also objectclass-specific capabilities here + */ + private void adjustSchemaForSimulatedCapabilities(PrismObject resource, ResourceSchema resourceSchema) { + ResourceType resourceType = resource.asObjectable(); + if (resourceType.getCapabilities() == null || resourceType.getCapabilities().getConfigured() == null) { + return; + } + ActivationCapabilityType activationCapability = CapabilityUtil.getCapability(resourceType + .getCapabilities().getConfigured().getAny(), ActivationCapabilityType.class); + if (CapabilityUtil.getEffectiveActivationStatus(activationCapability) != null) { + QName attributeName = activationCapability.getStatus().getAttribute(); + Boolean ignore = activationCapability.getStatus().isIgnoreAttribute(); + if (attributeName != null) { + // The attribute used for enable/disable simulation should be ignored in the schema + // otherwise strange things may happen, such as changing the same attribute both from + // activation/enable and from the attribute using its native name. + for (ObjectClassComplexTypeDefinition objectClassDefinition : resourceSchema + .getDefinitions(ObjectClassComplexTypeDefinition.class)) { + ResourceAttributeDefinition attributeDefinition = objectClassDefinition + .findAttributeDefinition(attributeName); + if (attributeDefinition != null) { + if (ignore == null || ignore.booleanValue()) { + ((MutableItemDefinition) attributeDefinition).setProcessing(ItemProcessing.IGNORE); + } + } else { + // simulated activation attribute points to something that is not in the schema + // technically, this is an error. But it looks to be quite common in connectors. + // The enable/disable is using operational attributes that are not exposed in the + // schema, but they work if passed to the connector. + // Therefore we don't want to break anything. We could log an warning here, but the + // warning would be quite frequent. Maybe a better place to warn user would be import + // of the object. + LOGGER.debug("Simulated activation attribute " + + attributeName + + " for objectclass " + + objectClassDefinition.getTypeName() + + " in " + + resource + + " does not exist in the resource schema. This may work well, but it is not clean. Connector exposing such schema should be fixed."); + } + } + } + } + } + + private void checkSchema(PrismSchema schema) throws SchemaException { + // This is resource schema, it should contain only + // ResourceObjectDefinitions + for (Definition def : schema.getDefinitions()) { + if (def instanceof ComplexTypeDefinition) { + // This is OK + } else if (def instanceof ResourceAttributeContainerDefinition) { + checkResourceObjectDefinition((ResourceAttributeContainerDefinition) def); + } else { + throw new SchemaException("Unexpected definition in resource schema: " + def); + } + } + } + + private void checkResourceObjectDefinition(ResourceAttributeContainerDefinition rod) + throws SchemaException { + for (ItemDefinition def : rod.getDefinitions()) { + if (!(def instanceof ResourceAttributeDefinition)) { + throw new SchemaException("Unexpected definition in resource schema object " + rod + ": " + + def); + } + } + } + + public void applyDefinition(ObjectDelta delta, ResourceType resourceWhenNoOid, GetOperationOptions options, Task task, OperationResult objectResult) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + + if (delta.isAdd()) { + PrismObject resource = delta.getObjectToAdd(); + applyConnectorSchemasToResource(resource, task, objectResult); + return; + + } else if (delta.isModify()) { + // Go on + } else { + return; + } + + if (delta.hasCompleteDefinition()){ + //nothing to do, all modifications has definitions..just aplly this deltas.. + return; + } + + + PrismObject resource; + String resourceOid = delta.getOid(); + if (resourceOid == null) { + Validate.notNull(resourceWhenNoOid, "Resource oid not specified in the object delta, and resource is not specified as well. Could not apply definition."); + resource = resourceWhenNoOid.asPrismObject(); + } else { + resource = getResource(resourceOid, options, task, objectResult); + } + + ResourceType resourceType = resource.asObjectable(); +// ResourceType resourceType = completeResource(resource.asObjectable(), null, objectResult); + //TODO TODO TODO FIXME FIXME FIXME copied from ObjectImprted..union this two cases + PrismContainer configurationContainer = ResourceTypeUtil.getConfigurationContainer(resourceType); + if (configurationContainer == null || configurationContainer.isEmpty()) { + // Nothing to check + objectResult.recordWarning("The resource has no configuration"); + return; + } + + // Check the resource configuration. The schema is in connector, so fetch the connector first + String connectorOid = resourceType.getConnectorRef().getOid(); + if (StringUtils.isBlank(connectorOid)) { + objectResult.recordFatalError("The connector reference (connectorRef) is null or empty"); + return; + } + + //ItemDelta.findItemDelta(delta.getModifications(), ResourceType.F_SCHEMA, ContainerDelta.class) == null || + + ReferenceDelta connectorRefDelta = ItemDeltaCollectionsUtil.findReferenceModification(delta.getModifications(), ResourceType.F_CONNECTOR_REF); + if (connectorRefDelta != null){ + Item connectorRefNew = connectorRefDelta.getItemNewMatchingPath(null); + if (connectorRefNew.getValues().size() == 1){ + PrismReferenceValue connectorRefValue = connectorRefNew.getValues().iterator().next(); + if (connectorRefValue.getOid() != null && !connectorOid.equals(connectorRefValue.getOid())){ + connectorOid = connectorRefValue.getOid(); + } + } + } + + PrismObject connector = null; + ConnectorType connectorType = null; + try { + connector = repositoryService.getObject(ConnectorType.class, connectorOid, null, objectResult); + connectorType = connector.asObjectable(); + } catch (ObjectNotFoundException e) { + // No connector, no fun. We can't check the schema. But this is referential integrity problem. + // Mark the error ... there is nothing more to do + objectResult.recordFatalError("Connector (OID:" + connectorOid + ") referenced from the resource is not in the repository", e); + return; + } catch (SchemaException e) { + // Probably a malformed connector. To be kind of robust, lets allow the import. + // Mark the error ... there is nothing more to do + objectResult.recordPartialError("Connector (OID:" + connectorOid + ") referenced from the resource has schema problems: " + e.getMessage(), e); + LOGGER.error("Connector (OID:{}) referenced from the imported resource \"{}\" has schema problems: {}-{}", + new Object[]{connectorOid, resourceType.getName(), e.getMessage(), e}); + return; + } + + Element connectorSchemaElement = ConnectorTypeUtil.getConnectorXsdSchema(connector); + MutablePrismSchema connectorSchema; + if (connectorSchemaElement == null) { + // No schema to validate with + return; + } + try { + connectorSchema = prismContext.schemaFactory().createPrismSchema(DOMUtil.getSchemaTargetNamespace(connectorSchemaElement)); + connectorSchema.parseThis(connectorSchemaElement, true, "schema for " + connector, prismContext); + } catch (SchemaException e) { + objectResult.recordFatalError("Error parsing connector schema for " + connector + ": "+e.getMessage(), e); + return; + } + QName configContainerQName = new QName(connectorType.getNamespace(), ResourceType.F_CONNECTOR_CONFIGURATION.getLocalPart()); + PrismContainerDefinition configContainerDef = + connectorSchema.findContainerDefinitionByElementName(configContainerQName); + if (configContainerDef == null) { + objectResult.recordFatalError("Definition of configuration container " + configContainerQName + " not found in the schema of of " + connector); + return; + } + + try { + configurationContainer.applyDefinition(configContainerDef); + } catch (SchemaException e) { + objectResult.recordFatalError("Configuration error in " + resource + ": "+e.getMessage(), e); + return; + } + + PrismContainer configContainer = resourceType.asPrismObject().findContainer(ResourceType.F_CONNECTOR_CONFIGURATION); + configContainer.applyDefinition(configContainerDef); + + for (ItemDelta itemDelta : delta.getModifications()){ + applyItemDefinition(itemDelta, configContainerDef, objectResult); + } + } + + private void applyItemDefinition(ItemDelta itemDelta, + PrismContainerDefinition configContainerDef, OperationResult objectResult) throws SchemaException { + if (itemDelta.getParentPath() == null){ + LOGGER.trace("No parent path defined for item delta {}", itemDelta); + return; + } + + QName first = itemDelta.getParentPath().firstToNameOrNull(); + if (first == null) { + return; + } + + if (itemDelta.getDefinition() == null && (ResourceType.F_CONNECTOR_CONFIGURATION.equals(first) || ResourceType.F_SCHEMA.equals(first))){ + ItemPath path = itemDelta.getPath().rest(); + D itemDef = configContainerDef.findItemDefinition(path); + if (itemDef == null){ + LOGGER.warn("No definition found for item {}. Check your namespaces?", path); + objectResult.recordWarning("No definition found for item delta: " + itemDelta +". Check your namespaces?" ); +// throw new SchemaException("No definition found for item " + path+ ". Check your namespaces?" ); + return; + } + itemDelta.applyDefinition(itemDef); + + } + } + + public void applyDefinition(PrismObject resource, Task task, OperationResult parentResult) + throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, + ExpressionEvaluationException { + applyConnectorSchemasToResource(resource, task, parentResult); + } + + public void applyDefinition(ObjectQuery query, OperationResult result) { + // TODO: not implemented yet + } + + public Object executeScript(String resourceOid, ProvisioningScriptType script, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + PrismObject resource = getResource(resourceOid, null, task, result); + ConnectorSpec connectorSpec = selectConnectorSpec(resource, ScriptCapabilityType.class); + if (connectorSpec == null) { + throw new UnsupportedOperationException("No connector supports script capability"); + } + ConnectorInstance connectorInstance = connectorManager.getConfiguredConnectorInstance(connectorSpec, false, result); + ExecuteProvisioningScriptOperation scriptOperation = ProvisioningUtil.convertToScriptOperation(script, "script on "+resource, prismContext); + try { + StateReporter reporter = new StateReporter(resourceOid, task); + return connectorInstance.executeScript(scriptOperation, reporter, result); + } catch (GenericFrameworkException e) { + // Not expected. Transform to system exception + result.recordFatalError("Generic provisioning framework error", e); + throw new SystemException("Generic provisioning framework error: " + e.getMessage(), e); + } + } + + public List getConnectorOperationalStatus(PrismObject resource, OperationResult result) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException { + List statuses = new ArrayList<>(); + for (ConnectorSpec connectorSpec: getAllConnectorSpecs(resource)) { + ConnectorInstance connectorInstance = connectorManager.getConfiguredConnectorInstance(connectorSpec, false, result); + ConnectorOperationalStatus operationalStatus = connectorInstance.getOperationalStatus(); + if (operationalStatus != null) { + operationalStatus.setConnectorName(connectorSpec.getConnectorName()); + statuses.add(operationalStatus); + } + } + return statuses; + } + + private List getAllConnectorSpecs(PrismObject resource) throws SchemaException { + List connectorSpecs = new ArrayList<>(); + connectorSpecs.add(getDefaultConnectorSpec(resource)); + for (ConnectorInstanceSpecificationType additionalConnectorType: resource.asObjectable().getAdditionalConnector()) { + connectorSpecs.add(getConnectorSpec(resource, additionalConnectorType)); + } + return connectorSpecs; + } + + // Should be used only internally (private). But it is public, because it is accessed from the tests. + public ConnectorInstance getConfiguredConnectorInstance(PrismObject resource, + Class operationCapabilityClass, boolean forceFresh, OperationResult parentResult) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException { + ConnectorSpec connectorSpec = selectConnectorSpec(resource, operationCapabilityClass); + if (connectorSpec == null) { + return null; + } + return connectorManager.getConfiguredConnectorInstance(connectorSpec, forceFresh, parentResult); + } + + // Used by the tests. Does not change anything. + ConnectorInstance getConfiguredConnectorInstanceFromCache(PrismObject resource, + Class operationCapabilityClass) throws SchemaException { + ConnectorSpec connectorSpec = selectConnectorSpec(resource, operationCapabilityClass); + return connectorSpec != null ? connectorManager.getConfiguredConnectorInstanceFromCache(connectorSpec) : null; + } + + public CapabilitiesType getConnectorCapabilities(ResourceType resource, + RefinedObjectClassDefinition objectClassDefinition, Class operationCapabilityClass) { + if (resource == null) { + return null; + } + + CapabilitiesType connectorCapabilities = null; + for (ConnectorInstanceSpecificationType additionalConnectorType : resource.getAdditionalConnector()) { + if (supportsCapability(additionalConnectorType, operationCapabilityClass)) { + connectorCapabilities = additionalConnectorType.getCapabilities(); + } + } + + if (connectorCapabilities == null) { + connectorCapabilities = resource.getCapabilities(); + } + + + CapabilitiesType finalCapabilities = applyObjectClassCapabilities(connectorCapabilities, objectClassDefinition); + LOGGER.trace("Returning final capabilities:\n{} ", finalCapabilities); + return finalCapabilities; + + } + + private CapabilitiesType applyObjectClassCapabilities(CapabilitiesType connectorCapabilities, RefinedObjectClassDefinition objectClassDefinition) { + + if (objectClassDefinition == null) { + return connectorCapabilities; + } + + CapabilitiesType objectClassCapabilities = objectClassDefinition.getCapabilities(); + if (objectClassCapabilities == null) { + LOGGER.trace("No capabilities for {} specified, skipping merge.", objectClassDefinition); + return connectorCapabilities; + } + + CapabilityCollectionType configured = objectClassCapabilities.getConfigured(); + if (configured == null) { + LOGGER.trace("Empty capabilities in {} specified, skipping merge", objectClassDefinition); + return connectorCapabilities; + } + + CapabilitiesType finalCapabilities = new CapabilitiesType(); + if (connectorCapabilities.getNative() != null) { + finalCapabilities.setNative(connectorCapabilities.getNative()); + } + + if (!hasConfiguredCapabilities(connectorCapabilities)) { + LOGGER.trace("No configured capabilities found for connector, replacing with capabilities defined for {}", objectClassDefinition); + finalCapabilities.setConfigured(configured); + return finalCapabilities; + } + + for (Object capability : connectorCapabilities.getConfigured().getAny()) { + + if (!CapabilityUtil.containsCapabilityWithSameElementName(configured.getAny(), capability)) { + configured.getAny().add(capability); + } + } + + finalCapabilities.setConfigured(configured); + return finalCapabilities; + } + + private boolean hasConfiguredCapabilities(CapabilitiesType supportedCapabilities) { + if (supportedCapabilities.getConfigured() == null) { + return false; + } + + if (supportedCapabilities.getConfigured().getAny().isEmpty()) { + return false; + + } + return true; + } + + private ConnectorSpec selectConnectorSpec(PrismObject resource, Map> capabilityMap, Class capabilityClass) throws SchemaException { + if (capabilityMap == null) { + return selectConnectorSpec(resource, capabilityClass); + } + for (ConnectorInstanceSpecificationType additionalConnectorType: resource.asObjectable().getAdditionalConnector()) { + if (supportsCapability(additionalConnectorType, capabilityMap.get(additionalConnectorType.getName()), capabilityClass)) { + return getConnectorSpec(resource, additionalConnectorType); + } + } + return getDefaultConnectorSpec(resource); + } + + private ConnectorSpec selectConnectorSpec(PrismObject resource, Class operationCapabilityClass) throws SchemaException { + for (ConnectorInstanceSpecificationType additionalConnectorType: resource.asObjectable().getAdditionalConnector()) { + if (supportsCapability(additionalConnectorType, operationCapabilityClass)) { + return getConnectorSpec(resource, additionalConnectorType); + } + } + return getDefaultConnectorSpec(resource); + } + + private boolean supportsCapability(ConnectorInstanceSpecificationType additionalConnectorType, Class capabilityClass) { + T cap = CapabilityUtil.getEffectiveCapability(additionalConnectorType.getCapabilities(), capabilityClass); + if (cap == null) { + return false; + } + return CapabilityUtil.isCapabilityEnabled(cap); + } + + private boolean supportsCapability(ConnectorInstanceSpecificationType additionalConnectorType, Collection nativeCapabilities, Class capabilityClass) { + CapabilitiesType specifiedCapabilitiesType = additionalConnectorType.getCapabilities(); + if (specifiedCapabilitiesType != null) { + CapabilityCollectionType configuredCapCollectionType = specifiedCapabilitiesType.getConfigured(); + if (configuredCapCollectionType != null) { + T configuredCap = CapabilityUtil.getCapability(configuredCapCollectionType.getAny(), capabilityClass); + if (configuredCap != null && !CapabilityUtil.isCapabilityEnabled(configuredCap)) { + return false; + } + } + + } + T cap = CapabilityUtil.getCapability(nativeCapabilities, capabilityClass); + if (cap == null) { + return false; + } + return CapabilityUtil.isCapabilityEnabled(cap); + } + + private ConnectorSpec getDefaultConnectorSpec(PrismObject resource) { + PrismContainer connectorConfiguration = resource.findContainer(ResourceType.F_CONNECTOR_CONFIGURATION); + return new ConnectorSpec(resource, null, ResourceTypeUtil.getConnectorOid(resource), connectorConfiguration); + } + + private ConnectorSpec getConnectorSpec(PrismObject resource, ConnectorInstanceSpecificationType additionalConnectorType) throws SchemaException { + if (additionalConnectorType.getConnectorRef() == null) { + throw new SchemaException("No connector reference in additional connector in "+resource); + } + String connectorOid = additionalConnectorType.getConnectorRef().getOid(); + if (StringUtils.isBlank(connectorOid)) { + throw new SchemaException("No connector OID in additional connector in "+resource); + } + PrismContainer connectorConfiguration = additionalConnectorType.asPrismContainerValue().findContainer(ConnectorInstanceSpecificationType.F_CONNECTOR_CONFIGURATION); + String connectorName = additionalConnectorType.getName(); + if (StringUtils.isBlank(connectorName)) { + throw new SchemaException("No connector name in additional connector in "+resource); + } + return new ConnectorSpec(resource, connectorName, connectorOid, connectorConfiguration); + } + + public PrismContext getPrismContext() { + return prismContext; + } +} From 45292aff01ea114d6bfa4503ae71aa2d551e206d Mon Sep 17 00:00:00 2001 From: Hiroyuki Wada Date: Tue, 18 Feb 2020 19:42:34 +0900 Subject: [PATCH 02/97] MID-6054 Fix assignment with custom relation --- .../scripting/actions/AssignExecutor.java | 16 +++++--- .../intest/scripting/TestScriptingBasic.java | 39 +++++++++++++++++++ .../resources/scripting/assign-to-will-2.xml | 31 +++++++++++++++ 3 files changed, 81 insertions(+), 5 deletions(-) create mode 100644 model/model-intest/src/test/resources/scripting/assign-to-will-2.xml diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/scripting/actions/AssignExecutor.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/scripting/actions/AssignExecutor.java index 460900c36e7..a044c27c272 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/scripting/actions/AssignExecutor.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/scripting/actions/AssignExecutor.java @@ -9,6 +9,7 @@ import com.evolveum.midpoint.model.api.ScriptExecutionException; import com.evolveum.midpoint.prism.delta.ObjectDelta; +import com.evolveum.midpoint.schema.RelationRegistry; import com.evolveum.midpoint.schema.constants.RelationTypes; import com.evolveum.midpoint.util.QNameUtil; import com.evolveum.midpoint.util.exception.SchemaException; @@ -16,6 +17,7 @@ import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.ArrayList; @@ -34,6 +36,9 @@ public class AssignExecutor extends AssignmentOperationsExecutor { private static final Trace LOGGER = TraceManager.getTrace(AssignExecutor.class); + @Autowired + protected RelationRegistry relationRegistry; + // private static final String NAME = "assign"; // private static final String PARAM_RESOURCE = "resource"; // private static final String PARAM_ROLE = "role"; @@ -139,20 +144,21 @@ protected ObjectDelta createDelta(AssignmentHolderType obj List assignments = new ArrayList<>(); if (roles != null) { + List relationDefinitions = relationRegistry.getRelationDefinitions(); for (ObjectReferenceType roleRef : roles) { AssignmentType assignmentType = new AssignmentType(); - RelationTypes foundRelation = null; - for (RelationTypes relationType : RelationTypes.values()) { + RelationDefinitionType foundRelation = null; + for (RelationDefinitionType relationDefinitionType : relationDefinitions) { if (prismContext.relationMatches(QNameUtil.uriToQName(relation, true), - relationType.getRelation())) { - foundRelation = relationType; + relationDefinitionType.getRef())) { + foundRelation = relationDefinitionType; break; } } if(foundRelation == null) { throw new IllegalArgumentException("Relation " + relation + " not found"); } - roleRef.setRelation(foundRelation.getRelation()); + roleRef.setRelation(foundRelation.getRef()); assignmentType.setTargetRef(roleRef); assignments.add(assignmentType); } diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/scripting/TestScriptingBasic.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/scripting/TestScriptingBasic.java index 7e785206523..d8a71676fe5 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/scripting/TestScriptingBasic.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/scripting/TestScriptingBasic.java @@ -17,6 +17,7 @@ import com.evolveum.midpoint.notifications.api.transports.Message; import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.crypto.EncryptionException; +import com.evolveum.midpoint.prism.delta.ContainerDelta; import com.evolveum.midpoint.prism.delta.ItemDelta; import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.path.ItemName; @@ -95,6 +96,7 @@ public class TestScriptingBasic extends AbstractInitializedModelIntegrationTest private static final File UNASSIGN_FROM_WILL_2_FILE = new File(TEST_DIR, "unassign-from-will-2.xml"); private static final File UNASSIGN_FROM_WILL_3_FILE = new File(TEST_DIR, "unassign-from-will-3.xml"); private static final File ASSIGN_TO_WILL_FILE = new File(TEST_DIR, "assign-to-will.xml"); + private static final File ASSIGN_TO_WILL_2_FILE = new File(TEST_DIR, "assign-to-will-2.xml"); private static final File PURGE_DUMMY_BLACK_SCHEMA_FILE = new File(TEST_DIR, "purge-dummy-black-schema.xml"); private static final File TEST_DUMMY_RESOURCE_FILE = new File(TEST_DIR, "test-dummy-resource.xml"); private static final File NOTIFICATION_ABOUT_JACK_FILE = new File(TEST_DIR, "notification-about-jack.xml"); @@ -716,6 +718,43 @@ public void test393UnassignFromWill3() throws Exception { MidPointAsserts.assertNotAssignedResource(will, "10000000-0000-0000-0000-000000000004"); } + @Test + public void test394AssignToWill2() throws Exception { + final String TEST_NAME = "test394AssignToWill2"; + TestUtil.displayTestTitle(this, TEST_NAME); + + // GIVEN + QName customRelation = new QName("http://midpoint.evolveum.com/xml/ns/samples/piracy", "piracy:captain"); + + Task task = createTask(DOT_CLASS + TEST_NAME); + OperationResult result = task.getResult(); + PrismProperty expression = parseAnyData(ASSIGN_TO_WILL_2_FILE); + + PrismObject systemConfig = repositoryService.getObject(SystemConfigurationType.class, + SystemObjectsType.SYSTEM_CONFIGURATION.value(), null, result); + RoleManagementConfigurationType roleManagement = systemConfig.asObjectable().getRoleManagement(); + PrismContainerValue oldValue = systemConfig.asObjectable().getRoleManagement().asPrismContainerValue(); + roleManagement.beginRelations().beginRelation().setRef(customRelation); + Collection modifications = new ArrayList<>(); + ContainerDelta deleteDelta = prismContext.deltaFactory().container().createModificationReplace(SystemConfigurationType.F_ROLE_MANAGEMENT, + SystemConfigurationType.class, oldValue.clone()); + ((Collection)modifications).add(deleteDelta); + modifySystemObjectInRepo(SystemConfigurationType.class, + SystemObjectsType.SYSTEM_CONFIGURATION.value(), modifications, result); + + // WHEN + ExecutionContext output = scriptingExpressionEvaluator.evaluateExpression(expression.getAnyValue().getValue(), task, result); + + // THEN + dumpOutput(output, result); + assertOutputData(output, 1, OperationResultStatus.SUCCESS); + result.computeStatus(); + TestUtil.assertSuccess(result); + PrismObject will = getUser(USER_WILL_OID); + display("will after assignments creation", will); + MidPointAsserts.assertAssigned(will, "12345678-d34d-b33f-f00d-555555556666", RoleType.COMPLEX_TYPE, customRelation); + } + @Test public void test400PurgeSchema() throws Exception { final String TEST_NAME = "test400PurgeSchema"; diff --git a/model/model-intest/src/test/resources/scripting/assign-to-will-2.xml b/model/model-intest/src/test/resources/scripting/assign-to-will-2.xml new file mode 100644 index 00000000000..dfe5ec7da92 --- /dev/null +++ b/model/model-intest/src/test/resources/scripting/assign-to-will-2.xml @@ -0,0 +1,31 @@ + + + + + c:UserType + + + c:name + willTurner + + + + assign + + role + 12345678-d34d-b33f-f00d-555555556666 + + + relation + piracy:captain + + + From 940c62e6abb4c74b384346119de756569fdd8706 Mon Sep 17 00:00:00 2001 From: Radovan Semancik Date: Mon, 24 Feb 2020 16:47:59 +0100 Subject: [PATCH 03/97] Refactor propertyConstraints -> itemConstraints --- .../gui/api/util/WebComponentUtil.java | 8490 ++++++++--------- .../ObjectPolicyConfigurationEditor.java | 663 +- .../component/ObjectPolicyPanel.java | 952 +- .../dto/ObjectPolicyDialogDto.java | 457 +- .../xml/ns/public/common/common-core-3.xsd | 21 +- .../model/common/ArchetypeManager.java | 8 +- .../model/impl/lens/ChangeExecutor.java | 3801 ++++---- .../midpoint/model/impl/lens/LensUtil.java | 2323 ++--- 8 files changed, 8375 insertions(+), 8340 deletions(-) diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/util/WebComponentUtil.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/util/WebComponentUtil.java index 1038fa0a758..162199a95df 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/util/WebComponentUtil.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/util/WebComponentUtil.java @@ -1,4245 +1,4245 @@ -/* - * Copyright (c) 2010-2019 Evolveum and contributors - * - * This work is dual-licensed under the Apache License 2.0 - * and European Union Public License. See LICENSE file for details. - */ -package com.evolveum.midpoint.gui.api.util; - -import com.evolveum.midpoint.common.LocalizationService; -import com.evolveum.midpoint.common.refinery.*; -import com.evolveum.midpoint.gui.api.GuiStyleConstants; -import com.evolveum.midpoint.gui.api.SubscriptionType; -import com.evolveum.midpoint.gui.api.component.BasePanel; -import com.evolveum.midpoint.gui.api.component.MainObjectListPanel; -import com.evolveum.midpoint.gui.api.model.LoadableModel; -import com.evolveum.midpoint.gui.api.model.NonEmptyModel; -import com.evolveum.midpoint.gui.api.model.ReadOnlyValueModel; -import com.evolveum.midpoint.gui.api.page.PageBase; -import com.evolveum.midpoint.gui.api.prism.ItemWrapper; -import com.evolveum.midpoint.gui.api.prism.PrismContainerWrapper; -import com.evolveum.midpoint.gui.impl.component.icon.CompositedIcon; -import com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder; -import com.evolveum.midpoint.gui.impl.component.icon.IconCssStyle; -import com.evolveum.midpoint.gui.impl.factory.WrapperContext; -import com.evolveum.midpoint.gui.impl.prism.PrismContainerValueWrapper; -import com.evolveum.midpoint.gui.impl.prism.PrismPropertyValueWrapper; -import com.evolveum.midpoint.gui.impl.prism.PrismPropertyWrapper; -import com.evolveum.midpoint.model.api.*; -import com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView; -import com.evolveum.midpoint.model.api.authentication.CompiledGuiProfile; -import com.evolveum.midpoint.model.api.util.ResourceUtils; -import com.evolveum.midpoint.model.api.visualizer.Scene; -import com.evolveum.midpoint.prism.*; -import com.evolveum.midpoint.prism.crypto.EncryptionException; -import com.evolveum.midpoint.prism.crypto.Protector; -import com.evolveum.midpoint.prism.delta.ChangeType; -import com.evolveum.midpoint.prism.delta.ObjectDelta; -import com.evolveum.midpoint.prism.delta.PropertyDelta; -import com.evolveum.midpoint.prism.path.ItemName; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.prism.path.ItemPathCollectionsUtil; -import com.evolveum.midpoint.prism.polystring.PolyString; -import com.evolveum.midpoint.prism.query.*; -import com.evolveum.midpoint.prism.query.builder.S_FilterEntryOrEmpty; -import com.evolveum.midpoint.prism.util.PolyStringUtils; -import com.evolveum.midpoint.prism.xml.XmlTypeConverter; -import com.evolveum.midpoint.schema.*; -import com.evolveum.midpoint.schema.constants.ObjectTypes; -import com.evolveum.midpoint.schema.constants.RelationTypes; -import com.evolveum.midpoint.schema.constants.SchemaConstants; -import com.evolveum.midpoint.schema.processor.ResourceSchema; -import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.schema.result.OperationResultStatus; -import com.evolveum.midpoint.schema.util.*; -import com.evolveum.midpoint.security.api.AuthorizationConstants; -import com.evolveum.midpoint.security.api.MidPointPrincipal; -import com.evolveum.midpoint.security.enforcer.api.AuthorizationParameters; -import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.task.api.TaskBinding; -import com.evolveum.midpoint.task.api.TaskCategory; -import com.evolveum.midpoint.task.api.TaskExecutionStatus; -import com.evolveum.midpoint.util.*; -import com.evolveum.midpoint.util.exception.*; -import com.evolveum.midpoint.util.logging.LoggingUtils; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.web.component.DateLabelComponent; -import com.evolveum.midpoint.web.component.TabbedPanel; -import com.evolveum.midpoint.web.component.breadcrumbs.Breadcrumb; -import com.evolveum.midpoint.web.component.breadcrumbs.BreadcrumbPageClass; -import com.evolveum.midpoint.web.component.breadcrumbs.BreadcrumbPageInstance; -import com.evolveum.midpoint.web.component.data.BaseSortableDataProvider; -import com.evolveum.midpoint.web.component.data.SelectableBeanObjectDataProvider; -import com.evolveum.midpoint.web.component.data.Table; -import com.evolveum.midpoint.web.component.data.column.ColumnMenuAction; -import com.evolveum.midpoint.web.component.data.column.ColumnUtils; -import com.evolveum.midpoint.web.component.input.DisplayableValueChoiceRenderer; -import com.evolveum.midpoint.web.component.input.DropDownChoicePanel; -import com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem; -import com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction; -import com.evolveum.midpoint.web.component.prism.*; -import com.evolveum.midpoint.web.component.prism.show.SceneDto; -import com.evolveum.midpoint.web.component.prism.show.SceneUtil; -import com.evolveum.midpoint.web.component.util.Selectable; -import com.evolveum.midpoint.web.component.util.SelectableBeanImpl; -import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour; -import com.evolveum.midpoint.web.page.PageDialog; -import com.evolveum.midpoint.web.page.admin.archetype.PageArchetype; -import com.evolveum.midpoint.web.page.admin.cases.PageCase; -import com.evolveum.midpoint.web.page.admin.reports.PageReport; -import com.evolveum.midpoint.web.page.admin.resources.PageResource; -import com.evolveum.midpoint.web.page.admin.resources.PageResourceWizard; -import com.evolveum.midpoint.web.page.admin.resources.PageResources; -import com.evolveum.midpoint.web.page.admin.resources.content.PageAccount; -import com.evolveum.midpoint.web.page.admin.roles.PageRole; -import com.evolveum.midpoint.web.page.admin.roles.PageRoles; -import com.evolveum.midpoint.web.page.admin.server.PageTasks; -import com.evolveum.midpoint.web.page.admin.server.PageTask; -import com.evolveum.midpoint.web.page.admin.server.dto.OperationResultStatusPresentationProperties; -import com.evolveum.midpoint.web.page.admin.services.PageService; -import com.evolveum.midpoint.web.page.admin.services.PageServices; -import com.evolveum.midpoint.web.page.admin.users.PageOrgUnit; -import com.evolveum.midpoint.web.page.admin.users.PageUser; -import com.evolveum.midpoint.web.page.admin.users.PageUsers; -import com.evolveum.midpoint.web.page.admin.valuePolicy.PageValuePolicy; -import com.evolveum.midpoint.web.page.admin.workflow.dto.EvaluatedTriggerGroupDto; -import com.evolveum.midpoint.web.security.MidPointApplication; -import com.evolveum.midpoint.web.security.util.SecurityUtils; -import com.evolveum.midpoint.web.session.SessionStorage; -import com.evolveum.midpoint.web.session.UserProfileStorage.TableId; -import com.evolveum.midpoint.web.util.DateValidator; -import com.evolveum.midpoint.web.util.InfoTooltipBehavior; -import com.evolveum.midpoint.web.util.ObjectTypeGuiDescriptor; -import com.evolveum.midpoint.web.util.OnePageParameterEncoder; -import com.evolveum.midpoint.wf.util.ApprovalUtils; -import com.evolveum.midpoint.wf.util.ChangesByState; -import com.evolveum.midpoint.xml.ns._public.common.common_3.*; -import com.evolveum.midpoint.xml.ns._public.model.scripting_3.ExecuteScriptType; -import com.evolveum.prism.xml.ns._public.query_3.QueryType; -import com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType; -import com.evolveum.prism.xml.ns._public.types_3.PolyStringTranslationType; -import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; -import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.Validate; -import org.apache.commons.lang.math.NumberUtils; -import org.apache.commons.lang.time.DurationFormatUtils; -import org.apache.commons.lang3.StringEscapeUtils; -import org.apache.commons.validator.routines.checkdigit.VerhoeffCheckDigit; -import org.apache.wicket.*; -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior; -import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink; -import org.apache.wicket.authroles.authentication.AuthenticatedWebApplication; -import org.apache.wicket.authroles.authorization.strategies.role.Roles; -import org.apache.wicket.behavior.Behavior; -import org.apache.wicket.core.request.handler.RenderPageRequestHandler; -import org.apache.wicket.datetime.PatternDateConverter; -import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable; -import org.apache.wicket.extensions.markup.html.repeater.util.SortParam; -import org.apache.wicket.extensions.markup.html.tabs.ITab; -import org.apache.wicket.feedback.IFeedback; -import org.apache.wicket.markup.html.WebMarkupContainer; -import org.apache.wicket.markup.html.basic.Label; -import org.apache.wicket.markup.html.form.DropDownChoice; -import org.apache.wicket.markup.html.form.Form; -import org.apache.wicket.markup.html.form.FormComponent; -import org.apache.wicket.markup.html.form.IChoiceRenderer; -import org.apache.wicket.markup.repeater.data.IDataProvider; -import org.apache.wicket.model.IModel; -import org.apache.wicket.model.Model; -import org.apache.wicket.model.StringResourceModel; -import org.apache.wicket.request.IRequestHandler; -import org.apache.wicket.request.cycle.RequestCycle; -import org.apache.wicket.request.mapper.parameter.PageParameters; -import org.apache.wicket.util.string.StringValue; -import org.apache.wicket.util.visit.IVisit; -import org.apache.wicket.util.visit.IVisitor; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.joda.time.format.DateTimeFormat; - -import javax.xml.datatype.XMLGregorianCalendar; -import javax.xml.namespace.QName; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.net.URI; -import java.text.SimpleDateFormat; -import java.util.*; -import java.util.function.Predicate; -import java.util.function.Supplier; -import java.util.stream.Collectors; -import java.util.stream.StreamSupport; - -import static com.evolveum.midpoint.gui.api.page.PageBase.createStringResourceStatic; - -/** - * Utility class containing miscellaneous methods used mostly in Wicket - * components. - * - * @author lazyman - */ -public final class WebComponentUtil { - - private static final Trace LOGGER = TraceManager.getTrace(WebComponentUtil.class); - - private static final String KEY_BOOLEAN_NULL = "Boolean.NULL"; - private static final String KEY_BOOLEAN_TRUE = "Boolean.TRUE"; - private static final String KEY_BOOLEAN_FALSE = "Boolean.FALSE"; - - /** - * To be used only for tests when there's no MidpointApplication. - * (Quite a hack. Replace eventually by a more serious solution.) - */ - private static RelationRegistry staticallyProvidedRelationRegistry; - - private static Map, Class> objectDetailsPageMap; - private static Map, Class> createNewObjectPageMap; - - static { - objectDetailsPageMap = new HashMap<>(); - objectDetailsPageMap.put(UserType.class, PageUser.class); - objectDetailsPageMap.put(OrgType.class, PageOrgUnit.class); - objectDetailsPageMap.put(RoleType.class, PageRole.class); - objectDetailsPageMap.put(ServiceType.class, PageService.class); - objectDetailsPageMap.put(ResourceType.class, PageResource.class); - objectDetailsPageMap.put(TaskType.class, PageTask.class); - objectDetailsPageMap.put(ReportType.class, PageReport.class); - objectDetailsPageMap.put(ValuePolicyType.class, PageValuePolicy.class); - objectDetailsPageMap.put(CaseType.class, PageCase.class); - objectDetailsPageMap.put(ArchetypeType.class, PageArchetype.class); - objectDetailsPageMap.put(ShadowType.class, PageAccount.class); - } - - static{ - createNewObjectPageMap = new HashMap<>(); - createNewObjectPageMap.put(ResourceType.class, PageResourceWizard.class); - } - - // only pages that support 'advanced search' are currently listed here (TODO: generalize) - private static Map, Class> objectListPageMap; - - static { - objectListPageMap = new HashMap<>(); - objectListPageMap.put(UserType.class, PageUsers.class); - objectListPageMap.put(RoleType.class, PageRoles.class); - objectListPageMap.put(ServiceType.class, PageServices.class); - objectListPageMap.put(ResourceType.class, PageResources.class); - objectListPageMap.put(TaskType.class, PageTasks.class); - } - - private static Map storageTableIdMap; - - static { - storageTableIdMap = new HashMap<>(); - storageTableIdMap.put(TableId.PAGE_RESOURCE_ACCOUNTS_PANEL_REPOSITORY_MODE, SessionStorage.KEY_RESOURCE_ACCOUNT_CONTENT + SessionStorage.KEY_RESOURCE_PAGE_REPOSITORY_CONTENT); - storageTableIdMap.put(TableId.PAGE_RESOURCE_ACCOUNTS_PANEL_RESOURCE_MODE, SessionStorage.KEY_RESOURCE_ACCOUNT_CONTENT + SessionStorage.KEY_RESOURCE_PAGE_RESOURCE_CONTENT); - storageTableIdMap.put(TableId.PAGE_RESOURCE_ENTITLEMENT_PANEL_REPOSITORY_MODE, SessionStorage.KEY_RESOURCE_ENTITLEMENT_CONTENT + SessionStorage.KEY_RESOURCE_PAGE_REPOSITORY_CONTENT); - storageTableIdMap.put(TableId.PAGE_RESOURCE_ENTITLEMENT_PANEL_RESOURCE_MODE, SessionStorage.KEY_RESOURCE_ENTITLEMENT_CONTENT + SessionStorage.KEY_RESOURCE_PAGE_RESOURCE_CONTENT); - storageTableIdMap.put(TableId.PAGE_RESOURCE_GENERIC_PANEL_REPOSITORY_MODE, SessionStorage.KEY_RESOURCE_GENERIC_CONTENT + SessionStorage.KEY_RESOURCE_PAGE_REPOSITORY_CONTENT); - storageTableIdMap.put(TableId.PAGE_RESOURCE_GENERIC_PANEL_RESOURCE_MODE, SessionStorage.KEY_RESOURCE_GENERIC_CONTENT + SessionStorage.KEY_RESOURCE_PAGE_RESOURCE_CONTENT); - storageTableIdMap.put(TableId.PAGE_RESOURCE_OBJECT_CLASS_PANEL, SessionStorage.KEY_RESOURCE_OBJECT_CLASS_CONTENT); - storageTableIdMap.put(TableId.ROLE_MEMEBER_PANEL, SessionStorage.KEY_ROLE_MEMEBER_PANEL); - storageTableIdMap.put(TableId.ORG_MEMEBER_PANEL, SessionStorage.KEY_ORG_MEMEBER_PANEL); - storageTableIdMap.put(TableId.SERVICE_MEMEBER_PANEL, SessionStorage.KEY_SERVICE_MEMEBER_PANEL); - - } - - private static final Map COMPONENT_MAP = new HashMap<>(); - - static { - COMPONENT_MAP.put("com.evolveum.midpoint", LoggingComponentType.ALL); - COMPONENT_MAP.put("com.evolveum.midpoint.model", LoggingComponentType.MODEL); - COMPONENT_MAP.put("com.evolveum.midpoint.provisioning", LoggingComponentType.PROVISIONING); - COMPONENT_MAP.put("com.evolveum.midpoint.repo", LoggingComponentType.REPOSITORY); - COMPONENT_MAP.put("com.evolveum.midpoint.web", LoggingComponentType.WEB); - COMPONENT_MAP.put("com.evolveum.midpoint.gui", LoggingComponentType.GUI); - COMPONENT_MAP.put("com.evolveum.midpoint.task", LoggingComponentType.TASKMANAGER); - COMPONENT_MAP.put("com.evolveum.midpoint.model.sync", - LoggingComponentType.RESOURCEOBJECTCHANGELISTENER); - COMPONENT_MAP.put("com.evolveum.midpoint.wf", LoggingComponentType.WORKFLOWS); - COMPONENT_MAP.put("com.evolveum.midpoint.notifications", LoggingComponentType.NOTIFICATIONS); - COMPONENT_MAP.put("com.evolveum.midpoint.certification", LoggingComponentType.ACCESS_CERTIFICATION); - COMPONENT_MAP.put("com.evolveum.midpoint.security", LoggingComponentType.SECURITY); - } - - public enum AssignmentOrder{ - - ASSIGNMENT(0), - INDUCEMENT(1); - - private int order; - - AssignmentOrder(int order){ - this.order = order; - } - - public int getOrder() { - return order; - } - } - - public static String nl2br(String text) { - if (text == null) { - return null; - } - return StringEscapeUtils.escapeHtml4(text).replace("\n", "
"); - } - - public static String getTypeLocalized(ObjectReferenceType ref) { - ObjectTypes type = ref != null ? ObjectTypes.getObjectTypeFromTypeQName(ref.getType()) : null; - ObjectTypeGuiDescriptor descriptor = ObjectTypeGuiDescriptor.getDescriptor(type); - if (descriptor == null) { - return null; - } - return createStringResourceStatic(null, descriptor.getLocalizationKey()).getString(); - } - - public static String getReferencedObjectNames(List refs, boolean showTypes) { - return getReferencedObjectNames(refs, showTypes, true); - } - - public static String getReferencedObjectNames(List refs, boolean showTypes, boolean translate) { - return refs.stream() - .map(ref -> emptyIfNull(getName(ref, translate)) + (showTypes ? (" (" + emptyIfNull(getTypeLocalized(ref)) + ")") : "")) - .collect(Collectors.joining(", ")); - } - - private static String emptyIfNull(String s) { - return s != null ? s : ""; - } - - public static String getReferencedObjectDisplayNamesAndNames(List refs, boolean showTypes) { - return refs.stream() - .map(ref -> emptyIfNull(getDisplayNameAndName(ref)) + (showTypes ? (" (" + emptyIfNull(getTypeLocalized(ref)) + ")") : "")) - .collect(Collectors.joining(", ")); - } - - public static String getReferencedObjectDisplayNamesAndNames(Referencable ref, boolean showTypes) { - return getReferencedObjectDisplayNamesAndNames(ref, showTypes, true); - } - - public static String getReferencedObjectDisplayNamesAndNames(Referencable ref, boolean showTypes, boolean translate) { - if (ref == null){ - return ""; - } - String name = ref.getTargetName() == null ? "" : - (translate ? ref.getTargetName().getOrig() : ""); - StringBuilder sb = new StringBuilder(name); - if(showTypes) { - sb.append(" ("); - ObjectTypes type = ObjectTypes.getObjectTypeFromTypeQName(ref.getType()); - ObjectTypeGuiDescriptor descriptor = ObjectTypeGuiDescriptor.getDescriptor(type); - if (descriptor == null) { - return null; - } - sb.append(emptyIfNull(createStringResourceStatic(null, descriptor.getLocalizationKey()).getString())).append(")"); - } - return sb.toString(); - } - - public static List loadReferencedObjectList(List refList, String operation, PageBase pageBase){ - List loadedObjectsList = new ArrayList<>(); - if (refList == null){ - return loadedObjectsList; - } - refList.forEach(objectRef -> { - OperationResult result = new OperationResult(operation); - PrismObject loadedObject = WebModelServiceUtils.resolveReferenceNoFetch(objectRef, pageBase, pageBase.createSimpleTask(operation), result); - if (loadedObject != null) { - loadedObjectsList.add(loadedObject.asObjectable()); - } - }); - return loadedObjectsList; - } - - public static List loadTargetUsersListForShoppingCart(String operation, PageBase pageBase){ - List usersOidsList = pageBase.getSessionStorage().getRoleCatalog().getTargetUserOidsList(); - if (CollectionUtils.isEmpty(usersOidsList)){ - return new ArrayList<>(); - } - List usersReferenceList = new ArrayList<>(); - usersOidsList.forEach(userOid -> { - usersReferenceList.add(WebComponentUtil.createObjectRef(userOid, null, UserType.COMPLEX_TYPE)); - }); - return WebComponentUtil.loadReferencedObjectList(usersReferenceList, operation, pageBase); - - } - - public static ObjectFilter getShadowTypeFilterForAssociation(ConstructionType construction, String operation, PageBase pageBase){ - PrismContext prismContext = pageBase.getPrismContext(); - if (construction == null){ - return null; - } - PrismObject resource = WebComponentUtil.getConstructionResource(construction, operation, pageBase); - if (resource == null){ - return null; - } - - ObjectQuery query = prismContext.queryFactory().createQuery(); - try { - RefinedResourceSchema refinedResourceSchema = RefinedResourceSchema.getRefinedSchema(resource); - RefinedObjectClassDefinition oc = refinedResourceSchema.getRefinedDefinition(construction.getKind(), construction.getIntent()); - if (oc == null){ - return null; - } - Collection refinedAssociationDefinitions = oc.getAssociationDefinitions(); - - for (RefinedAssociationDefinition refinedAssociationDefinition : refinedAssociationDefinitions) { - S_FilterEntryOrEmpty atomicFilter = prismContext.queryFor(ShadowType.class); - List orFilterClauses = new ArrayList<>(); - refinedAssociationDefinition.getIntents() - .forEach(intent -> orFilterClauses.add(atomicFilter.item(ShadowType.F_INTENT).eq(intent).buildFilter())); - OrFilter intentFilter = prismContext.queryFactory().createOr(orFilterClauses); - - AndFilter filter = (AndFilter) atomicFilter.item(ShadowType.F_KIND).eq(refinedAssociationDefinition.getKind()).and() - .item(ShadowType.F_RESOURCE_REF).ref(resource.getOid(), ResourceType.COMPLEX_TYPE).buildFilter(); - filter.addCondition(intentFilter); - query.setFilter(filter); // TODO this overwrites existing filter (created in previous cycle iteration)... is it OK? [med] - } - } catch (SchemaException ex) { - LOGGER.error("Couldn't create query filter for ShadowType for association: {}" , ex.getErrorTypeMessage()); - } - return query.getFilter(); - } - - public static void addAjaxOnUpdateBehavior(WebMarkupContainer container) { - container.visitChildren(new IVisitor() { - @Override - public void component(Component component, IVisit objectIVisit) { - if (component instanceof InputPanel) { - addAjaxOnBlurUpdateBehaviorToComponent(((InputPanel) component).getBaseFormComponent()); - } else if (component instanceof FormComponent) { - addAjaxOnBlurUpdateBehaviorToComponent(component); - } - } - }); - } - - private static void addAjaxOnBlurUpdateBehaviorToComponent(final Component component) { - component.setOutputMarkupId(true); - component.add(new AjaxFormComponentUpdatingBehavior("blur") { - - @Override - protected void onUpdate(AjaxRequestTarget target) { - } - }); - } - - public static String resolveLocalizableMessage(LocalizableMessageType localizableMessage, Component component) { - if (localizableMessage == null) { - return null; - } - return resolveLocalizableMessage(LocalizationUtil.toLocalizableMessage(localizableMessage), component); - } - - public static String resolveLocalizableMessage(LocalizableMessage localizableMessage, Component component) { - if (localizableMessage == null) { - return null; - } else if (localizableMessage instanceof SingleLocalizableMessage) { - return resolveLocalizableMessage((SingleLocalizableMessage) localizableMessage, component); - } else if (localizableMessage instanceof LocalizableMessageList) { - return resolveLocalizableMessage((LocalizableMessageList) localizableMessage, component); - } else { - throw new AssertionError("Unsupported localizable message type: " + localizableMessage); - } - } - - private static String resolveLocalizableMessage(SingleLocalizableMessage localizableMessage, Component component) { - if (localizableMessage == null) { - return null; - } - while (localizableMessage.getFallbackLocalizableMessage() != null) { - if (localizableMessage.getKey() != null) { - Localizer localizer = Application.get().getResourceSettings().getLocalizer(); - if (localizer.getStringIgnoreSettings(localizableMessage.getKey(), component, null, null) != null) { - break; // the key exists => we can use the current localizableMessage - } - } - if (localizableMessage.getFallbackLocalizableMessage() instanceof SingleLocalizableMessage) { - localizableMessage = (SingleLocalizableMessage) localizableMessage.getFallbackLocalizableMessage(); - } else { - return resolveLocalizableMessage(localizableMessage.getFallbackLocalizableMessage(), component); - } - } - String key = localizableMessage.getKey() != null ? localizableMessage.getKey() : localizableMessage.getFallbackMessage(); - StringResourceModel stringResourceModel = new StringResourceModel(key, component) - .setModel(new Model()) - .setDefaultValue(localizableMessage.getFallbackMessage()) - .setParameters(resolveArguments(localizableMessage.getArgs(), component)); - String rv = stringResourceModel.getString(); - //System.out.println("GUI: Resolving [" + key + "]: to [" + rv + "]"); - return rv; - } - - // todo deduplicate with similar method in LocalizationServiceImpl - private static String resolveLocalizableMessage(LocalizableMessageList msgList, Component component) { - String separator = resolveIfPresent(msgList.getSeparator(), component); - String prefix = resolveIfPresent(msgList.getPrefix(), component); - String suffix = resolveIfPresent(msgList.getPostfix(), component); - return msgList.getMessages().stream() - .map(m -> resolveLocalizableMessage(m, component)) - .collect(Collectors.joining(separator, prefix, suffix)); - } - - private static String resolveIfPresent(LocalizableMessage msg, Component component) { - return msg != null ? resolveLocalizableMessage(msg, component) : ""; - } - - private static Object[] resolveArguments(Object[] args, Component component) { - if (args == null) { - return null; - } - Object[] rv = new Object[args.length]; - for (int i = 0; i < args.length; i++) { - if (args[i] instanceof LocalizableMessage) { - rv[i] = resolveLocalizableMessage(((LocalizableMessage) args[i]), component); - } else { - rv[i] = args[i]; - } - } - return rv; - } - - // TODO add other classes; probably move to some enum - @Nullable - public static String getAuthorizationActionForTargetClass(Class targetClass) { - if (UserType.class.equals(targetClass)) { - return AuthorizationConstants.AUTZ_UI_USER_URL; - } else if (OrgType.class.equals(targetClass)) { - return AuthorizationConstants.AUTZ_UI_ORG_UNIT_URL; - } else if (RoleType.class.equals(targetClass)) { - return AuthorizationConstants.AUTZ_UI_ROLE_URL; - } else if (ServiceType.class.equals(targetClass)) { - return AuthorizationConstants.AUTZ_UI_SERVICE_URL; - } else if (ResourceType.class.equals(targetClass)) { - return AuthorizationConstants.AUTZ_UI_RESOURCE_URL; - } else { - return null; - } - } - - public static void safeResultCleanup(OperationResult result, Trace logger) { - try { - result.cleanupResultDeeply(); - } catch (Throwable t) { - LoggingUtils.logUnexpectedException(logger, "Couldn't clean up the operation result", t); - } - } - - /** - * Default list view setting should never be needed. Always check setting for specific - * object type (and archetype). - */ - @Deprecated - public static CompiledObjectCollectionView getDefaultGuiObjectListType(PageBase pageBase) { - return pageBase.getCompiledGuiProfile().getDefaultObjectCollectionView(); - } - - public enum Channel { - // TODO: move this to schema component - LIVE_SYNC(SchemaConstants.CHANGE_CHANNEL_LIVE_SYNC_URI), - RECONCILIATION(SchemaConstants.CHANGE_CHANNEL_RECON_URI), - RECOMPUTATION(SchemaConstants.CHANGE_CHANNEL_RECOMPUTE_URI), - DISCOVERY(SchemaConstants.CHANGE_CHANNEL_DISCOVERY_URI), - WEB_SERVICE(SchemaConstants.CHANNEL_WEB_SERVICE_URI), - IMPORT(SchemaConstants.CHANNEL_OBJECT_IMPORT_URI), - REST(SchemaConstants.CHANNEL_REST_URI), - INIT(SchemaConstants.CHANNEL_GUI_INIT_URI), - USER(SchemaConstants.CHANNEL_GUI_USER_URI), - SELF_REGISTRATION(SchemaConstants.CHANNEL_GUI_SELF_REGISTRATION_URI), - RESET_PASSWORD(SchemaConstants.CHANNEL_GUI_RESET_PASSWORD_URI); - - private String channel; - - Channel(String channel) { - this.channel = channel; - } - - public String getChannel() { - return channel; - } - } - - public static DateValidator getRangeValidator(Form form, ItemPath path) { - DateValidator validator = null; - List validators = form.getBehaviors(DateValidator.class); - if (validators != null) { - for (DateValidator val : validators) { - if (path.equivalent(val.getIdentifier())) { - validator = val; - break; - } - } - } - - if (validator == null) { - validator = new DateValidator(); - validator.setIdentifier(path); - form.add(validator); - } - - return validator; - } - - public static boolean isItemVisible(List visibleItems, ItemPath itemToBeFound) { - return ItemPathCollectionsUtil.containsSubpathOrEquivalent(visibleItems, itemToBeFound); - - } - - public static Class qnameToClass(PrismContext prismContext, QName type) { - return prismContext.getSchemaRegistry().determineCompileTimeClass(type); - } - - public static Class qnameToClass(PrismContext prismContext, QName type, Class returnType) { - return prismContext.getSchemaRegistry().determineCompileTimeClass(type); - } - - public static QName classToQName(PrismContext prismContext, Class clazz) { - return prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(clazz).getTypeName(); - } - - public static TaskType createSingleRecurrenceTask(String taskName, QName applicableType, ObjectQuery query, - ObjectDelta delta, ModelExecuteOptions options, String category, PageBase pageBase) throws SchemaException { - - TaskType task = new TaskType(pageBase.getPrismContext()); - - MidPointPrincipal owner = SecurityUtils.getPrincipalUser(); - - ObjectReferenceType ownerRef = new ObjectReferenceType(); - ownerRef.setOid(owner.getOid()); - ownerRef.setType(owner.getFocus().COMPLEX_TYPE); - task.setOwnerRef(ownerRef); - - task.setBinding(TaskBindingType.LOOSE); - task.setCategory(category); - task.setExecutionStatus(TaskExecutionStatusType.RUNNABLE); - task.setRecurrence(TaskRecurrenceType.SINGLE); - task.setThreadStopAction(ThreadStopActionType.RESTART); - task.setHandlerUri(pageBase.getTaskService().getHandlerUriForCategory(category)); - ScheduleType schedule = new ScheduleType(); - schedule.setMisfireAction(MisfireActionType.EXECUTE_IMMEDIATELY); - task.setSchedule(schedule); - - task.setName(WebComponentUtil.createPolyFromOrigString(taskName)); - - PrismObject prismTask = task.asPrismObject(); - QueryType queryType = pageBase.getQueryConverter().createQueryType(query); - prismTask.findOrCreateProperty(SchemaConstants.PATH_MODEL_EXTENSION_OBJECT_QUERY).addRealValue(queryType); - - if (applicableType != null) { - prismTask.findOrCreateProperty(SchemaConstants.PATH_MODEL_EXTENSION_OBJECT_TYPE).setRealValue(applicableType); - } - - if (delta != null) { - ObjectDeltaType deltaBean = DeltaConvertor.toObjectDeltaType(delta); - prismTask.findOrCreateProperty(SchemaConstants.PATH_MODEL_EXTENSION_OBJECT_DELTA).setRealValue(deltaBean); - } - - if (options != null) { - prismTask.findOrCreateProperty(SchemaConstants.PATH_MODEL_EXTENSION_EXECUTE_OPTIONS) - .setRealValue(options.toModelExecutionOptionsType()); - } - return task; - } - - public static void iterativeExecuteBulkAction(PageBase pageBase, ExecuteScriptType script, Task task, OperationResult result ) - throws SchemaException, SecurityViolationException, ObjectNotFoundException, ExpressionEvaluationException, - CommunicationException, ConfigurationException{ - - pageBase.getScriptingService().evaluateIterativeExpressionInBackground(script, task, result); - } - - public static Task createMemberOperationTask(Task operationalTask, QName type, ObjectQuery memberQuery, - ExecuteScriptType script, Collection> option, OperationResult parentResult, PageBase pageBase) throws SchemaException { - - MidPointPrincipal owner = SecurityUtils.getPrincipalUser(); - operationalTask.setOwner(owner.getFocus().asPrismObject()); - - operationalTask.setBinding(TaskBinding.LOOSE); - operationalTask.setInitialExecutionStatus(TaskExecutionStatus.RUNNABLE); - operationalTask.setThreadStopAction(ThreadStopActionType.RESTART); - ScheduleType schedule = new ScheduleType(); - schedule.setMisfireAction(MisfireActionType.EXECUTE_IMMEDIATELY); - operationalTask.makeSingle(schedule); - operationalTask.setName(WebComponentUtil.createPolyFromOrigString(parentResult.getOperation())); - - PrismPropertyDefinition propertyDefQuery = pageBase.getPrismContext().getSchemaRegistry() - .findPropertyDefinitionByElementName(SchemaConstants.MODEL_EXTENSION_OBJECT_QUERY); - PrismProperty queryProperty = propertyDefQuery.instantiate(); - QueryType queryType = pageBase.getQueryConverter().createQueryType(memberQuery); - queryProperty.setRealValue(queryType); - operationalTask.addExtensionProperty(queryProperty); - - PrismPropertyDefinition propertyDefType = pageBase.getPrismContext().getSchemaRegistry() - .findPropertyDefinitionByElementName(SchemaConstants.MODEL_EXTENSION_OBJECT_TYPE); - PrismProperty typeProperty = propertyDefType.instantiate(); - typeProperty.setRealValue(type); - operationalTask.addExtensionProperty(typeProperty); - - if (option != null) { - PrismPropertyDefinition propertyDefOption = pageBase.getPrismContext().getSchemaRegistry() - .findPropertyDefinitionByElementName(SchemaConstants.MODEL_EXTENSION_SEARCH_OPTIONS); - PrismProperty optionProperty = propertyDefOption.instantiate(); - optionProperty.setRealValue(MiscSchemaUtil.optionsToOptionsType(option)); - operationalTask.addExtensionProperty(optionProperty); - } - - try { - pageBase.getSecurityEnforcer().authorize(ModelAuthorizationAction.EXECUTE_SCRIPT.getUrl(), - null, AuthorizationParameters.EMPTY, null, operationalTask, parentResult); - operationalTask.setExtensionPropertyValue(SchemaConstants.SE_EXECUTE_SCRIPT, script); - operationalTask.setHandlerUri(ModelPublicConstants.ITERATIVE_SCRIPT_EXECUTION_TASK_HANDLER_URI); - return operationalTask; - } catch (ObjectNotFoundException | SchemaException - | ExpressionEvaluationException | CommunicationException | ConfigurationException - | SecurityViolationException e) { - parentResult.recordFatalError(pageBase.createStringResource("WebComponentUtil.message.startPerformed.fatalError.createTask").getString(), e); - LoggingUtils.logUnexpectedException(LOGGER, "Couldn't create bulk action task", e); - } - return null; - } - - public static void executeMemberOperation(Task operationalTask, OperationResult parentResult, PageBase pageBase) { - - OperationResult result = parentResult.createSubresult("evaluateExpressionInBackground"); - pageBase.getTaskManager().switchToBackground(operationalTask, result); - result.computeStatus(); - parentResult.recordInProgress(); - parentResult.setBackgroundTaskOid(operationalTask.getOid()); - pageBase.showResult(parentResult); - } - - public static boolean isAuthorized(String... action) { - if (action == null || action.length == 0) { - return true; - } - List actions = Arrays.asList(action); - return isAuthorized(actions); - } - - public static boolean isAuthorized(Collection actions) { - if (actions == null || actions.isEmpty()) { - return true; - } - Roles roles = new Roles(AuthorizationConstants.AUTZ_ALL_URL); - roles.add(AuthorizationConstants.AUTZ_GUI_ALL_URL); - roles.add(AuthorizationConstants.AUTZ_GUI_ALL_DEPRECATED_URL); - roles.addAll(actions); - if (((AuthenticatedWebApplication) AuthenticatedWebApplication.get()).hasAnyRole(roles)) { - return true; - } - return false; - } - - // TODO: move to util component - public static Integer safeLongToInteger(Long l) { - if (l == null) { - return null; - } - - if (l > Integer.MAX_VALUE || l < Integer.MIN_VALUE) { - throw new IllegalArgumentException( - "Couldn't transform long '" + l + "' to int, too big or too small."); - } - - return (int) l.longValue(); - } - - // TODO: move to schema component - public static List createObjectTypeList() { - - List types = new ArrayList<>(ObjectTypes.values().length); - for (ObjectTypes t : ObjectTypes.values()) { - types.add(t.getTypeQName()); - } - - return types.stream().sorted((type1, type2) -> { - Validate.notNull(type1); - Validate.notNull(type2); - - return String.CASE_INSENSITIVE_ORDER.compare(QNameUtil.qNameToUri(type1), QNameUtil.qNameToUri(type2)); - - - }).collect(Collectors.toList()); - - } - - public static List createAssignmentHolderTypeQnamesList() { - - List objectTypes = createAssignmentHolderTypesList(); - List types = new ArrayList<>(); - objectTypes.forEach(objectType -> { - types.add(objectType.getTypeQName()); - }); - - return types.stream().sorted((type1, type2) -> { - Validate.notNull(type1); - Validate.notNull(type2); - - return String.CASE_INSENSITIVE_ORDER.compare(QNameUtil.qNameToUri(type1), QNameUtil.qNameToUri(type2)); - - - }).collect(Collectors.toList()); - - } - - public static List createAssignmentHolderTypesList(){ - List objectTypes = new ArrayList<>(); - for (ObjectTypes t : ObjectTypes.values()) { - if (AssignmentHolderType.class.isAssignableFrom(t.getClassDefinition())) { - objectTypes.add(t); - } - } - return objectTypes.stream().sorted((type1, type2) -> { - Validate.notNull(type1); - Validate.notNull(type2); - - return String.CASE_INSENSITIVE_ORDER.compare(QNameUtil.qNameToUri(type1.getTypeQName()), QNameUtil.qNameToUri(type2.getTypeQName())); - - - }).collect(Collectors.toList()); - } - - // TODO: move to schema component - public static List createFocusTypeList() { - return createFocusTypeList(false); - } - - public static List createFocusTypeList(boolean includeAbstractType) { - List focusTypeList = new ArrayList<>(); - - focusTypeList.add(UserType.COMPLEX_TYPE); - focusTypeList.add(OrgType.COMPLEX_TYPE); - focusTypeList.add(RoleType.COMPLEX_TYPE); - focusTypeList.add(ServiceType.COMPLEX_TYPE); - - if (includeAbstractType) { - focusTypeList.add(FocusType.COMPLEX_TYPE); - } - - return focusTypeList; - } - - // TODO: move to schema component - public static List createAbstractRoleTypeList() { - List focusTypeList = new ArrayList<>(); - - focusTypeList.add(AbstractRoleType.COMPLEX_TYPE); - focusTypeList.add(OrgType.COMPLEX_TYPE); - focusTypeList.add(RoleType.COMPLEX_TYPE); - focusTypeList.add(ServiceType.COMPLEX_TYPE); - - return focusTypeList; - } - - public static List createAssignableTypesList() { - List focusTypeList = new ArrayList<>(); - - focusTypeList.add(ObjectTypes.RESOURCE); - focusTypeList.add(ObjectTypes.ORG); - focusTypeList.add(ObjectTypes.ROLE); - focusTypeList.add(ObjectTypes.SERVICE); - - return focusTypeList; - } - - public static List createSupportedTargetTypeList(QName targetTypeFromDef) { - if (targetTypeFromDef == null || ObjectType.COMPLEX_TYPE.equals(targetTypeFromDef)) { - return createObjectTypeList(); - } - - if (AbstractRoleType.COMPLEX_TYPE.equals(targetTypeFromDef)) { - return createAbstractRoleTypeList(); - } - - if (FocusType.COMPLEX_TYPE.equals(targetTypeFromDef)) { - return createFocusTypeList(); - } - - if (AssignmentHolderType.COMPLEX_TYPE.equals(targetTypeFromDef)) { - return createAssignmentHolderTypeQnamesList(); - } - - return Arrays.asList(targetTypeFromDef); - } - - /** - * Takes a collection of object types (classes) that may contain abstract types. Returns a collection - * that only contain concrete types. - * @param common supertype for all the types in the collections - * - * TODO: move to schema component - */ - public static List resolveObjectTypesToQNames(Collection> types, PrismContext prismContext) { - if (types == null) { - return null; - } - List concreteTypes = new ArrayList<>(types.size()); - for (Class type: types) { - if (type == null || type.equals(ObjectType.class)) { - MiscUtil.addAllIfNotPresent(concreteTypes, createObjectTypeList()); - } else if (type.equals(FocusType.class)) { - MiscUtil.addAllIfNotPresent(concreteTypes, createFocusTypeList()); - } else if (type.equals(AbstractRoleType.class)) { - MiscUtil.addAllIfNotPresent(concreteTypes, createAbstractRoleTypeList()); - } else { - MiscUtil.addIfNotPresent(concreteTypes, classToQName(prismContext, type)); - } - } - return concreteTypes; - } - - public static IModel createLocalizedModelForEnum(T value, Component comp) { - String key = value != null ? value.getClass().getSimpleName() + "." + value.name() : ""; - return new StringResourceModel(key, comp, null); - } - - public static IModel> createReadonlyModelFromEnum(final Class type) { - return (IModel>) () -> { - List list = new ArrayList<>(); - Collections.addAll(list, type.getEnumConstants()); - - return list; - }; - } - - // use for small enums only - @NotNull - public static IModel> createReadonlyValueModelFromEnum(@NotNull Class type, @NotNull Predicate filter) { - return new ReadOnlyValueModel<>( - Arrays.stream(type.getEnumConstants()) - .filter(filter) - .collect(Collectors.toList())); - } - - public static List createTaskCategoryList() { - List categories = new ArrayList<>(); - - // todo change to something better and add i18n - // TaskManager manager = getTaskManager(); - // List list = manager.getAllTaskCategories(); - // if (list != null) { - // Collections.sort(list); - // for (String item : list) { - // if (item != TaskCategory.IMPORT_FROM_FILE && item != - // TaskCategory.WORKFLOW) { - // categories.add(item); - // } - // } - // } - categories.add(TaskCategory.LIVE_SYNCHRONIZATION); - categories.add(TaskCategory.RECONCILIATION); - categories.add(TaskCategory.IMPORTING_ACCOUNTS); - categories.add(TaskCategory.RECOMPUTATION); - categories.add(TaskCategory.DEMO); - // TODO: what about other categories? - // categories.add(TaskCategory.ACCESS_CERTIFICATION); - // categories.add(TaskCategory.BULK_ACTIONS); - // categories.add(TaskCategory.CUSTOM); - // categories.add(TaskCategory.EXECUTE_CHANGES); - // categories.add(TaskCategory.IMPORT_FROM_FILE); - // categories.add(TaskCategory.IMPORT_FROM_FILE); - return categories; - } - - public static IModel createCategoryNameModel(final Component component, - final IModel categorySymbolModel) { - return (IModel) () -> createStringResourceStatic(component, - "pageTasks.category." + categorySymbolModel.getObject()).getString(); - } - - public static ObjectReferenceType createObjectRef(String oid, String name, QName type) { - ObjectReferenceType ort = new ObjectReferenceType(); - ort.setOid(oid); - ort.setTargetName(createPolyFromOrigString(name)); - ort.setType(type); - return ort; - } - - public static DropDownChoicePanel createEnumPanel(Class clazz, String id, - final IModel model, final Component component) { - return createEnumPanel(clazz, id, model, component, true); - - } - public static DropDownChoicePanel createEnumPanel(Class clazz, String id, - final IModel model, final Component component, boolean allowNull) { - return createEnumPanel(clazz, id, WebComponentUtil.createReadonlyModelFromEnum(clazz), - model, component, allowNull ); - } - - public static DropDownChoicePanel createEnumPanel(Class clazz, String id, - IModel> choicesList, final IModel model, final Component component, boolean allowNull) { - return createEnumPanel(clazz, id, choicesList, model, component, allowNull, null); - } - - public static DropDownChoicePanel createEnumPanel(Class clazz, String id, - IModel> choicesList, final IModel model, final Component component, boolean allowNull, String nullValidDisplayValue) { - return new DropDownChoicePanel(id, model, choicesList, getEnumChoiceRenderer(component) - , allowNull){ - - private static final long serialVersionUID = 1L; - - @Override - protected String getNullValidDisplayValue() { - return nullValidDisplayValue != null && StringUtils.isNotEmpty(nullValidDisplayValue.trim()) ? - nullValidDisplayValue : super.getNullValidDisplayValue(); - } - }; - } - - public static IChoiceRenderer getEnumChoiceRenderer(Component component){ - return new IChoiceRenderer() { - - private static final long serialVersionUID = 1L; - - @Override - public E getObject(String id, IModel> choices) { - if (StringUtils.isBlank(id)) { - return null; - } - return choices.getObject().get(Integer.parseInt(id)); - } - - @Override - public Object getDisplayValue(E object) { - return WebComponentUtil.createLocalizedModelForEnum(object, component).getObject(); - } - - @Override - public String getIdValue(E object, int index) { - return Integer.toString(index); - } - }; - } - - public static DropDownChoicePanel createEnumPanel(final PrismPropertyDefinition def, String id, - final IModel model) { - final Object o = model.getObject(); - - final IModel> enumModelValues = (IModel>) () -> getDisplayableValues(def.getAllowedValues()); - - return new DropDownChoicePanel(id, model, enumModelValues, new DisplayableValueChoiceRenderer(getDisplayableValues(def.getAllowedValues())), true); - } - - private static List getDisplayableValues(Collection allowedValues) { - List values = null; - if (allowedValues != null) { - values = new ArrayList<>(allowedValues.size()); - for (T v : allowedValues) { - if (v instanceof DisplayableValue) { - values.add(((DisplayableValue) v)); - } - } - } - return values; - } - - public static String getName(ObjectType object) { - return getName(object, true); - } - - public static String getName(ObjectType object, boolean translate) { - if (object == null) { - return null; - } - - return getName(object.asPrismObject(), translate); - } - - public static String getEffectiveName(ObjectType object, QName propertyName) { - return getEffectiveName(object, propertyName, true); - } - - public static String getEffectiveName(ObjectType object, QName propertyName, boolean translate) { - if (object == null) { - return null; - } - - return getEffectiveName(object.asPrismObject(), propertyName, translate); - } - - public static String getEffectiveName(PrismObject object, QName propertyName) { - return getEffectiveName(object, propertyName, true); - } - - public static String getEffectiveName(PrismObject object, QName propertyName, boolean translate) { - if (object == null) { - return null; - } - - PrismProperty prop = object.findProperty(ItemName.fromQName(propertyName)); - - if (prop != null) { - Object realValue = prop.getRealValue(); - if (prop.getDefinition().getTypeName().equals(DOMUtil.XSD_STRING)) { - return (String) realValue; - } else if (realValue instanceof PolyString) { - return translate ? getTranslatedPolyString((PolyString) realValue) - : WebComponentUtil.getOrigStringFromPoly((PolyString) realValue); - } - } - - PolyString name = getValue(object, ObjectType.F_NAME, PolyString.class); - if (name == null){ - return null; - } - return translate ? getTranslatedPolyString(name) - : WebComponentUtil.getOrigStringFromPoly(name); - } - - public static String getTranslatedPolyString(PolyStringType value){ - return getTranslatedPolyString(PolyString.toPolyString(value)); - } - - public static String getTranslatedPolyString(PolyString value){ - MidPointApplication application = MidPointApplication.get(); - return getTranslatedPolyString(value, application != null ? application.getLocalizationService() : null); - } - - public static String getTranslatedPolyString(PolyString value, LocalizationService localizationService){ - if (value == null){ - return ""; - } - if (localizationService == null){ - localizationService = MidPointApplication.get().getLocalizationService(); - } - return localizationService.translate(value, getCurrentLocale(), true); - } - - public static String getName(ObjectReferenceType ref, PageBase pageBase, String operation) { - String name = getName(ref); - if (StringUtils.isEmpty(name) || name.equals(ref.getOid())) { - String oid = ref.getOid(); - Collection> options = SelectorOptions - .createCollection(GetOperationOptions.createNoFetch()); - Class type = (Class) ObjectType.class; - PrismObject object = WebModelServiceUtils.loadObject(type, oid, pageBase, - pageBase.createSimpleTask(operation), new OperationResult(operation)); - if (object != null) { - name = object.getName().getOrig(); - } - } - return name; - } - - public static String getDisplayNameOrName(ObjectReferenceType ref, PageBase pageBase, String operation) { - return getDisplayNameOrName(ref, pageBase, operation, true); - } - - public static String getDisplayNameOrName(ObjectReferenceType ref, PageBase pageBase, - String operation, boolean translate) { - String name = getName(ref, translate); - if (StringUtils.isEmpty(name) || name.equals(ref.getOid())) { - String oid = ref.getOid(); - Collection> options = SelectorOptions - .createCollection(GetOperationOptions.createNoFetch()); - Class type = ref.getType() != null ? (Class)qnameToClass(pageBase.getPrismContext(), ref.getType()) : (Class) ObjectType.class; - PrismObject object = WebModelServiceUtils.loadObject(type, oid, pageBase, - pageBase.createSimpleTask(operation), new OperationResult(operation)); - if (object != null) { - name = getDisplayNameOrName(object, true); - } - } - return name; - } - - public static String getEffectiveName(ObjectReferenceType ref, QName propertyName, - PageBase pageBase, String operation) { - return getEffectiveName(ref, propertyName, pageBase, operation, true); - } - public static String getEffectiveName(ObjectReferenceType ref, QName propertyName, - PageBase pageBase, String operation, boolean translate) { - PrismObject object = WebModelServiceUtils.loadObject(ref, pageBase, - pageBase.createSimpleTask(operation), new OperationResult(operation)); - - if (object == null) { - return "Not Found"; - } - - return getEffectiveName(object, propertyName, translate); - - } - - public static String getName(ObjectReferenceType ref) { - return getName(ref, true); - } - - public static String getName(ObjectReferenceType ref, boolean translate) { - if (ref == null) { - return null; - } - if (ref.getTargetName() != null) { - if (translate){ - return getTranslatedPolyString(ref.getTargetName()); - } - return getOrigStringFromPoly(ref.getTargetName()); - } - if (ref.asReferenceValue().getObject() != null) { - return getName(ref.asReferenceValue().getObject(), translate); - } - return ref.getOid(); - } - - public static String getName(PrismObject object) { - return getName(object, true); - } - - public static String getName(PrismObject object, boolean translate) { - return getName(object, translate, (LocalizationService) null); - } - - public static String getName(PrismObject object, boolean translate, LocalizationService localizationService) { - if (object == null) { - return null; - } - PolyString name = getValue(object, ObjectType.F_NAME, PolyString.class); - if (name == null){ - return null; - } - if (translate){ - return getTranslatedPolyString(name, localizationService); - } - return name.getOrig(); - } - - public static String getDisplayName(PrismContainerValue prismContainerValue) { - if (prismContainerValue == null) { - return "ContainerPanel.containerProperties"; - } - - String displayName = null; - - if (prismContainerValue.canRepresent(LifecycleStateType.class)) { - LifecycleStateType lifecycleStateType = (LifecycleStateType) prismContainerValue.asContainerable(); - String name = lifecycleStateType.getDisplayName(); - if (name == null || name.isEmpty()) { - Class cvalClass = prismContainerValue.getCompileTimeClass(); - name = lifecycleStateType.getName(); - } - - if (name != null && !name.isEmpty()) { - displayName = name; - } - } else if (prismContainerValue.canRepresent(PropertyConstraintType.class)) { - PropertyConstraintType propertyConstraintType = (PropertyConstraintType) prismContainerValue.asContainerable(); - String path = ""; - if (propertyConstraintType.getPath() != null) { - path = propertyConstraintType.getPath().getItemPath().toString(); - } - - if (path != null && !path.isEmpty()) { - displayName = path; - } - } else if (prismContainerValue.canRepresent(AssignmentType.class)) { - AssignmentType assignmentType = (AssignmentType) prismContainerValue.asContainerable(); - if (assignmentType.getTargetRef() != null) { - ObjectReferenceType assignmentTargetRef = assignmentType.getTargetRef(); - displayName = getName(assignmentTargetRef) + " - " + normalizeRelation(assignmentTargetRef.getRelation()).getLocalPart(); - } else { - displayName = "AssignmentTypeDetailsPanel.containerTitle"; - } - } else if (prismContainerValue.canRepresent(ExclusionPolicyConstraintType.class)) { - ExclusionPolicyConstraintType exclusionConstraint = (ExclusionPolicyConstraintType) prismContainerValue.asContainerable(); - String exclusionConstraintName = (exclusionConstraint.getName() != null ? exclusionConstraint.getName() : - exclusionConstraint.asPrismContainerValue().getParent().getPath().last()) + " - " - + StringUtils.defaultIfEmpty(getName(exclusionConstraint.getTargetRef()), ""); - displayName = StringUtils.isNotEmpty(exclusionConstraintName) && StringUtils.isNotEmpty(getName(exclusionConstraint.getTargetRef())) ? exclusionConstraintName : "ExclusionPolicyConstraintType.details"; - } else if (prismContainerValue.canRepresent(AbstractPolicyConstraintType.class)) { - AbstractPolicyConstraintType constraint = (AbstractPolicyConstraintType) prismContainerValue.asContainerable(); - String constraintName = constraint.getName(); - if (StringUtils.isNotEmpty(constraintName)) { - displayName = constraintName; - } else { - displayName = constraint.asPrismContainerValue().getParent().getPath().last().toString() + ".details"; - } - } else if (prismContainerValue.canRepresent(RichHyperlinkType.class)) { - RichHyperlinkType richHyperlink = (RichHyperlinkType) prismContainerValue.asContainerable(); - String label = richHyperlink.getLabel(); - String description = richHyperlink.getDescription(); - String targetUrl = richHyperlink.getTargetUrl(); - if (StringUtils.isNotEmpty(label)) { - displayName = label + (StringUtils.isNotEmpty(description) ? (" - " + description) : ""); - } else if (StringUtils.isNotEmpty(targetUrl)) { - displayName = targetUrl; - } - } else if (prismContainerValue.canRepresent(UserInterfaceFeatureType.class)) { - UserInterfaceFeatureType userInterfaceFeature = (UserInterfaceFeatureType) prismContainerValue.asContainerable(); - String identifier = userInterfaceFeature.getIdentifier(); - - if (StringUtils.isBlank(identifier)) { - DisplayType uifDisplay = userInterfaceFeature.getDisplay(); - if (uifDisplay != null) { - displayName = WebComponentUtil.getOrigStringFromPoly(uifDisplay.getLabel()); - } - - if (displayName == null) { - displayName = "UserInterfaceFeatureType.containerTitle"; - } - } else { - displayName = identifier; - } - } else if (prismContainerValue.canRepresent(GuiObjectColumnType.class)) { - GuiObjectColumnType guiObjectColumn = (GuiObjectColumnType) prismContainerValue.asContainerable(); - String name = guiObjectColumn.getName(); - if (StringUtils.isNotEmpty(name)) { - displayName = name; - } - } else if (prismContainerValue.canRepresent(GuiObjectListViewType.class)) { - GuiObjectListViewType guiObjectListView = (GuiObjectListViewType) prismContainerValue.asContainerable(); - String name = guiObjectListView.getName(); - if (StringUtils.isNotEmpty(name)) { - displayName = name; - } - } else if (prismContainerValue.canRepresent(GenericPcpAspectConfigurationType.class)) { - GenericPcpAspectConfigurationType genericPcpAspectConfiguration = (GenericPcpAspectConfigurationType) prismContainerValue.asContainerable(); - String name = genericPcpAspectConfiguration.getName(); - if (StringUtils.isNotEmpty(name)) { - displayName = name; - } - } else if (prismContainerValue.canRepresent(RelationDefinitionType.class)) { - RelationDefinitionType relationDefinition = (RelationDefinitionType) prismContainerValue.asContainerable(); - if (relationDefinition.getRef() != null) { - String name = (relationDefinition.getRef().getLocalPart()); - String description = relationDefinition.getDescription(); - if (StringUtils.isNotEmpty(name)) { - displayName = name + (StringUtils.isNotEmpty(description) ? (" - " + description) : ""); - } - } - } else if (prismContainerValue.canRepresent(ResourceItemDefinitionType.class)) { - ResourceItemDefinitionType resourceItemDefinition = (ResourceItemDefinitionType) prismContainerValue.asContainerable(); - if (resourceItemDefinition.getDisplayName() != null && !resourceItemDefinition.getDisplayName().isEmpty()) { - displayName = resourceItemDefinition.getDisplayName(); - } else { - return prismContainerValue.getParent().getPath().last().toString(); - } - } else if (prismContainerValue.canRepresent(MappingType.class)) { - MappingType mapping = (MappingType) prismContainerValue.asContainerable(); - if (mapping.getName() != null && !mapping.getName().isEmpty()) { - String name = mapping.getName(); - String description = mapping.getDescription(); - displayName = name + (StringUtils.isNotEmpty(description) ? (" - " + description) : ""); - } - } else { - - Class cvalClass = prismContainerValue.getCompileTimeClass(); - if (cvalClass != null) { - displayName = cvalClass.getSimpleName() + ".details"; - } else { - displayName = "ContainerPanel.containerProperties"; - } - } - - - String escaped = org.apache.commons.lang.StringEscapeUtils.escapeHtml(displayName); - return escaped; - } - - public static QName normalizeRelation(QName relation) { - return getRelationRegistry().normalizeRelation(relation); - } - - public static String getDisplayNameOrName(PrismObject object) { - return getDisplayNameOrName(object, true); - } - - public static String getDisplayNameOrName(PrismObject object, boolean translate) { - return getDisplayNameOrName(object, translate, null); - } - - public static String getDisplayNameOrName(PrismObject object, boolean translate, LocalizationService localizationService) { - if (object == null) { - return null; - } - - String displayName = getDisplayName(object, translate, localizationService); - return displayName != null ? displayName : getName(object, translate, localizationService); - } - - public static String getDisplayNameOrName(ObjectReferenceType ref) { - return getDisplayNameOrName(ref, true); - } - - public static String getDisplayNameOrName(ObjectReferenceType ref, boolean translate) { - if (ref == null) { - return null; - } - String displayName = getDisplayName(ref, translate); - return StringUtils.isNotEmpty(displayName) ? displayName : getName(ref,translate); - } - - // () OR simply if there's no display name - public static String getDisplayNameAndName(ObjectReferenceType ref) { - return getDisplayNameOrName(ref, true); - } - - private static String getDisplayNameAndName(ObjectReferenceType ref, boolean translate) { - if (ref == null) { - return null; - } - String displayName = getDisplayName(ref, translate); - String name = getName(ref, translate); - return displayName != null ? displayName + " (" + name + ")" : name; - } - - public static String getDisplayName(ObjectReferenceType ref) { - return getDisplayName(ref, true); - } - - public static String getDisplayName(ObjectReferenceType ref, boolean translate) { - if (translate){ - return getTranslatedPolyString(ObjectTypeUtil.getDisplayName(ref)); - } else { - return PolyString.getOrig(ObjectTypeUtil.getDisplayName(ref)); - } - } - - public static String getDisplayName(PrismObject object) { - return getDisplayName(object, true); - } - - public static String getDisplayName(PrismObject object, boolean translate) { - return getDisplayName(object, translate, null); - } - - public static String getDisplayName(PrismObject object, boolean translate, LocalizationService localizationService) { - if (object == null){ - return ""; - } - if (translate){ - if (localizationService == null) { - return getTranslatedPolyString(ObjectTypeUtil.getDisplayName(object)); - } else { - return getTranslatedPolyString(PolyString.toPolyString(ObjectTypeUtil.getDisplayName(object)), localizationService); - } - } else { - return PolyString.getOrig(ObjectTypeUtil.getDisplayName(object)); - } - } - - public static PolyStringType createPolyFromOrigString(String str) { - if (str == null) { - return null; - } - - PolyStringType poly = new PolyStringType(); - poly.setOrig(str); - - return poly; - } - - public static String getOrigStringFromPoly(PolyString str) { - return str != null ? str.getOrig() : null; - } - - public static String getOrigStringFromPoly(PolyStringType str) { - return str != null ? str.getOrig() : null; - } - - public static T getValue(PrismContainerValue object, QName propertyName, Class type) { - if (object == null) { - return null; - } - - PrismProperty property = object.findProperty(ItemName.fromQName(propertyName)); - if (property == null || property.isEmpty()) { - return null; - } - - return (T) property.getRealValue(type); - } - - public static T getContainerValue(PrismContainerValue object, QName containerName, Class type) { - if (object == null) { - return null; - } - - PrismContainer container = object.findContainer(containerName); - if (container == null || container.isEmpty()) { - return null; - } - - PrismContainerValue containerValue = container.getValue(); - - if (containerValue == null || containerValue.isEmpty()) { - return null; - } - - return (T) containerValue.getValue(); - } - - public static T getValue(PrismContainer object, QName propertyName, Class type) { - if (object == null) { - return null; - } - - return getValue(object.getValue(), propertyName, type); - } - - public static Locale getLocaleFromString(String localeString) { - if (localeString == null) { - return null; - } - localeString = localeString.trim(); - if (localeString.toLowerCase().equals("default")) { - return Locale.getDefault(); - } - - // Extract language - int languageIndex = localeString.indexOf('_'); - String language = null; - if (languageIndex == -1) { - // No further "_" so is "{language}" only - return new Locale(localeString, ""); - } else { - language = localeString.substring(0, languageIndex); - } - - // Extract country - int countryIndex = localeString.indexOf('_', languageIndex + 1); - String country = null; - if (countryIndex == -1) { - // No further "_" so is "{language}_{country}" - country = localeString.substring(languageIndex + 1); - return new Locale(language, country); - } else { - // Assume all remaining is the variant so is - // "{language}_{country}_{variant}" - country = localeString.substring(languageIndex + 1, countryIndex); - String variant = localeString.substring(countryIndex + 1); - return new Locale(language, country, variant); - } - } - - public static void encryptCredentials(ObjectDelta delta, boolean encrypt, MidPointApplication app) { - if (delta == null || delta.isEmpty()) { - return; - } - - PropertyDelta propertyDelta = delta.findPropertyDelta(SchemaConstants.PATH_CREDENTIALS_PASSWORD_VALUE); - if (propertyDelta == null) { - return; - } - - Collection> values = propertyDelta - .getValues(ProtectedStringType.class); - for (PrismPropertyValue value : values) { - ProtectedStringType string = value.getValue(); - encryptProtectedString(string, encrypt, app); - } - } - - public static void encryptCredentials(PrismObject object, boolean encrypt, MidPointApplication app) { - PrismContainer password = object.findContainer(SchemaConstants.PATH_CREDENTIALS_PASSWORD); - if (password == null) { - return; - } - PrismProperty protectedStringProperty = password.findProperty(PasswordType.F_VALUE); - if (protectedStringProperty == null - || protectedStringProperty.getRealValue(ProtectedStringType.class) == null) { - return; - } - - ProtectedStringType string = (ProtectedStringType) protectedStringProperty - .getRealValue(ProtectedStringType.class); - - encryptProtectedString(string, encrypt, app); - } - - public static void encryptProtectedString(ProtectedStringType string, boolean encrypt, - MidPointApplication app) { - if (string == null) { - return; - } - Protector protector = app.getProtector(); - try { - if (encrypt) { - if (StringUtils.isEmpty(string.getClearValue())) { - return; - } - protector.encrypt(string); - } else { - if (string.getEncryptedDataType() == null) { - return; - } - protector.decrypt(string); - } - } catch (EncryptionException ex) { - LoggingUtils.logUnexpectedException(LOGGER, "Couldn't encrypt protected string", ex); - } catch (SchemaException e) { - LoggingUtils.logUnexpectedException(LOGGER, "Couldn't encrypt/decrypt protected string", e); - } - } - - public static List getSelectedData(Table table) { - DataTable dataTable = table.getDataTable(); - BaseSortableDataProvider provider = (BaseSortableDataProvider) dataTable.getDataProvider(); - - List selected = new ArrayList<>(); - for (T bean : provider.getAvailableData()) { - if (bean.isSelected()) { - selected.add(bean); - } - } - - return selected; - } - - public static void clearProviderCache(IDataProvider provider){ - if (provider == null){ - return; - } - if (provider instanceof BaseSortableDataProvider){ - ((BaseSortableDataProvider)provider).clearCache(); - } - if (provider instanceof SelectableBeanObjectDataProvider) { - ((SelectableBeanObjectDataProvider) provider).clearSelectedObjects(); - } - } - - public static Collection> createDeltaCollection( - ObjectDelta... deltas) { - Collection> collection = new ArrayList<>(); - for (ObjectDelta delta : deltas) { - collection.add(delta); - } - - return collection; - } - - public static boolean showResultInPage(OperationResult result) { - if (result == null) { - return false; - } - - return !result.isSuccess() && !result.isHandledError() && !result.isInProgress(); - } - - public static String formatDate(XMLGregorianCalendar calendar) { - if (calendar == null) { - return null; - } - - return formatDate(XmlTypeConverter.toDate(calendar)); - } - - public static String formatDate(Date date) { - return formatDate(null, date); - } - - public static String formatDate(String format, Date date) { - if (date == null) { - return null; - } - - if (StringUtils.isEmpty(format)) { - format = "EEEE, d. MMM yyyy HH:mm:ss"; - } - Locale locale = Session.get().getLocale(); - if (locale == null) { - locale = Locale.US; - } - SimpleDateFormat dateFormat = new SimpleDateFormat(format, locale); - return dateFormat.format(date); - } - - public static String getLocalizedDatePattern(String style) { - return DateTimeFormat.patternForStyle(style, getCurrentLocale()); - } - - public static Locale getCurrentLocale() { - Locale locale = Session.get().getLocale(); - if (locale == null) { - locale = Locale.getDefault(); - } - return locale; - } - - public static String getLocalizedDate(XMLGregorianCalendar date, String style) { - return getLocalizedDate(XmlTypeConverter.toDate(date), style); - } - - public static String getLocalizedDate(Date date, String style) { - if (date == null) { - return null; - } - PatternDateConverter converter = new PatternDateConverter(getLocalizedDatePattern(style), true); - return converter.convertToString(date, getCurrentLocale()); - } - - public static String getShortDateTimeFormattedValue(XMLGregorianCalendar date, PageBase pageBase) { - return getShortDateTimeFormattedValue(XmlTypeConverter.toDate(date), pageBase); - } - - public static String getShortDateTimeFormattedValue(Date date, PageBase pageBase) { - if (date == null) { - return ""; - } - String shortDateTimeFortam = getShortDateTimeFormat(pageBase); - return getLocalizedDate(date, shortDateTimeFortam); - } - - public static String getLongDateTimeFormattedValue(XMLGregorianCalendar date, PageBase pageBase) { - return getLongDateTimeFormattedValue(XmlTypeConverter.toDate(date), pageBase); - } - - public static String getLongDateTimeFormattedValue(Date date, PageBase pageBase) { - if (date == null) { - return ""; - } - String longDateTimeFormat = getLongDateTimeFormat(pageBase); - return getLocalizedDate(date, longDateTimeFormat); - } - - public static String getShortDateTimeFormat(PageBase pageBase){ - AdminGuiConfigurationDisplayFormatsType displayFormats = pageBase.getCompiledGuiProfile().getDisplayFormats(); - if (displayFormats == null || StringUtils.isEmpty(displayFormats.getShortDateTimeFormat())){ - return DateLabelComponent.SHORT_MEDIUM_STYLE; - } else { - return displayFormats.getShortDateTimeFormat(); - } - } - - public static String getLongDateTimeFormat(PageBase pageBase){ - AdminGuiConfigurationDisplayFormatsType displayFormats = pageBase.getCompiledGuiProfile().getDisplayFormats(); - if (displayFormats == null || StringUtils.isEmpty(displayFormats.getLongDateTimeFormat())){ - return DateLabelComponent.LONG_MEDIUM_STYLE; - } else { - return displayFormats.getLongDateTimeFormat(); - } - } - - public static boolean isActivationEnabled(PrismObject object) { - Validate.notNull(object); - - PrismContainer activation = object.findContainer(UserType.F_ACTIVATION); // this - // is - // equal - // to - // account - // activation... - if (activation == null) { - return false; - } - - ActivationStatusType status = (ActivationStatusType) activation - .getPropertyRealValue(ActivationType.F_ADMINISTRATIVE_STATUS, ActivationStatusType.class); - if (status == null) { - return false; - } - - // todo imrove with activation dates... - return ActivationStatusType.ENABLED.equals(status); - } - - public static boolean isSuccessOrHandledError(OperationResult result) { - if (result == null) { - return false; - } - - return result.isSuccess() || result.isHandledError(); - } - - public static boolean isSuccessOrHandledError(OperationResultType resultType) { - if (resultType == null) { - return false; - } - return resultType.getStatus() == OperationResultStatusType.SUCCESS || resultType.getStatus() == OperationResultStatusType.HANDLED_ERROR; - } - - public static boolean isSuccessOrHandledErrorOrWarning(OperationResult result) { - if (result == null) { - return false; - } - - return result.isSuccess() || result.isHandledError() || result.isWarning(); - } - - public static String createDefaultIcon(PrismObject object) { - Class type = object.getCompileTimeClass(); - if (type.equals(UserType.class)) { - return createUserIcon((PrismObject) object); - } else if (RoleType.class.equals(type)) { - return createRoleIcon((PrismObject) object); - } else if (OrgType.class.equals(type)) { - return createOrgIcon((PrismObject) object); - } else if (ServiceType.class.equals(type)) { - return createServiceIcon((PrismObject) object); - } else if (type.equals(TaskType.class)) { - return createTaskIcon((PrismObject) object); - } else if (type.equals(ResourceType.class)) { - return createResourceIcon((PrismObject) object); - } - - return ""; - } - - // TODO reconcile with ObjectTypeGuiDescriptor - public static String createDefaultColoredIcon(QName objectType) { - if (objectType == null) { - return ""; - } else if (QNameUtil.match(UserType.COMPLEX_TYPE, objectType) || QNameUtil.match(PersonaConstructionType.COMPLEX_TYPE, objectType)) { - return GuiStyleConstants.CLASS_OBJECT_USER_ICON_COLORED; - } else if (QNameUtil.match(RoleType.COMPLEX_TYPE, objectType)) { - return GuiStyleConstants.CLASS_OBJECT_ROLE_ICON_COLORED; - } else if (QNameUtil.match(OrgType.COMPLEX_TYPE, objectType)) { - return GuiStyleConstants.CLASS_OBJECT_ORG_ICON_COLORED; - } else if (QNameUtil.match(ServiceType.COMPLEX_TYPE, objectType)) { - return GuiStyleConstants.CLASS_OBJECT_SERVICE_ICON_COLORED; - } else if (QNameUtil.match(TaskType.COMPLEX_TYPE, objectType)) { - return GuiStyleConstants.CLASS_OBJECT_TASK_ICON_COLORED; - } else if (QNameUtil.match(ResourceType.COMPLEX_TYPE, objectType) || QNameUtil.match(ConstructionType.COMPLEX_TYPE, objectType)) { - return GuiStyleConstants.CLASS_OBJECT_RESOURCE_ICON_COLORED; - } else if (QNameUtil.match(AccessCertificationCampaignType.COMPLEX_TYPE, objectType)) { - return GuiStyleConstants.CLASS_OBJECT_CERT_CAMPAIGN_ICON_COLORED; - } else if (QNameUtil.match(AccessCertificationDefinitionType.COMPLEX_TYPE, objectType)) { - return GuiStyleConstants.CLASS_OBJECT_CERT_DEF_ICON_COLORED; - } else if (QNameUtil.match(CaseWorkItemType.COMPLEX_TYPE, objectType)) { - return GuiStyleConstants.CLASS_OBJECT_WORK_ITEM_ICON_COLORED; - } else if (QNameUtil.match(ShadowType.COMPLEX_TYPE, objectType)) { - return GuiStyleConstants.CLASS_OBJECT_SHADOW_ICON_COLORED; - } else if (QNameUtil.match(PolicyRuleType.COMPLEX_TYPE, objectType)) { - return GuiStyleConstants.CLASS_POLICY_RULES_ICON_COLORED; - } else if (QNameUtil.match(ObjectPolicyConfigurationType.COMPLEX_TYPE, objectType) || QNameUtil.match(GlobalPolicyRuleType.COMPLEX_TYPE, objectType) - || QNameUtil.match(FileAppenderConfigurationType.COMPLEX_TYPE, objectType) || QNameUtil.match(SyslogAppenderConfigurationType.COMPLEX_TYPE, objectType)) { - return GuiStyleConstants.CLASS_SYSTEM_CONFIGURATION_ICON_COLORED; - } else { - return ""; - } - } - - // TODO reconcile with ObjectTypeGuiDescriptor - public static String createDefaultBlackIcon(QName objectType) { - if (objectType == null) { - return ""; - } else if (QNameUtil.match(UserType.COMPLEX_TYPE, objectType) || QNameUtil.match(PersonaConstructionType.COMPLEX_TYPE, objectType)) { - return GuiStyleConstants.CLASS_OBJECT_USER_ICON; - } else if (QNameUtil.match(RoleType.COMPLEX_TYPE, objectType)) { - return GuiStyleConstants.CLASS_OBJECT_ROLE_ICON; - } else if (QNameUtil.match(OrgType.COMPLEX_TYPE, objectType)) { - return GuiStyleConstants.CLASS_OBJECT_ORG_ICON; - } else if (QNameUtil.match(ServiceType.COMPLEX_TYPE, objectType)) { - return GuiStyleConstants.CLASS_OBJECT_SERVICE_ICON; - } else if (QNameUtil.match(TaskType.COMPLEX_TYPE, objectType)) { - return GuiStyleConstants.CLASS_OBJECT_TASK_ICON; - } else if (QNameUtil.match(ResourceType.COMPLEX_TYPE, objectType) || QNameUtil.match(ConstructionType.COMPLEX_TYPE, objectType)) { - return GuiStyleConstants.CLASS_OBJECT_RESOURCE_ICON; - } else if (QNameUtil.match(AccessCertificationCampaignType.COMPLEX_TYPE, objectType)) { - return GuiStyleConstants.CLASS_OBJECT_CERT_CAMPAIGN_ICON; - } else if (QNameUtil.match(AccessCertificationDefinitionType.COMPLEX_TYPE, objectType)) { - return GuiStyleConstants.CLASS_OBJECT_CERT_DEF_ICON; - } else if (QNameUtil.match(CaseWorkItemType.COMPLEX_TYPE, objectType)) { - return GuiStyleConstants.CLASS_OBJECT_WORK_ITEM_ICON; - } else if (QNameUtil.match(ShadowType.COMPLEX_TYPE, objectType)) { - return GuiStyleConstants.CLASS_OBJECT_SHADOW_ICON; - } else if (QNameUtil.match(PolicyRuleType.COMPLEX_TYPE, objectType)) { - return GuiStyleConstants.CLASS_POLICY_RULES_ICON; - } else if (QNameUtil.match(SystemConfigurationType.COMPLEX_TYPE, objectType)) { - return GuiStyleConstants.CLASS_SYSTEM_CONFIGURATION_ICON; - } else if (QNameUtil.match(MappingType.COMPLEX_TYPE, objectType)) { - //TODO fix icon style for mapping type - return ""; - } else { - return ""; - } - } - - public static String getBoxCssClasses(QName objectType) { - if (QNameUtil.match(UserType.COMPLEX_TYPE, objectType)) { - return GuiStyleConstants.CLASS_OBJECT_USER_BOX_CSS_CLASSES; - } else if (QNameUtil.match(RoleType.COMPLEX_TYPE, objectType)) { - return GuiStyleConstants.CLASS_OBJECT_ROLE_BOX_CSS_CLASSES; - } else if (QNameUtil.match(OrgType.COMPLEX_TYPE, objectType)) { - return GuiStyleConstants.CLASS_OBJECT_ORG_BOX_CSS_CLASSES; - } else if (QNameUtil.match(ServiceType.COMPLEX_TYPE, objectType)) { - return GuiStyleConstants.CLASS_OBJECT_SERVICE_BOX_CSS_CLASSES; - } else if (QNameUtil.match(TaskType.COMPLEX_TYPE, objectType)) { - return GuiStyleConstants.CLASS_OBJECT_TASK_BOX_CSS_CLASSES; - } else if (QNameUtil.match(ResourceType.COMPLEX_TYPE, objectType)) { - return GuiStyleConstants.CLASS_OBJECT_RESOURCE_BOX_CSS_CLASSES; - } else { - return ""; - } - } - - public static String getBoxThinCssClasses(QName objectType) { - if (QNameUtil.match(UserType.COMPLEX_TYPE, objectType)) { - return GuiStyleConstants.CLASS_OBJECT_USER_BOX_THIN_CSS_CLASSES; - } else if (QNameUtil.match(RoleType.COMPLEX_TYPE, objectType)) { - return GuiStyleConstants.CLASS_OBJECT_ROLE_BOX_THIN_CSS_CLASSES; - } else if (QNameUtil.match(OrgType.COMPLEX_TYPE, objectType)) { - return GuiStyleConstants.CLASS_OBJECT_ORG_BOX_THIN_CSS_CLASSES; - } else if (QNameUtil.match(ServiceType.COMPLEX_TYPE, objectType)) { - return GuiStyleConstants.CLASS_OBJECT_SERVICE_BOX_THIN_CSS_CLASSES; - } else if (QNameUtil.match(TaskType.COMPLEX_TYPE, objectType)) { - return GuiStyleConstants.CLASS_OBJECT_TASK_BOX_THIN_CSS_CLASSES; - } else if (QNameUtil.match(ResourceType.COMPLEX_TYPE, objectType)) { - return GuiStyleConstants.CLASS_OBJECT_RESOURCE_BOX_THIN_CSS_CLASSES; - } else { - return ""; - } - } - - // can this implementation be made more efficient? [pm] - @SuppressWarnings("WeakerAccess") - public static boolean isOfKind(QName relation, RelationKindType kind) { - return getRelationRegistry().isOfKind(relation, kind); - } - - protected static RelationRegistry getRelationRegistry() { - if (staticallyProvidedRelationRegistry != null) { - return staticallyProvidedRelationRegistry; - } else { - return MidPointApplication.get().getRelationRegistry(); - } - } - - public static boolean isManagerRelation(QName relation) { - return isOfKind(relation, RelationKindType.MANAGER); - } - - public static boolean isDefaultRelation(QName relation) { - return getRelationRegistry().isDefault(relation); - } - - @SuppressWarnings("WeakerAccess") - public static QName getDefaultRelation() { - return getRelationRegistry().getDefaultRelation(); - } - - @NotNull - public static QName getDefaultRelationOrFail() { - QName relation = getDefaultRelation(); - if (relation != null) { - return relation; - } else { - throw new IllegalStateException("No default relation is defined"); - } - } - - @SuppressWarnings("WeakerAccess") - @Nullable - public static QName getDefaultRelationFor(RelationKindType kind) { - return getRelationRegistry().getDefaultRelationFor(kind); - } - - @NotNull - public static QName getDefaultRelationOrFail(RelationKindType kind) { - QName relation = getDefaultRelationFor(kind); - if (relation != null) { - return relation; - } else { - throw new IllegalStateException("No default relation for kind " + kind); - } - } - - @NotNull - public static String getRelationHeaderLabelKey(QName relation) { - String label = getRelationHeaderLabelKeyIfKnown(relation); - if (label != null) { - return label; - } else { - return relation != null ? relation.getLocalPart() : "default"; - } - } - - @Nullable - public static String getRelationHeaderLabelKeyIfKnown(QName relation) { - RelationDefinitionType definition = getRelationRegistry().getRelationDefinition(relation); - if (definition != null && definition.getDisplay() != null && definition.getDisplay().getLabel() != null) { - return definition.getDisplay().getLabel().getOrig(); - } else { - return null; - } - } - - public static String createUserIcon(PrismObject object) { - UserType user = object.asObjectable(); - - // if user has superuser role assigned, it's superuser - boolean isEndUser = false; - for (AssignmentType assignment : user.getAssignment()) { - ObjectReferenceType targetRef = assignment.getTargetRef(); - if (targetRef == null) { - continue; - } - if (StringUtils.equals(targetRef.getOid(), SystemObjectsType.ROLE_SUPERUSER.value())) { - return GuiStyleConstants.CLASS_OBJECT_USER_ICON + " " - + GuiStyleConstants.CLASS_ICON_STYLE_PRIVILEGED; - } - if (StringUtils.equals(targetRef.getOid(), SystemObjectsType.ROLE_END_USER.value())) { - isEndUser = true; - } - } - - boolean isManager = false; - for (ObjectReferenceType parentOrgRef : user.getParentOrgRef()) { - if (isManagerRelation(parentOrgRef.getRelation())) { - isManager = true; - break; - } - } - - String additionalStyle = ""; -// getIconEnabledDisabled(object); -// if (additionalStyle == null) { - // Set manager and end-user icon only as a last resort. All other - // colors have priority. - if (isManager) { - additionalStyle = GuiStyleConstants.CLASS_ICON_STYLE_MANAGER; - } else if (isEndUser) { - additionalStyle = GuiStyleConstants.CLASS_ICON_STYLE_END_USER; - } else { - additionalStyle = GuiStyleConstants.CLASS_ICON_STYLE_NORMAL; - } -// } - return GuiStyleConstants.CLASS_OBJECT_USER_ICON + " " + additionalStyle; - } - - public static String createRoleIcon(PrismObject object) { - for (AuthorizationType authorization : object.asObjectable().getAuthorization()) { - if (authorization.getAction().contains(AuthorizationConstants.AUTZ_ALL_URL)) { - return GuiStyleConstants.CLASS_OBJECT_ROLE_ICON + " " - + GuiStyleConstants.CLASS_ICON_STYLE_PRIVILEGED; - } - } - - return getObjectNormalIconStyle(GuiStyleConstants.CLASS_OBJECT_ROLE_ICON); - } - - public static String createOrgIcon(PrismObject object) { - return getObjectNormalIconStyle(GuiStyleConstants.CLASS_OBJECT_ORG_ICON); - } - - public static String createServiceIcon(PrismObject object) { - return getObjectNormalIconStyle(GuiStyleConstants.CLASS_OBJECT_SERVICE_ICON); - } - - private static String getObjectNormalIconStyle(String baseIcon){ - return baseIcon + " " + GuiStyleConstants.CLASS_ICON_STYLE_NORMAL; - } - - private static String getIconEnabledDisabled(PrismObject object, - String baseIcon) { - String additionalStyle = getIconEnabledDisabled(object); - if (additionalStyle == null) { - return baseIcon + " " + GuiStyleConstants.CLASS_ICON_STYLE_NORMAL; - } else { - return baseIcon + " " + additionalStyle; - } - } - - public static String getIconEnabledDisabled(PrismObject object) { - ActivationType activation = object.asObjectable().getActivation(); - if (activation != null) { - if (ActivationStatusType.DISABLED.equals(activation.getEffectiveStatus())) { - return GuiStyleConstants.CLASS_ICON_STYLE_DISABLED; - } else if (ActivationStatusType.ARCHIVED.equals(activation.getEffectiveStatus())) { - return GuiStyleConstants.CLASS_ICON_STYLE_ARCHIVED; - } - } - - return null; - } - - public static String createResourceIcon(PrismObject object) { - OperationalStateType operationalState = object.asObjectable().getOperationalState(); - if (operationalState != null) { - AvailabilityStatusType lastAvailabilityStatus = operationalState.getLastAvailabilityStatus(); - if (lastAvailabilityStatus == AvailabilityStatusType.UP) { - return GuiStyleConstants.CLASS_OBJECT_RESOURCE_ICON + " " - + GuiStyleConstants.CLASS_ICON_STYLE_UP; - } - if (lastAvailabilityStatus == AvailabilityStatusType.DOWN) { - return GuiStyleConstants.CLASS_OBJECT_RESOURCE_ICON + " " - + GuiStyleConstants.CLASS_ICON_STYLE_DOWN; - } - - if (lastAvailabilityStatus == AvailabilityStatusType.BROKEN) { - return GuiStyleConstants.CLASS_OBJECT_RESOURCE_ICON + " " - + GuiStyleConstants.CLASS_ICON_STYLE_BROKEN; - } - } - return GuiStyleConstants.CLASS_OBJECT_RESOURCE_ICON + " " + GuiStyleConstants.CLASS_ICON_STYLE_NORMAL; - } - - public static String createTaskIcon(PrismObject object) { - return GuiStyleConstants.CLASS_OBJECT_TASK_ICON + " " + GuiStyleConstants.CLASS_ICON_STYLE_NORMAL; - } - - public static String createShadowIcon(PrismContainerValue prismContainerValue) { - return createShadowIcon(((ShadowType)prismContainerValue.getRealValue()).asPrismContainer()); - } - - public static String createShadowIcon(PrismObject object) { - ShadowType shadow = object.asObjectable(); - - if (ShadowUtil.isProtected(object)) { - return GuiStyleConstants.CLASS_SHADOW_ICON_PROTECTED; - } - - ShadowKindType kind = shadow.getKind(); - if (kind == null) { - return GuiStyleConstants.CLASS_SHADOW_ICON_UNKNOWN; - } - - switch (kind) { - case ACCOUNT: - return GuiStyleConstants.CLASS_SHADOW_ICON_ACCOUNT; - case GENERIC: - return GuiStyleConstants.CLASS_SHADOW_ICON_GENERIC; - case ENTITLEMENT: - return GuiStyleConstants.CLASS_SHADOW_ICON_ENTITLEMENT; - - } - - return GuiStyleConstants.CLASS_SHADOW_ICON_UNKNOWN; - } - - public static void initNewObjectWithReference(PageBase pageBase, QName type, List newReferences) throws SchemaException { - PrismContext prismContext = pageBase.getPrismContext(); - PrismObjectDefinition def = prismContext.getSchemaRegistry().findObjectDefinitionByType(type); - PrismObject obj = def.instantiate(); - AHT assignmentHolder = obj.asObjectable(); - if (newReferences != null) { - newReferences.stream().forEach(ref -> { - AssignmentType assignment = new AssignmentType(); - assignment.setTargetRef(ref); - assignmentHolder.getAssignment().add(assignment); - - // Set parentOrgRef in any case. This is not strictly correct. - // The parentOrgRef should be added by the projector. But - // this is needed to successfully pass through security - // TODO: fix MID-3234 - if (ref.getType() != null && OrgType.COMPLEX_TYPE.equals(ref.getType())) { - assignmentHolder.getParentOrgRef().add(ref.clone()); - } - - }); - } - - WebComponentUtil.dispatchToObjectDetailsPage(obj, true, pageBase); - } - - public static String createErrorIcon(OperationResult result) { - if (result == null){ - return ""; - } - OperationResultStatus status = result.getStatus(); - OperationResultStatusPresentationProperties icon = OperationResultStatusPresentationProperties - .parseOperationalResultStatus(status); - return icon.getIcon() + " fa-lg"; - } - - public static void refreshFeedbacks(MarkupContainer component, final AjaxRequestTarget target) { - component.visitChildren(IFeedback.class, (IVisitor) (component1, visit) -> target.add(component1)); - } - - /* - * Methods used for providing prismContext into various objects. - */ - public static void revive(LoadableModel loadableModel, PrismContext prismContext) - throws SchemaException { - if (loadableModel != null) { - loadableModel.revive(prismContext); - } - } - - public static void reviveObject(Object object, PrismContext prismContext) throws SchemaException { - if (object == null) { - return; - } - if (object instanceof Collection) { - for (Object item : (Collection) object) { - reviveObject(item, prismContext); - } - } else if (object instanceof Revivable) { - ((Revivable) object).revive(prismContext); - } - } - - // useful for components other than those inheriting from PageBase - public static PrismContext getPrismContext(Component component) { - return ((MidPointApplication) component.getApplication()).getPrismContext(); - } - - - public static List getChannelList() { - List channels = new ArrayList<>(); - - for (Channel channel : Channel.values()) { - channels.add(channel.getChannel()); - } - - return channels; - } - - public static List getMatchingRuleList() { - List list = new ArrayList<>(); - - list.add(PrismConstants.DEFAULT_MATCHING_RULE_NAME); - list.add(PrismConstants.STRING_IGNORE_CASE_MATCHING_RULE_NAME); - list.add(PrismConstants.POLY_STRING_STRICT_MATCHING_RULE_NAME); - list.add(PrismConstants.POLY_STRING_ORIG_MATCHING_RULE_NAME); - list.add(PrismConstants.POLY_STRING_NORM_MATCHING_RULE_NAME); - list.add(PrismConstants.DISTINGUISHED_NAME_MATCHING_RULE_NAME); - list.add(PrismConstants.EXCHANGE_EMAIL_ADDRESSES_MATCHING_RULE_NAME); - list.add(PrismConstants.UUID_MATCHING_RULE_NAME); - list.add(PrismConstants.XML_MATCHING_RULE_NAME); - - return list; - } - - public static String createHumanReadableByteCount(long bytes) { - int unit = 1024; - if (bytes < unit) - return bytes + "B"; - int exp = (int) (Math.log(bytes) / Math.log(unit)); - char pre = "KMGTPE".charAt(exp - 1); - return String.format("%.1f%sB", bytes / Math.pow(unit, exp), pre); - } - - public static void setCurrentPage(Table table, ObjectPaging paging) { - if (table == null) { - return; - } - - if (paging == null) { - table.getDataTable().setCurrentPage(0); - return; - } - - long itemsPerPage = table.getDataTable().getItemsPerPage(); - long page = ((paging.getOffset() + itemsPerPage) / itemsPerPage) - 1; - if (page < 0) { - page = 0; - } - - table.getDataTable().setCurrentPage(page); - } - - public static PageBase getPageBase(Component component) { - Page page = component.getPage(); - if (page instanceof PageBase) { - return (PageBase) page; - } else if (page instanceof PageDialog) { - return ((PageDialog) page).getPageBase(); - } else { - throw new IllegalStateException("Couldn't determine page base for " + page); - } - } - - public static String debugHandler(IRequestHandler handler) { - if (handler == null) { - return null; - } - if (handler instanceof RenderPageRequestHandler) { - return "RenderPageRequestHandler(" + ((RenderPageRequestHandler) handler).getPageClass().getName() - + ")"; - } else { - return handler.toString(); - } - } - - // todo specify functionality of this method - public static ItemPath joinPath(ItemPath path1, ItemPath path2) { - ItemPath path = ItemPath.emptyIfNull(path1); - ItemPath deltaPath = ItemPath.emptyIfNull(path2); - List newPath = new ArrayList<>(); - - Object firstDeltaSegment = deltaPath.first(); - for (Object seg : path.getSegments()) { - if (ItemPath.segmentsEquivalent(seg, firstDeltaSegment)) { - break; - } - newPath.add(seg); - } - newPath.addAll(deltaPath.getSegments()); - - return ItemPath.create(newPath); - } - - public static T getObjectFromReference(ObjectReferenceType ref, Class type) { - if (ref == null || ref.asReferenceValue().getObject() == null) { - return null; - } - Objectable object = ref.asReferenceValue().getObject().asObjectable(); - if (!type.isAssignableFrom(object.getClass())) { - throw new IllegalStateException("Got " + object.getClass() + " when expected " + type + ": " - + ObjectTypeUtil.toShortString(ref, true)); - } - return (T) object; - } - - public static void dispatchToObjectDetailsPage(ObjectReferenceType objectRef, Component component, boolean failIfUnsupported) { - if (objectRef == null) { - return; // should not occur - } - Validate.notNull(objectRef.getOid(), "No OID in objectRef"); - Validate.notNull(objectRef.getType(), "No type in objectRef"); - Class targetClass = ObjectTypes.getObjectTypeFromTypeQName(objectRef.getType()).getClassDefinition(); - dispatchToObjectDetailsPage(targetClass, objectRef.getOid(), component, failIfUnsupported); - } - - public static void dispatchToObjectDetailsPage(PrismObject obj, Component component) { - dispatchToObjectDetailsPage(obj, false, component); - } - - // shows the actual object that is passed via parameter (not its state in repository) - public static void dispatchToObjectDetailsPage(PrismObject obj, boolean isNewObject, Component component) { - Class newObjectPageClass = isNewObject ? getNewlyCreatedObjectPage(obj.getCompileTimeClass()) : getObjectDetailsPage(obj.getCompileTimeClass()); - if (newObjectPageClass == null) { - throw new IllegalArgumentException("Cannot determine details page for "+obj.getCompileTimeClass()); - } - - Constructor constructor; - try { - PageBase page; - if (ResourceType.class.equals(obj.getCompileTimeClass())) { - constructor = newObjectPageClass.getConstructor(PageParameters.class); - page = (PageBase) constructor.newInstance(new PageParameters()); - } else { - constructor = newObjectPageClass.getConstructor(PrismObject.class, boolean.class); - page = (PageBase) constructor.newInstance(obj, isNewObject); - - } - if (component.getPage() instanceof PageBase) { - // this way we have correct breadcrumbs - PageBase pb = (PageBase) component.getPage(); - pb.navigateToNext(page); - } else { - component.setResponsePage(page); - } - } catch (NoSuchMethodException | SecurityException e) { - throw new SystemException("Unable to locate constructor (PrismObject) in " + newObjectPageClass - - + ": " + e.getMessage(), e); - } catch (InstantiationException | IllegalAccessException | IllegalArgumentException - | InvocationTargetException e) { - throw new SystemException("Error instantiating " + newObjectPageClass + ": " + e.getMessage(), e); - } - } - - public static void dispatchToObjectDetailsPage(Class objectClass, String oid, Component component, boolean failIfUnsupported) { - PageParameters parameters = new PageParameters(); - parameters.add(OnePageParameterEncoder.PARAMETER, oid); - Class page = getObjectDetailsPage(objectClass); - if (page != null) { - ((PageBase) component.getPage()).navigateToNext(page, parameters); - } else if (failIfUnsupported) { - throw new SystemException("Cannot determine details page for "+objectClass); - } - } - - public static boolean hasDetailsPage(PrismObject object) { - Class clazz = object.getCompileTimeClass(); - return hasDetailsPage(clazz); - } - - public static boolean hasDetailsPage(Class clazz) { - return objectDetailsPageMap.containsKey(clazz); - } - - public static boolean hasDetailsPage(ObjectReferenceType ref) { - if (ref == null) { - return false; - } - ObjectTypes t = ObjectTypes.getObjectTypeFromTypeQName(ref.getType()); - if (t == null) { - return false; - } - return hasDetailsPage(t.getClassDefinition()); - } - - public static String getStorageKeyForTableId(TableId tableId) { - return storageTableIdMap.get(tableId); - } - - public static Class getObjectDetailsPage(Class type) { - return objectDetailsPageMap.get(type); - } - - public static Class getNewlyCreatedObjectPage(Class type) { - if (ResourceType.class.equals(type)) { - return createNewObjectPageMap.get(type); - } else { - return objectDetailsPageMap.get(type); - } - } - - public static Class getObjectListPage(Class type) { - return objectListPageMap.get(type); - } - - @NotNull - public static TabbedPanel createTabPanel( - String id, final PageBase parentPage, final List tabs, TabbedPanel.RightSideItemProvider provider) { - return createTabPanel(id, parentPage, tabs, provider, null); - } - - @NotNull - public static TabbedPanel createTabPanel( - String id, final PageBase parentPage, final List tabs, TabbedPanel.RightSideItemProvider provider, - final String tabChangeParameter) { - - TabbedPanel tabPanel = new TabbedPanel(id, tabs, provider) { - private static final long serialVersionUID = 1L; - - @Override - protected void onTabChange(int index) { - if (tabChangeParameter != null) { - parentPage.updateBreadcrumbParameters(tabChangeParameter, index); - } - } - - @Override - protected WebMarkupContainer newLink(String linkId, final int index) { - return new AjaxSubmitLink(linkId) { - private static final long serialVersionUID = 1L; - - @Override - protected void onError(AjaxRequestTarget target) { - super.onError(target); - target.add(parentPage.getFeedbackPanel()); - } - - @Override - protected void onSubmit(AjaxRequestTarget target) { - super.onSubmit(target); - - setSelectedTab(index); - if (target != null) { - target.add(findParent(TabbedPanel.class)); - } - } - - }; - } - }; - tabPanel.setOutputMarkupId(true); - return tabPanel; - } - - public static Component createHelp(String id) { - Label helpLabel = new Label(id); - helpLabel.add(new InfoTooltipBehavior()); - return helpLabel; - } - - private static void debugDumpComponentTree(StringBuilder sb, Component c, int level) { - DebugUtil.indentDebugDump(sb, level); - sb.append(c).append("\n"); - if (c instanceof MarkupContainer) { - for (Component sub : (MarkupContainer) c) { - debugDumpComponentTree(sb, sub, level + 1); - } - } - } - - public static String exceptionToString(String message, Exception e) { - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - pw.println(message); - e.printStackTrace(pw); - pw.close(); - return sw.toString(); - } - - public static Behavior visibleIfFalse(final NonEmptyModel model) { - return new VisibleEnableBehaviour() { - private static final long serialVersionUID = 1L; - - @Override - public boolean isVisible() { - return !model.getObject(); - } - }; - } - - public static Behavior enabledIfFalse(final NonEmptyModel model) { - return new VisibleEnableBehaviour() { - private static final long serialVersionUID = 1L; - - @Override - public boolean isEnabled() { - return !model.getObject(); - } - }; - } - - public static String getStringParameter(PageParameters params, String key) { - if (params == null || params.get(key) == null) { - return null; - } - - StringValue value = params.get(key); - if (StringUtils.isBlank(value.toString())) { - return null; - } - - return value.toString(); - } - - public static Integer getIntegerParameter(PageParameters params, String key) { - if (params == null || params.get(key) == null) { - return null; - } - - StringValue value = params.get(key); - if (!StringUtils.isNumeric(value.toString())) { - return null; - } - - return value.toInteger(); - } - - public static boolean isSubscriptionIdCorrect(String subscriptionId){ - if (StringUtils.isEmpty(subscriptionId)) { - return false; - } - if (!NumberUtils.isDigits(subscriptionId)){ - return false; - } - if (subscriptionId.length() < 11){ - return false; - } - String subscriptionType = subscriptionId.substring(0, 2); - boolean isTypeCorrect = false; - for (SubscriptionType type : SubscriptionType.values()){ - if (type.getSubscriptionType().equals(subscriptionType)){ - isTypeCorrect = true; - break; - } - } - if (!isTypeCorrect){ - return false; - } - String substring1 = subscriptionId.substring(2, 4); - String substring2 = subscriptionId.substring(4, 6); - try { - if (Integer.parseInt(substring1) < 1 || Integer.parseInt(substring1) > 12) { - return false; - } - - SimpleDateFormat dateFormat = new SimpleDateFormat("yy"); - String currentYear = dateFormat.format(Calendar.getInstance().getTime()); - if (Integer.parseInt(substring2) < Integer.parseInt(currentYear)){ - return false; - } - - String expDateStr = subscriptionId.substring(2, 6); - dateFormat = new SimpleDateFormat("MMyy"); - Date expDate = dateFormat.parse(expDateStr); - Calendar expireCalendarValue = Calendar.getInstance(); - expireCalendarValue.setTime(expDate); - expireCalendarValue.add(Calendar.MONTH, 1); - Date currentDate = new Date(System.currentTimeMillis()); - if (expireCalendarValue.getTime().before(currentDate) || expireCalendarValue.getTime().equals(currentDate)) { - return false; - } - } catch (Exception ex) { - return false; - } - VerhoeffCheckDigit checkDigit = new VerhoeffCheckDigit(); - if (checkDigit.isValid(subscriptionId)){ - return true; - } - return false; - } - - public static void setSelectedTabFromPageParameters(TabbedPanel tabbed, PageParameters params, String paramName) { - IModel tabsModel = tabbed.getTabs(); - - Integer tabIndex = getIntegerParameter(params, paramName); - if (tabIndex == null || tabIndex < 0 || tabIndex >= tabsModel.getObject().size()) { - return; - } - - tabbed.setSelectedTab(tabIndex); - } - - public static boolean getElementVisibility(UserInterfaceElementVisibilityType visibilityType){ - return getElementVisibility(visibilityType, new ArrayList<>()); - } - - public static boolean getElementVisibility(UserInterfaceElementVisibilityType visibilityType, List requiredAuthorizations){ - if (UserInterfaceElementVisibilityType.HIDDEN.equals(visibilityType) || - UserInterfaceElementVisibilityType.VACANT.equals(visibilityType)){ - return false; - } - if (UserInterfaceElementVisibilityType.VISIBLE.equals(visibilityType)){ - return true; - } - if (UserInterfaceElementVisibilityType.AUTOMATIC.equals(visibilityType)){ - return WebComponentUtil.isAuthorized(requiredAuthorizations); - } - return true; - } - - public static IModel createAbstractRoleConfirmationMessage(String actionName, - ColumnMenuAction action, MainObjectListPanel abstractRoleTable, PageBase pageBase) { - List selectedRoles = new ArrayList<>(); - if (action.getRowModel() == null) { - selectedRoles.addAll(abstractRoleTable.getSelectedObjects()); - } else { - selectedRoles.add(((SelectableBeanImpl) action.getRowModel().getObject()).getValue()); - } - OperationResult result = new OperationResult("Search Members"); - boolean atLeastOneWithMembers = false; - for (AR selectedRole : selectedRoles) { - ObjectQuery query = pageBase.getPrismContext().queryFor(FocusType.class) - .item(FocusType.F_ROLE_MEMBERSHIP_REF)// TODO MID-3581 - .ref(ObjectTypeUtil.createObjectRef(selectedRole, pageBase.getPrismContext()).asReferenceValue()) - .maxSize(1) - .build(); - List> members = WebModelServiceUtils.searchObjects(FocusType.class, query, result, pageBase); - if (CollectionUtils.isNotEmpty(members)) { - atLeastOneWithMembers = true; - break; - } - } - String members = atLeastOneWithMembers ? ".members" : ""; - ObjectTypes objectType = ObjectTypes.getObjectType(abstractRoleTable.getType()); - String propertyKeyPrefix = ObjectTypes.SERVICE.equals(objectType) ? "pageServices" : "pageRoles"; - - if (action.getRowModel() == null) { - return pageBase.createStringResource(propertyKeyPrefix + ".message.confirmationMessageForMultipleObject" + members, - actionName, abstractRoleTable.getSelectedObjectsCount()); - } else { - return pageBase.createStringResource(propertyKeyPrefix + ".message.confirmationMessageForSingleObject" + members, - actionName, ((ObjectType)((SelectableBeanImpl)action.getRowModel().getObject()).getValue()).getName()); - } - } - - public static DisplayType getNewObjectDisplayTypeFromCollectionView(CompiledObjectCollectionView view, PageBase pageBase){ - DisplayType displayType = view != null ? view.getDisplay() : null; - if (displayType == null){ - displayType = WebComponentUtil.createDisplayType(GuiStyleConstants.CLASS_ADD_NEW_OBJECT, "green", ""); - } - if (PolyStringUtils.isEmpty(displayType.getTooltip()) && !PolyStringUtils.isEmpty(displayType.getLabel())){ - StringBuilder sb = new StringBuilder(); - sb.append(pageBase.createStringResource("MainObjectListPanel.newObject").getString()); - sb.append(" "); - sb.append(displayType.getLabel().getOrig().toLowerCase()); - displayType.setTooltip(WebComponentUtil.createPolyFromOrigString(sb.toString())); - } - return view != null ? view.getDisplay() : null; - } - - /** - * Returns name of the collection suitable to be displayed in the menu or other labels. - * E.g. "All tasks", "Active employees". - */ - public static PolyStringType getCollectionLabel(DisplayType viewDisplayType, CollectionRefSpecificationType collectionRefSpec ,ObjectType collectionRefTarget) { - if (viewDisplayType != null) { - PolyStringType viewPluralLabel = viewDisplayType.getPluralLabel(); - if (viewPluralLabel != null) { - return viewPluralLabel; - } - PolyStringType viewLabel = viewDisplayType.getLabel(); - if (viewLabel != null) { - return viewLabel; - } - } - if (collectionRefTarget != null) { - if (collectionRefTarget instanceof ObjectCollectionType) { - // MID-5709 - // TODO: use collectionRefTarget.getDisplay() first - when the schema is updated - } - // TODO: try to use archetype policy? - return collectionRefTarget.getName(); - } - return null; - } - - public static ItemVisibility checkShadowActivationAndPasswordVisibility(ItemWrapper itemWrapper, - ShadowType shadowType) { - ObjectReferenceType resourceRef = shadowType.getResourceRef(); - if (resourceRef == null) { - //TODO: what to return if we don't have resource available? - return ItemVisibility.AUTO; - } - PrismObject resource = resourceRef.asReferenceValue().getObject(); - if (resource == null) { - //TODO: what to return if we don't have resource available? - return ItemVisibility.AUTO; - } - ResourceType resourceType = resource.asObjectable(); - - CompositeRefinedObjectClassDefinition ocd = null; - - try { - RefinedResourceSchema resourceSchema = RefinedResourceSchema.getRefinedSchema(resource); - ocd = resourceSchema.determineCompositeObjectClassDefinition(shadowType.asPrismObject()); - } catch (SchemaException e) { - LOGGER.error("Cannot find refined definition for {} in {}", shadowType, resource); - } - ResourceObjectTypeDefinitionType resourceObjectTypeDefinitionType = ResourceTypeUtil.findObjectTypeDefinition(resource, shadowType.getKind(), shadowType.getIntent()); - - - if (SchemaConstants.PATH_ACTIVATION.equivalent(itemWrapper.getPath())) { - if (ResourceTypeUtil.isActivationCapabilityEnabled(resourceType, resourceObjectTypeDefinitionType)) { - return ItemVisibility.AUTO; - } else { - return ItemVisibility.HIDDEN; - } - } - - if (SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS.equivalent(itemWrapper.getPath())) { - if (ResourceTypeUtil.isActivationStatusCapabilityEnabled(resourceType, resourceObjectTypeDefinitionType)) { - return ItemVisibility.AUTO; - } else { - return ItemVisibility.HIDDEN; - } - } - - if (SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS.equivalent(itemWrapper.getPath())) { - if (ResourceTypeUtil.isActivationLockoutStatusCapabilityEnabled(resourceType, resourceObjectTypeDefinitionType)) { - return ItemVisibility.AUTO; - } else { - return ItemVisibility.HIDDEN; - } - } - - if (SchemaConstants.PATH_ACTIVATION_VALID_FROM.equivalent(itemWrapper.getPath())) { - if (ResourceTypeUtil.isActivationValidityFromCapabilityEnabled(resourceType, resourceObjectTypeDefinitionType)) { - return ItemVisibility.AUTO; - } else { - return ItemVisibility.HIDDEN; - } - } - - if (SchemaConstants.PATH_ACTIVATION_VALID_TO.equivalent(itemWrapper.getPath())) { - if (ResourceTypeUtil.isActivationValidityToCapabilityEnabled(resourceType, resourceObjectTypeDefinitionType)) { - return ItemVisibility.AUTO; - } else { - return ItemVisibility.HIDDEN; - } - } - - if (SchemaConstants.PATH_PASSWORD.equivalent(itemWrapper.getPath())) { - if (ResourceTypeUtil.isPasswordCapabilityEnabled(resourceType, resourceObjectTypeDefinitionType)) { - return ItemVisibility.AUTO; - } else { - return ItemVisibility.HIDDEN; - } - } - - if (ShadowType.F_ASSOCIATION.equivalent(itemWrapper.getPath())) { - if (ocd != null && CollectionUtils.isNotEmpty(ocd.getAssociationDefinitions())) { - return ItemVisibility.AUTO; - } else { - return ItemVisibility.HIDDEN; - } - } - - return ItemVisibility.AUTO; - - } - - public static boolean isActivationSupported(ShadowType shadowType) { - ObjectReferenceType resourceRef = shadowType.getResourceRef(); - if (resourceRef == null) { - //TODO: what to return if we don't have resource available? - return true; - } - PrismObject resource = resourceRef.asReferenceValue().getObject(); - if (resource == null) { - //TODO: what to return if we don't have resource available? - return true; - } - - ResourceObjectTypeDefinitionType resourceObjectTypeDefinitionType = ResourceTypeUtil.findObjectTypeDefinition(resource, shadowType.getKind(), shadowType.getIntent()); - - if (ResourceTypeUtil.isActivationCapabilityEnabled(resource.asObjectable(), resourceObjectTypeDefinitionType)) { - return true; - } - - return false; - - } - - public static boolean isPasswordSupported(ShadowType shadowType) { - ObjectReferenceType resourceRef = shadowType.getResourceRef(); - if (resourceRef == null) { - //TODO: what to return if we don't have resource available? - return true; - } - PrismObject resource = resourceRef.asReferenceValue().getObject(); - if (resource == null) { - //TODO: what to return if we don't have resource available? - return true; - } - - ResourceObjectTypeDefinitionType resourceObjectTypeDefinitionType = ResourceTypeUtil.findObjectTypeDefinition(resource, shadowType.getKind(), shadowType.getIntent()); - - if (ResourceTypeUtil.isPasswordCapabilityEnabled(resource.asObjectable(), resourceObjectTypeDefinitionType)) { - return true; - } - - return false; - - } - - - public static boolean isAssociationSupported(ShadowType shadowType) { - ObjectReferenceType resourceRef = shadowType.getResourceRef(); - if (resourceRef == null) { - //TODO: what to return if we don't have resource available? - return true; - } - PrismObject resource = resourceRef.asReferenceValue().getObject(); - if (resource == null) { - //TODO: what to return if we don't have resource available? - return true; - } - - CompositeRefinedObjectClassDefinition ocd = null; - - try { - RefinedResourceSchema resourceSchema = RefinedResourceSchema.getRefinedSchema(resource); - ocd = resourceSchema.determineCompositeObjectClassDefinition(shadowType.asPrismObject()); - } catch (SchemaException e) { - LOGGER.error("Cannot find refined definition for {} in {}", shadowType, resource); - } - - if (ocd == null) { - return false; - } - - return CollectionUtils.isNotEmpty(ocd.getAssociationDefinitions()); - } - - public static void refreshResourceSchema(@NotNull PrismObject resource, String operation, AjaxRequestTarget target, PageBase pageBase){ - Task task = pageBase.createSimpleTask(operation); - OperationResult parentResult = new OperationResult(operation); - - try { - ResourceUtils.deleteSchema(resource, pageBase.getModelService(), pageBase.getPrismContext(), task, parentResult); - pageBase.getModelService().testResource(resource.getOid(), task); // try to load fresh scehma - } catch (ObjectAlreadyExistsException | ObjectNotFoundException | SchemaException - | ExpressionEvaluationException | CommunicationException | ConfigurationException - | PolicyViolationException | SecurityViolationException e) { - LoggingUtils.logUnexpectedException(LOGGER, "Error refreshing resource schema", e); - parentResult.recordFatalError(pageBase.createStringResource("WebComponentUtil.message.refreshResourceSchema.fatalError").getString(), e); - } - - parentResult.computeStatus(); - pageBase.showResult(parentResult, "pageResource.refreshSchema.failed"); - target.add(pageBase.getFeedbackPanel()); - } - - public static List getCategoryRelationChoices(AreaCategoryType category, ModelServiceLocator pageBase){ - List relationsList = new ArrayList<>(); - List defList = getRelationDefinitions(pageBase); - defList.forEach(def -> { - if (def.getCategory() != null && def.getCategory().contains(category)) { - relationsList.add(def.getRef()); - } - }); - return relationsList; - } - - public static QName getCategoryDefaultRelation(AreaCategoryType category){ - if (AreaCategoryType.GOVERNANCE.equals(category)) { - return RelationTypes.APPROVER.getRelation(); - } - return null; - } - - public static List getAllRelations(ModelServiceLocator pageBase) { - List allRelationDefinitions = getRelationDefinitions(pageBase); - List allRelationsQName = new ArrayList<>(allRelationDefinitions.size()); - allRelationDefinitions.forEach(relation -> allRelationsQName.add(relation.getRef())); - return allRelationsQName; - } - - @NotNull - public static List getRelationDefinitions(ModelServiceLocator pageBase) { - return pageBase.getModelInteractionService().getRelationDefinitions(); - } - - public static RelationDefinitionType getRelationDefinition(QName relation) { - return getRelationRegistry().getRelationDefinition(relation); - } - - public static List prepareAutoCompleteList(LookupTableType lookupTable, String input, - LocalizationService localizationService){ - List values = new ArrayList<>(); - - if (lookupTable == null) { - return values; - } - - List rows = lookupTable.getRow(); - - if (input == null || input.isEmpty()) { - for (LookupTableRowType row : rows) { - - PolyString polystring = null; - if (row.getLabel() != null) { - polystring = setTranslateToPolystring(row); - } - values.add(localizationService.translate(polystring, getCurrentLocale(), true)); - } - } else { - for (LookupTableRowType row : rows) { - if (row.getLabel() == null) { - continue; - } - PolyString polystring = setTranslateToPolystring(row); - String rowLabel = localizationService.translate(polystring, getCurrentLocale(), true); - if (rowLabel != null && rowLabel.toLowerCase().contains(input.toLowerCase())) { - values.add(rowLabel); - } - } - } - return values; - } - - private static PolyString setTranslateToPolystring(LookupTableRowType row){ - PolyString polystring = row.getLabel().toPolyString(); - return setTranslateToPolystring(polystring); - } - - private static PolyString setTranslateToPolystring(PolyString polystring){ - if (org.apache.commons.lang3.StringUtils.isNotBlank(polystring.getOrig())) { - if (polystring.getTranslation() == null) { - PolyStringTranslationType translation = new PolyStringTranslationType(); - translation.setKey(polystring.getOrig()); - if (org.apache.commons.lang3.StringUtils.isBlank(translation.getFallback())) { - translation.setFallback(polystring.getOrig()); - } - polystring.setTranslation(translation); - } else if (org.apache.commons.lang3.StringUtils.isNotBlank(polystring.getTranslation().getKey())) { - polystring.getTranslation().setKey(polystring.getOrig()); - if (org.apache.commons.lang3.StringUtils.isBlank(polystring.getTranslation().getFallback())) { - polystring.getTranslation().setFallback(polystring.getOrig()); - } - } - } - return polystring; - } - - public static DropDownChoice createTriStateCombo(String id, IModel model) { - final IChoiceRenderer renderer = new IChoiceRenderer() { - - @Override - public Boolean getObject(String id, IModel> choices) { - return id != null ? choices.getObject().get(Integer.parseInt(id)) : null; - } - - @Override - public String getDisplayValue(Boolean object) { - String key; - if (object == null) { - key = KEY_BOOLEAN_NULL; - } else { - key = object ? KEY_BOOLEAN_TRUE : KEY_BOOLEAN_FALSE; - } - - StringResourceModel model = PageBase.createStringResourceStatic(null, key); - - return model.getString(); - } - - @Override - public String getIdValue(Boolean object, int index) { - return Integer.toString(index); - } - }; - - DropDownChoice dropDown = new DropDownChoice(id, model, createChoices(), renderer) { - - @Override - protected CharSequence getDefaultChoice(String selectedValue) { - StringResourceModel model = PageBase.createStringResourceStatic(null, KEY_BOOLEAN_NULL); - - return model.getString(); - } - }; - dropDown.setNullValid(true); - - return dropDown; - } - - public static boolean isAllNulls(Iterable array) { - return StreamSupport.stream(array.spliterator(), true).allMatch(o -> o == null); - } - - public static ObjectFilter createAssociationShadowRefFilter(RefinedAssociationDefinition refinedAssocationDefinition, PrismContext prismContext, - String resourceOid){ - S_FilterEntryOrEmpty atomicFilter = prismContext.queryFor(ShadowType.class); - List orFilterClauses = new ArrayList<>(); - refinedAssocationDefinition.getIntents() - .forEach(intent -> orFilterClauses.add(atomicFilter.item(ShadowType.F_INTENT).eq(intent).buildFilter())); - OrFilter intentFilter = prismContext.queryFactory().createOr(orFilterClauses); - - AndFilter filter = (AndFilter) atomicFilter.item(ShadowType.F_KIND).eq(refinedAssocationDefinition.getKind()).and() - .item(ShadowType.F_RESOURCE_REF).ref(resourceOid, ResourceType.COMPLEX_TYPE).buildFilter(); - filter.addCondition(intentFilter); - return filter; - } - - private static IModel> createChoices() { - return (IModel>) () -> { - List list = new ArrayList<>(); - list.add(null); - list.add(Boolean.TRUE); - list.add(Boolean.FALSE); - - return list; - }; - } - - private static LookupTableType createAppenderChoices(List appenders) { - LookupTableType lookupTable = new LookupTableType(); - List list = lookupTable.createRowList(); - - for (AppenderConfigurationType appender : appenders) { - LookupTableRowType row = new LookupTableRowType(); - String name = appender.getName(); - row.setKey(name); - row.setValue(name); - row.setLabel(new PolyStringType(name)); - list.add(row); - } - return lookupTable; - } - - public static Class getPreviousPageClass(PageBase parentPage){ - List breadcrumbs = parentPage.getBreadcrumbs(); - if (breadcrumbs == null || breadcrumbs.size() < 2){ - return null; - } - Breadcrumb previousBreadcrumb = breadcrumbs.get(breadcrumbs.size() - 2); - Class page = null; - if (previousBreadcrumb instanceof BreadcrumbPageClass){ - page = ((BreadcrumbPageClass) previousBreadcrumb).getPage(); - } else if (previousBreadcrumb instanceof BreadcrumbPageInstance){ - page = ((BreadcrumbPageInstance) previousBreadcrumb).getPage().getClass(); - } - return page; - } - - @NotNull - public static List createMenuItemsFromActions(@NotNull List actions, String operation, - PageBase pageBase, @NotNull Supplier> selectedObjectsSupplier) { - List menuItems = new ArrayList<>(); - actions.forEach(action -> { - if (action.getTaskTemplateRef() == null) { - return; - } - String templateOid = action.getTaskTemplateRef().getOid(); - if (StringUtils.isEmpty(templateOid)) { - return; - } - String label = action.getDisplay() != null && PolyStringUtils.isNotEmpty(action.getDisplay().getLabel()) ? - action.getDisplay().getLabel().getOrig() : action.getName(); - menuItems.add(new InlineMenuItem(Model.of(label)) { - private static final long serialVersionUID = 1L; - - @Override - public InlineMenuItemAction initAction() { - return new InlineMenuItemAction() { - private static final long serialVersionUID = 1L; - - @Override - public void onClick(AjaxRequestTarget target) { - OperationResult result = new OperationResult(operation); - try { - Collection oids = CollectionUtils.emptyIfNull(selectedObjectsSupplier.get()) - .stream() - .filter(o -> o.getOid() != null) - .map(o -> o.getOid()) - .collect(Collectors.toSet()); - if (!oids.isEmpty()) { - Map extensionValues = prepareExtensionValues(oids); - TaskType executorTask = pageBase.getModelInteractionService().submitTaskFromTemplate( - templateOid, extensionValues, pageBase.createSimpleTask(operation), result); - result.recordInProgress(); // this should be probably have been done in submitTaskFromTemplate - result.setBackgroundTaskOid(executorTask.getOid()); - } else { - result.recordWarning(pageBase.createStringResource("WebComponentUtil.message.createMenuItemsFromActions.warning").getString()); - } - } catch (Exception ex) { - result.recordFatalError(result.getOperation(), ex); - target.add(pageBase.getFeedbackPanel()); - } finally { - pageBase.showResult(result); - target.add(pageBase.getFeedbackPanel()); - } - } - }; - } - - /** - * Extension values are task-dependent. Therefore, in the future we will probably make - * this behaviour configurable. For the time being we assume that the task template will be - * of "iterative task handler" type and so it will expect mext:objectQuery extension property. - */ - - @NotNull - private Map prepareExtensionValues(Collection oids) throws SchemaException { - Map extensionValues = new HashMap<>(); - PrismContext prismContext = pageBase.getPrismContext(); - ObjectQuery objectQuery = prismContext.queryFor(ObjectType.class) - .id(oids.toArray(new String[0])) - .build(); - QueryType queryBean = pageBase.getQueryConverter().createQueryType(objectQuery); - extensionValues.put(SchemaConstants.MODEL_EXTENSION_OBJECT_QUERY, queryBean); - return extensionValues; - } - }); - }); - return menuItems; - } - - @SuppressWarnings("unused") - public static RelationRegistry getStaticallyProvidedRelationRegistry() { - return staticallyProvidedRelationRegistry; - } - - public static ObjectFilter getAssignableRolesFilter(PrismObject focusObject, Class type, AssignmentOrder assignmentOrder, - OperationResult result, Task task, PageBase pageBase) { - return getAssignableRolesFilter(focusObject, type, null, assignmentOrder, result, task, pageBase); - } - - public static ObjectFilter getAssignableRolesFilter(PrismObject focusObject, Class type, - QName relation, AssignmentOrder assignmentOrder, - OperationResult result, Task task, PageBase pageBase) { - ObjectFilter filter = null; - LOGGER.debug("Loading objects which can be assigned"); - try { - ModelInteractionService mis = pageBase.getModelInteractionService(); - RoleSelectionSpecification roleSpec = - mis.getAssignableRoleSpecification(focusObject, type, assignmentOrder.getOrder(), task, result); - filter = roleSpec.getGlobalFilter(); - if (relation != null){ - ObjectFilter relationFilter = roleSpec.getRelationFilter(relation); - if (filter == null){ - return relationFilter; - } else if (relationFilter == null){ - return filter; - } else { - return pageBase.getPrismContext().queryFactory().createOr(filter, relationFilter); - } - } - } catch (Exception ex) { - LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load available roles", ex); - result.recordFatalError(pageBase.createStringResource("WebComponentUtil.message.getAssignableRolesFilter.fatalError").getString(), ex); - } finally { - result.recomputeStatus(); - } - if (!result.isSuccess() && !result.isHandledError()) { - pageBase.showResult(result); - } - return filter; - } - - public static List getAssignableRelationsList(PrismObject focusObject, Class type, - AssignmentOrder assignmentOrder, - OperationResult result, Task task, PageBase pageBase){ - List relationsList = null; - LOGGER.debug("Loading assignable relations list"); - try { - ModelInteractionService mis = pageBase.getModelInteractionService(); - RoleSelectionSpecification roleSpec = - mis.getAssignableRoleSpecification(focusObject, type, assignmentOrder.getOrder(), task, result); - relationsList = roleSpec != null && roleSpec.getGlobalFilter() == null && roleSpec.getRelationMap() != null ? - new ArrayList(roleSpec.getRelationMap().keySet()) : null; - } catch (Exception ex) { - LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load assignable relations list", ex); - result.recordFatalError(pageBase.createStringResource("WebComponentUtil.message.getAssignableRelationsList.fatalError").getString(), ex); - } finally { - result.recomputeStatus(); - } - if (!result.isSuccess() && !result.isHandledError()) { - pageBase.showResult(result); - } - return relationsList; - } - - public static String formatDurationWordsForLocal(long durationMillis, boolean suppressLeadingZeroElements, - boolean suppressTrailingZeroElements, PageBase pageBase){ - - String duration = DurationFormatUtils.formatDurationWords(durationMillis, suppressLeadingZeroElements, suppressTrailingZeroElements); - - duration = StringUtils.replaceOnce(duration, "seconds", pageBase.createStringResource("WebComponentUtil.formatDurationWordsForLocal.seconds").getString()); - duration = StringUtils.replaceOnce(duration, "minutes", pageBase.createStringResource("WebComponentUtil.formatDurationWordsForLocal.minutes").getString()); - duration = StringUtils.replaceOnce(duration, "hours", pageBase.createStringResource("WebComponentUtil.formatDurationWordsForLocal.hours").getString()); - duration = StringUtils.replaceOnce(duration, "days", pageBase.createStringResource("WebComponentUtil.formatDurationWordsForLocal.days").getString()); - duration = StringUtils.replaceOnce(duration, "second", pageBase.createStringResource("WebComponentUtil.formatDurationWordsForLocal.second").getString()); - duration = StringUtils.replaceOnce(duration, "minute", pageBase.createStringResource("WebComponentUtil.formatDurationWordsForLocal.minute").getString()); - duration = StringUtils.replaceOnce(duration, "hour", pageBase.createStringResource("WebComponentUtil.formatDurationWordsForLocal.hour").getString()); - duration = StringUtils.replaceOnce(duration, "day", pageBase.createStringResource("WebComponentUtil.formatDurationWordsForLocal.day").getString()); - - return duration; - } - - public static List loadResourceObjectClassValues(ResourceType resource, PageBase pageBase){ - try { - ResourceSchema schema = RefinedResourceSchemaImpl.getResourceSchema(resource, pageBase.getPrismContext()); - if (schema != null) { - return schema.getObjectClassList(); - } - } catch (SchemaException|RuntimeException e){ - LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load object class list from resource.", e); - pageBase.error("Couldn't load object class list from resource."); - } - return new ArrayList<>(); - } - - public static List getRefinedAssociationDefinition(ResourceType resource, ShadowKindType kind, String intent){ - List associationDefinitions = new ArrayList<>(); - - try { - - if (resource == null) { - return associationDefinitions; - } - RefinedResourceSchema refinedResourceSchema = RefinedResourceSchema.getRefinedSchema(resource.asPrismObject()); - RefinedObjectClassDefinition oc = refinedResourceSchema.getRefinedDefinition(kind, intent); - if (oc == null) { - LOGGER.debug("Association for {}/{} not supported by resource {}", kind, intent, resource); - return associationDefinitions; - } - associationDefinitions.addAll(oc.getAssociationDefinitions()); - - if (CollectionUtils.isEmpty(associationDefinitions)) { - LOGGER.debug("Association for {}/{} not supported by resource {}", kind, intent, resource); - return associationDefinitions; - } - } catch (Exception ex) { - LOGGER.error("Association for {}/{} not supported by resource {}: {}", kind, intent, resource, ex.getLocalizedMessage()); - } - return associationDefinitions; - } - - public static String getAssociationDisplayName(RefinedAssociationDefinition assocDef) { - if (assocDef == null){ - return ""; - } - StringBuilder sb = new StringBuilder(); - if (assocDef.getDisplayName() != null) { - sb.append(assocDef.getDisplayName()).append(", "); - } - if (assocDef.getResourceObjectAssociationType() != null && assocDef.getResourceObjectAssociationType().getRef() != null) { - sb.append("ref: ").append(assocDef.getResourceObjectAssociationType().getRef().getItemPath().toString()); - } - return sb.toString(); - } - - @Deprecated - public static ExpressionType getAssociationExpression(PrismContainerValueWrapper assignmentValueWrapper, PageBase pageBase) { - return getAssociationExpression(assignmentValueWrapper, false, null, pageBase); - } - - //TODO refactor.. - @Deprecated - public static ExpressionType getAssociationExpression(PrismContainerValueWrapper assignmentValueWrapper, - boolean createIfNotExist, PrismContext prismContext, PageBase pageBase) { - if (assignmentValueWrapper == null){ - return null; - } - if (createIfNotExist && prismContext == null) { - throw new IllegalArgumentException("createIfNotExist is set but prismContext is null"); - } - PrismContainerWrapper association; - try { - association = assignmentValueWrapper - .findContainer(ItemPath.create(AssignmentType.F_CONSTRUCTION, ConstructionType.F_ASSOCIATION)); - } catch (SchemaException e) { - LOGGER.error("Cannot find association wrapper, reason: {}", e.getMessage(), e); - pageBase.getSession().error("Cannot find association wrapper, reason: " + e.getMessage()); - return null; - } - - if (association == null || association.getValues() == null || association.getValues().size() == 0){ - return null; - } - //FIXME HACK not to add empty association value - if (ContainerStatus.ADDING.equals(association.getStatus())){ - association.getItem().clear(); - } - PrismContainerValueWrapper associationValueWrapper = association.getValues().get(0); - PrismPropertyWrapper expressionWrapper; - try { - expressionWrapper = associationValueWrapper.findProperty(ItemPath.create(ResourceObjectAssociationType.F_OUTBOUND, MappingType.F_EXPRESSION)); - } catch (SchemaException e) { - LOGGER.error("Cannot find expression wrapper, reason: {}", e.getMessage(), e); - pageBase.getSession().error("Cannot find expression wrapper, reason: " + e.getMessage()); - return null; - } - - if (expressionWrapper == null){ - return null; - } - List> expressionValues = expressionWrapper.getValues(); - if (expressionValues == null || expressionValues.size() == 0){ - return null; - } - try { - ExpressionType expression = expressionValues.get(0).getRealValue(); - if (expression == null && createIfNotExist) { - expression = new ExpressionType(); - PrismPropertyValue exp = prismContext.itemFactory().createPropertyValue(expression); - WrapperContext context = new WrapperContext(null, null); - PrismPropertyValueWrapper val = (PrismPropertyValueWrapper) pageBase - .createValueWrapper(expressionWrapper, exp, ValueStatus.ADDED, context); - // ValueWrapperOld val = new - // ValueWrapperOld<>(expressionWrapper, exp, prismContext); - expressionValues.remove(0); - expressionValues.add(0, val); - } - } catch (SchemaException e) { - // TODO erro handling - return null; - } - return expressionValues.get(0).getRealValue(); - } - - public static PrismObject getConstructionResource(ConstructionType construction, String operation, PageBase pageBase){ - ObjectReferenceType resourceRef = construction.getResourceRef(); - if (resourceRef.asReferenceValue().getObject() != null) { - return resourceRef.asReferenceValue().getObject(); - } - OperationResult result = new OperationResult(operation); - Task task = pageBase.createSimpleTask(operation); - return WebModelServiceUtils.resolveReferenceNoFetch(resourceRef, pageBase, task, result); - } - - public static ArchetypePolicyType getArchetypeSpecification(PrismObject object, ModelServiceLocator locator){ - if (object == null || object.asObjectable() == null){ - return null; - } - String objectName = object.asObjectable().getName() != null ? object.asObjectable().getName().getOrig() : "Unknown"; - OperationResult result = new OperationResult("loadArchetypeSpecificationFor" + objectName); - if (!object.canRepresent(AssignmentHolderType.class)) { - return null; - } - ArchetypePolicyType spec = null; - try { - spec = locator.getModelInteractionService().determineArchetypePolicy((PrismObject) object, result); - } catch (SchemaException | ConfigurationException ex){ - result.recordPartialError(ex.getLocalizedMessage()); - LOGGER.error("Cannot load ArchetypeInteractionSpecification for object {}: {}", object, ex.getLocalizedMessage()); - } - return spec; - } - - public static String getIconCssClass(DisplayType displayType){ - if (displayType == null || displayType.getIcon() == null){ - return ""; - } - return displayType.getIcon().getCssClass(); - } - - public static String getIconColor(DisplayType displayType){ - if (displayType == null || displayType.getIcon() == null){ - return ""; - } - return displayType.getIcon().getColor(); - } - - public static String getDisplayTypeTitle(DisplayType displayType){ - if (displayType == null || displayType.getTooltip() == null){ - return ""; - } - return displayType.getTooltip().getOrig(); - } - - public static DisplayType getDisplayTypeForObject(O obj, OperationResult result, PageBase pageBase){ - if (obj == null){ - return null; - } - if (obj instanceof ArchetypeType && ((ArchetypeType)obj).getArchetypePolicy() != null) { - return ((ArchetypeType)obj).getArchetypePolicy().getDisplay(); - } - DisplayType displayType = WebComponentUtil.getArchetypePolicyDisplayType(obj, pageBase); -// if (displayType != null){ -// String disabledStyle = ""; -// if (obj instanceof FocusType) { -// disabledStyle = WebComponentUtil.getIconEnabledDisabled(((FocusType)obj).asPrismObject()); -// if (displayType.getIcon() != null && StringUtils.isNotEmpty(displayType.getIcon().getCssClass()) && -// disabledStyle != null){ -// displayType.getIcon().setCssClass(displayType.getIcon().getCssClass() + " " + disabledStyle); -// displayType.getIcon().setColor(""); -// } -// } -// } else { - if (displayType == null){ - displayType = WebComponentUtil.createDisplayType(createDefaultIcon(obj.asPrismObject()), - "", ColumnUtils.getIconColumnTitle(obj, result)); - } - return displayType; - } - - public static CompositedIcon createCompositeIconForObject(O obj, OperationResult result, PageBase pageBase){ - DisplayType basicIconDisplayType = getDisplayTypeForObject(obj, result, pageBase); - CompositedIconBuilder iconBuilder = new CompositedIconBuilder(); - if (basicIconDisplayType == null){ - return new CompositedIconBuilder().build(); - } - IconType lifecycleStateIcon = getIconForLifecycleState(obj); - IconType activationStatusIcon = getIconForActivationStatus(obj); - StringBuilder title = new StringBuilder(basicIconDisplayType.getTooltip() != null ? basicIconDisplayType.getTooltip().getOrig() : ""); - - if (StringUtils.isNotEmpty(lifecycleStateIcon.getCssClass())){ - if (title.length() > 0){ - title.append("\n"); - } - title.append(pageBase.createStringResource("ObjectType.lifecycleState").getString()) - .append(": ") - .append(obj.getLifecycleState()); - } - if (StringUtils.isNotEmpty(activationStatusIcon.getCssClass()) && obj instanceof FocusType - && ((FocusType)obj).getActivation() != null){ - if (title.length() > 0){ - title.append("\n"); - } - String lockedStatus = LockoutStatusType.LOCKED.equals(((FocusType)obj).getActivation().getLockoutStatus()) ? - ((FocusType)obj).getActivation().getLockoutStatus().value() : ""; - String effectiveStatus = ((FocusType)obj).getActivation().getEffectiveStatus() != null ? - ((FocusType)obj).getActivation().getEffectiveStatus().value() : ""; - title.append(pageBase.createStringResource("CapabilitiesType.activationStatus").getString()) - .append(": ") - .append(StringUtils.isNotEmpty(lockedStatus) ? lockedStatus : effectiveStatus); - } - String iconColor = getIconColor(basicIconDisplayType); - - CompositedIconBuilder builder = iconBuilder.setBasicIcon( - getIconCssClass(basicIconDisplayType), IconCssStyle.IN_ROW_STYLE) - .appendColorHtmlValue(StringUtils.isNotEmpty(iconColor) ? iconColor : "") - .appendLayerIcon(lifecycleStateIcon, IconCssStyle.BOTTOM_LEFT_FOR_COLUMN_STYLE) - .appendLayerIcon(activationStatusIcon, IconCssStyle.BOTTOM_RIGHT_FOR_COLUMN_STYLE); - - if (StringUtils.isNotEmpty(title.toString())){ - builder.setTitle(title.toString()); - } - return builder.build(); - } - - public static IconType getIconForLifecycleState(O obj){ - IconType icon = new IconType(); - if (obj == null){ - icon.setCssClass(""); - return icon; - } - if (SchemaConstants.LIFECYCLE_ARCHIVED.equals(obj.getLifecycleState())){ - icon.setCssClass(GuiStyleConstants.CLASS_FILE_EXCEL); - } else if (SchemaConstants.LIFECYCLE_DRAFT.equals(obj.getLifecycleState())){ - icon.setCssClass(GuiStyleConstants.CLASS_FILE_BLACK_FILLED); - } else if (SchemaConstants.LIFECYCLE_PROPOSED.equals(obj.getLifecycleState())){ - icon.setCssClass(GuiStyleConstants.CLASS_FILE_WHITE_FILLED); - } - if (icon.getCssClass() == null){ - icon.setCssClass(""); - } - icon.setColor("blue"); - return icon; - } - - public static IconType getIconForActivationStatus(O obj){ - IconType icon = new IconType(); - if (obj == null || !(obj instanceof FocusType) || ((FocusType) obj).getActivation() == null){ - icon.setCssClass(""); - return icon; - } - if (LockoutStatusType.LOCKED.equals(((FocusType) obj).getActivation().getLockoutStatus())){ - icon.setCssClass(GuiStyleConstants.CLASS_LOCK_STATUS); - } else if (ActivationStatusType.DISABLED.equals(((FocusType) obj).getActivation().getEffectiveStatus())){ - icon.setCssClass(GuiStyleConstants.CLASS_BAN); - } else if (ActivationStatusType.ARCHIVED.equals(((FocusType) obj).getActivation().getEffectiveStatus())){ - icon.setCssClass(GuiStyleConstants.CLASS_ICON_NO_OBJECTS); - } else if (!ActivationStatusType.ENABLED.equals(((FocusType) obj).getActivation().getEffectiveStatus())){ - icon.setCssClass(GuiStyleConstants.CLASS_TEST_CONNECTION_MENU_ITEM); - } - if (icon.getCssClass() == null){ - icon.setCssClass(""); - } - icon.setColor("red"); - return icon; - } - - public static DisplayType createDisplayType(String iconCssClass){ - return createDisplayType(iconCssClass, "", ""); - } - - public static DisplayType createDisplayType(String iconCssClass, String iconColor, String title){ - DisplayType displayType = new DisplayType(); - IconType icon = new IconType(); - icon.setCssClass(iconCssClass); - icon.setColor(iconColor); - displayType.setIcon(icon); - - displayType.setTooltip(createPolyFromOrigString(title)); - return displayType; - } - - public static DisplayType createDisplayType(String iconCssClass, PolyStringType title){ - DisplayType displayType = new DisplayType(); - IconType icon = new IconType(); - icon.setCssClass(iconCssClass); - displayType.setIcon(icon); - - displayType.setTooltip(title); - return displayType; - } - - public static IconType createIconType(String iconStyle){ - return createIconType(iconStyle, ""); - } - - public static IconType createIconType(String iconStyle, String color){ - IconType icon = new IconType(); - icon.setCssClass(iconStyle); - icon.setColor(color); - return icon; - } - - - public static CompositedIconBuilder getAssignmentRelationIconBuilder(PageBase pageBase, AssignmentObjectRelation relationSpec, - IconType relationIcon, IconType actionButtonIcon){ - CompositedIconBuilder builder = new CompositedIconBuilder(); - if (relationSpec == null){ - if (actionButtonIcon == null){ - return null; - } - builder.setBasicIcon(actionButtonIcon, IconCssStyle.IN_ROW_STYLE) - .appendColorHtmlValue(actionButtonIcon.getColor()); - return builder; - } - DisplayType objectTypeDisplay = null; - if (CollectionUtils.isNotEmpty(relationSpec.getArchetypeRefs())){ - try { - String operation = pageBase.getClass().getSimpleName() + "." + "loadArchetypeObject"; - ArchetypeType archetype = pageBase.getModelObjectResolver().resolve(relationSpec.getArchetypeRefs().get(0), ArchetypeType.class, - null, null, pageBase.createSimpleTask(operation), - new OperationResult(operation)); - if (archetype != null && archetype.getArchetypePolicy() != null){ - objectTypeDisplay = archetype.getArchetypePolicy().getDisplay(); - } - } catch (Exception ex){ - LOGGER.error("Couldn't load archetype object, " + ex.getLocalizedMessage()); - } - } - if (objectTypeDisplay == null){ - objectTypeDisplay = new DisplayType(); - } - if (objectTypeDisplay.getIcon() == null){ - objectTypeDisplay.setIcon(new IconType()); - } - QName objectType = org.apache.commons.collections.CollectionUtils.isNotEmpty(relationSpec.getObjectTypes()) ? relationSpec.getObjectTypes().get(0) : null; - if (StringUtils.isEmpty(WebComponentUtil.getIconCssClass(objectTypeDisplay)) && objectType != null){ - objectTypeDisplay.getIcon().setCssClass(WebComponentUtil.createDefaultBlackIcon(objectType)); - } - if (StringUtils.isNotEmpty(WebComponentUtil.getIconCssClass(objectTypeDisplay))) { - builder.setBasicIcon(objectTypeDisplay.getIcon(), IconCssStyle.IN_ROW_STYLE) - .appendColorHtmlValue(WebComponentUtil.getIconColor(objectTypeDisplay)) - .appendLayerIcon(actionButtonIcon, IconCssStyle.BOTTOM_RIGHT_STYLE) - .appendLayerIcon(relationIcon, IconCssStyle.TOP_RIGHT_STYLE); - } else { - builder.setBasicIcon(actionButtonIcon, IconCssStyle.IN_ROW_STYLE) - .appendColorHtmlValue(actionButtonIcon.getColor()); - } - return builder; - } - - - public static DisplayType getArchetypePolicyDisplayType(O object, PageBase pageBase) { - if (object != null) { - ArchetypePolicyType archetypePolicy = WebComponentUtil.getArchetypeSpecification(object.asPrismObject(), pageBase); - if (archetypePolicy != null) { - return archetypePolicy.getDisplay(); - } - } - return null; - } - - public static IModel getIconUrlModel(IconType icon){ - if (icon == null || StringUtils.isEmpty(icon.getImageUrl())){ - return Model.of(); - } - String sUrl = icon.getImageUrl(); - if (URI.create(sUrl).isAbsolute()) { - return Model.of(sUrl); - } - - List segments = RequestCycle.get().getUrlRenderer().getBaseUrl().getSegments(); - if (segments == null || segments.size() < 2) { - return Model.of(sUrl); - } - - String prefix = StringUtils.repeat("../", segments.size() - 1); - if (!sUrl.startsWith("/")) { - return Model.of(prefix + sUrl); - } - - return Model.of(StringUtils.left(prefix, prefix.length() - 1) + sUrl); - } - - public static void deleteSyncTokenPerformed(AjaxRequestTarget target, ResourceType resourceType, PageBase pageBase){ - String resourceOid = resourceType.getOid(); - String handlerUri = "http://midpoint.evolveum.com/xml/ns/public/model/synchronization/task/live-sync/handler-3"; - ObjectReferenceType resourceRef = new ObjectReferenceType(); - resourceRef.setOid(resourceOid); - PrismObject oldTask; - - OperationResult result = new OperationResult(pageBase.getClass().getName() + "." + "deleteSyncToken"); - ObjectQuery query = pageBase.getPrismContext().queryFor(TaskType.class) - .item(TaskType.F_OBJECT_REF).ref(resourceOid) - .and().item(TaskType.F_HANDLER_URI).eq(handlerUri) - .build(); - - List> taskList = WebModelServiceUtils.searchObjects(TaskType.class, query, result, pageBase); - - if (taskList.size() != 1) { - pageBase.error(pageBase.createStringResource("pageResource.message.invalidTaskSearch")); - } else { - oldTask = taskList.get(0); - saveTask(oldTask, result, pageBase); - } - - result.recomputeStatus(); - pageBase.showResult(result); - target.add(pageBase.getFeedbackPanel()); - } - - /** - * The idea is to divide the list of AssignmentObjectRelation objects in such way that each AssignmentObjectRelation - * in the list will contain not more than 1 relation. This will simplify creating of a new_assignment_button - * on some panels - * - * @param initialRelationsList - * @return - */ - public static List divideAssignmentRelationsByRelationValue(List initialRelationsList){ - if (org.apache.commons.collections.CollectionUtils.isEmpty(initialRelationsList)){ - return initialRelationsList; - } - List combinedRelationList = new ArrayList<>(); - initialRelationsList.forEach(assignmentTargetRelation -> { - if (org.apache.commons.collections.CollectionUtils.isEmpty(assignmentTargetRelation.getObjectTypes()) && - org.apache.commons.collections.CollectionUtils.isEmpty(assignmentTargetRelation.getRelations())){ - return; - } - if (org.apache.commons.collections.CollectionUtils.isEmpty(assignmentTargetRelation.getRelations())){ - combinedRelationList.add(assignmentTargetRelation); - } else { - assignmentTargetRelation.getRelations().forEach(relation -> { - AssignmentObjectRelation relationObj = new AssignmentObjectRelation(); - relationObj.setObjectTypes(assignmentTargetRelation.getObjectTypes()); - relationObj.setRelations(Arrays.asList(relation)); - relationObj.setArchetypeRefs(assignmentTargetRelation.getArchetypeRefs()); - relationObj.setDescription(assignmentTargetRelation.getDescription()); - combinedRelationList.add(relationObj); - }); - } - }); - return combinedRelationList; - } - - /** - * The idea is to divide the list of AssignmentObjectRelation objects in such way that each AssignmentObjectRelation - * in the list will contain not more than 1 relation, not more than 1 object type and not more than one archetype reference. - * This will simplify creating of a new_assignment_button - * - * @param initialAssignmentRelationsList - * @return - */ - public static List divideAssignmentRelationsByAllValues(List initialAssignmentRelationsList){ - if (initialAssignmentRelationsList == null){ - return null; - } - List dividedByRelationList = divideAssignmentRelationsByRelationValue(initialAssignmentRelationsList); - List resultList = new ArrayList<>(); - dividedByRelationList.forEach(assignmentObjectRelation -> { - if (CollectionUtils.isNotEmpty(assignmentObjectRelation.getObjectTypes())){ - assignmentObjectRelation.getObjectTypes().forEach(objectType -> { - if (CollectionUtils.isNotEmpty(assignmentObjectRelation.getArchetypeRefs())){ - assignmentObjectRelation.getArchetypeRefs().forEach(archetypeRef -> { - AssignmentObjectRelation newRelation = new AssignmentObjectRelation(); - newRelation.setObjectTypes(Arrays.asList(objectType)); - newRelation.setRelations(assignmentObjectRelation.getRelations()); - newRelation.setArchetypeRefs(Arrays.asList(archetypeRef)); - newRelation.setDescription(assignmentObjectRelation.getDescription()); - resultList.add(newRelation); - }); - } else { - AssignmentObjectRelation newRelation = new AssignmentObjectRelation(); - newRelation.setObjectTypes(Arrays.asList(objectType)); - newRelation.setRelations(assignmentObjectRelation.getRelations()); - newRelation.setArchetypeRefs(assignmentObjectRelation.getArchetypeRefs()); - newRelation.setDescription(assignmentObjectRelation.getDescription()); - resultList.add(newRelation); - } - }); - } else { - if (CollectionUtils.isNotEmpty(assignmentObjectRelation.getArchetypeRefs())){ - assignmentObjectRelation.getArchetypeRefs().forEach(archetypeRef -> { - AssignmentObjectRelation newRelation = new AssignmentObjectRelation(); - newRelation.setObjectTypes(assignmentObjectRelation.getObjectTypes()); - newRelation.setRelations(assignmentObjectRelation.getRelations()); - newRelation.setArchetypeRefs(Arrays.asList(archetypeRef)); - newRelation.setDescription(assignmentObjectRelation.getDescription()); - resultList.add(newRelation); - }); - } else { - AssignmentObjectRelation newRelation = new AssignmentObjectRelation(); - newRelation.setObjectTypes(assignmentObjectRelation.getObjectTypes()); - newRelation.setRelations(assignmentObjectRelation.getRelations()); - newRelation.setArchetypeRefs(assignmentObjectRelation.getArchetypeRefs()); - newRelation.setDescription(assignmentObjectRelation.getDescription()); - resultList.add(newRelation); - } - } - }); - return resultList; - } - - public static DisplayType getAssignmentObjectRelationDisplayType(PageBase pageBase, AssignmentObjectRelation assignmentTargetRelation, - String defaultTitleKey){ - if (assignmentTargetRelation == null){ - return createDisplayType("", "", pageBase.createStringResource(defaultTitleKey, "", "").getString()); - } - - String typeTitle = ""; - if (CollectionUtils.isNotEmpty(assignmentTargetRelation.getArchetypeRefs())){ - OperationResult result = new OperationResult(pageBase.getClass().getSimpleName() + "." + "loadArchetypeObject"); - try { - ArchetypeType archetype = pageBase.getModelObjectResolver().resolve(assignmentTargetRelation.getArchetypeRefs().get(0), ArchetypeType.class, - null, null, pageBase.createSimpleTask(result.getOperation()), result); - if (archetype != null) { - DisplayType archetypeDisplayType = archetype.getArchetypePolicy() != null ? archetype.getArchetypePolicy().getDisplay() : null; - String archetypeTooltip = archetypeDisplayType != null && archetypeDisplayType.getLabel() != null && - StringUtils.isNotEmpty(archetypeDisplayType.getLabel().getOrig()) ? - archetypeDisplayType.getLabel().getOrig() : - (archetype.getName() != null && StringUtils.isNotEmpty(archetype.getName().getOrig()) ? - archetype.getName().getOrig() : null); - typeTitle = StringUtils.isNotEmpty(archetypeTooltip) ? - pageBase.createStringResource("abstractRoleMemberPanel.withType", archetypeTooltip).getString() : ""; - } - } catch (Exception ex){ - LOGGER.error("Couldn't load archetype object. " + ex.getLocalizedMessage()); - } - } else if (CollectionUtils.isNotEmpty(assignmentTargetRelation.getObjectTypes())){ - QName type = !CollectionUtils.isEmpty(assignmentTargetRelation.getObjectTypes()) ? - assignmentTargetRelation.getObjectTypes().get(0) : null; - String typeName = type != null ? pageBase.createStringResource("ObjectTypeLowercase." + type.getLocalPart()).getString() : null; - typeTitle = StringUtils.isNotEmpty(typeName) ? - pageBase.createStringResource("abstractRoleMemberPanel.withType", typeName).getString() : ""; - } - - - QName relation = !CollectionUtils.isEmpty(assignmentTargetRelation.getRelations()) ? - assignmentTargetRelation.getRelations().get(0) : null; - - String relationValue = ""; - String relationTitle = ""; - if (relation != null){ - RelationDefinitionType def = WebComponentUtil.getRelationDefinition(relation); - if (def != null){ - DisplayType displayType = null; - if (def.getDisplay() == null){ - displayType = new DisplayType(); - } else { - displayType = createDisplayType(def.getDisplay().getCssClass()); - if (def.getDisplay().getIcon() != null){ - displayType.setIcon(new IconType()); - displayType.getIcon().setCssClass(def.getDisplay().getIcon().getCssClass()); - displayType.getIcon().setColor(def.getDisplay().getIcon().getColor()); - } - } - if (displayType.getLabel() != null && StringUtils.isNotEmpty(displayType.getLabel().getOrig())){ - relationValue = pageBase.createStringResource(displayType.getLabel().getOrig()).getString(); - } else { - String relationKey = "RelationTypes." + RelationTypes.getRelationTypeByRelationValue(relation); - relationValue = pageBase.createStringResource(relationValue).getString(); - if (StringUtils.isEmpty(relationValue) || relationKey.equals(relationValue)){ - relationValue = relation.getLocalPart(); - } - } - - relationTitle = pageBase.createStringResource("abstractRoleMemberPanel.withRelation", relationValue).getString(); - - - if (displayType.getIcon() == null || StringUtils.isEmpty(displayType.getIcon().getCssClass())){ - displayType.setIcon(createIconType("")); - } - displayType.setTooltip(createPolyFromOrigString(pageBase.createStringResource(defaultTitleKey, typeTitle, relationTitle).getString())); - return displayType; - } - } - return createDisplayType(GuiStyleConstants.EVO_ASSIGNMENT_ICON, "green", pageBase.createStringResource(defaultTitleKey, typeTitle, relationTitle).getString()); - } - - public static void saveTask(PrismObject oldTask, OperationResult result, PageBase pageBase){ - Task task = pageBase.createSimpleTask(pageBase.getClass().getName() + "." + "saveSyncTask"); - - PrismProperty property = oldTask.findProperty(ItemPath.create(TaskType.F_EXTENSION, SchemaConstants.SYNC_TOKEN)); - - if(property == null){ - return; - } - Object value = property.getRealValue(); - - ObjectDelta delta = pageBase.getPrismContext().deltaFactory().object().createModifyDelta(oldTask.getOid(), - pageBase.getPrismContext().deltaFactory().property() - .createModificationDeleteProperty(ItemPath.create(TaskType.F_EXTENSION, SchemaConstants.SYNC_TOKEN), property.getDefinition(), value), - TaskType.class); - - if(LOGGER.isTraceEnabled()){ - LOGGER.trace(delta.debugDump()); - } - - try { - pageBase.getModelService().executeChanges(WebComponentUtil.createDeltaCollection(delta), null, task, result); - } catch (Exception e){ - LoggingUtils.logUnexpectedException(LOGGER, "Couldn't save task.", e); - result.recordFatalError(pageBase.createStringResource("WebModelUtils.couldntSaveTask").getString(), e); - } - result.recomputeStatus(); - } - - // TODO: use LocalizationService.translate(polyString) instead - @Deprecated - public static String getLocalizedOrOriginPolyStringValue(PolyString polyString){ - String value = getLocalizedPolyStringValue(setTranslateToPolystring(polyString)); - if(value == null) { - return getOrigStringFromPoly(polyString); - } - return value; - } - - @Deprecated - private static String getLocalizedPolyStringValue(PolyString polyString){ - if (polyString == null){ - return null; - } - if ((polyString.getTranslation() == null || StringUtils.isEmpty(polyString.getTranslation().getKey())) && - (polyString.getLang() == null || polyString.getLang().isEmpty())){ - return null; - } - if (polyString.getLang() != null && !polyString.getLang().isEmpty()){ - //check if it's really selected by user or configured through sysconfig locale - String currentLocale = getCurrentLocale().getLanguage(); - for (String language : polyString.getLang().keySet()){ - if (currentLocale.equals(language)){ - return polyString.getLang().get(language); - } - } - } - - if (polyString.getTranslation() != null && StringUtils.isNotEmpty(polyString.getTranslation().getKey())){ - List argumentValues = new ArrayList<>(); - polyString.getTranslation().getArgument().forEach(argument -> { - String argumentValue = ""; - String translationValue = ""; - if (argument.getTranslation() != null){ - String argumentKey = argument.getTranslation().getKey(); - String valueByKey = StringUtils.isNotEmpty(argumentKey) ? new StringResourceModel(argumentKey).getString() : null; - translationValue = StringUtils.isNotEmpty(valueByKey) ? valueByKey : argument.getTranslation().getFallback(); - } - argumentValue = StringUtils.isNotEmpty(translationValue) ? translationValue : argument.getValue(); - argumentValues.add(argumentValue); - }); - return new StringResourceModel(polyString.getTranslation().getKey()) - .setDefaultValue(polyString.getTranslation().getKey()) - .setModel(new Model()) - .setParameters(argumentValues.toArray()) - .getString(); - } - return null; - } - - public static List sortDropDownChoices(IModel> choicesModel, IChoiceRenderer renderer){ - List sortedList = choicesModel.getObject().stream().sorted((choice1, choice2) -> { - if (choice1 == null || choice2 == null){ - return 0; - } - return String.CASE_INSENSITIVE_ORDER.compare(renderer.getDisplayValue(choice1).toString(), renderer.getDisplayValue(choice2).toString()); - - - }).collect(Collectors.toList()); - return sortedList; - } - - public static SceneDto createSceneDto(CaseWorkItemType caseWorkItem, PageBase pageBase, String operation){ - if (caseWorkItem == null){ - return null; - } - return createSceneDto(CaseTypeUtil.getCase(caseWorkItem), pageBase, operation); - } - - public static List computeTriggers(ApprovalContextType wfc, Integer stage) { - List triggers = new ArrayList<>(); - if (wfc == null) { - return triggers; - } - EvaluatedTriggerGroupDto.UniquenessFilter uniquenessFilter = new EvaluatedTriggerGroupDto.UniquenessFilter(); - List> rulesPerStageList = ApprovalContextUtil.getRulesPerStage(wfc); - for (int i = 0; i < rulesPerStageList.size(); i++) { - Integer stageNumber = i + 1; - boolean highlighted = stageNumber.equals(stage); - EvaluatedTriggerGroupDto group = EvaluatedTriggerGroupDto.initializeFromRules(rulesPerStageList.get(i), highlighted, uniquenessFilter); - triggers.add(group); - } - return triggers; - } - - public static SceneDto createSceneDto(CaseType caseObject, PageBase pageBase, String operation){ - if (caseObject == null || caseObject.getApprovalContext() == null) { - return null; - } - ObjectReferenceType objectRef = caseObject.getObjectRef(); - - OperationResult result = new OperationResult(operation); - Task task = pageBase.createSimpleTask(operation); - try { - Scene deltasScene = SceneUtil.visualizeObjectTreeDeltas(caseObject.getApprovalContext().getDeltasToApprove(), "pageWorkItem.delta", - pageBase.getPrismContext(), pageBase.getModelInteractionService(), objectRef, task, result); - return new SceneDto(deltasScene); - } catch (SchemaException | ExpressionEvaluationException ex){ - LOGGER.error("Unable to create delta visualization for case {}: {}", caseObject, ex.getLocalizedMessage(), ex); - } - return null; - } - - public static void workItemApproveActionPerformed(AjaxRequestTarget target, CaseWorkItemType workItem, AbstractWorkItemOutputType workItemOutput, - Component formPanel, PrismObject powerDonor, boolean approved, OperationResult result, PageBase pageBase) { - if (workItem == null){ - return; - } - CaseType parentCase = CaseWorkItemUtil.getCase(workItem); - if (CaseTypeUtil.isManualProvisioningCase(parentCase)){ - Task task = pageBase.createSimpleTask(result.getOperation()); - try { - AbstractWorkItemOutputType output = workItem.getOutput(); - if (output == null) { - output = new AbstractWorkItemOutputType(pageBase.getPrismContext()); - } - output.setOutcome(ApprovalUtils.toUri(approved)); - if (workItemOutput != null && workItemOutput.getComment() != null){ - output.setComment(workItemOutput.getComment()); - } - if (workItemOutput != null && workItemOutput.getEvidence() != null){ - output.setEvidence(workItemOutput.getEvidence()); - } - WorkItemId workItemId = WorkItemId.create(parentCase.getOid(), workItem.getId()); - pageBase.getWorkflowService().completeWorkItem(workItemId, output, task, result); - } catch (Exception ex) { - LoggingUtils.logUnexpectedException(LOGGER, "Unable to complete work item, ", ex); - result.recordFatalError(ex); - } - } else { - - Task task = pageBase.createSimpleTask(result.getOperation()); - try { - try { - ObjectDelta additionalDelta = null; - if (formPanel != null && formPanel instanceof DynamicFormPanel) { - if (approved) { - boolean requiredFieldsPresent = ((DynamicFormPanel) formPanel).checkRequiredFields(pageBase); - if (!requiredFieldsPresent) { - target.add(pageBase.getFeedbackPanel()); - return; - } - } - additionalDelta = ((DynamicFormPanel) formPanel).getObjectDelta(); - if (additionalDelta != null) { - pageBase.getPrismContext().adopt(additionalDelta); - } - } - assumePowerOfAttorneyIfRequested(result, powerDonor, pageBase); - pageBase.getWorkflowService().completeWorkItem(WorkItemId.of(workItem), - workItemOutput, - additionalDelta, task, result); - } finally { - dropPowerOfAttorneyIfRequested(result, powerDonor, pageBase); - } - } catch (Exception ex) { - result.recordFatalError(pageBase.createStringResource("WebModelUtils.couldntSaveWorkItem").getString(), ex); - LoggingUtils.logUnexpectedException(LOGGER, "Couldn't save work item", ex); - } - } - result.computeStatusIfUnknown(); - } - - public static List createMetadataOrdering(SortParam sortParam, String metadataProperty, PrismContext prismContext){ - if (sortParam != null && sortParam.getProperty() != null) { - OrderDirection order = sortParam.isAscending() ? OrderDirection.ASCENDING : OrderDirection.DESCENDING; - if (sortParam.getProperty().equals(metadataProperty)) { - return Collections.singletonList( - prismContext.queryFactory().createOrdering( - ItemPath.create(ReportOutputType.F_METADATA, MetadataType.F_CREATE_TIMESTAMP), order)); - } - return Collections.singletonList( - prismContext.queryFactory().createOrdering( - ItemPath.create(new QName(SchemaConstantsGenerated.NS_COMMON, sortParam.getProperty())), order)); - - - } else { - return null; - } - } - - public static void claimWorkItemActionPerformed(CaseWorkItemType workItemToClaim, - String operation, AjaxRequestTarget target, PageBase pageBase){ - Task task = pageBase.createSimpleTask(operation); - OperationResult mainResult = task.getResult(); - WorkflowService workflowService = pageBase.getWorkflowService(); - OperationResult result = mainResult.createSubresult(operation); - try { - workflowService.claimWorkItem(WorkItemId.of(workItemToClaim), task, result); - result.computeStatusIfUnknown(); - } catch (ObjectNotFoundException | SecurityViolationException | RuntimeException | SchemaException | - ObjectAlreadyExistsException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) { - result.recordPartialError(pageBase.createStringResource("pageWorkItems.message.partialError.claimed").getString(), e); - } - if (mainResult.isUnknown()) { - mainResult.recomputeStatus(); - } - - if (mainResult.isSuccess()) { - mainResult.recordStatus(OperationResultStatus.SUCCESS, - pageBase.createStringResource("pageWorkItems.message.success.claimed").getString()); - } - - pageBase.showResult(mainResult); - - pageBase.resetWorkItemCountModel(); - target.add(pageBase); - - } - - public static void assumePowerOfAttorneyIfRequested(OperationResult result, PrismObject powerDonor, PageBase pageBase) { - if (powerDonor != null) { - WebModelServiceUtils.assumePowerOfAttorney(powerDonor, pageBase.getModelInteractionService(), pageBase.getTaskManager(), result); - } - } - - public static void dropPowerOfAttorneyIfRequested(OperationResult result, PrismObject powerDonor, PageBase pageBase) { - if (powerDonor != null) { - WebModelServiceUtils.dropPowerOfAttorney(pageBase.getModelInteractionService(), pageBase.getTaskManager(), result); - } - } - - - @NotNull - public static List computeChangesCategorizationList(ChangesByState changesByState, ObjectReferenceType objectRef, - ModelInteractionService modelInteractionService, PrismContext prismContext, Task opTask, - OperationResult thisOpResult) throws SchemaException, ExpressionEvaluationException { - List changes = new ArrayList<>(); - if (!changesByState.getApplied().isEmpty()) { - changes.add(createTaskChangesDto("TaskDto.changesApplied", "box-solid box-success", changesByState.getApplied(), - modelInteractionService, prismContext, objectRef, opTask, thisOpResult)); - } - if (!changesByState.getBeingApplied().isEmpty()) { - changes.add(createTaskChangesDto("TaskDto.changesBeingApplied", "box-solid box-info", changesByState.getBeingApplied(), - modelInteractionService, prismContext, objectRef, opTask, thisOpResult)); - } - if (!changesByState.getWaitingToBeApplied().isEmpty()) { - changes.add(createTaskChangesDto("TaskDto.changesWaitingToBeApplied", "box-solid box-warning", - changesByState.getWaitingToBeApplied(), modelInteractionService, prismContext, objectRef, opTask, thisOpResult)); - } - if (!changesByState.getWaitingToBeApproved().isEmpty()) { - changes.add(createTaskChangesDto("TaskDto.changesWaitingToBeApproved", "box-solid box-primary", - changesByState.getWaitingToBeApproved(), modelInteractionService, prismContext, objectRef, opTask, thisOpResult)); - } - if (!changesByState.getRejected().isEmpty()) { - changes.add(createTaskChangesDto("TaskDto.changesRejected", "box-solid box-danger", changesByState.getRejected(), - modelInteractionService, prismContext, objectRef, opTask, thisOpResult)); - } - if (!changesByState.getCanceled().isEmpty()) { - changes.add(createTaskChangesDto("TaskDto.changesCanceled", "box-solid box-danger", changesByState.getCanceled(), - modelInteractionService, prismContext, objectRef, opTask, thisOpResult)); - } - return changes; - } - - private static SceneDto createTaskChangesDto(String titleKey, String boxClassOverride, ObjectTreeDeltas deltas, ModelInteractionService modelInteractionService, - PrismContext prismContext, ObjectReferenceType objectRef, Task opTask, OperationResult result) throws SchemaException, ExpressionEvaluationException { - ObjectTreeDeltasType deltasType = ObjectTreeDeltas.toObjectTreeDeltasType(deltas); - Scene scene = SceneUtil.visualizeObjectTreeDeltas(deltasType, titleKey, prismContext, modelInteractionService, objectRef, opTask, result); - SceneDto sceneDto = new SceneDto(scene); - sceneDto.setBoxClassOverride(boxClassOverride); - return sceneDto; - } - - public static String getMidpointCustomSystemName(PageBase pageBase, String defaultSystemNameKey){ - DeploymentInformationType deploymentInfo = MidPointApplication.get().getDeploymentInfo(); - String subscriptionId = deploymentInfo != null ? deploymentInfo.getSubscriptionIdentifier() : null; - if (!isSubscriptionIdCorrect(subscriptionId) || - SubscriptionType.DEMO_SUBSRIPTION.getSubscriptionType().equals(subscriptionId.substring(0, 2))) { - return pageBase.createStringResource(defaultSystemNameKey).getString(); - } - return deploymentInfo != null && StringUtils.isNotEmpty(deploymentInfo.getSystemName()) ? - deploymentInfo.getSystemName() : pageBase.createStringResource(defaultSystemNameKey).getString(); - } - - public static IModel getResourceLabelModel(ShadowType shadow, PageBase pageBase){ - return pageBase.createStringResource("DisplayNamePanel.resource", - WebComponentUtil.getReferencedObjectDisplayNamesAndNames(shadow.getResourceRef(), false)); - } - - public static IModel getResourceAttributesLabelModel(ShadowType shadow, PageBase pageBase){ - StringBuilder sb = new StringBuilder(); - if(shadow != null) { - if(shadow.getObjectClass() != null && !StringUtils.isBlank(shadow.getObjectClass().getLocalPart())) { - sb.append(pageBase.createStringResource("DisplayNamePanel.objectClass", shadow.getObjectClass().getLocalPart()).getString()); - } - if(shadow.getKind() != null && !StringUtils.isBlank(shadow.getKind().name())) { - sb.append(", "); - sb.append(pageBase.createStringResource("DisplayNamePanel.kind", shadow.getKind().name()).getString()); - } - - if(!StringUtils.isBlank(shadow.getIntent())) { - sb.append(", "); - sb.append(pageBase.createStringResource("DisplayNamePanel.intent", shadow.getIntent()).getString()); - } - - if(!StringUtils.isBlank(shadow.getTag())) { - sb.append(", "); - sb.append(pageBase.createStringResource("DisplayNamePanel.tag", shadow.getTag()).getString()); - } - return Model.of(sb.toString()); - } - return Model.of(""); - } - - public static String getPendingOperationsLabels(ShadowType shadow, BasePanel panel) { - if(shadow == null || shadow.getPendingOperation().isEmpty()) { - return null; - } - StringBuilder sb = new StringBuilder(); - List operations = shadow.getPendingOperation(); - sb.append("\n").append(panel.getString("DisplayNamePanel.pendingOperation")).append(":"); - boolean isFirst = true; - for(PendingOperationType operation : operations) { - if(operation != null) { - if(!isFirst) { - sb.append(", "); - } else { - sb.append(" "); - } - sb.append(getPendingOperationLabel(operation, panel)); - isFirst = false; - } - } - return sb.toString(); - } - - public static String getPendingOperationLabel(PendingOperationType realValue, BasePanel panel) { - StringBuilder sb = new StringBuilder(); - boolean empty = true; - ObjectDeltaType delta = realValue.getDelta(); - if(delta != null && delta.getChangeType() != null) { - sb.append(panel.getString(delta.getChangeType())); - empty = false; - } - PendingOperationTypeType type = realValue.getType(); - if(type != null) { - if(!empty) { - sb.append(" "); - } - sb.append("(").append(panel.getString(type)).append(")"); - } - OperationResultStatusType rStatus = realValue.getResultStatus(); - PendingOperationExecutionStatusType eStatus = realValue.getExecutionStatus(); - if(!empty) { - sb.append(" "); - } - sb.append(panel.getString("PendingOperationType.label.status")).append(": "); - if (rStatus == null) { - sb.append(panel.getString(eStatus)); - } else { - sb.append(panel.getString(rStatus)); - } - return sb.toString(); - } - - - public static String getObjectListPageStorageKey(String additionalKeyValue){ - if (StringUtils.isEmpty(additionalKeyValue)){ - return SessionStorage.KEY_OBJECT_LIST; - } - return SessionStorage.KEY_OBJECT_LIST + "." + additionalKeyValue; - } - - public static AssignmentHolderType getObjectFromAddDeltyForCase(CaseType aCase) { - if (aCase != null && aCase.getApprovalContext() != null - && aCase.getApprovalContext().getDeltasToApprove() != null) { - ObjectTreeDeltasType deltaTree = aCase.getApprovalContext().getDeltasToApprove(); - if(deltaTree != null && deltaTree.getFocusPrimaryDelta() != null) { - ObjectDeltaType primaryDelta = deltaTree.getFocusPrimaryDelta(); - if(primaryDelta != null && (primaryDelta.getItemDelta() == null || primaryDelta.getItemDelta().isEmpty()) - && primaryDelta.getObjectToAdd() != null && primaryDelta.getObjectToAdd() instanceof AssignmentHolderType - && ChangeType.ADD.equals(ChangeType.toChangeType(primaryDelta.getChangeType()))) { - return (AssignmentHolderType) primaryDelta.getObjectToAdd(); - } - } - } - return null; - } - - public static boolean isRefreshEnabled(PageBase pageBase, QName type) { - CompiledGuiProfile cup = pageBase.getCompiledGuiProfile(); - if (cup == null) { - return false; - } - - List views = cup.getObjectCollectionViews(); - if (CollectionUtils.isEmpty(views)) { - return false; - } - - for (CompiledObjectCollectionView view : views) { - if (QNameUtil.match(type, view.getObjectType())) { - if (view.getRefreshInterval() != null) { - return true; - } - - } - } - return false; - } - - public static Long xgc2long(XMLGregorianCalendar gc) { - return gc != null ? XmlTypeConverter.toMillis(gc) : null; - } - - public static String getSimpleChannel(String chanelUri) { - if (chanelUri == null) { - return null; - } - int i = chanelUri.indexOf('#'); - if (i < 0) { - return chanelUri; - } - return chanelUri.substring(i + 1); - } - - public static List getIntensForKind(PrismObject resource, ShadowKindType kind, PageBase parentPage) { - - RefinedResourceSchema refinedSchema = null; - try { - refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource, - parentPage.getPrismContext()); - - } catch (SchemaException e) { - return Collections.emptyList(); - } - - if (kind == null) { - return Collections.emptyList(); - } - - return RefinedResourceSchemaImpl.getIntentsForKind(refinedSchema, kind); - } - -} +/* + * Copyright (c) 2010-2019 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ +package com.evolveum.midpoint.gui.api.util; + +import com.evolveum.midpoint.common.LocalizationService; +import com.evolveum.midpoint.common.refinery.*; +import com.evolveum.midpoint.gui.api.GuiStyleConstants; +import com.evolveum.midpoint.gui.api.SubscriptionType; +import com.evolveum.midpoint.gui.api.component.BasePanel; +import com.evolveum.midpoint.gui.api.component.MainObjectListPanel; +import com.evolveum.midpoint.gui.api.model.LoadableModel; +import com.evolveum.midpoint.gui.api.model.NonEmptyModel; +import com.evolveum.midpoint.gui.api.model.ReadOnlyValueModel; +import com.evolveum.midpoint.gui.api.page.PageBase; +import com.evolveum.midpoint.gui.api.prism.ItemWrapper; +import com.evolveum.midpoint.gui.api.prism.PrismContainerWrapper; +import com.evolveum.midpoint.gui.impl.component.icon.CompositedIcon; +import com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder; +import com.evolveum.midpoint.gui.impl.component.icon.IconCssStyle; +import com.evolveum.midpoint.gui.impl.factory.WrapperContext; +import com.evolveum.midpoint.gui.impl.prism.PrismContainerValueWrapper; +import com.evolveum.midpoint.gui.impl.prism.PrismPropertyValueWrapper; +import com.evolveum.midpoint.gui.impl.prism.PrismPropertyWrapper; +import com.evolveum.midpoint.model.api.*; +import com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView; +import com.evolveum.midpoint.model.api.authentication.CompiledGuiProfile; +import com.evolveum.midpoint.model.api.util.ResourceUtils; +import com.evolveum.midpoint.model.api.visualizer.Scene; +import com.evolveum.midpoint.prism.*; +import com.evolveum.midpoint.prism.crypto.EncryptionException; +import com.evolveum.midpoint.prism.crypto.Protector; +import com.evolveum.midpoint.prism.delta.ChangeType; +import com.evolveum.midpoint.prism.delta.ObjectDelta; +import com.evolveum.midpoint.prism.delta.PropertyDelta; +import com.evolveum.midpoint.prism.path.ItemName; +import com.evolveum.midpoint.prism.path.ItemPath; +import com.evolveum.midpoint.prism.path.ItemPathCollectionsUtil; +import com.evolveum.midpoint.prism.polystring.PolyString; +import com.evolveum.midpoint.prism.query.*; +import com.evolveum.midpoint.prism.query.builder.S_FilterEntryOrEmpty; +import com.evolveum.midpoint.prism.util.PolyStringUtils; +import com.evolveum.midpoint.prism.xml.XmlTypeConverter; +import com.evolveum.midpoint.schema.*; +import com.evolveum.midpoint.schema.constants.ObjectTypes; +import com.evolveum.midpoint.schema.constants.RelationTypes; +import com.evolveum.midpoint.schema.constants.SchemaConstants; +import com.evolveum.midpoint.schema.processor.ResourceSchema; +import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.schema.result.OperationResultStatus; +import com.evolveum.midpoint.schema.util.*; +import com.evolveum.midpoint.security.api.AuthorizationConstants; +import com.evolveum.midpoint.security.api.MidPointPrincipal; +import com.evolveum.midpoint.security.enforcer.api.AuthorizationParameters; +import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.task.api.TaskBinding; +import com.evolveum.midpoint.task.api.TaskCategory; +import com.evolveum.midpoint.task.api.TaskExecutionStatus; +import com.evolveum.midpoint.util.*; +import com.evolveum.midpoint.util.exception.*; +import com.evolveum.midpoint.util.logging.LoggingUtils; +import com.evolveum.midpoint.util.logging.Trace; +import com.evolveum.midpoint.util.logging.TraceManager; +import com.evolveum.midpoint.web.component.DateLabelComponent; +import com.evolveum.midpoint.web.component.TabbedPanel; +import com.evolveum.midpoint.web.component.breadcrumbs.Breadcrumb; +import com.evolveum.midpoint.web.component.breadcrumbs.BreadcrumbPageClass; +import com.evolveum.midpoint.web.component.breadcrumbs.BreadcrumbPageInstance; +import com.evolveum.midpoint.web.component.data.BaseSortableDataProvider; +import com.evolveum.midpoint.web.component.data.SelectableBeanObjectDataProvider; +import com.evolveum.midpoint.web.component.data.Table; +import com.evolveum.midpoint.web.component.data.column.ColumnMenuAction; +import com.evolveum.midpoint.web.component.data.column.ColumnUtils; +import com.evolveum.midpoint.web.component.input.DisplayableValueChoiceRenderer; +import com.evolveum.midpoint.web.component.input.DropDownChoicePanel; +import com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem; +import com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction; +import com.evolveum.midpoint.web.component.prism.*; +import com.evolveum.midpoint.web.component.prism.show.SceneDto; +import com.evolveum.midpoint.web.component.prism.show.SceneUtil; +import com.evolveum.midpoint.web.component.util.Selectable; +import com.evolveum.midpoint.web.component.util.SelectableBeanImpl; +import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour; +import com.evolveum.midpoint.web.page.PageDialog; +import com.evolveum.midpoint.web.page.admin.archetype.PageArchetype; +import com.evolveum.midpoint.web.page.admin.cases.PageCase; +import com.evolveum.midpoint.web.page.admin.reports.PageReport; +import com.evolveum.midpoint.web.page.admin.resources.PageResource; +import com.evolveum.midpoint.web.page.admin.resources.PageResourceWizard; +import com.evolveum.midpoint.web.page.admin.resources.PageResources; +import com.evolveum.midpoint.web.page.admin.resources.content.PageAccount; +import com.evolveum.midpoint.web.page.admin.roles.PageRole; +import com.evolveum.midpoint.web.page.admin.roles.PageRoles; +import com.evolveum.midpoint.web.page.admin.server.PageTasks; +import com.evolveum.midpoint.web.page.admin.server.PageTask; +import com.evolveum.midpoint.web.page.admin.server.dto.OperationResultStatusPresentationProperties; +import com.evolveum.midpoint.web.page.admin.services.PageService; +import com.evolveum.midpoint.web.page.admin.services.PageServices; +import com.evolveum.midpoint.web.page.admin.users.PageOrgUnit; +import com.evolveum.midpoint.web.page.admin.users.PageUser; +import com.evolveum.midpoint.web.page.admin.users.PageUsers; +import com.evolveum.midpoint.web.page.admin.valuePolicy.PageValuePolicy; +import com.evolveum.midpoint.web.page.admin.workflow.dto.EvaluatedTriggerGroupDto; +import com.evolveum.midpoint.web.security.MidPointApplication; +import com.evolveum.midpoint.web.security.util.SecurityUtils; +import com.evolveum.midpoint.web.session.SessionStorage; +import com.evolveum.midpoint.web.session.UserProfileStorage.TableId; +import com.evolveum.midpoint.web.util.DateValidator; +import com.evolveum.midpoint.web.util.InfoTooltipBehavior; +import com.evolveum.midpoint.web.util.ObjectTypeGuiDescriptor; +import com.evolveum.midpoint.web.util.OnePageParameterEncoder; +import com.evolveum.midpoint.wf.util.ApprovalUtils; +import com.evolveum.midpoint.wf.util.ChangesByState; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; +import com.evolveum.midpoint.xml.ns._public.model.scripting_3.ExecuteScriptType; +import com.evolveum.prism.xml.ns._public.query_3.QueryType; +import com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType; +import com.evolveum.prism.xml.ns._public.types_3.PolyStringTranslationType; +import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; +import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.Validate; +import org.apache.commons.lang.math.NumberUtils; +import org.apache.commons.lang.time.DurationFormatUtils; +import org.apache.commons.lang3.StringEscapeUtils; +import org.apache.commons.validator.routines.checkdigit.VerhoeffCheckDigit; +import org.apache.wicket.*; +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior; +import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink; +import org.apache.wicket.authroles.authentication.AuthenticatedWebApplication; +import org.apache.wicket.authroles.authorization.strategies.role.Roles; +import org.apache.wicket.behavior.Behavior; +import org.apache.wicket.core.request.handler.RenderPageRequestHandler; +import org.apache.wicket.datetime.PatternDateConverter; +import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable; +import org.apache.wicket.extensions.markup.html.repeater.util.SortParam; +import org.apache.wicket.extensions.markup.html.tabs.ITab; +import org.apache.wicket.feedback.IFeedback; +import org.apache.wicket.markup.html.WebMarkupContainer; +import org.apache.wicket.markup.html.basic.Label; +import org.apache.wicket.markup.html.form.DropDownChoice; +import org.apache.wicket.markup.html.form.Form; +import org.apache.wicket.markup.html.form.FormComponent; +import org.apache.wicket.markup.html.form.IChoiceRenderer; +import org.apache.wicket.markup.repeater.data.IDataProvider; +import org.apache.wicket.model.IModel; +import org.apache.wicket.model.Model; +import org.apache.wicket.model.StringResourceModel; +import org.apache.wicket.request.IRequestHandler; +import org.apache.wicket.request.cycle.RequestCycle; +import org.apache.wicket.request.mapper.parameter.PageParameters; +import org.apache.wicket.util.string.StringValue; +import org.apache.wicket.util.visit.IVisit; +import org.apache.wicket.util.visit.IVisitor; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.joda.time.format.DateTimeFormat; + +import javax.xml.datatype.XMLGregorianCalendar; +import javax.xml.namespace.QName; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.net.URI; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.function.Predicate; +import java.util.function.Supplier; +import java.util.stream.Collectors; +import java.util.stream.StreamSupport; + +import static com.evolveum.midpoint.gui.api.page.PageBase.createStringResourceStatic; + +/** + * Utility class containing miscellaneous methods used mostly in Wicket + * components. + * + * @author lazyman + */ +public final class WebComponentUtil { + + private static final Trace LOGGER = TraceManager.getTrace(WebComponentUtil.class); + + private static final String KEY_BOOLEAN_NULL = "Boolean.NULL"; + private static final String KEY_BOOLEAN_TRUE = "Boolean.TRUE"; + private static final String KEY_BOOLEAN_FALSE = "Boolean.FALSE"; + + /** + * To be used only for tests when there's no MidpointApplication. + * (Quite a hack. Replace eventually by a more serious solution.) + */ + private static RelationRegistry staticallyProvidedRelationRegistry; + + private static Map, Class> objectDetailsPageMap; + private static Map, Class> createNewObjectPageMap; + + static { + objectDetailsPageMap = new HashMap<>(); + objectDetailsPageMap.put(UserType.class, PageUser.class); + objectDetailsPageMap.put(OrgType.class, PageOrgUnit.class); + objectDetailsPageMap.put(RoleType.class, PageRole.class); + objectDetailsPageMap.put(ServiceType.class, PageService.class); + objectDetailsPageMap.put(ResourceType.class, PageResource.class); + objectDetailsPageMap.put(TaskType.class, PageTask.class); + objectDetailsPageMap.put(ReportType.class, PageReport.class); + objectDetailsPageMap.put(ValuePolicyType.class, PageValuePolicy.class); + objectDetailsPageMap.put(CaseType.class, PageCase.class); + objectDetailsPageMap.put(ArchetypeType.class, PageArchetype.class); + objectDetailsPageMap.put(ShadowType.class, PageAccount.class); + } + + static{ + createNewObjectPageMap = new HashMap<>(); + createNewObjectPageMap.put(ResourceType.class, PageResourceWizard.class); + } + + // only pages that support 'advanced search' are currently listed here (TODO: generalize) + private static Map, Class> objectListPageMap; + + static { + objectListPageMap = new HashMap<>(); + objectListPageMap.put(UserType.class, PageUsers.class); + objectListPageMap.put(RoleType.class, PageRoles.class); + objectListPageMap.put(ServiceType.class, PageServices.class); + objectListPageMap.put(ResourceType.class, PageResources.class); + objectListPageMap.put(TaskType.class, PageTasks.class); + } + + private static Map storageTableIdMap; + + static { + storageTableIdMap = new HashMap<>(); + storageTableIdMap.put(TableId.PAGE_RESOURCE_ACCOUNTS_PANEL_REPOSITORY_MODE, SessionStorage.KEY_RESOURCE_ACCOUNT_CONTENT + SessionStorage.KEY_RESOURCE_PAGE_REPOSITORY_CONTENT); + storageTableIdMap.put(TableId.PAGE_RESOURCE_ACCOUNTS_PANEL_RESOURCE_MODE, SessionStorage.KEY_RESOURCE_ACCOUNT_CONTENT + SessionStorage.KEY_RESOURCE_PAGE_RESOURCE_CONTENT); + storageTableIdMap.put(TableId.PAGE_RESOURCE_ENTITLEMENT_PANEL_REPOSITORY_MODE, SessionStorage.KEY_RESOURCE_ENTITLEMENT_CONTENT + SessionStorage.KEY_RESOURCE_PAGE_REPOSITORY_CONTENT); + storageTableIdMap.put(TableId.PAGE_RESOURCE_ENTITLEMENT_PANEL_RESOURCE_MODE, SessionStorage.KEY_RESOURCE_ENTITLEMENT_CONTENT + SessionStorage.KEY_RESOURCE_PAGE_RESOURCE_CONTENT); + storageTableIdMap.put(TableId.PAGE_RESOURCE_GENERIC_PANEL_REPOSITORY_MODE, SessionStorage.KEY_RESOURCE_GENERIC_CONTENT + SessionStorage.KEY_RESOURCE_PAGE_REPOSITORY_CONTENT); + storageTableIdMap.put(TableId.PAGE_RESOURCE_GENERIC_PANEL_RESOURCE_MODE, SessionStorage.KEY_RESOURCE_GENERIC_CONTENT + SessionStorage.KEY_RESOURCE_PAGE_RESOURCE_CONTENT); + storageTableIdMap.put(TableId.PAGE_RESOURCE_OBJECT_CLASS_PANEL, SessionStorage.KEY_RESOURCE_OBJECT_CLASS_CONTENT); + storageTableIdMap.put(TableId.ROLE_MEMEBER_PANEL, SessionStorage.KEY_ROLE_MEMEBER_PANEL); + storageTableIdMap.put(TableId.ORG_MEMEBER_PANEL, SessionStorage.KEY_ORG_MEMEBER_PANEL); + storageTableIdMap.put(TableId.SERVICE_MEMEBER_PANEL, SessionStorage.KEY_SERVICE_MEMEBER_PANEL); + + } + + private static final Map COMPONENT_MAP = new HashMap<>(); + + static { + COMPONENT_MAP.put("com.evolveum.midpoint", LoggingComponentType.ALL); + COMPONENT_MAP.put("com.evolveum.midpoint.model", LoggingComponentType.MODEL); + COMPONENT_MAP.put("com.evolveum.midpoint.provisioning", LoggingComponentType.PROVISIONING); + COMPONENT_MAP.put("com.evolveum.midpoint.repo", LoggingComponentType.REPOSITORY); + COMPONENT_MAP.put("com.evolveum.midpoint.web", LoggingComponentType.WEB); + COMPONENT_MAP.put("com.evolveum.midpoint.gui", LoggingComponentType.GUI); + COMPONENT_MAP.put("com.evolveum.midpoint.task", LoggingComponentType.TASKMANAGER); + COMPONENT_MAP.put("com.evolveum.midpoint.model.sync", + LoggingComponentType.RESOURCEOBJECTCHANGELISTENER); + COMPONENT_MAP.put("com.evolveum.midpoint.wf", LoggingComponentType.WORKFLOWS); + COMPONENT_MAP.put("com.evolveum.midpoint.notifications", LoggingComponentType.NOTIFICATIONS); + COMPONENT_MAP.put("com.evolveum.midpoint.certification", LoggingComponentType.ACCESS_CERTIFICATION); + COMPONENT_MAP.put("com.evolveum.midpoint.security", LoggingComponentType.SECURITY); + } + + public enum AssignmentOrder{ + + ASSIGNMENT(0), + INDUCEMENT(1); + + private int order; + + AssignmentOrder(int order){ + this.order = order; + } + + public int getOrder() { + return order; + } + } + + public static String nl2br(String text) { + if (text == null) { + return null; + } + return StringEscapeUtils.escapeHtml4(text).replace("\n", "
"); + } + + public static String getTypeLocalized(ObjectReferenceType ref) { + ObjectTypes type = ref != null ? ObjectTypes.getObjectTypeFromTypeQName(ref.getType()) : null; + ObjectTypeGuiDescriptor descriptor = ObjectTypeGuiDescriptor.getDescriptor(type); + if (descriptor == null) { + return null; + } + return createStringResourceStatic(null, descriptor.getLocalizationKey()).getString(); + } + + public static String getReferencedObjectNames(List refs, boolean showTypes) { + return getReferencedObjectNames(refs, showTypes, true); + } + + public static String getReferencedObjectNames(List refs, boolean showTypes, boolean translate) { + return refs.stream() + .map(ref -> emptyIfNull(getName(ref, translate)) + (showTypes ? (" (" + emptyIfNull(getTypeLocalized(ref)) + ")") : "")) + .collect(Collectors.joining(", ")); + } + + private static String emptyIfNull(String s) { + return s != null ? s : ""; + } + + public static String getReferencedObjectDisplayNamesAndNames(List refs, boolean showTypes) { + return refs.stream() + .map(ref -> emptyIfNull(getDisplayNameAndName(ref)) + (showTypes ? (" (" + emptyIfNull(getTypeLocalized(ref)) + ")") : "")) + .collect(Collectors.joining(", ")); + } + + public static String getReferencedObjectDisplayNamesAndNames(Referencable ref, boolean showTypes) { + return getReferencedObjectDisplayNamesAndNames(ref, showTypes, true); + } + + public static String getReferencedObjectDisplayNamesAndNames(Referencable ref, boolean showTypes, boolean translate) { + if (ref == null){ + return ""; + } + String name = ref.getTargetName() == null ? "" : + (translate ? ref.getTargetName().getOrig() : ""); + StringBuilder sb = new StringBuilder(name); + if(showTypes) { + sb.append(" ("); + ObjectTypes type = ObjectTypes.getObjectTypeFromTypeQName(ref.getType()); + ObjectTypeGuiDescriptor descriptor = ObjectTypeGuiDescriptor.getDescriptor(type); + if (descriptor == null) { + return null; + } + sb.append(emptyIfNull(createStringResourceStatic(null, descriptor.getLocalizationKey()).getString())).append(")"); + } + return sb.toString(); + } + + public static List loadReferencedObjectList(List refList, String operation, PageBase pageBase){ + List loadedObjectsList = new ArrayList<>(); + if (refList == null){ + return loadedObjectsList; + } + refList.forEach(objectRef -> { + OperationResult result = new OperationResult(operation); + PrismObject loadedObject = WebModelServiceUtils.resolveReferenceNoFetch(objectRef, pageBase, pageBase.createSimpleTask(operation), result); + if (loadedObject != null) { + loadedObjectsList.add(loadedObject.asObjectable()); + } + }); + return loadedObjectsList; + } + + public static List loadTargetUsersListForShoppingCart(String operation, PageBase pageBase){ + List usersOidsList = pageBase.getSessionStorage().getRoleCatalog().getTargetUserOidsList(); + if (CollectionUtils.isEmpty(usersOidsList)){ + return new ArrayList<>(); + } + List usersReferenceList = new ArrayList<>(); + usersOidsList.forEach(userOid -> { + usersReferenceList.add(WebComponentUtil.createObjectRef(userOid, null, UserType.COMPLEX_TYPE)); + }); + return WebComponentUtil.loadReferencedObjectList(usersReferenceList, operation, pageBase); + + } + + public static ObjectFilter getShadowTypeFilterForAssociation(ConstructionType construction, String operation, PageBase pageBase){ + PrismContext prismContext = pageBase.getPrismContext(); + if (construction == null){ + return null; + } + PrismObject resource = WebComponentUtil.getConstructionResource(construction, operation, pageBase); + if (resource == null){ + return null; + } + + ObjectQuery query = prismContext.queryFactory().createQuery(); + try { + RefinedResourceSchema refinedResourceSchema = RefinedResourceSchema.getRefinedSchema(resource); + RefinedObjectClassDefinition oc = refinedResourceSchema.getRefinedDefinition(construction.getKind(), construction.getIntent()); + if (oc == null){ + return null; + } + Collection refinedAssociationDefinitions = oc.getAssociationDefinitions(); + + for (RefinedAssociationDefinition refinedAssociationDefinition : refinedAssociationDefinitions) { + S_FilterEntryOrEmpty atomicFilter = prismContext.queryFor(ShadowType.class); + List orFilterClauses = new ArrayList<>(); + refinedAssociationDefinition.getIntents() + .forEach(intent -> orFilterClauses.add(atomicFilter.item(ShadowType.F_INTENT).eq(intent).buildFilter())); + OrFilter intentFilter = prismContext.queryFactory().createOr(orFilterClauses); + + AndFilter filter = (AndFilter) atomicFilter.item(ShadowType.F_KIND).eq(refinedAssociationDefinition.getKind()).and() + .item(ShadowType.F_RESOURCE_REF).ref(resource.getOid(), ResourceType.COMPLEX_TYPE).buildFilter(); + filter.addCondition(intentFilter); + query.setFilter(filter); // TODO this overwrites existing filter (created in previous cycle iteration)... is it OK? [med] + } + } catch (SchemaException ex) { + LOGGER.error("Couldn't create query filter for ShadowType for association: {}" , ex.getErrorTypeMessage()); + } + return query.getFilter(); + } + + public static void addAjaxOnUpdateBehavior(WebMarkupContainer container) { + container.visitChildren(new IVisitor() { + @Override + public void component(Component component, IVisit objectIVisit) { + if (component instanceof InputPanel) { + addAjaxOnBlurUpdateBehaviorToComponent(((InputPanel) component).getBaseFormComponent()); + } else if (component instanceof FormComponent) { + addAjaxOnBlurUpdateBehaviorToComponent(component); + } + } + }); + } + + private static void addAjaxOnBlurUpdateBehaviorToComponent(final Component component) { + component.setOutputMarkupId(true); + component.add(new AjaxFormComponentUpdatingBehavior("blur") { + + @Override + protected void onUpdate(AjaxRequestTarget target) { + } + }); + } + + public static String resolveLocalizableMessage(LocalizableMessageType localizableMessage, Component component) { + if (localizableMessage == null) { + return null; + } + return resolveLocalizableMessage(LocalizationUtil.toLocalizableMessage(localizableMessage), component); + } + + public static String resolveLocalizableMessage(LocalizableMessage localizableMessage, Component component) { + if (localizableMessage == null) { + return null; + } else if (localizableMessage instanceof SingleLocalizableMessage) { + return resolveLocalizableMessage((SingleLocalizableMessage) localizableMessage, component); + } else if (localizableMessage instanceof LocalizableMessageList) { + return resolveLocalizableMessage((LocalizableMessageList) localizableMessage, component); + } else { + throw new AssertionError("Unsupported localizable message type: " + localizableMessage); + } + } + + private static String resolveLocalizableMessage(SingleLocalizableMessage localizableMessage, Component component) { + if (localizableMessage == null) { + return null; + } + while (localizableMessage.getFallbackLocalizableMessage() != null) { + if (localizableMessage.getKey() != null) { + Localizer localizer = Application.get().getResourceSettings().getLocalizer(); + if (localizer.getStringIgnoreSettings(localizableMessage.getKey(), component, null, null) != null) { + break; // the key exists => we can use the current localizableMessage + } + } + if (localizableMessage.getFallbackLocalizableMessage() instanceof SingleLocalizableMessage) { + localizableMessage = (SingleLocalizableMessage) localizableMessage.getFallbackLocalizableMessage(); + } else { + return resolveLocalizableMessage(localizableMessage.getFallbackLocalizableMessage(), component); + } + } + String key = localizableMessage.getKey() != null ? localizableMessage.getKey() : localizableMessage.getFallbackMessage(); + StringResourceModel stringResourceModel = new StringResourceModel(key, component) + .setModel(new Model()) + .setDefaultValue(localizableMessage.getFallbackMessage()) + .setParameters(resolveArguments(localizableMessage.getArgs(), component)); + String rv = stringResourceModel.getString(); + //System.out.println("GUI: Resolving [" + key + "]: to [" + rv + "]"); + return rv; + } + + // todo deduplicate with similar method in LocalizationServiceImpl + private static String resolveLocalizableMessage(LocalizableMessageList msgList, Component component) { + String separator = resolveIfPresent(msgList.getSeparator(), component); + String prefix = resolveIfPresent(msgList.getPrefix(), component); + String suffix = resolveIfPresent(msgList.getPostfix(), component); + return msgList.getMessages().stream() + .map(m -> resolveLocalizableMessage(m, component)) + .collect(Collectors.joining(separator, prefix, suffix)); + } + + private static String resolveIfPresent(LocalizableMessage msg, Component component) { + return msg != null ? resolveLocalizableMessage(msg, component) : ""; + } + + private static Object[] resolveArguments(Object[] args, Component component) { + if (args == null) { + return null; + } + Object[] rv = new Object[args.length]; + for (int i = 0; i < args.length; i++) { + if (args[i] instanceof LocalizableMessage) { + rv[i] = resolveLocalizableMessage(((LocalizableMessage) args[i]), component); + } else { + rv[i] = args[i]; + } + } + return rv; + } + + // TODO add other classes; probably move to some enum + @Nullable + public static String getAuthorizationActionForTargetClass(Class targetClass) { + if (UserType.class.equals(targetClass)) { + return AuthorizationConstants.AUTZ_UI_USER_URL; + } else if (OrgType.class.equals(targetClass)) { + return AuthorizationConstants.AUTZ_UI_ORG_UNIT_URL; + } else if (RoleType.class.equals(targetClass)) { + return AuthorizationConstants.AUTZ_UI_ROLE_URL; + } else if (ServiceType.class.equals(targetClass)) { + return AuthorizationConstants.AUTZ_UI_SERVICE_URL; + } else if (ResourceType.class.equals(targetClass)) { + return AuthorizationConstants.AUTZ_UI_RESOURCE_URL; + } else { + return null; + } + } + + public static void safeResultCleanup(OperationResult result, Trace logger) { + try { + result.cleanupResultDeeply(); + } catch (Throwable t) { + LoggingUtils.logUnexpectedException(logger, "Couldn't clean up the operation result", t); + } + } + + /** + * Default list view setting should never be needed. Always check setting for specific + * object type (and archetype). + */ + @Deprecated + public static CompiledObjectCollectionView getDefaultGuiObjectListType(PageBase pageBase) { + return pageBase.getCompiledGuiProfile().getDefaultObjectCollectionView(); + } + + public enum Channel { + // TODO: move this to schema component + LIVE_SYNC(SchemaConstants.CHANGE_CHANNEL_LIVE_SYNC_URI), + RECONCILIATION(SchemaConstants.CHANGE_CHANNEL_RECON_URI), + RECOMPUTATION(SchemaConstants.CHANGE_CHANNEL_RECOMPUTE_URI), + DISCOVERY(SchemaConstants.CHANGE_CHANNEL_DISCOVERY_URI), + WEB_SERVICE(SchemaConstants.CHANNEL_WEB_SERVICE_URI), + IMPORT(SchemaConstants.CHANNEL_OBJECT_IMPORT_URI), + REST(SchemaConstants.CHANNEL_REST_URI), + INIT(SchemaConstants.CHANNEL_GUI_INIT_URI), + USER(SchemaConstants.CHANNEL_GUI_USER_URI), + SELF_REGISTRATION(SchemaConstants.CHANNEL_GUI_SELF_REGISTRATION_URI), + RESET_PASSWORD(SchemaConstants.CHANNEL_GUI_RESET_PASSWORD_URI); + + private String channel; + + Channel(String channel) { + this.channel = channel; + } + + public String getChannel() { + return channel; + } + } + + public static DateValidator getRangeValidator(Form form, ItemPath path) { + DateValidator validator = null; + List validators = form.getBehaviors(DateValidator.class); + if (validators != null) { + for (DateValidator val : validators) { + if (path.equivalent(val.getIdentifier())) { + validator = val; + break; + } + } + } + + if (validator == null) { + validator = new DateValidator(); + validator.setIdentifier(path); + form.add(validator); + } + + return validator; + } + + public static boolean isItemVisible(List visibleItems, ItemPath itemToBeFound) { + return ItemPathCollectionsUtil.containsSubpathOrEquivalent(visibleItems, itemToBeFound); + + } + + public static Class qnameToClass(PrismContext prismContext, QName type) { + return prismContext.getSchemaRegistry().determineCompileTimeClass(type); + } + + public static Class qnameToClass(PrismContext prismContext, QName type, Class returnType) { + return prismContext.getSchemaRegistry().determineCompileTimeClass(type); + } + + public static QName classToQName(PrismContext prismContext, Class clazz) { + return prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(clazz).getTypeName(); + } + + public static TaskType createSingleRecurrenceTask(String taskName, QName applicableType, ObjectQuery query, + ObjectDelta delta, ModelExecuteOptions options, String category, PageBase pageBase) throws SchemaException { + + TaskType task = new TaskType(pageBase.getPrismContext()); + + MidPointPrincipal owner = SecurityUtils.getPrincipalUser(); + + ObjectReferenceType ownerRef = new ObjectReferenceType(); + ownerRef.setOid(owner.getOid()); + ownerRef.setType(owner.getFocus().COMPLEX_TYPE); + task.setOwnerRef(ownerRef); + + task.setBinding(TaskBindingType.LOOSE); + task.setCategory(category); + task.setExecutionStatus(TaskExecutionStatusType.RUNNABLE); + task.setRecurrence(TaskRecurrenceType.SINGLE); + task.setThreadStopAction(ThreadStopActionType.RESTART); + task.setHandlerUri(pageBase.getTaskService().getHandlerUriForCategory(category)); + ScheduleType schedule = new ScheduleType(); + schedule.setMisfireAction(MisfireActionType.EXECUTE_IMMEDIATELY); + task.setSchedule(schedule); + + task.setName(WebComponentUtil.createPolyFromOrigString(taskName)); + + PrismObject prismTask = task.asPrismObject(); + QueryType queryType = pageBase.getQueryConverter().createQueryType(query); + prismTask.findOrCreateProperty(SchemaConstants.PATH_MODEL_EXTENSION_OBJECT_QUERY).addRealValue(queryType); + + if (applicableType != null) { + prismTask.findOrCreateProperty(SchemaConstants.PATH_MODEL_EXTENSION_OBJECT_TYPE).setRealValue(applicableType); + } + + if (delta != null) { + ObjectDeltaType deltaBean = DeltaConvertor.toObjectDeltaType(delta); + prismTask.findOrCreateProperty(SchemaConstants.PATH_MODEL_EXTENSION_OBJECT_DELTA).setRealValue(deltaBean); + } + + if (options != null) { + prismTask.findOrCreateProperty(SchemaConstants.PATH_MODEL_EXTENSION_EXECUTE_OPTIONS) + .setRealValue(options.toModelExecutionOptionsType()); + } + return task; + } + + public static void iterativeExecuteBulkAction(PageBase pageBase, ExecuteScriptType script, Task task, OperationResult result ) + throws SchemaException, SecurityViolationException, ObjectNotFoundException, ExpressionEvaluationException, + CommunicationException, ConfigurationException{ + + pageBase.getScriptingService().evaluateIterativeExpressionInBackground(script, task, result); + } + + public static Task createMemberOperationTask(Task operationalTask, QName type, ObjectQuery memberQuery, + ExecuteScriptType script, Collection> option, OperationResult parentResult, PageBase pageBase) throws SchemaException { + + MidPointPrincipal owner = SecurityUtils.getPrincipalUser(); + operationalTask.setOwner(owner.getFocus().asPrismObject()); + + operationalTask.setBinding(TaskBinding.LOOSE); + operationalTask.setInitialExecutionStatus(TaskExecutionStatus.RUNNABLE); + operationalTask.setThreadStopAction(ThreadStopActionType.RESTART); + ScheduleType schedule = new ScheduleType(); + schedule.setMisfireAction(MisfireActionType.EXECUTE_IMMEDIATELY); + operationalTask.makeSingle(schedule); + operationalTask.setName(WebComponentUtil.createPolyFromOrigString(parentResult.getOperation())); + + PrismPropertyDefinition propertyDefQuery = pageBase.getPrismContext().getSchemaRegistry() + .findPropertyDefinitionByElementName(SchemaConstants.MODEL_EXTENSION_OBJECT_QUERY); + PrismProperty queryProperty = propertyDefQuery.instantiate(); + QueryType queryType = pageBase.getQueryConverter().createQueryType(memberQuery); + queryProperty.setRealValue(queryType); + operationalTask.addExtensionProperty(queryProperty); + + PrismPropertyDefinition propertyDefType = pageBase.getPrismContext().getSchemaRegistry() + .findPropertyDefinitionByElementName(SchemaConstants.MODEL_EXTENSION_OBJECT_TYPE); + PrismProperty typeProperty = propertyDefType.instantiate(); + typeProperty.setRealValue(type); + operationalTask.addExtensionProperty(typeProperty); + + if (option != null) { + PrismPropertyDefinition propertyDefOption = pageBase.getPrismContext().getSchemaRegistry() + .findPropertyDefinitionByElementName(SchemaConstants.MODEL_EXTENSION_SEARCH_OPTIONS); + PrismProperty optionProperty = propertyDefOption.instantiate(); + optionProperty.setRealValue(MiscSchemaUtil.optionsToOptionsType(option)); + operationalTask.addExtensionProperty(optionProperty); + } + + try { + pageBase.getSecurityEnforcer().authorize(ModelAuthorizationAction.EXECUTE_SCRIPT.getUrl(), + null, AuthorizationParameters.EMPTY, null, operationalTask, parentResult); + operationalTask.setExtensionPropertyValue(SchemaConstants.SE_EXECUTE_SCRIPT, script); + operationalTask.setHandlerUri(ModelPublicConstants.ITERATIVE_SCRIPT_EXECUTION_TASK_HANDLER_URI); + return operationalTask; + } catch (ObjectNotFoundException | SchemaException + | ExpressionEvaluationException | CommunicationException | ConfigurationException + | SecurityViolationException e) { + parentResult.recordFatalError(pageBase.createStringResource("WebComponentUtil.message.startPerformed.fatalError.createTask").getString(), e); + LoggingUtils.logUnexpectedException(LOGGER, "Couldn't create bulk action task", e); + } + return null; + } + + public static void executeMemberOperation(Task operationalTask, OperationResult parentResult, PageBase pageBase) { + + OperationResult result = parentResult.createSubresult("evaluateExpressionInBackground"); + pageBase.getTaskManager().switchToBackground(operationalTask, result); + result.computeStatus(); + parentResult.recordInProgress(); + parentResult.setBackgroundTaskOid(operationalTask.getOid()); + pageBase.showResult(parentResult); + } + + public static boolean isAuthorized(String... action) { + if (action == null || action.length == 0) { + return true; + } + List actions = Arrays.asList(action); + return isAuthorized(actions); + } + + public static boolean isAuthorized(Collection actions) { + if (actions == null || actions.isEmpty()) { + return true; + } + Roles roles = new Roles(AuthorizationConstants.AUTZ_ALL_URL); + roles.add(AuthorizationConstants.AUTZ_GUI_ALL_URL); + roles.add(AuthorizationConstants.AUTZ_GUI_ALL_DEPRECATED_URL); + roles.addAll(actions); + if (((AuthenticatedWebApplication) AuthenticatedWebApplication.get()).hasAnyRole(roles)) { + return true; + } + return false; + } + + // TODO: move to util component + public static Integer safeLongToInteger(Long l) { + if (l == null) { + return null; + } + + if (l > Integer.MAX_VALUE || l < Integer.MIN_VALUE) { + throw new IllegalArgumentException( + "Couldn't transform long '" + l + "' to int, too big or too small."); + } + + return (int) l.longValue(); + } + + // TODO: move to schema component + public static List createObjectTypeList() { + + List types = new ArrayList<>(ObjectTypes.values().length); + for (ObjectTypes t : ObjectTypes.values()) { + types.add(t.getTypeQName()); + } + + return types.stream().sorted((type1, type2) -> { + Validate.notNull(type1); + Validate.notNull(type2); + + return String.CASE_INSENSITIVE_ORDER.compare(QNameUtil.qNameToUri(type1), QNameUtil.qNameToUri(type2)); + + + }).collect(Collectors.toList()); + + } + + public static List createAssignmentHolderTypeQnamesList() { + + List objectTypes = createAssignmentHolderTypesList(); + List types = new ArrayList<>(); + objectTypes.forEach(objectType -> { + types.add(objectType.getTypeQName()); + }); + + return types.stream().sorted((type1, type2) -> { + Validate.notNull(type1); + Validate.notNull(type2); + + return String.CASE_INSENSITIVE_ORDER.compare(QNameUtil.qNameToUri(type1), QNameUtil.qNameToUri(type2)); + + + }).collect(Collectors.toList()); + + } + + public static List createAssignmentHolderTypesList(){ + List objectTypes = new ArrayList<>(); + for (ObjectTypes t : ObjectTypes.values()) { + if (AssignmentHolderType.class.isAssignableFrom(t.getClassDefinition())) { + objectTypes.add(t); + } + } + return objectTypes.stream().sorted((type1, type2) -> { + Validate.notNull(type1); + Validate.notNull(type2); + + return String.CASE_INSENSITIVE_ORDER.compare(QNameUtil.qNameToUri(type1.getTypeQName()), QNameUtil.qNameToUri(type2.getTypeQName())); + + + }).collect(Collectors.toList()); + } + + // TODO: move to schema component + public static List createFocusTypeList() { + return createFocusTypeList(false); + } + + public static List createFocusTypeList(boolean includeAbstractType) { + List focusTypeList = new ArrayList<>(); + + focusTypeList.add(UserType.COMPLEX_TYPE); + focusTypeList.add(OrgType.COMPLEX_TYPE); + focusTypeList.add(RoleType.COMPLEX_TYPE); + focusTypeList.add(ServiceType.COMPLEX_TYPE); + + if (includeAbstractType) { + focusTypeList.add(FocusType.COMPLEX_TYPE); + } + + return focusTypeList; + } + + // TODO: move to schema component + public static List createAbstractRoleTypeList() { + List focusTypeList = new ArrayList<>(); + + focusTypeList.add(AbstractRoleType.COMPLEX_TYPE); + focusTypeList.add(OrgType.COMPLEX_TYPE); + focusTypeList.add(RoleType.COMPLEX_TYPE); + focusTypeList.add(ServiceType.COMPLEX_TYPE); + + return focusTypeList; + } + + public static List createAssignableTypesList() { + List focusTypeList = new ArrayList<>(); + + focusTypeList.add(ObjectTypes.RESOURCE); + focusTypeList.add(ObjectTypes.ORG); + focusTypeList.add(ObjectTypes.ROLE); + focusTypeList.add(ObjectTypes.SERVICE); + + return focusTypeList; + } + + public static List createSupportedTargetTypeList(QName targetTypeFromDef) { + if (targetTypeFromDef == null || ObjectType.COMPLEX_TYPE.equals(targetTypeFromDef)) { + return createObjectTypeList(); + } + + if (AbstractRoleType.COMPLEX_TYPE.equals(targetTypeFromDef)) { + return createAbstractRoleTypeList(); + } + + if (FocusType.COMPLEX_TYPE.equals(targetTypeFromDef)) { + return createFocusTypeList(); + } + + if (AssignmentHolderType.COMPLEX_TYPE.equals(targetTypeFromDef)) { + return createAssignmentHolderTypeQnamesList(); + } + + return Arrays.asList(targetTypeFromDef); + } + + /** + * Takes a collection of object types (classes) that may contain abstract types. Returns a collection + * that only contain concrete types. + * @param common supertype for all the types in the collections + * + * TODO: move to schema component + */ + public static List resolveObjectTypesToQNames(Collection> types, PrismContext prismContext) { + if (types == null) { + return null; + } + List concreteTypes = new ArrayList<>(types.size()); + for (Class type: types) { + if (type == null || type.equals(ObjectType.class)) { + MiscUtil.addAllIfNotPresent(concreteTypes, createObjectTypeList()); + } else if (type.equals(FocusType.class)) { + MiscUtil.addAllIfNotPresent(concreteTypes, createFocusTypeList()); + } else if (type.equals(AbstractRoleType.class)) { + MiscUtil.addAllIfNotPresent(concreteTypes, createAbstractRoleTypeList()); + } else { + MiscUtil.addIfNotPresent(concreteTypes, classToQName(prismContext, type)); + } + } + return concreteTypes; + } + + public static IModel createLocalizedModelForEnum(T value, Component comp) { + String key = value != null ? value.getClass().getSimpleName() + "." + value.name() : ""; + return new StringResourceModel(key, comp, null); + } + + public static IModel> createReadonlyModelFromEnum(final Class type) { + return (IModel>) () -> { + List list = new ArrayList<>(); + Collections.addAll(list, type.getEnumConstants()); + + return list; + }; + } + + // use for small enums only + @NotNull + public static IModel> createReadonlyValueModelFromEnum(@NotNull Class type, @NotNull Predicate filter) { + return new ReadOnlyValueModel<>( + Arrays.stream(type.getEnumConstants()) + .filter(filter) + .collect(Collectors.toList())); + } + + public static List createTaskCategoryList() { + List categories = new ArrayList<>(); + + // todo change to something better and add i18n + // TaskManager manager = getTaskManager(); + // List list = manager.getAllTaskCategories(); + // if (list != null) { + // Collections.sort(list); + // for (String item : list) { + // if (item != TaskCategory.IMPORT_FROM_FILE && item != + // TaskCategory.WORKFLOW) { + // categories.add(item); + // } + // } + // } + categories.add(TaskCategory.LIVE_SYNCHRONIZATION); + categories.add(TaskCategory.RECONCILIATION); + categories.add(TaskCategory.IMPORTING_ACCOUNTS); + categories.add(TaskCategory.RECOMPUTATION); + categories.add(TaskCategory.DEMO); + // TODO: what about other categories? + // categories.add(TaskCategory.ACCESS_CERTIFICATION); + // categories.add(TaskCategory.BULK_ACTIONS); + // categories.add(TaskCategory.CUSTOM); + // categories.add(TaskCategory.EXECUTE_CHANGES); + // categories.add(TaskCategory.IMPORT_FROM_FILE); + // categories.add(TaskCategory.IMPORT_FROM_FILE); + return categories; + } + + public static IModel createCategoryNameModel(final Component component, + final IModel categorySymbolModel) { + return (IModel) () -> createStringResourceStatic(component, + "pageTasks.category." + categorySymbolModel.getObject()).getString(); + } + + public static ObjectReferenceType createObjectRef(String oid, String name, QName type) { + ObjectReferenceType ort = new ObjectReferenceType(); + ort.setOid(oid); + ort.setTargetName(createPolyFromOrigString(name)); + ort.setType(type); + return ort; + } + + public static DropDownChoicePanel createEnumPanel(Class clazz, String id, + final IModel model, final Component component) { + return createEnumPanel(clazz, id, model, component, true); + + } + public static DropDownChoicePanel createEnumPanel(Class clazz, String id, + final IModel model, final Component component, boolean allowNull) { + return createEnumPanel(clazz, id, WebComponentUtil.createReadonlyModelFromEnum(clazz), + model, component, allowNull ); + } + + public static DropDownChoicePanel createEnumPanel(Class clazz, String id, + IModel> choicesList, final IModel model, final Component component, boolean allowNull) { + return createEnumPanel(clazz, id, choicesList, model, component, allowNull, null); + } + + public static DropDownChoicePanel createEnumPanel(Class clazz, String id, + IModel> choicesList, final IModel model, final Component component, boolean allowNull, String nullValidDisplayValue) { + return new DropDownChoicePanel(id, model, choicesList, getEnumChoiceRenderer(component) + , allowNull){ + + private static final long serialVersionUID = 1L; + + @Override + protected String getNullValidDisplayValue() { + return nullValidDisplayValue != null && StringUtils.isNotEmpty(nullValidDisplayValue.trim()) ? + nullValidDisplayValue : super.getNullValidDisplayValue(); + } + }; + } + + public static IChoiceRenderer getEnumChoiceRenderer(Component component){ + return new IChoiceRenderer() { + + private static final long serialVersionUID = 1L; + + @Override + public E getObject(String id, IModel> choices) { + if (StringUtils.isBlank(id)) { + return null; + } + return choices.getObject().get(Integer.parseInt(id)); + } + + @Override + public Object getDisplayValue(E object) { + return WebComponentUtil.createLocalizedModelForEnum(object, component).getObject(); + } + + @Override + public String getIdValue(E object, int index) { + return Integer.toString(index); + } + }; + } + + public static DropDownChoicePanel createEnumPanel(final PrismPropertyDefinition def, String id, + final IModel model) { + final Object o = model.getObject(); + + final IModel> enumModelValues = (IModel>) () -> getDisplayableValues(def.getAllowedValues()); + + return new DropDownChoicePanel(id, model, enumModelValues, new DisplayableValueChoiceRenderer(getDisplayableValues(def.getAllowedValues())), true); + } + + private static List getDisplayableValues(Collection allowedValues) { + List values = null; + if (allowedValues != null) { + values = new ArrayList<>(allowedValues.size()); + for (T v : allowedValues) { + if (v instanceof DisplayableValue) { + values.add(((DisplayableValue) v)); + } + } + } + return values; + } + + public static String getName(ObjectType object) { + return getName(object, true); + } + + public static String getName(ObjectType object, boolean translate) { + if (object == null) { + return null; + } + + return getName(object.asPrismObject(), translate); + } + + public static String getEffectiveName(ObjectType object, QName propertyName) { + return getEffectiveName(object, propertyName, true); + } + + public static String getEffectiveName(ObjectType object, QName propertyName, boolean translate) { + if (object == null) { + return null; + } + + return getEffectiveName(object.asPrismObject(), propertyName, translate); + } + + public static String getEffectiveName(PrismObject object, QName propertyName) { + return getEffectiveName(object, propertyName, true); + } + + public static String getEffectiveName(PrismObject object, QName propertyName, boolean translate) { + if (object == null) { + return null; + } + + PrismProperty prop = object.findProperty(ItemName.fromQName(propertyName)); + + if (prop != null) { + Object realValue = prop.getRealValue(); + if (prop.getDefinition().getTypeName().equals(DOMUtil.XSD_STRING)) { + return (String) realValue; + } else if (realValue instanceof PolyString) { + return translate ? getTranslatedPolyString((PolyString) realValue) + : WebComponentUtil.getOrigStringFromPoly((PolyString) realValue); + } + } + + PolyString name = getValue(object, ObjectType.F_NAME, PolyString.class); + if (name == null){ + return null; + } + return translate ? getTranslatedPolyString(name) + : WebComponentUtil.getOrigStringFromPoly(name); + } + + public static String getTranslatedPolyString(PolyStringType value){ + return getTranslatedPolyString(PolyString.toPolyString(value)); + } + + public static String getTranslatedPolyString(PolyString value){ + MidPointApplication application = MidPointApplication.get(); + return getTranslatedPolyString(value, application != null ? application.getLocalizationService() : null); + } + + public static String getTranslatedPolyString(PolyString value, LocalizationService localizationService){ + if (value == null){ + return ""; + } + if (localizationService == null){ + localizationService = MidPointApplication.get().getLocalizationService(); + } + return localizationService.translate(value, getCurrentLocale(), true); + } + + public static String getName(ObjectReferenceType ref, PageBase pageBase, String operation) { + String name = getName(ref); + if (StringUtils.isEmpty(name) || name.equals(ref.getOid())) { + String oid = ref.getOid(); + Collection> options = SelectorOptions + .createCollection(GetOperationOptions.createNoFetch()); + Class type = (Class) ObjectType.class; + PrismObject object = WebModelServiceUtils.loadObject(type, oid, pageBase, + pageBase.createSimpleTask(operation), new OperationResult(operation)); + if (object != null) { + name = object.getName().getOrig(); + } + } + return name; + } + + public static String getDisplayNameOrName(ObjectReferenceType ref, PageBase pageBase, String operation) { + return getDisplayNameOrName(ref, pageBase, operation, true); + } + + public static String getDisplayNameOrName(ObjectReferenceType ref, PageBase pageBase, + String operation, boolean translate) { + String name = getName(ref, translate); + if (StringUtils.isEmpty(name) || name.equals(ref.getOid())) { + String oid = ref.getOid(); + Collection> options = SelectorOptions + .createCollection(GetOperationOptions.createNoFetch()); + Class type = ref.getType() != null ? (Class)qnameToClass(pageBase.getPrismContext(), ref.getType()) : (Class) ObjectType.class; + PrismObject object = WebModelServiceUtils.loadObject(type, oid, pageBase, + pageBase.createSimpleTask(operation), new OperationResult(operation)); + if (object != null) { + name = getDisplayNameOrName(object, true); + } + } + return name; + } + + public static String getEffectiveName(ObjectReferenceType ref, QName propertyName, + PageBase pageBase, String operation) { + return getEffectiveName(ref, propertyName, pageBase, operation, true); + } + public static String getEffectiveName(ObjectReferenceType ref, QName propertyName, + PageBase pageBase, String operation, boolean translate) { + PrismObject object = WebModelServiceUtils.loadObject(ref, pageBase, + pageBase.createSimpleTask(operation), new OperationResult(operation)); + + if (object == null) { + return "Not Found"; + } + + return getEffectiveName(object, propertyName, translate); + + } + + public static String getName(ObjectReferenceType ref) { + return getName(ref, true); + } + + public static String getName(ObjectReferenceType ref, boolean translate) { + if (ref == null) { + return null; + } + if (ref.getTargetName() != null) { + if (translate){ + return getTranslatedPolyString(ref.getTargetName()); + } + return getOrigStringFromPoly(ref.getTargetName()); + } + if (ref.asReferenceValue().getObject() != null) { + return getName(ref.asReferenceValue().getObject(), translate); + } + return ref.getOid(); + } + + public static String getName(PrismObject object) { + return getName(object, true); + } + + public static String getName(PrismObject object, boolean translate) { + return getName(object, translate, (LocalizationService) null); + } + + public static String getName(PrismObject object, boolean translate, LocalizationService localizationService) { + if (object == null) { + return null; + } + PolyString name = getValue(object, ObjectType.F_NAME, PolyString.class); + if (name == null){ + return null; + } + if (translate){ + return getTranslatedPolyString(name, localizationService); + } + return name.getOrig(); + } + + public static String getDisplayName(PrismContainerValue prismContainerValue) { + if (prismContainerValue == null) { + return "ContainerPanel.containerProperties"; + } + + String displayName = null; + + if (prismContainerValue.canRepresent(LifecycleStateType.class)) { + LifecycleStateType lifecycleStateType = (LifecycleStateType) prismContainerValue.asContainerable(); + String name = lifecycleStateType.getDisplayName(); + if (name == null || name.isEmpty()) { + Class cvalClass = prismContainerValue.getCompileTimeClass(); + name = lifecycleStateType.getName(); + } + + if (name != null && !name.isEmpty()) { + displayName = name; + } + } else if (prismContainerValue.canRepresent(ItemConstraintType.class)) { + ItemConstraintType itemConstraintType = (ItemConstraintType) prismContainerValue.asContainerable(); + String path = ""; + if (itemConstraintType.getPath() != null) { + path = itemConstraintType.getPath().getItemPath().toString(); + } + + if (path != null && !path.isEmpty()) { + displayName = path; + } + } else if (prismContainerValue.canRepresent(AssignmentType.class)) { + AssignmentType assignmentType = (AssignmentType) prismContainerValue.asContainerable(); + if (assignmentType.getTargetRef() != null) { + ObjectReferenceType assignmentTargetRef = assignmentType.getTargetRef(); + displayName = getName(assignmentTargetRef) + " - " + normalizeRelation(assignmentTargetRef.getRelation()).getLocalPart(); + } else { + displayName = "AssignmentTypeDetailsPanel.containerTitle"; + } + } else if (prismContainerValue.canRepresent(ExclusionPolicyConstraintType.class)) { + ExclusionPolicyConstraintType exclusionConstraint = (ExclusionPolicyConstraintType) prismContainerValue.asContainerable(); + String exclusionConstraintName = (exclusionConstraint.getName() != null ? exclusionConstraint.getName() : + exclusionConstraint.asPrismContainerValue().getParent().getPath().last()) + " - " + + StringUtils.defaultIfEmpty(getName(exclusionConstraint.getTargetRef()), ""); + displayName = StringUtils.isNotEmpty(exclusionConstraintName) && StringUtils.isNotEmpty(getName(exclusionConstraint.getTargetRef())) ? exclusionConstraintName : "ExclusionPolicyConstraintType.details"; + } else if (prismContainerValue.canRepresent(AbstractPolicyConstraintType.class)) { + AbstractPolicyConstraintType constraint = (AbstractPolicyConstraintType) prismContainerValue.asContainerable(); + String constraintName = constraint.getName(); + if (StringUtils.isNotEmpty(constraintName)) { + displayName = constraintName; + } else { + displayName = constraint.asPrismContainerValue().getParent().getPath().last().toString() + ".details"; + } + } else if (prismContainerValue.canRepresent(RichHyperlinkType.class)) { + RichHyperlinkType richHyperlink = (RichHyperlinkType) prismContainerValue.asContainerable(); + String label = richHyperlink.getLabel(); + String description = richHyperlink.getDescription(); + String targetUrl = richHyperlink.getTargetUrl(); + if (StringUtils.isNotEmpty(label)) { + displayName = label + (StringUtils.isNotEmpty(description) ? (" - " + description) : ""); + } else if (StringUtils.isNotEmpty(targetUrl)) { + displayName = targetUrl; + } + } else if (prismContainerValue.canRepresent(UserInterfaceFeatureType.class)) { + UserInterfaceFeatureType userInterfaceFeature = (UserInterfaceFeatureType) prismContainerValue.asContainerable(); + String identifier = userInterfaceFeature.getIdentifier(); + + if (StringUtils.isBlank(identifier)) { + DisplayType uifDisplay = userInterfaceFeature.getDisplay(); + if (uifDisplay != null) { + displayName = WebComponentUtil.getOrigStringFromPoly(uifDisplay.getLabel()); + } + + if (displayName == null) { + displayName = "UserInterfaceFeatureType.containerTitle"; + } + } else { + displayName = identifier; + } + } else if (prismContainerValue.canRepresent(GuiObjectColumnType.class)) { + GuiObjectColumnType guiObjectColumn = (GuiObjectColumnType) prismContainerValue.asContainerable(); + String name = guiObjectColumn.getName(); + if (StringUtils.isNotEmpty(name)) { + displayName = name; + } + } else if (prismContainerValue.canRepresent(GuiObjectListViewType.class)) { + GuiObjectListViewType guiObjectListView = (GuiObjectListViewType) prismContainerValue.asContainerable(); + String name = guiObjectListView.getName(); + if (StringUtils.isNotEmpty(name)) { + displayName = name; + } + } else if (prismContainerValue.canRepresent(GenericPcpAspectConfigurationType.class)) { + GenericPcpAspectConfigurationType genericPcpAspectConfiguration = (GenericPcpAspectConfigurationType) prismContainerValue.asContainerable(); + String name = genericPcpAspectConfiguration.getName(); + if (StringUtils.isNotEmpty(name)) { + displayName = name; + } + } else if (prismContainerValue.canRepresent(RelationDefinitionType.class)) { + RelationDefinitionType relationDefinition = (RelationDefinitionType) prismContainerValue.asContainerable(); + if (relationDefinition.getRef() != null) { + String name = (relationDefinition.getRef().getLocalPart()); + String description = relationDefinition.getDescription(); + if (StringUtils.isNotEmpty(name)) { + displayName = name + (StringUtils.isNotEmpty(description) ? (" - " + description) : ""); + } + } + } else if (prismContainerValue.canRepresent(ResourceItemDefinitionType.class)) { + ResourceItemDefinitionType resourceItemDefinition = (ResourceItemDefinitionType) prismContainerValue.asContainerable(); + if (resourceItemDefinition.getDisplayName() != null && !resourceItemDefinition.getDisplayName().isEmpty()) { + displayName = resourceItemDefinition.getDisplayName(); + } else { + return prismContainerValue.getParent().getPath().last().toString(); + } + } else if (prismContainerValue.canRepresent(MappingType.class)) { + MappingType mapping = (MappingType) prismContainerValue.asContainerable(); + if (mapping.getName() != null && !mapping.getName().isEmpty()) { + String name = mapping.getName(); + String description = mapping.getDescription(); + displayName = name + (StringUtils.isNotEmpty(description) ? (" - " + description) : ""); + } + } else { + + Class cvalClass = prismContainerValue.getCompileTimeClass(); + if (cvalClass != null) { + displayName = cvalClass.getSimpleName() + ".details"; + } else { + displayName = "ContainerPanel.containerProperties"; + } + } + + + String escaped = org.apache.commons.lang.StringEscapeUtils.escapeHtml(displayName); + return escaped; + } + + public static QName normalizeRelation(QName relation) { + return getRelationRegistry().normalizeRelation(relation); + } + + public static String getDisplayNameOrName(PrismObject object) { + return getDisplayNameOrName(object, true); + } + + public static String getDisplayNameOrName(PrismObject object, boolean translate) { + return getDisplayNameOrName(object, translate, null); + } + + public static String getDisplayNameOrName(PrismObject object, boolean translate, LocalizationService localizationService) { + if (object == null) { + return null; + } + + String displayName = getDisplayName(object, translate, localizationService); + return displayName != null ? displayName : getName(object, translate, localizationService); + } + + public static String getDisplayNameOrName(ObjectReferenceType ref) { + return getDisplayNameOrName(ref, true); + } + + public static String getDisplayNameOrName(ObjectReferenceType ref, boolean translate) { + if (ref == null) { + return null; + } + String displayName = getDisplayName(ref, translate); + return StringUtils.isNotEmpty(displayName) ? displayName : getName(ref,translate); + } + + // () OR simply if there's no display name + public static String getDisplayNameAndName(ObjectReferenceType ref) { + return getDisplayNameOrName(ref, true); + } + + private static String getDisplayNameAndName(ObjectReferenceType ref, boolean translate) { + if (ref == null) { + return null; + } + String displayName = getDisplayName(ref, translate); + String name = getName(ref, translate); + return displayName != null ? displayName + " (" + name + ")" : name; + } + + public static String getDisplayName(ObjectReferenceType ref) { + return getDisplayName(ref, true); + } + + public static String getDisplayName(ObjectReferenceType ref, boolean translate) { + if (translate){ + return getTranslatedPolyString(ObjectTypeUtil.getDisplayName(ref)); + } else { + return PolyString.getOrig(ObjectTypeUtil.getDisplayName(ref)); + } + } + + public static String getDisplayName(PrismObject object) { + return getDisplayName(object, true); + } + + public static String getDisplayName(PrismObject object, boolean translate) { + return getDisplayName(object, translate, null); + } + + public static String getDisplayName(PrismObject object, boolean translate, LocalizationService localizationService) { + if (object == null){ + return ""; + } + if (translate){ + if (localizationService == null) { + return getTranslatedPolyString(ObjectTypeUtil.getDisplayName(object)); + } else { + return getTranslatedPolyString(PolyString.toPolyString(ObjectTypeUtil.getDisplayName(object)), localizationService); + } + } else { + return PolyString.getOrig(ObjectTypeUtil.getDisplayName(object)); + } + } + + public static PolyStringType createPolyFromOrigString(String str) { + if (str == null) { + return null; + } + + PolyStringType poly = new PolyStringType(); + poly.setOrig(str); + + return poly; + } + + public static String getOrigStringFromPoly(PolyString str) { + return str != null ? str.getOrig() : null; + } + + public static String getOrigStringFromPoly(PolyStringType str) { + return str != null ? str.getOrig() : null; + } + + public static T getValue(PrismContainerValue object, QName propertyName, Class type) { + if (object == null) { + return null; + } + + PrismProperty property = object.findProperty(ItemName.fromQName(propertyName)); + if (property == null || property.isEmpty()) { + return null; + } + + return (T) property.getRealValue(type); + } + + public static T getContainerValue(PrismContainerValue object, QName containerName, Class type) { + if (object == null) { + return null; + } + + PrismContainer container = object.findContainer(containerName); + if (container == null || container.isEmpty()) { + return null; + } + + PrismContainerValue containerValue = container.getValue(); + + if (containerValue == null || containerValue.isEmpty()) { + return null; + } + + return (T) containerValue.getValue(); + } + + public static T getValue(PrismContainer object, QName propertyName, Class type) { + if (object == null) { + return null; + } + + return getValue(object.getValue(), propertyName, type); + } + + public static Locale getLocaleFromString(String localeString) { + if (localeString == null) { + return null; + } + localeString = localeString.trim(); + if (localeString.toLowerCase().equals("default")) { + return Locale.getDefault(); + } + + // Extract language + int languageIndex = localeString.indexOf('_'); + String language = null; + if (languageIndex == -1) { + // No further "_" so is "{language}" only + return new Locale(localeString, ""); + } else { + language = localeString.substring(0, languageIndex); + } + + // Extract country + int countryIndex = localeString.indexOf('_', languageIndex + 1); + String country = null; + if (countryIndex == -1) { + // No further "_" so is "{language}_{country}" + country = localeString.substring(languageIndex + 1); + return new Locale(language, country); + } else { + // Assume all remaining is the variant so is + // "{language}_{country}_{variant}" + country = localeString.substring(languageIndex + 1, countryIndex); + String variant = localeString.substring(countryIndex + 1); + return new Locale(language, country, variant); + } + } + + public static void encryptCredentials(ObjectDelta delta, boolean encrypt, MidPointApplication app) { + if (delta == null || delta.isEmpty()) { + return; + } + + PropertyDelta propertyDelta = delta.findPropertyDelta(SchemaConstants.PATH_CREDENTIALS_PASSWORD_VALUE); + if (propertyDelta == null) { + return; + } + + Collection> values = propertyDelta + .getValues(ProtectedStringType.class); + for (PrismPropertyValue value : values) { + ProtectedStringType string = value.getValue(); + encryptProtectedString(string, encrypt, app); + } + } + + public static void encryptCredentials(PrismObject object, boolean encrypt, MidPointApplication app) { + PrismContainer password = object.findContainer(SchemaConstants.PATH_CREDENTIALS_PASSWORD); + if (password == null) { + return; + } + PrismProperty protectedStringProperty = password.findProperty(PasswordType.F_VALUE); + if (protectedStringProperty == null + || protectedStringProperty.getRealValue(ProtectedStringType.class) == null) { + return; + } + + ProtectedStringType string = (ProtectedStringType) protectedStringProperty + .getRealValue(ProtectedStringType.class); + + encryptProtectedString(string, encrypt, app); + } + + public static void encryptProtectedString(ProtectedStringType string, boolean encrypt, + MidPointApplication app) { + if (string == null) { + return; + } + Protector protector = app.getProtector(); + try { + if (encrypt) { + if (StringUtils.isEmpty(string.getClearValue())) { + return; + } + protector.encrypt(string); + } else { + if (string.getEncryptedDataType() == null) { + return; + } + protector.decrypt(string); + } + } catch (EncryptionException ex) { + LoggingUtils.logUnexpectedException(LOGGER, "Couldn't encrypt protected string", ex); + } catch (SchemaException e) { + LoggingUtils.logUnexpectedException(LOGGER, "Couldn't encrypt/decrypt protected string", e); + } + } + + public static List getSelectedData(Table table) { + DataTable dataTable = table.getDataTable(); + BaseSortableDataProvider provider = (BaseSortableDataProvider) dataTable.getDataProvider(); + + List selected = new ArrayList<>(); + for (T bean : provider.getAvailableData()) { + if (bean.isSelected()) { + selected.add(bean); + } + } + + return selected; + } + + public static void clearProviderCache(IDataProvider provider){ + if (provider == null){ + return; + } + if (provider instanceof BaseSortableDataProvider){ + ((BaseSortableDataProvider)provider).clearCache(); + } + if (provider instanceof SelectableBeanObjectDataProvider) { + ((SelectableBeanObjectDataProvider) provider).clearSelectedObjects(); + } + } + + public static Collection> createDeltaCollection( + ObjectDelta... deltas) { + Collection> collection = new ArrayList<>(); + for (ObjectDelta delta : deltas) { + collection.add(delta); + } + + return collection; + } + + public static boolean showResultInPage(OperationResult result) { + if (result == null) { + return false; + } + + return !result.isSuccess() && !result.isHandledError() && !result.isInProgress(); + } + + public static String formatDate(XMLGregorianCalendar calendar) { + if (calendar == null) { + return null; + } + + return formatDate(XmlTypeConverter.toDate(calendar)); + } + + public static String formatDate(Date date) { + return formatDate(null, date); + } + + public static String formatDate(String format, Date date) { + if (date == null) { + return null; + } + + if (StringUtils.isEmpty(format)) { + format = "EEEE, d. MMM yyyy HH:mm:ss"; + } + Locale locale = Session.get().getLocale(); + if (locale == null) { + locale = Locale.US; + } + SimpleDateFormat dateFormat = new SimpleDateFormat(format, locale); + return dateFormat.format(date); + } + + public static String getLocalizedDatePattern(String style) { + return DateTimeFormat.patternForStyle(style, getCurrentLocale()); + } + + public static Locale getCurrentLocale() { + Locale locale = Session.get().getLocale(); + if (locale == null) { + locale = Locale.getDefault(); + } + return locale; + } + + public static String getLocalizedDate(XMLGregorianCalendar date, String style) { + return getLocalizedDate(XmlTypeConverter.toDate(date), style); + } + + public static String getLocalizedDate(Date date, String style) { + if (date == null) { + return null; + } + PatternDateConverter converter = new PatternDateConverter(getLocalizedDatePattern(style), true); + return converter.convertToString(date, getCurrentLocale()); + } + + public static String getShortDateTimeFormattedValue(XMLGregorianCalendar date, PageBase pageBase) { + return getShortDateTimeFormattedValue(XmlTypeConverter.toDate(date), pageBase); + } + + public static String getShortDateTimeFormattedValue(Date date, PageBase pageBase) { + if (date == null) { + return ""; + } + String shortDateTimeFortam = getShortDateTimeFormat(pageBase); + return getLocalizedDate(date, shortDateTimeFortam); + } + + public static String getLongDateTimeFormattedValue(XMLGregorianCalendar date, PageBase pageBase) { + return getLongDateTimeFormattedValue(XmlTypeConverter.toDate(date), pageBase); + } + + public static String getLongDateTimeFormattedValue(Date date, PageBase pageBase) { + if (date == null) { + return ""; + } + String longDateTimeFormat = getLongDateTimeFormat(pageBase); + return getLocalizedDate(date, longDateTimeFormat); + } + + public static String getShortDateTimeFormat(PageBase pageBase){ + AdminGuiConfigurationDisplayFormatsType displayFormats = pageBase.getCompiledGuiProfile().getDisplayFormats(); + if (displayFormats == null || StringUtils.isEmpty(displayFormats.getShortDateTimeFormat())){ + return DateLabelComponent.SHORT_MEDIUM_STYLE; + } else { + return displayFormats.getShortDateTimeFormat(); + } + } + + public static String getLongDateTimeFormat(PageBase pageBase){ + AdminGuiConfigurationDisplayFormatsType displayFormats = pageBase.getCompiledGuiProfile().getDisplayFormats(); + if (displayFormats == null || StringUtils.isEmpty(displayFormats.getLongDateTimeFormat())){ + return DateLabelComponent.LONG_MEDIUM_STYLE; + } else { + return displayFormats.getLongDateTimeFormat(); + } + } + + public static boolean isActivationEnabled(PrismObject object) { + Validate.notNull(object); + + PrismContainer activation = object.findContainer(UserType.F_ACTIVATION); // this + // is + // equal + // to + // account + // activation... + if (activation == null) { + return false; + } + + ActivationStatusType status = (ActivationStatusType) activation + .getPropertyRealValue(ActivationType.F_ADMINISTRATIVE_STATUS, ActivationStatusType.class); + if (status == null) { + return false; + } + + // todo imrove with activation dates... + return ActivationStatusType.ENABLED.equals(status); + } + + public static boolean isSuccessOrHandledError(OperationResult result) { + if (result == null) { + return false; + } + + return result.isSuccess() || result.isHandledError(); + } + + public static boolean isSuccessOrHandledError(OperationResultType resultType) { + if (resultType == null) { + return false; + } + return resultType.getStatus() == OperationResultStatusType.SUCCESS || resultType.getStatus() == OperationResultStatusType.HANDLED_ERROR; + } + + public static boolean isSuccessOrHandledErrorOrWarning(OperationResult result) { + if (result == null) { + return false; + } + + return result.isSuccess() || result.isHandledError() || result.isWarning(); + } + + public static String createDefaultIcon(PrismObject object) { + Class type = object.getCompileTimeClass(); + if (type.equals(UserType.class)) { + return createUserIcon((PrismObject) object); + } else if (RoleType.class.equals(type)) { + return createRoleIcon((PrismObject) object); + } else if (OrgType.class.equals(type)) { + return createOrgIcon((PrismObject) object); + } else if (ServiceType.class.equals(type)) { + return createServiceIcon((PrismObject) object); + } else if (type.equals(TaskType.class)) { + return createTaskIcon((PrismObject) object); + } else if (type.equals(ResourceType.class)) { + return createResourceIcon((PrismObject) object); + } + + return ""; + } + + // TODO reconcile with ObjectTypeGuiDescriptor + public static String createDefaultColoredIcon(QName objectType) { + if (objectType == null) { + return ""; + } else if (QNameUtil.match(UserType.COMPLEX_TYPE, objectType) || QNameUtil.match(PersonaConstructionType.COMPLEX_TYPE, objectType)) { + return GuiStyleConstants.CLASS_OBJECT_USER_ICON_COLORED; + } else if (QNameUtil.match(RoleType.COMPLEX_TYPE, objectType)) { + return GuiStyleConstants.CLASS_OBJECT_ROLE_ICON_COLORED; + } else if (QNameUtil.match(OrgType.COMPLEX_TYPE, objectType)) { + return GuiStyleConstants.CLASS_OBJECT_ORG_ICON_COLORED; + } else if (QNameUtil.match(ServiceType.COMPLEX_TYPE, objectType)) { + return GuiStyleConstants.CLASS_OBJECT_SERVICE_ICON_COLORED; + } else if (QNameUtil.match(TaskType.COMPLEX_TYPE, objectType)) { + return GuiStyleConstants.CLASS_OBJECT_TASK_ICON_COLORED; + } else if (QNameUtil.match(ResourceType.COMPLEX_TYPE, objectType) || QNameUtil.match(ConstructionType.COMPLEX_TYPE, objectType)) { + return GuiStyleConstants.CLASS_OBJECT_RESOURCE_ICON_COLORED; + } else if (QNameUtil.match(AccessCertificationCampaignType.COMPLEX_TYPE, objectType)) { + return GuiStyleConstants.CLASS_OBJECT_CERT_CAMPAIGN_ICON_COLORED; + } else if (QNameUtil.match(AccessCertificationDefinitionType.COMPLEX_TYPE, objectType)) { + return GuiStyleConstants.CLASS_OBJECT_CERT_DEF_ICON_COLORED; + } else if (QNameUtil.match(CaseWorkItemType.COMPLEX_TYPE, objectType)) { + return GuiStyleConstants.CLASS_OBJECT_WORK_ITEM_ICON_COLORED; + } else if (QNameUtil.match(ShadowType.COMPLEX_TYPE, objectType)) { + return GuiStyleConstants.CLASS_OBJECT_SHADOW_ICON_COLORED; + } else if (QNameUtil.match(PolicyRuleType.COMPLEX_TYPE, objectType)) { + return GuiStyleConstants.CLASS_POLICY_RULES_ICON_COLORED; + } else if (QNameUtil.match(ObjectPolicyConfigurationType.COMPLEX_TYPE, objectType) || QNameUtil.match(GlobalPolicyRuleType.COMPLEX_TYPE, objectType) + || QNameUtil.match(FileAppenderConfigurationType.COMPLEX_TYPE, objectType) || QNameUtil.match(SyslogAppenderConfigurationType.COMPLEX_TYPE, objectType)) { + return GuiStyleConstants.CLASS_SYSTEM_CONFIGURATION_ICON_COLORED; + } else { + return ""; + } + } + + // TODO reconcile with ObjectTypeGuiDescriptor + public static String createDefaultBlackIcon(QName objectType) { + if (objectType == null) { + return ""; + } else if (QNameUtil.match(UserType.COMPLEX_TYPE, objectType) || QNameUtil.match(PersonaConstructionType.COMPLEX_TYPE, objectType)) { + return GuiStyleConstants.CLASS_OBJECT_USER_ICON; + } else if (QNameUtil.match(RoleType.COMPLEX_TYPE, objectType)) { + return GuiStyleConstants.CLASS_OBJECT_ROLE_ICON; + } else if (QNameUtil.match(OrgType.COMPLEX_TYPE, objectType)) { + return GuiStyleConstants.CLASS_OBJECT_ORG_ICON; + } else if (QNameUtil.match(ServiceType.COMPLEX_TYPE, objectType)) { + return GuiStyleConstants.CLASS_OBJECT_SERVICE_ICON; + } else if (QNameUtil.match(TaskType.COMPLEX_TYPE, objectType)) { + return GuiStyleConstants.CLASS_OBJECT_TASK_ICON; + } else if (QNameUtil.match(ResourceType.COMPLEX_TYPE, objectType) || QNameUtil.match(ConstructionType.COMPLEX_TYPE, objectType)) { + return GuiStyleConstants.CLASS_OBJECT_RESOURCE_ICON; + } else if (QNameUtil.match(AccessCertificationCampaignType.COMPLEX_TYPE, objectType)) { + return GuiStyleConstants.CLASS_OBJECT_CERT_CAMPAIGN_ICON; + } else if (QNameUtil.match(AccessCertificationDefinitionType.COMPLEX_TYPE, objectType)) { + return GuiStyleConstants.CLASS_OBJECT_CERT_DEF_ICON; + } else if (QNameUtil.match(CaseWorkItemType.COMPLEX_TYPE, objectType)) { + return GuiStyleConstants.CLASS_OBJECT_WORK_ITEM_ICON; + } else if (QNameUtil.match(ShadowType.COMPLEX_TYPE, objectType)) { + return GuiStyleConstants.CLASS_OBJECT_SHADOW_ICON; + } else if (QNameUtil.match(PolicyRuleType.COMPLEX_TYPE, objectType)) { + return GuiStyleConstants.CLASS_POLICY_RULES_ICON; + } else if (QNameUtil.match(SystemConfigurationType.COMPLEX_TYPE, objectType)) { + return GuiStyleConstants.CLASS_SYSTEM_CONFIGURATION_ICON; + } else if (QNameUtil.match(MappingType.COMPLEX_TYPE, objectType)) { + //TODO fix icon style for mapping type + return ""; + } else { + return ""; + } + } + + public static String getBoxCssClasses(QName objectType) { + if (QNameUtil.match(UserType.COMPLEX_TYPE, objectType)) { + return GuiStyleConstants.CLASS_OBJECT_USER_BOX_CSS_CLASSES; + } else if (QNameUtil.match(RoleType.COMPLEX_TYPE, objectType)) { + return GuiStyleConstants.CLASS_OBJECT_ROLE_BOX_CSS_CLASSES; + } else if (QNameUtil.match(OrgType.COMPLEX_TYPE, objectType)) { + return GuiStyleConstants.CLASS_OBJECT_ORG_BOX_CSS_CLASSES; + } else if (QNameUtil.match(ServiceType.COMPLEX_TYPE, objectType)) { + return GuiStyleConstants.CLASS_OBJECT_SERVICE_BOX_CSS_CLASSES; + } else if (QNameUtil.match(TaskType.COMPLEX_TYPE, objectType)) { + return GuiStyleConstants.CLASS_OBJECT_TASK_BOX_CSS_CLASSES; + } else if (QNameUtil.match(ResourceType.COMPLEX_TYPE, objectType)) { + return GuiStyleConstants.CLASS_OBJECT_RESOURCE_BOX_CSS_CLASSES; + } else { + return ""; + } + } + + public static String getBoxThinCssClasses(QName objectType) { + if (QNameUtil.match(UserType.COMPLEX_TYPE, objectType)) { + return GuiStyleConstants.CLASS_OBJECT_USER_BOX_THIN_CSS_CLASSES; + } else if (QNameUtil.match(RoleType.COMPLEX_TYPE, objectType)) { + return GuiStyleConstants.CLASS_OBJECT_ROLE_BOX_THIN_CSS_CLASSES; + } else if (QNameUtil.match(OrgType.COMPLEX_TYPE, objectType)) { + return GuiStyleConstants.CLASS_OBJECT_ORG_BOX_THIN_CSS_CLASSES; + } else if (QNameUtil.match(ServiceType.COMPLEX_TYPE, objectType)) { + return GuiStyleConstants.CLASS_OBJECT_SERVICE_BOX_THIN_CSS_CLASSES; + } else if (QNameUtil.match(TaskType.COMPLEX_TYPE, objectType)) { + return GuiStyleConstants.CLASS_OBJECT_TASK_BOX_THIN_CSS_CLASSES; + } else if (QNameUtil.match(ResourceType.COMPLEX_TYPE, objectType)) { + return GuiStyleConstants.CLASS_OBJECT_RESOURCE_BOX_THIN_CSS_CLASSES; + } else { + return ""; + } + } + + // can this implementation be made more efficient? [pm] + @SuppressWarnings("WeakerAccess") + public static boolean isOfKind(QName relation, RelationKindType kind) { + return getRelationRegistry().isOfKind(relation, kind); + } + + protected static RelationRegistry getRelationRegistry() { + if (staticallyProvidedRelationRegistry != null) { + return staticallyProvidedRelationRegistry; + } else { + return MidPointApplication.get().getRelationRegistry(); + } + } + + public static boolean isManagerRelation(QName relation) { + return isOfKind(relation, RelationKindType.MANAGER); + } + + public static boolean isDefaultRelation(QName relation) { + return getRelationRegistry().isDefault(relation); + } + + @SuppressWarnings("WeakerAccess") + public static QName getDefaultRelation() { + return getRelationRegistry().getDefaultRelation(); + } + + @NotNull + public static QName getDefaultRelationOrFail() { + QName relation = getDefaultRelation(); + if (relation != null) { + return relation; + } else { + throw new IllegalStateException("No default relation is defined"); + } + } + + @SuppressWarnings("WeakerAccess") + @Nullable + public static QName getDefaultRelationFor(RelationKindType kind) { + return getRelationRegistry().getDefaultRelationFor(kind); + } + + @NotNull + public static QName getDefaultRelationOrFail(RelationKindType kind) { + QName relation = getDefaultRelationFor(kind); + if (relation != null) { + return relation; + } else { + throw new IllegalStateException("No default relation for kind " + kind); + } + } + + @NotNull + public static String getRelationHeaderLabelKey(QName relation) { + String label = getRelationHeaderLabelKeyIfKnown(relation); + if (label != null) { + return label; + } else { + return relation != null ? relation.getLocalPart() : "default"; + } + } + + @Nullable + public static String getRelationHeaderLabelKeyIfKnown(QName relation) { + RelationDefinitionType definition = getRelationRegistry().getRelationDefinition(relation); + if (definition != null && definition.getDisplay() != null && definition.getDisplay().getLabel() != null) { + return definition.getDisplay().getLabel().getOrig(); + } else { + return null; + } + } + + public static String createUserIcon(PrismObject object) { + UserType user = object.asObjectable(); + + // if user has superuser role assigned, it's superuser + boolean isEndUser = false; + for (AssignmentType assignment : user.getAssignment()) { + ObjectReferenceType targetRef = assignment.getTargetRef(); + if (targetRef == null) { + continue; + } + if (StringUtils.equals(targetRef.getOid(), SystemObjectsType.ROLE_SUPERUSER.value())) { + return GuiStyleConstants.CLASS_OBJECT_USER_ICON + " " + + GuiStyleConstants.CLASS_ICON_STYLE_PRIVILEGED; + } + if (StringUtils.equals(targetRef.getOid(), SystemObjectsType.ROLE_END_USER.value())) { + isEndUser = true; + } + } + + boolean isManager = false; + for (ObjectReferenceType parentOrgRef : user.getParentOrgRef()) { + if (isManagerRelation(parentOrgRef.getRelation())) { + isManager = true; + break; + } + } + + String additionalStyle = ""; +// getIconEnabledDisabled(object); +// if (additionalStyle == null) { + // Set manager and end-user icon only as a last resort. All other + // colors have priority. + if (isManager) { + additionalStyle = GuiStyleConstants.CLASS_ICON_STYLE_MANAGER; + } else if (isEndUser) { + additionalStyle = GuiStyleConstants.CLASS_ICON_STYLE_END_USER; + } else { + additionalStyle = GuiStyleConstants.CLASS_ICON_STYLE_NORMAL; + } +// } + return GuiStyleConstants.CLASS_OBJECT_USER_ICON + " " + additionalStyle; + } + + public static String createRoleIcon(PrismObject object) { + for (AuthorizationType authorization : object.asObjectable().getAuthorization()) { + if (authorization.getAction().contains(AuthorizationConstants.AUTZ_ALL_URL)) { + return GuiStyleConstants.CLASS_OBJECT_ROLE_ICON + " " + + GuiStyleConstants.CLASS_ICON_STYLE_PRIVILEGED; + } + } + + return getObjectNormalIconStyle(GuiStyleConstants.CLASS_OBJECT_ROLE_ICON); + } + + public static String createOrgIcon(PrismObject object) { + return getObjectNormalIconStyle(GuiStyleConstants.CLASS_OBJECT_ORG_ICON); + } + + public static String createServiceIcon(PrismObject object) { + return getObjectNormalIconStyle(GuiStyleConstants.CLASS_OBJECT_SERVICE_ICON); + } + + private static String getObjectNormalIconStyle(String baseIcon){ + return baseIcon + " " + GuiStyleConstants.CLASS_ICON_STYLE_NORMAL; + } + + private static String getIconEnabledDisabled(PrismObject object, + String baseIcon) { + String additionalStyle = getIconEnabledDisabled(object); + if (additionalStyle == null) { + return baseIcon + " " + GuiStyleConstants.CLASS_ICON_STYLE_NORMAL; + } else { + return baseIcon + " " + additionalStyle; + } + } + + public static String getIconEnabledDisabled(PrismObject object) { + ActivationType activation = object.asObjectable().getActivation(); + if (activation != null) { + if (ActivationStatusType.DISABLED.equals(activation.getEffectiveStatus())) { + return GuiStyleConstants.CLASS_ICON_STYLE_DISABLED; + } else if (ActivationStatusType.ARCHIVED.equals(activation.getEffectiveStatus())) { + return GuiStyleConstants.CLASS_ICON_STYLE_ARCHIVED; + } + } + + return null; + } + + public static String createResourceIcon(PrismObject object) { + OperationalStateType operationalState = object.asObjectable().getOperationalState(); + if (operationalState != null) { + AvailabilityStatusType lastAvailabilityStatus = operationalState.getLastAvailabilityStatus(); + if (lastAvailabilityStatus == AvailabilityStatusType.UP) { + return GuiStyleConstants.CLASS_OBJECT_RESOURCE_ICON + " " + + GuiStyleConstants.CLASS_ICON_STYLE_UP; + } + if (lastAvailabilityStatus == AvailabilityStatusType.DOWN) { + return GuiStyleConstants.CLASS_OBJECT_RESOURCE_ICON + " " + + GuiStyleConstants.CLASS_ICON_STYLE_DOWN; + } + + if (lastAvailabilityStatus == AvailabilityStatusType.BROKEN) { + return GuiStyleConstants.CLASS_OBJECT_RESOURCE_ICON + " " + + GuiStyleConstants.CLASS_ICON_STYLE_BROKEN; + } + } + return GuiStyleConstants.CLASS_OBJECT_RESOURCE_ICON + " " + GuiStyleConstants.CLASS_ICON_STYLE_NORMAL; + } + + public static String createTaskIcon(PrismObject object) { + return GuiStyleConstants.CLASS_OBJECT_TASK_ICON + " " + GuiStyleConstants.CLASS_ICON_STYLE_NORMAL; + } + + public static String createShadowIcon(PrismContainerValue prismContainerValue) { + return createShadowIcon(((ShadowType)prismContainerValue.getRealValue()).asPrismContainer()); + } + + public static String createShadowIcon(PrismObject object) { + ShadowType shadow = object.asObjectable(); + + if (ShadowUtil.isProtected(object)) { + return GuiStyleConstants.CLASS_SHADOW_ICON_PROTECTED; + } + + ShadowKindType kind = shadow.getKind(); + if (kind == null) { + return GuiStyleConstants.CLASS_SHADOW_ICON_UNKNOWN; + } + + switch (kind) { + case ACCOUNT: + return GuiStyleConstants.CLASS_SHADOW_ICON_ACCOUNT; + case GENERIC: + return GuiStyleConstants.CLASS_SHADOW_ICON_GENERIC; + case ENTITLEMENT: + return GuiStyleConstants.CLASS_SHADOW_ICON_ENTITLEMENT; + + } + + return GuiStyleConstants.CLASS_SHADOW_ICON_UNKNOWN; + } + + public static void initNewObjectWithReference(PageBase pageBase, QName type, List newReferences) throws SchemaException { + PrismContext prismContext = pageBase.getPrismContext(); + PrismObjectDefinition def = prismContext.getSchemaRegistry().findObjectDefinitionByType(type); + PrismObject obj = def.instantiate(); + AHT assignmentHolder = obj.asObjectable(); + if (newReferences != null) { + newReferences.stream().forEach(ref -> { + AssignmentType assignment = new AssignmentType(); + assignment.setTargetRef(ref); + assignmentHolder.getAssignment().add(assignment); + + // Set parentOrgRef in any case. This is not strictly correct. + // The parentOrgRef should be added by the projector. But + // this is needed to successfully pass through security + // TODO: fix MID-3234 + if (ref.getType() != null && OrgType.COMPLEX_TYPE.equals(ref.getType())) { + assignmentHolder.getParentOrgRef().add(ref.clone()); + } + + }); + } + + WebComponentUtil.dispatchToObjectDetailsPage(obj, true, pageBase); + } + + public static String createErrorIcon(OperationResult result) { + if (result == null){ + return ""; + } + OperationResultStatus status = result.getStatus(); + OperationResultStatusPresentationProperties icon = OperationResultStatusPresentationProperties + .parseOperationalResultStatus(status); + return icon.getIcon() + " fa-lg"; + } + + public static void refreshFeedbacks(MarkupContainer component, final AjaxRequestTarget target) { + component.visitChildren(IFeedback.class, (IVisitor) (component1, visit) -> target.add(component1)); + } + + /* + * Methods used for providing prismContext into various objects. + */ + public static void revive(LoadableModel loadableModel, PrismContext prismContext) + throws SchemaException { + if (loadableModel != null) { + loadableModel.revive(prismContext); + } + } + + public static void reviveObject(Object object, PrismContext prismContext) throws SchemaException { + if (object == null) { + return; + } + if (object instanceof Collection) { + for (Object item : (Collection) object) { + reviveObject(item, prismContext); + } + } else if (object instanceof Revivable) { + ((Revivable) object).revive(prismContext); + } + } + + // useful for components other than those inheriting from PageBase + public static PrismContext getPrismContext(Component component) { + return ((MidPointApplication) component.getApplication()).getPrismContext(); + } + + + public static List getChannelList() { + List channels = new ArrayList<>(); + + for (Channel channel : Channel.values()) { + channels.add(channel.getChannel()); + } + + return channels; + } + + public static List getMatchingRuleList() { + List list = new ArrayList<>(); + + list.add(PrismConstants.DEFAULT_MATCHING_RULE_NAME); + list.add(PrismConstants.STRING_IGNORE_CASE_MATCHING_RULE_NAME); + list.add(PrismConstants.POLY_STRING_STRICT_MATCHING_RULE_NAME); + list.add(PrismConstants.POLY_STRING_ORIG_MATCHING_RULE_NAME); + list.add(PrismConstants.POLY_STRING_NORM_MATCHING_RULE_NAME); + list.add(PrismConstants.DISTINGUISHED_NAME_MATCHING_RULE_NAME); + list.add(PrismConstants.EXCHANGE_EMAIL_ADDRESSES_MATCHING_RULE_NAME); + list.add(PrismConstants.UUID_MATCHING_RULE_NAME); + list.add(PrismConstants.XML_MATCHING_RULE_NAME); + + return list; + } + + public static String createHumanReadableByteCount(long bytes) { + int unit = 1024; + if (bytes < unit) + return bytes + "B"; + int exp = (int) (Math.log(bytes) / Math.log(unit)); + char pre = "KMGTPE".charAt(exp - 1); + return String.format("%.1f%sB", bytes / Math.pow(unit, exp), pre); + } + + public static void setCurrentPage(Table table, ObjectPaging paging) { + if (table == null) { + return; + } + + if (paging == null) { + table.getDataTable().setCurrentPage(0); + return; + } + + long itemsPerPage = table.getDataTable().getItemsPerPage(); + long page = ((paging.getOffset() + itemsPerPage) / itemsPerPage) - 1; + if (page < 0) { + page = 0; + } + + table.getDataTable().setCurrentPage(page); + } + + public static PageBase getPageBase(Component component) { + Page page = component.getPage(); + if (page instanceof PageBase) { + return (PageBase) page; + } else if (page instanceof PageDialog) { + return ((PageDialog) page).getPageBase(); + } else { + throw new IllegalStateException("Couldn't determine page base for " + page); + } + } + + public static String debugHandler(IRequestHandler handler) { + if (handler == null) { + return null; + } + if (handler instanceof RenderPageRequestHandler) { + return "RenderPageRequestHandler(" + ((RenderPageRequestHandler) handler).getPageClass().getName() + + ")"; + } else { + return handler.toString(); + } + } + + // todo specify functionality of this method + public static ItemPath joinPath(ItemPath path1, ItemPath path2) { + ItemPath path = ItemPath.emptyIfNull(path1); + ItemPath deltaPath = ItemPath.emptyIfNull(path2); + List newPath = new ArrayList<>(); + + Object firstDeltaSegment = deltaPath.first(); + for (Object seg : path.getSegments()) { + if (ItemPath.segmentsEquivalent(seg, firstDeltaSegment)) { + break; + } + newPath.add(seg); + } + newPath.addAll(deltaPath.getSegments()); + + return ItemPath.create(newPath); + } + + public static T getObjectFromReference(ObjectReferenceType ref, Class type) { + if (ref == null || ref.asReferenceValue().getObject() == null) { + return null; + } + Objectable object = ref.asReferenceValue().getObject().asObjectable(); + if (!type.isAssignableFrom(object.getClass())) { + throw new IllegalStateException("Got " + object.getClass() + " when expected " + type + ": " + + ObjectTypeUtil.toShortString(ref, true)); + } + return (T) object; + } + + public static void dispatchToObjectDetailsPage(ObjectReferenceType objectRef, Component component, boolean failIfUnsupported) { + if (objectRef == null) { + return; // should not occur + } + Validate.notNull(objectRef.getOid(), "No OID in objectRef"); + Validate.notNull(objectRef.getType(), "No type in objectRef"); + Class targetClass = ObjectTypes.getObjectTypeFromTypeQName(objectRef.getType()).getClassDefinition(); + dispatchToObjectDetailsPage(targetClass, objectRef.getOid(), component, failIfUnsupported); + } + + public static void dispatchToObjectDetailsPage(PrismObject obj, Component component) { + dispatchToObjectDetailsPage(obj, false, component); + } + + // shows the actual object that is passed via parameter (not its state in repository) + public static void dispatchToObjectDetailsPage(PrismObject obj, boolean isNewObject, Component component) { + Class newObjectPageClass = isNewObject ? getNewlyCreatedObjectPage(obj.getCompileTimeClass()) : getObjectDetailsPage(obj.getCompileTimeClass()); + if (newObjectPageClass == null) { + throw new IllegalArgumentException("Cannot determine details page for "+obj.getCompileTimeClass()); + } + + Constructor constructor; + try { + PageBase page; + if (ResourceType.class.equals(obj.getCompileTimeClass())) { + constructor = newObjectPageClass.getConstructor(PageParameters.class); + page = (PageBase) constructor.newInstance(new PageParameters()); + } else { + constructor = newObjectPageClass.getConstructor(PrismObject.class, boolean.class); + page = (PageBase) constructor.newInstance(obj, isNewObject); + + } + if (component.getPage() instanceof PageBase) { + // this way we have correct breadcrumbs + PageBase pb = (PageBase) component.getPage(); + pb.navigateToNext(page); + } else { + component.setResponsePage(page); + } + } catch (NoSuchMethodException | SecurityException e) { + throw new SystemException("Unable to locate constructor (PrismObject) in " + newObjectPageClass + + + ": " + e.getMessage(), e); + } catch (InstantiationException | IllegalAccessException | IllegalArgumentException + | InvocationTargetException e) { + throw new SystemException("Error instantiating " + newObjectPageClass + ": " + e.getMessage(), e); + } + } + + public static void dispatchToObjectDetailsPage(Class objectClass, String oid, Component component, boolean failIfUnsupported) { + PageParameters parameters = new PageParameters(); + parameters.add(OnePageParameterEncoder.PARAMETER, oid); + Class page = getObjectDetailsPage(objectClass); + if (page != null) { + ((PageBase) component.getPage()).navigateToNext(page, parameters); + } else if (failIfUnsupported) { + throw new SystemException("Cannot determine details page for "+objectClass); + } + } + + public static boolean hasDetailsPage(PrismObject object) { + Class clazz = object.getCompileTimeClass(); + return hasDetailsPage(clazz); + } + + public static boolean hasDetailsPage(Class clazz) { + return objectDetailsPageMap.containsKey(clazz); + } + + public static boolean hasDetailsPage(ObjectReferenceType ref) { + if (ref == null) { + return false; + } + ObjectTypes t = ObjectTypes.getObjectTypeFromTypeQName(ref.getType()); + if (t == null) { + return false; + } + return hasDetailsPage(t.getClassDefinition()); + } + + public static String getStorageKeyForTableId(TableId tableId) { + return storageTableIdMap.get(tableId); + } + + public static Class getObjectDetailsPage(Class type) { + return objectDetailsPageMap.get(type); + } + + public static Class getNewlyCreatedObjectPage(Class type) { + if (ResourceType.class.equals(type)) { + return createNewObjectPageMap.get(type); + } else { + return objectDetailsPageMap.get(type); + } + } + + public static Class getObjectListPage(Class type) { + return objectListPageMap.get(type); + } + + @NotNull + public static TabbedPanel createTabPanel( + String id, final PageBase parentPage, final List tabs, TabbedPanel.RightSideItemProvider provider) { + return createTabPanel(id, parentPage, tabs, provider, null); + } + + @NotNull + public static TabbedPanel createTabPanel( + String id, final PageBase parentPage, final List tabs, TabbedPanel.RightSideItemProvider provider, + final String tabChangeParameter) { + + TabbedPanel tabPanel = new TabbedPanel(id, tabs, provider) { + private static final long serialVersionUID = 1L; + + @Override + protected void onTabChange(int index) { + if (tabChangeParameter != null) { + parentPage.updateBreadcrumbParameters(tabChangeParameter, index); + } + } + + @Override + protected WebMarkupContainer newLink(String linkId, final int index) { + return new AjaxSubmitLink(linkId) { + private static final long serialVersionUID = 1L; + + @Override + protected void onError(AjaxRequestTarget target) { + super.onError(target); + target.add(parentPage.getFeedbackPanel()); + } + + @Override + protected void onSubmit(AjaxRequestTarget target) { + super.onSubmit(target); + + setSelectedTab(index); + if (target != null) { + target.add(findParent(TabbedPanel.class)); + } + } + + }; + } + }; + tabPanel.setOutputMarkupId(true); + return tabPanel; + } + + public static Component createHelp(String id) { + Label helpLabel = new Label(id); + helpLabel.add(new InfoTooltipBehavior()); + return helpLabel; + } + + private static void debugDumpComponentTree(StringBuilder sb, Component c, int level) { + DebugUtil.indentDebugDump(sb, level); + sb.append(c).append("\n"); + if (c instanceof MarkupContainer) { + for (Component sub : (MarkupContainer) c) { + debugDumpComponentTree(sb, sub, level + 1); + } + } + } + + public static String exceptionToString(String message, Exception e) { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + pw.println(message); + e.printStackTrace(pw); + pw.close(); + return sw.toString(); + } + + public static Behavior visibleIfFalse(final NonEmptyModel model) { + return new VisibleEnableBehaviour() { + private static final long serialVersionUID = 1L; + + @Override + public boolean isVisible() { + return !model.getObject(); + } + }; + } + + public static Behavior enabledIfFalse(final NonEmptyModel model) { + return new VisibleEnableBehaviour() { + private static final long serialVersionUID = 1L; + + @Override + public boolean isEnabled() { + return !model.getObject(); + } + }; + } + + public static String getStringParameter(PageParameters params, String key) { + if (params == null || params.get(key) == null) { + return null; + } + + StringValue value = params.get(key); + if (StringUtils.isBlank(value.toString())) { + return null; + } + + return value.toString(); + } + + public static Integer getIntegerParameter(PageParameters params, String key) { + if (params == null || params.get(key) == null) { + return null; + } + + StringValue value = params.get(key); + if (!StringUtils.isNumeric(value.toString())) { + return null; + } + + return value.toInteger(); + } + + public static boolean isSubscriptionIdCorrect(String subscriptionId){ + if (StringUtils.isEmpty(subscriptionId)) { + return false; + } + if (!NumberUtils.isDigits(subscriptionId)){ + return false; + } + if (subscriptionId.length() < 11){ + return false; + } + String subscriptionType = subscriptionId.substring(0, 2); + boolean isTypeCorrect = false; + for (SubscriptionType type : SubscriptionType.values()){ + if (type.getSubscriptionType().equals(subscriptionType)){ + isTypeCorrect = true; + break; + } + } + if (!isTypeCorrect){ + return false; + } + String substring1 = subscriptionId.substring(2, 4); + String substring2 = subscriptionId.substring(4, 6); + try { + if (Integer.parseInt(substring1) < 1 || Integer.parseInt(substring1) > 12) { + return false; + } + + SimpleDateFormat dateFormat = new SimpleDateFormat("yy"); + String currentYear = dateFormat.format(Calendar.getInstance().getTime()); + if (Integer.parseInt(substring2) < Integer.parseInt(currentYear)){ + return false; + } + + String expDateStr = subscriptionId.substring(2, 6); + dateFormat = new SimpleDateFormat("MMyy"); + Date expDate = dateFormat.parse(expDateStr); + Calendar expireCalendarValue = Calendar.getInstance(); + expireCalendarValue.setTime(expDate); + expireCalendarValue.add(Calendar.MONTH, 1); + Date currentDate = new Date(System.currentTimeMillis()); + if (expireCalendarValue.getTime().before(currentDate) || expireCalendarValue.getTime().equals(currentDate)) { + return false; + } + } catch (Exception ex) { + return false; + } + VerhoeffCheckDigit checkDigit = new VerhoeffCheckDigit(); + if (checkDigit.isValid(subscriptionId)){ + return true; + } + return false; + } + + public static void setSelectedTabFromPageParameters(TabbedPanel tabbed, PageParameters params, String paramName) { + IModel tabsModel = tabbed.getTabs(); + + Integer tabIndex = getIntegerParameter(params, paramName); + if (tabIndex == null || tabIndex < 0 || tabIndex >= tabsModel.getObject().size()) { + return; + } + + tabbed.setSelectedTab(tabIndex); + } + + public static boolean getElementVisibility(UserInterfaceElementVisibilityType visibilityType){ + return getElementVisibility(visibilityType, new ArrayList<>()); + } + + public static boolean getElementVisibility(UserInterfaceElementVisibilityType visibilityType, List requiredAuthorizations){ + if (UserInterfaceElementVisibilityType.HIDDEN.equals(visibilityType) || + UserInterfaceElementVisibilityType.VACANT.equals(visibilityType)){ + return false; + } + if (UserInterfaceElementVisibilityType.VISIBLE.equals(visibilityType)){ + return true; + } + if (UserInterfaceElementVisibilityType.AUTOMATIC.equals(visibilityType)){ + return WebComponentUtil.isAuthorized(requiredAuthorizations); + } + return true; + } + + public static IModel createAbstractRoleConfirmationMessage(String actionName, + ColumnMenuAction action, MainObjectListPanel abstractRoleTable, PageBase pageBase) { + List selectedRoles = new ArrayList<>(); + if (action.getRowModel() == null) { + selectedRoles.addAll(abstractRoleTable.getSelectedObjects()); + } else { + selectedRoles.add(((SelectableBeanImpl) action.getRowModel().getObject()).getValue()); + } + OperationResult result = new OperationResult("Search Members"); + boolean atLeastOneWithMembers = false; + for (AR selectedRole : selectedRoles) { + ObjectQuery query = pageBase.getPrismContext().queryFor(FocusType.class) + .item(FocusType.F_ROLE_MEMBERSHIP_REF)// TODO MID-3581 + .ref(ObjectTypeUtil.createObjectRef(selectedRole, pageBase.getPrismContext()).asReferenceValue()) + .maxSize(1) + .build(); + List> members = WebModelServiceUtils.searchObjects(FocusType.class, query, result, pageBase); + if (CollectionUtils.isNotEmpty(members)) { + atLeastOneWithMembers = true; + break; + } + } + String members = atLeastOneWithMembers ? ".members" : ""; + ObjectTypes objectType = ObjectTypes.getObjectType(abstractRoleTable.getType()); + String propertyKeyPrefix = ObjectTypes.SERVICE.equals(objectType) ? "pageServices" : "pageRoles"; + + if (action.getRowModel() == null) { + return pageBase.createStringResource(propertyKeyPrefix + ".message.confirmationMessageForMultipleObject" + members, + actionName, abstractRoleTable.getSelectedObjectsCount()); + } else { + return pageBase.createStringResource(propertyKeyPrefix + ".message.confirmationMessageForSingleObject" + members, + actionName, ((ObjectType)((SelectableBeanImpl)action.getRowModel().getObject()).getValue()).getName()); + } + } + + public static DisplayType getNewObjectDisplayTypeFromCollectionView(CompiledObjectCollectionView view, PageBase pageBase){ + DisplayType displayType = view != null ? view.getDisplay() : null; + if (displayType == null){ + displayType = WebComponentUtil.createDisplayType(GuiStyleConstants.CLASS_ADD_NEW_OBJECT, "green", ""); + } + if (PolyStringUtils.isEmpty(displayType.getTooltip()) && !PolyStringUtils.isEmpty(displayType.getLabel())){ + StringBuilder sb = new StringBuilder(); + sb.append(pageBase.createStringResource("MainObjectListPanel.newObject").getString()); + sb.append(" "); + sb.append(displayType.getLabel().getOrig().toLowerCase()); + displayType.setTooltip(WebComponentUtil.createPolyFromOrigString(sb.toString())); + } + return view != null ? view.getDisplay() : null; + } + + /** + * Returns name of the collection suitable to be displayed in the menu or other labels. + * E.g. "All tasks", "Active employees". + */ + public static PolyStringType getCollectionLabel(DisplayType viewDisplayType, CollectionRefSpecificationType collectionRefSpec ,ObjectType collectionRefTarget) { + if (viewDisplayType != null) { + PolyStringType viewPluralLabel = viewDisplayType.getPluralLabel(); + if (viewPluralLabel != null) { + return viewPluralLabel; + } + PolyStringType viewLabel = viewDisplayType.getLabel(); + if (viewLabel != null) { + return viewLabel; + } + } + if (collectionRefTarget != null) { + if (collectionRefTarget instanceof ObjectCollectionType) { + // MID-5709 + // TODO: use collectionRefTarget.getDisplay() first - when the schema is updated + } + // TODO: try to use archetype policy? + return collectionRefTarget.getName(); + } + return null; + } + + public static ItemVisibility checkShadowActivationAndPasswordVisibility(ItemWrapper itemWrapper, + ShadowType shadowType) { + ObjectReferenceType resourceRef = shadowType.getResourceRef(); + if (resourceRef == null) { + //TODO: what to return if we don't have resource available? + return ItemVisibility.AUTO; + } + PrismObject resource = resourceRef.asReferenceValue().getObject(); + if (resource == null) { + //TODO: what to return if we don't have resource available? + return ItemVisibility.AUTO; + } + ResourceType resourceType = resource.asObjectable(); + + CompositeRefinedObjectClassDefinition ocd = null; + + try { + RefinedResourceSchema resourceSchema = RefinedResourceSchema.getRefinedSchema(resource); + ocd = resourceSchema.determineCompositeObjectClassDefinition(shadowType.asPrismObject()); + } catch (SchemaException e) { + LOGGER.error("Cannot find refined definition for {} in {}", shadowType, resource); + } + ResourceObjectTypeDefinitionType resourceObjectTypeDefinitionType = ResourceTypeUtil.findObjectTypeDefinition(resource, shadowType.getKind(), shadowType.getIntent()); + + + if (SchemaConstants.PATH_ACTIVATION.equivalent(itemWrapper.getPath())) { + if (ResourceTypeUtil.isActivationCapabilityEnabled(resourceType, resourceObjectTypeDefinitionType)) { + return ItemVisibility.AUTO; + } else { + return ItemVisibility.HIDDEN; + } + } + + if (SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS.equivalent(itemWrapper.getPath())) { + if (ResourceTypeUtil.isActivationStatusCapabilityEnabled(resourceType, resourceObjectTypeDefinitionType)) { + return ItemVisibility.AUTO; + } else { + return ItemVisibility.HIDDEN; + } + } + + if (SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS.equivalent(itemWrapper.getPath())) { + if (ResourceTypeUtil.isActivationLockoutStatusCapabilityEnabled(resourceType, resourceObjectTypeDefinitionType)) { + return ItemVisibility.AUTO; + } else { + return ItemVisibility.HIDDEN; + } + } + + if (SchemaConstants.PATH_ACTIVATION_VALID_FROM.equivalent(itemWrapper.getPath())) { + if (ResourceTypeUtil.isActivationValidityFromCapabilityEnabled(resourceType, resourceObjectTypeDefinitionType)) { + return ItemVisibility.AUTO; + } else { + return ItemVisibility.HIDDEN; + } + } + + if (SchemaConstants.PATH_ACTIVATION_VALID_TO.equivalent(itemWrapper.getPath())) { + if (ResourceTypeUtil.isActivationValidityToCapabilityEnabled(resourceType, resourceObjectTypeDefinitionType)) { + return ItemVisibility.AUTO; + } else { + return ItemVisibility.HIDDEN; + } + } + + if (SchemaConstants.PATH_PASSWORD.equivalent(itemWrapper.getPath())) { + if (ResourceTypeUtil.isPasswordCapabilityEnabled(resourceType, resourceObjectTypeDefinitionType)) { + return ItemVisibility.AUTO; + } else { + return ItemVisibility.HIDDEN; + } + } + + if (ShadowType.F_ASSOCIATION.equivalent(itemWrapper.getPath())) { + if (ocd != null && CollectionUtils.isNotEmpty(ocd.getAssociationDefinitions())) { + return ItemVisibility.AUTO; + } else { + return ItemVisibility.HIDDEN; + } + } + + return ItemVisibility.AUTO; + + } + + public static boolean isActivationSupported(ShadowType shadowType) { + ObjectReferenceType resourceRef = shadowType.getResourceRef(); + if (resourceRef == null) { + //TODO: what to return if we don't have resource available? + return true; + } + PrismObject resource = resourceRef.asReferenceValue().getObject(); + if (resource == null) { + //TODO: what to return if we don't have resource available? + return true; + } + + ResourceObjectTypeDefinitionType resourceObjectTypeDefinitionType = ResourceTypeUtil.findObjectTypeDefinition(resource, shadowType.getKind(), shadowType.getIntent()); + + if (ResourceTypeUtil.isActivationCapabilityEnabled(resource.asObjectable(), resourceObjectTypeDefinitionType)) { + return true; + } + + return false; + + } + + public static boolean isPasswordSupported(ShadowType shadowType) { + ObjectReferenceType resourceRef = shadowType.getResourceRef(); + if (resourceRef == null) { + //TODO: what to return if we don't have resource available? + return true; + } + PrismObject resource = resourceRef.asReferenceValue().getObject(); + if (resource == null) { + //TODO: what to return if we don't have resource available? + return true; + } + + ResourceObjectTypeDefinitionType resourceObjectTypeDefinitionType = ResourceTypeUtil.findObjectTypeDefinition(resource, shadowType.getKind(), shadowType.getIntent()); + + if (ResourceTypeUtil.isPasswordCapabilityEnabled(resource.asObjectable(), resourceObjectTypeDefinitionType)) { + return true; + } + + return false; + + } + + + public static boolean isAssociationSupported(ShadowType shadowType) { + ObjectReferenceType resourceRef = shadowType.getResourceRef(); + if (resourceRef == null) { + //TODO: what to return if we don't have resource available? + return true; + } + PrismObject resource = resourceRef.asReferenceValue().getObject(); + if (resource == null) { + //TODO: what to return if we don't have resource available? + return true; + } + + CompositeRefinedObjectClassDefinition ocd = null; + + try { + RefinedResourceSchema resourceSchema = RefinedResourceSchema.getRefinedSchema(resource); + ocd = resourceSchema.determineCompositeObjectClassDefinition(shadowType.asPrismObject()); + } catch (SchemaException e) { + LOGGER.error("Cannot find refined definition for {} in {}", shadowType, resource); + } + + if (ocd == null) { + return false; + } + + return CollectionUtils.isNotEmpty(ocd.getAssociationDefinitions()); + } + + public static void refreshResourceSchema(@NotNull PrismObject resource, String operation, AjaxRequestTarget target, PageBase pageBase){ + Task task = pageBase.createSimpleTask(operation); + OperationResult parentResult = new OperationResult(operation); + + try { + ResourceUtils.deleteSchema(resource, pageBase.getModelService(), pageBase.getPrismContext(), task, parentResult); + pageBase.getModelService().testResource(resource.getOid(), task); // try to load fresh scehma + } catch (ObjectAlreadyExistsException | ObjectNotFoundException | SchemaException + | ExpressionEvaluationException | CommunicationException | ConfigurationException + | PolicyViolationException | SecurityViolationException e) { + LoggingUtils.logUnexpectedException(LOGGER, "Error refreshing resource schema", e); + parentResult.recordFatalError(pageBase.createStringResource("WebComponentUtil.message.refreshResourceSchema.fatalError").getString(), e); + } + + parentResult.computeStatus(); + pageBase.showResult(parentResult, "pageResource.refreshSchema.failed"); + target.add(pageBase.getFeedbackPanel()); + } + + public static List getCategoryRelationChoices(AreaCategoryType category, ModelServiceLocator pageBase){ + List relationsList = new ArrayList<>(); + List defList = getRelationDefinitions(pageBase); + defList.forEach(def -> { + if (def.getCategory() != null && def.getCategory().contains(category)) { + relationsList.add(def.getRef()); + } + }); + return relationsList; + } + + public static QName getCategoryDefaultRelation(AreaCategoryType category){ + if (AreaCategoryType.GOVERNANCE.equals(category)) { + return RelationTypes.APPROVER.getRelation(); + } + return null; + } + + public static List getAllRelations(ModelServiceLocator pageBase) { + List allRelationDefinitions = getRelationDefinitions(pageBase); + List allRelationsQName = new ArrayList<>(allRelationDefinitions.size()); + allRelationDefinitions.forEach(relation -> allRelationsQName.add(relation.getRef())); + return allRelationsQName; + } + + @NotNull + public static List getRelationDefinitions(ModelServiceLocator pageBase) { + return pageBase.getModelInteractionService().getRelationDefinitions(); + } + + public static RelationDefinitionType getRelationDefinition(QName relation) { + return getRelationRegistry().getRelationDefinition(relation); + } + + public static List prepareAutoCompleteList(LookupTableType lookupTable, String input, + LocalizationService localizationService){ + List values = new ArrayList<>(); + + if (lookupTable == null) { + return values; + } + + List rows = lookupTable.getRow(); + + if (input == null || input.isEmpty()) { + for (LookupTableRowType row : rows) { + + PolyString polystring = null; + if (row.getLabel() != null) { + polystring = setTranslateToPolystring(row); + } + values.add(localizationService.translate(polystring, getCurrentLocale(), true)); + } + } else { + for (LookupTableRowType row : rows) { + if (row.getLabel() == null) { + continue; + } + PolyString polystring = setTranslateToPolystring(row); + String rowLabel = localizationService.translate(polystring, getCurrentLocale(), true); + if (rowLabel != null && rowLabel.toLowerCase().contains(input.toLowerCase())) { + values.add(rowLabel); + } + } + } + return values; + } + + private static PolyString setTranslateToPolystring(LookupTableRowType row){ + PolyString polystring = row.getLabel().toPolyString(); + return setTranslateToPolystring(polystring); + } + + private static PolyString setTranslateToPolystring(PolyString polystring){ + if (org.apache.commons.lang3.StringUtils.isNotBlank(polystring.getOrig())) { + if (polystring.getTranslation() == null) { + PolyStringTranslationType translation = new PolyStringTranslationType(); + translation.setKey(polystring.getOrig()); + if (org.apache.commons.lang3.StringUtils.isBlank(translation.getFallback())) { + translation.setFallback(polystring.getOrig()); + } + polystring.setTranslation(translation); + } else if (org.apache.commons.lang3.StringUtils.isNotBlank(polystring.getTranslation().getKey())) { + polystring.getTranslation().setKey(polystring.getOrig()); + if (org.apache.commons.lang3.StringUtils.isBlank(polystring.getTranslation().getFallback())) { + polystring.getTranslation().setFallback(polystring.getOrig()); + } + } + } + return polystring; + } + + public static DropDownChoice createTriStateCombo(String id, IModel model) { + final IChoiceRenderer renderer = new IChoiceRenderer() { + + @Override + public Boolean getObject(String id, IModel> choices) { + return id != null ? choices.getObject().get(Integer.parseInt(id)) : null; + } + + @Override + public String getDisplayValue(Boolean object) { + String key; + if (object == null) { + key = KEY_BOOLEAN_NULL; + } else { + key = object ? KEY_BOOLEAN_TRUE : KEY_BOOLEAN_FALSE; + } + + StringResourceModel model = PageBase.createStringResourceStatic(null, key); + + return model.getString(); + } + + @Override + public String getIdValue(Boolean object, int index) { + return Integer.toString(index); + } + }; + + DropDownChoice dropDown = new DropDownChoice(id, model, createChoices(), renderer) { + + @Override + protected CharSequence getDefaultChoice(String selectedValue) { + StringResourceModel model = PageBase.createStringResourceStatic(null, KEY_BOOLEAN_NULL); + + return model.getString(); + } + }; + dropDown.setNullValid(true); + + return dropDown; + } + + public static boolean isAllNulls(Iterable array) { + return StreamSupport.stream(array.spliterator(), true).allMatch(o -> o == null); + } + + public static ObjectFilter createAssociationShadowRefFilter(RefinedAssociationDefinition refinedAssocationDefinition, PrismContext prismContext, + String resourceOid){ + S_FilterEntryOrEmpty atomicFilter = prismContext.queryFor(ShadowType.class); + List orFilterClauses = new ArrayList<>(); + refinedAssocationDefinition.getIntents() + .forEach(intent -> orFilterClauses.add(atomicFilter.item(ShadowType.F_INTENT).eq(intent).buildFilter())); + OrFilter intentFilter = prismContext.queryFactory().createOr(orFilterClauses); + + AndFilter filter = (AndFilter) atomicFilter.item(ShadowType.F_KIND).eq(refinedAssocationDefinition.getKind()).and() + .item(ShadowType.F_RESOURCE_REF).ref(resourceOid, ResourceType.COMPLEX_TYPE).buildFilter(); + filter.addCondition(intentFilter); + return filter; + } + + private static IModel> createChoices() { + return (IModel>) () -> { + List list = new ArrayList<>(); + list.add(null); + list.add(Boolean.TRUE); + list.add(Boolean.FALSE); + + return list; + }; + } + + private static LookupTableType createAppenderChoices(List appenders) { + LookupTableType lookupTable = new LookupTableType(); + List list = lookupTable.createRowList(); + + for (AppenderConfigurationType appender : appenders) { + LookupTableRowType row = new LookupTableRowType(); + String name = appender.getName(); + row.setKey(name); + row.setValue(name); + row.setLabel(new PolyStringType(name)); + list.add(row); + } + return lookupTable; + } + + public static Class getPreviousPageClass(PageBase parentPage){ + List breadcrumbs = parentPage.getBreadcrumbs(); + if (breadcrumbs == null || breadcrumbs.size() < 2){ + return null; + } + Breadcrumb previousBreadcrumb = breadcrumbs.get(breadcrumbs.size() - 2); + Class page = null; + if (previousBreadcrumb instanceof BreadcrumbPageClass){ + page = ((BreadcrumbPageClass) previousBreadcrumb).getPage(); + } else if (previousBreadcrumb instanceof BreadcrumbPageInstance){ + page = ((BreadcrumbPageInstance) previousBreadcrumb).getPage().getClass(); + } + return page; + } + + @NotNull + public static List createMenuItemsFromActions(@NotNull List actions, String operation, + PageBase pageBase, @NotNull Supplier> selectedObjectsSupplier) { + List menuItems = new ArrayList<>(); + actions.forEach(action -> { + if (action.getTaskTemplateRef() == null) { + return; + } + String templateOid = action.getTaskTemplateRef().getOid(); + if (StringUtils.isEmpty(templateOid)) { + return; + } + String label = action.getDisplay() != null && PolyStringUtils.isNotEmpty(action.getDisplay().getLabel()) ? + action.getDisplay().getLabel().getOrig() : action.getName(); + menuItems.add(new InlineMenuItem(Model.of(label)) { + private static final long serialVersionUID = 1L; + + @Override + public InlineMenuItemAction initAction() { + return new InlineMenuItemAction() { + private static final long serialVersionUID = 1L; + + @Override + public void onClick(AjaxRequestTarget target) { + OperationResult result = new OperationResult(operation); + try { + Collection oids = CollectionUtils.emptyIfNull(selectedObjectsSupplier.get()) + .stream() + .filter(o -> o.getOid() != null) + .map(o -> o.getOid()) + .collect(Collectors.toSet()); + if (!oids.isEmpty()) { + Map extensionValues = prepareExtensionValues(oids); + TaskType executorTask = pageBase.getModelInteractionService().submitTaskFromTemplate( + templateOid, extensionValues, pageBase.createSimpleTask(operation), result); + result.recordInProgress(); // this should be probably have been done in submitTaskFromTemplate + result.setBackgroundTaskOid(executorTask.getOid()); + } else { + result.recordWarning(pageBase.createStringResource("WebComponentUtil.message.createMenuItemsFromActions.warning").getString()); + } + } catch (Exception ex) { + result.recordFatalError(result.getOperation(), ex); + target.add(pageBase.getFeedbackPanel()); + } finally { + pageBase.showResult(result); + target.add(pageBase.getFeedbackPanel()); + } + } + }; + } + + /** + * Extension values are task-dependent. Therefore, in the future we will probably make + * this behaviour configurable. For the time being we assume that the task template will be + * of "iterative task handler" type and so it will expect mext:objectQuery extension property. + */ + + @NotNull + private Map prepareExtensionValues(Collection oids) throws SchemaException { + Map extensionValues = new HashMap<>(); + PrismContext prismContext = pageBase.getPrismContext(); + ObjectQuery objectQuery = prismContext.queryFor(ObjectType.class) + .id(oids.toArray(new String[0])) + .build(); + QueryType queryBean = pageBase.getQueryConverter().createQueryType(objectQuery); + extensionValues.put(SchemaConstants.MODEL_EXTENSION_OBJECT_QUERY, queryBean); + return extensionValues; + } + }); + }); + return menuItems; + } + + @SuppressWarnings("unused") + public static RelationRegistry getStaticallyProvidedRelationRegistry() { + return staticallyProvidedRelationRegistry; + } + + public static ObjectFilter getAssignableRolesFilter(PrismObject focusObject, Class type, AssignmentOrder assignmentOrder, + OperationResult result, Task task, PageBase pageBase) { + return getAssignableRolesFilter(focusObject, type, null, assignmentOrder, result, task, pageBase); + } + + public static ObjectFilter getAssignableRolesFilter(PrismObject focusObject, Class type, + QName relation, AssignmentOrder assignmentOrder, + OperationResult result, Task task, PageBase pageBase) { + ObjectFilter filter = null; + LOGGER.debug("Loading objects which can be assigned"); + try { + ModelInteractionService mis = pageBase.getModelInteractionService(); + RoleSelectionSpecification roleSpec = + mis.getAssignableRoleSpecification(focusObject, type, assignmentOrder.getOrder(), task, result); + filter = roleSpec.getGlobalFilter(); + if (relation != null){ + ObjectFilter relationFilter = roleSpec.getRelationFilter(relation); + if (filter == null){ + return relationFilter; + } else if (relationFilter == null){ + return filter; + } else { + return pageBase.getPrismContext().queryFactory().createOr(filter, relationFilter); + } + } + } catch (Exception ex) { + LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load available roles", ex); + result.recordFatalError(pageBase.createStringResource("WebComponentUtil.message.getAssignableRolesFilter.fatalError").getString(), ex); + } finally { + result.recomputeStatus(); + } + if (!result.isSuccess() && !result.isHandledError()) { + pageBase.showResult(result); + } + return filter; + } + + public static List getAssignableRelationsList(PrismObject focusObject, Class type, + AssignmentOrder assignmentOrder, + OperationResult result, Task task, PageBase pageBase){ + List relationsList = null; + LOGGER.debug("Loading assignable relations list"); + try { + ModelInteractionService mis = pageBase.getModelInteractionService(); + RoleSelectionSpecification roleSpec = + mis.getAssignableRoleSpecification(focusObject, type, assignmentOrder.getOrder(), task, result); + relationsList = roleSpec != null && roleSpec.getGlobalFilter() == null && roleSpec.getRelationMap() != null ? + new ArrayList(roleSpec.getRelationMap().keySet()) : null; + } catch (Exception ex) { + LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load assignable relations list", ex); + result.recordFatalError(pageBase.createStringResource("WebComponentUtil.message.getAssignableRelationsList.fatalError").getString(), ex); + } finally { + result.recomputeStatus(); + } + if (!result.isSuccess() && !result.isHandledError()) { + pageBase.showResult(result); + } + return relationsList; + } + + public static String formatDurationWordsForLocal(long durationMillis, boolean suppressLeadingZeroElements, + boolean suppressTrailingZeroElements, PageBase pageBase){ + + String duration = DurationFormatUtils.formatDurationWords(durationMillis, suppressLeadingZeroElements, suppressTrailingZeroElements); + + duration = StringUtils.replaceOnce(duration, "seconds", pageBase.createStringResource("WebComponentUtil.formatDurationWordsForLocal.seconds").getString()); + duration = StringUtils.replaceOnce(duration, "minutes", pageBase.createStringResource("WebComponentUtil.formatDurationWordsForLocal.minutes").getString()); + duration = StringUtils.replaceOnce(duration, "hours", pageBase.createStringResource("WebComponentUtil.formatDurationWordsForLocal.hours").getString()); + duration = StringUtils.replaceOnce(duration, "days", pageBase.createStringResource("WebComponentUtil.formatDurationWordsForLocal.days").getString()); + duration = StringUtils.replaceOnce(duration, "second", pageBase.createStringResource("WebComponentUtil.formatDurationWordsForLocal.second").getString()); + duration = StringUtils.replaceOnce(duration, "minute", pageBase.createStringResource("WebComponentUtil.formatDurationWordsForLocal.minute").getString()); + duration = StringUtils.replaceOnce(duration, "hour", pageBase.createStringResource("WebComponentUtil.formatDurationWordsForLocal.hour").getString()); + duration = StringUtils.replaceOnce(duration, "day", pageBase.createStringResource("WebComponentUtil.formatDurationWordsForLocal.day").getString()); + + return duration; + } + + public static List loadResourceObjectClassValues(ResourceType resource, PageBase pageBase){ + try { + ResourceSchema schema = RefinedResourceSchemaImpl.getResourceSchema(resource, pageBase.getPrismContext()); + if (schema != null) { + return schema.getObjectClassList(); + } + } catch (SchemaException|RuntimeException e){ + LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load object class list from resource.", e); + pageBase.error("Couldn't load object class list from resource."); + } + return new ArrayList<>(); + } + + public static List getRefinedAssociationDefinition(ResourceType resource, ShadowKindType kind, String intent){ + List associationDefinitions = new ArrayList<>(); + + try { + + if (resource == null) { + return associationDefinitions; + } + RefinedResourceSchema refinedResourceSchema = RefinedResourceSchema.getRefinedSchema(resource.asPrismObject()); + RefinedObjectClassDefinition oc = refinedResourceSchema.getRefinedDefinition(kind, intent); + if (oc == null) { + LOGGER.debug("Association for {}/{} not supported by resource {}", kind, intent, resource); + return associationDefinitions; + } + associationDefinitions.addAll(oc.getAssociationDefinitions()); + + if (CollectionUtils.isEmpty(associationDefinitions)) { + LOGGER.debug("Association for {}/{} not supported by resource {}", kind, intent, resource); + return associationDefinitions; + } + } catch (Exception ex) { + LOGGER.error("Association for {}/{} not supported by resource {}: {}", kind, intent, resource, ex.getLocalizedMessage()); + } + return associationDefinitions; + } + + public static String getAssociationDisplayName(RefinedAssociationDefinition assocDef) { + if (assocDef == null){ + return ""; + } + StringBuilder sb = new StringBuilder(); + if (assocDef.getDisplayName() != null) { + sb.append(assocDef.getDisplayName()).append(", "); + } + if (assocDef.getResourceObjectAssociationType() != null && assocDef.getResourceObjectAssociationType().getRef() != null) { + sb.append("ref: ").append(assocDef.getResourceObjectAssociationType().getRef().getItemPath().toString()); + } + return sb.toString(); + } + + @Deprecated + public static ExpressionType getAssociationExpression(PrismContainerValueWrapper assignmentValueWrapper, PageBase pageBase) { + return getAssociationExpression(assignmentValueWrapper, false, null, pageBase); + } + + //TODO refactor.. + @Deprecated + public static ExpressionType getAssociationExpression(PrismContainerValueWrapper assignmentValueWrapper, + boolean createIfNotExist, PrismContext prismContext, PageBase pageBase) { + if (assignmentValueWrapper == null){ + return null; + } + if (createIfNotExist && prismContext == null) { + throw new IllegalArgumentException("createIfNotExist is set but prismContext is null"); + } + PrismContainerWrapper association; + try { + association = assignmentValueWrapper + .findContainer(ItemPath.create(AssignmentType.F_CONSTRUCTION, ConstructionType.F_ASSOCIATION)); + } catch (SchemaException e) { + LOGGER.error("Cannot find association wrapper, reason: {}", e.getMessage(), e); + pageBase.getSession().error("Cannot find association wrapper, reason: " + e.getMessage()); + return null; + } + + if (association == null || association.getValues() == null || association.getValues().size() == 0){ + return null; + } + //FIXME HACK not to add empty association value + if (ContainerStatus.ADDING.equals(association.getStatus())){ + association.getItem().clear(); + } + PrismContainerValueWrapper associationValueWrapper = association.getValues().get(0); + PrismPropertyWrapper expressionWrapper; + try { + expressionWrapper = associationValueWrapper.findProperty(ItemPath.create(ResourceObjectAssociationType.F_OUTBOUND, MappingType.F_EXPRESSION)); + } catch (SchemaException e) { + LOGGER.error("Cannot find expression wrapper, reason: {}", e.getMessage(), e); + pageBase.getSession().error("Cannot find expression wrapper, reason: " + e.getMessage()); + return null; + } + + if (expressionWrapper == null){ + return null; + } + List> expressionValues = expressionWrapper.getValues(); + if (expressionValues == null || expressionValues.size() == 0){ + return null; + } + try { + ExpressionType expression = expressionValues.get(0).getRealValue(); + if (expression == null && createIfNotExist) { + expression = new ExpressionType(); + PrismPropertyValue exp = prismContext.itemFactory().createPropertyValue(expression); + WrapperContext context = new WrapperContext(null, null); + PrismPropertyValueWrapper val = (PrismPropertyValueWrapper) pageBase + .createValueWrapper(expressionWrapper, exp, ValueStatus.ADDED, context); + // ValueWrapperOld val = new + // ValueWrapperOld<>(expressionWrapper, exp, prismContext); + expressionValues.remove(0); + expressionValues.add(0, val); + } + } catch (SchemaException e) { + // TODO erro handling + return null; + } + return expressionValues.get(0).getRealValue(); + } + + public static PrismObject getConstructionResource(ConstructionType construction, String operation, PageBase pageBase){ + ObjectReferenceType resourceRef = construction.getResourceRef(); + if (resourceRef.asReferenceValue().getObject() != null) { + return resourceRef.asReferenceValue().getObject(); + } + OperationResult result = new OperationResult(operation); + Task task = pageBase.createSimpleTask(operation); + return WebModelServiceUtils.resolveReferenceNoFetch(resourceRef, pageBase, task, result); + } + + public static ArchetypePolicyType getArchetypeSpecification(PrismObject object, ModelServiceLocator locator){ + if (object == null || object.asObjectable() == null){ + return null; + } + String objectName = object.asObjectable().getName() != null ? object.asObjectable().getName().getOrig() : "Unknown"; + OperationResult result = new OperationResult("loadArchetypeSpecificationFor" + objectName); + if (!object.canRepresent(AssignmentHolderType.class)) { + return null; + } + ArchetypePolicyType spec = null; + try { + spec = locator.getModelInteractionService().determineArchetypePolicy((PrismObject) object, result); + } catch (SchemaException | ConfigurationException ex){ + result.recordPartialError(ex.getLocalizedMessage()); + LOGGER.error("Cannot load ArchetypeInteractionSpecification for object {}: {}", object, ex.getLocalizedMessage()); + } + return spec; + } + + public static String getIconCssClass(DisplayType displayType){ + if (displayType == null || displayType.getIcon() == null){ + return ""; + } + return displayType.getIcon().getCssClass(); + } + + public static String getIconColor(DisplayType displayType){ + if (displayType == null || displayType.getIcon() == null){ + return ""; + } + return displayType.getIcon().getColor(); + } + + public static String getDisplayTypeTitle(DisplayType displayType){ + if (displayType == null || displayType.getTooltip() == null){ + return ""; + } + return displayType.getTooltip().getOrig(); + } + + public static DisplayType getDisplayTypeForObject(O obj, OperationResult result, PageBase pageBase){ + if (obj == null){ + return null; + } + if (obj instanceof ArchetypeType && ((ArchetypeType)obj).getArchetypePolicy() != null) { + return ((ArchetypeType)obj).getArchetypePolicy().getDisplay(); + } + DisplayType displayType = WebComponentUtil.getArchetypePolicyDisplayType(obj, pageBase); +// if (displayType != null){ +// String disabledStyle = ""; +// if (obj instanceof FocusType) { +// disabledStyle = WebComponentUtil.getIconEnabledDisabled(((FocusType)obj).asPrismObject()); +// if (displayType.getIcon() != null && StringUtils.isNotEmpty(displayType.getIcon().getCssClass()) && +// disabledStyle != null){ +// displayType.getIcon().setCssClass(displayType.getIcon().getCssClass() + " " + disabledStyle); +// displayType.getIcon().setColor(""); +// } +// } +// } else { + if (displayType == null){ + displayType = WebComponentUtil.createDisplayType(createDefaultIcon(obj.asPrismObject()), + "", ColumnUtils.getIconColumnTitle(obj, result)); + } + return displayType; + } + + public static CompositedIcon createCompositeIconForObject(O obj, OperationResult result, PageBase pageBase){ + DisplayType basicIconDisplayType = getDisplayTypeForObject(obj, result, pageBase); + CompositedIconBuilder iconBuilder = new CompositedIconBuilder(); + if (basicIconDisplayType == null){ + return new CompositedIconBuilder().build(); + } + IconType lifecycleStateIcon = getIconForLifecycleState(obj); + IconType activationStatusIcon = getIconForActivationStatus(obj); + StringBuilder title = new StringBuilder(basicIconDisplayType.getTooltip() != null ? basicIconDisplayType.getTooltip().getOrig() : ""); + + if (StringUtils.isNotEmpty(lifecycleStateIcon.getCssClass())){ + if (title.length() > 0){ + title.append("\n"); + } + title.append(pageBase.createStringResource("ObjectType.lifecycleState").getString()) + .append(": ") + .append(obj.getLifecycleState()); + } + if (StringUtils.isNotEmpty(activationStatusIcon.getCssClass()) && obj instanceof FocusType + && ((FocusType)obj).getActivation() != null){ + if (title.length() > 0){ + title.append("\n"); + } + String lockedStatus = LockoutStatusType.LOCKED.equals(((FocusType)obj).getActivation().getLockoutStatus()) ? + ((FocusType)obj).getActivation().getLockoutStatus().value() : ""; + String effectiveStatus = ((FocusType)obj).getActivation().getEffectiveStatus() != null ? + ((FocusType)obj).getActivation().getEffectiveStatus().value() : ""; + title.append(pageBase.createStringResource("CapabilitiesType.activationStatus").getString()) + .append(": ") + .append(StringUtils.isNotEmpty(lockedStatus) ? lockedStatus : effectiveStatus); + } + String iconColor = getIconColor(basicIconDisplayType); + + CompositedIconBuilder builder = iconBuilder.setBasicIcon( + getIconCssClass(basicIconDisplayType), IconCssStyle.IN_ROW_STYLE) + .appendColorHtmlValue(StringUtils.isNotEmpty(iconColor) ? iconColor : "") + .appendLayerIcon(lifecycleStateIcon, IconCssStyle.BOTTOM_LEFT_FOR_COLUMN_STYLE) + .appendLayerIcon(activationStatusIcon, IconCssStyle.BOTTOM_RIGHT_FOR_COLUMN_STYLE); + + if (StringUtils.isNotEmpty(title.toString())){ + builder.setTitle(title.toString()); + } + return builder.build(); + } + + public static IconType getIconForLifecycleState(O obj){ + IconType icon = new IconType(); + if (obj == null){ + icon.setCssClass(""); + return icon; + } + if (SchemaConstants.LIFECYCLE_ARCHIVED.equals(obj.getLifecycleState())){ + icon.setCssClass(GuiStyleConstants.CLASS_FILE_EXCEL); + } else if (SchemaConstants.LIFECYCLE_DRAFT.equals(obj.getLifecycleState())){ + icon.setCssClass(GuiStyleConstants.CLASS_FILE_BLACK_FILLED); + } else if (SchemaConstants.LIFECYCLE_PROPOSED.equals(obj.getLifecycleState())){ + icon.setCssClass(GuiStyleConstants.CLASS_FILE_WHITE_FILLED); + } + if (icon.getCssClass() == null){ + icon.setCssClass(""); + } + icon.setColor("blue"); + return icon; + } + + public static IconType getIconForActivationStatus(O obj){ + IconType icon = new IconType(); + if (obj == null || !(obj instanceof FocusType) || ((FocusType) obj).getActivation() == null){ + icon.setCssClass(""); + return icon; + } + if (LockoutStatusType.LOCKED.equals(((FocusType) obj).getActivation().getLockoutStatus())){ + icon.setCssClass(GuiStyleConstants.CLASS_LOCK_STATUS); + } else if (ActivationStatusType.DISABLED.equals(((FocusType) obj).getActivation().getEffectiveStatus())){ + icon.setCssClass(GuiStyleConstants.CLASS_BAN); + } else if (ActivationStatusType.ARCHIVED.equals(((FocusType) obj).getActivation().getEffectiveStatus())){ + icon.setCssClass(GuiStyleConstants.CLASS_ICON_NO_OBJECTS); + } else if (!ActivationStatusType.ENABLED.equals(((FocusType) obj).getActivation().getEffectiveStatus())){ + icon.setCssClass(GuiStyleConstants.CLASS_TEST_CONNECTION_MENU_ITEM); + } + if (icon.getCssClass() == null){ + icon.setCssClass(""); + } + icon.setColor("red"); + return icon; + } + + public static DisplayType createDisplayType(String iconCssClass){ + return createDisplayType(iconCssClass, "", ""); + } + + public static DisplayType createDisplayType(String iconCssClass, String iconColor, String title){ + DisplayType displayType = new DisplayType(); + IconType icon = new IconType(); + icon.setCssClass(iconCssClass); + icon.setColor(iconColor); + displayType.setIcon(icon); + + displayType.setTooltip(createPolyFromOrigString(title)); + return displayType; + } + + public static DisplayType createDisplayType(String iconCssClass, PolyStringType title){ + DisplayType displayType = new DisplayType(); + IconType icon = new IconType(); + icon.setCssClass(iconCssClass); + displayType.setIcon(icon); + + displayType.setTooltip(title); + return displayType; + } + + public static IconType createIconType(String iconStyle){ + return createIconType(iconStyle, ""); + } + + public static IconType createIconType(String iconStyle, String color){ + IconType icon = new IconType(); + icon.setCssClass(iconStyle); + icon.setColor(color); + return icon; + } + + + public static CompositedIconBuilder getAssignmentRelationIconBuilder(PageBase pageBase, AssignmentObjectRelation relationSpec, + IconType relationIcon, IconType actionButtonIcon){ + CompositedIconBuilder builder = new CompositedIconBuilder(); + if (relationSpec == null){ + if (actionButtonIcon == null){ + return null; + } + builder.setBasicIcon(actionButtonIcon, IconCssStyle.IN_ROW_STYLE) + .appendColorHtmlValue(actionButtonIcon.getColor()); + return builder; + } + DisplayType objectTypeDisplay = null; + if (CollectionUtils.isNotEmpty(relationSpec.getArchetypeRefs())){ + try { + String operation = pageBase.getClass().getSimpleName() + "." + "loadArchetypeObject"; + ArchetypeType archetype = pageBase.getModelObjectResolver().resolve(relationSpec.getArchetypeRefs().get(0), ArchetypeType.class, + null, null, pageBase.createSimpleTask(operation), + new OperationResult(operation)); + if (archetype != null && archetype.getArchetypePolicy() != null){ + objectTypeDisplay = archetype.getArchetypePolicy().getDisplay(); + } + } catch (Exception ex){ + LOGGER.error("Couldn't load archetype object, " + ex.getLocalizedMessage()); + } + } + if (objectTypeDisplay == null){ + objectTypeDisplay = new DisplayType(); + } + if (objectTypeDisplay.getIcon() == null){ + objectTypeDisplay.setIcon(new IconType()); + } + QName objectType = org.apache.commons.collections.CollectionUtils.isNotEmpty(relationSpec.getObjectTypes()) ? relationSpec.getObjectTypes().get(0) : null; + if (StringUtils.isEmpty(WebComponentUtil.getIconCssClass(objectTypeDisplay)) && objectType != null){ + objectTypeDisplay.getIcon().setCssClass(WebComponentUtil.createDefaultBlackIcon(objectType)); + } + if (StringUtils.isNotEmpty(WebComponentUtil.getIconCssClass(objectTypeDisplay))) { + builder.setBasicIcon(objectTypeDisplay.getIcon(), IconCssStyle.IN_ROW_STYLE) + .appendColorHtmlValue(WebComponentUtil.getIconColor(objectTypeDisplay)) + .appendLayerIcon(actionButtonIcon, IconCssStyle.BOTTOM_RIGHT_STYLE) + .appendLayerIcon(relationIcon, IconCssStyle.TOP_RIGHT_STYLE); + } else { + builder.setBasicIcon(actionButtonIcon, IconCssStyle.IN_ROW_STYLE) + .appendColorHtmlValue(actionButtonIcon.getColor()); + } + return builder; + } + + + public static DisplayType getArchetypePolicyDisplayType(O object, PageBase pageBase) { + if (object != null) { + ArchetypePolicyType archetypePolicy = WebComponentUtil.getArchetypeSpecification(object.asPrismObject(), pageBase); + if (archetypePolicy != null) { + return archetypePolicy.getDisplay(); + } + } + return null; + } + + public static IModel getIconUrlModel(IconType icon){ + if (icon == null || StringUtils.isEmpty(icon.getImageUrl())){ + return Model.of(); + } + String sUrl = icon.getImageUrl(); + if (URI.create(sUrl).isAbsolute()) { + return Model.of(sUrl); + } + + List segments = RequestCycle.get().getUrlRenderer().getBaseUrl().getSegments(); + if (segments == null || segments.size() < 2) { + return Model.of(sUrl); + } + + String prefix = StringUtils.repeat("../", segments.size() - 1); + if (!sUrl.startsWith("/")) { + return Model.of(prefix + sUrl); + } + + return Model.of(StringUtils.left(prefix, prefix.length() - 1) + sUrl); + } + + public static void deleteSyncTokenPerformed(AjaxRequestTarget target, ResourceType resourceType, PageBase pageBase){ + String resourceOid = resourceType.getOid(); + String handlerUri = "http://midpoint.evolveum.com/xml/ns/public/model/synchronization/task/live-sync/handler-3"; + ObjectReferenceType resourceRef = new ObjectReferenceType(); + resourceRef.setOid(resourceOid); + PrismObject oldTask; + + OperationResult result = new OperationResult(pageBase.getClass().getName() + "." + "deleteSyncToken"); + ObjectQuery query = pageBase.getPrismContext().queryFor(TaskType.class) + .item(TaskType.F_OBJECT_REF).ref(resourceOid) + .and().item(TaskType.F_HANDLER_URI).eq(handlerUri) + .build(); + + List> taskList = WebModelServiceUtils.searchObjects(TaskType.class, query, result, pageBase); + + if (taskList.size() != 1) { + pageBase.error(pageBase.createStringResource("pageResource.message.invalidTaskSearch")); + } else { + oldTask = taskList.get(0); + saveTask(oldTask, result, pageBase); + } + + result.recomputeStatus(); + pageBase.showResult(result); + target.add(pageBase.getFeedbackPanel()); + } + + /** + * The idea is to divide the list of AssignmentObjectRelation objects in such way that each AssignmentObjectRelation + * in the list will contain not more than 1 relation. This will simplify creating of a new_assignment_button + * on some panels + * + * @param initialRelationsList + * @return + */ + public static List divideAssignmentRelationsByRelationValue(List initialRelationsList){ + if (org.apache.commons.collections.CollectionUtils.isEmpty(initialRelationsList)){ + return initialRelationsList; + } + List combinedRelationList = new ArrayList<>(); + initialRelationsList.forEach(assignmentTargetRelation -> { + if (org.apache.commons.collections.CollectionUtils.isEmpty(assignmentTargetRelation.getObjectTypes()) && + org.apache.commons.collections.CollectionUtils.isEmpty(assignmentTargetRelation.getRelations())){ + return; + } + if (org.apache.commons.collections.CollectionUtils.isEmpty(assignmentTargetRelation.getRelations())){ + combinedRelationList.add(assignmentTargetRelation); + } else { + assignmentTargetRelation.getRelations().forEach(relation -> { + AssignmentObjectRelation relationObj = new AssignmentObjectRelation(); + relationObj.setObjectTypes(assignmentTargetRelation.getObjectTypes()); + relationObj.setRelations(Arrays.asList(relation)); + relationObj.setArchetypeRefs(assignmentTargetRelation.getArchetypeRefs()); + relationObj.setDescription(assignmentTargetRelation.getDescription()); + combinedRelationList.add(relationObj); + }); + } + }); + return combinedRelationList; + } + + /** + * The idea is to divide the list of AssignmentObjectRelation objects in such way that each AssignmentObjectRelation + * in the list will contain not more than 1 relation, not more than 1 object type and not more than one archetype reference. + * This will simplify creating of a new_assignment_button + * + * @param initialAssignmentRelationsList + * @return + */ + public static List divideAssignmentRelationsByAllValues(List initialAssignmentRelationsList){ + if (initialAssignmentRelationsList == null){ + return null; + } + List dividedByRelationList = divideAssignmentRelationsByRelationValue(initialAssignmentRelationsList); + List resultList = new ArrayList<>(); + dividedByRelationList.forEach(assignmentObjectRelation -> { + if (CollectionUtils.isNotEmpty(assignmentObjectRelation.getObjectTypes())){ + assignmentObjectRelation.getObjectTypes().forEach(objectType -> { + if (CollectionUtils.isNotEmpty(assignmentObjectRelation.getArchetypeRefs())){ + assignmentObjectRelation.getArchetypeRefs().forEach(archetypeRef -> { + AssignmentObjectRelation newRelation = new AssignmentObjectRelation(); + newRelation.setObjectTypes(Arrays.asList(objectType)); + newRelation.setRelations(assignmentObjectRelation.getRelations()); + newRelation.setArchetypeRefs(Arrays.asList(archetypeRef)); + newRelation.setDescription(assignmentObjectRelation.getDescription()); + resultList.add(newRelation); + }); + } else { + AssignmentObjectRelation newRelation = new AssignmentObjectRelation(); + newRelation.setObjectTypes(Arrays.asList(objectType)); + newRelation.setRelations(assignmentObjectRelation.getRelations()); + newRelation.setArchetypeRefs(assignmentObjectRelation.getArchetypeRefs()); + newRelation.setDescription(assignmentObjectRelation.getDescription()); + resultList.add(newRelation); + } + }); + } else { + if (CollectionUtils.isNotEmpty(assignmentObjectRelation.getArchetypeRefs())){ + assignmentObjectRelation.getArchetypeRefs().forEach(archetypeRef -> { + AssignmentObjectRelation newRelation = new AssignmentObjectRelation(); + newRelation.setObjectTypes(assignmentObjectRelation.getObjectTypes()); + newRelation.setRelations(assignmentObjectRelation.getRelations()); + newRelation.setArchetypeRefs(Arrays.asList(archetypeRef)); + newRelation.setDescription(assignmentObjectRelation.getDescription()); + resultList.add(newRelation); + }); + } else { + AssignmentObjectRelation newRelation = new AssignmentObjectRelation(); + newRelation.setObjectTypes(assignmentObjectRelation.getObjectTypes()); + newRelation.setRelations(assignmentObjectRelation.getRelations()); + newRelation.setArchetypeRefs(assignmentObjectRelation.getArchetypeRefs()); + newRelation.setDescription(assignmentObjectRelation.getDescription()); + resultList.add(newRelation); + } + } + }); + return resultList; + } + + public static DisplayType getAssignmentObjectRelationDisplayType(PageBase pageBase, AssignmentObjectRelation assignmentTargetRelation, + String defaultTitleKey){ + if (assignmentTargetRelation == null){ + return createDisplayType("", "", pageBase.createStringResource(defaultTitleKey, "", "").getString()); + } + + String typeTitle = ""; + if (CollectionUtils.isNotEmpty(assignmentTargetRelation.getArchetypeRefs())){ + OperationResult result = new OperationResult(pageBase.getClass().getSimpleName() + "." + "loadArchetypeObject"); + try { + ArchetypeType archetype = pageBase.getModelObjectResolver().resolve(assignmentTargetRelation.getArchetypeRefs().get(0), ArchetypeType.class, + null, null, pageBase.createSimpleTask(result.getOperation()), result); + if (archetype != null) { + DisplayType archetypeDisplayType = archetype.getArchetypePolicy() != null ? archetype.getArchetypePolicy().getDisplay() : null; + String archetypeTooltip = archetypeDisplayType != null && archetypeDisplayType.getLabel() != null && + StringUtils.isNotEmpty(archetypeDisplayType.getLabel().getOrig()) ? + archetypeDisplayType.getLabel().getOrig() : + (archetype.getName() != null && StringUtils.isNotEmpty(archetype.getName().getOrig()) ? + archetype.getName().getOrig() : null); + typeTitle = StringUtils.isNotEmpty(archetypeTooltip) ? + pageBase.createStringResource("abstractRoleMemberPanel.withType", archetypeTooltip).getString() : ""; + } + } catch (Exception ex){ + LOGGER.error("Couldn't load archetype object. " + ex.getLocalizedMessage()); + } + } else if (CollectionUtils.isNotEmpty(assignmentTargetRelation.getObjectTypes())){ + QName type = !CollectionUtils.isEmpty(assignmentTargetRelation.getObjectTypes()) ? + assignmentTargetRelation.getObjectTypes().get(0) : null; + String typeName = type != null ? pageBase.createStringResource("ObjectTypeLowercase." + type.getLocalPart()).getString() : null; + typeTitle = StringUtils.isNotEmpty(typeName) ? + pageBase.createStringResource("abstractRoleMemberPanel.withType", typeName).getString() : ""; + } + + + QName relation = !CollectionUtils.isEmpty(assignmentTargetRelation.getRelations()) ? + assignmentTargetRelation.getRelations().get(0) : null; + + String relationValue = ""; + String relationTitle = ""; + if (relation != null){ + RelationDefinitionType def = WebComponentUtil.getRelationDefinition(relation); + if (def != null){ + DisplayType displayType = null; + if (def.getDisplay() == null){ + displayType = new DisplayType(); + } else { + displayType = createDisplayType(def.getDisplay().getCssClass()); + if (def.getDisplay().getIcon() != null){ + displayType.setIcon(new IconType()); + displayType.getIcon().setCssClass(def.getDisplay().getIcon().getCssClass()); + displayType.getIcon().setColor(def.getDisplay().getIcon().getColor()); + } + } + if (displayType.getLabel() != null && StringUtils.isNotEmpty(displayType.getLabel().getOrig())){ + relationValue = pageBase.createStringResource(displayType.getLabel().getOrig()).getString(); + } else { + String relationKey = "RelationTypes." + RelationTypes.getRelationTypeByRelationValue(relation); + relationValue = pageBase.createStringResource(relationValue).getString(); + if (StringUtils.isEmpty(relationValue) || relationKey.equals(relationValue)){ + relationValue = relation.getLocalPart(); + } + } + + relationTitle = pageBase.createStringResource("abstractRoleMemberPanel.withRelation", relationValue).getString(); + + + if (displayType.getIcon() == null || StringUtils.isEmpty(displayType.getIcon().getCssClass())){ + displayType.setIcon(createIconType("")); + } + displayType.setTooltip(createPolyFromOrigString(pageBase.createStringResource(defaultTitleKey, typeTitle, relationTitle).getString())); + return displayType; + } + } + return createDisplayType(GuiStyleConstants.EVO_ASSIGNMENT_ICON, "green", pageBase.createStringResource(defaultTitleKey, typeTitle, relationTitle).getString()); + } + + public static void saveTask(PrismObject oldTask, OperationResult result, PageBase pageBase){ + Task task = pageBase.createSimpleTask(pageBase.getClass().getName() + "." + "saveSyncTask"); + + PrismProperty property = oldTask.findProperty(ItemPath.create(TaskType.F_EXTENSION, SchemaConstants.SYNC_TOKEN)); + + if(property == null){ + return; + } + Object value = property.getRealValue(); + + ObjectDelta delta = pageBase.getPrismContext().deltaFactory().object().createModifyDelta(oldTask.getOid(), + pageBase.getPrismContext().deltaFactory().property() + .createModificationDeleteProperty(ItemPath.create(TaskType.F_EXTENSION, SchemaConstants.SYNC_TOKEN), property.getDefinition(), value), + TaskType.class); + + if(LOGGER.isTraceEnabled()){ + LOGGER.trace(delta.debugDump()); + } + + try { + pageBase.getModelService().executeChanges(WebComponentUtil.createDeltaCollection(delta), null, task, result); + } catch (Exception e){ + LoggingUtils.logUnexpectedException(LOGGER, "Couldn't save task.", e); + result.recordFatalError(pageBase.createStringResource("WebModelUtils.couldntSaveTask").getString(), e); + } + result.recomputeStatus(); + } + + // TODO: use LocalizationService.translate(polyString) instead + @Deprecated + public static String getLocalizedOrOriginPolyStringValue(PolyString polyString){ + String value = getLocalizedPolyStringValue(setTranslateToPolystring(polyString)); + if(value == null) { + return getOrigStringFromPoly(polyString); + } + return value; + } + + @Deprecated + private static String getLocalizedPolyStringValue(PolyString polyString){ + if (polyString == null){ + return null; + } + if ((polyString.getTranslation() == null || StringUtils.isEmpty(polyString.getTranslation().getKey())) && + (polyString.getLang() == null || polyString.getLang().isEmpty())){ + return null; + } + if (polyString.getLang() != null && !polyString.getLang().isEmpty()){ + //check if it's really selected by user or configured through sysconfig locale + String currentLocale = getCurrentLocale().getLanguage(); + for (String language : polyString.getLang().keySet()){ + if (currentLocale.equals(language)){ + return polyString.getLang().get(language); + } + } + } + + if (polyString.getTranslation() != null && StringUtils.isNotEmpty(polyString.getTranslation().getKey())){ + List argumentValues = new ArrayList<>(); + polyString.getTranslation().getArgument().forEach(argument -> { + String argumentValue = ""; + String translationValue = ""; + if (argument.getTranslation() != null){ + String argumentKey = argument.getTranslation().getKey(); + String valueByKey = StringUtils.isNotEmpty(argumentKey) ? new StringResourceModel(argumentKey).getString() : null; + translationValue = StringUtils.isNotEmpty(valueByKey) ? valueByKey : argument.getTranslation().getFallback(); + } + argumentValue = StringUtils.isNotEmpty(translationValue) ? translationValue : argument.getValue(); + argumentValues.add(argumentValue); + }); + return new StringResourceModel(polyString.getTranslation().getKey()) + .setDefaultValue(polyString.getTranslation().getKey()) + .setModel(new Model()) + .setParameters(argumentValues.toArray()) + .getString(); + } + return null; + } + + public static List sortDropDownChoices(IModel> choicesModel, IChoiceRenderer renderer){ + List sortedList = choicesModel.getObject().stream().sorted((choice1, choice2) -> { + if (choice1 == null || choice2 == null){ + return 0; + } + return String.CASE_INSENSITIVE_ORDER.compare(renderer.getDisplayValue(choice1).toString(), renderer.getDisplayValue(choice2).toString()); + + + }).collect(Collectors.toList()); + return sortedList; + } + + public static SceneDto createSceneDto(CaseWorkItemType caseWorkItem, PageBase pageBase, String operation){ + if (caseWorkItem == null){ + return null; + } + return createSceneDto(CaseTypeUtil.getCase(caseWorkItem), pageBase, operation); + } + + public static List computeTriggers(ApprovalContextType wfc, Integer stage) { + List triggers = new ArrayList<>(); + if (wfc == null) { + return triggers; + } + EvaluatedTriggerGroupDto.UniquenessFilter uniquenessFilter = new EvaluatedTriggerGroupDto.UniquenessFilter(); + List> rulesPerStageList = ApprovalContextUtil.getRulesPerStage(wfc); + for (int i = 0; i < rulesPerStageList.size(); i++) { + Integer stageNumber = i + 1; + boolean highlighted = stageNumber.equals(stage); + EvaluatedTriggerGroupDto group = EvaluatedTriggerGroupDto.initializeFromRules(rulesPerStageList.get(i), highlighted, uniquenessFilter); + triggers.add(group); + } + return triggers; + } + + public static SceneDto createSceneDto(CaseType caseObject, PageBase pageBase, String operation){ + if (caseObject == null || caseObject.getApprovalContext() == null) { + return null; + } + ObjectReferenceType objectRef = caseObject.getObjectRef(); + + OperationResult result = new OperationResult(operation); + Task task = pageBase.createSimpleTask(operation); + try { + Scene deltasScene = SceneUtil.visualizeObjectTreeDeltas(caseObject.getApprovalContext().getDeltasToApprove(), "pageWorkItem.delta", + pageBase.getPrismContext(), pageBase.getModelInteractionService(), objectRef, task, result); + return new SceneDto(deltasScene); + } catch (SchemaException | ExpressionEvaluationException ex){ + LOGGER.error("Unable to create delta visualization for case {}: {}", caseObject, ex.getLocalizedMessage(), ex); + } + return null; + } + + public static void workItemApproveActionPerformed(AjaxRequestTarget target, CaseWorkItemType workItem, AbstractWorkItemOutputType workItemOutput, + Component formPanel, PrismObject powerDonor, boolean approved, OperationResult result, PageBase pageBase) { + if (workItem == null){ + return; + } + CaseType parentCase = CaseWorkItemUtil.getCase(workItem); + if (CaseTypeUtil.isManualProvisioningCase(parentCase)){ + Task task = pageBase.createSimpleTask(result.getOperation()); + try { + AbstractWorkItemOutputType output = workItem.getOutput(); + if (output == null) { + output = new AbstractWorkItemOutputType(pageBase.getPrismContext()); + } + output.setOutcome(ApprovalUtils.toUri(approved)); + if (workItemOutput != null && workItemOutput.getComment() != null){ + output.setComment(workItemOutput.getComment()); + } + if (workItemOutput != null && workItemOutput.getEvidence() != null){ + output.setEvidence(workItemOutput.getEvidence()); + } + WorkItemId workItemId = WorkItemId.create(parentCase.getOid(), workItem.getId()); + pageBase.getWorkflowService().completeWorkItem(workItemId, output, task, result); + } catch (Exception ex) { + LoggingUtils.logUnexpectedException(LOGGER, "Unable to complete work item, ", ex); + result.recordFatalError(ex); + } + } else { + + Task task = pageBase.createSimpleTask(result.getOperation()); + try { + try { + ObjectDelta additionalDelta = null; + if (formPanel != null && formPanel instanceof DynamicFormPanel) { + if (approved) { + boolean requiredFieldsPresent = ((DynamicFormPanel) formPanel).checkRequiredFields(pageBase); + if (!requiredFieldsPresent) { + target.add(pageBase.getFeedbackPanel()); + return; + } + } + additionalDelta = ((DynamicFormPanel) formPanel).getObjectDelta(); + if (additionalDelta != null) { + pageBase.getPrismContext().adopt(additionalDelta); + } + } + assumePowerOfAttorneyIfRequested(result, powerDonor, pageBase); + pageBase.getWorkflowService().completeWorkItem(WorkItemId.of(workItem), + workItemOutput, + additionalDelta, task, result); + } finally { + dropPowerOfAttorneyIfRequested(result, powerDonor, pageBase); + } + } catch (Exception ex) { + result.recordFatalError(pageBase.createStringResource("WebModelUtils.couldntSaveWorkItem").getString(), ex); + LoggingUtils.logUnexpectedException(LOGGER, "Couldn't save work item", ex); + } + } + result.computeStatusIfUnknown(); + } + + public static List createMetadataOrdering(SortParam sortParam, String metadataProperty, PrismContext prismContext){ + if (sortParam != null && sortParam.getProperty() != null) { + OrderDirection order = sortParam.isAscending() ? OrderDirection.ASCENDING : OrderDirection.DESCENDING; + if (sortParam.getProperty().equals(metadataProperty)) { + return Collections.singletonList( + prismContext.queryFactory().createOrdering( + ItemPath.create(ReportOutputType.F_METADATA, MetadataType.F_CREATE_TIMESTAMP), order)); + } + return Collections.singletonList( + prismContext.queryFactory().createOrdering( + ItemPath.create(new QName(SchemaConstantsGenerated.NS_COMMON, sortParam.getProperty())), order)); + + + } else { + return null; + } + } + + public static void claimWorkItemActionPerformed(CaseWorkItemType workItemToClaim, + String operation, AjaxRequestTarget target, PageBase pageBase){ + Task task = pageBase.createSimpleTask(operation); + OperationResult mainResult = task.getResult(); + WorkflowService workflowService = pageBase.getWorkflowService(); + OperationResult result = mainResult.createSubresult(operation); + try { + workflowService.claimWorkItem(WorkItemId.of(workItemToClaim), task, result); + result.computeStatusIfUnknown(); + } catch (ObjectNotFoundException | SecurityViolationException | RuntimeException | SchemaException | + ObjectAlreadyExistsException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) { + result.recordPartialError(pageBase.createStringResource("pageWorkItems.message.partialError.claimed").getString(), e); + } + if (mainResult.isUnknown()) { + mainResult.recomputeStatus(); + } + + if (mainResult.isSuccess()) { + mainResult.recordStatus(OperationResultStatus.SUCCESS, + pageBase.createStringResource("pageWorkItems.message.success.claimed").getString()); + } + + pageBase.showResult(mainResult); + + pageBase.resetWorkItemCountModel(); + target.add(pageBase); + + } + + public static void assumePowerOfAttorneyIfRequested(OperationResult result, PrismObject powerDonor, PageBase pageBase) { + if (powerDonor != null) { + WebModelServiceUtils.assumePowerOfAttorney(powerDonor, pageBase.getModelInteractionService(), pageBase.getTaskManager(), result); + } + } + + public static void dropPowerOfAttorneyIfRequested(OperationResult result, PrismObject powerDonor, PageBase pageBase) { + if (powerDonor != null) { + WebModelServiceUtils.dropPowerOfAttorney(pageBase.getModelInteractionService(), pageBase.getTaskManager(), result); + } + } + + + @NotNull + public static List computeChangesCategorizationList(ChangesByState changesByState, ObjectReferenceType objectRef, + ModelInteractionService modelInteractionService, PrismContext prismContext, Task opTask, + OperationResult thisOpResult) throws SchemaException, ExpressionEvaluationException { + List changes = new ArrayList<>(); + if (!changesByState.getApplied().isEmpty()) { + changes.add(createTaskChangesDto("TaskDto.changesApplied", "box-solid box-success", changesByState.getApplied(), + modelInteractionService, prismContext, objectRef, opTask, thisOpResult)); + } + if (!changesByState.getBeingApplied().isEmpty()) { + changes.add(createTaskChangesDto("TaskDto.changesBeingApplied", "box-solid box-info", changesByState.getBeingApplied(), + modelInteractionService, prismContext, objectRef, opTask, thisOpResult)); + } + if (!changesByState.getWaitingToBeApplied().isEmpty()) { + changes.add(createTaskChangesDto("TaskDto.changesWaitingToBeApplied", "box-solid box-warning", + changesByState.getWaitingToBeApplied(), modelInteractionService, prismContext, objectRef, opTask, thisOpResult)); + } + if (!changesByState.getWaitingToBeApproved().isEmpty()) { + changes.add(createTaskChangesDto("TaskDto.changesWaitingToBeApproved", "box-solid box-primary", + changesByState.getWaitingToBeApproved(), modelInteractionService, prismContext, objectRef, opTask, thisOpResult)); + } + if (!changesByState.getRejected().isEmpty()) { + changes.add(createTaskChangesDto("TaskDto.changesRejected", "box-solid box-danger", changesByState.getRejected(), + modelInteractionService, prismContext, objectRef, opTask, thisOpResult)); + } + if (!changesByState.getCanceled().isEmpty()) { + changes.add(createTaskChangesDto("TaskDto.changesCanceled", "box-solid box-danger", changesByState.getCanceled(), + modelInteractionService, prismContext, objectRef, opTask, thisOpResult)); + } + return changes; + } + + private static SceneDto createTaskChangesDto(String titleKey, String boxClassOverride, ObjectTreeDeltas deltas, ModelInteractionService modelInteractionService, + PrismContext prismContext, ObjectReferenceType objectRef, Task opTask, OperationResult result) throws SchemaException, ExpressionEvaluationException { + ObjectTreeDeltasType deltasType = ObjectTreeDeltas.toObjectTreeDeltasType(deltas); + Scene scene = SceneUtil.visualizeObjectTreeDeltas(deltasType, titleKey, prismContext, modelInteractionService, objectRef, opTask, result); + SceneDto sceneDto = new SceneDto(scene); + sceneDto.setBoxClassOverride(boxClassOverride); + return sceneDto; + } + + public static String getMidpointCustomSystemName(PageBase pageBase, String defaultSystemNameKey){ + DeploymentInformationType deploymentInfo = MidPointApplication.get().getDeploymentInfo(); + String subscriptionId = deploymentInfo != null ? deploymentInfo.getSubscriptionIdentifier() : null; + if (!isSubscriptionIdCorrect(subscriptionId) || + SubscriptionType.DEMO_SUBSRIPTION.getSubscriptionType().equals(subscriptionId.substring(0, 2))) { + return pageBase.createStringResource(defaultSystemNameKey).getString(); + } + return deploymentInfo != null && StringUtils.isNotEmpty(deploymentInfo.getSystemName()) ? + deploymentInfo.getSystemName() : pageBase.createStringResource(defaultSystemNameKey).getString(); + } + + public static IModel getResourceLabelModel(ShadowType shadow, PageBase pageBase){ + return pageBase.createStringResource("DisplayNamePanel.resource", + WebComponentUtil.getReferencedObjectDisplayNamesAndNames(shadow.getResourceRef(), false)); + } + + public static IModel getResourceAttributesLabelModel(ShadowType shadow, PageBase pageBase){ + StringBuilder sb = new StringBuilder(); + if(shadow != null) { + if(shadow.getObjectClass() != null && !StringUtils.isBlank(shadow.getObjectClass().getLocalPart())) { + sb.append(pageBase.createStringResource("DisplayNamePanel.objectClass", shadow.getObjectClass().getLocalPart()).getString()); + } + if(shadow.getKind() != null && !StringUtils.isBlank(shadow.getKind().name())) { + sb.append(", "); + sb.append(pageBase.createStringResource("DisplayNamePanel.kind", shadow.getKind().name()).getString()); + } + + if(!StringUtils.isBlank(shadow.getIntent())) { + sb.append(", "); + sb.append(pageBase.createStringResource("DisplayNamePanel.intent", shadow.getIntent()).getString()); + } + + if(!StringUtils.isBlank(shadow.getTag())) { + sb.append(", "); + sb.append(pageBase.createStringResource("DisplayNamePanel.tag", shadow.getTag()).getString()); + } + return Model.of(sb.toString()); + } + return Model.of(""); + } + + public static String getPendingOperationsLabels(ShadowType shadow, BasePanel panel) { + if(shadow == null || shadow.getPendingOperation().isEmpty()) { + return null; + } + StringBuilder sb = new StringBuilder(); + List operations = shadow.getPendingOperation(); + sb.append("\n").append(panel.getString("DisplayNamePanel.pendingOperation")).append(":"); + boolean isFirst = true; + for(PendingOperationType operation : operations) { + if(operation != null) { + if(!isFirst) { + sb.append(", "); + } else { + sb.append(" "); + } + sb.append(getPendingOperationLabel(operation, panel)); + isFirst = false; + } + } + return sb.toString(); + } + + public static String getPendingOperationLabel(PendingOperationType realValue, BasePanel panel) { + StringBuilder sb = new StringBuilder(); + boolean empty = true; + ObjectDeltaType delta = realValue.getDelta(); + if(delta != null && delta.getChangeType() != null) { + sb.append(panel.getString(delta.getChangeType())); + empty = false; + } + PendingOperationTypeType type = realValue.getType(); + if(type != null) { + if(!empty) { + sb.append(" "); + } + sb.append("(").append(panel.getString(type)).append(")"); + } + OperationResultStatusType rStatus = realValue.getResultStatus(); + PendingOperationExecutionStatusType eStatus = realValue.getExecutionStatus(); + if(!empty) { + sb.append(" "); + } + sb.append(panel.getString("PendingOperationType.label.status")).append(": "); + if (rStatus == null) { + sb.append(panel.getString(eStatus)); + } else { + sb.append(panel.getString(rStatus)); + } + return sb.toString(); + } + + + public static String getObjectListPageStorageKey(String additionalKeyValue){ + if (StringUtils.isEmpty(additionalKeyValue)){ + return SessionStorage.KEY_OBJECT_LIST; + } + return SessionStorage.KEY_OBJECT_LIST + "." + additionalKeyValue; + } + + public static AssignmentHolderType getObjectFromAddDeltyForCase(CaseType aCase) { + if (aCase != null && aCase.getApprovalContext() != null + && aCase.getApprovalContext().getDeltasToApprove() != null) { + ObjectTreeDeltasType deltaTree = aCase.getApprovalContext().getDeltasToApprove(); + if(deltaTree != null && deltaTree.getFocusPrimaryDelta() != null) { + ObjectDeltaType primaryDelta = deltaTree.getFocusPrimaryDelta(); + if(primaryDelta != null && (primaryDelta.getItemDelta() == null || primaryDelta.getItemDelta().isEmpty()) + && primaryDelta.getObjectToAdd() != null && primaryDelta.getObjectToAdd() instanceof AssignmentHolderType + && ChangeType.ADD.equals(ChangeType.toChangeType(primaryDelta.getChangeType()))) { + return (AssignmentHolderType) primaryDelta.getObjectToAdd(); + } + } + } + return null; + } + + public static boolean isRefreshEnabled(PageBase pageBase, QName type) { + CompiledGuiProfile cup = pageBase.getCompiledGuiProfile(); + if (cup == null) { + return false; + } + + List views = cup.getObjectCollectionViews(); + if (CollectionUtils.isEmpty(views)) { + return false; + } + + for (CompiledObjectCollectionView view : views) { + if (QNameUtil.match(type, view.getObjectType())) { + if (view.getRefreshInterval() != null) { + return true; + } + + } + } + return false; + } + + public static Long xgc2long(XMLGregorianCalendar gc) { + return gc != null ? XmlTypeConverter.toMillis(gc) : null; + } + + public static String getSimpleChannel(String chanelUri) { + if (chanelUri == null) { + return null; + } + int i = chanelUri.indexOf('#'); + if (i < 0) { + return chanelUri; + } + return chanelUri.substring(i + 1); + } + + public static List getIntensForKind(PrismObject resource, ShadowKindType kind, PageBase parentPage) { + + RefinedResourceSchema refinedSchema = null; + try { + refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource, + parentPage.getPrismContext()); + + } catch (SchemaException e) { + return Collections.emptyList(); + } + + if (kind == null) { + return Collections.emptyList(); + } + + return RefinedResourceSchemaImpl.getIntentsForKind(refinedSchema, kind); + } + +} diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/ObjectPolicyConfigurationEditor.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/ObjectPolicyConfigurationEditor.java index 399535fba17..a6fb072f979 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/ObjectPolicyConfigurationEditor.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/ObjectPolicyConfigurationEditor.java @@ -1,332 +1,331 @@ -/* - * Copyright (c) 2010-2017 Evolveum and contributors - * - * This work is dual-licensed under the Apache License 2.0 - * and European Union Public License. See LICENSE file for details. - */ - -package com.evolveum.midpoint.web.component; - -import java.util.Iterator; -import java.util.List; - -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior; -import org.apache.wicket.ajax.markup.html.AjaxLink; -import org.apache.wicket.behavior.AttributeAppender; -import org.apache.wicket.feedback.ComponentFeedbackMessageFilter; -import org.apache.wicket.markup.html.WebMarkupContainer; -import org.apache.wicket.markup.html.basic.Label; -import org.apache.wicket.markup.html.form.TextField; -import org.apache.wicket.markup.html.list.ListItem; -import org.apache.wicket.markup.html.list.ListView; -import org.apache.wicket.markup.html.panel.FeedbackPanel; -import org.apache.wicket.model.IModel; - -import com.evolveum.midpoint.gui.api.component.BasePanel; -import com.evolveum.midpoint.gui.api.model.LoadableModel; -import com.evolveum.midpoint.gui.api.util.WebComponentUtil; -import com.evolveum.midpoint.prism.PrismContainerValue; -import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour; -import com.evolveum.midpoint.web.page.admin.configuration.component.ObjectPolicyPanel; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectPolicyConfigurationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyConstraintsType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.PropertyConstraintType; - -/** - * @author shood - */ - -public class ObjectPolicyConfigurationEditor extends BasePanel> { - - private static final long serialVersionUID = 1L; - - - private static final Trace LOGGER = TraceManager.getTrace(ObjectPolicyConfigurationEditor.class); - - private static final String DOT_CLASS = ObjectPolicyConfigurationEditor.class.getName() + "."; - - private static final String ID_LABEL = "label"; - private static final String ID_REPEATER = "repeater"; - private static final String ID_TEXT_WRAPPER = "textWrapper"; - private static final String ID_BUTTON_EDIT = "edit"; - private static final String ID_NAME = "name"; - private static final String ID_FEEDBACK = "feedback"; - private static final String ID_BUTTON_GROUP = "buttonGroup"; - private static final String ID_BUTTON_REMOVE = "remove"; - private static final String ID_BUTTON_ADD = "add"; - private static final String ID_BUTTON_ADD_FIRST = "addFirstButton"; - - private static final String CLASS_MULTI_VALUE = "multivalue-form"; - private static final String OFFSET_CLASS = "col-md-offset-4"; - - public ObjectPolicyConfigurationEditor(String id, IModel> model){ - super(id, model); - - setOutputMarkupId(true); - - initLayout(); - } - - protected void initLayout(){ - - final Label label = new Label(ID_LABEL, createStringResource("objectPolicyConfigurationEditor.label")); - add(label); - - AjaxLink addFirst = new AjaxLink(ID_BUTTON_ADD_FIRST) { - private static final long serialVersionUID = 1L; - - @Override - public void onClick(AjaxRequestTarget target) { - addPerformed(target); - } - }; - addFirst.add(new VisibleEnableBehaviour() { - private static final long serialVersionUID = 1L; - - @Override - public boolean isVisible() { - List modelObj = ObjectPolicyConfigurationEditor.this.getModelObject(); - return modelObj == null || modelObj.size() == 0; - } - }); - addFirst.setOutputMarkupId(true); - add(addFirst); - - ListView repeater = new ListView(ID_REPEATER, getModel()) { - private static final long serialVersionUID = 1L; - - @Override - protected void populateItem(final ListItem item) { - WebMarkupContainer textWrapper = new WebMarkupContainer(ID_TEXT_WRAPPER); - textWrapper.add(AttributeAppender.prepend("class", new IModel(){ - private static final long serialVersionUID = 1L; - - @Override - public String getObject(){ - if(item.getIndex() > 0){ - return OFFSET_CLASS + " " + CLASS_MULTI_VALUE; - } - - return null; - } - })); - item.add(textWrapper); - - TextField name = new TextField<>(ID_NAME, createNameModel(item.getModel())); - name.setOutputMarkupId(true); - name.add(new AjaxFormComponentUpdatingBehavior("blur") { - private static final long serialVersionUID = 1L; - - @Override - protected void onUpdate(AjaxRequestTarget target) {} - }); - name.setEnabled(false); - name.add(AttributeAppender.replace("placeholder", createStringResource("objectPolicyConfigurationEditor.name.placeholder"))); - textWrapper.add(name); - - FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK, new ComponentFeedbackMessageFilter(name)); - textWrapper.add(feedback); - - AjaxLink edit = new AjaxLink(ID_BUTTON_EDIT) { - private static final long serialVersionUID = 1L; - - @Override - public void onClick(AjaxRequestTarget target) { - editPerformed(target, item); - } - }; - textWrapper.add(edit); - - WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP); - buttonGroup.add(AttributeAppender.append("class", new IModel() { - private static final long serialVersionUID = 1L; - - @Override - public String getObject() { - if(item.getIndex() > 0){ - return CLASS_MULTI_VALUE; - } - - return null; - } - })); - item.add(buttonGroup); - initButtons(buttonGroup, item); - } - }; - - repeater.setOutputMarkupId(true); - add(repeater); - } - - private void replace(ObjectPolicyConfigurationType old, ObjectPolicyConfigurationType newC){ - boolean added = false; - - List list = getModelObject(); - for(ObjectPolicyConfigurationType o: list){ - if(old.equals(o)){ - o.getPropertyConstraint().clear(); - for (PropertyConstraintType constraintType : newC.getPropertyConstraint()) { - PrismContainerValue constraint = constraintType.asPrismContainerValue(); - o.getPropertyConstraint().add(constraint.clone().asContainerable()); - } - o.setObjectTemplateRef(newC.getObjectTemplateRef()); - o.setType(newC.getType()); - o.setSubtype(newC.getSubtype()); - added = true; - } - } - - if(!added){ - list.add((ObjectPolicyConfigurationType) newC.asPrismContainerValue().clone().asContainerable()); - } - } - - private void initButtons(WebMarkupContainer buttonGroup, final ListItem item){ - AjaxLink add = new AjaxLink(ID_BUTTON_ADD) { - private static final long serialVersionUID = 1L; - - @Override - public void onClick(AjaxRequestTarget target) { - addPerformed(target); - } - }; - add.add(new VisibleEnableBehaviour() { - private static final long serialVersionUID = 1L; - - @Override - public boolean isVisible() { - return isAddButtonVisible(item); - } - }); - buttonGroup.add(add); - - AjaxLink remove = new AjaxLink(ID_BUTTON_REMOVE) { - private static final long serialVersionUID = 1L; - - @Override - public void onClick(AjaxRequestTarget target) { - removePerformed(target, item); - } - }; - remove.add(new VisibleEnableBehaviour() { - private static final long serialVersionUID = 1L; - - @Override - public boolean isVisible() { - return isRemoveButtonVisible(); - } - }); - buttonGroup.add(remove); - } - - protected boolean isAddButtonVisible(ListItem item) { - int size = getModelObject().size(); - if (size <= 1) { - return true; - } - if (item.getIndex() == size - 1) { - return true; - } - - return false; - } - - protected boolean isRemoveButtonVisible() { - int size = getModelObject().size(); - if (size > 0) { - return true; - } - - return false; - } - - private IModel createNameModel(final IModel model){ - return new LoadableModel() { - private static final long serialVersionUID = 1L; - - @Override - public String load() { - StringBuilder sb = new StringBuilder(); - ObjectPolicyConfigurationType config = model.getObject(); - - if(config != null){ - ObjectReferenceType ref = config.getObjectTemplateRef(); - - if (ref != null) { - sb.append(WebComponentUtil.getOrigStringFromPoly(ref.getTargetName())); - } - - if (config.getConflictResolution() != null) { - if (sb.length() > 0) { - sb.append(" "); - } - sb.append(getString("ObjectPolicyConfigurationEditor.conflictResolution")); - } - - if(config.getType() != null) { - if (sb.length() > 0) { - sb.append(": "); - } - sb.append(config.getType().getLocalPart()); - } - - if (config.getSubtype() != null) { - sb.append("(").append(config.getSubtype()).append(")"); - } - } - - return sb.toString(); - } - }; - } - - private void addPerformed(AjaxRequestTarget target){ - List list = getModelObject(); - list.add(new ObjectPolicyConfigurationType()); - - target.add(this); - } - - private void removePerformed(AjaxRequestTarget target, ListItem item){ - List list = getModelObject(); - Iterator iterator = list.iterator(); - - while (iterator.hasNext()){ - ObjectPolicyConfigurationType object = iterator.next(); - - if(object.equals(item.getModelObject())){ - iterator.remove(); - break; - } - } - - target.add(this); - } - - private void editPerformed(AjaxRequestTarget target, ListItem item){ - ObjectPolicyPanel objectPolicyPanel = new ObjectPolicyPanel(getPageBase().getMainPopupBodyId(), item.getModelObject()) { - private static final long serialVersionUID = 1L; - - @Override - protected void savePerformed(AjaxRequestTarget target){ - ObjectPolicyConfigurationType oldConfig = getModel().getObject().getConfig(); - OperationResult result = new OperationResult(DOT_CLASS + "preparePropertyConstraint"); - ObjectPolicyConfigurationType newConfig = getModel().getObject().preparePolicyConfig(result); -// - ObjectPolicyConfigurationEditor.this.replace(oldConfig, newConfig); - ObjectPolicyConfigurationEditor.this.getPageBase().hideMainPopup(target); - getPageBase().showResult(result, false); - target.add(ObjectPolicyConfigurationEditor.this); - } - }; - objectPolicyPanel.setOutputMarkupId(true); - getPageBase().showMainPopup(objectPolicyPanel, target); - } - -} +/* + * Copyright (c) 2010-2017 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ + +package com.evolveum.midpoint.web.component; + +import java.util.Iterator; +import java.util.List; + +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior; +import org.apache.wicket.ajax.markup.html.AjaxLink; +import org.apache.wicket.behavior.AttributeAppender; +import org.apache.wicket.feedback.ComponentFeedbackMessageFilter; +import org.apache.wicket.markup.html.WebMarkupContainer; +import org.apache.wicket.markup.html.basic.Label; +import org.apache.wicket.markup.html.form.TextField; +import org.apache.wicket.markup.html.list.ListItem; +import org.apache.wicket.markup.html.list.ListView; +import org.apache.wicket.markup.html.panel.FeedbackPanel; +import org.apache.wicket.model.IModel; + +import com.evolveum.midpoint.gui.api.component.BasePanel; +import com.evolveum.midpoint.gui.api.model.LoadableModel; +import com.evolveum.midpoint.gui.api.util.WebComponentUtil; +import com.evolveum.midpoint.prism.PrismContainerValue; +import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.util.logging.Trace; +import com.evolveum.midpoint.util.logging.TraceManager; +import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour; +import com.evolveum.midpoint.web.page.admin.configuration.component.ObjectPolicyPanel; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectPolicyConfigurationType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ItemConstraintType; + +/** + * @author shood + */ + +public class ObjectPolicyConfigurationEditor extends BasePanel> { + + private static final long serialVersionUID = 1L; + + + private static final Trace LOGGER = TraceManager.getTrace(ObjectPolicyConfigurationEditor.class); + + private static final String DOT_CLASS = ObjectPolicyConfigurationEditor.class.getName() + "."; + + private static final String ID_LABEL = "label"; + private static final String ID_REPEATER = "repeater"; + private static final String ID_TEXT_WRAPPER = "textWrapper"; + private static final String ID_BUTTON_EDIT = "edit"; + private static final String ID_NAME = "name"; + private static final String ID_FEEDBACK = "feedback"; + private static final String ID_BUTTON_GROUP = "buttonGroup"; + private static final String ID_BUTTON_REMOVE = "remove"; + private static final String ID_BUTTON_ADD = "add"; + private static final String ID_BUTTON_ADD_FIRST = "addFirstButton"; + + private static final String CLASS_MULTI_VALUE = "multivalue-form"; + private static final String OFFSET_CLASS = "col-md-offset-4"; + + public ObjectPolicyConfigurationEditor(String id, IModel> model){ + super(id, model); + + setOutputMarkupId(true); + + initLayout(); + } + + protected void initLayout(){ + + final Label label = new Label(ID_LABEL, createStringResource("objectPolicyConfigurationEditor.label")); + add(label); + + AjaxLink addFirst = new AjaxLink(ID_BUTTON_ADD_FIRST) { + private static final long serialVersionUID = 1L; + + @Override + public void onClick(AjaxRequestTarget target) { + addPerformed(target); + } + }; + addFirst.add(new VisibleEnableBehaviour() { + private static final long serialVersionUID = 1L; + + @Override + public boolean isVisible() { + List modelObj = ObjectPolicyConfigurationEditor.this.getModelObject(); + return modelObj == null || modelObj.size() == 0; + } + }); + addFirst.setOutputMarkupId(true); + add(addFirst); + + ListView repeater = new ListView(ID_REPEATER, getModel()) { + private static final long serialVersionUID = 1L; + + @Override + protected void populateItem(final ListItem item) { + WebMarkupContainer textWrapper = new WebMarkupContainer(ID_TEXT_WRAPPER); + textWrapper.add(AttributeAppender.prepend("class", new IModel(){ + private static final long serialVersionUID = 1L; + + @Override + public String getObject(){ + if(item.getIndex() > 0){ + return OFFSET_CLASS + " " + CLASS_MULTI_VALUE; + } + + return null; + } + })); + item.add(textWrapper); + + TextField name = new TextField<>(ID_NAME, createNameModel(item.getModel())); + name.setOutputMarkupId(true); + name.add(new AjaxFormComponentUpdatingBehavior("blur") { + private static final long serialVersionUID = 1L; + + @Override + protected void onUpdate(AjaxRequestTarget target) {} + }); + name.setEnabled(false); + name.add(AttributeAppender.replace("placeholder", createStringResource("objectPolicyConfigurationEditor.name.placeholder"))); + textWrapper.add(name); + + FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK, new ComponentFeedbackMessageFilter(name)); + textWrapper.add(feedback); + + AjaxLink edit = new AjaxLink(ID_BUTTON_EDIT) { + private static final long serialVersionUID = 1L; + + @Override + public void onClick(AjaxRequestTarget target) { + editPerformed(target, item); + } + }; + textWrapper.add(edit); + + WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP); + buttonGroup.add(AttributeAppender.append("class", new IModel() { + private static final long serialVersionUID = 1L; + + @Override + public String getObject() { + if(item.getIndex() > 0){ + return CLASS_MULTI_VALUE; + } + + return null; + } + })); + item.add(buttonGroup); + initButtons(buttonGroup, item); + } + }; + + repeater.setOutputMarkupId(true); + add(repeater); + } + + private void replace(ObjectPolicyConfigurationType old, ObjectPolicyConfigurationType newC){ + boolean added = false; + + List list = getModelObject(); + for(ObjectPolicyConfigurationType o: list){ + if(old.equals(o)){ + o.getPropertyConstraint().clear(); + for (ItemConstraintType constraintType : newC.getPropertyConstraint()) { + PrismContainerValue constraint = constraintType.asPrismContainerValue(); + o.getPropertyConstraint().add(constraint.clone().asContainerable()); + } + o.setObjectTemplateRef(newC.getObjectTemplateRef()); + o.setType(newC.getType()); + o.setSubtype(newC.getSubtype()); + added = true; + } + } + + if(!added){ + list.add((ObjectPolicyConfigurationType) newC.asPrismContainerValue().clone().asContainerable()); + } + } + + private void initButtons(WebMarkupContainer buttonGroup, final ListItem item){ + AjaxLink add = new AjaxLink(ID_BUTTON_ADD) { + private static final long serialVersionUID = 1L; + + @Override + public void onClick(AjaxRequestTarget target) { + addPerformed(target); + } + }; + add.add(new VisibleEnableBehaviour() { + private static final long serialVersionUID = 1L; + + @Override + public boolean isVisible() { + return isAddButtonVisible(item); + } + }); + buttonGroup.add(add); + + AjaxLink remove = new AjaxLink(ID_BUTTON_REMOVE) { + private static final long serialVersionUID = 1L; + + @Override + public void onClick(AjaxRequestTarget target) { + removePerformed(target, item); + } + }; + remove.add(new VisibleEnableBehaviour() { + private static final long serialVersionUID = 1L; + + @Override + public boolean isVisible() { + return isRemoveButtonVisible(); + } + }); + buttonGroup.add(remove); + } + + protected boolean isAddButtonVisible(ListItem item) { + int size = getModelObject().size(); + if (size <= 1) { + return true; + } + if (item.getIndex() == size - 1) { + return true; + } + + return false; + } + + protected boolean isRemoveButtonVisible() { + int size = getModelObject().size(); + if (size > 0) { + return true; + } + + return false; + } + + private IModel createNameModel(final IModel model){ + return new LoadableModel() { + private static final long serialVersionUID = 1L; + + @Override + public String load() { + StringBuilder sb = new StringBuilder(); + ObjectPolicyConfigurationType config = model.getObject(); + + if(config != null){ + ObjectReferenceType ref = config.getObjectTemplateRef(); + + if (ref != null) { + sb.append(WebComponentUtil.getOrigStringFromPoly(ref.getTargetName())); + } + + if (config.getConflictResolution() != null) { + if (sb.length() > 0) { + sb.append(" "); + } + sb.append(getString("ObjectPolicyConfigurationEditor.conflictResolution")); + } + + if(config.getType() != null) { + if (sb.length() > 0) { + sb.append(": "); + } + sb.append(config.getType().getLocalPart()); + } + + if (config.getSubtype() != null) { + sb.append("(").append(config.getSubtype()).append(")"); + } + } + + return sb.toString(); + } + }; + } + + private void addPerformed(AjaxRequestTarget target){ + List list = getModelObject(); + list.add(new ObjectPolicyConfigurationType()); + + target.add(this); + } + + private void removePerformed(AjaxRequestTarget target, ListItem item){ + List list = getModelObject(); + Iterator iterator = list.iterator(); + + while (iterator.hasNext()){ + ObjectPolicyConfigurationType object = iterator.next(); + + if(object.equals(item.getModelObject())){ + iterator.remove(); + break; + } + } + + target.add(this); + } + + private void editPerformed(AjaxRequestTarget target, ListItem item){ + ObjectPolicyPanel objectPolicyPanel = new ObjectPolicyPanel(getPageBase().getMainPopupBodyId(), item.getModelObject()) { + private static final long serialVersionUID = 1L; + + @Override + protected void savePerformed(AjaxRequestTarget target){ + ObjectPolicyConfigurationType oldConfig = getModel().getObject().getConfig(); + OperationResult result = new OperationResult(DOT_CLASS + "preparePropertyConstraint"); + ObjectPolicyConfigurationType newConfig = getModel().getObject().preparePolicyConfig(result); +// + ObjectPolicyConfigurationEditor.this.replace(oldConfig, newConfig); + ObjectPolicyConfigurationEditor.this.getPageBase().hideMainPopup(target); + getPageBase().showResult(result, false); + target.add(ObjectPolicyConfigurationEditor.this); + } + }; + objectPolicyPanel.setOutputMarkupId(true); + getPageBase().showMainPopup(objectPolicyPanel, target); + } + +} diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/configuration/component/ObjectPolicyPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/configuration/component/ObjectPolicyPanel.java index 908aa9e1e6a..defc5953e5d 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/configuration/component/ObjectPolicyPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/configuration/component/ObjectPolicyPanel.java @@ -1,477 +1,475 @@ -/* - * Copyright (c) 2010-2017 Evolveum and contributors - * - * This work is dual-licensed under the Apache License 2.0 - * and European Union Public License. See LICENSE file for details. - */ - -package com.evolveum.midpoint.web.page.admin.configuration.component; - - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import javax.xml.namespace.QName; - -import org.apache.commons.lang3.BooleanUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.wicket.AttributeModifier; -import org.apache.wicket.Component; -import org.apache.wicket.MarkupContainer; -import org.apache.wicket.RestartResponseException; -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior; -import org.apache.wicket.ajax.markup.html.AjaxLink; -import org.apache.wicket.behavior.AttributeAppender; -import org.apache.wicket.feedback.ComponentFeedbackMessageFilter; -import org.apache.wicket.markup.html.WebMarkupContainer; -import org.apache.wicket.markup.html.form.CheckBox; -import org.apache.wicket.markup.html.form.Form; -import org.apache.wicket.markup.html.form.TextField; -import org.apache.wicket.markup.html.list.ListItem; -import org.apache.wicket.markup.html.list.ListView; -import org.apache.wicket.markup.html.panel.FeedbackPanel; -import org.apache.wicket.model.IModel; -import org.apache.wicket.model.Model; -import org.apache.wicket.model.PropertyModel; -import org.apache.wicket.model.StringResourceModel; -import org.apache.wicket.validation.IValidatable; -import org.apache.wicket.validation.IValidator; -import org.apache.wicket.validation.ValidationError; - -import com.evolveum.midpoint.gui.api.component.BasePanel; -import com.evolveum.midpoint.gui.api.model.LoadableModel; -import com.evolveum.midpoint.gui.api.page.PageBase; -import com.evolveum.midpoint.gui.api.util.WebComponentUtil; -import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.query.ObjectQuery; -import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.util.logging.LoggingUtils; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.web.component.AjaxSubmitButton; -import com.evolveum.midpoint.web.component.dialog.Popupable; -import com.evolveum.midpoint.web.component.form.DropDownFormGroup; -import com.evolveum.midpoint.web.component.input.ChoiceableChoiceRenderer; -import com.evolveum.midpoint.web.component.input.QNameObjectTypeChoiceRenderer; -import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour; -import com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectPolicyDialogDto; -import com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectTemplateConfigTypeReferenceDto; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectPolicyConfigurationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.PropertyConstraintType; -import com.evolveum.prism.xml.ns._public.types_3.ItemPathType; - - -/** - * @author shood - */ -public class ObjectPolicyPanel extends BasePanel implements Popupable{ - - /** - * - */ - private static final long serialVersionUID = 1L; - - private static final Trace LOGGER = TraceManager.getTrace(ObjectPolicyPanel.class); - - private static final String DOT_CLASS = ObjectPolicyPanel.class.getName() + "."; - - private static final String OPERATION_LOAD_ALL_OBJECT_TEMPLATES = DOT_CLASS + "loadObjectTemplates"; - - private static final String ID_FORM = "mainForm"; - private static final String ID_TYPE = "type"; - private static final String ID_SUBTYPE = "subtype"; - private static final String ID_OBJECT_TEMPLATE = "objectTemplate"; - private static final String ID_BUTTON_SAVE = "saveButton"; - private static final String ID_BUTTON_CANCEL = "cancelButton"; - private static final String ID_OID_BOUND = "oidBound"; - private static final String ID_PROPERTY = "property"; - private static final String ID_PROPERTY_PATH = "propertyPath"; - private static final String ID_REPEATER = "repeater"; - private static final String ID_TEXT_WRAPPER = "textWrapper"; - private static final String ID_BUTTON_GROUP = "buttonGroup"; - private static final String ID_BUTTON_REMOVE = "remove"; - private static final String ID_BUTTON_ADD = "add"; - private static final String ID_FEEDBACK = "feedback"; - private static final String ID_CONFLICT_RESOLUTION_CONTAINER = "conflictResolutionContainer"; - - private static final String ID_LABEL_SIZE = "col-md-4"; - private static final String ID_INPUT_SIZE = "col-md-8"; - - private static final String CLASS_MULTI_VALUE = "multivalue-form"; - private static final String OFFSET_CLASS = "col-md-offset-4"; - - private IModel model; - - public ObjectPolicyPanel(String id, final ObjectPolicyConfigurationType config) { - super(id); - - model = new LoadableModel(false) { - private static final long serialVersionUID = 1L; - - @Override - protected ObjectPolicyDialogDto load() { - return loadModel(config); - } - }; - - initLayout(config); - - setOutputMarkupId(true); - } - - private ObjectPolicyDialogDto loadModel(ObjectPolicyConfigurationType config) { - ObjectPolicyDialogDto dto = new ObjectPolicyDialogDto(config, getPageBase()); - return dto; - } - - public StringResourceModel createStringResource(String resourceKey, Object... objects) { - return PageBase.createStringResourceStatic(this, resourceKey, objects); - } - - public void initLayout(ObjectPolicyConfigurationType config) { - Form form = new Form<>(ID_FORM); - form.setOutputMarkupId(true); - add(form); - - DropDownFormGroup type = new DropDownFormGroup<>(ID_TYPE, - new PropertyModel<>(model, ObjectPolicyDialogDto.F_TYPE), createTypeChoiceList(), - new QNameObjectTypeChoiceRenderer(), createStringResource("ObjectPolicyDialog.type"), ID_LABEL_SIZE, - ID_INPUT_SIZE, false); - form.add(type); - type.getInput().setNullValid(config.getConflictResolution() != null); - type.getInput().setRequired(config.getConflictResolution() == null); // traditional template entries still require object type - TextField fieldSubtype = new TextField<>(ID_SUBTYPE, new PropertyModel(model, ObjectPolicyDialogDto.F_SUBTYPE)); - form.add(fieldSubtype); - form.add(fieldSubtype); - - DropDownFormGroup template = new DropDownFormGroup<>(ID_OBJECT_TEMPLATE, - new PropertyModel<>(model, ObjectPolicyDialogDto.F_TEMPLATE_REF), - createObjectTemplateList(), new ChoiceableChoiceRenderer<>(), - createStringResource("ObjectPolicyDialog.template"), ID_LABEL_SIZE, ID_INPUT_SIZE, false); - form.add(template); - template.getInput().setNullValid(config.getConflictResolution() != null); - template.getInput().setRequired(config.getConflictResolution() == null); - - WebMarkupContainer conflictResolutionContainer = new WebMarkupContainer(ID_CONFLICT_RESOLUTION_CONTAINER); - conflictResolutionContainer.setVisible(config.getConflictResolution() != null); - form.add(conflictResolutionContainer); - - ListView repeater = new ListView(ID_REPEATER, - new PropertyModel<>(model, ObjectPolicyDialogDto.F_PROPERTY_LIST)) { - - private static final long serialVersionUID = 1L; - - @Override - protected void populateItem(final ListItem item) { - WebMarkupContainer textWrapper = new WebMarkupContainer(ID_TEXT_WRAPPER); - textWrapper.setOutputMarkupId(true); - textWrapper.add(AttributeAppender.prepend("class", new IModel() { - - private static final long serialVersionUID = 1L; - @Override - public String getObject() { - if (item.getIndex() > 0) { - return OFFSET_CLASS + " " + CLASS_MULTI_VALUE; - } - - return null; - } - })); - item.add(textWrapper); - - - ItemPathType itemPathType = (item.getModelObject() != null ) ? item.getModelObject().getPath() : null; - String pathToShow = itemPathType != null ? itemPathType.getItemPath().toString() : null; - - TextField property = new TextField<>(ID_PROPERTY, Model.of(pathToShow)); - - property.add(new AjaxFormComponentUpdatingBehavior("blur") { - private static final long serialVersionUID = 1L; - @Override - protected void onUpdate(AjaxRequestTarget target) { - Component component = this.getComponent(); - String newValue = (String) component.getDefaultModelObject(); - ItemPathType itemPathType = null; - if (StringUtils.isNotBlank(newValue)) { - itemPathType = getPrismContext().itemPathParser().asItemPathType(newValue); - } - item.getModelObject().setPath(itemPathType); - } - }); - property.add(AttributeAppender.replace("placeholder", - createStringResource("ObjectPolicyDialog.property.placeholder"))); - textWrapper.add(property); - - - - CheckBox oidBound = new CheckBox(ID_OID_BOUND, - new PropertyModel<>(item.getModel(), PropertyConstraintType.F_OID_BOUND.getLocalPart())); - - oidBound.add(AttributeModifier.replace("title", - createStringResource("ObjectPolicyDialog.label.oidBound.help"))); - textWrapper.add(oidBound); - oidBound.add(new PropertyConstraintValidator(item.getModelObject())); - oidBound.add(new EmptyOnChangeAjaxFormUpdatingBehavior()); - FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK, new ComponentFeedbackMessageFilter(oidBound)); - textWrapper.add(feedback); - - WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP); - buttonGroup.add(AttributeAppender.append("class", new IModel() { - - private static final long serialVersionUID = 1L; - @Override - public String getObject() { - if (item.getIndex() > 0) { - return CLASS_MULTI_VALUE; - } - - return null; - } - })); - item.add(buttonGroup); - initButtons(buttonGroup, item); - } - - }; - form.add(repeater); - - AjaxSubmitButton cancel = new AjaxSubmitButton(ID_BUTTON_CANCEL, - createStringResource("ObjectPolicyDialog.button.cancel")) { - - private static final long serialVersionUID = 1L; - @Override - protected void onSubmit(AjaxRequestTarget target) { - cancelPerformed(target); - } - - @Override - protected void onError(AjaxRequestTarget target) { - cancelPerformed(target); - } - }; - form.add(cancel); - - AjaxSubmitButton save = new AjaxSubmitButton(ID_BUTTON_SAVE, - createStringResource("ObjectPolicyDialog.button.save")) { - - private static final long serialVersionUID = 1L; - @Override - protected void onSubmit(AjaxRequestTarget target) { - savePerformed(target); - } - - @Override - protected void onError(AjaxRequestTarget target) { - target.add(getPageBase().getFeedbackPanel()); - target.add(form); - } - }; - form.add(save); - } - - private void initButtons(WebMarkupContainer buttonGroup, final ListItem item) { - AjaxLink add = new AjaxLink(ID_BUTTON_ADD) { - - private static final long serialVersionUID = 1L; - - @Override - public void onClick(AjaxRequestTarget target) { - addPerformed(target); - } - }; - - add.add(new VisibleEnableBehaviour() { - - private static final long serialVersionUID = 1L; - @Override - public boolean isVisible() { - return isAddButtonVisible(item); - } - }); - buttonGroup.add(add); - - AjaxLink remove = new AjaxLink(ID_BUTTON_REMOVE) { - - private static final long serialVersionUID = 1L; - - @Override - public void onClick(AjaxRequestTarget target) { - removePerformed(target, item); - } - }; - remove.add(new VisibleEnableBehaviour() { - - private static final long serialVersionUID = 1L; - @Override - public boolean isVisible() { - return isRemoveButtonVisible(); - } - }); - buttonGroup.add(remove); - } - - private void addPerformed(AjaxRequestTarget target) { - List list = model.getObject().getPropertyConstraintsList(); - list.add(new PropertyConstraintType()); - } - - private void removePerformed(AjaxRequestTarget target, ListItem item) { - List list = model.getObject().getPropertyConstraintsList(); - Iterator iterator = list.iterator(); - - while (iterator.hasNext()) { - PropertyConstraintType object = iterator.next(); - - if (object.equals(item.getModelObject())) { - iterator.remove(); - break; - } - } - - if (list.size() == 0) { - list.add(new PropertyConstraintType()); - } - } - - protected boolean isAddButtonVisible(ListItem item) { - int size = model.getObject().getPropertyConstraintsList().size(); - if (size <= 1) { - return true; - } - if (item.getIndex() == size - 1) { - return true; - } - - return false; - } - - protected boolean isRemoveButtonVisible() { - int size = model.getObject().getPropertyConstraintsList().size(); - if (size > 0) { - return true; - } - - return false; - } - - protected IModel> createObjectTemplateList() { - return new IModel>() { - - private static final long serialVersionUID = 1L; - @Override - public List getObject() { - List> templateList = null; - List list = new ArrayList<>(); - OperationResult result = new OperationResult(OPERATION_LOAD_ALL_OBJECT_TEMPLATES); - Task task = getPageBase().createSimpleTask(OPERATION_LOAD_ALL_OBJECT_TEMPLATES); - - try { - templateList = getPageBase().getModelService().searchObjects(ObjectTemplateType.class, - null, null, task, result); - result.recomputeStatus(); - } catch (Exception e) { - result.recordFatalError(getString("ObjectPolicyPanel.message.createObjectTemplateList.fatalError"), e); - LoggingUtils.logUnexpectedException(LOGGER, "Could not get list of object templates", e); - // TODO - show this error in GUI - } - - if (templateList != null) { - ObjectTemplateType template; - for (PrismObject obj : templateList) { - template = obj.asObjectable(); - list.add(new ObjectTemplateConfigTypeReferenceDto(template.getOid(), - WebComponentUtil.getName(template))); - } - } - return list; - } - }; - } - - // TODO - to what types can be ObjectTemplate bound? - private IModel> createTypeChoiceList() { - return new IModel>() { - - private static final long serialVersionUID = 1L; - @Override - public List getObject() { - return WebComponentUtil.createFocusTypeList(); - } - }; - } - - private static class PropertyConstraintValidator implements IValidator { - - private static final long serialVersionUID = 1L; - - private PropertyConstraintType propertyConstraintType; - - private PropertyConstraintValidator(PropertyConstraintType propertyConstraint) { - this.propertyConstraintType = propertyConstraint; - - } - - @Override - public void validate(IValidatable validatable) { - - if (propertyConstraintType == null) { - return; - } - - if (BooleanUtils.isTrue(validatable.getValue()) && (propertyConstraintType == null || propertyConstraintType.getPath() == null)) { - ValidationError err = new ValidationError(); - err.addKey("propertyConstraintValidator.error"); - validatable.error(err); - } - - } - } - - - private void cancelPerformed(AjaxRequestTarget target) { - getPageBase().hideMainPopup(target); - } - - protected void savePerformed(AjaxRequestTarget target) { - target.add(getPageBase().getFeedbackPanel()); - getPageBase().hideMainPopup(target); - } - - public IModel getModel() { - return model; - } - - @Override - public int getWidth() { - return 625; - } - - @Override - public int getHeight() { - return 400; - } - - @Override - public String getWidthUnit(){ - return "px"; - } - - @Override - public String getHeightUnit(){ - return "px"; - } - - @Override - public StringResourceModel getTitle() { - return createStringResource("ObjectPolicyDialog.label"); - } - - @Override - public Component getComponent() { - return this; - } -} +/* + * Copyright (c) 2010-2017 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ + +package com.evolveum.midpoint.web.page.admin.configuration.component; + + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import javax.xml.namespace.QName; + +import com.evolveum.midpoint.xml.ns._public.common.common_3.ItemConstraintType; + +import org.apache.commons.lang3.BooleanUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.wicket.AttributeModifier; +import org.apache.wicket.Component; +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior; +import org.apache.wicket.ajax.markup.html.AjaxLink; +import org.apache.wicket.behavior.AttributeAppender; +import org.apache.wicket.feedback.ComponentFeedbackMessageFilter; +import org.apache.wicket.markup.html.WebMarkupContainer; +import org.apache.wicket.markup.html.form.CheckBox; +import org.apache.wicket.markup.html.form.Form; +import org.apache.wicket.markup.html.form.TextField; +import org.apache.wicket.markup.html.list.ListItem; +import org.apache.wicket.markup.html.list.ListView; +import org.apache.wicket.markup.html.panel.FeedbackPanel; +import org.apache.wicket.model.IModel; +import org.apache.wicket.model.Model; +import org.apache.wicket.model.PropertyModel; +import org.apache.wicket.model.StringResourceModel; +import org.apache.wicket.validation.IValidatable; +import org.apache.wicket.validation.IValidator; +import org.apache.wicket.validation.ValidationError; + +import com.evolveum.midpoint.gui.api.component.BasePanel; +import com.evolveum.midpoint.gui.api.model.LoadableModel; +import com.evolveum.midpoint.gui.api.page.PageBase; +import com.evolveum.midpoint.gui.api.util.WebComponentUtil; +import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.util.logging.LoggingUtils; +import com.evolveum.midpoint.util.logging.Trace; +import com.evolveum.midpoint.util.logging.TraceManager; +import com.evolveum.midpoint.web.component.AjaxSubmitButton; +import com.evolveum.midpoint.web.component.dialog.Popupable; +import com.evolveum.midpoint.web.component.form.DropDownFormGroup; +import com.evolveum.midpoint.web.component.input.ChoiceableChoiceRenderer; +import com.evolveum.midpoint.web.component.input.QNameObjectTypeChoiceRenderer; +import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour; +import com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectPolicyDialogDto; +import com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectTemplateConfigTypeReferenceDto; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectPolicyConfigurationType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType; +import com.evolveum.prism.xml.ns._public.types_3.ItemPathType; + + +/** + * @author shood + */ +public class ObjectPolicyPanel extends BasePanel implements Popupable{ + + /** + * + */ + private static final long serialVersionUID = 1L; + + private static final Trace LOGGER = TraceManager.getTrace(ObjectPolicyPanel.class); + + private static final String DOT_CLASS = ObjectPolicyPanel.class.getName() + "."; + + private static final String OPERATION_LOAD_ALL_OBJECT_TEMPLATES = DOT_CLASS + "loadObjectTemplates"; + + private static final String ID_FORM = "mainForm"; + private static final String ID_TYPE = "type"; + private static final String ID_SUBTYPE = "subtype"; + private static final String ID_OBJECT_TEMPLATE = "objectTemplate"; + private static final String ID_BUTTON_SAVE = "saveButton"; + private static final String ID_BUTTON_CANCEL = "cancelButton"; + private static final String ID_OID_BOUND = "oidBound"; + private static final String ID_PROPERTY = "property"; + private static final String ID_PROPERTY_PATH = "propertyPath"; + private static final String ID_REPEATER = "repeater"; + private static final String ID_TEXT_WRAPPER = "textWrapper"; + private static final String ID_BUTTON_GROUP = "buttonGroup"; + private static final String ID_BUTTON_REMOVE = "remove"; + private static final String ID_BUTTON_ADD = "add"; + private static final String ID_FEEDBACK = "feedback"; + private static final String ID_CONFLICT_RESOLUTION_CONTAINER = "conflictResolutionContainer"; + + private static final String ID_LABEL_SIZE = "col-md-4"; + private static final String ID_INPUT_SIZE = "col-md-8"; + + private static final String CLASS_MULTI_VALUE = "multivalue-form"; + private static final String OFFSET_CLASS = "col-md-offset-4"; + + private IModel model; + + public ObjectPolicyPanel(String id, final ObjectPolicyConfigurationType config) { + super(id); + + model = new LoadableModel(false) { + private static final long serialVersionUID = 1L; + + @Override + protected ObjectPolicyDialogDto load() { + return loadModel(config); + } + }; + + initLayout(config); + + setOutputMarkupId(true); + } + + private ObjectPolicyDialogDto loadModel(ObjectPolicyConfigurationType config) { + ObjectPolicyDialogDto dto = new ObjectPolicyDialogDto(config, getPageBase()); + return dto; + } + + public StringResourceModel createStringResource(String resourceKey, Object... objects) { + return PageBase.createStringResourceStatic(this, resourceKey, objects); + } + + public void initLayout(ObjectPolicyConfigurationType config) { + Form form = new Form<>(ID_FORM); + form.setOutputMarkupId(true); + add(form); + + DropDownFormGroup type = new DropDownFormGroup<>(ID_TYPE, + new PropertyModel<>(model, ObjectPolicyDialogDto.F_TYPE), createTypeChoiceList(), + new QNameObjectTypeChoiceRenderer(), createStringResource("ObjectPolicyDialog.type"), ID_LABEL_SIZE, + ID_INPUT_SIZE, false); + form.add(type); + type.getInput().setNullValid(config.getConflictResolution() != null); + type.getInput().setRequired(config.getConflictResolution() == null); // traditional template entries still require object type + TextField fieldSubtype = new TextField<>(ID_SUBTYPE, new PropertyModel(model, ObjectPolicyDialogDto.F_SUBTYPE)); + form.add(fieldSubtype); + form.add(fieldSubtype); + + DropDownFormGroup template = new DropDownFormGroup<>(ID_OBJECT_TEMPLATE, + new PropertyModel<>(model, ObjectPolicyDialogDto.F_TEMPLATE_REF), + createObjectTemplateList(), new ChoiceableChoiceRenderer<>(), + createStringResource("ObjectPolicyDialog.template"), ID_LABEL_SIZE, ID_INPUT_SIZE, false); + form.add(template); + template.getInput().setNullValid(config.getConflictResolution() != null); + template.getInput().setRequired(config.getConflictResolution() == null); + + WebMarkupContainer conflictResolutionContainer = new WebMarkupContainer(ID_CONFLICT_RESOLUTION_CONTAINER); + conflictResolutionContainer.setVisible(config.getConflictResolution() != null); + form.add(conflictResolutionContainer); + + ListView repeater = new ListView(ID_REPEATER, + new PropertyModel<>(model, ObjectPolicyDialogDto.F_PROPERTY_LIST)) { + + private static final long serialVersionUID = 1L; + + @Override + protected void populateItem(final ListItem item) { + WebMarkupContainer textWrapper = new WebMarkupContainer(ID_TEXT_WRAPPER); + textWrapper.setOutputMarkupId(true); + textWrapper.add(AttributeAppender.prepend("class", new IModel() { + + private static final long serialVersionUID = 1L; + @Override + public String getObject() { + if (item.getIndex() > 0) { + return OFFSET_CLASS + " " + CLASS_MULTI_VALUE; + } + + return null; + } + })); + item.add(textWrapper); + + + ItemPathType itemPathType = (item.getModelObject() != null ) ? item.getModelObject().getPath() : null; + String pathToShow = itemPathType != null ? itemPathType.getItemPath().toString() : null; + + TextField property = new TextField<>(ID_PROPERTY, Model.of(pathToShow)); + + property.add(new AjaxFormComponentUpdatingBehavior("blur") { + private static final long serialVersionUID = 1L; + @Override + protected void onUpdate(AjaxRequestTarget target) { + Component component = this.getComponent(); + String newValue = (String) component.getDefaultModelObject(); + ItemPathType itemPathType = null; + if (StringUtils.isNotBlank(newValue)) { + itemPathType = getPrismContext().itemPathParser().asItemPathType(newValue); + } + item.getModelObject().setPath(itemPathType); + } + }); + property.add(AttributeAppender.replace("placeholder", + createStringResource("ObjectPolicyDialog.property.placeholder"))); + textWrapper.add(property); + + + + CheckBox oidBound = new CheckBox(ID_OID_BOUND, + new PropertyModel<>(item.getModel(), ItemConstraintType.F_OID_BOUND.getLocalPart())); + + oidBound.add(AttributeModifier.replace("title", + createStringResource("ObjectPolicyDialog.label.oidBound.help"))); + textWrapper.add(oidBound); + oidBound.add(new PropertyConstraintValidator(item.getModelObject())); + oidBound.add(new EmptyOnChangeAjaxFormUpdatingBehavior()); + FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK, new ComponentFeedbackMessageFilter(oidBound)); + textWrapper.add(feedback); + + WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP); + buttonGroup.add(AttributeAppender.append("class", new IModel() { + + private static final long serialVersionUID = 1L; + @Override + public String getObject() { + if (item.getIndex() > 0) { + return CLASS_MULTI_VALUE; + } + + return null; + } + })); + item.add(buttonGroup); + initButtons(buttonGroup, item); + } + + }; + form.add(repeater); + + AjaxSubmitButton cancel = new AjaxSubmitButton(ID_BUTTON_CANCEL, + createStringResource("ObjectPolicyDialog.button.cancel")) { + + private static final long serialVersionUID = 1L; + @Override + protected void onSubmit(AjaxRequestTarget target) { + cancelPerformed(target); + } + + @Override + protected void onError(AjaxRequestTarget target) { + cancelPerformed(target); + } + }; + form.add(cancel); + + AjaxSubmitButton save = new AjaxSubmitButton(ID_BUTTON_SAVE, + createStringResource("ObjectPolicyDialog.button.save")) { + + private static final long serialVersionUID = 1L; + @Override + protected void onSubmit(AjaxRequestTarget target) { + savePerformed(target); + } + + @Override + protected void onError(AjaxRequestTarget target) { + target.add(getPageBase().getFeedbackPanel()); + target.add(form); + } + }; + form.add(save); + } + + private void initButtons(WebMarkupContainer buttonGroup, final ListItem item) { + AjaxLink add = new AjaxLink(ID_BUTTON_ADD) { + + private static final long serialVersionUID = 1L; + + @Override + public void onClick(AjaxRequestTarget target) { + addPerformed(target); + } + }; + + add.add(new VisibleEnableBehaviour() { + + private static final long serialVersionUID = 1L; + @Override + public boolean isVisible() { + return isAddButtonVisible(item); + } + }); + buttonGroup.add(add); + + AjaxLink remove = new AjaxLink(ID_BUTTON_REMOVE) { + + private static final long serialVersionUID = 1L; + + @Override + public void onClick(AjaxRequestTarget target) { + removePerformed(target, item); + } + }; + remove.add(new VisibleEnableBehaviour() { + + private static final long serialVersionUID = 1L; + @Override + public boolean isVisible() { + return isRemoveButtonVisible(); + } + }); + buttonGroup.add(remove); + } + + private void addPerformed(AjaxRequestTarget target) { + List list = model.getObject().getPropertyConstraintsList(); + list.add(new ItemConstraintType()); + } + + private void removePerformed(AjaxRequestTarget target, ListItem item) { + List list = model.getObject().getPropertyConstraintsList(); + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) { + ItemConstraintType object = iterator.next(); + + if (object.equals(item.getModelObject())) { + iterator.remove(); + break; + } + } + + if (list.size() == 0) { + list.add(new ItemConstraintType()); + } + } + + protected boolean isAddButtonVisible(ListItem item) { + int size = model.getObject().getPropertyConstraintsList().size(); + if (size <= 1) { + return true; + } + if (item.getIndex() == size - 1) { + return true; + } + + return false; + } + + protected boolean isRemoveButtonVisible() { + int size = model.getObject().getPropertyConstraintsList().size(); + if (size > 0) { + return true; + } + + return false; + } + + protected IModel> createObjectTemplateList() { + return new IModel>() { + + private static final long serialVersionUID = 1L; + @Override + public List getObject() { + List> templateList = null; + List list = new ArrayList<>(); + OperationResult result = new OperationResult(OPERATION_LOAD_ALL_OBJECT_TEMPLATES); + Task task = getPageBase().createSimpleTask(OPERATION_LOAD_ALL_OBJECT_TEMPLATES); + + try { + templateList = getPageBase().getModelService().searchObjects(ObjectTemplateType.class, + null, null, task, result); + result.recomputeStatus(); + } catch (Exception e) { + result.recordFatalError(getString("ObjectPolicyPanel.message.createObjectTemplateList.fatalError"), e); + LoggingUtils.logUnexpectedException(LOGGER, "Could not get list of object templates", e); + // TODO - show this error in GUI + } + + if (templateList != null) { + ObjectTemplateType template; + for (PrismObject obj : templateList) { + template = obj.asObjectable(); + list.add(new ObjectTemplateConfigTypeReferenceDto(template.getOid(), + WebComponentUtil.getName(template))); + } + } + return list; + } + }; + } + + // TODO - to what types can be ObjectTemplate bound? + private IModel> createTypeChoiceList() { + return new IModel>() { + + private static final long serialVersionUID = 1L; + @Override + public List getObject() { + return WebComponentUtil.createFocusTypeList(); + } + }; + } + + private static class PropertyConstraintValidator implements IValidator { + + private static final long serialVersionUID = 1L; + + private ItemConstraintType itemConstraintType; + + private PropertyConstraintValidator(ItemConstraintType propertyConstraint) { + this.itemConstraintType = propertyConstraint; + + } + + @Override + public void validate(IValidatable validatable) { + + if (itemConstraintType == null) { + return; + } + + if (BooleanUtils.isTrue(validatable.getValue()) && (itemConstraintType == null || itemConstraintType.getPath() == null)) { + ValidationError err = new ValidationError(); + err.addKey("propertyConstraintValidator.error"); + validatable.error(err); + } + + } + } + + + private void cancelPerformed(AjaxRequestTarget target) { + getPageBase().hideMainPopup(target); + } + + protected void savePerformed(AjaxRequestTarget target) { + target.add(getPageBase().getFeedbackPanel()); + getPageBase().hideMainPopup(target); + } + + public IModel getModel() { + return model; + } + + @Override + public int getWidth() { + return 625; + } + + @Override + public int getHeight() { + return 400; + } + + @Override + public String getWidthUnit(){ + return "px"; + } + + @Override + public String getHeightUnit(){ + return "px"; + } + + @Override + public StringResourceModel getTitle() { + return createStringResource("ObjectPolicyDialog.label"); + } + + @Override + public Component getComponent() { + return this; + } +} diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/configuration/dto/ObjectPolicyDialogDto.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/configuration/dto/ObjectPolicyDialogDto.java index 38de49e25e6..aa1895afa52 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/configuration/dto/ObjectPolicyDialogDto.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/configuration/dto/ObjectPolicyDialogDto.java @@ -1,231 +1,226 @@ -/* - * Copyright (c) 2010-2017 Evolveum and contributors - * - * This work is dual-licensed under the Apache License 2.0 - * and European Union Public License. See LICENSE file for details. - */ - -package com.evolveum.midpoint.web.page.admin.configuration.dto; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; - -import javax.xml.namespace.QName; - -import org.apache.commons.lang3.BooleanUtils; -import org.apache.wicket.util.convert.IConverter; - -import com.evolveum.midpoint.gui.api.page.PageBase; -import com.evolveum.midpoint.gui.api.util.WebComponentUtil; -import com.evolveum.midpoint.gui.api.util.WebModelServiceUtils; -import com.evolveum.midpoint.prism.PrismContainerValue; -import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectPolicyConfigurationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyConstraintsType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.PropertyConstraintType; -import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; - -/** - * @author shood - * */ -public class ObjectPolicyDialogDto implements Serializable{ - private static final long serialVersionUID = 1L; - - private static final String DOT_CLASS = ObjectPolicyDialogDto.class.getName() + "."; - - private static final String OPERATION_LOAD_OBJECT_TEMPLATE = DOT_CLASS + "loadObjectTemplate"; - - public static final String F_CONFIG = "config"; - public static final String F_TEMPLATE_REF = "templateRef"; - public static final String F_TYPE = "type"; - public static final String F_SUBTYPE = "subtype"; - public static final String F_PROPERTY_LIST = "propertyConstraintsList"; - - private List propertyConstraintsList; - private ObjectPolicyConfigurationType config; - private QName type; - private String subtype; - private ObjectTemplateConfigTypeReferenceDto templateRef; - PageBase page; - - public ObjectPolicyDialogDto(ObjectPolicyConfigurationType config, PageBase page) { - this.config = config; - type = config.getType(); - subtype = config.getSubtype(); - this.page =page; - -// for (PropertyConstraintType constraint : config.getPropertyConstraint()) { -// propertyConstraintsList.add(new PropertyConstraintTypeDto(constraint)); -// } - - propertyConstraintsList = config.getPropertyConstraint(); - - if (propertyConstraintsList.isEmpty()) { - propertyConstraintsList.add(new PropertyConstraintType()); - } - - if(config.getObjectTemplateRef() != null){ - ObjectReferenceType ref = config.getObjectTemplateRef(); - templateRef = new ObjectTemplateConfigTypeReferenceDto(ref.getOid(), getObjectTemplateName(ref.getOid(), page)); - } - } - - public ObjectPolicyConfigurationType preparePolicyConfig(OperationResult result){ - ObjectPolicyConfigurationType newConfig = new ObjectPolicyConfigurationType(); - - for (PropertyConstraintType constraintType : propertyConstraintsList) { - PrismContainerValue constraint = constraintType.asPrismContainerValue(); - if (BooleanUtils.isTrue(constraintType.isOidBound()) && constraintType.getPath() == null) { - result.recordWarning(page.createStringResource("ObjectPolicyDialogDto.message.preparePolicyConfig.warning").getString()); - } - if (!constraint.isEmpty() && constraintType.getPath() != null) { - newConfig.getPropertyConstraint().add(constraint.clone().asContainerable()); - } - } - newConfig.setType(type); - newConfig.setSubtype(subtype); - newConfig.setConflictResolution(config.getConflictResolution()); - - if (templateRef != null) { - ObjectReferenceType ref = new ObjectReferenceType(); - ref.setOid(templateRef.getOid()); - ref.setType(ObjectTemplateType.COMPLEX_TYPE); - ref.setTargetName(new PolyStringType(templateRef.getName())); - newConfig.setObjectTemplateRef(ref); - } - - result.recordSuccessIfUnknown(); - return newConfig; - } - - public List getPropertyConstraintsList() { - return propertyConstraintsList; - } - - public void setPropertyConstraintsList(List propertyConstraintsList) { - this.propertyConstraintsList = propertyConstraintsList; - } - - public QName getType() { - return type; - } - - public void setType(QName type) { - this.type = type; - } - - public String getSubtype() { - return subtype; - } - - public void setSubtype(String subtype) { - this.subtype = subtype; - } - - private String getObjectTemplateName(String oid, PageBase page){ - Task task = page.createSimpleTask(OPERATION_LOAD_OBJECT_TEMPLATE); - OperationResult result = task.getResult(); - - PrismObject templatePrism = WebModelServiceUtils.loadObject(ObjectTemplateType.class, oid, - page, task, result); - - if(templatePrism != null){ - return WebComponentUtil.getName(templatePrism); - } - - return ""; - } - - public ObjectPolicyConfigurationType getConfig() { - return config; - } - - public void setConfig(ObjectPolicyConfigurationType config) { - this.config = config; - } - - public ObjectTemplateConfigTypeReferenceDto getTemplateRef() { - return templateRef; - } - - public void setTemplateRef(ObjectTemplateConfigTypeReferenceDto templateRef) { - this.templateRef = templateRef; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((config == null) ? 0 : config.hashCode()); - result = prime * result - + ((propertyConstraintsList == null) ? 0 : propertyConstraintsList.hashCode()); - result = prime * result + ((subtype == null) ? 0 : subtype.hashCode()); - result = prime * result + ((templateRef == null) ? 0 : templateRef.hashCode()); - result = prime * result + ((type == null) ? 0 : type.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - ObjectPolicyDialogDto other = (ObjectPolicyDialogDto) obj; - if (config == null) { - if (other.config != null) { - return false; - } - } else if (!config.equals(other.config)) { - return false; - } - if (propertyConstraintsList == null) { - if (other.propertyConstraintsList != null) { - return false; - } - } else if (!propertyConstraintsList.equals(other.propertyConstraintsList)) { - return false; - } - if (subtype == null) { - if (other.subtype != null) { - return false; - } - } else if (!subtype.equals(other.subtype)) { - return false; - } - if (templateRef == null) { - if (other.templateRef != null) { - return false; - } - } else if (!templateRef.equals(other.templateRef)) { - return false; - } - if (type == null) { - if (other.type != null) { - return false; - } - } else if (!type.equals(other.type)) { - return false; - } - return true; - } - - @Override - public String toString() { - return "ObjectPolicyDialogDto(propertyConstraintsList=" + propertyConstraintsList + ", config=" - + config + ", type=" + type + ", subtype=" + subtype + ", templateRef=" + templateRef + ")"; - } - - -} +/* + * Copyright (c) 2010-2017 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ + +package com.evolveum.midpoint.web.page.admin.configuration.dto; + +import java.io.Serializable; +import java.util.List; + +import javax.xml.namespace.QName; + +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; + +import org.apache.commons.lang3.BooleanUtils; + +import com.evolveum.midpoint.gui.api.page.PageBase; +import com.evolveum.midpoint.gui.api.util.WebComponentUtil; +import com.evolveum.midpoint.gui.api.util.WebModelServiceUtils; +import com.evolveum.midpoint.prism.PrismContainerValue; +import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ItemConstraintType; +import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; + +/** + * @author shood + * */ +public class ObjectPolicyDialogDto implements Serializable{ + private static final long serialVersionUID = 1L; + + private static final String DOT_CLASS = ObjectPolicyDialogDto.class.getName() + "."; + + private static final String OPERATION_LOAD_OBJECT_TEMPLATE = DOT_CLASS + "loadObjectTemplate"; + + public static final String F_CONFIG = "config"; + public static final String F_TEMPLATE_REF = "templateRef"; + public static final String F_TYPE = "type"; + public static final String F_SUBTYPE = "subtype"; + public static final String F_PROPERTY_LIST = "propertyConstraintsList"; + + private List propertyConstraintsList; + private ObjectPolicyConfigurationType config; + private QName type; + private String subtype; + private ObjectTemplateConfigTypeReferenceDto templateRef; + PageBase page; + + public ObjectPolicyDialogDto(ObjectPolicyConfigurationType config, PageBase page) { + this.config = config; + type = config.getType(); + subtype = config.getSubtype(); + this.page =page; + +// for (PropertyConstraintType constraint : config.getPropertyConstraint()) { +// propertyConstraintsList.add(new PropertyConstraintTypeDto(constraint)); +// } + + propertyConstraintsList = config.getPropertyConstraint(); + + if (propertyConstraintsList.isEmpty()) { + propertyConstraintsList.add(new ItemConstraintType()); + } + + if(config.getObjectTemplateRef() != null){ + ObjectReferenceType ref = config.getObjectTemplateRef(); + templateRef = new ObjectTemplateConfigTypeReferenceDto(ref.getOid(), getObjectTemplateName(ref.getOid(), page)); + } + } + + public ObjectPolicyConfigurationType preparePolicyConfig(OperationResult result){ + ObjectPolicyConfigurationType newConfig = new ObjectPolicyConfigurationType(); + + for (ItemConstraintType constraintType : propertyConstraintsList) { + PrismContainerValue constraint = constraintType.asPrismContainerValue(); + if (BooleanUtils.isTrue(constraintType.isOidBound()) && constraintType.getPath() == null) { + result.recordWarning(page.createStringResource("ObjectPolicyDialogDto.message.preparePolicyConfig.warning").getString()); + } + if (!constraint.isEmpty() && constraintType.getPath() != null) { + newConfig.getPropertyConstraint().add(constraint.clone().asContainerable()); + } + } + newConfig.setType(type); + newConfig.setSubtype(subtype); + newConfig.setConflictResolution(config.getConflictResolution()); + + if (templateRef != null) { + ObjectReferenceType ref = new ObjectReferenceType(); + ref.setOid(templateRef.getOid()); + ref.setType(ObjectTemplateType.COMPLEX_TYPE); + ref.setTargetName(new PolyStringType(templateRef.getName())); + newConfig.setObjectTemplateRef(ref); + } + + result.recordSuccessIfUnknown(); + return newConfig; + } + + public List getPropertyConstraintsList() { + return propertyConstraintsList; + } + + public void setPropertyConstraintsList(List propertyConstraintsList) { + this.propertyConstraintsList = propertyConstraintsList; + } + + public QName getType() { + return type; + } + + public void setType(QName type) { + this.type = type; + } + + public String getSubtype() { + return subtype; + } + + public void setSubtype(String subtype) { + this.subtype = subtype; + } + + private String getObjectTemplateName(String oid, PageBase page){ + Task task = page.createSimpleTask(OPERATION_LOAD_OBJECT_TEMPLATE); + OperationResult result = task.getResult(); + + PrismObject templatePrism = WebModelServiceUtils.loadObject(ObjectTemplateType.class, oid, + page, task, result); + + if(templatePrism != null){ + return WebComponentUtil.getName(templatePrism); + } + + return ""; + } + + public ObjectPolicyConfigurationType getConfig() { + return config; + } + + public void setConfig(ObjectPolicyConfigurationType config) { + this.config = config; + } + + public ObjectTemplateConfigTypeReferenceDto getTemplateRef() { + return templateRef; + } + + public void setTemplateRef(ObjectTemplateConfigTypeReferenceDto templateRef) { + this.templateRef = templateRef; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((config == null) ? 0 : config.hashCode()); + result = prime * result + + ((propertyConstraintsList == null) ? 0 : propertyConstraintsList.hashCode()); + result = prime * result + ((subtype == null) ? 0 : subtype.hashCode()); + result = prime * result + ((templateRef == null) ? 0 : templateRef.hashCode()); + result = prime * result + ((type == null) ? 0 : type.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + ObjectPolicyDialogDto other = (ObjectPolicyDialogDto) obj; + if (config == null) { + if (other.config != null) { + return false; + } + } else if (!config.equals(other.config)) { + return false; + } + if (propertyConstraintsList == null) { + if (other.propertyConstraintsList != null) { + return false; + } + } else if (!propertyConstraintsList.equals(other.propertyConstraintsList)) { + return false; + } + if (subtype == null) { + if (other.subtype != null) { + return false; + } + } else if (!subtype.equals(other.subtype)) { + return false; + } + if (templateRef == null) { + if (other.templateRef != null) { + return false; + } + } else if (!templateRef.equals(other.templateRef)) { + return false; + } + if (type == null) { + if (other.type != null) { + return false; + } + } else if (!type.equals(other.type)) { + return false; + } + return true; + } + + @Override + public String toString() { + return "ObjectPolicyDialogDto(propertyConstraintsList=" + propertyConstraintsList + ", config=" + + config + ", type=" + type + ", subtype=" + subtype + ", templateRef=" + templateRef + ")"; + } + + +} diff --git a/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd b/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd index 50e3d1d3693..4ddbf3b3513 100755 --- a/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd +++ b/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd @@ -14886,10 +14886,23 @@ - + + + ObjectPolicyConfigurationType.itemConstraint + 4.1 + + + + + + + DEPRECATED. Use itemConstraint instead. + ObjectPolicyConfigurationType.propertyConstraint + true + 4.1 @@ -19477,21 +19490,21 @@ - + Definition of a property constraints. - PropertyConstraintType.details + ItemConstraintType.details - PropertyConstraintType.path + ItemConstraintType.path diff --git a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/ArchetypeManager.java b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/ArchetypeManager.java index 6767de74644..5c67dd0058c 100644 --- a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/ArchetypeManager.java +++ b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/ArchetypeManager.java @@ -169,8 +169,14 @@ private ArchetypePolicyType merge(ArchetypePolicyType archetypePolicy, ObjectPol if (archetypePolicy.getObjectTemplateRef() == null && objectPolicy.getObjectTemplateRef() != null) { resultPolicy.setObjectTemplateRef(objectPolicy.getObjectTemplateRef().clone()); } + if (archetypePolicy.getItemConstraint().isEmpty()) { + for (ItemConstraintType objItemConstraint : objectPolicy.getItemConstraint()) { + resultPolicy.getItemConstraint().add(objItemConstraint.clone()); + } + } + // Deprecated if (archetypePolicy.getPropertyConstraint().isEmpty()) { - for (PropertyConstraintType objPropertyConstraint : objectPolicy.getPropertyConstraint()) { + for (ItemConstraintType objPropertyConstraint : objectPolicy.getPropertyConstraint()) { resultPolicy.getPropertyConstraint().add(objPropertyConstraint.clone()); } } diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/ChangeExecutor.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/ChangeExecutor.java index 3a1eeef378f..141d2fd0b94 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/ChangeExecutor.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/ChangeExecutor.java @@ -1,1897 +1,1904 @@ -/* - * Copyright (c) 2010-2019 Evolveum and contributors - * - * This work is dual-licensed under the Apache License 2.0 - * and European Union Public License. See LICENSE file for details. - */ - -package com.evolveum.midpoint.model.impl.lens; - -import static com.evolveum.midpoint.model.api.ProgressInformation.ActivityType.FOCUS_OPERATION; -import static com.evolveum.midpoint.model.api.ProgressInformation.ActivityType.RESOURCE_OBJECT_OPERATION; -import static com.evolveum.midpoint.model.api.ProgressInformation.StateType.ENTERING; -import static com.evolveum.midpoint.prism.PrismContainerValue.asContainerables; -import static com.evolveum.midpoint.schema.internals.InternalsConfig.consistencyChecks; - -import com.evolveum.midpoint.common.Clock; -import com.evolveum.midpoint.common.SynchronizationUtils; -import com.evolveum.midpoint.prism.delta.*; -import com.evolveum.midpoint.prism.equivalence.EquivalenceStrategy; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.prism.xnode.PrimitiveXNode; -import com.evolveum.midpoint.prism.xnode.XNodeFactory; -import com.evolveum.midpoint.repo.api.ConflictWatcher; -import com.evolveum.midpoint.repo.api.ModificationPrecondition; -import com.evolveum.midpoint.repo.api.PreconditionViolationException; -import com.evolveum.midpoint.repo.common.expression.Expression; -import com.evolveum.midpoint.repo.common.expression.ExpressionEvaluationContext; -import com.evolveum.midpoint.repo.common.expression.ExpressionFactory; -import com.evolveum.midpoint.repo.common.expression.ExpressionUtil; -import com.evolveum.midpoint.repo.common.expression.ExpressionVariables; -import com.evolveum.midpoint.model.api.ModelAuthorizationAction; -import com.evolveum.midpoint.model.api.ModelExecuteOptions; -import com.evolveum.midpoint.model.api.ProgressInformation; -import com.evolveum.midpoint.model.api.context.SynchronizationPolicyDecision; -import com.evolveum.midpoint.model.impl.ModelObjectResolver; -import com.evolveum.midpoint.model.impl.expr.ExpressionEnvironment; -import com.evolveum.midpoint.model.impl.expr.ModelExpressionThreadLocalHolder; -import com.evolveum.midpoint.model.impl.lens.projector.credentials.CredentialsProcessor; -import com.evolveum.midpoint.model.impl.lens.projector.focus.FocusConstraintsChecker; -import com.evolveum.midpoint.model.impl.util.ModelImplUtils; -import com.evolveum.midpoint.prism.*; -import com.evolveum.midpoint.prism.crypto.EncryptionException; -import com.evolveum.midpoint.provisioning.api.ProvisioningOperationOptions; -import com.evolveum.midpoint.provisioning.api.ProvisioningService; -import com.evolveum.midpoint.repo.api.RepoAddOptions; -import com.evolveum.midpoint.repo.api.RepositoryService; -import com.evolveum.midpoint.repo.api.VersionPrecondition; -import com.evolveum.midpoint.repo.common.util.RepoCommonUtils; -import com.evolveum.midpoint.schema.GetOperationOptions; -import com.evolveum.midpoint.schema.ObjectDeltaOperation; -import com.evolveum.midpoint.schema.PointInTimeType; -import com.evolveum.midpoint.schema.ResourceShadowDiscriminator; -import com.evolveum.midpoint.schema.SelectorOptions; -import com.evolveum.midpoint.schema.constants.ExpressionConstants; -import com.evolveum.midpoint.schema.constants.ObjectTypes; -import com.evolveum.midpoint.schema.constants.SchemaConstants; -import com.evolveum.midpoint.schema.expression.ExpressionProfile; -import com.evolveum.midpoint.schema.internals.InternalsConfig; -import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.schema.result.OperationResultStatus; -import com.evolveum.midpoint.schema.util.ExceptionUtil; -import com.evolveum.midpoint.schema.util.MiscSchemaUtil; -import com.evolveum.midpoint.schema.util.ResourceTypeUtil; -import com.evolveum.midpoint.schema.util.ShadowUtil; -import com.evolveum.midpoint.security.api.MidPointPrincipal; -import com.evolveum.midpoint.security.api.OwnerResolver; -import com.evolveum.midpoint.security.api.SecurityContextManager; -import com.evolveum.midpoint.security.enforcer.api.AuthorizationParameters; -import com.evolveum.midpoint.security.enforcer.api.SecurityEnforcer; -import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.task.api.TaskManager; -import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.DebugUtil; -import com.evolveum.midpoint.util.MiscUtil; -import com.evolveum.midpoint.util.QNameUtil; -import com.evolveum.midpoint.util.exception.*; -import com.evolveum.midpoint.util.logging.LoggingUtils; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.common_3.*; -import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; -import com.evolveum.prism.xml.ns._public.types_3.RawType; - -import org.apache.commons.lang.BooleanUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Component; - -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import javax.annotation.PostConstruct; -import javax.xml.bind.JAXBElement; -import javax.xml.datatype.XMLGregorianCalendar; -import javax.xml.namespace.QName; - -/** - * @author semancik - */ -@Component -public class ChangeExecutor { - - private static final Trace LOGGER = TraceManager.getTrace(ChangeExecutor.class); - - private static final String OPERATION_EXECUTE_DELTA = ChangeExecutor.class.getName() + ".executeDelta"; - private static final String OPERATION_EXECUTE = ChangeExecutor.class.getName() + ".execute"; - private static final String OPERATION_EXECUTE_FOCUS = OPERATION_EXECUTE + ".focus"; - private static final String OPERATION_EXECUTE_PROJECTION = OPERATION_EXECUTE + ".projection"; - private static final String OPERATION_LINK_ACCOUNT = ChangeExecutor.class.getName() + ".linkShadow"; - private static final String OPERATION_UNLINK_ACCOUNT = ChangeExecutor.class.getName() + ".unlinkShadow"; - private static final String OPERATION_UPDATE_SITUATION_IN_SHADOW = ChangeExecutor.class.getName() + ".updateSituationInShadow"; - - @Autowired private transient TaskManager taskManager; - @Autowired @Qualifier("cacheRepositoryService") private transient RepositoryService cacheRepositoryService; - @Autowired private ProvisioningService provisioning; - @Autowired private PrismContext prismContext; - @Autowired private ExpressionFactory expressionFactory; - @Autowired private SecurityEnforcer securityEnforcer; - @Autowired private SecurityContextManager securityContextManager; - @Autowired private Clock clock; - @Autowired private ModelObjectResolver objectResolver; - @Autowired private OperationalDataManager metadataManager; - @Autowired private CredentialsProcessor credentialsProcessor; - - private PrismObjectDefinition userDefinition = null; - private PrismObjectDefinition shadowDefinition = null; - - @PostConstruct - private void locateDefinitions() { - userDefinition = prismContext.getSchemaRegistry() - .findObjectDefinitionByCompileTimeClass(UserType.class); - shadowDefinition = prismContext.getSchemaRegistry() - .findObjectDefinitionByCompileTimeClass(ShadowType.class); - } - - // returns true if current operation has to be restarted, see - // ObjectAlreadyExistsException handling (TODO specify more exactly) - public boolean executeChanges(LensContext context, Task task, - OperationResult parentResult) throws ObjectAlreadyExistsException, ObjectNotFoundException, - SchemaException, CommunicationException, ConfigurationException, - SecurityViolationException, ExpressionEvaluationException, PreconditionViolationException, PolicyViolationException { - - OperationResult result = parentResult.createSubresult(OPERATION_EXECUTE); - - try { - - // FOCUS - - context.checkAbortRequested(); - - LensFocusContext focusContext = context.getFocusContext(); - if (focusContext != null) { - ObjectDelta focusDelta = focusContext.getWaveExecutableDelta(context.getExecutionWave()); - - focusDelta = applyPendingObjectPolicyStateModifications(focusContext, focusDelta); - focusDelta = applyPendingAssignmentPolicyStateModifications(focusContext, focusDelta); - - if (focusDelta == null && !context.hasProjectionChange()) { - LOGGER.trace("Skipping focus change execute, because user delta is null"); - } else { - - if (focusDelta == null) { - focusDelta = focusContext.getObjectAny().createModifyDelta(); - } - - ArchetypePolicyType archetypePolicy = focusContext.getArchetypePolicyType(); - applyObjectPolicy(focusContext, focusDelta, archetypePolicy); - - OperationResult subResult = result.createSubresult( - OPERATION_EXECUTE_FOCUS + "." + focusContext.getObjectTypeClass().getSimpleName()); - - try { - // Will remove credential deltas or hash them - focusDelta = credentialsProcessor.transformFocusExecutionDelta(context, focusDelta); - } catch (EncryptionException e) { - recordFatalError(subResult, result, null, e); - result.computeStatus(); - throw new SystemException(e.getMessage(), e); - } - - applyLastProvisioningTimestamp(context, focusDelta); - - try { - - context.reportProgress(new ProgressInformation(FOCUS_OPERATION, ENTERING)); - - ConflictResolutionType conflictResolution = ModelExecuteOptions - .getFocusConflictResolution(context.getOptions()); - - executeDelta(focusDelta, focusContext, context, null, conflictResolution, null, task, subResult); - - if (focusDelta.isAdd() && focusDelta.getOid() != null) { - // The watcher can already exist; if the OID was pre-existing in the object. - if (context.getFocusConflictWatcher() == null) { - ConflictWatcher watcher = context - .createAndRegisterFocusConflictWatcher(focusDelta.getOid(), cacheRepositoryService); - watcher.setExpectedVersion(focusDelta.getObjectToAdd().getVersion()); - } - } - subResult.computeStatus(); - - } catch (SchemaException | ObjectNotFoundException | CommunicationException | ConfigurationException | SecurityViolationException | ExpressionEvaluationException | RuntimeException e) { - recordFatalError(subResult, result, null, e); - throw e; - - } catch (PreconditionViolationException e) { - - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Modification precondition failed for {}: {}", focusContext.getHumanReadableName(), - e.getMessage()); - } - // TODO: fatal error if the conflict resolution is "error" (later) - result.recordHandledError(e); - throw e; - - } catch (ObjectAlreadyExistsException e) { - subResult.computeStatus(); - if (!subResult.isSuccess() && !subResult.isHandledError()) { - subResult.recordFatalError(e); - } - result.computeStatusComposite(); - throw e; - } finally { - context.reportProgress(new ProgressInformation(FOCUS_OPERATION, subResult)); - } - } - } - - // PROJECTIONS - - context.checkAbortRequested(); - - boolean restartRequested = false; - - for (LensProjectionContext projCtx : context.getProjectionContexts()) { - if (projCtx.getWave() != context.getExecutionWave()) { - LOGGER.trace("Skipping projection context {} because its wave ({}) is different from execution wave ({})", - projCtx.toHumanReadableString(), projCtx.getWave(), context.getExecutionWave()); - continue; - } - - if (!projCtx.isCanProject()) { - LOGGER.trace("Skipping projection context {} because canProject is false", projCtx.toHumanReadableString()); - continue; - } - - // we should not get here, but just to be sure - if (projCtx.getSynchronizationPolicyDecision() == SynchronizationPolicyDecision.IGNORE) { - LOGGER.trace("Skipping ignored projection context {}", projCtx.toHumanReadableString()); - continue; - } - - OperationResult subResult = result.subresult(OPERATION_EXECUTE_PROJECTION + "." + projCtx.getObjectTypeClass().getSimpleName()) - .addParam("resource", projCtx.getResource()) - .addArbitraryObjectAsContext("discriminator", projCtx.getResourceShadowDiscriminator()) - .build(); - - PrismObject shadowAfterModification = null; - try { - LOGGER.trace("Executing projection context {}", projCtx.toHumanReadableString()); - - context.checkAbortRequested(); - - context.reportProgress(new ProgressInformation(RESOURCE_OBJECT_OPERATION, - projCtx.getResourceShadowDiscriminator(), ENTERING)); - - executeReconciliationScript(projCtx, context, BeforeAfterType.BEFORE, task, subResult); - - ObjectDelta projDelta = projCtx.getExecutableDelta(); - - if (shouldBeDeleted(projDelta, projCtx)) { - projDelta = prismContext.deltaFactory().object() - .createDeleteDelta(projCtx.getObjectTypeClass(), projCtx.getOid()); - } - - if (projCtx.getSynchronizationPolicyDecision() == SynchronizationPolicyDecision.BROKEN) { - if (context.getFocusContext() != null - && context.getFocusContext().getDelta() != null - && context.getFocusContext().getDelta().isDelete() - && context.getOptions() != null - && ModelExecuteOptions.isForce(context.getOptions())) { - if (projDelta == null) { - projDelta = prismContext.deltaFactory().object() - .createDeleteDelta(projCtx.getObjectTypeClass(), projCtx.getOid()); - } - } - if (projDelta != null && projDelta.isDelete()) { - - shadowAfterModification = executeDelta(projDelta, projCtx, context, null, null, projCtx.getResource(), task, - subResult); - - } - } else { - - if (projDelta == null || projDelta.isEmpty()) { - LOGGER.trace("No change for {}", projCtx.getResourceShadowDiscriminator()); - shadowAfterModification = projCtx.getObjectCurrent(); - if (focusContext != null) { - updateLinks(context, focusContext, projCtx, shadowAfterModification, task, subResult); - } - - // Make sure post-reconcile delta is always executed, - // even if there is no change - executeReconciliationScript(projCtx, context, BeforeAfterType.AFTER, task, - subResult); - - subResult.computeStatus(); - subResult.recordNotApplicableIfUnknown(); - continue; - - } else if (projDelta.isDelete() && projCtx.getResourceShadowDiscriminator() != null - && projCtx.getResourceShadowDiscriminator().getOrder() > 0) { - // HACK ... for higher-order context check if this was - // already deleted - LensProjectionContext lowerOrderContext = LensUtil.findLowerOrderContext(context, - projCtx); - if (lowerOrderContext != null && lowerOrderContext.isDelete()) { - // We assume that this was already executed - subResult.setStatus(OperationResultStatus.NOT_APPLICABLE); - continue; - } - } - - shadowAfterModification = executeDelta(projDelta, projCtx, context, null, null, projCtx.getResource(), task, subResult); - - if (projCtx.isAdd() && shadowAfterModification != null) { - projCtx.setExists(true); - } - - } - - subResult.computeStatus(); - if (focusContext != null) { - updateLinks(context, focusContext, projCtx, shadowAfterModification, task, subResult); - } - - executeReconciliationScript(projCtx, context, BeforeAfterType.AFTER, task, subResult); - - subResult.computeStatus(); - subResult.recordNotApplicableIfUnknown(); - - } catch (SchemaException | ObjectNotFoundException | PreconditionViolationException | CommunicationException | - ConfigurationException | SecurityViolationException | PolicyViolationException | ExpressionEvaluationException | RuntimeException | Error e) { - recordProjectionExecutionException(e, projCtx, subResult, SynchronizationPolicyDecision.BROKEN); - - // We still want to update the links here. E.g. this may be live sync case where we discovered new account - // try to reconcile, but the reconciliation fails. We still want this shadow linked to user. - if (focusContext != null) { - updateLinks(context, focusContext, projCtx, shadowAfterModification, task, subResult); - } - - ModelImplUtils.handleConnectorErrorCriticality(projCtx.getResource(), e, subResult); - - - } catch (ObjectAlreadyExistsException e) { - - // This exception is quite special. We have to decide how bad this really is. - // This may be rename conflict. Which would be bad. - // Or this may be attempt to create account that already exists and just needs - // to be linked. Which is no big deal and consistency mechanism (discovery) will - // easily handle that. In that case it is done in "another task" which is - // quasi-asynchornously executed from provisioning by calling notifyChange. - // Once that is done then the account is already linked. And all we need to do - // is to restart this whole operation. - - // check if this is a repeated attempt - OAEE was not handled - // correctly, e.g. if creating "Users" user in AD, whereas - // "Users" is SAM Account Name which is used by a built-in group - // - in such case, mark the context as broken - if (isRepeatedAlreadyExistsException(projCtx)) { - // This is the bad case. Currently we do not do anything more intelligent than to look for - // repeated error. If we get OAEE twice then this is bad and we thow up. - // TODO: do something smarter here - LOGGER.debug("Repeated ObjectAlreadyExistsException detected, marking projection {} as broken", projCtx.toHumanReadableString()); - recordProjectionExecutionException(e, projCtx, subResult, - SynchronizationPolicyDecision.BROKEN); - continue; - } - - // in his case we do not need to set account context as - // broken, instead we need to restart projector for this - // context to recompute new account or find out if the - // account was already linked.. - // and also do not set fatal error to the operation result, this - // is a special case - // if it is fatal, it will be set later - // but we need to set some result - subResult.recordSuccess(); - restartRequested = true; - LOGGER.debug("ObjectAlreadyExistsException for projection {}, requesting projector restart", projCtx.toHumanReadableString()); - // we will process remaining projections when retrying the wave - break; - - } finally { - context.reportProgress(new ProgressInformation(RESOURCE_OBJECT_OPERATION, - projCtx.getResourceShadowDiscriminator(), subResult)); - } - } - - // Result computation here needs to be slightly different - result.computeStatusComposite(); - return restartRequested; - - } catch (Throwable t) { - result.recordThrowableIfNeeded(t); // last resort: to avoid UNKNOWN subresults - throw t; - } - } - - private ObjectDelta applyPendingObjectPolicyStateModifications(LensFocusContext focusContext, - ObjectDelta focusDelta) throws SchemaException { - for (ItemDelta itemDelta : focusContext.getPendingObjectPolicyStateModifications()) { - focusDelta = focusContext.swallowToDelta(focusDelta, itemDelta); - } - focusContext.clearPendingObjectPolicyStateModifications(); - return focusDelta; - } - - private ObjectDelta applyPendingAssignmentPolicyStateModifications(LensFocusContext focusContext, ObjectDelta focusDelta) - throws SchemaException { - for (Map.Entry>> entry : focusContext - .getPendingAssignmentPolicyStateModifications().entrySet()) { - PlusMinusZero mode = entry.getKey().mode; - if (mode == PlusMinusZero.MINUS) { - continue; // this assignment is being thrown out anyway, so let's ignore it (at least for now) - } - AssignmentType assignmentToFind = entry.getKey().assignment; - List> modifications = entry.getValue(); - if (modifications.isEmpty()) { - continue; - } - LOGGER.trace("Applying policy state modifications for {} ({}):\n{}", assignmentToFind, mode, - DebugUtil.debugDumpLazily(modifications)); - if (mode == PlusMinusZero.ZERO) { - if (assignmentToFind.getId() == null) { - throw new IllegalStateException("Existing assignment with null id: " + assignmentToFind); - } - for (ItemDelta modification : modifications) { - focusDelta = focusContext.swallowToDelta(focusDelta, modification); - } - } else { - assert mode == PlusMinusZero.PLUS; - if (focusDelta != null && focusDelta.isAdd()) { - swallowIntoValues(((FocusType) focusDelta.getObjectToAdd().asObjectable()).getAssignment(), - assignmentToFind, modifications); - } else { - ContainerDelta assignmentDelta = focusDelta != null ? - focusDelta.findContainerDelta(FocusType.F_ASSIGNMENT) : null; - if (assignmentDelta == null) { - throw new IllegalStateException( - "We have 'plus' assignment to modify but there's no assignment delta. Assignment=" - + assignmentToFind + ", objectDelta=" + focusDelta); - } - if (assignmentDelta.isReplace()) { - swallowIntoValues(asContainerables(assignmentDelta.getValuesToReplace()), assignmentToFind, - modifications); - } else if (assignmentDelta.isAdd()) { - swallowIntoValues(asContainerables(assignmentDelta.getValuesToAdd()), assignmentToFind, - modifications); - } else { - throw new IllegalStateException( - "We have 'plus' assignment to modify but there're no values to add or replace in assignment delta. Assignment=" - + assignmentToFind + ", objectDelta=" + focusDelta); - } - } - } - } - focusContext.clearPendingAssignmentPolicyStateModifications(); - return focusDelta; - } - - private void swallowIntoValues(Collection assignments, AssignmentType assignmentToFind, List> modifications) - throws SchemaException { - for (AssignmentType assignment : assignments) { - PrismContainerValue pcv = assignment.asPrismContainerValue(); - PrismContainerValue pcvToFind = assignmentToFind.asPrismContainerValue(); - if (pcv.representsSameValue(pcvToFind, false) || pcv.equals(pcvToFind, EquivalenceStrategy.REAL_VALUE_CONSIDER_DIFFERENT_IDS)) { - // TODO what if ID of the assignment being added is changed in repo? Hopefully it will be not. - for (ItemDelta modification : modifications) { - ItemPath newParentPath = modification.getParentPath().rest(2); // killing assignment + ID - ItemDelta pathRelativeModification = modification.cloneWithChangedParentPath(newParentPath); - pathRelativeModification.applyTo(pcv); - } - return; - } - } - // TODO change to warning - throw new IllegalStateException("We have 'plus' assignment to modify but it couldn't be found in assignment delta. Assignment=" + assignmentToFind + ", new assignments=" + assignments); - } - - private void applyLastProvisioningTimestamp(LensContext context, ObjectDelta focusDelta) throws SchemaException { - if (!context.hasProjectionChange()) { - return; - } - if (focusDelta.isAdd()) { - - PrismObject objectToAdd = focusDelta.getObjectToAdd(); - PrismContainer metadataContainer = objectToAdd.findOrCreateContainer(ObjectType.F_METADATA); - metadataContainer.getRealValue().setLastProvisioningTimestamp(clock.currentTimeXMLGregorianCalendar()); - - } else if (focusDelta.isModify()) { - - PropertyDelta provTimestampDelta = prismContext.deltaFactory().property().createModificationReplaceProperty( - ItemPath.create(ObjectType.F_METADATA, MetadataType.F_LAST_PROVISIONING_TIMESTAMP), - context.getFocusContext().getObjectDefinition(), - clock.currentTimeXMLGregorianCalendar()); - focusDelta.addModification(provTimestampDelta); - - } - } - - private boolean shouldBeDeleted(ObjectDelta accDelta, LensProjectionContext accCtx) { - return (accDelta == null || accDelta.isEmpty()) - && (accCtx.getSynchronizationPolicyDecision() == SynchronizationPolicyDecision.DELETE - || accCtx.getSynchronizationIntent() == SynchronizationIntent.DELETE); - } - - private boolean isRepeatedAlreadyExistsException( - LensProjectionContext projContext) { - int deltas = projContext.getExecutedDeltas().size(); - LOGGER.trace("isRepeatedAlreadyExistsException starting; number of executed deltas = {}", deltas); - if (deltas < 2) { - return false; - } - LensObjectDeltaOperation lastDeltaOp = projContext.getExecutedDeltas().get(deltas - 1); - LensObjectDeltaOperation previousDeltaOp = projContext.getExecutedDeltas() - .get(deltas - 2); - // TODO check also previous execution result to see if it's - // AlreadyExistException? - ObjectDelta lastDelta = lastDeltaOp.getObjectDelta(); - ObjectDelta previousDelta = previousDeltaOp.getObjectDelta(); - boolean rv; - if (lastDelta.isAdd() && previousDelta.isAdd()) { - rv = isEquivalentAddDelta(lastDelta.getObjectToAdd(), previousDelta.getObjectToAdd()); - } else if (lastDelta.isModify() && previousDelta.isModify()) { - rv = isEquivalentModifyDelta(lastDelta.getModifications(), previousDelta.getModifications()); - } else { - rv = false; - } - LOGGER.trace( - "isRepeatedAlreadyExistsException returning {}; based of comparison of previousDelta:\n{}\nwith lastDelta:\n{}", - rv, previousDelta, lastDelta); - return rv; - } - - private boolean isEquivalentModifyDelta(Collection> modifications1, - Collection> modifications2) { - Collection> attrDeltas1 = ItemDeltaCollectionsUtil - .findItemDeltasSubPath(modifications1, ShadowType.F_ATTRIBUTES); - Collection> attrDeltas2 = ItemDeltaCollectionsUtil - .findItemDeltasSubPath(modifications2, ShadowType.F_ATTRIBUTES); - //noinspection unchecked,RedundantCast - return MiscUtil.unorderedCollectionEquals((Collection) attrDeltas1, (Collection) attrDeltas2); - } - - private boolean isEquivalentAddDelta(PrismObject object1, PrismObject object2) { - PrismContainer attributes1 = object1.findContainer(ShadowType.F_ATTRIBUTES); - PrismContainer attributes2 = object2.findContainer(ShadowType.F_ATTRIBUTES); - if (attributes1 == null || attributes2 == null || attributes1.size() != 1 - || attributes2.size() != 1) { // suspicious cases - return false; - } - return attributes1.getValue().equivalent(attributes2.getValue()); - } - - private void applyObjectPolicy(LensFocusContext focusContext, - ObjectDelta focusDelta, ArchetypePolicyType archetypePolicy) { - if (archetypePolicy == null) { - return; - } - PrismObject objectNew = focusContext.getObjectNew(); - if (focusDelta.isAdd() && objectNew.getOid() == null) { - - for (PropertyConstraintType propertyConstraintType : archetypePolicy - .getPropertyConstraint()) { - if (BooleanUtils.isTrue(propertyConstraintType.isOidBound())) { - ItemPath itemPath = propertyConstraintType.getPath().getItemPath(); - PrismProperty prop = objectNew.findProperty(itemPath); - String stringValue = prop.getRealValue().toString(); - focusContext.setOid(stringValue); - } - } - - } - } - - private

void recordProjectionExecutionException(Throwable e, - LensProjectionContext accCtx, OperationResult subResult, SynchronizationPolicyDecision decision) { - subResult.recordFatalError(e); - LOGGER.error("Error executing changes for {}: {}", accCtx.toHumanReadableString(), e.getMessage(), e); - if (decision != null) { - accCtx.setSynchronizationPolicyDecision(decision); - } - } - - private void recordFatalError(OperationResult subResult, OperationResult result, String message, - Throwable e) { - if (message == null) { - message = e.getMessage(); - } - subResult.recordFatalError(e); - if (result != null) { - result.computeStatusComposite(); - } - } - - /** - * Make sure that the account is linked (or unlinked) as needed. - */ - private void updateLinks(LensContext context, - LensFocusContext focusObjectContext, LensProjectionContext projCtx, - PrismObject shadowAfterModification, - Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { - if (focusObjectContext == null) { - return; - } - Class objectTypeClass = focusObjectContext.getObjectTypeClass(); - if (!FocusType.class.isAssignableFrom(objectTypeClass)) { - return; - } - //noinspection unchecked - LensFocusContext focusContext = (LensFocusContext) focusObjectContext; - - if (projCtx.getResourceShadowDiscriminator() != null - && projCtx.getResourceShadowDiscriminator().getOrder() > 0) { - // Don't mess with links for higher-order contexts. The link should - // be dealt with - // during processing of zero-order context. - return; - } - - String projOid = projCtx.getOid(); - if (projOid == null) { - if (projCtx.getSynchronizationPolicyDecision() == SynchronizationPolicyDecision.BROKEN) { - // This seems to be OK. In quite a strange way, but still OK. - return; - } - LOGGER.error("Projection {} has null OID, this should not happen, context:\n{}", projCtx.toHumanReadableString(), projCtx.debugDump()); - throw new IllegalStateException("Projection "+projCtx.toHumanReadableString()+" has null OID, this should not happen"); - } - - if (linkShouldExist(projCtx, shadowAfterModification, result)) { - // Link should exist - PrismObject objectCurrent = focusContext.getObjectCurrent(); - if (objectCurrent != null) { - for (ObjectReferenceType linkRef : objectCurrent.asObjectable().getLinkRef()) { - if (projOid.equals(linkRef.getOid())) { - // Already linked, nothing to do, only be sure, the situation is set with the good value - LOGGER.trace("Updating situation in already linked shadow."); - updateSituationInShadow(task, SynchronizationSituationType.LINKED, context, focusObjectContext, projCtx, result); - return; - } - } - } - // Not linked, need to link - linkShadow(focusContext.getOid(), projOid, focusObjectContext, projCtx, task, result); - // be sure, that the situation is set correctly - LOGGER.trace("Updating situation after shadow was linked."); - updateSituationInShadow(task, SynchronizationSituationType.LINKED, context, focusObjectContext, projCtx, result); - } else { - // Link should NOT exist - if (!focusContext.isDelete()) { - PrismObject objectCurrent = focusContext.getObjectCurrent(); - // it is possible that objectCurrent is null (and objectNew is - // non-null), in case of User ADD operation (MID-2176) - if (objectCurrent != null) { - PrismReference linkRef = objectCurrent.findReference(FocusType.F_LINK_REF); - if (linkRef != null) { - for (PrismReferenceValue linkRefVal : linkRef.getValues()) { - if (linkRefVal.getOid().equals(projOid)) { - // Linked, need to unlink - unlinkShadow(focusContext.getOid(), linkRefVal, focusObjectContext, projCtx, task, result); - } - } - } - } - } - - // This should NOT be UNLINKED. We just do not know the situation here. Reflect that in the shadow. - LOGGER.trace("Resource object {} unlinked from the user, updating also situation in shadow.", projOid); - updateSituationInShadow(task, null, context, focusObjectContext, projCtx, result); - // Not linked, that's OK - } - } - - private boolean linkShouldExist(LensProjectionContext projCtx, PrismObject shadowAfterModification, OperationResult result) { - if (!projCtx.isShadowExistsInRepo()) { - // Nothing to link to - return false; - } - if (projCtx.getSynchronizationPolicyDecision() == SynchronizationPolicyDecision.UNLINK) { - return false; - } - if (isEmptyThombstone(projCtx)) { - return false; - } - if (projCtx.getSynchronizationPolicyDecision() == SynchronizationPolicyDecision.DELETE - || projCtx.isDelete()) { - return shadowAfterModification != null; - } - if (projCtx.hasPendingOperations()) { - return true; - } - return true; - } - - /** - * Return true if this projection is just a linkRef that points to no - * shadow. - */ - private boolean isEmptyThombstone(LensProjectionContext projCtx) { - return projCtx.getResourceShadowDiscriminator() != null - && projCtx.getResourceShadowDiscriminator().isTombstone() - && projCtx.getObjectCurrent() == null; - } - - private void linkShadow(String userOid, String shadowOid, - LensElementContext focusContext, LensProjectionContext projCtx, Task task, - OperationResult parentResult) throws ObjectNotFoundException, SchemaException { - - Class typeClass = focusContext.getObjectTypeClass(); - if (!FocusType.class.isAssignableFrom(typeClass)) { - return; - } - - String channel = focusContext.getLensContext().getChannel(); - - LOGGER.debug("Linking shadow " + shadowOid + " to focus " + userOid); - OperationResult result = parentResult.createSubresult(OPERATION_LINK_ACCOUNT); - PrismReferenceValue linkRef = prismContext.itemFactory().createReferenceValue(); - linkRef.setOid(shadowOid); - linkRef.setTargetType(ShadowType.COMPLEX_TYPE); - Collection linkRefDeltas = prismContext.deltaFactory().reference() - .createModificationAddCollection(FocusType.F_LINK_REF, getUserDefinition(), linkRef); - - try { - cacheRepositoryService.modifyObject(typeClass, userOid, linkRefDeltas, result); - task.recordObjectActionExecuted(focusContext.getObjectAny(), typeClass, userOid, - ChangeType.MODIFY, channel, null); - } catch (ObjectAlreadyExistsException ex) { - task.recordObjectActionExecuted(focusContext.getObjectAny(), typeClass, userOid, - ChangeType.MODIFY, channel, ex); - throw new SystemException(ex); - } catch (Throwable t) { - task.recordObjectActionExecuted(focusContext.getObjectAny(), typeClass, userOid, - ChangeType.MODIFY, channel, t); - throw t; - } finally { - result.computeStatus(); - ObjectDelta userDelta = prismContext.deltaFactory().object().createModifyDelta(userOid, linkRefDeltas, typeClass - ); - LensObjectDeltaOperation userDeltaOp = LensUtil.createObjectDeltaOperation(userDelta, result, - focusContext, projCtx); - focusContext.addToExecutedDeltas(userDeltaOp); - } - - } - - private PrismObjectDefinition getUserDefinition() { - return userDefinition; - } - - private void unlinkShadow(String focusOid, PrismReferenceValue accountRef, - LensElementContext focusContext, LensProjectionContext projCtx, Task task, - OperationResult parentResult) throws ObjectNotFoundException, SchemaException { - - Class typeClass = focusContext.getObjectTypeClass(); - if (!FocusType.class.isAssignableFrom(typeClass)) { - return; - } - - String channel = focusContext.getLensContext().getChannel(); - - LOGGER.debug("Unlinking shadow " + accountRef.getOid() + " from focus " + focusOid); - OperationResult result = parentResult.createSubresult(OPERATION_UNLINK_ACCOUNT); - Collection accountRefDeltas = prismContext.deltaFactory().reference().createModificationDeleteCollection( - FocusType.F_LINK_REF, getUserDefinition(), accountRef.clone()); - - try { - cacheRepositoryService.modifyObject(typeClass, focusOid, accountRefDeltas, result); - task.recordObjectActionExecuted(focusContext.getObjectAny(), typeClass, focusOid, - ChangeType.MODIFY, channel, null); - } catch (ObjectAlreadyExistsException ex) { - task.recordObjectActionExecuted(focusContext.getObjectAny(), typeClass, focusOid, - ChangeType.MODIFY, channel, ex); - result.recordFatalError(ex); - throw new SystemException(ex); - } catch (Throwable t) { - task.recordObjectActionExecuted(focusContext.getObjectAny(), typeClass, focusOid, - ChangeType.MODIFY, channel, t); - throw t; - } finally { - result.computeStatus(); - ObjectDelta userDelta = prismContext.deltaFactory().object() - .createModifyDelta(focusOid, accountRefDeltas, typeClass - ); - LensObjectDeltaOperation userDeltaOp = LensUtil.createObjectDeltaOperation(userDelta, result, - focusContext, projCtx); - focusContext.addToExecutedDeltas(userDeltaOp); - } - - } - - private void updateSituationInShadow(Task task, SynchronizationSituationType newSituation, - LensContext context, LensFocusContext focusContext, LensProjectionContext projectionCtx, - OperationResult parentResult) - throws SchemaException { - - String projectionOid = projectionCtx.getOid(); - - OperationResult result = parentResult.createMinorSubresult(OPERATION_UPDATE_SITUATION_IN_SHADOW); - result.addArbitraryObjectAsParam("situation", newSituation); - result.addParam("accountRef", projectionOid); - - PrismObject currentShadow; - GetOperationOptions getOptions = GetOperationOptions.createNoFetch(); - getOptions.setAllowNotFound(true); - try { - // TODO consider skipping this operation - at least in some cases - currentShadow = provisioning.getObject(ShadowType.class, projectionOid, - SelectorOptions.createCollection(getOptions), task, result); - } catch (ObjectNotFoundException ex) { - LOGGER.trace("Shadow is gone, skipping modifying situation in shadow."); - result.recordSuccess(); - return; - } catch (Exception ex) { - LOGGER.trace("Problem with getting shadow, skipping modifying situation in shadow."); - result.recordPartialError(ex); - return; - } - - SynchronizationSituationType currentSynchronizationSituation = currentShadow.asObjectable().getSynchronizationSituation(); - if (currentSynchronizationSituation == SynchronizationSituationType.DELETED && ShadowUtil.isDead(currentShadow.asObjectable())) { - LOGGER.trace("Skipping update of synchronization situation for deleted dead shadow"); - result.recordSuccess(); - return; - } - - InternalsConfigurationType internalsConfig = context.getInternalsConfiguration(); - boolean cansSkip = - internalsConfig != null && internalsConfig.getSynchronizationSituationUpdating() != null && - Boolean.TRUE.equals(internalsConfig.getSynchronizationSituationUpdating().isSkipWhenNoChange()); - if (cansSkip) { - if (newSituation == currentSynchronizationSituation) { - LOGGER.trace("Skipping update of synchronization situation because there is no change ({})", - currentSynchronizationSituation); - result.recordSuccess(); - return; - } else { - LOGGER.trace("Updating synchronization situation {} -> {}", currentSynchronizationSituation, newSituation); - } - } - - XMLGregorianCalendar now = clock.currentTimeXMLGregorianCalendar(); - List> syncSituationDeltas = SynchronizationUtils - .createSynchronizationSituationAndDescriptionDelta(currentShadow, newSituation, task.getChannel(), - projectionCtx.hasFullShadow(), now, prismContext); - - try { - ModelImplUtils.setRequestee(task, focusContext); - ProvisioningOperationOptions options = ProvisioningOperationOptions.createCompletePostponed(false); - options.setDoNotDiscovery(true); - provisioning.modifyObject(ShadowType.class, projectionOid, syncSituationDeltas, null, options, task, result); - projectionCtx.setSynchronizationSituationResolved(newSituation); - LOGGER.trace("Situation in projection {} was updated to {}.", projectionCtx, newSituation); - } catch (ObjectNotFoundException ex) { - // if the object not found exception is thrown, it's ok..probably - // the account was deleted by previous execution of changes..just - // log in the trace the message for the user.. - LOGGER.debug( - "Situation in account could not be updated. Account not found on the resource. Skipping modifying situation in account"); - return; - } catch (Exception ex) { - result.recordFatalError(ex); - throw new SystemException(ex.getMessage(), ex); - } finally { - ModelImplUtils.clearRequestee(task); - } - // if everything is OK, add result of the situation modification to the - // parent result - result.recordSuccess(); - - } - - /** - * @return Returns estimate of the object after modification. Or null if the object was deleted. - * NOTE: this is only partially implemented (only for shadow delete). - */ - private PrismObject executeDelta(ObjectDelta objectDelta, - LensElementContext objectContext, LensContext context, ModelExecuteOptions options, - ConflictResolutionType conflictResolution, ResourceType resource, Task task, OperationResult parentResult) - throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, - CommunicationException, ConfigurationException, SecurityViolationException, - PolicyViolationException, ExpressionEvaluationException, PreconditionViolationException { - - if (objectDelta == null) { - throw new IllegalArgumentException("Null change"); - } - - if (objectDelta.getOid() == null) { - objectDelta.setOid(objectContext.getOid()); - } - - objectDelta = computeDeltaToExecute(objectDelta, objectContext); - if (LOGGER.isTraceEnabled()) { - LOGGER.trace("computeDeltaToExecute returned:\n{}", - objectDelta != null ? objectDelta.debugDump(1) : "(null)"); - } - - if (objectDelta == null || objectDelta.isEmpty()) { - LOGGER.debug("Skipping execution of delta because it was already executed: {}", objectContext); - return objectContext.getObjectCurrent(); - } - - if (InternalsConfig.consistencyChecks) { - objectDelta.checkConsistence(ConsistencyCheckScope.fromBoolean(consistencyChecks)); - } - - // Other types than focus types may not be definition-complete (e.g. - // accounts and resources are completed in provisioning) - if (FocusType.class.isAssignableFrom(objectDelta.getObjectTypeClass())) { - objectDelta.assertDefinitions(); - } - - LensUtil.setDeltaOldValue(objectContext, objectDelta); - - if (LOGGER.isTraceEnabled()) { - logDeltaExecution(objectDelta, context, resource, null, task); - } - - OperationResult result = parentResult.createSubresult(OPERATION_EXECUTE_DELTA); - PrismObject objectAfterModification = null; - - try { - if (objectDelta.getChangeType() == ChangeType.ADD) { - objectAfterModification = executeAddition(objectDelta, context, objectContext, options, resource, task, result); - } else if (objectDelta.getChangeType() == ChangeType.MODIFY) { - executeModification(objectDelta, context, objectContext, options, conflictResolution, resource, task, result); - } else if (objectDelta.getChangeType() == ChangeType.DELETE) { - objectAfterModification = executeDeletion(objectDelta, context, objectContext, options, resource, task, result); - } - - // To make sure that the OID is set (e.g. after ADD operation) - LensUtil.setContextOid(context, objectContext, objectDelta.getOid()); - - } finally { - - result.computeStatus(); - if (objectContext != null) { - if (!objectDelta.hasCompleteDefinition()) { - throw new SchemaException("object delta does not have complete definition"); - } - LensObjectDeltaOperation objectDeltaOp = LensUtil.createObjectDeltaOperation( - objectDelta.clone(), result, objectContext, null, resource); - if (LOGGER.isTraceEnabled()) { - LOGGER.trace("Recording executed delta:\n{}", objectDeltaOp.shorterDebugDump(1)); - } - objectContext.addToExecutedDeltas(objectDeltaOp); - if (result.isTracingNormal(ModelExecuteDeltaTraceType.class)) { - TraceType trace = new ModelExecuteDeltaTraceType(prismContext) - .delta(objectDeltaOp.clone().toLensObjectDeltaOperationType()); // todo kill operation result? - result.addTrace(trace); - } - } else { - if (result.isTracingNormal(ModelExecuteDeltaTraceType.class)) { - LensObjectDeltaOperation objectDeltaOp = new LensObjectDeltaOperation<>(objectDelta); // todo - TraceType trace = new ModelExecuteDeltaTraceType(prismContext) - .delta(objectDeltaOp.toLensObjectDeltaOperationType()); - result.addTrace(trace); - } - } - - if (LOGGER.isDebugEnabled()) { - if (LOGGER.isTraceEnabled()) { - LOGGER.trace("EXECUTION result {}", result.getLastSubresult()); - } else { - // Execution of deltas was not logged yet - logDeltaExecution(objectDelta, context, resource, result.getLastSubresult(), task); - } - } - } - - return objectAfterModification; - } - - private void removeExecutedItemDeltas( - ObjectDelta objectDelta, LensElementContext objectContext) { - if (objectContext == null) { - return; - } - - if (objectDelta == null || objectDelta.isEmpty()) { - return; - } - - if (objectDelta.getModifications() == null || objectDelta.getModifications().isEmpty()) { - return; - } - - List> executedDeltas = objectContext.getExecutedDeltas(); - for (LensObjectDeltaOperation executedDelta : executedDeltas) { - ObjectDelta executed = executedDelta.getObjectDelta(); - Iterator objectDeltaIterator = objectDelta.getModifications().iterator(); - while (objectDeltaIterator.hasNext()) { - ItemDelta d = objectDeltaIterator.next(); - if (executed.containsModification(d, EquivalenceStrategy.LITERAL_IGNORE_METADATA) || d.isEmpty()) { // todo why literal? - objectDeltaIterator.remove(); - } - } - } - } - -// // TODO beware - what if the delta was executed but not successfully? -// private boolean alreadyExecuted(ObjectDelta objectDelta, -// LensElementContext objectContext) { -// if (objectContext == null) { -// return false; -// } -// if (LOGGER.isTraceEnabled()) { -// LOGGER.trace("Checking for already executed delta:\n{}\nIn deltas:\n{}", objectDelta.debugDump(), -// DebugUtil.debugDump(objectContext.getExecutedDeltas())); -// } -// return ObjectDeltaOperation.containsDelta(objectContext.getExecutedDeltas(), objectDelta); -// } - - /** - * Was this object already added? (temporary method, should be removed soon) - */ - private boolean wasAdded(List> executedOperations, - String oid) { - for (LensObjectDeltaOperation operation : executedOperations) { - if (operation.getObjectDelta().isAdd() && oid.equals(operation.getObjectDelta().getOid()) - && !operation.getExecutionResult().isFatalError()) { - return true; - } - } - return false; - } - - /** - * Computes delta to execute, given a list of already executes deltas. See - * below. - */ - private ObjectDelta computeDeltaToExecute(ObjectDelta objectDelta, - LensElementContext objectContext) throws SchemaException { - if (objectContext == null) { - return objectDelta; - } - if (LOGGER.isTraceEnabled()) { - LOGGER.trace("Computing delta to execute from delta:\n{}\nGiven these executed deltas:\n{}", - objectDelta.debugDump(1), LensObjectDeltaOperation.shorterDebugDump(objectContext.getExecutedDeltas(),1)); - } - List> executedDeltas = objectContext.getExecutedDeltas(); - ObjectDelta diffDelta = computeDiffDelta(executedDeltas, objectDelta); - - // One more check: is the computed delta idempotent related to objectCurrent? - // Currently we deal only with focusContext because of safety; and also because this check is a reaction - // in change to focus context secondary delta swallowing code (MID-5207). - // - // LookupTableType operation optimization is not available here, because it looks like that isRedundant - // does not work reliably for key-based row deletions (MID-5276). - if (diffDelta != null && objectContext instanceof LensFocusContext && - !objectContext.isOfType(LookupTableType.class) && - diffDelta.isRedundant(objectContext.getObjectCurrent(), false)) { - LOGGER.trace("delta is idempotent related to {}", objectContext.getObjectCurrent()); - return null; - } - return diffDelta; - } - - /** - * Compute a "difference delta" - given that executedDeltas were executed, - * and objectDelta is about to be executed; eliminates parts that have - * already been done. It is meant as a kind of optimization (for MODIFY - * deltas) and error avoidance (for ADD deltas). - * - * Explanation for ADD deltas: there are situations where an execution wave - * is restarted - when unexpected AlreadyExistsException is reported from - * provisioning. However, in such cases, duplicate ADD Focus deltas were - * generated. So we (TEMPORARILY!) decided to filter them out here. - * - * Unfortunately, this mechanism is not well-defined, and seems to work more - * "by accident" than "by design". It should be replaced with something more - * serious. Perhaps by re-reading current focus state when repeating a wave? - * Actually, it is a supplement for rewriting ADD->MODIFY deltas in - * LensElementContext.getFixedPrimaryDelta. That method converts primary - * deltas (and as far as I know, that is the only place where this problem - * should occur). Nevertheless, for historical and safety reasons I keep - * also the processing in this method. - * - * Anyway, currently it treats only three cases: - * 1) if the objectDelta is present in the list of executed deltas - * 2) if the objectDelta is ADD, and another ADD delta is there (then the difference is computed) - * 3) if objectDelta is MODIFY or DELETE and previous delta was MODIFY - * - */ - private ObjectDelta computeDiffDelta( - List> executedDeltas, ObjectDelta objectDelta) { - if (executedDeltas == null || executedDeltas.isEmpty()) { - return objectDelta; - } - - // any delta related to our OID, not ending with fatal error - ObjectDeltaOperation lastRelated = findLastRelatedDelta(executedDeltas, objectDelta); - if (LOGGER.isTraceEnabled()) { - LOGGER.trace("findLastRelatedDelta returned:\n{}", - lastRelated != null ? lastRelated.shorterDebugDump(1) : " (null)"); - } - if (lastRelated == null) { - return objectDelta; // nothing found, let us apply our delta - } - if (lastRelated.getExecutionResult().isSuccess() && lastRelated.containsDelta(objectDelta)) { - return null; // case 1 - exact match found with SUCCESS result, - // let's skip the processing of our delta - } - if (!objectDelta.isAdd()) { - if (lastRelated.getObjectDelta().isDelete()) { - return null; // case 3 - } else { - return objectDelta; // MODIFY or DELETE delta after ADD or MODIFY delta - we may safely apply it - } - } - // determine if we got case 2 - if (lastRelated.getObjectDelta().isDelete()) { - return objectDelta; // we can (and should) apply the ADD delta as a - // whole, because the object was deleted - } - // let us treat the most simple case here - meaning we have existing ADD - // delta and nothing more - // TODO add more sophistication if needed - if (!lastRelated.getObjectDelta().isAdd()) { - return objectDelta; // this will probably fail, but ... - } - // at this point we know that ADD was more-or-less successfully - // executed, so let's compute the difference, creating a MODIFY delta - PrismObject alreadyAdded = lastRelated.getObjectDelta().getObjectToAdd(); - PrismObject toBeAddedNow = objectDelta.getObjectToAdd(); - return alreadyAdded.diff(toBeAddedNow); - } - - private ObjectDeltaOperation findLastRelatedDelta( - List> executedDeltas, ObjectDelta objectDelta) { - for (int i = executedDeltas.size() - 1; i >= 0; i--) { - ObjectDeltaOperation currentOdo = executedDeltas.get(i); - if (currentOdo.getExecutionResult().isFatalError()) { - continue; - } - ObjectDelta current = currentOdo.getObjectDelta(); - - if (current.equals(objectDelta)) { - return currentOdo; - } - - String oid1 = current.isAdd() ? current.getObjectToAdd().getOid() : current.getOid(); - String oid2 = objectDelta.isAdd() ? objectDelta.getObjectToAdd().getOid() - : objectDelta.getOid(); - if (oid1 != null && oid2 != null) { - if (oid1.equals(oid2)) { - return currentOdo; - } - continue; - } - // ADD-MODIFY and ADD-DELETE combinations lead to applying whole - // delta (as a result of computeDiffDelta) - // so we can be lazy and check only ADD-ADD combinations here... - if (!current.isAdd() || !objectDelta.isAdd()) { - continue; - } - // we simply check the type (for focus objects) and - // resource+kind+intent (for shadows) - PrismObject currentObject = current.getObjectToAdd(); - PrismObject objectTypeToAdd = objectDelta.getObjectToAdd(); - Class currentObjectClass = currentObject.getCompileTimeClass(); - Class objectTypeToAddClass = objectTypeToAdd.getCompileTimeClass(); - if (currentObjectClass == null || !currentObjectClass.equals(objectTypeToAddClass)) { - continue; - } - if (FocusType.class.isAssignableFrom(currentObjectClass)) { - return currentOdo; // we suppose there is only one delta of - // Focus class - } - } - return null; - } - - private ProvisioningOperationOptions copyFromModelOptions(ModelExecuteOptions options) { - ProvisioningOperationOptions provisioningOptions = new ProvisioningOperationOptions(); - if (options == null) { - return provisioningOptions; - } - - provisioningOptions.setForce(options.getForce()); - provisioningOptions.setOverwrite(options.getOverwrite()); - return provisioningOptions; - } - - private ProvisioningOperationOptions getProvisioningOptions(LensContext context, - ModelExecuteOptions modelOptions, PrismObject existingShadow, ObjectDelta delta) throws SecurityViolationException { - if (modelOptions == null && context != null) { - modelOptions = context.getOptions(); - } - ProvisioningOperationOptions provisioningOptions = copyFromModelOptions(modelOptions); - - if (executeAsSelf(context, modelOptions, existingShadow, delta)) { - LOGGER.trace("Setting 'execute as self' provisioning option for {}", existingShadow); - provisioningOptions.setRunAsAccountOid(existingShadow.getOid()); - } - - if (context != null && context.getChannel() != null) { - - if (context.getChannel().equals(QNameUtil.qNameToUri(SchemaConstants.CHANGE_CHANNEL_RECON))) { - // TODO: this is probably wrong. We should not have special case - // for recon channel! This should be handled by the provisioning task - // setting the right options there. - provisioningOptions.setCompletePostponed(false); - } - - if (context.getChannel().equals(SchemaConstants.CHANGE_CHANNEL_DISCOVERY_URI)) { - // We want to avoid endless loops in error handling. - provisioningOptions.setDoNotDiscovery(true); - } - } - - return provisioningOptions; - } - - // This is a bit of black magic. We only want to execute as self if there a user is changing its own password - // and we also have old password value. - // Later, this should be improved. Maybe we need special model operation option for this? Or maybe it should be somehow - // automatically detected based on resource capabilities? We do not know yet. Therefore let's do the simplest possible - // thing. Otherwise we might do something that we will later regret. - private boolean executeAsSelf(LensContext context, - ModelExecuteOptions modelOptions, PrismObject existingShadow, ObjectDelta delta) throws SecurityViolationException { - if (existingShadow == null) { - return false; - } - - if (!SchemaConstants.CHANNEL_GUI_SELF_SERVICE_URI.equals(context.getChannel())) { - return false; - } - - if (delta == null) { - return false; - } - if (!delta.isModify()) { - return false; - } - PropertyDelta passwordDelta = delta.findPropertyDelta(SchemaConstants.PATH_PASSWORD_VALUE); - if (passwordDelta == null) { - return false; - } - if (passwordDelta.getEstimatedOldValues() == null || passwordDelta.getEstimatedOldValues().isEmpty()) { - return false; - } - ProtectedStringType oldPassword = passwordDelta.getEstimatedOldValues().iterator().next().getValue(); - if (!oldPassword.canGetCleartext()) { - return false; - } - - LensFocusContext focusContext = context.getFocusContext(); - if (focusContext == null) { - return false; - } - if (!focusContext.represents(UserType.class)) { - return false; - } - - MidPointPrincipal principal = securityContextManager.getPrincipal(); - if (principal == null) { - return false; - } - FocusType loggedInUser = principal.getFocus(); - - if (!loggedInUser.getOid().equals(focusContext.getOid())) { - return false; - } - return true; - } - - private void logDeltaExecution(ObjectDelta objectDelta, - LensContext context, ResourceType resource, OperationResult result, Task task) { - StringBuilder sb = new StringBuilder(); - sb.append("---[ "); - if (result == null) { - sb.append("Going to EXECUTE"); - } else { - sb.append("EXECUTED"); - } - sb.append(" delta of ").append(objectDelta.getObjectTypeClass().getSimpleName()); - sb.append(" ]---------------------\n"); - DebugUtil.debugDumpLabel(sb, "Channel", 0); - sb.append(" ").append(LensUtil.getChannel(context, task)).append("\n"); - if (context != null) { - DebugUtil.debugDumpLabel(sb, "Wave", 0); - sb.append(" ").append(context.getExecutionWave()).append("\n"); - } - if (resource != null) { - sb.append("Resource: ").append(resource.toString()).append("\n"); - } - sb.append(objectDelta.debugDump()); - sb.append("\n"); - if (result != null) { - DebugUtil.debugDumpLabel(sb, "Result", 0); - sb.append(" ").append(result.getStatus()).append(": ").append(result.getMessage()); - } - sb.append("\n--------------------------------------------------"); - - LOGGER.debug("\n{}", sb); - } - - private OwnerResolver createOwnerResolver(final LensContext context, Task task, - OperationResult result) { - return new LensOwnerResolver<>(context, objectResolver, task, result); - } - - private PrismObject executeAddition(ObjectDelta change, - LensContext context, LensElementContext objectContext, ModelExecuteOptions options, - ResourceType resource, Task task, OperationResult result) throws ObjectAlreadyExistsException, - ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, - SecurityViolationException, PolicyViolationException, ExpressionEvaluationException, PreconditionViolationException { - - PrismObject objectToAdd = change.getObjectToAdd(); - - for (ItemDelta delta : change.getModifications()) { - delta.applyTo(objectToAdd); - } - change.getModifications().clear(); - - OwnerResolver ownerResolver = createOwnerResolver(context, task, result); - T objectTypeToAdd = objectToAdd.asObjectable(); - try { - securityEnforcer.authorize(ModelAuthorizationAction.ADD.getUrl(), - AuthorizationPhaseType.EXECUTION, AuthorizationParameters.Builder.buildObjectAdd(objectToAdd), ownerResolver, task, result); - - - metadataManager.applyMetadataAdd(context, objectToAdd, clock.currentTimeXMLGregorianCalendar(), task, result); - - if (options == null) { - options = context.getOptions(); - } - - RepoAddOptions addOpt = new RepoAddOptions(); - if (ModelExecuteOptions.isOverwrite(options)) { - addOpt.setOverwrite(true); - } - if (ModelExecuteOptions.isNoCrypt(options)) { - addOpt.setAllowUnencryptedValues(true); - } - - String oid; - if (objectTypeToAdd instanceof TaskType) { - oid = addTask((TaskType) objectTypeToAdd, addOpt, result); - } else if (objectTypeToAdd instanceof NodeType) { - throw new UnsupportedOperationException("NodeType cannot be added using model interface"); - } else if (ObjectTypes.isManagedByProvisioning(objectTypeToAdd)) { - - ProvisioningOperationOptions provisioningOptions = getProvisioningOptions(context, options, - (PrismObject)objectContext.getObjectCurrent(), (ObjectDelta)change); - - oid = addProvisioningObject(objectToAdd, context, objectContext, provisioningOptions, - resource, task, result); - if (oid == null) { - throw new SystemException( - "Provisioning addObject returned null OID while adding " + objectToAdd); - } - result.addReturn("createdAccountOid", oid); - } else { - FocusConstraintsChecker.clearCacheFor(objectToAdd.asObjectable().getName()); - - oid = cacheRepositoryService.addObject(objectToAdd, addOpt, result); - if (oid == null) { - throw new SystemException("Repository addObject returned null OID while adding " + objectToAdd); - } - } - if (!change.isImmutable()) { - change.setOid(oid); - } - objectToAdd.setOid(oid); - task.recordObjectActionExecuted(objectToAdd, objectToAdd.getCompileTimeClass(), oid, - ChangeType.ADD, context.getChannel(), null); - return objectToAdd; - } catch (Throwable t) { - task.recordObjectActionExecuted(objectToAdd, objectToAdd.getCompileTimeClass(), null, - ChangeType.ADD, context.getChannel(), t); - if (objectTypeToAdd instanceof ShadowType) { - handleProvisioningError(resource, t, task, result); - ((LensProjectionContext) objectContext).setSynchronizationPolicyDecision(SynchronizationPolicyDecision.BROKEN); - return null; - } - throw t; - - - } - } - - private void handleProvisioningError(ResourceType resource, Throwable t, Task task, OperationResult result) throws ObjectNotFoundException, ConfigurationException, SecurityViolationException, PolicyViolationException, ExpressionEvaluationException, ObjectAlreadyExistsException, PreconditionViolationException, CommunicationException, SchemaException { - ErrorSelectorType errorSelectorType = ResourceTypeUtil.getConnectorErrorCriticality(resource); - CriticalityType criticality = ExceptionUtil.getCriticality(errorSelectorType, t, CriticalityType.FATAL); - RepoCommonUtils.processErrorCriticality(task, criticality, t, result); - if (CriticalityType.IGNORE == criticality) { - result.muteLastSubresultError(); - } - } - - private PrismObject executeDeletion(ObjectDelta change, - LensContext context, LensElementContext objectContext, ModelExecuteOptions options, - ResourceType resource, Task task, OperationResult result) throws ObjectNotFoundException, - ObjectAlreadyExistsException, SchemaException, CommunicationException, - ConfigurationException, SecurityViolationException, PolicyViolationException, ExpressionEvaluationException, PreconditionViolationException { - - String oid = change.getOid(); - Class objectTypeClass = change.getObjectTypeClass(); - - PrismObject objectOld = objectContext.getObjectOld(); - OwnerResolver ownerResolver = createOwnerResolver(context, task, result); - PrismObject objectAfterModification = null; - try { - securityEnforcer.authorize(ModelAuthorizationAction.DELETE.getUrl(), - AuthorizationPhaseType.EXECUTION, AuthorizationParameters.Builder.buildObjectDelete(objectOld), ownerResolver, task, result); - - if (TaskType.class.isAssignableFrom(objectTypeClass)) { - taskManager.deleteTask(oid, result); - } else if (NodeType.class.isAssignableFrom(objectTypeClass)) { - taskManager.deleteNode(oid, result); - } else if (ObjectTypes.isClassManagedByProvisioning(objectTypeClass)) { - ProvisioningOperationOptions provisioningOptions = getProvisioningOptions(context, options, - (PrismObject)objectContext.getObjectCurrent(), (ObjectDelta)change); - try { - objectAfterModification = deleteProvisioningObject(objectTypeClass, oid, context, objectContext, - provisioningOptions, resource, task, result); - } catch (ObjectNotFoundException e) { - // Object that we wanted to delete is already gone. This can - // happen in some race conditions. - // As the resulting state is the same as we wanted it to be - // we will not complain and we will go on. - LOGGER.trace("Attempt to delete object {} ({}) that is already gone", oid, - objectTypeClass); - result.muteLastSubresultError(); - } - } else { - try { - cacheRepositoryService.deleteObject(objectTypeClass, oid, result); - } catch (ObjectNotFoundException e) { - // Object that we wanted to delete is already gone. This can - // happen in some race conditions. - // As the resulting state is the same as we wanted it to be - // we will not complain and we will go on. - LOGGER.trace("Attempt to delete object {} ({}) that is already gone", oid, - objectTypeClass); - result.muteLastSubresultError(); - } - } - task.recordObjectActionExecuted(objectOld, objectTypeClass, oid, ChangeType.DELETE, - context.getChannel(), null); - } catch (Throwable t) { - task.recordObjectActionExecuted(objectOld, objectTypeClass, oid, ChangeType.DELETE, - context.getChannel(), t); - - if (ShadowType.class.isAssignableFrom(objectTypeClass)) { - handleProvisioningError(resource, t, task, result); - return objectContext.getObjectCurrent(); - } - - throw t; - } - - return objectAfterModification; - } - - private void executeModification(ObjectDelta delta, - LensContext context, LensElementContext objectContext, ModelExecuteOptions options, - ConflictResolutionType conflictResolution, ResourceType resource, Task task, OperationResult result) - throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException, CommunicationException, - ConfigurationException, SecurityViolationException, PolicyViolationException, ExpressionEvaluationException, PreconditionViolationException { - Class objectTypeClass = delta.getObjectTypeClass(); - - // We need current object here. The current object is used to get data for id-only container delete deltas, - // replace deltas and so on. The authorization code can figure out new object if needed, but it needs - // current object to start from. - // We cannot use old object here. That would fail in multi-wave executions. We want object that has all the previous - // wave changes already applied. - PrismObject baseObject = objectContext.getObjectCurrent(); - OwnerResolver ownerResolver = createOwnerResolver(context, task, result); - try { - securityEnforcer.authorize(ModelAuthorizationAction.MODIFY.getUrl(), - AuthorizationPhaseType.EXECUTION, AuthorizationParameters.Builder.buildObjectDelta(baseObject, delta), ownerResolver, task, result); - - if (shouldApplyModifyMetadata(objectTypeClass, context.getSystemConfigurationType())) { - metadataManager.applyMetadataModify(delta, objectContext, objectTypeClass, - clock.currentTimeXMLGregorianCalendar(), task, context, result); - } - - if (delta.isEmpty()) { - // Nothing to do - return; - } - - if (TaskType.class.isAssignableFrom(objectTypeClass)) { - taskManager.modifyTask(delta.getOid(), delta.getModifications(), result); - } else if (NodeType.class.isAssignableFrom(objectTypeClass)) { - throw new UnsupportedOperationException("NodeType is not modifiable using model interface"); - } else if (ObjectTypes.isClassManagedByProvisioning(objectTypeClass)) { - ProvisioningOperationOptions provisioningOptions = getProvisioningOptions(context, options, - (PrismObject)objectContext.getObjectCurrent(), (ObjectDelta)delta); - String oid = modifyProvisioningObject(objectTypeClass, delta.getOid(), - delta.getModifications(), context, objectContext, provisioningOptions, resource, - task, result); - if (!oid.equals(delta.getOid())) { - delta.setOid(oid); - } - } else { - FocusConstraintsChecker.clearCacheForDelta(delta.getModifications()); - ModificationPrecondition precondition = null; - if (conflictResolution != null) { - String readVersion = objectContext.getObjectReadVersion(); - if (readVersion != null) { - LOGGER.trace("Modification with precondition, readVersion={}", readVersion); - precondition = new VersionPrecondition<>(readVersion); - } else { - LOGGER.warn("Requested careful modification of {}, but there is no read version", objectContext.getHumanReadableName()); - } - } - cacheRepositoryService.modifyObject(objectTypeClass, delta.getOid(), - delta.getModifications(), precondition, null, result); - } - task.recordObjectActionExecuted(baseObject, objectTypeClass, delta.getOid(), ChangeType.MODIFY, - context.getChannel(), null); - } catch (Throwable t) { - task.recordObjectActionExecuted(baseObject, objectTypeClass, delta.getOid(), ChangeType.MODIFY, - context.getChannel(), t); - throw t; - } - } - - private boolean shouldApplyModifyMetadata(Class objectTypeClass, SystemConfigurationType config) { - if (!ShadowType.class.equals(objectTypeClass)) { - return true; - } else if (config == null || config.getInternals() == null || config.getInternals().getShadowMetadataRecording() == null) { - return true; - } else { - MetadataRecordingStrategyType recording = config.getInternals().getShadowMetadataRecording(); - return !Boolean.TRUE.equals(recording.isSkipOnModify()); - } - } - - private String addTask(TaskType task, RepoAddOptions addOpt, OperationResult result) - throws ObjectAlreadyExistsException { - try { - return taskManager.addTask(task.asPrismObject(), addOpt, result); - } catch (ObjectAlreadyExistsException ex) { - throw ex; - } catch (Exception ex) { - LoggingUtils.logException(LOGGER, "Couldn't add object {} to task manager", ex, task.getName()); - throw new SystemException(ex.getMessage(), ex); - } - } - - private String addProvisioningObject(PrismObject object, - LensContext context, LensElementContext objectContext, ProvisioningOperationOptions options, - ResourceType resource, Task task, OperationResult result) throws ObjectNotFoundException, - ObjectAlreadyExistsException, SchemaException, CommunicationException, - ConfigurationException, SecurityViolationException, ExpressionEvaluationException, PolicyViolationException { - - if (object.canRepresent(ShadowType.class)) { - ShadowType shadow = (ShadowType) object.asObjectable(); - String resourceOid = ShadowUtil.getResourceOid(shadow); - if (resourceOid == null) { - throw new IllegalArgumentException("Resource OID is null in shadow"); - } - } - - OperationProvisioningScriptsType scripts = null; - if (object.canRepresent(ShadowType.class)) { - scripts = prepareScripts(object, context, objectContext, ProvisioningOperationTypeType.ADD, - resource, task, result); - } - ModelImplUtils.setRequestee(task, context); - String oid = provisioning.addObject(object, scripts, options, task, result); - ModelImplUtils.clearRequestee(task); - return oid; - } - - private PrismObject deleteProvisioningObject( - Class objectTypeClass, String oid, LensContext context, LensElementContext objectContext, - ProvisioningOperationOptions options, ResourceType resource, Task task, OperationResult result) - throws ObjectNotFoundException, ObjectAlreadyExistsException, SchemaException, - CommunicationException, ConfigurationException, SecurityViolationException, - ExpressionEvaluationException, PolicyViolationException { - - PrismObject shadowToModify = null; - OperationProvisioningScriptsType scripts = null; - try { - GetOperationOptions rootOpts = GetOperationOptions.createNoFetch(); - rootOpts.setPointInTimeType(PointInTimeType.FUTURE); - shadowToModify = provisioning.getObject(objectTypeClass, oid, - SelectorOptions.createCollection(rootOpts), task, result); - } catch (ObjectNotFoundException ex) { - // this is almost OK, mute the error and try to delete account (it - // will fail if something is wrong) - result.muteLastSubresultError(); - } - if (ShadowType.class.isAssignableFrom(objectTypeClass)) { - scripts = prepareScripts(shadowToModify, context, objectContext, - ProvisioningOperationTypeType.DELETE, resource, task, result); - } - ModelImplUtils.setRequestee(task, context); - PrismObject objectAfterModification = provisioning.deleteObject(objectTypeClass, oid, options, scripts, task, result); - ModelImplUtils.clearRequestee(task); - return objectAfterModification; - } - - private String modifyProvisioningObject( - Class objectTypeClass, String oid, Collection modifications, - LensContext context, LensElementContext objectContext, ProvisioningOperationOptions options, - ResourceType resource, Task task, OperationResult result) throws ObjectNotFoundException, - CommunicationException, SchemaException, ConfigurationException, - SecurityViolationException, ExpressionEvaluationException, ObjectAlreadyExistsException, PolicyViolationException { - - PrismObject shadowToModify = null; - OperationProvisioningScriptsType scripts = null; - try { - GetOperationOptions rootOpts = GetOperationOptions.createNoFetch(); - rootOpts.setPointInTimeType(PointInTimeType.FUTURE); - shadowToModify = provisioning.getObject(objectTypeClass, oid, - SelectorOptions.createCollection(rootOpts), task, result); - } catch (ObjectNotFoundException e) { - // We do not want the operation to fail here. The object might have - // been re-created on the resource - // or discovery might re-create it. So simply ignore this error and - // give provisioning a chance to fail - // properly. - result.muteLastSubresultError(); - LOGGER.warn("Repository object {}: {} is gone. But trying to modify resource object anyway", - objectTypeClass, oid); - } - if (ShadowType.class.isAssignableFrom(objectTypeClass)) { - scripts = prepareScripts(shadowToModify, context, objectContext, - ProvisioningOperationTypeType.MODIFY, resource, task, result); - } - ModelImplUtils.setRequestee(task, context); - String changedOid = provisioning.modifyObject(objectTypeClass, oid, modifications, scripts, options, - task, result); - ModelImplUtils.clearRequestee(task); - return changedOid; - } - - private OperationProvisioningScriptsType prepareScripts( - PrismObject changedObject, LensContext context, LensElementContext objectContext, - ProvisioningOperationTypeType operation, ResourceType resource, Task task, OperationResult result) - throws ObjectNotFoundException, SchemaException, CommunicationException, - ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - - if (resource == null) { - LOGGER.warn("Resource does not exist. Skipping processing scripts."); - return null; - } - OperationProvisioningScriptsType resourceScripts = resource.getScripts(); - PrismObject resourceObject = (PrismObject) changedObject; - - PrismObject user = null; - if (context.getFocusContext() != null) { - if (context.getFocusContext().getObjectNew() != null) { - user = context.getFocusContext().getObjectNew(); - } else if (context.getFocusContext().getObjectCurrent() != null) { - user = context.getFocusContext().getObjectCurrent(); - } else if (context.getFocusContext().getObjectOld() != null) { - user = context.getFocusContext().getObjectOld(); - } - } - - LensProjectionContext projectionCtx = (LensProjectionContext) objectContext; - PrismObject shadow = null; - if (projectionCtx.getObjectNew() != null) { - shadow = projectionCtx.getObjectNew(); - } else if (projectionCtx.getObjectCurrent() != null) { - shadow = projectionCtx.getObjectCurrent(); - } else { - shadow = projectionCtx.getObjectOld(); - } - - if (shadow == null) { - //put at least something - shadow = resourceObject.clone(); - } - - ResourceShadowDiscriminator discr = ((LensProjectionContext) objectContext) - .getResourceShadowDiscriminator(); - - ExpressionVariables variables = ModelImplUtils.getDefaultExpressionVariables(user, shadow, discr, - resource.asPrismObject(), context.getSystemConfiguration(), objectContext, prismContext); - // Having delta in provisioning scripts may be very useful. E.g. the script can optimize execution of expensive operations. - variables.put(ExpressionConstants.VAR_DELTA, projectionCtx.getDelta(), ObjectDelta.class); - ExpressionProfile expressionProfile = MiscSchemaUtil.getExpressionProfile(); - ModelExpressionThreadLocalHolder.pushExpressionEnvironment(new ExpressionEnvironment<>(context, (LensProjectionContext) objectContext, task, result)); - try { - return evaluateScript(resourceScripts, discr, operation, null, variables, expressionProfile, context, objectContext, task, result); - } finally { - ModelExpressionThreadLocalHolder.popExpressionEnvironment(); - } - - } - - private OperationProvisioningScriptsType evaluateScript(OperationProvisioningScriptsType resourceScripts, - ResourceShadowDiscriminator discr, ProvisioningOperationTypeType operation, BeforeAfterType order, - ExpressionVariables variables, ExpressionProfile expressionProfile, LensContext context, - LensElementContext objectContext, Task task, - OperationResult result) - throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { - OperationProvisioningScriptsType outScripts = new OperationProvisioningScriptsType(); - - if (resourceScripts != null) { - OperationProvisioningScriptsType scripts = resourceScripts.clone(); - for (OperationProvisioningScriptType script : scripts.getScript()) { - if (discr != null) { - if (script.getKind() != null && !script.getKind().isEmpty() - && !script.getKind().contains(discr.getKind())) { - continue; - } - if (script.getIntent() != null && !script.getIntent().isEmpty() - && !script.getIntent().contains(discr.getIntent()) && discr.getIntent() != null) { - continue; - } - } - if (operation != null) { - if (!script.getOperation().contains(operation)) { - continue; - } - } - if (order != null) { - if (order != null && order != script.getOrder()) { - continue; - } - } - // Let's do the most expensive evaluation last - if (!evaluateScriptCondition(script, variables, expressionProfile, task, result)){ - continue; - } - for (ProvisioningScriptArgumentType argument : script.getArgument()) { - evaluateScriptArgument(argument, variables, context, objectContext, task, result); - } - outScripts.getScript().add(script); - } - } - - return outScripts; - } - - private boolean evaluateScriptCondition(OperationProvisioningScriptType script, - ExpressionVariables variables, ExpressionProfile expressionProfile, Task task, OperationResult result) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException { - ExpressionType condition = script.getCondition(); - if (condition == null) { - return true; - } - - PrismPropertyValue conditionOutput = ExpressionUtil.evaluateCondition(variables, condition, expressionProfile, expressionFactory, " condition for provisioning script ", task, result); - if (conditionOutput == null) { - return true; - } - - Boolean conditionOutputValue = conditionOutput.getValue(); - - return BooleanUtils.isNotFalse(conditionOutputValue); - - } - - private void evaluateScriptArgument(ProvisioningScriptArgumentType argument, - ExpressionVariables variables, LensContext context, - LensElementContext objectContext, Task task, - OperationResult result) - throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { - - final QName FAKE_SCRIPT_ARGUMENT_NAME = new QName(SchemaConstants.NS_C, "arg"); - - PrismPropertyDefinition scriptArgumentDefinition = prismContext.definitionFactory().createPropertyDefinition( - FAKE_SCRIPT_ARGUMENT_NAME, DOMUtil.XSD_STRING); - - String shortDesc = "Provisioning script argument expression"; - Expression, PrismPropertyDefinition> expression = expressionFactory - .makeExpression(argument, scriptArgumentDefinition, MiscSchemaUtil.getExpressionProfile(), shortDesc, task, result); - - ExpressionEvaluationContext params = new ExpressionEvaluationContext(null, variables, shortDesc, task); - ExpressionEnvironment env = new ExpressionEnvironment<>(context, - objectContext instanceof LensProjectionContext ? (LensProjectionContext) objectContext : null, task, result); - PrismValueDeltaSetTriple> outputTriple = ModelExpressionThreadLocalHolder - .evaluateExpressionInContext(expression, params, env, result); - - Collection> nonNegativeValues = null; - if (outputTriple != null) { - nonNegativeValues = outputTriple.getNonNegativeValues(); - } - - // replace dynamic script with static value.. - XNodeFactory factory = prismContext.xnodeFactory(); - - argument.getExpressionEvaluator().clear(); - if (nonNegativeValues == null || nonNegativeValues.isEmpty()) { - // We need to create at least one evaluator. Otherwise the - // expression code will complain - JAXBElement el = new JAXBElement<>(SchemaConstants.C_VALUE, RawType.class, new RawType(prismContext)); - argument.getExpressionEvaluator().add(el); - - } else { - for (PrismPropertyValue val : nonNegativeValues) { - PrimitiveXNode prim = factory.primitive(val.getValue(), DOMUtil.XSD_STRING); - JAXBElement el = new JAXBElement<>(SchemaConstants.C_VALUE, RawType.class, new RawType(prim, prismContext)); - argument.getExpressionEvaluator().add(el); - } - } - } - - private void executeReconciliationScript( - LensProjectionContext projContext, LensContext context, BeforeAfterType order, Task task, - OperationResult parentResult) throws SchemaException, ObjectNotFoundException, - ExpressionEvaluationException, CommunicationException, ConfigurationException, - SecurityViolationException, ObjectAlreadyExistsException { - - if (!projContext.isDoReconciliation()) { - return; - } - - ResourceType resource = projContext.getResource(); - if (resource == null) { - LOGGER.warn("Resource does not exist. Skipping processing reconciliation scripts."); - return; - } - - OperationProvisioningScriptsType resourceScripts = resource.getScripts(); - if (resourceScripts == null) { - return; - } - ExpressionProfile expressionProfile = MiscSchemaUtil.getExpressionProfile(); - executeProvisioningScripts(context, projContext, resourceScripts, ProvisioningOperationTypeType.RECONCILE, order, expressionProfile, task, parentResult); - } - - private Object executeProvisioningScripts(LensContext context, LensProjectionContext projContext, - OperationProvisioningScriptsType scripts, ProvisioningOperationTypeType operation, BeforeAfterType order, ExpressionProfile expressionProfile, Task task, OperationResult parentResult) - throws SchemaException, ObjectNotFoundException, - ExpressionEvaluationException, CommunicationException, ConfigurationException, - SecurityViolationException, ObjectAlreadyExistsException { - - ResourceType resource = projContext.getResource(); - if (resource == null) { - LOGGER.warn("Resource does not exist. Skipping processing reconciliation scripts."); - return null; - } - - PrismObject user = null; - PrismObject shadow = null; - - if (context.getFocusContext() != null) { - if (context.getFocusContext().getObjectNew() != null) { - user = context.getFocusContext().getObjectNew(); - } else if (context.getFocusContext().getObjectOld() != null) { - user = context.getFocusContext().getObjectOld(); - } - // if (order == ProvisioningScriptOrderType.BEFORE) { - // user = context.getFocusContext().getObjectOld(); - // } else if (order == ProvisioningScriptOrderType.AFTER) { - // user = context.getFocusContext().getObjectNew(); - // } else { - // throw new IllegalArgumentException("Unknown order "+order); - // } - } - - if (order == BeforeAfterType.BEFORE) { - shadow = (PrismObject) projContext.getObjectOld(); - } else if (order == BeforeAfterType.AFTER) { - shadow = (PrismObject) projContext.getObjectNew(); - } else { - shadow = (PrismObject) projContext.getObjectCurrent(); - } - - ExpressionVariables variables = ModelImplUtils.getDefaultExpressionVariables(user, shadow, - projContext.getResourceShadowDiscriminator(), resource.asPrismObject(), - context.getSystemConfiguration(), projContext, prismContext); - Object scriptResult = null; - ModelExpressionThreadLocalHolder.pushExpressionEnvironment(new ExpressionEnvironment<>(context, projContext, task, parentResult)); - try { - OperationProvisioningScriptsType evaluatedScript = evaluateScript(scripts, - projContext.getResourceShadowDiscriminator(), operation, order, - variables, expressionProfile, context, projContext, task, parentResult); - for (OperationProvisioningScriptType script : evaluatedScript.getScript()) { - ModelImplUtils.setRequestee(task, context); - scriptResult = provisioning.executeScript(resource.getOid(), script, task, parentResult); - ModelImplUtils.clearRequestee(task); - } - } finally { - ModelExpressionThreadLocalHolder.popExpressionEnvironment(); - } - - return scriptResult; - } - - -} +/* + * Copyright (c) 2010-2019 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ + +package com.evolveum.midpoint.model.impl.lens; + +import static com.evolveum.midpoint.model.api.ProgressInformation.ActivityType.FOCUS_OPERATION; +import static com.evolveum.midpoint.model.api.ProgressInformation.ActivityType.RESOURCE_OBJECT_OPERATION; +import static com.evolveum.midpoint.model.api.ProgressInformation.StateType.ENTERING; +import static com.evolveum.midpoint.prism.PrismContainerValue.asContainerables; +import static com.evolveum.midpoint.schema.internals.InternalsConfig.consistencyChecks; + +import com.evolveum.midpoint.common.Clock; +import com.evolveum.midpoint.common.SynchronizationUtils; +import com.evolveum.midpoint.prism.delta.*; +import com.evolveum.midpoint.prism.equivalence.EquivalenceStrategy; +import com.evolveum.midpoint.prism.path.ItemPath; +import com.evolveum.midpoint.prism.xnode.PrimitiveXNode; +import com.evolveum.midpoint.prism.xnode.XNodeFactory; +import com.evolveum.midpoint.repo.api.ConflictWatcher; +import com.evolveum.midpoint.repo.api.ModificationPrecondition; +import com.evolveum.midpoint.repo.api.PreconditionViolationException; +import com.evolveum.midpoint.repo.common.expression.Expression; +import com.evolveum.midpoint.repo.common.expression.ExpressionEvaluationContext; +import com.evolveum.midpoint.repo.common.expression.ExpressionFactory; +import com.evolveum.midpoint.repo.common.expression.ExpressionUtil; +import com.evolveum.midpoint.repo.common.expression.ExpressionVariables; +import com.evolveum.midpoint.model.api.ModelAuthorizationAction; +import com.evolveum.midpoint.model.api.ModelExecuteOptions; +import com.evolveum.midpoint.model.api.ProgressInformation; +import com.evolveum.midpoint.model.api.context.SynchronizationPolicyDecision; +import com.evolveum.midpoint.model.impl.ModelObjectResolver; +import com.evolveum.midpoint.model.impl.expr.ExpressionEnvironment; +import com.evolveum.midpoint.model.impl.expr.ModelExpressionThreadLocalHolder; +import com.evolveum.midpoint.model.impl.lens.projector.credentials.CredentialsProcessor; +import com.evolveum.midpoint.model.impl.lens.projector.focus.FocusConstraintsChecker; +import com.evolveum.midpoint.model.impl.util.ModelImplUtils; +import com.evolveum.midpoint.prism.*; +import com.evolveum.midpoint.prism.crypto.EncryptionException; +import com.evolveum.midpoint.provisioning.api.ProvisioningOperationOptions; +import com.evolveum.midpoint.provisioning.api.ProvisioningService; +import com.evolveum.midpoint.repo.api.RepoAddOptions; +import com.evolveum.midpoint.repo.api.RepositoryService; +import com.evolveum.midpoint.repo.api.VersionPrecondition; +import com.evolveum.midpoint.repo.common.util.RepoCommonUtils; +import com.evolveum.midpoint.schema.GetOperationOptions; +import com.evolveum.midpoint.schema.ObjectDeltaOperation; +import com.evolveum.midpoint.schema.PointInTimeType; +import com.evolveum.midpoint.schema.ResourceShadowDiscriminator; +import com.evolveum.midpoint.schema.SelectorOptions; +import com.evolveum.midpoint.schema.constants.ExpressionConstants; +import com.evolveum.midpoint.schema.constants.ObjectTypes; +import com.evolveum.midpoint.schema.constants.SchemaConstants; +import com.evolveum.midpoint.schema.expression.ExpressionProfile; +import com.evolveum.midpoint.schema.internals.InternalsConfig; +import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.schema.result.OperationResultStatus; +import com.evolveum.midpoint.schema.util.ExceptionUtil; +import com.evolveum.midpoint.schema.util.MiscSchemaUtil; +import com.evolveum.midpoint.schema.util.ResourceTypeUtil; +import com.evolveum.midpoint.schema.util.ShadowUtil; +import com.evolveum.midpoint.security.api.MidPointPrincipal; +import com.evolveum.midpoint.security.api.OwnerResolver; +import com.evolveum.midpoint.security.api.SecurityContextManager; +import com.evolveum.midpoint.security.enforcer.api.AuthorizationParameters; +import com.evolveum.midpoint.security.enforcer.api.SecurityEnforcer; +import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.task.api.TaskManager; +import com.evolveum.midpoint.util.DOMUtil; +import com.evolveum.midpoint.util.DebugUtil; +import com.evolveum.midpoint.util.MiscUtil; +import com.evolveum.midpoint.util.QNameUtil; +import com.evolveum.midpoint.util.exception.*; +import com.evolveum.midpoint.util.logging.LoggingUtils; +import com.evolveum.midpoint.util.logging.Trace; +import com.evolveum.midpoint.util.logging.TraceManager; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; +import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; +import com.evolveum.prism.xml.ns._public.types_3.RawType; + +import org.apache.commons.lang.BooleanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Component; + +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import javax.annotation.PostConstruct; +import javax.xml.bind.JAXBElement; +import javax.xml.datatype.XMLGregorianCalendar; +import javax.xml.namespace.QName; + +/** + * @author semancik + */ +@Component +public class ChangeExecutor { + + private static final Trace LOGGER = TraceManager.getTrace(ChangeExecutor.class); + + private static final String OPERATION_EXECUTE_DELTA = ChangeExecutor.class.getName() + ".executeDelta"; + private static final String OPERATION_EXECUTE = ChangeExecutor.class.getName() + ".execute"; + private static final String OPERATION_EXECUTE_FOCUS = OPERATION_EXECUTE + ".focus"; + private static final String OPERATION_EXECUTE_PROJECTION = OPERATION_EXECUTE + ".projection"; + private static final String OPERATION_LINK_ACCOUNT = ChangeExecutor.class.getName() + ".linkShadow"; + private static final String OPERATION_UNLINK_ACCOUNT = ChangeExecutor.class.getName() + ".unlinkShadow"; + private static final String OPERATION_UPDATE_SITUATION_IN_SHADOW = ChangeExecutor.class.getName() + ".updateSituationInShadow"; + + @Autowired private transient TaskManager taskManager; + @Autowired @Qualifier("cacheRepositoryService") private transient RepositoryService cacheRepositoryService; + @Autowired private ProvisioningService provisioning; + @Autowired private PrismContext prismContext; + @Autowired private ExpressionFactory expressionFactory; + @Autowired private SecurityEnforcer securityEnforcer; + @Autowired private SecurityContextManager securityContextManager; + @Autowired private Clock clock; + @Autowired private ModelObjectResolver objectResolver; + @Autowired private OperationalDataManager metadataManager; + @Autowired private CredentialsProcessor credentialsProcessor; + + private PrismObjectDefinition userDefinition = null; + private PrismObjectDefinition shadowDefinition = null; + + @PostConstruct + private void locateDefinitions() { + userDefinition = prismContext.getSchemaRegistry() + .findObjectDefinitionByCompileTimeClass(UserType.class); + shadowDefinition = prismContext.getSchemaRegistry() + .findObjectDefinitionByCompileTimeClass(ShadowType.class); + } + + // returns true if current operation has to be restarted, see + // ObjectAlreadyExistsException handling (TODO specify more exactly) + public boolean executeChanges(LensContext context, Task task, + OperationResult parentResult) throws ObjectAlreadyExistsException, ObjectNotFoundException, + SchemaException, CommunicationException, ConfigurationException, + SecurityViolationException, ExpressionEvaluationException, PreconditionViolationException, PolicyViolationException { + + OperationResult result = parentResult.createSubresult(OPERATION_EXECUTE); + + try { + + // FOCUS + + context.checkAbortRequested(); + + LensFocusContext focusContext = context.getFocusContext(); + if (focusContext != null) { + ObjectDelta focusDelta = focusContext.getWaveExecutableDelta(context.getExecutionWave()); + + focusDelta = applyPendingObjectPolicyStateModifications(focusContext, focusDelta); + focusDelta = applyPendingAssignmentPolicyStateModifications(focusContext, focusDelta); + + if (focusDelta == null && !context.hasProjectionChange()) { + LOGGER.trace("Skipping focus change execute, because user delta is null"); + } else { + + if (focusDelta == null) { + focusDelta = focusContext.getObjectAny().createModifyDelta(); + } + + ArchetypePolicyType archetypePolicy = focusContext.getArchetypePolicyType(); + applyObjectPolicy(focusContext, focusDelta, archetypePolicy); + + OperationResult subResult = result.createSubresult( + OPERATION_EXECUTE_FOCUS + "." + focusContext.getObjectTypeClass().getSimpleName()); + + try { + // Will remove credential deltas or hash them + focusDelta = credentialsProcessor.transformFocusExecutionDelta(context, focusDelta); + } catch (EncryptionException e) { + recordFatalError(subResult, result, null, e); + result.computeStatus(); + throw new SystemException(e.getMessage(), e); + } + + applyLastProvisioningTimestamp(context, focusDelta); + + try { + + context.reportProgress(new ProgressInformation(FOCUS_OPERATION, ENTERING)); + + ConflictResolutionType conflictResolution = ModelExecuteOptions + .getFocusConflictResolution(context.getOptions()); + + executeDelta(focusDelta, focusContext, context, null, conflictResolution, null, task, subResult); + + if (focusDelta.isAdd() && focusDelta.getOid() != null) { + // The watcher can already exist; if the OID was pre-existing in the object. + if (context.getFocusConflictWatcher() == null) { + ConflictWatcher watcher = context + .createAndRegisterFocusConflictWatcher(focusDelta.getOid(), cacheRepositoryService); + watcher.setExpectedVersion(focusDelta.getObjectToAdd().getVersion()); + } + } + subResult.computeStatus(); + + } catch (SchemaException | ObjectNotFoundException | CommunicationException | ConfigurationException | SecurityViolationException | ExpressionEvaluationException | RuntimeException e) { + recordFatalError(subResult, result, null, e); + throw e; + + } catch (PreconditionViolationException e) { + + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Modification precondition failed for {}: {}", focusContext.getHumanReadableName(), + e.getMessage()); + } + // TODO: fatal error if the conflict resolution is "error" (later) + result.recordHandledError(e); + throw e; + + } catch (ObjectAlreadyExistsException e) { + subResult.computeStatus(); + if (!subResult.isSuccess() && !subResult.isHandledError()) { + subResult.recordFatalError(e); + } + result.computeStatusComposite(); + throw e; + } finally { + context.reportProgress(new ProgressInformation(FOCUS_OPERATION, subResult)); + } + } + } + + // PROJECTIONS + + context.checkAbortRequested(); + + boolean restartRequested = false; + + for (LensProjectionContext projCtx : context.getProjectionContexts()) { + if (projCtx.getWave() != context.getExecutionWave()) { + LOGGER.trace("Skipping projection context {} because its wave ({}) is different from execution wave ({})", + projCtx.toHumanReadableString(), projCtx.getWave(), context.getExecutionWave()); + continue; + } + + if (!projCtx.isCanProject()) { + LOGGER.trace("Skipping projection context {} because canProject is false", projCtx.toHumanReadableString()); + continue; + } + + // we should not get here, but just to be sure + if (projCtx.getSynchronizationPolicyDecision() == SynchronizationPolicyDecision.IGNORE) { + LOGGER.trace("Skipping ignored projection context {}", projCtx.toHumanReadableString()); + continue; + } + + OperationResult subResult = result.subresult(OPERATION_EXECUTE_PROJECTION + "." + projCtx.getObjectTypeClass().getSimpleName()) + .addParam("resource", projCtx.getResource()) + .addArbitraryObjectAsContext("discriminator", projCtx.getResourceShadowDiscriminator()) + .build(); + + PrismObject shadowAfterModification = null; + try { + LOGGER.trace("Executing projection context {}", projCtx.toHumanReadableString()); + + context.checkAbortRequested(); + + context.reportProgress(new ProgressInformation(RESOURCE_OBJECT_OPERATION, + projCtx.getResourceShadowDiscriminator(), ENTERING)); + + executeReconciliationScript(projCtx, context, BeforeAfterType.BEFORE, task, subResult); + + ObjectDelta projDelta = projCtx.getExecutableDelta(); + + if (shouldBeDeleted(projDelta, projCtx)) { + projDelta = prismContext.deltaFactory().object() + .createDeleteDelta(projCtx.getObjectTypeClass(), projCtx.getOid()); + } + + if (projCtx.getSynchronizationPolicyDecision() == SynchronizationPolicyDecision.BROKEN) { + if (context.getFocusContext() != null + && context.getFocusContext().getDelta() != null + && context.getFocusContext().getDelta().isDelete() + && context.getOptions() != null + && ModelExecuteOptions.isForce(context.getOptions())) { + if (projDelta == null) { + projDelta = prismContext.deltaFactory().object() + .createDeleteDelta(projCtx.getObjectTypeClass(), projCtx.getOid()); + } + } + if (projDelta != null && projDelta.isDelete()) { + + shadowAfterModification = executeDelta(projDelta, projCtx, context, null, null, projCtx.getResource(), task, + subResult); + + } + } else { + + if (projDelta == null || projDelta.isEmpty()) { + LOGGER.trace("No change for {}", projCtx.getResourceShadowDiscriminator()); + shadowAfterModification = projCtx.getObjectCurrent(); + if (focusContext != null) { + updateLinks(context, focusContext, projCtx, shadowAfterModification, task, subResult); + } + + // Make sure post-reconcile delta is always executed, + // even if there is no change + executeReconciliationScript(projCtx, context, BeforeAfterType.AFTER, task, + subResult); + + subResult.computeStatus(); + subResult.recordNotApplicableIfUnknown(); + continue; + + } else if (projDelta.isDelete() && projCtx.getResourceShadowDiscriminator() != null + && projCtx.getResourceShadowDiscriminator().getOrder() > 0) { + // HACK ... for higher-order context check if this was + // already deleted + LensProjectionContext lowerOrderContext = LensUtil.findLowerOrderContext(context, + projCtx); + if (lowerOrderContext != null && lowerOrderContext.isDelete()) { + // We assume that this was already executed + subResult.setStatus(OperationResultStatus.NOT_APPLICABLE); + continue; + } + } + + shadowAfterModification = executeDelta(projDelta, projCtx, context, null, null, projCtx.getResource(), task, subResult); + + if (projCtx.isAdd() && shadowAfterModification != null) { + projCtx.setExists(true); + } + + } + + subResult.computeStatus(); + if (focusContext != null) { + updateLinks(context, focusContext, projCtx, shadowAfterModification, task, subResult); + } + + executeReconciliationScript(projCtx, context, BeforeAfterType.AFTER, task, subResult); + + subResult.computeStatus(); + subResult.recordNotApplicableIfUnknown(); + + } catch (SchemaException | ObjectNotFoundException | PreconditionViolationException | CommunicationException | + ConfigurationException | SecurityViolationException | PolicyViolationException | ExpressionEvaluationException | RuntimeException | Error e) { + recordProjectionExecutionException(e, projCtx, subResult, SynchronizationPolicyDecision.BROKEN); + + // We still want to update the links here. E.g. this may be live sync case where we discovered new account + // try to reconcile, but the reconciliation fails. We still want this shadow linked to user. + if (focusContext != null) { + updateLinks(context, focusContext, projCtx, shadowAfterModification, task, subResult); + } + + ModelImplUtils.handleConnectorErrorCriticality(projCtx.getResource(), e, subResult); + + + } catch (ObjectAlreadyExistsException e) { + + // This exception is quite special. We have to decide how bad this really is. + // This may be rename conflict. Which would be bad. + // Or this may be attempt to create account that already exists and just needs + // to be linked. Which is no big deal and consistency mechanism (discovery) will + // easily handle that. In that case it is done in "another task" which is + // quasi-asynchornously executed from provisioning by calling notifyChange. + // Once that is done then the account is already linked. And all we need to do + // is to restart this whole operation. + + // check if this is a repeated attempt - OAEE was not handled + // correctly, e.g. if creating "Users" user in AD, whereas + // "Users" is SAM Account Name which is used by a built-in group + // - in such case, mark the context as broken + if (isRepeatedAlreadyExistsException(projCtx)) { + // This is the bad case. Currently we do not do anything more intelligent than to look for + // repeated error. If we get OAEE twice then this is bad and we thow up. + // TODO: do something smarter here + LOGGER.debug("Repeated ObjectAlreadyExistsException detected, marking projection {} as broken", projCtx.toHumanReadableString()); + recordProjectionExecutionException(e, projCtx, subResult, + SynchronizationPolicyDecision.BROKEN); + continue; + } + + // in his case we do not need to set account context as + // broken, instead we need to restart projector for this + // context to recompute new account or find out if the + // account was already linked.. + // and also do not set fatal error to the operation result, this + // is a special case + // if it is fatal, it will be set later + // but we need to set some result + subResult.recordSuccess(); + restartRequested = true; + LOGGER.debug("ObjectAlreadyExistsException for projection {}, requesting projector restart", projCtx.toHumanReadableString()); + // we will process remaining projections when retrying the wave + break; + + } finally { + context.reportProgress(new ProgressInformation(RESOURCE_OBJECT_OPERATION, + projCtx.getResourceShadowDiscriminator(), subResult)); + } + } + + // Result computation here needs to be slightly different + result.computeStatusComposite(); + return restartRequested; + + } catch (Throwable t) { + result.recordThrowableIfNeeded(t); // last resort: to avoid UNKNOWN subresults + throw t; + } + } + + private ObjectDelta applyPendingObjectPolicyStateModifications(LensFocusContext focusContext, + ObjectDelta focusDelta) throws SchemaException { + for (ItemDelta itemDelta : focusContext.getPendingObjectPolicyStateModifications()) { + focusDelta = focusContext.swallowToDelta(focusDelta, itemDelta); + } + focusContext.clearPendingObjectPolicyStateModifications(); + return focusDelta; + } + + private ObjectDelta applyPendingAssignmentPolicyStateModifications(LensFocusContext focusContext, ObjectDelta focusDelta) + throws SchemaException { + for (Map.Entry>> entry : focusContext + .getPendingAssignmentPolicyStateModifications().entrySet()) { + PlusMinusZero mode = entry.getKey().mode; + if (mode == PlusMinusZero.MINUS) { + continue; // this assignment is being thrown out anyway, so let's ignore it (at least for now) + } + AssignmentType assignmentToFind = entry.getKey().assignment; + List> modifications = entry.getValue(); + if (modifications.isEmpty()) { + continue; + } + LOGGER.trace("Applying policy state modifications for {} ({}):\n{}", assignmentToFind, mode, + DebugUtil.debugDumpLazily(modifications)); + if (mode == PlusMinusZero.ZERO) { + if (assignmentToFind.getId() == null) { + throw new IllegalStateException("Existing assignment with null id: " + assignmentToFind); + } + for (ItemDelta modification : modifications) { + focusDelta = focusContext.swallowToDelta(focusDelta, modification); + } + } else { + assert mode == PlusMinusZero.PLUS; + if (focusDelta != null && focusDelta.isAdd()) { + swallowIntoValues(((FocusType) focusDelta.getObjectToAdd().asObjectable()).getAssignment(), + assignmentToFind, modifications); + } else { + ContainerDelta assignmentDelta = focusDelta != null ? + focusDelta.findContainerDelta(FocusType.F_ASSIGNMENT) : null; + if (assignmentDelta == null) { + throw new IllegalStateException( + "We have 'plus' assignment to modify but there's no assignment delta. Assignment=" + + assignmentToFind + ", objectDelta=" + focusDelta); + } + if (assignmentDelta.isReplace()) { + swallowIntoValues(asContainerables(assignmentDelta.getValuesToReplace()), assignmentToFind, + modifications); + } else if (assignmentDelta.isAdd()) { + swallowIntoValues(asContainerables(assignmentDelta.getValuesToAdd()), assignmentToFind, + modifications); + } else { + throw new IllegalStateException( + "We have 'plus' assignment to modify but there're no values to add or replace in assignment delta. Assignment=" + + assignmentToFind + ", objectDelta=" + focusDelta); + } + } + } + } + focusContext.clearPendingAssignmentPolicyStateModifications(); + return focusDelta; + } + + private void swallowIntoValues(Collection assignments, AssignmentType assignmentToFind, List> modifications) + throws SchemaException { + for (AssignmentType assignment : assignments) { + PrismContainerValue pcv = assignment.asPrismContainerValue(); + PrismContainerValue pcvToFind = assignmentToFind.asPrismContainerValue(); + if (pcv.representsSameValue(pcvToFind, false) || pcv.equals(pcvToFind, EquivalenceStrategy.REAL_VALUE_CONSIDER_DIFFERENT_IDS)) { + // TODO what if ID of the assignment being added is changed in repo? Hopefully it will be not. + for (ItemDelta modification : modifications) { + ItemPath newParentPath = modification.getParentPath().rest(2); // killing assignment + ID + ItemDelta pathRelativeModification = modification.cloneWithChangedParentPath(newParentPath); + pathRelativeModification.applyTo(pcv); + } + return; + } + } + // TODO change to warning + throw new IllegalStateException("We have 'plus' assignment to modify but it couldn't be found in assignment delta. Assignment=" + assignmentToFind + ", new assignments=" + assignments); + } + + private void applyLastProvisioningTimestamp(LensContext context, ObjectDelta focusDelta) throws SchemaException { + if (!context.hasProjectionChange()) { + return; + } + if (focusDelta.isAdd()) { + + PrismObject objectToAdd = focusDelta.getObjectToAdd(); + PrismContainer metadataContainer = objectToAdd.findOrCreateContainer(ObjectType.F_METADATA); + metadataContainer.getRealValue().setLastProvisioningTimestamp(clock.currentTimeXMLGregorianCalendar()); + + } else if (focusDelta.isModify()) { + + PropertyDelta provTimestampDelta = prismContext.deltaFactory().property().createModificationReplaceProperty( + ItemPath.create(ObjectType.F_METADATA, MetadataType.F_LAST_PROVISIONING_TIMESTAMP), + context.getFocusContext().getObjectDefinition(), + clock.currentTimeXMLGregorianCalendar()); + focusDelta.addModification(provTimestampDelta); + + } + } + + private boolean shouldBeDeleted(ObjectDelta accDelta, LensProjectionContext accCtx) { + return (accDelta == null || accDelta.isEmpty()) + && (accCtx.getSynchronizationPolicyDecision() == SynchronizationPolicyDecision.DELETE + || accCtx.getSynchronizationIntent() == SynchronizationIntent.DELETE); + } + + private boolean isRepeatedAlreadyExistsException( + LensProjectionContext projContext) { + int deltas = projContext.getExecutedDeltas().size(); + LOGGER.trace("isRepeatedAlreadyExistsException starting; number of executed deltas = {}", deltas); + if (deltas < 2) { + return false; + } + LensObjectDeltaOperation lastDeltaOp = projContext.getExecutedDeltas().get(deltas - 1); + LensObjectDeltaOperation previousDeltaOp = projContext.getExecutedDeltas() + .get(deltas - 2); + // TODO check also previous execution result to see if it's + // AlreadyExistException? + ObjectDelta lastDelta = lastDeltaOp.getObjectDelta(); + ObjectDelta previousDelta = previousDeltaOp.getObjectDelta(); + boolean rv; + if (lastDelta.isAdd() && previousDelta.isAdd()) { + rv = isEquivalentAddDelta(lastDelta.getObjectToAdd(), previousDelta.getObjectToAdd()); + } else if (lastDelta.isModify() && previousDelta.isModify()) { + rv = isEquivalentModifyDelta(lastDelta.getModifications(), previousDelta.getModifications()); + } else { + rv = false; + } + LOGGER.trace( + "isRepeatedAlreadyExistsException returning {}; based of comparison of previousDelta:\n{}\nwith lastDelta:\n{}", + rv, previousDelta, lastDelta); + return rv; + } + + private boolean isEquivalentModifyDelta(Collection> modifications1, + Collection> modifications2) { + Collection> attrDeltas1 = ItemDeltaCollectionsUtil + .findItemDeltasSubPath(modifications1, ShadowType.F_ATTRIBUTES); + Collection> attrDeltas2 = ItemDeltaCollectionsUtil + .findItemDeltasSubPath(modifications2, ShadowType.F_ATTRIBUTES); + //noinspection unchecked,RedundantCast + return MiscUtil.unorderedCollectionEquals((Collection) attrDeltas1, (Collection) attrDeltas2); + } + + private boolean isEquivalentAddDelta(PrismObject object1, PrismObject object2) { + PrismContainer attributes1 = object1.findContainer(ShadowType.F_ATTRIBUTES); + PrismContainer attributes2 = object2.findContainer(ShadowType.F_ATTRIBUTES); + if (attributes1 == null || attributes2 == null || attributes1.size() != 1 + || attributes2.size() != 1) { // suspicious cases + return false; + } + return attributes1.getValue().equivalent(attributes2.getValue()); + } + + private void applyObjectPolicy(LensFocusContext focusContext, + ObjectDelta focusDelta, ArchetypePolicyType archetypePolicy) { + if (archetypePolicy == null) { + return; + } + PrismObject objectNew = focusContext.getObjectNew(); + if (focusDelta.isAdd() && objectNew.getOid() == null) { + + for (ItemConstraintType itemConstraintType : archetypePolicy.getItemConstraint()) { + processItemConstraint(focusContext, objectNew, itemConstraintType); + } + // Deprecated + for (ItemConstraintType itemConstraintType : archetypePolicy.getPropertyConstraint()) { + processItemConstraint(focusContext, objectNew, itemConstraintType); + } + + } + } + + private void processItemConstraint(LensFocusContext focusContext, PrismObject objectNew, ItemConstraintType itemConstraintType) { + if (BooleanUtils.isTrue(itemConstraintType.isOidBound())) { + ItemPath itemPath = itemConstraintType.getPath().getItemPath(); + PrismProperty prop = objectNew.findProperty(itemPath); + String stringValue = prop.getRealValue().toString(); + focusContext.setOid(stringValue); + } + } + + private

void recordProjectionExecutionException(Throwable e, + LensProjectionContext accCtx, OperationResult subResult, SynchronizationPolicyDecision decision) { + subResult.recordFatalError(e); + LOGGER.error("Error executing changes for {}: {}", accCtx.toHumanReadableString(), e.getMessage(), e); + if (decision != null) { + accCtx.setSynchronizationPolicyDecision(decision); + } + } + + private void recordFatalError(OperationResult subResult, OperationResult result, String message, + Throwable e) { + if (message == null) { + message = e.getMessage(); + } + subResult.recordFatalError(e); + if (result != null) { + result.computeStatusComposite(); + } + } + + /** + * Make sure that the account is linked (or unlinked) as needed. + */ + private void updateLinks(LensContext context, + LensFocusContext focusObjectContext, LensProjectionContext projCtx, + PrismObject shadowAfterModification, + Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { + if (focusObjectContext == null) { + return; + } + Class objectTypeClass = focusObjectContext.getObjectTypeClass(); + if (!FocusType.class.isAssignableFrom(objectTypeClass)) { + return; + } + //noinspection unchecked + LensFocusContext focusContext = (LensFocusContext) focusObjectContext; + + if (projCtx.getResourceShadowDiscriminator() != null + && projCtx.getResourceShadowDiscriminator().getOrder() > 0) { + // Don't mess with links for higher-order contexts. The link should + // be dealt with + // during processing of zero-order context. + return; + } + + String projOid = projCtx.getOid(); + if (projOid == null) { + if (projCtx.getSynchronizationPolicyDecision() == SynchronizationPolicyDecision.BROKEN) { + // This seems to be OK. In quite a strange way, but still OK. + return; + } + LOGGER.error("Projection {} has null OID, this should not happen, context:\n{}", projCtx.toHumanReadableString(), projCtx.debugDump()); + throw new IllegalStateException("Projection "+projCtx.toHumanReadableString()+" has null OID, this should not happen"); + } + + if (linkShouldExist(projCtx, shadowAfterModification, result)) { + // Link should exist + PrismObject objectCurrent = focusContext.getObjectCurrent(); + if (objectCurrent != null) { + for (ObjectReferenceType linkRef : objectCurrent.asObjectable().getLinkRef()) { + if (projOid.equals(linkRef.getOid())) { + // Already linked, nothing to do, only be sure, the situation is set with the good value + LOGGER.trace("Updating situation in already linked shadow."); + updateSituationInShadow(task, SynchronizationSituationType.LINKED, context, focusObjectContext, projCtx, result); + return; + } + } + } + // Not linked, need to link + linkShadow(focusContext.getOid(), projOid, focusObjectContext, projCtx, task, result); + // be sure, that the situation is set correctly + LOGGER.trace("Updating situation after shadow was linked."); + updateSituationInShadow(task, SynchronizationSituationType.LINKED, context, focusObjectContext, projCtx, result); + } else { + // Link should NOT exist + if (!focusContext.isDelete()) { + PrismObject objectCurrent = focusContext.getObjectCurrent(); + // it is possible that objectCurrent is null (and objectNew is + // non-null), in case of User ADD operation (MID-2176) + if (objectCurrent != null) { + PrismReference linkRef = objectCurrent.findReference(FocusType.F_LINK_REF); + if (linkRef != null) { + for (PrismReferenceValue linkRefVal : linkRef.getValues()) { + if (linkRefVal.getOid().equals(projOid)) { + // Linked, need to unlink + unlinkShadow(focusContext.getOid(), linkRefVal, focusObjectContext, projCtx, task, result); + } + } + } + } + } + + // This should NOT be UNLINKED. We just do not know the situation here. Reflect that in the shadow. + LOGGER.trace("Resource object {} unlinked from the user, updating also situation in shadow.", projOid); + updateSituationInShadow(task, null, context, focusObjectContext, projCtx, result); + // Not linked, that's OK + } + } + + private boolean linkShouldExist(LensProjectionContext projCtx, PrismObject shadowAfterModification, OperationResult result) { + if (!projCtx.isShadowExistsInRepo()) { + // Nothing to link to + return false; + } + if (projCtx.getSynchronizationPolicyDecision() == SynchronizationPolicyDecision.UNLINK) { + return false; + } + if (isEmptyThombstone(projCtx)) { + return false; + } + if (projCtx.getSynchronizationPolicyDecision() == SynchronizationPolicyDecision.DELETE + || projCtx.isDelete()) { + return shadowAfterModification != null; + } + if (projCtx.hasPendingOperations()) { + return true; + } + return true; + } + + /** + * Return true if this projection is just a linkRef that points to no + * shadow. + */ + private boolean isEmptyThombstone(LensProjectionContext projCtx) { + return projCtx.getResourceShadowDiscriminator() != null + && projCtx.getResourceShadowDiscriminator().isTombstone() + && projCtx.getObjectCurrent() == null; + } + + private void linkShadow(String userOid, String shadowOid, + LensElementContext focusContext, LensProjectionContext projCtx, Task task, + OperationResult parentResult) throws ObjectNotFoundException, SchemaException { + + Class typeClass = focusContext.getObjectTypeClass(); + if (!FocusType.class.isAssignableFrom(typeClass)) { + return; + } + + String channel = focusContext.getLensContext().getChannel(); + + LOGGER.debug("Linking shadow " + shadowOid + " to focus " + userOid); + OperationResult result = parentResult.createSubresult(OPERATION_LINK_ACCOUNT); + PrismReferenceValue linkRef = prismContext.itemFactory().createReferenceValue(); + linkRef.setOid(shadowOid); + linkRef.setTargetType(ShadowType.COMPLEX_TYPE); + Collection linkRefDeltas = prismContext.deltaFactory().reference() + .createModificationAddCollection(FocusType.F_LINK_REF, getUserDefinition(), linkRef); + + try { + cacheRepositoryService.modifyObject(typeClass, userOid, linkRefDeltas, result); + task.recordObjectActionExecuted(focusContext.getObjectAny(), typeClass, userOid, + ChangeType.MODIFY, channel, null); + } catch (ObjectAlreadyExistsException ex) { + task.recordObjectActionExecuted(focusContext.getObjectAny(), typeClass, userOid, + ChangeType.MODIFY, channel, ex); + throw new SystemException(ex); + } catch (Throwable t) { + task.recordObjectActionExecuted(focusContext.getObjectAny(), typeClass, userOid, + ChangeType.MODIFY, channel, t); + throw t; + } finally { + result.computeStatus(); + ObjectDelta userDelta = prismContext.deltaFactory().object().createModifyDelta(userOid, linkRefDeltas, typeClass + ); + LensObjectDeltaOperation userDeltaOp = LensUtil.createObjectDeltaOperation(userDelta, result, + focusContext, projCtx); + focusContext.addToExecutedDeltas(userDeltaOp); + } + + } + + private PrismObjectDefinition getUserDefinition() { + return userDefinition; + } + + private void unlinkShadow(String focusOid, PrismReferenceValue accountRef, + LensElementContext focusContext, LensProjectionContext projCtx, Task task, + OperationResult parentResult) throws ObjectNotFoundException, SchemaException { + + Class typeClass = focusContext.getObjectTypeClass(); + if (!FocusType.class.isAssignableFrom(typeClass)) { + return; + } + + String channel = focusContext.getLensContext().getChannel(); + + LOGGER.debug("Unlinking shadow " + accountRef.getOid() + " from focus " + focusOid); + OperationResult result = parentResult.createSubresult(OPERATION_UNLINK_ACCOUNT); + Collection accountRefDeltas = prismContext.deltaFactory().reference().createModificationDeleteCollection( + FocusType.F_LINK_REF, getUserDefinition(), accountRef.clone()); + + try { + cacheRepositoryService.modifyObject(typeClass, focusOid, accountRefDeltas, result); + task.recordObjectActionExecuted(focusContext.getObjectAny(), typeClass, focusOid, + ChangeType.MODIFY, channel, null); + } catch (ObjectAlreadyExistsException ex) { + task.recordObjectActionExecuted(focusContext.getObjectAny(), typeClass, focusOid, + ChangeType.MODIFY, channel, ex); + result.recordFatalError(ex); + throw new SystemException(ex); + } catch (Throwable t) { + task.recordObjectActionExecuted(focusContext.getObjectAny(), typeClass, focusOid, + ChangeType.MODIFY, channel, t); + throw t; + } finally { + result.computeStatus(); + ObjectDelta userDelta = prismContext.deltaFactory().object() + .createModifyDelta(focusOid, accountRefDeltas, typeClass + ); + LensObjectDeltaOperation userDeltaOp = LensUtil.createObjectDeltaOperation(userDelta, result, + focusContext, projCtx); + focusContext.addToExecutedDeltas(userDeltaOp); + } + + } + + private void updateSituationInShadow(Task task, SynchronizationSituationType newSituation, + LensContext context, LensFocusContext focusContext, LensProjectionContext projectionCtx, + OperationResult parentResult) + throws SchemaException { + + String projectionOid = projectionCtx.getOid(); + + OperationResult result = parentResult.createMinorSubresult(OPERATION_UPDATE_SITUATION_IN_SHADOW); + result.addArbitraryObjectAsParam("situation", newSituation); + result.addParam("accountRef", projectionOid); + + PrismObject currentShadow; + GetOperationOptions getOptions = GetOperationOptions.createNoFetch(); + getOptions.setAllowNotFound(true); + try { + // TODO consider skipping this operation - at least in some cases + currentShadow = provisioning.getObject(ShadowType.class, projectionOid, + SelectorOptions.createCollection(getOptions), task, result); + } catch (ObjectNotFoundException ex) { + LOGGER.trace("Shadow is gone, skipping modifying situation in shadow."); + result.recordSuccess(); + return; + } catch (Exception ex) { + LOGGER.trace("Problem with getting shadow, skipping modifying situation in shadow."); + result.recordPartialError(ex); + return; + } + + SynchronizationSituationType currentSynchronizationSituation = currentShadow.asObjectable().getSynchronizationSituation(); + if (currentSynchronizationSituation == SynchronizationSituationType.DELETED && ShadowUtil.isDead(currentShadow.asObjectable())) { + LOGGER.trace("Skipping update of synchronization situation for deleted dead shadow"); + result.recordSuccess(); + return; + } + + InternalsConfigurationType internalsConfig = context.getInternalsConfiguration(); + boolean cansSkip = + internalsConfig != null && internalsConfig.getSynchronizationSituationUpdating() != null && + Boolean.TRUE.equals(internalsConfig.getSynchronizationSituationUpdating().isSkipWhenNoChange()); + if (cansSkip) { + if (newSituation == currentSynchronizationSituation) { + LOGGER.trace("Skipping update of synchronization situation because there is no change ({})", + currentSynchronizationSituation); + result.recordSuccess(); + return; + } else { + LOGGER.trace("Updating synchronization situation {} -> {}", currentSynchronizationSituation, newSituation); + } + } + + XMLGregorianCalendar now = clock.currentTimeXMLGregorianCalendar(); + List> syncSituationDeltas = SynchronizationUtils + .createSynchronizationSituationAndDescriptionDelta(currentShadow, newSituation, task.getChannel(), + projectionCtx.hasFullShadow(), now, prismContext); + + try { + ModelImplUtils.setRequestee(task, focusContext); + ProvisioningOperationOptions options = ProvisioningOperationOptions.createCompletePostponed(false); + options.setDoNotDiscovery(true); + provisioning.modifyObject(ShadowType.class, projectionOid, syncSituationDeltas, null, options, task, result); + projectionCtx.setSynchronizationSituationResolved(newSituation); + LOGGER.trace("Situation in projection {} was updated to {}.", projectionCtx, newSituation); + } catch (ObjectNotFoundException ex) { + // if the object not found exception is thrown, it's ok..probably + // the account was deleted by previous execution of changes..just + // log in the trace the message for the user.. + LOGGER.debug( + "Situation in account could not be updated. Account not found on the resource. Skipping modifying situation in account"); + return; + } catch (Exception ex) { + result.recordFatalError(ex); + throw new SystemException(ex.getMessage(), ex); + } finally { + ModelImplUtils.clearRequestee(task); + } + // if everything is OK, add result of the situation modification to the + // parent result + result.recordSuccess(); + + } + + /** + * @return Returns estimate of the object after modification. Or null if the object was deleted. + * NOTE: this is only partially implemented (only for shadow delete). + */ + private PrismObject executeDelta(ObjectDelta objectDelta, + LensElementContext objectContext, LensContext context, ModelExecuteOptions options, + ConflictResolutionType conflictResolution, ResourceType resource, Task task, OperationResult parentResult) + throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, + CommunicationException, ConfigurationException, SecurityViolationException, + PolicyViolationException, ExpressionEvaluationException, PreconditionViolationException { + + if (objectDelta == null) { + throw new IllegalArgumentException("Null change"); + } + + if (objectDelta.getOid() == null) { + objectDelta.setOid(objectContext.getOid()); + } + + objectDelta = computeDeltaToExecute(objectDelta, objectContext); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("computeDeltaToExecute returned:\n{}", + objectDelta != null ? objectDelta.debugDump(1) : "(null)"); + } + + if (objectDelta == null || objectDelta.isEmpty()) { + LOGGER.debug("Skipping execution of delta because it was already executed: {}", objectContext); + return objectContext.getObjectCurrent(); + } + + if (InternalsConfig.consistencyChecks) { + objectDelta.checkConsistence(ConsistencyCheckScope.fromBoolean(consistencyChecks)); + } + + // Other types than focus types may not be definition-complete (e.g. + // accounts and resources are completed in provisioning) + if (FocusType.class.isAssignableFrom(objectDelta.getObjectTypeClass())) { + objectDelta.assertDefinitions(); + } + + LensUtil.setDeltaOldValue(objectContext, objectDelta); + + if (LOGGER.isTraceEnabled()) { + logDeltaExecution(objectDelta, context, resource, null, task); + } + + OperationResult result = parentResult.createSubresult(OPERATION_EXECUTE_DELTA); + PrismObject objectAfterModification = null; + + try { + if (objectDelta.getChangeType() == ChangeType.ADD) { + objectAfterModification = executeAddition(objectDelta, context, objectContext, options, resource, task, result); + } else if (objectDelta.getChangeType() == ChangeType.MODIFY) { + executeModification(objectDelta, context, objectContext, options, conflictResolution, resource, task, result); + } else if (objectDelta.getChangeType() == ChangeType.DELETE) { + objectAfterModification = executeDeletion(objectDelta, context, objectContext, options, resource, task, result); + } + + // To make sure that the OID is set (e.g. after ADD operation) + LensUtil.setContextOid(context, objectContext, objectDelta.getOid()); + + } finally { + + result.computeStatus(); + if (objectContext != null) { + if (!objectDelta.hasCompleteDefinition()) { + throw new SchemaException("object delta does not have complete definition"); + } + LensObjectDeltaOperation objectDeltaOp = LensUtil.createObjectDeltaOperation( + objectDelta.clone(), result, objectContext, null, resource); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Recording executed delta:\n{}", objectDeltaOp.shorterDebugDump(1)); + } + objectContext.addToExecutedDeltas(objectDeltaOp); + if (result.isTracingNormal(ModelExecuteDeltaTraceType.class)) { + TraceType trace = new ModelExecuteDeltaTraceType(prismContext) + .delta(objectDeltaOp.clone().toLensObjectDeltaOperationType()); // todo kill operation result? + result.addTrace(trace); + } + } else { + if (result.isTracingNormal(ModelExecuteDeltaTraceType.class)) { + LensObjectDeltaOperation objectDeltaOp = new LensObjectDeltaOperation<>(objectDelta); // todo + TraceType trace = new ModelExecuteDeltaTraceType(prismContext) + .delta(objectDeltaOp.toLensObjectDeltaOperationType()); + result.addTrace(trace); + } + } + + if (LOGGER.isDebugEnabled()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("EXECUTION result {}", result.getLastSubresult()); + } else { + // Execution of deltas was not logged yet + logDeltaExecution(objectDelta, context, resource, result.getLastSubresult(), task); + } + } + } + + return objectAfterModification; + } + + private void removeExecutedItemDeltas( + ObjectDelta objectDelta, LensElementContext objectContext) { + if (objectContext == null) { + return; + } + + if (objectDelta == null || objectDelta.isEmpty()) { + return; + } + + if (objectDelta.getModifications() == null || objectDelta.getModifications().isEmpty()) { + return; + } + + List> executedDeltas = objectContext.getExecutedDeltas(); + for (LensObjectDeltaOperation executedDelta : executedDeltas) { + ObjectDelta executed = executedDelta.getObjectDelta(); + Iterator objectDeltaIterator = objectDelta.getModifications().iterator(); + while (objectDeltaIterator.hasNext()) { + ItemDelta d = objectDeltaIterator.next(); + if (executed.containsModification(d, EquivalenceStrategy.LITERAL_IGNORE_METADATA) || d.isEmpty()) { // todo why literal? + objectDeltaIterator.remove(); + } + } + } + } + +// // TODO beware - what if the delta was executed but not successfully? +// private boolean alreadyExecuted(ObjectDelta objectDelta, +// LensElementContext objectContext) { +// if (objectContext == null) { +// return false; +// } +// if (LOGGER.isTraceEnabled()) { +// LOGGER.trace("Checking for already executed delta:\n{}\nIn deltas:\n{}", objectDelta.debugDump(), +// DebugUtil.debugDump(objectContext.getExecutedDeltas())); +// } +// return ObjectDeltaOperation.containsDelta(objectContext.getExecutedDeltas(), objectDelta); +// } + + /** + * Was this object already added? (temporary method, should be removed soon) + */ + private boolean wasAdded(List> executedOperations, + String oid) { + for (LensObjectDeltaOperation operation : executedOperations) { + if (operation.getObjectDelta().isAdd() && oid.equals(operation.getObjectDelta().getOid()) + && !operation.getExecutionResult().isFatalError()) { + return true; + } + } + return false; + } + + /** + * Computes delta to execute, given a list of already executes deltas. See + * below. + */ + private ObjectDelta computeDeltaToExecute(ObjectDelta objectDelta, + LensElementContext objectContext) throws SchemaException { + if (objectContext == null) { + return objectDelta; + } + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Computing delta to execute from delta:\n{}\nGiven these executed deltas:\n{}", + objectDelta.debugDump(1), LensObjectDeltaOperation.shorterDebugDump(objectContext.getExecutedDeltas(),1)); + } + List> executedDeltas = objectContext.getExecutedDeltas(); + ObjectDelta diffDelta = computeDiffDelta(executedDeltas, objectDelta); + + // One more check: is the computed delta idempotent related to objectCurrent? + // Currently we deal only with focusContext because of safety; and also because this check is a reaction + // in change to focus context secondary delta swallowing code (MID-5207). + // + // LookupTableType operation optimization is not available here, because it looks like that isRedundant + // does not work reliably for key-based row deletions (MID-5276). + if (diffDelta != null && objectContext instanceof LensFocusContext && + !objectContext.isOfType(LookupTableType.class) && + diffDelta.isRedundant(objectContext.getObjectCurrent(), false)) { + LOGGER.trace("delta is idempotent related to {}", objectContext.getObjectCurrent()); + return null; + } + return diffDelta; + } + + /** + * Compute a "difference delta" - given that executedDeltas were executed, + * and objectDelta is about to be executed; eliminates parts that have + * already been done. It is meant as a kind of optimization (for MODIFY + * deltas) and error avoidance (for ADD deltas). + * + * Explanation for ADD deltas: there are situations where an execution wave + * is restarted - when unexpected AlreadyExistsException is reported from + * provisioning. However, in such cases, duplicate ADD Focus deltas were + * generated. So we (TEMPORARILY!) decided to filter them out here. + * + * Unfortunately, this mechanism is not well-defined, and seems to work more + * "by accident" than "by design". It should be replaced with something more + * serious. Perhaps by re-reading current focus state when repeating a wave? + * Actually, it is a supplement for rewriting ADD->MODIFY deltas in + * LensElementContext.getFixedPrimaryDelta. That method converts primary + * deltas (and as far as I know, that is the only place where this problem + * should occur). Nevertheless, for historical and safety reasons I keep + * also the processing in this method. + * + * Anyway, currently it treats only three cases: + * 1) if the objectDelta is present in the list of executed deltas + * 2) if the objectDelta is ADD, and another ADD delta is there (then the difference is computed) + * 3) if objectDelta is MODIFY or DELETE and previous delta was MODIFY + * + */ + private ObjectDelta computeDiffDelta( + List> executedDeltas, ObjectDelta objectDelta) { + if (executedDeltas == null || executedDeltas.isEmpty()) { + return objectDelta; + } + + // any delta related to our OID, not ending with fatal error + ObjectDeltaOperation lastRelated = findLastRelatedDelta(executedDeltas, objectDelta); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("findLastRelatedDelta returned:\n{}", + lastRelated != null ? lastRelated.shorterDebugDump(1) : " (null)"); + } + if (lastRelated == null) { + return objectDelta; // nothing found, let us apply our delta + } + if (lastRelated.getExecutionResult().isSuccess() && lastRelated.containsDelta(objectDelta)) { + return null; // case 1 - exact match found with SUCCESS result, + // let's skip the processing of our delta + } + if (!objectDelta.isAdd()) { + if (lastRelated.getObjectDelta().isDelete()) { + return null; // case 3 + } else { + return objectDelta; // MODIFY or DELETE delta after ADD or MODIFY delta - we may safely apply it + } + } + // determine if we got case 2 + if (lastRelated.getObjectDelta().isDelete()) { + return objectDelta; // we can (and should) apply the ADD delta as a + // whole, because the object was deleted + } + // let us treat the most simple case here - meaning we have existing ADD + // delta and nothing more + // TODO add more sophistication if needed + if (!lastRelated.getObjectDelta().isAdd()) { + return objectDelta; // this will probably fail, but ... + } + // at this point we know that ADD was more-or-less successfully + // executed, so let's compute the difference, creating a MODIFY delta + PrismObject alreadyAdded = lastRelated.getObjectDelta().getObjectToAdd(); + PrismObject toBeAddedNow = objectDelta.getObjectToAdd(); + return alreadyAdded.diff(toBeAddedNow); + } + + private ObjectDeltaOperation findLastRelatedDelta( + List> executedDeltas, ObjectDelta objectDelta) { + for (int i = executedDeltas.size() - 1; i >= 0; i--) { + ObjectDeltaOperation currentOdo = executedDeltas.get(i); + if (currentOdo.getExecutionResult().isFatalError()) { + continue; + } + ObjectDelta current = currentOdo.getObjectDelta(); + + if (current.equals(objectDelta)) { + return currentOdo; + } + + String oid1 = current.isAdd() ? current.getObjectToAdd().getOid() : current.getOid(); + String oid2 = objectDelta.isAdd() ? objectDelta.getObjectToAdd().getOid() + : objectDelta.getOid(); + if (oid1 != null && oid2 != null) { + if (oid1.equals(oid2)) { + return currentOdo; + } + continue; + } + // ADD-MODIFY and ADD-DELETE combinations lead to applying whole + // delta (as a result of computeDiffDelta) + // so we can be lazy and check only ADD-ADD combinations here... + if (!current.isAdd() || !objectDelta.isAdd()) { + continue; + } + // we simply check the type (for focus objects) and + // resource+kind+intent (for shadows) + PrismObject currentObject = current.getObjectToAdd(); + PrismObject objectTypeToAdd = objectDelta.getObjectToAdd(); + Class currentObjectClass = currentObject.getCompileTimeClass(); + Class objectTypeToAddClass = objectTypeToAdd.getCompileTimeClass(); + if (currentObjectClass == null || !currentObjectClass.equals(objectTypeToAddClass)) { + continue; + } + if (FocusType.class.isAssignableFrom(currentObjectClass)) { + return currentOdo; // we suppose there is only one delta of + // Focus class + } + } + return null; + } + + private ProvisioningOperationOptions copyFromModelOptions(ModelExecuteOptions options) { + ProvisioningOperationOptions provisioningOptions = new ProvisioningOperationOptions(); + if (options == null) { + return provisioningOptions; + } + + provisioningOptions.setForce(options.getForce()); + provisioningOptions.setOverwrite(options.getOverwrite()); + return provisioningOptions; + } + + private ProvisioningOperationOptions getProvisioningOptions(LensContext context, + ModelExecuteOptions modelOptions, PrismObject existingShadow, ObjectDelta delta) throws SecurityViolationException { + if (modelOptions == null && context != null) { + modelOptions = context.getOptions(); + } + ProvisioningOperationOptions provisioningOptions = copyFromModelOptions(modelOptions); + + if (executeAsSelf(context, modelOptions, existingShadow, delta)) { + LOGGER.trace("Setting 'execute as self' provisioning option for {}", existingShadow); + provisioningOptions.setRunAsAccountOid(existingShadow.getOid()); + } + + if (context != null && context.getChannel() != null) { + + if (context.getChannel().equals(QNameUtil.qNameToUri(SchemaConstants.CHANGE_CHANNEL_RECON))) { + // TODO: this is probably wrong. We should not have special case + // for recon channel! This should be handled by the provisioning task + // setting the right options there. + provisioningOptions.setCompletePostponed(false); + } + + if (context.getChannel().equals(SchemaConstants.CHANGE_CHANNEL_DISCOVERY_URI)) { + // We want to avoid endless loops in error handling. + provisioningOptions.setDoNotDiscovery(true); + } + } + + return provisioningOptions; + } + + // This is a bit of black magic. We only want to execute as self if there a user is changing its own password + // and we also have old password value. + // Later, this should be improved. Maybe we need special model operation option for this? Or maybe it should be somehow + // automatically detected based on resource capabilities? We do not know yet. Therefore let's do the simplest possible + // thing. Otherwise we might do something that we will later regret. + private boolean executeAsSelf(LensContext context, + ModelExecuteOptions modelOptions, PrismObject existingShadow, ObjectDelta delta) throws SecurityViolationException { + if (existingShadow == null) { + return false; + } + + if (!SchemaConstants.CHANNEL_GUI_SELF_SERVICE_URI.equals(context.getChannel())) { + return false; + } + + if (delta == null) { + return false; + } + if (!delta.isModify()) { + return false; + } + PropertyDelta passwordDelta = delta.findPropertyDelta(SchemaConstants.PATH_PASSWORD_VALUE); + if (passwordDelta == null) { + return false; + } + if (passwordDelta.getEstimatedOldValues() == null || passwordDelta.getEstimatedOldValues().isEmpty()) { + return false; + } + ProtectedStringType oldPassword = passwordDelta.getEstimatedOldValues().iterator().next().getValue(); + if (!oldPassword.canGetCleartext()) { + return false; + } + + LensFocusContext focusContext = context.getFocusContext(); + if (focusContext == null) { + return false; + } + if (!focusContext.represents(UserType.class)) { + return false; + } + + MidPointPrincipal principal = securityContextManager.getPrincipal(); + if (principal == null) { + return false; + } + FocusType loggedInUser = principal.getFocus(); + + if (!loggedInUser.getOid().equals(focusContext.getOid())) { + return false; + } + return true; + } + + private void logDeltaExecution(ObjectDelta objectDelta, + LensContext context, ResourceType resource, OperationResult result, Task task) { + StringBuilder sb = new StringBuilder(); + sb.append("---[ "); + if (result == null) { + sb.append("Going to EXECUTE"); + } else { + sb.append("EXECUTED"); + } + sb.append(" delta of ").append(objectDelta.getObjectTypeClass().getSimpleName()); + sb.append(" ]---------------------\n"); + DebugUtil.debugDumpLabel(sb, "Channel", 0); + sb.append(" ").append(LensUtil.getChannel(context, task)).append("\n"); + if (context != null) { + DebugUtil.debugDumpLabel(sb, "Wave", 0); + sb.append(" ").append(context.getExecutionWave()).append("\n"); + } + if (resource != null) { + sb.append("Resource: ").append(resource.toString()).append("\n"); + } + sb.append(objectDelta.debugDump()); + sb.append("\n"); + if (result != null) { + DebugUtil.debugDumpLabel(sb, "Result", 0); + sb.append(" ").append(result.getStatus()).append(": ").append(result.getMessage()); + } + sb.append("\n--------------------------------------------------"); + + LOGGER.debug("\n{}", sb); + } + + private OwnerResolver createOwnerResolver(final LensContext context, Task task, + OperationResult result) { + return new LensOwnerResolver<>(context, objectResolver, task, result); + } + + private PrismObject executeAddition(ObjectDelta change, + LensContext context, LensElementContext objectContext, ModelExecuteOptions options, + ResourceType resource, Task task, OperationResult result) throws ObjectAlreadyExistsException, + ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, + SecurityViolationException, PolicyViolationException, ExpressionEvaluationException, PreconditionViolationException { + + PrismObject objectToAdd = change.getObjectToAdd(); + + for (ItemDelta delta : change.getModifications()) { + delta.applyTo(objectToAdd); + } + change.getModifications().clear(); + + OwnerResolver ownerResolver = createOwnerResolver(context, task, result); + T objectTypeToAdd = objectToAdd.asObjectable(); + try { + securityEnforcer.authorize(ModelAuthorizationAction.ADD.getUrl(), + AuthorizationPhaseType.EXECUTION, AuthorizationParameters.Builder.buildObjectAdd(objectToAdd), ownerResolver, task, result); + + + metadataManager.applyMetadataAdd(context, objectToAdd, clock.currentTimeXMLGregorianCalendar(), task, result); + + if (options == null) { + options = context.getOptions(); + } + + RepoAddOptions addOpt = new RepoAddOptions(); + if (ModelExecuteOptions.isOverwrite(options)) { + addOpt.setOverwrite(true); + } + if (ModelExecuteOptions.isNoCrypt(options)) { + addOpt.setAllowUnencryptedValues(true); + } + + String oid; + if (objectTypeToAdd instanceof TaskType) { + oid = addTask((TaskType) objectTypeToAdd, addOpt, result); + } else if (objectTypeToAdd instanceof NodeType) { + throw new UnsupportedOperationException("NodeType cannot be added using model interface"); + } else if (ObjectTypes.isManagedByProvisioning(objectTypeToAdd)) { + + ProvisioningOperationOptions provisioningOptions = getProvisioningOptions(context, options, + (PrismObject)objectContext.getObjectCurrent(), (ObjectDelta)change); + + oid = addProvisioningObject(objectToAdd, context, objectContext, provisioningOptions, + resource, task, result); + if (oid == null) { + throw new SystemException( + "Provisioning addObject returned null OID while adding " + objectToAdd); + } + result.addReturn("createdAccountOid", oid); + } else { + FocusConstraintsChecker.clearCacheFor(objectToAdd.asObjectable().getName()); + + oid = cacheRepositoryService.addObject(objectToAdd, addOpt, result); + if (oid == null) { + throw new SystemException("Repository addObject returned null OID while adding " + objectToAdd); + } + } + if (!change.isImmutable()) { + change.setOid(oid); + } + objectToAdd.setOid(oid); + task.recordObjectActionExecuted(objectToAdd, objectToAdd.getCompileTimeClass(), oid, + ChangeType.ADD, context.getChannel(), null); + return objectToAdd; + } catch (Throwable t) { + task.recordObjectActionExecuted(objectToAdd, objectToAdd.getCompileTimeClass(), null, + ChangeType.ADD, context.getChannel(), t); + if (objectTypeToAdd instanceof ShadowType) { + handleProvisioningError(resource, t, task, result); + ((LensProjectionContext) objectContext).setSynchronizationPolicyDecision(SynchronizationPolicyDecision.BROKEN); + return null; + } + throw t; + + + } + } + + private void handleProvisioningError(ResourceType resource, Throwable t, Task task, OperationResult result) throws ObjectNotFoundException, ConfigurationException, SecurityViolationException, PolicyViolationException, ExpressionEvaluationException, ObjectAlreadyExistsException, PreconditionViolationException, CommunicationException, SchemaException { + ErrorSelectorType errorSelectorType = ResourceTypeUtil.getConnectorErrorCriticality(resource); + CriticalityType criticality = ExceptionUtil.getCriticality(errorSelectorType, t, CriticalityType.FATAL); + RepoCommonUtils.processErrorCriticality(task, criticality, t, result); + if (CriticalityType.IGNORE == criticality) { + result.muteLastSubresultError(); + } + } + + private PrismObject executeDeletion(ObjectDelta change, + LensContext context, LensElementContext objectContext, ModelExecuteOptions options, + ResourceType resource, Task task, OperationResult result) throws ObjectNotFoundException, + ObjectAlreadyExistsException, SchemaException, CommunicationException, + ConfigurationException, SecurityViolationException, PolicyViolationException, ExpressionEvaluationException, PreconditionViolationException { + + String oid = change.getOid(); + Class objectTypeClass = change.getObjectTypeClass(); + + PrismObject objectOld = objectContext.getObjectOld(); + OwnerResolver ownerResolver = createOwnerResolver(context, task, result); + PrismObject objectAfterModification = null; + try { + securityEnforcer.authorize(ModelAuthorizationAction.DELETE.getUrl(), + AuthorizationPhaseType.EXECUTION, AuthorizationParameters.Builder.buildObjectDelete(objectOld), ownerResolver, task, result); + + if (TaskType.class.isAssignableFrom(objectTypeClass)) { + taskManager.deleteTask(oid, result); + } else if (NodeType.class.isAssignableFrom(objectTypeClass)) { + taskManager.deleteNode(oid, result); + } else if (ObjectTypes.isClassManagedByProvisioning(objectTypeClass)) { + ProvisioningOperationOptions provisioningOptions = getProvisioningOptions(context, options, + (PrismObject)objectContext.getObjectCurrent(), (ObjectDelta)change); + try { + objectAfterModification = deleteProvisioningObject(objectTypeClass, oid, context, objectContext, + provisioningOptions, resource, task, result); + } catch (ObjectNotFoundException e) { + // Object that we wanted to delete is already gone. This can + // happen in some race conditions. + // As the resulting state is the same as we wanted it to be + // we will not complain and we will go on. + LOGGER.trace("Attempt to delete object {} ({}) that is already gone", oid, + objectTypeClass); + result.muteLastSubresultError(); + } + } else { + try { + cacheRepositoryService.deleteObject(objectTypeClass, oid, result); + } catch (ObjectNotFoundException e) { + // Object that we wanted to delete is already gone. This can + // happen in some race conditions. + // As the resulting state is the same as we wanted it to be + // we will not complain and we will go on. + LOGGER.trace("Attempt to delete object {} ({}) that is already gone", oid, + objectTypeClass); + result.muteLastSubresultError(); + } + } + task.recordObjectActionExecuted(objectOld, objectTypeClass, oid, ChangeType.DELETE, + context.getChannel(), null); + } catch (Throwable t) { + task.recordObjectActionExecuted(objectOld, objectTypeClass, oid, ChangeType.DELETE, + context.getChannel(), t); + + if (ShadowType.class.isAssignableFrom(objectTypeClass)) { + handleProvisioningError(resource, t, task, result); + return objectContext.getObjectCurrent(); + } + + throw t; + } + + return objectAfterModification; + } + + private void executeModification(ObjectDelta delta, + LensContext context, LensElementContext objectContext, ModelExecuteOptions options, + ConflictResolutionType conflictResolution, ResourceType resource, Task task, OperationResult result) + throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException, CommunicationException, + ConfigurationException, SecurityViolationException, PolicyViolationException, ExpressionEvaluationException, PreconditionViolationException { + Class objectTypeClass = delta.getObjectTypeClass(); + + // We need current object here. The current object is used to get data for id-only container delete deltas, + // replace deltas and so on. The authorization code can figure out new object if needed, but it needs + // current object to start from. + // We cannot use old object here. That would fail in multi-wave executions. We want object that has all the previous + // wave changes already applied. + PrismObject baseObject = objectContext.getObjectCurrent(); + OwnerResolver ownerResolver = createOwnerResolver(context, task, result); + try { + securityEnforcer.authorize(ModelAuthorizationAction.MODIFY.getUrl(), + AuthorizationPhaseType.EXECUTION, AuthorizationParameters.Builder.buildObjectDelta(baseObject, delta), ownerResolver, task, result); + + if (shouldApplyModifyMetadata(objectTypeClass, context.getSystemConfigurationType())) { + metadataManager.applyMetadataModify(delta, objectContext, objectTypeClass, + clock.currentTimeXMLGregorianCalendar(), task, context, result); + } + + if (delta.isEmpty()) { + // Nothing to do + return; + } + + if (TaskType.class.isAssignableFrom(objectTypeClass)) { + taskManager.modifyTask(delta.getOid(), delta.getModifications(), result); + } else if (NodeType.class.isAssignableFrom(objectTypeClass)) { + throw new UnsupportedOperationException("NodeType is not modifiable using model interface"); + } else if (ObjectTypes.isClassManagedByProvisioning(objectTypeClass)) { + ProvisioningOperationOptions provisioningOptions = getProvisioningOptions(context, options, + (PrismObject)objectContext.getObjectCurrent(), (ObjectDelta)delta); + String oid = modifyProvisioningObject(objectTypeClass, delta.getOid(), + delta.getModifications(), context, objectContext, provisioningOptions, resource, + task, result); + if (!oid.equals(delta.getOid())) { + delta.setOid(oid); + } + } else { + FocusConstraintsChecker.clearCacheForDelta(delta.getModifications()); + ModificationPrecondition precondition = null; + if (conflictResolution != null) { + String readVersion = objectContext.getObjectReadVersion(); + if (readVersion != null) { + LOGGER.trace("Modification with precondition, readVersion={}", readVersion); + precondition = new VersionPrecondition<>(readVersion); + } else { + LOGGER.warn("Requested careful modification of {}, but there is no read version", objectContext.getHumanReadableName()); + } + } + cacheRepositoryService.modifyObject(objectTypeClass, delta.getOid(), + delta.getModifications(), precondition, null, result); + } + task.recordObjectActionExecuted(baseObject, objectTypeClass, delta.getOid(), ChangeType.MODIFY, + context.getChannel(), null); + } catch (Throwable t) { + task.recordObjectActionExecuted(baseObject, objectTypeClass, delta.getOid(), ChangeType.MODIFY, + context.getChannel(), t); + throw t; + } + } + + private boolean shouldApplyModifyMetadata(Class objectTypeClass, SystemConfigurationType config) { + if (!ShadowType.class.equals(objectTypeClass)) { + return true; + } else if (config == null || config.getInternals() == null || config.getInternals().getShadowMetadataRecording() == null) { + return true; + } else { + MetadataRecordingStrategyType recording = config.getInternals().getShadowMetadataRecording(); + return !Boolean.TRUE.equals(recording.isSkipOnModify()); + } + } + + private String addTask(TaskType task, RepoAddOptions addOpt, OperationResult result) + throws ObjectAlreadyExistsException { + try { + return taskManager.addTask(task.asPrismObject(), addOpt, result); + } catch (ObjectAlreadyExistsException ex) { + throw ex; + } catch (Exception ex) { + LoggingUtils.logException(LOGGER, "Couldn't add object {} to task manager", ex, task.getName()); + throw new SystemException(ex.getMessage(), ex); + } + } + + private String addProvisioningObject(PrismObject object, + LensContext context, LensElementContext objectContext, ProvisioningOperationOptions options, + ResourceType resource, Task task, OperationResult result) throws ObjectNotFoundException, + ObjectAlreadyExistsException, SchemaException, CommunicationException, + ConfigurationException, SecurityViolationException, ExpressionEvaluationException, PolicyViolationException { + + if (object.canRepresent(ShadowType.class)) { + ShadowType shadow = (ShadowType) object.asObjectable(); + String resourceOid = ShadowUtil.getResourceOid(shadow); + if (resourceOid == null) { + throw new IllegalArgumentException("Resource OID is null in shadow"); + } + } + + OperationProvisioningScriptsType scripts = null; + if (object.canRepresent(ShadowType.class)) { + scripts = prepareScripts(object, context, objectContext, ProvisioningOperationTypeType.ADD, + resource, task, result); + } + ModelImplUtils.setRequestee(task, context); + String oid = provisioning.addObject(object, scripts, options, task, result); + ModelImplUtils.clearRequestee(task); + return oid; + } + + private PrismObject deleteProvisioningObject( + Class objectTypeClass, String oid, LensContext context, LensElementContext objectContext, + ProvisioningOperationOptions options, ResourceType resource, Task task, OperationResult result) + throws ObjectNotFoundException, ObjectAlreadyExistsException, SchemaException, + CommunicationException, ConfigurationException, SecurityViolationException, + ExpressionEvaluationException, PolicyViolationException { + + PrismObject shadowToModify = null; + OperationProvisioningScriptsType scripts = null; + try { + GetOperationOptions rootOpts = GetOperationOptions.createNoFetch(); + rootOpts.setPointInTimeType(PointInTimeType.FUTURE); + shadowToModify = provisioning.getObject(objectTypeClass, oid, + SelectorOptions.createCollection(rootOpts), task, result); + } catch (ObjectNotFoundException ex) { + // this is almost OK, mute the error and try to delete account (it + // will fail if something is wrong) + result.muteLastSubresultError(); + } + if (ShadowType.class.isAssignableFrom(objectTypeClass)) { + scripts = prepareScripts(shadowToModify, context, objectContext, + ProvisioningOperationTypeType.DELETE, resource, task, result); + } + ModelImplUtils.setRequestee(task, context); + PrismObject objectAfterModification = provisioning.deleteObject(objectTypeClass, oid, options, scripts, task, result); + ModelImplUtils.clearRequestee(task); + return objectAfterModification; + } + + private String modifyProvisioningObject( + Class objectTypeClass, String oid, Collection modifications, + LensContext context, LensElementContext objectContext, ProvisioningOperationOptions options, + ResourceType resource, Task task, OperationResult result) throws ObjectNotFoundException, + CommunicationException, SchemaException, ConfigurationException, + SecurityViolationException, ExpressionEvaluationException, ObjectAlreadyExistsException, PolicyViolationException { + + PrismObject shadowToModify = null; + OperationProvisioningScriptsType scripts = null; + try { + GetOperationOptions rootOpts = GetOperationOptions.createNoFetch(); + rootOpts.setPointInTimeType(PointInTimeType.FUTURE); + shadowToModify = provisioning.getObject(objectTypeClass, oid, + SelectorOptions.createCollection(rootOpts), task, result); + } catch (ObjectNotFoundException e) { + // We do not want the operation to fail here. The object might have + // been re-created on the resource + // or discovery might re-create it. So simply ignore this error and + // give provisioning a chance to fail + // properly. + result.muteLastSubresultError(); + LOGGER.warn("Repository object {}: {} is gone. But trying to modify resource object anyway", + objectTypeClass, oid); + } + if (ShadowType.class.isAssignableFrom(objectTypeClass)) { + scripts = prepareScripts(shadowToModify, context, objectContext, + ProvisioningOperationTypeType.MODIFY, resource, task, result); + } + ModelImplUtils.setRequestee(task, context); + String changedOid = provisioning.modifyObject(objectTypeClass, oid, modifications, scripts, options, + task, result); + ModelImplUtils.clearRequestee(task); + return changedOid; + } + + private OperationProvisioningScriptsType prepareScripts( + PrismObject changedObject, LensContext context, LensElementContext objectContext, + ProvisioningOperationTypeType operation, ResourceType resource, Task task, OperationResult result) + throws ObjectNotFoundException, SchemaException, CommunicationException, + ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + + if (resource == null) { + LOGGER.warn("Resource does not exist. Skipping processing scripts."); + return null; + } + OperationProvisioningScriptsType resourceScripts = resource.getScripts(); + PrismObject resourceObject = (PrismObject) changedObject; + + PrismObject user = null; + if (context.getFocusContext() != null) { + if (context.getFocusContext().getObjectNew() != null) { + user = context.getFocusContext().getObjectNew(); + } else if (context.getFocusContext().getObjectCurrent() != null) { + user = context.getFocusContext().getObjectCurrent(); + } else if (context.getFocusContext().getObjectOld() != null) { + user = context.getFocusContext().getObjectOld(); + } + } + + LensProjectionContext projectionCtx = (LensProjectionContext) objectContext; + PrismObject shadow = null; + if (projectionCtx.getObjectNew() != null) { + shadow = projectionCtx.getObjectNew(); + } else if (projectionCtx.getObjectCurrent() != null) { + shadow = projectionCtx.getObjectCurrent(); + } else { + shadow = projectionCtx.getObjectOld(); + } + + if (shadow == null) { + //put at least something + shadow = resourceObject.clone(); + } + + ResourceShadowDiscriminator discr = ((LensProjectionContext) objectContext) + .getResourceShadowDiscriminator(); + + ExpressionVariables variables = ModelImplUtils.getDefaultExpressionVariables(user, shadow, discr, + resource.asPrismObject(), context.getSystemConfiguration(), objectContext, prismContext); + // Having delta in provisioning scripts may be very useful. E.g. the script can optimize execution of expensive operations. + variables.put(ExpressionConstants.VAR_DELTA, projectionCtx.getDelta(), ObjectDelta.class); + ExpressionProfile expressionProfile = MiscSchemaUtil.getExpressionProfile(); + ModelExpressionThreadLocalHolder.pushExpressionEnvironment(new ExpressionEnvironment<>(context, (LensProjectionContext) objectContext, task, result)); + try { + return evaluateScript(resourceScripts, discr, operation, null, variables, expressionProfile, context, objectContext, task, result); + } finally { + ModelExpressionThreadLocalHolder.popExpressionEnvironment(); + } + + } + + private OperationProvisioningScriptsType evaluateScript(OperationProvisioningScriptsType resourceScripts, + ResourceShadowDiscriminator discr, ProvisioningOperationTypeType operation, BeforeAfterType order, + ExpressionVariables variables, ExpressionProfile expressionProfile, LensContext context, + LensElementContext objectContext, Task task, + OperationResult result) + throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { + OperationProvisioningScriptsType outScripts = new OperationProvisioningScriptsType(); + + if (resourceScripts != null) { + OperationProvisioningScriptsType scripts = resourceScripts.clone(); + for (OperationProvisioningScriptType script : scripts.getScript()) { + if (discr != null) { + if (script.getKind() != null && !script.getKind().isEmpty() + && !script.getKind().contains(discr.getKind())) { + continue; + } + if (script.getIntent() != null && !script.getIntent().isEmpty() + && !script.getIntent().contains(discr.getIntent()) && discr.getIntent() != null) { + continue; + } + } + if (operation != null) { + if (!script.getOperation().contains(operation)) { + continue; + } + } + if (order != null) { + if (order != null && order != script.getOrder()) { + continue; + } + } + // Let's do the most expensive evaluation last + if (!evaluateScriptCondition(script, variables, expressionProfile, task, result)){ + continue; + } + for (ProvisioningScriptArgumentType argument : script.getArgument()) { + evaluateScriptArgument(argument, variables, context, objectContext, task, result); + } + outScripts.getScript().add(script); + } + } + + return outScripts; + } + + private boolean evaluateScriptCondition(OperationProvisioningScriptType script, + ExpressionVariables variables, ExpressionProfile expressionProfile, Task task, OperationResult result) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException { + ExpressionType condition = script.getCondition(); + if (condition == null) { + return true; + } + + PrismPropertyValue conditionOutput = ExpressionUtil.evaluateCondition(variables, condition, expressionProfile, expressionFactory, " condition for provisioning script ", task, result); + if (conditionOutput == null) { + return true; + } + + Boolean conditionOutputValue = conditionOutput.getValue(); + + return BooleanUtils.isNotFalse(conditionOutputValue); + + } + + private void evaluateScriptArgument(ProvisioningScriptArgumentType argument, + ExpressionVariables variables, LensContext context, + LensElementContext objectContext, Task task, + OperationResult result) + throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { + + final QName FAKE_SCRIPT_ARGUMENT_NAME = new QName(SchemaConstants.NS_C, "arg"); + + PrismPropertyDefinition scriptArgumentDefinition = prismContext.definitionFactory().createPropertyDefinition( + FAKE_SCRIPT_ARGUMENT_NAME, DOMUtil.XSD_STRING); + + String shortDesc = "Provisioning script argument expression"; + Expression, PrismPropertyDefinition> expression = expressionFactory + .makeExpression(argument, scriptArgumentDefinition, MiscSchemaUtil.getExpressionProfile(), shortDesc, task, result); + + ExpressionEvaluationContext params = new ExpressionEvaluationContext(null, variables, shortDesc, task); + ExpressionEnvironment env = new ExpressionEnvironment<>(context, + objectContext instanceof LensProjectionContext ? (LensProjectionContext) objectContext : null, task, result); + PrismValueDeltaSetTriple> outputTriple = ModelExpressionThreadLocalHolder + .evaluateExpressionInContext(expression, params, env, result); + + Collection> nonNegativeValues = null; + if (outputTriple != null) { + nonNegativeValues = outputTriple.getNonNegativeValues(); + } + + // replace dynamic script with static value.. + XNodeFactory factory = prismContext.xnodeFactory(); + + argument.getExpressionEvaluator().clear(); + if (nonNegativeValues == null || nonNegativeValues.isEmpty()) { + // We need to create at least one evaluator. Otherwise the + // expression code will complain + JAXBElement el = new JAXBElement<>(SchemaConstants.C_VALUE, RawType.class, new RawType(prismContext)); + argument.getExpressionEvaluator().add(el); + + } else { + for (PrismPropertyValue val : nonNegativeValues) { + PrimitiveXNode prim = factory.primitive(val.getValue(), DOMUtil.XSD_STRING); + JAXBElement el = new JAXBElement<>(SchemaConstants.C_VALUE, RawType.class, new RawType(prim, prismContext)); + argument.getExpressionEvaluator().add(el); + } + } + } + + private void executeReconciliationScript( + LensProjectionContext projContext, LensContext context, BeforeAfterType order, Task task, + OperationResult parentResult) throws SchemaException, ObjectNotFoundException, + ExpressionEvaluationException, CommunicationException, ConfigurationException, + SecurityViolationException, ObjectAlreadyExistsException { + + if (!projContext.isDoReconciliation()) { + return; + } + + ResourceType resource = projContext.getResource(); + if (resource == null) { + LOGGER.warn("Resource does not exist. Skipping processing reconciliation scripts."); + return; + } + + OperationProvisioningScriptsType resourceScripts = resource.getScripts(); + if (resourceScripts == null) { + return; + } + ExpressionProfile expressionProfile = MiscSchemaUtil.getExpressionProfile(); + executeProvisioningScripts(context, projContext, resourceScripts, ProvisioningOperationTypeType.RECONCILE, order, expressionProfile, task, parentResult); + } + + private Object executeProvisioningScripts(LensContext context, LensProjectionContext projContext, + OperationProvisioningScriptsType scripts, ProvisioningOperationTypeType operation, BeforeAfterType order, ExpressionProfile expressionProfile, Task task, OperationResult parentResult) + throws SchemaException, ObjectNotFoundException, + ExpressionEvaluationException, CommunicationException, ConfigurationException, + SecurityViolationException, ObjectAlreadyExistsException { + + ResourceType resource = projContext.getResource(); + if (resource == null) { + LOGGER.warn("Resource does not exist. Skipping processing reconciliation scripts."); + return null; + } + + PrismObject user = null; + PrismObject shadow = null; + + if (context.getFocusContext() != null) { + if (context.getFocusContext().getObjectNew() != null) { + user = context.getFocusContext().getObjectNew(); + } else if (context.getFocusContext().getObjectOld() != null) { + user = context.getFocusContext().getObjectOld(); + } + // if (order == ProvisioningScriptOrderType.BEFORE) { + // user = context.getFocusContext().getObjectOld(); + // } else if (order == ProvisioningScriptOrderType.AFTER) { + // user = context.getFocusContext().getObjectNew(); + // } else { + // throw new IllegalArgumentException("Unknown order "+order); + // } + } + + if (order == BeforeAfterType.BEFORE) { + shadow = (PrismObject) projContext.getObjectOld(); + } else if (order == BeforeAfterType.AFTER) { + shadow = (PrismObject) projContext.getObjectNew(); + } else { + shadow = (PrismObject) projContext.getObjectCurrent(); + } + + ExpressionVariables variables = ModelImplUtils.getDefaultExpressionVariables(user, shadow, + projContext.getResourceShadowDiscriminator(), resource.asPrismObject(), + context.getSystemConfiguration(), projContext, prismContext); + Object scriptResult = null; + ModelExpressionThreadLocalHolder.pushExpressionEnvironment(new ExpressionEnvironment<>(context, projContext, task, parentResult)); + try { + OperationProvisioningScriptsType evaluatedScript = evaluateScript(scripts, + projContext.getResourceShadowDiscriminator(), operation, order, + variables, expressionProfile, context, projContext, task, parentResult); + for (OperationProvisioningScriptType script : evaluatedScript.getScript()) { + ModelImplUtils.setRequestee(task, context); + scriptResult = provisioning.executeScript(resource.getOid(), script, task, parentResult); + ModelImplUtils.clearRequestee(task); + } + } finally { + ModelExpressionThreadLocalHolder.popExpressionEnvironment(); + } + + return scriptResult; + } + + +} diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensUtil.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensUtil.java index 16ffbac420f..0c59129a461 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensUtil.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensUtil.java @@ -1,1153 +1,1170 @@ -/* - * Copyright (c) 2010-2019 Evolveum and contributors - * - * This work is dual-licensed under the Apache License 2.0 - * and European Union Public License. See LICENSE file for details. - */ -package com.evolveum.midpoint.model.impl.lens; - -import java.util.*; -import java.util.function.Function; -import java.util.function.Supplier; -import java.util.stream.Collectors; - -import javax.xml.datatype.XMLGregorianCalendar; -import javax.xml.namespace.QName; - -import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl; -import com.evolveum.midpoint.model.api.context.EvaluatedPolicyRule; -import com.evolveum.midpoint.model.api.context.EvaluatedPolicyRuleTrigger; -import com.evolveum.midpoint.model.common.mapping.PrismValueDeltaSetTripleProducer; -import com.evolveum.midpoint.prism.path.ItemName; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.prism.polystring.PolyString; -import com.evolveum.midpoint.prism.util.ItemDeltaItem; -import com.evolveum.midpoint.repo.api.RepositoryService; -import com.evolveum.midpoint.schema.SchemaConstantsGenerated; -import com.evolveum.midpoint.schema.util.*; -import com.evolveum.midpoint.util.DebugUtil; -import com.evolveum.midpoint.util.LocalizableMessage; -import com.evolveum.midpoint.util.QNameUtil; -import com.evolveum.midpoint.util.exception.*; -import com.evolveum.midpoint.util.logging.LoggingUtils; - -import com.evolveum.midpoint.xml.ns._public.common.common_3.*; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType; - -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.lang.BooleanUtils; - -import com.evolveum.midpoint.common.ActivationComputer; -import com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition; -import com.evolveum.midpoint.common.refinery.RefinedResourceSchema; -import com.evolveum.midpoint.model.common.mapping.MappingImpl; -import com.evolveum.midpoint.model.impl.expr.ExpressionEnvironment; -import com.evolveum.midpoint.model.impl.expr.ModelExpressionThreadLocalHolder; -import com.evolveum.midpoint.model.impl.util.ModelImplUtils; -import com.evolveum.midpoint.prism.*; -import com.evolveum.midpoint.prism.delta.ItemDelta; -import com.evolveum.midpoint.prism.delta.ObjectDelta; -import com.evolveum.midpoint.prism.delta.PrismValueDeltaSetTriple; -import com.evolveum.midpoint.prism.delta.PropertyDelta; -import com.evolveum.midpoint.provisioning.api.ProvisioningService; -import com.evolveum.midpoint.repo.common.ObjectResolver; -import com.evolveum.midpoint.repo.common.expression.Expression; -import com.evolveum.midpoint.repo.common.expression.ExpressionEvaluationContext; -import com.evolveum.midpoint.repo.common.expression.ExpressionFactory; -import com.evolveum.midpoint.repo.common.expression.ExpressionUtil; -import com.evolveum.midpoint.repo.common.expression.ExpressionVariables; -import com.evolveum.midpoint.repo.common.expression.Source; -import com.evolveum.midpoint.schema.CapabilityUtil; -import com.evolveum.midpoint.schema.GetOperationOptions; -import com.evolveum.midpoint.schema.ResourceShadowDiscriminator; -import com.evolveum.midpoint.schema.ResultHandler; -import com.evolveum.midpoint.schema.SelectorOptions; -import com.evolveum.midpoint.schema.VirtualAssignmenetSpecification; -import com.evolveum.midpoint.schema.constants.ExpressionConstants; -import com.evolveum.midpoint.schema.constants.SchemaConstants; -import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; -import org.jetbrains.annotations.NotNull; - -import static com.evolveum.midpoint.util.MiscUtil.getSingleValue; -import static java.util.Collections.emptySet; - -/** - * @author semancik - * - */ -public class LensUtil { - - private static final Trace LOGGER = TraceManager.getTrace(LensUtil.class); - - public static ResourceType getResourceReadOnly(LensContext context, - String resourceOid, ProvisioningService provisioningService, Task task, OperationResult result) throws ObjectNotFoundException, - CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - ResourceType resourceType = context.getResource(resourceOid); - if (resourceType == null) { - // Fetching from provisioning to take advantage of caching and - // pre-parsed schema - Collection> options = SelectorOptions.createCollection(GetOperationOptions.createReadOnly()); - resourceType = provisioningService.getObject(ResourceType.class, resourceOid, options, task, result) - .asObjectable(); - context.rememberResource(resourceType); - } - return resourceType; - } - - @NotNull - static ResourceType getResourceReadOnly(LensContext context, String resourceOid, ObjectResolver objectResolver, - Task task, OperationResult result) throws ObjectNotFoundException, - CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - ResourceType resourceFromContext = context.getResource(resourceOid); - if (resourceFromContext != null) { - return resourceFromContext; - } else { - Collection> options = SelectorOptions.createCollection(GetOperationOptions.createReadOnly()); - ResourceType resourceFetched = objectResolver.getObject(ResourceType.class, resourceOid, options, task, result); - context.rememberResource(resourceFetched); - return resourceFetched; - } - } - - public static String refineProjectionIntent(ShadowKindType kind, String intent, ResourceType resource, PrismContext prismContext) throws SchemaException { - RefinedResourceSchema refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource, LayerType.MODEL, prismContext); - RefinedObjectClassDefinition rObjClassDef = refinedSchema.getRefinedDefinition(kind, intent); - if (rObjClassDef == null) { - LOGGER.error("No projection definition for kind={}, intent={} in {}", kind, intent, resource); - LOGGER.error("Diagnostic output follows:\n\nResource:\n{}\n\nRefined resource schema:\n{}", - resource.asPrismObject().debugDump(), refinedSchema.debugDump()); - throw new SchemaException("No projection definition for kind="+kind+" intent="+intent+" in "+resource); - } - return rObjClassDef.getIntent(); - } - - public static LensProjectionContext getProjectionContext(LensContext context, PrismObject equivalentAccount, - ProvisioningService provisioningService, PrismContext prismContext, - Task task, OperationResult result) throws ObjectNotFoundException, - CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - ShadowType equivalentAccountType = equivalentAccount.asObjectable(); - ShadowKindType kind = ShadowUtil.getKind(equivalentAccountType); - return getProjectionContext(context, ShadowUtil.getResourceOid(equivalentAccountType), - kind, equivalentAccountType.getIntent(), equivalentAccountType.getTag(), provisioningService, - prismContext, task, result); - } - - private static LensProjectionContext getProjectionContext(LensContext context, String resourceOid, - ShadowKindType kind, String intent, String tag, - ProvisioningService provisioningService, PrismContext prismContext, - Task task, OperationResult result) throws ObjectNotFoundException, - CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - ResourceType resource = getResourceReadOnly(context, resourceOid, provisioningService, task, result); - String refinedIntent = refineProjectionIntent(kind, intent, resource, prismContext); - ResourceShadowDiscriminator rsd = new ResourceShadowDiscriminator(resourceOid, kind, refinedIntent, tag, false); - return context.findProjectionContext(rsd); - } - - public static LensProjectionContext getOrCreateProjectionContext(LensContext context, - ResourceShadowDiscriminator rsd) { - LensProjectionContext accountSyncContext = context.findProjectionContext(rsd); - if (accountSyncContext == null) { - accountSyncContext = context.createProjectionContext(rsd); - ResourceType resource = context.getResource(rsd.getResourceOid()); - accountSyncContext.setResource(resource); - } - accountSyncContext.setDoReconciliation(context.isDoReconciliationForAllProjections()); - return accountSyncContext; - } - - public static LensProjectionContext createAccountContext(LensContext context, ResourceShadowDiscriminator rsd){ - return new LensProjectionContext(context, rsd); - } - - public static V cloneAndApplyMetadata(V value, boolean isAssignment, - Collection> origins) throws SchemaException { - return cloneAndApplyMetadata(value, isAssignment, () -> getAutoCreationIdentifier(origins)); - } - -// public static Collection cloneAndApplyMetadata(Collection values, boolean isAssignment, -// MappingType mapping) throws SchemaException { -// List rv = new ArrayList<>(); -// for (V value : values) { -// rv.add(cloneAndApplyMetadata(value, isAssignment, mapping::getName)); -// } -// return rv; -// } - - public static V cloneAndApplyMetadata(V value, boolean isAssignment, - PrismValueDeltaSetTripleProducer mapping) throws SchemaException { - return cloneAndApplyMetadata(value, isAssignment, mapping::getIdentifier); - } - - public static V cloneAndApplyMetadata(V value, boolean isAssignment, - MappingType mapping) throws SchemaException { - return cloneAndApplyMetadata(value, isAssignment, mapping::getName); - } - - private static V cloneAndApplyMetadata(V value, boolean isAssignment, - Supplier originMappingNameSupplier) throws SchemaException { - //noinspection unchecked - V cloned = (V) value.clone(); - if (isAssignment && cloned instanceof PrismContainerValue) { - ((PrismContainerValue) cloned).setId(null); - String originMappingName = originMappingNameSupplier.get(); - LOGGER.trace("cloneAndApplyMetadata: originMappingName = {}", originMappingName); - if (originMappingName != null) { - //noinspection unchecked - PrismContainer metadataContainer = ((PrismContainerValue) cloned).findOrCreateContainer(AssignmentType.F_METADATA); - metadataContainer.getValue().asContainerable().setOriginMappingName(originMappingName); - } - } - return cloned; - } - - private static String getAutoCreationIdentifier(Collection> origins) { - // let's ignore conflicts (name1 vs name2, named vs unnamed) for now - for (ItemValueWithOrigin origin : origins) { - if (origin.getMapping() != null && origin.getMapping().getIdentifier() != null) { - return origin.getMapping().getIdentifier(); - } - } - return null; - } - - public static PropertyDelta createActivationTimestampDelta(ActivationStatusType status, - XMLGregorianCalendar now, - PrismContainerDefinition activationDefinition, OriginType origin, - PrismContext prismContext) { - ItemName timestampPropertyName; - if (status == null || status == ActivationStatusType.ENABLED) { - timestampPropertyName = ActivationType.F_ENABLE_TIMESTAMP; - } else if (status == ActivationStatusType.DISABLED) { - timestampPropertyName = ActivationType.F_DISABLE_TIMESTAMP; - } else if (status == ActivationStatusType.ARCHIVED) { - timestampPropertyName = ActivationType.F_ARCHIVE_TIMESTAMP; - } else { - throw new IllegalArgumentException("Unknown activation status "+status); - } - - PrismPropertyDefinition timestampDef = activationDefinition.findPropertyDefinition(timestampPropertyName); - PropertyDelta timestampDelta - = timestampDef.createEmptyDelta(FocusType.F_ACTIVATION.append(timestampPropertyName)); - timestampDelta.setValueToReplace(prismContext.itemFactory().createPropertyValue(now, origin, null)); - return timestampDelta; - } - - public static void moveTriggers(LensProjectionContext projCtx, LensFocusContext focusCtx) throws SchemaException { - ObjectDelta projSecondaryDelta = projCtx.getSecondaryDelta(); - if (projSecondaryDelta == null) { - return; - } - Collection modifications = projSecondaryDelta.getModifications(); - Iterator iterator = modifications.iterator(); - while (iterator.hasNext()) { - ItemDelta projModification = iterator.next(); - LOGGER.trace("MOD: {}\n{}", projModification.getPath(), projModification.debugDumpLazily()); - if (projModification.getPath().equivalent(SchemaConstants.PATH_TRIGGER)) { - focusCtx.swallowToProjectionWaveSecondaryDelta(projModification); - iterator.remove(); - } - } - } - - public static Object getIterationVariableValue(LensProjectionContext accCtx) { - Integer iterationOld = null; - PrismObject shadowCurrent = accCtx.getObjectCurrent(); - if (shadowCurrent != null) { - iterationOld = shadowCurrent.asObjectable().getIteration(); - } - if (iterationOld == null) { - return accCtx.getIteration(); - } - PrismPropertyDefinition propDef = accCtx.getPrismContext().definitionFactory().createPropertyDefinition(ExpressionConstants.VAR_ITERATION_QNAME, - DOMUtil.XSD_INT); - PrismProperty propOld = propDef.instantiate(); - propOld.setRealValue(iterationOld); - PropertyDelta propDelta = propDef.createEmptyDelta(ExpressionConstants.VAR_ITERATION_QNAME); - propDelta.setRealValuesToReplace(accCtx.getIteration()); - PrismProperty propNew = propDef.instantiate(); - propNew.setRealValue(accCtx.getIteration()); - ItemDeltaItem,PrismPropertyDefinition> idi = new ItemDeltaItem<>(propOld, propDelta, propNew, propDef); - return idi; - } - - public static Object getIterationTokenVariableValue(LensProjectionContext accCtx) { - String iterationTokenOld = null; - PrismObject shadowCurrent = accCtx.getObjectCurrent(); - if (shadowCurrent != null) { - iterationTokenOld = shadowCurrent.asObjectable().getIterationToken(); - } - if (iterationTokenOld == null) { - return accCtx.getIterationToken(); - } - PrismPropertyDefinition propDef = accCtx.getPrismContext().definitionFactory().createPropertyDefinition( - ExpressionConstants.VAR_ITERATION_TOKEN_QNAME, DOMUtil.XSD_STRING); - PrismProperty propOld = propDef.instantiate(); - propOld.setRealValue(iterationTokenOld); - PropertyDelta propDelta = propDef.createEmptyDelta(ExpressionConstants.VAR_ITERATION_TOKEN_QNAME); - propDelta.setRealValuesToReplace(accCtx.getIterationToken()); - PrismProperty propNew = propDef.instantiate(); - propNew.setRealValue(accCtx.getIterationToken()); - ItemDeltaItem,PrismPropertyDefinition> idi = new ItemDeltaItem<>(propOld, propDelta, propNew, propDef); - return idi; - } - - /** - * Extracts the delta from this projection context and also from all other projection contexts that have - * equivalent discriminator. - */ - public static PropertyDelta findAPrioriDelta(LensContext context, - LensProjectionContext projCtx, ItemPath projectionPropertyPath) throws SchemaException { - PropertyDelta aPrioriDelta = null; - for (LensProjectionContext aProjCtx: findRelatedContexts(context, projCtx)) { - ObjectDelta aProjDelta = aProjCtx.getDelta(); - if (aProjDelta != null) { - PropertyDelta aPropProjDelta = aProjDelta.findPropertyDelta(projectionPropertyPath); - if (aPropProjDelta != null) { - if (aPrioriDelta == null) { - aPrioriDelta = aPropProjDelta.clone(); - } else { - aPrioriDelta.merge(aPropProjDelta); - } - } - } - } - return aPrioriDelta; - } - - /** - * Extracts the delta from this projection context and also from all other projection contexts that have - * equivalent discriminator. - */ - public static ObjectDelta findAPrioriDelta(LensContext context, - LensProjectionContext projCtx) throws SchemaException { - ObjectDelta aPrioriDelta = null; - for (LensProjectionContext aProjCtx: findRelatedContexts(context, projCtx)) { - ObjectDelta aProjDelta = aProjCtx.getDelta(); - if (aProjDelta != null) { - if (aPrioriDelta == null) { - aPrioriDelta = aProjDelta.clone(); - } else { - aPrioriDelta.merge(aProjDelta); - } - } - } - return aPrioriDelta; - } - - /** - * Returns a list of context that have equivalent discriminator with the reference context. Ordered by "order" in the - * discriminator. - */ - public static List findRelatedContexts( - LensContext context, LensProjectionContext refProjCtx) { - List projCtxs = new ArrayList<>(); - ResourceShadowDiscriminator refDiscr = refProjCtx.getResourceShadowDiscriminator(); - if (refDiscr == null) { - return projCtxs; - } - for (LensProjectionContext aProjCtx: context.getProjectionContexts()) { - ResourceShadowDiscriminator aDiscr = aProjCtx.getResourceShadowDiscriminator(); - if (refDiscr.equivalent(aDiscr)) { - projCtxs.add(aProjCtx); - } - } - Comparator orderComparator = new Comparator() { - @Override - public int compare(LensProjectionContext ctx1, LensProjectionContext ctx2) { - int order1 = ctx1.getResourceShadowDiscriminator().getOrder(); - int order2 = ctx2.getResourceShadowDiscriminator().getOrder(); - return Integer.compare(order1, order2); - } - }; - Collections.sort(projCtxs, orderComparator); - return projCtxs; - } - - public static boolean hasLowerOrderContext(LensContext context, - LensProjectionContext refProjCtx) { - ResourceShadowDiscriminator refDiscr = refProjCtx.getResourceShadowDiscriminator(); - for (LensProjectionContext aProjCtx: context.getProjectionContexts()) { - ResourceShadowDiscriminator aDiscr = aProjCtx.getResourceShadowDiscriminator(); - if (refDiscr.equivalent(aDiscr) && (refDiscr.getOrder() > aDiscr.getOrder())) { - return true; - } - } - return false; - } - - public static boolean hasDependentContext(LensContext context, - LensProjectionContext targetProjectionContext) { - for (LensProjectionContext projectionContext: context.getProjectionContexts()) { - for (ResourceObjectTypeDependencyType dependency: projectionContext.getDependencies()) { - if (isDependencyTargetContext(projectionContext, targetProjectionContext, dependency)) { - return true; - } - } - } - return false; - } - - public static boolean isDependencyTargetContext(LensProjectionContext sourceProjContext, LensProjectionContext targetProjectionContext, ResourceObjectTypeDependencyType dependency) { - ResourceShadowDiscriminator refDiscr = new ResourceShadowDiscriminator(dependency, - sourceProjContext.getResource().getOid(), sourceProjContext.getKind()); - return targetProjectionContext.compareResourceShadowDiscriminator(refDiscr, false); - } - - public static LensProjectionContext findLowerOrderContext(LensContext context, - LensProjectionContext refProjCtx) { - int minOrder = -1; - LensProjectionContext foundCtx = null; - ResourceShadowDiscriminator refDiscr = refProjCtx.getResourceShadowDiscriminator(); - for (LensProjectionContext aProjCtx: context.getProjectionContexts()) { - ResourceShadowDiscriminator aDiscr = aProjCtx.getResourceShadowDiscriminator(); - if (refDiscr.equivalent(aDiscr) && (refDiscr.getOrder() > aDiscr.getOrder())) { - if (minOrder < 0 || (aDiscr.getOrder() < minOrder)) { - minOrder = aDiscr.getOrder(); - foundCtx = aProjCtx; - } - } - } - return foundCtx; - } - - public static void setContextOid(LensContext context, - LensElementContext objectContext, String oid) { - objectContext.setOid(oid); - // Check if we need to propagate this oid also to higher-order contexts - if (!(objectContext instanceof LensProjectionContext)) { - return; - } - LensProjectionContext refProjCtx = (LensProjectionContext)objectContext; - ResourceShadowDiscriminator refDiscr = refProjCtx.getResourceShadowDiscriminator(); - if (refDiscr == null) { - return; - } - for (LensProjectionContext aProjCtx: context.getProjectionContexts()) { - ResourceShadowDiscriminator aDiscr = aProjCtx.getResourceShadowDiscriminator(); - if (aDiscr != null && refDiscr.equivalent(aDiscr) && (refDiscr.getOrder() < aDiscr.getOrder())) { - aProjCtx.setOid(oid); - } - } - } - - public static PrismObjectDefinition getFocusDefinition(LensContext context) { - LensFocusContext focusContext = context.getFocusContext(); - if (focusContext == null) { - return null; - } - Class typeClass = focusContext.getObjectTypeClass(); - return context.getPrismContext().getSchemaRegistry().findObjectDefinitionByCompileTimeClass(typeClass); - } - - public static IterationSpecificationType getIterationSpecification(ObjectTemplateType objectTemplate) { - return objectTemplate != null ? objectTemplate.getIterationSpecification() : null; - } - - public static int determineMaxIterations(IterationSpecificationType iterationSpecType) { - return iterationSpecType != null ? iterationSpecType.getMaxIterations() : 0; - } - - public static String formatIterationToken(LensContext context, - LensElementContext accountContext, IterationSpecificationType iterationType, - int iteration, ExpressionFactory expressionFactory, ExpressionVariables variables, - Task task, OperationResult result) - throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { - if (iterationType == null) { - return formatIterationTokenDefault(iteration); - } - ExpressionType tokenExpressionType = iterationType.getTokenExpression(); - if (tokenExpressionType == null) { - return formatIterationTokenDefault(iteration); - } - PrismContext prismContext = context.getPrismContext(); - PrismPropertyDefinition outputDefinition = prismContext.definitionFactory().createPropertyDefinition(ExpressionConstants.VAR_ITERATION_TOKEN_QNAME, - DOMUtil.XSD_STRING); - Expression,PrismPropertyDefinition> expression = expressionFactory.makeExpression(tokenExpressionType, outputDefinition, MiscSchemaUtil.getExpressionProfile(), "iteration token expression in "+accountContext.getHumanReadableName(), task, result); - - Collection> sources = new ArrayList<>(); - MutablePrismPropertyDefinition inputDefinition = prismContext.definitionFactory().createPropertyDefinition(ExpressionConstants.VAR_ITERATION_QNAME, - DOMUtil.XSD_INT); - inputDefinition.setMaxOccurs(1); - PrismProperty input = inputDefinition.instantiate(); - input.addRealValue(iteration); - ItemDeltaItem,PrismPropertyDefinition> idi = new ItemDeltaItem<>(input); - Source,PrismPropertyDefinition> iterationSource = new Source<>(idi, ExpressionConstants.VAR_ITERATION_QNAME); - sources.add(iterationSource); - - ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources , variables, - "iteration token expression in "+accountContext.getHumanReadableName(), task); - PrismValueDeltaSetTriple> outputTriple = ModelExpressionThreadLocalHolder.evaluateExpressionInContext(expression, expressionContext, task, result); - Collection> outputValues = outputTriple.getNonNegativeValues(); - if (outputValues.isEmpty()) { - return ""; - } - if (outputValues.size() > 1) { - throw new ExpressionEvaluationException("Iteration token expression in "+accountContext.getHumanReadableName()+" returned more than one value ("+outputValues.size()+" values)"); - } - String realValue = outputValues.iterator().next().getValue(); - if (realValue == null) { - return ""; - } - return realValue; - } - - public static String formatIterationTokenDefault(int iteration) { - if (iteration == 0) { - return ""; - } - return Integer.toString(iteration); - } - - public static boolean evaluateIterationCondition(LensContext context, - LensElementContext accountContext, IterationSpecificationType iterationType, - int iteration, String iterationToken, boolean beforeIteration, - ExpressionFactory expressionFactory, ExpressionVariables variables, Task task, OperationResult result) - throws ExpressionEvaluationException, SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException { - if (iterationType == null) { - return true; - } - ExpressionType expressionType; - String desc; - if (beforeIteration) { - expressionType = iterationType.getPreIterationCondition(); - desc = "pre-iteration expression in "+accountContext.getHumanReadableName(); - } else { - expressionType = iterationType.getPostIterationCondition(); - desc = "post-iteration expression in "+accountContext.getHumanReadableName(); - } - if (expressionType == null) { - return true; - } - Expression,PrismPropertyDefinition> expression = expressionFactory.makeExpression( - expressionType, ExpressionUtil.createConditionOutputDefinition(context.getPrismContext()), MiscSchemaUtil.getExpressionProfile(), - desc, task, result); - - variables.put(ExpressionConstants.VAR_ITERATION, iteration, Integer.class); - variables.put(ExpressionConstants.VAR_ITERATION_TOKEN, iterationToken, String.class); - - ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(null , variables, desc, task); - ExpressionEnvironment env = new ExpressionEnvironment<>(context, null, task, result); - PrismValueDeltaSetTriple> outputTriple = - ModelExpressionThreadLocalHolder.evaluateExpressionInContext(expression, expressionContext, env, result); - Collection> outputValues = outputTriple.getNonNegativeValues(); - if (outputValues.isEmpty()) { - return false; - } - if (outputValues.size() > 1) { - throw new ExpressionEvaluationException(desc+" returned more than one value ("+outputValues.size()+" values)"); - } - Boolean realValue = outputValues.iterator().next().getValue(); - if (realValue == null) { - return false; - } - return realValue; - - } - - /** - * Used for assignments and similar objects that do not have separate lifecycle. - */ - public static boolean isAssignmentValid(AssignmentHolderType focus, AssignmentType assignmentType, XMLGregorianCalendar now, - ActivationComputer activationComputer, LifecycleStateModelType focusStateModel) { - ObjectReferenceType targetRef = assignmentType.getTargetRef(); - if (targetRef != null) { - if (QNameUtil.match(ArchetypeType.COMPLEX_TYPE, targetRef.getType())) { - // Archetype assignments are always valid, even in non-valid lifecycle states. - // The object cannot lose its (arche)type. - return true; - } - } - String focusLifecycleState = focus.getLifecycleState(); - - if (!activationComputer.lifecycleHasActiveAssignments(focusLifecycleState, focusStateModel)) { - return false; - } - return isValid(assignmentType.getLifecycleState(), assignmentType.getActivation(), now, activationComputer, focusStateModel); - } - - public static Collection getForcedAssignments(LifecycleStateModelType lifecycleModel, String targetLifecycle, - ObjectResolver objectResolver, PrismContext prismContext, Task task, OperationResult result) throws SchemaException, - ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - VirtualAssignmenetSpecification virtualAssignmenetSpecification = LifecycleUtil.getForcedAssignmentSpecification(lifecycleModel, targetLifecycle, prismContext); - - Collection forcedAssignments = new HashSet<>(); - if (virtualAssignmenetSpecification != null) { - - ResultHandler handler = (object, parentResult) -> { - AssignmentType assignment = ObjectTypeUtil.createAssignmentTo(object, prismContext); - return forcedAssignments.add(assignment); - }; - - objectResolver.searchIterative(virtualAssignmenetSpecification.getType(), - prismContext.queryFactory().createQuery(virtualAssignmenetSpecification.getFilter()), null, handler, task, result); - - } - - return forcedAssignments; - } - - public static boolean isFocusValid(AssignmentHolderType focus, XMLGregorianCalendar now, ActivationComputer activationComputer, LifecycleStateModelType focusStateModel) { - if (FocusType.class.isAssignableFrom(focus.getClass())) { - return isValid(focus.getLifecycleState(), ((FocusType) focus).getActivation(), now, activationComputer, focusStateModel); - } - return isValid(focus.getLifecycleState(), null, now, activationComputer, focusStateModel); - } - - private static boolean isValid(String lifecycleState, ActivationType activationType, XMLGregorianCalendar now, ActivationComputer activationComputer, LifecycleStateModelType focusStateModel) { - TimeIntervalStatusType validityStatus = activationComputer.getValidityStatus(activationType, now); - ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus(lifecycleState, activationType, validityStatus, focusStateModel); - return effectiveStatus == ActivationStatusType.ENABLED; - } - - public static AssignmentPathVariables computeAssignmentPathVariables(AssignmentPathImpl assignmentPath) throws SchemaException { - if (assignmentPath == null || assignmentPath.isEmpty()) { - return null; - } - AssignmentPathVariables vars = new AssignmentPathVariables(); - vars.setAssignmentPath(assignmentPath.clone()); - - Iterator iterator = assignmentPath.getSegments().iterator(); - while (iterator.hasNext()) { - AssignmentPathSegmentImpl segment = iterator.next(); - ItemDeltaItem,PrismContainerDefinition> segmentAssignmentIdi = segment.getAssignmentIdi(); - - ItemDeltaItem,PrismContainerDefinition> magicAssignmentIdi; - // Magic assignment - if (vars.getMagicAssignment() == null) { - magicAssignmentIdi = segmentAssignmentIdi.clone(); - vars.setMagicAssignment(magicAssignmentIdi); - } else { - // Collect extension values from the assignment extension - magicAssignmentIdi = vars.getMagicAssignment(); - mergeExtension(magicAssignmentIdi, segmentAssignmentIdi); - } - - // Collect extension values from the source object extension - ObjectType segmentSource = segment.getSource(); - if (segmentSource != null) { - mergeExtension(magicAssignmentIdi, segmentSource.asPrismObject()); - } - - // immediate assignment (use assignment from previous iteration) - vars.setImmediateAssignment(vars.getThisAssignment()); - - // this assignment - ItemDeltaItem,PrismContainerDefinition> thisAssignment = segmentAssignmentIdi.clone(); - vars.setThisAssignment(thisAssignment); - - if (iterator.hasNext() && segmentSource instanceof AbstractRoleType) { - vars.setImmediateRole((PrismObject) segmentSource.asPrismObject()); - } - } - - AssignmentPathSegmentImpl focusAssignmentSegment = assignmentPath.first(); - vars.setFocusAssignment(focusAssignmentSegment.getAssignmentIdi().clone()); - - // a bit of hack -- TODO reconsider in 3.7 - // objects are already cloned - convertToLegacy(vars.getMagicAssignment()); - convertToLegacy(vars.getThisAssignment()); - convertToLegacy(vars.getFocusAssignment()); - convertToLegacy(vars.getImmediateAssignment()); - - return vars; - } - - private static void convertToLegacy( - ItemDeltaItem, PrismContainerDefinition> idi) { - if (idi == null || idi.getDelta() == null || idi.getSubItemDeltas() != null) { - return; - } - // Legacy approach (when adding/removing assignments) was: itemOld+itemNew = value, delta = null - // This was recently changed, to provide precise information (add = null->itemNew, delete = itemOld->null). - // However, to not break scripts before 3.6 release we provide imitation of old behavior here. - // (Moreover, for magic assignment the delta is not correct anyway.) - if (idi.getDelta().isAdd() || idi.getDelta().isReplace()) { - idi.setItemOld(idi.getItemNew().clone()); - } else { - idi.setItemNew(idi.getItemOld().clone()); - } - idi.setDelta(null); - } - - private static void mergeExtension(ItemDeltaItem,PrismContainerDefinition> destIdi, ItemDeltaItem,PrismContainerDefinition> srcIdi) throws SchemaException { - mergeExtension(destIdi.getItemOld(), srcIdi.getItemOld()); - mergeExtension(destIdi.getItemNew(), srcIdi.getItemNew()); - if (srcIdi.getDelta() != null || srcIdi.getSubItemDeltas() != null) { - throw new UnsupportedOperationException("Merge of IDI with deltas not supported"); - } - } - - private static void mergeExtension(Item,PrismContainerDefinition> dstItem, - Item,PrismContainerDefinition> srcItem) throws SchemaException { - if (srcItem == null || dstItem == null) { - return; - } - PrismContainer srcExtension = ((PrismContainer)srcItem).findContainer(AssignmentType.F_EXTENSION); - mergeExtensionContainers(dstItem, srcExtension); - } - - private static void mergeExtension(ItemDeltaItem,PrismContainerDefinition> destIdi, - PrismObject srcObject) throws SchemaException { - if (srcObject == null) { - return; - } - - PrismContainer srcExtension = srcObject.findContainer(ObjectType.F_EXTENSION); - - mergeExtensionContainers(destIdi.getItemNew(), srcExtension); - mergeExtensionContainers(destIdi.getItemOld(), srcExtension); - } - - private static void mergeExtensionContainers(Item,PrismContainerDefinition> dstItem, PrismContainer srcExtension) throws SchemaException { - if (dstItem == null) { - return; - } - PrismContainer dstContainer = (PrismContainer) dstItem; - if (srcExtension != null && !srcExtension.isEmpty()) { - PrismContainer dstExtensionContainer = dstContainer.findOrCreateContainer(AssignmentType.F_EXTENSION); - PrismContainerValue dstExtensionContainerValue = dstExtensionContainer.getValues().isEmpty() - ? dstExtensionContainer.createNewValue() : dstExtensionContainer.getValue(); - ObjectTypeUtil.mergeExtension(dstExtensionContainerValue, srcExtension.getValue()); - } - } - - public static MappingImpl.Builder addAssignmentPathVariables(MappingImpl.Builder builder, AssignmentPathVariables assignmentPathVariables, PrismContext prismContext) { - ExpressionVariables expressionVariables = new ExpressionVariables(); - ModelImplUtils.addAssignmentPathVariables(assignmentPathVariables, expressionVariables, prismContext); - return builder.addVariableDefinitions(expressionVariables); - } - - public static void checkContextSanity(LensContext context, String activityDescription, - OperationResult result) throws SchemaException, PolicyViolationException { - LensFocusContext focusContext = context.getFocusContext(); - if (focusContext != null) { - PrismObject focusObjectNew = focusContext.getObjectNew(); - if (focusObjectNew != null) { - PolyStringType namePolyType = focusObjectNew.asObjectable().getName(); - if (namePolyType == null) { - throw new SchemaException("Focus "+focusObjectNew+" does not have a name after "+activityDescription); - } - ArchetypePolicyType archetypePolicy = focusContext.getArchetypePolicyType(); - checkArchetypePolicy(focusContext, archetypePolicy); - } - } - } - - private static void checkArchetypePolicy(LensFocusContext focusContext, ArchetypePolicyType archetypePolicy) throws SchemaException, PolicyViolationException { - if (archetypePolicy == null) { - return; - } - PrismObject focusObjectNew = focusContext.getObjectNew(); - ObjectDelta focusDelta = focusContext.getDelta(); - - for (PropertyConstraintType propertyConstraintType: archetypePolicy.getPropertyConstraint()) { - ItemPath itemPath = propertyConstraintType.getPath().getItemPath(); - if (BooleanUtils.isTrue(propertyConstraintType.isOidBound())) { - if (focusDelta != null) { - if (focusDelta.isAdd()) { - PrismProperty propNew = focusObjectNew.findProperty(itemPath); - if (propNew != null) { - // prop delta is OK, but it has to match - if (focusObjectNew.getOid() != null) { - if (!focusObjectNew.getOid().equals(propNew.getRealValue().toString())) { - throw new PolicyViolationException("Cannot set "+itemPath+" to a value different than OID in oid bound mode"); - } - } - } - } else { - PropertyDelta nameDelta = focusDelta.findPropertyDelta(itemPath); - if (nameDelta != null) { - if (nameDelta.isReplace()) { - Collection> valuesToReplace = nameDelta.getValuesToReplace(); - if (valuesToReplace.size() == 1) { - String stringValue = valuesToReplace.iterator().next().getValue().toString(); - if (focusContext.getOid().equals(stringValue)) { - // This is OK. It is most likely a correction made by a recompute. - continue; - } - } - } - throw new PolicyViolationException("Cannot change "+itemPath+" in oid bound mode"); - } - } - } - } - } - - } - - public static PrismContainer createAssignmentSingleValueContainer(@NotNull AssignmentType assignmentType) throws SchemaException { - // Make it appear to be single-value. Therefore paths without segment IDs will work. - return assignmentType.asPrismContainerValue().asSingleValuedContainer(SchemaConstantsGenerated.C_ASSIGNMENT); - } - - public static AssignmentType getAssignmentType(ItemDeltaItem,PrismContainerDefinition> assignmentIdi, boolean old) { - return PrismContainerValue.asContainerable(assignmentIdi.getSingleValue(old)); - } - - - public static String getChannel(LensContext context, Task task) { - if (context != null && context.getChannel() != null){ - return context.getChannel(); - } else if (task.getChannel() != null){ - return task.getChannel(); - } - return null; - } - - public static void setDeltaOldValue(LensElementContext ctx, ItemDelta itemDelta) { - if (itemDelta.getEstimatedOldValues() != null) { - return; - } - if (ctx.getObjectOld() == null) { - return; - } - Item itemOld = ctx.getObjectOld().findItem(itemDelta.getPath()); - if (itemOld != null) { - //noinspection unchecked - itemDelta.setEstimatedOldValues((Collection) PrismValueCollectionsUtil.cloneCollection(itemOld.getValues())); - return; - } - // Here we need to distinguish whether the item is missing because it is not filled in (e.g. familyName in MID-4237) - // or because it was not loaded (as for attributes or associations). - if (!isItemLoadable(ctx.getObjectOld(), itemDelta.getPath())) { - itemDelta.setEstimatedOldValues(emptySet()); - return; - } - // get the old data from current object. Still better estimate than nothing - if (ctx.getObjectCurrent() != null) { - itemOld = ctx.getObjectCurrent().findItem(itemDelta.getPath()); - if (itemOld != null) { - //noinspection unchecked - itemDelta.setEstimatedOldValues((Collection) PrismValueCollectionsUtil.cloneCollection(itemOld.getValues())); - } - } - } - - // a heuristic by now - private static boolean isItemLoadable(PrismObject object, ItemPath path) { - if (!(object.asObjectable() instanceof ShadowType)) { - return false; - } - return path.startsWithName(ShadowType.F_ATTRIBUTES) || path.startsWithName(ShadowType.F_ASSOCIATION); - } - - public static void setDeltaOldValue(LensElementContext ctx, ObjectDelta objectDelta) { - if (objectDelta == null) { - return; - } - if (!objectDelta.isModify()) { - return; - } - for (ItemDelta modification: objectDelta.getModifications()) { - setDeltaOldValue(ctx, modification); - } - } - - public static LensObjectDeltaOperation createObjectDeltaOperation(ObjectDelta focusDelta, OperationResult result, - LensElementContext focusContext, LensProjectionContext projCtx) { - return createObjectDeltaOperation(focusDelta, result, focusContext, projCtx, null); - } - - // projCtx may or may not be present (object itself can be focus or projection) - public static LensObjectDeltaOperation createObjectDeltaOperation(ObjectDelta objectDelta, OperationResult result, - LensElementContext objectContext, - LensProjectionContext projCtx, - ResourceType resource) { - LensObjectDeltaOperation objectDeltaOp = new LensObjectDeltaOperation<>(objectDelta.clone()); - objectDeltaOp.setExecutionResult(result); - PrismObject object = objectContext.getObjectAny(); - if (object != null) { - PolyString name = object.getName(); - if (name == null && object.asObjectable() instanceof ShadowType) { - try { - name = ShadowUtil.determineShadowName((PrismObject) object); - if (name == null) { - LOGGER.debug("No name for shadow:\n{}", object.debugDump()); - } else if (name.getNorm() == null) { - name.recompute(objectContext.getPrismContext().getDefaultPolyStringNormalizer()); - } - } catch (SchemaException e) { - LoggingUtils.logUnexpectedException(LOGGER, "Couldn't determine name for shadow -- continuing with no name; shadow:\n{}", e, object.debugDump()); - } - } - objectDeltaOp.setObjectName(name); - } - if (resource == null && projCtx != null) { - resource = projCtx.getResource(); - } - if (resource != null) { - objectDeltaOp.setResourceOid(resource.getOid()); - objectDeltaOp.setResourceName(PolyString.toPolyString(resource.getName())); - } else if (objectContext instanceof LensProjectionContext) { - objectDeltaOp.setResourceOid(((LensProjectionContext) objectContext).getResourceOid()); - } - return objectDeltaOp; - } - - public static void triggerRule(@NotNull EvaluatedPolicyRule rule, Collection> triggers, - Collection policySituations) { - - LOGGER.debug("Policy rule {} triggered: {}", rule.getName(), triggers); - if (LOGGER.isTraceEnabled()) { - LOGGER.trace("Policy rule {} triggered:\n{}", rule.getName(), DebugUtil.debugDump(triggers, 1)); - } - - ((EvaluatedPolicyRuleImpl) rule).addTriggers(triggers); - CollectionUtils.addIgnoreNull(policySituations, rule.getPolicySituation()); - } - - public static void processRuleWithException(@NotNull EvaluatedPolicyRule rule, Collection> triggers, - PolicyExceptionType policyException) { - - LOGGER.debug("Policy rule {} would be triggered, but there is an exception for it. Not triggering", rule.getName()); - if (LOGGER.isTraceEnabled()) { - LOGGER.trace("Policy rule {} would be triggered, but there is an exception for it:\nTriggers:\n{}\nException:\n{}", - rule.getName(), DebugUtil.debugDump(triggers, 1), policyException); - } - ((EvaluatedPolicyRuleImpl)rule).addPolicyException(policyException); - } - - - public static void checkMaxIterations(int iteration, int maxIterations, String conflictMessage, String humanReadableName) - throws ObjectAlreadyExistsException { - if (iteration > maxIterations) { - StringBuilder sb = new StringBuilder(); - if (iteration == 1) { - sb.append("Error processing "); - } else { - sb.append("Too many iterations (").append(iteration).append(") for "); - } - sb.append(humanReadableName); - if (iteration == 1) { - sb.append(": constraint violation: "); - } else { - sb.append(": cannot determine values that satisfy constraints: "); - } - if (conflictMessage != null) { - sb.append(conflictMessage); - } - throw new ObjectAlreadyExistsException(sb.toString()); - } - } - - public static boolean needsFullShadowForCredentialProcessing(LensProjectionContext projCtx) throws SchemaException { - RefinedObjectClassDefinition refinedProjDef = projCtx.getStructuralObjectClassDefinition(); - if (refinedProjDef == null) { - return false; - } - - List outboundMappingType = refinedProjDef.getPasswordOutbound(); - if (outboundMappingType == null) { - return false; - } - for (MappingType mappingType: outboundMappingType) { - if (mappingType.getStrength() == MappingStrengthType.STRONG || mappingType.getStrength() == MappingStrengthType.WEAK) { - return true; - } - } - return false; - } - - public static boolean isPasswordReturnedByDefault(LensProjectionContext projCtx) { - CredentialsCapabilityType credentialsCapabilityType = ResourceTypeUtil.getEffectiveCapability(projCtx.getResource(), CredentialsCapabilityType.class); - return CapabilityUtil.isPasswordReturnedByDefault(credentialsCapabilityType); - } - - public static boolean evaluateBoolean(ExpressionType expressionBean, ExpressionVariables expressionVariables, - String contextDescription, ExpressionFactory expressionFactory, PrismContext prismContext, Task task, - OperationResult result) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { - return evaluateExpressionSingle(expressionBean, expressionVariables, contextDescription, expressionFactory, prismContext, - task, result, - DOMUtil.XSD_BOOLEAN, false, null); - } - - public static String evaluateString(ExpressionType expressionBean, ExpressionVariables expressionVariables, - String contextDescription, ExpressionFactory expressionFactory, PrismContext prismContext, Task task, - OperationResult result) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { - return evaluateExpressionSingle(expressionBean, expressionVariables, contextDescription, expressionFactory, prismContext, - task, result, - DOMUtil.XSD_STRING, null, null); - } - - public static LocalizableMessageType evaluateLocalizableMessageType(ExpressionType expressionBean, ExpressionVariables expressionVariables, - String contextDescription, ExpressionFactory expressionFactory, PrismContext prismContext, Task task, - OperationResult result) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { - Function additionalConvertor = (o) -> { - if (o == null || o instanceof LocalizableMessageType) { - return o; - } else if (o instanceof LocalizableMessage) { - return LocalizationUtil.createLocalizableMessageType((LocalizableMessage) o); - } else { - return new SingleLocalizableMessageType().fallbackMessage(String.valueOf(o)); - } - }; - return evaluateExpressionSingle(expressionBean, expressionVariables, contextDescription, expressionFactory, prismContext, - task, result, LocalizableMessageType.COMPLEX_TYPE, null, additionalConvertor); - } - - public static T evaluateExpressionSingle(ExpressionType expressionBean, ExpressionVariables expressionVariables, - String contextDescription, ExpressionFactory expressionFactory, PrismContext prismContext, Task task, - OperationResult result, QName typeName, - T defaultValue, Function additionalConvertor) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { - PrismPropertyDefinition resultDef = prismContext.definitionFactory().createPropertyDefinition( - new QName(SchemaConstants.NS_C, "result"), typeName); - Expression,PrismPropertyDefinition> expression = - expressionFactory.makeExpression(expressionBean, resultDef, MiscSchemaUtil.getExpressionProfile(), contextDescription, task, result); - ExpressionEvaluationContext eeContext = new ExpressionEvaluationContext(null, expressionVariables, contextDescription, task); - eeContext.setAdditionalConvertor(additionalConvertor); - PrismValueDeltaSetTriple> exprResultTriple = ModelExpressionThreadLocalHolder - .evaluateExpressionInContext(expression, eeContext, task, result); - List results = exprResultTriple.getZeroSet().stream() - .map(ppv -> (T) ppv.getRealValue()) - .collect(Collectors.toList()); - return getSingleValue(results, defaultValue, contextDescription); - } - - @NotNull - public static SingleLocalizableMessageType interpretLocalizableMessageTemplate(LocalizableMessageTemplateType template, - ExpressionVariables var, ExpressionFactory expressionFactory, PrismContext prismContext, - Task task, OperationResult result) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, - ConfigurationException, SecurityViolationException { - SingleLocalizableMessageType rv = new SingleLocalizableMessageType(); - if (template.getKey() != null) { - rv.setKey(template.getKey()); - } else if (template.getKeyExpression() != null) { - rv.setKey(evaluateString(template.getKeyExpression(), var, "localizable message key expression", expressionFactory, prismContext, task, result)); - } - if (!template.getArgument().isEmpty() && !template.getArgumentExpression().isEmpty()) { - throw new IllegalArgumentException("Both argument and argumentExpression items are non empty"); - } else if (!template.getArgumentExpression().isEmpty()) { - for (ExpressionType argumentExpression : template.getArgumentExpression()) { - LocalizableMessageType argument = evaluateLocalizableMessageType(argumentExpression, var, - "localizable message argument expression", expressionFactory, prismContext, task, result); - rv.getArgument().add(new LocalizableMessageArgumentType().localizable(argument)); - } - } else { - // TODO allow localizable messages templates here - rv.getArgument().addAll(template.getArgument()); - } - if (template.getFallbackMessage() != null) { - rv.setFallbackMessage(template.getFallbackMessage()); - } else if (template.getFallbackMessageExpression() != null) { - rv.setFallbackMessage(evaluateString(template.getFallbackMessageExpression(), var, - "localizable message fallback expression", expressionFactory, prismContext, task, result)); - } - return rv; - } - - public static void reclaimSequences(LensContext context, RepositoryService repositoryService, Task task, OperationResult result) throws SchemaException { - if (context == null) { - return; - } - - Map sequenceMap = context.getSequences(); - LOGGER.trace("Context sequence map: {}", sequenceMap); - for (Map.Entry sequenceMapEntry: sequenceMap.entrySet()) { - Collection unusedValues = new ArrayList<>(1); - unusedValues.add(sequenceMapEntry.getValue()); - try { - LOGGER.trace("Returning value {} to sequence {}", sequenceMapEntry.getValue(), sequenceMapEntry.getKey()); - repositoryService.returnUnusedValuesToSequence(sequenceMapEntry.getKey(), unusedValues, result); - } catch (ObjectNotFoundException e) { - LOGGER.error("Cannot return unused value to sequence {}: it does not exist", sequenceMapEntry.getKey(), e); - // ... but otherwise ignore it and go on - } - } - } - - public static void applyObjectPolicyConstraints(LensFocusContext focusContext, ArchetypePolicyType archetypePolicy, PrismContext prismContext) throws SchemaException, ConfigurationException { - if (archetypePolicy == null) { - return; - } - - final PrismObject focusNew = focusContext.getObjectNew(); - if (focusNew == null) { - // This is delete. Nothing to do. - return; - } - - for (PropertyConstraintType propertyConstraintType: archetypePolicy.getPropertyConstraint()) { - if (propertyConstraintType.getPath() == null) { - LOGGER.error("Invalid configuration. Path is mandatory for property constraint definition in {} defined in system configuration", archetypePolicy); - throw new SchemaException("Invalid configuration. Path is mandatory for property constraint definition in " + archetypePolicy + " defined in system configuration."); - } - ItemPath itemPath = propertyConstraintType.getPath().getItemPath(); - if (BooleanUtils.isTrue(propertyConstraintType.isOidBound())) { - PrismProperty prop = focusNew.findProperty(itemPath); - if (prop == null || prop.isEmpty()) { - String newValue = focusNew.getOid(); - if (newValue == null) { - newValue = OidUtil.generateOid(); - } - LOGGER.trace("Generating new OID-bound value for {}: {}", itemPath, newValue); - PrismObjectDefinition focusDefinition = focusContext.getObjectDefinition(); - PrismPropertyDefinition propDef = focusDefinition.findPropertyDefinition(itemPath); - if (propDef == null) { - throw new SchemaException("No definition for property "+itemPath+" in "+focusDefinition+" as specified in object policy"); - } - PropertyDelta propDelta = propDef.createEmptyDelta(itemPath); - if (String.class.isAssignableFrom(propDef.getTypeClass())) { - propDelta.setValueToReplace(prismContext.itemFactory().createPropertyValue(newValue, OriginType.USER_POLICY, null)); - } else if (PolyString.class.isAssignableFrom(propDef.getTypeClass())) { - propDelta.setValueToReplace(prismContext.itemFactory().createPropertyValue(new PolyString(newValue), OriginType.USER_POLICY, null)); - } else { - throw new SchemaException("Unsupported type "+propDef.getTypeName()+" for property "+itemPath+" in "+focusDefinition+" as specified in object policy, only string and polystring properties are supported for OID-bound mode"); - } - focusContext.swallowToSecondaryDelta(propDelta); - focusContext.recompute(); - } - } - } - } - - public static LensContext.ExportType getExportType(TraceType trace, OperationResult result) { - return result.isTracingNormal(trace.getClass()) ? LensContext.ExportType.TRACE : LensContext.ExportType.MINIMAL; - } - - public static LensContext.ExportType getExportTypeTraceOrReduced(TraceType trace, OperationResult result) { - return result.isTracingNormal(trace.getClass()) ? LensContext.ExportType.TRACE : LensContext.ExportType.REDUCED; - } - - public static ItemDelta getAprioriItemDelta(ObjectDelta focusDelta, ItemPath itemPath) { - return focusDelta != null ? focusDelta.findItemDelta(itemPath) : null; - } - - public static String determineExplicitArchetypeOid(PrismObject object) { - String explicitArchetypeOid = null; - // Used in cases where archetype assignment haven't had the change to be processed yet. - // E.g. in case that we are creating a new object with archetype assignment - if (object.canRepresent(AssignmentHolderType.class)) { - AssignmentHolderType assignmentHolderType = (AssignmentHolderType)object.asObjectable(); - List archetypeRefs = assignmentHolderType.getArchetypeRef(); - if (archetypeRefs.isEmpty()) { - explicitArchetypeOid = determineExplicitArchetypeOidFromAssignments(object); - } - } - return explicitArchetypeOid; - } - - public static String determineExplicitArchetypeOidFromAssignments(PrismObject object) { - String explicitArchetypeOid = null; - if (object.canRepresent(AssignmentHolderType.class)) { - for (AssignmentType assignment : ((AssignmentHolderType)object.asObjectable()).getAssignment()) { - ObjectReferenceType targetRef = assignment.getTargetRef(); - if (targetRef != null && QNameUtil.match(ArchetypeType.COMPLEX_TYPE, targetRef.getType())) { - explicitArchetypeOid = targetRef.getOid(); - } - } - } - return explicitArchetypeOid; - } -} +/* + * Copyright (c) 2010-2019 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ +package com.evolveum.midpoint.model.impl.lens; + +import java.util.*; +import java.util.function.Function; +import java.util.function.Supplier; +import java.util.stream.Collectors; + +import javax.xml.datatype.XMLGregorianCalendar; +import javax.xml.namespace.QName; + +import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl; +import com.evolveum.midpoint.model.api.context.EvaluatedPolicyRule; +import com.evolveum.midpoint.model.api.context.EvaluatedPolicyRuleTrigger; +import com.evolveum.midpoint.model.common.mapping.PrismValueDeltaSetTripleProducer; +import com.evolveum.midpoint.prism.path.ItemName; +import com.evolveum.midpoint.prism.path.ItemPath; +import com.evolveum.midpoint.prism.polystring.PolyString; +import com.evolveum.midpoint.prism.util.ItemDeltaItem; +import com.evolveum.midpoint.repo.api.RepositoryService; +import com.evolveum.midpoint.schema.SchemaConstantsGenerated; +import com.evolveum.midpoint.schema.util.*; +import com.evolveum.midpoint.util.DebugUtil; +import com.evolveum.midpoint.util.LocalizableMessage; +import com.evolveum.midpoint.util.QNameUtil; +import com.evolveum.midpoint.util.exception.*; +import com.evolveum.midpoint.util.logging.LoggingUtils; + +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; +import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType; + +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang.BooleanUtils; + +import com.evolveum.midpoint.common.ActivationComputer; +import com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition; +import com.evolveum.midpoint.common.refinery.RefinedResourceSchema; +import com.evolveum.midpoint.model.common.mapping.MappingImpl; +import com.evolveum.midpoint.model.impl.expr.ExpressionEnvironment; +import com.evolveum.midpoint.model.impl.expr.ModelExpressionThreadLocalHolder; +import com.evolveum.midpoint.model.impl.util.ModelImplUtils; +import com.evolveum.midpoint.prism.*; +import com.evolveum.midpoint.prism.delta.ItemDelta; +import com.evolveum.midpoint.prism.delta.ObjectDelta; +import com.evolveum.midpoint.prism.delta.PrismValueDeltaSetTriple; +import com.evolveum.midpoint.prism.delta.PropertyDelta; +import com.evolveum.midpoint.provisioning.api.ProvisioningService; +import com.evolveum.midpoint.repo.common.ObjectResolver; +import com.evolveum.midpoint.repo.common.expression.Expression; +import com.evolveum.midpoint.repo.common.expression.ExpressionEvaluationContext; +import com.evolveum.midpoint.repo.common.expression.ExpressionFactory; +import com.evolveum.midpoint.repo.common.expression.ExpressionUtil; +import com.evolveum.midpoint.repo.common.expression.ExpressionVariables; +import com.evolveum.midpoint.repo.common.expression.Source; +import com.evolveum.midpoint.schema.CapabilityUtil; +import com.evolveum.midpoint.schema.GetOperationOptions; +import com.evolveum.midpoint.schema.ResourceShadowDiscriminator; +import com.evolveum.midpoint.schema.ResultHandler; +import com.evolveum.midpoint.schema.SelectorOptions; +import com.evolveum.midpoint.schema.VirtualAssignmenetSpecification; +import com.evolveum.midpoint.schema.constants.ExpressionConstants; +import com.evolveum.midpoint.schema.constants.SchemaConstants; +import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.util.DOMUtil; +import com.evolveum.midpoint.util.logging.Trace; +import com.evolveum.midpoint.util.logging.TraceManager; +import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; +import org.jetbrains.annotations.NotNull; + +import static com.evolveum.midpoint.util.MiscUtil.getSingleValue; +import static java.util.Collections.emptySet; + +/** + * @author semancik + * + */ +public class LensUtil { + + private static final Trace LOGGER = TraceManager.getTrace(LensUtil.class); + + public static ResourceType getResourceReadOnly(LensContext context, + String resourceOid, ProvisioningService provisioningService, Task task, OperationResult result) throws ObjectNotFoundException, + CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + ResourceType resourceType = context.getResource(resourceOid); + if (resourceType == null) { + // Fetching from provisioning to take advantage of caching and + // pre-parsed schema + Collection> options = SelectorOptions.createCollection(GetOperationOptions.createReadOnly()); + resourceType = provisioningService.getObject(ResourceType.class, resourceOid, options, task, result) + .asObjectable(); + context.rememberResource(resourceType); + } + return resourceType; + } + + @NotNull + static ResourceType getResourceReadOnly(LensContext context, String resourceOid, ObjectResolver objectResolver, + Task task, OperationResult result) throws ObjectNotFoundException, + CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + ResourceType resourceFromContext = context.getResource(resourceOid); + if (resourceFromContext != null) { + return resourceFromContext; + } else { + Collection> options = SelectorOptions.createCollection(GetOperationOptions.createReadOnly()); + ResourceType resourceFetched = objectResolver.getObject(ResourceType.class, resourceOid, options, task, result); + context.rememberResource(resourceFetched); + return resourceFetched; + } + } + + public static String refineProjectionIntent(ShadowKindType kind, String intent, ResourceType resource, PrismContext prismContext) throws SchemaException { + RefinedResourceSchema refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource, LayerType.MODEL, prismContext); + RefinedObjectClassDefinition rObjClassDef = refinedSchema.getRefinedDefinition(kind, intent); + if (rObjClassDef == null) { + LOGGER.error("No projection definition for kind={}, intent={} in {}", kind, intent, resource); + LOGGER.error("Diagnostic output follows:\n\nResource:\n{}\n\nRefined resource schema:\n{}", + resource.asPrismObject().debugDump(), refinedSchema.debugDump()); + throw new SchemaException("No projection definition for kind="+kind+" intent="+intent+" in "+resource); + } + return rObjClassDef.getIntent(); + } + + public static LensProjectionContext getProjectionContext(LensContext context, PrismObject equivalentAccount, + ProvisioningService provisioningService, PrismContext prismContext, + Task task, OperationResult result) throws ObjectNotFoundException, + CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + ShadowType equivalentAccountType = equivalentAccount.asObjectable(); + ShadowKindType kind = ShadowUtil.getKind(equivalentAccountType); + return getProjectionContext(context, ShadowUtil.getResourceOid(equivalentAccountType), + kind, equivalentAccountType.getIntent(), equivalentAccountType.getTag(), provisioningService, + prismContext, task, result); + } + + private static LensProjectionContext getProjectionContext(LensContext context, String resourceOid, + ShadowKindType kind, String intent, String tag, + ProvisioningService provisioningService, PrismContext prismContext, + Task task, OperationResult result) throws ObjectNotFoundException, + CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + ResourceType resource = getResourceReadOnly(context, resourceOid, provisioningService, task, result); + String refinedIntent = refineProjectionIntent(kind, intent, resource, prismContext); + ResourceShadowDiscriminator rsd = new ResourceShadowDiscriminator(resourceOid, kind, refinedIntent, tag, false); + return context.findProjectionContext(rsd); + } + + public static LensProjectionContext getOrCreateProjectionContext(LensContext context, + ResourceShadowDiscriminator rsd) { + LensProjectionContext accountSyncContext = context.findProjectionContext(rsd); + if (accountSyncContext == null) { + accountSyncContext = context.createProjectionContext(rsd); + ResourceType resource = context.getResource(rsd.getResourceOid()); + accountSyncContext.setResource(resource); + } + accountSyncContext.setDoReconciliation(context.isDoReconciliationForAllProjections()); + return accountSyncContext; + } + + public static LensProjectionContext createAccountContext(LensContext context, ResourceShadowDiscriminator rsd){ + return new LensProjectionContext(context, rsd); + } + + public static V cloneAndApplyMetadata(V value, boolean isAssignment, + Collection> origins) throws SchemaException { + return cloneAndApplyMetadata(value, isAssignment, () -> getAutoCreationIdentifier(origins)); + } + +// public static Collection cloneAndApplyMetadata(Collection values, boolean isAssignment, +// MappingType mapping) throws SchemaException { +// List rv = new ArrayList<>(); +// for (V value : values) { +// rv.add(cloneAndApplyMetadata(value, isAssignment, mapping::getName)); +// } +// return rv; +// } + + public static V cloneAndApplyMetadata(V value, boolean isAssignment, + PrismValueDeltaSetTripleProducer mapping) throws SchemaException { + return cloneAndApplyMetadata(value, isAssignment, mapping::getIdentifier); + } + + public static V cloneAndApplyMetadata(V value, boolean isAssignment, + MappingType mapping) throws SchemaException { + return cloneAndApplyMetadata(value, isAssignment, mapping::getName); + } + + private static V cloneAndApplyMetadata(V value, boolean isAssignment, + Supplier originMappingNameSupplier) throws SchemaException { + //noinspection unchecked + V cloned = (V) value.clone(); + if (isAssignment && cloned instanceof PrismContainerValue) { + ((PrismContainerValue) cloned).setId(null); + String originMappingName = originMappingNameSupplier.get(); + LOGGER.trace("cloneAndApplyMetadata: originMappingName = {}", originMappingName); + if (originMappingName != null) { + //noinspection unchecked + PrismContainer metadataContainer = ((PrismContainerValue) cloned).findOrCreateContainer(AssignmentType.F_METADATA); + metadataContainer.getValue().asContainerable().setOriginMappingName(originMappingName); + } + } + return cloned; + } + + private static String getAutoCreationIdentifier(Collection> origins) { + // let's ignore conflicts (name1 vs name2, named vs unnamed) for now + for (ItemValueWithOrigin origin : origins) { + if (origin.getMapping() != null && origin.getMapping().getIdentifier() != null) { + return origin.getMapping().getIdentifier(); + } + } + return null; + } + + public static PropertyDelta createActivationTimestampDelta(ActivationStatusType status, + XMLGregorianCalendar now, + PrismContainerDefinition activationDefinition, OriginType origin, + PrismContext prismContext) { + ItemName timestampPropertyName; + if (status == null || status == ActivationStatusType.ENABLED) { + timestampPropertyName = ActivationType.F_ENABLE_TIMESTAMP; + } else if (status == ActivationStatusType.DISABLED) { + timestampPropertyName = ActivationType.F_DISABLE_TIMESTAMP; + } else if (status == ActivationStatusType.ARCHIVED) { + timestampPropertyName = ActivationType.F_ARCHIVE_TIMESTAMP; + } else { + throw new IllegalArgumentException("Unknown activation status "+status); + } + + PrismPropertyDefinition timestampDef = activationDefinition.findPropertyDefinition(timestampPropertyName); + PropertyDelta timestampDelta + = timestampDef.createEmptyDelta(FocusType.F_ACTIVATION.append(timestampPropertyName)); + timestampDelta.setValueToReplace(prismContext.itemFactory().createPropertyValue(now, origin, null)); + return timestampDelta; + } + + public static void moveTriggers(LensProjectionContext projCtx, LensFocusContext focusCtx) throws SchemaException { + ObjectDelta projSecondaryDelta = projCtx.getSecondaryDelta(); + if (projSecondaryDelta == null) { + return; + } + Collection modifications = projSecondaryDelta.getModifications(); + Iterator iterator = modifications.iterator(); + while (iterator.hasNext()) { + ItemDelta projModification = iterator.next(); + LOGGER.trace("MOD: {}\n{}", projModification.getPath(), projModification.debugDumpLazily()); + if (projModification.getPath().equivalent(SchemaConstants.PATH_TRIGGER)) { + focusCtx.swallowToProjectionWaveSecondaryDelta(projModification); + iterator.remove(); + } + } + } + + public static Object getIterationVariableValue(LensProjectionContext accCtx) { + Integer iterationOld = null; + PrismObject shadowCurrent = accCtx.getObjectCurrent(); + if (shadowCurrent != null) { + iterationOld = shadowCurrent.asObjectable().getIteration(); + } + if (iterationOld == null) { + return accCtx.getIteration(); + } + PrismPropertyDefinition propDef = accCtx.getPrismContext().definitionFactory().createPropertyDefinition(ExpressionConstants.VAR_ITERATION_QNAME, + DOMUtil.XSD_INT); + PrismProperty propOld = propDef.instantiate(); + propOld.setRealValue(iterationOld); + PropertyDelta propDelta = propDef.createEmptyDelta(ExpressionConstants.VAR_ITERATION_QNAME); + propDelta.setRealValuesToReplace(accCtx.getIteration()); + PrismProperty propNew = propDef.instantiate(); + propNew.setRealValue(accCtx.getIteration()); + ItemDeltaItem,PrismPropertyDefinition> idi = new ItemDeltaItem<>(propOld, propDelta, propNew, propDef); + return idi; + } + + public static Object getIterationTokenVariableValue(LensProjectionContext accCtx) { + String iterationTokenOld = null; + PrismObject shadowCurrent = accCtx.getObjectCurrent(); + if (shadowCurrent != null) { + iterationTokenOld = shadowCurrent.asObjectable().getIterationToken(); + } + if (iterationTokenOld == null) { + return accCtx.getIterationToken(); + } + PrismPropertyDefinition propDef = accCtx.getPrismContext().definitionFactory().createPropertyDefinition( + ExpressionConstants.VAR_ITERATION_TOKEN_QNAME, DOMUtil.XSD_STRING); + PrismProperty propOld = propDef.instantiate(); + propOld.setRealValue(iterationTokenOld); + PropertyDelta propDelta = propDef.createEmptyDelta(ExpressionConstants.VAR_ITERATION_TOKEN_QNAME); + propDelta.setRealValuesToReplace(accCtx.getIterationToken()); + PrismProperty propNew = propDef.instantiate(); + propNew.setRealValue(accCtx.getIterationToken()); + ItemDeltaItem,PrismPropertyDefinition> idi = new ItemDeltaItem<>(propOld, propDelta, propNew, propDef); + return idi; + } + + /** + * Extracts the delta from this projection context and also from all other projection contexts that have + * equivalent discriminator. + */ + public static PropertyDelta findAPrioriDelta(LensContext context, + LensProjectionContext projCtx, ItemPath projectionPropertyPath) throws SchemaException { + PropertyDelta aPrioriDelta = null; + for (LensProjectionContext aProjCtx: findRelatedContexts(context, projCtx)) { + ObjectDelta aProjDelta = aProjCtx.getDelta(); + if (aProjDelta != null) { + PropertyDelta aPropProjDelta = aProjDelta.findPropertyDelta(projectionPropertyPath); + if (aPropProjDelta != null) { + if (aPrioriDelta == null) { + aPrioriDelta = aPropProjDelta.clone(); + } else { + aPrioriDelta.merge(aPropProjDelta); + } + } + } + } + return aPrioriDelta; + } + + /** + * Extracts the delta from this projection context and also from all other projection contexts that have + * equivalent discriminator. + */ + public static ObjectDelta findAPrioriDelta(LensContext context, + LensProjectionContext projCtx) throws SchemaException { + ObjectDelta aPrioriDelta = null; + for (LensProjectionContext aProjCtx: findRelatedContexts(context, projCtx)) { + ObjectDelta aProjDelta = aProjCtx.getDelta(); + if (aProjDelta != null) { + if (aPrioriDelta == null) { + aPrioriDelta = aProjDelta.clone(); + } else { + aPrioriDelta.merge(aProjDelta); + } + } + } + return aPrioriDelta; + } + + /** + * Returns a list of context that have equivalent discriminator with the reference context. Ordered by "order" in the + * discriminator. + */ + public static List findRelatedContexts( + LensContext context, LensProjectionContext refProjCtx) { + List projCtxs = new ArrayList<>(); + ResourceShadowDiscriminator refDiscr = refProjCtx.getResourceShadowDiscriminator(); + if (refDiscr == null) { + return projCtxs; + } + for (LensProjectionContext aProjCtx: context.getProjectionContexts()) { + ResourceShadowDiscriminator aDiscr = aProjCtx.getResourceShadowDiscriminator(); + if (refDiscr.equivalent(aDiscr)) { + projCtxs.add(aProjCtx); + } + } + Comparator orderComparator = new Comparator() { + @Override + public int compare(LensProjectionContext ctx1, LensProjectionContext ctx2) { + int order1 = ctx1.getResourceShadowDiscriminator().getOrder(); + int order2 = ctx2.getResourceShadowDiscriminator().getOrder(); + return Integer.compare(order1, order2); + } + }; + Collections.sort(projCtxs, orderComparator); + return projCtxs; + } + + public static boolean hasLowerOrderContext(LensContext context, + LensProjectionContext refProjCtx) { + ResourceShadowDiscriminator refDiscr = refProjCtx.getResourceShadowDiscriminator(); + for (LensProjectionContext aProjCtx: context.getProjectionContexts()) { + ResourceShadowDiscriminator aDiscr = aProjCtx.getResourceShadowDiscriminator(); + if (refDiscr.equivalent(aDiscr) && (refDiscr.getOrder() > aDiscr.getOrder())) { + return true; + } + } + return false; + } + + public static boolean hasDependentContext(LensContext context, + LensProjectionContext targetProjectionContext) { + for (LensProjectionContext projectionContext: context.getProjectionContexts()) { + for (ResourceObjectTypeDependencyType dependency: projectionContext.getDependencies()) { + if (isDependencyTargetContext(projectionContext, targetProjectionContext, dependency)) { + return true; + } + } + } + return false; + } + + public static boolean isDependencyTargetContext(LensProjectionContext sourceProjContext, LensProjectionContext targetProjectionContext, ResourceObjectTypeDependencyType dependency) { + ResourceShadowDiscriminator refDiscr = new ResourceShadowDiscriminator(dependency, + sourceProjContext.getResource().getOid(), sourceProjContext.getKind()); + return targetProjectionContext.compareResourceShadowDiscriminator(refDiscr, false); + } + + public static LensProjectionContext findLowerOrderContext(LensContext context, + LensProjectionContext refProjCtx) { + int minOrder = -1; + LensProjectionContext foundCtx = null; + ResourceShadowDiscriminator refDiscr = refProjCtx.getResourceShadowDiscriminator(); + for (LensProjectionContext aProjCtx: context.getProjectionContexts()) { + ResourceShadowDiscriminator aDiscr = aProjCtx.getResourceShadowDiscriminator(); + if (refDiscr.equivalent(aDiscr) && (refDiscr.getOrder() > aDiscr.getOrder())) { + if (minOrder < 0 || (aDiscr.getOrder() < minOrder)) { + minOrder = aDiscr.getOrder(); + foundCtx = aProjCtx; + } + } + } + return foundCtx; + } + + public static void setContextOid(LensContext context, + LensElementContext objectContext, String oid) { + objectContext.setOid(oid); + // Check if we need to propagate this oid also to higher-order contexts + if (!(objectContext instanceof LensProjectionContext)) { + return; + } + LensProjectionContext refProjCtx = (LensProjectionContext)objectContext; + ResourceShadowDiscriminator refDiscr = refProjCtx.getResourceShadowDiscriminator(); + if (refDiscr == null) { + return; + } + for (LensProjectionContext aProjCtx: context.getProjectionContexts()) { + ResourceShadowDiscriminator aDiscr = aProjCtx.getResourceShadowDiscriminator(); + if (aDiscr != null && refDiscr.equivalent(aDiscr) && (refDiscr.getOrder() < aDiscr.getOrder())) { + aProjCtx.setOid(oid); + } + } + } + + public static PrismObjectDefinition getFocusDefinition(LensContext context) { + LensFocusContext focusContext = context.getFocusContext(); + if (focusContext == null) { + return null; + } + Class typeClass = focusContext.getObjectTypeClass(); + return context.getPrismContext().getSchemaRegistry().findObjectDefinitionByCompileTimeClass(typeClass); + } + + public static IterationSpecificationType getIterationSpecification(ObjectTemplateType objectTemplate) { + return objectTemplate != null ? objectTemplate.getIterationSpecification() : null; + } + + public static int determineMaxIterations(IterationSpecificationType iterationSpecType) { + return iterationSpecType != null ? iterationSpecType.getMaxIterations() : 0; + } + + public static String formatIterationToken(LensContext context, + LensElementContext accountContext, IterationSpecificationType iterationType, + int iteration, ExpressionFactory expressionFactory, ExpressionVariables variables, + Task task, OperationResult result) + throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { + if (iterationType == null) { + return formatIterationTokenDefault(iteration); + } + ExpressionType tokenExpressionType = iterationType.getTokenExpression(); + if (tokenExpressionType == null) { + return formatIterationTokenDefault(iteration); + } + PrismContext prismContext = context.getPrismContext(); + PrismPropertyDefinition outputDefinition = prismContext.definitionFactory().createPropertyDefinition(ExpressionConstants.VAR_ITERATION_TOKEN_QNAME, + DOMUtil.XSD_STRING); + Expression,PrismPropertyDefinition> expression = expressionFactory.makeExpression(tokenExpressionType, outputDefinition, MiscSchemaUtil.getExpressionProfile(), "iteration token expression in "+accountContext.getHumanReadableName(), task, result); + + Collection> sources = new ArrayList<>(); + MutablePrismPropertyDefinition inputDefinition = prismContext.definitionFactory().createPropertyDefinition(ExpressionConstants.VAR_ITERATION_QNAME, + DOMUtil.XSD_INT); + inputDefinition.setMaxOccurs(1); + PrismProperty input = inputDefinition.instantiate(); + input.addRealValue(iteration); + ItemDeltaItem,PrismPropertyDefinition> idi = new ItemDeltaItem<>(input); + Source,PrismPropertyDefinition> iterationSource = new Source<>(idi, ExpressionConstants.VAR_ITERATION_QNAME); + sources.add(iterationSource); + + ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources , variables, + "iteration token expression in "+accountContext.getHumanReadableName(), task); + PrismValueDeltaSetTriple> outputTriple = ModelExpressionThreadLocalHolder.evaluateExpressionInContext(expression, expressionContext, task, result); + Collection> outputValues = outputTriple.getNonNegativeValues(); + if (outputValues.isEmpty()) { + return ""; + } + if (outputValues.size() > 1) { + throw new ExpressionEvaluationException("Iteration token expression in "+accountContext.getHumanReadableName()+" returned more than one value ("+outputValues.size()+" values)"); + } + String realValue = outputValues.iterator().next().getValue(); + if (realValue == null) { + return ""; + } + return realValue; + } + + public static String formatIterationTokenDefault(int iteration) { + if (iteration == 0) { + return ""; + } + return Integer.toString(iteration); + } + + public static boolean evaluateIterationCondition(LensContext context, + LensElementContext accountContext, IterationSpecificationType iterationType, + int iteration, String iterationToken, boolean beforeIteration, + ExpressionFactory expressionFactory, ExpressionVariables variables, Task task, OperationResult result) + throws ExpressionEvaluationException, SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException { + if (iterationType == null) { + return true; + } + ExpressionType expressionType; + String desc; + if (beforeIteration) { + expressionType = iterationType.getPreIterationCondition(); + desc = "pre-iteration expression in "+accountContext.getHumanReadableName(); + } else { + expressionType = iterationType.getPostIterationCondition(); + desc = "post-iteration expression in "+accountContext.getHumanReadableName(); + } + if (expressionType == null) { + return true; + } + Expression,PrismPropertyDefinition> expression = expressionFactory.makeExpression( + expressionType, ExpressionUtil.createConditionOutputDefinition(context.getPrismContext()), MiscSchemaUtil.getExpressionProfile(), + desc, task, result); + + variables.put(ExpressionConstants.VAR_ITERATION, iteration, Integer.class); + variables.put(ExpressionConstants.VAR_ITERATION_TOKEN, iterationToken, String.class); + + ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(null , variables, desc, task); + ExpressionEnvironment env = new ExpressionEnvironment<>(context, null, task, result); + PrismValueDeltaSetTriple> outputTriple = + ModelExpressionThreadLocalHolder.evaluateExpressionInContext(expression, expressionContext, env, result); + Collection> outputValues = outputTriple.getNonNegativeValues(); + if (outputValues.isEmpty()) { + return false; + } + if (outputValues.size() > 1) { + throw new ExpressionEvaluationException(desc+" returned more than one value ("+outputValues.size()+" values)"); + } + Boolean realValue = outputValues.iterator().next().getValue(); + if (realValue == null) { + return false; + } + return realValue; + + } + + /** + * Used for assignments and similar objects that do not have separate lifecycle. + */ + public static boolean isAssignmentValid(AssignmentHolderType focus, AssignmentType assignmentType, XMLGregorianCalendar now, + ActivationComputer activationComputer, LifecycleStateModelType focusStateModel) { + ObjectReferenceType targetRef = assignmentType.getTargetRef(); + if (targetRef != null) { + if (QNameUtil.match(ArchetypeType.COMPLEX_TYPE, targetRef.getType())) { + // Archetype assignments are always valid, even in non-valid lifecycle states. + // The object cannot lose its (arche)type. + return true; + } + } + String focusLifecycleState = focus.getLifecycleState(); + + if (!activationComputer.lifecycleHasActiveAssignments(focusLifecycleState, focusStateModel)) { + return false; + } + return isValid(assignmentType.getLifecycleState(), assignmentType.getActivation(), now, activationComputer, focusStateModel); + } + + public static Collection getForcedAssignments(LifecycleStateModelType lifecycleModel, String targetLifecycle, + ObjectResolver objectResolver, PrismContext prismContext, Task task, OperationResult result) throws SchemaException, + ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + VirtualAssignmenetSpecification virtualAssignmenetSpecification = LifecycleUtil.getForcedAssignmentSpecification(lifecycleModel, targetLifecycle, prismContext); + + Collection forcedAssignments = new HashSet<>(); + if (virtualAssignmenetSpecification != null) { + + ResultHandler handler = (object, parentResult) -> { + AssignmentType assignment = ObjectTypeUtil.createAssignmentTo(object, prismContext); + return forcedAssignments.add(assignment); + }; + + objectResolver.searchIterative(virtualAssignmenetSpecification.getType(), + prismContext.queryFactory().createQuery(virtualAssignmenetSpecification.getFilter()), null, handler, task, result); + + } + + return forcedAssignments; + } + + public static boolean isFocusValid(AssignmentHolderType focus, XMLGregorianCalendar now, ActivationComputer activationComputer, LifecycleStateModelType focusStateModel) { + if (FocusType.class.isAssignableFrom(focus.getClass())) { + return isValid(focus.getLifecycleState(), ((FocusType) focus).getActivation(), now, activationComputer, focusStateModel); + } + return isValid(focus.getLifecycleState(), null, now, activationComputer, focusStateModel); + } + + private static boolean isValid(String lifecycleState, ActivationType activationType, XMLGregorianCalendar now, ActivationComputer activationComputer, LifecycleStateModelType focusStateModel) { + TimeIntervalStatusType validityStatus = activationComputer.getValidityStatus(activationType, now); + ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus(lifecycleState, activationType, validityStatus, focusStateModel); + return effectiveStatus == ActivationStatusType.ENABLED; + } + + public static AssignmentPathVariables computeAssignmentPathVariables(AssignmentPathImpl assignmentPath) throws SchemaException { + if (assignmentPath == null || assignmentPath.isEmpty()) { + return null; + } + AssignmentPathVariables vars = new AssignmentPathVariables(); + vars.setAssignmentPath(assignmentPath.clone()); + + Iterator iterator = assignmentPath.getSegments().iterator(); + while (iterator.hasNext()) { + AssignmentPathSegmentImpl segment = iterator.next(); + ItemDeltaItem,PrismContainerDefinition> segmentAssignmentIdi = segment.getAssignmentIdi(); + + ItemDeltaItem,PrismContainerDefinition> magicAssignmentIdi; + // Magic assignment + if (vars.getMagicAssignment() == null) { + magicAssignmentIdi = segmentAssignmentIdi.clone(); + vars.setMagicAssignment(magicAssignmentIdi); + } else { + // Collect extension values from the assignment extension + magicAssignmentIdi = vars.getMagicAssignment(); + mergeExtension(magicAssignmentIdi, segmentAssignmentIdi); + } + + // Collect extension values from the source object extension + ObjectType segmentSource = segment.getSource(); + if (segmentSource != null) { + mergeExtension(magicAssignmentIdi, segmentSource.asPrismObject()); + } + + // immediate assignment (use assignment from previous iteration) + vars.setImmediateAssignment(vars.getThisAssignment()); + + // this assignment + ItemDeltaItem,PrismContainerDefinition> thisAssignment = segmentAssignmentIdi.clone(); + vars.setThisAssignment(thisAssignment); + + if (iterator.hasNext() && segmentSource instanceof AbstractRoleType) { + vars.setImmediateRole((PrismObject) segmentSource.asPrismObject()); + } + } + + AssignmentPathSegmentImpl focusAssignmentSegment = assignmentPath.first(); + vars.setFocusAssignment(focusAssignmentSegment.getAssignmentIdi().clone()); + + // a bit of hack -- TODO reconsider in 3.7 + // objects are already cloned + convertToLegacy(vars.getMagicAssignment()); + convertToLegacy(vars.getThisAssignment()); + convertToLegacy(vars.getFocusAssignment()); + convertToLegacy(vars.getImmediateAssignment()); + + return vars; + } + + private static void convertToLegacy( + ItemDeltaItem, PrismContainerDefinition> idi) { + if (idi == null || idi.getDelta() == null || idi.getSubItemDeltas() != null) { + return; + } + // Legacy approach (when adding/removing assignments) was: itemOld+itemNew = value, delta = null + // This was recently changed, to provide precise information (add = null->itemNew, delete = itemOld->null). + // However, to not break scripts before 3.6 release we provide imitation of old behavior here. + // (Moreover, for magic assignment the delta is not correct anyway.) + if (idi.getDelta().isAdd() || idi.getDelta().isReplace()) { + idi.setItemOld(idi.getItemNew().clone()); + } else { + idi.setItemNew(idi.getItemOld().clone()); + } + idi.setDelta(null); + } + + private static void mergeExtension(ItemDeltaItem,PrismContainerDefinition> destIdi, ItemDeltaItem,PrismContainerDefinition> srcIdi) throws SchemaException { + mergeExtension(destIdi.getItemOld(), srcIdi.getItemOld()); + mergeExtension(destIdi.getItemNew(), srcIdi.getItemNew()); + if (srcIdi.getDelta() != null || srcIdi.getSubItemDeltas() != null) { + throw new UnsupportedOperationException("Merge of IDI with deltas not supported"); + } + } + + private static void mergeExtension(Item,PrismContainerDefinition> dstItem, + Item,PrismContainerDefinition> srcItem) throws SchemaException { + if (srcItem == null || dstItem == null) { + return; + } + PrismContainer srcExtension = ((PrismContainer)srcItem).findContainer(AssignmentType.F_EXTENSION); + mergeExtensionContainers(dstItem, srcExtension); + } + + private static void mergeExtension(ItemDeltaItem,PrismContainerDefinition> destIdi, + PrismObject srcObject) throws SchemaException { + if (srcObject == null) { + return; + } + + PrismContainer srcExtension = srcObject.findContainer(ObjectType.F_EXTENSION); + + mergeExtensionContainers(destIdi.getItemNew(), srcExtension); + mergeExtensionContainers(destIdi.getItemOld(), srcExtension); + } + + private static void mergeExtensionContainers(Item,PrismContainerDefinition> dstItem, PrismContainer srcExtension) throws SchemaException { + if (dstItem == null) { + return; + } + PrismContainer dstContainer = (PrismContainer) dstItem; + if (srcExtension != null && !srcExtension.isEmpty()) { + PrismContainer dstExtensionContainer = dstContainer.findOrCreateContainer(AssignmentType.F_EXTENSION); + PrismContainerValue dstExtensionContainerValue = dstExtensionContainer.getValues().isEmpty() + ? dstExtensionContainer.createNewValue() : dstExtensionContainer.getValue(); + ObjectTypeUtil.mergeExtension(dstExtensionContainerValue, srcExtension.getValue()); + } + } + + public static MappingImpl.Builder addAssignmentPathVariables(MappingImpl.Builder builder, AssignmentPathVariables assignmentPathVariables, PrismContext prismContext) { + ExpressionVariables expressionVariables = new ExpressionVariables(); + ModelImplUtils.addAssignmentPathVariables(assignmentPathVariables, expressionVariables, prismContext); + return builder.addVariableDefinitions(expressionVariables); + } + + public static void checkContextSanity(LensContext context, String activityDescription, + OperationResult result) throws SchemaException, PolicyViolationException { + LensFocusContext focusContext = context.getFocusContext(); + if (focusContext != null) { + PrismObject focusObjectNew = focusContext.getObjectNew(); + if (focusObjectNew != null) { + PolyStringType namePolyType = focusObjectNew.asObjectable().getName(); + if (namePolyType == null) { + throw new SchemaException("Focus "+focusObjectNew+" does not have a name after "+activityDescription); + } + ArchetypePolicyType archetypePolicy = focusContext.getArchetypePolicyType(); + checkArchetypePolicy(focusContext, archetypePolicy); + } + } + } + + private static void checkArchetypePolicy(LensFocusContext focusContext, ArchetypePolicyType archetypePolicy) throws SchemaException, PolicyViolationException { + if (archetypePolicy == null) { + return; + } + PrismObject focusObjectNew = focusContext.getObjectNew(); + ObjectDelta focusDelta = focusContext.getDelta(); + + for (ItemConstraintType itemConstraintType : archetypePolicy.getItemConstraint()) { + processItemConstraint(focusContext, focusDelta, focusObjectNew, itemConstraintType); + } + // Deprecated + for (ItemConstraintType itemConstraintType : archetypePolicy.getPropertyConstraint()) { + processItemConstraint(focusContext, focusDelta, focusObjectNew, itemConstraintType); + } + + } + + private static void processItemConstraint(LensFocusContext focusContext, ObjectDelta focusDelta, PrismObject focusObjectNew, ItemConstraintType itemConstraintType) throws PolicyViolationException { + ItemPath itemPath = itemConstraintType.getPath().getItemPath(); + if (BooleanUtils.isTrue(itemConstraintType.isOidBound())) { + if (focusDelta != null) { + if (focusDelta.isAdd()) { + PrismProperty propNew = focusObjectNew.findProperty(itemPath); + if (propNew != null) { + // prop delta is OK, but it has to match + if (focusObjectNew.getOid() != null) { + if (!focusObjectNew.getOid().equals(propNew.getRealValue().toString())) { + throw new PolicyViolationException("Cannot set "+itemPath+" to a value different than OID in oid bound mode"); + } + } + } + } else { + PropertyDelta nameDelta = focusDelta.findPropertyDelta(itemPath); + if (nameDelta != null) { + if (nameDelta.isReplace()) { + Collection> valuesToReplace = nameDelta.getValuesToReplace(); + if (valuesToReplace.size() == 1) { + String stringValue = valuesToReplace.iterator().next().getValue().toString(); + if (focusContext.getOid().equals(stringValue)) { + // This is OK. It is most likely a correction made by a recompute. + return; + } + } + } + throw new PolicyViolationException("Cannot change "+itemPath+" in oid bound mode"); + } + } + } + } + + } + + public static PrismContainer createAssignmentSingleValueContainer(@NotNull AssignmentType assignmentType) throws SchemaException { + // Make it appear to be single-value. Therefore paths without segment IDs will work. + return assignmentType.asPrismContainerValue().asSingleValuedContainer(SchemaConstantsGenerated.C_ASSIGNMENT); + } + + public static AssignmentType getAssignmentType(ItemDeltaItem,PrismContainerDefinition> assignmentIdi, boolean old) { + return PrismContainerValue.asContainerable(assignmentIdi.getSingleValue(old)); + } + + + public static String getChannel(LensContext context, Task task) { + if (context != null && context.getChannel() != null){ + return context.getChannel(); + } else if (task.getChannel() != null){ + return task.getChannel(); + } + return null; + } + + public static void setDeltaOldValue(LensElementContext ctx, ItemDelta itemDelta) { + if (itemDelta.getEstimatedOldValues() != null) { + return; + } + if (ctx.getObjectOld() == null) { + return; + } + Item itemOld = ctx.getObjectOld().findItem(itemDelta.getPath()); + if (itemOld != null) { + //noinspection unchecked + itemDelta.setEstimatedOldValues((Collection) PrismValueCollectionsUtil.cloneCollection(itemOld.getValues())); + return; + } + // Here we need to distinguish whether the item is missing because it is not filled in (e.g. familyName in MID-4237) + // or because it was not loaded (as for attributes or associations). + if (!isItemLoadable(ctx.getObjectOld(), itemDelta.getPath())) { + itemDelta.setEstimatedOldValues(emptySet()); + return; + } + // get the old data from current object. Still better estimate than nothing + if (ctx.getObjectCurrent() != null) { + itemOld = ctx.getObjectCurrent().findItem(itemDelta.getPath()); + if (itemOld != null) { + //noinspection unchecked + itemDelta.setEstimatedOldValues((Collection) PrismValueCollectionsUtil.cloneCollection(itemOld.getValues())); + } + } + } + + // a heuristic by now + private static boolean isItemLoadable(PrismObject object, ItemPath path) { + if (!(object.asObjectable() instanceof ShadowType)) { + return false; + } + return path.startsWithName(ShadowType.F_ATTRIBUTES) || path.startsWithName(ShadowType.F_ASSOCIATION); + } + + public static void setDeltaOldValue(LensElementContext ctx, ObjectDelta objectDelta) { + if (objectDelta == null) { + return; + } + if (!objectDelta.isModify()) { + return; + } + for (ItemDelta modification: objectDelta.getModifications()) { + setDeltaOldValue(ctx, modification); + } + } + + public static LensObjectDeltaOperation createObjectDeltaOperation(ObjectDelta focusDelta, OperationResult result, + LensElementContext focusContext, LensProjectionContext projCtx) { + return createObjectDeltaOperation(focusDelta, result, focusContext, projCtx, null); + } + + // projCtx may or may not be present (object itself can be focus or projection) + public static LensObjectDeltaOperation createObjectDeltaOperation(ObjectDelta objectDelta, OperationResult result, + LensElementContext objectContext, + LensProjectionContext projCtx, + ResourceType resource) { + LensObjectDeltaOperation objectDeltaOp = new LensObjectDeltaOperation<>(objectDelta.clone()); + objectDeltaOp.setExecutionResult(result); + PrismObject object = objectContext.getObjectAny(); + if (object != null) { + PolyString name = object.getName(); + if (name == null && object.asObjectable() instanceof ShadowType) { + try { + name = ShadowUtil.determineShadowName((PrismObject) object); + if (name == null) { + LOGGER.debug("No name for shadow:\n{}", object.debugDump()); + } else if (name.getNorm() == null) { + name.recompute(objectContext.getPrismContext().getDefaultPolyStringNormalizer()); + } + } catch (SchemaException e) { + LoggingUtils.logUnexpectedException(LOGGER, "Couldn't determine name for shadow -- continuing with no name; shadow:\n{}", e, object.debugDump()); + } + } + objectDeltaOp.setObjectName(name); + } + if (resource == null && projCtx != null) { + resource = projCtx.getResource(); + } + if (resource != null) { + objectDeltaOp.setResourceOid(resource.getOid()); + objectDeltaOp.setResourceName(PolyString.toPolyString(resource.getName())); + } else if (objectContext instanceof LensProjectionContext) { + objectDeltaOp.setResourceOid(((LensProjectionContext) objectContext).getResourceOid()); + } + return objectDeltaOp; + } + + public static void triggerRule(@NotNull EvaluatedPolicyRule rule, Collection> triggers, + Collection policySituations) { + + LOGGER.debug("Policy rule {} triggered: {}", rule.getName(), triggers); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Policy rule {} triggered:\n{}", rule.getName(), DebugUtil.debugDump(triggers, 1)); + } + + ((EvaluatedPolicyRuleImpl) rule).addTriggers(triggers); + CollectionUtils.addIgnoreNull(policySituations, rule.getPolicySituation()); + } + + public static void processRuleWithException(@NotNull EvaluatedPolicyRule rule, Collection> triggers, + PolicyExceptionType policyException) { + + LOGGER.debug("Policy rule {} would be triggered, but there is an exception for it. Not triggering", rule.getName()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Policy rule {} would be triggered, but there is an exception for it:\nTriggers:\n{}\nException:\n{}", + rule.getName(), DebugUtil.debugDump(triggers, 1), policyException); + } + ((EvaluatedPolicyRuleImpl)rule).addPolicyException(policyException); + } + + + public static void checkMaxIterations(int iteration, int maxIterations, String conflictMessage, String humanReadableName) + throws ObjectAlreadyExistsException { + if (iteration > maxIterations) { + StringBuilder sb = new StringBuilder(); + if (iteration == 1) { + sb.append("Error processing "); + } else { + sb.append("Too many iterations (").append(iteration).append(") for "); + } + sb.append(humanReadableName); + if (iteration == 1) { + sb.append(": constraint violation: "); + } else { + sb.append(": cannot determine values that satisfy constraints: "); + } + if (conflictMessage != null) { + sb.append(conflictMessage); + } + throw new ObjectAlreadyExistsException(sb.toString()); + } + } + + public static boolean needsFullShadowForCredentialProcessing(LensProjectionContext projCtx) throws SchemaException { + RefinedObjectClassDefinition refinedProjDef = projCtx.getStructuralObjectClassDefinition(); + if (refinedProjDef == null) { + return false; + } + + List outboundMappingType = refinedProjDef.getPasswordOutbound(); + if (outboundMappingType == null) { + return false; + } + for (MappingType mappingType: outboundMappingType) { + if (mappingType.getStrength() == MappingStrengthType.STRONG || mappingType.getStrength() == MappingStrengthType.WEAK) { + return true; + } + } + return false; + } + + public static boolean isPasswordReturnedByDefault(LensProjectionContext projCtx) { + CredentialsCapabilityType credentialsCapabilityType = ResourceTypeUtil.getEffectiveCapability(projCtx.getResource(), CredentialsCapabilityType.class); + return CapabilityUtil.isPasswordReturnedByDefault(credentialsCapabilityType); + } + + public static boolean evaluateBoolean(ExpressionType expressionBean, ExpressionVariables expressionVariables, + String contextDescription, ExpressionFactory expressionFactory, PrismContext prismContext, Task task, + OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { + return evaluateExpressionSingle(expressionBean, expressionVariables, contextDescription, expressionFactory, prismContext, + task, result, + DOMUtil.XSD_BOOLEAN, false, null); + } + + public static String evaluateString(ExpressionType expressionBean, ExpressionVariables expressionVariables, + String contextDescription, ExpressionFactory expressionFactory, PrismContext prismContext, Task task, + OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { + return evaluateExpressionSingle(expressionBean, expressionVariables, contextDescription, expressionFactory, prismContext, + task, result, + DOMUtil.XSD_STRING, null, null); + } + + public static LocalizableMessageType evaluateLocalizableMessageType(ExpressionType expressionBean, ExpressionVariables expressionVariables, + String contextDescription, ExpressionFactory expressionFactory, PrismContext prismContext, Task task, + OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { + Function additionalConvertor = (o) -> { + if (o == null || o instanceof LocalizableMessageType) { + return o; + } else if (o instanceof LocalizableMessage) { + return LocalizationUtil.createLocalizableMessageType((LocalizableMessage) o); + } else { + return new SingleLocalizableMessageType().fallbackMessage(String.valueOf(o)); + } + }; + return evaluateExpressionSingle(expressionBean, expressionVariables, contextDescription, expressionFactory, prismContext, + task, result, LocalizableMessageType.COMPLEX_TYPE, null, additionalConvertor); + } + + public static T evaluateExpressionSingle(ExpressionType expressionBean, ExpressionVariables expressionVariables, + String contextDescription, ExpressionFactory expressionFactory, PrismContext prismContext, Task task, + OperationResult result, QName typeName, + T defaultValue, Function additionalConvertor) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { + PrismPropertyDefinition resultDef = prismContext.definitionFactory().createPropertyDefinition( + new QName(SchemaConstants.NS_C, "result"), typeName); + Expression,PrismPropertyDefinition> expression = + expressionFactory.makeExpression(expressionBean, resultDef, MiscSchemaUtil.getExpressionProfile(), contextDescription, task, result); + ExpressionEvaluationContext eeContext = new ExpressionEvaluationContext(null, expressionVariables, contextDescription, task); + eeContext.setAdditionalConvertor(additionalConvertor); + PrismValueDeltaSetTriple> exprResultTriple = ModelExpressionThreadLocalHolder + .evaluateExpressionInContext(expression, eeContext, task, result); + List results = exprResultTriple.getZeroSet().stream() + .map(ppv -> (T) ppv.getRealValue()) + .collect(Collectors.toList()); + return getSingleValue(results, defaultValue, contextDescription); + } + + @NotNull + public static SingleLocalizableMessageType interpretLocalizableMessageTemplate(LocalizableMessageTemplateType template, + ExpressionVariables var, ExpressionFactory expressionFactory, PrismContext prismContext, + Task task, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, + ConfigurationException, SecurityViolationException { + SingleLocalizableMessageType rv = new SingleLocalizableMessageType(); + if (template.getKey() != null) { + rv.setKey(template.getKey()); + } else if (template.getKeyExpression() != null) { + rv.setKey(evaluateString(template.getKeyExpression(), var, "localizable message key expression", expressionFactory, prismContext, task, result)); + } + if (!template.getArgument().isEmpty() && !template.getArgumentExpression().isEmpty()) { + throw new IllegalArgumentException("Both argument and argumentExpression items are non empty"); + } else if (!template.getArgumentExpression().isEmpty()) { + for (ExpressionType argumentExpression : template.getArgumentExpression()) { + LocalizableMessageType argument = evaluateLocalizableMessageType(argumentExpression, var, + "localizable message argument expression", expressionFactory, prismContext, task, result); + rv.getArgument().add(new LocalizableMessageArgumentType().localizable(argument)); + } + } else { + // TODO allow localizable messages templates here + rv.getArgument().addAll(template.getArgument()); + } + if (template.getFallbackMessage() != null) { + rv.setFallbackMessage(template.getFallbackMessage()); + } else if (template.getFallbackMessageExpression() != null) { + rv.setFallbackMessage(evaluateString(template.getFallbackMessageExpression(), var, + "localizable message fallback expression", expressionFactory, prismContext, task, result)); + } + return rv; + } + + public static void reclaimSequences(LensContext context, RepositoryService repositoryService, Task task, OperationResult result) throws SchemaException { + if (context == null) { + return; + } + + Map sequenceMap = context.getSequences(); + LOGGER.trace("Context sequence map: {}", sequenceMap); + for (Map.Entry sequenceMapEntry: sequenceMap.entrySet()) { + Collection unusedValues = new ArrayList<>(1); + unusedValues.add(sequenceMapEntry.getValue()); + try { + LOGGER.trace("Returning value {} to sequence {}", sequenceMapEntry.getValue(), sequenceMapEntry.getKey()); + repositoryService.returnUnusedValuesToSequence(sequenceMapEntry.getKey(), unusedValues, result); + } catch (ObjectNotFoundException e) { + LOGGER.error("Cannot return unused value to sequence {}: it does not exist", sequenceMapEntry.getKey(), e); + // ... but otherwise ignore it and go on + } + } + } + + public static void applyObjectPolicyConstraints(LensFocusContext focusContext, ArchetypePolicyType archetypePolicy, PrismContext prismContext) throws SchemaException, ConfigurationException { + if (archetypePolicy == null) { + return; + } + + final PrismObject focusNew = focusContext.getObjectNew(); + if (focusNew == null) { + // This is delete. Nothing to do. + return; + } + + for (ItemConstraintType itemConstraintType : archetypePolicy.getItemConstraint()) { + applyObjectPolicyItemConstraint(focusContext, archetypePolicy, prismContext, focusNew, itemConstraintType); + } + // Deprecated + for (ItemConstraintType itemConstraintType : archetypePolicy.getPropertyConstraint()) { + applyObjectPolicyItemConstraint(focusContext, archetypePolicy, prismContext, focusNew, itemConstraintType); + } + } + + private static void applyObjectPolicyItemConstraint(LensFocusContext focusContext, ArchetypePolicyType archetypePolicy, PrismContext prismContext, PrismObject focusNew, ItemConstraintType itemConstraintType) throws SchemaException, ConfigurationException { + if (itemConstraintType.getPath() == null) { + LOGGER.error("Invalid configuration. Path is mandatory for property constraint definition in {} defined in system configuration", archetypePolicy); + throw new SchemaException("Invalid configuration. Path is mandatory for property constraint definition in " + archetypePolicy + " defined in system configuration."); + } + ItemPath itemPath = itemConstraintType.getPath().getItemPath(); + if (BooleanUtils.isTrue(itemConstraintType.isOidBound())) { + PrismProperty prop = focusNew.findProperty(itemPath); + if (prop == null || prop.isEmpty()) { + String newValue = focusNew.getOid(); + if (newValue == null) { + newValue = OidUtil.generateOid(); + } + LOGGER.trace("Generating new OID-bound value for {}: {}", itemPath, newValue); + PrismObjectDefinition focusDefinition = focusContext.getObjectDefinition(); + PrismPropertyDefinition propDef = focusDefinition.findPropertyDefinition(itemPath); + if (propDef == null) { + throw new SchemaException("No definition for property "+itemPath+" in "+focusDefinition+" as specified in object policy"); + } + PropertyDelta propDelta = propDef.createEmptyDelta(itemPath); + if (String.class.isAssignableFrom(propDef.getTypeClass())) { + propDelta.setValueToReplace(prismContext.itemFactory().createPropertyValue(newValue, OriginType.USER_POLICY, null)); + } else if (PolyString.class.isAssignableFrom(propDef.getTypeClass())) { + propDelta.setValueToReplace(prismContext.itemFactory().createPropertyValue(new PolyString(newValue), OriginType.USER_POLICY, null)); + } else { + throw new SchemaException("Unsupported type "+propDef.getTypeName()+" for property "+itemPath+" in "+focusDefinition+" as specified in object policy, only string and polystring properties are supported for OID-bound mode"); + } + focusContext.swallowToSecondaryDelta(propDelta); + focusContext.recompute(); + } + } + } + + public static LensContext.ExportType getExportType(TraceType trace, OperationResult result) { + return result.isTracingNormal(trace.getClass()) ? LensContext.ExportType.TRACE : LensContext.ExportType.MINIMAL; + } + + public static LensContext.ExportType getExportTypeTraceOrReduced(TraceType trace, OperationResult result) { + return result.isTracingNormal(trace.getClass()) ? LensContext.ExportType.TRACE : LensContext.ExportType.REDUCED; + } + + public static ItemDelta getAprioriItemDelta(ObjectDelta focusDelta, ItemPath itemPath) { + return focusDelta != null ? focusDelta.findItemDelta(itemPath) : null; + } + + public static String determineExplicitArchetypeOid(PrismObject object) { + String explicitArchetypeOid = null; + // Used in cases where archetype assignment haven't had the change to be processed yet. + // E.g. in case that we are creating a new object with archetype assignment + if (object.canRepresent(AssignmentHolderType.class)) { + AssignmentHolderType assignmentHolderType = (AssignmentHolderType)object.asObjectable(); + List archetypeRefs = assignmentHolderType.getArchetypeRef(); + if (archetypeRefs.isEmpty()) { + explicitArchetypeOid = determineExplicitArchetypeOidFromAssignments(object); + } + } + return explicitArchetypeOid; + } + + public static String determineExplicitArchetypeOidFromAssignments(PrismObject object) { + String explicitArchetypeOid = null; + if (object.canRepresent(AssignmentHolderType.class)) { + for (AssignmentType assignment : ((AssignmentHolderType)object.asObjectable()).getAssignment()) { + ObjectReferenceType targetRef = assignment.getTargetRef(); + if (targetRef != null && QNameUtil.match(ArchetypeType.COMPLEX_TYPE, targetRef.getType())) { + explicitArchetypeOid = targetRef.getOid(); + } + } + } + return explicitArchetypeOid; + } +} From b697ea5025b686ccf298bd2857b3bec532b581cb Mon Sep 17 00:00:00 2001 From: Radovan Semancik Date: Mon, 24 Feb 2020 18:47:01 +0100 Subject: [PATCH 04/97] Archetype: hide items impl WIP (MID-6043) --- .../xml/ns/public/common/common-core-3.xsd | 7 + .../ModelInteractionServiceImpl.java | 3841 +++++++++-------- .../impl/controller/SchemaTransformer.java | 1743 ++++---- 3 files changed, 2833 insertions(+), 2758 deletions(-) diff --git a/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd b/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd index 4ddbf3b3513..8a5b2d735f4 100755 --- a/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd +++ b/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd @@ -19508,6 +19508,13 @@ + + + + ItemConstraintType.visibility + + + diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelInteractionServiceImpl.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelInteractionServiceImpl.java index af981bba9db..4c890a63256 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelInteractionServiceImpl.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelInteractionServiceImpl.java @@ -1,1916 +1,1925 @@ -/* - * Copyright (c) 2010-2019 Evolveum and contributors - * - * This work is dual-licensed under the Apache License 2.0 - * and European Union Public License. See LICENSE file for details. - */ -package com.evolveum.midpoint.model.impl.controller; - -import static com.evolveum.midpoint.schema.GetOperationOptions.createExecutionPhase; -import static com.evolveum.midpoint.schema.SelectorOptions.createCollection; -import static com.evolveum.midpoint.schema.util.ObjectTypeUtil.createObjectRef; -import static com.evolveum.midpoint.xml.ns._public.common.common_3.TaskExecutionStatusType.RUNNABLE; -import static java.util.Collections.singleton; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - -import javax.xml.namespace.QName; - -import com.evolveum.midpoint.TerminateSessionEvent; -import com.evolveum.midpoint.model.api.authentication.*; -import com.evolveum.midpoint.model.common.stringpolicy.*; -import com.evolveum.midpoint.schema.cache.CacheConfigurationManager; -import com.evolveum.midpoint.schema.util.*; -import com.evolveum.midpoint.security.enforcer.api.FilterGizmo; -import com.evolveum.midpoint.xml.ns._public.common.api_types_3.*; -import com.evolveum.midpoint.xml.ns._public.common.common_3.*; -import org.apache.commons.lang.BooleanUtils; -import org.apache.commons.lang.Validate; -import org.apache.commons.lang3.StringUtils; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Component; - -import com.evolveum.midpoint.common.ActivationComputer; -import com.evolveum.midpoint.common.Clock; -import com.evolveum.midpoint.common.refinery.CompositeRefinedObjectClassDefinition; -import com.evolveum.midpoint.common.refinery.LayerRefinedAttributeDefinition; -import com.evolveum.midpoint.common.refinery.LayerRefinedAttributeDefinitionImpl; -import com.evolveum.midpoint.common.refinery.LayerRefinedObjectClassDefinition; -import com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition; -import com.evolveum.midpoint.common.refinery.RefinedResourceSchema; -import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl; -import com.evolveum.midpoint.model.api.AssignmentObjectRelation; -import com.evolveum.midpoint.model.api.CollectionStats; -import com.evolveum.midpoint.model.api.AssignmentCandidatesSpecification; -import com.evolveum.midpoint.model.api.ModelAuthorizationAction; -import com.evolveum.midpoint.model.api.ModelExecuteOptions; -import com.evolveum.midpoint.model.api.ModelInteractionService; -import com.evolveum.midpoint.model.api.ModelService; -import com.evolveum.midpoint.model.api.ProgressListener; -import com.evolveum.midpoint.model.api.RoleSelectionSpecification; -import com.evolveum.midpoint.model.api.context.EvaluatedAssignment; -import com.evolveum.midpoint.model.api.context.EvaluatedAssignmentTarget; -import com.evolveum.midpoint.model.api.context.EvaluatedPolicyRule; -import com.evolveum.midpoint.model.api.context.ModelContext; -import com.evolveum.midpoint.model.api.hooks.HookRegistry; -import com.evolveum.midpoint.model.api.util.DeputyUtils; -import com.evolveum.midpoint.model.api.util.MergeDeltas; -import com.evolveum.midpoint.model.api.visualizer.Scene; -import com.evolveum.midpoint.model.common.ArchetypeManager; -import com.evolveum.midpoint.model.common.SystemObjectCache; -import com.evolveum.midpoint.model.common.mapping.MappingFactory; -import com.evolveum.midpoint.model.impl.ModelCrudService; -import com.evolveum.midpoint.model.impl.ModelObjectResolver; -import com.evolveum.midpoint.model.impl.lens.AssignmentEvaluator; -import com.evolveum.midpoint.model.impl.lens.Clockwork; -import com.evolveum.midpoint.model.impl.lens.ContextFactory; -import com.evolveum.midpoint.model.impl.lens.LensContext; -import com.evolveum.midpoint.model.impl.lens.LensContextPlaceholder; -import com.evolveum.midpoint.model.impl.lens.LensUtil; -import com.evolveum.midpoint.model.impl.lens.OperationalDataManager; -import com.evolveum.midpoint.model.impl.lens.projector.mappings.MappingEvaluator; -import com.evolveum.midpoint.model.impl.lens.projector.Projector; -import com.evolveum.midpoint.model.impl.security.SecurityHelper; -import com.evolveum.midpoint.model.impl.security.GuiProfileCompiler; -import com.evolveum.midpoint.model.impl.visualizer.Visualizer; -import com.evolveum.midpoint.prism.Containerable; -import com.evolveum.midpoint.prism.Item; -import com.evolveum.midpoint.prism.ItemDefinition; -import com.evolveum.midpoint.prism.PrismConstants; -import com.evolveum.midpoint.prism.PrismContainer; -import com.evolveum.midpoint.prism.PrismContainerDefinition; -import com.evolveum.midpoint.prism.PrismContainerValue; -import com.evolveum.midpoint.prism.PrismContext; -import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.PrismObjectDefinition; -import com.evolveum.midpoint.prism.PrismProperty; -import com.evolveum.midpoint.prism.PrismPropertyDefinition; -import com.evolveum.midpoint.prism.PrismPropertyValue; -import com.evolveum.midpoint.prism.PrismReferenceValue; -import com.evolveum.midpoint.prism.crypto.EncryptionException; -import com.evolveum.midpoint.prism.crypto.Protector; -import com.evolveum.midpoint.prism.delta.DeltaFactory; -import com.evolveum.midpoint.prism.delta.ObjectDelta; -import com.evolveum.midpoint.prism.delta.PlusMinusZero; -import com.evolveum.midpoint.prism.delta.PropertyDelta; -import com.evolveum.midpoint.prism.path.ItemName; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.prism.polystring.PolyString; -import com.evolveum.midpoint.prism.query.EqualFilter; -import com.evolveum.midpoint.prism.query.ObjectFilter; -import com.evolveum.midpoint.prism.query.ObjectQuery; -import com.evolveum.midpoint.prism.util.ItemDeltaItem; -import com.evolveum.midpoint.prism.util.ItemPathTypeUtil; -import com.evolveum.midpoint.prism.util.ObjectDeltaObject; -import com.evolveum.midpoint.provisioning.api.ProvisioningService; -import com.evolveum.midpoint.repo.api.RepositoryService; -import com.evolveum.midpoint.repo.cache.RepositoryCache; -import com.evolveum.midpoint.repo.common.expression.ExpressionFactory; -import com.evolveum.midpoint.repo.common.expression.ExpressionVariables; -import com.evolveum.midpoint.schema.GetOperationOptions; -import com.evolveum.midpoint.schema.ObjectDeltaOperation; -import com.evolveum.midpoint.schema.RelationRegistry; -import com.evolveum.midpoint.schema.ResourceShadowDiscriminator; -import com.evolveum.midpoint.schema.SchemaHelper; -import com.evolveum.midpoint.schema.SearchResultList; -import com.evolveum.midpoint.schema.SelectorOptions; -import com.evolveum.midpoint.schema.constants.ObjectTypes; -import com.evolveum.midpoint.schema.constants.SchemaConstants; -import com.evolveum.midpoint.schema.expression.VariablesMap; -import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.schema.result.OperationResultStatus; -import com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus; -import com.evolveum.midpoint.security.api.MidPointPrincipal; -import com.evolveum.midpoint.security.api.SecurityContextManager; -import com.evolveum.midpoint.security.enforcer.api.ItemSecurityConstraints; -import com.evolveum.midpoint.security.enforcer.api.ObjectSecurityConstraints; -import com.evolveum.midpoint.security.enforcer.api.SecurityEnforcer; -import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.DebugUtil; -import com.evolveum.midpoint.util.DisplayableValue; -import com.evolveum.midpoint.util.LocalizableMessage; -import com.evolveum.midpoint.util.LocalizableMessageBuilder; -import com.evolveum.midpoint.util.MiscUtil; -import com.evolveum.midpoint.util.QNameUtil; -import com.evolveum.midpoint.util.annotation.Experimental; -import com.evolveum.midpoint.util.exception.CommonException; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; -import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.PolicyViolationException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SecurityViolationException; -import com.evolveum.midpoint.util.exception.SystemException; -import com.evolveum.midpoint.util.logging.LoggingUtils; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.prism.xml.ns._public.types_3.ItemPathType; -import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; -import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; -import com.evolveum.prism.xml.ns._public.types_3.RawType; - -/** - * @author semancik - * - */ -@Component("modelInteractionService") -public class ModelInteractionServiceImpl implements ModelInteractionService { - - private static final Trace LOGGER = TraceManager.getTrace(ModelInteractionServiceImpl.class); - - @Autowired private ContextFactory contextFactory; - @Autowired private Projector projector; - @Autowired private SecurityEnforcer securityEnforcer; - @Autowired private SecurityContextManager securityContextManager; - @Autowired private SchemaTransformer schemaTransformer; - @Autowired private ProvisioningService provisioning; - @Autowired private ModelObjectResolver objectResolver; - @Autowired private ObjectMerger objectMerger; - @Autowired - @Qualifier("cacheRepositoryService") - private transient RepositoryService cacheRepositoryService; - @Autowired private SystemObjectCache systemObjectCache; - @Autowired private ArchetypeManager archetypeManager; - @Autowired private RelationRegistry relationRegistry; - @Autowired private ValuePolicyProcessor policyProcessor; - @Autowired private Protector protector; - @Autowired private PrismContext prismContext; - @Autowired private SchemaHelper schemaHelper; - @Autowired private Visualizer visualizer; - @Autowired private ModelService modelService; - @Autowired private ModelCrudService modelCrudService; - @Autowired private SecurityHelper securityHelper; - @Autowired private MappingFactory mappingFactory; - @Autowired private MappingEvaluator mappingEvaluator; - @Autowired private ActivationComputer activationComputer; - @Autowired private Clock clock; - @Autowired private HookRegistry hookRegistry; - @Autowired private GuiProfiledPrincipalManager guiProfiledPrincipalManager; - @Autowired private GuiProfileCompiler guiProfileCompiler; - @Autowired private ExpressionFactory expressionFactory; - @Autowired private OperationalDataManager metadataManager; - @Autowired private Clockwork clockwork; - @Autowired private CollectionProcessor collectionProcessor; - @Autowired private CacheConfigurationManager cacheConfigurationManager; - @Autowired private ClusterwideUserSessionManager clusterwideUserSessionManager; - - private static final String OPERATION_GENERATE_VALUE = ModelInteractionService.class.getName() + ".generateValue"; - private static final String OPERATION_VALIDATE_VALUE = ModelInteractionService.class.getName() + ".validateValue"; - private static final String OPERATION_DETERMINE_VIRTUAL_CONTAINERS = ModelInteractionService.class.getName() + ".determineVirtualContainers"; - - /* (non-Javadoc) - * @see com.evolveum.midpoint.model.api.ModelInteractionService#previewChanges(com.evolveum.midpoint.prism.delta.ObjectDelta, com.evolveum.midpoint.schema.result.OperationResult) - */ - @Override - public ModelContext previewChanges( - Collection> deltas, ModelExecuteOptions options, Task task, OperationResult parentResult) - throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { - return previewChanges(deltas, options, task, Collections.emptyList(), parentResult); - } - - @Override - public ModelContext previewChanges( - Collection> deltas, ModelExecuteOptions options, Task task, - Collection listeners, OperationResult parentResult) - throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { - - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Preview changes input:\n{}", DebugUtil.debugDump(deltas)); - } - int size = 0; - if (deltas != null) { - size = deltas.size(); - } - Collection> clonedDeltas = new ArrayList<>(size); - if (deltas != null) { - for (ObjectDelta delta : deltas){ - clonedDeltas.add(delta.clone()); - } - } - - OperationResult result = parentResult.createSubresult(PREVIEW_CHANGES); - LensContext context = null; - - try { - RepositoryCache.enter(cacheConfigurationManager); - // used cloned deltas instead of origin deltas, because some of the - // values should be lost later.. - context = contextFactory.createContext(clonedDeltas, options, task, result); - context = clockwork.previewChanges(context, listeners, task, result); - - schemaTransformer.applySchemasAndSecurity(context, null, task, result); - } finally { - LensUtil.reclaimSequences(context, cacheRepositoryService, task, result); - - RepositoryCache.exit(); - } - - return context; - } - - @Override - public ModelContext unwrapModelContext(LensContextType wrappedContext, Task task, OperationResult result) throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException, ExpressionEvaluationException { - return LensContext.fromLensContextType(wrappedContext, prismContext, provisioning, task, result); - } - - @Override - public PrismObjectDefinition getEditObjectDefinition(PrismObject object, AuthorizationPhaseType phase, Task task, OperationResult parentResult) throws SchemaException, ConfigurationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, SecurityViolationException { - OperationResult result = parentResult.createMinorSubresult(GET_EDIT_OBJECT_DEFINITION); - PrismObjectDefinition objectDefinition = object.getDefinition().deepClone(true, schemaTransformer::setFullAccessFlags ); - - try { - - PrismObject baseObject = object; - if (object.getOid() != null) { - // Re-read the object from the repository to make sure we have all the properties. - // the object from method parameters may be already processed by the security code - // and properties needed to evaluate authorizations may not be there - // MID-3126, see also MID-3435 - baseObject = cacheRepositoryService.getObject(object.getCompileTimeClass(), object.getOid(), null, result); - } - - // TODO: maybe we need to expose owner resolver in the interface? - ObjectSecurityConstraints securityConstraints = securityEnforcer.compileSecurityConstraints(baseObject, null, task, result); - if (LOGGER.isTraceEnabled()) { - LOGGER.trace("Security constrains for {}:\n{}", object, securityConstraints==null?"null":securityConstraints.debugDump()); - } - if (securityConstraints == null) { - // Nothing allowed => everything denied - result.setStatus(OperationResultStatus.NOT_APPLICABLE); - return null; - } - - ObjectTemplateType objectTemplateType = null; - try { - objectTemplateType = schemaTransformer.determineObjectTemplate(object, phase, result); - } catch (ConfigurationException | ObjectNotFoundException e) { - result.recordFatalError(e); - } - schemaTransformer.applyObjectTemplateToDefinition(objectDefinition, objectTemplateType, result); - - schemaTransformer.applySecurityConstraints(objectDefinition, securityConstraints, phase); - - if (object.canRepresent(ShadowType.class)) { - PrismObject shadow = (PrismObject)object; - String resourceOid = ShadowUtil.getResourceOid(shadow); - if (resourceOid != null) { - Collection> options = createCollection(GetOperationOptions.createReadOnly()); - PrismObject resource; - try { - resource = provisioning.getObject(ResourceType.class, resourceOid, options, task, result); - } catch (CommunicationException | SecurityViolationException | ExpressionEvaluationException e) { - throw new ConfigurationException(e.getMessage(), e); - } - RefinedObjectClassDefinition refinedObjectClassDefinition = getEditObjectClassDefinition(shadow, resource, phase, task, result); - if (refinedObjectClassDefinition != null) { - objectDefinition.getComplexTypeDefinition().toMutable().replaceDefinition(ShadowType.F_ATTRIBUTES, - refinedObjectClassDefinition.toResourceAttributeContainerDefinition()); - - objectDefinition.findContainerDefinition(ItemPath.create(ShadowType.F_ASSOCIATION)).toMutable() - .replaceDefinition(ShadowAssociationType.F_IDENTIFIERS, refinedObjectClassDefinition.toResourceAttributeContainerDefinition(ShadowAssociationType.F_IDENTIFIERS)); - } - } - } - - result.computeStatus(); - return objectDefinition; - - } catch (ConfigurationException | ObjectNotFoundException | ExpressionEvaluationException | SchemaException e) { - result.recordFatalError(e); - throw e; - } - - } - - @Override - public PrismObjectDefinition getEditShadowDefinition(ResourceShadowDiscriminator discr, AuthorizationPhaseType phase, Task task, OperationResult parentResult) throws SchemaException, ConfigurationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, SecurityViolationException { - // HACK hack hack - // Make a dummy shadow instance here and evaluate the schema for that. It is not 100% correct. But good enough for now. - // TODO: refactor when we add better support for multi-tenancy - - PrismObject shadow = prismContext.createObject(ShadowType.class); - ShadowType shadowType = shadow.asObjectable(); - ObjectReferenceType resourceRef = new ObjectReferenceType(); - if (discr != null) { - resourceRef.setOid(discr.getResourceOid()); - shadowType.setResourceRef(resourceRef); - shadowType.setKind(discr.getKind()); - shadowType.setIntent(discr.getIntent()); - shadowType.setObjectClass(discr.getObjectClass()); - } - - return getEditObjectDefinition(shadow, phase, task, parentResult); - } - - @Override - public RefinedObjectClassDefinition getEditObjectClassDefinition(PrismObject shadow, PrismObject resource, AuthorizationPhaseType phase, Task task, OperationResult result) - throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { - Validate.notNull(resource, "Resource must not be null"); - - RefinedResourceSchema refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource); - CompositeRefinedObjectClassDefinition rocd = refinedSchema.determineCompositeObjectClassDefinition(shadow); - if (rocd == null) { - LOGGER.debug("No object class definition for shadow {}, returning null", shadow.getOid()); - return null; - } - LayerRefinedObjectClassDefinition layeredROCD = rocd.forLayer(LayerType.PRESENTATION); - - // TODO: maybe we need to expose owner resolver in the interface? - ObjectSecurityConstraints securityConstraints = securityEnforcer.compileSecurityConstraints(shadow, null, task, result); - if (LOGGER.isTraceEnabled()) { - LOGGER.trace("Security constrains for {}:\n{}", shadow, securityConstraints==null?"null":securityConstraints.debugDump()); - } - if (securityConstraints == null) { - return null; - } - - ItemPath attributesPath = SchemaConstants.PATH_ATTRIBUTES; - AuthorizationDecisionType attributesReadDecision = schemaTransformer.computeItemDecision(securityConstraints, attributesPath, ModelAuthorizationAction.AUTZ_ACTIONS_URLS_GET, - securityConstraints.findAllItemsDecision(ModelAuthorizationAction.AUTZ_ACTIONS_URLS_GET, phase), phase); - AuthorizationDecisionType attributesAddDecision = schemaTransformer.computeItemDecision(securityConstraints, attributesPath, ModelAuthorizationAction.AUTZ_ACTIONS_URLS_ADD, - securityConstraints.findAllItemsDecision(ModelAuthorizationAction.ADD.getUrl(), phase), phase); - AuthorizationDecisionType attributesModifyDecision = schemaTransformer.computeItemDecision(securityConstraints, attributesPath, ModelAuthorizationAction.AUTZ_ACTIONS_URLS_MODIFY, - securityConstraints.findAllItemsDecision(ModelAuthorizationAction.MODIFY.getUrl(), phase), phase); - LOGGER.trace("Attributes container access read:{}, add:{}, modify:{}", attributesReadDecision, attributesAddDecision, - attributesModifyDecision); - - /* - * We are going to modify attribute definitions list. - * So let's make a (shallow) clone here, although it is probably not strictly necessary. - */ - layeredROCD = layeredROCD.clone(); - for (LayerRefinedAttributeDefinition rAttrDef: layeredROCD.getAttributeDefinitions()) { - ItemPath attributePath = ItemPath.create(ShadowType.F_ATTRIBUTES, rAttrDef.getItemName()); - AuthorizationDecisionType attributeReadDecision = schemaTransformer.computeItemDecision(securityConstraints, attributePath, ModelAuthorizationAction.AUTZ_ACTIONS_URLS_GET, attributesReadDecision, phase); - AuthorizationDecisionType attributeAddDecision = schemaTransformer.computeItemDecision(securityConstraints, attributePath, ModelAuthorizationAction.AUTZ_ACTIONS_URLS_ADD, attributesAddDecision, phase); - AuthorizationDecisionType attributeModifyDecision = schemaTransformer.computeItemDecision(securityConstraints, attributePath, ModelAuthorizationAction.AUTZ_ACTIONS_URLS_MODIFY, attributesModifyDecision, phase); - LOGGER.trace("Attribute {} access read:{}, add:{}, modify:{}", rAttrDef.getItemName(), attributeReadDecision, - attributeAddDecision, attributeModifyDecision); - if (attributeReadDecision != AuthorizationDecisionType.ALLOW) { - ((LayerRefinedAttributeDefinitionImpl) rAttrDef).setOverrideCanRead(false); - } - if (attributeAddDecision != AuthorizationDecisionType.ALLOW) { - ((LayerRefinedAttributeDefinitionImpl) rAttrDef).setOverrideCanAdd(false); - } - if (attributeModifyDecision != AuthorizationDecisionType.ALLOW) { - ((LayerRefinedAttributeDefinitionImpl) rAttrDef).setOverrideCanModify(false); - } - } - - // TODO what about activation and credentials? - - return layeredROCD; - } - - public ItemSecurityConstraints getAllowedRequestAssignmentItems(PrismObject object, PrismObject target, Task task, OperationResult result) throws SchemaException, SecurityViolationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - return securityEnforcer.getAllowedRequestAssignmentItems(securityContextManager.getPrincipal(), ModelAuthorizationAction.ASSIGN.getUrl(), object, target, null, task, result); - } - - @Override - public Collection> getActionUrls() { - return Arrays.asList(ModelAuthorizationAction.values()); - } - - @Override - public RoleSelectionSpecification getAssignableRoleSpecification(PrismObject focus, Class targetType, int assignmentOrder, Task task, OperationResult parentResult) - throws ObjectNotFoundException, SchemaException, ConfigurationException, ExpressionEvaluationException, CommunicationException, SecurityViolationException { - OperationResult result = parentResult.createMinorSubresult(GET_ASSIGNABLE_ROLE_SPECIFICATION); - - ObjectSecurityConstraints securityConstraints; - try { - securityConstraints = securityEnforcer.compileSecurityConstraints(focus, null, task, result); - } catch (ExpressionEvaluationException | ObjectNotFoundException | SchemaException | CommunicationException | SecurityViolationException e) { - result.recordFatalError(e); - throw e; - } - if (LOGGER.isTraceEnabled()) { - LOGGER.trace("Security constrains for getAssignableRoleSpecification on {}:\n{}", focus, securityConstraints==null?null:securityConstraints.debugDump(1)); - } - if (securityConstraints == null) { - return null; - } - - // Global decisions: processing #modify authorizations: allow/deny for all items or allow/deny for assignment/inducement item. - ItemPath assignmentPath; - if (assignmentOrder == 0) { - assignmentPath = SchemaConstants.PATH_ASSIGNMENT; - } else { - assignmentPath = SchemaConstants.PATH_INDUCEMENT; - } - AuthorizationDecisionType assignmentItemDecision = securityConstraints.findItemDecision(assignmentPath, - ModelAuthorizationAction.MODIFY.getUrl(), AuthorizationPhaseType.REQUEST); - LOGGER.trace("getAssignableRoleSpecification decision for {}:{}", assignmentPath, assignmentItemDecision); - if (assignmentItemDecision == AuthorizationDecisionType.ALLOW) { - RoleSelectionSpecification spec = new RoleSelectionSpecification(); - spec.setGlobalFilter(prismContext.queryFactory().createAll()); - result.recordSuccess(); - return spec; - } - if (assignmentItemDecision == AuthorizationDecisionType.DENY) { - result.recordSuccess(); - RoleSelectionSpecification spec = new RoleSelectionSpecification(); - spec.setGlobalFilter(prismContext.queryFactory().createNone()); - return spec; - } - AuthorizationDecisionType allItemsDecision = securityConstraints.findAllItemsDecision(ModelAuthorizationAction.MODIFY.getUrl(), AuthorizationPhaseType.REQUEST); - if (allItemsDecision == AuthorizationDecisionType.ALLOW) { - RoleSelectionSpecification spec = new RoleSelectionSpecification(); - spec.setGlobalFilter(prismContext.queryFactory().createAll()); - result.recordSuccess(); - return spec; - } - if (allItemsDecision == AuthorizationDecisionType.DENY) { - result.recordSuccess(); - RoleSelectionSpecification spec = new RoleSelectionSpecification(); - spec.setGlobalFilter(prismContext.queryFactory().createNone()); - return spec; - } - - // Assignment decisions: processing #assign authorizations - MidPointPrincipal principal = securityEnforcer.getMidPointPrincipal(); - OrderConstraintsType orderConstraints = new OrderConstraintsType(); - orderConstraints.setOrder(assignmentOrder); - List orderConstraintsList = new ArrayList<>(1); - orderConstraintsList.add(orderConstraints); - - FilterGizmo gizmo = new FilterGizmoAssignableRoles(prismContext); - - try { - - RoleSelectionSpecification spec = securityEnforcer.computeSecurityFilter(principal, ModelAuthorizationAction.AUTZ_ACTIONS_URLS_ASSIGN, AuthorizationPhaseType.REQUEST, - targetType, focus, prismContext.queryFactory().createAll(), null, orderConstraintsList, gizmo, task, result); - - result.recordSuccess(); - return spec; - - } catch (SchemaException | ConfigurationException | ObjectNotFoundException | ExpressionEvaluationException e) { - result.recordFatalError(e); - throw e; - } - -// -// // Assignment decisions: processing #assign authorizations -// OrderConstraintsType orderConstraints = new OrderConstraintsType(); -// orderConstraints.setOrder(assignmentOrder); -// List orderConstraintsList = new ArrayList<>(1); -// orderConstraintsList.add(orderConstraints); -// try { -// ObjectFilter filter = securityEnforcer.preProcessObjectFilter(ModelAuthorizationAction.AUTZ_ACTIONS_URLS_ASSIGN, -// AuthorizationPhaseType.REQUEST, targetType, focus, FilterCreationUtil.createAll(prismContext), null, orderConstraintsList, task, result); -// LOGGER.trace("assignableRoleSpec filter: {}", filter); -// spec.setFilter(filter); -// if (filter instanceof NoneFilter) { -// result.recordSuccess(); -// spec.setNoRoleTypes(); -// return spec; -// } else if (filter == null || filter instanceof AllFilter) { -// getGlobalAssignableRoleSpecification(spec, result); -// result.recordSuccess(); -// return spec; -// } else if (filter instanceof OrFilter) { -// Collection allRoleTypeDvals = new ArrayList<>(); -// for (ObjectFilter subfilter: ((OrFilter)filter).getConditions()) { -// Collection roleTypeDvals = getRoleSelectionSpecEntries(subfilter); -// if (roleTypeDvals == null || roleTypeDvals.isEmpty()) { -// // This branch of the OR clause does not have any constraint for roleType -// // therefore all role types are possible (regardless of other branches, this is OR) -// spec = new RoleSelectionSpecification(); -// spec.setFilter(filter); -// getGlobalAssignableRoleSpecification(spec, result); -// result.recordSuccess(); -// return spec; -// } else { -// allRoleTypeDvals.addAll(roleTypeDvals); -// } -// } -// addRoleTypeSpecEntries(spec, allRoleTypeDvals, result); -// } else { -// Collection roleTypeDvals = getRoleSelectionSpecEntries(filter); -// if (roleTypeDvals == null || roleTypeDvals.isEmpty()) { -// getGlobalAssignableRoleSpecification(spec, result); -// result.recordSuccess(); -// return spec; -// } else { -// addRoleTypeSpecEntries(spec, roleTypeDvals, result); -// } -// } -// result.recordSuccess(); -// return spec; -// } catch (SchemaException | ConfigurationException | ObjectNotFoundException | ExpressionEvaluationException e) { -// result.recordFatalError(e); -// throw e; -// } - - - } - - - private Collection createSingleDisplayableValueCollection( - RoleSelectionSpecEntry dval) { - if (dval == null) { - return null; - } - Collection col = new ArrayList<>(1); - col.add(dval); - return col; - } - - private RoleSelectionSpecEntry getRoleSelectionSpecEq(EqualFilter eqFilter) throws SchemaException { - if (QNameUtil.match(RoleType.F_ROLE_TYPE, eqFilter.getElementName()) || QNameUtil.match(RoleType.F_SUBTYPE, eqFilter.getElementName())) { - List> ppvs = eqFilter.getValues(); - if (ppvs.size() > 1) { - throw new SchemaException("More than one value in roleType search filter"); - } - String roleType = ppvs.get(0).getValue(); - RoleSelectionSpecEntry roleTypeDval = new RoleSelectionSpecEntry(roleType, roleType, null); - return roleTypeDval; - } - return null; - } - - - @Override - public ObjectFilter getDonorFilter(Class searchResultType, ObjectFilter origFilter, String targetAuthorizationAction, Task task, OperationResult parentResult) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { - return securityEnforcer.preProcessObjectFilter(ModelAuthorizationAction.AUTZ_ACTIONS_URLS_ATTORNEY, null, searchResultType, null, origFilter, targetAuthorizationAction, null, task, parentResult); - } - - @Override - public boolean canSearch(Class resultType, - Class objectType, String objectOid, boolean includeSpecial, ObjectQuery query, Task task, OperationResult result) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - PrismObject object = null; - if (objectOid != null) { - object = (PrismObject) objectResolver.getObject(objectType, objectOid, null, task, result).asPrismObject(); - } - return securityEnforcer.canSearch(ModelAuthorizationAction.AUTZ_ACTIONS_URLS_SEARCH, null, resultType, object, includeSpecial, query.getFilter(), task, result); - } - - @Override - public AuthenticationsPolicyType getAuthenticationPolicy(PrismObject user, Task task, - OperationResult parentResult) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - // TODO: check for user membership in an organization (later versions) - - OperationResult result = parentResult.createMinorSubresult(GET_AUTHENTICATIONS_POLICY); - return resolvePolicyTypeFromSecurityPolicy(AuthenticationsPolicyType.class, SecurityPolicyType.F_AUTHENTICATION, user, task, result); - - } - - @Override - @Deprecated - public RegistrationsPolicyType getRegistrationPolicy(PrismObject user, Task task, OperationResult parentResult) - throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - // TODO: check for user membership in an organization (later versions) - - OperationResult result = parentResult.createMinorSubresult(GET_REGISTRATIONS_POLICY); - return resolvePolicyTypeFromSecurityPolicy(RegistrationsPolicyType.class, SecurityPolicyType.F_REGISTRATION, user, task, - result); - } - - @Override - public RegistrationsPolicyType getFlowPolicy(PrismObject focus, Task task, OperationResult parentResult) - throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - // TODO: check for user membership in an organization (later versions) - OperationResult result = parentResult.createMinorSubresult(GET_REGISTRATIONS_POLICY); - return resolvePolicyTypeFromSecurityPolicy(RegistrationsPolicyType.class, SecurityPolicyType.F_FLOW, focus, task, - result); - } - - - @Override - public CredentialsPolicyType getCredentialsPolicy(PrismObject focus, Task task, OperationResult parentResult) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - // TODO: check for user membership in an organization (later versions) - - OperationResult result = parentResult.createMinorSubresult(GET_CREDENTIALS_POLICY); - return resolvePolicyTypeFromSecurityPolicy(CredentialsPolicyType.class, SecurityPolicyType.F_CREDENTIALS, focus, task, result); - } - - private C resolvePolicyTypeFromSecurityPolicy(Class type, QName path, PrismObject focus, Task task, OperationResult parentResult) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - - SecurityPolicyType securityPolicyType = getSecurityPolicy(focus, task, parentResult); - if (securityPolicyType == null) { - return null; - } - PrismContainer container = securityPolicyType.asPrismObject().findContainer(ItemName.fromQName(path)); - if (container == null) { - return null; - } - PrismContainerValue containerValue = container.getValue(); - parentResult.recordSuccess(); - return containerValue.asContainerable(); - } - - @Override - public SecurityPolicyType getSecurityPolicy(PrismObject focus, Task task, OperationResult parentResult) - throws SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - OperationResult result = parentResult.createMinorSubresult(GET_SECURITY_POLICY); - try { - PrismObject systemConfiguration = systemObjectCache.getSystemConfiguration(result); - if (systemConfiguration == null) { - result.recordNotApplicableIfUnknown(); - return null; - } - - SecurityPolicyType securityPolicyType = securityHelper.locateSecurityPolicy(focus, systemConfiguration, task, result); - if (securityPolicyType == null) { - result.recordNotApplicableIfUnknown(); - return null; - } - - return securityPolicyType; - } catch (Throwable e) { - result.recordFatalError(e); - throw e; - } finally { - result.computeStatusIfUnknown(); - } - } - - @NotNull - public CompiledGuiProfile getCompiledGuiProfile(Task task, OperationResult parentResult) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - MidPointPrincipal principal = null; - try { - principal = securityContextManager.getPrincipal(); - } catch (SecurityViolationException e) { - LOGGER.warn("Security violation while getting principlal to get GUI config: {}", e.getMessage(), e); - } - - if (principal == null || !(principal instanceof GuiProfiledPrincipal)) { - // May be used for unathenticated user, error pages and so on - return guiProfileCompiler.getGlobalCompiledGuiProfile(task, parentResult); - } else { - return ((GuiProfiledPrincipal)principal).getCompiledGuiProfile(); - } - } - - @Override - public List getLoggedInPrincipals(Task task, OperationResult result) { - // TODO some authorization here? - return clusterwideUserSessionManager.getLoggedInPrincipals(task, result); - } - - @Override - public void terminateSessions(TerminateSessionEvent terminateSessionEvent, Task task, OperationResult result) { - // TODO some authorization here? - clusterwideUserSessionManager.terminateSessions(terminateSessionEvent, task, result); - } - - @Override - public SystemConfigurationType getSystemConfiguration(OperationResult parentResult) throws ObjectNotFoundException, SchemaException { - PrismObject systemConfiguration = systemObjectCache.getSystemConfiguration(parentResult); - if (systemConfiguration == null) { - return null; - } - return systemConfiguration.asObjectable(); - } - - @Override - public DeploymentInformationType getDeploymentInformationConfiguration(OperationResult parentResult) throws ObjectNotFoundException, SchemaException { - PrismObject systemConfiguration = systemObjectCache.getSystemConfiguration(parentResult); - if (systemConfiguration == null) { - return null; - } - return systemConfiguration.asObjectable().getDeploymentInformation(); - } - - @Override - public SystemConfigurationAuditType getAuditConfiguration(OperationResult parentResult) throws ObjectNotFoundException, SchemaException { - PrismObject systemConfiguration = systemObjectCache.getSystemConfiguration(parentResult); - if (systemConfiguration == null) { - return null; - } - return systemConfiguration.asObjectable().getAudit(); - } - - @Override - public List getMergeConfiguration(OperationResult parentResult) throws ObjectNotFoundException, SchemaException { - PrismObject systemConfiguration = systemObjectCache.getSystemConfiguration(parentResult); - if (systemConfiguration == null) { - return null; - } - return systemConfiguration.asObjectable().getMergeConfiguration(); - } - - @Override - public AccessCertificationConfigurationType getCertificationConfiguration(OperationResult parentResult) throws ObjectNotFoundException, SchemaException { - PrismObject systemConfiguration = systemObjectCache.getSystemConfiguration(parentResult); - if (systemConfiguration == null) { - return null; - } - return systemConfiguration.asObjectable().getAccessCertification(); - } - - @Override - public boolean checkPassword(String userOid, ProtectedStringType password, Task task, OperationResult parentResult) - throws ObjectNotFoundException, SchemaException { - OperationResult result = parentResult.createMinorSubresult(CHECK_PASSWORD); - UserType userType; - try { - userType = objectResolver.getObjectSimple(UserType.class, userOid, null, task, result); - } catch (ObjectNotFoundException e) { - result.recordFatalError(e); - throw e; - } - if (userType.getCredentials() == null || userType.getCredentials().getPassword() == null - || userType.getCredentials().getPassword().getValue() == null) { - return password == null; - } - ProtectedStringType currentPassword = userType.getCredentials().getPassword().getValue(); - boolean cmp; - try { - cmp = protector.compareCleartext(password, currentPassword); - } catch (EncryptionException e) { - result.recordFatalError(e); - throw new SystemException(e.getMessage(),e); - } - result.recordSuccess(); - return cmp; - } - - @Override - public List visualizeDeltas(List> deltas, Task task, OperationResult result) throws SchemaException, ExpressionEvaluationException { - return visualizer.visualizeDeltas(deltas, task, result); - } - - @Override - @NotNull - public Scene visualizeDelta(ObjectDelta delta, Task task, OperationResult result) throws SchemaException, ExpressionEvaluationException { - return visualizer.visualizeDelta(delta, task, result); - } - - @Override - @NotNull - public Scene visualizeDelta(ObjectDelta delta, boolean includeOperationalItems, Task task, OperationResult result) throws SchemaException, ExpressionEvaluationException{ - return visualizer.visualizeDelta(delta, null, includeOperationalItems, task, result); - } - - @Override - @NotNull - public Scene visualizeDelta(ObjectDelta delta, boolean includeOperationalItems, ObjectReferenceType objectRef, Task task, OperationResult result) throws SchemaException, ExpressionEvaluationException { - return visualizer.visualizeDelta(delta, objectRef, task, result); - } - - @Override - public List getConnectorOperationalStatus(String resourceOid, Task task, OperationResult parentResult) - throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - OperationResult result = parentResult.createMinorSubresult(GET_CONNECTOR_OPERATIONAL_STATUS); - List status; - try { - status = provisioning.getConnectorOperationalStatus(resourceOid, task, result); - } catch (SchemaException | ObjectNotFoundException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) { - result.recordFatalError(e); - throw e; - } - result.computeStatus(); - return status; - } - - @Override - public MergeDeltas mergeObjectsPreviewDeltas(Class type, String leftOid, - String rightOid, String mergeConfigurationName, Task task, OperationResult parentResult) - throws ObjectNotFoundException, SchemaException, ConfigurationException, ExpressionEvaluationException, CommunicationException, SecurityViolationException { - OperationResult result = parentResult.createMinorSubresult(MERGE_OBJECTS_PREVIEW_DELTA); - - try { - - MergeDeltas mergeDeltas = objectMerger.computeMergeDeltas(type, leftOid, rightOid, mergeConfigurationName, task, result); - - result.computeStatus(); - return mergeDeltas; - - } catch (ObjectNotFoundException | SchemaException | ConfigurationException | ExpressionEvaluationException | - CommunicationException | SecurityViolationException | RuntimeException | Error e) { - result.recordFatalError(e); - throw e; - } - } - - @Override - public PrismObject mergeObjectsPreviewObject(Class type, String leftOid, - String rightOid, String mergeConfigurationName, Task task, OperationResult parentResult) - throws ObjectNotFoundException, SchemaException, ConfigurationException, ExpressionEvaluationException, CommunicationException, SecurityViolationException { - OperationResult result = parentResult.createMinorSubresult(MERGE_OBJECTS_PREVIEW_OBJECT); - - try { - - MergeDeltas mergeDeltas = objectMerger.computeMergeDeltas(type, leftOid, rightOid, mergeConfigurationName, task, result); - - if (LOGGER.isTraceEnabled()) { - LOGGER.trace("Merge preview {} + {} deltas:\n{}", leftOid, rightOid, mergeDeltas.debugDump(1)); - } - - final PrismObject objectLeft = (PrismObject) objectResolver.getObjectSimple(type, leftOid, null, task, result).asPrismObject(); - - if (mergeDeltas == null) { - result.computeStatus(); - return objectLeft; - } - - mergeDeltas.getLeftObjectDelta().applyTo(objectLeft); - mergeDeltas.getLeftLinkDelta().applyTo(objectLeft); - - result.computeStatus(); - return objectLeft; - - } catch (ObjectNotFoundException | SchemaException | ConfigurationException | ExpressionEvaluationException | - CommunicationException | SecurityViolationException | RuntimeException | Error e) { - result.recordFatalError(e); - throw e; - } - } - - @Override - public String generateValue(ValuePolicyType policy, int defaultLength, boolean generateMinimalSize, - PrismObject object, String shortDesc, Task task, OperationResult parentResult) throws ExpressionEvaluationException, SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException { - return policyProcessor.generate(null, policy, defaultLength, generateMinimalSize, createOriginResolver(object, parentResult), shortDesc, task, parentResult); - } - - @Override - public void generateValue(PrismObject object, PolicyItemsDefinitionType policyItemsDefinition, - Task task, OperationResult parentResult) throws ObjectAlreadyExistsException, ExpressionEvaluationException, SchemaException, ObjectNotFoundException, - CommunicationException, ConfigurationException, SecurityViolationException, PolicyViolationException { - - OperationResult result = parentResult.createSubresult(OPERATION_GENERATE_VALUE); - - - ValuePolicyType valuePolicy = null; - try { - valuePolicy = getValuePolicy(object, task, result); - } catch (ObjectNotFoundException | SchemaException | CommunicationException - | ConfigurationException | SecurityViolationException - | ExpressionEvaluationException e) { - LOGGER.error("Failed to get value policy for generating value. ", e); - result.recordFatalError("Error while getting value policy. Reason: " + e.getMessage(), e); - throw e; - } - - Collection> deltasToExecute = new ArrayList<>(); - for (PolicyItemDefinitionType policyItemDefinition : policyItemsDefinition.getPolicyItemDefinition()) { - OperationResult generateValueResult = parentResult.createSubresult(OPERATION_GENERATE_VALUE); - - LOGGER.trace("Default value policy: {}" , valuePolicy); - try { - generateValue(object, valuePolicy, policyItemDefinition, task, generateValueResult); - } catch (ExpressionEvaluationException | SchemaException | ObjectNotFoundException - | CommunicationException | ConfigurationException | SecurityViolationException e) { - LOGGER.error("Failed to generate value for {} ", policyItemDefinition, e); - generateValueResult.recordFatalError("Failed to generate value for " + policyItemDefinition + ". Reason: " + e.getMessage(), e); - policyItemDefinition.setResult(generateValueResult.createOperationResultType()); - continue; - } - - //TODO: not sure about the bulk actions here - ItemPath path = getPath(policyItemDefinition); - if (path == null) { - if (isExecute(policyItemDefinition)) { - LOGGER.error("No item path defined in the target for policy item definition. Cannot generate value"); - generateValueResult.recordFatalError( - "No item path defined in the target for policy item definition. Cannot generate value"); - continue; - } - } - - PrismPropertyDefinition propertyDef = null; - if (path != null) { - result.addArbitraryObjectAsParam("policyItemPath", path); - - propertyDef = getItemDefinition(object, path); - if (propertyDef == null) { - if (isExecute(policyItemDefinition)) { - LOGGER.error("No definition for property {} in object. Is the path referencing prism property?" + path, - object); - generateValueResult.recordFatalError("No definition for property " + path + " in object " + object - + ". Is the path referencing prism property?"); - continue; - } - - } - } - // end of not sure - - collectDeltasForGeneratedValuesIfNeeded(object, policyItemDefinition, deltasToExecute, path, propertyDef, generateValueResult); - generateValueResult.computeStatusIfUnknown(); - } - result.computeStatus(); - if (!result.isAcceptable()) { - return; - } - try { - if (!deltasToExecute.isEmpty()) { - if (object == null) { - LOGGER.error("Cannot execute changes for generated values, no object specified in request."); - result.recordFatalError("Cannot execute changes for generated values, no object specified in request."); - throw new SchemaException("Cannot execute changes for generated values, no object specified in request."); - } - String oid = object.getOid(); - Class clazz = (Class) object.asObjectable().getClass(); - modelCrudService.modifyObject(clazz, oid, deltasToExecute, null, task, result); - - } - } catch (ObjectNotFoundException | SchemaException | ExpressionEvaluationException - | CommunicationException | ConfigurationException | ObjectAlreadyExistsException - | PolicyViolationException | SecurityViolationException e) { - LOGGER.error("Could not execute deltas for generated values. Reason: " + e.getMessage(), e); - result.recordFatalError("Could not execute deltas for gegenerated values. Reason: "+ e.getMessage(), e); - throw e; - } - - - } - - private boolean isExecute(PolicyItemDefinitionType policyItemDefinition) { - if (policyItemDefinition.isExecute() == null) { - return false; - } - - return policyItemDefinition.isExecute().booleanValue(); - } - private ItemPath getPath(PolicyItemDefinitionType policyItemDefinition) { - PolicyItemTargetType target = policyItemDefinition.getTarget(); - if (target == null) { - return null; - } - ItemPathType itemPathType = target.getPath(); - return itemPathType != null ? itemPathType.getItemPath() : null; - } - - private PrismPropertyDefinition getItemDefinition(PrismObject object, ItemPath path) { - ItemDefinition itemDef = object.getDefinition().findItemDefinition(path); - if (itemDef == null) { - return null; - } else if (!(itemDef instanceof PrismPropertyDefinition)) { - return null; - } - - return (PrismPropertyDefinition) itemDef; - } - - private void collectDeltasForGeneratedValuesIfNeeded(PrismObject object, - PolicyItemDefinitionType policyItemDefinition, Collection> deltasToExecute, ItemPath path, - PrismPropertyDefinition itemDef, OperationResult result) throws SchemaException { - - Object value = policyItemDefinition.getValue(); - - if (itemDef != null){ - if (ProtectedStringType.COMPLEX_TYPE.equals(itemDef.getTypeName())) { - ProtectedStringType pst = new ProtectedStringType(); - pst.setClearValue((String) value); - value = pst; - } else if (PolyStringType.COMPLEX_TYPE.equals(itemDef.getTypeName())) { - value = new PolyString((String) value); - } - } - if (object == null && isExecute(policyItemDefinition)) { - LOGGER.warn("Cannot apply generated changes and cannot execute them becasue there is no target object specified."); - result.recordFatalError("Cannot apply generated changes and cannot execute them becasue there is no target object specified."); - return; - } - if (object != null) { - PropertyDelta propertyDelta = prismContext.deltaFactory().property() - .createModificationReplaceProperty(path, object.getDefinition(), value); - propertyDelta.applyTo(object); // in bulk actions we need to modify original objects - hope that REST is OK with this - if (BooleanUtils.isTrue(policyItemDefinition.isExecute())) { - deltasToExecute.add(propertyDelta); - } - } - - } - - private void generateValue(PrismObject object, ValuePolicyType defaultPolicy, - PolicyItemDefinitionType policyItemDefinition, Task task, OperationResult result) - throws ExpressionEvaluationException, SchemaException, ObjectNotFoundException, CommunicationException, - ConfigurationException, SecurityViolationException { - - PolicyItemTargetType target = policyItemDefinition.getTarget(); - if ((target == null || ItemPathTypeUtil.isEmpty(target.getPath())) && isExecute(policyItemDefinition)) { - LOGGER.error("Target item path must be defined"); - throw new SchemaException("Target item path must be defined"); - } - ItemPath targetPath = null; - - if (target != null) { - targetPath = target.getPath().getItemPath(); - } - - ValuePolicyType valuePolicy = resolveValuePolicy(policyItemDefinition, defaultPolicy, task, result); - LOGGER.trace("Value policy used for generating new value : {}", valuePolicy); - StringPolicyType stringPolicy = valuePolicy != null ? valuePolicy.getStringPolicy() : null; - if (stringPolicy == null) { - LOGGER.trace("No sting policy defined. Cannot generate value."); - result.recordFatalError("No string policy defined. Cannot generate value"); - return; -// throw new SchemaException("No value policy for " + targetPath); - } - - String newValue = policyProcessor.generate(targetPath, valuePolicy, 10, false, createOriginResolver(object, result), - "generating value for" + targetPath, task, result); - policyItemDefinition.setValue(newValue); - } - - private ValuePolicyType resolveValuePolicy(PolicyItemDefinitionType policyItemDefinition, ValuePolicyType defaultPolicy, - Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - if (policyItemDefinition.getValuePolicyRef() != null) { - LOGGER.trace("Trying to resolve value policy {} for policy item definition", policyItemDefinition); - return objectResolver.resolve(policyItemDefinition.getValuePolicyRef(), ValuePolicyType.class, null, - "valuePolicyRef in policyItemDefinition", task, result); - } - - return defaultPolicy; - } - - public void validateValue(PrismObject object, PolicyItemsDefinitionType policyItemsDefinition, - Task task, OperationResult parentResult) throws ExpressionEvaluationException, SchemaException, ObjectNotFoundException, - CommunicationException, ConfigurationException, SecurityViolationException, PolicyViolationException { - ValuePolicyType valuePolicy = getValuePolicy(object, task, parentResult); - for (PolicyItemDefinitionType policyItemDefinition : policyItemsDefinition.getPolicyItemDefinition()) { - validateValue(object, valuePolicy, policyItemDefinition, task, parentResult); - } - } - - private ValuePolicyType getValuePolicy(PrismObject object, Task task, - OperationResult parentResult) throws ObjectNotFoundException, SchemaException, CommunicationException, - ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - // user-level policy - CredentialsPolicyType credentialsPolicy = null; - PrismObject user = null; - if (object != null && object.getCompileTimeClass().isAssignableFrom(UserType.class)) { - LOGGER.trace("Start to resolve policy for user"); - user = (PrismObject) object; - credentialsPolicy = getCredentialsPolicy(user, task, parentResult); - LOGGER.trace("Resolved user policy: {}", credentialsPolicy); - } - - SystemConfigurationType systemConfigurationType = getSystemConfiguration(parentResult); - if (!containsValuePolicyDefinition(credentialsPolicy)) { - SecurityPolicyType securityPolicy = securityHelper.locateGlobalSecurityPolicy(user, systemConfigurationType.asPrismObject(), task, parentResult); - if (securityPolicy != null) { - credentialsPolicy = securityPolicy.getCredentials(); - LOGGER.trace("Resolved policy from global security policy: {}", credentialsPolicy); - } - } - - if (containsValuePolicyDefinition(credentialsPolicy)) { - if (credentialsPolicy.getPassword().getValuePolicyRef() != null) { - return objectResolver.resolve(credentialsPolicy.getPassword().getValuePolicyRef(), ValuePolicyType.class, null, "valuePolicyRef in password credential policy", task, parentResult); - } - } - - return null; - } - - private boolean containsValuePolicyDefinition(CredentialsPolicyType policy) { - if (policy == null) { - return false; - } - - if (policy.getPassword() == null) { - return false; - } - - if (policy.getPassword().getValuePolicyRef() != null) { - return true; - } - - return false; - } - - private boolean validateValue(PrismObject object, ValuePolicyType policy, PolicyItemDefinitionType policyItemDefinition, Task task, OperationResult parentResult) throws ExpressionEvaluationException, SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, PolicyViolationException { - - ValuePolicyType stringPolicy = resolveValuePolicy(policyItemDefinition, policy, task, parentResult); - - Object value = policyItemDefinition.getValue(); - String valueToValidate; - if (value instanceof RawType) { - valueToValidate = ((RawType) value).getParsedRealValue(String.class); - } else { - valueToValidate = (String) value; - } - - List valuesToValidate = new ArrayList<>(); - PolicyItemTargetType target = policyItemDefinition.getTarget(); - ItemPath path = target != null ? target.getPath().getItemPath() : null; - if (StringUtils.isNotEmpty(valueToValidate)) { - valuesToValidate.add(valueToValidate); - } else { - if (target == null || target.getPath() == null) { - LOGGER.error("Target item path must be defined"); - parentResult.recordFatalError("Target item path must be defined"); - throw new SchemaException("Target item path must be defined"); - } - if (object == null) { - LOGGER.error("Object which values should be validated is null. Nothing to validate."); - parentResult.recordFatalError("Object which values should be validated is null. Nothing to validate."); - throw new SchemaException("Object which values should be validated is null. Nothing to validate."); - } - - PrismProperty property = object.findProperty(path); - if (property == null || property.isEmpty()) { - LOGGER.error("Attribute {} has no value. Nothing to validate.", property); - parentResult.recordFatalError("Attribute " + property + " has no value. Nothing to validate"); - throw new SchemaException("Attribute " + property + " has no value. Nothing to validate"); - } - - - PrismPropertyDefinition itemToValidateDefinition = property.getDefinition(); - QName definitionName = itemToValidateDefinition.getTypeName(); - if (!isSupportedType(definitionName)) { - LOGGER.error("Trying to validate string policy on the property of type {} failed. Unsupported type.", - itemToValidateDefinition); - parentResult.recordFatalError("Trying to validate string policy on the property of type " - + itemToValidateDefinition + " failed. Unsupported type."); - throw new SchemaException("Trying to validate string policy on the property of type " - + itemToValidateDefinition + " failed. Unsupported type."); - } - - if (itemToValidateDefinition.isSingleValue()) { - if (definitionName.equals(PolyStringType.COMPLEX_TYPE)) { - valueToValidate = ((PolyString) property.getRealValue()).getOrig(); - - } else if (definitionName.equals(ProtectedStringType.COMPLEX_TYPE)){ - ProtectedStringType protectedString = ((ProtectedStringType) property.getRealValue()); - valueToValidate = getClearValue(protectedString); - - - } else { - valueToValidate = (String) property.getRealValue(); - } - valuesToValidate.add(valueToValidate); - } else { - if (definitionName.equals(DOMUtil.XSD_STRING)) { - valuesToValidate.addAll(property.getRealValues(String.class)); - } else if (definitionName.equals(ProtectedStringType.COMPLEX_TYPE)) { - for (ProtectedStringType protectedString : property.getRealValues(ProtectedStringType.class)) { - valuesToValidate.add(getClearValue(protectedString)); - } - } else { - for (PolyString val : property.getRealValues(PolyString.class)) { - valuesToValidate.add(val.getOrig()); - } - } - } - - } - - for (String newValue : valuesToValidate) { - OperationResult result = parentResult.createSubresult(OPERATION_VALIDATE_VALUE + ".value"); - if (path != null ) result.addParam("path", path.toString()); - result.addParam("valueToValidate", newValue); - - ObjectValuePolicyEvaluator.Builder evaluatorBuilder = new ObjectValuePolicyEvaluator.Builder() - .valuePolicy(stringPolicy) - .valuePolicyProcessor(policyProcessor) - .protector(protector) - .valueItemPath(path) - .originResolver(getOriginResolver(object)) - .task(task) - .shortDesc(" rest validate "); - O objectable = object != null ? object.asObjectable() : null; - if (path != null && objectable instanceof FocusType) { - //noinspection unchecked - PrismObject focus = (PrismObject) object; - if (path.isSuperPathOrEquivalent(SchemaConstants.PATH_PASSWORD)) { - evaluatorBuilder.securityPolicy(getSecurityPolicy(focus, task, parentResult)); - PrismContainer passwordContainer = focus.findContainer(SchemaConstants.PATH_PASSWORD); - PasswordType password = passwordContainer != null ? passwordContainer.getValue().asContainerable() : null; - evaluatorBuilder.oldCredential(password); - } else if (path.isSuperPathOrEquivalent(SchemaConstants.PATH_SECURITY_QUESTIONS)) { - LOGGER.trace("Setting security questions related policy."); - SecurityPolicyType securityPolicy = getSecurityPolicy(focus, task, parentResult); - evaluatorBuilder.securityPolicy(securityPolicy); - PrismContainer securityQuestionsContainer = - focus.findContainer(SchemaConstants.PATH_SECURITY_QUESTIONS); - SecurityQuestionsCredentialsType securityQuestions = securityQuestionsContainer != null ? - securityQuestionsContainer.getValue().asContainerable() : null; - //evaluatorBuilder.oldCredentialType(securityQuestions); // TODO what with this? - evaluatorBuilder.valuePolicy(resolveSecurityQuestionsPolicy(securityPolicy, task, parentResult)); - } - } - evaluatorBuilder.now(clock.currentTimeXMLGregorianCalendar()); - LOGGER.trace("Validating value started"); - evaluatorBuilder.build().validateStringValue(newValue, result); - LOGGER.trace("Validating value finished"); -// - result.computeStatus(); - -// if (!policyProcessor.validateValue(newValue, stringPolicy, createOriginResolver(object, result), "validate value " + (path!= null ? "for " + path : "") + " for " + object + " value " + valueToValidate, task, result)) { -// result.recordFatalError("Validation for value " + newValue + " against policy " + stringPolicy + " failed"); -// LOGGER.error("Validation for value {} against policy {} failed", newValue, stringPolicy); -// } - - } - - parentResult.computeStatus(); - policyItemDefinition.setResult(parentResult.createOperationResultType()); - - return parentResult.isAcceptable(); - - } - - /** - * @param securityPolicy - * @return - * @throws ExpressionEvaluationException - * @throws SecurityViolationException - * @throws ConfigurationException - * @throws CommunicationException - * @throws SchemaException - * @throws ObjectNotFoundException - */ - private ValuePolicyType resolveSecurityQuestionsPolicy(SecurityPolicyType securityPolicy, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - if (securityPolicy == null) { - return null; - } - - CredentialsPolicyType credentialsPolicy = securityPolicy.getCredentials(); - if (credentialsPolicy == null) { - return null; - } - - SecurityQuestionsCredentialsPolicyType securityQuestionsPolicy = credentialsPolicy.getSecurityQuestions(); - if (securityQuestionsPolicy == null) { - return null; - } - - ObjectReferenceType policyRef = securityQuestionsPolicy.getValuePolicyRef(); - if (policyRef == null) { - return null; - } - - return objectResolver.resolve(policyRef, ValuePolicyType.class, null, " resolve value policy for security questions", task, result); - } - - private ObjectBasedValuePolicyOriginResolver getOriginResolver(PrismObject object) { - if (object != null && UserType.class.equals(object.getCompileTimeClass())) { - return new FocusValuePolicyOriginResolver<>((PrismObject) object, objectResolver); - } - - //TODO not supported yet, throw exception instead of null??? - return null; - } - - private ObjectBasedValuePolicyOriginResolver createOriginResolver(PrismObject object, OperationResult result) throws SchemaException { - if (object == null) { - return null; - } - if (object.canRepresent(UserType.class)) { - return new FocusValuePolicyOriginResolver<>((PrismObject) object, objectResolver); - } - if (object.canRepresent(ShadowType.class)) { - return new ShadowValuePolicyOriginResolver((PrismObject) object, objectResolver); - } - SchemaException e = new SchemaException("Unsupport object type "+object); - result.recordFatalError(e); - throw e; - } - - private boolean isSupportedType(QName type) { - - if (QNameUtil.qNameToUri(type).equals(QNameUtil.qNameToUri(DOMUtil.XSD_STRING))){ - return true; - } - - if (QNameUtil.qNameToUri(type).equals(QNameUtil.qNameToUri(PolyStringType.COMPLEX_TYPE))) { - return true; - } - - if (QNameUtil.qNameToUri(type).equals(QNameUtil.qNameToUri(ProtectedStringType.COMPLEX_TYPE))) { - return true; - } - - return false; - } - - private String getClearValue(ProtectedStringType protectedString) throws SchemaException, PolicyViolationException { - try { - if (protectedString.isEncrypted()) { - - return protector.decryptString(protectedString); - - } else if (protectedString.getClearValue() != null) { - return protector.decryptString(protectedString); - } else if (protectedString.isHashed()) { - throw new SchemaException("Cannot validate value of hashed password"); - } - } catch (EncryptionException e) { - throw new PolicyViolationException(e.getMessage(), e); - } - return null; - } - - // TODO TODO TODO deduplicate this somehow! - - @NotNull - @Override - public List getDeputyAssignees(AbstractWorkItemType workItem, Task task, OperationResult parentResult) - throws SchemaException { - OperationResult result = parentResult.createMinorSubresult(GET_DEPUTY_ASSIGNEES); - RepositoryCache.enter(cacheConfigurationManager); - try { - Set oidsToSkip = new HashSet<>(); - List deputies = new ArrayList<>(); - workItem.getAssigneeRef().forEach(a -> oidsToSkip.add(a.getOid())); - getDeputyAssignees(deputies, workItem, oidsToSkip, task, result); - result.computeStatusIfUnknown(); - return deputies; - } catch (Throwable t) { - result.recordFatalError(t.getMessage(), t); - throw t; - } finally { - RepositoryCache.exit(); - } - } - - @NotNull - @Override - public List getDeputyAssignees(ObjectReferenceType assigneeRef, QName limitationItemName, Task task, - OperationResult parentResult) throws SchemaException { - OperationResult result = parentResult.createMinorSubresult(GET_DEPUTY_ASSIGNEES); - RepositoryCache.enter(cacheConfigurationManager); - try { - Set oidsToSkip = new HashSet<>(); - oidsToSkip.add(assigneeRef.getOid()); - List deputies = new ArrayList<>(); - getDeputyAssigneesNoWorkItem(deputies, assigneeRef, limitationItemName, oidsToSkip, task, result); - result.computeStatusIfUnknown(); - return deputies; - } catch (Throwable t) { - result.recordFatalError(t.getMessage(), t); - throw t; - } finally { - RepositoryCache.exit(); - } - } - - private void getDeputyAssignees(List deputies, AbstractWorkItemType workItem, Set oidsToSkip, - Task task, OperationResult result) throws SchemaException { - List assigneeReferencesToQuery = workItem.getAssigneeRef().stream() - .map(assigneeRef -> assigneeRef.clone().relation(PrismConstants.Q_ANY).asReferenceValue()) - .collect(Collectors.toList()); - ObjectQuery query = prismContext.queryFor(UserType.class) - .item(UserType.F_DELEGATED_REF).ref(assigneeReferencesToQuery) - .build(); - SearchResultList> potentialDeputies = cacheRepositoryService - .searchObjects(UserType.class, query, null, result); - for (PrismObject potentialDeputy : potentialDeputies) { - if (oidsToSkip.contains(potentialDeputy.getOid())) { - continue; - } - if (determineDeputyValidity(potentialDeputy, workItem.getAssigneeRef(), workItem, OtherPrivilegesLimitationType.F_APPROVAL_WORK_ITEMS, task, result)) { - deputies.add(ObjectTypeUtil.createObjectRefWithFullObject(potentialDeputy, prismContext)); - oidsToSkip.add(potentialDeputy.getOid()); - } - } - } - - private void getDeputyAssigneesNoWorkItem(List deputies, ObjectReferenceType assigneeRef, - QName limitationItemName, Set oidsToSkip, - Task task, OperationResult result) throws SchemaException { - PrismReferenceValue assigneeReferenceToQuery = assigneeRef.clone().relation(PrismConstants.Q_ANY).asReferenceValue(); - ObjectQuery query = prismContext.queryFor(UserType.class) - .item(UserType.F_DELEGATED_REF).ref(assigneeReferenceToQuery) - .build(); - SearchResultList> potentialDeputies = cacheRepositoryService - .searchObjects(UserType.class, query, null, result); - for (PrismObject potentialDeputy : potentialDeputies) { - if (oidsToSkip.contains(potentialDeputy.getOid())) { - continue; - } - if (determineDeputyValidity(potentialDeputy, Collections.singletonList(assigneeRef), null, limitationItemName, task, result)) { - deputies.add(ObjectTypeUtil.createObjectRefWithFullObject(potentialDeputy, prismContext)); - oidsToSkip.add(potentialDeputy.getOid()); - } - } - } - - private boolean determineDeputyValidity(PrismObject potentialDeputy, List assignees, - @Nullable AbstractWorkItemType workItem, QName privilegeLimitationItemName, Task task, OperationResult result) { - AssignmentEvaluator.Builder builder = - new AssignmentEvaluator.Builder() - .repository(cacheRepositoryService) - .focusOdo(new ObjectDeltaObject<>(potentialDeputy, null, potentialDeputy, potentialDeputy.getDefinition())) - .channel(null) - .objectResolver(objectResolver) - .systemObjectCache(systemObjectCache) - .relationRegistry(relationRegistry) - .prismContext(prismContext) - .mappingFactory(mappingFactory) - .mappingEvaluator(mappingEvaluator) - .activationComputer(activationComputer) - .now(clock.currentTimeXMLGregorianCalendar()) - .loginMode(true) - // We do not have real lens context here. But the push methods in ModelExpressionThreadLocalHolder - // will need something to push on the stack. So give them context placeholder. - .lensContext(new LensContextPlaceholder<>(potentialDeputy, prismContext)); - AssignmentEvaluator assignmentEvaluator = builder.build(); - - for (AssignmentType assignmentType: potentialDeputy.asObjectable().getAssignment()) { - if (!DeputyUtils.isDelegationAssignment(assignmentType, relationRegistry)) { - continue; - } - try { - ItemDeltaItem, PrismContainerDefinition> assignmentIdi = - new ItemDeltaItem<>(LensUtil.createAssignmentSingleValueContainer(assignmentType)); - // TODO some special mode for verification of the validity - we don't need complete calculation here! - EvaluatedAssignment assignment = assignmentEvaluator - .evaluate(assignmentIdi, PlusMinusZero.ZERO, false, potentialDeputy.asObjectable(), - potentialDeputy.toString(), false, task, result); - if (!assignment.isValid()) { - continue; - } - for (EvaluatedAssignmentTarget target : assignment.getRoles().getNonNegativeValues()) { - if (target.getTarget() != null && target.getTarget().getOid() != null - && DeputyUtils.isDelegationPath(target.getAssignmentPath(), relationRegistry) - && ObjectTypeUtil.containsOid(assignees, target.getTarget().getOid())) { - List limitations = DeputyUtils.extractLimitations(target.getAssignmentPath()); - if (workItem != null && DeputyUtils.limitationsAllow(limitations, privilegeLimitationItemName, workItem) - || workItem == null && SchemaDeputyUtil.limitationsAllow(limitations, privilegeLimitationItemName)) { - return true; - } - } - } - } catch (CommonException e) { - LoggingUtils.logUnexpectedException(LOGGER, "Couldn't verify 'deputy' relation between {} and {} for work item {}; assignment: {}", - e, potentialDeputy, assignees, workItem, assignmentType); - } - } - return false; - } - - @Override - public ActivationStatusType getAssignmentEffectiveStatus(String lifecycleStatus, ActivationType activationType) { - return activationComputer.getEffectiveStatus(lifecycleStatus, activationType, null); - } - - @Override - public MidPointPrincipal assumePowerOfAttorney(PrismObject donor, Task task, OperationResult result) throws SchemaException, SecurityViolationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - MidPointPrincipal attorneyPrincipal = securityContextManager.getPrincipal(); - MidPointPrincipal donorPrincipal = securityEnforcer.createDonorPrincipal(attorneyPrincipal, ModelAuthorizationAction.ATTORNEY.getUrl(), donor, task, result); - - // TODO: audit switch - - securityContextManager.setupPreAuthenticatedSecurityContext(donorPrincipal); - - return donorPrincipal; - } - - @Override - public MidPointPrincipal dropPowerOfAttorney(Task task, OperationResult result) throws SchemaException, SecurityViolationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - MidPointPrincipal donorPrincipal = securityContextManager.getPrincipal(); - if (donorPrincipal.getAttorney() == null) { - throw new IllegalStateException("Attempt to drop attorney powers using non-donor principal "+donorPrincipal); - } - MidPointPrincipal previousPrincipal = donorPrincipal.getPreviousPrincipal(); - if (previousPrincipal == null) { - throw new IllegalStateException("Attempt to drop attorney powers, but no previous principal in "+donorPrincipal); - } - - // TODO: audit switch - - // TODO: maybe refresh previous principal using userProfileService? - securityContextManager.setupPreAuthenticatedSecurityContext(previousPrincipal); - - return previousPrincipal; - } - - @Override - @NotNull - public LocalizableMessageType createLocalizableMessageType(LocalizableMessageTemplateType template, - VariablesMap variables, Task task, OperationResult result) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, - ConfigurationException, SecurityViolationException { - ExpressionVariables vars = new ExpressionVariables(); - vars.putAll(variables); - return LensUtil.interpretLocalizableMessageTemplate(template, vars, expressionFactory, prismContext, task, result); - } - - @Override - public ExecuteCredentialResetResponseType executeCredentialsReset(PrismObject user, - ExecuteCredentialResetRequestType executeCredentialResetRequest, Task task, OperationResult parentResult) - throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, - SecurityViolationException, ExpressionEvaluationException, ObjectAlreadyExistsException, PolicyViolationException { - LocalizableMessageBuilder builder = new LocalizableMessageBuilder(); - - ExecuteCredentialResetResponseType response = new ExecuteCredentialResetResponseType(prismContext); - - String resetMethod = executeCredentialResetRequest.getResetMethod(); - if (StringUtils.isBlank(resetMethod)) { - LocalizableMessage localizableMessage = builder.fallbackMessage("Failed to execute reset password. Bad request.").key("execute.reset.credential.bad.request").build(); - response = response.message(LocalizationUtil.createLocalizableMessageType(localizableMessage)); - throw new SchemaException(localizableMessage); - - } - - SecurityPolicyType securityPolicy = getSecurityPolicy(user, task, parentResult); - CredentialsResetPolicyType resetPolicyType = securityPolicy.getCredentialsReset(); - //TODO: search according tot he credentialID and others - if (resetPolicyType == null) { - LocalizableMessage localizableMessage = builder.fallbackMessage("Failed to execute reset password. Bad configuration.").key("execute.reset.credential.bad.configuration").build(); - response = response.message(LocalizationUtil.createLocalizableMessageType(localizableMessage)); - throw new SchemaException(localizableMessage); - } - - if (!resetMethod.equals(resetPolicyType.getName())) { - LocalizableMessage localizableMessage = builder.fallbackMessage("Failed to execute reset password. Bad method.").key("execute.reset.credential.bad.method").build(); - response = response.message(LocalizationUtil.createLocalizableMessageType(localizableMessage)); - throw new SchemaException(localizableMessage); - } - - - CredentialSourceType credentialSourceType = resetPolicyType.getNewCredentialSource(); - - if (credentialSourceType == null) { - //TODO: go through deprecated functionality - LocalizableMessage localizableMessage = builder.fallbackMessage("Failed to execute reset password. No credential source.").key("execute.reset.credential.no.credential.source").build(); - response = response.message(LocalizationUtil.createLocalizableMessageType(localizableMessage)); - //for now just let the user know that he needs to specify it - return response; - } - - ValuePolicyType valuePolicy = getValuePolicy(user, task, parentResult); - - ObjectDelta userDelta = null; - if (credentialSourceType.getUserEntry() != null) { - PolicyItemDefinitionType policyItemDefinitione = new PolicyItemDefinitionType(); - policyItemDefinitione.setValue(executeCredentialResetRequest.getUserEntry()); - - if (!validateValue(user, valuePolicy, policyItemDefinitione, task, parentResult)) { - LOGGER.error("Cannot execute reset password. New password doesn't satisfy policy constraints"); - parentResult.recordFatalError("Cannot execute reset password. New password doesn't satisfy policy constraints"); - LocalizableMessage localizableMessage = builder.fallbackMessage("New password doesn't satisfy policy constraints.").key("execute.reset.credential.validation.failed").build(); - throw new PolicyViolationException(localizableMessage); - } - - ProtectedStringType newProtectedPassword = new ProtectedStringType(); - newProtectedPassword.setClearValue(executeCredentialResetRequest.getUserEntry()); - userDelta = prismContext.deltaFactory().object().createModificationReplaceProperty(UserType.class, user.getOid(), - SchemaConstants.PATH_PASSWORD_VALUE, newProtectedPassword); - - } - - if (BooleanUtils.isTrue(resetPolicyType.isForceChange())) { - if (userDelta != null) { - userDelta.addModificationReplaceProperty(SchemaConstants.PATH_PASSWORD_FORCE_CHANGE, Boolean.TRUE); - } - } - - - try { - Collection> result = modelService.executeChanges( - MiscUtil.createCollection(userDelta), ModelExecuteOptions.createRaw(), task, parentResult); - } catch (ObjectNotFoundException | SchemaException | CommunicationException | ConfigurationException - | SecurityViolationException | ExpressionEvaluationException | ObjectAlreadyExistsException | PolicyViolationException e) { - response.message(LocalizationUtil.createForFallbackMessage("Failed to reset credential: " + e.getMessage())); - throw e; - } - - parentResult.recomputeStatus(); - LocalizableMessage message = builder.fallbackMessage("Reset password was successful").key("execute.reset.credential.successful").fallbackLocalizableMessage(null).build(); - response.setMessage(LocalizationUtil.createLocalizableMessageType(message)); - - return response; - } - - - @Override - public void refreshPrincipal(String oid, Class clazz) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - try { - MidPointPrincipal principal = guiProfiledPrincipalManager.getPrincipalByOid(oid, clazz); - securityContextManager.setupPreAuthenticatedSecurityContext(principal); - } catch (Throwable e) { - LOGGER.error("Cannot refresh authentication for user identified with" + oid); - throw e; - } - } - - @Override - public List getRelationDefinitions() { - return relationRegistry.getRelationDefinitions(); - } - - @NotNull - @Override - public TaskType submitTaskFromTemplate(String templateTaskOid, List> extensionItems, Task opTask, OperationResult parentResult) - throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, - ConfigurationException, ExpressionEvaluationException, ObjectAlreadyExistsException, PolicyViolationException { - OperationResult result = parentResult.createMinorSubresult(SUBMIT_TASK_FROM_TEMPLATE); - try { - MidPointPrincipal principal = securityContextManager.getPrincipal(); - if (principal == null) { - throw new SecurityViolationException("No current user"); - } - TaskType newTask = modelService.getObject(TaskType.class, templateTaskOid, - createCollection(createExecutionPhase()), opTask, result).asObjectable(); - newTask.setName(PolyStringType.fromOrig(newTask.getName().getOrig() + " " + (int) (Math.random() * 10000))); - newTask.setOid(null); - newTask.setTaskIdentifier(null); - newTask.setOwnerRef(createObjectRef(principal.getFocus(), prismContext)); - newTask.setExecutionStatus(RUNNABLE); - for (Item extensionItem : extensionItems) { - newTask.asPrismObject().getExtension().add(extensionItem.clone()); - } - ObjectDelta taskAddDelta = DeltaFactory.Object.createAddDelta(newTask.asPrismObject()); - Collection> executedChanges = modelService.executeChanges(singleton(taskAddDelta), null, opTask, result); - String newTaskOid = ObjectDeltaOperation.findAddDeltaOid(executedChanges, newTask.asPrismObject()); - newTask.setOid(newTaskOid); - newTask.setTaskIdentifier(newTaskOid); - result.computeStatus(); - return newTask; - } catch (Throwable t) { - result.recordFatalError("Couldn't submit task from template: " + t.getMessage(), t); - throw t; - } - } - - @NotNull - @Override - public TaskType submitTaskFromTemplate(String templateTaskOid, Map extensionValues, Task opTask, OperationResult parentResult) - throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, - ConfigurationException, ExpressionEvaluationException, ObjectAlreadyExistsException, PolicyViolationException { - PrismContainerDefinition extDef = prismContext.getSchemaRegistry() - .findObjectDefinitionByCompileTimeClass(TaskType.class).findContainerDefinition(TaskType.F_EXTENSION); - List> extensionItems = ObjectTypeUtil.mapToExtensionItems(extensionValues, extDef, prismContext); - return submitTaskFromTemplate(templateTaskOid, extensionItems, opTask, parentResult); - } - - @Override - public ArchetypePolicyType determineArchetypePolicy(PrismObject assignmentHolder, OperationResult result) throws SchemaException, ConfigurationException { - return archetypeManager.determineArchetypePolicy(assignmentHolder, result); - } - - private PrismObject determineArchetype(PrismObject assignmentHolder, OperationResult result) throws SchemaException, ConfigurationException { - return archetypeManager.determineArchetype(assignmentHolder, result); - } - - @Override - public AssignmentCandidatesSpecification determineAssignmentTargetSpecification(PrismObject object, OperationResult result) throws SchemaException { - SearchResultList> archetypes = systemObjectCache.getAllArchetypes(result); - List assignmentTargetRelations = new ArrayList<>(); - for (PrismObject archetype : archetypes) { - List archetypeFocusTypes = null; - for (AssignmentType inducement : archetype.asObjectable().getInducement()) { - for (AssignmentRelationType assignmentRelation : inducement.getAssignmentRelation()) { - if (canBeAssignmentHolder(assignmentRelation, object)) { - if (archetypeFocusTypes == null) { - archetypeFocusTypes = determineArchetypeFocusTypes(archetype); - } - AssignmentObjectRelation targetRelation = new AssignmentObjectRelation(); - targetRelation.addObjectTypes(archetypeFocusTypes); - targetRelation.addArchetypeRef(archetype); - targetRelation.addRelations(assignmentRelation.getRelation()); - targetRelation.setDescription(assignmentRelation.getDescription()); - assignmentTargetRelations.add(targetRelation); - } - } - } - } - - AssignmentCandidatesSpecification spec = new AssignmentCandidatesSpecification(); - spec.setAssignmentObjectRelations(assignmentTargetRelations); - // TODO: empty list vs null: default setting - return spec; - } - - @Override - public List getFilteredArchetypesByHolderType(PrismObject object, OperationResult result) throws SchemaException { - SearchResultList> archetypes = systemObjectCache.getAllArchetypes(result); - List filteredArchetypes = new ArrayList<>(); - for (PrismObject archetype : archetypes) { - for (AssignmentType assignment : archetype.asObjectable().getAssignment()) { - for (AssignmentRelationType assignmentRelation : assignment.getAssignmentRelation()) { - if (isHolderType(assignmentRelation.getHolderType(), object)){ - filteredArchetypes.add(archetype.asObjectable()); - } - } - if (filteredArchetypes.contains(archetype.asObjectable())){ - break; - } - } - } - return filteredArchetypes; - } - - - @Override - public AssignmentCandidatesSpecification determineAssignmentHolderSpecification(PrismObject assignmentTarget, OperationResult result) - throws SchemaException, ConfigurationException { - - if (assignmentTarget == null) { - return null; - } - - // assignmentRelation statements in the assignment - we want to control what objects can be assigned to the archetype definition - if (ArchetypeType.class.isAssignableFrom(assignmentTarget.getCompileTimeClass())) { - ArchetypeType archetypeType = (ArchetypeType) assignmentTarget.asObjectable(); - return determineArchetypeAssignmentCandidateSpecification(archetypeType.getAssignment(), archetypeType.getArchetypePolicy()); - } - - - // apply assignmentRelation to "archetyped" objects - PrismObject targetArchetype = determineArchetype(assignmentTarget, result); - if (targetArchetype == null) { - return null; - } - - // TODO: empty list vs null: default setting - ArchetypeType targetArchetypeType = targetArchetype.asObjectable(); - return determineArchetypeAssignmentCandidateSpecification(targetArchetypeType.getInducement(), targetArchetypeType.getArchetypePolicy()); - - } - - private AssignmentCandidatesSpecification determineArchetypeAssignmentCandidateSpecification(List archetypeAssigmentsOrInducements, ArchetypePolicyType archetypePolicy) { - AssignmentCandidatesSpecification spec = new AssignmentCandidatesSpecification(); - List assignmentHolderRelations = new ArrayList<>(); - for (AssignmentType inducement : archetypeAssigmentsOrInducements) { - for (AssignmentRelationType assignmentRelation : inducement.getAssignmentRelation()) { - AssignmentObjectRelation holderRelation = new AssignmentObjectRelation(); - holderRelation.addObjectTypes(ObjectTypes.canonizeObjectTypes(assignmentRelation.getHolderType())); - holderRelation.addArchetypeRefs(assignmentRelation.getHolderArchetypeRef()); - holderRelation.addRelations(assignmentRelation.getRelation()); - holderRelation.setDescription(assignmentRelation.getDescription()); - assignmentHolderRelations.add(holderRelation); - } - } - spec.setAssignmentObjectRelations(assignmentHolderRelations); - spec.setSupportGenericAssignment(archetypePolicy == null - || AssignmentRelationApproachType.CLOSED != archetypePolicy.getAssignmentRelationApproach()); - return spec; - } - - private List determineArchetypeFocusTypes(PrismObject archetype) { - List focusTypes = new ArrayList<>(); - for (AssignmentType assignment : archetype.asObjectable().getAssignment()) { - for (AssignmentRelationType assignmentRelation : assignment.getAssignmentRelation()) { - focusTypes.addAll(ObjectTypes.canonizeObjectTypes(assignmentRelation.getHolderType())); - } - } - if (focusTypes.isEmpty()) { - focusTypes.add(AssignmentHolderType.COMPLEX_TYPE); - } - return focusTypes; - } - - private boolean canBeAssignmentHolder(AssignmentRelationType assignmentRelation, PrismObject holder) { - return isHolderType(assignmentRelation.getHolderType(), holder) && isHolderArchetype(assignmentRelation.getHolderArchetypeRef(), holder); - } - - private boolean isHolderType(List requiredHolderTypes, PrismObject holder) { - if (requiredHolderTypes.isEmpty()) { - return true; - } - for (QName requiredHolderType : requiredHolderTypes) { - if (MiscSchemaUtil.canBeAssignedFrom(requiredHolderType, holder.getCompileTimeClass())) { - return true; - } - } - return false; - } - - private boolean isHolderArchetype(List requiredHolderArchetypeRefs, PrismObject holder) { - if (requiredHolderArchetypeRefs.isEmpty()) { - return true; - } - List presentHolderArchetypeRefs = holder.asObjectable().getArchetypeRef(); - for (ObjectReferenceType requiredHolderArchetypeRef : requiredHolderArchetypeRefs) { - if (MiscSchemaUtil.contains(presentHolderArchetypeRefs, requiredHolderArchetypeRef)) { - return true; - } - } - return false; - } - - @Override - @Experimental - @NotNull - public Collection evaluateCollectionPolicyRules(@NotNull PrismObject collection, @Nullable CompiledObjectCollectionView collectionView, @Nullable Class targetTypeClass, @NotNull Task task, @NotNull OperationResult result) - throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - return collectionProcessor.evaluateCollectionPolicyRules(collection, collectionView, targetTypeClass, task, result); - } - - @Override - @Experimental - @NotNull - public CompiledObjectCollectionView compileObjectCollectionView(@NotNull PrismObject collection, @Nullable Class targetTypeClass, @NotNull Task task, @NotNull OperationResult result) - throws SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, - ExpressionEvaluationException, ObjectNotFoundException { - return collectionProcessor.compileObjectCollectionView(collection, targetTypeClass, task, result); - } - - @Override - @Experimental - @NotNull - public CollectionStats determineCollectionStats(@NotNull CompiledObjectCollectionView collectionView, @NotNull Task task, @NotNull OperationResult result) - throws SchemaException, ObjectNotFoundException, SecurityViolationException, ConfigurationException, CommunicationException, ExpressionEvaluationException { - return collectionProcessor.determineCollectionStats(collectionView, task, result); - } - - @Override - public Collection determineVirtualContainers(PrismObject object, @NotNull Task task, @NotNull OperationResult parentResult) { - - OperationResult result = parentResult.createMinorSubresult(OPERATION_DETERMINE_VIRTUAL_CONTAINERS); - Collection virtualContainers = new ArrayList<>(); - if (AssignmentHolderType.class.isAssignableFrom(object.getCompileTimeClass())) { - - try { - ArchetypePolicyType archetypePolicyType = determineArchetypePolicy((PrismObject) object, result); - if (archetypePolicyType != null) { - ArchetypeAdminGuiConfigurationType archetypeAdminGui = archetypePolicyType.getAdminGuiConfiguration(); - if (archetypeAdminGui != null) { - GuiObjectDetailsPageType guiDetails = archetypeAdminGui.getObjectDetails(); - if (guiDetails != null && guiDetails.getContainer() != null) { - virtualContainers.addAll(guiDetails.getContainer()) ; - } - } - } - } catch (SchemaException | ConfigurationException e) { - LOGGER.error("Cannot determine virtual containers for {}, reason: {}", object, e.getMessage(), e); - result.recordPartialError("Cannot determine virtual containers for " + object + ", reason: " + e.getMessage(), e); - } - - } - - QName objectType = object.getDefinition().getTypeName(); - try { - CompiledGuiProfile userProfile = getCompiledGuiProfile(task, result); - GuiObjectDetailsSetType objectDetailsSetType = userProfile.getObjectDetails(); - if (objectDetailsSetType == null) { - result.recordSuccess(); - return virtualContainers; - } - List detailsPages = objectDetailsSetType.getObjectDetailsPage(); - for (GuiObjectDetailsPageType detailsPage : detailsPages) { - if (objectType == null) { - LOGGER.trace("Object type is not known, skipping considering custom details page settings."); - continue; - } - if (detailsPage.getType() == null) { - LOGGER.trace("Object type for details page {} not know, skipping considering custom details page settings.", detailsPage); - continue; - } - - if (QNameUtil.match(objectType, detailsPage.getType()) && detailsPage.getContainer() != null) { - virtualContainers.addAll(detailsPage.getContainer()); - } - } - result.recordSuccess(); - return virtualContainers; - } catch (ObjectNotFoundException | SchemaException | CommunicationException | ConfigurationException | SecurityViolationException | ExpressionEvaluationException e) { - LOGGER.error("Cannot determine virtual containers for {}, reason: {}", objectType, e.getMessage(), e); - result.recordPartialError("Cannot determine virtual containers for " + objectType + ", reason: " + e.getMessage(), e); - return virtualContainers; - } - - } - -} +/* + * Copyright (c) 2010-2019 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ +package com.evolveum.midpoint.model.impl.controller; + +import static com.evolveum.midpoint.schema.GetOperationOptions.createExecutionPhase; +import static com.evolveum.midpoint.schema.SelectorOptions.createCollection; +import static com.evolveum.midpoint.schema.util.ObjectTypeUtil.createObjectRef; +import static com.evolveum.midpoint.xml.ns._public.common.common_3.TaskExecutionStatusType.RUNNABLE; +import static java.util.Collections.singleton; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +import javax.xml.namespace.QName; + +import com.evolveum.midpoint.TerminateSessionEvent; +import com.evolveum.midpoint.model.api.authentication.*; +import com.evolveum.midpoint.model.common.stringpolicy.*; +import com.evolveum.midpoint.schema.cache.CacheConfigurationManager; +import com.evolveum.midpoint.schema.util.*; +import com.evolveum.midpoint.security.enforcer.api.FilterGizmo; +import com.evolveum.midpoint.xml.ns._public.common.api_types_3.*; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; +import org.apache.commons.lang.BooleanUtils; +import org.apache.commons.lang.Validate; +import org.apache.commons.lang3.StringUtils; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Component; + +import com.evolveum.midpoint.common.ActivationComputer; +import com.evolveum.midpoint.common.Clock; +import com.evolveum.midpoint.common.refinery.CompositeRefinedObjectClassDefinition; +import com.evolveum.midpoint.common.refinery.LayerRefinedAttributeDefinition; +import com.evolveum.midpoint.common.refinery.LayerRefinedAttributeDefinitionImpl; +import com.evolveum.midpoint.common.refinery.LayerRefinedObjectClassDefinition; +import com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition; +import com.evolveum.midpoint.common.refinery.RefinedResourceSchema; +import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl; +import com.evolveum.midpoint.model.api.AssignmentObjectRelation; +import com.evolveum.midpoint.model.api.CollectionStats; +import com.evolveum.midpoint.model.api.AssignmentCandidatesSpecification; +import com.evolveum.midpoint.model.api.ModelAuthorizationAction; +import com.evolveum.midpoint.model.api.ModelExecuteOptions; +import com.evolveum.midpoint.model.api.ModelInteractionService; +import com.evolveum.midpoint.model.api.ModelService; +import com.evolveum.midpoint.model.api.ProgressListener; +import com.evolveum.midpoint.model.api.RoleSelectionSpecification; +import com.evolveum.midpoint.model.api.context.EvaluatedAssignment; +import com.evolveum.midpoint.model.api.context.EvaluatedAssignmentTarget; +import com.evolveum.midpoint.model.api.context.EvaluatedPolicyRule; +import com.evolveum.midpoint.model.api.context.ModelContext; +import com.evolveum.midpoint.model.api.hooks.HookRegistry; +import com.evolveum.midpoint.model.api.util.DeputyUtils; +import com.evolveum.midpoint.model.api.util.MergeDeltas; +import com.evolveum.midpoint.model.api.visualizer.Scene; +import com.evolveum.midpoint.model.common.ArchetypeManager; +import com.evolveum.midpoint.model.common.SystemObjectCache; +import com.evolveum.midpoint.model.common.mapping.MappingFactory; +import com.evolveum.midpoint.model.impl.ModelCrudService; +import com.evolveum.midpoint.model.impl.ModelObjectResolver; +import com.evolveum.midpoint.model.impl.lens.AssignmentEvaluator; +import com.evolveum.midpoint.model.impl.lens.Clockwork; +import com.evolveum.midpoint.model.impl.lens.ContextFactory; +import com.evolveum.midpoint.model.impl.lens.LensContext; +import com.evolveum.midpoint.model.impl.lens.LensContextPlaceholder; +import com.evolveum.midpoint.model.impl.lens.LensUtil; +import com.evolveum.midpoint.model.impl.lens.OperationalDataManager; +import com.evolveum.midpoint.model.impl.lens.projector.mappings.MappingEvaluator; +import com.evolveum.midpoint.model.impl.lens.projector.Projector; +import com.evolveum.midpoint.model.impl.security.SecurityHelper; +import com.evolveum.midpoint.model.impl.security.GuiProfileCompiler; +import com.evolveum.midpoint.model.impl.visualizer.Visualizer; +import com.evolveum.midpoint.prism.Containerable; +import com.evolveum.midpoint.prism.Item; +import com.evolveum.midpoint.prism.ItemDefinition; +import com.evolveum.midpoint.prism.PrismConstants; +import com.evolveum.midpoint.prism.PrismContainer; +import com.evolveum.midpoint.prism.PrismContainerDefinition; +import com.evolveum.midpoint.prism.PrismContainerValue; +import com.evolveum.midpoint.prism.PrismContext; +import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.prism.PrismObjectDefinition; +import com.evolveum.midpoint.prism.PrismProperty; +import com.evolveum.midpoint.prism.PrismPropertyDefinition; +import com.evolveum.midpoint.prism.PrismPropertyValue; +import com.evolveum.midpoint.prism.PrismReferenceValue; +import com.evolveum.midpoint.prism.crypto.EncryptionException; +import com.evolveum.midpoint.prism.crypto.Protector; +import com.evolveum.midpoint.prism.delta.DeltaFactory; +import com.evolveum.midpoint.prism.delta.ObjectDelta; +import com.evolveum.midpoint.prism.delta.PlusMinusZero; +import com.evolveum.midpoint.prism.delta.PropertyDelta; +import com.evolveum.midpoint.prism.path.ItemName; +import com.evolveum.midpoint.prism.path.ItemPath; +import com.evolveum.midpoint.prism.polystring.PolyString; +import com.evolveum.midpoint.prism.query.EqualFilter; +import com.evolveum.midpoint.prism.query.ObjectFilter; +import com.evolveum.midpoint.prism.query.ObjectQuery; +import com.evolveum.midpoint.prism.util.ItemDeltaItem; +import com.evolveum.midpoint.prism.util.ItemPathTypeUtil; +import com.evolveum.midpoint.prism.util.ObjectDeltaObject; +import com.evolveum.midpoint.provisioning.api.ProvisioningService; +import com.evolveum.midpoint.repo.api.RepositoryService; +import com.evolveum.midpoint.repo.cache.RepositoryCache; +import com.evolveum.midpoint.repo.common.expression.ExpressionFactory; +import com.evolveum.midpoint.repo.common.expression.ExpressionVariables; +import com.evolveum.midpoint.schema.GetOperationOptions; +import com.evolveum.midpoint.schema.ObjectDeltaOperation; +import com.evolveum.midpoint.schema.RelationRegistry; +import com.evolveum.midpoint.schema.ResourceShadowDiscriminator; +import com.evolveum.midpoint.schema.SchemaHelper; +import com.evolveum.midpoint.schema.SearchResultList; +import com.evolveum.midpoint.schema.SelectorOptions; +import com.evolveum.midpoint.schema.constants.ObjectTypes; +import com.evolveum.midpoint.schema.constants.SchemaConstants; +import com.evolveum.midpoint.schema.expression.VariablesMap; +import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.schema.result.OperationResultStatus; +import com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus; +import com.evolveum.midpoint.security.api.MidPointPrincipal; +import com.evolveum.midpoint.security.api.SecurityContextManager; +import com.evolveum.midpoint.security.enforcer.api.ItemSecurityConstraints; +import com.evolveum.midpoint.security.enforcer.api.ObjectSecurityConstraints; +import com.evolveum.midpoint.security.enforcer.api.SecurityEnforcer; +import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.util.DOMUtil; +import com.evolveum.midpoint.util.DebugUtil; +import com.evolveum.midpoint.util.DisplayableValue; +import com.evolveum.midpoint.util.LocalizableMessage; +import com.evolveum.midpoint.util.LocalizableMessageBuilder; +import com.evolveum.midpoint.util.MiscUtil; +import com.evolveum.midpoint.util.QNameUtil; +import com.evolveum.midpoint.util.annotation.Experimental; +import com.evolveum.midpoint.util.exception.CommonException; +import com.evolveum.midpoint.util.exception.CommunicationException; +import com.evolveum.midpoint.util.exception.ConfigurationException; +import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; +import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; +import com.evolveum.midpoint.util.exception.ObjectNotFoundException; +import com.evolveum.midpoint.util.exception.PolicyViolationException; +import com.evolveum.midpoint.util.exception.SchemaException; +import com.evolveum.midpoint.util.exception.SecurityViolationException; +import com.evolveum.midpoint.util.exception.SystemException; +import com.evolveum.midpoint.util.logging.LoggingUtils; +import com.evolveum.midpoint.util.logging.Trace; +import com.evolveum.midpoint.util.logging.TraceManager; +import com.evolveum.prism.xml.ns._public.types_3.ItemPathType; +import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; +import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; +import com.evolveum.prism.xml.ns._public.types_3.RawType; + +/** + * @author semancik + * + */ +@Component("modelInteractionService") +public class ModelInteractionServiceImpl implements ModelInteractionService { + + private static final Trace LOGGER = TraceManager.getTrace(ModelInteractionServiceImpl.class); + + @Autowired private ContextFactory contextFactory; + @Autowired private Projector projector; + @Autowired private SecurityEnforcer securityEnforcer; + @Autowired private SecurityContextManager securityContextManager; + @Autowired private SchemaTransformer schemaTransformer; + @Autowired private ProvisioningService provisioning; + @Autowired private ModelObjectResolver objectResolver; + @Autowired private ObjectMerger objectMerger; + @Autowired + @Qualifier("cacheRepositoryService") + private transient RepositoryService cacheRepositoryService; + @Autowired private SystemObjectCache systemObjectCache; + @Autowired private ArchetypeManager archetypeManager; + @Autowired private RelationRegistry relationRegistry; + @Autowired private ValuePolicyProcessor policyProcessor; + @Autowired private Protector protector; + @Autowired private PrismContext prismContext; + @Autowired private SchemaHelper schemaHelper; + @Autowired private Visualizer visualizer; + @Autowired private ModelService modelService; + @Autowired private ModelCrudService modelCrudService; + @Autowired private SecurityHelper securityHelper; + @Autowired private MappingFactory mappingFactory; + @Autowired private MappingEvaluator mappingEvaluator; + @Autowired private ActivationComputer activationComputer; + @Autowired private Clock clock; + @Autowired private HookRegistry hookRegistry; + @Autowired private GuiProfiledPrincipalManager guiProfiledPrincipalManager; + @Autowired private GuiProfileCompiler guiProfileCompiler; + @Autowired private ExpressionFactory expressionFactory; + @Autowired private OperationalDataManager metadataManager; + @Autowired private Clockwork clockwork; + @Autowired private CollectionProcessor collectionProcessor; + @Autowired private CacheConfigurationManager cacheConfigurationManager; + @Autowired private ClusterwideUserSessionManager clusterwideUserSessionManager; + + private static final String OPERATION_GENERATE_VALUE = ModelInteractionService.class.getName() + ".generateValue"; + private static final String OPERATION_VALIDATE_VALUE = ModelInteractionService.class.getName() + ".validateValue"; + private static final String OPERATION_DETERMINE_VIRTUAL_CONTAINERS = ModelInteractionService.class.getName() + ".determineVirtualContainers"; + + /* (non-Javadoc) + * @see com.evolveum.midpoint.model.api.ModelInteractionService#previewChanges(com.evolveum.midpoint.prism.delta.ObjectDelta, com.evolveum.midpoint.schema.result.OperationResult) + */ + @Override + public ModelContext previewChanges( + Collection> deltas, ModelExecuteOptions options, Task task, OperationResult parentResult) + throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { + return previewChanges(deltas, options, task, Collections.emptyList(), parentResult); + } + + @Override + public ModelContext previewChanges( + Collection> deltas, ModelExecuteOptions options, Task task, + Collection listeners, OperationResult parentResult) + throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { + + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Preview changes input:\n{}", DebugUtil.debugDump(deltas)); + } + int size = 0; + if (deltas != null) { + size = deltas.size(); + } + Collection> clonedDeltas = new ArrayList<>(size); + if (deltas != null) { + for (ObjectDelta delta : deltas){ + clonedDeltas.add(delta.clone()); + } + } + + OperationResult result = parentResult.createSubresult(PREVIEW_CHANGES); + LensContext context = null; + + try { + RepositoryCache.enter(cacheConfigurationManager); + // used cloned deltas instead of origin deltas, because some of the + // values should be lost later.. + context = contextFactory.createContext(clonedDeltas, options, task, result); + context = clockwork.previewChanges(context, listeners, task, result); + + schemaTransformer.applySchemasAndSecurity(context, null, task, result); + } finally { + LensUtil.reclaimSequences(context, cacheRepositoryService, task, result); + + RepositoryCache.exit(); + } + + return context; + } + + @Override + public ModelContext unwrapModelContext(LensContextType wrappedContext, Task task, OperationResult result) throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException, ExpressionEvaluationException { + return LensContext.fromLensContextType(wrappedContext, prismContext, provisioning, task, result); + } + + @Override + public PrismObjectDefinition getEditObjectDefinition(PrismObject object, AuthorizationPhaseType phase, Task task, OperationResult parentResult) throws SchemaException, ConfigurationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, SecurityViolationException { + OperationResult result = parentResult.createMinorSubresult(GET_EDIT_OBJECT_DEFINITION); + PrismObjectDefinition objectDefinition = object.getDefinition().deepClone(true, schemaTransformer::setFullAccessFlags ); + + try { + + PrismObject baseObject = object; + if (object.getOid() != null) { + // Re-read the object from the repository to make sure we have all the properties. + // the object from method parameters may be already processed by the security code + // and properties needed to evaluate authorizations may not be there + // MID-3126, see also MID-3435 + baseObject = cacheRepositoryService.getObject(object.getCompileTimeClass(), object.getOid(), null, result); + } + + // TODO: maybe we need to expose owner resolver in the interface? + ObjectSecurityConstraints securityConstraints = securityEnforcer.compileSecurityConstraints(baseObject, null, task, result); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Security constrains for {}:\n{}", object, securityConstraints==null?"null":securityConstraints.debugDump()); + } + if (securityConstraints == null) { + // Nothing allowed => everything denied + result.setStatus(OperationResultStatus.NOT_APPLICABLE); + return null; + } + + try { + ArchetypePolicyType archetypePolicy = archetypeManager.determineArchetypePolicy(object, result); + if (archetypePolicy != null) { + + schemaTransformer.applyItemsConstraints(objectDefinition, archetypePolicy, result); + + ObjectReferenceType objectTemplateRef = archetypePolicy.getObjectTemplateRef(); + if (objectTemplateRef != null) { + PrismObject objectTemplate = cacheRepositoryService.getObject(ObjectTemplateType.class, objectTemplateRef.getOid(), null, result); + schemaTransformer.applyObjectTemplateToDefinition(objectDefinition, objectTemplate.asObjectable(), result); + } + + } + } catch (ConfigurationException | ObjectNotFoundException e) { + result.recordFatalError(e); + } + + schemaTransformer.applySecurityConstraints(objectDefinition, securityConstraints, phase); + + if (object.canRepresent(ShadowType.class)) { + PrismObject shadow = (PrismObject)object; + String resourceOid = ShadowUtil.getResourceOid(shadow); + if (resourceOid != null) { + Collection> options = createCollection(GetOperationOptions.createReadOnly()); + PrismObject resource; + try { + resource = provisioning.getObject(ResourceType.class, resourceOid, options, task, result); + } catch (CommunicationException | SecurityViolationException | ExpressionEvaluationException e) { + throw new ConfigurationException(e.getMessage(), e); + } + RefinedObjectClassDefinition refinedObjectClassDefinition = getEditObjectClassDefinition(shadow, resource, phase, task, result); + if (refinedObjectClassDefinition != null) { + objectDefinition.getComplexTypeDefinition().toMutable().replaceDefinition(ShadowType.F_ATTRIBUTES, + refinedObjectClassDefinition.toResourceAttributeContainerDefinition()); + + objectDefinition.findContainerDefinition(ItemPath.create(ShadowType.F_ASSOCIATION)).toMutable() + .replaceDefinition(ShadowAssociationType.F_IDENTIFIERS, refinedObjectClassDefinition.toResourceAttributeContainerDefinition(ShadowAssociationType.F_IDENTIFIERS)); + } + } + } + + result.computeStatus(); + return objectDefinition; + + } catch (ConfigurationException | ObjectNotFoundException | ExpressionEvaluationException | SchemaException e) { + result.recordFatalError(e); + throw e; + } + + } + + @Override + public PrismObjectDefinition getEditShadowDefinition(ResourceShadowDiscriminator discr, AuthorizationPhaseType phase, Task task, OperationResult parentResult) throws SchemaException, ConfigurationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, SecurityViolationException { + // HACK hack hack + // Make a dummy shadow instance here and evaluate the schema for that. It is not 100% correct. But good enough for now. + // TODO: refactor when we add better support for multi-tenancy + + PrismObject shadow = prismContext.createObject(ShadowType.class); + ShadowType shadowType = shadow.asObjectable(); + ObjectReferenceType resourceRef = new ObjectReferenceType(); + if (discr != null) { + resourceRef.setOid(discr.getResourceOid()); + shadowType.setResourceRef(resourceRef); + shadowType.setKind(discr.getKind()); + shadowType.setIntent(discr.getIntent()); + shadowType.setObjectClass(discr.getObjectClass()); + } + + return getEditObjectDefinition(shadow, phase, task, parentResult); + } + + @Override + public RefinedObjectClassDefinition getEditObjectClassDefinition(PrismObject shadow, PrismObject resource, AuthorizationPhaseType phase, Task task, OperationResult result) + throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { + Validate.notNull(resource, "Resource must not be null"); + + RefinedResourceSchema refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource); + CompositeRefinedObjectClassDefinition rocd = refinedSchema.determineCompositeObjectClassDefinition(shadow); + if (rocd == null) { + LOGGER.debug("No object class definition for shadow {}, returning null", shadow.getOid()); + return null; + } + LayerRefinedObjectClassDefinition layeredROCD = rocd.forLayer(LayerType.PRESENTATION); + + // TODO: maybe we need to expose owner resolver in the interface? + ObjectSecurityConstraints securityConstraints = securityEnforcer.compileSecurityConstraints(shadow, null, task, result); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Security constrains for {}:\n{}", shadow, securityConstraints==null?"null":securityConstraints.debugDump()); + } + if (securityConstraints == null) { + return null; + } + + ItemPath attributesPath = SchemaConstants.PATH_ATTRIBUTES; + AuthorizationDecisionType attributesReadDecision = schemaTransformer.computeItemDecision(securityConstraints, attributesPath, ModelAuthorizationAction.AUTZ_ACTIONS_URLS_GET, + securityConstraints.findAllItemsDecision(ModelAuthorizationAction.AUTZ_ACTIONS_URLS_GET, phase), phase); + AuthorizationDecisionType attributesAddDecision = schemaTransformer.computeItemDecision(securityConstraints, attributesPath, ModelAuthorizationAction.AUTZ_ACTIONS_URLS_ADD, + securityConstraints.findAllItemsDecision(ModelAuthorizationAction.ADD.getUrl(), phase), phase); + AuthorizationDecisionType attributesModifyDecision = schemaTransformer.computeItemDecision(securityConstraints, attributesPath, ModelAuthorizationAction.AUTZ_ACTIONS_URLS_MODIFY, + securityConstraints.findAllItemsDecision(ModelAuthorizationAction.MODIFY.getUrl(), phase), phase); + LOGGER.trace("Attributes container access read:{}, add:{}, modify:{}", attributesReadDecision, attributesAddDecision, + attributesModifyDecision); + + /* + * We are going to modify attribute definitions list. + * So let's make a (shallow) clone here, although it is probably not strictly necessary. + */ + layeredROCD = layeredROCD.clone(); + for (LayerRefinedAttributeDefinition rAttrDef: layeredROCD.getAttributeDefinitions()) { + ItemPath attributePath = ItemPath.create(ShadowType.F_ATTRIBUTES, rAttrDef.getItemName()); + AuthorizationDecisionType attributeReadDecision = schemaTransformer.computeItemDecision(securityConstraints, attributePath, ModelAuthorizationAction.AUTZ_ACTIONS_URLS_GET, attributesReadDecision, phase); + AuthorizationDecisionType attributeAddDecision = schemaTransformer.computeItemDecision(securityConstraints, attributePath, ModelAuthorizationAction.AUTZ_ACTIONS_URLS_ADD, attributesAddDecision, phase); + AuthorizationDecisionType attributeModifyDecision = schemaTransformer.computeItemDecision(securityConstraints, attributePath, ModelAuthorizationAction.AUTZ_ACTIONS_URLS_MODIFY, attributesModifyDecision, phase); + LOGGER.trace("Attribute {} access read:{}, add:{}, modify:{}", rAttrDef.getItemName(), attributeReadDecision, + attributeAddDecision, attributeModifyDecision); + if (attributeReadDecision != AuthorizationDecisionType.ALLOW) { + ((LayerRefinedAttributeDefinitionImpl) rAttrDef).setOverrideCanRead(false); + } + if (attributeAddDecision != AuthorizationDecisionType.ALLOW) { + ((LayerRefinedAttributeDefinitionImpl) rAttrDef).setOverrideCanAdd(false); + } + if (attributeModifyDecision != AuthorizationDecisionType.ALLOW) { + ((LayerRefinedAttributeDefinitionImpl) rAttrDef).setOverrideCanModify(false); + } + } + + // TODO what about activation and credentials? + + return layeredROCD; + } + + public ItemSecurityConstraints getAllowedRequestAssignmentItems(PrismObject object, PrismObject target, Task task, OperationResult result) throws SchemaException, SecurityViolationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { + return securityEnforcer.getAllowedRequestAssignmentItems(securityContextManager.getPrincipal(), ModelAuthorizationAction.ASSIGN.getUrl(), object, target, null, task, result); + } + + @Override + public Collection> getActionUrls() { + return Arrays.asList(ModelAuthorizationAction.values()); + } + + @Override + public RoleSelectionSpecification getAssignableRoleSpecification(PrismObject focus, Class targetType, int assignmentOrder, Task task, OperationResult parentResult) + throws ObjectNotFoundException, SchemaException, ConfigurationException, ExpressionEvaluationException, CommunicationException, SecurityViolationException { + OperationResult result = parentResult.createMinorSubresult(GET_ASSIGNABLE_ROLE_SPECIFICATION); + + ObjectSecurityConstraints securityConstraints; + try { + securityConstraints = securityEnforcer.compileSecurityConstraints(focus, null, task, result); + } catch (ExpressionEvaluationException | ObjectNotFoundException | SchemaException | CommunicationException | SecurityViolationException e) { + result.recordFatalError(e); + throw e; + } + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Security constrains for getAssignableRoleSpecification on {}:\n{}", focus, securityConstraints==null?null:securityConstraints.debugDump(1)); + } + if (securityConstraints == null) { + return null; + } + + // Global decisions: processing #modify authorizations: allow/deny for all items or allow/deny for assignment/inducement item. + ItemPath assignmentPath; + if (assignmentOrder == 0) { + assignmentPath = SchemaConstants.PATH_ASSIGNMENT; + } else { + assignmentPath = SchemaConstants.PATH_INDUCEMENT; + } + AuthorizationDecisionType assignmentItemDecision = securityConstraints.findItemDecision(assignmentPath, + ModelAuthorizationAction.MODIFY.getUrl(), AuthorizationPhaseType.REQUEST); + LOGGER.trace("getAssignableRoleSpecification decision for {}:{}", assignmentPath, assignmentItemDecision); + if (assignmentItemDecision == AuthorizationDecisionType.ALLOW) { + RoleSelectionSpecification spec = new RoleSelectionSpecification(); + spec.setGlobalFilter(prismContext.queryFactory().createAll()); + result.recordSuccess(); + return spec; + } + if (assignmentItemDecision == AuthorizationDecisionType.DENY) { + result.recordSuccess(); + RoleSelectionSpecification spec = new RoleSelectionSpecification(); + spec.setGlobalFilter(prismContext.queryFactory().createNone()); + return spec; + } + AuthorizationDecisionType allItemsDecision = securityConstraints.findAllItemsDecision(ModelAuthorizationAction.MODIFY.getUrl(), AuthorizationPhaseType.REQUEST); + if (allItemsDecision == AuthorizationDecisionType.ALLOW) { + RoleSelectionSpecification spec = new RoleSelectionSpecification(); + spec.setGlobalFilter(prismContext.queryFactory().createAll()); + result.recordSuccess(); + return spec; + } + if (allItemsDecision == AuthorizationDecisionType.DENY) { + result.recordSuccess(); + RoleSelectionSpecification spec = new RoleSelectionSpecification(); + spec.setGlobalFilter(prismContext.queryFactory().createNone()); + return spec; + } + + // Assignment decisions: processing #assign authorizations + MidPointPrincipal principal = securityEnforcer.getMidPointPrincipal(); + OrderConstraintsType orderConstraints = new OrderConstraintsType(); + orderConstraints.setOrder(assignmentOrder); + List orderConstraintsList = new ArrayList<>(1); + orderConstraintsList.add(orderConstraints); + + FilterGizmo gizmo = new FilterGizmoAssignableRoles(prismContext); + + try { + + RoleSelectionSpecification spec = securityEnforcer.computeSecurityFilter(principal, ModelAuthorizationAction.AUTZ_ACTIONS_URLS_ASSIGN, AuthorizationPhaseType.REQUEST, + targetType, focus, prismContext.queryFactory().createAll(), null, orderConstraintsList, gizmo, task, result); + + result.recordSuccess(); + return spec; + + } catch (SchemaException | ConfigurationException | ObjectNotFoundException | ExpressionEvaluationException e) { + result.recordFatalError(e); + throw e; + } + +// +// // Assignment decisions: processing #assign authorizations +// OrderConstraintsType orderConstraints = new OrderConstraintsType(); +// orderConstraints.setOrder(assignmentOrder); +// List orderConstraintsList = new ArrayList<>(1); +// orderConstraintsList.add(orderConstraints); +// try { +// ObjectFilter filter = securityEnforcer.preProcessObjectFilter(ModelAuthorizationAction.AUTZ_ACTIONS_URLS_ASSIGN, +// AuthorizationPhaseType.REQUEST, targetType, focus, FilterCreationUtil.createAll(prismContext), null, orderConstraintsList, task, result); +// LOGGER.trace("assignableRoleSpec filter: {}", filter); +// spec.setFilter(filter); +// if (filter instanceof NoneFilter) { +// result.recordSuccess(); +// spec.setNoRoleTypes(); +// return spec; +// } else if (filter == null || filter instanceof AllFilter) { +// getGlobalAssignableRoleSpecification(spec, result); +// result.recordSuccess(); +// return spec; +// } else if (filter instanceof OrFilter) { +// Collection allRoleTypeDvals = new ArrayList<>(); +// for (ObjectFilter subfilter: ((OrFilter)filter).getConditions()) { +// Collection roleTypeDvals = getRoleSelectionSpecEntries(subfilter); +// if (roleTypeDvals == null || roleTypeDvals.isEmpty()) { +// // This branch of the OR clause does not have any constraint for roleType +// // therefore all role types are possible (regardless of other branches, this is OR) +// spec = new RoleSelectionSpecification(); +// spec.setFilter(filter); +// getGlobalAssignableRoleSpecification(spec, result); +// result.recordSuccess(); +// return spec; +// } else { +// allRoleTypeDvals.addAll(roleTypeDvals); +// } +// } +// addRoleTypeSpecEntries(spec, allRoleTypeDvals, result); +// } else { +// Collection roleTypeDvals = getRoleSelectionSpecEntries(filter); +// if (roleTypeDvals == null || roleTypeDvals.isEmpty()) { +// getGlobalAssignableRoleSpecification(spec, result); +// result.recordSuccess(); +// return spec; +// } else { +// addRoleTypeSpecEntries(spec, roleTypeDvals, result); +// } +// } +// result.recordSuccess(); +// return spec; +// } catch (SchemaException | ConfigurationException | ObjectNotFoundException | ExpressionEvaluationException e) { +// result.recordFatalError(e); +// throw e; +// } + + + } + + + private Collection createSingleDisplayableValueCollection( + RoleSelectionSpecEntry dval) { + if (dval == null) { + return null; + } + Collection col = new ArrayList<>(1); + col.add(dval); + return col; + } + + private RoleSelectionSpecEntry getRoleSelectionSpecEq(EqualFilter eqFilter) throws SchemaException { + if (QNameUtil.match(RoleType.F_ROLE_TYPE, eqFilter.getElementName()) || QNameUtil.match(RoleType.F_SUBTYPE, eqFilter.getElementName())) { + List> ppvs = eqFilter.getValues(); + if (ppvs.size() > 1) { + throw new SchemaException("More than one value in roleType search filter"); + } + String roleType = ppvs.get(0).getValue(); + RoleSelectionSpecEntry roleTypeDval = new RoleSelectionSpecEntry(roleType, roleType, null); + return roleTypeDval; + } + return null; + } + + + @Override + public ObjectFilter getDonorFilter(Class searchResultType, ObjectFilter origFilter, String targetAuthorizationAction, Task task, OperationResult parentResult) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { + return securityEnforcer.preProcessObjectFilter(ModelAuthorizationAction.AUTZ_ACTIONS_URLS_ATTORNEY, null, searchResultType, null, origFilter, targetAuthorizationAction, null, task, parentResult); + } + + @Override + public boolean canSearch(Class resultType, + Class objectType, String objectOid, boolean includeSpecial, ObjectQuery query, Task task, OperationResult result) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + PrismObject object = null; + if (objectOid != null) { + object = (PrismObject) objectResolver.getObject(objectType, objectOid, null, task, result).asPrismObject(); + } + return securityEnforcer.canSearch(ModelAuthorizationAction.AUTZ_ACTIONS_URLS_SEARCH, null, resultType, object, includeSpecial, query.getFilter(), task, result); + } + + @Override + public AuthenticationsPolicyType getAuthenticationPolicy(PrismObject user, Task task, + OperationResult parentResult) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + // TODO: check for user membership in an organization (later versions) + + OperationResult result = parentResult.createMinorSubresult(GET_AUTHENTICATIONS_POLICY); + return resolvePolicyTypeFromSecurityPolicy(AuthenticationsPolicyType.class, SecurityPolicyType.F_AUTHENTICATION, user, task, result); + + } + + @Override + @Deprecated + public RegistrationsPolicyType getRegistrationPolicy(PrismObject user, Task task, OperationResult parentResult) + throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + // TODO: check for user membership in an organization (later versions) + + OperationResult result = parentResult.createMinorSubresult(GET_REGISTRATIONS_POLICY); + return resolvePolicyTypeFromSecurityPolicy(RegistrationsPolicyType.class, SecurityPolicyType.F_REGISTRATION, user, task, + result); + } + + @Override + public RegistrationsPolicyType getFlowPolicy(PrismObject focus, Task task, OperationResult parentResult) + throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + // TODO: check for user membership in an organization (later versions) + OperationResult result = parentResult.createMinorSubresult(GET_REGISTRATIONS_POLICY); + return resolvePolicyTypeFromSecurityPolicy(RegistrationsPolicyType.class, SecurityPolicyType.F_FLOW, focus, task, + result); + } + + + @Override + public CredentialsPolicyType getCredentialsPolicy(PrismObject focus, Task task, OperationResult parentResult) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + // TODO: check for user membership in an organization (later versions) + + OperationResult result = parentResult.createMinorSubresult(GET_CREDENTIALS_POLICY); + return resolvePolicyTypeFromSecurityPolicy(CredentialsPolicyType.class, SecurityPolicyType.F_CREDENTIALS, focus, task, result); + } + + private C resolvePolicyTypeFromSecurityPolicy(Class type, QName path, PrismObject focus, Task task, OperationResult parentResult) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + + SecurityPolicyType securityPolicyType = getSecurityPolicy(focus, task, parentResult); + if (securityPolicyType == null) { + return null; + } + PrismContainer container = securityPolicyType.asPrismObject().findContainer(ItemName.fromQName(path)); + if (container == null) { + return null; + } + PrismContainerValue containerValue = container.getValue(); + parentResult.recordSuccess(); + return containerValue.asContainerable(); + } + + @Override + public SecurityPolicyType getSecurityPolicy(PrismObject focus, Task task, OperationResult parentResult) + throws SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + OperationResult result = parentResult.createMinorSubresult(GET_SECURITY_POLICY); + try { + PrismObject systemConfiguration = systemObjectCache.getSystemConfiguration(result); + if (systemConfiguration == null) { + result.recordNotApplicableIfUnknown(); + return null; + } + + SecurityPolicyType securityPolicyType = securityHelper.locateSecurityPolicy(focus, systemConfiguration, task, result); + if (securityPolicyType == null) { + result.recordNotApplicableIfUnknown(); + return null; + } + + return securityPolicyType; + } catch (Throwable e) { + result.recordFatalError(e); + throw e; + } finally { + result.computeStatusIfUnknown(); + } + } + + @NotNull + public CompiledGuiProfile getCompiledGuiProfile(Task task, OperationResult parentResult) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + MidPointPrincipal principal = null; + try { + principal = securityContextManager.getPrincipal(); + } catch (SecurityViolationException e) { + LOGGER.warn("Security violation while getting principlal to get GUI config: {}", e.getMessage(), e); + } + + if (principal == null || !(principal instanceof GuiProfiledPrincipal)) { + // May be used for unathenticated user, error pages and so on + return guiProfileCompiler.getGlobalCompiledGuiProfile(task, parentResult); + } else { + return ((GuiProfiledPrincipal)principal).getCompiledGuiProfile(); + } + } + + @Override + public List getLoggedInPrincipals(Task task, OperationResult result) { + // TODO some authorization here? + return clusterwideUserSessionManager.getLoggedInPrincipals(task, result); + } + + @Override + public void terminateSessions(TerminateSessionEvent terminateSessionEvent, Task task, OperationResult result) { + // TODO some authorization here? + clusterwideUserSessionManager.terminateSessions(terminateSessionEvent, task, result); + } + + @Override + public SystemConfigurationType getSystemConfiguration(OperationResult parentResult) throws ObjectNotFoundException, SchemaException { + PrismObject systemConfiguration = systemObjectCache.getSystemConfiguration(parentResult); + if (systemConfiguration == null) { + return null; + } + return systemConfiguration.asObjectable(); + } + + @Override + public DeploymentInformationType getDeploymentInformationConfiguration(OperationResult parentResult) throws ObjectNotFoundException, SchemaException { + PrismObject systemConfiguration = systemObjectCache.getSystemConfiguration(parentResult); + if (systemConfiguration == null) { + return null; + } + return systemConfiguration.asObjectable().getDeploymentInformation(); + } + + @Override + public SystemConfigurationAuditType getAuditConfiguration(OperationResult parentResult) throws ObjectNotFoundException, SchemaException { + PrismObject systemConfiguration = systemObjectCache.getSystemConfiguration(parentResult); + if (systemConfiguration == null) { + return null; + } + return systemConfiguration.asObjectable().getAudit(); + } + + @Override + public List getMergeConfiguration(OperationResult parentResult) throws ObjectNotFoundException, SchemaException { + PrismObject systemConfiguration = systemObjectCache.getSystemConfiguration(parentResult); + if (systemConfiguration == null) { + return null; + } + return systemConfiguration.asObjectable().getMergeConfiguration(); + } + + @Override + public AccessCertificationConfigurationType getCertificationConfiguration(OperationResult parentResult) throws ObjectNotFoundException, SchemaException { + PrismObject systemConfiguration = systemObjectCache.getSystemConfiguration(parentResult); + if (systemConfiguration == null) { + return null; + } + return systemConfiguration.asObjectable().getAccessCertification(); + } + + @Override + public boolean checkPassword(String userOid, ProtectedStringType password, Task task, OperationResult parentResult) + throws ObjectNotFoundException, SchemaException { + OperationResult result = parentResult.createMinorSubresult(CHECK_PASSWORD); + UserType userType; + try { + userType = objectResolver.getObjectSimple(UserType.class, userOid, null, task, result); + } catch (ObjectNotFoundException e) { + result.recordFatalError(e); + throw e; + } + if (userType.getCredentials() == null || userType.getCredentials().getPassword() == null + || userType.getCredentials().getPassword().getValue() == null) { + return password == null; + } + ProtectedStringType currentPassword = userType.getCredentials().getPassword().getValue(); + boolean cmp; + try { + cmp = protector.compareCleartext(password, currentPassword); + } catch (EncryptionException e) { + result.recordFatalError(e); + throw new SystemException(e.getMessage(),e); + } + result.recordSuccess(); + return cmp; + } + + @Override + public List visualizeDeltas(List> deltas, Task task, OperationResult result) throws SchemaException, ExpressionEvaluationException { + return visualizer.visualizeDeltas(deltas, task, result); + } + + @Override + @NotNull + public Scene visualizeDelta(ObjectDelta delta, Task task, OperationResult result) throws SchemaException, ExpressionEvaluationException { + return visualizer.visualizeDelta(delta, task, result); + } + + @Override + @NotNull + public Scene visualizeDelta(ObjectDelta delta, boolean includeOperationalItems, Task task, OperationResult result) throws SchemaException, ExpressionEvaluationException{ + return visualizer.visualizeDelta(delta, null, includeOperationalItems, task, result); + } + + @Override + @NotNull + public Scene visualizeDelta(ObjectDelta delta, boolean includeOperationalItems, ObjectReferenceType objectRef, Task task, OperationResult result) throws SchemaException, ExpressionEvaluationException { + return visualizer.visualizeDelta(delta, objectRef, task, result); + } + + @Override + public List getConnectorOperationalStatus(String resourceOid, Task task, OperationResult parentResult) + throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + OperationResult result = parentResult.createMinorSubresult(GET_CONNECTOR_OPERATIONAL_STATUS); + List status; + try { + status = provisioning.getConnectorOperationalStatus(resourceOid, task, result); + } catch (SchemaException | ObjectNotFoundException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) { + result.recordFatalError(e); + throw e; + } + result.computeStatus(); + return status; + } + + @Override + public MergeDeltas mergeObjectsPreviewDeltas(Class type, String leftOid, + String rightOid, String mergeConfigurationName, Task task, OperationResult parentResult) + throws ObjectNotFoundException, SchemaException, ConfigurationException, ExpressionEvaluationException, CommunicationException, SecurityViolationException { + OperationResult result = parentResult.createMinorSubresult(MERGE_OBJECTS_PREVIEW_DELTA); + + try { + + MergeDeltas mergeDeltas = objectMerger.computeMergeDeltas(type, leftOid, rightOid, mergeConfigurationName, task, result); + + result.computeStatus(); + return mergeDeltas; + + } catch (ObjectNotFoundException | SchemaException | ConfigurationException | ExpressionEvaluationException | + CommunicationException | SecurityViolationException | RuntimeException | Error e) { + result.recordFatalError(e); + throw e; + } + } + + @Override + public PrismObject mergeObjectsPreviewObject(Class type, String leftOid, + String rightOid, String mergeConfigurationName, Task task, OperationResult parentResult) + throws ObjectNotFoundException, SchemaException, ConfigurationException, ExpressionEvaluationException, CommunicationException, SecurityViolationException { + OperationResult result = parentResult.createMinorSubresult(MERGE_OBJECTS_PREVIEW_OBJECT); + + try { + + MergeDeltas mergeDeltas = objectMerger.computeMergeDeltas(type, leftOid, rightOid, mergeConfigurationName, task, result); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Merge preview {} + {} deltas:\n{}", leftOid, rightOid, mergeDeltas.debugDump(1)); + } + + final PrismObject objectLeft = (PrismObject) objectResolver.getObjectSimple(type, leftOid, null, task, result).asPrismObject(); + + if (mergeDeltas == null) { + result.computeStatus(); + return objectLeft; + } + + mergeDeltas.getLeftObjectDelta().applyTo(objectLeft); + mergeDeltas.getLeftLinkDelta().applyTo(objectLeft); + + result.computeStatus(); + return objectLeft; + + } catch (ObjectNotFoundException | SchemaException | ConfigurationException | ExpressionEvaluationException | + CommunicationException | SecurityViolationException | RuntimeException | Error e) { + result.recordFatalError(e); + throw e; + } + } + + @Override + public String generateValue(ValuePolicyType policy, int defaultLength, boolean generateMinimalSize, + PrismObject object, String shortDesc, Task task, OperationResult parentResult) throws ExpressionEvaluationException, SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException { + return policyProcessor.generate(null, policy, defaultLength, generateMinimalSize, createOriginResolver(object, parentResult), shortDesc, task, parentResult); + } + + @Override + public void generateValue(PrismObject object, PolicyItemsDefinitionType policyItemsDefinition, + Task task, OperationResult parentResult) throws ObjectAlreadyExistsException, ExpressionEvaluationException, SchemaException, ObjectNotFoundException, + CommunicationException, ConfigurationException, SecurityViolationException, PolicyViolationException { + + OperationResult result = parentResult.createSubresult(OPERATION_GENERATE_VALUE); + + + ValuePolicyType valuePolicy = null; + try { + valuePolicy = getValuePolicy(object, task, result); + } catch (ObjectNotFoundException | SchemaException | CommunicationException + | ConfigurationException | SecurityViolationException + | ExpressionEvaluationException e) { + LOGGER.error("Failed to get value policy for generating value. ", e); + result.recordFatalError("Error while getting value policy. Reason: " + e.getMessage(), e); + throw e; + } + + Collection> deltasToExecute = new ArrayList<>(); + for (PolicyItemDefinitionType policyItemDefinition : policyItemsDefinition.getPolicyItemDefinition()) { + OperationResult generateValueResult = parentResult.createSubresult(OPERATION_GENERATE_VALUE); + + LOGGER.trace("Default value policy: {}" , valuePolicy); + try { + generateValue(object, valuePolicy, policyItemDefinition, task, generateValueResult); + } catch (ExpressionEvaluationException | SchemaException | ObjectNotFoundException + | CommunicationException | ConfigurationException | SecurityViolationException e) { + LOGGER.error("Failed to generate value for {} ", policyItemDefinition, e); + generateValueResult.recordFatalError("Failed to generate value for " + policyItemDefinition + ". Reason: " + e.getMessage(), e); + policyItemDefinition.setResult(generateValueResult.createOperationResultType()); + continue; + } + + //TODO: not sure about the bulk actions here + ItemPath path = getPath(policyItemDefinition); + if (path == null) { + if (isExecute(policyItemDefinition)) { + LOGGER.error("No item path defined in the target for policy item definition. Cannot generate value"); + generateValueResult.recordFatalError( + "No item path defined in the target for policy item definition. Cannot generate value"); + continue; + } + } + + PrismPropertyDefinition propertyDef = null; + if (path != null) { + result.addArbitraryObjectAsParam("policyItemPath", path); + + propertyDef = getItemDefinition(object, path); + if (propertyDef == null) { + if (isExecute(policyItemDefinition)) { + LOGGER.error("No definition for property {} in object. Is the path referencing prism property?" + path, + object); + generateValueResult.recordFatalError("No definition for property " + path + " in object " + object + + ". Is the path referencing prism property?"); + continue; + } + + } + } + // end of not sure + + collectDeltasForGeneratedValuesIfNeeded(object, policyItemDefinition, deltasToExecute, path, propertyDef, generateValueResult); + generateValueResult.computeStatusIfUnknown(); + } + result.computeStatus(); + if (!result.isAcceptable()) { + return; + } + try { + if (!deltasToExecute.isEmpty()) { + if (object == null) { + LOGGER.error("Cannot execute changes for generated values, no object specified in request."); + result.recordFatalError("Cannot execute changes for generated values, no object specified in request."); + throw new SchemaException("Cannot execute changes for generated values, no object specified in request."); + } + String oid = object.getOid(); + Class clazz = (Class) object.asObjectable().getClass(); + modelCrudService.modifyObject(clazz, oid, deltasToExecute, null, task, result); + + } + } catch (ObjectNotFoundException | SchemaException | ExpressionEvaluationException + | CommunicationException | ConfigurationException | ObjectAlreadyExistsException + | PolicyViolationException | SecurityViolationException e) { + LOGGER.error("Could not execute deltas for generated values. Reason: " + e.getMessage(), e); + result.recordFatalError("Could not execute deltas for gegenerated values. Reason: "+ e.getMessage(), e); + throw e; + } + + + } + + private boolean isExecute(PolicyItemDefinitionType policyItemDefinition) { + if (policyItemDefinition.isExecute() == null) { + return false; + } + + return policyItemDefinition.isExecute().booleanValue(); + } + private ItemPath getPath(PolicyItemDefinitionType policyItemDefinition) { + PolicyItemTargetType target = policyItemDefinition.getTarget(); + if (target == null) { + return null; + } + ItemPathType itemPathType = target.getPath(); + return itemPathType != null ? itemPathType.getItemPath() : null; + } + + private PrismPropertyDefinition getItemDefinition(PrismObject object, ItemPath path) { + ItemDefinition itemDef = object.getDefinition().findItemDefinition(path); + if (itemDef == null) { + return null; + } else if (!(itemDef instanceof PrismPropertyDefinition)) { + return null; + } + + return (PrismPropertyDefinition) itemDef; + } + + private void collectDeltasForGeneratedValuesIfNeeded(PrismObject object, + PolicyItemDefinitionType policyItemDefinition, Collection> deltasToExecute, ItemPath path, + PrismPropertyDefinition itemDef, OperationResult result) throws SchemaException { + + Object value = policyItemDefinition.getValue(); + + if (itemDef != null){ + if (ProtectedStringType.COMPLEX_TYPE.equals(itemDef.getTypeName())) { + ProtectedStringType pst = new ProtectedStringType(); + pst.setClearValue((String) value); + value = pst; + } else if (PolyStringType.COMPLEX_TYPE.equals(itemDef.getTypeName())) { + value = new PolyString((String) value); + } + } + if (object == null && isExecute(policyItemDefinition)) { + LOGGER.warn("Cannot apply generated changes and cannot execute them becasue there is no target object specified."); + result.recordFatalError("Cannot apply generated changes and cannot execute them becasue there is no target object specified."); + return; + } + if (object != null) { + PropertyDelta propertyDelta = prismContext.deltaFactory().property() + .createModificationReplaceProperty(path, object.getDefinition(), value); + propertyDelta.applyTo(object); // in bulk actions we need to modify original objects - hope that REST is OK with this + if (BooleanUtils.isTrue(policyItemDefinition.isExecute())) { + deltasToExecute.add(propertyDelta); + } + } + + } + + private void generateValue(PrismObject object, ValuePolicyType defaultPolicy, + PolicyItemDefinitionType policyItemDefinition, Task task, OperationResult result) + throws ExpressionEvaluationException, SchemaException, ObjectNotFoundException, CommunicationException, + ConfigurationException, SecurityViolationException { + + PolicyItemTargetType target = policyItemDefinition.getTarget(); + if ((target == null || ItemPathTypeUtil.isEmpty(target.getPath())) && isExecute(policyItemDefinition)) { + LOGGER.error("Target item path must be defined"); + throw new SchemaException("Target item path must be defined"); + } + ItemPath targetPath = null; + + if (target != null) { + targetPath = target.getPath().getItemPath(); + } + + ValuePolicyType valuePolicy = resolveValuePolicy(policyItemDefinition, defaultPolicy, task, result); + LOGGER.trace("Value policy used for generating new value : {}", valuePolicy); + StringPolicyType stringPolicy = valuePolicy != null ? valuePolicy.getStringPolicy() : null; + if (stringPolicy == null) { + LOGGER.trace("No sting policy defined. Cannot generate value."); + result.recordFatalError("No string policy defined. Cannot generate value"); + return; +// throw new SchemaException("No value policy for " + targetPath); + } + + String newValue = policyProcessor.generate(targetPath, valuePolicy, 10, false, createOriginResolver(object, result), + "generating value for" + targetPath, task, result); + policyItemDefinition.setValue(newValue); + } + + private ValuePolicyType resolveValuePolicy(PolicyItemDefinitionType policyItemDefinition, ValuePolicyType defaultPolicy, + Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + if (policyItemDefinition.getValuePolicyRef() != null) { + LOGGER.trace("Trying to resolve value policy {} for policy item definition", policyItemDefinition); + return objectResolver.resolve(policyItemDefinition.getValuePolicyRef(), ValuePolicyType.class, null, + "valuePolicyRef in policyItemDefinition", task, result); + } + + return defaultPolicy; + } + + public void validateValue(PrismObject object, PolicyItemsDefinitionType policyItemsDefinition, + Task task, OperationResult parentResult) throws ExpressionEvaluationException, SchemaException, ObjectNotFoundException, + CommunicationException, ConfigurationException, SecurityViolationException, PolicyViolationException { + ValuePolicyType valuePolicy = getValuePolicy(object, task, parentResult); + for (PolicyItemDefinitionType policyItemDefinition : policyItemsDefinition.getPolicyItemDefinition()) { + validateValue(object, valuePolicy, policyItemDefinition, task, parentResult); + } + } + + private ValuePolicyType getValuePolicy(PrismObject object, Task task, + OperationResult parentResult) throws ObjectNotFoundException, SchemaException, CommunicationException, + ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + // user-level policy + CredentialsPolicyType credentialsPolicy = null; + PrismObject user = null; + if (object != null && object.getCompileTimeClass().isAssignableFrom(UserType.class)) { + LOGGER.trace("Start to resolve policy for user"); + user = (PrismObject) object; + credentialsPolicy = getCredentialsPolicy(user, task, parentResult); + LOGGER.trace("Resolved user policy: {}", credentialsPolicy); + } + + SystemConfigurationType systemConfigurationType = getSystemConfiguration(parentResult); + if (!containsValuePolicyDefinition(credentialsPolicy)) { + SecurityPolicyType securityPolicy = securityHelper.locateGlobalSecurityPolicy(user, systemConfigurationType.asPrismObject(), task, parentResult); + if (securityPolicy != null) { + credentialsPolicy = securityPolicy.getCredentials(); + LOGGER.trace("Resolved policy from global security policy: {}", credentialsPolicy); + } + } + + if (containsValuePolicyDefinition(credentialsPolicy)) { + if (credentialsPolicy.getPassword().getValuePolicyRef() != null) { + return objectResolver.resolve(credentialsPolicy.getPassword().getValuePolicyRef(), ValuePolicyType.class, null, "valuePolicyRef in password credential policy", task, parentResult); + } + } + + return null; + } + + private boolean containsValuePolicyDefinition(CredentialsPolicyType policy) { + if (policy == null) { + return false; + } + + if (policy.getPassword() == null) { + return false; + } + + if (policy.getPassword().getValuePolicyRef() != null) { + return true; + } + + return false; + } + + private boolean validateValue(PrismObject object, ValuePolicyType policy, PolicyItemDefinitionType policyItemDefinition, Task task, OperationResult parentResult) throws ExpressionEvaluationException, SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, PolicyViolationException { + + ValuePolicyType stringPolicy = resolveValuePolicy(policyItemDefinition, policy, task, parentResult); + + Object value = policyItemDefinition.getValue(); + String valueToValidate; + if (value instanceof RawType) { + valueToValidate = ((RawType) value).getParsedRealValue(String.class); + } else { + valueToValidate = (String) value; + } + + List valuesToValidate = new ArrayList<>(); + PolicyItemTargetType target = policyItemDefinition.getTarget(); + ItemPath path = target != null ? target.getPath().getItemPath() : null; + if (StringUtils.isNotEmpty(valueToValidate)) { + valuesToValidate.add(valueToValidate); + } else { + if (target == null || target.getPath() == null) { + LOGGER.error("Target item path must be defined"); + parentResult.recordFatalError("Target item path must be defined"); + throw new SchemaException("Target item path must be defined"); + } + if (object == null) { + LOGGER.error("Object which values should be validated is null. Nothing to validate."); + parentResult.recordFatalError("Object which values should be validated is null. Nothing to validate."); + throw new SchemaException("Object which values should be validated is null. Nothing to validate."); + } + + PrismProperty property = object.findProperty(path); + if (property == null || property.isEmpty()) { + LOGGER.error("Attribute {} has no value. Nothing to validate.", property); + parentResult.recordFatalError("Attribute " + property + " has no value. Nothing to validate"); + throw new SchemaException("Attribute " + property + " has no value. Nothing to validate"); + } + + + PrismPropertyDefinition itemToValidateDefinition = property.getDefinition(); + QName definitionName = itemToValidateDefinition.getTypeName(); + if (!isSupportedType(definitionName)) { + LOGGER.error("Trying to validate string policy on the property of type {} failed. Unsupported type.", + itemToValidateDefinition); + parentResult.recordFatalError("Trying to validate string policy on the property of type " + + itemToValidateDefinition + " failed. Unsupported type."); + throw new SchemaException("Trying to validate string policy on the property of type " + + itemToValidateDefinition + " failed. Unsupported type."); + } + + if (itemToValidateDefinition.isSingleValue()) { + if (definitionName.equals(PolyStringType.COMPLEX_TYPE)) { + valueToValidate = ((PolyString) property.getRealValue()).getOrig(); + + } else if (definitionName.equals(ProtectedStringType.COMPLEX_TYPE)){ + ProtectedStringType protectedString = ((ProtectedStringType) property.getRealValue()); + valueToValidate = getClearValue(protectedString); + + + } else { + valueToValidate = (String) property.getRealValue(); + } + valuesToValidate.add(valueToValidate); + } else { + if (definitionName.equals(DOMUtil.XSD_STRING)) { + valuesToValidate.addAll(property.getRealValues(String.class)); + } else if (definitionName.equals(ProtectedStringType.COMPLEX_TYPE)) { + for (ProtectedStringType protectedString : property.getRealValues(ProtectedStringType.class)) { + valuesToValidate.add(getClearValue(protectedString)); + } + } else { + for (PolyString val : property.getRealValues(PolyString.class)) { + valuesToValidate.add(val.getOrig()); + } + } + } + + } + + for (String newValue : valuesToValidate) { + OperationResult result = parentResult.createSubresult(OPERATION_VALIDATE_VALUE + ".value"); + if (path != null ) result.addParam("path", path.toString()); + result.addParam("valueToValidate", newValue); + + ObjectValuePolicyEvaluator.Builder evaluatorBuilder = new ObjectValuePolicyEvaluator.Builder() + .valuePolicy(stringPolicy) + .valuePolicyProcessor(policyProcessor) + .protector(protector) + .valueItemPath(path) + .originResolver(getOriginResolver(object)) + .task(task) + .shortDesc(" rest validate "); + O objectable = object != null ? object.asObjectable() : null; + if (path != null && objectable instanceof FocusType) { + //noinspection unchecked + PrismObject focus = (PrismObject) object; + if (path.isSuperPathOrEquivalent(SchemaConstants.PATH_PASSWORD)) { + evaluatorBuilder.securityPolicy(getSecurityPolicy(focus, task, parentResult)); + PrismContainer passwordContainer = focus.findContainer(SchemaConstants.PATH_PASSWORD); + PasswordType password = passwordContainer != null ? passwordContainer.getValue().asContainerable() : null; + evaluatorBuilder.oldCredential(password); + } else if (path.isSuperPathOrEquivalent(SchemaConstants.PATH_SECURITY_QUESTIONS)) { + LOGGER.trace("Setting security questions related policy."); + SecurityPolicyType securityPolicy = getSecurityPolicy(focus, task, parentResult); + evaluatorBuilder.securityPolicy(securityPolicy); + PrismContainer securityQuestionsContainer = + focus.findContainer(SchemaConstants.PATH_SECURITY_QUESTIONS); + SecurityQuestionsCredentialsType securityQuestions = securityQuestionsContainer != null ? + securityQuestionsContainer.getValue().asContainerable() : null; + //evaluatorBuilder.oldCredentialType(securityQuestions); // TODO what with this? + evaluatorBuilder.valuePolicy(resolveSecurityQuestionsPolicy(securityPolicy, task, parentResult)); + } + } + evaluatorBuilder.now(clock.currentTimeXMLGregorianCalendar()); + LOGGER.trace("Validating value started"); + evaluatorBuilder.build().validateStringValue(newValue, result); + LOGGER.trace("Validating value finished"); +// + result.computeStatus(); + +// if (!policyProcessor.validateValue(newValue, stringPolicy, createOriginResolver(object, result), "validate value " + (path!= null ? "for " + path : "") + " for " + object + " value " + valueToValidate, task, result)) { +// result.recordFatalError("Validation for value " + newValue + " against policy " + stringPolicy + " failed"); +// LOGGER.error("Validation for value {} against policy {} failed", newValue, stringPolicy); +// } + + } + + parentResult.computeStatus(); + policyItemDefinition.setResult(parentResult.createOperationResultType()); + + return parentResult.isAcceptable(); + + } + + /** + * @param securityPolicy + * @return + * @throws ExpressionEvaluationException + * @throws SecurityViolationException + * @throws ConfigurationException + * @throws CommunicationException + * @throws SchemaException + * @throws ObjectNotFoundException + */ + private ValuePolicyType resolveSecurityQuestionsPolicy(SecurityPolicyType securityPolicy, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + if (securityPolicy == null) { + return null; + } + + CredentialsPolicyType credentialsPolicy = securityPolicy.getCredentials(); + if (credentialsPolicy == null) { + return null; + } + + SecurityQuestionsCredentialsPolicyType securityQuestionsPolicy = credentialsPolicy.getSecurityQuestions(); + if (securityQuestionsPolicy == null) { + return null; + } + + ObjectReferenceType policyRef = securityQuestionsPolicy.getValuePolicyRef(); + if (policyRef == null) { + return null; + } + + return objectResolver.resolve(policyRef, ValuePolicyType.class, null, " resolve value policy for security questions", task, result); + } + + private ObjectBasedValuePolicyOriginResolver getOriginResolver(PrismObject object) { + if (object != null && UserType.class.equals(object.getCompileTimeClass())) { + return new FocusValuePolicyOriginResolver<>((PrismObject) object, objectResolver); + } + + //TODO not supported yet, throw exception instead of null??? + return null; + } + + private ObjectBasedValuePolicyOriginResolver createOriginResolver(PrismObject object, OperationResult result) throws SchemaException { + if (object == null) { + return null; + } + if (object.canRepresent(UserType.class)) { + return new FocusValuePolicyOriginResolver<>((PrismObject) object, objectResolver); + } + if (object.canRepresent(ShadowType.class)) { + return new ShadowValuePolicyOriginResolver((PrismObject) object, objectResolver); + } + SchemaException e = new SchemaException("Unsupport object type "+object); + result.recordFatalError(e); + throw e; + } + + private boolean isSupportedType(QName type) { + + if (QNameUtil.qNameToUri(type).equals(QNameUtil.qNameToUri(DOMUtil.XSD_STRING))){ + return true; + } + + if (QNameUtil.qNameToUri(type).equals(QNameUtil.qNameToUri(PolyStringType.COMPLEX_TYPE))) { + return true; + } + + if (QNameUtil.qNameToUri(type).equals(QNameUtil.qNameToUri(ProtectedStringType.COMPLEX_TYPE))) { + return true; + } + + return false; + } + + private String getClearValue(ProtectedStringType protectedString) throws SchemaException, PolicyViolationException { + try { + if (protectedString.isEncrypted()) { + + return protector.decryptString(protectedString); + + } else if (protectedString.getClearValue() != null) { + return protector.decryptString(protectedString); + } else if (protectedString.isHashed()) { + throw new SchemaException("Cannot validate value of hashed password"); + } + } catch (EncryptionException e) { + throw new PolicyViolationException(e.getMessage(), e); + } + return null; + } + + // TODO TODO TODO deduplicate this somehow! + + @NotNull + @Override + public List getDeputyAssignees(AbstractWorkItemType workItem, Task task, OperationResult parentResult) + throws SchemaException { + OperationResult result = parentResult.createMinorSubresult(GET_DEPUTY_ASSIGNEES); + RepositoryCache.enter(cacheConfigurationManager); + try { + Set oidsToSkip = new HashSet<>(); + List deputies = new ArrayList<>(); + workItem.getAssigneeRef().forEach(a -> oidsToSkip.add(a.getOid())); + getDeputyAssignees(deputies, workItem, oidsToSkip, task, result); + result.computeStatusIfUnknown(); + return deputies; + } catch (Throwable t) { + result.recordFatalError(t.getMessage(), t); + throw t; + } finally { + RepositoryCache.exit(); + } + } + + @NotNull + @Override + public List getDeputyAssignees(ObjectReferenceType assigneeRef, QName limitationItemName, Task task, + OperationResult parentResult) throws SchemaException { + OperationResult result = parentResult.createMinorSubresult(GET_DEPUTY_ASSIGNEES); + RepositoryCache.enter(cacheConfigurationManager); + try { + Set oidsToSkip = new HashSet<>(); + oidsToSkip.add(assigneeRef.getOid()); + List deputies = new ArrayList<>(); + getDeputyAssigneesNoWorkItem(deputies, assigneeRef, limitationItemName, oidsToSkip, task, result); + result.computeStatusIfUnknown(); + return deputies; + } catch (Throwable t) { + result.recordFatalError(t.getMessage(), t); + throw t; + } finally { + RepositoryCache.exit(); + } + } + + private void getDeputyAssignees(List deputies, AbstractWorkItemType workItem, Set oidsToSkip, + Task task, OperationResult result) throws SchemaException { + List assigneeReferencesToQuery = workItem.getAssigneeRef().stream() + .map(assigneeRef -> assigneeRef.clone().relation(PrismConstants.Q_ANY).asReferenceValue()) + .collect(Collectors.toList()); + ObjectQuery query = prismContext.queryFor(UserType.class) + .item(UserType.F_DELEGATED_REF).ref(assigneeReferencesToQuery) + .build(); + SearchResultList> potentialDeputies = cacheRepositoryService + .searchObjects(UserType.class, query, null, result); + for (PrismObject potentialDeputy : potentialDeputies) { + if (oidsToSkip.contains(potentialDeputy.getOid())) { + continue; + } + if (determineDeputyValidity(potentialDeputy, workItem.getAssigneeRef(), workItem, OtherPrivilegesLimitationType.F_APPROVAL_WORK_ITEMS, task, result)) { + deputies.add(ObjectTypeUtil.createObjectRefWithFullObject(potentialDeputy, prismContext)); + oidsToSkip.add(potentialDeputy.getOid()); + } + } + } + + private void getDeputyAssigneesNoWorkItem(List deputies, ObjectReferenceType assigneeRef, + QName limitationItemName, Set oidsToSkip, + Task task, OperationResult result) throws SchemaException { + PrismReferenceValue assigneeReferenceToQuery = assigneeRef.clone().relation(PrismConstants.Q_ANY).asReferenceValue(); + ObjectQuery query = prismContext.queryFor(UserType.class) + .item(UserType.F_DELEGATED_REF).ref(assigneeReferenceToQuery) + .build(); + SearchResultList> potentialDeputies = cacheRepositoryService + .searchObjects(UserType.class, query, null, result); + for (PrismObject potentialDeputy : potentialDeputies) { + if (oidsToSkip.contains(potentialDeputy.getOid())) { + continue; + } + if (determineDeputyValidity(potentialDeputy, Collections.singletonList(assigneeRef), null, limitationItemName, task, result)) { + deputies.add(ObjectTypeUtil.createObjectRefWithFullObject(potentialDeputy, prismContext)); + oidsToSkip.add(potentialDeputy.getOid()); + } + } + } + + private boolean determineDeputyValidity(PrismObject potentialDeputy, List assignees, + @Nullable AbstractWorkItemType workItem, QName privilegeLimitationItemName, Task task, OperationResult result) { + AssignmentEvaluator.Builder builder = + new AssignmentEvaluator.Builder() + .repository(cacheRepositoryService) + .focusOdo(new ObjectDeltaObject<>(potentialDeputy, null, potentialDeputy, potentialDeputy.getDefinition())) + .channel(null) + .objectResolver(objectResolver) + .systemObjectCache(systemObjectCache) + .relationRegistry(relationRegistry) + .prismContext(prismContext) + .mappingFactory(mappingFactory) + .mappingEvaluator(mappingEvaluator) + .activationComputer(activationComputer) + .now(clock.currentTimeXMLGregorianCalendar()) + .loginMode(true) + // We do not have real lens context here. But the push methods in ModelExpressionThreadLocalHolder + // will need something to push on the stack. So give them context placeholder. + .lensContext(new LensContextPlaceholder<>(potentialDeputy, prismContext)); + AssignmentEvaluator assignmentEvaluator = builder.build(); + + for (AssignmentType assignmentType: potentialDeputy.asObjectable().getAssignment()) { + if (!DeputyUtils.isDelegationAssignment(assignmentType, relationRegistry)) { + continue; + } + try { + ItemDeltaItem, PrismContainerDefinition> assignmentIdi = + new ItemDeltaItem<>(LensUtil.createAssignmentSingleValueContainer(assignmentType)); + // TODO some special mode for verification of the validity - we don't need complete calculation here! + EvaluatedAssignment assignment = assignmentEvaluator + .evaluate(assignmentIdi, PlusMinusZero.ZERO, false, potentialDeputy.asObjectable(), + potentialDeputy.toString(), false, task, result); + if (!assignment.isValid()) { + continue; + } + for (EvaluatedAssignmentTarget target : assignment.getRoles().getNonNegativeValues()) { + if (target.getTarget() != null && target.getTarget().getOid() != null + && DeputyUtils.isDelegationPath(target.getAssignmentPath(), relationRegistry) + && ObjectTypeUtil.containsOid(assignees, target.getTarget().getOid())) { + List limitations = DeputyUtils.extractLimitations(target.getAssignmentPath()); + if (workItem != null && DeputyUtils.limitationsAllow(limitations, privilegeLimitationItemName, workItem) + || workItem == null && SchemaDeputyUtil.limitationsAllow(limitations, privilegeLimitationItemName)) { + return true; + } + } + } + } catch (CommonException e) { + LoggingUtils.logUnexpectedException(LOGGER, "Couldn't verify 'deputy' relation between {} and {} for work item {}; assignment: {}", + e, potentialDeputy, assignees, workItem, assignmentType); + } + } + return false; + } + + @Override + public ActivationStatusType getAssignmentEffectiveStatus(String lifecycleStatus, ActivationType activationType) { + return activationComputer.getEffectiveStatus(lifecycleStatus, activationType, null); + } + + @Override + public MidPointPrincipal assumePowerOfAttorney(PrismObject donor, Task task, OperationResult result) throws SchemaException, SecurityViolationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { + MidPointPrincipal attorneyPrincipal = securityContextManager.getPrincipal(); + MidPointPrincipal donorPrincipal = securityEnforcer.createDonorPrincipal(attorneyPrincipal, ModelAuthorizationAction.ATTORNEY.getUrl(), donor, task, result); + + // TODO: audit switch + + securityContextManager.setupPreAuthenticatedSecurityContext(donorPrincipal); + + return donorPrincipal; + } + + @Override + public MidPointPrincipal dropPowerOfAttorney(Task task, OperationResult result) throws SchemaException, SecurityViolationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { + MidPointPrincipal donorPrincipal = securityContextManager.getPrincipal(); + if (donorPrincipal.getAttorney() == null) { + throw new IllegalStateException("Attempt to drop attorney powers using non-donor principal "+donorPrincipal); + } + MidPointPrincipal previousPrincipal = donorPrincipal.getPreviousPrincipal(); + if (previousPrincipal == null) { + throw new IllegalStateException("Attempt to drop attorney powers, but no previous principal in "+donorPrincipal); + } + + // TODO: audit switch + + // TODO: maybe refresh previous principal using userProfileService? + securityContextManager.setupPreAuthenticatedSecurityContext(previousPrincipal); + + return previousPrincipal; + } + + @Override + @NotNull + public LocalizableMessageType createLocalizableMessageType(LocalizableMessageTemplateType template, + VariablesMap variables, Task task, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, + ConfigurationException, SecurityViolationException { + ExpressionVariables vars = new ExpressionVariables(); + vars.putAll(variables); + return LensUtil.interpretLocalizableMessageTemplate(template, vars, expressionFactory, prismContext, task, result); + } + + @Override + public ExecuteCredentialResetResponseType executeCredentialsReset(PrismObject user, + ExecuteCredentialResetRequestType executeCredentialResetRequest, Task task, OperationResult parentResult) + throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, + SecurityViolationException, ExpressionEvaluationException, ObjectAlreadyExistsException, PolicyViolationException { + LocalizableMessageBuilder builder = new LocalizableMessageBuilder(); + + ExecuteCredentialResetResponseType response = new ExecuteCredentialResetResponseType(prismContext); + + String resetMethod = executeCredentialResetRequest.getResetMethod(); + if (StringUtils.isBlank(resetMethod)) { + LocalizableMessage localizableMessage = builder.fallbackMessage("Failed to execute reset password. Bad request.").key("execute.reset.credential.bad.request").build(); + response = response.message(LocalizationUtil.createLocalizableMessageType(localizableMessage)); + throw new SchemaException(localizableMessage); + + } + + SecurityPolicyType securityPolicy = getSecurityPolicy(user, task, parentResult); + CredentialsResetPolicyType resetPolicyType = securityPolicy.getCredentialsReset(); + //TODO: search according tot he credentialID and others + if (resetPolicyType == null) { + LocalizableMessage localizableMessage = builder.fallbackMessage("Failed to execute reset password. Bad configuration.").key("execute.reset.credential.bad.configuration").build(); + response = response.message(LocalizationUtil.createLocalizableMessageType(localizableMessage)); + throw new SchemaException(localizableMessage); + } + + if (!resetMethod.equals(resetPolicyType.getName())) { + LocalizableMessage localizableMessage = builder.fallbackMessage("Failed to execute reset password. Bad method.").key("execute.reset.credential.bad.method").build(); + response = response.message(LocalizationUtil.createLocalizableMessageType(localizableMessage)); + throw new SchemaException(localizableMessage); + } + + + CredentialSourceType credentialSourceType = resetPolicyType.getNewCredentialSource(); + + if (credentialSourceType == null) { + //TODO: go through deprecated functionality + LocalizableMessage localizableMessage = builder.fallbackMessage("Failed to execute reset password. No credential source.").key("execute.reset.credential.no.credential.source").build(); + response = response.message(LocalizationUtil.createLocalizableMessageType(localizableMessage)); + //for now just let the user know that he needs to specify it + return response; + } + + ValuePolicyType valuePolicy = getValuePolicy(user, task, parentResult); + + ObjectDelta userDelta = null; + if (credentialSourceType.getUserEntry() != null) { + PolicyItemDefinitionType policyItemDefinitione = new PolicyItemDefinitionType(); + policyItemDefinitione.setValue(executeCredentialResetRequest.getUserEntry()); + + if (!validateValue(user, valuePolicy, policyItemDefinitione, task, parentResult)) { + LOGGER.error("Cannot execute reset password. New password doesn't satisfy policy constraints"); + parentResult.recordFatalError("Cannot execute reset password. New password doesn't satisfy policy constraints"); + LocalizableMessage localizableMessage = builder.fallbackMessage("New password doesn't satisfy policy constraints.").key("execute.reset.credential.validation.failed").build(); + throw new PolicyViolationException(localizableMessage); + } + + ProtectedStringType newProtectedPassword = new ProtectedStringType(); + newProtectedPassword.setClearValue(executeCredentialResetRequest.getUserEntry()); + userDelta = prismContext.deltaFactory().object().createModificationReplaceProperty(UserType.class, user.getOid(), + SchemaConstants.PATH_PASSWORD_VALUE, newProtectedPassword); + + } + + if (BooleanUtils.isTrue(resetPolicyType.isForceChange())) { + if (userDelta != null) { + userDelta.addModificationReplaceProperty(SchemaConstants.PATH_PASSWORD_FORCE_CHANGE, Boolean.TRUE); + } + } + + + try { + Collection> result = modelService.executeChanges( + MiscUtil.createCollection(userDelta), ModelExecuteOptions.createRaw(), task, parentResult); + } catch (ObjectNotFoundException | SchemaException | CommunicationException | ConfigurationException + | SecurityViolationException | ExpressionEvaluationException | ObjectAlreadyExistsException | PolicyViolationException e) { + response.message(LocalizationUtil.createForFallbackMessage("Failed to reset credential: " + e.getMessage())); + throw e; + } + + parentResult.recomputeStatus(); + LocalizableMessage message = builder.fallbackMessage("Reset password was successful").key("execute.reset.credential.successful").fallbackLocalizableMessage(null).build(); + response.setMessage(LocalizationUtil.createLocalizableMessageType(message)); + + return response; + } + + + @Override + public void refreshPrincipal(String oid, Class clazz) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + try { + MidPointPrincipal principal = guiProfiledPrincipalManager.getPrincipalByOid(oid, clazz); + securityContextManager.setupPreAuthenticatedSecurityContext(principal); + } catch (Throwable e) { + LOGGER.error("Cannot refresh authentication for user identified with" + oid); + throw e; + } + } + + @Override + public List getRelationDefinitions() { + return relationRegistry.getRelationDefinitions(); + } + + @NotNull + @Override + public TaskType submitTaskFromTemplate(String templateTaskOid, List> extensionItems, Task opTask, OperationResult parentResult) + throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, + ConfigurationException, ExpressionEvaluationException, ObjectAlreadyExistsException, PolicyViolationException { + OperationResult result = parentResult.createMinorSubresult(SUBMIT_TASK_FROM_TEMPLATE); + try { + MidPointPrincipal principal = securityContextManager.getPrincipal(); + if (principal == null) { + throw new SecurityViolationException("No current user"); + } + TaskType newTask = modelService.getObject(TaskType.class, templateTaskOid, + createCollection(createExecutionPhase()), opTask, result).asObjectable(); + newTask.setName(PolyStringType.fromOrig(newTask.getName().getOrig() + " " + (int) (Math.random() * 10000))); + newTask.setOid(null); + newTask.setTaskIdentifier(null); + newTask.setOwnerRef(createObjectRef(principal.getFocus(), prismContext)); + newTask.setExecutionStatus(RUNNABLE); + for (Item extensionItem : extensionItems) { + newTask.asPrismObject().getExtension().add(extensionItem.clone()); + } + ObjectDelta taskAddDelta = DeltaFactory.Object.createAddDelta(newTask.asPrismObject()); + Collection> executedChanges = modelService.executeChanges(singleton(taskAddDelta), null, opTask, result); + String newTaskOid = ObjectDeltaOperation.findAddDeltaOid(executedChanges, newTask.asPrismObject()); + newTask.setOid(newTaskOid); + newTask.setTaskIdentifier(newTaskOid); + result.computeStatus(); + return newTask; + } catch (Throwable t) { + result.recordFatalError("Couldn't submit task from template: " + t.getMessage(), t); + throw t; + } + } + + @NotNull + @Override + public TaskType submitTaskFromTemplate(String templateTaskOid, Map extensionValues, Task opTask, OperationResult parentResult) + throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, + ConfigurationException, ExpressionEvaluationException, ObjectAlreadyExistsException, PolicyViolationException { + PrismContainerDefinition extDef = prismContext.getSchemaRegistry() + .findObjectDefinitionByCompileTimeClass(TaskType.class).findContainerDefinition(TaskType.F_EXTENSION); + List> extensionItems = ObjectTypeUtil.mapToExtensionItems(extensionValues, extDef, prismContext); + return submitTaskFromTemplate(templateTaskOid, extensionItems, opTask, parentResult); + } + + @Override + public ArchetypePolicyType determineArchetypePolicy(PrismObject assignmentHolder, OperationResult result) throws SchemaException, ConfigurationException { + return archetypeManager.determineArchetypePolicy(assignmentHolder, result); + } + + private PrismObject determineArchetype(PrismObject assignmentHolder, OperationResult result) throws SchemaException, ConfigurationException { + return archetypeManager.determineArchetype(assignmentHolder, result); + } + + @Override + public AssignmentCandidatesSpecification determineAssignmentTargetSpecification(PrismObject object, OperationResult result) throws SchemaException { + SearchResultList> archetypes = systemObjectCache.getAllArchetypes(result); + List assignmentTargetRelations = new ArrayList<>(); + for (PrismObject archetype : archetypes) { + List archetypeFocusTypes = null; + for (AssignmentType inducement : archetype.asObjectable().getInducement()) { + for (AssignmentRelationType assignmentRelation : inducement.getAssignmentRelation()) { + if (canBeAssignmentHolder(assignmentRelation, object)) { + if (archetypeFocusTypes == null) { + archetypeFocusTypes = determineArchetypeFocusTypes(archetype); + } + AssignmentObjectRelation targetRelation = new AssignmentObjectRelation(); + targetRelation.addObjectTypes(archetypeFocusTypes); + targetRelation.addArchetypeRef(archetype); + targetRelation.addRelations(assignmentRelation.getRelation()); + targetRelation.setDescription(assignmentRelation.getDescription()); + assignmentTargetRelations.add(targetRelation); + } + } + } + } + + AssignmentCandidatesSpecification spec = new AssignmentCandidatesSpecification(); + spec.setAssignmentObjectRelations(assignmentTargetRelations); + // TODO: empty list vs null: default setting + return spec; + } + + @Override + public List getFilteredArchetypesByHolderType(PrismObject object, OperationResult result) throws SchemaException { + SearchResultList> archetypes = systemObjectCache.getAllArchetypes(result); + List filteredArchetypes = new ArrayList<>(); + for (PrismObject archetype : archetypes) { + for (AssignmentType assignment : archetype.asObjectable().getAssignment()) { + for (AssignmentRelationType assignmentRelation : assignment.getAssignmentRelation()) { + if (isHolderType(assignmentRelation.getHolderType(), object)){ + filteredArchetypes.add(archetype.asObjectable()); + } + } + if (filteredArchetypes.contains(archetype.asObjectable())){ + break; + } + } + } + return filteredArchetypes; + } + + + @Override + public AssignmentCandidatesSpecification determineAssignmentHolderSpecification(PrismObject assignmentTarget, OperationResult result) + throws SchemaException, ConfigurationException { + + if (assignmentTarget == null) { + return null; + } + + // assignmentRelation statements in the assignment - we want to control what objects can be assigned to the archetype definition + if (ArchetypeType.class.isAssignableFrom(assignmentTarget.getCompileTimeClass())) { + ArchetypeType archetypeType = (ArchetypeType) assignmentTarget.asObjectable(); + return determineArchetypeAssignmentCandidateSpecification(archetypeType.getAssignment(), archetypeType.getArchetypePolicy()); + } + + + // apply assignmentRelation to "archetyped" objects + PrismObject targetArchetype = determineArchetype(assignmentTarget, result); + if (targetArchetype == null) { + return null; + } + + // TODO: empty list vs null: default setting + ArchetypeType targetArchetypeType = targetArchetype.asObjectable(); + return determineArchetypeAssignmentCandidateSpecification(targetArchetypeType.getInducement(), targetArchetypeType.getArchetypePolicy()); + + } + + private AssignmentCandidatesSpecification determineArchetypeAssignmentCandidateSpecification(List archetypeAssigmentsOrInducements, ArchetypePolicyType archetypePolicy) { + AssignmentCandidatesSpecification spec = new AssignmentCandidatesSpecification(); + List assignmentHolderRelations = new ArrayList<>(); + for (AssignmentType inducement : archetypeAssigmentsOrInducements) { + for (AssignmentRelationType assignmentRelation : inducement.getAssignmentRelation()) { + AssignmentObjectRelation holderRelation = new AssignmentObjectRelation(); + holderRelation.addObjectTypes(ObjectTypes.canonizeObjectTypes(assignmentRelation.getHolderType())); + holderRelation.addArchetypeRefs(assignmentRelation.getHolderArchetypeRef()); + holderRelation.addRelations(assignmentRelation.getRelation()); + holderRelation.setDescription(assignmentRelation.getDescription()); + assignmentHolderRelations.add(holderRelation); + } + } + spec.setAssignmentObjectRelations(assignmentHolderRelations); + spec.setSupportGenericAssignment(archetypePolicy == null + || AssignmentRelationApproachType.CLOSED != archetypePolicy.getAssignmentRelationApproach()); + return spec; + } + + private List determineArchetypeFocusTypes(PrismObject archetype) { + List focusTypes = new ArrayList<>(); + for (AssignmentType assignment : archetype.asObjectable().getAssignment()) { + for (AssignmentRelationType assignmentRelation : assignment.getAssignmentRelation()) { + focusTypes.addAll(ObjectTypes.canonizeObjectTypes(assignmentRelation.getHolderType())); + } + } + if (focusTypes.isEmpty()) { + focusTypes.add(AssignmentHolderType.COMPLEX_TYPE); + } + return focusTypes; + } + + private boolean canBeAssignmentHolder(AssignmentRelationType assignmentRelation, PrismObject holder) { + return isHolderType(assignmentRelation.getHolderType(), holder) && isHolderArchetype(assignmentRelation.getHolderArchetypeRef(), holder); + } + + private boolean isHolderType(List requiredHolderTypes, PrismObject holder) { + if (requiredHolderTypes.isEmpty()) { + return true; + } + for (QName requiredHolderType : requiredHolderTypes) { + if (MiscSchemaUtil.canBeAssignedFrom(requiredHolderType, holder.getCompileTimeClass())) { + return true; + } + } + return false; + } + + private boolean isHolderArchetype(List requiredHolderArchetypeRefs, PrismObject holder) { + if (requiredHolderArchetypeRefs.isEmpty()) { + return true; + } + List presentHolderArchetypeRefs = holder.asObjectable().getArchetypeRef(); + for (ObjectReferenceType requiredHolderArchetypeRef : requiredHolderArchetypeRefs) { + if (MiscSchemaUtil.contains(presentHolderArchetypeRefs, requiredHolderArchetypeRef)) { + return true; + } + } + return false; + } + + @Override + @Experimental + @NotNull + public Collection evaluateCollectionPolicyRules(@NotNull PrismObject collection, @Nullable CompiledObjectCollectionView collectionView, @Nullable Class targetTypeClass, @NotNull Task task, @NotNull OperationResult result) + throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + return collectionProcessor.evaluateCollectionPolicyRules(collection, collectionView, targetTypeClass, task, result); + } + + @Override + @Experimental + @NotNull + public CompiledObjectCollectionView compileObjectCollectionView(@NotNull PrismObject collection, @Nullable Class targetTypeClass, @NotNull Task task, @NotNull OperationResult result) + throws SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, + ExpressionEvaluationException, ObjectNotFoundException { + return collectionProcessor.compileObjectCollectionView(collection, targetTypeClass, task, result); + } + + @Override + @Experimental + @NotNull + public CollectionStats determineCollectionStats(@NotNull CompiledObjectCollectionView collectionView, @NotNull Task task, @NotNull OperationResult result) + throws SchemaException, ObjectNotFoundException, SecurityViolationException, ConfigurationException, CommunicationException, ExpressionEvaluationException { + return collectionProcessor.determineCollectionStats(collectionView, task, result); + } + + @Override + public Collection determineVirtualContainers(PrismObject object, @NotNull Task task, @NotNull OperationResult parentResult) { + + OperationResult result = parentResult.createMinorSubresult(OPERATION_DETERMINE_VIRTUAL_CONTAINERS); + Collection virtualContainers = new ArrayList<>(); + if (AssignmentHolderType.class.isAssignableFrom(object.getCompileTimeClass())) { + + try { + ArchetypePolicyType archetypePolicyType = determineArchetypePolicy((PrismObject) object, result); + if (archetypePolicyType != null) { + ArchetypeAdminGuiConfigurationType archetypeAdminGui = archetypePolicyType.getAdminGuiConfiguration(); + if (archetypeAdminGui != null) { + GuiObjectDetailsPageType guiDetails = archetypeAdminGui.getObjectDetails(); + if (guiDetails != null && guiDetails.getContainer() != null) { + virtualContainers.addAll(guiDetails.getContainer()) ; + } + } + } + } catch (SchemaException | ConfigurationException e) { + LOGGER.error("Cannot determine virtual containers for {}, reason: {}", object, e.getMessage(), e); + result.recordPartialError("Cannot determine virtual containers for " + object + ", reason: " + e.getMessage(), e); + } + + } + + QName objectType = object.getDefinition().getTypeName(); + try { + CompiledGuiProfile userProfile = getCompiledGuiProfile(task, result); + GuiObjectDetailsSetType objectDetailsSetType = userProfile.getObjectDetails(); + if (objectDetailsSetType == null) { + result.recordSuccess(); + return virtualContainers; + } + List detailsPages = objectDetailsSetType.getObjectDetailsPage(); + for (GuiObjectDetailsPageType detailsPage : detailsPages) { + if (objectType == null) { + LOGGER.trace("Object type is not known, skipping considering custom details page settings."); + continue; + } + if (detailsPage.getType() == null) { + LOGGER.trace("Object type for details page {} not know, skipping considering custom details page settings.", detailsPage); + continue; + } + + if (QNameUtil.match(objectType, detailsPage.getType()) && detailsPage.getContainer() != null) { + virtualContainers.addAll(detailsPage.getContainer()); + } + } + result.recordSuccess(); + return virtualContainers; + } catch (ObjectNotFoundException | SchemaException | CommunicationException | ConfigurationException | SecurityViolationException | ExpressionEvaluationException e) { + LOGGER.error("Cannot determine virtual containers for {}, reason: {}", objectType, e.getMessage(), e); + result.recordPartialError("Cannot determine virtual containers for " + objectType + ", reason: " + e.getMessage(), e); + return virtualContainers; + } + + } + +} diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/SchemaTransformer.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/SchemaTransformer.java index 83a3d6a6356..c0c330745c4 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/SchemaTransformer.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/SchemaTransformer.java @@ -1,842 +1,901 @@ -/* - * Copyright (c) 2014-2019 Evolveum and contributors - * - * This work is dual-licensed under the Apache License 2.0 - * and European Union Public License. See LICENSE file for details. - */ -package com.evolveum.midpoint.model.impl.controller; - -import com.evolveum.midpoint.common.crypto.CryptoUtil; -import com.evolveum.midpoint.model.api.ModelAuthorizationAction; -import com.evolveum.midpoint.model.api.ModelExecuteOptions; -import com.evolveum.midpoint.model.common.ArchetypeManager; -import com.evolveum.midpoint.model.common.SystemObjectCache; -import com.evolveum.midpoint.model.impl.lens.LensContext; -import com.evolveum.midpoint.model.impl.lens.LensElementContext; -import com.evolveum.midpoint.model.impl.lens.LensFocusContext; -import com.evolveum.midpoint.model.impl.lens.LensProjectionContext; -import com.evolveum.midpoint.prism.*; -import com.evolveum.midpoint.prism.delta.ContainerDelta; -import com.evolveum.midpoint.prism.delta.ItemDelta; -import com.evolveum.midpoint.prism.delta.ObjectDelta; -import com.evolveum.midpoint.prism.path.UniformItemPath; -import com.evolveum.midpoint.prism.path.ItemName; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.prism.xml.XsdTypeMapper; -import com.evolveum.midpoint.repo.api.RepositoryService; -import com.evolveum.midpoint.schema.DefinitionProcessingOption; -import com.evolveum.midpoint.schema.GetOperationOptions; -import com.evolveum.midpoint.schema.SearchResultList; -import com.evolveum.midpoint.schema.SelectorOptions; -import com.evolveum.midpoint.schema.constants.SchemaConstants; -import com.evolveum.midpoint.schema.internals.InternalsConfig; -import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.schema.util.MiscSchemaUtil; -import com.evolveum.midpoint.schema.util.ObjectTypeUtil; -import com.evolveum.midpoint.security.api.SecurityUtil; -import com.evolveum.midpoint.security.enforcer.api.AuthorizationParameters; -import com.evolveum.midpoint.security.enforcer.api.ObjectSecurityConstraints; -import com.evolveum.midpoint.security.enforcer.api.SecurityEnforcer; -import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.util.exception.*; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.common_3.*; -import com.evolveum.prism.xml.ns._public.types_3.ItemPathType; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.Validate; -import org.jetbrains.annotations.Contract; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Component; - -import java.util.*; - -/** - * Transforms the schema and objects by applying security constraints, - * object template schema refinements, etc. - * - * @author semancik - */ -@Component -public class SchemaTransformer { - - private static final Trace LOGGER = TraceManager.getTrace(SchemaTransformer.class); - - private static final String OPERATION_APPLY_SCHEMAS_AND_SECURITY = SchemaTransformer.class.getName()+".applySchemasAndSecurity"; - - @Autowired @Qualifier("cacheRepositoryService") private transient RepositoryService cacheRepositoryService; - @Autowired private SecurityEnforcer securityEnforcer; - @Autowired private SystemObjectCache systemObjectCache; - @Autowired private ArchetypeManager archetypeManager; - - @Autowired - private PrismContext prismContext; - - // TODO why are the following two methods distinct? Clarify their names. - public void applySchemasAndSecurityToObjectTypes(List objectTypes, - GetOperationOptions rootOptions, Collection> options, - AuthorizationPhaseType phase, Task task, OperationResult result) - throws SecurityViolationException, SchemaException, ConfigurationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException { - for (int i = 0; i < objectTypes.size(); i++) { - PrismObject object = (PrismObject) objectTypes.get(i).asPrismObject(); - object = object.cloneIfImmutable(); - objectTypes.set(i, object.asObjectable()); - applySchemasAndSecurity(object, rootOptions, options, phase, task, result); - } - } - - public void applySchemasAndSecurityToObjects(List> objects, - GetOperationOptions rootOptions, Collection> options, - AuthorizationPhaseType phase, Task task, OperationResult result) - throws SecurityViolationException, SchemaException { - for (int i = 0; i < objects.size(); i++) { - PrismObject object = objects.get(i); - object = object.cloneIfImmutable(); - objects.set(i, object); - applySchemaAndSecurityToObject(object, rootOptions, options, phase, task, result); - } - } - - // Expecting that C is a direct child of T. - // Expecting that container values point to their respective parents (in order to evaluate the security!) - public - SearchResultList applySchemasAndSecurityToContainers(SearchResultList originalResultList, Class parentObjectType, ItemName childItemName, - GetOperationOptions rootOptions, Collection> options, AuthorizationPhaseType phase, Task task, OperationResult result) - throws SecurityViolationException, SchemaException, ObjectNotFoundException, ConfigurationException, ExpressionEvaluationException, CommunicationException { - - List newValues = new ArrayList<>(); - Map,Object> processedParents = new IdentityHashMap<>(); - for (C value: originalResultList) { - Long originalId = value.asPrismContainerValue().getId(); - if (originalId == null) { - throw new SchemaException("No ID in container value " + value); - } - PrismObject parent = ObjectTypeUtil.getParentObject(value); - boolean wasProcessed; - if (parent != null) { - wasProcessed = processedParents.containsKey(parent); - } else { - // temporary solution TODO reconsider - parent = prismContext.createObject(parentObjectType); - PrismContainer childContainer = parent.findOrCreateItem(childItemName, PrismContainer.class); - childContainer.add(value.asPrismContainerValue()); - wasProcessed = false; - } - if (!wasProcessed) { - // TODO what if parent is immutable? - applySchemasAndSecurity(parent, rootOptions, options, phase, task, result); - processedParents.put(parent, null); - } - PrismContainer updatedChildContainer = parent.findContainer(childItemName); - if (updatedChildContainer != null) { - PrismContainerValue updatedChildValue = updatedChildContainer.getValue(originalId); - if (updatedChildValue != null) { - newValues.add(updatedChildValue.asContainerable()); - } - } - } - return new SearchResultList<>(newValues, originalResultList.getMetadata()); - } - - private void applySchemaAndSecurityToObject(PrismObject object, GetOperationOptions rootOptions, - Collection> options, AuthorizationPhaseType phase, Task task, OperationResult result) throws SecurityViolationException { - OperationResult subresult = new OperationResult(SchemaTransformer.class.getName()+".applySchemasAndSecurityToObject"); - try { - applySchemasAndSecurity(object, rootOptions, options, phase, task, subresult); - } catch (IllegalArgumentException | IllegalStateException | SchemaException |ConfigurationException |ObjectNotFoundException | ExpressionEvaluationException | CommunicationException e) { - LOGGER.error("Error post-processing object {}: {}", object, e.getMessage(), e); - OperationResultType fetchResult = object.asObjectable().getFetchResult(); - if (fetchResult == null) { - fetchResult = subresult.createOperationResultType(); - object.asObjectable().setFetchResult(fetchResult); - } else { - fetchResult.getPartialResults().add(subresult.createOperationResultType()); - } - fetchResult.setStatus(OperationResultStatusType.FATAL_ERROR); - } catch (SecurityViolationException e) { - // We cannot go on and leave this object in the result set. The object was not post-processed. - // Leaving it in the result set may leak information. - result.recordFatalError(e); - throw e; - } - } - - private void authorizeOptions(GetOperationOptions rootOptions, PrismObject object, ObjectDelta delta, AuthorizationPhaseType phase, Task task, OperationResult result) - throws SchemaException, SecurityViolationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - if (GetOperationOptions.isRaw(rootOptions)) { - securityEnforcer.authorize(ModelAuthorizationAction.RAW_OPERATION.getUrl(), phase, AuthorizationParameters.Builder.buildObjectDelta(object, delta), null, task, result); - } - } - - /** - * Validate the objects, apply security to the object definition, remove any non-visible properties (security), - * apply object template definitions and so on. This method is called for - * any object that is returned from the Model Service. - */ - public void applySchemasAndSecurity(PrismObject object, GetOperationOptions rootOptions, - Collection> options, - AuthorizationPhaseType phase, Task task, OperationResult parentResult) - throws SchemaException, SecurityViolationException, ConfigurationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException { - LOGGER.trace("applySchemasAndSecurity({}) starting", object); - OperationResult result = parentResult.createMinorSubresult(SchemaTransformer.class.getName()+".applySchemasAndSecurity"); - authorizeOptions(rootOptions, object, null, phase, task, result); - validateObject(object, rootOptions, result); - - ObjectSecurityConstraints securityConstraints = compileSecurityConstraints(object, task, result); - PrismObjectDefinition objectDefinition = object.deepCloneDefinition(true, this::setFullAccessFlags); - - if (phase == null) { - if (!GetOperationOptions.isExecutionPhase(rootOptions)) { - applySchemasAndSecurityPhase(object, securityConstraints, objectDefinition, rootOptions, AuthorizationPhaseType.REQUEST, task, result); - } - applySchemasAndSecurityPhase(object, securityConstraints, objectDefinition, rootOptions, AuthorizationPhaseType.EXECUTION, task, result); - } else { - if (phase == AuthorizationPhaseType.REQUEST && GetOperationOptions.isExecutionPhase(rootOptions)) { - // Skip application of security constraints for request phase. - // The caller asked to skip evaluation of request authorization, so everything is allowed here. - } else { - applySchemasAndSecurityPhase(object, securityConstraints, objectDefinition, rootOptions, phase, task, result); - } - } - - // we do not need to process object template when processing REQUEST in RAW mode. - if (!GetOperationOptions.isRaw(rootOptions)) { - ObjectTemplateType objectTemplateType; - try { - objectTemplateType = determineObjectTemplate(object, AuthorizationPhaseType.REQUEST, result); - } catch (ConfigurationException | SchemaException | ObjectNotFoundException e) { - result.recordFatalError(e); - throw e; - } - applyObjectTemplateToObject(object, objectTemplateType, result); - } - - if (CollectionUtils.isNotEmpty(options)) { - Map> definitionProcessing = SelectorOptions.extractOptionValues(options, (o) -> o.getDefinitionProcessing(), prismContext); - if (CollectionUtils.isNotEmpty(definitionProcessing.get(DefinitionProcessingOption.NONE))) { - throw new UnsupportedOperationException("'NONE' definition processing is not supported now"); - } - Collection onlyIfExists = definitionProcessing.get(DefinitionProcessingOption.ONLY_IF_EXISTS); - if (CollectionUtils.isNotEmpty(onlyIfExists)) { - if (onlyIfExists.size() != 1 || !ItemPath.isEmpty(onlyIfExists.iterator().next())) { - throw new UnsupportedOperationException("'ONLY_IF_EXISTS' definition processing is currently supported on root level only; not on " + onlyIfExists); - } - Collection full = definitionProcessing.get(DefinitionProcessingOption.FULL); - object.trimDefinitionTree(full); - } - } - - result.computeStatus(); - result.recordSuccessIfUnknown(); - LOGGER.trace("applySchemasAndSecurity finishing"); // to allow folding in log viewer - } - - public void applySchemasAndSecurity(LensContext context, - AuthorizationPhaseType phase, Task task, OperationResult parentResult) throws SecurityViolationException, SchemaException, ConfigurationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException { - LOGGER.trace("applySchemasAndSecurity({}) starting", context); - OperationResult result = parentResult.createMinorSubresult(OPERATION_APPLY_SCHEMAS_AND_SECURITY); - - try { - applySchemasAndSecurityFocus(context, phase, task, result); - applySchemasAndSecurityProjections(context, phase, task, result); - - result.computeStatus(); - result.recordSuccessIfUnknown(); - - } catch (Throwable e) { - result.recordFatalError(e); - throw e; - } - - LOGGER.trace("applySchemasAndSecurity finishing"); // to allow folding in log viewer - } - - private void applySchemasAndSecurityFocus(LensContext context, - AuthorizationPhaseType phase, Task task, OperationResult result) throws SecurityViolationException, SchemaException, ConfigurationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException { - LensFocusContext focusContext = context.getFocusContext(); - if (focusContext == null) { - return; - } - - ObjectSecurityConstraints securityConstraints = applySchemasAndSecurityElementContext(context, focusContext, phase, task, result); - - AuthorizationDecisionType assignmentDecision = securityConstraints.findItemDecision(SchemaConstants.PATH_ASSIGNMENT, ModelAuthorizationAction.AUTZ_ACTIONS_URLS_GET, phase); - if (!AuthorizationDecisionType.ALLOW.equals(assignmentDecision)) { - PrismObject object = focusContext.getObjectAny(); - LOGGER.trace("Logged in user isn't authorized to read (or get) assignment item of the object: {}", object); - result.recordWarning("Logged in user isn't authorized to read (or get) assignment item of the object: " + object); - context.setEvaluatedAssignmentTriple(null); - } - } - - private void applySchemasAndSecurityProjections(LensContext context, - AuthorizationPhaseType phase, Task task, OperationResult result) throws SecurityViolationException, SchemaException, ConfigurationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException { - for (LensProjectionContext projCtx : context.getProjectionContexts()) { - if (projCtx != null && projCtx.getObjectAny() != null) { - applySchemasAndSecurityElementContext(context, projCtx, phase, task, result); - } - } - } - - private ObjectSecurityConstraints applySchemasAndSecurityElementContext(LensContext context, LensElementContext elementContext, - AuthorizationPhaseType phase, Task task, OperationResult result) throws SecurityViolationException, SchemaException, ConfigurationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException { - - PrismObject object = elementContext.getObjectAny(); - - if (object == null ) { - if (elementContext.getDelta() == null) { - return null; - } else { - throw new IllegalArgumentException("Cannot apply schema and security of null object"); - } - } - GetOperationOptions getOptions = ModelExecuteOptions.toGetOperationOptions(context.getOptions()); - authorizeOptions(getOptions, object, null, phase, task, result); - - ObjectSecurityConstraints securityConstraints = compileSecurityConstraints(object, task, result); - - AuthorizationDecisionType globalReadDecision = securityConstraints.findAllItemsDecision(ModelAuthorizationAction.AUTZ_ACTIONS_URLS_GET, phase); - if (globalReadDecision == AuthorizationDecisionType.DENY) { - // shortcut - SecurityUtil.logSecurityDeny(object, "because the authorization denies access"); - throw new AuthorizationException("Access denied"); - } - - AuthorizationDecisionType globalAddDecision = securityConstraints.findAllItemsDecision(ModelAuthorizationAction.ADD.getUrl(), phase); - AuthorizationDecisionType globalModifyDecision = securityConstraints.findAllItemsDecision(ModelAuthorizationAction.MODIFY.getUrl(), phase); - - elementContext.forEachObject(focusObject -> - applySecurityConstraints(focusObject.getValue(), securityConstraints, phase, - globalReadDecision, globalAddDecision, globalModifyDecision, - false)); - - elementContext.forEachDelta(focusDelta -> - applySecurityConstraints(focusDelta, securityConstraints, phase, - globalReadDecision, globalAddDecision, globalModifyDecision)); - - return securityConstraints; - } - - public void setFullAccessFlags(ItemDefinition itemDef) { - itemDef.toMutable().setCanRead(true); - itemDef.toMutable().setCanAdd(true); - itemDef.toMutable().setCanModify(true); - } - - private void applySchemasAndSecurityPhase(PrismObject object, ObjectSecurityConstraints securityConstraints, PrismObjectDefinition objectDefinition, - GetOperationOptions rootOptions, AuthorizationPhaseType phase, Task task, OperationResult result) - throws SchemaException, SecurityViolationException, ConfigurationException, ObjectNotFoundException { - Validate.notNull(phase); - try { - AuthorizationDecisionType globalReadDecision = securityConstraints.findAllItemsDecision(ModelAuthorizationAction.AUTZ_ACTIONS_URLS_GET, phase); - if (globalReadDecision == AuthorizationDecisionType.DENY) { - // shortcut - SecurityUtil.logSecurityDeny(object, "because the authorization denies access"); - throw new AuthorizationException("Access denied"); - } - - AuthorizationDecisionType globalAddDecision = securityConstraints.findAllItemsDecision(ModelAuthorizationAction.ADD.getUrl(), phase); - AuthorizationDecisionType globalModifyDecision = securityConstraints.findAllItemsDecision(ModelAuthorizationAction.MODIFY.getUrl(), phase); - applySecurityConstraints(object.getValue(), securityConstraints, phase, - globalReadDecision, globalAddDecision, globalModifyDecision, true); - if (object.isEmpty()) { - // let's make it explicit - SecurityUtil.logSecurityDeny(object, "because the subject has not access to any item"); - throw new AuthorizationException("Access denied"); - } - - applySecurityConstraintsItemDef(objectDefinition, new IdentityHashMap<>(), ItemPath.EMPTY_PATH, securityConstraints, globalReadDecision, globalAddDecision, globalModifyDecision, phase); - } catch (SecurityViolationException | RuntimeException e) { - result.recordFatalError(e); - throw e; - } - } - - private ObjectSecurityConstraints compileSecurityConstraints(PrismObject object, Task task, OperationResult result) throws SecurityViolationException, SchemaException, ConfigurationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException { - try { - ObjectSecurityConstraints securityConstraints = securityEnforcer.compileSecurityConstraints(object, null, task, result); - if (LOGGER.isTraceEnabled()) { - LOGGER.trace("Security constraints for {}:\n{}", object, securityConstraints==null?"null":securityConstraints.debugDump()); - } - if (securityConstraints == null) { - SecurityUtil.logSecurityDeny(object, "because no security constraints are defined (default deny)"); - throw new AuthorizationException("Access denied"); - } - return securityConstraints; - } catch (Throwable e) { - result.recordFatalError(e); - throw e; - } - } - - private void applySecurityConstraints(PrismContainerValue pcv, ObjectSecurityConstraints securityConstraints, AuthorizationPhaseType phase, - AuthorizationDecisionType defaultReadDecision, AuthorizationDecisionType defaultAddDecision, - AuthorizationDecisionType defaultModifyDecision, boolean applyToDefinitions) { - LOGGER.trace("applySecurityConstraints(items): items={}, phase={}, defaults R={}, A={}, M={}", - pcv.getItems(), phase, defaultReadDecision, defaultAddDecision, defaultModifyDecision); - if (pcv.hasNoItems()) { - return; - } - List itemsToRemove = new ArrayList<>(); - for (Item item : pcv.getItems()) { - ItemPath itemPath = item.getPath(); - ItemDefinition itemDef = item.getDefinition(); - if (itemDef != null && itemDef.isElaborate()) { - LOGGER.trace("applySecurityConstraints(item): {}: skip (elaborate)", itemPath); - continue; - } - ItemPath nameOnlyItemPath = itemPath.namedSegmentsOnly(); - AuthorizationDecisionType itemReadDecision = computeItemDecision(securityConstraints, nameOnlyItemPath, ModelAuthorizationAction.AUTZ_ACTIONS_URLS_GET, defaultReadDecision, phase); - AuthorizationDecisionType itemAddDecision = computeItemDecision(securityConstraints, nameOnlyItemPath, ModelAuthorizationAction.AUTZ_ACTIONS_URLS_ADD, defaultReadDecision, phase); - AuthorizationDecisionType itemModifyDecision = computeItemDecision(securityConstraints, nameOnlyItemPath, ModelAuthorizationAction.AUTZ_ACTIONS_URLS_MODIFY, defaultReadDecision, phase); - LOGGER.trace("applySecurityConstraints(item): {}: decisions R={}, A={}, M={}", - itemPath, itemReadDecision, itemAddDecision, itemModifyDecision); - if (applyToDefinitions && itemDef != null) { - if (itemReadDecision != AuthorizationDecisionType.ALLOW) { - itemDef.toMutable().setCanRead(false); - } - if (itemAddDecision != AuthorizationDecisionType.ALLOW) { - itemDef.toMutable().setCanAdd(false); - } - if (itemModifyDecision != AuthorizationDecisionType.ALLOW) { - itemDef.toMutable().setCanModify(false); - } - } - if (item instanceof PrismContainer) { - if (itemReadDecision == AuthorizationDecisionType.DENY) { - // Explicitly denied access to the entire container - itemsToRemove.add(item); - } else { - // No explicit decision (even ALLOW is not final here as something may be denied deeper inside) - AuthorizationDecisionType subDefaultReadDecision = defaultReadDecision; - if (itemReadDecision == AuthorizationDecisionType.ALLOW) { - // This means allow to all subitems unless otherwise denied. - subDefaultReadDecision = AuthorizationDecisionType.ALLOW; - } - List> values = ((PrismContainer)item).getValues(); - reduceContainerValues(values, securityConstraints, phase, itemReadDecision, itemAddDecision, itemModifyDecision, subDefaultReadDecision, applyToDefinitions); - if (item.hasNoValues() && itemReadDecision == null) { - // We have removed all the content, if there was any. So, in the default case, there's nothing that - // we are interested in inside this item. Therefore let's just remove it. - // (If itemReadDecision is ALLOW, we obviously keep this untouched.) - itemsToRemove.add(item); - } - } - } else { - if (itemReadDecision == AuthorizationDecisionType.DENY || itemReadDecision == null) { - itemsToRemove.add(item); - } - } - } - for (Item itemToRemove : itemsToRemove) { - pcv.remove(itemToRemove); - } - } - - private void applySecurityConstraints(ObjectDelta objectDelta, ObjectSecurityConstraints securityConstraints, AuthorizationPhaseType phase, - AuthorizationDecisionType defaultReadDecision, AuthorizationDecisionType defaultAddDecision, AuthorizationDecisionType defaultModifyDecision) { - LOGGER.trace("applySecurityConstraints(objectDelta): items={}, phase={}, defaults R={}, A={}, M={}", - objectDelta, phase, defaultReadDecision, defaultAddDecision, defaultModifyDecision); - if (objectDelta == null) { - return; - } - if (objectDelta.isAdd()) { - applySecurityConstraints(objectDelta.getObjectToAdd().getValue(), securityConstraints, phase, defaultReadDecision, defaultAddDecision, defaultModifyDecision, false); - return; - } - if (objectDelta.isDelete()) { - // Nothing to do - return; - } - // Modify delta - Collection> modifications = objectDelta.getModifications(); - if (modifications == null || modifications.isEmpty()) { - // Nothing to do - return; - } - List> itemsToRemove = new ArrayList<>(); - for (ItemDelta modification : modifications) { - ItemPath itemPath = modification.getPath(); - ItemDefinition itemDef = modification.getDefinition(); - if (itemDef != null && itemDef.isElaborate()) { - LOGGER.trace("applySecurityConstraints(item): {}: skip (elaborate)", itemPath); - continue; - } - ItemPath nameOnlyItemPath = itemPath.namedSegmentsOnly(); - AuthorizationDecisionType itemReadDecision = computeItemDecision(securityConstraints, nameOnlyItemPath, ModelAuthorizationAction.AUTZ_ACTIONS_URLS_GET, defaultReadDecision, phase); - AuthorizationDecisionType itemAddDecision = computeItemDecision(securityConstraints, nameOnlyItemPath, ModelAuthorizationAction.AUTZ_ACTIONS_URLS_ADD, defaultReadDecision, phase); - AuthorizationDecisionType itemModifyDecision = computeItemDecision(securityConstraints, nameOnlyItemPath, ModelAuthorizationAction.AUTZ_ACTIONS_URLS_MODIFY, defaultReadDecision, phase); - LOGGER.trace("applySecurityConstraints(item): {}: decisions R={}, A={}, M={}", - itemPath, itemReadDecision, itemAddDecision, itemModifyDecision); - if (modification instanceof ContainerDelta) { - if (itemReadDecision == AuthorizationDecisionType.DENY) { - // Explicitly denied access to the entire container - itemsToRemove.add(modification); - } else { - // No explicit decision (even ALLOW is not final here as something may be denied deeper inside) - AuthorizationDecisionType subDefaultReadDecision = defaultReadDecision; - if (itemReadDecision == AuthorizationDecisionType.ALLOW) { - // This means allow to all subitems unless otherwise denied. - subDefaultReadDecision = AuthorizationDecisionType.ALLOW; - } - - reduceContainerValues((List>) ((ContainerDelta)modification).getValuesToAdd(), - securityConstraints, phase, itemReadDecision, itemAddDecision, itemModifyDecision, subDefaultReadDecision, false); - reduceContainerValues((List>) ((ContainerDelta)modification).getValuesToDelete(), - securityConstraints, phase, itemReadDecision, itemAddDecision, itemModifyDecision, subDefaultReadDecision, false); - reduceContainerValues((List>) ((ContainerDelta)modification).getValuesToReplace(), - securityConstraints, phase, itemReadDecision, itemAddDecision, itemModifyDecision, subDefaultReadDecision, false); - - if (modification.isEmpty() && itemReadDecision == null) { - // We have removed all the content, if there was any. So, in the default case, there's nothing that - // we are interested in inside this item. Therefore let's just remove it. - // (If itemReadDecision is ALLOW, we obviously keep this untouched.) - itemsToRemove.add(modification); - } - } - } else { - if (itemReadDecision == AuthorizationDecisionType.DENY || itemReadDecision == null) { - itemsToRemove.add(modification); - break; - } - } - } - for (ItemDelta modificationToRemove : itemsToRemove) { - modifications.remove(modificationToRemove); - } - } - - private boolean reduceContainerValues(List> values, ObjectSecurityConstraints securityConstraints, AuthorizationPhaseType phase, - AuthorizationDecisionType itemReadDecision, AuthorizationDecisionType itemAddDecision, AuthorizationDecisionType itemModifyDecision, AuthorizationDecisionType subDefaultReadDecision, - boolean applyToDefinitions) { - if (values == null) { - return false; - } - boolean removedSomething = false; - Iterator> vi = values.iterator(); - while (vi.hasNext()) { - PrismContainerValue cval = vi.next(); - applySecurityConstraints(cval, securityConstraints, phase, - subDefaultReadDecision, itemAddDecision, itemModifyDecision, applyToDefinitions); - if (cval.hasNoItems() && itemReadDecision == null) { - // We have removed all the content, if there was any. So, in the default case, there's nothing that - // we are interested in inside this PCV. Therefore let's just remove it. - // (If itemReadDecision is ALLOW, we obviously keep this untouched.) - vi.remove(); - removedSomething = true; - } - } - return removedSomething; - } - - public void applySecurityConstraints(D itemDefinition, ObjectSecurityConstraints securityConstraints, - AuthorizationPhaseType phase) { - if (phase == null) { - applySecurityConstraintsPhase(itemDefinition, securityConstraints, AuthorizationPhaseType.REQUEST); - applySecurityConstraintsPhase(itemDefinition, securityConstraints, AuthorizationPhaseType.EXECUTION); - } else { - applySecurityConstraintsPhase(itemDefinition, securityConstraints, phase); - } - } - - private void applySecurityConstraintsPhase(D itemDefinition, ObjectSecurityConstraints securityConstraints, - AuthorizationPhaseType phase) { - Validate.notNull(phase); - LOGGER.trace("applySecurityConstraints(itemDefs): def={}, phase={}", itemDefinition, phase); - applySecurityConstraintsItemDef(itemDefinition, new IdentityHashMap<>(), ItemPath.EMPTY_PATH, securityConstraints, - null, null, null, phase); - - } - - private void applySecurityConstraintsItemDef(D itemDefinition, - IdentityHashMap definitionsSeen, - ItemPath nameOnlyItemPath, ObjectSecurityConstraints securityConstraints, AuthorizationDecisionType defaultReadDecision, - AuthorizationDecisionType defaultAddDecision, AuthorizationDecisionType defaultModifyDecision, - AuthorizationPhaseType phase) { - - boolean thisWasSeen = definitionsSeen.containsKey(itemDefinition); - definitionsSeen.put(itemDefinition, null); - - AuthorizationDecisionType readDecision = computeItemDecision(securityConstraints, nameOnlyItemPath, ModelAuthorizationAction.AUTZ_ACTIONS_URLS_GET, defaultReadDecision, phase); - AuthorizationDecisionType addDecision = computeItemDecision(securityConstraints, nameOnlyItemPath, ModelAuthorizationAction.AUTZ_ACTIONS_URLS_ADD, defaultAddDecision, phase); - AuthorizationDecisionType modifyDecision = computeItemDecision(securityConstraints, nameOnlyItemPath, ModelAuthorizationAction.AUTZ_ACTIONS_URLS_MODIFY, defaultModifyDecision, phase); - - boolean anySubElementRead = false; - boolean anySubElementAdd = false; - boolean anySubElementModify = false; - if (itemDefinition instanceof PrismContainerDefinition && !thisWasSeen) { - PrismContainerDefinition containerDefinition = (PrismContainerDefinition)itemDefinition; - List subDefinitions = ((PrismContainerDefinition)containerDefinition).getDefinitions(); - for (ItemDefinition subDef: subDefinitions) { - ItemPath subPath = ItemPath.create(nameOnlyItemPath, subDef.getItemName()); - if (subDef.isElaborate()) { - LOGGER.trace("applySecurityConstraints(itemDef): {}: skip (elaborate)", subPath); - continue; - } - if (!subDef.getItemName().equals(ShadowType.F_ATTRIBUTES)) { // Shadow attributes have special handling - applySecurityConstraintsItemDef(subDef, definitionsSeen, subPath, securityConstraints, - readDecision, addDecision, modifyDecision, phase); - } - if (subDef.canRead()) { - anySubElementRead = true; - } - if (subDef.canAdd()) { - anySubElementAdd = true; - } - if (subDef.canModify()) { - anySubElementModify = true; - } - } - } - - LOGGER.trace("applySecurityConstraints(itemDef): {}: decisions R={}, A={}, M={}; subelements R={}, A={}, M={}", - nameOnlyItemPath, readDecision, addDecision, modifyDecision, anySubElementRead, anySubElementAdd, anySubElementModify); - - if (readDecision != AuthorizationDecisionType.ALLOW) { - itemDefinition.toMutable().setCanRead(false); - } - if (addDecision != AuthorizationDecisionType.ALLOW) { - itemDefinition.toMutable().setCanAdd(false); - } - if (modifyDecision != AuthorizationDecisionType.ALLOW) { - itemDefinition.toMutable().setCanModify(false); - } - - if (anySubElementRead) { - itemDefinition.toMutable().setCanRead(true); - } - if (anySubElementAdd) { - itemDefinition.toMutable().setCanAdd(true); - } - if (anySubElementModify) { - itemDefinition.toMutable().setCanModify(true); - } - } - - @Contract("_, _, _, !null, _ -> !null") - public AuthorizationDecisionType computeItemDecision(ObjectSecurityConstraints securityConstraints, ItemPath nameOnlyItemPath, String[] actionUrls, - AuthorizationDecisionType defaultDecision, AuthorizationPhaseType phase) { - AuthorizationDecisionType explicitDecision = securityConstraints.findItemDecision(nameOnlyItemPath, actionUrls, phase); -// LOGGER.trace("Explicit decision for {} ({} {}): {}", nameOnlyItemPath, actionUrl, phase, explicitDecision); - if (explicitDecision != null) { - return explicitDecision; - } else { - return defaultDecision; - } - } - - public ObjectTemplateType determineObjectTemplate(PrismObject object, AuthorizationPhaseType phase, OperationResult result) throws SchemaException, ConfigurationException, ObjectNotFoundException { - ArchetypePolicyType archetypePolicy = archetypeManager.determineArchetypePolicy(object, result); - if (archetypePolicy == null) { - return null; - } - ObjectReferenceType objectTemplateRef = archetypePolicy.getObjectTemplateRef(); - if (objectTemplateRef == null || StringUtils.isEmpty(objectTemplateRef.getOid())) { - return null; - } - PrismObject template = cacheRepositoryService.getObject(ObjectTemplateType.class, objectTemplateRef.getOid(), null, result); - return template.asObjectable(); - } - - public ObjectTemplateType determineObjectTemplate(Class objectClass, AuthorizationPhaseType phase, OperationResult result) throws SchemaException, ConfigurationException, ObjectNotFoundException { - PrismObject systemConfiguration = systemObjectCache.getSystemConfiguration(result); - if (systemConfiguration == null) { - return null; - } - ObjectPolicyConfigurationType objectPolicyConfiguration = ArchetypeManager.determineObjectPolicyConfiguration(objectClass, null, systemConfiguration.asObjectable()); - if (objectPolicyConfiguration == null) { - return null; - } - ObjectReferenceType objectTemplateRef = objectPolicyConfiguration.getObjectTemplateRef(); - if (objectTemplateRef == null) { - return null; - } - PrismObject template = cacheRepositoryService.getObject(ObjectTemplateType.class, objectTemplateRef.getOid(), null, result); - return template.asObjectable(); - } - - public void applyObjectTemplateToDefinition(PrismObjectDefinition objectDefinition, ObjectTemplateType objectTemplateType, OperationResult result) throws ObjectNotFoundException, SchemaException { - if (objectTemplateType == null) { - return; - } - for (ObjectReferenceType includeRef: objectTemplateType.getIncludeRef()) { - PrismObject subTemplate = cacheRepositoryService.getObject(ObjectTemplateType.class, includeRef.getOid(), null, result); - applyObjectTemplateToDefinition(objectDefinition, subTemplate.asObjectable(), result); - } - for (ObjectTemplateItemDefinitionType templateItemDefType: objectTemplateType.getItem()) { - ItemPathType ref = templateItemDefType.getRef(); - if (ref == null) { - throw new SchemaException("No 'ref' in item definition in "+objectTemplateType); - } - ItemPath itemPath = prismContext.toPath(ref); - ItemDefinition itemDef = objectDefinition.findItemDefinition(itemPath); - if (itemDef != null) { - applyObjectTemplateItem(itemDef, templateItemDefType, "item " + itemPath + " in object type " + objectDefinition.getTypeName() + " as specified in item definition in " + objectTemplateType); - } else { - OperationResult subResult = result.createMinorSubresult(SchemaTransformer.class.getName() + ".applyObjectTemplateToDefinition"); - subResult.recordPartialError("No definition for item " + itemPath + " in object type " + objectDefinition.getTypeName() + " as specified in item definition in " + objectTemplateType); - continue; - } - } - } - - private void applyObjectTemplateToObject(PrismObject object, ObjectTemplateType objectTemplateType, OperationResult result) throws ObjectNotFoundException, SchemaException { - if (objectTemplateType == null) { - return; - } - for (ObjectReferenceType includeRef: objectTemplateType.getIncludeRef()) { - PrismObject subTemplate = cacheRepositoryService.getObject(ObjectTemplateType.class, includeRef.getOid(), null, result); - applyObjectTemplateToObject(object, subTemplate.asObjectable(), result); - } - for (ObjectTemplateItemDefinitionType templateItemDefType: objectTemplateType.getItem()) { - ItemPathType ref = templateItemDefType.getRef(); - if (ref == null) { - throw new SchemaException("No 'ref' in item definition in "+objectTemplateType); - } - ItemPath itemPath = prismContext.toPath(ref); - ItemDefinition itemDefFromObject = object.getDefinition().findItemDefinition(itemPath); - if (itemDefFromObject != null) { - applyObjectTemplateItem(itemDefFromObject, templateItemDefType, "item " + itemPath + " in " + object - + " as specified in item definition in " + objectTemplateType); - } else { - OperationResult subResult = result.createMinorSubresult(SchemaTransformer.class.getName() + ".applyObjectTemplateToObject"); - subResult.recordPartialError("No definition for item " + itemPath + " in " + object - + " as specified in item definition in " + objectTemplateType); - continue; - } - Item item = object.findItem(itemPath); - if (item != null) { - ItemDefinition itemDef = item.getDefinition(); - if (itemDef != itemDefFromObject) { - applyObjectTemplateItem(itemDef, templateItemDefType, "item "+itemPath+" in " + object - + " as specified in item definition in "+objectTemplateType); - } - } - - } - } - - private void applyObjectTemplateItem(ID itemDef, - ObjectTemplateItemDefinitionType templateItemDefType, String desc) throws SchemaException { - if (itemDef == null) { - throw new SchemaException("No definition for "+desc); - } - - MutableItemDefinition mutableDef = itemDef.toMutable(); - - String displayName = templateItemDefType.getDisplayName(); - if (displayName != null) { - mutableDef.setDisplayName(displayName); - } - - String help = templateItemDefType.getHelp(); - if (help != null) { - mutableDef.setHelp(help); - } - - Integer displayOrder = templateItemDefType.getDisplayOrder(); - if (displayOrder != null) { - mutableDef.setDisplayOrder(displayOrder); - } - - Boolean emphasized = templateItemDefType.isEmphasized(); - if (emphasized != null) { - mutableDef.setEmphasized(emphasized); - } - - Boolean deprecated = templateItemDefType.isDeprecated(); - if (deprecated != null) { - mutableDef.setDeprecated(deprecated); - } - - Boolean experimental = templateItemDefType.isExperimental(); - if (experimental != null) { - mutableDef.setExperimental(experimental); - } - - List limitations = templateItemDefType.getLimitations(); - if (limitations != null) { - PropertyLimitationsType limitationsType = MiscSchemaUtil.getLimitationsType(limitations, LayerType.PRESENTATION); - if (limitationsType != null) { - if (limitationsType.getMinOccurs() != null) { - mutableDef.setMinOccurs(XsdTypeMapper.multiplicityToInteger(limitationsType.getMinOccurs())); - } - if (limitationsType.getMaxOccurs() != null) { - mutableDef.setMaxOccurs(XsdTypeMapper.multiplicityToInteger(limitationsType.getMaxOccurs())); - } - if (limitationsType.getProcessing() != null) { - mutableDef.setProcessing(MiscSchemaUtil.toItemProcessing(limitationsType.getProcessing())); - } - PropertyAccessType accessType = limitationsType.getAccess(); - if (accessType != null) { - if (accessType.isAdd() != null) { - mutableDef.setCanAdd(accessType.isAdd()); - } - if (accessType.isModify() != null) { - mutableDef.setCanModify(accessType.isModify()); - } - if (accessType.isRead() != null) { - mutableDef.setCanRead(accessType.isRead()); - } - } - } - } - - ObjectReferenceType valueEnumerationRef = templateItemDefType.getValueEnumerationRef(); - if (valueEnumerationRef != null) { - PrismReferenceValue valueEnumerationRVal = MiscSchemaUtil.objectReferenceTypeToReferenceValue(valueEnumerationRef, prismContext); - mutableDef.setValueEnumerationRef(valueEnumerationRVal); - } - - FormItemValidationType templateValidation = templateItemDefType.getValidation(); - if (templateValidation != null) { - itemDef.setAnnotation(ItemRefinedDefinitionType.F_VALIDATION, templateValidation.clone()); - } - } - - - private void validateObject(PrismObject object, GetOperationOptions options, OperationResult result) { - try { - if (InternalsConfig.readEncryptionChecks) { - CryptoUtil.checkEncrypted(object); - } - if (!InternalsConfig.consistencyChecks) { - return; - } - Class type = object.getCompileTimeClass(); - boolean tolerateRaw = GetOperationOptions.isTolerateRawData(options); - if (type == ResourceType.class || ShadowType.class.isAssignableFrom(type) || type == ReportType.class) { - // We tolerate raw values for resource and shadows in case the user has requested so - tolerateRaw = GetOperationOptions.isRaw(options); - } - if (hasError(object, result)) { - // If there is an error then the object might not be complete. - // E.g. we do not have a complete dynamic schema to apply to the object - // Tolerate some raw meat in that case. - tolerateRaw = true; - } - if (InternalsConfig.consistencyChecks) { - object.checkConsistence(true, !tolerateRaw, ConsistencyCheckScope.THOROUGH); - } - } catch (RuntimeException e) { - result.recordFatalError(e); - throw e; - } - } - - private boolean hasError(PrismObject object, OperationResult result) { - if (result != null && result.isError()) { // actually, result is pretty tiny here - does not include object fetch/get operation - return true; - } - OperationResultType fetchResult = object.asObjectable().getFetchResult(); - if (fetchResult != null && - (fetchResult.getStatus() == OperationResultStatusType.FATAL_ERROR || - fetchResult.getStatus() == OperationResultStatusType.PARTIAL_ERROR)) { - return true; - } - return false; - } - -} +/* + * Copyright (c) 2014-2019 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ +package com.evolveum.midpoint.model.impl.controller; + +import com.evolveum.midpoint.common.crypto.CryptoUtil; +import com.evolveum.midpoint.model.api.ModelAuthorizationAction; +import com.evolveum.midpoint.model.api.ModelExecuteOptions; +import com.evolveum.midpoint.model.common.ArchetypeManager; +import com.evolveum.midpoint.model.common.SystemObjectCache; +import com.evolveum.midpoint.model.impl.lens.LensContext; +import com.evolveum.midpoint.model.impl.lens.LensElementContext; +import com.evolveum.midpoint.model.impl.lens.LensFocusContext; +import com.evolveum.midpoint.model.impl.lens.LensProjectionContext; +import com.evolveum.midpoint.prism.*; +import com.evolveum.midpoint.prism.delta.ContainerDelta; +import com.evolveum.midpoint.prism.delta.ItemDelta; +import com.evolveum.midpoint.prism.delta.ObjectDelta; +import com.evolveum.midpoint.prism.path.UniformItemPath; +import com.evolveum.midpoint.prism.path.ItemName; +import com.evolveum.midpoint.prism.path.ItemPath; +import com.evolveum.midpoint.prism.xml.XsdTypeMapper; +import com.evolveum.midpoint.repo.api.RepositoryService; +import com.evolveum.midpoint.schema.DefinitionProcessingOption; +import com.evolveum.midpoint.schema.GetOperationOptions; +import com.evolveum.midpoint.schema.SearchResultList; +import com.evolveum.midpoint.schema.SelectorOptions; +import com.evolveum.midpoint.schema.constants.SchemaConstants; +import com.evolveum.midpoint.schema.internals.InternalsConfig; +import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.schema.util.MiscSchemaUtil; +import com.evolveum.midpoint.schema.util.ObjectTypeUtil; +import com.evolveum.midpoint.security.api.SecurityUtil; +import com.evolveum.midpoint.security.enforcer.api.AuthorizationParameters; +import com.evolveum.midpoint.security.enforcer.api.ObjectSecurityConstraints; +import com.evolveum.midpoint.security.enforcer.api.SecurityEnforcer; +import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.util.exception.*; +import com.evolveum.midpoint.util.logging.Trace; +import com.evolveum.midpoint.util.logging.TraceManager; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; +import com.evolveum.prism.xml.ns._public.types_3.ItemPathType; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.Validate; +import org.jetbrains.annotations.Contract; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Component; + +import java.util.*; + +/** + * Transforms the schema and objects by applying security constraints, + * object template schema refinements, etc. + * + * @author semancik + */ +@Component +public class SchemaTransformer { + + private static final Trace LOGGER = TraceManager.getTrace(SchemaTransformer.class); + + private static final String OPERATION_APPLY_SCHEMAS_AND_SECURITY = SchemaTransformer.class.getName()+".applySchemasAndSecurity"; + + @Autowired @Qualifier("cacheRepositoryService") private transient RepositoryService cacheRepositoryService; + @Autowired private SecurityEnforcer securityEnforcer; + @Autowired private SystemObjectCache systemObjectCache; + @Autowired private ArchetypeManager archetypeManager; + + @Autowired + private PrismContext prismContext; + + // TODO why are the following two methods distinct? Clarify their names. + public void applySchemasAndSecurityToObjectTypes(List objectTypes, + GetOperationOptions rootOptions, Collection> options, + AuthorizationPhaseType phase, Task task, OperationResult result) + throws SecurityViolationException, SchemaException, ConfigurationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException { + for (int i = 0; i < objectTypes.size(); i++) { + PrismObject object = (PrismObject) objectTypes.get(i).asPrismObject(); + object = object.cloneIfImmutable(); + objectTypes.set(i, object.asObjectable()); + applySchemasAndSecurity(object, rootOptions, options, phase, task, result); + } + } + + public void applySchemasAndSecurityToObjects(List> objects, + GetOperationOptions rootOptions, Collection> options, + AuthorizationPhaseType phase, Task task, OperationResult result) + throws SecurityViolationException, SchemaException { + for (int i = 0; i < objects.size(); i++) { + PrismObject object = objects.get(i); + object = object.cloneIfImmutable(); + objects.set(i, object); + applySchemaAndSecurityToObject(object, rootOptions, options, phase, task, result); + } + } + + // Expecting that C is a direct child of T. + // Expecting that container values point to their respective parents (in order to evaluate the security!) + public + SearchResultList applySchemasAndSecurityToContainers(SearchResultList originalResultList, Class parentObjectType, ItemName childItemName, + GetOperationOptions rootOptions, Collection> options, AuthorizationPhaseType phase, Task task, OperationResult result) + throws SecurityViolationException, SchemaException, ObjectNotFoundException, ConfigurationException, ExpressionEvaluationException, CommunicationException { + + List newValues = new ArrayList<>(); + Map,Object> processedParents = new IdentityHashMap<>(); + for (C value: originalResultList) { + Long originalId = value.asPrismContainerValue().getId(); + if (originalId == null) { + throw new SchemaException("No ID in container value " + value); + } + PrismObject parent = ObjectTypeUtil.getParentObject(value); + boolean wasProcessed; + if (parent != null) { + wasProcessed = processedParents.containsKey(parent); + } else { + // temporary solution TODO reconsider + parent = prismContext.createObject(parentObjectType); + PrismContainer childContainer = parent.findOrCreateItem(childItemName, PrismContainer.class); + childContainer.add(value.asPrismContainerValue()); + wasProcessed = false; + } + if (!wasProcessed) { + // TODO what if parent is immutable? + applySchemasAndSecurity(parent, rootOptions, options, phase, task, result); + processedParents.put(parent, null); + } + PrismContainer updatedChildContainer = parent.findContainer(childItemName); + if (updatedChildContainer != null) { + PrismContainerValue updatedChildValue = updatedChildContainer.getValue(originalId); + if (updatedChildValue != null) { + newValues.add(updatedChildValue.asContainerable()); + } + } + } + return new SearchResultList<>(newValues, originalResultList.getMetadata()); + } + + private void applySchemaAndSecurityToObject(PrismObject object, GetOperationOptions rootOptions, + Collection> options, AuthorizationPhaseType phase, Task task, OperationResult result) throws SecurityViolationException { + OperationResult subresult = new OperationResult(SchemaTransformer.class.getName()+".applySchemasAndSecurityToObject"); + try { + applySchemasAndSecurity(object, rootOptions, options, phase, task, subresult); + } catch (IllegalArgumentException | IllegalStateException | SchemaException |ConfigurationException |ObjectNotFoundException | ExpressionEvaluationException | CommunicationException e) { + LOGGER.error("Error post-processing object {}: {}", object, e.getMessage(), e); + OperationResultType fetchResult = object.asObjectable().getFetchResult(); + if (fetchResult == null) { + fetchResult = subresult.createOperationResultType(); + object.asObjectable().setFetchResult(fetchResult); + } else { + fetchResult.getPartialResults().add(subresult.createOperationResultType()); + } + fetchResult.setStatus(OperationResultStatusType.FATAL_ERROR); + } catch (SecurityViolationException e) { + // We cannot go on and leave this object in the result set. The object was not post-processed. + // Leaving it in the result set may leak information. + result.recordFatalError(e); + throw e; + } + } + + private void authorizeOptions(GetOperationOptions rootOptions, PrismObject object, ObjectDelta delta, AuthorizationPhaseType phase, Task task, OperationResult result) + throws SchemaException, SecurityViolationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { + if (GetOperationOptions.isRaw(rootOptions)) { + securityEnforcer.authorize(ModelAuthorizationAction.RAW_OPERATION.getUrl(), phase, AuthorizationParameters.Builder.buildObjectDelta(object, delta), null, task, result); + } + } + + /** + * Validate the objects, apply security to the object definition, remove any non-visible properties (security), + * apply object template definitions and so on. This method is called for + * any object that is returned from the Model Service. + */ + public void applySchemasAndSecurity(PrismObject object, GetOperationOptions rootOptions, + Collection> options, + AuthorizationPhaseType phase, Task task, OperationResult parentResult) + throws SchemaException, SecurityViolationException, ConfigurationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException { + LOGGER.trace("applySchemasAndSecurity({}) starting", object); + OperationResult result = parentResult.createMinorSubresult(SchemaTransformer.class.getName()+".applySchemasAndSecurity"); + authorizeOptions(rootOptions, object, null, phase, task, result); + validateObject(object, rootOptions, result); + + ObjectSecurityConstraints securityConstraints = compileSecurityConstraints(object, task, result); + PrismObjectDefinition objectDefinition = object.deepCloneDefinition(true, this::setFullAccessFlags); + + if (phase == null) { + if (!GetOperationOptions.isExecutionPhase(rootOptions)) { + applySchemasAndSecurityPhase(object, securityConstraints, objectDefinition, rootOptions, AuthorizationPhaseType.REQUEST, task, result); + } + applySchemasAndSecurityPhase(object, securityConstraints, objectDefinition, rootOptions, AuthorizationPhaseType.EXECUTION, task, result); + } else { + if (phase == AuthorizationPhaseType.REQUEST && GetOperationOptions.isExecutionPhase(rootOptions)) { + // Skip application of security constraints for request phase. + // The caller asked to skip evaluation of request authorization, so everything is allowed here. + } else { + applySchemasAndSecurityPhase(object, securityConstraints, objectDefinition, rootOptions, phase, task, result); + } + } + + // we do not need to process object template when processing REQUEST in RAW mode. + if (!GetOperationOptions.isRaw(rootOptions)) { + ObjectTemplateType objectTemplateType; + try { + objectTemplateType = determineObjectTemplate(object, AuthorizationPhaseType.REQUEST, result); + } catch (ConfigurationException | SchemaException | ObjectNotFoundException e) { + result.recordFatalError(e); + throw e; + } + applyObjectTemplateToObject(object, objectTemplateType, result); + } + + if (CollectionUtils.isNotEmpty(options)) { + Map> definitionProcessing = SelectorOptions.extractOptionValues(options, (o) -> o.getDefinitionProcessing(), prismContext); + if (CollectionUtils.isNotEmpty(definitionProcessing.get(DefinitionProcessingOption.NONE))) { + throw new UnsupportedOperationException("'NONE' definition processing is not supported now"); + } + Collection onlyIfExists = definitionProcessing.get(DefinitionProcessingOption.ONLY_IF_EXISTS); + if (CollectionUtils.isNotEmpty(onlyIfExists)) { + if (onlyIfExists.size() != 1 || !ItemPath.isEmpty(onlyIfExists.iterator().next())) { + throw new UnsupportedOperationException("'ONLY_IF_EXISTS' definition processing is currently supported on root level only; not on " + onlyIfExists); + } + Collection full = definitionProcessing.get(DefinitionProcessingOption.FULL); + object.trimDefinitionTree(full); + } + } + + result.computeStatus(); + result.recordSuccessIfUnknown(); + LOGGER.trace("applySchemasAndSecurity finishing"); // to allow folding in log viewer + } + + public void applySchemasAndSecurity(LensContext context, + AuthorizationPhaseType phase, Task task, OperationResult parentResult) throws SecurityViolationException, SchemaException, ConfigurationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException { + LOGGER.trace("applySchemasAndSecurity({}) starting", context); + OperationResult result = parentResult.createMinorSubresult(OPERATION_APPLY_SCHEMAS_AND_SECURITY); + + try { + applySchemasAndSecurityFocus(context, phase, task, result); + applySchemasAndSecurityProjections(context, phase, task, result); + + result.computeStatus(); + result.recordSuccessIfUnknown(); + + } catch (Throwable e) { + result.recordFatalError(e); + throw e; + } + + LOGGER.trace("applySchemasAndSecurity finishing"); // to allow folding in log viewer + } + + private void applySchemasAndSecurityFocus(LensContext context, + AuthorizationPhaseType phase, Task task, OperationResult result) throws SecurityViolationException, SchemaException, ConfigurationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException { + LensFocusContext focusContext = context.getFocusContext(); + if (focusContext == null) { + return; + } + + ObjectSecurityConstraints securityConstraints = applySchemasAndSecurityElementContext(context, focusContext, phase, task, result); + + AuthorizationDecisionType assignmentDecision = securityConstraints.findItemDecision(SchemaConstants.PATH_ASSIGNMENT, ModelAuthorizationAction.AUTZ_ACTIONS_URLS_GET, phase); + if (!AuthorizationDecisionType.ALLOW.equals(assignmentDecision)) { + PrismObject object = focusContext.getObjectAny(); + LOGGER.trace("Logged in user isn't authorized to read (or get) assignment item of the object: {}", object); + result.recordWarning("Logged in user isn't authorized to read (or get) assignment item of the object: " + object); + context.setEvaluatedAssignmentTriple(null); + } + } + + private void applySchemasAndSecurityProjections(LensContext context, + AuthorizationPhaseType phase, Task task, OperationResult result) throws SecurityViolationException, SchemaException, ConfigurationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException { + for (LensProjectionContext projCtx : context.getProjectionContexts()) { + if (projCtx != null && projCtx.getObjectAny() != null) { + applySchemasAndSecurityElementContext(context, projCtx, phase, task, result); + } + } + } + + private ObjectSecurityConstraints applySchemasAndSecurityElementContext(LensContext context, LensElementContext elementContext, + AuthorizationPhaseType phase, Task task, OperationResult result) throws SecurityViolationException, SchemaException, ConfigurationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException { + + PrismObject object = elementContext.getObjectAny(); + + if (object == null ) { + if (elementContext.getDelta() == null) { + return null; + } else { + throw new IllegalArgumentException("Cannot apply schema and security of null object"); + } + } + GetOperationOptions getOptions = ModelExecuteOptions.toGetOperationOptions(context.getOptions()); + authorizeOptions(getOptions, object, null, phase, task, result); + + ObjectSecurityConstraints securityConstraints = compileSecurityConstraints(object, task, result); + + AuthorizationDecisionType globalReadDecision = securityConstraints.findAllItemsDecision(ModelAuthorizationAction.AUTZ_ACTIONS_URLS_GET, phase); + if (globalReadDecision == AuthorizationDecisionType.DENY) { + // shortcut + SecurityUtil.logSecurityDeny(object, "because the authorization denies access"); + throw new AuthorizationException("Access denied"); + } + + AuthorizationDecisionType globalAddDecision = securityConstraints.findAllItemsDecision(ModelAuthorizationAction.ADD.getUrl(), phase); + AuthorizationDecisionType globalModifyDecision = securityConstraints.findAllItemsDecision(ModelAuthorizationAction.MODIFY.getUrl(), phase); + + elementContext.forEachObject(focusObject -> + applySecurityConstraints(focusObject.getValue(), securityConstraints, phase, + globalReadDecision, globalAddDecision, globalModifyDecision, + false)); + + elementContext.forEachDelta(focusDelta -> + applySecurityConstraints(focusDelta, securityConstraints, phase, + globalReadDecision, globalAddDecision, globalModifyDecision)); + + return securityConstraints; + } + + public void setFullAccessFlags(ItemDefinition itemDef) { + itemDef.toMutable().setCanRead(true); + itemDef.toMutable().setCanAdd(true); + itemDef.toMutable().setCanModify(true); + } + + private void applySchemasAndSecurityPhase(PrismObject object, ObjectSecurityConstraints securityConstraints, PrismObjectDefinition objectDefinition, + GetOperationOptions rootOptions, AuthorizationPhaseType phase, Task task, OperationResult result) + throws SchemaException, SecurityViolationException, ConfigurationException, ObjectNotFoundException { + Validate.notNull(phase); + try { + AuthorizationDecisionType globalReadDecision = securityConstraints.findAllItemsDecision(ModelAuthorizationAction.AUTZ_ACTIONS_URLS_GET, phase); + if (globalReadDecision == AuthorizationDecisionType.DENY) { + // shortcut + SecurityUtil.logSecurityDeny(object, "because the authorization denies access"); + throw new AuthorizationException("Access denied"); + } + + AuthorizationDecisionType globalAddDecision = securityConstraints.findAllItemsDecision(ModelAuthorizationAction.ADD.getUrl(), phase); + AuthorizationDecisionType globalModifyDecision = securityConstraints.findAllItemsDecision(ModelAuthorizationAction.MODIFY.getUrl(), phase); + applySecurityConstraints(object.getValue(), securityConstraints, phase, + globalReadDecision, globalAddDecision, globalModifyDecision, true); + if (object.isEmpty()) { + // let's make it explicit + SecurityUtil.logSecurityDeny(object, "because the subject has not access to any item"); + throw new AuthorizationException("Access denied"); + } + + applySecurityConstraintsItemDef(objectDefinition, new IdentityHashMap<>(), ItemPath.EMPTY_PATH, securityConstraints, globalReadDecision, globalAddDecision, globalModifyDecision, phase); + } catch (SecurityViolationException | RuntimeException e) { + result.recordFatalError(e); + throw e; + } + } + + private ObjectSecurityConstraints compileSecurityConstraints(PrismObject object, Task task, OperationResult result) throws SecurityViolationException, SchemaException, ConfigurationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException { + try { + ObjectSecurityConstraints securityConstraints = securityEnforcer.compileSecurityConstraints(object, null, task, result); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Security constraints for {}:\n{}", object, securityConstraints==null?"null":securityConstraints.debugDump()); + } + if (securityConstraints == null) { + SecurityUtil.logSecurityDeny(object, "because no security constraints are defined (default deny)"); + throw new AuthorizationException("Access denied"); + } + return securityConstraints; + } catch (Throwable e) { + result.recordFatalError(e); + throw e; + } + } + + private void applySecurityConstraints(PrismContainerValue pcv, ObjectSecurityConstraints securityConstraints, AuthorizationPhaseType phase, + AuthorizationDecisionType defaultReadDecision, AuthorizationDecisionType defaultAddDecision, + AuthorizationDecisionType defaultModifyDecision, boolean applyToDefinitions) { + LOGGER.trace("applySecurityConstraints(items): items={}, phase={}, defaults R={}, A={}, M={}", + pcv.getItems(), phase, defaultReadDecision, defaultAddDecision, defaultModifyDecision); + if (pcv.hasNoItems()) { + return; + } + List itemsToRemove = new ArrayList<>(); + for (Item item : pcv.getItems()) { + ItemPath itemPath = item.getPath(); + ItemDefinition itemDef = item.getDefinition(); + if (itemDef != null && itemDef.isElaborate()) { + LOGGER.trace("applySecurityConstraints(item): {}: skip (elaborate)", itemPath); + continue; + } + ItemPath nameOnlyItemPath = itemPath.namedSegmentsOnly(); + AuthorizationDecisionType itemReadDecision = computeItemDecision(securityConstraints, nameOnlyItemPath, ModelAuthorizationAction.AUTZ_ACTIONS_URLS_GET, defaultReadDecision, phase); + AuthorizationDecisionType itemAddDecision = computeItemDecision(securityConstraints, nameOnlyItemPath, ModelAuthorizationAction.AUTZ_ACTIONS_URLS_ADD, defaultReadDecision, phase); + AuthorizationDecisionType itemModifyDecision = computeItemDecision(securityConstraints, nameOnlyItemPath, ModelAuthorizationAction.AUTZ_ACTIONS_URLS_MODIFY, defaultReadDecision, phase); + LOGGER.trace("applySecurityConstraints(item): {}: decisions R={}, A={}, M={}", + itemPath, itemReadDecision, itemAddDecision, itemModifyDecision); + if (applyToDefinitions && itemDef != null) { + if (itemReadDecision != AuthorizationDecisionType.ALLOW) { + itemDef.toMutable().setCanRead(false); + } + if (itemAddDecision != AuthorizationDecisionType.ALLOW) { + itemDef.toMutable().setCanAdd(false); + } + if (itemModifyDecision != AuthorizationDecisionType.ALLOW) { + itemDef.toMutable().setCanModify(false); + } + } + if (item instanceof PrismContainer) { + if (itemReadDecision == AuthorizationDecisionType.DENY) { + // Explicitly denied access to the entire container + itemsToRemove.add(item); + } else { + // No explicit decision (even ALLOW is not final here as something may be denied deeper inside) + AuthorizationDecisionType subDefaultReadDecision = defaultReadDecision; + if (itemReadDecision == AuthorizationDecisionType.ALLOW) { + // This means allow to all subitems unless otherwise denied. + subDefaultReadDecision = AuthorizationDecisionType.ALLOW; + } + List> values = ((PrismContainer)item).getValues(); + reduceContainerValues(values, securityConstraints, phase, itemReadDecision, itemAddDecision, itemModifyDecision, subDefaultReadDecision, applyToDefinitions); + if (item.hasNoValues() && itemReadDecision == null) { + // We have removed all the content, if there was any. So, in the default case, there's nothing that + // we are interested in inside this item. Therefore let's just remove it. + // (If itemReadDecision is ALLOW, we obviously keep this untouched.) + itemsToRemove.add(item); + } + } + } else { + if (itemReadDecision == AuthorizationDecisionType.DENY || itemReadDecision == null) { + itemsToRemove.add(item); + } + } + } + for (Item itemToRemove : itemsToRemove) { + pcv.remove(itemToRemove); + } + } + + private void applySecurityConstraints(ObjectDelta objectDelta, ObjectSecurityConstraints securityConstraints, AuthorizationPhaseType phase, + AuthorizationDecisionType defaultReadDecision, AuthorizationDecisionType defaultAddDecision, AuthorizationDecisionType defaultModifyDecision) { + LOGGER.trace("applySecurityConstraints(objectDelta): items={}, phase={}, defaults R={}, A={}, M={}", + objectDelta, phase, defaultReadDecision, defaultAddDecision, defaultModifyDecision); + if (objectDelta == null) { + return; + } + if (objectDelta.isAdd()) { + applySecurityConstraints(objectDelta.getObjectToAdd().getValue(), securityConstraints, phase, defaultReadDecision, defaultAddDecision, defaultModifyDecision, false); + return; + } + if (objectDelta.isDelete()) { + // Nothing to do + return; + } + // Modify delta + Collection> modifications = objectDelta.getModifications(); + if (modifications == null || modifications.isEmpty()) { + // Nothing to do + return; + } + List> itemsToRemove = new ArrayList<>(); + for (ItemDelta modification : modifications) { + ItemPath itemPath = modification.getPath(); + ItemDefinition itemDef = modification.getDefinition(); + if (itemDef != null && itemDef.isElaborate()) { + LOGGER.trace("applySecurityConstraints(item): {}: skip (elaborate)", itemPath); + continue; + } + ItemPath nameOnlyItemPath = itemPath.namedSegmentsOnly(); + AuthorizationDecisionType itemReadDecision = computeItemDecision(securityConstraints, nameOnlyItemPath, ModelAuthorizationAction.AUTZ_ACTIONS_URLS_GET, defaultReadDecision, phase); + AuthorizationDecisionType itemAddDecision = computeItemDecision(securityConstraints, nameOnlyItemPath, ModelAuthorizationAction.AUTZ_ACTIONS_URLS_ADD, defaultReadDecision, phase); + AuthorizationDecisionType itemModifyDecision = computeItemDecision(securityConstraints, nameOnlyItemPath, ModelAuthorizationAction.AUTZ_ACTIONS_URLS_MODIFY, defaultReadDecision, phase); + LOGGER.trace("applySecurityConstraints(item): {}: decisions R={}, A={}, M={}", + itemPath, itemReadDecision, itemAddDecision, itemModifyDecision); + if (modification instanceof ContainerDelta) { + if (itemReadDecision == AuthorizationDecisionType.DENY) { + // Explicitly denied access to the entire container + itemsToRemove.add(modification); + } else { + // No explicit decision (even ALLOW is not final here as something may be denied deeper inside) + AuthorizationDecisionType subDefaultReadDecision = defaultReadDecision; + if (itemReadDecision == AuthorizationDecisionType.ALLOW) { + // This means allow to all subitems unless otherwise denied. + subDefaultReadDecision = AuthorizationDecisionType.ALLOW; + } + + reduceContainerValues((List>) ((ContainerDelta)modification).getValuesToAdd(), + securityConstraints, phase, itemReadDecision, itemAddDecision, itemModifyDecision, subDefaultReadDecision, false); + reduceContainerValues((List>) ((ContainerDelta)modification).getValuesToDelete(), + securityConstraints, phase, itemReadDecision, itemAddDecision, itemModifyDecision, subDefaultReadDecision, false); + reduceContainerValues((List>) ((ContainerDelta)modification).getValuesToReplace(), + securityConstraints, phase, itemReadDecision, itemAddDecision, itemModifyDecision, subDefaultReadDecision, false); + + if (modification.isEmpty() && itemReadDecision == null) { + // We have removed all the content, if there was any. So, in the default case, there's nothing that + // we are interested in inside this item. Therefore let's just remove it. + // (If itemReadDecision is ALLOW, we obviously keep this untouched.) + itemsToRemove.add(modification); + } + } + } else { + if (itemReadDecision == AuthorizationDecisionType.DENY || itemReadDecision == null) { + itemsToRemove.add(modification); + break; + } + } + } + for (ItemDelta modificationToRemove : itemsToRemove) { + modifications.remove(modificationToRemove); + } + } + + private boolean reduceContainerValues(List> values, ObjectSecurityConstraints securityConstraints, AuthorizationPhaseType phase, + AuthorizationDecisionType itemReadDecision, AuthorizationDecisionType itemAddDecision, AuthorizationDecisionType itemModifyDecision, AuthorizationDecisionType subDefaultReadDecision, + boolean applyToDefinitions) { + if (values == null) { + return false; + } + boolean removedSomething = false; + Iterator> vi = values.iterator(); + while (vi.hasNext()) { + PrismContainerValue cval = vi.next(); + applySecurityConstraints(cval, securityConstraints, phase, + subDefaultReadDecision, itemAddDecision, itemModifyDecision, applyToDefinitions); + if (cval.hasNoItems() && itemReadDecision == null) { + // We have removed all the content, if there was any. So, in the default case, there's nothing that + // we are interested in inside this PCV. Therefore let's just remove it. + // (If itemReadDecision is ALLOW, we obviously keep this untouched.) + vi.remove(); + removedSomething = true; + } + } + return removedSomething; + } + + public void applySecurityConstraints(D itemDefinition, ObjectSecurityConstraints securityConstraints, + AuthorizationPhaseType phase) { + if (phase == null) { + applySecurityConstraintsPhase(itemDefinition, securityConstraints, AuthorizationPhaseType.REQUEST); + applySecurityConstraintsPhase(itemDefinition, securityConstraints, AuthorizationPhaseType.EXECUTION); + } else { + applySecurityConstraintsPhase(itemDefinition, securityConstraints, phase); + } + } + + private void applySecurityConstraintsPhase(D itemDefinition, ObjectSecurityConstraints securityConstraints, + AuthorizationPhaseType phase) { + Validate.notNull(phase); + LOGGER.trace("applySecurityConstraints(itemDefs): def={}, phase={}", itemDefinition, phase); + applySecurityConstraintsItemDef(itemDefinition, new IdentityHashMap<>(), ItemPath.EMPTY_PATH, securityConstraints, + null, null, null, phase); + + } + + private void applySecurityConstraintsItemDef(D itemDefinition, + IdentityHashMap definitionsSeen, + ItemPath nameOnlyItemPath, ObjectSecurityConstraints securityConstraints, AuthorizationDecisionType defaultReadDecision, + AuthorizationDecisionType defaultAddDecision, AuthorizationDecisionType defaultModifyDecision, + AuthorizationPhaseType phase) { + + boolean thisWasSeen = definitionsSeen.containsKey(itemDefinition); + definitionsSeen.put(itemDefinition, null); + + AuthorizationDecisionType readDecision = computeItemDecision(securityConstraints, nameOnlyItemPath, ModelAuthorizationAction.AUTZ_ACTIONS_URLS_GET, defaultReadDecision, phase); + AuthorizationDecisionType addDecision = computeItemDecision(securityConstraints, nameOnlyItemPath, ModelAuthorizationAction.AUTZ_ACTIONS_URLS_ADD, defaultAddDecision, phase); + AuthorizationDecisionType modifyDecision = computeItemDecision(securityConstraints, nameOnlyItemPath, ModelAuthorizationAction.AUTZ_ACTIONS_URLS_MODIFY, defaultModifyDecision, phase); + + boolean anySubElementRead = false; + boolean anySubElementAdd = false; + boolean anySubElementModify = false; + if (itemDefinition instanceof PrismContainerDefinition && !thisWasSeen) { + PrismContainerDefinition containerDefinition = (PrismContainerDefinition)itemDefinition; + List subDefinitions = ((PrismContainerDefinition)containerDefinition).getDefinitions(); + for (ItemDefinition subDef: subDefinitions) { + ItemPath subPath = ItemPath.create(nameOnlyItemPath, subDef.getItemName()); + if (subDef.isElaborate()) { + LOGGER.trace("applySecurityConstraints(itemDef): {}: skip (elaborate)", subPath); + continue; + } + if (!subDef.getItemName().equals(ShadowType.F_ATTRIBUTES)) { // Shadow attributes have special handling + applySecurityConstraintsItemDef(subDef, definitionsSeen, subPath, securityConstraints, + readDecision, addDecision, modifyDecision, phase); + } + if (subDef.canRead()) { + anySubElementRead = true; + } + if (subDef.canAdd()) { + anySubElementAdd = true; + } + if (subDef.canModify()) { + anySubElementModify = true; + } + } + } + + LOGGER.trace("applySecurityConstraints(itemDef): {}: decisions R={}, A={}, M={}; subelements R={}, A={}, M={}", + nameOnlyItemPath, readDecision, addDecision, modifyDecision, anySubElementRead, anySubElementAdd, anySubElementModify); + + if (readDecision != AuthorizationDecisionType.ALLOW) { + itemDefinition.toMutable().setCanRead(false); + } + if (addDecision != AuthorizationDecisionType.ALLOW) { + itemDefinition.toMutable().setCanAdd(false); + } + if (modifyDecision != AuthorizationDecisionType.ALLOW) { + itemDefinition.toMutable().setCanModify(false); + } + + if (anySubElementRead) { + itemDefinition.toMutable().setCanRead(true); + } + if (anySubElementAdd) { + itemDefinition.toMutable().setCanAdd(true); + } + if (anySubElementModify) { + itemDefinition.toMutable().setCanModify(true); + } + } + + @Contract("_, _, _, !null, _ -> !null") + public AuthorizationDecisionType computeItemDecision(ObjectSecurityConstraints securityConstraints, ItemPath nameOnlyItemPath, String[] actionUrls, + AuthorizationDecisionType defaultDecision, AuthorizationPhaseType phase) { + AuthorizationDecisionType explicitDecision = securityConstraints.findItemDecision(nameOnlyItemPath, actionUrls, phase); +// LOGGER.trace("Explicit decision for {} ({} {}): {}", nameOnlyItemPath, actionUrl, phase, explicitDecision); + if (explicitDecision != null) { + return explicitDecision; + } else { + return defaultDecision; + } + } + + public ObjectTemplateType determineObjectTemplate(PrismObject object, AuthorizationPhaseType phase, OperationResult result) throws SchemaException, ConfigurationException, ObjectNotFoundException { + ArchetypePolicyType archetypePolicy = archetypeManager.determineArchetypePolicy(object, result); + if (archetypePolicy == null) { + return null; + } + ObjectReferenceType objectTemplateRef = archetypePolicy.getObjectTemplateRef(); + if (objectTemplateRef == null || StringUtils.isEmpty(objectTemplateRef.getOid())) { + return null; + } + PrismObject template = cacheRepositoryService.getObject(ObjectTemplateType.class, objectTemplateRef.getOid(), null, result); + return template.asObjectable(); + } + + public ObjectTemplateType determineObjectTemplate(Class objectClass, AuthorizationPhaseType phase, OperationResult result) throws SchemaException, ConfigurationException, ObjectNotFoundException { + PrismObject systemConfiguration = systemObjectCache.getSystemConfiguration(result); + if (systemConfiguration == null) { + return null; + } + ObjectPolicyConfigurationType objectPolicyConfiguration = ArchetypeManager.determineObjectPolicyConfiguration(objectClass, null, systemConfiguration.asObjectable()); + if (objectPolicyConfiguration == null) { + return null; + } + ObjectReferenceType objectTemplateRef = objectPolicyConfiguration.getObjectTemplateRef(); + if (objectTemplateRef == null) { + return null; + } + PrismObject template = cacheRepositoryService.getObject(ObjectTemplateType.class, objectTemplateRef.getOid(), null, result); + return template.asObjectable(); + } + + public void applyObjectTemplateToDefinition(PrismObjectDefinition objectDefinition, ObjectTemplateType objectTemplateType, OperationResult result) throws ObjectNotFoundException, SchemaException { + if (objectTemplateType == null) { + return; + } + for (ObjectReferenceType includeRef: objectTemplateType.getIncludeRef()) { + PrismObject subTemplate = cacheRepositoryService.getObject(ObjectTemplateType.class, includeRef.getOid(), null, result); + applyObjectTemplateToDefinition(objectDefinition, subTemplate.asObjectable(), result); + } + for (ObjectTemplateItemDefinitionType templateItemDefType: objectTemplateType.getItem()) { + ItemPathType ref = templateItemDefType.getRef(); + if (ref == null) { + throw new SchemaException("No 'ref' in item definition in "+objectTemplateType); + } + ItemPath itemPath = prismContext.toPath(ref); + ItemDefinition itemDef = objectDefinition.findItemDefinition(itemPath); + if (itemDef != null) { + applyObjectTemplateItem(itemDef, templateItemDefType, "item " + itemPath + " in object type " + objectDefinition.getTypeName() + " as specified in item definition in " + objectTemplateType); + } else { + OperationResult subResult = result.createMinorSubresult(SchemaTransformer.class.getName() + ".applyObjectTemplateToDefinition"); + subResult.recordPartialError("No definition for item " + itemPath + " in object type " + objectDefinition.getTypeName() + " as specified in item definition in " + objectTemplateType); + continue; + } + } + } + + private void applyObjectTemplateToObject(PrismObject object, ObjectTemplateType objectTemplateType, OperationResult result) throws ObjectNotFoundException, SchemaException { + if (objectTemplateType == null) { + return; + } + for (ObjectReferenceType includeRef: objectTemplateType.getIncludeRef()) { + PrismObject subTemplate = cacheRepositoryService.getObject(ObjectTemplateType.class, includeRef.getOid(), null, result); + applyObjectTemplateToObject(object, subTemplate.asObjectable(), result); + } + for (ObjectTemplateItemDefinitionType templateItemDefType: objectTemplateType.getItem()) { + ItemPathType ref = templateItemDefType.getRef(); + if (ref == null) { + throw new SchemaException("No 'ref' in item definition in "+objectTemplateType); + } + ItemPath itemPath = prismContext.toPath(ref); + ItemDefinition itemDefFromObject = object.getDefinition().findItemDefinition(itemPath); + if (itemDefFromObject != null) { + applyObjectTemplateItem(itemDefFromObject, templateItemDefType, "item " + itemPath + " in " + object + + " as specified in item definition in " + objectTemplateType); + } else { + OperationResult subResult = result.createMinorSubresult(SchemaTransformer.class.getName() + ".applyObjectTemplateToObject"); + subResult.recordPartialError("No definition for item " + itemPath + " in " + object + + " as specified in item definition in " + objectTemplateType); + continue; + } + Item item = object.findItem(itemPath); + if (item != null) { + ItemDefinition itemDef = item.getDefinition(); + if (itemDef != itemDefFromObject) { + applyObjectTemplateItem(itemDef, templateItemDefType, "item "+itemPath+" in " + object + + " as specified in item definition in "+objectTemplateType); + } + } + + } + } + + private void applyObjectTemplateItem(ID itemDef, + ObjectTemplateItemDefinitionType templateItemDefType, String desc) throws SchemaException { + if (itemDef == null) { + throw new SchemaException("No definition for "+desc); + } + + MutableItemDefinition mutableDef = itemDef.toMutable(); + + String displayName = templateItemDefType.getDisplayName(); + if (displayName != null) { + mutableDef.setDisplayName(displayName); + } + + String help = templateItemDefType.getHelp(); + if (help != null) { + mutableDef.setHelp(help); + } + + Integer displayOrder = templateItemDefType.getDisplayOrder(); + if (displayOrder != null) { + mutableDef.setDisplayOrder(displayOrder); + } + + Boolean emphasized = templateItemDefType.isEmphasized(); + if (emphasized != null) { + mutableDef.setEmphasized(emphasized); + } + + Boolean deprecated = templateItemDefType.isDeprecated(); + if (deprecated != null) { + mutableDef.setDeprecated(deprecated); + } + + Boolean experimental = templateItemDefType.isExperimental(); + if (experimental != null) { + mutableDef.setExperimental(experimental); + } + + List limitations = templateItemDefType.getLimitations(); + if (limitations != null) { + PropertyLimitationsType limitationsType = MiscSchemaUtil.getLimitationsType(limitations, LayerType.PRESENTATION); + if (limitationsType != null) { + if (limitationsType.getMinOccurs() != null) { + mutableDef.setMinOccurs(XsdTypeMapper.multiplicityToInteger(limitationsType.getMinOccurs())); + } + if (limitationsType.getMaxOccurs() != null) { + mutableDef.setMaxOccurs(XsdTypeMapper.multiplicityToInteger(limitationsType.getMaxOccurs())); + } + if (limitationsType.getProcessing() != null) { + mutableDef.setProcessing(MiscSchemaUtil.toItemProcessing(limitationsType.getProcessing())); + } + PropertyAccessType accessType = limitationsType.getAccess(); + if (accessType != null) { + if (accessType.isAdd() != null) { + mutableDef.setCanAdd(accessType.isAdd()); + } + if (accessType.isModify() != null) { + mutableDef.setCanModify(accessType.isModify()); + } + if (accessType.isRead() != null) { + mutableDef.setCanRead(accessType.isRead()); + } + } + } + } + + ObjectReferenceType valueEnumerationRef = templateItemDefType.getValueEnumerationRef(); + if (valueEnumerationRef != null) { + PrismReferenceValue valueEnumerationRVal = MiscSchemaUtil.objectReferenceTypeToReferenceValue(valueEnumerationRef, prismContext); + mutableDef.setValueEnumerationRef(valueEnumerationRVal); + } + + FormItemValidationType templateValidation = templateItemDefType.getValidation(); + if (templateValidation != null) { + itemDef.setAnnotation(ItemRefinedDefinitionType.F_VALIDATION, templateValidation.clone()); + } + } + + public void applyItemsConstraints(PrismObjectDefinition objectDefinition, ArchetypePolicyType archetypePolicy, OperationResult result) throws ObjectNotFoundException, SchemaException { + if (archetypePolicy == null) { + return; + } + Map visibilityMap = new HashMap<>(); + for (ItemConstraintType itemConstraint: archetypePolicy.getItemConstraint()) { + UserInterfaceElementVisibilityType visibility = itemConstraint.getVisibility(); + if (visibility == null) { + continue; + } + ItemPathType itemPathType = itemConstraint.getPath(); + if (itemPathType == null) { + throw new SchemaException("No 'path' in item definition in archetype policy for "+objectDefinition); + } + ItemPath itemPath = prismContext.toPath(itemPathType); + visibilityMap.put(itemPath, visibility); + } + if (visibilityMap.isEmpty()) { + return; + } + reduceItems(objectDefinition, ItemPath.EMPTY_PATH, visibilityMap); + } + + private UserInterfaceElementVisibilityType reduceItems(PrismContainerDefinition containerDefinition, ItemPath containerPath, Map visibilityMap) { + UserInterfaceElementVisibilityType containerVisibility = determineVisibility(visibilityMap, containerPath); + if (containerVisibility == UserInterfaceElementVisibilityType.HIDDEN) { + containerDefinition.getDefinitions().clear(); + return containerVisibility; + } + Iterator iterator = containerDefinition.getDefinitions().iterator(); + while (iterator.hasNext()) { + ItemDefinition subDefinition = iterator.next(); + ItemPath itemPath = containerPath.append(subDefinition.getItemName()); + if (subDefinition instanceof PrismContainerDefinition) { + PrismContainerDefinition subContainerDef = (PrismContainerDefinition)subDefinition; + UserInterfaceElementVisibilityType itemVisibility = reduceItems(subContainerDef, itemPath, visibilityMap); + if (subContainerDef.isEmpty() && itemVisibility != UserInterfaceElementVisibilityType.VISIBLE) { + iterator.remove(); + } + } else { + UserInterfaceElementVisibilityType itemVisibility = determineVisibility(visibilityMap, itemPath); + if (itemVisibility == UserInterfaceElementVisibilityType.VACANT || itemVisibility == UserInterfaceElementVisibilityType.HIDDEN) { + iterator.remove(); + } + } + } + return containerVisibility; + } + + private UserInterfaceElementVisibilityType determineVisibility(Map visibilityMap, ItemPath itemPath) { + if (itemPath == null || itemPath.isEmpty()) { + return UserInterfaceElementVisibilityType.AUTOMATIC; + } + UserInterfaceElementVisibilityType visibility = visibilityMap.get(itemPath); + if (visibility != null) { + return visibility; + } + return determineVisibility(visibilityMap, itemPath.allExceptLast()); + } + + private void validateObject(PrismObject object, GetOperationOptions options, OperationResult result) { + try { + if (InternalsConfig.readEncryptionChecks) { + CryptoUtil.checkEncrypted(object); + } + if (!InternalsConfig.consistencyChecks) { + return; + } + Class type = object.getCompileTimeClass(); + boolean tolerateRaw = GetOperationOptions.isTolerateRawData(options); + if (type == ResourceType.class || ShadowType.class.isAssignableFrom(type) || type == ReportType.class) { + // We tolerate raw values for resource and shadows in case the user has requested so + tolerateRaw = GetOperationOptions.isRaw(options); + } + if (hasError(object, result)) { + // If there is an error then the object might not be complete. + // E.g. we do not have a complete dynamic schema to apply to the object + // Tolerate some raw meat in that case. + tolerateRaw = true; + } + if (InternalsConfig.consistencyChecks) { + object.checkConsistence(true, !tolerateRaw, ConsistencyCheckScope.THOROUGH); + } + } catch (RuntimeException e) { + result.recordFatalError(e); + throw e; + } + } + + private boolean hasError(PrismObject object, OperationResult result) { + if (result != null && result.isError()) { // actually, result is pretty tiny here - does not include object fetch/get operation + return true; + } + OperationResultType fetchResult = object.asObjectable().getFetchResult(); + if (fetchResult != null && + (fetchResult.getStatus() == OperationResultStatusType.FATAL_ERROR || + fetchResult.getStatus() == OperationResultStatusType.PARTIAL_ERROR)) { + return true; + } + return false; + } + +} From 8f48fb0caf80b5d04a41ef65578351ad5d8251f6 Mon Sep 17 00:00:00 2001 From: Katarina Valalikova Date: Mon, 24 Feb 2020 22:05:13 +0100 Subject: [PATCH 05/97] schema for MID-6019 --- .../xml/ns/public/common/common-core-3.xsd | 25 ++----------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd b/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd index b55490052dc..4efafed90f1 100755 --- a/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd +++ b/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd @@ -6242,7 +6242,7 @@ - + Holds the information when the change of availabilityStatus was made. @@ -6369,7 +6369,7 @@ - Describes the reason for chanign availability status of the resource. + Describes the reason for changing availability status of the resource. 4.1 @@ -6400,27 +6400,6 @@ - - - - Structure containing metadata history about operational state of the resource. - E.g. if resource is up or down, when it was last checked, etc. - It should not contain configuration, just the operational state. - - - - - 4.1 - - - - - - - - - - From a3705d53fa593a83207572c045ad5cfb32af26b5 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Tue, 25 Feb 2020 18:41:46 +0100 Subject: [PATCH 06/97] TestNameHolder: TODO with plan how to get rid of it --- .../com/evolveum/midpoint/schema/util/TestNameHolder.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/TestNameHolder.java b/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/TestNameHolder.java index 17ab0077be8..8763f458a3a 100644 --- a/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/TestNameHolder.java +++ b/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/TestNameHolder.java @@ -9,7 +9,11 @@ /** * Very ugly hack. Assumes single-threaded tests. + * TODO notes: + * - implement TestTracerImpl where this usage is pulled out of production (main) code + * - and (perhaps in a single step) replace it with MidpointTestMethodContext usage */ +@Deprecated public class TestNameHolder { private static String currentTestName; From 5fa80eed0e8d91729106b0902fd23419565a2beb Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Tue, 25 Feb 2020 18:53:03 +0100 Subject: [PATCH 07/97] AbstractIntegrationTest: better before-/after-method with test context MidpointTestMethodContext is used ALWAYS, but some cleanup of all the integration tests is necessary. Previously conditional autoTaskManagementEnabled is gone. --- .../evolveum/midpoint/test/util/TestUtil.java | 197 ++++++------ .../impl/lens/TestAssignmentProcessor2.java | 2 - .../lens/TestPasswordPolicyProcessor.java | 2 - .../model/impl/lens/TestPolicyRules.java | 7 +- .../model/intest/TestStrangeCases.java | 2 - .../model/intest/TestUserTemplate.java | 7 +- .../async/TestAsyncUpdateTaskMechanics.java | 5 - .../model/intest/mapping/TestMapping.java | 2 - .../intest/sync/TestProgressReporting.java | 2 - .../model/intest/sync/TestRecomputeTask.java | 4 - .../wf/impl/AbstractWfTestPolicy.java | 6 - .../wf/impl/other/ManualResourceTest.java | 5 - .../impl/async/TestAsyncUpdate.java | 5 - .../test/AbstractIntegrationTest.java | 303 ++++++++---------- .../midpoint/test/IntegrationTestTools.java | 2 +- .../test/MidpointTestMethodContext.java | 15 +- .../midpoint/testing/story/TestDelivery.java | 7 +- .../testing/story/TestLargeGroups.java | 23 +- .../testing/story/TestManyThreads.java | 2 - .../story/grouper/AbstractGrouperTest.java | 5 - 20 files changed, 240 insertions(+), 363 deletions(-) diff --git a/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/TestUtil.java b/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/TestUtil.java index 910393c8532..d92ad24ff9b 100644 --- a/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/TestUtil.java +++ b/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/TestUtil.java @@ -7,32 +7,12 @@ package com.evolveum.midpoint.test.util; -import com.evolveum.midpoint.prism.Containerable; -import com.evolveum.midpoint.prism.ItemDefinition; -import com.evolveum.midpoint.prism.PrimitiveType; -import com.evolveum.midpoint.prism.PrismContainer; -import com.evolveum.midpoint.prism.PrismContext; -import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.PrismPropertyValue; -import com.evolveum.midpoint.prism.path.ItemName; -import com.evolveum.midpoint.schema.constants.SchemaConstants; -import com.evolveum.midpoint.schema.processor.ObjectFactory; -import com.evolveum.midpoint.schema.processor.ResourceAttribute; -import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition; -import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.schema.result.OperationResultStatus; -import com.evolveum.midpoint.schema.util.TestNameHolder; -import com.evolveum.midpoint.util.JAXBUtil; -import com.evolveum.midpoint.util.MiscUtil; -import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultStatusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertNotNull; +import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.fail; import java.io.BufferedReader; import java.io.File; @@ -41,17 +21,9 @@ import java.nio.file.Files; import java.nio.file.Paths; import java.nio.file.attribute.PosixFilePermission; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.GregorianCalendar; -import java.util.HashSet; -import java.util.List; -import java.util.Random; -import java.util.Set; +import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; - import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeConstants; import javax.xml.datatype.DatatypeFactory; @@ -64,12 +36,22 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; -import static org.testng.AssertJUnit.fail; +import com.evolveum.midpoint.prism.*; +import com.evolveum.midpoint.prism.path.ItemName; +import com.evolveum.midpoint.schema.constants.SchemaConstants; +import com.evolveum.midpoint.schema.processor.ObjectFactory; +import com.evolveum.midpoint.schema.processor.ResourceAttribute; +import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition; +import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.schema.result.OperationResultStatus; +import com.evolveum.midpoint.schema.util.TestNameHolder; +import com.evolveum.midpoint.util.JAXBUtil; +import com.evolveum.midpoint.util.MiscUtil; +import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; +import com.evolveum.midpoint.util.exception.SchemaException; +import com.evolveum.midpoint.util.logging.Trace; +import com.evolveum.midpoint.util.logging.TraceManager; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; /** * Unit test utilities. @@ -124,7 +106,7 @@ public static void assertSetEquals(String message, Collection actual, T.. } public static void assertSetEquals(String message, T[] actual, T[] expected) { - assertTrue(message+"expected "+Arrays.toString(expected)+", was "+Arrays.toString(actual), + assertTrue(message + "expected " + Arrays.toString(expected) + ", was " + Arrays.toString(actual), MiscUtil.unorderedArrayEquals(actual, expected)); } @@ -132,7 +114,7 @@ public static String getNodeOid(Node node) { Node oidNode = null; if ((null == node.getAttributes()) || (null == (oidNode = node.getAttributes().getNamedItem( - SchemaConstants.C_OID_ATTRIBUTE.getLocalPart()))) + SchemaConstants.C_OID_ATTRIBUTE.getLocalPart()))) || (StringUtils.isEmpty(oidNode.getNodeValue()))) { return null; } @@ -150,22 +132,22 @@ public static void setAttribute(PrismObject account, QName attrName, } public static void assertElement(List elements, QName elementQName, String value) { - for (Object element: elements) { + for (Object element : elements) { QName thisElementQName = JAXBUtil.getElementQName(element); if (elementQName.equals(thisElementQName)) { if (element instanceof Element) { - String thisElementContent = ((Element)element).getTextContent(); + String thisElementContent = ((Element) element).getTextContent(); if (value.equals(thisElementContent)) { return; } else { - AssertJUnit.fail("Wrong value for element with name "+elementQName+"; expected "+value+"; was "+thisElementContent); + AssertJUnit.fail("Wrong value for element with name " + elementQName + "; expected " + value + "; was " + thisElementContent); } } else { - throw new IllegalArgumentException("Unexpected type of element "+elementQName+": "+element.getClass()); + throw new IllegalArgumentException("Unexpected type of element " + elementQName + ": " + element.getClass()); } } } - AssertJUnit.fail("No element with name "+elementQName); + AssertJUnit.fail("No element with name " + elementQName); } public static void assertExceptionSanity(ObjectAlreadyExistsException e) { @@ -174,7 +156,7 @@ public static void assertExceptionSanity(ObjectAlreadyExistsException e) { System.out.println(ExceptionUtils.getFullStackTrace(e)); assert !e.getMessage().isEmpty() : "Empty exception message"; assert e.getMessage().length() < MAX_EXCEPTION_MESSAGE_LENGTH : "Exception message too long (" - +e.getMessage().length()+" characters): "+e.getMessage(); + + e.getMessage().length() + " characters): " + e.getMessage(); } public static void displayTestTitle(String testName) { @@ -190,6 +172,11 @@ public static void displayTestTitle(Object testCase, String testName) { TestNameHolder.setCurrentTestName(qualifiedTestName); } + public static void displayFooter(String footerText) { + System.out.println(TEST_OUT_PREFIX + footerText); + LOGGER.info(TEST_LOG_PREFIX + footerText); + } + public static void displayWhen(String testName) { System.out.println(TEST_OUT_SECTION_PREFIX + " WHEN " + testName + TEST_OUT_SECTION_SUFFIX); LOGGER.info(TEST_LOG_SECTION_PREFIX + " WHEN " + testName + TEST_LOG_SECTION_SUFFIX); @@ -230,7 +217,7 @@ public static void assertSuccess(String message, OperationResult result, Operati return; } if (result.getStatus() == null || result.getStatus().equals(OperationResultStatus.UNKNOWN)) { - String logmsg = message + ": undefined status ("+result.getStatus()+") on operation "+result.getOperation(); + String logmsg = message + ": undefined status (" + result.getStatus() + ") on operation " + result.getOperation(); LOGGER.error(logmsg); LOGGER.trace(logmsg + "\n" + originalResult.debugDump()); System.out.println(logmsg + "\n" + originalResult.debugDump()); @@ -276,7 +263,7 @@ public static void assertSuccess(String message, OperationResult result, int lev } public static void assertSuccess(String message, OperationResult result) { - assertSuccess(message, result,-1); + assertSuccess(message, result, -1); } public static void assertSuccess(OperationResultType result) { @@ -289,23 +276,23 @@ public static void assertSuccess(String message, OperationResultType result) { } assertNotNull(message + ": null result", result); // Ignore top-level if the operation name is not set - if (result.getOperation()!=null) { + if (result.getOperation() != null) { if (result.getStatus() == null || result.getStatus() == OperationResultStatusType.UNKNOWN) { - fail(message + ": undefined status ("+result.getStatus()+") on operation "+result.getOperation()); + fail(message + ": undefined status (" + result.getStatus() + ") on operation " + result.getOperation()); } if (result.getStatus() != OperationResultStatusType.SUCCESS && result.getStatus() != OperationResultStatusType.NOT_APPLICABLE && result.getStatus() != OperationResultStatusType.HANDLED_ERROR) { - fail(message + ": " + result.getMessage() + " ("+result.getStatus()+")"); + fail(message + ": " + result.getMessage() + " (" + result.getStatus() + ")"); } } List partialResults = result.getPartialResults(); for (OperationResultType subResult : partialResults) { - if (subResult==null) { - fail(message+": null subresult under operation "+result.getOperation()); + if (subResult == null) { + fail(message + ": null subresult under operation " + result.getOperation()); } - if (subResult.getOperation()==null) { - fail(message+": null subresult operation under operation "+result.getOperation()); + if (subResult.getOperation() == null) { + fail(message + ": null subresult operation under operation " + result.getOperation()); } assertSuccess(message, subResult); } @@ -313,51 +300,51 @@ public static void assertSuccess(String message, OperationResultType result) { public static void assertInProgressOrSuccess(OperationResult result) { if (!result.isInProgress()) { - assertSuccess("Operation "+result.getOperation()+" result", result); + assertSuccess("Operation " + result.getOperation() + " result", result); } } public static void assertSuccess(OperationResult result) { - assertSuccess("Operation "+result.getOperation()+" result", result); + assertSuccess("Operation " + result.getOperation() + " result", result); } public static void assertSuccess(OperationResult result, int depth) { - assertSuccess("Operation "+result.getOperation()+" result", result, depth); + assertSuccess("Operation " + result.getOperation() + " result", result, depth); } public static void assertStatus(OperationResult result, OperationResultStatus expectedStatus) { - assertEquals("Operation "+result.getOperation()+" result", expectedStatus, result.getStatus()); + assertEquals("Operation " + result.getOperation() + " result", expectedStatus, result.getStatus()); } public static void assertStatus(OperationResultType result, OperationResultStatusType expectedStatus) { - assertEquals("Operation "+result.getOperation()+" result", expectedStatus, result.getStatus()); + assertEquals("Operation " + result.getOperation() + " result", expectedStatus, result.getStatus()); } public static boolean hasWarningAssertSuccess(String message, OperationResultType result) { boolean hasWarning = false; // Ignore top-level if the operation name is not set - if (result.getOperation()!=null) { + if (result.getOperation() != null) { if (result.getStatus() == OperationResultStatusType.WARNING) { // Do not descent into warnings. There may be lions inside. Or errors. return true; } else { if (result.getStatus() == null || result.getStatus() == OperationResultStatusType.UNKNOWN) { - fail(message + ": undefined status ("+result.getStatus()+") on operation "+result.getOperation()); + fail(message + ": undefined status (" + result.getStatus() + ") on operation " + result.getOperation()); } if (result.getStatus() != OperationResultStatusType.SUCCESS && result.getStatus() != OperationResultStatusType.NOT_APPLICABLE && result.getStatus() != OperationResultStatusType.HANDLED_ERROR) { - fail(message + ": " + result.getMessage() + " ("+result.getStatus()+")"); + fail(message + ": " + result.getMessage() + " (" + result.getStatus() + ")"); } } } List partialResults = result.getPartialResults(); for (OperationResultType subResult : partialResults) { - if (subResult==null) { - fail(message+": null subresult under operation "+result.getOperation()); + if (subResult == null) { + fail(message + ": null subresult under operation " + result.getOperation()); } - if (subResult.getOperation()==null) { - fail(message+": null subresult operation under operation "+result.getOperation()); + if (subResult.getOperation() == null) { + fail(message + ": null subresult operation under operation " + result.getOperation()); } if (hasWarningAssertSuccess(message, subResult)) { hasWarning = true; @@ -380,23 +367,23 @@ public static void assertFailure(String message, OperationResult result) { public static void assertFailure(OperationResult result) { if (!result.isError()) { - String message = "Expected that operation "+result.getOperation()+" fails, but the result was "+result.getStatus(); + String message = "Expected that operation " + result.getOperation() + " fails, but the result was " + result.getStatus(); System.out.println(message); System.out.println(result.debugDump()); - LOGGER.error("{}",message); - LOGGER.error("{}",result.debugDump()); + LOGGER.error("{}", message); + LOGGER.error("{}", result.debugDump()); AssertJUnit.fail(message); } assertNoUnknown(result); } public static void assertPartialError(OperationResult result) { - assertTrue("Expected that operation "+result.getOperation()+" fails partially, but the result was "+result.getStatus(), result.getStatus() == OperationResultStatus.PARTIAL_ERROR); + assertTrue("Expected that operation " + result.getOperation() + " fails partially, but the result was " + result.getStatus(), result.getStatus() == OperationResultStatus.PARTIAL_ERROR); assertNoUnknown(result); } public static void assertResultStatus(OperationResult result, OperationResultStatus expectedStatus) { - assertTrue("Expected that operation "+result.getOperation()+" will result with "+expectedStatus+", but the result was "+result.getStatus(), result.getStatus() == expectedStatus); + assertTrue("Expected that operation " + result.getOperation() + " will result with " + expectedStatus + ", but the result was " + result.getStatus(), result.getStatus() == expectedStatus); assertNoUnknown(result); } @@ -406,26 +393,26 @@ public static void assertFailure(OperationResultType result) { public static void assertFailure(String message, OperationResultType result) { assertTrue((message == null ? "" : message + ": ") + - "Expected that operation "+result.getOperation()+" fails, but the result was "+result.getStatus(), + "Expected that operation " + result.getOperation() + " fails, but the result was " + result.getStatus(), OperationResultStatusType.FATAL_ERROR == result.getStatus() || - OperationResultStatusType.PARTIAL_ERROR == result.getStatus()) ; + OperationResultStatusType.PARTIAL_ERROR == result.getStatus()); assertNoUnknown(result); } public static void assertNoUnknown(OperationResult result) { if (result.isUnknown()) { - AssertJUnit.fail("Unkwnown status for operation "+result.getOperation()); + AssertJUnit.fail("Unkwnown status for operation " + result.getOperation()); } - for (OperationResult subresult: result.getSubresults()) { + for (OperationResult subresult : result.getSubresults()) { assertNoUnknown(subresult); } } public static void assertNoUnknown(OperationResultType result) { if (result.getStatus() == OperationResultStatusType.UNKNOWN) { - AssertJUnit.fail("Unkwnown status for operation "+result.getOperation()); + AssertJUnit.fail("Unkwnown status for operation " + result.getOperation()); } - for (OperationResultType subresult: result.getPartialResults()) { + for (OperationResultType subresult : result.getPartialResults()) { assertNoUnknown(subresult); } } @@ -444,7 +431,7 @@ public static void assertWarning(String message, OperationResult result) { public static boolean hasWarningAssertSuccess(String message, OperationResult result, OperationResult originalResult, int stopLevel, int currentLevel) { if (result.getStatus() == null || result.getStatus().equals(OperationResultStatus.UNKNOWN)) { - String logmsg = message + ": undefined status ("+result.getStatus()+") on operation "+result.getOperation(); + String logmsg = message + ": undefined status (" + result.getStatus() + ") on operation " + result.getOperation(); LOGGER.error(logmsg); LOGGER.trace(logmsg + "\n" + originalResult.debugDump()); System.out.println(logmsg + "\n" + originalResult.debugDump()); @@ -487,7 +474,7 @@ public static void assertWarning(String message, OperationResult result, int sto } public static void assertInProgress(String message, OperationResult result) { - assertTrue("Expected result IN_PROGRESS but it was "+result.getStatus()+" in "+message, + assertTrue("Expected result IN_PROGRESS but it was " + result.getStatus() + " in " + message, result.getStatus() == OperationResultStatus.IN_PROGRESS); } @@ -495,7 +482,7 @@ public static String getErrorMessage(OperationResult result) { if (result.isError()) { return result.getMessage(); } - for (OperationResult subresult: result.getSubresults()) { + for (OperationResult subresult : result.getSubresults()) { String message = getErrorMessage(subresult); if (message != null) { return message; @@ -543,9 +530,9 @@ public static String execSystemCommand(String command, boolean ignoreExitCode) t } reader.close(); String outstring = output.toString(); - LOGGER.debug("Command output:\n{}",outstring); + LOGGER.debug("Command output:\n{}", outstring); if (!ignoreExitCode && exitCode != 0) { - String msg = "Execution of command '"+command+"' failed with exit code "+exitCode; + String msg = "Execution of command '" + command + "' failed with exit code " + exitCode; LOGGER.error("{}", msg); throw new IOException(msg); } @@ -556,12 +543,12 @@ public static void assertBetween(String message, XMLGregorianCalendar start, XML XMLGregorianCalendar actual) { assertNotNull(message + " is null", actual); if (start != null) { - assertTrue(message+": expected time to be after "+start+" but it was "+actual, - actual.compare(start) == DatatypeConstants.GREATER || actual.compare(start) == DatatypeConstants.EQUAL); + assertTrue(message + ": expected time to be after " + start + " but it was " + actual, + actual.compare(start) == DatatypeConstants.GREATER || actual.compare(start) == DatatypeConstants.EQUAL); } if (end != null) { - assertTrue(message+": expected time to be before "+end+" but it was "+actual, - actual.compare(end) == DatatypeConstants.LESSER || actual.compare(end) == DatatypeConstants.EQUAL); + assertTrue(message + ": expected time to be before " + end + " but it was " + actual, + actual.compare(end) == DatatypeConstants.LESSER || actual.compare(end) == DatatypeConstants.EQUAL); } } @@ -569,23 +556,23 @@ public static void assertBetween(String message, Long start, Long end, Long actual) { assertNotNull(message + " is null", actual); if (start != null) { - assertTrue(message+": expected time to be after "+start+" but it was "+actual, actual >= start); + assertTrue(message + ": expected time to be after " + start + " but it was " + actual, actual >= start); } if (end != null) { - assertTrue(message+": expected time to be before "+end+" but it was "+actual, actual <= end); + assertTrue(message + ": expected time to be before " + end + " but it was " + actual, actual <= end); } } public static void assertEqualsTimestamp(String message, XMLGregorianCalendar expected, XMLGregorianCalendar actual) { - assertNotNull(message+"; expected "+expected, actual); - assertTrue(message+"; expected "+expected+" but was "+actual, expected.compare(actual) == 0); + assertNotNull(message + "; expected " + expected, actual); + assertTrue(message + "; expected " + expected + " but was " + actual, expected.compare(actual) == 0); } public static void assertCreateTimestamp(PrismObject object, XMLGregorianCalendar start, XMLGregorianCalendar end) { MetadataType metadata = object.asObjectable().getMetadata(); - assertNotNull("No metadata in "+object, metadata); - assertBetween("createTimestamp in "+object, start, end, metadata.getCreateTimestamp()); + assertNotNull("No metadata in " + object, metadata); + assertBetween("createTimestamp in " + object, start, end, metadata.getCreateTimestamp()); } public static void assertModifyTimestamp(PrismObject object, XMLGregorianCalendar start, @@ -596,8 +583,8 @@ public static void assertModifyTimestamp(PrismObject objec public static void assertModifyTimestamp(PrismObject object, XMLGregorianCalendar start, XMLGregorianCalendar end, String channel) { MetadataType metadata = object.asObjectable().getMetadata(); - assertNotNull("No metadata in "+object, metadata); - assertBetween("modifyTimestamp in "+object, start, end, metadata.getModifyTimestamp()); + assertNotNull("No metadata in " + object, metadata); + assertBetween("modifyTimestamp in " + object, start, end, metadata.getModifyTimestamp()); if (channel != null) { assertEquals("Wrong channel", channel, metadata.getModifyChannel()); } @@ -627,13 +614,13 @@ public static int getJavaMajorVersion() { if (matcher.matches()) { return Integer.parseInt(matcher.group(1)); } else { - throw new IllegalStateException("Cannot match java version string '"+javaVersionString+"'"); + throw new IllegalStateException("Cannot match java version string '" + javaVersionString + "'"); } } public static void assertMessageContains(String message, String expectedSubstring) { - assertTrue("Expected that message will contain substring '"+expectedSubstring+"', but it did not. Message: "+message, + assertTrue("Expected that message will contain substring '" + expectedSubstring + "', but it did not. Message: " + message, message.contains(expectedSubstring)); } @@ -660,12 +647,12 @@ public static void assertPrivateFilePermissions(File f) throws IOException { } } - private static void assertPermission(File f, Set permissions, PosixFilePermission permission) { - assertTrue(permissions.contains(permission), f.getPath() + ": missing permission "+permission); + private static void assertPermission(File f, Set permissions, PosixFilePermission permission) { + assertTrue(permissions.contains(permission), f.getPath() + ": missing permission " + permission); } private static void assertNoPermission(File f, Set permissions, PosixFilePermission permission) { - assertFalse(permissions.contains(permission), f.getPath() + ": unexpected permission "+permission); + assertFalse(permissions.contains(permission), f.getPath() + ": unexpected permission " + permission); } public static ParallelTestThread[] multithread(final String TEST_NAME, MultithreadRunner lambda, int numberOfThreads, Integer randomStartDelayRange) { @@ -677,7 +664,7 @@ public static ParallelTestThread[] multithread(final String TEST_NAME, Multithre LOGGER.info("{} starting", Thread.currentThread().getName()); lambda.run(ii); }); - threads[i].setName("Thread " + (i+1) + " of " + numberOfThreads); + threads[i].setName("Thread " + (i + 1) + " of " + numberOfThreads); threads[i].start(); } return threads; @@ -702,7 +689,7 @@ public static void waitForThreads(ParallelTestThread[] threads, long timeout) th } Throwable threadException = threads[i].getException(); if (threadException != null) { - throw new AssertionError("Test thread "+i+" failed: "+threadException.getMessage(), threadException); + throw new AssertionError("Test thread " + i + " failed: " + threadException.getMessage(), threadException); } } } diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor2.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor2.java index 4704ff61119..3b62cb5d907 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor2.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor2.java @@ -154,8 +154,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti initDummyResourcePirate(RESOURCE_DUMMY_EMPTY_INSTANCE_NAME, RESOURCE_DUMMY_EMPTY_FILE, RESOURCE_DUMMY_EMPTY_OID, initTask, initResult); - setAutoTaskManagementEnabled(true); - if (FIRST_PART) { createObjectsInFirstPart(false, initTask, initResult, null); } diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPasswordPolicyProcessor.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPasswordPolicyProcessor.java index 485f0cdbae4..c5430f15938 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPasswordPolicyProcessor.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPasswordPolicyProcessor.java @@ -50,8 +50,6 @@ public abstract class TestPasswordPolicyProcessor extends A @Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { super.initSystem(initTask, initResult); - - setAutoTaskManagementEnabled(true); } abstract Class getType(); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules.java index c7792fdf5b2..906016b1bf8 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules.java @@ -79,16 +79,11 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti // setPredefinedTestMethodTracing(MODEL_LOGGING); } - @Override - protected boolean isAutoTaskManagementEnabled() { - return true; - } - @Test public void test005JackAttemptAssignRoleJudge() throws Exception { Task task = getTask(); OperationResult result = getResult(); - + // GIVEN LensContext context = createUserLensContext(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestStrangeCases.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestStrangeCases.java index 88fb45fd645..fdd89056082 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestStrangeCases.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestStrangeCases.java @@ -139,8 +139,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Exception { super.initSystem(initTask, initResult); - setAutoTaskManagementEnabled(true); - initDummyResource(RESOURCE_DUMMY_CIRCUS_NAME, RESOURCE_DUMMY_CIRCUS_FILE, RESOURCE_DUMMY_CIRCUS_OID, initTask, initResult); getDummyResourceController(RESOURCE_DUMMY_RED_NAME).addAccount(ACCOUNT_GUYBRUSH_DUMMY_USERNAME, "Guybrush Threepwood", "Monkey Island"); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplate.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplate.java index 07f7d112fd0..e2d7d7a20e0 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplate.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplate.java @@ -114,18 +114,13 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti repoAddObjectFromFile(USER_TEMPLATE_MAROONED_FILE, initResult); repoAddObjectFromFile(USER_TEMPLATE_USELESS_FILE, initResult); repoAdd(USER_TEMPLATE_MID_5892, initResult); - + setDefaultObjectTemplate(UserType.COMPLEX_TYPE, USER_TEMPLATE_COMPLEX_OID, initResult); setDefaultObjectTemplate(UserType.COMPLEX_TYPE, SUBTYPE_MAROONED, USER_TEMPLATE_MAROONED_OID, initResult); setDefaultObjectTemplate(UserType.COMPLEX_TYPE, SUBTYPE_USELESS, USER_TEMPLATE_USELESS_OID, initResult); setDefaultObjectTemplate(UserType.COMPLEX_TYPE, SUBTYPE_MID_5892, USER_TEMPLATE_MID_5892.oid, initResult); } - @Override - protected boolean isAutoTaskManagementEnabled() { - return true; - } - protected int getNumberOfRoles() { return super.getNumberOfRoles() + NUMBER_OF_IMPORTED_ROLES; } diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateTaskMechanics.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateTaskMechanics.java index 48e9d65173f..98346a3b961 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateTaskMechanics.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateTaskMechanics.java @@ -69,11 +69,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti importObjectFromFile(RESOURCE_HR.file, initResult); } - @Override - protected boolean isAutoTaskManagementEnabled() { - return true; - } - @Override protected File getSystemConfigurationFile() { return SYSTEM_CONFIGURATION_FILE; diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMapping.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMapping.java index 73844390a4f..04779794a12 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMapping.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMapping.java @@ -170,8 +170,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); setDefaultObjectTemplate(UserType.COMPLEX_TYPE, USER_TYPE_CARTHESIAN, USER_TEMPLATE_CARTHESIAN_OID, initResult); - - setAutoTaskManagementEnabled(true); } /** diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestProgressReporting.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestProgressReporting.java index d45a58ab122..80c25f85788 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestProgressReporting.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestProgressReporting.java @@ -62,8 +62,6 @@ public class TestProgressReporting extends AbstractInitializedModelIntegrationTe public void initSystem(Task initTask, OperationResult initResult) throws Exception { super.initSystem(initTask, initResult); - setAutoTaskManagementEnabled(true); - interruptedSyncResource = new DummyInterruptedSyncResource(); interruptedSyncResource.init(dummyResourceCollection, initTask, initResult); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestRecomputeTask.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestRecomputeTask.java index a3bd43018e6..f7021037572 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestRecomputeTask.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestRecomputeTask.java @@ -87,10 +87,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti addObject(ARCHETYPE_TASK_RECOMPUTATION, initTask, initResult); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - - setAutoTaskManagementEnabled(true); - -// DebugUtil.setDetailedDebugDump(true); } @Test diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/AbstractWfTestPolicy.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/AbstractWfTestPolicy.java index 627d1fe544e..4edb532b255 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/AbstractWfTestPolicy.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/AbstractWfTestPolicy.java @@ -39,7 +39,6 @@ import com.evolveum.midpoint.wf.util.ApprovalUtils; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.lang3.ObjectUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; @@ -87,11 +86,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti super.initSystem(initTask, initResult); } - @Override - protected boolean isAutoTaskManagementEnabled() { - return true; - } - protected File getSystemConfigurationFile() { return SYSTEM_CONFIGURATION_FILE; } diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/ManualResourceTest.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/ManualResourceTest.java index 688bd4a4d14..8e813cefc63 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/ManualResourceTest.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/ManualResourceTest.java @@ -112,11 +112,6 @@ protected File getSystemConfigurationFile() { return SYSTEM_CONFIGURATION_FILE; } - @Override - protected boolean isAutoTaskManagementEnabled() { - return true; - } - private PrismObject createUserWill() throws SchemaException { PrismObject user = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class).instantiate(); user.asObjectable() diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/async/TestAsyncUpdate.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/async/TestAsyncUpdate.java index e4ae589050e..21e6eebd078 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/async/TestAsyncUpdate.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/async/TestAsyncUpdate.java @@ -95,11 +95,6 @@ protected TracingProfileType getTestMethodTracingProfile() { .fileNamePattern(TEST_METHOD_TRACING_FILENAME_PATTERN); } - @Override - protected boolean isAutoTaskManagementEnabled() { - return true; - } - @Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { // We need to switch off the encryption checks. Some values cannot be encrypted as we do 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 bb4a0011e02..2d89fe1eb20 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 @@ -6,15 +6,50 @@ */ package com.evolveum.midpoint.test; +import static org.testng.AssertJUnit.*; + import static com.evolveum.midpoint.test.PredefinedTestMethodTracing.OFF; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertTrue; + +import java.io.File; +import java.io.IOException; +import java.io.RandomAccessFile; +import java.lang.reflect.Method; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.cert.X509Certificate; +import java.time.ZonedDateTime; +import java.util.*; +import java.util.function.BiConsumer; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import javax.net.ssl.TrustManager; +import javax.net.ssl.TrustManagerFactory; +import javax.net.ssl.X509TrustManager; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.datatype.Duration; +import javax.xml.datatype.XMLGregorianCalendar; +import javax.xml.namespace.QName; import ch.qos.logback.classic.Level; import ch.qos.logback.classic.Logger; import ch.qos.logback.classic.LoggerContext; +import org.apache.commons.lang.SystemUtils; +import org.jetbrains.annotations.NotNull; +import org.opends.server.types.Entry; +import org.opends.server.types.SearchResultEntry; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.security.crypto.password.LdapShaPasswordEncoder; +import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; +import org.testng.*; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Listeners; +import org.w3c.dom.Element; + import com.evolveum.icf.dummy.resource.DummyResource; import com.evolveum.midpoint.common.Clock; import com.evolveum.midpoint.common.LocalizationService; @@ -31,7 +66,8 @@ import com.evolveum.midpoint.prism.delta.builder.S_ItemEntry; import com.evolveum.midpoint.prism.match.MatchingRule; import com.evolveum.midpoint.prism.match.MatchingRuleRegistry; -import com.evolveum.midpoint.prism.path.*; +import com.evolveum.midpoint.prism.path.ItemName; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.prism.query.ObjectFilter; import com.evolveum.midpoint.prism.query.ObjectQuery; @@ -51,8 +87,8 @@ import com.evolveum.midpoint.schema.internals.InternalCounters; import com.evolveum.midpoint.schema.internals.InternalMonitor; import com.evolveum.midpoint.schema.internals.InternalsConfig; -import com.evolveum.midpoint.schema.processor.*; import com.evolveum.midpoint.schema.processor.ObjectFactory; +import com.evolveum.midpoint.schema.processor.*; import com.evolveum.midpoint.schema.result.CompiledTracingProfile; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.result.OperationResultStatus; @@ -66,11 +102,7 @@ import com.evolveum.midpoint.test.asserter.prism.PrismObjectAsserter; import com.evolveum.midpoint.test.asserter.refinedschema.RefinedResourceSchemaAsserter; import com.evolveum.midpoint.test.ldap.OpenDJController; -import com.evolveum.midpoint.test.util.DerbyController; -import com.evolveum.midpoint.test.util.MidPointTestConstants; -import com.evolveum.midpoint.test.util.MultithreadRunner; -import com.evolveum.midpoint.test.util.ParallelTestThread; -import com.evolveum.midpoint.test.util.TestUtil; +import com.evolveum.midpoint.test.util.*; import com.evolveum.midpoint.tools.testng.CurrentTestResultHolder; import com.evolveum.midpoint.util.*; import com.evolveum.midpoint.util.exception.*; @@ -81,49 +113,8 @@ import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; import com.evolveum.prism.xml.ns._public.types_3.RawType; -import org.apache.commons.lang.SystemUtils; -import org.jetbrains.annotations.NotNull; -import org.opends.server.types.Entry; -import org.opends.server.types.SearchResultEntry; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.security.crypto.password.LdapShaPasswordEncoder; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; -import org.testng.*; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Listeners; -import org.w3c.dom.Element; - -import javax.net.ssl.TrustManager; -import javax.net.ssl.TrustManagerFactory; -import javax.net.ssl.X509TrustManager; -import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBException; -import javax.xml.datatype.Duration; -import javax.xml.datatype.XMLGregorianCalendar; -import javax.xml.namespace.QName; - -import java.io.File; -import java.io.IOException; -import java.io.RandomAccessFile; -import java.lang.reflect.Method; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.cert.X509Certificate; -import java.time.ZonedDateTime; -import java.util.*; -import java.util.function.BiConsumer; -import java.util.function.Consumer; -import java.util.stream.Collectors; - -import static org.testng.AssertJUnit.assertNotNull; - /** * @author Radovan Semancik - * */ @Listeners({ CurrentTestResultHolder.class }) public abstract class AbstractIntegrationTest extends AbstractTestNGSpringContextTests { @@ -131,8 +122,6 @@ public abstract class AbstractIntegrationTest extends AbstractTestNGSpringContex protected static final String USER_ADMINISTRATOR_USERNAME = "administrator"; public static final String COMMON_DIR_NAME = "common"; - @Deprecated - public static final String COMMON_DIR_PATH = MidPointTestConstants.TEST_RESOURCES_PATH + "/" + COMMON_DIR_NAME; public static final File COMMON_DIR = new File(MidPointTestConstants.TEST_RESOURCES_DIR, COMMON_DIR_NAME); protected static final String DEFAULT_INTENT = "default"; @@ -146,11 +135,6 @@ public abstract class AbstractIntegrationTest extends AbstractTestNGSpringContex private static final float FLOAT_EPSILON = 0.001f; - protected static final String ATTR_TASK = "task"; - protected static final String ATTR_RESULT = "result"; - - private static final String UNKNOWN_METHOD = "unknownMethod"; - // Values used to check if something is unchanged or changed properly protected LdapShaPasswordEncoder ldapShaPasswordEncoder = new LdapShaPasswordEncoder(); @@ -162,7 +146,7 @@ public abstract class AbstractIntegrationTest extends AbstractTestNGSpringContex @Autowired @Qualifier("cacheRepositoryService") protected RepositoryService repositoryService; - protected static Set initializedClasses = new HashSet<>(); + protected static Set> initializedClasses = new HashSet<>(); private long lastDummyResourceGroupMembersReadCount; private long lastDummyResourceWriteOperationCount; @@ -191,17 +175,13 @@ public abstract class AbstractIntegrationTest extends AbstractTestNGSpringContex */ protected PredefinedTestMethodTracing predefinedTestMethodTracing; - /** - * Enables automatic task and operation result management in test methods. - */ - protected boolean autoTaskManagementEnabled; - // We need this complicated init as we want to initialize repo only once. // JUnit will // create new class instance for every test, so @Before and @PostInit will // not work // directly. We also need to init the repo after spring autowire is done, so // @BeforeClass won't work either. + // TODO with TestNG we can use @BeforeClass again I guess (Virgo) @BeforeMethod public void initSystemConditional() throws Exception { // Check whether we are already initialized @@ -248,15 +228,9 @@ protected void unsetSystemInitialized() { /** * Creates appropriate task and result and set it into MidpointTestMethodContext. - * - * EXPERIMENTAL. */ @BeforeMethod - public void setTaskAndResult(ITestContext ctx, Method testMethod) throws SchemaException { - if (!isAutoTaskManagementEnabled()) { - return; - } - + public void startTestContext(ITestContext ctx, Method testMethod) throws SchemaException { String testShortName = testMethod.getDeclaringClass().getSimpleName() + "." + testMethod.getName(); String testFullName = testMethod.getDeclaringClass().getName() + "." + testMethod.getName(); TestUtil.displayTestTitle(testShortName); @@ -274,10 +248,32 @@ public void setTaskAndResult(ITestContext ctx, Method testMethod) throws SchemaE // (I.e. not via the test context.) task.setResult(result); - ctx.setAttribute(ATTR_TASK, task); - ctx.setAttribute(ATTR_RESULT, result); + MidpointTestMethodContext.create(testMethod.getName(), task, result); + } - MidpointTestMethodContext.setup(testMethod.getName(), task, result); + /** + * Finish and destroy the test context, output duration and store the operation trace. + */ + @AfterMethod + public void finishTestContext(ITestResult testResult, Method testMethod) { + MidpointTestMethodContext context = MidpointTestMethodContext.get(); + MidpointTestMethodContext.destroy(); // let's destroy it before anything else in this method + + long testMsDuration = testResult.getEndMillis() - testResult.getStartMillis(); + TestUtil.displayFooter(testMethod.getName() + " FINISHED in " + testMsDuration + " ms"); + + Task task = context.getTask(); + if (task != null) { + OperationResult result = context.getResult(); + if (result != null) { + result.computeStatusIfUnknown(); + if (result.isTraced()) { + System.out.println("Storing the trace."); + tracer.storeTrace(task, result, null); + } + task.getResult().computeStatusIfUnknown(); + } + } } protected TracingProfileType getTestMethodTracingProfile() { @@ -296,21 +292,6 @@ protected TracingProfileType getTestMethodTracingProfile() { } } - /** - * @return Whether automatic task and operation result management is enabled. - * - * Please either override this method or set autoTaskManagementEnabled to true. - * - * This method is a temporary solution until all test methods will use this automatic task/result management. - */ - protected boolean isAutoTaskManagementEnabled() { - return autoTaskManagementEnabled; - } - - public void setAutoTaskManagementEnabled(boolean autoTaskManagementEnabled) { - this.autoTaskManagementEnabled = autoTaskManagementEnabled; - } - public PredefinedTestMethodTracing getPredefinedTestMethodTracing() { return predefinedTestMethodTracing; } @@ -319,41 +300,8 @@ public void setPredefinedTestMethodTracing(PredefinedTestMethodTracing predefine this.predefinedTestMethodTracing = predefinedTestMethodTracing; } - /** - * Stores a trace of the operation result, if requested. - */ - @AfterMethod - public void storeTraceIfRequested(ITestContext ctx, Method testMethod) { - if (!isAutoTaskManagementEnabled()) { - return; - } - - System.out.println("After method: " + testMethod.getName()); - Task task = getTask(ctx); - if (task != null) { - OperationResult result = getResult(ctx); - if (result != null) { - result.computeStatusIfUnknown(); - if (result.isTraced()) { - System.out.println("Storing the trace."); - tracer.storeTrace(task, result, null); - } - task.getResult().computeStatusIfUnknown(); - } - } - - // Beware of any other after methods. They might need this context. - MidpointTestMethodContext.destroy(); - } - - @Deprecated - protected OperationResult getResult(IAttributes attrs) { - return (OperationResult) attrs.getAttribute(ATTR_RESULT); - } - - @Deprecated - protected Task getTask(IAttributes attrs) { - return (Task) attrs.getAttribute(ATTR_TASK); + protected Task getTask() { + return MidpointTestMethodContext.get().getTask(); } protected String getTestNameShort() { @@ -361,20 +309,12 @@ protected String getTestNameShort() { if (ctx != null) { return ctx.getMethodName(); } else { - return createAdHocTestContext(UNKNOWN_METHOD).getMethodName(); + // TODO simplify if passes + throw new IllegalStateException("getTestNameShort called while MidpointTestMethodContext is null"); +// return createAdHocTestContext(UNKNOWN_METHOD).getMethodName(); } } - /** - * Retrieves the task from thread-local test method context; creating the ad-hoc context if it does not exist. - * - * We expect this method to be called on startup of auto-task-managed test methods, therefore "getTask" is more suitable - * name that "getOrCreateTestTask". - */ - protected Task getTask() { - return getOrCreateTestTask(UNKNOWN_METHOD); - } - /** * Retrieves the task from thread-local test method context; creating the appropriately named ad-hoc context * if it does not exist. @@ -382,11 +322,13 @@ protected Task getTask() { * We expect this method to be called from places where we really don't know if the context exists or not. Hence its name. */ protected Task getOrCreateTestTask(String methodName) { + // TODO if OK, replace with getTask() MidpointTestMethodContext ctx = MidpointTestMethodContext.get(); if (ctx != null) { return ctx.getTask(); } else { - return createAdHocTestContext(methodName).getTask(); + throw new IllegalStateException("getOrCreateTestTask called while MidpointTestMethodContext is null"); +// return createAdHocTestContext(methodName).getTask(); } } @@ -398,11 +340,13 @@ protected Task getOrCreateTestTask(String methodName) { * by createTask method. */ protected Task getOrCreateSimpleTask(String operationName) { + // TODO if OK, replace with getTask() MidpointTestMethodContext ctx = MidpointTestMethodContext.get(); if (ctx != null) { return ctx.getTask(); } else { - return taskManager.createTaskInstance(this.getClass().getName() + "." + operationName); + throw new IllegalStateException("getOrCreateSimpleTask called while MidpointTestMethodContext is null"); +// return taskManager.createTaskInstance(this.getClass().getName() + "." + operationName); } } @@ -423,7 +367,9 @@ protected OperationResult getResult() { if (ctx != null) { return ctx.getResult(); } else { - return createAdHocTestContext(UNKNOWN_METHOD).getResult(); + // TODO simplify if OK + throw new IllegalStateException("getResult called while MidpointTestMethodContext is null"); +// return createAdHocTestContext(UNKNOWN_METHOD).getResult(); } } @@ -432,7 +378,7 @@ private MidpointTestMethodContext createAdHocTestContext(String methodName) { LOGGER.warn("No test context for current thread: creating new"); System.out.println("No test context for current thread: creating new"); Task task = createTask(methodName); - return MidpointTestMethodContext.setup(methodName, task, task.getResult()); + return MidpointTestMethodContext.create(methodName, task, task.getResult()); } abstract public void initSystem(Task initTask, OperationResult initResult) throws Exception; @@ -464,18 +410,23 @@ protected PrismObject repoAdd(TestResource resource, O return repoAddObjectFromFile(resource.file, parentResult); } - protected PrismObject repoAddObjectFromFile(File file, Class type, - OperationResult parentResult) throws SchemaException, ObjectAlreadyExistsException, EncryptionException, IOException { + protected PrismObject repoAddObjectFromFile( + File file, Class type, OperationResult parentResult) + throws SchemaException, ObjectAlreadyExistsException, EncryptionException, IOException { + return repoAddObjectFromFile(file, false, parentResult); } - protected PrismObject repoAddObjectFromFile(File file, Class type, - boolean metadata, OperationResult parentResult) throws SchemaException, ObjectAlreadyExistsException, EncryptionException, IOException { + protected PrismObject repoAddObjectFromFile( + File file, Class type, boolean metadata, OperationResult parentResult) + throws SchemaException, ObjectAlreadyExistsException, EncryptionException, IOException { + return repoAddObjectFromFile(file, metadata, parentResult); } - protected PrismObject repoAddObjectFromFile(File file, - boolean metadata, OperationResult parentResult) throws SchemaException, ObjectAlreadyExistsException, EncryptionException, IOException { + protected PrismObject repoAddObjectFromFile( + File file, boolean metadata, OperationResult parentResult) + throws SchemaException, ObjectAlreadyExistsException, EncryptionException, IOException { OperationResult result = parentResult.createSubresult(AbstractIntegrationTest.class.getName() + ".repoAddObjectFromFile"); @@ -536,16 +487,14 @@ protected void repoAddObject(PrismObject object, repoAddObject(object, null, result); } - protected void repoAddObject(PrismObject object, String contextDesc, - OperationResult result) throws SchemaException, ObjectAlreadyExistsException, EncryptionException { + protected void repoAddObject( + PrismObject object, String contextDesc, OperationResult result) + throws SchemaException, ObjectAlreadyExistsException, EncryptionException { if (object.canRepresent(TaskType.class)) { Assert.assertNotNull(taskManager, "Task manager is not initialized"); try { taskManager.addTask((PrismObject) object, result); - } catch (ObjectAlreadyExistsException ex) { - result.recordFatalError(ex.getMessage(), ex); - throw ex; - } catch (SchemaException ex) { + } catch (ObjectAlreadyExistsException | SchemaException ex) { result.recordFatalError(ex.getMessage(), ex); throw ex; } @@ -555,40 +504,38 @@ protected void repoAddObject(PrismObject object, Strin CryptoUtil.encryptValues(protector, object); String oid = repositoryService.addObject(object, null, result); object.setOid(oid); - } catch(ObjectAlreadyExistsException ex){ - result.recordFatalError(ex.getMessage()+" while adding "+object+(contextDesc==null?"":" "+contextDesc), ex); - throw ex; - } catch(SchemaException ex){ - result.recordFatalError(ex.getMessage()+" while adding "+object+(contextDesc==null?"":" "+contextDesc), ex); - throw ex; - } catch (EncryptionException ex) { + } catch(ObjectAlreadyExistsException | SchemaException | EncryptionException ex){ result.recordFatalError(ex.getMessage()+" while adding "+object+(contextDesc==null?"":" "+contextDesc), ex); throw ex; } } } - protected List> repoAddObjectsFromFile(String filePath, Class type, - OperationResult parentResult) throws SchemaException, ObjectAlreadyExistsException, IOException { + protected List> repoAddObjectsFromFile( + String filePath, Class type, OperationResult parentResult) + throws SchemaException, ObjectAlreadyExistsException, IOException, EncryptionException { + return repoAddObjectsFromFile(new File(filePath), type, parentResult); } - protected List> repoAddObjectsFromFile(File file, Class type, - OperationResult parentResult) throws SchemaException, ObjectAlreadyExistsException, IOException { + protected List> repoAddObjectsFromFile( + File file, Class type, OperationResult parentResult) + throws SchemaException, ObjectAlreadyExistsException, IOException, EncryptionException { + OperationResult result = parentResult.createSubresult(AbstractIntegrationTest.class.getName() + ".addObjectsFromFile"); result.addParam("file", file.getPath()); LOGGER.trace("addObjectsFromFile: {}", file); List> objects = (List) prismContext.parserFor(file).parseObjects(); - for (PrismObject object: objects) { + for (PrismObject object : objects) { try { repoAddObject(object, result); } catch (ObjectAlreadyExistsException e) { - throw new ObjectAlreadyExistsException(e.getMessage()+" while adding "+object+" from file "+file, e); + throw new ObjectAlreadyExistsException(e.getMessage() + " while adding " + object + " from file " + file, e); } catch (SchemaException e) { - new SchemaException(e.getMessage()+" while adding "+object+" from file "+file, e); + throw new SchemaException(e.getMessage() + " while adding " + object + " from file " + file, e); } catch (EncryptionException e) { - new EncryptionException(e.getMessage()+" while adding "+object+" from file "+file, e); + throw new EncryptionException(e.getMessage() + " while adding " + object + " from file " + file, e); } } result.recordSuccess(); @@ -596,21 +543,21 @@ protected List> repoAddObjectsFromFile(Fil } // these objects can be of various types - protected List repoAddObjectsFromFile(File file, OperationResult parentResult) throws SchemaException, ObjectAlreadyExistsException, IOException { + protected List repoAddObjectsFromFile(File file, OperationResult parentResult) throws SchemaException, ObjectAlreadyExistsException, IOException, EncryptionException { OperationResult result = parentResult.createSubresult(AbstractIntegrationTest.class.getName() + ".addObjectsFromFile"); result.addParam("file", file.getPath()); LOGGER.trace("addObjectsFromFile: {}", file); List objects = (List) prismContext.parserFor(file).parseObjects(); - for (PrismObject object: objects) { + for (PrismObject object : objects) { try { repoAddObject(object, result); } catch (ObjectAlreadyExistsException e) { - throw new ObjectAlreadyExistsException(e.getMessage()+" while adding "+object+" from file "+file, e); + throw new ObjectAlreadyExistsException(e.getMessage() + " while adding " + object + " from file " + file, e); } catch (SchemaException e) { - new SchemaException(e.getMessage()+" while adding "+object+" from file "+file, e); + throw new SchemaException(e.getMessage() + " while adding " + object + " from file " + file, e); } catch (EncryptionException e) { - new EncryptionException(e.getMessage()+" while adding "+object+" from file "+file, e); + throw new EncryptionException(e.getMessage() + " while adding " + object + " from file " + file, e); } } result.recordSuccess(); @@ -1611,7 +1558,7 @@ protected PasswordType assertUserPassword(PrismObject user, String exp return password; } - protected void assertUserNoPassword(PrismObject user) throws EncryptionException, SchemaException { + protected void assertUserNoPassword(PrismObject user) { UserType userType = user.asObjectable(); CredentialsType creds = userType.getCredentials(); if (creds != null) { @@ -1880,6 +1827,7 @@ protected void displaySkip(String testName) { * Used to display string HEREHERE both in test output and in logfiles. This can be used * to conveniently correlate a place in the test, output and logfiles. */ + @SuppressWarnings("unused") protected void displayHEREHERE() { IntegrationTestTools.display("HEREHERE"); } @@ -1904,7 +1852,7 @@ public static void display(String message, ObjectType o) { IntegrationTestTools.display(message, o); } - public static void display(String message, Collection collection) { + public static void display(String message, Collection collection) { IntegrationTestTools.display(message, collection); } @@ -1990,7 +1938,8 @@ protected void assertFloat(String message, Float expectedPercentage, Float actua fail(message + ", expected: " + expectedPercentage + ", but was "+actualPercentage); } } - if (actualPercentage > expectedPercentage + FLOAT_EPSILON || actualPercentage < expectedPercentage - FLOAT_EPSILON) { + //noinspection ConstantConditions + if (actualPercentage > expectedPercentage + FLOAT_EPSILON || (actualPercentage < (expectedPercentage - FLOAT_EPSILON))) { fail(message + ", expected: " + expectedPercentage + ", but was "+actualPercentage); } } @@ -1999,9 +1948,7 @@ protected Task createTask(String operationName) { if (!operationName.contains(".")) { operationName = this.getClass().getName() + "." + operationName; } - Task task = taskManager.createTaskInstance(operationName); -// setModelAndProvisioningLoggingTracing(task); - return task; + return taskManager.createTaskInstance(operationName); } protected void setDefaultTracing(Task task) { diff --git a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/IntegrationTestTools.java b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/IntegrationTestTools.java index ae4482ebe63..32d4a77e23e 100644 --- a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/IntegrationTestTools.java +++ b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/IntegrationTestTools.java @@ -443,7 +443,7 @@ public static void display(String message, ObjectType o) { + ObjectTypeUtil.dump(o)); } - public static void display(String message, Collection collection) { + public static void display(String message, Collection collection) { String dump; if (collection == null) { dump = ": null"; diff --git a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/MidpointTestMethodContext.java b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/MidpointTestMethodContext.java index 6dd864dcbe2..cb02dede71d 100644 --- a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/MidpointTestMethodContext.java +++ b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/MidpointTestMethodContext.java @@ -11,7 +11,10 @@ import com.evolveum.midpoint.task.api.Task; /** - * Thread-local context for midPoint test method. + * Value object carrying test context information like task, result and method name. + *

+ * Static methods are used for creating the context and working with it via {@link ThreadLocal}. + * It is important to to call {@link #destroy()} at the end (in some after-method). */ public final class MidpointTestMethodContext { @@ -50,16 +53,16 @@ public OperationResult getResult() { return result; } - public static MidpointTestMethodContext get() { - return TEST_CONTEXT_THREAD_LOCAL.get(); - } - - public static MidpointTestMethodContext setup(String methodName, Task task, OperationResult result) { + public static MidpointTestMethodContext create(String methodName, Task task, OperationResult result) { MidpointTestMethodContext ctx = new MidpointTestMethodContext(methodName, task, result); TEST_CONTEXT_THREAD_LOCAL.set(ctx); return ctx; } + public static MidpointTestMethodContext get() { + return TEST_CONTEXT_THREAD_LOCAL.get(); + } + public static void destroy() { TEST_CONTEXT_THREAD_LOCAL.remove(); } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelivery.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelivery.java index 968c57764b2..a5ba6d7a196 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelivery.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelivery.java @@ -160,12 +160,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti // setGlobalTracingOverride(createModelAndWorkflowLoggingTracingProfile()); } - @Override - protected boolean isAutoTaskManagementEnabled() { - return true; - } - -// @Override + // @Override // protected TracingProfileType getTestMethodTracingProfile() { // return createModelAndWorkflowLoggingTracingProfile() // .fileNamePattern(TEST_METHOD_TRACING_FILENAME_PATTERN); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLargeGroups.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLargeGroups.java index accac1ece2f..d89316239a8 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLargeGroups.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLargeGroups.java @@ -46,7 +46,6 @@ /** * An attempt to test performance of various operations on large groups. * E.g. MID-5836 but others as well (in the future). - * */ @ContextConfiguration(locations = { "classpath:ctx-story-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) @@ -77,11 +76,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti dummyResource.setSyncStyle(DummySyncStyle.SMART); } - @Override - protected boolean isAutoTaskManagementEnabled() { - return true; - } - @Override protected TracingProfileType getTestMethodTracingProfile() { return createModelLoggingTracingProfile() @@ -89,8 +83,8 @@ protected TracingProfileType getTestMethodTracingProfile() { } @Test - public void test000Sanity(ITestContext ctx) throws Exception { - Task task = getTask(ctx); + public void test000Sanity() throws Exception { + Task task = getTask(); OperationResult testResult = modelService.testResource(RESOURCE_DUMMY_OID, task); TestUtil.assertSuccess(testResult); @@ -101,8 +95,8 @@ public void test000Sanity(ITestContext ctx) throws Exception { */ @Test public void test100GetLargeGroup(ITestContext ctx) throws Exception { - Task task = getTask(ctx); - OperationResult result = getResult(ctx); + Task task = getTask(); + OperationResult result = getResult(); final int MEMBERS = 20000; @@ -124,9 +118,12 @@ public void test100GetLargeGroup(ITestContext ctx) throws Exception { assert100LargeGroupSearch(ctx, badOptions, MEMBERS); } - private void assert100LargeGroupSearch(ITestContext ctx, Collection> options, final int MEMBERS) throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException { - Task task = getTask(ctx); - OperationResult result = getResult(ctx); + private void assert100LargeGroupSearch( + ITestContext ctx, Collection> options, final int MEMBERS) + throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException { + + Task task = getTask(); + OperationResult result = getResult(); ResourceAttributeDefinition nameDefinition = libraryMidpointFunctions .getAttributeDefinition(resourceDummy, dummyResourceCtl.getGroupObjectClass(), SchemaConstants.ICFS_NAME); ObjectQuery query = prismContext.queryFor(ShadowType.class) diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestManyThreads.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestManyThreads.java index 33d92d9b792..bffda86e1fa 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestManyThreads.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestManyThreads.java @@ -61,8 +61,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti resourceDummy = importAndGetObjectFromFile(ResourceType.class, RESOURCE_DUMMY.file, RESOURCE_DUMMY.oid, initTask, initResult); dummyResourceCtl = DummyResourceContoller.create(null, resourceDummy); dummyResource = dummyResourceCtl.getDummyResource(); - - setAutoTaskManagementEnabled(true); } @Test diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/AbstractGrouperTest.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/AbstractGrouperTest.java index 53493c1fb24..a7de7802c53 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/AbstractGrouperTest.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/AbstractGrouperTest.java @@ -136,11 +136,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti addObject(TASK_GROUP_SCAVENGER, initTask, initResult); } - @Override - protected boolean isAutoTaskManagementEnabled() { - return true; - } - @Override protected File getSystemConfigurationFile() { return SYSTEM_CONFIGURATION_FILE; From 77faea50e7f006cd6b13dc6c6d8f12c43ae0179f Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Tue, 25 Feb 2020 19:07:43 +0100 Subject: [PATCH 08/97] AbstractIntegrationTest: removed/inlined displayTestTitle() --- .../TestIntegrationObjectWrapperFactory.java | 3 - .../midpoint/gui/TestWrapperDelta.java | 1 - ...AbstractInitializedGuiIntegrationTest.java | 2 +- .../midpoint/web/TestIntegrationSecurity.java | 5 +- .../lens/TestAbstractAssignmentEvaluator.java | 15 -- .../impl/lens/TestAssignmentProcessor.java | 2 +- .../model/impl/lens/TestClockwork.java | 4 - .../model/impl/lens/TestPolicyRules2.java | 20 --- .../model/impl/lens/TestProjector.java | 23 +-- .../model/impl/lens/TestReconScript.java | 7 +- .../TestCorrelationConfirmationEvaluator.java | 6 - .../impl/sync/TestSynchronizationService.java | 15 -- .../midpoint/model/intest/TestActivation.java | 72 +-------- .../midpoint/model/intest/TestAudit.java | 15 -- .../midpoint/model/intest/TestCaseIgnore.java | 15 +- .../model/intest/TestConnectorDummyFake.java | 15 -- .../intest/TestConnectorMultiInstance.java | 7 - .../model/intest/TestConsistencySimple.java | 1 - .../midpoint/model/intest/TestDeputy.java | 37 +---- .../model/intest/TestEntitlements.java | 76 +--------- .../midpoint/model/intest/TestInbounds.java | 20 --- .../midpoint/model/intest/TestIntent.java | 5 - .../midpoint/model/intest/TestIteration.java | 45 +----- .../model/intest/TestIterativeTasks.java | 1 - .../midpoint/model/intest/TestLifecycle.java | 10 -- .../intest/TestModelServiceContract.java | 43 ------ .../model/intest/TestPreviewChanges.java | 44 +----- .../model/intest/TestRaceConditions.java | 3 +- .../midpoint/model/intest/TestResources.java | 22 --- .../model/intest/TestScriptHooks.java | 2 - .../model/intest/TestTolerantAttributes.java | 3 +- .../model/intest/TestUserTemplate.java | 7 +- .../intest/TestUserTemplateWithRanges.java | 13 +- .../intest/archetypes/TestArchetypes.java | 25 ---- .../intest/archetypes/TestCollections.java | 24 --- .../gensync/TestAssociationInbound.java | 2 +- .../model/intest/gensync/TestEditSchema.java | 36 ----- .../intest/gensync/TestRoleEntitlement.java | 25 ---- .../intest/importer/AbstractImportTest.java | 19 --- .../AbstractDirectManualResourceTest.java | 38 +---- .../AbstractGroupingManualResourceTest.java | 14 -- .../manual/AbstractManualResourceTest.java | 39 ----- .../manual/TestDummyItsmIntegration.java | 17 +-- .../model/intest/manual/TestSemiManual.java | 5 - .../intest/manual/TestSemiManualDisable.java | 3 +- .../intest/manual/TestSemiManualGrouping.java | 2 +- .../TestSemiManualGroupingProposed.java | 4 +- .../mapping/TestMappingAutoInbound.java | 13 +- .../intest/mapping/TestMappingInbound.java | 21 --- .../model/intest/misc/TestMigration.java | 3 - .../midpoint/model/intest/misc/TestMisc.java | 20 --- .../intest/misc/TestUuidNonUniqueName.java | 6 +- .../model/intest/multi/TestMultiAccount.java | 7 +- .../multi/TestMultiConnectorResources.java | 14 +- .../model/intest/multi/TestMultiResource.java | 64 +------- .../intest/negative/TestAssignmentErrors.java | 9 -- .../intest/negative/TestBrokenResources.java | 33 ---- .../model/intest/orgstruct/TestOrgStruct.java | 56 ------- .../intest/password/AbstractPasswordTest.java | 106 +------------ .../password/TestPasswordDefaultHashing.java | 4 +- .../intest/persona/AbstractPersonaTest.java | 10 -- .../intest/persona/TestPersonaPassword.java | 2 +- .../intest/rbac/TestAssignmentValidity.java | 49 ------ .../model/intest/rbac/TestAutoassign.java | 6 +- .../model/intest/rbac/TestMetaMeta.java | 15 -- .../midpoint/model/intest/rbac/TestRbac.java | 141 ------------------ .../intest/rbac/TestSegregationOfDuties.java | 60 +------- .../intest/security/TestSecurityAdvanced.java | 51 +------ .../intest/security/TestSecurityBasic.java | 68 +-------- .../intest/security/TestSecurityMedium.java | 3 - .../security/TestSecurityMultitenant.java | 16 +- .../security/TestSecurityPrincipal.java | 14 -- .../sync/AbstractObjTemplateSyncTest.java | 2 +- .../AbstractSynchronizationStoryTest.java | 17 +-- .../model/intest/sync/TestImportRecon.java | 38 ----- .../intest/sync/TestInboundLiveSyncTask.java | 3 - .../intest/sync/TestInboundReconTask.java | 3 +- .../model/intest/sync/TestLiveSyncTask.java | 1 - .../sync/TestLiveSyncTaskMechanics.java | 11 +- .../intest/sync/TestParallelDiscovery.java | 3 - .../sync/TestParallelSynchronization.java | 4 +- .../midpoint/model/intest/sync/TestUuid.java | 4 - .../sync/TestValidityRecomputeTask.java | 49 ------ .../evolveum/midpoint/report/TestReport.java | 7 +- .../midpoint/report/TestReportWebService.java | 10 +- .../impl/TestConnectorDiscovery.java | 2 - .../impl/TestConnectorManager.java | 3 - .../impl/dummy/AbstractBasicDummyTest.java | 26 ---- .../provisioning/impl/dummy/TestDummy.java | 115 +------------- .../impl/dummy/TestDummyCaching.java | 4 - .../impl/dummy/TestDummyConsistency.java | 43 ------ .../impl/dummy/TestDummyExtra.java | 2 - .../impl/dummy/TestDummyNegative.java | 5 - .../impl/dummy/TestDummyParallelism.java | 10 -- .../TestDummyResourceAndSchemaCaching.java | 11 +- .../impl/dummy/TestDummySchemaless.java | 4 - .../manual/AbstractManualResourceTest.java | 31 ---- .../provisioning/impl/opendj/TestOpenDj.java | 78 +--------- .../impl/opendj/TestOpenDjDumber.java | 1 - .../impl/opendj/TestOpenDjNegative.java | 21 +-- .../common/commandline/TestCommandLine.java | 2 - .../test/AbstractIntegrationTest.java | 4 - .../midpoint/security/impl/TestEmpty.java | 1 - .../midpoint/testing/longtest/TestLdap.java | 11 +- .../testing/longtest/TestLdapComplex.java | 5 +- .../midpoint/testing/longtest/TestRunAs.java | 8 +- .../testing/rest/TestAbstractRestService.java | 67 --------- .../TestRestServiceProxyAuthentication.java | 10 -- .../midpoint/testing/sanity/TestSanity.java | 37 ----- .../TestConfiguredCapabilitiesActivation.java | 5 - .../story/TestConsistencyMechanism.java | 47 ------ .../testing/story/TestDelayedEnable.java | 34 +---- .../testing/story/TestEntertainment.java | 3 - .../testing/story/TestExistentialIssues.java | 7 - .../testing/story/TestImportGroups.java | 2 +- .../story/TestInboundOutboundAssociation.java | 17 --- .../testing/story/TestInducement.java | 8 - .../testing/story/TestLimitedResources.java | 10 -- .../testing/story/TestLiveSyncMadness.java | 8 +- .../story/TestMachineIntelligence.java | 1 - .../midpoint/testing/story/TestMapleLeaf.java | 13 -- .../testing/story/TestMappingMadness.java | 8 - .../story/TestMisbehavingResources.java | 7 +- .../testing/story/TestNormalizers.java | 3 - .../testing/story/TestNullAttribute.java | 9 +- .../testing/story/TestOperationCounts.java | 4 - .../testing/story/TestOperationPerf.java | 2 - .../midpoint/testing/story/TestOrgSync.java | 22 +-- .../story/TestPlentyOfAssignments.java | 12 +- .../testing/story/TestReconNullValue.java | 16 +- .../midpoint/testing/story/TestScience.java | 6 +- .../testing/story/TestServiceAccounts.java | 11 -- .../story/TestServiceAccountsClassifier.java | 11 +- .../testing/story/TestShadowsPerformance.java | 6 +- .../midpoint/testing/story/TestStrings.java | 17 --- .../testing/story/TestThresholds.java | 6 - .../story/TestThresholdsReconFull.java | 3 - .../midpoint/testing/story/TestUnix.java | 49 +----- .../testing/story/TestUnixTolerantAux.java | 5 - .../midpoint/testing/story/TestVillage.java | 30 +--- .../midpoint/testing/story/TestWriter.java | 3 - .../ldap/TestLdapAssociationPerformance.java | 10 -- .../testing/story/ldap/TestLdapComplex.java | 32 ---- .../story/ldap/TestLdapDependency.java | 9 -- .../testing/story/ldap/TestLdapMutilated.java | 24 --- .../story/ldap/TestLdapReconPerformance.java | 7 - .../story/ldap/TestLdapSyncMassive.java | 12 +- .../hierarchy/AbstractLdapHierarchyTest.java | 11 -- .../notorious/AbstractNotoriousTest.java | 27 ---- .../notorious/TestSupernotoriousOrg.java | 1 - .../testing/story/perf/TestImport.java | 3 +- .../testing/story/security/TestPrivacy.java | 2 +- .../story/security/TestRoleMembers.java | 4 - .../testing/story/uuid/AbstractUuidTest.java | 9 +- .../testing/story/uuid/TestUuidClient.java | 11 +- .../testing/story/uuid/TestUuidExtension.java | 12 -- 156 files changed, 76 insertions(+), 2739 deletions(-) diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestIntegrationObjectWrapperFactory.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestIntegrationObjectWrapperFactory.java index 78380a4215a..3860eef11e3 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestIntegrationObjectWrapperFactory.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestIntegrationObjectWrapperFactory.java @@ -575,7 +575,6 @@ public void test160CreateWrapperOrgScummBar() throws Exception { @Test public void test220AssignRoleLandluberToWally() throws Exception { final String TEST_NAME = "test220AssignRoleLandluberToWally"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -888,7 +887,6 @@ private void modifyTransformProp(PrismContainerValueWrapper trans @Test public void test800EditSchemaJackPropReadAllModifySomeUser() throws Exception { final String TEST_NAME = "test800EditSchemaJackPropReadAllModifySomeUser"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_PROP_READ_ALL_MODIFY_SOME_USER_OID); @@ -961,7 +959,6 @@ public void test800EditSchemaJackPropReadAllModifySomeUser() throws Exception { @Test public void test802EditSchemaJackPropReadSomeModifySomeUser() throws Exception { final String TEST_NAME = "test800EditSchemaJackPropReadAllModifySomeUser"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_PROP_READ_SOME_MODIFY_SOME_USER_OID); diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestWrapperDelta.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestWrapperDelta.java index 49836aa40dd..4cf3917b6a4 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestWrapperDelta.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestWrapperDelta.java @@ -265,7 +265,6 @@ public void test111modifyUserAssignemnt() throws Exception { @Test public void test200createUser() throws Exception { String TEST_NAME = "test200createUser"; - displayTestTitle(TEST_NAME); Task task = createSimpleTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/AbstractInitializedGuiIntegrationTest.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/AbstractInitializedGuiIntegrationTest.java index 9b1c4cdeeee..26d5596a154 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/AbstractInitializedGuiIntegrationTest.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/AbstractInitializedGuiIntegrationTest.java @@ -17,6 +17,7 @@ import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.logging.Trace; @@ -72,7 +73,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000PreparationAndSanity() throws Exception { final String TEST_NAME = "test000PreparationAndSanity"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestIntegrationSecurity.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestIntegrationSecurity.java index 596395b8ee8..e8934d7e9ff 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestIntegrationSecurity.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestIntegrationSecurity.java @@ -14,6 +14,7 @@ import java.util.ArrayList; import java.util.Collection; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType; import org.springframework.beans.factory.annotation.Autowired; @@ -92,7 +93,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100DecideNoRole() throws Exception { final String TEST_NAME = "test100DecideNoRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); PrismObject user = getUser(USER_JACK_OID); @@ -119,7 +119,6 @@ public void test100DecideNoRole() throws Exception { @Test public void test110DecideRoleUiAllowAll() throws Exception { final String TEST_NAME = "test110DecideRoleUiAllowAll"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_UI_ALLOW_ALL_OID); @@ -147,7 +146,6 @@ public void test110DecideRoleUiAllowAll() throws Exception { @Test public void test120DecideRoleUiDenyAll() throws Exception { final String TEST_NAME = "test120DecideRoleUiDenyAll"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_UI_DENY_ALL_OID); @@ -179,7 +177,6 @@ public void test120DecideRoleUiDenyAll() throws Exception { @Test public void test200DecideRoleUiDenyAllow() throws Exception { final String TEST_NAME = "test200DecideRoleUiDenyAllow"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_UI_DENY_ALLOW_OID); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAbstractAssignmentEvaluator.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAbstractAssignmentEvaluator.java index 21ee669e441..51a86ade1ad 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAbstractAssignmentEvaluator.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAbstractAssignmentEvaluator.java @@ -110,7 +110,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100Direct() throws Exception { final String TEST_NAME = "test100Direct"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentEvaluator.class.getName() + "." + TEST_NAME); @@ -149,7 +148,6 @@ public void test100Direct() throws Exception { @Test public void test110DirectExpression() throws Exception { final String TEST_NAME = "test110DirectExpression"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentEvaluator.class.getName() + "." + TEST_NAME); @@ -188,7 +186,6 @@ public void test110DirectExpression() throws Exception { @Test public void test120DirectExpressionReplaceDescription() throws Exception { final String TEST_NAME = "test120DirectExpressionReplaceDescription"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentEvaluator.class.getName() + "." + TEST_NAME); @@ -250,7 +247,6 @@ public void test120DirectExpressionReplaceDescription() throws Exception { @Test public void test130DirectExpressionReplaceDescriptionFromNull() throws Exception { final String TEST_NAME = "test130DirectExpressionReplaceDescriptionFromNull"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentEvaluator.class.getName() + "." + TEST_NAME); @@ -334,7 +330,6 @@ Explanation for roles structure (copied from role-corp-generic-metarole.xml) @Test public void test140RoleVisitor() throws Exception { final String TEST_NAME = "test140RoleVisitor"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentEvaluator.class.getName() + "." + TEST_NAME); @@ -379,7 +374,6 @@ public void test140RoleVisitor() throws Exception { @Test public void test142RoleVisitorDisabledAssignment() throws Exception { final String TEST_NAME = "test142RoleVisitorDisabledAssignment"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentEvaluator.class.getName() + "." + TEST_NAME); @@ -426,7 +420,6 @@ public void test142RoleVisitorDisabledAssignment() throws Exception { @Test public void test150RoleEngineer() throws Exception { final String TEST_NAME = "test150RoleEngineer"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentEvaluator.class.getName() + "." + TEST_NAME); @@ -472,7 +465,6 @@ public void test150RoleEngineer() throws Exception { @Test public void test160AddRoleEngineer() throws Exception { final String TEST_NAME = "test160AddRoleEngineer"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentEvaluator.class.getName() + "." + TEST_NAME); @@ -543,7 +535,6 @@ public void test160AddRoleEngineer() throws Exception { @Test public void test170RoleManagerChangeCostCenter() throws Exception { final String TEST_NAME = "test170RoleManagerChangeCostCenter"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentEvaluator.class.getName() + "." + TEST_NAME); @@ -606,7 +597,6 @@ public void test170RoleManagerChangeCostCenter() throws Exception { @Test public void test180RoleManagerRemoveCostCenter() throws Exception { final String TEST_NAME = "test180RoleManagerRemoveCostCenter"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentEvaluator.class.getName() + "." + TEST_NAME); @@ -666,7 +656,6 @@ public void test180RoleManagerRemoveCostCenter() throws Exception { @Test(enabled = false) public void test200DisableEngineerEmployeeInducement() throws Exception { final String TEST_NAME = "test200DisableEngineerEmployeeInducement"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentEvaluator.class.getName() + "." + TEST_NAME); @@ -707,7 +696,6 @@ public void test200DisableEngineerEmployeeInducement() throws Exception { @Test(enabled = false) public void test299ReenableEngineerEmployeeInducement() throws Exception { final String TEST_NAME = "test299ReenableEngineerEmployeeInducement"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentEvaluator.class.getName() + "." + TEST_NAME); @@ -728,7 +716,6 @@ public void test299ReenableEngineerEmployeeInducement() throws Exception { @Test public void test300DisableRoleEmployee() throws Exception { final String TEST_NAME = "test300DisableRoleEmployee"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentEvaluator.class.getName() + "." + TEST_NAME); @@ -783,7 +770,6 @@ public void test300DisableRoleEmployee() throws Exception { @Test public void test310DisableRoleEngineer() throws Exception { final String TEST_NAME = "test310DisableRoleEngineer"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentEvaluator.class.getName() + "." + TEST_NAME); @@ -843,7 +829,6 @@ public void test310DisableRoleEngineer() throws Exception { @Test public void test400UserFred() throws Exception { final String TEST_NAME = "test400UserFred"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentEvaluator.class.getName() + "." + TEST_NAME); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor.java index 3cffc187f3a..2c34c33244f 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor.java @@ -22,6 +22,7 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.ObjectTypeUtil; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; @@ -366,7 +367,6 @@ public void test021AddAssignmentModifyAccountAssignment() throws Exception { @Test public void test031DeleteAssignmentModifyAccount() throws Exception { final String TEST_NAME = "test031DeleteAssignmentModifyAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentProcessor.class.getName() + "." + TEST_NAME); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestClockwork.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestClockwork.java index 33f54317ae6..3f4dfa5aa80 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestClockwork.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestClockwork.java @@ -90,7 +90,6 @@ public void initSystem(Task initTask, OperationResult initResult) @Test public void test010SerializeAddUserBarbossa() throws Exception { final String TEST_NAME = "test010SerializeAddUserBarbossa"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -130,7 +129,6 @@ public void test010SerializeAddUserBarbossa() throws Exception { @Test public void test020AssignAccountToJackSync() throws Exception { final String TEST_NAME = "test020AssignAccountToJackSync"; - displayTestTitle(TEST_NAME); try { @@ -209,7 +207,6 @@ public void test031AssignAccountToJackAsyncSerialize() throws Exception { @Test public void test053ModifyUserBarbossaDisable() throws Exception { final String TEST_NAME = "test053ModifyUserBarbossaDisable"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -266,7 +263,6 @@ public void test053ModifyUserBarbossaDisable() throws Exception { } private void assignAccountToJackAsync(String testName, boolean serialize) throws Exception { - displayTestTitle(testName); // GIVEN Task task = createTask(testName); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules2.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules2.java index b6239bbcc77..1ae6bb4a0ec 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules2.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules2.java @@ -131,7 +131,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100JackAttemptAssignRoleStudent() throws Exception { final String TEST_NAME = "test100JackAttemptAssignRoleStudent"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -174,7 +173,6 @@ public void test100JackAttemptAssignRoleStudent() throws Exception { @Test public void test110JoeAttemptAssignRoleStudent() throws Exception { final String TEST_NAME = "test110JoeAttemptAssignRoleStudent"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -221,7 +219,6 @@ public void test110JoeAttemptAssignRoleStudent() throws Exception { @Test public void test120JackAttemptToMoveTo1900AndAssignRoleStudent() throws Exception { final String TEST_NAME = "test120JackAttemptToMoveTo1900AndAssignRoleStudent"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -274,7 +271,6 @@ public void test120JackAttemptToMoveTo1900AndAssignRoleStudent() throws Exceptio @Test public void test130JackMoveTo1900AndAssignRoleStudent() throws Exception { final String TEST_NAME = "test130JackMoveTo1900AndAssignRoleStudent"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -330,7 +326,6 @@ public void test130JackMoveTo1900AndAssignRoleStudent() throws Exception { @Test public void test135JackChangeValidTo() throws Exception { final String TEST_NAME = "test135JackChangeValidTo"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -378,7 +373,6 @@ public void test135JackChangeValidTo() throws Exception { @Test public void test140JackNoChange() throws Exception { final String TEST_NAME = "test140JackNoChange"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -419,7 +413,6 @@ public void test140JackNoChange() throws Exception { @Test public void test142JackNoChangeButTaskExists() throws Exception { final String TEST_NAME = "test142JackNoChangeButTaskExists"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -480,7 +473,6 @@ public void test142JackNoChangeButTaskExists() throws Exception { @Test public void test150FrankAttemptToAssignRoleStudentButDisabled() throws Exception { final String TEST_NAME = "test150FrankAttemptToAssignRoleStudentButDisabled"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -528,7 +520,6 @@ public void test150FrankAttemptToAssignRoleStudentButDisabled() throws Exception @Test public void test160AttemptToAddPeter() throws Exception { final String TEST_NAME = "test160AttemptToAddPeter"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -568,7 +559,6 @@ public void test160AttemptToAddPeter() throws Exception { @Test public void test170AddPeter() throws Exception { final String TEST_NAME = "test170AddPeter"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -626,7 +616,6 @@ public void test170AddPeter() throws Exception { @Test public void test180StudentRecompute() throws Exception { final String TEST_NAME = "test180StudentRecompute"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -662,7 +651,6 @@ public void test180StudentRecompute() throws Exception { @Test public void test200AddUnresolvable() throws Exception { final String TEST_NAME = "test200AddUnresolvable"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -693,7 +681,6 @@ public void test200AddUnresolvable() throws Exception { @Test public void test210AddCyclic() throws Exception { final String TEST_NAME = "test210AddCyclic"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -724,7 +711,6 @@ public void test210AddCyclic() throws Exception { @Test public void test220AddChained() throws Exception { final String TEST_NAME = "test220AddChained"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -784,7 +770,6 @@ public void test220AddChained() throws Exception { @Test public void test230AddAmbiguous() throws Exception { final String TEST_NAME = "test230AddAmbiguous"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -816,7 +801,6 @@ public void test230AddAmbiguous() throws Exception { @Test public void test300ModifyInducement() throws Exception { final String TEST_NAME = "test300ModifyInducement"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -851,7 +835,6 @@ public void test300ModifyInducement() throws Exception { @Test public void test310ModifyInducementPass() throws Exception { final String TEST_NAME = "test310ModifyInducementPass"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -878,7 +861,6 @@ public void test310ModifyInducementPass() throws Exception { @Test public void test320ModifyInducementPass2() throws Exception { final String TEST_NAME = "test320ModifyInducementPass2"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -905,7 +887,6 @@ public void test320ModifyInducementPass2() throws Exception { @Test public void test330AddInducement() throws Exception { final String TEST_NAME = "test330AddInducement"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -940,7 +921,6 @@ public void test330AddInducement() throws Exception { @Test public void test340AddInducementViaExpression() throws Exception { final String TEST_NAME = "test340AddInducementViaExpression"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjector.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjector.java index 67f5b1c7fa3..052eae93ce2 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjector.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjector.java @@ -41,6 +41,7 @@ import com.evolveum.midpoint.schema.util.ResourceTypeUtil; import com.evolveum.midpoint.schema.util.SchemaTestConstants; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.util.TestUtil; @@ -92,7 +93,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); assertNoJackShadow(); } @@ -100,7 +100,6 @@ public void test000Sanity() throws Exception { @Test public void test010BasicContextOperations() throws Exception { final String TEST_NAME = "test010BasicContextOperations"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -186,7 +185,6 @@ public void test010BasicContextOperations() throws Exception { @Test public void test100AddAccountToJackDirect() throws Exception { final String TEST_NAME = "test100AddAccountToJackDirect"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -254,7 +252,6 @@ public void test100AddAccountToJackDirect() throws Exception { @Test public void test110AssignAccountToJack() throws Exception { final String TEST_NAME = "test110AssignAccountToJack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -283,7 +280,6 @@ public void test110AssignAccountToJack() throws Exception { @Test public void test111AssignAccountToJackBroken() throws Exception { final String TEST_NAME = "test111AssignAccountToJackBroken"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -347,7 +343,6 @@ private void assertAssignAccountToJack(LensContext context) { @Test public void test250ModifyUserBarbossaLocality() throws Exception { final String TEST_NAME = "test250ModifyUserBarbossaLocality"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -398,7 +393,6 @@ public void test250ModifyUserBarbossaLocality() throws Exception { @Test public void test251ModifyUserBarbossaFullname() throws Exception { final String TEST_NAME = "test251ModifyUserBarbossaFullname"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -450,7 +444,6 @@ public void test251ModifyUserBarbossaFullname() throws Exception { @Test public void test254ModifyUserBarbossaDisable() throws Exception { final String TEST_NAME = "test254ModifyUserBarbossaDisable"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -513,7 +506,6 @@ public void test254ModifyUserBarbossaDisable() throws Exception { @Test public void test255ModifyUserBarbossaAssignment() throws Exception { final String TEST_NAME = "test255ModifyUserBarbossaAssignment"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -567,7 +559,6 @@ public void test255ModifyUserBarbossaAssignment() throws Exception { @Test public void test260ModifyAccountBarbossaDrinkReplace() throws Exception { final String TEST_NAME = "test260ModifyAccountBarbossaDrinkReplace"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -604,7 +595,6 @@ public void test260ModifyAccountBarbossaDrinkReplace() throws Exception { @Test public void test261ModifyAccountBarbossaQuoteReplace() throws Exception { final String TEST_NAME = "test261ModifyAccountBarbossaQuoteReplace"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -666,7 +656,6 @@ public void test261ModifyAccountBarbossaQuoteReplace() throws Exception { @Test public void test269DeleteBarbossaDummyAccount() throws Exception { final String TEST_NAME = "test269DeleteBarbossaDummyAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -703,7 +692,6 @@ public void test269DeleteBarbossaDummyAccount() throws Exception { @Test public void test270AddUserBarbossaAssignmentBrethren() throws Exception { final String TEST_NAME = "test270AddUserBarbossaAssignmentBrethren"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -750,7 +738,6 @@ public void test270AddUserBarbossaAssignmentBrethren() throws Exception { @Test public void test275DeleteUserBarbossaAssignmentBrethren() throws Exception { final String TEST_NAME = "test275DeleteUserBarbossaAssignmentBrethren"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -799,7 +786,6 @@ public void test275DeleteUserBarbossaAssignmentBrethren() throws Exception { @Test public void test280AddUserBarbossaAssignmentMutinier() throws Exception { final String TEST_NAME = "test280AddUserBarbossaAssignmentMutinier"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -847,7 +833,6 @@ public void test280AddUserBarbossaAssignmentMutinier() throws Exception { @Test public void test301AssignConflictingAccountToJack() throws Exception { final String TEST_NAME = "test301AssignConflictingAccountToJack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -896,7 +881,6 @@ public void test301AssignConflictingAccountToJack() throws Exception { @Test public void test400ImportHermanDummy() throws Exception { final String TEST_NAME = "test400ImportHermanDummy"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -954,7 +938,6 @@ public void test400ImportHermanDummy() throws Exception { @Test public void test401ImportHermanDummy() throws Exception { final String TEST_NAME = "test401ImportHermanDummy"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1001,7 +984,6 @@ public void test401ImportHermanDummy() throws Exception { @Test public void test450GuybrushInboundFromDelta() throws Exception { final String TEST_NAME = "test450GuybrushInboundFromDelta"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1036,7 +1018,6 @@ public void test450GuybrushInboundFromDelta() throws Exception { @Test public void test451GuybrushInboundFromAbsolute() throws Exception { final String TEST_NAME = "test451GuybrushInboundFromAbsolute"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1078,7 +1059,6 @@ public void test451GuybrushInboundFromAbsolute() throws Exception { @Test public void test500ReconcileGuybrushDummy() throws Exception { final String TEST_NAME = "test500ReconcileGuybrushDummy"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1143,7 +1123,6 @@ public void test500ReconcileGuybrushDummy() throws Exception { @Test public void test600AddLargo() throws Exception { final String TEST_NAME = "test600AddLargo"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestReconScript.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestReconScript.java index 6d44ebba8ad..ff351529252 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestReconScript.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestReconScript.java @@ -26,6 +26,7 @@ import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.asserter.ShadowAsserter; import com.evolveum.midpoint.util.QNameUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType; @@ -49,7 +50,6 @@ public class TestReconScript extends AbstractInternalModelIntegrationTest { @Test public void text001testReconcileScriptsWhenProvisioning() throws Exception{ final String TEST_NAME = "text001testReconcileScriptsWhenProvisioning"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult parentResult = new OperationResult(TEST_NAME); @@ -92,7 +92,6 @@ public void text001testReconcileScriptsWhenProvisioning() throws Exception{ @Test public void test002testReconcileScriptsWhenReconciling() throws Exception{ final String TEST_NAME = "test002testReconcileScriptsWhenReconciling"; - displayTestTitle(TEST_NAME); getDummyResource().getScriptHistory().clear(); @@ -124,7 +123,6 @@ public void test002testReconcileScriptsWhenReconciling() throws Exception{ @Test public void test003testReconcileScriptsAddUserAction() throws Exception{ final String TEST_NAME = "test003testReconcileScriptsAddUserAction"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult parentResult = new OperationResult(TEST_NAME); @@ -170,8 +168,6 @@ public void test003testReconcileScriptsAddUserAction() throws Exception{ @Test public void test005TestDryRunDelete() throws Exception{ final String TEST_NAME = "test005TestDryRunDelete"; - displayTestTitle(TEST_NAME); - PrismObject task = getTask(TASK_RECON_DUMMY_OID); OperationResult parentResult = new OperationResult(TEST_NAME); @@ -203,7 +199,6 @@ public void test005TestDryRunDelete() throws Exception{ @Test public void test006TestReconDelete() throws Exception{ final String TEST_NAME = "test006TestReconDelete"; - displayTestTitle(TEST_NAME); PrismObject task = getTask(TASK_RECON_DUMMY_OID); OperationResult parentResult = new OperationResult(TEST_NAME); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/sync/TestCorrelationConfirmationEvaluator.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/sync/TestCorrelationConfirmationEvaluator.java index 51b56f3d926..299a06df3ae 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/sync/TestCorrelationConfirmationEvaluator.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/sync/TestCorrelationConfirmationEvaluator.java @@ -62,7 +62,6 @@ public class TestCorrelationConfirmationEvaluator extends AbstractInternalModelI @Test public void test001CorrelationOrFilter() throws Exception{ String TEST_NAME = "test001CorrelationOrFilter"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -96,7 +95,6 @@ public void test001CorrelationOrFilter() throws Exception{ @Test public void test002CorrelationMoreThanOne() throws Exception{ String TEST_NAME = "test002CorrelationMoreThanOne"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -129,7 +127,6 @@ public void test002CorrelationMoreThanOne() throws Exception{ @Test public void test003CorrelationWithCondition() throws Exception{ String TEST_NAME = "test003CorrelationWithCondition"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -164,7 +161,6 @@ public void test003CorrelationWithCondition() throws Exception{ @Test public void test004CorrelationMatchCaseInsensitive() throws Exception{ String TEST_NAME = "test004CorrelationMatchCaseInsensitive"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -192,7 +188,6 @@ public void test004CorrelationMatchCaseInsensitive() throws Exception{ @Test public void test005CorrelationMatchCaseInsensitive() throws Exception{ String TEST_NAME = "test005CorrelationMatchCaseInsensitive"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -243,7 +238,6 @@ private SynchronizationContext createSynchronizationContext(File accou @Test public void test006CorrelationFindCaseInsensitive() throws Exception{ String TEST_NAME = "test006CorrelationFindCaseInsensitive"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/sync/TestSynchronizationService.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/sync/TestSynchronizationService.java index b8df391eb64..be9c54ec707 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/sync/TestSynchronizationService.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/sync/TestSynchronizationService.java @@ -89,7 +89,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test010AddedAccountJack() throws Exception { final String TEST_NAME = "test010AddedAccountJack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -147,7 +146,6 @@ public void test010AddedAccountJack() throws Exception { @Test public void test020ModifyLootAbsolute() throws Exception { final String TEST_NAME = "test020ModifyLootAbsolute"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -205,7 +203,6 @@ public void test020ModifyLootAbsolute() throws Exception { @Test public void test021ModifyLootAbsoluteEmpty() throws Exception { final String TEST_NAME = "test021ModifyLootAbsoluteEmpty"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -267,7 +264,6 @@ public void test021ModifyLootAbsoluteEmpty() throws Exception { @Test public void test030Reconcile() throws Exception { final String TEST_NAME = "test030Reconcile"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -314,7 +310,6 @@ public void test030Reconcile() throws Exception { @Test public void test039DeletedAccountJack() throws Exception { final String TEST_NAME = "test039DeletedAccountJack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -417,7 +412,6 @@ public void test039DeletedAccountJack() throws Exception { @Test public void test050AddedAccountCalypso() throws Exception { final String TEST_NAME = "test050AddedAccountCalypso"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -468,7 +462,6 @@ public void test050AddedAccountCalypso() throws Exception { @Test public void test051CalypsoRecon() throws Exception { final String TEST_NAME = "test051CalypsoRecon"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -514,7 +507,6 @@ public void test051CalypsoRecon() throws Exception { @Test public void test100AddedAccountJack() throws Exception { final String TEST_NAME = "test100AddedAccountJack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -586,7 +578,6 @@ public void test100AddedAccountJack() throws Exception { @Test public void test199DeletedAccountJackTotal() throws Exception { final String TEST_NAME = "test199DeletedAccountJackTotal"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -644,7 +635,6 @@ public void test199DeletedAccountJackTotal() throws Exception { @Test public void test200AddedAccountJackSchemaViolation() throws Exception { final String TEST_NAME = "test200AddedAccountJackSchemaViolation"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -718,7 +708,6 @@ public void test200AddedAccountJackSchemaViolation() throws Exception { @Test public void test202UpdatedAccountJackSchemaViolation() throws Exception { final String TEST_NAME = "test202UpdatedAccountJackSchemaViolation"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -781,7 +770,6 @@ public void test202UpdatedAccountJackSchemaViolation() throws Exception { @Test public void test210AssignJackDummy() throws Exception { final String TEST_NAME = "test210AssignJackDummy"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -830,7 +818,6 @@ public void test210AssignJackDummy() throws Exception { @Test public void test212AssignJackDummyLimited() throws Exception { final String TEST_NAME = "test212AssignJackDummyLimited"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -889,7 +876,6 @@ public void test212AssignJackDummyLimited() throws Exception { @Test public void test214UpdatedAccountJackLimited() throws Exception { final String TEST_NAME = "test214UpdatedAccountJackLimited"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -975,7 +961,6 @@ public void test214UpdatedAccountJackLimited() throws Exception { @Test public void test300AddedGroupPirates() throws Exception { final String TEST_NAME = "test300AddedGroupPirates"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestActivation.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestActivation.java index 08947a29806..c370531f50e 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestActivation.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestActivation.java @@ -28,6 +28,7 @@ import com.evolveum.midpoint.prism.delta.*; import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.schema.util.ObjectTypeUtil; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.TestResource; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; @@ -97,7 +98,7 @@ public class TestActivation extends AbstractInitializedModelIntegrationTest { private static final TestResource RESOURCE_DUMMY_PRECREATE = new TestResource(TEST_DIR, "resource-dummy-precreate.xml", "f18711a2-5db5-4562-b50d-3ef4c74f2e1d"); private static final String RESOURCE_DUMMY_PRECREATE_NAME = "precreate"; - + protected static final String ACCOUNT_MANCOMB_DUMMY_USERNAME = "mancomb"; private static final Date ACCOUNT_MANCOMB_VALID_FROM_DATE = MiscUtil.asDate(2011, 2, 3, 4, 5, 6); private static final Date ACCOUNT_MANCOMB_VALID_TO_DATE = MiscUtil.asDate(2066, 5, 4, 3, 2, 1); @@ -145,7 +146,7 @@ public void initSystem(Task initTask, OperationResult initResult) resourceDummyCoral = importAndGetObjectFromFile(ResourceType.class, RESOURCE_DUMMY_CORAL_FILE, RESOURCE_DUMMY_CORAL_OID, initTask, initResult); resourceDummyCoralType = resourceDummyCoral.asObjectable(); dummyResourceCtlCoral.setResource(resourceDummyCoral); - + dummyResourceCtlPrecreate = DummyResourceContoller.create(RESOURCE_DUMMY_PRECREATE_NAME, resourceDummyPrecreate); dummyResourcePrecreate = dummyResourceCtlPrecreate.getDummyResource(); resourceDummyPrecreate = importAndGetObjectFromFile(ResourceType.class, RESOURCE_DUMMY_PRECREATE.file, RESOURCE_DUMMY_PRECREATE.oid, initTask, initResult); @@ -156,7 +157,6 @@ public void initSystem(Task initTask, OperationResult initResult) @Test public void test050CheckJackEnabled() throws Exception { final String TEST_NAME = "test050CheckJackEnabled"; - displayTestTitle(TEST_NAME); // GIVEN, WHEN // this happens during test initialization when user-jack.xml is added @@ -173,7 +173,6 @@ public void test050CheckJackEnabled() throws Exception { @Test public void test051ModifyUserJackDisable() throws Exception { final String TEST_NAME = "test051ModifyUserJackDisable"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -205,7 +204,6 @@ public void test051ModifyUserJackDisable() throws Exception { @Test public void test052ModifyUserJackNull() throws Exception { final String TEST_NAME = "test052ModifyUserJackNull"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -236,7 +234,6 @@ public void test052ModifyUserJackNull() throws Exception { @Test public void test055ModifyUserJackEnable() throws Exception { final String TEST_NAME = "test055ModifyUserJackEnable"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -268,7 +265,6 @@ public void test055ModifyUserJackEnable() throws Exception { @Test public void test056RecomputeUserJackEffectiveEnable() throws Exception { final String TEST_NAME = "test056RecomputeUserJackEffectiveEnable"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -321,7 +317,6 @@ public void test056RecomputeUserJackEffectiveEnable() throws Exception { @Test public void test060ModifyUserJackLifecycleActive() throws Exception { final String TEST_NAME = "test060ModifyUserJackLifecycleActive"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -353,7 +348,6 @@ public void test060ModifyUserJackLifecycleActive() throws Exception { @Test public void test061ModifyUserJackLifecycleDraft() throws Exception { final String TEST_NAME = "test061ModifyUserJackLifecycleDraft"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -385,7 +379,6 @@ public void test061ModifyUserJackLifecycleDraft() throws Exception { @Test public void test065ModifyUserJackLifecycleDeprecated() throws Exception { final String TEST_NAME = "test065ModifyUserJackLifecycleDeprecated"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -417,7 +410,6 @@ public void test065ModifyUserJackLifecycleDeprecated() throws Exception { @Test public void test068ModifyUserJackLifecycleArchived() throws Exception { final String TEST_NAME = "test068ModifyUserJackLifecycleArchived"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -448,7 +440,6 @@ public void test068ModifyUserJackLifecycleArchived() throws Exception { @Test public void test069ModifyUserJackLifecycleNull() throws Exception { final String TEST_NAME = "test069ModifyUserJackLifecycleNull"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -479,7 +470,6 @@ public void test069ModifyUserJackLifecycleNull() throws Exception { @Test public void test100ModifyUserJackAssignAccount() throws Exception { final String TEST_NAME = "test100ModifyUserJackAssignAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -554,7 +544,6 @@ public void test100ModifyUserJackAssignAccount() throws Exception { @Test public void test101ModifyUserJackDisable() throws Exception { final String TEST_NAME = "test101ModifyUserJackDisable"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -653,7 +642,6 @@ public void test111ModifyAccountJackDisable() throws Exception { @Test public void test112UserJackRecompute() throws Exception { final String TEST_NAME = "test112UserJackRecompute"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -693,7 +681,6 @@ public void test112UserJackRecompute() throws Exception { @Test public void test114ModifyUserJackEnable() throws Exception { final String TEST_NAME = "test114ModifyUserJackEnable"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -731,7 +718,6 @@ public void test114ModifyUserJackEnable() throws Exception { @Test public void test115ModifyUserJackAdministrativeStatusNull() throws Exception { final String TEST_NAME = "test115ModifyUserJackAdministrativeStatusNull"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -772,7 +758,6 @@ public void test115ModifyUserJackAdministrativeStatusNull() throws Exception { @Test public void test118ModifyJackActivationUserAndAccount() throws Exception { final String TEST_NAME = "test118ModifyJackActivationUserAndAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -819,7 +804,6 @@ public void test118ModifyJackActivationUserAndAccount() throws Exception { @Test public void test120ModifyUserJackAssignAccountDummyRed() throws Exception { final String TEST_NAME = "test120ModifyUserJackAssignAccountDummyRed"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -871,7 +855,6 @@ public void test120ModifyUserJackAssignAccountDummyRed() throws Exception { @Test public void test121ModifyJackUserAndAccountRed() throws Exception { final String TEST_NAME = "test121ModifyJackUserAndAccountRed"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -952,7 +935,6 @@ public void test130ModifyAccountDefaultAndRed() throws Exception { @Test public void test138ModifyJackEnabled() throws Exception { final String TEST_NAME = "test138ModifyJackEnabled"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -983,7 +965,6 @@ public void test138ModifyJackEnabled() throws Exception { @Test public void test139ModifyUserJackUnAssignAccountDummyRed() throws Exception { final String TEST_NAME = "test139ModifyUserJackUnAssignAccountDummyRed"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -1021,7 +1002,6 @@ public void test139ModifyUserJackUnAssignAccountDummyRed() throws Exception { @Test public void test140ModifyUserJackAssignAccountDummyRed() throws Exception { final String TEST_NAME = "test140ModifyUserJackAssignAccountDummyRed"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1071,7 +1051,6 @@ public void test140ModifyUserJackAssignAccountDummyRed() throws Exception { @Test public void test147ModifyUserJackUnassignAccountDummyRedRaw() throws Exception { final String TEST_NAME = "test147ModifyUserJackUnassignAccountDummyRedRaw"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1119,7 +1098,6 @@ public void test147ModifyUserJackUnassignAccountDummyRedRaw() throws Exception { @Test public void test149RecomputeJack() throws Exception { final String TEST_NAME = "test149RecomputeJack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1168,7 +1146,6 @@ public void test149RecomputeJack() throws Exception { @Test public void test150ModifyUserJackAssignYellowAccount() throws Exception { final String TEST_NAME = "test150ModifyUserJackAssignYellowAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1219,7 +1196,6 @@ public void test150ModifyUserJackAssignYellowAccount() throws Exception { @Test public void test151ReconcileJack() throws Exception { final String TEST_NAME = "test151ReconcileJack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1260,7 +1236,6 @@ public void test151ReconcileJack() throws Exception { @Test public void test152ModifyAccountsJackDisable() throws Exception { final String TEST_NAME = "test152ModifyAccountsJackDisable"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1305,7 +1280,6 @@ public void test152ModifyAccountsJackDisable() throws Exception { @Test public void test153ModifyAccountsJackEnable() throws Exception { final String TEST_NAME = "test153ModifyAccountsJackEnable"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -1378,7 +1352,6 @@ private void checkAdminStatusFor15x(PrismObject user, boolean userStat @Test public void test160ModifyUserJackAssignAccountKhaki() throws Exception { final String TEST_NAME = "test160ModifyUserJackAssignAccountKhaki"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1457,7 +1430,6 @@ public void test160ModifyUserJackAssignAccountKhaki() throws Exception { @Test public void test170GetAccountUnlocked() throws Exception { final String TEST_NAME = "test170GetAccountUnlocked"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -1481,7 +1453,6 @@ public void test170GetAccountUnlocked() throws Exception { @Test public void test172GetAccountLocked() throws Exception { final String TEST_NAME = "test172GetAccountLocked"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -1509,7 +1480,6 @@ public void test172GetAccountLocked() throws Exception { @Test public void test174ModifyAccountUnlock() throws Exception { final String TEST_NAME = "test174ModifyAccountUnlock"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -1544,7 +1514,6 @@ public void test174ModifyAccountUnlock() throws Exception { @Test public void test176ModifyUserUnlock() throws Exception { final String TEST_NAME = "test176ModifyUserUnlock"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -1580,7 +1549,6 @@ public void test176ModifyUserUnlock() throws Exception { @Test public void test199DeleteUserJack() throws Exception { final String TEST_NAME = "test199DeleteUserJack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -1614,7 +1582,6 @@ public void test199DeleteUserJack() throws Exception { @Test public void test200AddUserLargo() throws Exception { final String TEST_NAME = "test200AddUserLargo"; - displayTestTitle(TEST_NAME); // GIVEN long startMillis = System.currentTimeMillis(); @@ -1640,7 +1607,6 @@ public void test200AddUserLargo() throws Exception { @Test public void test205ModifyUserLargoAssignAccount() throws Exception { final String TEST_NAME = "test205ModifyUserLargoAssignAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -1679,7 +1645,6 @@ public void test205ModifyUserLargoAssignAccount() throws Exception { @Test public void test210ModifyLargoValidTo10MinsAgo() throws Exception { final String TEST_NAME = "test210ModifyLargoValidTo10MinsAgo"; - displayTestTitle(TEST_NAME); // GIVEN long startMillis = System.currentTimeMillis(); @@ -1717,7 +1682,6 @@ public void test210ModifyLargoValidTo10MinsAgo() throws Exception { @Test public void test211ModifyLargoValidToManana() throws Exception { final String TEST_NAME = "test211ModifyLargoValidToManana"; - displayTestTitle(TEST_NAME); // GIVEN long startMillis = System.currentTimeMillis(); @@ -1759,7 +1723,6 @@ public void test211ModifyLargoValidToManana() throws Exception { @Test public void test212SeeLargoTomorrow() throws Exception { final String TEST_NAME = "test212SeeLargoTomorrow"; - displayTestTitle(TEST_NAME); // GIVEN long startMillis = System.currentTimeMillis(); @@ -1802,7 +1765,6 @@ public void test212SeeLargoTomorrow() throws Exception { @Test public void test213HastaLaMananaLargo() throws Exception { final String TEST_NAME = "test213HastaLaMananaLargo"; - displayTestTitle(TEST_NAME); // GIVEN long startMillis = System.currentTimeMillis(); @@ -1842,7 +1804,6 @@ public void test213HastaLaMananaLargo() throws Exception { @Test public void test215ModifyLargoRemoveValidTo() throws Exception { final String TEST_NAME = "test215ModifyLargoRemoveValidTo"; - displayTestTitle(TEST_NAME); // GIVEN long startMillis = clock.currentTimeMillis(); @@ -1879,7 +1840,6 @@ public void test215ModifyLargoRemoveValidTo() throws Exception { @Test public void test217ModifyLargoRemoveValidFrom() throws Exception { final String TEST_NAME = "test217ModifyLargoRemoveValidFrom"; - displayTestTitle(TEST_NAME); // GIVEN long startMillis = clock.currentTimeMillis(); @@ -1921,7 +1881,6 @@ public void test217ModifyLargoRemoveValidFrom() throws Exception { @Test public void test230JackUnassignRepoRecompute() throws Exception { final String TEST_NAME = "test230JackUnassignRepoRecompute"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -1953,7 +1912,6 @@ public void test230JackUnassignRepoRecompute() throws Exception { @Test public void test231JackRecomputeReconcile() throws Exception { final String TEST_NAME = "test231JackRecomputeReconcile"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -1979,7 +1937,6 @@ public void test231JackRecomputeReconcile() throws Exception { @Test public void test240AddUserRappDraft() throws Exception { final String TEST_NAME = "test240AddUserRappDraft"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2037,7 +1994,6 @@ public void test240AddUserRappDraft() throws Exception { @Test public void test241RecomputeRappDraft() throws Exception { final String TEST_NAME = "test240AddUserRappDraft"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2080,7 +2036,6 @@ public void test241RecomputeRappDraft() throws Exception { @Test public void test242RappAssignCaptain() throws Exception { final String TEST_NAME = "test242RappAssignCaptain"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2118,7 +2073,6 @@ public void test242RappAssignCaptain() throws Exception { @Test public void test245ActivateRapp() throws Exception { final String TEST_NAME = "test245ActivateRapp"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2161,7 +2115,6 @@ public void test245ActivateRapp() throws Exception { @Test public void test248DeactivateRapp() throws Exception { final String TEST_NAME = "test248DeactivateRapp"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2198,7 +2151,6 @@ public void test248DeactivateRapp() throws Exception { @Test public void test249DeleteUserRapp() throws Exception { final String TEST_NAME = "test249DeleteUserRapp"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2223,7 +2175,6 @@ public void test249DeleteUserRapp() throws Exception { @Test public void test300AddDummyGreenAccountMancomb() throws Exception { final String TEST_NAME = "test300AddDummyGreenAccountMancomb"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2264,7 +2215,6 @@ public void test300AddDummyGreenAccountMancomb() throws Exception { @Test public void test310ImportAccountsFromDummyGreen() throws Exception { final String TEST_NAME = "test310ImportAccountsFromDummyGreen"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); @@ -2302,7 +2252,6 @@ public void test310ImportAccountsFromDummyGreen() throws Exception { @Test public void test350AssignMancombBlueAccount() throws Exception { final String TEST_NAME = "test350AssignMancombBlueAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -2329,7 +2278,6 @@ public void test350AssignMancombBlueAccount() throws Exception { @Test public void test352AssignMancombBlackAccount() throws Exception { final String TEST_NAME = "test352AssignMancombBlackAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -2362,7 +2310,6 @@ public void test352AssignMancombBlackAccount() throws Exception { @Test public void test355MancombModifyAdministrativeStatusNull() throws Exception { final String TEST_NAME = "test355MancombModifyAdministrativeStatusNull"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -2397,7 +2344,6 @@ public void test355MancombModifyAdministrativeStatusNull() throws Exception { @Test public void test400AddHerman() throws Exception { final String TEST_NAME = "test400AddHerman"; - displayTestTitle(TEST_NAME); // WHEN addObject(USER_HERMAN_FILE); @@ -2414,7 +2360,6 @@ public void test400AddHerman() throws Exception { @Test public void test410AssignHermanKhakiAccount() throws Exception { final String TEST_NAME = "test410AssignHermanKhakiAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -2519,7 +2464,6 @@ public void test525SerivceSeaMonkeyRecompute() throws Exception { } private void test5X0CheckInitial(final String TEST_NAME, Class type, String oid) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN, WHEN // this happens during test initialization when the role is added @@ -2537,7 +2481,6 @@ private void test5X0CheckInitial(final String TEST_NAME, C * MID-2877 */ private void test5X1Recompute(final String TEST_NAME, Class type, String oid) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -2564,7 +2507,6 @@ private void test5X1Recompute(final String TEST_NAME, Clas * MID-2877 */ private void test5X2ModifyDisable(final String TEST_NAME, Class type, String oid) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -2596,7 +2538,6 @@ private void test5X2ModifyDisable(final String TEST_NAME, * MID-2877 */ private void test5X4ModifyEnable(final String TEST_NAME, Class type, String oid) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -2628,7 +2569,6 @@ private void test5X4ModifyEnable(final String TEST_NAME, C * Make sure that recompute does not destroy anything. */ public void test5X5Recompute(final String TEST_NAME, Class type, String oid) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -2659,7 +2599,6 @@ public void test5X5Recompute(final String TEST_NAME, Class @Test public void test600AddUser1() throws Exception { final String TEST_NAME = "test600AddUser1"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2705,7 +2644,6 @@ private void checkSuspendedAttribute(DummyAccount dummyAccount, Boolean expected @Test public void test610EnableUser1() throws Exception { final String TEST_NAME = "test610EnableUser1"; - displayTestTitle(TEST_NAME); // GIVEN PrismObject user1 = findUserByUsername("user1"); @@ -2742,7 +2680,6 @@ public void test610EnableUser1() throws Exception { @Test public void test700ModifyJackRemoveAdministrativeStatus() throws Exception { final String TEST_NAME = "test700ModifyJackRemoveAdministrativeStatus"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -2794,7 +2731,6 @@ public void test700ModifyJackRemoveAdministrativeStatus() throws Exception { @Test public void test702ModifyJackFuneralTimestampBeforeNow() throws Exception { final String TEST_NAME = "test702ModifyJackFuneralTimestampBeforeNow"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -2840,7 +2776,6 @@ public void test702ModifyJackFuneralTimestampBeforeNow() throws Exception { @Test public void test704ModifyJackFuneralTimestampAfterNow() throws Exception { final String TEST_NAME = "test704ModifyJackFuneralTimestampAfterNow"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -2882,7 +2817,6 @@ public void test704ModifyJackFuneralTimestampAfterNow() throws Exception { @Test public void test750AddAndDeleteUserWithPrecreate() throws Exception { final String TEST_NAME = "test750AddAndDeleteUserWithPrecreate"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestAudit.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestAudit.java index f2754aa3ed4..8b7d7196d72 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestAudit.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestAudit.java @@ -98,7 +98,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); assertTrue(modelAuditService.supportsRetrieval()); @@ -118,7 +117,6 @@ public void test000Sanity() throws Exception { @Test public void test010SanityJack() throws Exception { final String TEST_NAME = "test010SanityJack"; - displayTestTitle(TEST_NAME); // WHEN List auditRecords = getObjectAuditRecords(USER_JACK_OID); @@ -132,7 +130,6 @@ public void test010SanityJack() throws Exception { @Test public void test100ModifyUserJackKid() throws Exception { final String TEST_NAME = "test100ModifyUserJackKid"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -161,7 +158,6 @@ public void test100ModifyUserJackKid() throws Exception { @Test public void test105CreateUserHerman() throws Exception { final String TEST_NAME = "test105CreateUserHerman"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -193,7 +189,6 @@ public void test105CreateUserHerman() throws Exception { @Test public void test110ModifyUserJackSailor() throws Exception { final String TEST_NAME = "test110ModifyUserJackSailor"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -226,7 +221,6 @@ public void test110ModifyUserJackSailor() throws Exception { @Test public void test115ModifyUserHermanMarooned() throws Exception { final String TEST_NAME = "test115ModifyUserHermanMarooned"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -257,7 +251,6 @@ public void test115ModifyUserHermanMarooned() throws Exception { @Test public void test120ModifyUserJackCaptain() throws Exception { final String TEST_NAME = "test120ModifyUserJackCaptain"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -288,7 +281,6 @@ public void test120ModifyUserJackCaptain() throws Exception { @Test public void test125ModifyUserHermanHermit() throws Exception { final String TEST_NAME = "test125ModifyUserHermanHermit"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -325,7 +317,6 @@ public void test125ModifyUserHermanHermit() throws Exception { @Test public void test135ModifyUserHermanCivilisedHermit() throws Exception { final String TEST_NAME = "test135ModifyUserHermanCivilisedHermit"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -357,7 +348,6 @@ public void test135ModifyUserHermanCivilisedHermit() throws Exception { @Test public void test200ReconstructJackSailor() throws Exception { final String TEST_NAME = "test200ReconstructJackSailor"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -388,7 +378,6 @@ public void test200ReconstructJackSailor() throws Exception { @Test public void test210ReconstructJackKid() throws Exception { final String TEST_NAME = "test210ReconstructJackKid"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -421,7 +410,6 @@ public void test210ReconstructJackKid() throws Exception { @Test public void test250ReconstructHermanCreated() throws Exception { final String TEST_NAME = "test250ReconstructHermanCreated"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -461,7 +449,6 @@ public void test250ReconstructHermanCreated() throws Exception { @Test public void test252ReconstructHermanMarooned() throws Exception { final String TEST_NAME = "test252ReconstructHermanMarooned"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -494,7 +481,6 @@ public void test252ReconstructHermanMarooned() throws Exception { @Test public void test254ReconstructHermanHermit() throws Exception { final String TEST_NAME = "test254ReconstructHermanHermit"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -525,7 +511,6 @@ public void test254ReconstructHermanHermit() throws Exception { @Test public void test300QueryUnknown() throws Exception { final String TEST_NAME = "test300QueryUnknown"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestCaseIgnore.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestCaseIgnore.java index 5c092a2171a..e2fd2e47c80 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestCaseIgnore.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestCaseIgnore.java @@ -25,6 +25,7 @@ import com.evolveum.midpoint.schema.util.ObjectQueryUtil; import com.evolveum.midpoint.schema.util.ResourceTypeUtil; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DOMUtil; @@ -101,7 +102,6 @@ public void initSystem(Task initTask, OperationResult initResult) @Test public void test000Sanity() throws Exception { final String TEST_NAME="test000Sanity"; - displayTestTitle(TEST_NAME); assertShadows(5); } @@ -109,7 +109,6 @@ public void test000Sanity() throws Exception { @Test public void test131ModifyUserJackAssignAccount() throws Exception { final String TEST_NAME="test131ModifyUserJackAssignAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestCaseIgnore.class.getName() + "." + TEST_NAME); @@ -163,7 +162,6 @@ public void test131ModifyUserJackAssignAccount() throws Exception { @Test public void test133SeachAccountShadows() throws Exception { final String TEST_NAME="test133SeachAccountShadows"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestCaseIgnore.class.getName() + "." + TEST_NAME); @@ -217,7 +215,6 @@ public void test133SeachAccountShadows() throws Exception { @Test public void test139ModifyUserJackUnassignAccount() throws Exception { final String TEST_NAME = "test139ModifyUserJackUnassignAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestCaseIgnore.class.getName() + "." + TEST_NAME); @@ -257,7 +254,6 @@ public void test139ModifyUserJackUnassignAccount() throws Exception { @Test public void test150JackAssignRoleX() throws Exception { final String TEST_NAME = "test150JackAssignRoleX"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -304,7 +300,6 @@ public void test150JackAssignRoleX() throws Exception { @Test public void test152GetJack() throws Exception { final String TEST_NAME = "test152GetJack"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -346,7 +341,6 @@ public void test152GetJack() throws Exception { @Test public void test159JackUnAssignRoleX() throws Exception { final String TEST_NAME = "test159JackUnAssignRoleX"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -378,7 +372,6 @@ public void test159JackUnAssignRoleX() throws Exception { @Test public void test160JackAssignRoleBasic() throws Exception { final String TEST_NAME = "test160JackAssignRoleBasic"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -427,7 +420,6 @@ public void test160JackAssignRoleBasic() throws Exception { @Test public void test161JackAssignRoleJoker() throws Exception { final String TEST_NAME = "test161JackAssignRoleJoker"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -480,7 +472,6 @@ public void test161JackAssignRoleJoker() throws Exception { @Test public void test165JackUnAssignRoleJoker() throws Exception { final String TEST_NAME = "test165JackUnAssignRoleJoker"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -529,7 +520,6 @@ public void test165JackUnAssignRoleJoker() throws Exception { @Test public void test169JackUnAssignRoleBasic() throws Exception { final String TEST_NAME = "test169JackUnAssignRoleBasic"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -564,7 +554,6 @@ public void test169JackUnAssignRoleBasic() throws Exception { @Test public void test170JackAssignRoleJoker() throws Exception { final String TEST_NAME = "test170JackAssignRoleJoker"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -612,7 +601,6 @@ public void test170JackAssignRoleJoker() throws Exception { @Test public void test179JackUnAssignRoleJoker() throws Exception { final String TEST_NAME = "test179JackUnAssignRoleJoker"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -655,7 +643,6 @@ public void test179JackUnAssignRoleJoker() throws Exception { @Test public void test200GuybrushAssignRoleFools() throws Exception { final String TEST_NAME = "test200GuybrushAssignRoleFools"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConnectorDummyFake.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConnectorDummyFake.java index 47618efce57..2467b678cfc 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConnectorDummyFake.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConnectorDummyFake.java @@ -86,7 +86,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test010ListConnectors() throws Exception { final String TEST_NAME = "test010ListConnectors"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -124,7 +123,6 @@ public void test010ListConnectors() throws Exception { @Test public void test020ImportFakeResource() throws Exception { final String TEST_NAME = "test020ImportFakeResource"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -149,7 +147,6 @@ public void test020ImportFakeResource() throws Exception { @Test public void test021TestFakeResource() throws Exception { final String TEST_NAME = "test021TestFakeResource"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -166,7 +163,6 @@ public void test021TestFakeResource() throws Exception { @Test public void test022ListAccountsFakeResource() throws Exception { final String TEST_NAME = "test022ListAccountsFakeResource"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -186,7 +182,6 @@ public void test022ListAccountsFakeResource() throws Exception { @Test public void test030ImportDummyResource() throws Exception { final String TEST_NAME = "test030ImportDummyResource"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -211,7 +206,6 @@ public void test030ImportDummyResource() throws Exception { @Test public void test031TestDummyResource() throws Exception { final String TEST_NAME = "test031TestDummyResource"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -228,7 +222,6 @@ public void test031TestDummyResource() throws Exception { @Test public void test032ListAccountsDummyResource() throws Exception { final String TEST_NAME = "test032ListAccountsDummyResource"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -250,7 +243,6 @@ public void test032ListAccountsDummyResource() throws Exception { @Test public void test100UpgradeModelAddDelete() throws Exception { final String TEST_NAME = "test100UpgradeModelAddDelete"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -285,7 +277,6 @@ public void test100UpgradeModelAddDelete() throws Exception { @Test public void test150DowngradeModelAddDelete() throws Exception { final String TEST_NAME = "test150DowngradeModelAddDelete"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -315,7 +306,6 @@ public void test150DowngradeModelAddDelete() throws Exception { @Test public void test200UpgradeModelReplace() throws Exception { final String TEST_NAME = "test200UpgradeModelReplace"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -343,7 +333,6 @@ public void test200UpgradeModelReplace() throws Exception { @Test public void test250DowngradeModelReplace() throws Exception { final String TEST_NAME = "test250DowngradeModelReplace"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -370,7 +359,6 @@ public void test250DowngradeModelReplace() throws Exception { @Test public void test300UpgradeRawAddDelete() throws Exception { final String TEST_NAME = "test300UpgradeRawAddDelete"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -403,7 +391,6 @@ public void test300UpgradeRawAddDelete() throws Exception { @Test public void test350DowngradeRawAddDelete() throws Exception { final String TEST_NAME = "test350DowngradeRawAddDelete"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -438,7 +425,6 @@ public void test350DowngradeRawAddDelete() throws Exception { @Test public void test400UpgradeRawReplace() throws Exception { final String TEST_NAME = "test400UpgradeRawReplace"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -471,7 +457,6 @@ public void test400UpgradeRawReplace() throws Exception { @Test public void test450DowngradeRawReplace() throws Exception { final String TEST_NAME = "test450DowngradeRawReplace"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConnectorMultiInstance.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConnectorMultiInstance.java index 1fd43a92ab1..ef6d9523301 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConnectorMultiInstance.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConnectorMultiInstance.java @@ -82,7 +82,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -100,7 +99,6 @@ public void test000Sanity() throws Exception { @Test public void test100JackAssignDummyYellow() throws Exception { final String TEST_NAME = "test100JackAssignDummyYellow"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -132,7 +130,6 @@ public void test100JackAssignDummyYellow() throws Exception { @Test public void test102ReadJackDummyYellowAgain() throws Exception { final String TEST_NAME = "test102ReadJackDummyYellowAgain"; - displayTestTitle(TEST_NAME); // WHEN PrismObject shadowYellow = getShadowModel(accountJackYellowOid); @@ -155,7 +152,6 @@ public void test102ReadJackDummyYellowAgain() throws Exception { @Test public void test110ReadJackDummyYellowBlocking() throws Exception { final String TEST_NAME = "test110ReadJackDummyYellowBlocking"; - displayTestTitle(TEST_NAME); dummyResourceYellow.setBlockOperations(true); final Holder> shadowHolder = new Holder<>(); @@ -200,7 +196,6 @@ public void test110ReadJackDummyYellowBlocking() throws Exception { @Test public void test120ReadJackDummyYellowTwoOperationsOneBlocking() throws Exception { final String TEST_NAME = "test120ReadJackDummyYellowTwoOperationsOneBlocking"; - displayTestTitle(TEST_NAME); dummyResourceYellow.setBlockOperations(true); final Holder> shadowHolder1 = new Holder<>(); @@ -267,7 +262,6 @@ public void test120ReadJackDummyYellowTwoOperationsOneBlocking() throws Exceptio @Test public void test125ReadJackDummyYellowTwoBlocking() throws Exception { final String TEST_NAME = "test125ReadJackDummyYellowTwoBlocking"; - displayTestTitle(TEST_NAME); dummyResourceYellow.setBlockOperations(true); final Holder> shadowHolder1 = new Holder<>(); @@ -325,7 +319,6 @@ public void run() throws Exception { @Test public void test200GuybrushAssignDummyBlack() throws Exception { final String TEST_NAME = "test200GuybrushAssignDummyBlack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConsistencySimple.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConsistencySimple.java index 861d7c7c173..c5c9c924ad7 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConsistencySimple.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConsistencySimple.java @@ -146,7 +146,6 @@ public void test270Recompute_Delete_Delete() throws Exception { private void executeTest(final String TEST_NAME, FocusOperation focusOperation, ShadowOperation shadowOperation, ResourceObjectOperation resourceObjectOperation) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME + ".given"); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestDeputy.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestDeputy.java index 9dec763e4b0..a380f859620 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestDeputy.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestDeputy.java @@ -24,6 +24,7 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType; import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType; @@ -53,7 +54,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); PrismObject userJack = getUser(USER_JACK_OID); display("User Jack", userJack); @@ -75,7 +75,6 @@ public void test000Sanity() throws Exception { @Test public void test100AssignDeputyNoBigDeal() throws Exception { final String TEST_NAME = "test100AssignDeputyNoBigDeal"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -112,7 +111,6 @@ public void test100AssignDeputyNoBigDeal() throws Exception { @Test public void test109UnassignDeputyNoBigDeal() throws Exception { final String TEST_NAME = "test109UnassignDeputyNoBigDeal"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -148,7 +146,6 @@ public void test109UnassignDeputyNoBigDeal() throws Exception { @Test public void test110AssignJackPirate() throws Exception { final String TEST_NAME = "test110AssignJackPirate"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -186,7 +183,6 @@ public void test110AssignJackPirate() throws Exception { @Test public void test112AssignDeputyPirate() throws Exception { final String TEST_NAME = "test112AssignDeputyPirate"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -229,7 +225,6 @@ public void test112AssignDeputyPirate() throws Exception { @Test public void test119UnassignDeputyPirate() throws Exception { final String TEST_NAME = "test119UnassignDeputyPirate"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -267,7 +262,6 @@ public void test119UnassignDeputyPirate() throws Exception { @Test public void test120AssignbarbossaDeputyOfGuybrush() throws Exception { final String TEST_NAME = "test120AssignbarbossaDeputyOfGuybrush"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -310,7 +304,6 @@ public void test120AssignbarbossaDeputyOfGuybrush() throws Exception { @Test public void test122AssignGuybrushPirate() throws Exception { final String TEST_NAME = "test122AssignGuybrushPirate"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -349,7 +342,6 @@ public void test122AssignGuybrushPirate() throws Exception { @Test public void test124RecomputeBarbossa() throws Exception { final String TEST_NAME = "test124RecomputeBarbossa"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -390,7 +382,6 @@ public void test124RecomputeBarbossa() throws Exception { @Test public void test126UnassignGuybrushPirate() throws Exception { final String TEST_NAME = "test126UnassignGuybrushPirate"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -428,7 +419,6 @@ public void test126UnassignGuybrushPirate() throws Exception { @Test public void test128RecomputeBarbossa() throws Exception { final String TEST_NAME = "test128RecomputeBarbossa"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -462,7 +452,6 @@ public void test128RecomputeBarbossa() throws Exception { @Test public void test129UnassignBarbossaDeputyOfGuybrush() throws Exception { final String TEST_NAME = "test129UnassignBarbossaDeputyOfGuybrush"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -498,7 +487,6 @@ public void test129UnassignBarbossaDeputyOfGuybrush() throws Exception { @Test public void test150AssignJackMoreRoles() throws Exception { final String TEST_NAME = "test150AssignJackMoreRoles"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -552,7 +540,6 @@ public void test150AssignJackMoreRoles() throws Exception { @Test public void test152AssignbarbossaDeputyLimitedDeputy() throws Exception { final String TEST_NAME = "test152AssignbarbossaDeputyLimitedDeputy"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -589,7 +576,6 @@ public void test152AssignbarbossaDeputyLimitedDeputy() throws Exception { @Test public void test154UnassignbarbossaDeputyLimitedDeputy() throws Exception { final String TEST_NAME = "test154UnassignbarbossaDeputyLimitedDeputy"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -623,7 +609,6 @@ public void test154UnassignbarbossaDeputyLimitedDeputy() throws Exception { @Test public void test156AssignbarbossaDeputyLimitedDeputyRed() throws Exception { final String TEST_NAME = "test156AssignbarbossaDeputyLimitedDeputyRed"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -661,7 +646,6 @@ public void test156AssignbarbossaDeputyLimitedDeputyRed() throws Exception { @Test public void test159UnassignbarbossaDeputyLimitedDeputyRed() throws Exception { final String TEST_NAME = "test159UnassignbarbossaDeputyLimitedDeputyRed"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -703,7 +687,6 @@ public void test159UnassignbarbossaDeputyLimitedDeputyRed() throws Exception { @Test public void test160AssignbarbossaDeputyLimitedDeputyEmpty() throws Exception { final String TEST_NAME = "test160AssignbarbossaDeputyLimitedDeputyEmpty"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -740,7 +723,6 @@ public void test160AssignbarbossaDeputyLimitedDeputyEmpty() throws Exception { @Test public void test162UnassignbarbossaDeputyLimitedDeputyEmpty() throws Exception { final String TEST_NAME = "test162UnassignbarbossaDeputyLimitedDeputyEmpty"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -780,7 +762,6 @@ public void test162UnassignbarbossaDeputyLimitedDeputyEmpty() throws Exception { @Test public void test170AddRoleDrinker() throws Exception { final String TEST_NAME = "test170AssignJackRoleDrinker"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -805,7 +786,6 @@ public void test170AddRoleDrinker() throws Exception { @Test public void test172AssignJackRoleDrinker() throws Exception { final String TEST_NAME = "test170AssignJackRoleDrinker"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -835,7 +815,6 @@ public void test172AssignJackRoleDrinker() throws Exception { @Test public void test174AssignBarbossaDeputyLimitedDeputyDrinker() throws Exception { final String TEST_NAME = "test174AssignBarbossaDeputyLimitedDeputyDrinker"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -874,7 +853,6 @@ public void test174AssignBarbossaDeputyLimitedDeputyDrinker() throws Exception { @Test public void test176AssignbarGuybrushLimitedDeputyOfBarbossa() throws Exception { final String TEST_NAME = "test176AssignbarGuybrushLimitedDeputyOfBarbossa"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -912,7 +890,6 @@ public void test176AssignbarGuybrushLimitedDeputyOfBarbossa() throws Exception { @Test public void test178UnassignBarbossaDeputyLimitedDeputyDrinker() throws Exception { final String TEST_NAME = "test178UnassignBsarbossaDeputyLimitedDeputyDrinker"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -959,7 +936,6 @@ public void test178UnassignBarbossaDeputyLimitedDeputyDrinker() throws Exception @Test public void test179UnassignbarGuybrushLimitedDeputyOfBarbossa() throws Exception { final String TEST_NAME = "test179UnassignbarGuybrushLimitedDeputyOfBarbossa"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -988,7 +964,6 @@ public void test179UnassignbarGuybrushLimitedDeputyOfBarbossa() throws Exception @Test public void test180AssignBarbossaDeputyOfJack() throws Exception { final String TEST_NAME = "test180AssignBarbossaDeputyOfJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1017,7 +992,6 @@ public void test180AssignBarbossaDeputyOfJack() throws Exception { @Test public void test182AssignGuybrushLimitedDeputyOfBarbossa() throws Exception { final String TEST_NAME = "test182AssignGuybrushLimitedDeputyOfBarbossa"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1053,7 +1027,6 @@ public void test182AssignGuybrushLimitedDeputyOfBarbossa() throws Exception { @Test public void test184UnassignGuybrushLimitedDeputyOfBarbossa() throws Exception { final String TEST_NAME = "test182AssignGuybrushLimitedDeputyOfBarbossa"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1082,7 +1055,6 @@ public void test184UnassignGuybrushLimitedDeputyOfBarbossa() throws Exception { @Test public void test186AssignGuybrushDeputyOfBarbossa() throws Exception { final String TEST_NAME = "test182AssignGuybrushLimitedDeputyOfBarbossa"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1116,7 +1088,6 @@ public void test186AssignGuybrushDeputyOfBarbossa() throws Exception { @Test public void test188UnassignGuybrushDeputyOfBarbossa() throws Exception { final String TEST_NAME = "test188UnassignGuybrushDeputyOfBarbossa"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1140,7 +1111,6 @@ public void test188UnassignGuybrushDeputyOfBarbossa() throws Exception { @Test public void test189UnassignBarbossaDeputyOfJack() throws Exception { final String TEST_NAME = "test189UnassignBarbossaDeputyOfJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1164,7 +1134,6 @@ public void test189UnassignBarbossaDeputyOfJack() throws Exception { @Test public void test190AssignBarbossaDeputyLimitedDeputyEmptyDrinker() throws Exception { final String TEST_NAME = "test190AssignBarbossaDeputyLimitedDeputyEmptyDrinker"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1202,7 +1171,6 @@ public void test190AssignBarbossaDeputyLimitedDeputyEmptyDrinker() throws Except @Test public void test192UnassignbarbossaDeputyLimitedDeputyEmptyDrinker() throws Exception { final String TEST_NAME = "test192UnassignbarbossaDeputyLimitedDeputyEmptyDrinker"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1244,7 +1212,6 @@ public void test192UnassignbarbossaDeputyLimitedDeputyEmptyDrinker() throws Exce @Test public void test800ImportValidityScannerTask() throws Exception { final String TEST_NAME = "test800ImportValidityScannerTask"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TestValidityRecomputeTask.class.getName() + "." + TEST_NAME); @@ -1272,7 +1239,6 @@ public void test800ImportValidityScannerTask() throws Exception { @Test public void test802AssignBarbossaDeputyOfJack() throws Exception { final String TEST_NAME = "test802AssignBarbossaDeputyOfJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1326,7 +1292,6 @@ public void test802AssignBarbossaDeputyOfJack() throws Exception { @Test public void test804BarbosaThreeHoursLater() throws Exception { final String TEST_NAME = "test804BarbosaThreeHoursLater"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestEntitlements.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestEntitlements.java index 64a0e2f1706..8c95ab7c472 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestEntitlements.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestEntitlements.java @@ -26,6 +26,7 @@ import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.schema.util.ObjectQueryUtil; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.util.TestUtil; @@ -146,7 +147,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100AddGroupShadowSwashbucklers() throws Exception { final String TEST_NAME = "test100AddGroupShadowSwashbucklers"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -175,7 +175,6 @@ public void test100AddGroupShadowSwashbucklers() throws Exception { @Test public void test101GetGroupShadowSwashbucklers() throws Exception { final String TEST_NAME = "test101GetGroupShadowSwashbucklers"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -198,7 +197,6 @@ public void test101GetGroupShadowSwashbucklers() throws Exception { @Test public void test110AssociateGuybrushToSwashbucklers() throws Exception { final String TEST_NAME = "test110AssociateGuybrushToSwashbucklers"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -223,7 +221,6 @@ public void test110AssociateGuybrushToSwashbucklers() throws Exception { @Test public void test200AssignRoleSwashbucklerToJack() throws Exception { final String TEST_NAME = "test200AssignRoleSwashbucklerToJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -254,7 +251,6 @@ public void test200AssignRoleSwashbucklerToJack() throws Exception { @Test public void test209UnAssignRoleSwashbucklerFromJack() throws Exception { final String TEST_NAME = "test209UnAssignRoleSwashbucklerFromJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -288,7 +284,6 @@ public void test209UnAssignRoleSwashbucklerFromJack() throws Exception { @Test public void test220AssignRoleLandluberToWally() throws Exception { final String TEST_NAME = "test220AssignRoleLandluberToWally"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -318,7 +313,6 @@ public void test220AssignRoleLandluberToWally() throws Exception { @Test public void test222AssignRoleMapmakerToWally() throws Exception { final String TEST_NAME = "test222AssignRoleMapmakerToWally"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -361,7 +355,6 @@ public void test222AssignRoleMapmakerToWally() throws Exception { @Test public void test224UnassignRoleMapmakerFromWally() throws Exception { final String TEST_NAME = "test224UnassignRoleMapmakerFromWally"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -386,7 +379,6 @@ public void test224UnassignRoleMapmakerFromWally() throws Exception { @Test public void test300AddRoleWimp() throws Exception { final String TEST_NAME = "test300AddRoleWimp"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -419,7 +411,6 @@ public void test300AddRoleWimp() throws Exception { @Test public void test302AddRoleBrute() throws Exception { final String TEST_NAME = "test302AddRoleBrute"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -447,7 +438,6 @@ public void test302AddRoleBrute() throws Exception { @Test public void test304AddRoleThug() throws Exception { final String TEST_NAME = "test304AddRoleThug"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -475,7 +465,6 @@ public void test304AddRoleThug() throws Exception { @Test public void test310AssignRoleWimpToLargo() throws Exception { final String TEST_NAME = "test310AssignRoleWimpToLargo"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -502,7 +491,6 @@ public void test310AssignRoleWimpToLargo() throws Exception { @Test public void test312AssignRoleBruteToLargo() throws Exception { final String TEST_NAME = "test312AssignRoleBruteToLargo"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -527,7 +515,6 @@ public void test312AssignRoleBruteToLargo() throws Exception { @Test public void test313UnAssignRoleBruteFromLargo() throws Exception { final String TEST_NAME = "test313UnAssignRoleBruteFromLargo"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -562,7 +549,6 @@ public void test313UnAssignRoleBruteFromLargo() throws Exception { @Test public void test314AssignRoleThugToLargo() throws Exception { final String TEST_NAME = "test314AssignRoleThugToLargo"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -587,7 +573,6 @@ public void test314AssignRoleThugToLargo() throws Exception { @Test public void test315UnAssignRoleThugFromLargo() throws Exception { final String TEST_NAME = "test315UnAssignRoleThugFromLargo"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -625,7 +610,6 @@ public void test315UnAssignRoleThugFromLargo() throws Exception { @Test public void test317RenameLargo() throws Exception { final String TEST_NAME = "test317RenameLargo"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -657,7 +641,6 @@ public void test317RenameLargo() throws Exception { @Test public void test319UnassignRoleWimpFromLargo() throws Exception { final String TEST_NAME = "test319UnassignRoleWimpFromLargo"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -694,7 +677,6 @@ public void test319UnassignRoleWimpFromLargo() throws Exception { @Test public void test320AssignRoleBruteToRapp() throws Exception { final String TEST_NAME = "test320AssignRoleBruteToRapp"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -721,7 +703,6 @@ public void test320AssignRoleBruteToRapp() throws Exception { @Test public void test322AssignRoleWimpToRapp() throws Exception { final String TEST_NAME = "test322AssignRoleWimpToRapp"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -753,7 +734,6 @@ public void test322AssignRoleWimpToRapp() throws Exception { @Test public void test324AssignRoleThugToRapp() throws Exception { final String TEST_NAME = "test324AssignRoleThugToRapp"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -792,7 +772,6 @@ public void test324AssignRoleThugToRapp() throws Exception { @Test public void test327UnassignRoleWimpFromRapp() throws Exception { final String TEST_NAME = "test327UnassignRoleWimpFromRapp"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -834,7 +813,6 @@ public void test327UnassignRoleWimpFromRapp() throws Exception { @Test public void test328UnassignRoleThugFromRapp() throws Exception { final String TEST_NAME = "test328UnassignRoleThugFromRapp"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -879,7 +857,6 @@ public void test328UnassignRoleThugFromRapp() throws Exception { @Test public void test329UnAssignRoleBruteFromRapp() throws Exception { final String TEST_NAME = "test329UnAssignRoleBruteFromRapp"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -918,7 +895,6 @@ public void test329UnAssignRoleBruteFromRapp() throws Exception { @Test public void test350AssignOrangeAccountToGuybrushAndRapp() throws Exception { final String TEST_NAME = "test350AssignOrangeAccountToGuybrushAndRapp"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -944,7 +920,6 @@ public void test350AssignOrangeAccountToGuybrushAndRapp() throws Exception { @Test public void test351AssignRoleCrewOfGuybrushToRapp() throws Exception { final String TEST_NAME = "test351AssignRoleCrewOfGuybrushToRapp"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -989,7 +964,6 @@ public void test351AssignRoleCrewOfGuybrushToRapp() throws Exception { @Test public void test358UnassignRoleCrewOfGuybrushToRapp() throws Exception { final String TEST_NAME = "test358UnassignRoleCrewOfGuybrushToRapp"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1029,7 +1003,6 @@ public void test358UnassignRoleCrewOfGuybrushToRapp() throws Exception { @Test public void test359UnassignOrangeAccountFromGuybrushAndRapp() throws Exception { final String TEST_NAME = "test359UnassignOrangeAccountFromGuybrushAndRapp"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1052,7 +1025,6 @@ public void test359UnassignOrangeAccountFromGuybrushAndRapp() throws Exception { @Test public void test600AssignRolePirateToJack() throws Exception { final String TEST_NAME = "test600AssignRolePirateToJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1087,7 +1059,6 @@ public void test600AssignRolePirateToJack() throws Exception { @Test public void test610AssignRoleSwashbucklerToJack() throws Exception { final String TEST_NAME = "test610AssignRoleSwashbucklerToJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1121,7 +1092,6 @@ public void test610AssignRoleSwashbucklerToJack() throws Exception { @Test public void test620UnAssignSwashbucklerFromJack() throws Exception { final String TEST_NAME = "test620UnAssignSwashbucklerFromJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1159,7 +1129,6 @@ public void test620UnAssignSwashbucklerFromJack() throws Exception { @Test public void test630AssignRoleSwashbucklerToJackValidity() throws Exception { final String TEST_NAME = "test630AssignRoleSwashbucklerToJackValidity"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1203,7 +1172,6 @@ public void test630AssignRoleSwashbucklerToJackValidity() throws Exception { @Test public void test640JackRoleSwashbucklerBecomesValid() throws Exception { final String TEST_NAME = "test640JackRoleSwashbucklerBecomesValid"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1239,7 +1207,6 @@ public void test640JackRoleSwashbucklerBecomesValid() throws Exception { @Test public void test645JackRoleSwashbucklerIsValid() throws Exception { final String TEST_NAME = "test645JackRoleSwashbucklerIsValid"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1271,7 +1238,6 @@ public void test645JackRoleSwashbucklerIsValid() throws Exception { @Test public void test650JackRoleSwashbucklerBecomesInvalid() throws Exception { final String TEST_NAME = "test650JackRoleSwashbucklerBecomesInvalid"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1307,7 +1273,6 @@ public void test650JackRoleSwashbucklerBecomesInvalid() throws Exception { @Test public void test659UnassignRoleSwashbucklerFromJack() throws Exception { final String TEST_NAME = "test659UnassignRoleSwashbucklerFromJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1347,7 +1312,6 @@ public void test659UnassignRoleSwashbucklerFromJack() throws Exception { @Test public void test699UnassignRolePirateFromJack() throws Exception { final String TEST_NAME = "test699UnassignRolePirateFromJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1373,7 +1337,6 @@ public void test699UnassignRolePirateFromJack() throws Exception { @Test public void test700ReconcileGuybrush() throws Exception { final String TEST_NAME = "test700ReconcileGuybrush"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1407,7 +1370,6 @@ public void test700ReconcileGuybrush() throws Exception { @Test public void test710AssociateGuybrushToLandlubers() throws Exception { final String TEST_NAME = "test710AssociateGuybrushToLandlubers"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1433,7 +1395,6 @@ public void test710AssociateGuybrushToLandlubers() throws Exception { @Test public void test715AssociateGuybrushToThugs() throws Exception { final String TEST_NAME = "test715AssociateGuybrushToThugs"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1477,7 +1438,6 @@ public void test715AssociateGuybrushToThugs() throws Exception { @Test public void test720ReconcileGuybrush() throws Exception { final String TEST_NAME = "test720ReconcileGuybrush"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1503,7 +1463,6 @@ public void test720ReconcileGuybrush() throws Exception { @Test public void test729CleanupGuybrush() throws Exception { final String TEST_NAME = "test729CleanupGuybrush"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1535,7 +1494,6 @@ public void test729CleanupGuybrush() throws Exception { @Test public void test750PrepareGuybrushFuturePerfect() throws Exception { final String TEST_NAME = "test750PrepareGuybrushFuturePerfect"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1578,7 +1536,6 @@ private String orgGroupName(String ou) { @Test public void test752GuybrushFuturePerfect() throws Exception { final String TEST_NAME = "test752GuybrushFuturePerfect"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1604,7 +1561,6 @@ public void test752GuybrushFuturePerfect() throws Exception { @Test public void test759CleanupGuybrush() throws Exception { final String TEST_NAME = "test759CleanupGuybrush"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1631,7 +1587,6 @@ public void test759CleanupGuybrush() throws Exception { @Test public void test760GuybrushOrgGroupsRepo() throws Exception { final String TEST_NAME = "test760GuybrushOrgGroupsRepo"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1659,7 +1614,6 @@ public void test760GuybrushOrgGroupsRepo() throws Exception { @Test public void test765ReconcileGuybrush() throws Exception { final String TEST_NAME = "test765ReconcileGuybrush"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1691,7 +1645,6 @@ public void test765ReconcileGuybrush() throws Exception { @Test public void test769CleanupGuybrush() throws Exception { final String TEST_NAME = "test769CleanupGuybrush"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1718,7 +1671,6 @@ public void test769CleanupGuybrush() throws Exception { @Test public void test780AssignGuybrushSwashbuckler() throws Exception { final String TEST_NAME = "test780AssignGuybrushSwashbuckler"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1743,7 +1695,6 @@ public void test780AssignGuybrushSwashbuckler() throws Exception { @Test public void test781GuybrushTheLostSwashbuckler() throws Exception { final String TEST_NAME = "test781GuybrushTheLostSwashbuckler"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1767,7 +1718,6 @@ public void test781GuybrushTheLostSwashbuckler() throws Exception { @Test public void test784UnassignGuybrushSwashbuckler() throws Exception { final String TEST_NAME = "test784UnassignGuybrushSwashbuckler"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1787,7 +1737,6 @@ public void test784UnassignGuybrushSwashbuckler() throws Exception { @Test public void test785AssignGuybrushBlueSwashbuckler() throws Exception { final String TEST_NAME = "test785AssignGuybrushBlueSwashbuckler"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1815,7 +1764,6 @@ public void test785AssignGuybrushBlueSwashbuckler() throws Exception { @Test public void test786GuybrushTheLostBlueSwashbuckler() throws Exception { final String TEST_NAME = "test786GuybrushTheLostBlueSwashbuckler"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1839,7 +1787,6 @@ public void test786GuybrushTheLostBlueSwashbuckler() throws Exception { @Test public void test789UnassignGuybrushBlueSwashbuckler() throws Exception { final String TEST_NAME = "test789UnassignGuybrushBlueSwashbuckler"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1862,7 +1809,6 @@ public void test789UnassignGuybrushBlueSwashbuckler() throws Exception { @Test public void test800AssignRoleSwashbucklerToJackNone() throws Exception { final String TEST_NAME = "test800AssignRoleSwashbucklerToJackNone"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1896,7 +1842,6 @@ public void test800AssignRoleSwashbucklerToJackNone() throws Exception { @Test public void test805ReconcileJackNone() throws Exception { final String TEST_NAME = "test805ReconcileJackNone"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1925,7 +1870,6 @@ public void test805ReconcileJackNone() throws Exception { @Test public void test809UnAssignRoleSwashbucklerFromJackNone() throws Exception { final String TEST_NAME = "test809UnAssignRoleSwashbucklerFromJackNone"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1953,7 +1897,6 @@ public void test809UnAssignRoleSwashbucklerFromJackNone() throws Exception { @Test public void test810AssignRoleSwashbucklerToJackPositive() throws Exception { final String TEST_NAME = "test810AssignRoleSwashbucklerToJackPositive"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1985,7 +1928,6 @@ public void test810AssignRoleSwashbucklerToJackPositive() throws Exception { @Test public void test815ReconcileJackPositive() throws Exception { final String TEST_NAME = "test815ReconcileJackPositive"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2014,7 +1956,6 @@ public void test815ReconcileJackPositive() throws Exception { @Test public void test817UnAssignRoleSwashbucklerFromJackPositive() throws Exception { final String TEST_NAME = "test817UnAssignRoleSwashbucklerFromJackPositive"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2042,7 +1983,6 @@ public void test817UnAssignRoleSwashbucklerFromJackPositive() throws Exception { @Test public void test819ReconcileJackPositive() throws Exception { final String TEST_NAME = "test819ReconcileJackPositive"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2075,7 +2015,6 @@ public void test819ReconcileJackPositive() throws Exception { @Test public void test820RecomputeJackFull() throws Exception { final String TEST_NAME = "test820RecomputeJackFull"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2106,7 +2045,6 @@ public void test820RecomputeJackFull() throws Exception { @Test public void test822AssignRoleSwashbucklerToJackFull() throws Exception { final String TEST_NAME = "test822AssignRoleSwashbucklerToJackFull"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2138,7 +2076,6 @@ public void test822AssignRoleSwashbucklerToJackFull() throws Exception { @Test public void test825ReconcileJackFull() throws Exception { final String TEST_NAME = "test825ReconcileJackFull"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2167,7 +2104,6 @@ public void test825ReconcileJackFull() throws Exception { @Test public void test827UnAssignRoleSwashbucklerFromJackFull() throws Exception { final String TEST_NAME = "test827UnAssignRoleSwashbucklerFromJackFull"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2195,7 +2131,6 @@ public void test827UnAssignRoleSwashbucklerFromJackFull() throws Exception { @Test public void test829ReconcileJackFull() throws Exception { final String TEST_NAME = "test829ReconcileJackFull"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2224,7 +2159,6 @@ public void test829ReconcileJackFull() throws Exception { @Test public void test830AssignJackAccountDummy() throws Exception { final String TEST_NAME = "test830AssignJackAccountDummy"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2255,7 +2189,6 @@ public void test830AssignJackAccountDummy() throws Exception { @Test public void test840AssignRoleSwashbucklerToJackNone() throws Exception { final String TEST_NAME = "test840AssignRoleSwashbucklerToJackNone"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2287,7 +2220,6 @@ public void test840AssignRoleSwashbucklerToJackNone() throws Exception { @Test public void test849UnassignRoleSwashbucklerFromJackNone() throws Exception { final String TEST_NAME = "test849UnassignRoleSwashbucklerFromJackNone"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2315,7 +2247,6 @@ public void test849UnassignRoleSwashbucklerFromJackNone() throws Exception { @Test public void test850AssignRoleSwashbucklerToJackPositive() throws Exception { final String TEST_NAME = "test850AssignRoleSwashbucklerToJackPositive"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2347,7 +2278,6 @@ public void test850AssignRoleSwashbucklerToJackPositive() throws Exception { @Test public void test859UnassignRoleSwashbucklerToJackPositive() throws Exception { final String TEST_NAME = "test859UnassignRoleSwashbucklerToJackPositive"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2377,7 +2307,6 @@ public void test859UnassignRoleSwashbucklerToJackPositive() throws Exception { @Test public void test860RecomputeJackFull() throws Exception { final String TEST_NAME = "test860RecomputeJackFull"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2405,7 +2334,6 @@ public void test860RecomputeJackFull() throws Exception { @Test public void test862AssignRoleSwashbucklerToJackFull() throws Exception { final String TEST_NAME = "test862AssignRoleSwashbucklerToJackFull"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2437,7 +2365,6 @@ public void test862AssignRoleSwashbucklerToJackFull() throws Exception { @Test public void test869UnassignRoleSwashbucklerToJackFull() throws Exception { final String TEST_NAME = "test869UnassignRoleSwashbucklerToJackFull"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2465,7 +2392,6 @@ public void test869UnassignRoleSwashbucklerToJackFull() throws Exception { @Test public void test899UnAssignAccountJackDummy() throws Exception { final String TEST_NAME = "test899UnAssignAccountJackDummy"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestInbounds.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestInbounds.java index 8c57b3bc43b..1147a4a463d 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestInbounds.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestInbounds.java @@ -24,7 +24,6 @@ import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.util.PrismAsserts; -import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.prism.xml.XmlTypeConverter; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; @@ -58,7 +57,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -78,7 +76,6 @@ public void test000Sanity() throws Exception { @Test public void test101ModifyUserSubtypePirate() throws Exception { final String TEST_NAME = "test101ModifyUserSubtypePirate"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -122,7 +119,6 @@ public void test101ModifyUserSubtypePirate() throws Exception { @Test public void test102ModifyUserSubtypeBuccaneer() throws Exception { final String TEST_NAME = "test102ModifyUserSubtypeBuccaneer"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -157,7 +153,6 @@ public void test102ModifyUserSubtypeBuccaneer() throws Exception { @Test public void test103DeleteUserEmployeeTypeBartender() throws Exception { final String TEST_NAME = "test103ModifyUserEmployeeTypeBartender"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -198,7 +193,6 @@ public void test103DeleteUserEmployeeTypeBartender() throws Exception { @Test public void test200AssignAccountOrange() throws Exception { final String TEST_NAME = "test200AssignAccountOrange"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -241,7 +235,6 @@ public void test200AssignAccountOrange() throws Exception { @Test public void test202ModifyAccountOrangeGossip() throws Exception { final String TEST_NAME = "test202ModifyAccountOrangeGossip"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -286,7 +279,6 @@ public void test202ModifyAccountOrangeGossip() throws Exception { @Test public void test204AssignAccountOrangeAgain() throws Exception { final String TEST_NAME = "test204AssignAccountOrangeAgain"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -330,7 +322,6 @@ public void test204AssignAccountOrangeAgain() throws Exception { @Test public void test209ModifyAccountOrangeGossipRemove() throws Exception { final String TEST_NAME = "test209ModifyAccountOrangeGossipRemove"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -376,7 +367,6 @@ public void test209ModifyAccountOrangeGossipRemove() throws Exception { @Test public void test210ModifyAccountOrangeQuoteMonkey() throws Exception { final String TEST_NAME = "test210ModifyAccountOrangeQuoteMonkey"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -427,7 +417,6 @@ public void test210ModifyAccountOrangeQuoteMonkey() throws Exception { @Test public void test211ModifyAccountOrangeQuotePirate() throws Exception { final String TEST_NAME = "test211ModifyAccountOrangeQuotePirate"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -478,7 +467,6 @@ public void test211ModifyAccountOrangeQuotePirate() throws Exception { @Test public void test214ModifyAccountOrangeQuoteWoodchuck() throws Exception { final String TEST_NAME = "test214ModifyAccountOrangeQuoteWoodchuck"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -525,7 +513,6 @@ public void test214ModifyAccountOrangeQuoteWoodchuck() throws Exception { @Test public void test250UnlinkAccountDefaultDummy() throws Exception { final String TEST_NAME = "test250UnlinkAccountDefaultDummy"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -570,7 +557,6 @@ public void test250UnlinkAccountDefaultDummy() throws Exception { @Test public void test252ModifyAccountOrangeGossipRecon() throws Exception { final String TEST_NAME = "test252ModifyAccountOrangeGossipRecon"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -616,7 +602,6 @@ public void test252ModifyAccountOrangeGossipRecon() throws Exception { @Test public void test259ModifyAccountOrangeGossipRemoveRecon() throws Exception { final String TEST_NAME = "test259ModifyAccountOrangeGossipRemoveRecon"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -663,7 +648,6 @@ public void test259ModifyAccountOrangeGossipRemoveRecon() throws Exception { @Test public void test260ModifyAccountOrangeQuoteMonkeyRecon() throws Exception { final String TEST_NAME = "test260ModifyAccountOrangeQuoteMonkeyRecon"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -718,7 +702,6 @@ public void test260ModifyAccountOrangeQuoteMonkeyRecon() throws Exception { @Test public void test261ModifyAccountOrangeQuotePirateRecon() throws Exception { final String TEST_NAME = "test261ModifyAccountOrangeQuotePirateRecon"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -768,7 +751,6 @@ public void test261ModifyAccountOrangeQuotePirateRecon() throws Exception { @Test public void test264ModifyAccountOrangeQuoteWoodchuckRecon() throws Exception { final String TEST_NAME = "test264ModifyAccountOrangeQuoteWoodchuckRecon"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -816,7 +798,6 @@ public void test264ModifyAccountOrangeQuoteWoodchuckRecon() throws Exception { @Test public void test297ModifyAccountOrangeGossipRecon() throws Exception { final String TEST_NAME = "test297ModifyAccountOrangeGossipRecon"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -858,7 +839,6 @@ public void test297ModifyAccountOrangeGossipRecon() throws Exception { @Test public void test299UnassignAccountOrange() throws Exception { final String TEST_NAME = "test299UnassignAccountOrange"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIntent.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIntent.java index ede644502b0..a1eedd432f6 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIntent.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIntent.java @@ -55,7 +55,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test131ModifyUserJackAssignAccountDefault() throws Exception { final String TEST_NAME="test131ModifyUserJackAssignAccountDefault"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -115,7 +114,6 @@ public void test131ModifyUserJackAssignAccountDefault() throws Exception { @Test public void test132ModifyUserJackAssignAccountTest() throws Exception { final String TEST_NAME="test132ModifyUserJackAssignAccountTest"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -188,7 +186,6 @@ public void test132ModifyUserJackAssignAccountTest() throws Exception { @Test public void test135ModifyUserJackFullName() throws Exception { final String TEST_NAME="test135ModifyUserJackFullName"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -250,7 +247,6 @@ public void test135ModifyUserJackFullName() throws Exception { @Test public void test147ModifyUserJackUnAssignAccountDefault() throws Exception { final String TEST_NAME="test147ModifyUserJackUnAssignAccountDefault"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -310,7 +306,6 @@ public void test147ModifyUserJackUnAssignAccountDefault() throws Exception { @Test public void test149ModifyUserJackUnassignAccountTest() throws Exception { final String TEST_NAME = "test149ModifyUserJackUnassignAccountTest"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIteration.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIteration.java index e52dddd9ce1..65d1aa2cb60 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIteration.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIteration.java @@ -21,6 +21,7 @@ import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.schema.SearchResultList; import com.evolveum.midpoint.schema.constants.SchemaConstants; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType; @@ -227,7 +228,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100JackAssignAccountDummyConflicting() throws Exception { final String TEST_NAME = "test100JackAssignAccountDummyConflicting"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -282,7 +282,6 @@ public void test100JackAssignAccountDummyConflicting() throws Exception { @Test public void test200JackAssignAccountDummyPinkConflicting() throws Exception { final String TEST_NAME = "test200JackAssignAccountDummyPinkConflicting"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -366,7 +365,6 @@ public void test200JackAssignAccountDummyPinkConflicting() throws Exception { @Test public void test210GuybrushAssignAccountDummyPink() throws Exception { final String TEST_NAME = "test210GuybrushAssignAccountDummyPink"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -419,7 +417,6 @@ public void test210GuybrushAssignAccountDummyPink() throws Exception { @Test public void test220DeWattAssignAccountDummyPinkCaseIgnore() throws Exception { final String TEST_NAME = "test220DeWattAssignAccountDummyPinkCaseIgnore"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -486,7 +483,6 @@ public void test220DeWattAssignAccountDummyPinkCaseIgnore() throws Exception { @Test public void test230ScroogeAddAccountDummyConflictingNoShadow() throws Exception { final String TEST_NAME = "test230ScroogeAddAccountDummyConflictingNoShadow"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -538,7 +534,6 @@ public void test230ScroogeAddAccountDummyConflictingNoShadow() throws Exception @Test public void test235HackerAddAccountDummyEternalConflict() throws Exception { final String TEST_NAME = "test235HackerAddAccountDummyEternalConflict"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -584,7 +579,6 @@ public void test235HackerAddAccountDummyEternalConflict() throws Exception { @Test public void test240LargoAssignAccountDummyConflictingNoShadow() throws Exception { final String TEST_NAME = "test240LargoAssignAccountDummyConflictingNoShadow"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -652,7 +646,6 @@ public void test240LargoAssignAccountDummyConflictingNoShadow() throws Exception @Test public void test260JupiterConflictNoShadowSyncBack() throws Exception { final String TEST_NAME = "test260JupiterConflictNoShadowSyncBack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -713,7 +706,6 @@ public void test262JupiterCleanup() throws Exception { } protected void cleanUpJupiter(String TEST_NAME) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, SchemaViolationException, ConflictException, InterruptedException { - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -754,7 +746,6 @@ protected void cleanUpJupiter(String TEST_NAME) throws SchemaException, ObjectAl @Test public void test264JupiterConflictNoShadowSyncBackSeparate() throws Exception { final String TEST_NAME = "test264JupiterConflictNoShadowSyncBackSeparate"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -820,7 +811,6 @@ public void test266JupiterCleanupAgain() throws Exception { @Test public void test270JupiterConflictOtherNoShadowSyncBack() throws Exception { final String TEST_NAME = "test270JupiterConflictOtherNoShadowSyncBack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -902,7 +892,6 @@ private void assertUserJupiter(PrismObject user) { @Test public void test280RenameBobNoShadow() throws Exception { final String TEST_NAME = "test280RenameBobNoShadow"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -963,7 +952,6 @@ public void test280RenameBobNoShadow() throws Exception { @Test public void test282RenamePeterNoShadowSync() throws Exception { final String TEST_NAME = "test282RenamePeterNoShadowSync"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1040,7 +1028,6 @@ public void test282RenamePeterNoShadowSync() throws Exception { @Test public void test290AlfredConflictNoShadowSyncBackAdd() throws Exception { final String TEST_NAME = "test290AlfredConflictNoShadowSyncBackAdd"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1092,7 +1079,6 @@ public void test290AlfredConflictNoShadowSyncBackAdd() throws Exception { @Test public void test300JackAssignAccountDummyVioletConflicting() throws Exception { final String TEST_NAME = "test300JackAssignAccountDummyVioletConflicting"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1159,7 +1145,6 @@ public void test300JackAssignAccountDummyVioletConflicting() throws Exception { @Test public void test350GuybrushAssignAccountDummyViolet() throws Exception { final String TEST_NAME = "test350GuybrushAssignAccountDummyViolet"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1216,7 +1201,6 @@ public void test350GuybrushAssignAccountDummyViolet() throws Exception { @Test public void test360HermanAssignAccountDummyViolet() throws Exception { final String TEST_NAME = "test360HermanAssignAccountDummyViolet"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1276,7 +1260,6 @@ public void test360HermanAssignAccountDummyViolet() throws Exception { @Test public void test400RenameAngelicaConflicting() throws Exception { final String TEST_NAME = "test400RenameAngelicaConflicting"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1310,7 +1293,6 @@ public void test400RenameAngelicaConflicting() throws Exception { @Test public void test500JackAssignAccountDummyMagenta() throws Exception { final String TEST_NAME = "test500JackAssignAccountDummyMagenta"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1379,7 +1361,6 @@ public void test500JackAssignAccountDummyMagenta() throws Exception { @Test public void test510DrakeAssignAccountDummyMagenta() throws Exception { final String TEST_NAME = "test510DrakeAssignAccountDummyMagenta"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1459,7 +1440,6 @@ public void test510DrakeAssignAccountDummyMagenta() throws Exception { @Test public void test520DrakeModifyLocality() throws Exception { final String TEST_NAME = "test520DrakeModifyLocality"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1524,7 +1504,6 @@ public void test520DrakeModifyLocality() throws Exception { @Test public void test530GuybrushAssignAccountDummyMagenta() throws Exception { final String TEST_NAME = "test530GuybrushAssignAccountDummyMagenta"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1591,7 +1570,6 @@ public void test530GuybrushAssignAccountDummyMagenta() throws Exception { @Test public void test532GuybrushModifyDescription() throws Exception { final String TEST_NAME = "test532GuybrushModifyDescription"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1655,7 +1633,6 @@ public void test532GuybrushModifyDescription() throws Exception { @Test public void test600JackRename() throws Exception { final String TEST_NAME = "test600JackRename"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1717,7 +1694,6 @@ public void test600JackRename() throws Exception { @Test public void test700DarkVioletSyncTask() throws Exception { final String TEST_NAME = "test700DarkVioletSyncTask"; - displayTestTitle(TEST_NAME); // WHEN importObjectFromFile(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_FILE); @@ -1732,7 +1708,6 @@ public void test700DarkVioletSyncTask() throws Exception { @Test public void test710DarkVioletAddLeChuck() throws Exception { final String TEST_NAME = "test710DarkVioletAddLeChuck"; - displayTestTitle(TEST_NAME); // GIVEN dummyAuditService.clear(); @@ -1760,7 +1735,6 @@ public void test710DarkVioletAddLeChuck() throws Exception { @Test public void test712DarkVioletAddCharles() throws Exception { final String TEST_NAME = "test712DarkVioletAddCharles"; - displayTestTitle(TEST_NAME); // GIVEN dummyAuditService.clear(); @@ -1789,7 +1763,6 @@ public void test712DarkVioletAddCharles() throws Exception { @Test public void test714DarkVioletAddShinetop() throws Exception { final String TEST_NAME = "test714DarkVioletAddShinetop"; - displayTestTitle(TEST_NAME); // GIVEN dummyAuditService.clear(); @@ -1817,7 +1790,6 @@ public void test714DarkVioletAddShinetop() throws Exception { @Test public void test716DarkVioletDeleteCharles() throws Exception { final String TEST_NAME = "test716DarkVioletDeleteCharles"; - displayTestTitle(TEST_NAME); // GIVEN dummyAuditService.clear(); @@ -1839,7 +1811,6 @@ public void test716DarkVioletDeleteCharles() throws Exception { @Test public void test720DarkVioletModifyShinetopLocation() throws Exception { final String TEST_NAME = "test720DarkVioletModifyShinetopLocation"; - displayTestTitle(TEST_NAME); // GIVEN dummyAuditService.clear(); @@ -1864,7 +1835,6 @@ public void test720DarkVioletModifyShinetopLocation() throws Exception { @Test public void test722DarkVioletModifyShinetopFullName() throws Exception { final String TEST_NAME = "test722DarkVioletModifyShinetopFullName"; - displayTestTitle(TEST_NAME); // GIVEN dummyAuditService.clear(); @@ -1897,7 +1867,6 @@ public void test722DarkVioletModifyShinetopFullName() throws Exception { @Test public void test724DarkVioletAddLe_Chuck() throws Exception { final String TEST_NAME = "test724DarkVioletAddLe_Chuck"; - displayTestTitle(TEST_NAME); // GIVEN dummyAuditService.clear(); @@ -1931,7 +1900,6 @@ public void test724DarkVioletAddLe_Chuck() throws Exception { @Test public void test730DarkVioletAddBarbossa() throws Exception { final String TEST_NAME = "test730DarkVioletAddBarbossa"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1964,7 +1932,6 @@ public void test730DarkVioletAddBarbossa() throws Exception { @Test public void test732DarkVioletAddBarbossa() throws Exception { final String TEST_NAME = "test732DarkVioletAddBarbossa"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1992,7 +1959,6 @@ public void test732DarkVioletAddBarbossa() throws Exception { @Test public void test750DarkVioletAddMatusalem() throws Exception { final String TEST_NAME = "test750DarkVioletAddMatusalem"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2026,7 +1992,6 @@ public void test750DarkVioletAddMatusalem() throws Exception { @Test public void test752DarkVioletAddDiplomatico() throws Exception { final String TEST_NAME = "test752DarkVioletAddDiplomatico"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2061,7 +2026,6 @@ public void test752DarkVioletAddDiplomatico() throws Exception { @Test public void test754DarkVioletAddMilionario() throws Exception { final String TEST_NAME = "test754DarkVioletAddMilionario"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2093,7 +2057,6 @@ public void test754DarkVioletAddMilionario() throws Exception { @Test public void test756DarkVioletDeleteDiplomatico() throws Exception { final String TEST_NAME = "test756DarkVioletDeleteDiplomatico"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2117,7 +2080,6 @@ public void test756DarkVioletDeleteDiplomatico() throws Exception { @Test public void test760DarkVioletModifyMillonarioLocation() throws Exception { final String TEST_NAME = "test760DarkVioletModifyMillonarioLocation"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2147,7 +2109,6 @@ public void test760DarkVioletModifyMillonarioLocation() throws Exception { @Test public void test762DarkVioletModifyMillonarioFullName() throws Exception { final String TEST_NAME = "test762DarkVioletModifyMillonarioFullName"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2178,7 +2139,6 @@ public void test762DarkVioletModifyMillonarioFullName() throws Exception { @Test public void test764DarkVioletModifyMatusalemFullName() throws Exception { final String TEST_NAME = "test764DarkVioletModifyMatusalemFullName"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2212,7 +2172,6 @@ public void test764DarkVioletModifyMatusalemFullName() throws Exception { @Test public void test800UniqeEmailAddUserAlfredoFettucini() throws Exception { final String TEST_NAME = "test800UniqeEmailAddUserAlfredoFettucini"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2250,7 +2209,6 @@ public void test800UniqeEmailAddUserAlfredoFettucini() throws Exception { @Test public void test802UniqeEmailAddUserBillFettucini() throws Exception { final String TEST_NAME = "test802UniqeEmailAddUserBillFettucini"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2287,7 +2245,6 @@ public void test802UniqeEmailAddUserBillFettucini() throws Exception { @Test public void test820SubtypeSetByInbound() throws Exception { final String TEST_NAME = "test820SubtypeSetByInbound"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIterativeTasks.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIterativeTasks.java index f85e5339a86..8aa4e32b08f 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIterativeTasks.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIterativeTasks.java @@ -71,7 +71,6 @@ private void createUser(OperationResult result, int number) throws ObjectAlready @Test public void test100RunBucketsMultithreaded() throws Exception { final String TEST_NAME = "test100RunBucketsMultithreaded"; - displayTestTitle(TEST_NAME); // GIVEN diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestLifecycle.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestLifecycle.java index f186933438f..edc26ee0806 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestLifecycle.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestLifecycle.java @@ -88,7 +88,6 @@ protected File getSystemConfigurationFile() { @Test public void test050SetupJack() throws Exception { final String TEST_NAME = "test050SetupJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -120,7 +119,6 @@ public void test050SetupJack() throws Exception { @Test public void test052PrincipalJackDraft() throws Exception { final String TEST_NAME = "test052AutzJackDraft"; - displayTestTitle(TEST_NAME); // GIVEN // WHEN @@ -143,7 +141,6 @@ public void test052PrincipalJackDraft() throws Exception { @Test public void test060TransitionJackToProposed() throws Exception { final String TEST_NAME = "test060TransitionJackToProposed"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -171,7 +168,6 @@ public void test060TransitionJackToProposed() throws Exception { @Test public void test062PrincipalJackProposed() throws Exception { final String TEST_NAME = "test062PrincipalJackProposed"; - displayTestTitle(TEST_NAME); // GIVEN // WHEN @@ -199,7 +195,6 @@ public void test062PrincipalJackProposed() throws Exception { @Test public void test090TransitionJackToDefaultActive() throws Exception { final String TEST_NAME = "test090TransitionJackToDefaultActive"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -225,7 +220,6 @@ public void test090TransitionJackToDefaultActive() throws Exception { @Test public void test092PrincipalJackDefaultActive() throws Exception { final String TEST_NAME = "test092PrincipalJackDefaultActive"; - displayTestTitle(TEST_NAME); // GIVEN // WHEN @@ -253,7 +247,6 @@ protected void assertLifecycleState(PrismObject object @Test public void test100AssignJackCaretaker() throws Exception { final String TEST_NAME = "test100AssignJackCaretaker"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -278,7 +271,6 @@ public void test100AssignJackCaretaker() throws Exception { @Test public void test102UnassignJackHeadmaster() throws Exception { final String TEST_NAME = "test102UnassignJackHeadmaster"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -307,7 +299,6 @@ public void test102UnassignJackHeadmaster() throws Exception { @Test public void test110UnassignJackCaretaker() throws Exception { final String TEST_NAME = "test110UnassignJackCaretaker"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -335,7 +326,6 @@ public void test110UnassignJackCaretaker() throws Exception { @Test public void test112UnassignJackCaretaker() throws Exception { final String TEST_NAME = "test110UnassignJackCaretaker"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelServiceContract.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelServiceContract.java index 1e3a0aa6486..8829a1deb24 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelServiceContract.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelServiceContract.java @@ -13,7 +13,6 @@ import static org.testng.AssertJUnit.assertTrue; import java.io.File; -import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -55,7 +54,6 @@ import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.internals.InternalCounters; import com.evolveum.midpoint.schema.internals.InternalMonitor; -import com.evolveum.midpoint.schema.internals.InternalOperationClasses; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.result.OperationResultStatus; import com.evolveum.midpoint.schema.util.MiscSchemaUtil; @@ -118,7 +116,6 @@ public void initSystem(Task initTask, OperationResult initResult) @Test public void test050GetUserJack() throws Exception { final String TEST_NAME = "test050GetUserJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -140,7 +137,6 @@ public void test050GetUserJack() throws Exception { @Test public void test051GetUserBarbossa() throws Exception { final String TEST_NAME = "test051GetUserBarbossa"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -164,7 +160,6 @@ public void test051GetUserBarbossa() throws Exception { @Test public void test099ModifyUserAddAccountFailing() throws Exception { final String TEST_NAME = "test099ModifyUserAddAccountFailing"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -241,7 +236,6 @@ public void test099ModifyUserAddAccountFailing() throws Exception { @Test public void test100ModifyUserAddAccount() throws Exception { final String TEST_NAME = "test100ModifyUserAddAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -331,7 +325,6 @@ public void test100ModifyUserAddAccount() throws Exception { @Test public void test101GetAccount() throws Exception { final String TEST_NAME = "test101GetAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -555,7 +548,6 @@ public void test108ModifyUserAddAccountAgain() throws Exception { @Test public void test109ModifyUserAddAccountAgain() throws Exception { final String TEST_NAME = "test109ModifyUserAddAccountAgain"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -606,7 +598,6 @@ public void test109ModifyUserAddAccountAgain() throws Exception { @Test public void test110GetUserResolveAccount() throws Exception { final String TEST_NAME = "test110GetUserResolveAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -646,7 +637,6 @@ public void test110GetUserResolveAccount() throws Exception { @Test public void test111GetUserResolveAccountResource() throws Exception { final String TEST_NAME = "test111GetUserResolveAccountResource"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -689,7 +679,6 @@ public void test111GetUserResolveAccountResource() throws Exception { @Test public void test112GetUserResolveAccountNoFetch() throws Exception { final String TEST_NAME = "test112GetUserResolveAccountNoFetch"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -732,7 +721,6 @@ public void test112GetUserResolveAccountNoFetch() throws Exception { @Test public void test119ModifyUserDeleteAccount() throws Exception { final String TEST_NAME = "test119ModifyUserDeleteAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -805,7 +793,6 @@ public void test119ModifyUserDeleteAccount() throws Exception { @Test public void test120AddAccount() throws Exception { final String TEST_NAME = "test120AddAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestModelServiceContract.class.getName() + "." + TEST_NAME); @@ -882,7 +869,6 @@ public void test120AddAccount() throws Exception { @Test public void test121ModifyUserAddAccountRef() throws Exception { final String TEST_NAME = "test121ModifyUserAddAccountRef"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1123,7 +1109,6 @@ public void test130PreviewModifyUserJackAssignAccount() throws Exception { @Test public void test131ModifyUserJackAssignAccount() throws Exception { final String TEST_NAME="test131ModifyUserJackAssignAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1205,7 +1190,6 @@ public void test131ModifyUserJackAssignAccount() throws Exception { @Test public void test132ModifyAccountJackDummy() throws Exception { final String TEST_NAME = "test132ModifyAccountJackDummy"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1297,7 +1281,6 @@ public void test132ModifyAccountJackDummy() throws Exception { @Test public void test135ModifyUserJackAssignAccountAgain() throws Exception { final String TEST_NAME="test135ModifyUserJackAssignAccountAgain"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1361,7 +1344,6 @@ public void test135ModifyUserJackAssignAccountAgain() throws Exception { @Test public void test136JackRecomputeNoChange() throws Exception { final String TEST_NAME="test136JackRecomputeNoChange"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1424,7 +1406,6 @@ public void test136JackRecomputeNoChange() throws Exception { @Test public void test139ModifyUserJackUnassignAccount() throws Exception { final String TEST_NAME = "test139ModifyUserJackUnassignAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1487,7 +1468,6 @@ public void test139ModifyUserJackUnassignAccount() throws Exception { @Test public void test141ModifyUserJackAssignAccountPositiveEnforcement() throws Exception { final String TEST_NAME = "test141ModifyUserJackAssignAccountPositiveEnforcement"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1572,7 +1552,6 @@ public void test141ModifyUserJackAssignAccountPositiveEnforcement() throws Excep @Test public void test148ModifyUserJackUnassignAccountPositiveEnforcement() throws Exception { final String TEST_NAME = "test148ModifyUserJackUnassignAccountPositiveEnforcement"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1668,7 +1647,6 @@ public void test148ModifyUserJackUnassignAccountPositiveEnforcement() throws Exc @Test public void test149ModifyUserJackDeleteAccount() throws Exception { final String TEST_NAME = "test149ModifyUserJackDeleteAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1741,7 +1719,6 @@ public void test149ModifyUserJackDeleteAccount() throws Exception { @Test public void test151ModifyUserJackAssignAccountRelativeEnforcement() throws Exception { final String TEST_NAME = "test151ModifyUserJackAssignAccountRelativeEnforcement"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1819,7 +1796,6 @@ public void test151ModifyUserJackAssignAccountRelativeEnforcement() throws Excep @Test public void test158ModifyUserJackUnassignAccountRelativeEnforcement() throws Exception { final String TEST_NAME = "test158ModifyUserJackUnassignAccountRelativeEnforcement"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestModelServiceContract.class.getName() @@ -1884,7 +1860,6 @@ public void test158ModifyUserJackUnassignAccountRelativeEnforcement() throws Exc @Test public void test161ModifyUserJackAssignAccountNoneEnforcement() throws Exception { final String TEST_NAME = "test161ModifyUserJackAssignAccountNoneEnforcement"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1947,7 +1922,6 @@ public void test161ModifyUserJackAssignAccountNoneEnforcement() throws Exception @Test public void test163ModifyUserJackAddAccountNoneEnforcement() throws Exception { final String TEST_NAME = "test163ModifyUserJackAddAccountNoneEnforcement"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2028,7 +2002,6 @@ public void test163ModifyUserJackAddAccountNoneEnforcement() throws Exception { @Test public void test164ModifyUserJackUnassignAccountNoneEnforcement() throws Exception { final String TEST_NAME = "test164ModifyUserJackUnassignAccountNoneEnforcement"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestModelServiceContract.class.getName() @@ -2096,7 +2069,6 @@ public void test164ModifyUserJackUnassignAccountNoneEnforcement() throws Excepti @Test public void test169ModifyUserJackDeleteAccountNoneEnforcement() throws Exception { final String TEST_NAME = "test169ModifyUserJackDeleteAccountNoneEnforcement"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2164,7 +2136,6 @@ public void test169ModifyUserJackDeleteAccountNoneEnforcement() throws Exception @Test public void test180ModifyUserAddAccountFullEnforcement() throws Exception { final String TEST_NAME = "test180ModifyUserAddAccountFullEnforcement"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2226,7 +2197,6 @@ public void test180ModifyUserAddAccountFullEnforcement() throws Exception { @Test public void test182ModifyUserAddAndAssignAccountPositiveEnforcement() throws Exception { final String TEST_NAME = "test182ModifyUserAddAndAssignAccountPositiveEnforcement"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2361,7 +2331,6 @@ public void test189ModifyUserJackUnassignAndDeleteAccount() throws Exception { @Test public void test190ModifyUserJackAssignAccountAndModify() throws Exception { final String TEST_NAME = "test190ModifyUserJackAssignAccountAndModify"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2447,7 +2416,6 @@ public void test190ModifyUserJackAssignAccountAndModify() throws Exception { @Test public void test191ModifyUserJackModifyAssignment() throws Exception { final String TEST_NAME = "test191ModifyUserJackModifyAssignment"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2562,7 +2530,6 @@ public void test191ModifyUserJackModifyAssignment() throws Exception { @Test public void test192ModifyUserJack() throws Exception { final String TEST_NAME = "test192ModifyUserJack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2635,7 +2602,6 @@ public void test192ModifyUserJack() throws Exception { @Test public void test193ModifyUserJackLocationEmpty() throws Exception { final String TEST_NAME = "test193ModifyUserJackLocationEmpty"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2702,7 +2668,6 @@ public void test193ModifyUserJackLocationEmpty() throws Exception { @Test public void test194ModifyUserJackLocationNull() throws Exception { final String TEST_NAME = "test194ModifyUserJackLocationNull"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2736,7 +2701,6 @@ public void test194ModifyUserJackLocationNull() throws Exception { @Test public void test195ModifyUserJackLocationSea() throws Exception { final String TEST_NAME = "test195ModifyUserJackLocationSea"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2921,7 +2885,6 @@ public void test199DeleteUserJack() throws Exception { @Test public void test200AddUserBlackbeardWithAccount() throws Exception { final String TEST_NAME = "test200AddUserBlackbeardWithAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -3007,7 +2970,6 @@ public void test200AddUserBlackbeardWithAccount() throws Exception { @Test public void test210AddUserMorganWithAssignment() throws Exception { final String TEST_NAME = "test210AddUserMorganWithAssignment"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -3089,7 +3051,6 @@ public void test210AddUserMorganWithAssignment() throws Exception { @Test public void test212RenameUserMorgan() throws Exception { final String TEST_NAME = "test212RenameUserMorgan"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -3175,7 +3136,6 @@ public void test212RenameUserMorgan() throws Exception { @Test public void test240AddUserCharlesRaw() throws Exception { final String TEST_NAME = "test240AddUserCharlesRaw"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -3220,7 +3180,6 @@ public void test240AddUserCharlesRaw() throws Exception { @Test public void test241DeleteUserCharlesRaw() throws Exception { final String TEST_NAME = "test241DeleteUserCharlesRaw"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -3260,7 +3219,6 @@ public void test241DeleteUserCharlesRaw() throws Exception { @Test public void test300AddUserJackWithAssignmentBlue() throws Exception { final String TEST_NAME="test300AddUserJackWithAssignmentBlue"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -3330,7 +3288,6 @@ public void test300AddUserJackWithAssignmentBlue() throws Exception { @Test public void test302ModifyAccountJackDummyBlue() throws Exception { final String TEST_NAME = "test302ModifyAccountJackDummyBlue"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestPreviewChanges.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestPreviewChanges.java index f7462ea2b8f..3d5aab0e4ea 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestPreviewChanges.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestPreviewChanges.java @@ -22,10 +22,7 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.DummyResourceContoller; -import com.evolveum.midpoint.test.IntegrationTestTools; -import com.evolveum.midpoint.test.ObjectChecker; -import com.evolveum.midpoint.test.ObjectSource; +import com.evolveum.midpoint.test.*; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.*; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; @@ -146,7 +143,6 @@ public void check(ModelContext modelContext) { private void modifyUserAddAccountImplicit(String bundleName, ObjectSource> accountSource, ObjectChecker> checker) throws Exception { final String TEST_NAME = bundleName + "Implicit"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -168,7 +164,6 @@ private void modifyUserAddAccountImplicit(String bundleName, ObjectSource> accountSource, ObjectChecker> checker) throws Exception { final String TEST_NAME = bundleName + "Explicit"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -187,7 +182,6 @@ private void modifyUserAddAccountExplicit(String bundleName, ObjectSource> accountSource, ObjectChecker> checker) throws Exception { final String TEST_NAME = bundleName + "ImplicitExplicitSame"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -210,7 +204,6 @@ private void modifyUserAddAccountImplicitExplicitSame(String bundleName, private void modifyUserAddAccountImplicitExplicitSameReverse(String bundleName, ObjectSource> accountSource, ObjectChecker> checker) throws Exception { final String TEST_NAME = bundleName + "ImplicitExplicitSameReverse"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -233,7 +226,6 @@ private void modifyUserAddAccountImplicitExplicitSameReverse(String bundleName, private void modifyUserAddAccountImplicitExplicitEqual(String bundleName, ObjectSource> accountSource, ObjectChecker> checker) throws Exception { final String TEST_NAME = bundleName + "ImplicitExplicitEqual"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -256,7 +248,6 @@ private void modifyUserAddAccountImplicitExplicitEqual(String bundleName, private void modifyUserAddAccountImplicitExplicitEqualReverse(String bundleName, ObjectSource> accountSource, ObjectChecker> checker) throws Exception { final String TEST_NAME = bundleName + "ImplicitExplicitEqualReverse"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -279,7 +270,6 @@ private void modifyUserAddAccountImplicitExplicitEqualReverse(String bundleName, private void modifyUserAddAccountImplicitExplicitNotEqual(String bundleName, ObjectSource> accountSource, ObjectChecker> checker) throws Exception { final String TEST_NAME = bundleName + "ImplicitExplicitNotEqual"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -304,7 +294,6 @@ private void modifyUserAddAccountImplicitExplicitNotEqual(String bundleName, private void modifyUserAddAccountImplicitExplicitNotEqualReverse(String bundleName, ObjectSource> accountSource, ObjectChecker> checker) throws Exception { final String TEST_NAME = bundleName + "ImplicitExplicitNotEqualReverse"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -405,7 +394,6 @@ private void assertAddAccount(ModelContext modelContext, boolean expec @Test public void test130GetCompiledGuiProfile() throws Exception { final String TEST_NAME = "test130GetCompiledGuiProfile"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -434,7 +422,6 @@ public void test130GetCompiledGuiProfile() throws Exception { @Test public void test150GetGuybrushRefinedObjectClassDef() throws Exception { final String TEST_NAME = "test150GetGuybrushRefinedObjectClassDef"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -459,7 +446,6 @@ public void test150GetGuybrushRefinedObjectClassDef() throws Exception { @Test public void test200ModifyUserGuybrushDeleteAccount() throws Exception { final String TEST_NAME = "test200ModifyUserGuybrushDeleteAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -509,7 +495,6 @@ public void test200ModifyUserGuybrushDeleteAccount() throws Exception { @Test public void test210GuybrushAddAccount() throws Exception { final String TEST_NAME = "test210GuybrushAddAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -560,7 +545,6 @@ public void test210GuybrushAddAccount() throws Exception { @Test public void test212ModifyUserAddAccountRef() throws Exception { final String TEST_NAME = "test212ModifyUserAddAccountRef"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -618,7 +602,6 @@ public void test212ModifyUserAddAccountRef() throws Exception { @Test public void test220PreviewJackAssignRolePirate() throws Exception { final String TEST_NAME = "test220PreviewJackAssignRolePirate"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -646,7 +629,6 @@ public void test220PreviewJackAssignRolePirate() throws Exception { @Test public void test221PreviewJackAssignRolePirateReconcile() throws Exception { final String TEST_NAME = "test221PreviewJackAssignRolePirateReconcile"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -750,7 +732,6 @@ private void assertPreviewJackAssignRolePirate(ModelContext modelConte @Test public void test230GuybrushAssignAccountDummy() throws Exception { final String TEST_NAME = "test230GuybrushAssignAccountDummy"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -788,7 +769,6 @@ public void test230GuybrushAssignAccountDummy() throws Exception { @Test public void test231PreviewGuybrushModifyAccountFullName() throws Exception { final String TEST_NAME = "test231PreviewGuybrushModifyAccountFullName"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -841,7 +821,6 @@ public void test231PreviewGuybrushModifyAccountFullName() throws Exception { @Test public void test232PreviewGuybrushModifyAccountShip() throws Exception { final String TEST_NAME = "test232PreviewGuybrushModifyAccountShip"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -893,7 +872,6 @@ public void test232PreviewGuybrushModifyAccountShip() throws Exception { @Test public void test233PreviewGuybrushAddRolePirate() throws Exception { final String TEST_NAME = "test233PreviewGuybrushAddRolePirate"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -960,7 +938,6 @@ public void test233PreviewGuybrushAddRolePirate() throws Exception { @Test public void test234PreviewGuybrushAddRolePirateRecon() throws Exception { final String TEST_NAME = "test234PreviewGuybrushAddRolePirateRecon"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1029,7 +1006,6 @@ public void test234PreviewGuybrushAddRolePirateRecon() throws Exception { @Test public void test236PreviewGuybrushAddRoleSailor() throws Exception { final String TEST_NAME = "test236PreviewGuybrushAddRoleSailor"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1083,7 +1059,6 @@ public void test236PreviewGuybrushAddRoleSailor() throws Exception { @Test public void test238PreviewGuybrushAddRoleSailorOwner() throws Exception { final String TEST_NAME = "test238PreviewGuybrushAddRoleSailorOwner"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1121,7 +1096,6 @@ public void test238PreviewGuybrushAddRoleSailorOwner() throws Exception { @Test public void test239GuybrushUnAssignAccountDummy() throws Exception { final String TEST_NAME = "test239GuybrushUnAssignAccountDummy"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1147,7 +1121,6 @@ public void test239GuybrushUnAssignAccountDummy() throws Exception { @Test public void test240GuybrushAssignAccountDummyRelative() throws Exception { final String TEST_NAME = "test240GuybrushAssignAccountDummyRelative"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1176,7 +1149,6 @@ public void test240GuybrushAssignAccountDummyRelative() throws Exception { @Test public void test242PreviewGuybrushAddRolePirateRelative() throws Exception { final String TEST_NAME = "test242PreviewGuybrushAddRolePirateRelative"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1244,7 +1216,6 @@ public void test242PreviewGuybrushAddRolePirateRelative() throws Exception { @Test public void test244PreviewGuybrushAddRolePirateRelativeRecon() throws Exception { final String TEST_NAME = "test244PreviewGuybrushAddRolePirateRelativeRecon"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1309,7 +1280,6 @@ public void test244PreviewGuybrushAddRolePirateRelativeRecon() throws Exception @Test public void test249GuybrushUnAssignAccountDummyRelative() throws Exception { final String TEST_NAME = "test249GuybrushUnAssignAccountDummyRelative"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1363,7 +1333,6 @@ private void assertAccountItemModify(ObjectDelta accountDelta, @Test public void test300ModifyElaineAccountDummyReplace() throws Exception { final String TEST_NAME = "test300ModifyElaineAccountDummyReplace"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1419,7 +1388,6 @@ ACCOUNT_SHADOW_ELAINE_DUMMY_OID, getDummyResourceObject(), DummyResourceContolle @Test public void test301ModifyElaineAccountDummyDeleteAdd() throws Exception { final String TEST_NAME = "test301ModifyElaineAccountDummyDeleteAdd"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1480,7 +1448,6 @@ public void test301ModifyElaineAccountDummyDeleteAdd() throws Exception { @Test public void test400ModifyElaineAccountDummyRedReplace() throws Exception { final String TEST_NAME = "test400ModifyElaineAccountDummyRedReplace"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1511,7 +1478,6 @@ ACCOUNT_SHADOW_ELAINE_DUMMY_RED_OID, getDummyResourceObject(RESOURCE_DUMMY_RED_N @Test public void test401ModifyElaineAccountDummyRedDeleteAdd() throws Exception { final String TEST_NAME = "test401ModifyElaineAccountDummyRedDeleteAdd"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1544,7 +1510,6 @@ public void test401ModifyElaineAccountDummyRedDeleteAdd() throws Exception { @Test public void test500ModifyElaineAccountDummyBlueReplace() throws Exception { final String TEST_NAME = "test500ModifyElaineAccountDummyBlueReplace"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1600,7 +1565,6 @@ ACCOUNT_SHADOW_ELAINE_DUMMY_BLUE_OID, getDummyResourceObject(RESOURCE_DUMMY_BLUE @Test public void test501ModifyElaineAccountDummyBlueDeleteAdd() throws Exception { final String TEST_NAME = "test501ModifyElaineAccountDummyBlueDeleteAdd"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1664,7 +1628,6 @@ public void test501ModifyElaineAccountDummyBlueDeleteAdd() throws Exception { @Test public void test600ModifyElaineUserDummyReplace() throws Exception { final String TEST_NAME = "test600ModifyElaineUserDummyReplace"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1757,7 +1720,6 @@ public void test600ModifyElaineUserDummyReplace() throws Exception { @Test public void test610ModifyElaineUserAccountDummyReplace() throws Exception { final String TEST_NAME = "test610ModifyElaineUserAccountDummyReplace"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1861,7 +1823,6 @@ ACCOUNT_SHADOW_ELAINE_DUMMY_BLUE_OID, getDummyResourceObject(RESOURCE_DUMMY_BLUE @Test public void test620AddUserCapsize() throws Exception { final String TEST_NAME = "test620AddUserCapsize"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1952,7 +1913,6 @@ public void test620AddUserCapsize() throws Exception { @Test public void test630AddUserRogers() throws Exception { final String TEST_NAME = "test630AddUserRogers"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2050,7 +2010,6 @@ public void test630AddUserRogers() throws Exception { @Test public void test700DisableElaineAccountTwoResources() throws Exception { final String TEST_NAME = "test700DisableElaineAccountTwoResources"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2127,7 +2086,6 @@ public void test700DisableElaineAccountTwoResources() throws Exception { @Test public void test710PreviewGuybrushHavingRoleSailorOwner() throws Exception { final String TEST_NAME = "test710PreviewGuybrushHavingRoleSailorOwner"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestRaceConditions.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestRaceConditions.java index a7ebc2bd027..7f17ee2f80b 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestRaceConditions.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestRaceConditions.java @@ -13,6 +13,7 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.ObjectTypeUtil; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.SystemException; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; @@ -51,7 +52,6 @@ protected ConflictResolutionActionType getDefaultConflictResolutionAction() { @Test public void test100AssignRoles() throws Exception { final String TEST_NAME="test100AssignRoles"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -93,7 +93,6 @@ public void test100AssignRoles() throws Exception { @Test public void test110UnassignRoles() throws Exception { final String TEST_NAME = "test110UnassignRoles"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestRaceConditions.class.getName() + "." + TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestResources.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestResources.java index 147bfdca3eb..802ca522136 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestResources.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestResources.java @@ -146,7 +146,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test050GetResourceRaw() throws Exception { final String TEST_NAME = "test050GetResourceRaw"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -196,7 +195,6 @@ public void test050GetResourceRaw() throws Exception { @Test public void test052GetResourceNoFetch() throws Exception { final String TEST_NAME = "test052GetResourceNoFetch"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -248,7 +246,6 @@ public void test052GetResourceNoFetch() throws Exception { @Test public void test053GetResourceNoFetchAgain() throws Exception { final String TEST_NAME = "test053GetResourceNoFetchAgain"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -302,7 +299,6 @@ public void test053GetResourceNoFetchAgain() throws Exception { @Test public void test055GetResourceNoFetchReadOnly() throws Exception { final String TEST_NAME = "test055GetResourceNoFetchReadOnly"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -357,7 +353,6 @@ public void test055GetResourceNoFetchReadOnly() throws Exception { @Test public void test100SearchResourcesNoFetch() throws Exception { final String TEST_NAME = "test100SearchResourcesNoFetch"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -406,7 +401,6 @@ public void test100SearchResourcesNoFetch() throws Exception { @Test public void test102SearchResourcesNoFetchReadOnly() throws Exception { final String TEST_NAME = "test102SearchResourcesNoFetchReadOnly"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -457,7 +451,6 @@ public void test102SearchResourcesNoFetchReadOnly() throws Exception { @Test public void test105SearchResourcesIterativeNoFetch() throws Exception { final String TEST_NAME = "test105SearchResourcesIterativeNoFetch"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -509,7 +502,6 @@ public void test105SearchResourcesIterativeNoFetch() throws Exception { @Test public void test107SearchResourcesIterativeNoFetchReadOnly() throws Exception { final String TEST_NAME = "test107SearchResourcesIterativeNoFetchReadOnly"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -560,7 +552,6 @@ public void test107SearchResourcesIterativeNoFetchReadOnly() throws Exception { @Test public void test110GetResourceDummy() throws Exception { final String TEST_NAME = "test110GetResourceDummy"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -603,7 +594,6 @@ public void test110GetResourceDummy() throws Exception { @Test public void test112GetResourceDummyReadOnly() throws Exception { final String TEST_NAME = "test112GetResourceDummyReadOnly"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -645,7 +635,6 @@ public void test112GetResourceDummyReadOnly() throws Exception { @Test public void test120SearchResources() throws Exception { final String TEST_NAME = "test120SearchResources"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestResources.class.getName() + "." + TEST_NAME); @@ -687,7 +676,6 @@ public void test120SearchResources() throws Exception { @Test public void test125SearchResourcesIterative() throws Exception { final String TEST_NAME = "test125SearchResourcesIterative"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestResources.class.getName() + "." + TEST_NAME); @@ -806,7 +794,6 @@ private void assertResource(PrismObject resource, boolean expectSc @Test public void test200GetResourceRawAfterSchema() throws Exception { final String TEST_NAME = "test200GetResourceRawAfterSchema"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestResources.class.getName() + "." + TEST_NAME); @@ -836,7 +823,6 @@ public void test200GetResourceRawAfterSchema() throws Exception { @Test public void test210GetResourceDummyRed() throws Exception { final String TEST_NAME = "test210GetResourceDummyRed"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -872,7 +858,6 @@ public void test210GetResourceDummyRed() throws Exception { @Test public void test750GetResourceRaw() throws Exception { final String TEST_NAME = "test750GetResourceRaw"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -915,7 +900,6 @@ public void test750GetResourceRaw() throws Exception { @Test public void test752GetResourceDummy() throws Exception { final String TEST_NAME = "test752GetResourceDummy"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -949,7 +933,6 @@ public void test752GetResourceDummy() throws Exception { @Test public void test760ModifyConfigurationString() throws Exception { final String TEST_NAME = "test760ModifyConfigurationString"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -976,7 +959,6 @@ public void test760ModifyConfigurationString() throws Exception { @Test public void test761ModifyConfigurationStringRaw() throws Exception { final String TEST_NAME = "test761ModifyConfigurationStringRaw"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1045,7 +1027,6 @@ public void handleGlobalError(OperationResult currentResult) { private void modifyConfigurationDiffExpressionRaw(final String TEST_NAME, FailableFunction> parser) throws Exception { - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1118,7 +1099,6 @@ private ItemPath getConfigurationPropertyPath(QName elementQName) { @Test public void test800GetResourceDummy() throws Exception { final String TEST_NAME = "test800GetResourceDummy"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1152,7 +1132,6 @@ public void test800GetResourceDummy() throws Exception { @Test public void test820SingleDescriptionModify() throws Exception { final String TEST_NAME = "test820SingleDescriptionModify"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1174,7 +1153,6 @@ public void test820SingleDescriptionModify() throws Exception { @Test public void test840RandomModifySequence() throws Exception { final String TEST_NAME = "test840RandomModifySequence"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestScriptHooks.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestScriptHooks.java index 6b7a920003e..a4db2de84f1 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestScriptHooks.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestScriptHooks.java @@ -84,7 +84,6 @@ protected File getSystemConfigurationFile() { @Test public void test100JackAssignHookAccount() throws Exception { final String TEST_NAME = "test100JackAssignHookAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestScriptHooks.class.getName() + "." + TEST_NAME); @@ -138,7 +137,6 @@ public void test100JackAssignHookAccount() throws Exception { @Test public void test110JackAddOrganization() throws Exception { final String TEST_NAME = "test110JackAddOrganization"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestScriptHooks.class.getName() + "." + TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTolerantAttributes.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTolerantAttributes.java index cea50911872..7e8839c7ac9 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTolerantAttributes.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTolerantAttributes.java @@ -32,6 +32,7 @@ import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.MiscUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType; @@ -122,7 +123,6 @@ public void test100ModifyUserAddAccount() throws Exception { @Test public void test101ModifyAddAttributesIntolerantPattern() throws Exception { final String TEST_NAME = "test101ModifyAddAttributesIntolerantPattern"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -311,7 +311,6 @@ public void test104modifyReplaceAttributeTolerantPattern() throws Exception{ @Test public void test105ModifyAddNonTolerantAttribute() throws Exception { final String TEST_NAME = "test105ModifyAddNonTolerantAttribute"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestTolerantAttributes.class.getName() + ".test105modifyAddNonTolerantAttribute"); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplate.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplate.java index e2d7d7a20e0..0a05d237a8b 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplate.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplate.java @@ -21,6 +21,7 @@ import com.evolveum.midpoint.prism.ItemFactory; import com.evolveum.midpoint.prism.delta.*; import com.evolveum.midpoint.prism.path.ItemPath; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.TestResource; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; @@ -2502,7 +2503,6 @@ public void test802FuneralTimestamp() throws Exception { @Test public void test804PreKaboom() throws Exception { final String TEST_NAME = "test804PreKaboom"; - displayTestTitle(TEST_NAME); // GIVEN clockForward("P2D"); @@ -2525,7 +2525,6 @@ public void test804PreKaboom() throws Exception { @Test public void test808Kaboom() throws Exception { final String TEST_NAME = "test808Kaboom"; - displayTestTitle(TEST_NAME); // GIVEN clockForward("P1M"); @@ -2555,7 +2554,6 @@ public void test808Kaboom() throws Exception { @Test public void test810PreTalesBomb() throws Exception { final String TEST_NAME = "test810PreTalesBomb"; - displayTestTitle(TEST_NAME); // GIVEN clockForward("P1D"); @@ -2583,7 +2581,6 @@ public void test810PreTalesBomb() throws Exception { @Test public void test812TalesBoom() throws Exception { final String TEST_NAME = "test812TalesBoom"; - displayTestTitle(TEST_NAME); // GIVEN clockForward("P3M"); @@ -2608,7 +2605,6 @@ public void test812TalesBoom() throws Exception { @Test public void test813TalesBoomRecompute() throws Exception { final String TEST_NAME = "test813TalesBoomRecompute"; - displayTestTitle(TEST_NAME); // GIVEN @@ -2753,7 +2749,6 @@ public void test830PreLootBoom() throws Exception { @Test public void test832LootBoomConditionFalse() throws Exception { final String TEST_NAME = "test832LootBoomConditionFalse"; - displayTestTitle(TEST_NAME); // GIVEN clockForward("P9M"); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplateWithRanges.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplateWithRanges.java index 71ced36eee3..3c9547f3411 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplateWithRanges.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplateWithRanges.java @@ -14,6 +14,7 @@ import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.*; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; @@ -202,7 +203,6 @@ public void test140ChangeManagerAndRecomputeElaineAgain() throws Exception { @Test public void test200SimpleOrgUnitAddition() throws Exception { final String TEST_NAME = "test200SimpleOrgUnitAddition"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -245,7 +245,6 @@ public void test200SimpleOrgUnitAddition() throws Exception { @Test public void test210RemoveUnit1() throws Exception { final String TEST_NAME = "test210RemoveUnit1"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -325,7 +324,6 @@ public void test220RemoveUnit2AndNumber() throws Exception { @Test public void test230RestoreNumber() throws Exception { final String TEST_NAME = "test230RestoreNumber"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -361,7 +359,6 @@ public void test230RestoreNumber() throws Exception { @Test public void test300GuybrushBloodyNose() throws Exception { final String TEST_NAME = "test300GuybrushBloodyNose"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -393,7 +390,6 @@ public void test300GuybrushBloodyNose() throws Exception { @Test public void test309GuybrushNotBloody() throws Exception { final String TEST_NAME = "test309GuybrushNotBloody"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -421,7 +417,6 @@ public void test309GuybrushNotBloody() throws Exception { @Test public void test310GuybrushBloodyNoseFuneral() throws Exception { final String TEST_NAME = "test310GuybrushBloodyNoseFuneral"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -456,7 +451,6 @@ public void test310GuybrushBloodyNoseFuneral() throws Exception { @Test public void test319GuybrushNoBloodyNoseFuneral() throws Exception { final String TEST_NAME = "test319GuybrushNoBloodyNoseFuneral"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -484,7 +478,6 @@ public void test319GuybrushNoBloodyNoseFuneral() throws Exception { @Test public void test320GuybrushBloodyNose() throws Exception { final String TEST_NAME = "test320GuybrushBloodyNose"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -519,7 +512,6 @@ public void test320GuybrushBloodyNose() throws Exception { @Test public void test322GuybrushSetFuneral() throws Exception { final String TEST_NAME = "test322GuybrushSetFuneral"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -548,7 +540,6 @@ public void test322GuybrushSetFuneral() throws Exception { @Test public void test324GuybrushSetFuneral22222() throws Exception { final String TEST_NAME = "test324GuybrushSetFuneral22222"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -579,7 +570,6 @@ public void test324GuybrushSetFuneral22222() throws Exception { @Test public void test326GuybrushNoFuneral() throws Exception { final String TEST_NAME = "test326GuybrushNoFuneral"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -607,7 +597,6 @@ public void test326GuybrushNoFuneral() throws Exception { @Test public void test329GuybrushNoBloodyNose() throws Exception { final String TEST_NAME = "test329GuybrushNoBloodyNose"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestArchetypes.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestArchetypes.java index 5025f22b31e..969b5827c4e 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestArchetypes.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestArchetypes.java @@ -126,7 +126,6 @@ protected File getSystemConfigurationFile() { @Test public void test020SanityJack() throws Exception { final String TEST_NAME = "test020SanityJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -141,7 +140,6 @@ public void test020SanityJack() throws Exception { @Test public void test050AddArchetypeTest() throws Exception { final String TEST_NAME = "test050AddArchetypeTest"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -161,7 +159,6 @@ public void test050AddArchetypeTest() throws Exception { @Test public void test060AddArchetypesAndRoles() throws Exception { final String TEST_NAME = "test060AddArchetypesAndRoles"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -201,7 +198,6 @@ public void test060AddArchetypesAndRoles() throws Exception { @Test public void test070AssignGuybrushUserAdministrator() throws Exception { final String TEST_NAME = "test070AssignGuybrushUserAdministrator"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -221,7 +217,6 @@ public void test070AssignGuybrushUserAdministrator() throws Exception { @Test public void test100AssignJackArchetypeEmployee() throws Exception { final String TEST_NAME = "test100AssignJackArchetypeEmployee"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -265,7 +260,6 @@ private String costCenterEmployee() { @Test public void test102SearchEmployeeArchetypeRef() throws Exception { final String TEST_NAME = "test102SearchEmployeeArchetypeRef"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -303,7 +297,6 @@ public void test102SearchEmployeeArchetypeRef() throws Exception { @Test public void test104GetGuybryshCompiledGuiProfile() throws Exception { final String TEST_NAME = "test104GetGuybryshCompiledGuiProfile"; - displayTestTitle(TEST_NAME); // GIVEN login(USER_GUYBRUSH_USERNAME); @@ -369,7 +362,6 @@ public void test104GetGuybryshCompiledGuiProfile() throws Exception { @Test public void test109UnassignJackArchetypeEmployee() throws Exception { final String TEST_NAME = "test109UnassignJackArchetypeEmployee"; - displayTestTitle(TEST_NAME); loginAdministrator(); @@ -404,7 +396,6 @@ public void test109UnassignJackArchetypeEmployee() throws Exception { @Test public void test110AssignJackRoleEmployeeBase() throws Exception { final String TEST_NAME = "test110AssignJackRoleEmployeeBase"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -460,7 +451,6 @@ public void test110AssignJackRoleEmployeeBase() throws Exception { @Test public void test115UnassignJackRoleEmployeeBase() throws Exception { final String TEST_NAME = "test115UnassignJackRoleEmployeeBase"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -504,7 +494,6 @@ public void test115UnassignJackRoleEmployeeBase() throws Exception { @Test public void test120AssignJackArchetypeTest() throws Exception { final String TEST_NAME = "test120AssignJackArchetypeTest"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -540,7 +529,6 @@ public void test120AssignJackArchetypeTest() throws Exception { @Test public void test129UnassignJackArchetypeTest() throws Exception { final String TEST_NAME = "test129UnassignJackArchetypeTest"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -572,7 +560,6 @@ public void test129UnassignJackArchetypeTest() throws Exception { @Test public void test130AssignJackArchetypeContractor() throws Exception { final String TEST_NAME = "test130AssignJackArchetypeContractor"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -605,7 +592,6 @@ public void test130AssignJackArchetypeContractor() throws Exception { @Test public void test132JackContractorRecompute() throws Exception { final String TEST_NAME = "test132JackContractorRecompute"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -639,7 +625,6 @@ public void test132JackContractorRecompute() throws Exception { @Test public void test135UnassignJackArchetypeContractor() throws Exception { final String TEST_NAME = "test135UnassignJackArchetypeContractor"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -674,7 +659,6 @@ public void test135UnassignJackArchetypeContractor() throws Exception { @Test public void test137JackEmpnoAndRecompute() throws Exception { final String TEST_NAME = "test137JackEmpnoAndRecompute"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -711,7 +695,6 @@ public void test137JackEmpnoAndRecompute() throws Exception { @Test public void test140AddMeathookContractor() throws Exception { final String TEST_NAME = "test140AddMeathookContractor"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -746,7 +729,6 @@ public void test140AddMeathookContractor() throws Exception { @Test public void test150AddWannabe() throws Exception { final String TEST_NAME = "test150AddWannabe"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -782,7 +764,6 @@ public void test150AddWannabe() throws Exception { @Test public void test160AddSelfMadeMan() throws Exception { final String TEST_NAME = "test160AddSelfMadeMan"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -816,7 +797,6 @@ public void test160AddSelfMadeMan() throws Exception { @Test public void test162AddFraudster() throws Exception { final String TEST_NAME = "test162AddFraudster"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -846,7 +826,6 @@ public void test162AddFraudster() throws Exception { @Test public void test200AssignJackBarbossaArchetypeEmployee() throws Exception { final String TEST_NAME = "test200AssignJackBarbossaArchetypeEmployee"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -872,7 +851,6 @@ public void test200AssignJackBarbossaArchetypeEmployee() throws Exception { @Test public void test202GetGuybryshCompiledGuiProfileActiveEmployeesView() throws Exception { final String TEST_NAME = "test202GetGuybryshCompiledGuiProfileActiveEmployeesView"; - displayTestTitle(TEST_NAME); // GIVEN login(USER_GUYBRUSH_USERNAME); @@ -909,7 +887,6 @@ public void test202GetGuybryshCompiledGuiProfileActiveEmployeesView() throws Exc @Test public void test203DisableBarbossa() throws Exception { final String TEST_NAME = "test203DisableBarbossa"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -934,7 +911,6 @@ public void test203DisableBarbossa() throws Exception { @Test public void test205GetGuybryshCompiledGuiProfileActiveEmployeesView() throws Exception { final String TEST_NAME = "test205GetGuybryshCompiledGuiProfileActiveEmployeesView"; - displayTestTitle(TEST_NAME); // GIVEN login(USER_GUYBRUSH_USERNAME); @@ -971,7 +947,6 @@ public void test205GetGuybryshCompiledGuiProfileActiveEmployeesView() throws Exc @Test public void test300jackAssignArchetypeRaw() throws Exception { final String TEST_NAME = "test300jackAssignArchetypeRaw"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestCollections.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestCollections.java index 4e02c7b14a7..0509e0808d6 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestCollections.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestCollections.java @@ -11,9 +11,7 @@ import static org.testng.AssertJUnit.assertNotNull; import static org.testng.AssertJUnit.assertNull; -import java.io.File; import java.util.Collection; -import java.util.List; import java.util.stream.Collectors; import org.springframework.test.annotation.DirtiesContext; @@ -21,34 +19,19 @@ import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import com.evolveum.icf.dummy.resource.DummyResource; import com.evolveum.midpoint.model.api.CollectionStats; import com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView; import com.evolveum.midpoint.model.api.context.EvaluatedPolicyRule; -import com.evolveum.midpoint.model.intest.AbstractConfiguredModelIntegrationTest; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.schema.SearchResultList; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus; -import com.evolveum.midpoint.schema.util.ShadowUtil; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.DummyResourceContoller; -import com.evolveum.midpoint.test.IntegrationTestTools; -import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.FailableRunnable; -import com.evolveum.midpoint.util.Holder; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectCollectionType; import com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyConstraintKindType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; /** @@ -81,7 +64,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -101,7 +83,6 @@ public void test000Sanity() throws Exception { @Test public void test100CompileCollectionView() throws Exception { final String TEST_NAME = "test100CompileCollectionView"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -129,7 +110,6 @@ public void test100CompileCollectionView() throws Exception { @Test public void test102SearchCollectionUsers() throws Exception { final String TEST_NAME = "test102SearchCollectionUsers"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -149,7 +129,6 @@ public void test102SearchCollectionUsers() throws Exception { @Test public void test110CollectionStatsAllEnabled() throws Exception { final String TEST_NAME = "test110CollectionStatsAllEnabled"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -173,7 +152,6 @@ public void test110CollectionStatsAllEnabled() throws Exception { @Test public void test112EvaluateRulesAllEnabled() throws Exception { final String TEST_NAME = "test112EvaluateRulesAllEnabled"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -195,7 +173,6 @@ public void test112EvaluateRulesAllEnabled() throws Exception { @Test public void test120CollectionStatsOneDisabled() throws Exception { final String TEST_NAME = "test120CollectionStatsOneDisabled"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -222,7 +199,6 @@ public void test120CollectionStatsOneDisabled() throws Exception { @Test public void test122EvaluateRulesOneDisabled() throws Exception { final String TEST_NAME = "test122EvaluateRulesOneDisabled"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestAssociationInbound.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestAssociationInbound.java index 68261f071a3..c7d198ab053 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestAssociationInbound.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestAssociationInbound.java @@ -12,6 +12,7 @@ import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; @@ -75,7 +76,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100AssociationInboundMateForOrangeResource() throws Exception { final String TEST_NAME = "test100AssociationInboundMateForOrangeResource"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestEditSchema.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestEditSchema.java index f372bdf676a..bfdfe8f858a 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestEditSchema.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestEditSchema.java @@ -97,7 +97,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100LookupLanguagesGet() throws Exception { final String TEST_NAME="test100LookupLanguagesGet"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -124,7 +123,6 @@ public void test100LookupLanguagesGet() throws Exception { @Test public void test102LookupLanguagesGetExclude() throws Exception { final String TEST_NAME="test102LookupLanguagesGetExclude"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -155,7 +153,6 @@ public void test102LookupLanguagesGetExclude() throws Exception { @Test public void test110LookupLanguagesGetAll() throws Exception { final String TEST_NAME="test110LookupLanguagesGetAll"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -178,7 +175,6 @@ public void test110LookupLanguagesGetAll() throws Exception { @Test public void test120LookupLanguagesGetByKeyExact() throws Exception { final String TEST_NAME="test120LookupLanguagesGetByKeyExact"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -205,7 +201,6 @@ public void test120LookupLanguagesGetByKeyExact() throws Exception { @Test public void test121LookupLanguagesGetByKeyStartingWith() throws Exception { final String TEST_NAME="test121LookupLanguagesGetByKeyStartingWith"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -233,7 +228,6 @@ public void test121LookupLanguagesGetByKeyStartingWith() throws Exception { @Test public void test122LookupLanguagesGetByKeyContaining() throws Exception { final String TEST_NAME="test122LookupLanguagesGetByKeyContaining"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -260,7 +254,6 @@ public void test122LookupLanguagesGetByKeyContaining() throws Exception { @Test public void test123LookupLanguagesGetByKeyContainingWithPaging() throws Exception { final String TEST_NAME="test123LookupLanguagesGetByKeyContainingWithPaging"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -290,7 +283,6 @@ public void test123LookupLanguagesGetByKeyContainingWithPaging() throws Exceptio @Test public void test124LookupLanguagesGetByKeyContainingReturningNothing() throws Exception { final String TEST_NAME="test124LookupLanguagesGetByKeyContainingReturningNothing"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -324,7 +316,6 @@ public void test124LookupLanguagesGetByKeyContainingReturningNothing() throws Ex @Test public void test130LookupLanguagesGetByValueExact() throws Exception { final String TEST_NAME="test130LookupLanguagesGetByValueExact"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -355,7 +346,6 @@ public void test130LookupLanguagesGetByValueExact() throws Exception { @Test public void test131LookupLanguagesGetByLabelStartingWith() throws Exception { final String TEST_NAME="test131LookupLanguagesGetByLabelStartingWith"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -384,7 +374,6 @@ public void test131LookupLanguagesGetByLabelStartingWith() throws Exception { @Test public void test133LookupLanguagesGetByValueContainingWithPaging() throws Exception { final String TEST_NAME="test123LookupLanguagesGetByKeyContainingWithPaging"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -417,7 +406,6 @@ public void test133LookupLanguagesGetByValueContainingWithPaging() throws Except @Test(enabled = false) public void test140LookupLanguagesGetByIdExisting() throws Exception { final String TEST_NAME="test140LookupLanguagesGetByIdExisting"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -458,7 +446,6 @@ private void checkLookupResult(PrismObject lookup, String[]... @Test public void test150LookupLanguagesAddRowFull() throws Exception { final String TEST_NAME="test150LookupLanguagesAddRow"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -506,7 +493,6 @@ public void test150LookupLanguagesAddRowFull() throws Exception { @Test public void test152LookupLanguagesAddRowKeyLabel() throws Exception { final String TEST_NAME="test152LookupLanguagesAddRowKeyLabel"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -554,7 +540,6 @@ public void test152LookupLanguagesAddRowKeyLabel() throws Exception { @Test public void test154LookupLanguagesAddRowKeyValue() throws Exception { final String TEST_NAME="test154LookupLanguagesAddRowKeyValue"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -603,7 +588,6 @@ public void test154LookupLanguagesAddRowKeyValue() throws Exception { @Test public void test156LookupLanguagesAddRowExistingKey() throws Exception { final String TEST_NAME="test156LookupLanguagesAddRowExistingKey"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -664,7 +648,6 @@ public void test156LookupLanguagesAddRowExistingKey() throws Exception { @Test public void test162LookupLanguagesDeleteRowFullNoId() throws Exception { final String TEST_NAME="test162LookupLanguagesDeleteRowFullNoId"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -712,7 +695,6 @@ public void test162LookupLanguagesDeleteRowFullNoId() throws Exception { @Test public void test164LookupLanguagesDeleteRowFullId() throws Exception { final String TEST_NAME="test164LookupLanguagesDeleteRowFullId"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -758,7 +740,6 @@ public void test164LookupLanguagesDeleteRowFullId() throws Exception { @Test public void test166LookupLanguagesDeleteRowIdOnly() throws Exception { final String TEST_NAME="test166LookupLanguagesDeleteRowIdOnly"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -800,7 +781,6 @@ public void test166LookupLanguagesDeleteRowIdOnly() throws Exception { @Test public void test168LookupLanguagesDeleteRowByKey() throws Exception { final String TEST_NAME="test168LookupLanguagesDeleteRowByKey"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -841,7 +821,6 @@ public void test168LookupLanguagesDeleteRowByKey() throws Exception { @Test public void test170LookupLanguagesReplaceRows() throws Exception { final String TEST_NAME="test170LookupLanguagesReplaceRows"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -897,7 +876,6 @@ public void test170LookupLanguagesReplaceRows() throws Exception { @Test public void test180LookupLanguagesReplaceObject() throws Exception { final String TEST_NAME="test180LookupLanguagesReplaceObject"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -937,7 +915,6 @@ public void test180LookupLanguagesReplaceObject() throws Exception { @Test public void test182LookupLanguagesReimport() throws Exception { final String TEST_NAME="test182LookupLanguagesReimport"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1000,7 +977,6 @@ private PrismObject getLookupTableAll(String oid, Task task, Op @Test public void test200EditSchemaUser() throws Exception { final String TEST_NAME="test200EditSchemaUser"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1078,7 +1054,6 @@ public void test200EditSchemaUser() throws Exception { @Test public void test210UserDefinition() throws Exception { final String TEST_NAME="test210UserDefinition"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1136,7 +1111,6 @@ public void test210UserDefinition() throws Exception { @Test public void test211SchemaRegistryUntouched() throws Exception { final String TEST_NAME="test211SchemaRegistryUntouched"; - displayTestTitle(TEST_NAME); assertUntouchedUserDefinition(); assertSteadyResources(); @@ -1148,7 +1122,6 @@ public void test211SchemaRegistryUntouched() throws Exception { @Test public void test213ModifiedUserJack() throws Exception { final String TEST_NAME="test213ModifiedUserJack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1207,7 +1180,6 @@ public void validate(PrismContainerDefinition credentialsDef, S @Test public void test250EditSchemaRole() throws Exception { final String TEST_NAME="test250EditSchemaRole"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1234,7 +1206,6 @@ public void test250EditSchemaRole() throws Exception { @Test public void test260EditShadowSchemaKindIntent() throws Exception { final String TEST_NAME="test260EditShadowSchemaKindIntent"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1276,7 +1247,6 @@ public void test260EditShadowSchemaKindIntent() throws Exception { @Test public void test261EditShadowSchemaObjectclass() throws Exception { final String TEST_NAME="test261EditShadowSchemaObjectclass"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1309,7 +1279,6 @@ public void test261EditShadowSchemaObjectclass() throws Exception { @Test public void test263EditShadowSchemaEmpty() throws Exception { final String TEST_NAME="test263EditShadowSchemaEmpty"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1340,7 +1309,6 @@ public void test263EditShadowSchemaEmpty() throws Exception { @Test public void test265EditShadowSchemaNull() throws Exception { final String TEST_NAME="test265EditShadowSchemaNull"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1371,7 +1339,6 @@ public void test265EditShadowSchemaNull() throws Exception { @Test public void test310CustomRelations() throws Exception { final String TEST_NAME="test310CustomRelations"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1396,7 +1363,6 @@ public void test310CustomRelations() throws Exception { @Test public void test800OtisEditSchemaUser() throws Exception { final String TEST_NAME="test800OtisEditSchemaUser"; - displayTestTitle(TEST_NAME); // GIVEN login(USER_OTIS_USERNAME); @@ -1466,7 +1432,6 @@ public void test800OtisEditSchemaUser() throws Exception { @Test public void test810OtisGetJack() throws Exception { final String TEST_NAME="test810OtisGetJack"; - displayTestTitle(TEST_NAME); // GIVEN login(USER_OTIS_USERNAME); @@ -1550,7 +1515,6 @@ public void validate(PrismPropertyDefinition propDef, String name) throw @Test public void test820OtisSearchUsers() throws Exception { final String TEST_NAME="test820OtisSearchUsers"; - displayTestTitle(TEST_NAME); // GIVEN login(USER_OTIS_USERNAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestRoleEntitlement.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestRoleEntitlement.java index 8396f77b24d..44df4ca5d3a 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestRoleEntitlement.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestRoleEntitlement.java @@ -61,7 +61,6 @@ public class TestRoleEntitlement extends AbstractGenericSyncTest { @Test public void test050GetRolePirate() throws Exception { final String TEST_NAME = "test050GetRolePirate"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -88,7 +87,6 @@ protected void assertRolePirate(PrismObject role) { @Test public void test100ModifyRoleAddEntitlement() throws Exception { final String TEST_NAME = "test100ModifyRoleAddEntitlement"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -155,7 +153,6 @@ public void test100ModifyRoleAddEntitlement() throws Exception { @Test public void test101GetGroup() throws Exception { final String TEST_NAME = "test101GetGroup"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -185,7 +182,6 @@ public void test101GetGroup() throws Exception { @Test public void test102GetGroupNoFetch() throws Exception { final String TEST_NAME = "test102GetGroupNoFetch"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -211,7 +207,6 @@ public void test102GetGroupNoFetch() throws Exception { @Test public void test103GetGroupRaw() throws Exception { final String TEST_NAME = "test103GetGroupRaw"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -236,7 +231,6 @@ public void test103GetGroupRaw() throws Exception { @Test public void test108ModifyRoleAddEntitlementAgain() throws Exception { final String TEST_NAME = "test108ModifyRoleAddEntitlementAgain"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -283,7 +277,6 @@ public void test108ModifyRoleAddEntitlementAgain() throws Exception { @Test public void test110GetRoleResolveEntitlement() throws Exception { final String TEST_NAME = "test110GetRoleResolveEntitlement"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -312,7 +305,6 @@ public void test110GetRoleResolveEntitlement() throws Exception { @Test public void test111GetRoleResolveEntitlement() throws Exception { final String TEST_NAME = "test111GetRoleResolveEntitlement"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -345,7 +337,6 @@ public void test111GetRoleResolveEntitlement() throws Exception { @Test public void test112GetRoleResolveEntitlementNoFetch() throws Exception { final String TEST_NAME = "test112GetRoleResolveEntitlementNoFetch"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -377,7 +368,6 @@ public void test112GetRoleResolveEntitlementNoFetch() throws Exception { @Test public void test119ModifyRoleDeleteEntitlement() throws Exception { final String TEST_NAME = "test119ModifyRoleDeleteEntitlement"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -435,7 +425,6 @@ public void test119ModifyRoleDeleteEntitlement() throws Exception { @Test public void test120AddEntitlement() throws Exception { final String TEST_NAME = "test120AddEntitlement"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -490,7 +479,6 @@ public void test120AddEntitlement() throws Exception { @Test public void test121ModifyRoleLinkEntitlement() throws Exception { final String TEST_NAME = "test121ModifyRoleLinkEntitlement"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -543,7 +531,6 @@ public void test121ModifyRoleLinkEntitlement() throws Exception { @Test public void test128ModifyRoleUnlinkEntitlement() throws Exception { final String TEST_NAME = "test128ModifyRoleUnlinkEntitlement"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -596,7 +583,6 @@ public void test128ModifyRoleUnlinkEntitlement() throws Exception { @Test public void test129DeleteEntitlement() throws Exception { final String TEST_NAME = "test129DeleteEntitlement"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -638,7 +624,6 @@ public void test129DeleteEntitlement() throws Exception { @Test public void test131ModifyRoleAssignEntitlement() throws Exception { final String TEST_NAME = "test131ModifyRoleAssignEntitlement"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -700,7 +685,6 @@ public void test131ModifyRoleAssignEntitlement() throws Exception { @Test public void test132ModifyEntitlement() throws Exception { final String TEST_NAME = "test132ModifyEntitlement"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -765,7 +749,6 @@ public void test132ModifyEntitlement() throws Exception { @Test public void test139ModifyRoleUnassignEntitlement() throws Exception { final String TEST_NAME = "test139ModifyRoleUnassignEntitlement"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -815,7 +798,6 @@ public void test139ModifyRoleUnassignEntitlement() throws Exception { @Test public void test151ModifyRoleAssignEntitlementRelativeEnforcement() throws Exception { final String TEST_NAME = "test151ModifyRoleAssignEntitlementRelativeEnforcement"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -876,7 +858,6 @@ public void test151ModifyRoleAssignEntitlementRelativeEnforcement() throws Excep @Test public void test158ModifyRoleUnassignEntitlementRelativeEnforcement() throws Exception { final String TEST_NAME = "test158ModifyRoleUnassignEntitlementRelativeEnforcement"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestRoleEntitlement.class.getName() @@ -927,7 +908,6 @@ public void test158ModifyRoleUnassignEntitlementRelativeEnforcement() throws Exc @Test public void test160ModifyRolePropertyAndAssignEntitlement() throws Exception { final String TEST_NAME = "test160ModifyRolePropertyAndAssignEntitlement"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -989,7 +969,6 @@ public void test160ModifyRolePropertyAndAssignEntitlement() throws Exception { @Test public void test161ModifyRole() throws Exception { final String TEST_NAME = "test161ModifyRole"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1046,7 +1025,6 @@ public void test161ModifyRole() throws Exception { @Test public void test180RenameRole() throws Exception { final String TEST_NAME = "test180RenameRole"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1109,7 +1087,6 @@ public void test180RenameRole() throws Exception { @Test public void test199DeleteRole() throws Exception { final String TEST_NAME = "test199DeleteRole"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1164,7 +1141,6 @@ public void test199DeleteRole() throws Exception { @Test public void test200AddRoleSwashbuckler() throws Exception { final String TEST_NAME = "test200AddRoleSwashbuckler"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1230,7 +1206,6 @@ public void test200AddRoleSwashbuckler() throws Exception { @Test public void test210ModifyRoleSwashbucklerRiskLevel() throws Exception { final String TEST_NAME = "test210ModifyRoleSwashbucklerRiskLevel"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/importer/AbstractImportTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/importer/AbstractImportTest.java index d7824ffb298..32e2c4e8228 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/importer/AbstractImportTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/importer/AbstractImportTest.java @@ -151,14 +151,12 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti */ @Test public void test000Integrity() { - displayTestTitle("test000Integrity"); assertNotNull(modelService); assertNotNull(repositoryService); } @Test public void test001ImportConnector() throws FileNotFoundException, ObjectNotFoundException, SchemaException { - displayTestTitle("test001ImportConnector"); // GIVEN Task task = taskManager.createTaskInstance(); OperationResult result = new OperationResult(AbstractImportTest.class.getName() + "test001ImportConnector"); @@ -198,7 +196,6 @@ public void test001ImportConnector() throws FileNotFoundException, ObjectNotFoun @Test public void test003ImportUsers() throws Exception { - displayTestTitle("test003ImportUsers"); // GIVEN Task task = taskManager.createTaskInstance(); OperationResult result = new OperationResult(AbstractImportTest.class.getName() + "test003ImportUsers"); @@ -259,7 +256,6 @@ public void test003ImportUsers() throws Exception { // Import the same thing again. Watch how it burns :-) @Test public void test004DuplicateImportUsers() throws Exception { - displayTestTitle("test004DuplicateImportUsers"); // GIVEN Task task = taskManager.createTaskInstance(); OperationResult result = new OperationResult(AbstractImportTest.class.getName() + "test004DuplicateImportUsers"); @@ -292,7 +288,6 @@ public void test004DuplicateImportUsers() throws Exception { // Import the same thing again, this time with overwrite option. This should go well. @Test public void test005ImportUsersWithOverwrite() throws Exception { - displayTestTitle("test005ImportUsersWithOverwrite"); // GIVEN Task task = taskManager.createTaskInstance(); OperationResult result = new OperationResult(AbstractImportTest.class.getName() + "test005ImportUsersWithOverwrite"); @@ -356,7 +351,6 @@ public void test005ImportUsersWithOverwrite() throws Exception { // Import the same thing again, with overwrite and also while keeping OIDs @Test public void test006ImportUsersWithOverwriteKeepOid() throws Exception { - displayTestTitle("test006ImportUsersWithOverwriteKeepOid"); // GIVEN Task task = taskManager.createTaskInstance(); OperationResult result = new OperationResult(AbstractImportTest.class.getName() + "test005ImportUsersWithOverwrite"); @@ -418,7 +412,6 @@ public void test006ImportUsersWithOverwriteKeepOid() throws Exception { @Test public void test020ImportTask() throws Exception { final String TEST_NAME = "test020ImportTask"; - displayTestTitle( TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(AbstractImportTest.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -463,7 +456,6 @@ public void test020ImportTask() throws Exception { @Test public void test030ImportResource() throws Exception { final String TEST_NAME = "test030ImportResource"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(AbstractImportTest.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -514,7 +506,6 @@ public void test030ImportResource() throws Exception { @Test public void test031ReimportResource() throws Exception { final String TEST_NAME = "test031ReimportResource"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(AbstractImportTest.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -569,7 +560,6 @@ public void test031ReimportResource() throws Exception { @Test public void test032ImportResourceOidAndFilter() throws Exception { final String TEST_NAME = "test032ImportResourceOidAndFilter"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(AbstractImportTest.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -623,7 +613,6 @@ public void test032ImportResourceOidAndFilter() throws Exception { @Test public void test033ImportResourceDummyRuntime() throws Exception { final String TEST_NAME = "test033ImportResourceDummyRuntime"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(AbstractImportTest.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -662,7 +651,6 @@ public void test033ImportResourceDummyRuntime() throws Exception { @Test public void test040ImportUserHermanNoEncryption() throws Exception { final String TEST_NAME = "test040ImportUserHermanNoEncryption"; - displayTestTitle(TEST_NAME); // GIVEN InternalsConfig.readEncryptionChecks = false; @@ -709,7 +697,6 @@ public void test040ImportUserHermanNoEncryption() throws Exception { @Test public void test050ImportUserHermanOverwriteFullProcessing() throws Exception { final String TEST_NAME = "test050ImportUserHermanOverwriteFullProcessing"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(); @@ -754,7 +741,6 @@ public void test050ImportUserHermanOverwriteFullProcessing() throws Exception { @Test public void test060ImportConstrainedWrongFullProcessing() throws Exception { final String TEST_NAME = "test060ImportConstrainedWrongFullProcessing"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(); @@ -792,7 +778,6 @@ public void test060ImportConstrainedWrongFullProcessing() throws Exception { @Test public void test070ImportConstrainedWrong() throws Exception { final String TEST_NAME = "test070ImportConstrainedWrong"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(); @@ -828,7 +813,6 @@ public void test070ImportConstrainedWrong() throws Exception { @Test public void test100GoodRefImport() throws Exception { final String TEST_NAME = "test100GoodRefImport"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(); OperationResult result = new OperationResult(AbstractImportTest.class.getName() + "." +TEST_NAME); @@ -861,7 +845,6 @@ public void test100GoodRefImport() throws Exception { @Test public void test200BadImport() throws Exception { final String TEST_NAME = "test200BadImport"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(); OperationResult result = new OperationResult(AbstractImportTest.class.getName() + "." + TEST_NAME); @@ -893,7 +876,6 @@ public void test200BadImport() throws Exception { @Test public void test210ImportRoleOneLegacyDefault() throws Exception { final String TEST_NAME = "test210ImportRoleOneLegacyDefault"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(); OperationResult result = new OperationResult(AbstractImportTest.class.getName() + "." + TEST_NAME); @@ -918,7 +900,6 @@ public void test210ImportRoleOneLegacyDefault() throws Exception { @Test public void test212ImportRoleOneLegacyCompat() throws Exception { final String TEST_NAME = "test212ImportRoleOneLegacyCompat"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(); OperationResult result = new OperationResult(AbstractImportTest.class.getName() + "." + TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractDirectManualResourceTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractDirectManualResourceTest.java index c848740053c..06af0fa9f33 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractDirectManualResourceTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractDirectManualResourceTest.java @@ -13,6 +13,7 @@ import javax.xml.datatype.XMLGregorianCalendar; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.prism.xml.ns._public.types_3.RawType; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; @@ -125,7 +126,6 @@ protected boolean isDirect() { @Test public void test220ModifyUserWillDisable() throws Exception { final String TEST_NAME = "test220ModifyUserWillDisable"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -203,7 +203,6 @@ public void test220ModifyUserWillDisable() throws Exception { @Test public void test230ModifyAccountWillChangePasswordAndEnable() throws Exception { final String TEST_NAME = "test230ModifyAccountWillChangePasswordAndEnable"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -292,7 +291,6 @@ public void test230ModifyAccountWillChangePasswordAndEnable() throws Exception { @Test public void test240CloseDisableCaseAndReadAccountWill() throws Exception { final String TEST_NAME = "test240CloseDisableCaseAndReadAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -383,7 +381,6 @@ public void test240CloseDisableCaseAndReadAccountWill() throws Exception { @Test public void test250RecomputeWillAfter5min() throws Exception { final String TEST_NAME = "test250RecomputeWillAfter5min"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -471,7 +468,6 @@ public void test250RecomputeWillAfter5min() throws Exception { @Test public void test252UpdateBackingStoreAndGetAccountWill() throws Exception { final String TEST_NAME = "test252UpdateBackingStoreAndGetAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -530,7 +526,6 @@ public void test252UpdateBackingStoreAndGetAccountWill() throws Exception { @Test public void test260ClosePasswordChangeCaseAndRecomputeWill() throws Exception { final String TEST_NAME = "test260ClosePasswordChangeCaseAndRecomputeWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -635,7 +630,6 @@ public void test260ClosePasswordChangeCaseAndRecomputeWill() throws Exception { @Test public void test270RecomputeWillAfter7min() throws Exception { final String TEST_NAME = "test130RefreshAccountWillAfter7min"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -734,7 +728,6 @@ public void test270RecomputeWillAfter7min() throws Exception { @Test public void test272UpdateBackingStoreAndGetAccountWill() throws Exception { final String TEST_NAME = "test272UpdateBackingStoreAndGetAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -793,7 +786,6 @@ public void test272UpdateBackingStoreAndGetAccountWill() throws Exception { @Test public void test274RecomputeWillAfter22min() throws Exception { final String TEST_NAME = "test292RecomputeWillAfter22min"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -879,7 +871,6 @@ public void test274RecomputeWillAfter22min() throws Exception { @Test public void test280RecomputeWillAfter27min() throws Exception { final String TEST_NAME = "test280RecomputeWillAfter27min"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -953,7 +944,6 @@ public void test280RecomputeWillAfter27min() throws Exception { @Test public void test290RecomputeWillAfter32min() throws Exception { final String TEST_NAME = "test290RecomputeWillAfter32min"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1016,7 +1006,6 @@ public void test290RecomputeWillAfter32min() throws Exception { @Test public void test300UnassignAccountWill() throws Exception { final String TEST_NAME = "test300UnassignAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1093,7 +1082,6 @@ public void test300UnassignAccountWill() throws Exception { @Test public void test302RecomputeWill() throws Exception { final String TEST_NAME = "test302RecomputeWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1164,7 +1152,6 @@ public void test302RecomputeWill() throws Exception { @Test public void test310CloseCaseAndReconcileWill() throws Exception { final String TEST_NAME = "test310CloseCaseAndReconcileWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1230,7 +1217,6 @@ protected void assertUnassignedShadow(ShadowAsserter shadowModelAsserter, boo @Test public void test320RecomputeWillAfter5min() throws Exception { final String TEST_NAME = "test320RecomputeWillAfter5min"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1284,7 +1270,6 @@ public void test320RecomputeWillAfter5min() throws Exception { @Test public void test330UpdateBackingStoreAndRecomputeWill() throws Exception { final String TEST_NAME = "test330UpdateBackingStoreAndRecomputeWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1348,7 +1333,6 @@ public void test330UpdateBackingStoreAndRecomputeWill() throws Exception { @Test public void test340RecomputeWillAfter25min() throws Exception { final String TEST_NAME = "test340RecomputeWillAfter25min"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1390,7 +1374,6 @@ public void test340RecomputeWillAfter25min() throws Exception { @Test public void test342RecomputeWillAfter35min() throws Exception { final String TEST_NAME = "test342RecomputeWillAfter35min"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1429,7 +1412,6 @@ public void test342RecomputeWillAfter35min() throws Exception { @Test public void test344RecomputeWillAfter165min() throws Exception { final String TEST_NAME = "test344RecomputeWillAfter165min"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1468,7 +1450,6 @@ protected void assertDeprovisionedTimedOutUser(UserAsserter userAsserter, @Test public void test349CleanUp() throws Exception { final String TEST_NAME = "test349CleanUp"; - displayTestTitle(TEST_NAME); cleanupUser(TEST_NAME, userWillOid, USER_WILL_NAME, accountWillOid); } @@ -1496,7 +1477,6 @@ public void test500AssignWillRoleOne() throws Exception { @Test public void test510UnassignWillRoleOne() throws Exception { final String TEST_NAME = "test510UnassignWillRoleOne"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1567,7 +1547,6 @@ public void test510UnassignWillRoleOne() throws Exception { @Test public void test512ReconcileWill() throws Exception { final String TEST_NAME = "test512ReconcileWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1638,7 +1617,6 @@ public void test512ReconcileWill() throws Exception { @Test public void test515CloseCasesAndReconcileWill() throws Exception { final String TEST_NAME = "test515CloseCasesAndReconcileWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1739,7 +1717,6 @@ protected void assertWillUnassignPendingOperationCompleted(ShadowAsserter @Test public void test516RecomputeWillAfter20min() throws Exception { final String TEST_NAME = "test516RecomputeWillAfter20min"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1774,7 +1751,6 @@ public void test516RecomputeWillAfter20min() throws Exception { @Test public void test517RecomputeWillAfter50min() throws Exception { final String TEST_NAME = "test517RecomputeWillAfter50min"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1811,7 +1787,6 @@ public void test517RecomputeWillAfter50min() throws Exception { @Test public void test518RecomputeWillAfter180min() throws Exception { final String TEST_NAME = "test518RecomputeWillAfter180min"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1843,7 +1818,6 @@ public void test518RecomputeWillAfter180min() throws Exception { @Test public void test519CleanUp() throws Exception { final String TEST_NAME = "test519CleanUp"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1874,7 +1848,6 @@ public void test520AssignWillRoleOne() throws Exception { @Test public void test522AssignWillRoleTwoValidFrom() throws Exception { final String TEST_NAME = "test522AssignWillRoleTwoValidFrom"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1908,7 +1881,6 @@ public void test522AssignWillRoleTwoValidFrom() throws Exception { @Test public void test524TwoHoursForRoleTwo() throws Exception { final String TEST_NAME = "test524TwoHoursForRoleTwo"; - displayTestTitle(TEST_NAME); // GIVEN clockForward("PT2H5M"); @@ -1977,7 +1949,6 @@ public void test524TwoHoursForRoleTwo() throws Exception { @Test public void test525CloseCasesAndReconcileWill() throws Exception { final String TEST_NAME = "test525CloseCasesAndReconcileWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2015,7 +1986,6 @@ public void test525CloseCasesAndReconcileWill() throws Exception { @Test public void test526UnassignWillBothRoles() throws Exception { final String TEST_NAME = "test526UnassignWillBothRoles"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2075,7 +2045,6 @@ protected void assertTest526Deltas(PrismObject shadowRepo, Operation @Test public void test528CloseCaseAndRecomputeWill() throws Exception { final String TEST_NAME = "test528CloseCaseAndRecomputeWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2135,7 +2104,6 @@ protected void assertTest528Deltas(PrismObject shadowRepo, Operation @Test public void test529CleanUp() throws Exception { final String TEST_NAME = "test529CleanUp"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2158,7 +2126,6 @@ public void test529CleanUp() throws Exception { @Test public void test800ImportShadowRefreshTask() throws Exception { final String TEST_NAME = "test800ImportShadowRefreshTask"; - displayTestTitle(TEST_NAME); // GIVEN // WHEN @@ -2197,7 +2164,6 @@ public void test810AssignAccountWill() throws Exception { @Test public void test820AssignAccountJack() throws Exception { final String TEST_NAME = "test820AssignAccountJack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2235,7 +2201,6 @@ public void test820AssignAccountJack() throws Exception { @Test public void test830CloseCaseWillAndWaitForRefresh() throws Exception { final String TEST_NAME = "test830CloseCaseWillAndWaitForRefresh"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2263,7 +2228,6 @@ public void test830CloseCaseWillAndWaitForRefresh() throws Exception { @Test public void test840AddToBackingStoreAndGetAccountWill() throws Exception { final String TEST_NAME = "test840AddToBackingStoreAndGetAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractGroupingManualResourceTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractGroupingManualResourceTest.java index 0cf5d561b6d..ad6e3a582f2 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractGroupingManualResourceTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractGroupingManualResourceTest.java @@ -163,7 +163,6 @@ public void test100AssignWillRoleOne() throws Exception { @Test public void test220ModifyUserWillDisable() throws Exception { final String TEST_NAME = "test220ModifyUserWillDisable"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -244,7 +243,6 @@ public void test220ModifyUserWillDisable() throws Exception { @Test public void test230ModifyAccountWillChangePasswordAndEnable() throws Exception { final String TEST_NAME = "test230ModifyAccountWillChangePasswordAndEnable"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -338,7 +336,6 @@ protected void assertAccountWillAfterChangePasswordAndEnable(final String TEST_N @Test public void test232RunPropagationBeforeInterval() throws Exception { final String TEST_NAME = "test235RunPropagationAfterInterval"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -360,7 +357,6 @@ public void test232RunPropagationBeforeInterval() throws Exception { @Test public void test235RunPropagationAfterInterval() throws Exception { final String TEST_NAME = "test235RunPropagationAfterInterval"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -468,7 +464,6 @@ public void test235RunPropagationAfterInterval() throws Exception { @Test public void test240CloseCaseAndReadAccountWill() throws Exception { final String TEST_NAME = "test240CloseCaseAndReadAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -498,7 +493,6 @@ public void test240CloseCaseAndReadAccountWill() throws Exception { @Test public void test250RecomputeWillAfter5min() throws Exception { final String TEST_NAME = "test250RecomputeWillAfter5min"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -526,7 +520,6 @@ public void test250RecomputeWillAfter5min() throws Exception { @Test public void test272UpdateBackingStoreAndGetAccountWill() throws Exception { final String TEST_NAME = "test272UpdateBackingStoreAndGetAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -584,7 +577,6 @@ public void test272UpdateBackingStoreAndGetAccountWill() throws Exception { @Test public void test273GetAccountWill() throws Exception { final String TEST_NAME = "test273GetAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -640,7 +632,6 @@ public void test273GetAccountWill() throws Exception { @Test public void test290RecomputeWillAfter15min() throws Exception { final String TEST_NAME = "test290RecomputeWillAfter15min"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -700,7 +691,6 @@ public void test290RecomputeWillAfter15min() throws Exception { @Test public void test300UnassignAccountWill() throws Exception { final String TEST_NAME = "test300UnassignAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -776,7 +766,6 @@ public void test300UnassignAccountWill() throws Exception { @Test public void test302RunPropagationAfterInterval() throws Exception { final String TEST_NAME = "test302RunPropagationAfterInterval"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -852,7 +841,6 @@ public void test302RunPropagationAfterInterval() throws Exception { @Test public void test310CloseCaseAndRecomputeWill() throws Exception { final String TEST_NAME = "test310CloseCaseAndRecomputeWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -904,7 +892,6 @@ public void test310CloseCaseAndRecomputeWill() throws Exception { @Test public void test330UpdateBackingStoreAndRecomputeWill() throws Exception { final String TEST_NAME = "test330UpdateBackingStoreAndRecomputeWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -953,7 +940,6 @@ public void test330UpdateBackingStoreAndRecomputeWill() throws Exception { @Test public void test349CleanUp() throws Exception { final String TEST_NAME = "test349CleanUp"; - displayTestTitle(TEST_NAME); cleanupUser(TEST_NAME, userWillOid, USER_WILL_NAME, accountWillOid); } diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractManualResourceTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractManualResourceTest.java index af9bafe83b3..ee9a8e86e04 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractManualResourceTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractManualResourceTest.java @@ -267,7 +267,6 @@ protected boolean hasMultivalueInterests() { @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); OperationResult result = new OperationResult(AbstractManualResourceTest.class.getName() + "." + TEST_NAME); @@ -299,7 +298,6 @@ public void test012TestConnection() throws Exception { } public void testConnection(final String TEST_NAME, boolean initialized) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -377,7 +375,6 @@ protected boolean nativeCapabilitiesEntered() { @Test public void test014Configuration() throws Exception { final String TEST_NAME = "test014Configuration"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(AbstractManualResourceTest.class.getName() + "." + TEST_NAME); @@ -403,7 +400,6 @@ public void test014Configuration() throws Exception { @Test public void test016ParsedSchema() throws Exception { final String TEST_NAME = "test016ParsedSchema"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(AbstractManualResourceTest.class.getName() + "." + TEST_NAME); @@ -455,7 +451,6 @@ public void test017Capabilities() throws Exception { } public void testCapabilities(final String TEST_NAME) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(AbstractManualResourceTest.class.getName()+"."+TEST_NAME); @@ -505,7 +500,6 @@ public void test018ResourceCaching() throws Exception { } public void testResourceCaching(final String TEST_NAME) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -539,7 +533,6 @@ public void testResourceCaching(final String TEST_NAME) throws Exception { @Test public void test020ReimportResource() throws Exception { final String TEST_NAME = "test020ReimportResource"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -580,7 +573,6 @@ public void test028ResourceCaching() throws Exception { @Test public void test030ReimportResourceAgain() throws Exception { final String TEST_NAME = "test030ReimportResourceAgain"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -601,7 +593,6 @@ public void test030ReimportResourceAgain() throws Exception { @Test public void test032UseResource() throws Exception { final String TEST_NAME = "test032UseResource"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -694,7 +685,6 @@ public void test100AssignWillRoleOne() throws Exception { @Test public void test101GetAccountWillFuture() throws Exception { final String TEST_NAME = "test101GetAccountWillFuture"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -728,7 +718,6 @@ public void test101GetAccountWillFuture() throws Exception { @Test public void test102RecomputeWill() throws Exception { final String TEST_NAME = "test102RecomputeWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -752,7 +741,6 @@ public void test102RecomputeWill() throws Exception { @Test public void test103RunPropagation() throws Exception { final String TEST_NAME = "test103RunPropagation"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -779,7 +767,6 @@ public void test103RunPropagation() throws Exception { @Test public void test104RecomputeWill() throws Exception { final String TEST_NAME = "test104RecomputeWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -807,7 +794,6 @@ public void test104RecomputeWill() throws Exception { public void test105RunPropagationAgain() throws Exception { final String TEST_NAME = "test105RunPropagationAgain"; - displayTestTitle(TEST_NAME); // GIVEN rememberCounter(InternalCounters.CONNECTOR_MODIFICATION_COUNT); @@ -831,7 +817,6 @@ public void test105RunPropagationAgain() throws Exception { @Test public void test106AddToBackingStoreAndGetAccountWill() throws Exception { final String TEST_NAME = "test106AddToBackingStoreAndGetAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -876,7 +861,6 @@ public void test106AddToBackingStoreAndGetAccountWill() throws Exception { @Test public void test108GetAccountWillFuture() throws Exception { final String TEST_NAME = "test108GetAccountWillFuture"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -924,7 +908,6 @@ public void test108GetAccountWillFuture() throws Exception { @Test public void test110CloseCaseAndRecomputeWill() throws Exception { final String TEST_NAME = "test110CloseCaseAndRecomputeWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -957,7 +940,6 @@ public void test110CloseCaseAndRecomputeWill() throws Exception { public void test114RunPropagation() throws Exception { final String TEST_NAME = "test114RunPropagation"; - displayTestTitle(TEST_NAME); // GIVEN rememberCounter(InternalCounters.CONNECTOR_MODIFICATION_COUNT); @@ -980,7 +962,6 @@ public void test114RunPropagation() throws Exception { @Test public void test120RecomputeWillAfter5min() throws Exception { final String TEST_NAME = "test120RecomputeWillAfter5min"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1023,7 +1004,6 @@ public void test120RecomputeWillAfter5min() throws Exception { @Test public void test130RecomputeWillAfter25min() throws Exception { final String TEST_NAME = "test130RecomputeWillAfter25min"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1066,7 +1046,6 @@ public void test130RecomputeWillAfter25min() throws Exception { @Test public void test132RecomputeWillAfter32min() throws Exception { final String TEST_NAME = "test132RecomputeWillAfter32min"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1097,7 +1076,6 @@ public void test132RecomputeWillAfter32min() throws Exception { @Test public void test200ModifyUserWillFullname() throws Exception { final String TEST_NAME = "test200ModifyUserWillFullname"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1128,7 +1106,6 @@ public void test200ModifyUserWillFullname() throws Exception { @Test public void test202RecomputeWill() throws Exception { final String TEST_NAME = "test202RecomputeWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1149,7 +1126,6 @@ public void test202RecomputeWill() throws Exception { @Test public void test203RunPropagation() throws Exception { final String TEST_NAME = "test203RunPropagation"; - displayTestTitle(TEST_NAME); // GIVEN clockForward("PT2M"); @@ -1169,7 +1145,6 @@ public void test203RunPropagation() throws Exception { @Test public void test204RecomputeWill() throws Exception { final String TEST_NAME = "test204RecomputeWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1193,7 +1168,6 @@ public void test204RecomputeWill() throws Exception { @Test public void test206CloseCaseAndRecomputeWill() throws Exception { final String TEST_NAME = "test206CloseCaseAndRecomputeWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1271,7 +1245,6 @@ public void test206CloseCaseAndRecomputeWill() throws Exception { @Test public void test210RecomputeWillAfter5min() throws Exception { final String TEST_NAME = "test210RecomputeWillAfter5min"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1331,7 +1304,6 @@ public void test210RecomputeWillAfter5min() throws Exception { @Test public void test212UpdateBackingStoreAndGetAccountWill() throws Exception { final String TEST_NAME = "test212UpdateBackingStoreAndGetAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1393,7 +1365,6 @@ public void test212UpdateBackingStoreAndGetAccountWill() throws Exception { @Test public void test400PhantomAccount() throws Exception { final String TEST_NAME = "test400PhantomAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1467,7 +1438,6 @@ protected void setupPhantom(final String TEST_NAME) throws Exception { @Test public void test410AssignPhoenixAccount() throws Exception { final String TEST_NAME = "test410AssignPhoenixAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1514,7 +1484,6 @@ public void test410AssignPhoenixAccount() throws Exception { @Test public void test412AddPhoenixToBackingStoreAndCloseTicket() throws Exception { final String TEST_NAME = "test412AddPhoenixToBackingStoreAndCloseTicket"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1553,7 +1522,6 @@ public void test412AddPhoenixToBackingStoreAndCloseTicket() throws Exception { @Test public void test413PhoenixLetOperationsExpire() throws Exception { final String TEST_NAME = "test413PhoenixLetOperationsExpire"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1591,7 +1559,6 @@ public void test413PhoenixLetOperationsExpire() throws Exception { @Test public void test414UnassignPhoenixAccount() throws Exception { final String TEST_NAME = "test414UnassignPhoenixAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1635,7 +1602,6 @@ public void test414UnassignPhoenixAccount() throws Exception { @Test public void test416PhoenixAccountUnassignCloseCase() throws Exception { final String TEST_NAME = "test416PhoenixAccountUnassignCloseCase"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1683,7 +1649,6 @@ public void test416PhoenixAccountUnassignCloseCase() throws Exception { @Test public void test418AssignPhoenixAccountAgain() throws Exception { final String TEST_NAME = "test418AssignPhoenixAccountAgain"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1768,7 +1733,6 @@ protected int getConcurrentTestRandomStartDelayRangeUnassign() { @Test public void test900SetUpRoles() throws Exception { final String TEST_NAME = "test900SetUpRoles"; - displayTestTitle(TEST_NAME); if (!are9xxTestsEnabled()) { displaySkip(TEST_NAME); return; @@ -1819,7 +1783,6 @@ protected String getRoleInterest(int i) { @Test public void test910ConcurrentRolesAssign() throws Exception { final String TEST_NAME = "test910ConcurrentRolesAssign"; - displayTestTitle(TEST_NAME); if (!are9xxTestsEnabled()) { displaySkip(TEST_NAME); return; @@ -1898,7 +1861,6 @@ protected void assertTest910ShadowRepo(PrismObject shadowRepo, Task @Test public void test919ConcurrentRoleUnassign() throws Exception { final String TEST_NAME = "test919ConcurrentRoleUnassign"; - displayTestTitle(TEST_NAME); if (!are9xxTestsEnabled()) { displaySkip(TEST_NAME); return; @@ -2100,7 +2062,6 @@ protected void backingStoreAddPhoenix() throws IOException { } protected void assignWillRoleOne(final String TEST_NAME, String expectedFullName, PendingOperationExecutionStatusType executionStage) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestDummyItsmIntegration.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestDummyItsmIntegration.java index b8df20c3fb6..97e541fc411 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestDummyItsmIntegration.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestDummyItsmIntegration.java @@ -28,6 +28,7 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.result.OperationResultStatus; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.CommunicationException; @@ -98,7 +99,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); OperationResult result = new OperationResult(TestDummyItsmIntegration.class.getName() + "." + TEST_NAME); @@ -121,7 +121,6 @@ public void test000Sanity() throws Exception { @Test public void test012TestConnection() throws Exception { final String TEST_NAME = "test012TestConnection"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -150,7 +149,6 @@ public void test012TestConnection() throws Exception { @Test public void test100AssignAccountToJack() throws Exception { final String TEST_NAME = "test100AssignAccountToJack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -180,7 +178,6 @@ public void test100AssignAccountToJack() throws Exception { @Test public void test102CloseTicketAndRecomputeJack() throws Exception { final String TEST_NAME = "test102CloseTicketAndRecomputeJack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -207,7 +204,6 @@ public void test102CloseTicketAndRecomputeJack() throws Exception { @Test public void test104UnassignAccountFromJack() throws Exception { final String TEST_NAME = "test104UnassignAccountFromJack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -238,7 +234,6 @@ public void test104UnassignAccountFromJack() throws Exception { @Test public void test108CloseTicketAndRecomputeJack() throws Exception { final String TEST_NAME = "test108CloseTicketAndRecomputeJack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -275,7 +270,6 @@ public void test108CloseTicketAndRecomputeJack() throws Exception { @Test public void test109LetItExpire() throws Exception { final String TEST_NAME = "test109LetItExpire"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -300,7 +294,6 @@ public void test109LetItExpire() throws Exception { @Test public void test110AssignItsmAccountToJackCommunicationError() throws Exception { final String TEST_NAME = "test110AssignItsmAccountToJackCommunicationError"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -336,7 +329,6 @@ public void test110AssignItsmAccountToJackCommunicationError() throws Exception @Test public void test111ReconcileJackFixed() throws Exception { final String TEST_NAME = "test111ReconcileJackFixed"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -381,7 +373,6 @@ public void test111ReconcileJackFixed() throws Exception { @Test public void test112CloseTicketAndRecomputeJackCommunicationError() throws Exception { final String TEST_NAME = "test112CloseTicketAndRecomputeJackCommunicationError"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -419,7 +410,6 @@ public void test112CloseTicketAndRecomputeJackCommunicationError() throws Except @Test public void test113RecomputeJackFixed() throws Exception { final String TEST_NAME = "test113RecomputeJackFixed"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -454,7 +444,6 @@ public void test113RecomputeJackFixed() throws Exception { @Test public void test114UnassignAccountFromJackCommunicationError() throws Exception { final String TEST_NAME = "test114UnassignAccountFromJackCommunicationError"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -507,7 +496,6 @@ public void test114UnassignAccountFromJackCommunicationError() throws Exception @Test public void test115ReconcileJackFixed() throws Exception { final String TEST_NAME = "test115ReconcileJackFixed"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -552,7 +540,6 @@ public void test115ReconcileJackFixed() throws Exception { @Test public void test117CloseTicketAndRecomputeJackCommunicationError() throws Exception { final String TEST_NAME = "test117CloseTicketAndRecomputeJackCommunicationError"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -590,7 +577,6 @@ public void test117CloseTicketAndRecomputeJackCommunicationError() throws Except @Test public void test118RecomputeJackFixed() throws Exception { final String TEST_NAME = "test118RecomputeJackFixed"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -632,7 +618,6 @@ public void test118RecomputeJackFixed() throws Exception { @Test public void test119LetItExpire() throws Exception { final String TEST_NAME = "test119LetItExpire"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManual.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManual.java index 2daf60c980b..5bbe839880b 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManual.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManual.java @@ -117,7 +117,6 @@ protected int getNumberOfAccountAttributeDefinitions() { @Test public void test700AssignAccountJackExisting() throws Exception { final String TEST_NAME = "test700AssignAccountJack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -177,7 +176,6 @@ public void test700AssignAccountJackExisting() throws Exception { @Test public void test710UnassignAccountJack() throws Exception { final String TEST_NAME = "test710UnassignAccountJack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -233,7 +231,6 @@ public void test710UnassignAccountJack() throws Exception { @Test public void test712CloseCaseAndRecomputeJack() throws Exception { final String TEST_NAME = "test712CloseCaseAndRecomputeJack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -291,7 +288,6 @@ public void test712CloseCaseAndRecomputeJack() throws Exception { @Test public void test717RecomputeJackAfter130min() throws Exception { final String TEST_NAME = "test717RecomputeJackAfter130min"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -321,7 +317,6 @@ public void test717RecomputeJackAfter130min() throws Exception { @Test public void test719CleanUp() throws Exception { final String TEST_NAME = "test719CleanUp"; - displayTestTitle(TEST_NAME); cleanupUser(TEST_NAME, USER_JACK_OID, USER_JACK_USERNAME, accountJackOid); } diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualDisable.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualDisable.java index bce5a3883a1..98055435221 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualDisable.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualDisable.java @@ -21,6 +21,7 @@ import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.asserter.ShadowAsserter; import com.evolveum.midpoint.test.asserter.UserAsserter; import com.evolveum.midpoint.util.exception.ObjectNotFoundException; @@ -176,7 +177,6 @@ protected void cleanupUser(final String TEST_NAME, String userOid, String userna @Override public void test416PhoenixAccountUnassignCloseCase() throws Exception { final String TEST_NAME = "test416PhoenixAccountUnassignCloseCase"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -222,7 +222,6 @@ public void test416PhoenixAccountUnassignCloseCase() throws Exception { @Override public void test418AssignPhoenixAccountAgain() throws Exception { final String TEST_NAME = "test418AssignPhoenixAccountAgain"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGrouping.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGrouping.java index f491c6e778d..be7f6f14269 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGrouping.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGrouping.java @@ -28,6 +28,7 @@ import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.asserter.ShadowAsserter; import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.PendingOperationExecutionStatusType; @@ -123,7 +124,6 @@ protected void assertShadowPassword(PrismObject shadow) { @Override public void test400PhantomAccount() throws Exception { final String TEST_NAME = "test400PhantomAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGroupingProposed.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGroupingProposed.java index aeaca01531f..15a396162b9 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGroupingProposed.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGroupingProposed.java @@ -15,6 +15,7 @@ import java.io.File; import com.evolveum.midpoint.prism.query.FilterUtil; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.prism.xml.ns._public.types_3.RawType; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; @@ -76,7 +77,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test020ResourcesSanity() throws Exception { final String TEST_NAME = "test020ResourcesSanity"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -120,7 +120,6 @@ protected void assertFinishedPropagationTask(Task finishedTask, OperationResultS @Test public void test500AssignBigmouthRoleOne() throws Exception { final String TEST_NAME = "test500AssignBigmouthRoleOne"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -177,7 +176,6 @@ public void test500AssignBigmouthRoleOne() throws Exception { @Test public void test502RunPropagation() throws Exception { final String TEST_NAME = "test502RunPropagation"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingAutoInbound.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingAutoInbound.java index d0e8271ad8e..4e8fa32168a 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingAutoInbound.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingAutoInbound.java @@ -14,6 +14,7 @@ import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType; @@ -64,7 +65,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100ImportFromResource() throws Exception { final String TEST_NAME = "test100ImportFromResource"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -113,7 +113,6 @@ public void test100ImportFromResource() throws Exception { @Test public void test110ModifyAccountTitleCraticAndReconcile() throws Exception { final String TEST_NAME = "test110ModifyAccountTitleCraticAndReconcile"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -142,7 +141,6 @@ public void test110ModifyAccountTitleCraticAndReconcile() throws Exception { @Test public void test112ModifyAccountTitleDidacticGraphicAndReconcile() throws Exception { final String TEST_NAME = "test112ModifyAccountTitleDidacticGraphicAndReconcile"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -173,7 +171,6 @@ public void test112ModifyAccountTitleDidacticGraphicAndReconcile() throws Except @Test public void test200ImportFromResourceAssociations() throws Exception { final String TEST_NAME = "test200ImportFromResourceAssociations"; - displayTestTitle(TEST_NAME); assumeResourceAssigmentPolicy(RESOURCE_DUMMY_AUTOGREEN_OID, AssignmentPolicyEnforcementType.RELATIVE, false); @@ -224,7 +221,6 @@ public void test200ImportFromResourceAssociations() throws Exception { @Test public void test300ModifyAccountDirectAssign() throws Exception { final String TEST_NAME = "test300ModifyAccountDirectAssign"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -252,7 +248,6 @@ public void test300ModifyAccountDirectAssign() throws Exception { @Test public void test301removeUserFromAutoGroup() throws Exception { final String TEST_NAME = "test301removeUserFromAutoGroup"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -299,7 +294,6 @@ public void test301removeUserFromAutoGroup() throws Exception { @Test public void test402assignAutoGroupDirectly() throws Exception { final String TEST_NAME = "test402assignAutoGroupDirectly"; - displayTestTitle(TEST_NAME); DummyGroup craticGroup = getDummyResource(RESOURCE_DUMMY_AUTOGREEN_NAME).getGroupByName(GROUP_DUMMY_CRATIC_NAME); craticGroup.removeMember(USER_HERMAN_USERNAME); @@ -336,7 +330,6 @@ public void test402assignAutoGroupDirectly() throws Exception { @Test public void test403removeAllAssignments() throws Exception { final String TEST_NAME = "test403removeAllAssignments"; - displayTestTitle(TEST_NAME); DummyGroup testersGroup = getDummyResource(RESOURCE_DUMMY_AUTOGREEN_NAME).getGroupByName(GROUP_DUMMY_TESTERS_NAME); testersGroup.removeMember(USER_HERMAN_USERNAME); @@ -365,7 +358,6 @@ public void test403removeAllAssignments() throws Exception { @Test public void test404importAssociationAutotesters() throws Exception { final String TEST_NAME = "test404importAssociationAutotesters"; - displayTestTitle(TEST_NAME); assumeResourceAssigmentPolicy(RESOURCE_DUMMY_AUTOGREEN_OID, AssignmentPolicyEnforcementType.FULL, true); @@ -403,7 +395,6 @@ public void test404importAssociationAutotesters() throws Exception { @Test public void test405assignRoleAutocraticDirectly() throws Exception { final String TEST_NAME = "test405assignRoleAutocraticDirectly"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); // GIVEN @@ -431,7 +422,6 @@ public void test405assignRoleAutocraticDirectly() throws Exception { @Test public void test406unassignRoleAutocraticDirectly() throws Exception { final String TEST_NAME = "test406unassignRoleAutocraticAutotestersDirectly"; - displayTestTitle(TEST_NAME); assumeResourceAssigmentPolicy(RESOURCE_DUMMY_AUTOGREEN_OID, AssignmentPolicyEnforcementType.FULL, true); @@ -460,7 +450,6 @@ public void test406unassignRoleAutocraticDirectly() throws Exception { @Test public void test407addHermanToTestersReconcile() throws Exception { final String TEST_NAME = "test407addHermanToTestersReconcile"; - displayTestTitle(TEST_NAME); assumeResourceAssigmentPolicy(RESOURCE_DUMMY_AUTOGREEN_OID, AssignmentPolicyEnforcementType.FULL, true); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingInbound.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingInbound.java index 000c53a5047..b9625946651 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingInbound.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingInbound.java @@ -7,9 +7,7 @@ package com.evolveum.midpoint.model.intest.mapping; import com.evolveum.icf.dummy.resource.DummyAccount; -import com.evolveum.icf.dummy.resource.DummyResource; import com.evolveum.icf.dummy.resource.DummySyncStyle; -import com.evolveum.midpoint.audit.api.AuditEventStage; import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl; import com.evolveum.midpoint.model.api.ModelExecuteOptions; import com.evolveum.midpoint.prism.PrismObject; @@ -23,10 +21,8 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.DummyResourceContoller; -import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.asserter.UserAsserter; import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.MiscUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; @@ -96,7 +92,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test010SanitySchema() throws Exception { final String TEST_NAME = "test010SanitySchema"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -124,7 +119,6 @@ public void test010SanitySchema() throws Exception { @Test public void test100ImportLiveSyncTaskDummyTeaGreen() throws Exception { final String TEST_NAME = "test100ImportLiveSyncTaskDummyTeaGreen"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -143,7 +137,6 @@ public void test100ImportLiveSyncTaskDummyTeaGreen() throws Exception { @Test public void test110AddDummyTeaGreenAccountMancomb() throws Exception { final String TEST_NAME = "test110AddDummyTeaGreenAccountMancomb"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -205,7 +198,6 @@ public void test110AddDummyTeaGreenAccountMancomb() throws Exception { @Test public void test120ModifyMancombPhotoSource() throws Exception { final String TEST_NAME = "test120ModifyMancombPhotoSource"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -241,7 +233,6 @@ public void test120ModifyMancombPhotoSource() throws Exception { @Test public void test130ModifyMancombPhotoSourceAndReconcile() throws Exception { final String TEST_NAME = "test130ModifyMancombPhotoSourceAndReconcile"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -281,7 +272,6 @@ public void test130ModifyMancombPhotoSourceAndReconcile() throws Exception { @Test public void test140ModifyMancombPhotoInRepo() throws Exception { final String TEST_NAME = "test140ModifyMancombPhotoInRepo"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -318,7 +308,6 @@ public void test140ModifyMancombPhotoInRepo() throws Exception { @Test public void test150UserReconcile() throws Exception { final String TEST_NAME = "test150UserReconcile"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -377,7 +366,6 @@ public void test150UserReconcile() throws Exception { @Test public void test300DeleteDummyTeaGreenAccountMancomb() throws Exception { final String TEST_NAME = "test300DeleteDummyTeaGreenAccountMancomb"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -416,7 +404,6 @@ public void test300DeleteDummyTeaGreenAccountMancomb() throws Exception { @Test public void test399DeleteDummyTeaGreenAccountMancomb() throws Exception { final String TEST_NAME = "test399DeleteDummyTeaGreenAccountMancomb"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -435,7 +422,6 @@ public void test399DeleteDummyTeaGreenAccountMancomb() throws Exception { @Test public void test400AddUserLeeloo() throws Exception { final String TEST_NAME = "test400AddUserLeeloo"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -489,7 +475,6 @@ public void test400AddUserLeeloo() throws Exception { @Test public void test402UserLeelooRecompute() throws Exception { final String TEST_NAME = "test402UserLeelooRecompute"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -523,7 +508,6 @@ public void test402UserLeelooRecompute() throws Exception { @Test public void test404UserLeelooReconcile() throws Exception { final String TEST_NAME = "test404UserLeelooReconcile"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -561,7 +545,6 @@ public void test404UserLeelooReconcile() throws Exception { @Test public void test410UserLeeloominaiReconcile() throws Exception { final String TEST_NAME = "test410UserLeeloominaiReconcile"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -604,7 +587,6 @@ public void test410UserLeeloominaiReconcile() throws Exception { @Test public void test412UserLeeloominaiRecompute() throws Exception { final String TEST_NAME = "test412UserLeeloominaiRecompute"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -638,7 +620,6 @@ public void test412UserLeeloominaiRecompute() throws Exception { @Test public void test414UserLeeloominaiReconcile() throws Exception { final String TEST_NAME = "test414UserLeeloominaiReconcile"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -676,7 +657,6 @@ public void test414UserLeeloominaiReconcile() throws Exception { @Test public void test420UserLeelooStrangeReconcile() throws Exception { final String TEST_NAME = "test420UserLeelooStrangeReconcile"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -720,7 +700,6 @@ public void test420UserLeelooStrangeReconcile() throws Exception { @Test public void test424UserLeelooStrangeReconcile() throws Exception { final String TEST_NAME = "test424UserLeelooStrangeReconcile"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestMigration.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestMigration.java index fe4b9d3ea08..b26a2914ed3 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestMigration.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestMigration.java @@ -59,7 +59,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test050SanityLost1() throws Exception { final String TEST_NAME = "test050SanityLost1"; - displayTestTitle(TEST_NAME); // WHEN displayWhen(TEST_NAME); @@ -79,7 +78,6 @@ public void test050SanityLost1() throws Exception { @Test public void test100RefreshTaskDefault() throws Exception { final String TEST_NAME = "test100RefreshTaskDefault"; - displayTestTitle(TEST_NAME); addObject(TASK_SHADOW_REFRESH_FILE); @@ -104,7 +102,6 @@ public void test100RefreshTaskDefault() throws Exception { @Test public void test110RefreshTaskExplicitDummy() throws Exception { final String TEST_NAME = "test110RefreshTaskExplicitDummy"; - displayTestTitle(TEST_NAME); addObject(TASK_SHADOW_REFRESH_EXPLICIT_DUMMY_FILE); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestMisc.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestMisc.java index aedbffae1aa..70160b9ceff 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestMisc.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestMisc.java @@ -92,7 +92,6 @@ public void initSystem(Task initTask, OperationResult initResult) @Test public void test100GetRepositoryDiag() throws Exception { final String TEST_NAME = "test100GetRepositoryDiag"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -115,7 +114,6 @@ public void test100GetRepositoryDiag() throws Exception { @Test public void test110RepositorySelfTest() throws Exception { final String TEST_NAME = "test110RepositorySelfTest"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -135,7 +133,6 @@ public void test110RepositorySelfTest() throws Exception { @Test public void test200ExportUsers() throws Exception { final String TEST_NAME = "test200ExportUsers"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -178,7 +175,6 @@ public void test200ExportUsers() throws Exception { @Test public void test210SearchUsersMatchingRulesPolystringNorm() throws Exception { final String TEST_NAME = "test210SearchUsersMatchingRulesPolystringNorm"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -212,7 +208,6 @@ public void test210SearchUsersMatchingRulesPolystringNorm() throws Exception { @Test public void test212SearchUsersMatchingRulesPolystringIgnoreCase() throws Exception { final String TEST_NAME = "test212SearchUsersMatchingRulesPolystringIgnoreCase"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -242,7 +237,6 @@ public void test212SearchUsersMatchingRulesPolystringIgnoreCase() throws Excepti @Test public void test214SearchUsersMatchingRulesStringIgnoreCase() throws Exception { final String TEST_NAME = "test214SearchUsersMatchingRulesStringIgnoreCase"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -276,7 +270,6 @@ public void test214SearchUsersMatchingRulesStringIgnoreCase() throws Exception { @Test public void test216SearchUsersMatchingRulesStringNorm() throws Exception { final String TEST_NAME = "test216SearchUsersMatchingRulesStringNorm"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -306,7 +299,6 @@ public void test216SearchUsersMatchingRulesStringNorm() throws Exception { @Test public void test300RecomputeJack() throws Exception { final String TEST_NAME = "test300RecomputeJack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -331,7 +323,6 @@ public void test300RecomputeJack() throws Exception { @Test public void test302UpdateKeyJack() throws Exception { final String TEST_NAME = "test302UpdateKeyJack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -353,7 +344,6 @@ public void test302UpdateKeyJack() throws Exception { @Test public void test310AddUserClean() throws Exception { final String TEST_NAME = "test310AddUserClean"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -382,7 +372,6 @@ public void test310AddUserClean() throws Exception { @Test public void test312UpdateBinaryIdClean() throws Exception { final String TEST_NAME = "test312UpdateBinaryIdClean"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -407,7 +396,6 @@ public void test312UpdateBinaryIdClean() throws Exception { @Test public void test320DefaultRelations() throws Exception { final String TEST_NAME="test320DefaultRelations"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -430,7 +418,6 @@ public void test320DefaultRelations() throws Exception { @Test public void test400ImportRoleWithFilters() throws Exception { final String TEST_NAME = "test400ImportRoleWithFilters"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -455,7 +442,6 @@ public void test400ImportRoleWithFilters() throws Exception { @Test public void test500AddHocProvisioningScriptAssignJackResourceScripty() throws Exception { final String TEST_NAME = "test500AddHocProvisioningScriptAssignJackResourceScripty"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -489,7 +475,6 @@ public void test500AddHocProvisioningScriptAssignJackResourceScripty() throws Ex @Test public void test502GetAccountJackResourceScripty() throws Exception { final String TEST_NAME = "test502GetAccountJackResourceScripty"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -522,7 +507,6 @@ public void test502GetAccountJackResourceScripty() throws Exception { @Test public void test504GetAccountJackResourceScriptyAgain() throws Exception { final String TEST_NAME = "test504GetAccountJackResourceScriptyAgain"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -560,7 +544,6 @@ public void test504GetAccountJackResourceScriptyAgain() throws Exception { @Test public void test506ModifyResourceGetAccountJackResourceScripty() throws Exception { final String TEST_NAME = "test506ModifyResourceGetAccountJackResourceScripty"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -605,7 +588,6 @@ public void test506ModifyResourceGetAccountJackResourceScripty() throws Exceptio @Test public void test600jackAssignRoleShip() throws Exception { final String TEST_NAME = "test600jackAssignRoleShip"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -635,7 +617,6 @@ public void test600jackAssignRoleShip() throws Exception { @Test public void test601jackUnassignResourceAccount() throws Exception { final String TEST_NAME = "test601jackUnassignResourceAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -666,7 +647,6 @@ public void test601jackUnassignResourceAccount() throws Exception { @Test public void test602jackUnssigndRoleShip() throws Exception { final String TEST_NAME = "test602jackUnssigndRoleShip"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestUuidNonUniqueName.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestUuidNonUniqueName.java index 0ccfb204bb2..c942c450f17 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestUuidNonUniqueName.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestUuidNonUniqueName.java @@ -39,6 +39,7 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.ShadowUtil; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DOMUtil; @@ -88,7 +89,6 @@ public void initSystem(Task initTask, OperationResult initResult) @Test public void test010TestResourceConnection() throws Exception { final String TEST_NAME = "test010TestResourceConnection"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -109,7 +109,6 @@ public void test010TestResourceConnection() throws Exception { @Test public void test020RefinedSchema() throws Exception { final String TEST_NAME = "test020RefinedSchema"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -144,7 +143,6 @@ public void test020RefinedSchema() throws Exception { @Test public void test100AssignAccountToJackSparrow() throws Exception { final String TEST_NAME = "test100AssignAccountToJackSparrow"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -177,7 +175,6 @@ public void test100AssignAccountToJackSparrow() throws Exception { @Test public void test102GetAccountJackSparrow() throws Exception { final String TEST_NAME = "test102GetAccountJackSparrow"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -210,7 +207,6 @@ public void test102GetAccountJackSparrow() throws Exception { @Test public void test110AssignAccountToJackSkellington() throws Exception { final String TEST_NAME = "test110AssignAccountToJackSkellington"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiAccount.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiAccount.java index 5490c173d66..aed70a48c4b 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiAccount.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiAccount.java @@ -26,6 +26,7 @@ import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; @@ -91,7 +92,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test010ImportAccountsFromDummyMultiGreen() throws Exception { final String TEST_NAME = "test010ImportAccountsFromDummyMultiGreen"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); @@ -117,7 +117,6 @@ public void test010ImportAccountsFromDummyMultiGreen() throws Exception { @Test public void test020ImportPaulAtreides() throws Exception { final String TEST_NAME = "test020ImportPaulAtreides"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); @@ -162,7 +161,6 @@ public void test020ImportPaulAtreides() throws Exception { @Test public void test100ImportMuadDib() throws Exception { final String TEST_NAME = "test100ImportMuadDib"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); @@ -217,7 +215,6 @@ public void test100ImportMuadDib() throws Exception { @Test public void test102ReconcileUserPaul() throws Exception { final String TEST_NAME = "test102ReconcileUserPaul"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); @@ -270,7 +267,6 @@ public void test102ReconcileUserPaul() throws Exception { @Test public void test200ImportDuke() throws Exception { final String TEST_NAME = "test200ImportDuke"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); @@ -338,7 +334,6 @@ public void test200ImportDuke() throws Exception { @Test public void test210ImportMahdi() throws Exception { final String TEST_NAME = "test210ImportMahdi"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiConnectorResources.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiConnectorResources.java index 3e47ade9e49..635dfb6779c 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiConnectorResources.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiConnectorResources.java @@ -6,31 +6,21 @@ */ package com.evolveum.midpoint.model.intest.multi; -import com.evolveum.icf.dummy.resource.DummyResource; import com.evolveum.midpoint.model.intest.AbstractConfiguredModelIntegrationTest; -import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus; -import com.evolveum.midpoint.schema.util.ShadowUtil; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.DummyResourceContoller; -import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.FailableRunnable; -import com.evolveum.midpoint.util.Holder; -import com.evolveum.midpoint.util.exception.*; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; + import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; import java.io.File; -import java.util.List; import static org.testng.AssertJUnit.*; @@ -78,7 +68,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -98,7 +87,6 @@ public void test000Sanity() throws Exception { @Test public void test100JackAssignDummyOpaline() throws Exception { final String TEST_NAME = "test100JackAssignDummyOpaline"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiResource.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiResource.java index 03fea3ecc77..5b33902fe41 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiResource.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiResource.java @@ -33,6 +33,7 @@ import com.evolveum.midpoint.schema.result.OperationResultStatus; import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.asserter.UserAsserter; import com.evolveum.midpoint.test.util.TestUtil; @@ -365,7 +366,6 @@ public void test209JackUnAssignDummyIvory() throws Exception { @Test public void test210JackAssignDummyBeige() throws Exception { final String TEST_NAME = "test210JackAssignDummyBeige"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -403,7 +403,6 @@ public void test210JackAssignDummyBeige() throws Exception { @Test public void test219JackUnAssignDummyBeige() throws Exception { final String TEST_NAME = "test219JackUnAssignDummyBeige"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -438,7 +437,6 @@ public void test219JackUnAssignDummyBeige() throws Exception { @Test public void test220JackAssignDummyBeigeAndDefault() throws Exception { final String TEST_NAME = "test220JackAssignDummyBeigeAndDefault"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -477,7 +475,6 @@ public void test220JackAssignDummyBeigeAndDefault() throws Exception { @Test public void test221JackRecompute() throws Exception { final String TEST_NAME = "test221JackRecompute"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -511,7 +508,6 @@ public void test221JackRecompute() throws Exception { @Test public void test223JackKillDefaultDummyAccounAndRecompute() throws Exception { final String TEST_NAME = "test223JackKillDefaultDummyAccounAndRecompute"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -550,7 +546,6 @@ public void test223JackKillDefaultDummyAccounAndRecompute() throws Exception { @Test public void test224JackKillBeigeAccounAndRecompute() throws Exception { final String TEST_NAME = "test224JackKillBeigeAccounAndRecompute"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -609,7 +604,6 @@ public void test224JackKillBeigeAccounAndRecompute() throws Exception { @Test public void test225ForceDeleteDeadShadow() throws Exception { final String TEST_NAME = "test225ForceDeleteDeadShadow"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -664,7 +658,6 @@ public void test225ForceDeleteDeadShadow() throws Exception { @Test public void test226JackKillBothAccountsAndRecompute() throws Exception { final String TEST_NAME = "test226JackKillBothAccountsAndRecompute"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -742,7 +735,6 @@ public void test226JackKillBothAccountsAndRecompute() throws Exception { @Test public void test227ModifyUserJackDefaultDummyBrokenSchemaViolation() throws Exception { final String TEST_NAME = "test227ModifyUserJackDefaultDummyBrokenSchemaViolation"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestMultiResource.class.getName() + "." + TEST_NAME); @@ -810,7 +802,6 @@ public void test227ModifyUserJackDefaultDummyBrokenSchemaViolation() throws Exce @Test public void test228ModifyUserJackDefaultDummyNoError() throws Exception { final String TEST_NAME = "test228ModifyUserJackDefaultDummyNoError"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestMultiResource.class.getName() + "." + TEST_NAME); @@ -873,7 +864,6 @@ public void test228ModifyUserJackDefaultDummyNoError() throws Exception { @Test public void test229JackUnassignDummyBeigeAndDefault() throws Exception { final String TEST_NAME = "test229JackUnassignDummyBeigeAndDefault"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -924,7 +914,6 @@ public void test229JackUnassignDummyBeigeAndDefault() throws Exception { @Test public void test250JackAssignDummyLavender() throws Exception { final String TEST_NAME = "test250JackAssignDummyLavender"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -961,7 +950,6 @@ public void test250JackAssignDummyLavender() throws Exception { * resource through the user to the other resource. If dependency does not work then no value is propagated. */ public void jackAssignRoleDummies(final String TEST_NAME) throws Exception { - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1016,7 +1004,6 @@ public void jackAssignRoleDummies(final String TEST_NAME) throws Exception { } public void jackRename(final String TEST_NAME) throws Exception { - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1074,7 +1061,6 @@ public void jackRename(final String TEST_NAME, String toName, String toFullName, } public void jackUnAssignRoleDummies(final String TEST_NAME) throws Exception { - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1113,7 +1099,6 @@ public void jackUnAssignRoleDummies(final String TEST_NAME) throws Exception { */ public void jackAssignRoleDummiesError(final String TEST_NAME, String roleOid, String dummyResourceName, boolean expectAccount) throws Exception { - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1157,7 +1142,6 @@ private void clearJackOrganizationalUnit(Task task, OperationResult result) thro } public void jackUnassignRoleDummiesError(final String TEST_NAME, String roleOid, String otherResourceOid) throws Exception { - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1233,7 +1217,6 @@ public void jackUnassignRoleDummiesError(final String TEST_NAME, String roleOid, @Test public void test300AddAndAssignRelative() throws Exception { final String TEST_NAME = "test300AddAndAssignRelative"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Task task = createTask(TEST_NAME); @@ -1293,7 +1276,6 @@ public void test300AddAndAssignRelative() throws Exception { @Test public void test310AddedAccountAndUnassignRelative() throws Exception { final String TEST_NAME = "test310AddedAccountAndUnassignRelative"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Task task = createTask(TEST_NAME); @@ -1334,7 +1316,6 @@ public void test310AddedAccountAndUnassignRelative() throws Exception { @Test public void test319UnassignDummyRelative() throws Exception { final String TEST_NAME = "test319UnassignDummyRelative"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Task task = createTask(TEST_NAME); @@ -1370,7 +1351,6 @@ public void test319UnassignDummyRelative() throws Exception { @Test public void test350AddAccountLavender() throws Exception { final String TEST_NAME = "test350AddAccountLavender"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); Task task = createTask(TEST_NAME); @@ -1401,7 +1381,6 @@ public void test350AddAccountLavender() throws Exception { @Test public void test352AddAccountIvory() throws Exception { final String TEST_NAME = "test352AddAccountIvory"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); Task task = createTask(TEST_NAME); @@ -1425,7 +1404,6 @@ public void test352AddAccountIvory() throws Exception { @Test public void test354AddAccountBeige() throws Exception { final String TEST_NAME = "test354AddAccountBeige"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); Task task = createTask(TEST_NAME); @@ -1449,7 +1427,6 @@ public void test354AddAccountBeige() throws Exception { @Test public void test360AddAccountDummy() throws Exception { final String TEST_NAME = "test360AddAccountDummy"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); Task task = createTask(TEST_NAME); @@ -1476,7 +1453,6 @@ public void test360AddAccountDummy() throws Exception { @Test public void test362AddAccountLavender() throws Exception { final String TEST_NAME = "test362AddAccountLavender"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); Task task = createTask(TEST_NAME); @@ -1503,7 +1479,6 @@ public void test362AddAccountLavender() throws Exception { @Test public void test370DeleteAccountDummy() throws Exception { final String TEST_NAME = "test370DeleteAccountDummy"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); Task task = createTask(TEST_NAME); @@ -1540,7 +1515,6 @@ public void test370DeleteAccountDummy() throws Exception { @Test public void test372UnlinkAccountDummy() throws Exception { final String TEST_NAME = "test372UnlinkAccountDummy"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); Task task = createTask(TEST_NAME); @@ -1573,7 +1547,6 @@ public void test372UnlinkAccountDummy() throws Exception { @Test public void test374DeleteAccountLavender() throws Exception { final String TEST_NAME = "test374DeleteAccountLavender"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); Task task = createTask(TEST_NAME); @@ -1602,7 +1575,6 @@ public void test374DeleteAccountLavender() throws Exception { @Test public void test376DeleteAccountDummy() throws Exception { final String TEST_NAME = "test376DeleteAccountDummy"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); Task task = createTask(TEST_NAME); @@ -1628,7 +1600,6 @@ public void test376DeleteAccountDummy() throws Exception { @Test public void test378DeleteAccountBeige() throws Exception { final String TEST_NAME = "test378DeleteAccountBeige"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); Task task = createTask(TEST_NAME); @@ -1655,7 +1626,6 @@ public void test378DeleteAccountBeige() throws Exception { @Test public void test379DeleteAccountIvory() throws Exception { final String TEST_NAME = "test379DeleteAccountIvory"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); Task task = createTask(TEST_NAME); @@ -1683,7 +1653,6 @@ public void test379DeleteAccountIvory() throws Exception { @Test public void test380AddAccountPeru() throws Exception { final String TEST_NAME = "test380AddAccountPeru"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); getDummyResource().resetBreakMode(); @@ -1710,7 +1679,6 @@ public void test380AddAccountPeru() throws Exception { @Test public void test382AddAccountYellow() throws Exception { final String TEST_NAME = "test382AddAccountYellow"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); Task task = createTask(TEST_NAME); @@ -1746,7 +1714,6 @@ public void test382AddAccountYellow() throws Exception { @Test public void test385ModifyUserJackPasswordA() throws Exception { final String TEST_NAME = "test385ModifyUserJackPasswordA"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(AbstractPasswordTest.class.getName() + "." + TEST_NAME); @@ -1779,7 +1746,6 @@ public void test385ModifyUserJackPasswordA() throws Exception { @Test public void test389DeleteAccountPeru() throws Exception { final String TEST_NAME = "test389DeleteAccountPeru"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); Task task = createTask(TEST_NAME); @@ -1806,7 +1772,6 @@ public void test389DeleteAccountPeru() throws Exception { @Test public void test400DavidAndGoliathAssignRole() throws Exception { final String TEST_NAME = "test400DavidAndGoliathAssignRole"; - displayTestTitle(TEST_NAME); // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -1892,7 +1857,6 @@ private void assertDavidGoliath(String userOid, String ou, String name, boolean @Test public void test401DavidAndGoliathModifyOu() throws Exception { final String TEST_NAME = "test401DavidAndGoliathModifyOu"; - displayTestTitle(TEST_NAME); // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -1939,7 +1903,6 @@ public void test401DavidAndGoliathModifyOu() throws Exception { @Test public void test403DavidAndGoliathDisableUser() throws Exception { final String TEST_NAME = "test403DavidAndGoliathDisableUser"; - displayTestTitle(TEST_NAME); // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -1978,7 +1941,6 @@ public void test403DavidAndGoliathDisableUser() throws Exception { @Test public void test404DavidAndGoliathEnableUser() throws Exception { final String TEST_NAME = "test404DavidAndGoliathEnableUser"; - displayTestTitle(TEST_NAME); // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -2016,7 +1978,6 @@ public void test404DavidAndGoliathEnableUser() throws Exception { @Test public void test405DavidAndGoliathDisableAccountDavid() throws Exception { final String TEST_NAME = "test405DavidAndGoliathDisableAccountDavid"; - displayTestTitle(TEST_NAME); // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -2056,7 +2017,6 @@ public void test405DavidAndGoliathDisableAccountDavid() throws Exception { @Test public void test406DavidAndGoliathRecompute() throws Exception { final String TEST_NAME = "test406DavidAndGoliathRecompute"; - displayTestTitle(TEST_NAME); // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -2086,7 +2046,6 @@ public void test406DavidAndGoliathRecompute() throws Exception { @Test public void test408DavidAndGoliathEnableAccountDavid() throws Exception { final String TEST_NAME = "test408DavidAndGoliathEnableAccountDavid"; - displayTestTitle(TEST_NAME); // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -2123,7 +2082,6 @@ public void test408DavidAndGoliathEnableAccountDavid() throws Exception { @Test public void test410DavidAndGoliathRename() throws Exception { final String TEST_NAME = "test410DavidAndGoliathRename"; - displayTestTitle(TEST_NAME); // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -2170,7 +2128,6 @@ public void test410DavidAndGoliathRename() throws Exception { @Test public void test419DavidAndGoliathUnassignRole() throws Exception { final String TEST_NAME = "test419DavidAndGoliathUnassignRole"; - displayTestTitle(TEST_NAME); // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -2214,7 +2171,6 @@ public void test419DavidAndGoliathUnassignRole() throws Exception { @Test public void test420DavidAndGoliathAssignRoleGoliathDown() throws Exception { final String TEST_NAME = "test420DavidAndGoliathAssignRoleGoliathDown"; - displayTestTitle(TEST_NAME); // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -2293,7 +2249,6 @@ public void test420DavidAndGoliathAssignRoleGoliathDown() throws Exception { @Test public void test421DavidAndGoliathAssignRoleGoliathUpRecompute() throws Exception { final String TEST_NAME = "test421DavidAndGoliathAssignRoleGoliathUpRecompute"; - displayTestTitle(TEST_NAME); // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -2348,7 +2303,6 @@ public void test421DavidAndGoliathAssignRoleGoliathUpRecompute() throws Exceptio @Test public void test422DavidAndGoliathAssignRoleGoliathUpRecompute() throws Exception { final String TEST_NAME = "test422DavidAndGoliathAssignRoleGoliathUpRecompute"; - displayTestTitle(TEST_NAME); // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -2402,7 +2356,6 @@ public void test422DavidAndGoliathAssignRoleGoliathUpRecompute() throws Exceptio @Test public void test423DavidAndGoliathAssignRoleGoliathUpReconcile() throws Exception { final String TEST_NAME = "test423DavidAndGoliathAssignRoleGoliathUpReconcile"; - displayTestTitle(TEST_NAME); // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -2432,7 +2385,6 @@ public void test423DavidAndGoliathAssignRoleGoliathUpReconcile() throws Exceptio @Test public void test428DavidAndGoliathUnassignRole() throws Exception { final String TEST_NAME = "test428DavidAndGoliathUnassignRole"; - displayTestTitle(TEST_NAME); // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -2484,7 +2436,6 @@ public void test428DavidAndGoliathUnassignRole() throws Exception { @Test public void test429ExpireDeadShadow() throws Exception { final String TEST_NAME = "test429ExpireDeadShadow"; - displayTestTitle(TEST_NAME); // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -2521,7 +2472,6 @@ public void test429ExpireDeadShadow() throws Exception { @Test public void test430DavidAndGoliathAssignRoleDavidDown() throws Exception { final String TEST_NAME = "test430DavidAndGoliathAssignRoleDavidDown"; - displayTestTitle(TEST_NAME); // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -2586,7 +2536,6 @@ public void test430DavidAndGoliathAssignRoleDavidDown() throws Exception { @Test public void test440DavidAndGoliathAssignRoleAndCreateUserInOneStep() throws Exception { final String TEST_NAME = "test440DavidAndGoliathAssignRoleAndCreateUserInOneStep"; - displayTestTitle(TEST_NAME); getDummyResource(RESOURCE_DUMMY_GOLIATH_NAME).resetBreakMode(); getDummyResource(RESOURCE_DUMMY_DAVID_NAME).resetBreakMode(); @@ -2671,7 +2620,6 @@ public void test440DavidAndGoliathAssignRoleAndCreateUserInOneStep() throws Exce @Test public void test500PrepareJack() throws Exception { final String TEST_NAME = "test500PrepareJack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2707,7 +2655,6 @@ public void test500PrepareJack() throws Exception { @Test public void test501JackAssignDummyDarkYellow() throws Exception { final String TEST_NAME = "test501JackAssignDummyDarkYellow"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2738,7 +2685,6 @@ public void test501JackAssignDummyDarkYellow() throws Exception { @Test public void test502JackAssignDummyDarkPeru() throws Exception { final String TEST_NAME = "test502JackAssignDummyDarkPeru"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2770,7 +2716,6 @@ public void test502JackAssignDummyDarkPeru() throws Exception { @Test public void test504JackUnassignDummyDarkPeru() throws Exception { final String TEST_NAME = "test504JackUnassignDummyDarkPeru"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2799,7 +2744,6 @@ public void test504JackUnassignDummyDarkPeru() throws Exception { @Test public void test507JackUnassignDummyDarkYellow() throws Exception { final String TEST_NAME = "test507JackUnassignDummyDarkYellow"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2828,7 +2772,6 @@ public void test507JackUnassignDummyDarkYellow() throws Exception { @Test public void test508JackDeleteDummyDarkYellowAccount() throws Exception { final String TEST_NAME = "test508JackDeleteDummyDarkYellowAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2857,7 +2800,6 @@ public void test508JackDeleteDummyDarkYellowAccount() throws Exception { @Test public void test509JackDeleteDummyDarkPeruAccount() throws Exception { final String TEST_NAME = "test509JackDeleteDummyDarkPeruAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2886,7 +2828,6 @@ public void test509JackDeleteDummyDarkPeruAccount() throws Exception { @Test public void test510JackAssignRoleDarkYellowPeru() throws Exception { final String TEST_NAME = "test510JackAssignRoleDarkYellowPeru"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2923,7 +2864,6 @@ public void test510JackAssignRoleDarkYellowPeru() throws Exception { @Test public void test519JackUnassignDarkRoleYellowPeru() throws Exception { final String TEST_NAME = "test519JackUnassignDarkRoleYellowPeru"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2952,7 +2892,6 @@ public void test519JackUnassignDarkRoleYellowPeru() throws Exception { @Test public void test520JackAssignRoleDarkYellowPeru() throws Exception { final String TEST_NAME = "test520JackAssignRoleDarkYellowPeru"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2989,7 +2928,6 @@ public void test520JackAssignRoleDarkYellowPeru() throws Exception { @Test public void test529JackUnassignRoleDarkYellowPeru() throws Exception { final String TEST_NAME = "test529JackUnassignRoleDarkYellowPeru"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestAssignmentErrors.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestAssignmentErrors.java index 655111bbb69..96601193d4c 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestAssignmentErrors.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestAssignmentErrors.java @@ -42,7 +42,6 @@ import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.result.OperationResultStatus; -import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; @@ -166,7 +165,6 @@ public void test010RefinedSchemaWhite() throws Exception { @Test public void test100UserJackAssignBlankAccount() throws Exception { final String TEST_NAME = "test100UserJackAssignBlankAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -209,7 +207,6 @@ public void test100UserJackAssignBlankAccount() throws Exception { @Test public void test101AddUserCharlesAssignBlankAccount() throws Exception { final String TEST_NAME = "test101AddUserCharlesAssignBlankAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -252,7 +249,6 @@ public void test101AddUserCharlesAssignBlankAccount() throws Exception { @Test public void test200UserLemonheadAssignAccountBrokenNetwork() throws Exception { final String TEST_NAME = "test200UserLemonheadAssignAccountBrokenNetwork"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -331,7 +327,6 @@ public void test200UserLemonheadAssignAccountBrokenNetwork() throws Exception { @Test public void test210UserSharptoothAssignAccountBrokenGeneric() throws Exception { final String TEST_NAME = "test210UserSharptoothAssignAccountBrokenGeneric"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -401,7 +396,6 @@ public void test210UserSharptoothAssignAccountBrokenGeneric() throws Exception { @Test public void test212UserSharptoothAssignAccountRecovery() throws Exception { final String TEST_NAME = "test212UserSharptoothAssignAccountRecovery"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -475,7 +469,6 @@ public void test215UserSharptoothChangePasswordGenericError() throws Exception { // } public void testUserSharptoothChangePasswordError(final String TEST_NAME, BreakMode breakMode, String oldPassword, String newPassword, OperationResultStatus expectedResultStatus) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -513,7 +506,6 @@ public void testUserSharptoothChangePasswordError(final String TEST_NAME, BreakM @Test public void test220UserAssignAccountDeletedShadowRecomputeSync() throws Exception { final String TEST_NAME = "test220UserAssignAccountDeletedShadowRecomputeSync"; - displayTestTitle(TEST_NAME); //GIVEN PrismObject user = setupUserAssignAccountDeletedShadowRecompute(TEST_NAME, RESOURCE_DUMMY_OID, null, @@ -625,7 +617,6 @@ public void test222UserAssignAccountDeletedShadowRecomputeNoSync() throws Except @Test public void test224UserAssignAccountDeletedShadowRecomputeReducedSync() throws Exception { final String TEST_NAME = "test224UserAssignAccountDeletedShadowRecomputeReducedSync"; - displayTestTitle(TEST_NAME); //GIVEN PrismObject user = setupUserAssignAccountDeletedShadowRecompute(TEST_NAME, diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestBrokenResources.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestBrokenResources.java index 49ba88ecd0e..1bf59ea038e 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestBrokenResources.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestBrokenResources.java @@ -166,7 +166,6 @@ public void postInitSystem(Task initTask, OperationResult initResult) throws Exc @Test public void test010TestResourceBroken() throws Exception { final String TEST_NAME = "test010TestResourceBroken"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -183,7 +182,6 @@ public void test010TestResourceBroken() throws Exception { @Test public void test020GetResourceBroken() throws Exception { final String TEST_NAME = "test020GetResourceBroken"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -214,7 +212,6 @@ public void test030ListResources() throws Exception { @Test public void test100GetAccountMurray() throws Exception { final String TEST_NAME = "test100GetAccountMurray"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -241,7 +238,6 @@ public void test100GetAccountMurray() throws Exception { @Test public void test101GetAccountMurrayNoFetch() throws Exception { final String TEST_NAME = "test101GetAccountMurrayNoFetch"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -329,7 +325,6 @@ public void test210TestResourceNotFound() throws Exception { @Test public void test220GetResourceNotFound() throws Exception { final String TEST_NAME = "test220GetResourceNotFound"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestBrokenResources.class.getName() + "."+TEST_NAME); @@ -355,7 +350,6 @@ public void test220GetResourceNotFound() throws Exception { @Test public void test221GetResourceNotFoundResolveConnector() throws Exception { final String TEST_NAME = "test221GetResourceNotFoundResolveConnector"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestBrokenResources.class.getName() + "."+TEST_NAME); @@ -403,7 +397,6 @@ public void test310TestResourceNoJars() throws Exception { @Test public void test320GetResourceNoJars() throws Exception { final String TEST_NAME = "test320GetResourceNoJars"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -429,7 +422,6 @@ public void test320GetResourceNoJars() throws Exception { @Test public void test350AddResourceWrongConnectorOid() throws Exception { final String TEST_NAME = "test350AddResourceWrongConnectorOid"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -461,7 +453,6 @@ public void test350AddResourceWrongConnectorOid() throws Exception { @Test public void test352AddResourceWrongConnectorOidRaw() throws Exception { final String TEST_NAME = "test352AddResourceWrongConnectorOidRaw"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -494,7 +485,6 @@ public void test352AddResourceWrongConnectorOidRaw() throws Exception { @Test public void test355AddResourceWrongConnectorOidRepo() throws Exception { final String TEST_NAME = "test355AddResourceWrongConnectorOidRepo"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -513,7 +503,6 @@ public void test355AddResourceWrongConnectorOidRepo() throws Exception { @Test public void test358GetResourceWrongConnectorOid() throws Exception { final String TEST_NAME = "test358GetResourceWrongConnectorOid"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -539,7 +528,6 @@ public void test358GetResourceWrongConnectorOid() throws Exception { @Test public void test359DeleteResourceWrongConnectorOid() throws Exception { final String TEST_NAME = "test359DeleteResourceWrongConnectorOid"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -564,7 +552,6 @@ public void test359DeleteResourceWrongConnectorOid() throws Exception { @Test public void test360AddResourceNoConfiguration() throws Exception { final String TEST_NAME = "test360AddResourceNoConfiguration"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -588,7 +575,6 @@ public void test360AddResourceNoConfiguration() throws Exception { @Test public void test362GetResourceNoConfiguration() throws Exception { final String TEST_NAME = "test362GetResourceNoConfiguration"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -620,7 +606,6 @@ public void test368ListResources() throws Exception { @Test public void test369DeleteResourceNoConfiguration() throws Exception { final String TEST_NAME = "test369DeleteResourceNoConfiguration"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -650,7 +635,6 @@ public void test370ListResources() throws Exception { @Test public void test371ImportUnaccessibleResource() throws Exception { final String TEST_NAME = "test371ImportUnaccessibleResource"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -671,7 +655,6 @@ public void test371ImportUnaccessibleResource() throws Exception { @Test public void test372GetUnaccessibleResourceNoFetch() throws Exception { final String TEST_NAME = "test372GetUnaccessibleResourceNoFetch"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -730,7 +713,6 @@ public void test375ListResources() throws Exception { } public void testListResources(final String TEST_NAME, int expectedNumber, Collection> options) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN (1) Task task = createTask(TEST_NAME); @@ -786,7 +768,6 @@ public boolean handle(PrismObject object, OperationResult parentRe @Test public void test377GetResourceNoConfiguration() throws Exception { final String TEST_NAME = "test377GetResourceNoConfiguration"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -819,7 +800,6 @@ public void test377GetResourceNoConfiguration() throws Exception { @Test public void test400AssignTwoResouresNotFound() throws Exception { final String TEST_NAME = "test400AssignTwoResoures"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -851,7 +831,6 @@ public void test400AssignTwoResouresNotFound() throws Exception { @Test public void test401AssignTwoResouresBroken() throws Exception { final String TEST_NAME = "test401AssignTwoResouresBroken"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -895,7 +874,6 @@ private ObjectDelta createAssignTwoResourcesDelta(String badResourceOi @Test public void test500AssignResourceBlack() throws Exception { final String TEST_NAME = "test500AssignResourceBlack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -933,7 +911,6 @@ public void test500AssignResourceBlack() throws Exception { @Test public void test502ModifyUserEmployeeNumberNone() throws Exception { final String TEST_NAME = "test502ModifyUserEmployeeNumberNone"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -966,7 +943,6 @@ public void test502ModifyUserEmployeeNumberNone() throws Exception { @Test public void test509UnassignResourceBlack() throws Exception { final String TEST_NAME = "test509UnassignResourceBlack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -999,7 +975,6 @@ public void test509UnassignResourceBlack() throws Exception { @Test public void test510AssignResourceBlackError() throws Exception { final String TEST_NAME = "test510AssignResourceBlackError"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1046,7 +1021,6 @@ public void test510AssignResourceBlackError() throws Exception { @Test public void test512ReconcileUser() throws Exception { final String TEST_NAME = "test512ReconcileUser"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1078,7 +1052,6 @@ public void test512ReconcileUser() throws Exception { @Test public void test514ModifyUserEmployeeNumberRuntime() throws Exception { final String TEST_NAME = "test514ModifyUserEmployeeNumberRuntime"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1119,7 +1092,6 @@ public void test514ModifyUserEmployeeNumberRuntime() throws Exception { @Test public void test518UnassignResourceBlack() throws Exception { final String TEST_NAME = "test518UnassignResourceBlack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1161,7 +1133,6 @@ public void test518UnassignResourceBlack() throws Exception { @Test public void test519ReconcileUser() throws Exception { final String TEST_NAME = "test519ReconcileUser"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1192,7 +1163,6 @@ public void test519ReconcileUser() throws Exception { @Test public void test520AssignResourceEbonyError() throws Exception { final String TEST_NAME = "test520AssignResourceEbonyError"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1233,7 +1203,6 @@ public void test520AssignResourceEbonyError() throws Exception { @Test public void test524ModifyUserEmployeeNumberRuntime() throws Exception { final String TEST_NAME = "test524ModifyUserEmployeeNumberRuntime"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1266,7 +1235,6 @@ public void test524ModifyUserEmployeeNumberRuntime() throws Exception { @Test public void test528UnassignResourceEbony() throws Exception { final String TEST_NAME = "test528UnassignResourceEbony"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1319,7 +1287,6 @@ public void test528UnassignResourceEbony() throws Exception { @Test public void test600GuybrushAssignAccountDummyViolet() throws Exception { final String TEST_NAME = "test600GuybrushAssignAccountDummyViolet"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStruct.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStruct.java index 49e5a8cf117..6a1b1d5f34e 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStruct.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStruct.java @@ -121,7 +121,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test010AddOrgStruct() throws Exception { final String TEST_NAME = "test010AddOrgStruct"; - displayTestTitle(TEST_NAME); // Dummy, just to be overridden in subclasses addOrgStruct(); @@ -134,7 +133,6 @@ protected void addOrgStruct() throws Exception { @Test public void test051OrgStructSanity() throws Exception { final String TEST_NAME = "test051OrgStructSanity"; - displayTestTitle(TEST_NAME); // WHEN assertMonkeyIslandOrgSanity(); @@ -143,7 +141,6 @@ public void test051OrgStructSanity() throws Exception { @Test public void test052RootOrgQuery() throws Exception { final String TEST_NAME = "test052RootOrgQuery"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -164,7 +161,6 @@ public void test052RootOrgQuery() throws Exception { @Test public void test100JackAssignOrgtarget() throws Exception { final String TEST_NAME = "test100JackAssignOrgtarget"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -193,7 +189,6 @@ public void test100JackAssignOrgtarget() throws Exception { @Test public void test101JackAssignScummBar() throws Exception { final String TEST_NAME = "test101JackAssignScummBar"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -220,7 +215,6 @@ public void test101JackAssignScummBar() throws Exception { @Test public void test102JackUnassignScummBar() throws Exception { final String TEST_NAME = "test102JackUnassignScummBar"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -246,7 +240,6 @@ public void test102JackUnassignScummBar() throws Exception { @Test public void test201JackAssignScummBarAndSaveElaine() throws Exception { final String TEST_NAME = "test201JackAssignScummBarAndSaveElaine"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -278,7 +271,6 @@ public void test201JackAssignScummBarAndSaveElaine() throws Exception { @Test public void test202JackAssignMinistryOfOffense() throws Exception { final String TEST_NAME = "test202JackAssignMinistryOfOffense"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -300,7 +292,6 @@ public void test202JackAssignMinistryOfOffense() throws Exception { @Test public void test207JackUnAssignScummBar() throws Exception { final String TEST_NAME = "test207JackUnAssignScummBar"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -322,7 +313,6 @@ public void test207JackUnAssignScummBar() throws Exception { @Test public void test208JackUnassignAll() throws Exception { final String TEST_NAME = "test208JackUnassignAll"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -349,7 +339,6 @@ public void test208JackUnassignAll() throws Exception { @Test public void test210JackAssignMinistryOfOffenseMember() throws Exception { final String TEST_NAME = "test210JackAssignMinistryOfOffenseMember"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -380,7 +369,6 @@ public void test210JackAssignMinistryOfOffenseMember() throws Exception { @Test public void test211JackAssignMinistryOfOffenseMinister() throws Exception { final String TEST_NAME = "test211JackAssignMinistryOfOffenseMinister"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -408,7 +396,6 @@ public void test211JackAssignMinistryOfOffenseMinister() throws Exception { @Test public void test212JackUnassignMinistryOfOffenseMember() throws Exception { final String TEST_NAME = "test212JackUnassignMinistryOfOffenseMember"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -433,7 +420,6 @@ public void test212JackUnassignMinistryOfOffenseMember() throws Exception { @Test public void test213JackUnassignMinistryOfOffenseManager() throws Exception { final String TEST_NAME = "test213JackUnassignMinistryOfOffenseManager"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -456,7 +442,6 @@ public void test213JackUnassignMinistryOfOffenseManager() throws Exception { @Test public void test220JackAssignMinistryOfOffenseMemberAgain() throws Exception { final String TEST_NAME = "test220JackAssignMinistryOfOffenseMemberAgain"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -485,7 +470,6 @@ public void test220JackAssignMinistryOfOffenseMemberAgain() throws Exception { @Test public void test221JackAssignScummBarAndSaveElaine() throws Exception { final String TEST_NAME = "test221JackAssignScummBarAndSaveElaine"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -516,7 +500,6 @@ public void test221JackAssignScummBarAndSaveElaine() throws Exception { @Test public void test223JackChangeMinistryOfOffenseMemberToManager() throws Exception { final String TEST_NAME = "test221JackChangeMinistryOfOffenseMemberToManager"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -578,7 +561,6 @@ public void test223JackChangeMinistryOfOffenseMemberToManager() throws Exception @Test public void test230JackRecompute() throws Exception { final String TEST_NAME = "test230JackRecompute"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -604,7 +586,6 @@ public void test230JackRecompute() throws Exception { @Test public void test232JackDestroyRefsAndRecompute() throws Exception { final String TEST_NAME = "test232JackDestroyRefsAndRecompute"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -638,7 +619,6 @@ public void test232JackDestroyRefsAndRecompute() throws Exception { @Test public void test234JackDestroyRefsAndLightRecompute() throws Exception { final String TEST_NAME = "test234JackDestroyRefsAndLightRecompute"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -700,7 +680,6 @@ private Long findAssignmentIdForTarget(PrismObject user, String target @Test public void test300JackUnassignAllOrgs() throws Exception { final String TEST_NAME = "test300JackUnassignAllOrgs"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -733,7 +712,6 @@ public void test300JackUnassignAllOrgs() throws Exception { @Test public void test301JackAssignMinistryOfOffense() throws Exception { final String TEST_NAME = "test301JackAssignMinistryOfOffense"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -759,7 +737,6 @@ public void test301JackAssignMinistryOfOffense() throws Exception { @Test public void test305JackConflictZeroAndMinus() throws Exception { final String TEST_NAME = "test305JackConflictZeroAndMinus"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -791,7 +768,6 @@ public void test305JackConflictZeroAndMinus() throws Exception { @Test public void test307JackConflictPlusAndMinus() throws Exception { final String TEST_NAME = "test307JackConflictPlusAndMinus"; - displayTestTitle(TEST_NAME); executeConflictPlusAndMinus(TEST_NAME); } @@ -830,7 +806,6 @@ protected void executeConflictPlusAndMinus(String TEST_NAME) throws Exception { @Test public void test308JackUnassignRoleDefender() throws Exception { final String TEST_NAME = "test308JackUnassignRoleDefender"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -870,7 +845,6 @@ public void test308JackUnassignRoleDefender() throws Exception { @Test public void test309JackConflictPlusAndMinusAgain() throws Exception { final String TEST_NAME = "test309JackConflictPlusAndMinusAgain"; - displayTestTitle(TEST_NAME); executeConflictPlusAndMinus(TEST_NAME); } @@ -881,7 +855,6 @@ public void test309JackConflictPlusAndMinusAgain() throws Exception { @Test public void test310JackConflictParentOrgRefAndAssignmentsAddOrg() throws Exception { final String TEST_NAME = "test310JackConflictParentOrgRefAndAssignmentsAddOrg"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -915,7 +888,6 @@ public void test310JackConflictParentOrgRefAndAssignmentsAddOrg() throws Excepti @Test public void test349DeleteJack() throws Exception { final String TEST_NAME = "test349DeleteJack"; - displayTestTitle(TEST_NAME); executeDeleteJack(TEST_NAME); } @@ -949,7 +921,6 @@ protected void executeDeleteJack(String TEST_NAME) throws ObjectAlreadyExistsExc @Test public void test350AddJackAsMinistryOfOffenseManager() throws Exception { final String TEST_NAME = "test350AddJackAsMinistryOfOffenseManager"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -999,7 +970,6 @@ public void test350AddJackAsMinistryOfOffenseManager() throws Exception { @Test public void test360ElaineAssignGovernor() throws Exception { final String TEST_NAME = "test360ElaineAssignGovernor"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1036,7 +1006,6 @@ public void test360ElaineAssignGovernor() throws Exception { @Test public void test362ElaineAssignGovernmentMember() throws Exception { final String TEST_NAME = "test362ElaineAssignGovernmentMember"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1074,7 +1043,6 @@ public void test362ElaineAssignGovernmentMember() throws Exception { @Test public void test365GuybrushAssignSwashbucklerMember() throws Exception { final String TEST_NAME = "test365GuybrushAssignSwashbucklerMember"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1118,7 +1086,6 @@ public void test365GuybrushAssignSwashbucklerMember() throws Exception { @Test public void test368GuybrushAssignSwashbucklerManager() throws Exception { final String TEST_NAME = "test368GuybrushAssignSwashbucklerManager"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1164,7 +1131,6 @@ public void test368GuybrushAssignSwashbucklerManager() throws Exception { @Test public void test370BarbossaAssignOffenseMember() throws Exception { final String TEST_NAME = "test370BarbossaAssignOffenseMember"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1215,7 +1181,6 @@ public void test370BarbossaAssignOffenseMember() throws Exception { @Test public void test372HermanAssignSwashbucklerMember() throws Exception { final String TEST_NAME = "test365GuybrushAssignSwashbucklerMember"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1275,7 +1240,6 @@ public void test372HermanAssignSwashbucklerMember() throws Exception { @Test public void test399DeleteJack() throws Exception { final String TEST_NAME = "test399DeleteJack"; - displayTestTitle(TEST_NAME); executeDeleteJack(TEST_NAME); } @@ -1286,7 +1250,6 @@ public void test399DeleteJack() throws Exception { @Test public void test400AddJackWithOrgUnit() throws Exception { final String TEST_NAME = "test400AddJackWithOrgUnit"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1315,7 +1278,6 @@ public void test400AddJackWithOrgUnit() throws Exception { @Test public void test402JackChangeMinistryOfOffenseMemberToManagerByAddingRemovingAssignment() throws Exception { final String TEST_NAME = "test402JackChangeMinistryOfOffenseMemberToManagerByAddingRemovingAssignment"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1351,7 +1313,6 @@ public void test402JackChangeMinistryOfOffenseMemberToManagerByAddingRemovingAss @Test public void test404JackChangeMinistryOfOffenseManagerToMemberByAddingRemovingAssignment() throws Exception { final String TEST_NAME = "test404JackChangeMinistryOfOffenseManagerToMemberByAddingRemovingAssignment"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1385,7 +1346,6 @@ public void test404JackChangeMinistryOfOffenseManagerToMemberByAddingRemovingAss @Test public void test409DeleteJack() throws Exception { final String TEST_NAME = "test409DeleteJack"; - displayTestTitle(TEST_NAME); executeDeleteJack(TEST_NAME); } @@ -1397,7 +1357,6 @@ public void test409DeleteJack() throws Exception { @Test public void test410AddJackWithOrgUnit() throws Exception { final String TEST_NAME = "test400AddJackWithOrgUnit"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1427,7 +1386,6 @@ public void test410AddJackWithOrgUnit() throws Exception { @Test public void test412JackChangeMinistryOfOffenseMemberToManagerByModifyingAssignment() throws Exception { final String TEST_NAME = "test412JackChangeMinistryOfOffenseMemberToManagerByModifyingAssignment"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1469,7 +1427,6 @@ public void test412JackChangeMinistryOfOffenseMemberToManagerByModifyingAssignme @Test public void test420JackAssignTempOrg() throws Exception { final String TEST_NAME = "test420JackAssignTempOrg"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1493,7 +1450,6 @@ public void test420JackAssignTempOrg() throws Exception { @Test public void test425JackUnassignDeletedOrg() throws Exception { final String TEST_NAME = "test425JackUnassignDeletedOrg"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1522,7 +1478,6 @@ public void test425JackUnassignDeletedOrg() throws Exception { @Test public void test430JackAssignMetaroleOffender() throws Exception { final String TEST_NAME = "test430JackAssignMetaroleOffender"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1558,7 +1513,6 @@ public void test430JackAssignMetaroleOffender() throws Exception { @Test public void test431JackAssignMetaroleOffenderAdmin() throws Exception { final String TEST_NAME = "test431JackAssignMetaroleOffenderAdmin"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1587,7 +1541,6 @@ public void test431JackAssignMetaroleOffenderAdmin() throws Exception { @Test public void test437JackUnassignOffender() throws Exception { final String TEST_NAME = "test437JackUnassignOffender"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1615,7 +1568,6 @@ public void test437JackUnassignOffender() throws Exception { @Test public void test438JackUnassignOffenderAdmin() throws Exception { final String TEST_NAME = "test438JackUnassignOffenderAdmin"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1642,7 +1594,6 @@ public void test438JackUnassignOffenderAdmin() throws Exception { @Test public void test439JackCleanup() throws Exception { final String TEST_NAME = "test439JackCleanup"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1672,7 +1623,6 @@ public void test439JackCleanup() throws Exception { @Test public void test440JackModifyEmployeeTypeRolePirate() throws Exception { final String TEST_NAME = "test440JackModifyEmployeeTypeRolePirate"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1702,7 +1652,6 @@ public void test440JackModifyEmployeeTypeRolePirate() throws Exception { @Test public void test441JackModifyEmployeeTypeRoleCaptain() throws Exception { final String TEST_NAME = "test441JackModifyEmployeeTypeRoleCaptain"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1729,7 +1678,6 @@ public void test441JackModifyEmployeeTypeRoleCaptain() throws Exception { @Test public void test443JackModifyEmployeeTypeRoleNotExist() throws Exception { final String TEST_NAME = "test443JackModifyEmployeeTypeRoleNotExist"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1757,7 +1705,6 @@ public void test443JackModifyEmployeeTypeRoleNotExist() throws Exception { @Test public void test449JackModifyEmployeeTypeNull() throws Exception { final String TEST_NAME = "test449JackModifyEmployeeTypeNull"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1780,7 +1727,6 @@ public void test449JackModifyEmployeeTypeNull() throws Exception { @Test public void test500JackEndPirate() throws Exception { final String TEST_NAME = "test500JackEndPirate"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1816,7 +1762,6 @@ public void test500JackEndPirate() throws Exception { @Test public void test510JackEndPirate() throws Exception { final String TEST_NAME = "test510JackEndPirate"; - displayTestTitle(TEST_NAME); login(USER_JACK_USERNAME); @@ -1849,7 +1794,6 @@ public void test510JackEndPirate() throws Exception { @Test public void test799DeleteJack() throws Exception { final String TEST_NAME = "test799DeleteJack"; - displayTestTitle(TEST_NAME); login(USER_ADMINISTRATOR_USERNAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/AbstractPasswordTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/AbstractPasswordTest.java index 36abce3b353..0e3d427b55a 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/AbstractPasswordTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/AbstractPasswordTest.java @@ -15,6 +15,7 @@ import javax.xml.datatype.XMLGregorianCalendar; import com.evolveum.midpoint.prism.path.ItemPath; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.util.MidPointTestConstants; @@ -162,7 +163,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); AccountActivationNotifierType accountActivationNotifier = null; SystemConfigurationType systemConfig = getObject(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value()).asObjectable(); @@ -182,7 +182,6 @@ public void test000Sanity() throws Exception { @Test public void test010AddPasswordPolicy() throws Exception { final String TEST_NAME = "test010AddPasswordPolicy"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -205,7 +204,6 @@ public void test010AddPasswordPolicy() throws Exception { @Test public void test012AddSecurityPolicy() throws Exception { final String TEST_NAME = "test012AddSecurityPolicy"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -228,7 +226,6 @@ public void test012AddSecurityPolicy() throws Exception { @Test public void test050CheckJackPassword() throws Exception { final String TEST_NAME = "test050CheckJackPassword"; - displayTestTitle(TEST_NAME); // GIVEN, WHEN // this happens during test initialization when user-jack.xml is added @@ -249,7 +246,6 @@ public void test050CheckJackPassword() throws Exception { @Test public void test051ModifyUserJackPassword() throws Exception { final String TEST_NAME = "test051ModifyUserJackPassword"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -283,7 +279,6 @@ public void test051ModifyUserJackPassword() throws Exception { @Test public void test060CheckJackPasswordModelInteraction() throws Exception { final String TEST_NAME = "test060CheckJackPasswordModelInteraction"; - displayTestTitle(TEST_NAME); if (getPasswordStorageType() == CredentialsStorageTypeType.NONE) { // Nothing to check in this case @@ -317,7 +312,6 @@ public void test060CheckJackPasswordModelInteraction() throws Exception { @Test public void test070AddUserHerman() throws Exception { final String TEST_NAME = "test070AddUserHerman"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -352,7 +346,6 @@ public void test070AddUserHerman() throws Exception { @Test public void test100JackAssignAccountDummy() throws Exception { final String TEST_NAME = "test100JackAssignAccountDummy"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -406,7 +399,6 @@ public void test100JackAssignAccountDummy() throws Exception { @Test public void test110ModifyUserJackPassword() throws Exception { final String TEST_NAME = "test110ModifyUserJackPassword"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -456,7 +448,6 @@ public void test110ModifyUserJackPassword() throws Exception { @Test public void test111ModifyAccountJackPassword() throws Exception { final String TEST_NAME = "test111ModifyAccountJackPassword"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -492,7 +483,6 @@ public void test111ModifyAccountJackPassword() throws Exception { @Test public void test112ModifyJackPasswordUserAndAccount() throws Exception { final String TEST_NAME = "test112ModifyJackPasswordUserAndAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -543,7 +533,6 @@ public void test112ModifyJackPasswordUserAndAccount() throws Exception { @Test public void test120JackAssignAccountDummyRedAndUgly() throws Exception { final String TEST_NAME = "test120JackAssignAccountDummyRedAndUgly"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -594,7 +583,6 @@ public void test120JackAssignAccountDummyRedAndUgly() throws Exception { @Test public void test121ModifyJackPasswordUserAndAccountRed() throws Exception { final String TEST_NAME = "test121ModifyJackPasswordUserAndAccountRed"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -654,7 +642,6 @@ public void test121ModifyJackPasswordUserAndAccountRed() throws Exception { @Test public void test122ModifyAccountUglyJackPasswordBad() throws Exception { final String TEST_NAME = "test122ModifyAccountUglyJackPasswordBad"; - displayTestTitle(TEST_NAME); prepareTest(); // GIVEN @@ -684,7 +671,6 @@ public void test122ModifyAccountUglyJackPasswordBad() throws Exception { @Test public void test125ModifyJackEmployeeNumberBad() throws Exception { final String TEST_NAME = "test125ModifyJackEmployeeNumberBad"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -724,7 +710,6 @@ public void test125ModifyJackEmployeeNumberBad() throws Exception { @Test public void test128ModifyJackEmployeeNumberGood() throws Exception { final String TEST_NAME = "test128ModifyJackEmployeeNumberGood"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -762,7 +747,6 @@ public void test128ModifyJackEmployeeNumberGood() throws Exception { @Test public void test130JackAssignAccountDummyBlack() throws Exception { final String TEST_NAME = "test130JackAssignAccountDummyBlack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -805,7 +789,6 @@ public void test130JackAssignAccountDummyBlack() throws Exception { @Test public void test132ModifyAccountBlackJackPasswordBad() throws Exception { final String TEST_NAME = "test132ModifyAccountBlackJackPasswordBad"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(AbstractPasswordTest.class.getName() + "." + TEST_NAME); @@ -829,7 +812,6 @@ public void test132ModifyAccountBlackJackPasswordBad() throws Exception { @Test public void test139JackUnassignAccountDummyBlack() throws Exception { final String TEST_NAME = "test139JackUnassignAccountDummyBlack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -872,7 +854,6 @@ public void test139JackUnassignAccountDummyBlack() throws Exception { @Test public void test140JackAssignAccountDummyYellow() throws Exception { final String TEST_NAME = "test140JackAssignAccountDummyYellow"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -920,7 +901,6 @@ public void test140JackAssignAccountDummyYellow() throws Exception { @Test public void test142ModifyUserJackPasswordAA() throws Exception { final String TEST_NAME = "test142ModifyUserJackPasswordAA"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -976,7 +956,6 @@ public void test142ModifyUserJackPasswordAA() throws Exception { @Test public void test150AssignMonkeyDummyAccount() throws Exception { final String TEST_NAME = "test150AssignMonkeyDummyAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1008,7 +987,6 @@ public void test150AssignMonkeyDummyAccount() throws Exception { @Test public void test152ModifyUserMonkeyPassword() throws Exception { final String TEST_NAME = "test152ModifyUserMonkeyPassword"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1040,7 +1018,6 @@ public void test152ModifyUserMonkeyPassword() throws Exception { @Test public void test154ModifyUserMonkeyPasswordA() throws Exception { final String TEST_NAME = "test154ModifyUserMonkeyPasswordA"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1064,7 +1041,6 @@ public void test154ModifyUserMonkeyPasswordA() throws Exception { @Test public void test200ApplyPasswordPolicyHistoryLength() throws Exception { final String TEST_NAME = "test200ApplyPasswordPolicyHistoryLength"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1092,7 +1068,6 @@ public void test200ApplyPasswordPolicyHistoryLength() throws Exception { @Test public void test204UnassignAccountRed() throws Exception { final String TEST_NAME = "test204UnassignAccountRed"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1148,7 +1123,6 @@ public void test204UnassignAccountRed() throws Exception { @Test public void test206ReconcileUserJack() throws Exception { final String TEST_NAME = "test206ReconcileUserJack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1203,7 +1177,6 @@ public void test210ModifyUserJackPasswordGood() throws Exception { @Test public void test212ReconcileUserJack() throws Exception { final String TEST_NAME = "test212ReconcileUserJack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1227,7 +1200,6 @@ public void test212ReconcileUserJack() throws Exception { @Test public void test214RecomputeUserJack() throws Exception { final String TEST_NAME = "test214RecomputeUserJack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1261,7 +1233,6 @@ public void test220ModifyUserJackPasswordBadA() throws Exception { @Test public void test222ModifyUserJackPasswordBadContainer() throws Exception { final String TEST_NAME = "test222ModifyUserJackPasswordBadContainer"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1388,7 +1359,6 @@ public void test248ModifyUserJackPasswordGoodReuse() throws Exception { private void doTestModifyUserJackPasswordSuccessWithHistory(final String TEST_NAME, String newPassword, String... expectedPasswordHistory) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1416,7 +1386,6 @@ private void doTestModifyUserJackPasswordSuccessWithHistory(final String TEST_NA private void doTestModifyUserJackPasswordFailureWithHistory(final String TEST_NAME, String newPassword, String oldPassword, String... expectedPasswordHistory) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1472,7 +1441,6 @@ private void assertJackPasswordsWithHistory(String expectedCurrentPassword, Stri @Test public void test300TwoParentOrgRefs() throws Exception { final String TEST_NAME = "test300TwoParentOrgRefs"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1535,7 +1503,6 @@ public void test300TwoParentOrgRefs() throws Exception { @Test public void test310PreparePasswordStrengthTests() throws Exception { final String TEST_NAME = "test310PreparePasswordStrengthTests"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1590,7 +1557,6 @@ public void test310PreparePasswordStrengthTests() throws Exception { @Test public void test312ChangeUserPassword() throws Exception { final String TEST_NAME = "test312ChangeUserPassword"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1652,7 +1618,6 @@ public void test312ChangeUserPassword() throws Exception { @Test public void test314RemovePasswordFail() throws Exception { final String TEST_NAME = "test314RemovePasswordFail"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1690,7 +1655,6 @@ private void setPasswordMinOccurs(Integer value, Task task, OperationResult resu @Test public void test315RemovePassword() throws Exception { final String TEST_NAME = "test315RemovePassword"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1738,7 +1702,6 @@ public void test315RemovePassword() throws Exception { @Test public void test316UserRecompute() throws Exception { final String TEST_NAME = "test316UserRecompute"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1789,7 +1752,6 @@ public void test316UserRecompute() throws Exception { @Test public void test318ChangeUserPassword() throws Exception { final String TEST_NAME = "test318ChangeUserPassword"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1841,7 +1803,6 @@ public void test318ChangeUserPassword() throws Exception { @Test public void test320ChangeEmployeeNumber() throws Exception { final String TEST_NAME = "test320ChangeEmployeeNumber"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1875,7 +1836,6 @@ public void test320ChangeEmployeeNumber() throws Exception { @Test public void test330RemoveEmployeeNumber() throws Exception { final String TEST_NAME = "test330RemoveEmployeeNumber"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1914,7 +1874,6 @@ public void test330RemoveEmployeeNumber() throws Exception { @Test public void test340ModifyUserMonkeyPasswordAA() throws Exception { final String TEST_NAME = "test340ModifyUserMonkeyPasswordAA"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1951,7 +1910,6 @@ public void test340ModifyUserMonkeyPasswordAA() throws Exception { @Test public void test341RecomputeMonkey() throws Exception { final String TEST_NAME = "test341RecomputeMonkey"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1980,7 +1938,6 @@ public void test341RecomputeMonkey() throws Exception { @Test public void test342ReconcileMonkey() throws Exception { final String TEST_NAME = "test342ReconcileMonkey"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2009,7 +1966,6 @@ public void test342ReconcileMonkey() throws Exception { @Test public void test343ModifyUserMonkeyDescription() throws Exception { final String TEST_NAME = "test343ModifyUserMonkeyDescription"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2046,7 +2002,6 @@ public void test343ModifyUserMonkeyDescription() throws Exception { @Test public void test344ModifyUserMonkeyLocality() throws Exception { final String TEST_NAME = "test343ModifyUserMonkeyDescription"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2081,7 +2036,6 @@ public void test344ModifyUserMonkeyLocality() throws Exception { @Test public void test345AssignMonkeyAccountBlue() throws Exception { final String TEST_NAME = "test345AssignMonkeyAccountBlue"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2112,7 +2066,6 @@ public void test345AssignMonkeyAccountBlue() throws Exception { @Test public void test346UnassignMonkeyAccountBlue() throws Exception { final String TEST_NAME = "test346UnassignMonkeyAccountBlue"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2146,7 +2099,6 @@ public void test346UnassignMonkeyAccountBlue() throws Exception { @Test public void test347AssignMonkeyAccountYellow() throws Exception { final String TEST_NAME = "test347AssignMonkeyAccountYellow"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2175,7 +2127,6 @@ public void test347AssignMonkeyAccountYellow() throws Exception { @Test public void test348UnassignMonkeyAccountYellow() throws Exception { final String TEST_NAME = "test348UnassignMonkeyAccountYellow"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2210,7 +2161,6 @@ public void test348UnassignMonkeyAccountYellow() throws Exception { @Test public void test349AssignMonkeyPirate() throws Exception { final String TEST_NAME = "test349AssignMonkeyPirate"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2246,7 +2196,6 @@ public void test349AssignMonkeyPirate() throws Exception { @Test public void test350DisableMonkey() throws Exception { final String TEST_NAME = "test350DisableMonkey"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2282,7 +2231,6 @@ public void test350DisableMonkey() throws Exception { @Test public void test351EnableMonkey() throws Exception { final String TEST_NAME = "test351EnableMonkey"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2318,7 +2266,6 @@ public void test351EnableMonkey() throws Exception { @Test public void test352UnassignMonkeyPirate() throws Exception { final String TEST_NAME = "test352UnassignMonkeyPirate"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2353,7 +2300,6 @@ public void test352UnassignMonkeyPirate() throws Exception { @Test public void test354ModifyUserMonkeyPasswordValid1() throws Exception { final String TEST_NAME = "test354ModifyUserMonkeyPasswordValid1"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2382,7 +2328,6 @@ public void test354ModifyUserMonkeyPasswordValid1() throws Exception { @Test public void test355ModifyUserMonkeyDescriptionAgain() throws Exception { final String TEST_NAME = "test355ModifyUserMonkeyDescriptionAgain"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2410,7 +2355,6 @@ public void test355ModifyUserMonkeyDescriptionAgain() throws Exception { @Test public void test400AddUserRappWithAssignment() throws Exception { final String TEST_NAME = "test400AddUserRappWithAssignment"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2461,7 +2405,6 @@ public void test400AddUserRappWithAssignment() throws Exception { @Test public void test401UserRappRecompute() throws Exception { final String TEST_NAME = "test401UserRappRecompute"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2503,7 +2446,6 @@ public void test401UserRappRecompute() throws Exception { @Test public void test402AssignRappDummyRed() throws Exception { final String TEST_NAME = "test402AssignRappDummyRed"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2568,7 +2510,6 @@ public void test402AssignRappDummyRed() throws Exception { @Test public void test403UserRappRecompute() throws Exception { final String TEST_NAME = "test403UserRappRecompute"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2631,7 +2572,6 @@ public void test403UserRappRecompute() throws Exception { @Test public void test404InitializeRappDummyRed() throws Exception { final String TEST_NAME = "test404InitializeRappDummyRed"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2697,7 +2637,6 @@ public void test404InitializeRappDummyRed() throws Exception { @Test public void test405UserRappRecompute() throws Exception { final String TEST_NAME = "test405UserRappRecompute"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2761,7 +2700,6 @@ public void test405UserRappRecompute() throws Exception { @Test public void test410AssignRappDummyLifecycle() throws Exception { final String TEST_NAME = "test410AssignRappDummyLifecycle"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2809,7 +2747,6 @@ public void test410AssignRappDummyLifecycle() throws Exception { @Test public void test412InitializeRappDummyLifecycle() throws Exception { final String TEST_NAME = "test412InitializeRappDummyLifecycle"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2887,7 +2824,6 @@ public void test412InitializeRappDummyLifecycle() throws Exception { @Test public void test414UserRappRecompute() throws Exception { final String TEST_NAME = "test414UserRappRecompute"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2958,7 +2894,6 @@ public void test414UserRappRecompute() throws Exception { @Test public void test416UserRappSubtypeWreck() throws Exception { final String TEST_NAME = "test416UserRappSubtypeWreck"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -3035,7 +2970,6 @@ public void test416UserRappSubtypeWreck() throws Exception { @Test public void test420AddUserDrakeWithAssignment() throws Exception { final String TEST_NAME = "test420AddUserDrakeWithAssignment"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -3077,7 +3011,6 @@ public void test420AddUserDrakeWithAssignment() throws Exception { @Test public void test500JackAssignResourceSouvenir() throws Exception { final String TEST_NAME = "test500JackAssignResourceSouvenir"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -3140,7 +3073,6 @@ public void test500JackAssignResourceSouvenir() throws Exception { @Test public void test502JackInitializeAccountSouvenir() throws Exception { final String TEST_NAME = "test502JackInitializeAccountSouvenir"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -3186,7 +3118,6 @@ public void test502JackInitializeAccountSouvenir() throws Exception { @Test public void test510JackAssignResourceMaverick() throws Exception { final String TEST_NAME = "test510JackAssignResourceMaverick"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -3232,7 +3163,6 @@ public void test510JackAssignResourceMaverick() throws Exception { @Test public void test512JackInitializeAccountMaverickAlligator() throws Exception { final String TEST_NAME = "test512JackInitializeAccountMaverick"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -3269,7 +3199,6 @@ public void test512JackInitializeAccountMaverickAlligator() throws Exception { @Test public void test514JackInitializeAccountMaverickCrododile() throws Exception { final String TEST_NAME = "test514JackInitializeAccountMaverickCrododile"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -3310,7 +3239,6 @@ public void test514JackInitializeAccountMaverickCrododile() throws Exception { @Test public void test516JackChangePasswordResourceMaverickAlligator() throws Exception { final String TEST_NAME = "test516JackChangePasswordResourceMaverickAlligator"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -3341,7 +3269,6 @@ public void test516JackChangePasswordResourceMaverickAlligator() throws Exceptio @Test public void test518JackChangePasswordResourceMaverickGiantLizard() throws Exception { final String TEST_NAME = "test518JackChangePasswordResourceMaverickGiantLizard"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -3371,7 +3298,6 @@ public void test518JackChangePasswordResourceMaverickGiantLizard() throws Except @Test public void test530JackUnassignResourceSouvenir() throws Exception { final String TEST_NAME = "test530JackUnassignResourceSouvenir"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -3409,7 +3335,6 @@ public void test530JackUnassignResourceSouvenir() throws Exception { @Test public void test532JackChangePasswordResourceBlueAlligator() throws Exception { final String TEST_NAME = "test532JackChangePasswordResourceBlueAlligator"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -3449,7 +3374,6 @@ public void test532JackChangePasswordResourceBlueAlligator() throws Exception { @Test public void test535ModifyUserJackPasswordAlligator() throws Exception { final String TEST_NAME = "test535ModifyUserJackPasswordAlligator"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -3480,7 +3404,6 @@ public void test535ModifyUserJackPasswordAlligator() throws Exception { @Test public void test539JackUnassignResourceMaverick() throws Exception { final String TEST_NAME = "test539JackUnassignResourceMaverick"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -3530,7 +3453,6 @@ public void test552JackManyPasswordChangesEncrypted() throws Exception { * MID-4507 */ public void testJackManyPasswordChanges(final String TEST_NAME, String passwordPrefix, CredentialsStorageTypeType storageType) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN prepareTest(); @@ -3586,7 +3508,6 @@ private void testJackManyPasswordChangesAttempt(String TEST_NAME, String passwor @Test public void test560ChangeJackPasswordSuperuser() throws Exception { final String TEST_NAME = "test560ChangeJackPasswordSuperuser"; - displayTestTitle(TEST_NAME); // GIVEN prepareTest(); @@ -3654,7 +3575,6 @@ public void test560ChangeJackPasswordSuperuser() throws Exception { @Test public void test562ChangeJackPasswordSelfService() throws Exception { final String TEST_NAME = "test562ChangeJackPasswordSelfService"; - displayTestTitle(TEST_NAME); // GIVEN prepareTest(); @@ -3726,7 +3646,6 @@ public void test562ChangeJackPasswordSelfService() throws Exception { @Test public void test564ChangeJackPasswordAdmin() throws Exception { final String TEST_NAME = "test564ChangeJackPasswordAdmin"; - displayTestTitle(TEST_NAME); // GIVEN @@ -3873,7 +3792,6 @@ private void assertShadowPasswordMetadata(PrismObject shadow, @Test public void test900ModifyUserElainePassword() throws Exception { final String TEST_NAME = "test900ModifyUserElainePassword"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -3909,7 +3827,6 @@ public void test900ModifyUserElainePassword() throws Exception { @Test public void test902SetPasswordMinAge() throws Exception { final String TEST_NAME = "test900SetPasswordMinAge"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -3941,7 +3858,6 @@ public void test902SetPasswordMinAge() throws Exception { @Test public void test904ModifyUserElainePasswordAgain() throws Exception { final String TEST_NAME = "test904ModifyUserElainePasswordAgain"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -3975,7 +3891,6 @@ public void test904ModifyUserElainePasswordAgain() throws Exception { @Test public void test906ModifyUserElainePasswordLater() throws Exception { final String TEST_NAME = "test906ModifyUserElainePasswordLater"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -4014,7 +3929,6 @@ public void test906ModifyUserElainePasswordLater() throws Exception { @Test public void test910AddUserWithNoPasswordFail() throws Exception { final String TEST_NAME = "test910AddUserWithNoPasswordFail"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -4045,7 +3959,6 @@ public void test910AddUserWithNoPasswordFail() throws Exception { @Test public void test920AddCredentials() throws Exception { final String TEST_NAME = "test920AddCredentials"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -4086,7 +3999,6 @@ public void test920AddCredentials() throws Exception { @Test public void test922ReplaceCredentials() throws Exception { final String TEST_NAME = "test922ReplaceCredentials"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -4127,7 +4039,6 @@ public void test922ReplaceCredentials() throws Exception { @Test public void test924AddPassword() throws Exception { final String TEST_NAME = "test924AddPassword"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -4165,7 +4076,6 @@ public void test924AddPassword() throws Exception { @Test public void test926ReplacePassword() throws Exception { final String TEST_NAME = "test926ReplacePassword"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -4203,7 +4113,6 @@ public void test926ReplacePassword() throws Exception { @Test public void test928AddPasswordValue() throws Exception { final String TEST_NAME = "test928AddPasswordValue"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -4240,7 +4149,6 @@ public void test928AddPasswordValue() throws Exception { @Test public void test929ReplacePasswordValue() throws Exception { final String TEST_NAME = "test929ReplacePasswordValue"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -4280,7 +4188,6 @@ public void test929ReplacePasswordValue() throws Exception { @Test public void test950RemoveGlobalPasswordPolicy() throws Exception { final String TEST_NAME = "test950RemoveGlobalPasswordPolicy"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -4319,7 +4226,6 @@ public void test950RemoveGlobalPasswordPolicy() throws Exception { @Test public void test952SetupOrgPolicy() throws Exception { final String TEST_NAME = "test952SetupOrgPolicy"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -4368,7 +4274,6 @@ public void test952SetupOrgPolicy() throws Exception { @Test public void test954ModifyUserMonkeyPasswordAA() throws Exception { final String TEST_NAME = "test954ModifyUserMonkeyPasswordAA"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -4404,7 +4309,6 @@ public void test954ModifyUserMonkeyPasswordAA() throws Exception { @Test public void test956ModifyUserJackPasswordAA() throws Exception { final String TEST_NAME = "test956ModifyUserJackPasswordAA"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -4434,7 +4338,6 @@ public void test956ModifyUserJackPasswordAA() throws Exception { @Test public void test961RecomputeMonkey() throws Exception { final String TEST_NAME = "test961RecomputeMonkey"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -4463,7 +4366,6 @@ public void test961RecomputeMonkey() throws Exception { @Test public void test962ReconcileMonkey() throws Exception { final String TEST_NAME = "test962ReconcileMonkey"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -4492,7 +4394,6 @@ public void test962ReconcileMonkey() throws Exception { @Test public void test964ModifyUserMonkeyLocality() throws Exception { final String TEST_NAME = "test964ModifyUserMonkeyLocality"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -4527,7 +4428,6 @@ public void test964ModifyUserMonkeyLocality() throws Exception { @Test public void test965AssignMonkeyAccountBlue() throws Exception { final String TEST_NAME = "test965AssignMonkeyAccountBlue"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -4562,7 +4462,6 @@ public void test965AssignMonkeyAccountBlue() throws Exception { @Test public void test966AssignMonkeyAccountYellow() throws Exception { final String TEST_NAME = "test966AssignMonkeyAccountYellow"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -4596,7 +4495,6 @@ public void test966AssignMonkeyAccountYellow() throws Exception { @Test public void test970ReapplyGlobalPasswordPolicy() throws Exception { final String TEST_NAME = "test970ReapplyGlobalPasswordPolicy"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -4640,7 +4538,6 @@ public void test970ReapplyGlobalPasswordPolicy() throws Exception { @Test public void test972ChangePasswordJack() throws Exception { final String TEST_NAME = "test970ReapplyGlobalPasswordPolicy"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -4683,7 +4580,6 @@ public void test972ChangePasswordJack() throws Exception { @Test public void test974ChangePasswordJack() throws Exception { final String TEST_NAME = "test970ReapplyGlobalPasswordPolicy"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefaultHashing.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefaultHashing.java index 3a2aa70bbdb..ab142a8a0b6 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefaultHashing.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefaultHashing.java @@ -16,6 +16,7 @@ import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.PolicyViolationException; import com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsStorageTypeType; @@ -146,7 +147,6 @@ protected void assertAccountActivationNotification(String dummyResourceName, Str @Override public void test345AssignMonkeyAccountBlue() throws Exception { final String TEST_NAME = "test345AssignMonkeyAccountBlue"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -195,7 +195,6 @@ public void test345AssignMonkeyAccountBlue() throws Exception { @Override public void test347AssignMonkeyAccountYellow() throws Exception { final String TEST_NAME = "test347AssignMonkeyYellow"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -246,7 +245,6 @@ public void test347AssignMonkeyAccountYellow() throws Exception { @Override public void test966AssignMonkeyAccountYellow() throws Exception { final String TEST_NAME = "test966AssignMonkeyAccountYellow"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/AbstractPersonaTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/AbstractPersonaTest.java index 8b043c8458c..348635c6345 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/AbstractPersonaTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/AbstractPersonaTest.java @@ -58,7 +58,6 @@ public void initSystem(Task initTask, OperationResult initResult) @Test public void test100AssignRolePersonaAdminToJack() throws Exception { final String TEST_NAME = "test100AssignRolePersonaAdminToJack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -95,7 +94,6 @@ public void test100AssignRolePersonaAdminToJack() throws Exception { @Test public void test102RecomputeUserJack() throws Exception { final String TEST_NAME = "test102RecomputeUserJack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -115,7 +113,6 @@ public void test102RecomputeUserJack() throws Exception { @Test public void test103ReconcileUserJack() throws Exception { final String TEST_NAME = "test103ReconcileUserJack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -135,7 +132,6 @@ public void test103ReconcileUserJack() throws Exception { @Test public void test104RecomputeJackAdminPersona() throws Exception { final String TEST_NAME = "test104RecomputeJackAdminPersona"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -155,7 +151,6 @@ public void test104RecomputeJackAdminPersona() throws Exception { @Test public void test105ReconcileJackAdminPersona() throws Exception { final String TEST_NAME = "test105ReconcileJackAdminPersona"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -192,7 +187,6 @@ private void assertUserJack11x() throws Exception { @Test public void test120ModifyJackGivenName() throws Exception { final String TEST_NAME = "test120ModifyJackGivenName"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -230,7 +224,6 @@ public void test120ModifyJackGivenName() throws Exception { @Test public void test140ModifyUserJackPassword() throws Exception { final String TEST_NAME = "test140ModifyUserJackPassword"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -265,7 +258,6 @@ public void test140ModifyUserJackPassword() throws Exception { @Test public void test142ModifyPersonaPassword() throws Exception { final String TEST_NAME = "test142ModifyPersonaPassword"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -306,7 +298,6 @@ protected void assertPersonaAfterPersonaPasswordChange(PrismObject per @Test public void test145ModifyPersonaPasswordBack() throws Exception { final String TEST_NAME = "test145ModifyPersonaPasswordBack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -347,7 +338,6 @@ public void test145ModifyPersonaPasswordBack() throws Exception { @Test public void test199UnassignRolePersonaAdminFromJack() throws Exception { final String TEST_NAME = "test199UnassignRolePersonaAdminFromJack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/TestPersonaPassword.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/TestPersonaPassword.java index ad89ef9032b..aa2f367061f 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/TestPersonaPassword.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/TestPersonaPassword.java @@ -20,6 +20,7 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.util.exception.PolicyViolationException; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; @@ -70,7 +71,6 @@ protected void assertPersonaAfterUserPasswordChange(PrismObject person @Override public void test145ModifyPersonaPasswordBack() throws Exception { final String TEST_NAME = "test145ModifyPersonaPasswordBack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestAssignmentValidity.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestAssignmentValidity.java index 20a68ae9f19..f3d19046df1 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestAssignmentValidity.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestAssignmentValidity.java @@ -49,7 +49,6 @@ public void initSystem(Task initTask, OperationResult initResult) @Test public void test100JackAssignRolePirateValidTo() throws Exception { final String TEST_NAME = "test100JackAssignRolePirateValidTo"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -91,7 +90,6 @@ public void test100JackAssignRolePirateValidTo() throws Exception { @Test public void test102Forward15min() throws Exception { final String TEST_NAME = "test102Forward15min"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -123,7 +121,6 @@ public void test102Forward15min() throws Exception { @Test public void test104JackAssignRolePirateAgain() throws Exception { final String TEST_NAME = "test104JackAssignRolePirateAgain"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -159,7 +156,6 @@ public void test104JackAssignRolePirateAgain() throws Exception { @Test public void test106JackUnassignRolePirateValid() throws Exception { final String TEST_NAME = "test106JackUnassignRolePirateValid"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -198,7 +194,6 @@ public void test109JackUnassignAll() throws Exception { @Test public void test110JackAssignRolePirateValidToRaw() throws Exception { final String TEST_NAME = "test110JackAssignRolePirateValidToRaw"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -238,7 +233,6 @@ public void test110JackAssignRolePirateValidToRaw() throws Exception { @Test public void test111RecomputeJack() throws Exception { final String TEST_NAME = "test111RecomputeJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -272,7 +266,6 @@ public void test111RecomputeJack() throws Exception { @Test public void test112Forward15min() throws Exception { final String TEST_NAME = "test102Forward15min"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -304,7 +297,6 @@ public void test112Forward15min() throws Exception { @Test public void test114JackAssignRolePirateAgain() throws Exception { final String TEST_NAME = "test114JackAssignRolePirateAgain"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -348,7 +340,6 @@ public void test119JackUnassignAll() throws Exception { @Test public void test120JackAssignRoleSailorValidTo() throws Exception { final String TEST_NAME = "test120JackAssignRoleSailorValidTo"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -390,7 +381,6 @@ public void test120JackAssignRoleSailorValidTo() throws Exception { @Test public void test122Forward15min() throws Exception { final String TEST_NAME = "test122Forward15min"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -422,7 +412,6 @@ public void test122Forward15min() throws Exception { @Test public void test124JackAssignRoleSailorAgain() throws Exception { final String TEST_NAME = "test124JackAssignRoleSailorAgain"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -467,7 +456,6 @@ public void test129JackUnassignAll() throws Exception { @Test public void test130JackAssignRoleSailorValidToRaw() throws Exception { final String TEST_NAME = "test130JackAssignRoleSailorValidToRaw"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -507,7 +495,6 @@ public void test130JackAssignRoleSailorValidToRaw() throws Exception { @Test public void test131RecomputeJack() throws Exception { final String TEST_NAME = "test131RecomputeJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -541,7 +528,6 @@ public void test131RecomputeJack() throws Exception { @Test public void test132Forward15min() throws Exception { final String TEST_NAME = "test132Forward15min"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -573,7 +559,6 @@ public void test132Forward15min() throws Exception { @Test public void test134JackAssignRoleSailorAgain() throws Exception { final String TEST_NAME = "test134JackAssignRoleSailorAgain"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -618,7 +603,6 @@ public void test139JackUnassignAll() throws Exception { @Test public void test140JackAssignRoleSailorValidToRaw() throws Exception { final String TEST_NAME = "test140JackAssignRoleSailorValidToRaw"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -659,7 +643,6 @@ public void test140JackAssignRoleSailorValidToRaw() throws Exception { @Test public void test142Forward15min() throws Exception { final String TEST_NAME = "test142Forward15min"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); @@ -688,7 +671,6 @@ public void test142Forward15min() throws Exception { @Test public void test144JackAssignRoleSailorAgain() throws Exception { final String TEST_NAME = "test144JackAssignRoleSailorAgain"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -731,7 +713,6 @@ public void test149JackUnassignAll() throws Exception { @Test public void test150JackAssignRolePirate() throws Exception { final String TEST_NAME = "test150JackAssignRolePirate"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -767,7 +748,6 @@ public void test150JackAssignRolePirate() throws Exception { @Test public void test151JackAssignRoleSailorValidTo() throws Exception { final String TEST_NAME = "test151JackAssignRoleSailorValidTo"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -809,7 +789,6 @@ public void test151JackAssignRoleSailorValidTo() throws Exception { @Test public void test153Forward15min() throws Exception { final String TEST_NAME = "test153Forward15min"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -843,7 +822,6 @@ public void test153Forward15min() throws Exception { @Test public void test154JackAssignRoleSailorAgain() throws Exception { final String TEST_NAME = "test154JackAssignRoleSailorAgain"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -882,7 +860,6 @@ public void test159JackUnassignAll() throws Exception { @Test public void test160JackAssignRolePirate() throws Exception { final String TEST_NAME = "test160JackAssignRolePirate"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -917,7 +894,6 @@ public void test160JackAssignRolePirate() throws Exception { @Test public void test161JackAssignRoleSailorValidToRaw() throws Exception { final String TEST_NAME = "test161JackAssignRoleSailorValidToRaw"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -963,7 +939,6 @@ public void test161JackAssignRoleSailorValidToRaw() throws Exception { @Test public void test162RecomputeJack() throws Exception { final String TEST_NAME = "test162RecomputeJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1005,7 +980,6 @@ public void test162RecomputeJack() throws Exception { @Test public void test163Forward15min() throws Exception { final String TEST_NAME = "test163Forward15min"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1039,7 +1013,6 @@ public void test163Forward15min() throws Exception { @Test public void test164JackAssignRoleSailorAgain() throws Exception { final String TEST_NAME = "test164JackAssignRoleSailorAgain"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1078,7 +1051,6 @@ public void test169JackUnassignAll() throws Exception { @Test public void test170JackAssignRolePirate() throws Exception { final String TEST_NAME = "test170JackAssignRolePirate"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1113,7 +1085,6 @@ public void test170JackAssignRolePirate() throws Exception { @Test public void test171JackAssignRoleWeakSingerValidTo() throws Exception { final String TEST_NAME = "test171JackAssignRoleWeakSingerValidTo"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1155,7 +1126,6 @@ public void test171JackAssignRoleWeakSingerValidTo() throws Exception { @Test public void test173Forward15min() throws Exception { final String TEST_NAME = "test173Forward15min"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1190,7 +1160,6 @@ public void test173Forward15min() throws Exception { @Test public void test174JackAssignRoleSingerAgain() throws Exception { final String TEST_NAME = "test174JackAssignRoleSingerAgain"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1230,7 +1199,6 @@ public void test179JackUnassignAll() throws Exception { @Test public void test180JackAssignRoleSailorValidToRaw() throws Exception { final String TEST_NAME = "test180JackAssignRoleSailorValidToRaw"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1268,7 +1236,6 @@ public void test180JackAssignRoleSailorValidToRaw() throws Exception { @Test public void test182Forward15minAndAssignRaw() throws Exception { final String TEST_NAME = "test142Forward15min"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1297,7 +1264,6 @@ public void test182Forward15minAndAssignRaw() throws Exception { @Test public void test184RecomputeJack() throws Exception { final String TEST_NAME = "test184RecomputeJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1336,7 +1302,6 @@ public void test189JackUnassignAll() throws Exception { @Test public void test200JackAssignCurrentPirateFutureSailor() throws Exception { final String TEST_NAME = "test200JackAssignCurrentPirateFutureSailor"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1373,7 +1338,6 @@ public void test200JackAssignCurrentPirateFutureSailor() throws Exception { @Test public void test202RecomputeJack() throws Exception { final String TEST_NAME = "test202RecomputeJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1404,7 +1368,6 @@ public void test202RecomputeJack() throws Exception { @Test public void test204ReconcileJack() throws Exception { final String TEST_NAME = "test204ReconcileJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1442,7 +1405,6 @@ public void test209JackUnassignAll() throws Exception { @Test public void test210JackAssignCurrentPirateFutureRichSailor() throws Exception { final String TEST_NAME = "test210JackAssignCurrentPirateFutureRichSailor"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1479,7 +1441,6 @@ public void test210JackAssignCurrentPirateFutureRichSailor() throws Exception { @Test public void test212RecomputeJack() throws Exception { final String TEST_NAME = "test212RecomputeJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1510,7 +1471,6 @@ public void test212RecomputeJack() throws Exception { @Test public void test214ReconcileJack() throws Exception { final String TEST_NAME = "test214ReconcileJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1546,7 +1506,6 @@ public void test219JackUnassignAll() throws Exception { @Test public void test220JackAssignFutureRichSailor() throws Exception { final String TEST_NAME = "test220JackAssignFutureRichSailor"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1590,7 +1549,6 @@ public void test229JackUnassignAll() throws Exception { @Test public void test230JackAssignRoleStrongRichSailorValidTo() throws Exception { final String TEST_NAME = "test230JackAssignRoleStrongRichSailorValidTo"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1635,7 +1593,6 @@ public void test230JackAssignRoleStrongRichSailorValidTo() throws Exception { @Test public void test232Forward15min() throws Exception { final String TEST_NAME = "test232Forward15min"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1673,7 +1630,6 @@ public void test239JackUnassignAll() throws Exception { @Test public void test240JackAssignRoleRichSailorValidTo() throws Exception { final String TEST_NAME = "test240JackAssignRoleRichSailorValidTo"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1718,7 +1674,6 @@ public void test240JackAssignRoleRichSailorValidTo() throws Exception { @Test public void test242Forward15min() throws Exception { final String TEST_NAME = "test242Forward15min"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1755,7 +1710,6 @@ public void test249JackUnassignAll() throws Exception { @Test public void test250JackAssignFocusExistsResource() throws Exception { final String TEST_NAME = "test250JackAssignFocusExistsResource"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1792,7 +1746,6 @@ public void test250JackAssignFocusExistsResource() throws Exception { @Test public void test252RecomputeJack() throws Exception { final String TEST_NAME = "test252RecomputeJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1822,7 +1775,6 @@ public void test252RecomputeJack() throws Exception { @Test public void test254ReconcileJack() throws Exception { final String TEST_NAME = "test254ReconcileJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1924,7 +1876,6 @@ private void assertJackDummyPirateSingerAccount() throws Exception { } private void unassignAll(final String TEST_NAME) throws Exception { - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestAutoassign.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestAutoassign.java index 452c3910a6a..1d73e66b757 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestAutoassign.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestAutoassign.java @@ -23,6 +23,7 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleManagementConfigurationType; import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; @@ -85,7 +86,6 @@ public void initSystem(Task initTask, OperationResult initResult) @Test public void test100ModifyUnitWorker() throws Exception { final String TEST_NAME = "test100ModifyUnitWorker"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -119,7 +119,6 @@ public void test100ModifyUnitWorker() throws Exception { @Test public void test109ModifyUniNull() throws Exception { final String TEST_NAME = "test109ModifyUniNull"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -148,7 +147,6 @@ public void test109ModifyUniNull() throws Exception { @Test public void test110ModifyUnitSleepwalker() throws Exception { final String TEST_NAME = "test110ModifyUnitSleepwalker"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -189,7 +187,6 @@ public void test110ModifyUnitSleepwalker() throws Exception { @Test public void test112ModifyUnitSleeperToWorker() throws Exception { final String TEST_NAME = "test112ModifyUnitSleeperToWorker"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -226,7 +223,6 @@ public void test112ModifyUnitSleeperToWorker() throws Exception { @Test public void test114ModifyUnitAddSleeper() throws Exception { final String TEST_NAME = "test114ModifyUnitAddSleeper"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestMetaMeta.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestMetaMeta.java index 1758c41ce5d..0f48bb7ad98 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestMetaMeta.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestMetaMeta.java @@ -101,7 +101,6 @@ public void initSystem(Task initTask, OperationResult initResult) @Test public void test050AddMetaMeta() throws Exception { final String TEST_NAME = "test050AddMetaMeta"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -137,7 +136,6 @@ public void test050AddMetaMeta() throws Exception { @Test public void test100AddGreeks() throws Exception { final String TEST_NAME = "test100AddGreeks"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -156,7 +154,6 @@ public void test100AddGreeks() throws Exception { @Test public void test110AddRomans() throws Exception { final String TEST_NAME = "test110AddRomans"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -175,7 +172,6 @@ public void test110AddRomans() throws Exception { @Test public void test200CreateAlpha() throws Exception { final String TEST_NAME = "test200CreateAlpha"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -195,7 +191,6 @@ public void test200CreateAlpha() throws Exception { @Test public void test202CreateBeta() throws Exception { final String TEST_NAME = "test202CreateBeta"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -214,7 +209,6 @@ public void test202CreateBeta() throws Exception { @Test public void test210CreateA() throws Exception { final String TEST_NAME = "test210CreateA"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -236,7 +230,6 @@ public void test210CreateA() throws Exception { @Test public void test300AssignAlphaToJack() throws Exception { final String TEST_NAME = "test300AssignAlphaToJack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -256,7 +249,6 @@ public void test300AssignAlphaToJack() throws Exception { @Test public void test309UnassignAlphaFromJack() throws Exception { final String TEST_NAME = "test309UnassignAlphaFromJack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -285,7 +277,6 @@ public void test309UnassignAlphaFromJack() throws Exception { @Test public void test310AssignAToJack() throws Exception { final String TEST_NAME = "test310AssignAToJack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -308,7 +299,6 @@ public void test310AssignAToJack() throws Exception { @Test public void test312AssignBetaToJack() throws Exception { final String TEST_NAME = "test312AssignBetaToJack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -328,7 +318,6 @@ public void test312AssignBetaToJack() throws Exception { @Test public void test319UnassignBetaAFromJack() throws Exception { final String TEST_NAME = "test319UnassignBetaAFromJack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -359,7 +348,6 @@ public void test319UnassignBetaAFromJack() throws Exception { @Test public void test900LegacyAddMetaMeta() throws Exception { final String TEST_NAME = "test900LegacyAddMetaMeta"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -395,7 +383,6 @@ public void test900LegacyAddMetaMeta() throws Exception { @Test public void test910LegacyAddMetaLegacyOne() throws Exception { final String TEST_NAME = "test910LegacyAddMetaLegacyOne"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -432,7 +419,6 @@ public void test910LegacyAddMetaLegacyOne() throws Exception { @Test public void test920LegacyCreateGroupOne() throws Exception { final String TEST_NAME = "test920LegacyCreateGroupOne"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -473,7 +459,6 @@ public void test920LegacyCreateGroupOne() throws Exception { @Test public void test930LegacyAssignGroupOneToJack() throws Exception { final String TEST_NAME = "test930LegacyAssignGroupOneToJack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestRbac.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestRbac.java index aeebe2b6f81..8007bc6eb2d 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestRbac.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestRbac.java @@ -80,7 +80,6 @@ public void initSystem(Task initTask, OperationResult initResult) @Test public void test000SanityRolePirate() throws Exception { final String TEST_NAME = "test000SanityRolePirate"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -99,7 +98,6 @@ public void test000SanityRolePirate() throws Exception { @Test public void test001SanityRoleProjectOmnimanager() throws Exception { final String TEST_NAME = "test001SanityRoleProjectOmnimanager"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -120,7 +118,6 @@ public void test001SanityRoleProjectOmnimanager() throws Exception { @Test public void test010SearchRequestableRoles() throws Exception { final String TEST_NAME = "test010SearchRequestableRoles"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -141,7 +138,6 @@ public void test010SearchRequestableRoles() throws Exception { @Test public void test101JackAssignRolePirate() throws Exception { final String TEST_NAME = "test101JackAssignRolePirate"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -192,7 +188,6 @@ protected ModelExecuteOptions getDefaultOptions() { @Test public void test102JackModifyUserLocality() throws Exception { final String TEST_NAME = "test102JackModifyUserLocality"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -234,7 +229,6 @@ public void test102JackModifyUserLocality() throws Exception { @Test public void test110UnAssignRolePirate() throws Exception { final String TEST_NAME = "test110UnAssignRolePirate"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -257,7 +251,6 @@ public void test110UnAssignRolePirate() throws Exception { @Test public void test120JackAssignRolePirateWhileAlreadyHasAccount() throws Exception { final String TEST_NAME = "test120JackAssignRolePirateWhileAlreadyHasAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -325,7 +318,6 @@ public void test120JackAssignRolePirateWhileAlreadyHasAccount() throws Exception @Test public void test121JackAssignAccountImplicitIntent() throws Exception { final String TEST_NAME = "test121JackAssignAccountImplicitIntent"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -359,7 +351,6 @@ public void test121JackAssignAccountImplicitIntent() throws Exception { @Test public void test122JackAssignAccountExplicitIntent() throws Exception { final String TEST_NAME = "test122JackAssignAccountExplicitIntent"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -393,7 +384,6 @@ public void test122JackAssignAccountExplicitIntent() throws Exception { @Test public void test127UnAssignAccountImplicitIntent() throws Exception { final String TEST_NAME = "test127UnAssignAccountImplicitIntent"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -422,7 +412,6 @@ public void test127UnAssignAccountImplicitIntent() throws Exception { @Test public void test128UnAssignAccountExplicitIntent() throws Exception { final String TEST_NAME = "test128UnAssignAccountExplicitIntent"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -451,7 +440,6 @@ public void test128UnAssignAccountExplicitIntent() throws Exception { @Test public void test129UnAssignRolePirate() throws Exception { final String TEST_NAME = "test129UnAssignRolePirate"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -474,7 +462,6 @@ public void test129UnAssignRolePirate() throws Exception { @Test public void test130JackAssignRolePirateWithSeaInAssignment() throws Exception { final String TEST_NAME = "test130JackAssignRolePirateWithSeaInAssignment"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -512,7 +499,6 @@ public void test130JackAssignRolePirateWithSeaInAssignment() throws Exception { @Test public void test132JackUnAssignRolePirateWithSeaInAssignment() throws Exception { final String TEST_NAME = "test132JackUnAssignRolePirateWithSeaInAssignment"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -545,7 +531,6 @@ public void test132JackUnAssignRolePirateWithSeaInAssignment() throws Exception @Test public void test134JackAssignRoleAdriaticPirate() throws Exception { final String TEST_NAME = "test134JackAssignRoleAdriaticPirate"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -579,7 +564,6 @@ public void test134JackAssignRoleAdriaticPirate() throws Exception { @Test public void test135PreviewChangesEmptyDelta() throws Exception { final String TEST_NAME = "test135PreviewChangesEmptyDelta"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -612,7 +596,6 @@ public void test135PreviewChangesEmptyDelta() throws Exception { @Test public void test136JackUnAssignRoleAdriaticPirate() throws Exception { final String TEST_NAME = "test136JackUnAssignRoleAdriaticPirate"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -639,7 +622,6 @@ public void test136JackUnAssignRoleAdriaticPirate() throws Exception { @Test public void test137JackAssignRoleAdriaticPirateWithSeaInAssignment() throws Exception { final String TEST_NAME = "test137JackAssignRoleAdriaticPirateWithSeaInAssignment"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -677,7 +659,6 @@ public void test137JackAssignRoleAdriaticPirateWithSeaInAssignment() throws Exce @Test public void test139JackUnAssignRoleAdriaticPirateWithSeaInAssignment() throws Exception { final String TEST_NAME = "test139JackUnAssignRoleAdriaticPirateWithSeaInAssignment"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -707,7 +688,6 @@ public void test139JackUnAssignRoleAdriaticPirateWithSeaInAssignment() throws Ex @Test public void test144JackAssignRoleBlackSeaPirate() throws Exception { final String TEST_NAME = "test144JackAssignRoleBlackSeaPirate"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -738,7 +718,6 @@ public void test144JackAssignRoleBlackSeaPirate() throws Exception { @Test public void test146JackUnAssignRoleBlackSeaPirate() throws Exception { final String TEST_NAME = "test146JackUnAssignRoleBlackSeaPirate"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -761,7 +740,6 @@ public void test146JackUnAssignRoleBlackSeaPirate() throws Exception { @Test public void test147JackAssignRoleBlackSeaPirateWithSeaInAssignment() throws Exception { final String TEST_NAME = "test147JackAssignRoleBlackSeaPirateWithSeaInAssignment"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -800,7 +778,6 @@ public void test147JackAssignRoleBlackSeaPirateWithSeaInAssignment() throws Exce @Test public void test149JackUnAssignRoleBlackSeaPirateWithSeaInAssignment() throws Exception { final String TEST_NAME = "test149JackUnAssignRoleBlackSeaPirateWithSeaInAssignment"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -830,7 +807,6 @@ public void test149JackUnAssignRoleBlackSeaPirateWithSeaInAssignment() throws Ex @Test public void test154JackAssignRoleIndianOceanPirate() throws Exception { final String TEST_NAME = "test154JackAssignRoleIndianOceanPirate"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -865,7 +841,6 @@ public void test154JackAssignRoleIndianOceanPirate() throws Exception { @Test public void test156JackUnAssignRoleIndianOceanPirate() throws Exception { final String TEST_NAME = "test156JackUnAssignRoleIndianOceanPirate"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -939,7 +914,6 @@ public void test169JackUnassignRolePirateComplicated() throws Exception { } public void testJackAssignRolePirateRelationNoPrivs(final String TEST_NAME, QName relation) throws Exception { - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -982,7 +956,6 @@ private void assertJackAssignRolePirateRelationNoPrivs(QName relation) throws Ex } public void testJackUnassignRolePirateRelationNoPrivs(final String TEST_NAME, QName relation) throws Exception { - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1017,7 +990,6 @@ public void testJackUnassignRolePirateRelationNoPrivs(final String TEST_NAME, QN @Test public void test200ImportRoleAllTreasure() throws Exception { final String TEST_NAME = "test200ImportRoleAllTreasure"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1040,7 +1012,6 @@ public void test200ImportRoleAllTreasure() throws Exception { @Test public void test202JackAssignRoleAllTreasure() throws Exception { final String TEST_NAME = "test202JackAssignRoleAllTreasure"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1074,7 +1045,6 @@ public void test202JackAssignRoleAllTreasure() throws Exception { @Test public void test204AddGoldTreasureAndRecomputeJack() throws Exception { final String TEST_NAME = "test204AddGoldTreasureAndRecomputeJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1105,7 +1075,6 @@ public void test204AddGoldTreasureAndRecomputeJack() throws Exception { @Test public void test206JackAssignRoleAllLoot() throws Exception { final String TEST_NAME = "test206JackAssignRoleAllLoot"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1132,7 +1101,6 @@ public void test206JackAssignRoleAllLoot() throws Exception { @Test public void test208JackUnassignRoleAllLoot() throws Exception { final String TEST_NAME = "test208JackUnassignRoleAllLoot"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1158,7 +1126,6 @@ public void test208JackUnassignRoleAllLoot() throws Exception { @Test public void test209JackUnassignRoleAllTreasure() throws Exception { final String TEST_NAME = "test209JackUnassignRoleAllTreasure"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1182,7 +1149,6 @@ public void test209JackUnassignRoleAllTreasure() throws Exception { @Test(enabled=false) // MID-3966 public void test210JackAssignRoleAllYouCanGet() throws Exception { final String TEST_NAME = "test210JackAssignRoleAllYouCanGet"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1209,7 +1175,6 @@ public void test210JackAssignRoleAllYouCanGet() throws Exception { @Test(enabled=false) // MID-3966 public void test219JackUnassignRoleAllYouCanGet() throws Exception { final String TEST_NAME = "test219JackUnassignRoleAllYouCanGet"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1234,7 +1199,6 @@ public void test219JackUnassignRoleAllYouCanGet() throws Exception { @Test public void test501JackAssignRolePirate() throws Exception { final String TEST_NAME = "test501JackAssignRolePirate"; - displayTestTitle(TEST_NAME); // IMPORTANT: Changing the assignment policy assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -1271,7 +1235,6 @@ public void test501JackAssignRolePirate() throws Exception { @Test public void test502JackModifyUserLocality() throws Exception { final String TEST_NAME = "test502JackModifyUserLocality"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1311,7 +1274,6 @@ public void test502JackModifyUserLocality() throws Exception { @Test public void test510UnAssignRolePirate() throws Exception { final String TEST_NAME = "test510UnAssignRolePirate"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1340,7 +1302,6 @@ public void test510UnAssignRolePirate() throws Exception { @Test public void test511DeleteAccount() throws Exception { final String TEST_NAME = "test511DeleteAccount"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1372,7 +1333,6 @@ public void test511DeleteAccount() throws Exception { @Test public void test520JackAssignRolePirate() throws Exception { final String TEST_NAME = "test520JackAssignRolePirate"; - displayTestTitle(TEST_NAME); // IMPORTANT: Changing the assignment policy assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -1405,7 +1365,6 @@ public void test520JackAssignRolePirate() throws Exception { @Test public void test521JackUnassignRolePirateDeleteAccount() throws Exception { final String TEST_NAME = "test521JackUnassignRolePirateDeleteAccount"; - displayTestTitle(TEST_NAME); // IMPORTANT: Changing the assignment policy assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -1441,7 +1400,6 @@ public void test521JackUnassignRolePirateDeleteAccount() throws Exception { @Test public void test530JackAssignRoleCleric() throws Exception { final String TEST_NAME = "test530JackAssignRoleCleric"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Task task = createTask(TEST_NAME); @@ -1459,7 +1417,6 @@ public void test530JackAssignRoleCleric() throws Exception { @Test public void test532JackModifyAssignmentRoleCleric() throws Exception { final String TEST_NAME = "test532JackModifyAssignmentRoleCleric"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Task task = createTask(TEST_NAME); @@ -1494,7 +1451,6 @@ public void test532JackModifyAssignmentRoleCleric() throws Exception { @Test public void test539JackUnAssignRoleCleric() throws Exception { final String TEST_NAME = "test539JackUnAssignRoleCleric"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Task task = createTask(TEST_NAME); @@ -1531,7 +1487,6 @@ public void test539JackUnAssignRoleCleric() throws Exception { @Test public void test540JackAssignRoleWannabe() throws Exception { final String TEST_NAME = "test540JackAssignRoleWannabe"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Task task = createTask(TEST_NAME); @@ -1561,7 +1516,6 @@ public void test540JackAssignRoleWannabe() throws Exception { @Test public void test541JackRemoveHonorificSuffixWannabe() throws Exception { final String TEST_NAME = "test541JackRemoveHonorificSuffixWannabe"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Task task = createTask(TEST_NAME); @@ -1590,7 +1544,6 @@ public void test541JackRemoveHonorificSuffixWannabe() throws Exception { @Test public void test542JackModifySubtypeWannabe() throws Exception { final String TEST_NAME = "test542JackModifySubtypeWannabe"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Task task = createTask(TEST_NAME); @@ -1620,7 +1573,6 @@ public void test542JackModifySubtypeWannabe() throws Exception { @Test public void test543JackRemoveHonorificPrefixWannabe() throws Exception { final String TEST_NAME = "test543JackRemoveHonorificPrefixWannabe"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Task task = createTask(TEST_NAME); @@ -1649,7 +1601,6 @@ public void test543JackRemoveHonorificPrefixWannabe() throws Exception { @Test public void test544JackSetHonorificSuffixWannabe() throws Exception { final String TEST_NAME = "test544JackSetHonorificSuffixWannabe"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Task task = createTask(TEST_NAME); @@ -1681,7 +1632,6 @@ public void test544JackSetHonorificSuffixWannabe() throws Exception { @Test public void test545JackRestoreHonorificPrefixWannabe() throws Exception { final String TEST_NAME = "test545JackRestoreHonorificPrefixWannabe"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Task task = createTask(TEST_NAME); @@ -1712,7 +1662,6 @@ public void test545JackRestoreHonorificPrefixWannabe() throws Exception { @Test public void test549JackUnassignRoleWannabe() throws Exception { final String TEST_NAME = "test549JackUnassignRoleWannabe"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Task task = createTask(TEST_NAME); @@ -1738,7 +1687,6 @@ public void test549JackUnassignRoleWannabe() throws Exception { @Test public void test600JackAssignRoleJudge() throws Exception { final String TEST_NAME = "test600JackAssignRoleJudge"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Task task = createTask(TEST_NAME); @@ -1775,7 +1723,6 @@ public void test600JackAssignRoleJudge() throws Exception { @Test public void test602JackAssignRolePirate() throws Exception { final String TEST_NAME = "test602JackAssignRolePirate"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Task task = createTask(TEST_NAME); @@ -1811,7 +1758,6 @@ public void test602JackAssignRolePirate() throws Exception { @Test public void test605JackUnAssignRoleJudgeAssignRolePirate() throws Exception { final String TEST_NAME = "test605JackUnAssignRoleJudgeAssignRolePirate"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Task task = createTask(TEST_NAME); @@ -1849,7 +1795,6 @@ public void test605JackUnAssignRoleJudgeAssignRolePirate() throws Exception { @Test public void test609JackUnAssignRolePirate() throws Exception { final String TEST_NAME = "test609JackUnAssignRolePirate"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Task task = createTask(TEST_NAME); @@ -1870,7 +1815,6 @@ public void test609JackUnAssignRolePirate() throws Exception { @Test public void test610ElaineAssignRoleGovernor() throws Exception { final String TEST_NAME = "test610ElaineAssignRoleGovernor"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Task task = createTask(TEST_NAME); @@ -1908,7 +1852,6 @@ public void test610ElaineAssignRoleGovernor() throws Exception { @Test public void test612JackAssignRoleGovernor() throws Exception { final String TEST_NAME = "test612JackAssignRoleGovernor"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Task task = createTask(TEST_NAME); @@ -1945,7 +1888,6 @@ public void test613JackAssignRoleGovernorAsApprover() throws Exception { } final String TEST_NAME = "test613JackAssignRoleGovernorAsApprover"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Task task = createTask(TEST_NAME); @@ -1979,7 +1921,6 @@ public void test613JackAssignRoleGovernorAsApprover() throws Exception { @Test public void test620LemonheadAssignRoleCanibal() throws Exception { final String TEST_NAME = "test620LemonheadAssignRoleCanibal"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Task task = createTask(TEST_NAME); @@ -2010,7 +1951,6 @@ public void test620LemonheadAssignRoleCanibal() throws Exception { @Test public void test622SharptoothAssignRoleCanibal() throws Exception { final String TEST_NAME = "test622SharptoothAssignRoleCanibal"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Task task = createTask(TEST_NAME); @@ -2041,7 +1981,6 @@ public void test622SharptoothAssignRoleCanibal() throws Exception { @Test public void test624RedskullAssignRoleCanibal() throws Exception { final String TEST_NAME = "test624RedskullAssignRoleCanibal"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Task task = createTask(TEST_NAME); @@ -2072,7 +2011,6 @@ public void test624RedskullAssignRoleCanibal() throws Exception { @Test public void test625BignoseAssignRoleCanibal() throws Exception { final String TEST_NAME = "test625BignoseAssignRoleCanibal"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Task task = createTask(TEST_NAME); @@ -2109,7 +2047,6 @@ public void test625BignoseAssignRoleCanibal() throws Exception { @Test public void test627SharptoothUnassignRoleCanibal() throws Exception { final String TEST_NAME = "test627SharptoothUnassignRoleCanibal"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Task task = createTask(TEST_NAME); @@ -2135,7 +2072,6 @@ public void test627SharptoothUnassignRoleCanibal() throws Exception { @Test public void test628RedskullUnassignRoleCanibal() throws Exception { final String TEST_NAME = "test628RedskullUnassignRoleCanibal"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Task task = createTask(TEST_NAME); @@ -2175,7 +2111,6 @@ public void test630RappAssignRoleCannibalAsOwner() throws Exception { } final String TEST_NAME = "test630RappAssignRoleCannibalAsOwner"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Task task = createTask(TEST_NAME); @@ -2205,7 +2140,6 @@ public void test632RappUnassignRoleCannibalAsOwner() throws Exception { } final String TEST_NAME = "test632RappUnassignRoleCannibalAsOwner"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Task task = createTask(TEST_NAME); @@ -2246,7 +2180,6 @@ public void test634BignoseAssignRoleCannibalAsOwner() throws Exception { } final String TEST_NAME = "test634BignoseAssignRoleCannibalAsOwner"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Task task = createTask(TEST_NAME); @@ -2282,7 +2215,6 @@ public void test636BignoseUnassignRoleCannibalAsOwner() throws Exception { } final String TEST_NAME = "test636BignoseUnassignRoleCannibalAsOwner"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Task task = createTask(TEST_NAME); @@ -2309,7 +2241,6 @@ public void test636BignoseUnassignRoleCannibalAsOwner() throws Exception { @Test public void test649ElaineUnassignRoleGovernor() throws Exception { final String TEST_NAME = "test649ElaineUnassignRoleGovernor"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Task task = createTask(TEST_NAME); @@ -2338,7 +2269,6 @@ public void test649ElaineUnassignRoleGovernor() throws Exception { @Test public void test650BignoseAssignRoleCannibalAsOwner() throws Exception { final String TEST_NAME = "test650BignoseAssignRoleCannibalAsOwner"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); assertUserBefore(userBignoseOid) @@ -2365,7 +2295,6 @@ public void test650BignoseAssignRoleCannibalAsOwner() throws Exception { @Test public void test651BignoseAssignRoleCannibalAsApprover() throws Exception { final String TEST_NAME = "test651BignoseAssignRoleCannibalAsApprover"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Task task = createTask(TEST_NAME); @@ -2392,7 +2321,6 @@ public void test651BignoseAssignRoleCannibalAsApprover() throws Exception { @Test public void test655BignoseAssignRoleCannibal() throws Exception { final String TEST_NAME = "test655BignoseAssignRoleCannibal"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Task task = createTask(TEST_NAME); @@ -2417,7 +2345,6 @@ public void test655BignoseAssignRoleCannibal() throws Exception { @Test public void test656BignoseUnassignRoleCannibal() throws Exception { final String TEST_NAME = "test656BignoseUnassignRoleCannibal"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Task task = createTask(TEST_NAME); @@ -2441,7 +2368,6 @@ public void test656BignoseUnassignRoleCannibal() throws Exception { @Test public void test658BignoseUnassignRoleCannibalAsOwner() throws Exception { final String TEST_NAME = "test658BignoseUnassignRoleCannibalAsOwner"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Task task = createTask(TEST_NAME); @@ -2468,7 +2394,6 @@ public void test658BignoseUnassignRoleCannibalAsOwner() throws Exception { @Test public void test700JackAssignRoleJudge() throws Exception { final String TEST_NAME = "test700JackModifyJudgeRecompute"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -2494,7 +2419,6 @@ public void test700JackAssignRoleJudge() throws Exception { @Test public void test701JackModifyJudgeDeleteConstructionRecompute() throws Exception { final String TEST_NAME = "test701JackModifyJudgeDeleteConstructionRecompute"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -2525,7 +2449,6 @@ public void test701JackModifyJudgeDeleteConstructionRecompute() throws Exception @Test public void test702JackModifyJudgeAddInducementHonorabilityRecompute() throws Exception { final String TEST_NAME = "test702JackModifyJudgeAddInducementHonorabilityRecompute"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -2561,7 +2484,6 @@ public void test702JackModifyJudgeAddInducementHonorabilityRecompute() throws Ex @Test public void test703JackModifyJudgeDeleteInducementHonorabilityRecompute() throws Exception { final String TEST_NAME = "test703JackModifyJudgeDeleteInducementHonorabilityRecompute"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -2597,7 +2519,6 @@ public void test703JackModifyJudgeDeleteInducementHonorabilityRecompute() throws @Test public void test709JackUnAssignRoleJudge() throws Exception { final String TEST_NAME = "test709JackUnAssignRoleJudge"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -2622,7 +2543,6 @@ public void test709JackUnAssignRoleJudge() throws Exception { @Test public void test710JackAssignRoleEmpty() throws Exception { final String TEST_NAME = "test710JackAssignRoleEmpty"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -2648,7 +2568,6 @@ public void test710JackAssignRoleEmpty() throws Exception { @Test public void test712JackModifyEmptyRoleAddInducementPirateRecompute() throws Exception { final String TEST_NAME = "test712JackModifyEmptyRoleAddInducementPirateRecompute"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -2681,7 +2600,6 @@ public void test712JackModifyEmptyRoleAddInducementPirateRecompute() throws Exce @Test public void test714JackModifyEmptyRoleDeleteInducementPirateRecompute() throws Exception { final String TEST_NAME = "test714JackModifyEmptyRoleDeleteInducementPirateRecompute"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -2709,7 +2627,6 @@ public void test714JackModifyEmptyRoleDeleteInducementPirateRecompute() throws E @Test public void test719JackUnAssignRoleEmpty() throws Exception { final String TEST_NAME = "test719JackUnAssignRoleEmpty"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -2734,7 +2651,6 @@ public void test719JackUnAssignRoleEmpty() throws Exception { @Test public void test720JackAssignRoleGovernorTenantRef() throws Exception { final String TEST_NAME = "test720JackAssignRoleGovernorTenantRef"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -2766,7 +2682,6 @@ public void test720JackAssignRoleGovernorTenantRef() throws Exception { @Test public void test729JackUnassignRoleGovernorTenantRef() throws Exception { final String TEST_NAME = "test729JackUnassignRoleGovernorTenantRef"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -2799,7 +2714,6 @@ public void test729JackUnassignRoleGovernorTenantRef() throws Exception { @Test public void test750JackAssignRoleOmnimanager() throws Exception { final String TEST_NAME = "test750JackAssignRoleOmnimanager"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -2831,7 +2745,6 @@ public void test750JackAssignRoleOmnimanager() throws Exception { @Test public void test755AddProjectAndRecomputeJack() throws Exception { final String TEST_NAME = "test755AddProjectAndRecomputeJack"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -2867,7 +2780,6 @@ public void test755AddProjectAndRecomputeJack() throws Exception { @Test public void test759JackUnassignRoleOmnimanager() throws Exception { final String TEST_NAME = "test759JackUnassignRoleOmnimanager"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -2899,7 +2811,6 @@ public void test759JackUnassignRoleOmnimanager() throws Exception { @Test public void test760JackAssignRoleWeakGossiper() throws Exception { final String TEST_NAME = "test760JackAssignRoleWeakGossiper"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -2936,7 +2847,6 @@ public void test760JackAssignRoleWeakGossiper() throws Exception { @Test public void test761JackRecompute() throws Exception { final String TEST_NAME = "test761JackRecompute"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -2970,7 +2880,6 @@ public void test761JackRecompute() throws Exception { @Test public void test762JackReconcile() throws Exception { final String TEST_NAME = "test762JackReconcile"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -3004,7 +2913,6 @@ public void test762JackReconcile() throws Exception { @Test public void test763PreviewChanges() throws Exception { final String TEST_NAME = "test763PreviewChanges"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -3064,7 +2972,6 @@ public void test763PreviewChanges() throws Exception { @Test public void test764JackAssignRoleSailor() throws Exception { final String TEST_NAME = "test764JackAssignRoleSailor"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -3104,7 +3011,6 @@ public void test764JackAssignRoleSailor() throws Exception { @Test public void test765JackRecompute() throws Exception { final String TEST_NAME = "test765JackRecompute"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -3143,7 +3049,6 @@ public void test765JackRecompute() throws Exception { @Test public void test766JackReconcile() throws Exception { final String TEST_NAME = "test766JackReconcile"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -3184,7 +3089,6 @@ public void test766JackReconcile() throws Exception { @Test public void test767JackUnAssignRoleWeakGossiper() throws Exception { final String TEST_NAME = "test767JackUnAssignRoleWeakGossiper"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -3222,7 +3126,6 @@ public void test767JackUnAssignRoleWeakGossiper() throws Exception { @Test public void test768JackRecompute() throws Exception { final String TEST_NAME = "test768JackRecompute"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -3260,7 +3163,6 @@ public void test768JackRecompute() throws Exception { @Test public void test769JackUnAssignRoleSailor() throws Exception { final String TEST_NAME = "test762JackAssignRoleSailor"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -3295,7 +3197,6 @@ public void test769JackUnAssignRoleSailor() throws Exception { @Test public void test770JackAssignRoleSailor() throws Exception { final String TEST_NAME = "test770JackAssignRoleSailor"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -3335,7 +3236,6 @@ public void test770JackAssignRoleSailor() throws Exception { @Test public void test772JackAssignRoleGossiper() throws Exception { final String TEST_NAME = "test772JackAssignRoleGossiper"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -3376,7 +3276,6 @@ public void test772JackAssignRoleGossiper() throws Exception { @Test public void test774JackUnAssignRoleSailor() throws Exception { final String TEST_NAME = "test774JackUnAssignRoleSailor"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -3411,7 +3310,6 @@ public void test774JackUnAssignRoleSailor() throws Exception { @Test public void test775JackUnAssignRoleGossiper() throws Exception { final String TEST_NAME = "test775JackUnAssignRoleGossiper"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -3447,7 +3345,6 @@ public void test775JackUnAssignRoleGossiper() throws Exception { @Test public void test778JackAssignRoleGossiperAndSailor() throws Exception { final String TEST_NAME = "test778JackAssignRoleGossiperAndSailor"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -3494,7 +3391,6 @@ public void test778JackAssignRoleGossiperAndSailor() throws Exception { @Test public void test779JackUnassignRoleGossiperAndSailor() throws Exception { final String TEST_NAME = "test779JackUnassignRoleGossiperAndSailor"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -3535,7 +3431,6 @@ public void test779JackUnassignRoleGossiperAndSailor() throws Exception { @Test public void test780JackAssignRoleWeakSinger() throws Exception { final String TEST_NAME = "test780JackAssignRoleWeakSinger"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -3573,7 +3468,6 @@ public void test780JackAssignRoleWeakSinger() throws Exception { @Test public void test781JackAssignRoleWeakGossiper() throws Exception { final String TEST_NAME = "test781JackAssignRoleWeakGossiper"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -3611,7 +3505,6 @@ public void test781JackAssignRoleWeakGossiper() throws Exception { @Test public void test782JackAssignRoleSailor() throws Exception { final String TEST_NAME = "test782JackAssignRoleSailor"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -3654,7 +3547,6 @@ public void test782JackAssignRoleSailor() throws Exception { @Test public void test783JackUnassignRoleSailor() throws Exception { final String TEST_NAME = "test783JackUnassignRoleSailor"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -3689,7 +3581,6 @@ public void test783JackUnassignRoleSailor() throws Exception { @Test public void test784JackUnAssignRoleWeakSinger() throws Exception { final String TEST_NAME = "test784JackUnAssignRoleWeakSinger"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -3726,7 +3617,6 @@ public void test784JackUnAssignRoleWeakSinger() throws Exception { @Test public void test785JackUnAssignRoleGossiper() throws Exception { final String TEST_NAME = "test785JackUnAssignRoleGossiper"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -3761,7 +3651,6 @@ public void test785JackUnAssignRoleGossiper() throws Exception { @Test public void test786JackAssignRoleGossiperAndSinger() throws Exception { final String TEST_NAME = "test786JackAssignRoleGossiperAndSinger"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -3803,7 +3692,6 @@ public void test786JackAssignRoleGossiperAndSinger() throws Exception { @Test public void test788JackUnassignRoleGossiperAndSinger() throws Exception { final String TEST_NAME = "test788JackUnassignRoleGossiperAndSinger"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -3845,7 +3733,6 @@ public void test788JackUnassignRoleGossiperAndSinger() throws Exception { @Test public void test790JackAssignRoleWeakSinger() throws Exception { final String TEST_NAME = "test780JackAssignRoleWeakSinger"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -3885,7 +3772,6 @@ public void test790JackAssignRoleWeakSinger() throws Exception { @Test public void test791JackSwitchRolesGossiperAndSinger() throws Exception { final String TEST_NAME = "test791JackSwitchRolesGossiperAndSinger"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -3928,7 +3814,6 @@ public void test791JackSwitchRolesGossiperAndSinger() throws Exception { @Test public void test792JackAssignRoleSailor() throws Exception { final String TEST_NAME = "test792JackAssignRoleSailor"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -3973,7 +3858,6 @@ public void test792JackAssignRoleSailor() throws Exception { @Test public void test793JackSwitchRolesSingerAndGossiper() throws Exception { final String TEST_NAME = "test793JackSwitchRolesSingerAndGossiper"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -4020,7 +3904,6 @@ public void test793JackSwitchRolesSingerAndGossiper() throws Exception { @Test public void test794JackSwitchRolesSailorAndGossiper() throws Exception { final String TEST_NAME = "test793JackSwitchRolesSingerAndGossiper"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -4061,7 +3944,6 @@ public void test794JackSwitchRolesSailorAndGossiper() throws Exception { @Test public void test795JackSwitchRolesSingerAndSailor() throws Exception { final String TEST_NAME = "test795JackSwitchRolesSingerAndSailor"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -4108,7 +3990,6 @@ public void test795JackSwitchRolesSingerAndSailor() throws Exception { @Test public void test796JackSwitchRolesSailorAndGovernor() throws Exception { final String TEST_NAME = "test796JackSwitchRolesSailorAndGovernor"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -4156,7 +4037,6 @@ public void test796JackSwitchRolesSailorAndGovernor() throws Exception { @Test public void test799JackUnassignGovernorAndWeakGossiper() throws Exception { final String TEST_NAME = "test799JackUnassignGovernorAndWeakGossiper"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -4192,7 +4072,6 @@ public void test799JackUnassignGovernorAndWeakGossiper() throws Exception { @Test public void test800ModifyRoleImmutable() throws Exception { final String TEST_NAME = "test800ModifyRoleImmutable"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -4223,7 +4102,6 @@ public void test800ModifyRoleImmutable() throws Exception { @Test public void test802AddGlobalImmutableRole() throws Exception { final String TEST_NAME = "test802AddGlobalImmutableRole"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -4249,7 +4127,6 @@ public void test802AddGlobalImmutableRole() throws Exception { @Test public void test804ModifyRoleImmutableGlobalIdentifier() throws Exception { final String TEST_NAME = "test804ModifyRoleImmutableGlobalIdentifier"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -4277,7 +4154,6 @@ public void test804ModifyRoleImmutableGlobalIdentifier() throws Exception { @Test public void test805ModifyRoleImmutableGlobalDescription() throws Exception { final String TEST_NAME = "test805ModifyRoleImmutableGlobalDescription"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -4309,7 +4185,6 @@ public void test805ModifyRoleImmutableGlobalDescription() throws Exception { @Test public void test812AddGlobalImmutableDescriptionRole() throws Exception { final String TEST_NAME = "test812AddGlobalImmutableDescriptionRole"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -4338,7 +4213,6 @@ public void test812AddGlobalImmutableDescriptionRole() throws Exception { @Test public void test814ModifyRoleImmutableDescriptionGlobalIdentifier() throws Exception { final String TEST_NAME = "test814ModifyRoleImmutableDescriptionGlobalIdentifier"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -4363,7 +4237,6 @@ public void test814ModifyRoleImmutableDescriptionGlobalIdentifier() throws Excep @Test public void test815ModifyRoleImmutableGlobalDescription() throws Exception { final String TEST_NAME = "test815ModifyRoleImmutableGlobalDescription"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -4390,7 +4263,6 @@ public void test815ModifyRoleImmutableGlobalDescription() throws Exception { @Test public void test826AddNonCreateableRole() throws Exception { final String TEST_NAME = "test826AddNonCreateableRole"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -4418,7 +4290,6 @@ public void test826AddNonCreateableRole() throws Exception { @Test public void test826bAddCreateableRole() throws Exception { final String TEST_NAME = "test826bAddCreateableRole"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -4443,7 +4314,6 @@ public void test826bAddCreateableRole() throws Exception { @Test public void test827AddImmutableAssignRole() throws Exception { final String TEST_NAME = "test827AddImmutableAssignRole"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -4476,7 +4346,6 @@ public void test827AddImmutableAssignRole() throws Exception { @Test public void test828ModifyUntouchableMetarole() throws Exception { final String TEST_NAME = "test828ModifyUntouchableMetarole"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -4499,7 +4368,6 @@ public void test828ModifyUntouchableMetarole() throws Exception { @Test public void test830ModifyRoleJudge() throws Exception { final String TEST_NAME = "test830ModifyRoleJudge"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -4522,7 +4390,6 @@ public void test830ModifyRoleJudge() throws Exception { @Test public void test840AssignRoleNonAssignable() throws Exception { final String TEST_NAME = "test840AssignRoleNonAssignable"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -4553,7 +4420,6 @@ public void test840AssignRoleNonAssignable() throws Exception { @Test public void test850JackAssignRoleBloodyFool() throws Exception { final String TEST_NAME = "test850JackAssignRoleBloodyFool"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -4591,7 +4457,6 @@ public void test850JackAssignRoleBloodyFool() throws Exception { @Test public void test855JackModifyFoolMetaroleDeleteInducement() throws Exception { final String TEST_NAME = "test855JackModifyFoolMetaroleDeleteInducement"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -4619,7 +4484,6 @@ public void test855JackModifyFoolMetaroleDeleteInducement() throws Exception { @Test public void test857JackReconcile() throws Exception { final String TEST_NAME = "test857JackReconcile"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -4660,7 +4524,6 @@ public void test857JackReconcile() throws Exception { @Test public void test870AssignRoleScreaming() throws Exception { final String TEST_NAME = "test870AssignRoleScreaming"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); notificationManager.setDisabled(false); @@ -4698,7 +4561,6 @@ public void test870AssignRoleScreaming() throws Exception { @Test public void test880GlobalRuleOnChange() throws Exception { final String TEST_NAME = "test880GlobalRuleOnChange"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -4720,7 +4582,6 @@ public void test880GlobalRuleOnChange() throws Exception { @Test(enabled = false) // MID-4856 public void test890DeleteRoleUndeletable() throws Exception { final String TEST_NAME = "test890DeleteRoleUndeletable"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -4742,7 +4603,6 @@ public void test890DeleteRoleUndeletable() throws Exception { @Test // MID-4856 public void test892DeleteRoleUndeletableGlobal() throws Exception { final String TEST_NAME = "test892DeleteRoleUndeletableGlobal"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); @@ -4765,7 +4625,6 @@ public void test892DeleteRoleUndeletableGlobal() throws Exception { @Test public void test900ModifyDetectingRole() throws Exception { final String TEST_NAME = "test900ModifyDetectingRole"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); Task task = createTask(TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestSegregationOfDuties.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestSegregationOfDuties.java index 3913af56336..baf70d05de2 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestSegregationOfDuties.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestSegregationOfDuties.java @@ -36,6 +36,7 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.CommunicationException; @@ -187,7 +188,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test110SimpleExclusion1() throws Exception { final String TEST_NAME = "test110SimpleExclusion1"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -220,7 +220,6 @@ public void test110SimpleExclusion1() throws Exception { @Test public void test120SimpleExclusion2() throws Exception { final String TEST_NAME = "test120SimpleExclusion2"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -245,7 +244,6 @@ public void test120SimpleExclusion2() throws Exception { @Test public void test130SimpleExclusionBoth1() throws Exception { final String TEST_NAME = "test130SimpleExclusionBoth1"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -270,7 +268,6 @@ public void test130SimpleExclusionBoth1() throws Exception { @Test public void test140SimpleExclusionBoth2() throws Exception { final String TEST_NAME = "test140SimpleExclusionBoth2"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -295,7 +292,6 @@ public void test140SimpleExclusionBoth2() throws Exception { @Test public void test150SimpleExclusionBothBidirectional1() throws Exception { final String TEST_NAME = "test150SimpleExclusionBothBidirectional1"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -320,7 +316,6 @@ public void test150SimpleExclusionBothBidirectional1() throws Exception { @Test public void test160SimpleExclusionBothBidirectional2() throws Exception { final String TEST_NAME = "test160SimpleExclusionBothBidirectional2"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -345,7 +340,6 @@ public void test160SimpleExclusionBothBidirectional2() throws Exception { @Test public void test171SimpleExclusion1WithPolicyException() throws Exception { final String TEST_NAME = "test171SimpleExclusion1WithPolicyException"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -367,7 +361,6 @@ public void test171SimpleExclusion1WithPolicyException() throws Exception { @Test public void test172SimpleExclusion2WithPolicyException() throws Exception { final String TEST_NAME = "test172SimpleExclusion2WithPolicyException"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -389,7 +382,6 @@ public void test172SimpleExclusion2WithPolicyException() throws Exception { @Test public void test173SimpleExclusion3WithPolicyException() throws Exception { final String TEST_NAME = "test173SimpleExclusion3WithPolicyException"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -411,7 +403,6 @@ public void test173SimpleExclusion3WithPolicyException() throws Exception { @Test public void test174SimpleExclusion4WithPolicyException() throws Exception { final String TEST_NAME = "test174SimpleExclusion4WithPolicyException"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -438,7 +429,6 @@ public void test174SimpleExclusion4WithPolicyException() throws Exception { @Test public void test180JudgeExceptionalPirateAndThief() throws Exception { final String TEST_NAME = "test180JudgeExceptionalPirateAndThief"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -478,7 +468,6 @@ private Consumer getJudgeExceptionBlock(String excludedRoleName) @Test public void test190DifferentRelations() throws Exception { final String TEST_NAME = "test190DifferentRelations"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -502,7 +491,6 @@ public void test190DifferentRelations() throws Exception { @Test public void test193BothRelationsApprover() throws Exception { final String TEST_NAME = "test193BothRelationsApprover"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -526,7 +514,6 @@ public void test193BothRelationsApprover() throws Exception { @Test public void test194MemberAndManager() throws Exception { final String TEST_NAME = "test194MemberAndManager"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -557,7 +544,6 @@ public void test194MemberAndManager() throws Exception { @Test public void test200GuybrushAssignRoleGold() throws Exception { final String TEST_NAME = "test200GuybrushAssignRoleGold"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -591,7 +577,6 @@ public void test200GuybrushAssignRoleGold() throws Exception { @Test public void test202GuybrushAssignRoleSilver() throws Exception { final String TEST_NAME = "test202GuybrushAssignRoleSilver"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -626,7 +611,6 @@ public void test202GuybrushAssignRoleSilver() throws Exception { @Test public void test204GuybrushAssignRoleSailor() throws Exception { final String TEST_NAME = "test204GuybrushAssignRoleSailor"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -662,7 +646,6 @@ public void test204GuybrushAssignRoleSailor() throws Exception { @Test public void test206GuybrushAssignRoleBronze() throws Exception { final String TEST_NAME = "test206GuybrushAssignRoleBronze"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -697,7 +680,6 @@ public void test206GuybrushAssignRoleBronze() throws Exception { @Test public void test208GuybrushUnassignRoleBronze() throws Exception { final String TEST_NAME = "test208GuybrushUnassignRoleSilver"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -730,7 +712,6 @@ public void test208GuybrushUnassignRoleBronze() throws Exception { @Test public void test209GuybrushUnassignRoleSailor() throws Exception { final String TEST_NAME = "test209GuybrushUnassignRoleSailor"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -761,7 +742,6 @@ public void test209GuybrushUnassignRoleSailor() throws Exception { @Test public void test209aGuybrushAssignRoleGoldAndSilverEnforced() throws Exception { final String TEST_NAME = "test209aGuybrushAssignRoleGoldAndSilverEnforced"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -794,7 +774,6 @@ public void test209aGuybrushAssignRoleGoldAndSilverEnforced() throws Exception { @Test public void test209bGuybrushAssignRoleGoldAndSilver() throws Exception { final String TEST_NAME = "test209bGuybrushAssignRoleGoldAndSilver"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -827,7 +806,6 @@ public void test209bGuybrushAssignRoleGoldAndSilver() throws Exception { @Test public void test210GuybrushAssignRoleRed() throws Exception { final String TEST_NAME = "test210GuybrushAssignRoleRed"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -859,7 +837,6 @@ public void test210GuybrushAssignRoleRed() throws Exception { @Test public void test212GuybrushAssignRoleGreen() throws Exception { final String TEST_NAME = "test212GuybrushAssignRoleGreen"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -892,7 +869,6 @@ public void test212GuybrushAssignRoleGreen() throws Exception { @Test public void test214GuybrushAssignRoleColorNone() throws Exception { final String TEST_NAME = "test214GuybrushAssignRoleColorNone"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -923,7 +899,6 @@ public void test214GuybrushAssignRoleColorNone() throws Exception { @Test public void test216GuybrushAssignRoleBlue() throws Exception { final String TEST_NAME = "test216GuybrushAssignRoleBlue"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -953,7 +928,6 @@ public void test216GuybrushAssignRoleBlue() throws Exception { @Test public void test219GuybrushUnassignRoleBlue() throws Exception { final String TEST_NAME = "test219GuybrushUnassignRoleBlue"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -981,7 +955,6 @@ public void test219GuybrushUnassignRoleBlue() throws Exception { @Test public void test220GuybrushAssignRoleBlue() throws Exception { final String TEST_NAME = "test220GuybrushAssignRoleBlue"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1014,7 +987,6 @@ public void test220GuybrushAssignRoleBlue() throws Exception { @Test public void test221GuybrushDestroyAndRecompute() throws Exception { final String TEST_NAME = "test221GuybrushDestroyAndRecompute"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1055,7 +1027,6 @@ public void test221GuybrushDestroyAndRecompute() throws Exception { @Test public void test222GuybrushDestroyAndAssignRoleRed() throws Exception { final String TEST_NAME = "test222GuybrushDestroyAndAssignRoleRed"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1093,7 +1064,6 @@ public void test222GuybrushDestroyAndAssignRoleRed() throws Exception { @Test public void test229GuybrushUnassignRoleRed() throws Exception { final String TEST_NAME = "test229GuybrushUnassignRoleRed"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1124,7 +1094,6 @@ public void test229GuybrushUnassignRoleRed() throws Exception { @Test public void test230GuybrushAssignRoleRedAndBlueAndGreen() throws Exception { final String TEST_NAME = "test230GuybrushAssignRoleRedAndBlueAndGreen"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1158,7 +1127,6 @@ public void test230GuybrushAssignRoleRedAndBlueAndGreen() throws Exception { @Test public void test240GuybrushAssignRoleExecutiveOne() throws Exception { final String TEST_NAME = "test240GuybrushAssignRoleExecutiveOne"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1183,7 +1151,6 @@ public void test240GuybrushAssignRoleExecutiveOne() throws Exception { @Test public void test242GuybrushAssignRoleControllingOne() throws Exception { final String TEST_NAME = "test242GuybrushAssignRoleControllingOne"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1202,7 +1169,6 @@ public void test242GuybrushAssignRoleControllingOne() throws Exception { @Test public void test244GuybrushAssignRoleExecutiveTwo() throws Exception { final String TEST_NAME = "test244GuybrushAssignRoleExecutiveTwo"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1228,7 +1194,6 @@ public void test244GuybrushAssignRoleExecutiveTwo() throws Exception { @Test public void test245GuybrushAssignRoleControllingTwo() throws Exception { final String TEST_NAME = "test245GuybrushAssignRoleControllingTwo"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1249,7 +1214,6 @@ public void test245GuybrushAssignRoleControllingTwo() throws Exception { @Test public void test246GuybrushUnassignRoleExecutiveOne() throws Exception { final String TEST_NAME = "test246GuybrushUnassignRoleExecutiveOne"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1274,7 +1238,6 @@ public void test246GuybrushUnassignRoleExecutiveOne() throws Exception { @Test public void test247GuybrushAssignRoleControllingOne() throws Exception { final String TEST_NAME = "test247GuybrushAssignRoleControllingOne"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1295,7 +1258,6 @@ public void test247GuybrushAssignRoleControllingOne() throws Exception { @Test public void test249GuybrushUnassignRoleExecutiveTwo() throws Exception { final String TEST_NAME = "test249GuybrushUnassignRoleExecutiveTwo"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1323,7 +1285,6 @@ public void test249GuybrushUnassignRoleExecutiveTwo() throws Exception { @Test public void test250GuybrushAssignRoleControllingOne() throws Exception { final String TEST_NAME = "test250GuybrushAssignRoleControllingOne"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1348,7 +1309,6 @@ public void test250GuybrushAssignRoleControllingOne() throws Exception { @Test public void test252GuybrushAssignRoleExecutiveOne() throws Exception { final String TEST_NAME = "test252GuybrushAssignRoleExecutiveOne"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1367,7 +1327,6 @@ public void test252GuybrushAssignRoleExecutiveOne() throws Exception { @Test public void test259GuybrushUnassignRoleControllingOne() throws Exception { final String TEST_NAME = "test259GuybrushUnassignRoleControllingOne"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1392,7 +1351,6 @@ public void test259GuybrushUnassignRoleControllingOne() throws Exception { @Test public void test800ApplyGlobalPolicyRulesExclusion() throws Exception { final String TEST_NAME = "test800ApplyGlobalPolicyRulesExclusion"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1414,7 +1372,6 @@ public void test800ApplyGlobalPolicyRulesExclusion() throws Exception { @Test public void test810GuybrushAssignRoleCitizenSk() throws Exception { final String TEST_NAME = "test810GuybrushAssignRoleCitizenSk"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1436,7 +1393,6 @@ public void test810GuybrushAssignRoleCitizenSk() throws Exception { @Test public void test812GuybrushAssignRoleCitizenUs() throws Exception { final String TEST_NAME = "test812GuybrushAssignRoleCitizenUs"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1455,7 +1411,6 @@ public void test812GuybrushAssignRoleCitizenUs() throws Exception { @Test public void test814GuybrushAssignRoleEmpty() throws Exception { final String TEST_NAME = "test814GuybrushAssignRoleEmpty"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1478,7 +1433,6 @@ public void test814GuybrushAssignRoleEmpty() throws Exception { @Test public void test818GuybrushUnassignRoleCitizenSk() throws Exception { final String TEST_NAME = "test818GuybrushUnassignRoleCitizenSk"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1503,7 +1457,6 @@ public void test818GuybrushUnassignRoleCitizenSk() throws Exception { @Test public void test819GuybrushUnassignRoleEmpty() throws Exception { final String TEST_NAME = "test818GuybrushUnassignRoleCitizenSk"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1529,7 +1482,6 @@ public void test819GuybrushUnassignRoleEmpty() throws Exception { @Test public void test820GuybrushAssignRoleCriminal() throws Exception { final String TEST_NAME = "test820GuybrushAssignRoleCriminal"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1555,7 +1507,6 @@ public void test820GuybrushAssignRoleCriminal() throws Exception { @Test public void test822GuybrushAssignRoleMinister() throws Exception { final String TEST_NAME = "test822GuybrushAssignRoleMinister"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1580,7 +1531,6 @@ public void test822GuybrushAssignRoleMinister() throws Exception { @Test public void test826GuybrushUnassignRoleCriminal() throws Exception { final String TEST_NAME = "test826GuybrushUnassignRoleCriminal"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1603,7 +1553,6 @@ public void test826GuybrushUnassignRoleCriminal() throws Exception { @Test public void test829GuybrushUnassignRoleMinister() throws Exception { final String TEST_NAME = "test829GuybrushUnassignRoleMinister"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1626,7 +1575,6 @@ public void test829GuybrushUnassignRoleMinister() throws Exception { @Test public void test900ApplyGlobalPolicyRulesSoDApproval() throws Exception { final String TEST_NAME = "test900ApplyGlobalPolicyRulesSoDApproval"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1653,7 +1601,6 @@ public void test900ApplyGlobalPolicyRulesSoDApproval() throws Exception { @Test public void test920GuybrushAssignRoleCriminal() throws Exception { final String TEST_NAME = "test920GuybrushAssignRoleCriminal"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1683,7 +1630,6 @@ public void test920GuybrushAssignRoleCriminal() throws Exception { @Test public void test922GuybrushPreviewAssignRoleMinister() throws Exception { final String TEST_NAME = "test922GuybrushPreviewAssignRoleMinister"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1761,7 +1707,6 @@ private EvaluatedPolicyRule getEvaluatedPolicyRule(Collection userJack = getUser(USER_JACK_OID); @@ -95,7 +95,6 @@ public void test200AutzJackNoRole() throws Exception { @Test public void test201AutzJackSuperuserRole() throws Exception { final String TEST_NAME = "test201AutzJackSuperuserRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_SUPERUSER_OID); @@ -111,7 +110,6 @@ public void test201AutzJackSuperuserRole() throws Exception { @Test public void test202AutzJackReadonlyRole() throws Exception { final String TEST_NAME = "test202AutzJackReadonlyRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_READONLY_OID); @@ -138,7 +136,6 @@ public void test202AutzJackReadonlyRole() throws Exception { @Test public void test202rAutzJackReadonlyReqRole() throws Exception { final String TEST_NAME = "test202rAutzJackReadonlyReqRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_READONLY_REQ_OID); @@ -161,7 +158,6 @@ public void test202rAutzJackReadonlyReqRole() throws Exception { @Test public void test202eAutzJackReadonlyExecRole() throws Exception { final String TEST_NAME = "test202eAutzJackReadonlyExecRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_READONLY_EXEC_OID); @@ -181,7 +177,6 @@ public void test202eAutzJackReadonlyExecRole() throws Exception { @Test public void test202reAutzJackReadonlyReqExecRole() throws Exception { final String TEST_NAME = "test202reAutzJackReadonlyReqExecRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_READONLY_OID); @@ -202,7 +197,6 @@ public void test202reAutzJackReadonlyReqExecRole() throws Exception { @Test public void test203AutzJackReadonlyDeepRole() throws Exception { final String TEST_NAME = "test203AutzJackReadonlyDeepRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_READONLY_DEEP_OID); @@ -223,7 +217,6 @@ public void test203AutzJackReadonlyDeepRole() throws Exception { @Test public void test203eAutzJackReadonlyDeepExecRole() throws Exception { final String TEST_NAME = "test203eAutzJackReadonlyDeepExecRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_READONLY_DEEP_OID); @@ -242,7 +235,6 @@ public void test203eAutzJackReadonlyDeepExecRole() throws Exception { @Test public void test204AutzJackSelfRole() throws Exception { final String TEST_NAME = "test204AutzJackSelfRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_SELF_OID); @@ -297,7 +289,6 @@ public void test204AutzJackSelfRole() throws Exception { @Test public void test204aAutzJackCaseObjectSelfRole() throws Exception { final String TEST_NAME = "test204aAutzJackCaseObjectSelfRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_SELF_OID); @@ -351,7 +342,6 @@ public void test204aAutzJackCaseObjectSelfRole() throws Exception { @Test public void test204bAutzJackCaseAssigneeSelfRole() throws Exception { final String TEST_NAME = "test204bAutzJackCaseAssigneeSelfRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_SELF_OID); @@ -405,7 +395,6 @@ public void test204bAutzJackCaseAssigneeSelfRole() throws Exception { @Test public void test204cAutzJackCaseAssigneeSelfWithDelegatesRole() throws Exception { final String TEST_NAME = "test204cAutzJackCaseAssigneeSelfWithDelegatesRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_SELF_DELEGABLE_OID); @@ -470,7 +459,6 @@ public void test204cAutzJackCaseAssigneeSelfWithDelegatesRole() throws Exception @Test public void test204dAutzJackCaseAssigneeSelfWithNonWorkItemsDelegatesRole() throws Exception { final String TEST_NAME = "test204dAutzJackCaseAssigneeSelfWithNonWorkItemsDelegatesRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_SELF_DELEGABLE_OID); @@ -535,7 +523,6 @@ public void test204dAutzJackCaseAssigneeSelfWithNonWorkItemsDelegatesRole() thro @Test public void test205AutzJackObjectFilterModifyCaribbeanfRole() throws Exception { final String TEST_NAME = "test205AutzJackObjectFilterModifyCaribbeanfRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_OBJECT_FILTER_MODIFY_CARIBBEAN_OID); @@ -561,7 +548,6 @@ public void test205AutzJackObjectFilterModifyCaribbeanfRole() throws Exception { @Test public void test207AutzJackObjectFilterCaribbeanRole() throws Exception { final String TEST_NAME = "test207AutzJackObjectFilterCaribbeanfRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_OBJECT_FILTER_CARIBBEAN_OID); @@ -600,7 +586,6 @@ public void test207AutzJackObjectFilterCaribbeanRole() throws Exception { @Test public void test207rAutzJackObjectFilterCaribbeanRole() throws Exception { final String TEST_NAME = "test207rAutzJackObjectFilterCaribbeanRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_OBJECT_FILTER_CARIBBEAN_RAW_OID); @@ -654,7 +639,6 @@ public void test208sAutzJackReadSomeRoles() throws Exception { } public void testAutzJackReadSomeRoles(final String TEST_NAME, String roleOid) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, roleOid); @@ -694,7 +678,6 @@ public void testAutzJackReadSomeRoles(final String TEST_NAME, String roleOid) th @Test public void test209AutzJackSuperuserAndGuiAccessRole() throws Exception { final String TEST_NAME = "test209AutzJackSuperuserAndGuiAccessRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_SUPERUSER_OID); @@ -713,7 +696,6 @@ public void test209AutzJackSuperuserAndGuiAccessRole() throws Exception { @Test public void test210AutzJackPropReadAllModifySome() throws Exception { final String TEST_NAME = "test210AutzJackPropReadAllModifySome"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_PROP_READ_ALL_MODIFY_SOME_OID); @@ -751,7 +733,6 @@ public void test210AutzJackPropReadAllModifySome() throws Exception { @Test public void test211AutzJackPropReadAllModifySomeUser() throws Exception { final String TEST_NAME = "test211AutzJackPropReadAllModifySomeUser"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_PROP_READ_ALL_MODIFY_SOME_USER_OID); @@ -800,7 +781,6 @@ public void test211AutzJackPropReadAllModifySomeUser() throws Exception { @Test public void test212AutzJackPropReadAllModifySomeUserPartial() throws Exception { final String TEST_NAME = "test212AutzJackPropReadAllModifySomeUserPartial"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_PROP_READ_ALL_MODIFY_SOME_USER_PARTIAL_OID); @@ -879,7 +859,6 @@ public void test215reAutzJackPropReadSomeModifySomeReqExec() throws Exception { @Test public void test216AutzJackPropReadSomeModifySomeUser() throws Exception { final String TEST_NAME = "test216AutzJackPropReadSomeModifySomeUser"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_PROP_READ_SOME_MODIFY_SOME_USER_OID); @@ -894,7 +873,6 @@ public void test216AutzJackPropReadSomeModifySomeUser() throws Exception { @Test public void test217AutzJackPropGetSearchSomeModifySomeUser() throws Exception { final String TEST_NAME = "test217AutzJackPropGetSearchSomeModifySomeUser"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_PROP_GET_SEARCH_SOME_MODIFY_SOME_USER_OID); @@ -937,7 +915,6 @@ private void doReadSomeModifySomeUser(final String TEST_NAME) throws Exception { } public void testAutzJackPropReadSomeModifySome(final String TEST_NAME, String roleOid) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, roleOid); @@ -954,7 +931,6 @@ public void testAutzJackPropReadSomeModifySome(final String TEST_NAME, String ro @Test public void test218AutzJackPropReadSomeModifySomeExecAll() throws Exception { final String TEST_NAME = "test218AutzJackPropReadSomeModifySomeExecAll"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_PROP_READ_SOME_MODIFY_SOME_EXEC_ALL_OID); @@ -1034,7 +1010,6 @@ public void test218AutzJackPropReadSomeModifySomeExecAll() throws Exception { @Test public void test219AutzJackPropReadSomeModifySomeFullName() throws Exception { final String TEST_NAME = "test219AutzJackPropReadSomeModifySomeFullName"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_PROP_READ_SOME_MODIFY_SOME_FULLNAME_OID); @@ -1195,7 +1170,6 @@ public void test219AutzJackPropReadSomeModifySomeFullName() throws Exception { @Test public void test220AutzJackPropDenyModifySome() throws Exception { final String TEST_NAME = "test220AutzJackPropDenyModifySome"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_PROP_DENY_MODIFY_SOME_OID); @@ -1261,7 +1235,6 @@ public void test220AutzJackPropDenyModifySome() throws Exception { @Test public void test230AutzJackMasterMinistryOfRum() throws Exception { final String TEST_NAME = "test230AutzJackMasterMinistryOfRum"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_MASTER_MINISTRY_OF_RUM_OID); @@ -1293,7 +1266,6 @@ public void test230AutzJackMasterMinistryOfRum() throws Exception { @Test public void test232AutzJackReadOrgMinistryOfRum() throws Exception { final String TEST_NAME = "test232AutzJackReadOrgMinistryOfRum"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_ORG_READ_ORGS_MINISTRY_OF_RUM_OID); @@ -1325,7 +1297,6 @@ public void test232AutzJackReadOrgMinistryOfRum() throws Exception { @Test public void test240AutzJackManagerFullControlNoOrg() throws Exception { final String TEST_NAME = "test240AutzJackManagerFullControlNoOrg"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); @@ -1376,7 +1347,6 @@ public void test240AutzJackManagerFullControlNoOrg() throws Exception { @Test public void test241AutzJackManagerFullControlMemberMinistryOfRum() throws Exception { final String TEST_NAME = "test241AutzJackManagerFullControlMemberMinistryOfRum"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); @@ -1403,7 +1373,6 @@ public void test241AutzJackManagerFullControlMemberMinistryOfRum() throws Except @Test public void test242AutzJackManagerFullControlManagerMinistryOfRum() throws Exception { final String TEST_NAME = "test242AutzJackManagerFullControlManagerMinistryOfRum"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); @@ -1432,7 +1401,6 @@ public void test242AutzJackManagerFullControlManagerMinistryOfRum() throws Excep @Test public void test243AutzJackManagerFullControlManagerMinistryOfRumAndDefense() throws Exception { final String TEST_NAME = "test243AutzJackManagerFullControlManagerMinistryOfRumAndDefense"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); @@ -1464,7 +1432,6 @@ public void test243AutzJackManagerFullControlManagerMinistryOfRumAndDefense() th @Test public void test245AutzJackManagerUserAdminMemberMinistryOfRum() throws Exception { final String TEST_NAME = "test245AutzJackManagerUserAdminMemberMinistryOfRum"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); @@ -1491,7 +1458,6 @@ public void test245AutzJackManagerUserAdminMemberMinistryOfRum() throws Exceptio @Test public void test246AutzJackManagerUserAdminManagerMinistryOfRum() throws Exception { final String TEST_NAME = "test246AutzJackManagerUserAdminManagerMinistryOfRum"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); @@ -1520,7 +1486,6 @@ public void test246AutzJackManagerUserAdminManagerMinistryOfRum() throws Excepti @Test public void test247AutzJackManagerUserAdminManagerMinistryOfRumAndDefense() throws Exception { final String TEST_NAME = "test243AutzJackManagerFullControlManagerMinistryOfRumAndDefense"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); @@ -1765,7 +1730,6 @@ private void assertJack24xManagerDefense(String TEST_NAME, boolean fullControl) @Test public void test250AutzJackSelfAccountsRead() throws Exception { final String TEST_NAME = "test250AutzJackSelfAccountsRead"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); @@ -1842,7 +1806,6 @@ public void test250AutzJackSelfAccountsRead() throws Exception { @Test public void test255AutzJackSelfAccountsReadWrite() throws Exception { final String TEST_NAME = "test255AutzJackSelfAccountsReadWrite"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_SELF_ACCOUNTS_READ_WRITE_OID); @@ -1908,7 +1871,6 @@ public void test255AutzJackSelfAccountsReadWrite() throws Exception { @Test public void test256AutzJackSelfAccountsPartialControl() throws Exception { final String TEST_NAME = "test256AutzJackSelfAccountsPartialControl"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_SELF_ACCOUNTS_PARTIAL_CONTROL_OID); @@ -1991,7 +1953,6 @@ public void test256AutzJackSelfAccountsPartialControl() throws Exception { @Test public void test258AutzJackSelfAccountsPartialControlPassword() throws Exception { final String TEST_NAME = "test258AutzJackSelfAccountsPartialControlPassword"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_SELF_ACCOUNTS_PARTIAL_CONTROL_PASSWORD_OID); @@ -2055,7 +2016,6 @@ public void test258AutzJackSelfAccountsPartialControlPassword() throws Exception @Test public void test259AutzJackSelfAccountsPartialControl() throws Exception { final String TEST_NAME = "test259AutzJackSelfAccountsPartialControl"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_SELF_ACCOUNTS_PARTIAL_CONTROL_PASSWORD_OID); @@ -2126,7 +2086,6 @@ public void test259AutzJackSelfAccountsPartialControl() throws Exception { @Test public void test260AutzJackObjectFilterLocationShadowRole() throws Exception { final String TEST_NAME = "test260AutzJackObjectFilterLocationShadowRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_FILTER_OBJECT_USER_LOCATION_SHADOWS_OID); @@ -2198,7 +2157,6 @@ public void test260AutzJackObjectFilterLocationShadowRole() throws Exception { @Test public void test261AutzAngelicaObjectFilterLocationCreateUserShadowRole() throws Exception { final String TEST_NAME = "test261AutzJackObjectFilterLocationCreateUserShadowRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); @@ -2230,7 +2188,6 @@ public void test261AutzAngelicaObjectFilterLocationCreateUserShadowRole() throws @Test public void test270AutzJackAssignApplicationRoles() throws Exception { final String TEST_NAME = "test270AutzJackAssignApplicationRoles"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_ASSIGN_APPLICATION_ROLES_OID); @@ -2285,7 +2242,6 @@ public void test270AutzJackAssignApplicationRoles() throws Exception { @Test public void test272AutzJackAssignAnyRoles() throws Exception { final String TEST_NAME = "test272AutzJackAssignAnyRoles"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_ASSIGN_ANY_ROLES_OID); @@ -2345,7 +2301,6 @@ public void test272AutzJackAssignAnyRoles() throws Exception { @Test public void test273AutzJackRedyAssignmentExceptionRules() throws Exception { final String TEST_NAME = "test273AutzJackRedyAssignmentExceptionRules"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_ASSIGN_ANY_ROLES_OID); @@ -2399,7 +2354,6 @@ public void test273AutzJackRedyAssignmentExceptionRules() throws Exception { @Test public void test274AutzJackAssignNonApplicationRoles() throws Exception { final String TEST_NAME = "test274AutzJackAssignNonApplicationRoles"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_ASSIGN_NON_APPLICATION_ROLES_OID); @@ -2447,7 +2401,6 @@ public void test274AutzJackAssignNonApplicationRoles() throws Exception { @Test public void test275aAutzJackAssignRequestableRoles() throws Exception { final String TEST_NAME = "test275aAutzJackAssignRequestableRoles"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_ASSIGN_REQUESTABLE_ROLES_OID); @@ -2502,7 +2455,6 @@ public void test275aAutzJackAssignRequestableRoles() throws Exception { @Test public void test275bAutzJackAssignRequestableOrgs() throws Exception { final String TEST_NAME = "test275bAutzJackAssignRequestableOrgs"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_END_USER_REQUESTABLE_ABSTRACTROLES_OID); @@ -2547,7 +2499,6 @@ public void test275bAutzJackAssignRequestableOrgs() throws Exception { @Test public void test275cAutzJackAssignRequestableRolesAndInduceAnyRole() throws Exception { final String TEST_NAME = "test275cAutzJackAssignRequestableRolesAndInduceAnything"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_ASSIGN_REQUESTABLE_ROLES_OID); @@ -2604,7 +2555,6 @@ public void test275cAutzJackAssignRequestableRolesAndInduceAnyRole() throws Exce @Test public void test276AutzJackAssignRequestableRolesWithOrgRef() throws Exception { final String TEST_NAME = "test276AutzJackAssignRequestableRolesWithOrgRef"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_ASSIGN_REQUESTABLE_ROLES_OID); @@ -2658,7 +2608,6 @@ public void test276AutzJackAssignRequestableRolesWithOrgRef() throws Exception { @Test public void test277AutzJackAssignRequestableRolesWithOrgRefSecondTime() throws Exception { final String TEST_NAME = "test277AutzJackAssignRequestableRolesWithOrgRefSecondTime"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_ASSIGN_REQUESTABLE_ROLES_OID); @@ -2741,7 +2690,6 @@ public void test277AutzJackAssignRequestableRolesWithOrgRefSecondTime() throws E @Test public void test278AutzJackAssignRequestableRolesWithOrgRefTweakedDelta() throws Exception { final String TEST_NAME = "test278AutzJackAssignRequestableRolesWithOrgRefTweakedDelta"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_ASSIGN_REQUESTABLE_ROLES_OID); @@ -2810,7 +2758,6 @@ public void test278AutzJackAssignRequestableRolesWithOrgRefTweakedDelta() throws @Test public void test279AutzJackAssignRequestableRolesWithTenantRef() throws Exception { final String TEST_NAME = "test279AutzJackAssignRequestableRolesWithTenantRef"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_ASSIGN_REQUESTABLE_ROLES_OID); @@ -2864,7 +2811,6 @@ public void test279AutzJackAssignRequestableRolesWithTenantRef() throws Exceptio @Test public void test280AutzJackEndUser() throws Exception { final String TEST_NAME = "test280AutzJackEndUser"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); @@ -2952,7 +2898,6 @@ public void test280AutzJackEndUser() throws Exception { @Test public void test281AutzJackEndUserSecondTime() throws Exception { final String TEST_NAME = "test281AutzJackEndUserSecondTime"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); @@ -3018,7 +2963,6 @@ private void assertCredentialsPolicy(PrismObject user) throws ObjectNo @Test public void test282AutzJackEndUserAndModify() throws Exception { final String TEST_NAME = "test282AutzJackEndUserAndModify"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); @@ -3059,7 +3003,6 @@ public void test282AutzJackEndUserAndModify() throws Exception { @Test public void test283AutzJackModifyAndEndUser() throws Exception { final String TEST_NAME = "test283AutzJackModifyAndEndUser"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); @@ -3094,7 +3037,6 @@ public void test283AutzJackModifyAndEndUser() throws Exception { @Test public void test285AutzJackEndUserAndAdd() throws Exception { final String TEST_NAME = "test285AutzJackEndUserAndAdd"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); @@ -3128,7 +3070,6 @@ public void test285AutzJackEndUserAndAdd() throws Exception { @Test public void test295AutzJackAssignOrgRelation() throws Exception { final String TEST_NAME = "test295AutzJackAssignOrgRelation"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); @@ -3169,7 +3110,6 @@ public void test295AutzJackAssignOrgRelation() throws Exception { @Test public void test300AutzAnonymous() throws Exception { final String TEST_NAME = "test300AutzAnonymous"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); PrismObject userJack = getUser(USER_JACK_OID); @@ -3184,7 +3124,6 @@ public void test300AutzAnonymous() throws Exception { @Test public void test310AutzJackNoRolePrivileged() throws Exception { final String TEST_NAME = "test310AutzJackNoRolePrivileged"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); PrismObject userJack = getUser(USER_JACK_OID); @@ -3215,7 +3154,6 @@ public void test310AutzJackNoRolePrivileged() throws Exception { @Test public void test312AutzAnonymousPrivileged() throws Exception { final String TEST_NAME = "test312AutzAnonymousPrivileged"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); PrismObject userJack = getUser(USER_JACK_OID); @@ -3246,7 +3184,6 @@ public void test312AutzAnonymousPrivileged() throws Exception { @Test public void test313AutzAnonymousPrivilegedRestore() throws Exception { final String TEST_NAME = "test313AutzAnonymousPrivilegedRestore"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); PrismObject userJack = getUser(USER_JACK_OID); @@ -3269,7 +3206,6 @@ public void test313AutzAnonymousPrivilegedRestore() throws Exception { @Test public void test360AutzJackAuditorRole() throws Exception { final String TEST_NAME = "test360AutzJackAuditorRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_AUDITOR_OID); @@ -3295,7 +3231,6 @@ public void test360AutzJackAuditorRole() throws Exception { @Test public void test370AutzJackLimitedUserAdmin() throws Exception { final String TEST_NAME = "test370AutzJackLimitedUserAdmin"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_LIMITED_USER_ADMIN_OID); @@ -3323,7 +3258,6 @@ public void test370AutzJackLimitedUserAdmin() throws Exception { @Test public void test380AutzJackSelfTaskOwner() throws Exception { final String TEST_NAME = "test380AutzJackSelfTaskOwner"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_SELF_TASK_OWNER_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityMedium.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityMedium.java index 79bfa181677..b86c15f7bbf 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityMedium.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityMedium.java @@ -54,7 +54,6 @@ protected int getNumberOfRoles() { @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); @@ -79,7 +78,6 @@ public void test000Sanity() throws Exception { @Test public void test100AutzEmployeeManager() throws Exception { final String TEST_NAME = "test100AutzEmployeeManager"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_EMPLOYEE_MANAGER_OID); @@ -110,7 +108,6 @@ public void test100AutzEmployeeManager() throws Exception { @Test public void test102AutzEmployeeManagerAddEmployee() throws Exception { final String TEST_NAME = "test102AutzEmployeeManagerAddEmployee"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_EMPLOYEE_MANAGER_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityMultitenant.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityMultitenant.java index 92f5fabe5af..abbe2596080 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityMultitenant.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityMultitenant.java @@ -19,6 +19,7 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.security.api.AuthorizationConstants; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.util.exception.CommunicationException; import com.evolveum.midpoint.util.exception.ConfigurationException; import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; @@ -212,7 +213,6 @@ protected int getNumberOfRoles() { @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); @@ -241,7 +241,6 @@ public void test000Sanity() throws Exception { @Test public void test010ImportOrgstruct() throws Exception { final String TEST_NAME = "test010ImportOrgstruct"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -378,7 +377,6 @@ public void test010ImportOrgstruct() throws Exception { @Test public void test100AutzLetoRead() throws Exception { final String TEST_NAME = "test100AutzLetoRead"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(null); @@ -420,7 +418,6 @@ public void test100AutzLetoRead() throws Exception { @Test public void test102AutzLetoAdd() throws Exception { final String TEST_NAME = "test102AutzLetoAdd"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(null); @@ -465,7 +462,6 @@ public void test102AutzLetoAdd() throws Exception { @Test public void test104AutzLetoModify() throws Exception { final String TEST_NAME = "test104AutzLetoModify"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(null); @@ -497,7 +493,6 @@ public void test104AutzLetoModify() throws Exception { @Test public void test106AutzLetoAddResourceTask() throws Exception { final String TEST_NAME = "test106AutzLetoAddResourceTask"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(null); @@ -543,7 +538,6 @@ private void assertAddDummyResourceDeny(File file) throws SchemaException, IOExc @Test public void test109AutzLetoDelete() throws Exception { final String TEST_NAME = "test109AutzLetoDelete"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(null); @@ -573,7 +567,6 @@ public void test109AutzLetoDelete() throws Exception { @Test public void test110AutzLetoAddOrgs() throws Exception { final String TEST_NAME = "test110AutzLetoAddOrgs"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(null); @@ -628,7 +621,6 @@ public void test110AutzLetoAddOrgs() throws Exception { @Test public void test112AutzLetoProtectTenant() throws Exception { final String TEST_NAME = "test112AutzLetoProtectTenant"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(null); @@ -698,7 +690,6 @@ public void test112AutzLetoProtectTenant() throws Exception { @Test public void test114AutzLetoKeepWithinTenant() throws Exception { final String TEST_NAME = "test114AutzLetoKeepWithinTenant"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(null); @@ -761,7 +752,6 @@ public void test114AutzLetoKeepWithinTenant() throws Exception { @Test public void test116AutzLetoProtectTenantAdminRole() throws Exception { final String TEST_NAME = "test114AutzLetoKeepWithinTenant"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(null); @@ -819,7 +809,6 @@ public void test116AutzLetoProtectTenantAdminRole() throws Exception { @Test public void test118AutzLetoBusinessRoles() throws Exception { final String TEST_NAME = "test118AutzLetoBusinessRoles"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(null); @@ -859,7 +848,6 @@ public void test118AutzLetoBusinessRoles() throws Exception { @Test public void test120AutzPaulEndUser() throws Exception { final String TEST_NAME = "test120AutzPaulEndUser"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(null); @@ -895,7 +883,6 @@ public void test120AutzPaulEndUser() throws Exception { @Test public void test122AutzDuncanRoleManager() throws Exception { final String TEST_NAME = "test122AutzDuncanRoleManager"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(null); @@ -945,7 +932,6 @@ public void test122AutzDuncanRoleManager() throws Exception { @Test public void test130AutzEdricRead() throws Exception { final String TEST_NAME = "test120AutzEdricRead"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(null); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityPrincipal.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityPrincipal.java index da0a7a0e4a5..ced0b420ff9 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityPrincipal.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityPrincipal.java @@ -40,7 +40,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test010GetUserAdministrator() throws Exception { final String TEST_NAME = "test010GetUserAdministrator"; - displayTestTitle(TEST_NAME); resetAuthentication(); // WHEN @@ -58,7 +57,6 @@ public void test010GetUserAdministrator() throws Exception { @Test public void test050GetUserJack() throws Exception { final String TEST_NAME = "test050GetUserJack"; - displayTestTitle(TEST_NAME); resetAuthentication(); // WHEN @@ -78,7 +76,6 @@ public void test050GetUserJack() throws Exception { @Test public void test051GetUserBarbossa() throws Exception { final String TEST_NAME = "test051GetUserBarbossa"; - displayTestTitle(TEST_NAME); resetAuthentication(); // WHEN @@ -101,7 +98,6 @@ public void test051GetUserBarbossa() throws Exception { @Test public void test052GetUserGuybrush() throws Exception { final String TEST_NAME = "test052GetUserGuybrush"; - displayTestTitle(TEST_NAME); resetAuthentication(); // WHEN @@ -123,7 +119,6 @@ public void test052GetUserGuybrush() throws Exception { @Test public void test060GuybrushConditionalRoleFalse() throws Exception { final String TEST_NAME = "test060GuybrushConditionalRoleFalse"; - displayTestTitle(TEST_NAME); login(USER_ADMINISTRATOR_USERNAME); assignRole(USER_GUYBRUSH_OID, ROLE_CONDITIONAL_OID); @@ -151,7 +146,6 @@ public void test060GuybrushConditionalRoleFalse() throws Exception { @Test public void test061GuybrushConditionalRoleTrue() throws Exception { final String TEST_NAME = "test061GuybrushConditionalRoleTrue"; - displayTestTitle(TEST_NAME); login(USER_ADMINISTRATOR_USERNAME); Task task = createTask(TEST_NAME); @@ -183,7 +177,6 @@ public void test061GuybrushConditionalRoleTrue() throws Exception { @Test public void test062GuybrushConditionalRoleUnassign() throws Exception { final String TEST_NAME = "test062GuybrushConditionalRoleUnassign"; - displayTestTitle(TEST_NAME); login(USER_ADMINISTRATOR_USERNAME); unassignRole(USER_GUYBRUSH_OID, ROLE_CONDITIONAL_OID); @@ -209,7 +202,6 @@ public void test062GuybrushConditionalRoleUnassign() throws Exception { @Test public void test100JackRolePirate() throws Exception { final String TEST_NAME = "test100JackRolePirate"; - displayTestTitle(TEST_NAME); // GIVEN login(USER_ADMINISTRATOR_USERNAME); Task task = createTask(TEST_NAME); @@ -243,7 +235,6 @@ public void test100JackRolePirate() throws Exception { @Test public void test109JackUnassignRolePirate() throws Exception { final String TEST_NAME = "test109JackUnassignRolePirate"; - displayTestTitle(TEST_NAME); // GIVEN login(USER_ADMINISTRATOR_USERNAME); Task task = createTask(TEST_NAME); @@ -274,7 +265,6 @@ public void test109JackUnassignRolePirate() throws Exception { @Test public void test110GuybrushRoleNicePirate() throws Exception { final String TEST_NAME = "test110GuybrushRoleNicePirate"; - displayTestTitle(TEST_NAME); // GIVEN login(USER_ADMINISTRATOR_USERNAME); Task task = createTask(TEST_NAME); @@ -299,7 +289,6 @@ public void test110GuybrushRoleNicePirate() throws Exception { @Test public void test111GuybrushRoleCaptain() throws Exception { final String TEST_NAME = "test111GuybrushRoleCaptain"; - displayTestTitle(TEST_NAME); // GIVEN login(USER_ADMINISTRATOR_USERNAME); Task task = createTask(TEST_NAME); @@ -324,7 +313,6 @@ public void test111GuybrushRoleCaptain() throws Exception { @Test public void test119GuybrushUnassignRoles() throws Exception { final String TEST_NAME = "test119GuybrushUnassignRoles"; - displayTestTitle(TEST_NAME); // GIVEN login(USER_ADMINISTRATOR_USERNAME); Task task = createTask(TEST_NAME); @@ -352,7 +340,6 @@ public void test119GuybrushUnassignRoles() throws Exception { @Test public void test120JackRoleIndirectPirate() throws Exception { final String TEST_NAME = "test120JackRoleIndirectPirate"; - displayTestTitle(TEST_NAME); // GIVEN login(USER_ADMINISTRATOR_USERNAME); @@ -385,7 +372,6 @@ public void test120JackRoleIndirectPirate() throws Exception { @Test public void test122JackOrgIndirectPirate() throws Exception { final String TEST_NAME = "test122JackOrgIndirectPirate"; - displayTestTitle(TEST_NAME); // GIVEN login(USER_ADMINISTRATOR_USERNAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractObjTemplateSyncTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractObjTemplateSyncTest.java index c482e2ef321..b8e13a1b2e2 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractObjTemplateSyncTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractObjTemplateSyncTest.java @@ -13,6 +13,7 @@ import com.evolveum.midpoint.prism.xml.XmlTypeConverter; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.MiscUtil; @@ -129,7 +130,6 @@ public void test100ImportLiveSyncTaskDummyByzantine() throws Exception { @Test public void test110AddDummyByzantineAccountMancomb() throws Exception { final String TEST_NAME = "test110AddDummyByzantineAccountMancomb"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(AbstractObjTemplateSyncTest.class.getName() + "." + TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractSynchronizationStoryTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractSynchronizationStoryTest.java index c41bcf6e275..8c695447c32 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractSynchronizationStoryTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractSynchronizationStoryTest.java @@ -19,6 +19,7 @@ import javax.xml.namespace.QName; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; @@ -105,7 +106,6 @@ protected boolean isReconciliation() { @Test public void test100ImportLiveSyncTaskDummyGreen() throws Exception { final String TEST_NAME = "test100ImportLiveSyncTaskDummyGreen"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); @@ -124,7 +124,6 @@ public void test100ImportLiveSyncTaskDummyGreen() throws Exception { @Test public void test110AddDummyGreenAccountMancomb() throws Exception { final String TEST_NAME = "test110AddDummyGreenAccountMancomb"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); @@ -191,7 +190,6 @@ public void test110AddDummyGreenAccountMancomb() throws Exception { @Test public void test200ImportLiveSyncTaskDummyBlue() throws Exception { final String TEST_NAME = "test200ImportLiveSyncTaskDummyBlue"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); @@ -213,7 +211,6 @@ public void test200ImportLiveSyncTaskDummyBlue() throws Exception { @Test public void test210AddDummyGreenAccountWally() throws Exception { final String TEST_NAME = "test210AddDummyGreenAccountWally"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); @@ -265,7 +262,6 @@ public void test210AddDummyGreenAccountWally() throws Exception { @Test public void test220AddDummyBlueAccountWally() throws Exception { final String TEST_NAME = "test220AddDummyBlueAccountWally"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); @@ -329,7 +325,6 @@ public void test220AddDummyBlueAccountWally() throws Exception { @Test public void test315AddDummyBlueAccountMancomb() throws Exception { final String TEST_NAME = "test315AddDummyBlueAccountMancomb"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); @@ -386,7 +381,6 @@ public void test315AddDummyBlueAccountMancomb() throws Exception { @Test public void test350ImportLiveSyncTaskDummyDefault() throws Exception { final String TEST_NAME = "test350ImportLiveSyncTaskDummyDefault"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); @@ -414,7 +408,6 @@ public void test350ImportLiveSyncTaskDummyDefault() throws Exception { @Test public void test360ModifyUserAddDummyDefaultAccount() throws Exception { final String TEST_NAME = "test360ModifyUserAddDummyDefaultAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); @@ -530,7 +523,6 @@ public void test360ModifyUserAddDummyDefaultAccount() throws Exception { @Test public void test370ModifyDummyGreenAccountWally() throws Exception { final String TEST_NAME = "test370ModifyDummyGreenAccountWally"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); @@ -616,7 +608,6 @@ public void test370ModifyDummyGreenAccountWally() throws Exception { @Test public void test380ModifyUserWallyFullName() throws Exception { final String TEST_NAME = "test380ModifyUserWallyFullName"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); @@ -686,7 +677,6 @@ public void test380ModifyUserWallyFullName() throws Exception { @Test public void test382ModifyUserWallyLocality() throws Exception { final String TEST_NAME = "test382ModifyUserWallyLocality"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); @@ -767,7 +757,6 @@ public void test382ModifyUserWallyLocality() throws Exception { @Test public void test400DeleteDummyDefaultAccount() throws Exception { final String TEST_NAME = "test400DeleteDummyDefaultAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); @@ -836,7 +825,6 @@ public void test400DeleteDummyDefaultAccount() throws Exception { @Test public void test410DeleteDummyGreenAccount() throws Exception { final String TEST_NAME = "test410DeleteDummyGreenAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); @@ -931,7 +919,6 @@ public void test410DeleteDummyGreenAccount() throws Exception { @Test public void test510AddDummyGreenAccountWallyUserTemplate() throws Exception { final String TEST_NAME = "test510AddDummyGreenAccountWallyUserTemplate"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); @@ -975,7 +962,6 @@ public void test510AddDummyGreenAccountWallyUserTemplate() throws Exception { @Test public void test600AddDummyGreenAccountCalypso() throws Exception { final String TEST_NAME = "test600AddDummyGreenAccountCalypso"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); @@ -1021,7 +1007,6 @@ public void test600AddDummyGreenAccountCalypso() throws Exception { @Test public void test700AddDummyGreenAccountXjojo() throws Exception { final String TEST_NAME = "test700AddDummyGreenAccountXjojo"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestImportRecon.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestImportRecon.java index e912e4716b4..0d83abda207 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestImportRecon.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestImportRecon.java @@ -326,7 +326,6 @@ protected void loginImportUser() throws CommonException { @Test public void test001SanityAzure() throws Exception { final String TEST_NAME = "test001SanityAzure"; - displayTestTitle(TEST_NAME); display("Dummy resource azure", dummyResourceAzure); @@ -345,7 +344,6 @@ public void test001SanityAzure() throws Exception { @Test public void test002SanityAzureRefined() throws Exception { final String TEST_NAME = "test002SanityAzureRefined"; - displayTestTitle(TEST_NAME); // WHEN RefinedResourceSchema refinedSchemaAzure = RefinedResourceSchemaImpl.getRefinedSchema(resourceDummyAzureType, prismContext); @@ -362,7 +360,6 @@ public void test002SanityAzureRefined() throws Exception { @Test public void test100ImportStanFromResourceDummy() throws Exception { final String TEST_NAME = "test100ImportStanFromResourceDummy"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -411,7 +408,6 @@ public void test100ImportStanFromResourceDummy() throws Exception { @Test public void test150ImportFromResourceDummy() throws Exception { final String TEST_NAME = "test150ImportFromResourceDummy"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -481,7 +477,6 @@ public void test150ImportFromResourceDummy() throws Exception { @Test public void test155ImportFromResourceDummyAgain() throws Exception { final String TEST_NAME = "test155ImportFromResourceDummyAgain"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -541,7 +536,6 @@ public void test155ImportFromResourceDummyAgain() throws Exception { @Test public void test160ImportFromResourceDummyLime() throws Exception { final String TEST_NAME = "test160ImportFromResourceDummyLime"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -614,7 +608,6 @@ public void test160ImportFromResourceDummyLime() throws Exception { @Test public void test162ImportFromResourceDummyLimeRappOrganizationScummBar() throws Exception { final String TEST_NAME = "test162ImportFromResourceDummyLimeRappOrganizationScummBar"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -698,7 +691,6 @@ public void test162ImportFromResourceDummyLimeRappOrganizationScummBar() throws @Test public void test164ImportFromResourceDummyLimeRappOrganizationNull() throws Exception { final String TEST_NAME = "test164ImportFromResourceDummyLimeRappOrganizationNull"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -779,7 +771,6 @@ public void test164ImportFromResourceDummyLimeRappOrganizationNull() throws Exce @Test public void test200ReconcileDummy() throws Exception { final String TEST_NAME = "test200ReconcileDummy"; - displayTestTitle(TEST_NAME); // GIVEN loginAdministrator(); @@ -901,7 +892,6 @@ public void test200ReconcileDummy() throws Exception { @Test public void test210ReconcileDummyBroken() throws Exception { final String TEST_NAME = "test210ReconcileDummyBroken"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -973,7 +963,6 @@ public void test210ReconcileDummyBroken() throws Exception { @Test public void test219ReconcileDummyFixed() throws Exception { final String TEST_NAME = "test219ReconcileDummyFixed"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1053,7 +1042,6 @@ public void test219ReconcileDummyFixed() throws Exception { @Test public void test220ReconcileDummyBrokenGuybrush() throws Exception { final String TEST_NAME = "test220ReconcileDummyBrokenGuybrush"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1128,7 +1116,6 @@ public void test220ReconcileDummyBrokenGuybrush() throws Exception { @Test public void test229ReconcileDummyFixed() throws Exception { final String TEST_NAME = "test229ReconcileDummyFixed"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1211,7 +1198,6 @@ public void test229ReconcileDummyFixed() throws Exception { @Test public void test230ReconcileDummyRename() throws Exception { final String TEST_NAME = "test230ReconcileDummyRename"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1335,7 +1321,6 @@ private void addReconScripts(Collection scripts, String @Test public void test300ReconcileDummyAzureAddAccountOtis() throws Exception { final String TEST_NAME = "test300ReconcileDummyAzureAddAccountOtis"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1400,7 +1385,6 @@ public void test300ReconcileDummyAzureAddAccountOtis() throws Exception { @Test public void test310ReconcileDummyAzureAgain() throws Exception { final String TEST_NAME = "test310ReconcileDummyAzureAgain"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1467,7 +1451,6 @@ public void test310ReconcileDummyAzureAgain() throws Exception { @Test public void test320ReconcileDummyAzureDeleteOtis() throws Exception { final String TEST_NAME = "test320ReconcileDummyAzureDeleteOtis"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1540,7 +1523,6 @@ public void test320ReconcileDummyAzureDeleteOtis() throws Exception { @Test public void test330ReconcileDummyAzureAddAccountRapp() throws Exception { final String TEST_NAME = "test330ReconcileDummyAzureAddAccountRapp"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1637,7 +1619,6 @@ public void test330ReconcileDummyAzureAddAccountRapp() throws Exception { @Test public void test332ModifyUserRappAndReconcileDummyAzure() throws Exception { final String TEST_NAME = "test332ModifyUserRappAndReconcileDummyAzure"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1721,7 +1702,6 @@ public void test332ModifyUserRappAndReconcileDummyAzure() throws Exception { @Test public void test334AssignRoleCorpseToRappAndReconcileDummyAzure() throws Exception { final String TEST_NAME = "test334AssignRoleCorpseToRappAndReconcileDummyAzure"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1790,7 +1770,6 @@ public void test334AssignRoleCorpseToRappAndReconcileDummyAzure() throws Excepti @Test public void test339ReconcileDummyAzureDeleteRapp() throws Exception { final String TEST_NAME = "test339ReconcileDummyAzureDeleteRapp"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1867,7 +1846,6 @@ public void test339ReconcileDummyAzureDeleteRapp() throws Exception { @Test public void test400ReconcileDummyLimeAddAccount() throws Exception { final String TEST_NAME = "test400ReconcileDummyLimeAddAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1921,7 +1899,6 @@ public void test400ReconcileDummyLimeAddAccount() throws Exception { @Test public void test401ReconcileDummyLimeKateOnlyEmpty() throws Exception { final String TEST_NAME = "test401ReconcileDummyLimeKateOnlyEmpty"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1971,7 +1948,6 @@ public void test401ReconcileDummyLimeKateOnlyEmpty() throws Exception { @Test public void test402ReconcileDummyLimeKateOnlyGrog() throws Exception { final String TEST_NAME = "test402ReconcileDummyLimeKateOnlyGrog"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2019,7 +1995,6 @@ public void test402ReconcileDummyLimeKateOnlyGrog() throws Exception { @Test public void test403ReconcileDummyLimeKateOnlyNoValue() throws Exception { final String TEST_NAME = "test403ReconcileDummyLimeKateOnlyNoValue"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2066,7 +2041,6 @@ public void test403ReconcileDummyLimeKateOnlyNoValue() throws Exception { @Test public void test404ReconcileDummyLimeKateOnlyRum() throws Exception { final String TEST_NAME = "test404ReconcileDummyLimeKateOnlyRum"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2114,7 +2088,6 @@ public void test404ReconcileDummyLimeKateOnlyRum() throws Exception { @Test public void test405ReconcileDummyLimeKateOnlyEmpty() throws Exception { final String TEST_NAME = "test405ReconcileDummyLimeKateOnlyEmpty"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2162,7 +2135,6 @@ public void test405ReconcileDummyLimeKateOnlyEmpty() throws Exception { @Test public void test406ReconcileDummyLimeKateOnlyEmptyAgain() throws Exception { final String TEST_NAME = "test406ReconcileDummyLimeKateOnlyEmptyAgain"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2205,7 +2177,6 @@ public void test406ReconcileDummyLimeKateOnlyEmptyAgain() throws Exception { @Test public void test410ReconcileDummyLimeKatePassword() throws Exception { final String TEST_NAME = "test410ReconcileDummyLimeKatePassword"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2252,7 +2223,6 @@ public void test410ReconcileDummyLimeKatePassword() throws Exception { @Test public void test420ReconcileDummyLimeDeleteLinkedAccount() throws Exception { final String TEST_NAME = "test420ReconcileDummyLimeDeleteLinkedAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2306,7 +2276,6 @@ public void test420ReconcileDummyLimeDeleteLinkedAccount() throws Exception { @Test public void test500ImportTAugustusFromResourceDummy() throws Exception { final String TEST_NAME = "test500ImportTAugustusFromResourceDummy"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2372,7 +2341,6 @@ public void test500ImportTAugustusFromResourceDummy() throws Exception { @Test public void test502ImportAugustusFromResourceDummy() throws Exception { final String TEST_NAME = "test502ImportAugustusFromResourceDummy"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2442,7 +2410,6 @@ public void test502ImportAugustusFromResourceDummy() throws Exception { @Test public void test510ImportFromResourceDummy() throws Exception { final String TEST_NAME = "test510ImportFromResourceDummy"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2540,7 +2507,6 @@ public void test510ImportFromResourceDummy() throws Exception { @Test public void test520ReconResourceDummyFilter() throws Exception { final String TEST_NAME = "test520ReconResourceDummyFilter"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2575,7 +2541,6 @@ public void test520ReconResourceDummyFilter() throws Exception { @Test public void test600SearchAllDummyAccounts() throws Exception { final String TEST_NAME = "test600SearchAllDummyAccounts"; - displayTestTitle(TEST_NAME); // GIVEN loginAdministrator(); @@ -2603,7 +2568,6 @@ public void test600SearchAllDummyAccounts() throws Exception { @Test public void test610SearchDummyAccountsNameSubstring() throws Exception { final String TEST_NAME = "test610SearchDummyAccountsNameSubstring"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2633,7 +2597,6 @@ public void test610SearchDummyAccountsNameSubstring() throws Exception { @Test public void test900DeleteDummyShadows() throws Exception { final String TEST_NAME = "test900DeleteDummyShadows"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -2679,7 +2642,6 @@ public void test900DeleteDummyShadows() throws Exception { @Test public void test910DeleteDummyAccounts() throws Exception { final String TEST_NAME = "test910DeleteDummyAccounts"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundLiveSyncTask.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundLiveSyncTask.java index 97631ef76bf..97d089cdfc2 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundLiveSyncTask.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundLiveSyncTask.java @@ -19,12 +19,10 @@ import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; import com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationSituationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; /** * @author semancik @@ -62,7 +60,6 @@ protected String getSyncTaskOid(PrismObject resource) { @Override public void test199DeleteDummyEmeraldAccountMancomb() throws Exception { final String TEST_NAME = "test199DeleteDummyEmeraldAccountMancomb"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(AbstractInboundSyncTest.class.getName() + "." + TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundReconTask.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundReconTask.java index 176c9392779..574aaa87c13 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundReconTask.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundReconTask.java @@ -20,6 +20,7 @@ import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.MiscUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; @@ -66,7 +67,6 @@ protected String getSyncTaskOid(PrismObject resource) { @Override public void test180NoChange() throws Exception { final String TEST_NAME = "test180NoChange"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(AbstractInboundSyncTest.class.getName() + "." + TEST_NAME); @@ -109,7 +109,6 @@ public void test180NoChange() throws Exception { @Override public void test199DeleteDummyEmeraldAccountMancomb() throws Exception { final String TEST_NAME = "test199DeleteDummyEmeraldAccountMancomb"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(AbstractInboundSyncTest.class.getName() + "." + TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTask.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTask.java index 98be34e88f5..e0172bbb0f9 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTask.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTask.java @@ -78,7 +78,6 @@ protected String getSyncTaskOid(PrismObject resource) { @Test public void test999DeletingNotUpdatedShadowDummyGreen() throws Exception { final String TEST_NAME = "test800DeletingNotUpdatedShadowDummyGreen"; - displayTestTitle(TEST_NAME); String ACCOUNT_JACK_DUMMY_USERNAME = "jack"; String ACCOUNT_CAROL_DUMMY_USERNAME = "carol"; diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTaskMechanics.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTaskMechanics.java index 338206ba6e1..a3b9d2074ed 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTaskMechanics.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTaskMechanics.java @@ -24,6 +24,7 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.task.api.TaskExecutionStatus; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.TestResource; import com.evolveum.midpoint.util.exception.ObjectNotFoundException; import com.evolveum.midpoint.util.exception.SchemaException; @@ -148,7 +149,6 @@ private String getUserName(int i, boolean precise) { @Test public void test100SuspendWhileIcfSync() throws Exception { final String TEST_NAME = "test100SuspendWhileIcfSync"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); @@ -179,7 +179,6 @@ public void test100SuspendWhileIcfSync() throws Exception { @Test public void test105SuspendWhileIcfSyncImprecise() throws Exception { final String TEST_NAME = "test105SuspendWhileIcfSyncImprecise"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); @@ -214,7 +213,6 @@ public void test105SuspendWhileIcfSyncImprecise() throws Exception { @Test public void test110SuspendWhileProcessing() throws Exception { final String TEST_NAME = "test110SuspendWhileProcessing"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); @@ -270,7 +268,6 @@ public void test110SuspendWhileProcessing() throws Exception { @Test public void test115SuspendWhileProcessingImprecise() throws Exception { final String TEST_NAME = "test115SuspendWhileProcessingImprecise"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); @@ -314,7 +311,6 @@ public void test115SuspendWhileProcessingImprecise() throws Exception { @Test public void test120Batched() throws Exception { final String TEST_NAME = "test120Batched"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); @@ -382,7 +378,6 @@ public void test120Batched() throws Exception { @Test public void test125BatchedImprecise() throws Exception { final String TEST_NAME = "test125BatchedImprecise"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); @@ -429,7 +424,6 @@ public void test125BatchedImprecise() throws Exception { @Test public void test130Error() throws Exception { final String TEST_NAME = "test130Error"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); @@ -490,7 +484,6 @@ public void test130Error() throws Exception { @Test public void test135ErrorImprecise() throws Exception { final String TEST_NAME = "test135ErrorImprecise"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); @@ -557,7 +550,6 @@ public void test135ErrorImprecise() throws Exception { @Test public void test140DryRun() throws Exception { final String TEST_NAME = "test140DryRun"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); @@ -596,7 +588,6 @@ public void test140DryRun() throws Exception { @Test public void test150DryRunWithUpdate() throws Exception { final String TEST_NAME = "test150DryRunWithUpdate"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelDiscovery.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelDiscovery.java index a1e9afa6135..3ab56ed33b2 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelDiscovery.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelDiscovery.java @@ -195,7 +195,6 @@ protected PrismObject getDefaultActor() { @Test public void test001Sanity() throws Exception { final String TEST_NAME = "test001Sanity"; - displayTestTitle(TEST_NAME); display("Dummy resource azure", dummyResourceSteelBlue); @@ -214,7 +213,6 @@ public void test001Sanity() throws Exception { @Test public void test002SanityRefined() throws Exception { final String TEST_NAME = "test002SanityRefined"; - displayTestTitle(TEST_NAME); // WHEN RefinedResourceSchema refinedSchemaSteelBlue = RefinedResourceSchemaImpl.getRefinedSchema(resourceDummySteelBlueType, prismContext); @@ -231,7 +229,6 @@ public void test002SanityRefined() throws Exception { @Test public void test100Synchronize() throws Exception { final String TEST_NAME = "test100Synchronize"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelSynchronization.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelSynchronization.java index 324b0cede32..2a4000d7da8 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelSynchronization.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelSynchronization.java @@ -20,6 +20,7 @@ import com.evolveum.midpoint.schema.processor.ResourceSchema; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType; @@ -165,7 +166,6 @@ protected PrismObject getDefaultActor() { @Test public void test001SanityAzure() throws Exception { final String TEST_NAME = "test001SanityAzure"; - displayTestTitle(TEST_NAME); display("Dummy resource azure", dummyResourceSteelBlue); @@ -181,7 +181,6 @@ public void test001SanityAzure() throws Exception { @Test public void test002SanityAzureRefined() throws Exception { final String TEST_NAME = "test002SanityAzureRefined"; - displayTestTitle(TEST_NAME); // WHEN RefinedResourceSchema refinedSchemaAzure = RefinedResourceSchemaImpl.getRefinedSchema(resourceDummySteelBlueType, prismContext); @@ -195,7 +194,6 @@ public void test002SanityAzureRefined() throws Exception { @Test public void test100Synchronize() throws Exception { final String TEST_NAME = "test100Synchronize"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestUuid.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestUuid.java index c35d864cd24..4bf2faab8cd 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestUuid.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestUuid.java @@ -121,7 +121,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test200ReconcileDummyUuid() throws Exception { final String TEST_NAME = "test200ReconcileDummyUuid"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TestUuid.class.getName() + "." + TEST_NAME); @@ -171,7 +170,6 @@ public void test200ReconcileDummyUuid() throws Exception { @Test public void test210ReconcileDummyUuidAddAugustus() throws Exception { final String TEST_NAME = "test210ReconcileDummyUuidAddAugustus"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TestUuid.class.getName() + "." + TEST_NAME); @@ -239,7 +237,6 @@ public void test210ReconcileDummyUuidAddAugustus() throws Exception { @Test public void test220ReconcileDummyUuidDeleteAddAugustus() throws Exception { final String TEST_NAME = "test220ReconcileDummyUuidDeleteAddAugustus"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TestUuid.class.getName() + "." + TEST_NAME); @@ -329,7 +326,6 @@ public void test220ReconcileDummyUuidDeleteAddAugustus() throws Exception { @Test public void test230ReconcileDummyUuidDeleteAugustusAddAugustina() throws Exception { final String TEST_NAME = "test230ReconcileDummyUuidDeleteAugustusAddAugustina"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TestUuid.class.getName() + "." + TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestValidityRecomputeTask.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestValidityRecomputeTask.java index ff0656c078b..3bf20bd52af 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestValidityRecomputeTask.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestValidityRecomputeTask.java @@ -83,7 +83,6 @@ protected String getValidityScannerTaskFileName() { @Test public void test100ImportValidityScannerTask() throws Exception { final String TEST_NAME = "test100ImportValidityScannerTask"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -120,7 +119,6 @@ public void test100ImportValidityScannerTask() throws Exception { @Test public void test110JackAssignJudgeDisabled() throws Exception { final String TEST_NAME = "test110JackAssignJudgeDisabled"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -135,7 +133,6 @@ public void test110JackAssignJudgeDisabled() throws Exception { @Test public void test111JackAssignJudgeNotYetValid() throws Exception { final String TEST_NAME = "test111JackAssignJudgeNotYetValid"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -152,7 +149,6 @@ public void test111JackAssignJudgeNotYetValid() throws Exception { @Test public void test112JackAssignJudgeAfterValidity() throws Exception { final String TEST_NAME = "test112JackAssignJudgeAfterValidity"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -169,7 +165,6 @@ public void test112JackAssignJudgeAfterValidity() throws Exception { @Test public void test115JackAssignJudgeEnabled() throws Exception { final String TEST_NAME = "test115JackAssignJudgeEnabled"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -184,7 +179,6 @@ public void test115JackAssignJudgeEnabled() throws Exception { @Test public void test115JackAssignJudgeValid() throws Exception { final String TEST_NAME = "test115JackAssignJudgeValid"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -274,7 +268,6 @@ private void assert11xUserOk(PrismObject user) { @Test public void test120JackDisableAssignmentJudge() throws Exception { final String TEST_NAME = "test120JackDisableAssignmentJudge"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -306,7 +299,6 @@ public void test120JackDisableAssignmentJudge() throws Exception { @Test public void test122JackReplaceNullAdministrativeStatusAssignmentJudge() throws Exception { final String TEST_NAME = "test122JackReplaceNullAdministrativeStatusAssignmentJudge"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -331,7 +323,6 @@ public void test122JackReplaceNullAdministrativeStatusAssignmentJudge() throws E @Test public void test123JackDisableAssignmentJudge() throws Exception { final String TEST_NAME = "test123JackDisableAssignmentJudge"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -356,7 +347,6 @@ public void test123JackDisableAssignmentJudge() throws Exception { @Test public void test124JackEnableAssignmentJudge() throws Exception { final String TEST_NAME = "test124JackEnableAssignmentJudge"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -381,7 +371,6 @@ public void test124JackEnableAssignmentJudge() throws Exception { @Test public void test125JackDeleteAdministrativeStatusAssignmentJudge() throws Exception { final String TEST_NAME = "test125JackDeleteAdministrativeStatusAssignmentJudge"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -408,7 +397,6 @@ public void test125JackDeleteAdministrativeStatusAssignmentJudge() throws Except @Test public void test126JackAddAdministrativeStatusAssignmentJudge() throws Exception { final String TEST_NAME = "test126JackAddAdministrativeStatusAssignmentJudge"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -435,7 +423,6 @@ public void test126JackAddAdministrativeStatusAssignmentJudge() throws Exception @Test public void test127JackDeleteActivationAssignmentJudge() throws Exception { final String TEST_NAME = "test127JackDeleteActivationAssignmentJudge"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -463,7 +450,6 @@ public void test127JackDeleteActivationAssignmentJudge() throws Exception { @Test public void test128JackAssignmentJudgeValidToSetInvalid() throws Exception { final String TEST_NAME = "test128JackAssignmentJudgeValidToSetInvalid"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -493,7 +479,6 @@ public void test128JackAssignmentJudgeValidToSetInvalid() throws Exception { @Test public void test129JackAssignmentJudgeValidToSetValid() throws Exception { final String TEST_NAME = "test129JackAssignmentJudgeValidToSetValid"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -536,7 +521,6 @@ private AssignmentType getJudgeAssignment(String userOid) throws ObjectNotFoundE @Test public void test130BarbossaAssignJudgeEnabled() throws Exception { final String TEST_NAME = "test130BarbossaAssignJudgeEnabled"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -582,7 +566,6 @@ public void test130BarbossaAssignJudgeEnabled() throws Exception { @Test public void test131BarbossaAssignSailorEnabled() throws Exception { final String TEST_NAME = "test131BarbossaAssignSailorEnabled"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -624,7 +607,6 @@ public void test131BarbossaAssignSailorEnabled() throws Exception { @Test public void test132BarbossaDisableAssignmentJudge() throws Exception { final String TEST_NAME = "test132BarbossaDisableAssignmentJudge"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -665,7 +647,6 @@ public void test132BarbossaDisableAssignmentJudge() throws Exception { @Test public void test133BarbossaDisableAssignmentSailor() throws Exception { final String TEST_NAME = "test133BarbossaDisableAssignmentSailor"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -701,7 +682,6 @@ public void test133BarbossaDisableAssignmentSailor() throws Exception { @Test public void test134BarbossaEnableAssignmentJudge() throws Exception { final String TEST_NAME = "test134BarbossaEnableAssignmentJudge"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -739,7 +719,6 @@ public void test134BarbossaEnableAssignmentJudge() throws Exception { @Test public void test135BarbossaEnableAssignmentSailor() throws Exception { final String TEST_NAME = "test135BarbossaEnableAssignmentSailor"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -777,7 +756,6 @@ public void test135BarbossaEnableAssignmentSailor() throws Exception { @Test public void test136BarbossaDisableBothAssignments() throws Exception { final String TEST_NAME = "test136BarbossaDisableBothAssignments"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -823,7 +801,6 @@ public void test136BarbossaDisableBothAssignments() throws Exception { @Test public void test137BarbossaEnableBothAssignments() throws Exception { final String TEST_NAME = "test137BarbossaEnableBothAssignments"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -884,7 +861,6 @@ public void test137BarbossaEnableBothAssignments() throws Exception { @Test public void test139BarbossaDisableBothAssignmentsUnassign() throws Exception { final String TEST_NAME = "test139BarbossaDisableBothAssignmentsUnassign"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -964,7 +940,6 @@ public void test139BarbossaDisableBothAssignmentsUnassign() throws Exception { @Test public void test140BarbossaAssignRedJudgeEnabled() throws Exception { final String TEST_NAME = "test140BarbossaAssignRedJudgeEnabled"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1014,7 +989,6 @@ public void test140BarbossaAssignRedJudgeEnabled() throws Exception { @Test public void test141BarbossaAssignRedSailorEnabled() throws Exception { final String TEST_NAME = "test141BarbossaAssignRedSailorEnabled"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1056,7 +1030,6 @@ public void test141BarbossaAssignRedSailorEnabled() throws Exception { @Test public void test142BarbossaDisableAssignmentRedJudge() throws Exception { final String TEST_NAME = "test142BarbossaDisableAssignmentRedJudge"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1097,7 +1070,6 @@ public void test142BarbossaDisableAssignmentRedJudge() throws Exception { @Test public void test143BarbossaDisableAssignmentRedSailor() throws Exception { final String TEST_NAME = "test143BarbossaDisableAssignmentRedSailor"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1137,7 +1109,6 @@ public void test143BarbossaDisableAssignmentRedSailor() throws Exception { @Test public void test144BarbossaEnableAssignmentRedJudge() throws Exception { final String TEST_NAME = "test144BarbossaEnableAssignmentRedJudge"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1175,7 +1146,6 @@ public void test144BarbossaEnableAssignmentRedJudge() throws Exception { @Test public void test145BarbossaEnableAssignmentRedSailor() throws Exception { final String TEST_NAME = "test145BarbossaEnableAssignmentRedSailor"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1213,7 +1183,6 @@ public void test145BarbossaEnableAssignmentRedSailor() throws Exception { @Test public void test146BarbossaDisableBothRedAssignments() throws Exception { final String TEST_NAME = "test146BarbossaDisableBothRedAssignments"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1269,7 +1238,6 @@ public void test146BarbossaDisableBothRedAssignments() throws Exception { @Test public void test147BarbossaEnableBothRedAssignments() throws Exception { final String TEST_NAME = "test147BarbossaEnableBothRedAssignments"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1330,7 +1298,6 @@ public void test147BarbossaEnableBothRedAssignments() throws Exception { @Test public void test149BarbossaDisableBothRedAssignmentsUnassign() throws Exception { final String TEST_NAME = "test149BarbossaDisableBothRedAssignmentsUnassign"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1410,7 +1377,6 @@ public void test149BarbossaDisableBothRedAssignmentsUnassign() throws Exception @Test public void test190HermanGoesInvalid() throws Exception { final String TEST_NAME = "test190HermanGoesInvalid"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1447,7 +1413,6 @@ public void test190HermanGoesInvalid() throws Exception { @Test public void test200ImportTriggerScannerTask() throws Exception { final String TEST_NAME = "test200ImportTriggerScannerTask"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TestTriggerTask.class.getName() + "." + TEST_NAME); @@ -1477,7 +1442,6 @@ public void test200ImportTriggerScannerTask() throws Exception { @Test public void test205AccountRedElaineDisable() throws Exception { final String TEST_NAME = "test205AccountRedElaineDisable"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -1503,7 +1467,6 @@ public void test205AccountRedElaineDisable() throws Exception { @Test public void test210JackAssignAndUnassignAccountRed() throws Exception { final String TEST_NAME = "test210JackAssignAndUnassignAccountRed"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestMapping.class.getName() + "." + TEST_NAME); @@ -1561,7 +1524,6 @@ public void test210JackAssignAndUnassignAccountRed() throws Exception { @Test public void test215JackDummyAccountDeleteAfterMonth() throws Exception { final String TEST_NAME = "test215JackDummyAccountDeleteAfterMonth"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestMapping.class.getName() + "." + TEST_NAME); @@ -1586,7 +1548,6 @@ public void test215JackDummyAccountDeleteAfterMonth() throws Exception { @Test public void test220AddDrake() throws Exception { final String TEST_NAME = "test220AddDrake"; - displayTestTitle(TEST_NAME); XMLGregorianCalendar start = clock.currentTimeXMLGregorianCalendar(); display("Start", start); @@ -1652,7 +1613,6 @@ public void test220AddDrake() throws Exception { @Test public void test222Drake4DaysBeforeValidFrom() throws Exception { final String TEST_NAME = "test222Drake4DaysBeforeValidFrom"; - displayTestTitle(TEST_NAME); XMLGregorianCalendar start = (XMLGregorianCalendar) drakeValidFrom.clone(); start.add(XmlTypeConverter.createDuration(false, 0, 0, 4, 0, 0, 0)); @@ -1680,7 +1640,6 @@ public void test222Drake4DaysBeforeValidFrom() throws Exception { @Test public void test224Drake1DaysAfterValidFrom() throws Exception { final String TEST_NAME = "test224Drake1DaysAfterValidFrom"; - displayTestTitle(TEST_NAME); XMLGregorianCalendar start = (XMLGregorianCalendar) drakeValidFrom.clone(); start.add(XmlTypeConverter.createDuration(true, 0, 0, 1, 0, 0, 0)); @@ -1707,7 +1666,6 @@ public void test224Drake1DaysAfterValidFrom() throws Exception { @Test public void test226Drake1DayBeforeValidTo() throws Exception { final String TEST_NAME = "test226Drake1DayBeforeValidTo"; - displayTestTitle(TEST_NAME); XMLGregorianCalendar start = (XMLGregorianCalendar) drakeValidTo.clone(); start.add(XmlTypeConverter.createDuration(false, 0, 0, 1, 0, 0, 0)); @@ -1734,7 +1692,6 @@ public void test226Drake1DayBeforeValidTo() throws Exception { @Test public void test228Drake1DayAfterValidTo() throws Exception { final String TEST_NAME = "test228Drake1DayAfterValidTo"; - displayTestTitle(TEST_NAME); XMLGregorianCalendar start = (XMLGregorianCalendar) drakeValidTo.clone(); start.add(XmlTypeConverter.createDuration(true, 0, 0, 1, 0, 0, 0)); @@ -1762,7 +1719,6 @@ public void test228Drake1DayAfterValidTo() throws Exception { @Test public void test230Drake20DaysAfterValidTo() throws Exception { final String TEST_NAME = "test230Drake20DaysAfterValidTo"; - displayTestTitle(TEST_NAME); XMLGregorianCalendar start = (XMLGregorianCalendar) drakeValidTo.clone(); start.add(XmlTypeConverter.createDuration(true, 0, 0, 20, 0, 0, 0)); @@ -1790,7 +1746,6 @@ public void test230Drake20DaysAfterValidTo() throws Exception { @Test public void test232Drake40DaysAfterValidTo() throws Exception { final String TEST_NAME = "test232Drake40DaysAfterValidTo"; - displayTestTitle(TEST_NAME); XMLGregorianCalendar start = (XMLGregorianCalendar) drakeValidTo.clone(); start.add(XmlTypeConverter.createDuration(true, 0, 0, 40, 0, 0, 0)); @@ -1819,7 +1774,6 @@ public void test232Drake40DaysAfterValidTo() throws Exception { @Test public void test250CheckAccountRedElaine() throws Exception { final String TEST_NAME = "test250CheckAccountRedElaine"; - displayTestTitle(TEST_NAME); // GIVEN @@ -1838,7 +1792,6 @@ public void test250CheckAccountRedElaine() throws Exception { @Test public void test300HermanAssignJudgeNotYetValid() throws Exception { final String TEST_NAME = "test300HermanAssignJudgeNotYetValid"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1866,7 +1819,6 @@ public void test300HermanAssignJudgeNotYetValid() throws Exception { @Test public void test310HermanAssignJudgeBecomesValid() throws Exception { final String TEST_NAME = "test310HermanAssignJudgeBecomesValid"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1889,7 +1841,6 @@ public void test310HermanAssignJudgeBecomesValid() throws Exception { @Test public void test315HermanAssignJudgeBecomesInValid() throws Exception { final String TEST_NAME = "test315HermanAssignJudgeBecomesInValid"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); diff --git a/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReport.java b/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReport.java index 9481f8e5f68..3e637064eee 100644 --- a/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReport.java +++ b/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReport.java @@ -28,6 +28,7 @@ import com.evolveum.midpoint.schema.SearchResultList; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.CommunicationException; @@ -68,7 +69,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100ReportUserList() throws Exception { final String TEST_NAME = "test100ReportUserList"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -128,7 +128,6 @@ public void test114ReportUserListExpressionsPoisonousFieldCsv() throws Exception @Test public void test200ReportUserListScript() throws Exception { final String TEST_NAME = "test200ReportUserListScript"; - displayTestTitle(TEST_NAME); if (!isOsUnix()) { displaySkip(TEST_NAME); @@ -178,7 +177,6 @@ public void test310ReportAudit() throws Exception { } protected void testReportListUsersCsv(final String TEST_NAME, String reportOid) throws Exception { - displayTestTitle(TEST_NAME); PrismObject report = getObject(ReportType.class, reportOid); PrismObject finishedTask = runReport(TEST_NAME, report, false); @@ -189,7 +187,6 @@ protected void testReportListUsersCsv(final String TEST_NAME, String reportOid) } protected void testReportListUsersCsvFailure(final String TEST_NAME, String reportOid) throws Exception { - displayTestTitle(TEST_NAME); PrismObject report = getObject(ReportType.class, reportOid); PrismObject finishedTask = runReport(TEST_NAME, report, true); @@ -245,7 +242,6 @@ protected void assertNoCsvReport(PrismObject report) throws IOExcept } protected void testReportAuditCsvSuccess(final String TEST_NAME, String reportOid) throws Exception { - displayTestTitle(TEST_NAME); PrismObject report = getObject(ReportType.class, reportOid); @@ -257,7 +253,6 @@ protected void testReportAuditCsvSuccess(final String TEST_NAME, String reportOi } protected void testReportAuditCsvFailure(final String TEST_NAME, String reportOid) throws Exception { - displayTestTitle(TEST_NAME); PrismObject report = getObject(ReportType.class, reportOid); PrismObject finishedTask = runReport(TEST_NAME, report, true); diff --git a/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReportWebService.java b/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReportWebService.java index e4fe880b0cc..6bdaf3554d3 100644 --- a/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReportWebService.java +++ b/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReportWebService.java @@ -21,6 +21,7 @@ import com.evolveum.midpoint.schema.SearchResultList; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.util.exception.CommunicationException; import com.evolveum.midpoint.util.exception.ConfigurationException; import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; @@ -62,15 +63,13 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); - assertNotNull("No web service", reportWebService); + assertNotNull("No web service", reportWebService); } @Test public void test100ProcessReportUserList() throws Exception { final String TEST_NAME = "test100ProcessReportUserList"; - displayTestTitle(TEST_NAME); String query = createAllQueryString(UserType.class); RemoteReportParametersType parameters = createReportParameters(); @@ -89,7 +88,6 @@ public void test100ProcessReportUserList() throws Exception { @Test public void test110ProcessReportUserListNoReportOid() throws Exception { final String TEST_NAME = "test110ProcessReportUserListNoReportOid"; - displayTestTitle(TEST_NAME); String query = createAllQueryString(UserType.class); RemoteReportParametersType parameters = createReportParameters(); @@ -112,7 +110,6 @@ public void test110ProcessReportUserListNoReportOid() throws Exception { @Test public void test112ProcessReportUserListInvalidReportOid() throws Exception { final String TEST_NAME = "test112ProcessReportUserListInvalidReportOid"; - displayTestTitle(TEST_NAME); String query = createAllQueryString(UserType.class); RemoteReportParametersType parameters = createReportParameters(); @@ -138,7 +135,6 @@ public void test112ProcessReportUserListInvalidReportOid() throws Exception { @Test public void test115ProcessReportUserListUnauthorizedReader() throws Exception { final String TEST_NAME = "test115ProcessReportUserListUnauthorizedReader"; - displayTestTitle(TEST_NAME); login(USER_READER_USERNAME); @@ -168,7 +164,6 @@ public void test115ProcessReportUserListUnauthorizedReader() throws Exception { @Test public void test116ProcessReportUserListUnauthorizedRunner() throws Exception { final String TEST_NAME = "test116ProcessReportUserListUnauthorizedRunner"; - displayTestTitle(TEST_NAME); login(USER_RUNNER_USERNAME); @@ -198,7 +193,6 @@ public void test116ProcessReportUserListUnauthorizedRunner() throws Exception { @Test public void test119ProcessReportUserListReaderRunner() throws Exception { final String TEST_NAME = "test119ProcessReportUserListReaderRunner"; - displayTestTitle(TEST_NAME); login(USER_READER_RUNNER_USERNAME); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorDiscovery.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorDiscovery.java index a12cd5041bb..497a3ada780 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorDiscovery.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorDiscovery.java @@ -58,7 +58,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test001Connectors() throws Exception { final String TEST_NAME = "test001Connectors"; - displayTestTitle(TEST_NAME); OperationResult result = new OperationResult(TestConnectorDiscovery.class.getName() + "." + TEST_NAME); @@ -105,7 +104,6 @@ public void testListConnectors() throws Exception{ @Test public void testSearchConnectorSimple() throws SchemaException{ final String TEST_NAME = "testSearchConnectorSimple"; - displayTestTitle(TEST_NAME); OperationResult result = new OperationResult(TestConnectorDiscovery.class.getName() + "." + TEST_NAME); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorManager.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorManager.java index 4b848972ef7..39900f9bc19 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorManager.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorManager.java @@ -47,7 +47,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100ListConnectorFactories() throws Exception { final String TEST_NAME = "test100ListConnectorFactories"; - displayTestTitle(TEST_NAME); OperationResult result = new OperationResult(TestConnectorDiscovery.class.getName() + "." + TEST_NAME); @@ -77,7 +76,6 @@ public void test100ListConnectorFactories() throws Exception { @Test public void test110SelfTest() throws Exception { final String TEST_NAME = "test100ListConnectorFactories"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestConnectorDiscovery.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -94,7 +92,6 @@ public void test110SelfTest() throws Exception { @Test public void test120FrameworkVersion() throws Exception { final String TEST_NAME = "test120FrameworkVersion"; - displayTestTitle(TEST_NAME); // WHEN String frameworkVersion = connectorManager.getFrameworkVersion(); 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 ba73749f654..ba3e30b76b5 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 @@ -159,7 +159,6 @@ public static void assertCleanShutdown() throws Exception { @Test public void test000Integrity() throws Exception { final String TEST_NAME = "test000Integrity"; - displayTestTitle(TEST_NAME); display("Dummy resource instance", dummyResource.toString()); @@ -191,7 +190,6 @@ public void test000Integrity() throws Exception { @Test public void test010ListConnectors() throws Exception { final String TEST_NAME = "test010ListConnectors"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() + "." + TEST_NAME); @@ -240,7 +238,6 @@ public void test010ListConnectors() throws Exception { @Test public void test012ConnectorRediscovery() { final String TEST_NAME = "test012ConnectorRediscovery"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() + "." + TEST_NAME); @@ -259,7 +256,6 @@ public void test012ConnectorRediscovery() { @Test public void test015ListResourcesNoFetch() throws Exception { final String TEST_NAME = "test015ListResourcesNoFetch"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(AbstractBasicDummyTest.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -303,7 +299,6 @@ public void test015ListResourcesNoFetch() throws Exception { @Test public void test020Connection() throws Exception { final String TEST_NAME = "test020Connection"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -397,7 +392,6 @@ protected void assertResourceAfterTest() { @Test public void test021Configuration() throws Exception { final String TEST_NAME = "test021Configuration"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() + "." + TEST_NAME); @@ -450,7 +444,6 @@ protected void assertConfigurationProperty(PrismProperty confProp) { @Test public void test022ParsedSchema() throws Exception { final String TEST_NAME = "test022ParsedSchema"; - displayTestTitle(TEST_NAME); // GIVEN // THEN @@ -480,7 +473,6 @@ public void test022ParsedSchema() throws Exception { @Test public void test023RefinedSchema() throws Exception { final String TEST_NAME = "test023RefinedSchema"; - displayTestTitle(TEST_NAME); // GIVEN // WHEN @@ -568,7 +560,6 @@ public void test023RefinedSchema() throws Exception { @Test public void test024ParsedSchemaAgain() throws Exception { final String TEST_NAME = "test024ParsedSchemaAgain"; - displayTestTitle(TEST_NAME); // GIVEN // THEN @@ -588,7 +579,6 @@ public void test024ParsedSchemaAgain() throws Exception { @Test public void test028Capabilities() throws Exception { final String TEST_NAME = "test028Capabilities"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() @@ -722,7 +712,6 @@ protected void assertNativeCredentialsCapability(CredentialsCapabilityType capCr @Test public void test029CapabilitiesRepo() throws Exception { final String TEST_NAME = "test029CapabilitiesRepo"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() @@ -791,7 +780,6 @@ public void test029CapabilitiesRepo() throws Exception { @Test public void test030ResourceAndConnectorCachingTestConnection() throws Exception { final String TEST_NAME = "test030ResourceAndConnectorCachingTestConnection"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); @@ -828,7 +816,6 @@ public void test030ResourceAndConnectorCachingTestConnection() throws Exception @Test public void test032ResourceAndConnectorCaching() throws Exception { final String TEST_NAME = "test032ResourceAndConnectorCaching"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestOpenDj.class.getName() + "." + TEST_NAME); @@ -906,7 +893,6 @@ public void test032ResourceAndConnectorCaching() throws Exception { @Test public void test034ResourceAndConnectorCachingForceFresh() throws Exception { - displayTestTitle("test034ResourceAndConnectorCachingForceFresh"); // GIVEN OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() @@ -964,7 +950,6 @@ public void test034ResourceAndConnectorCachingForceFresh() throws Exception { @Test public void test040ApplyDefinitionShadow() throws Exception { final String TEST_NAME = "test040ApplyDefinitionShadow"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -990,7 +975,6 @@ public void test040ApplyDefinitionShadow() throws Exception { @Test public void test041ApplyDefinitionAddShadowDelta() throws Exception { final String TEST_NAME = "test041ApplyDefinitionAddShadowDelta"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1017,7 +1001,6 @@ public void test041ApplyDefinitionAddShadowDelta() throws Exception { @Test public void test042ApplyDefinitionResource() throws Exception { final String TEST_NAME = "test042ApplyDefinitionResource"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1047,7 +1030,6 @@ public void test042ApplyDefinitionResource() throws Exception { @Test public void test043ApplyDefinitionAddResourceDelta() throws Exception { final String TEST_NAME = "test043ApplyDefinitionAddResourceDelta"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1104,7 +1086,6 @@ public void test050SelfTest() throws Exception { @Test public void test080TestAttributesToReturn() throws Exception { final String TEST_NAME = "test080TestAttributesToReturn"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(); @@ -1132,7 +1113,6 @@ public void test080TestAttributesToReturn() throws Exception { @Test public void test090ConnectorStatsAfterSomeUse() throws Exception { final String TEST_NAME = "test090ConnectorStatsAfterSomeUse"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1165,7 +1145,6 @@ public void test090ConnectorStatsAfterSomeUse() throws Exception { @Test public void test100AddAccountWill() throws Exception { final String TEST_NAME = "test100AddAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1317,7 +1296,6 @@ protected void checkRepoAccountShadowWill(PrismObject accountRepo, X @Test public void test102GetAccount() throws Exception { final String TEST_NAME = "test102GetAccount"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() + "." + TEST_NAME); @@ -1358,7 +1336,6 @@ public void test102GetAccount() throws Exception { @Test public void test103GetAccountNoFetch() throws Exception { final String TEST_NAME="test103GetAccountNoFetch"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() + "."+TEST_NAME); @@ -1396,7 +1373,6 @@ public void test103GetAccountNoFetch() throws Exception { @Test public void test105ApplyDefinitionModifyDelta() throws Exception { final String TEST_NAME = "test105ApplyDefinitionModifyDelta"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1426,7 +1402,6 @@ public void test105ApplyDefinitionModifyDelta() throws Exception { @Test public void test106GetModifiedAccount() throws Exception { final String TEST_NAME = "test106GetModifiedAccount"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() + "." + TEST_NAME); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); @@ -1480,7 +1455,6 @@ public void test106GetModifiedAccount() throws Exception { @Test public void test999Shutdown() throws Exception { final String TEST_NAME = "test999Shutdown"; - displayTestTitle(TEST_NAME); // WHEN provisioningService.shutdown(); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummy.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummy.java index f3098a8ba12..c9590a8679a 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummy.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummy.java @@ -73,10 +73,7 @@ import com.evolveum.midpoint.schema.util.SchemaTestConstants; import com.evolveum.midpoint.schema.util.ShadowUtil; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.DummyResourceContoller; -import com.evolveum.midpoint.test.IntegrationTestTools; -import com.evolveum.midpoint.test.ObjectChecker; -import com.evolveum.midpoint.test.ProvisioningScriptSpec; +import com.evolveum.midpoint.test.*; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.Holder; import com.evolveum.midpoint.util.exception.CommunicationException; @@ -169,7 +166,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test101AddAccountWithoutName() throws Exception { final String TEST_NAME = "test101AddAccountWithoutName"; - displayTestTitle(TEST_NAME); // GIVEN Task syncTask = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -254,7 +250,6 @@ public void test101AddAccountWithoutName() throws Exception { @Test public void test107AGetModifiedAccountFromCacheMax() throws Exception { final String TEST_NAME = "test107AGetModifiedAccountFromCacheMax"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); @@ -309,7 +304,6 @@ public void test107AGetModifiedAccountFromCacheMax() throws Exception { @Test public void test107BGetModifiedAccountFromCacheHighStaleness() throws Exception { final String TEST_NAME = "test107BGetModifiedAccountFromCacheHighStaleness"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); @@ -360,7 +354,6 @@ public void test107CSkipCachingForIncompleteAttributes() throws Exception { @Test public void test108GetAccountLowStaleness() throws Exception { final String TEST_NAME = "test106GetModifiedAccount"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); @@ -417,7 +410,6 @@ public void test108GetAccountLowStaleness() throws Exception { @Test public void test109ModifiedAccountCleanup() throws Exception { final String TEST_NAME = "test109ModifiedAccountCleanup"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -458,7 +450,6 @@ public void test109ModifiedAccountCleanup() throws Exception { @Test public void test110SeachIterative() throws Exception { final String TEST_NAME = "test110SeachIterative"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -577,7 +568,6 @@ public boolean handle(PrismObject object, OperationResult parentResu @Test public void test111SeachIterativeNoFetch() throws Exception { final String TEST_NAME = "test111SeachIterativeNoFetch"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -632,7 +622,6 @@ public void test111SeachIterativeNoFetch() throws Exception { @Test public void test112SeachIterativeKindIntent() throws Exception { final String TEST_NAME = "test112SeachIterativeKindIntent"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -685,7 +674,6 @@ private int countProtected(List> shadows) @Test public void test113SearchAllShadowsInRepository() throws Exception { - displayTestTitle("test113SearchAllShadowsInRepository"); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + ".test113SearchAllShadowsInRepository"); @@ -711,7 +699,6 @@ public void test113SearchAllShadowsInRepository() throws Exception { @Test public void test114SearchAllAccounts() throws Exception { final String TEST_NAME = "test114SearchAllAccounts"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -742,7 +729,6 @@ public void test114SearchAllAccounts() throws Exception { @Test public void test115CountAllAccounts() throws Exception { final String TEST_NAME = "test115CountAllAccounts"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); ObjectQuery query = IntegrationTestTools.createAllShadowsQuery(resourceType, @@ -771,7 +757,6 @@ protected Integer getTest115ExpectedCount() { @Test public void test116SearchNullQueryResource() throws Exception { final String TEST_NAME = "test116SearchNullQueryResource"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -795,7 +780,6 @@ public void test116SearchNullQueryResource() throws Exception { @Test public void test117CountNullQueryResource() throws Exception { - displayTestTitle("test117CountNullQueryResource"); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + ".test117CountNullQueryResource"); @@ -824,7 +808,6 @@ public void test117CountNullQueryResource() throws Exception { @Test public void test118SearchAllAccountsLongStaleness() throws Exception { final String TEST_NAME = "test118SearchAllAccountsLongStaleness"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -872,7 +855,6 @@ public void test118SearchAllAccountsLongStaleness() throws Exception { @Test public void test119SearchAllAccountsMaxStaleness() throws Exception { final String TEST_NAME = "test119SearchAllAccountsMaxStaleness"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -916,7 +898,6 @@ public void test119SearchAllAccountsMaxStaleness() throws Exception { @Test public void test120ModifyWillReplaceFullname() throws Exception { final String TEST_NAME = "test120ModifyWillReplaceFullname"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -948,7 +929,6 @@ public void test120ModifyWillReplaceFullname() throws Exception { @Test public void test121ModifyObjectAddPirate() throws Exception { final String TEST_NAME = "test121ModifyObjectAddPirate"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -983,7 +963,6 @@ public void test121ModifyObjectAddPirate() throws Exception { @Test public void test122ModifyObjectAddCaptain() throws Exception { final String TEST_NAME = "test122ModifyObjectAddCaptain"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1018,7 +997,6 @@ public void test122ModifyObjectAddCaptain() throws Exception { @Test public void test123ModifyObjectDeletePirate() throws Exception { final String TEST_NAME = "test123ModifyObjectDeletePirate"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1056,7 +1034,6 @@ public void test123ModifyObjectDeletePirate() throws Exception { @Test public void test124ModifyAccountWillAddCaptainAgain() throws Exception { final String TEST_NAME = "test124ModifyAccountWillAddCaptainAgain"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1093,7 +1070,6 @@ public void test124ModifyAccountWillAddCaptainAgain() throws Exception { @Test public void test125CompareAccountWillPassword() throws Exception { final String TEST_NAME = "test125CompareAccountWillPassword"; - displayTestTitle(TEST_NAME); testComparePassword(TEST_NAME, "match", ACCOUNT_WILL_OID, accountWillCurrentPassword, getExpectedPasswordComparisonResultMatch()); testComparePassword(TEST_NAME, "mismatch", ACCOUNT_WILL_OID, "I woulD NeVeR ever USE this PASSword", getExpectedPasswordComparisonResultMismatch()); @@ -1107,7 +1083,6 @@ public void test125CompareAccountWillPassword() throws Exception { @Test public void test126ModifyAccountWillPassword() throws Exception { final String TEST_NAME = "test126ModifyAccountWillPassword"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1150,7 +1125,6 @@ public void test126ModifyAccountWillPassword() throws Exception { @Test public void test127CompareAccountWillPassword() throws Exception { final String TEST_NAME = "test125CompareAccountWillPassword"; - displayTestTitle(TEST_NAME); testComparePassword(TEST_NAME, "match", ACCOUNT_WILL_OID, accountWillCurrentPassword, getExpectedPasswordComparisonResultMatch()); testComparePassword(TEST_NAME, "mismatch old password", ACCOUNT_WILL_OID, ACCOUNT_WILL_PASSWORD, getExpectedPasswordComparisonResultMismatch()); @@ -1185,7 +1159,6 @@ protected void testComparePassword(final String TEST_NAME, String tag, String sh @Test public void test129NullAttributeValue() throws Exception { final String TEST_NAME = "test129NullAttributeValue"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1214,7 +1187,6 @@ public void test129NullAttributeValue() throws Exception { @Test public void test131AddScript() throws Exception { final String TEST_NAME = "test131AddScript"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -1269,7 +1241,6 @@ public void test131AddScript() throws Exception { @Test public void test132ModifyScript() throws Exception { final String TEST_NAME = "test132ModifyScript"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1315,7 +1286,6 @@ public void test132ModifyScript() throws Exception { @Test public void test133ModifyScriptNoExec() throws Exception { final String TEST_NAME = "test133ModifyScriptNoExec"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -1357,7 +1327,6 @@ public void test133ModifyScriptNoExec() throws Exception { @Test public void test134DeleteScript() throws Exception { final String TEST_NAME = "test134DeleteScript"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -1394,7 +1363,6 @@ public void test134DeleteScript() throws Exception { @Test public void test135ExecuteScript() throws Exception { final String TEST_NAME = "test135ExecuteScript"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -1425,7 +1393,6 @@ public void test135ExecuteScript() throws Exception { @Test public void test150DisableAccount() throws Exception { final String TEST_NAME = "test150DisableAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -1470,7 +1437,6 @@ public void test150DisableAccount() throws Exception { @Test public void test151SearchDisabledAccounts() throws Exception { final String TEST_NAME = "test151SearchDisabledAccounts"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -1503,7 +1469,6 @@ public void test151SearchDisabledAccounts() throws Exception { @Test public void test152ActivationStatusUndefinedAccount() throws Exception { final String TEST_NAME = "test152ActivationStatusUndefinedAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -1550,7 +1515,6 @@ public void test152ActivationStatusUndefinedAccount() throws Exception { @Test public void test154EnableAccount() throws Exception { final String TEST_NAME = "test154EnableAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -1594,7 +1558,6 @@ public void test154EnableAccount() throws Exception { @Test public void test155SearchDisabledAccounts() throws Exception { final String TEST_NAME = "test155SearchDisabledAccounts"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -1625,7 +1588,6 @@ public void test155SearchDisabledAccounts() throws Exception { @Test public void test156SetValidFrom() throws Exception { final String TEST_NAME = "test156SetValidFrom"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -1672,7 +1634,6 @@ public void test156SetValidFrom() throws Exception { @Test public void test157SetValidTo() throws Exception { final String TEST_NAME = "test157SetValidTo"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -1722,7 +1683,6 @@ public void test157SetValidTo() throws Exception { @Test public void test158DeleteValidToValidFrom() throws Exception { final String TEST_NAME = "test158DeleteValidToValidFrom"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -1778,7 +1738,6 @@ public void test158DeleteValidToValidFrom() throws Exception { @Test public void test159GetLockedoutAccount() throws Exception { final String TEST_NAME = "test159GetLockedoutAccount"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -1821,7 +1780,6 @@ public void test159GetLockedoutAccount() throws Exception { @Test public void test160SearchLockedAccounts() throws Exception { final String TEST_NAME = "test160SearchLockedAccounts"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -1854,7 +1812,6 @@ public void test160SearchLockedAccounts() throws Exception { @Test public void test162UnlockAccount() throws Exception { final String TEST_NAME = "test162UnlockAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -1900,7 +1857,6 @@ public void test162UnlockAccount() throws Exception { @Test public void test163GetAccount() throws Exception { final String TEST_NAME = "test163GetAccount"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -1941,7 +1897,6 @@ public void test163GetAccount() throws Exception { @Test public void test163SearchLockedAccounts() throws Exception { final String TEST_NAME = "test163SearchLockedAccounts"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -1971,7 +1926,6 @@ public void test163SearchLockedAccounts() throws Exception { @Test public void test170SearchNull() throws Exception { final String TEST_NAME = "test170SearchNull"; - displayTestTitle(TEST_NAME); testSeachIterative(TEST_NAME, null, null, true, true, false, "meathook", "daemon", transformNameFromResource("morgan"), transformNameFromResource("Will")); } @@ -1979,7 +1933,6 @@ public void test170SearchNull() throws Exception { @Test public void test171SearchShipSeaMonkey() throws Exception { final String TEST_NAME = "test171SearchShipSeaMonkey"; - displayTestTitle(TEST_NAME); testSeachIterativeSingleAttrFilter(TEST_NAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "Sea Monkey", null, true, "meathook"); @@ -1989,7 +1942,6 @@ public void test171SearchShipSeaMonkey() throws Exception { @Test(enabled=false) public void test172SearchShipNull() throws Exception { final String TEST_NAME = "test172SearchShipNull"; - displayTestTitle(TEST_NAME); testSeachIterativeSingleAttrFilter(TEST_NAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, null, null, true, "daemon", "Will"); @@ -1998,7 +1950,6 @@ public void test172SearchShipNull() throws Exception { @Test public void test173SearchWeaponCutlass() throws Exception { final String TEST_NAME = "test173SearchWeaponCutlass"; - displayTestTitle(TEST_NAME); // Make sure there is an account on resource that the provisioning has // never seen before, so there is no shadow @@ -2020,7 +1971,6 @@ public void test173SearchWeaponCutlass() throws Exception { @Test public void test175SearchUidExact() throws Exception { final String TEST_NAME = "test175SearchUidExact"; - displayTestTitle(TEST_NAME); dummyResource.setDisableNameHintChecks(true); testSeachIterativeSingleAttrFilter(TEST_NAME, SchemaConstants.ICFS_UID, willIcfUid, null, true, @@ -2031,7 +1981,6 @@ public void test175SearchUidExact() throws Exception { @Test public void test176SearchUidExactNoFetch() throws Exception { final String TEST_NAME = "test176SearchUidExactNoFetch"; - displayTestTitle(TEST_NAME); testSeachIterativeSingleAttrFilter(TEST_NAME, SchemaConstants.ICFS_UID, willIcfUid, GetOperationOptions.createNoFetch(), false, transformNameFromResource("Will")); @@ -2040,7 +1989,6 @@ public void test176SearchUidExactNoFetch() throws Exception { @Test public void test177SearchIcfNameRepoized() throws Exception { final String TEST_NAME = "test177SearchIcfNameRepoized"; - displayTestTitle(TEST_NAME); testSeachIterativeSingleAttrFilter(TEST_NAME, SchemaConstants.ICFS_NAME, getWillRepoIcfName(), null, true, transformNameFromResource(ACCOUNT_WILL_USERNAME)); @@ -2049,7 +1997,6 @@ SchemaConstants.ICFS_NAME, getWillRepoIcfName(), null, true, @Test public void test180SearchNullPagingOffset0Size3() throws Exception { final String TEST_NAME = "test180SearchNullPagingSize5"; - displayTestTitle(TEST_NAME); ObjectPaging paging = prismContext.queryFactory().createPaging(0,3); paging.setOrdering(createAttributeOrdering(SchemaConstants.ICFS_NAME)); SearchResultMetadata searchMetadata = testSeachIterativePaging(TEST_NAME, null, paging, null, @@ -2064,7 +2011,6 @@ public void test180SearchNullPagingOffset0Size3() throws Exception { @Test public void test181SearchNullPagingOffset0Size3Desc() throws Exception { final String TEST_NAME = "test181SearchNullPagingOffset0Size3Desc"; - displayTestTitle(TEST_NAME); ObjectPaging paging = prismContext.queryFactory().createPaging(0,3); paging.setOrdering(createAttributeOrdering(SchemaConstants.ICFS_NAME, OrderDirection.DESCENDING)); SearchResultMetadata searchMetadata = testSeachIterativePaging(TEST_NAME, null, paging, null, @@ -2075,7 +2021,6 @@ public void test181SearchNullPagingOffset0Size3Desc() throws Exception { @Test public void test182SearchNullPagingOffset1Size2() throws Exception { final String TEST_NAME = "test182SearchNullPagingOffset1Size2"; - displayTestTitle(TEST_NAME); ObjectPaging paging = prismContext.queryFactory().createPaging(1,2); paging.setOrdering(createAttributeOrdering(SchemaConstants.ICFS_NAME)); SearchResultMetadata searchMetadata = testSeachIterativePaging(TEST_NAME, null, paging, null, @@ -2086,7 +2031,6 @@ public void test182SearchNullPagingOffset1Size2() throws Exception { @Test public void test183SearchNullPagingOffset2Size3Desc() throws Exception { final String TEST_NAME = "test183SearchNullPagingOffset1Size3Desc"; - displayTestTitle(TEST_NAME); ObjectPaging paging = prismContext.queryFactory().createPaging(2,3); paging.setOrdering(createAttributeOrdering(SchemaConstants.ICFS_NAME, OrderDirection.DESCENDING)); SearchResultMetadata searchMetadata = testSeachIterativePaging(TEST_NAME, null, paging, null, @@ -2123,7 +2067,6 @@ protected ObjectOrdering createAttributeOrdering(QName attrQname, OrderDirection @Test public void test194SearchIcfNameRepoizedNoFetch() throws Exception { final String TEST_NAME = "test194SearchIcfNameRepoizedNoFetch"; - displayTestTitle(TEST_NAME); testSeachIterativeSingleAttrFilter(TEST_NAME, SchemaConstants.ICFS_NAME, getWillRepoIcfName(), GetOperationOptions.createNoFetch(), false, transformNameFromResource(ACCOUNT_WILL_USERNAME)); @@ -2132,7 +2075,6 @@ public void test194SearchIcfNameRepoizedNoFetch() throws Exception { @Test public void test195SearchIcfNameExact() throws Exception { final String TEST_NAME = "test195SearchIcfNameExact"; - displayTestTitle(TEST_NAME); testSeachIterativeSingleAttrFilter(TEST_NAME, SchemaConstants.ICFS_NAME, transformNameFromResource(ACCOUNT_WILL_USERNAME), null, true, transformNameFromResource(ACCOUNT_WILL_USERNAME)); @@ -2141,7 +2083,6 @@ SchemaConstants.ICFS_NAME, transformNameFromResource(ACCOUNT_WILL_USERNAME), nul @Test public void test196SearchIcfNameExactNoFetch() throws Exception { final String TEST_NAME = "test196SearchIcfNameExactNoFetch"; - displayTestTitle(TEST_NAME); testSeachIterativeSingleAttrFilter(TEST_NAME, SchemaConstants.ICFS_NAME, transformNameFromResource(ACCOUNT_WILL_USERNAME), GetOperationOptions.createNoFetch(), false, transformNameFromResource(ACCOUNT_WILL_USERNAME)); @@ -2151,7 +2092,6 @@ public void test196SearchIcfNameExactNoFetch() throws Exception { @Test public void test197SearchIcfNameAndUidExactNoFetch() throws Exception { final String TEST_NAME = "test197SearchIcfNameAndUidExactNoFetch"; - displayTestTitle(TEST_NAME); testSeachIterativeAlternativeAttrFilter(TEST_NAME, SchemaConstants.ICFS_NAME, transformNameFromResource(ACCOUNT_WILL_USERNAME), SchemaConstants.ICFS_UID, willIcfUid, GetOperationOptions.createNoFetch(), false, @@ -2162,7 +2102,6 @@ public void test197SearchIcfNameAndUidExactNoFetch() throws Exception { @Test public void test198SearchNone() throws Exception { final String TEST_NAME = "test198SearchNone"; - displayTestTitle(TEST_NAME); ObjectFilter attrFilter = FilterCreationUtil.createNone(prismContext); testSeachIterative(TEST_NAME, attrFilter, null, true, true, false); } @@ -2175,7 +2114,6 @@ public void test198SearchNone() throws Exception { @Test public void test199SearchOnAndOffResource() throws Exception { final String TEST_NAME = "test199SearchOnAndOffResource"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -2217,7 +2155,6 @@ public boolean handle(PrismObject object, OperationResult parentResu @Test public void test196SearchOnAndOffResourceNoFetch() throws Exception { final String TEST_NAME = "test196SearchOnAndOffResourceNoFetch"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -2451,7 +2388,6 @@ public boolean handle(PrismObject shadow, OperationResult parentResu @Test public void test200AddGroup() throws Exception { final String TEST_NAME = "test200AddGroup"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -2514,7 +2450,6 @@ public void test200AddGroup() throws Exception { @Test public void test202GetGroup() throws Exception { final String TEST_NAME = "test202GetGroup"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -2557,7 +2492,6 @@ private void checkGroupPirates(PrismObject shadow, OperationResult r @Test public void test203GetGroupNoFetch() throws Exception { final String TEST_NAME="test203GetGroupNoFetch"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "."+TEST_NAME); @@ -2592,7 +2526,6 @@ public void test203GetGroupNoFetch() throws Exception { @Test public void test205ModifyGroupReplace() throws Exception { final String TEST_NAME = "test205ModifyGroupReplace"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -2632,7 +2565,6 @@ public void test205ModifyGroupReplace() throws Exception { @Test public void test210AddPrivilege() throws Exception { final String TEST_NAME = "test210AddPrivilege"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -2686,7 +2618,6 @@ public void test210AddPrivilege() throws Exception { @Test public void test212GetPriv() throws Exception { final String TEST_NAME = "test212GetPriv"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -2725,7 +2656,6 @@ private void checkPrivPillage(PrismObject shadow, OperationResult re @Test public void test214AddPrivilegeBargain() throws Exception { final String TEST_NAME = "test214AddPrivilegeBargain"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -2797,7 +2727,6 @@ private void checkPrivBargain(PrismObject shadow, OperationResult re @Test public void test220EntitleAccountWillPirates() throws Exception { final String TEST_NAME = "test220EntitleAccountWillPirates"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -2843,7 +2772,6 @@ public void test220EntitleAccountWillPirates() throws Exception { @Test public void test221GetPirateWill() throws Exception { final String TEST_NAME = "test221GetPirateWill"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -2876,7 +2804,6 @@ public void test221GetPirateWill() throws Exception { @Test public void test222EntitleAccountWillPillage() throws Exception { final String TEST_NAME = "test222EntitleAccountWillPillage"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2932,7 +2859,6 @@ public void test222EntitleAccountWillPillage() throws Exception { @Test public void test223EntitleAccountWillBargain() throws Exception { final String TEST_NAME = "test223EntitleAccountWillBargain"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2981,7 +2907,6 @@ public void test223EntitleAccountWillBargain() throws Exception { @Test public void test224GetPillagingPirateWill() throws Exception { final String TEST_NAME = "test224GetPillagingPirateWill"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -3034,7 +2959,6 @@ public void test224GetPillagingPirateWill() throws Exception { @Test public void test225GetFoolishPirateWill() throws Exception { final String TEST_NAME = "test225GetFoolishPirateWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -3105,7 +3029,6 @@ public void test225GetFoolishPirateWill() throws Exception { @Test public void test226WillNonsensePrivilege() throws Exception { final String TEST_NAME = "test226WillNonsensePrivilege"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -3165,7 +3088,6 @@ public void test226WillNonsensePrivilege() throws Exception { @Test public void test230DetitleAccountWillPirates() throws Exception { final String TEST_NAME = "test230DetitleAccountWillPirates"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -3198,7 +3120,6 @@ public void test230DetitleAccountWillPirates() throws Exception { @Test public void test232EntitleAccountWillPiratesIdentifiersName() throws Exception { final String TEST_NAME = "test232EntitleAccountWillPiratesIdentifiersName"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -3231,7 +3152,6 @@ public void test232EntitleAccountWillPiratesIdentifiersName() throws Exception { @Test public void test233DetitleAccountWillPiratesIdentifiersName() throws Exception { final String TEST_NAME = "test233DetitleAccountWillPiratesIdentifiersName"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -3264,7 +3184,6 @@ public void test233DetitleAccountWillPiratesIdentifiersName() throws Exception { @Test public void test234EntitleAccountWillPiratesIdentifiersUid() throws Exception { final String TEST_NAME = "test234EntitleAccountWillPiratesIdentifiersUid"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -3297,7 +3216,6 @@ public void test234EntitleAccountWillPiratesIdentifiersUid() throws Exception { @Test public void test235DetitleAccountWillPiratesIdentifiersUid() throws Exception { final String TEST_NAME = "test235DetitleAccountWillPiratesIdentifiersUid"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -3403,7 +3321,6 @@ private void assertAccountPiratesEntitled() throws Exception { @Test public void test238DetitleAccountWillPillage() throws Exception { final String TEST_NAME = "test238DetitleAccountWillPillage"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -3452,7 +3369,6 @@ public void test238DetitleAccountWillPillage() throws Exception { @Test public void test239DetitleAccountWillBargain() throws Exception { final String TEST_NAME = "test239DetitleAccountWillBargain"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -3499,7 +3415,6 @@ public void test239DetitleAccountWillBargain() throws Exception { @Test public void test260AddAccountLeChuck() throws Exception { final String TEST_NAME = "test260AddAccountLeChuck"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -3584,7 +3499,6 @@ public void test260AddAccountLeChuck() throws Exception { @Test public void test265DeleteAccountLeChuck() throws Exception { final String TEST_NAME = "test265DeleteAccountLeChuck"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -3635,7 +3549,6 @@ public void test265DeleteAccountLeChuck() throws Exception { @Test public void test298DeletePrivPillage() throws Exception { final String TEST_NAME = "test298DeletePrivPillage"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -3675,7 +3588,6 @@ public void test298DeletePrivPillage() throws Exception { @Test public void test299DeleteGroupPirates() throws Exception { final String TEST_NAME = "test299DeleteGroupPirates"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -3715,7 +3627,6 @@ public void test299DeleteGroupPirates() throws Exception { @Test public void test300AccountRename() throws Exception { final String TEST_NAME = "test300AccountRename"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -3769,7 +3680,6 @@ public void test300AccountRename() throws Exception { @Test public void test310ModifyMorganEnlistTimestamp() throws Exception { final String TEST_NAME = "test310ModifyMorganEnlistTimestamp"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -3810,7 +3720,6 @@ public void test310ModifyMorganEnlistTimestamp() throws Exception { @Test public void test330ModifyAccountWillPasswordSelfService() throws Exception { final String TEST_NAME = "test330ModifyAccountWillPasswordSelfService"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -3861,7 +3770,6 @@ public void test330ModifyAccountWillPasswordSelfService() throws Exception { @Test public void test340ModifyWillReplaceGossipBloodAvast() throws Exception { final String TEST_NAME = "test340ModifyWillReplaceGossipBloodAvast"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -3894,7 +3802,6 @@ public void test340ModifyWillReplaceGossipBloodAvast() throws Exception { @Test public void test342ModifyWillAddGossipEunuch() throws Exception { final String TEST_NAME = "test342ModifyWillAddGossipEunuch"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -3927,7 +3834,6 @@ public void test342ModifyWillAddGossipEunuch() throws Exception { @Test public void test344ModifyWillDeleteGossipAvast() throws Exception { final String TEST_NAME = "test344ModifyWillDeleteGossipAvast"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -4002,14 +3908,12 @@ protected String getLastModifierName(String expected) { @Test public void test500AddProtectedAccount() throws Exception { final String TEST_NAME = "test500AddProtectedAccount"; - displayTestTitle(TEST_NAME); testAddProtectedAccount(TEST_NAME, ACCOUNT_DAVIEJONES_USERNAME); } @Test public void test501GetProtectedAccountShadow() throws Exception { final String TEST_NAME = "test501GetProtectedAccountShadow"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -4033,7 +3937,6 @@ public void test501GetProtectedAccountShadow() throws Exception { @Test public void test502ModifyProtectedAccountShadowAttributes() throws Exception { final String TEST_NAME = "test502ModifyProtectedAccountShadowAttributes"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -4075,7 +3978,6 @@ public void test502ModifyProtectedAccountShadowAttributes() throws Exception { @Test public void test503ModifyProtectedAccountShadowProperty() throws Exception { final String TEST_NAME = "test503ModifyProtectedAccountShadowProperty"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -4105,7 +4007,6 @@ public void test503ModifyProtectedAccountShadowProperty() throws Exception { @Test public void test509DeleteProtectedAccountShadow() throws Exception { final String TEST_NAME = "test509DeleteProtectedAccountShadow"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -4137,7 +4038,6 @@ public void test509DeleteProtectedAccountShadow() throws Exception { @Test public void test510AddProtectedAccounts() throws Exception { final String TEST_NAME = "test510AddProtectedAccounts"; - displayTestTitle(TEST_NAME); // GIVEN testAddProtectedAccount(TEST_NAME, "Xavier"); testAddProtectedAccount(TEST_NAME, "Xenophobia"); @@ -4150,7 +4050,6 @@ public void test510AddProtectedAccounts() throws Exception { @Test public void test511AddProtectedAccountCaseIgnore() throws Exception { final String TEST_NAME = "test511AddProtectedAccountCaseIgnore"; - displayTestTitle(TEST_NAME); // GIVEN testAddAccount(TEST_NAME, "xaxa"); testAddAccount(TEST_NAME, "somebody-ADM"); @@ -4230,7 +4129,6 @@ private void testAddAccount(final String TEST_NAME, String username) throws Exce @Test public void test520MigrationPrimaryIdentifierValueRefresh() throws Exception { final String TEST_NAME = "test520MigrationPrimaryIdentifierValueRefresh"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -4263,7 +4161,6 @@ public void test520MigrationPrimaryIdentifierValueRefresh() throws Exception { @Test public void test600AddAccountAlreadyExist() throws Exception { final String TEST_NAME = "test600AddAccountAlreadyExist"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -4309,7 +4206,6 @@ public void test600AddAccountAlreadyExist() throws Exception { @Test public void test800LiveSyncInit() throws Exception { final String TEST_NAME = "test800LiveSyncInit"; - displayTestTitle(TEST_NAME); syncTokenTask = taskManager.createTaskInstance(TestDummy.class.getName() + ".syncTask"); dummyResource.setSyncStyle(DummySyncStyle.DUMB); @@ -4345,7 +4241,6 @@ public void test800LiveSyncInit() throws Exception { @Test public void test801LiveSyncAddBlackbeard() throws Exception { final String TEST_NAME = "test801LiveSyncAddBlackbeard"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -4414,7 +4309,6 @@ public void test801LiveSyncAddBlackbeard() throws Exception { @Test public void test802LiveSyncModifyBlackbeard() throws Exception { final String TEST_NAME = "test802LiveSyncModifyBlackbeard"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -4574,7 +4468,6 @@ public void test849LiveSyncDeleteDrakeSmartAny() throws Exception { } public void testLiveSyncAddDrake(final String TEST_NAME, DummySyncStyle syncStyle, QName objectClass) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -4651,7 +4544,6 @@ public void testLiveSyncAddDrake(final String TEST_NAME, DummySyncStyle syncStyl } public void testLiveSyncModifyDrake(final String TEST_NAME, DummySyncStyle syncStyle, QName objectClass) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -4709,7 +4601,6 @@ public void testLiveSyncModifyDrake(final String TEST_NAME, DummySyncStyle syncS } public void testLiveSyncAddCorsairs(final String TEST_NAME, DummySyncStyle syncStyle, QName objectClass, boolean expectReaction) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -4785,7 +4676,6 @@ public void testLiveSyncAddCorsairs(final String TEST_NAME, DummySyncStyle syncS } public void testLiveSyncDeleteCorsairs(final String TEST_NAME, DummySyncStyle syncStyle, QName objectClass, boolean expectReaction) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -4853,7 +4743,6 @@ public void testLiveSyncDeleteCorsairs(final String TEST_NAME, DummySyncStyle sy } public void testLiveSyncDeleteDrake(final String TEST_NAME, DummySyncStyle syncStyle, QName objectClass) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -4914,7 +4803,6 @@ public void testLiveSyncDeleteDrake(final String TEST_NAME, DummySyncStyle syncS @Test public void test890LiveSyncModifyProtectedAccount() throws Exception { final String TEST_NAME = "test890LiveSyncModifyProtectedAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task syncTask = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); OperationResult result = syncTask.getResult(); @@ -4949,7 +4837,6 @@ public void test890LiveSyncModifyProtectedAccount() throws Exception { @Test public void test901FailResourceNotFound() throws Exception { final String TEST_NAME = "test901FailResourceNotFound"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyCaching.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyCaching.java index 848441a51e8..87583fa50ed 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyCaching.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyCaching.java @@ -95,7 +95,6 @@ protected ItemComparisonResult getExpectedPasswordComparisonResultMismatch() { @Override public void test107AGetModifiedAccountFromCacheMax() throws Exception { final String TEST_NAME = "test107AGetModifiedAccountFromCacheMax"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); @@ -163,7 +162,6 @@ public void test107AGetModifiedAccountFromCacheMax() throws Exception { @Override public void test107BGetModifiedAccountFromCacheHighStaleness() throws Exception { final String TEST_NAME = "test107BGetModifiedAccountFromCacheHighStaleness"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); @@ -225,7 +223,6 @@ public void test107BGetModifiedAccountFromCacheHighStaleness() throws Exception @Test public void test107CSkipCachingForIncompleteAttributes() throws Exception { final String TEST_NAME = "test107CSkipCachingForIncompleteAttributes"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); @@ -298,7 +295,6 @@ public void test107CSkipCachingForIncompleteAttributes() throws Exception { @Override public void test119SearchAllAccountsMaxStaleness() throws Exception { final String TEST_NAME = "test119SearchAllAccountsMaxStaleness"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyConsistency.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyConsistency.java index 46e611bbc47..4564b94b458 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyConsistency.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyConsistency.java @@ -106,7 +106,6 @@ protected File getResourceDummyFile() { @Test public void test000Integrity() throws Exception { final String TEST_NAME = "test000Integrity"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -129,7 +128,6 @@ public void test000Integrity() throws Exception { @Test public void test050AddAccountWill() throws Exception { final String TEST_NAME = "test050AddAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -185,7 +183,6 @@ public void test050AddAccountWill() throws Exception { @Test public void test100AddAccountMorganCommunicationFailure() throws Exception { final String TEST_NAME = "test100AddAccountMorganCommunicationFailure"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -227,7 +224,6 @@ public void test100AddAccountMorganCommunicationFailure() throws Exception { @Test public void test102GetAccountMorganRecovery() throws Exception { final String TEST_NAME = "test102GetAccountMorganRecovery"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -255,7 +251,6 @@ public void test102GetAccountMorganRecovery() throws Exception { @Test public void test104RefreshAccountMorganCommunicationFailure() throws Exception { final String TEST_NAME = "test104RefreshAccountMorganCommunicationFailure"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -287,7 +282,6 @@ public void test104RefreshAccountMorganCommunicationFailure() throws Exception { @Test public void test105GetForceRefreshAccountMorganCommunicationFailure() throws Exception { final String TEST_NAME = "test105GetForceRefreshAccountMorganCommunicationFailure"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -327,7 +321,6 @@ public void test105GetForceRefreshAccountMorganCommunicationFailure() throws Exc @Test public void test106RefreshAccountMorganCommunicationFailureRetry() throws Exception { final String TEST_NAME = "test106RefreshAccountMorganCommunicationFailureRetry"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -367,7 +360,6 @@ public void test106RefreshAccountMorganCommunicationFailureRetry() throws Except @Test public void test108RefreshAccountMorganCommunicationFailureRetryAgain() throws Exception { final String TEST_NAME = "test108RefreshAccountMorganCommunicationFailureRetryAgain"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -493,7 +485,6 @@ private void assertMorganDead() throws Exception { @Test public void test109RefreshAccountMorganDead() throws Exception { final String TEST_NAME = "test109RefreshAccountMorganDead"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -525,7 +516,6 @@ public void test109RefreshAccountMorganDead() throws Exception { @Test public void test110AddAccountMorganAgainCommunicationFailure() throws Exception { final String TEST_NAME = "test110AddAccountMorganAgainCommunicationFailure"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -566,7 +556,6 @@ public void test110AddAccountMorganAgainCommunicationFailure() throws Exception @Test public void test114RefreshAccountMorganCommunicationFailure() throws Exception { final String TEST_NAME = "test114RefreshAccountMorganCommunicationFailure"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -600,7 +589,6 @@ public void test114RefreshAccountMorganCommunicationFailure() throws Exception { @Test public void test116RefreshAccountMorganRetrySuccess() throws Exception { final String TEST_NAME = "test116RefreshAccountMorganRetrySuccess"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -636,7 +624,6 @@ public void test116RefreshAccountMorganRetrySuccess() throws Exception { @Test public void test120ModifyMorganFullNameCommunicationFailure() throws Exception { final String TEST_NAME = "test120ModifyMorganFullNameCommunicationFailure"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -674,7 +661,6 @@ public void test120ModifyMorganFullNameCommunicationFailure() throws Exception { @Test public void test124RefreshAccountMorganCommunicationFailure() throws Exception { final String TEST_NAME = "test124RefreshAccountMorganCommunicationFailure"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -706,7 +692,6 @@ public void test124RefreshAccountMorganCommunicationFailure() throws Exception { @Test public void test126RefreshAccountMorganCommunicationFailureRetry() throws Exception { final String TEST_NAME = "test126RefreshAccountMorganCommunicationFailureRetry"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -746,7 +731,6 @@ public void test126RefreshAccountMorganCommunicationFailureRetry() throws Except @Test public void test128RefreshAccountMorganCommunicationFailureRetryAgain() throws Exception { final String TEST_NAME = "test128RefreshAccountMorganCommunicationFailureRetryAgain"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -783,7 +767,6 @@ public void test128RefreshAccountMorganCommunicationFailureRetryAgain() throws E @Test public void test129RefreshAccountMorganFailed() throws Exception { final String TEST_NAME = "test129RefreshAccountMorganFailed"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -812,7 +795,6 @@ public void test129RefreshAccountMorganFailed() throws Exception { @Test public void test130ModifyMorganFullNameAgainCommunicationFailure() throws Exception { final String TEST_NAME = "test130ModifyMorganFullNameAgainCommunicationFailure"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -851,7 +833,6 @@ public void test130ModifyMorganFullNameAgainCommunicationFailure() throws Except @Test public void test132GetAccountMorganCommunicationFailure() throws Exception { final String TEST_NAME = "test132GetAccountMorganCommunicationFailure"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -887,7 +868,6 @@ public void test132GetAccountMorganCommunicationFailure() throws Exception { @Test(enabled=false) // MID-4796 public void test133GetAccountMorganStalenessZeroCommunicationFailure() throws Exception { final String TEST_NAME = "test133GetAccountMorganStalenessZeroCommunicationFailure"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -929,7 +909,6 @@ public void test133GetAccountMorganStalenessZeroCommunicationFailure() throws Ex @Test public void test134GetAccountMorganForceRefreshRetryCommunicationFailure() throws Exception { final String TEST_NAME = "test134GetAccountMorganForceRefreshRetryCommunicationFailure"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -964,7 +943,6 @@ public void test134GetAccountMorganForceRefreshRetryCommunicationFailure() throw @Test public void test136RefreshAccountMorganRetrySuccess() throws Exception { final String TEST_NAME = "test136RefreshAccountMorganRetrySuccess"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1000,7 +978,6 @@ public void test136RefreshAccountMorganRetrySuccess() throws Exception { @Test public void test170DeleteMorganCommunicationFailure() throws Exception { final String TEST_NAME = "test170DeleteMorganCommunicationFailure"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1037,7 +1014,6 @@ public void test170DeleteMorganCommunicationFailure() throws Exception { @Test public void test174RefreshAccountMorganCommunicationFailure() throws Exception { final String TEST_NAME = "test174RefreshAccountMorganCommunicationFailure"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1069,7 +1045,6 @@ public void test174RefreshAccountMorganCommunicationFailure() throws Exception { @Test public void test176RefreshAccountMorganCommunicationFailureRetry() throws Exception { final String TEST_NAME = "test176RefreshAccountMorganCommunicationFailureRetry"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1109,7 +1084,6 @@ public void test176RefreshAccountMorganCommunicationFailureRetry() throws Except @Test public void test178RefreshAccountMorganCommunicationFailureRetryAgain() throws Exception { final String TEST_NAME = "test178RefreshAccountMorganCommunicationFailureRetryAgain"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1145,7 +1119,6 @@ public void test178RefreshAccountMorganCommunicationFailureRetryAgain() throws E @Test public void test179RefreshAccountMorganFailed() throws Exception { final String TEST_NAME = "test179RefreshAccountMorganFailed"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1174,7 +1147,6 @@ public void test179RefreshAccountMorganFailed() throws Exception { @Test public void test180DeleteMorganCommunicationFailureAgain() throws Exception { final String TEST_NAME = "test180DeleteMorganCommunicationFailureAgain"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1212,7 +1184,6 @@ public void test180DeleteMorganCommunicationFailureAgain() throws Exception { @Test public void test186RefreshAccountMorganRetrySuccess() throws Exception { final String TEST_NAME = "test186RefreshAccountMorganRetrySuccess"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1255,7 +1226,6 @@ public void test186RefreshAccountMorganRetrySuccess() throws Exception { @Test public void test190AccountMorganDeadExpireOperation() throws Exception { final String TEST_NAME = "test190AccountMorganDeadExpireOperation"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1340,7 +1310,6 @@ public void test190AccountMorganDeadExpireOperation() throws Exception { @Test public void test192AccountMorganSecondDeadExpireOperation() throws Exception { final String TEST_NAME = "test192AccountMorganSecondDeadExpireOperation"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1408,7 +1377,6 @@ public void test192AccountMorganSecondDeadExpireOperation() throws Exception { @Test public void test194AccountMorganDeadExpireShadow() throws Exception { final String TEST_NAME = "test194AccountMorganDeadExpireShadow"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1445,7 +1413,6 @@ public void test194AccountMorganDeadExpireShadow() throws Exception { @Test public void test196AccountMorganSecondDeadExpireShadow() throws Exception { final String TEST_NAME = "test196AccountMorganSecondDeadExpireShadow"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1483,7 +1450,6 @@ public void test196AccountMorganSecondDeadExpireShadow() throws Exception { @Test public void test800AddAccountMorganAlreadyExists() throws Exception { final String TEST_NAME = "test800AddAccountMorganAlreadyExists"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1563,7 +1529,6 @@ public void test800AddAccountMorganAlreadyExists() throws Exception { @Test public void test802AddAccountMorganAlreadyExistsAgain() throws Exception { final String TEST_NAME = "test802AddAccountMorganAlreadyExistsAgain"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1648,7 +1613,6 @@ public void test802AddAccountMorganAlreadyExistsAgain() throws Exception { @Test public void test804AddAccountElizabeth() throws Exception { final String TEST_NAME = "test804AddAccountElizabeth"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1682,7 +1646,6 @@ public void test804AddAccountElizabeth() throws Exception { @Test public void test806RenameAccountElizabethAlreadyExists() throws Exception { final String TEST_NAME = "test806RenameAccountElizabethAlreadyExists"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1762,7 +1725,6 @@ public void test806RenameAccountElizabethAlreadyExists() throws Exception { @Test public void test808RenameAccountElizabethAlreadyExistsAgain() throws Exception { final String TEST_NAME = "test808RenameAccountElizabethAlreadyExistsAgain"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1855,7 +1817,6 @@ public void test808RenameAccountElizabethAlreadyExistsAgain() throws Exception { @Test public void test810GetAccountMorganNotFound() throws Exception { final String TEST_NAME = "test810GetAccountMorganNotFound"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1922,7 +1883,6 @@ public void test810GetAccountMorganNotFound() throws Exception { @Test public void test812ModifyAccountWillNotFound() throws Exception { final String TEST_NAME = "test812ModifyAccountWillNotFound"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1995,7 +1955,6 @@ public void test812ModifyAccountWillNotFound() throws Exception { @Test public void test814DeleteAccountElizabethNotFound() throws Exception { final String TEST_NAME = "test814DeleteAccountElizabethNotFound"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2059,7 +2018,6 @@ public void test814DeleteAccountElizabethNotFound() throws Exception { @Test public void test816AddAccountElizabethAfterDeathAlreadyExists() throws Exception { final String TEST_NAME = "test816AddAccountElizabethAfterDeathAlreadyExists"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2127,7 +2085,6 @@ public void test816AddAccountElizabethAfterDeathAlreadyExists() throws Exception @Test public void test900GetAccountMurrayPending() throws Exception { final String TEST_NAME = "test900GetAccountMurrayPending"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); 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 8687d52dde9..ec5d3d621aa 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 @@ -105,7 +105,6 @@ protected void assertNativeCredentialsCapability(CredentialsCapabilityType capCr @Test public void test400AddAccountElizabeth() throws Exception { final String TEST_NAME = "test400AddAccountElizabeth"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -246,7 +245,6 @@ public void test419DisassociateCrewWillElizabeth() throws Exception { @Test public void test499DeleteAccountElizabeth() throws Exception { final String TEST_NAME = "test499DeleteAccountElizabeth"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyNegative.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyNegative.java index 690b8116fc3..45b97196d82 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyNegative.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyNegative.java @@ -106,7 +106,6 @@ public void testGetResourceBrokenSchema(BreakMode breakMode, String testName) th @Test public void test190GetResource() throws Exception { final String TEST_NAME = "test190GetResource"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -128,7 +127,6 @@ public void test190GetResource() throws Exception { @Test public void test200AddAccountNullAttributes() throws Exception { final String TEST_NAME = "test200AddAccountNullAttributes"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -222,7 +220,6 @@ public void test210AddAccountNoObjectclass() throws Exception { @Test public void test220AddAccountNoResourceRef() throws Exception { final String TEST_NAME = "test220AddAccountNoResourceRef"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummyNegative.class.getName() + "." + TEST_NAME); @@ -254,7 +251,6 @@ public void test220AddAccountNoResourceRef() throws Exception { @Test public void test221DeleteAccountResourceNotFound() throws Exception { final String TEST_NAME = "test221DeleteAccountResourceNotFound"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummyNegative.class.getName() + "." + TEST_NAME); @@ -291,7 +287,6 @@ public void test221DeleteAccountResourceNotFound() throws Exception { @Test public void test230GetAccountDeletedShadow() throws Exception { final String TEST_NAME = "test230GetAccountDeletedShadow"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummyNegative.class.getName() + "." + TEST_NAME); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyParallelism.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyParallelism.java index 2c1a959a5eb..ed5cff814e2 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyParallelism.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyParallelism.java @@ -142,7 +142,6 @@ protected void assertWillRepoShadowAfterCreate(PrismObject repoShado @Test public void test120ModifyWillReplaceFullname() throws Exception { final String TEST_NAME = "test120ModifyWillReplaceFullname"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -182,7 +181,6 @@ public void test120ModifyWillReplaceFullname() throws Exception { @Test public void test190DeleteWill() throws Exception { final String TEST_NAME = "test190DeleteWill"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -222,7 +220,6 @@ public void test190DeleteWill() throws Exception { @Test public void test200ParallelCreate() throws Exception { final String TEST_NAME = "test200ParallelCreate"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -316,7 +313,6 @@ public void test204ParallelModifyDisable() throws Exception { } private PrismObject parallelModifyTest(final String TEST_NAME, FailableProducer> deltaProducer) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -378,7 +374,6 @@ private PrismObject parallelModifyTest(final String TEST_NAME, Faila @Test public void test209ParallelDelete() throws Exception { final String TEST_NAME = "test209ParallelDelete"; - displayTestTitle(TEST_NAME); // GIVEN final Counter successCounter = new Counter(); @@ -437,7 +432,6 @@ public void test209ParallelDelete() throws Exception { @Test public void test210ParallelCreateSlow() throws Exception { final String TEST_NAME = "test210ParallelCreateSlow"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -526,7 +520,6 @@ public void test214ParallelModifyDisableSlow() throws Exception { } private PrismObject parallelModifyTestSlow(final String TEST_NAME, FailableProducer> deltaProducer) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -589,7 +582,6 @@ private PrismObject parallelModifyTestSlow(final String TEST_NAME, F @Test public void test229ParallelDeleteSlow() throws Exception { final String TEST_NAME = "test229ParallelDeleteSlow"; - displayTestTitle(TEST_NAME); // GIVEN final Counter successCounter = new Counter(); @@ -659,7 +651,6 @@ public void test229ParallelDeleteSlow() throws Exception { @Test public void test230ParallelGroupSearch() throws Exception { final String TEST_NAME = "test230ParallelGroupSearch"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -751,7 +742,6 @@ private ObjectQuery createGroupNameQuery(String groupName) throws SchemaExceptio @Test public void test800ParallelReadAndModifyResource() throws Exception { final String TEST_NAME = "test800ParallelReadAndModifyResource"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyResourceAndSchemaCaching.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyResourceAndSchemaCaching.java index ef4e9859bfc..07b94dd1038 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyResourceAndSchemaCaching.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyResourceAndSchemaCaching.java @@ -30,6 +30,7 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.ResourceTypeUtil; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DOMUtil; @@ -63,7 +64,6 @@ public class TestDummyResourceAndSchemaCaching extends AbstractDummyTest { @Test public void test010GetResource() throws Exception { final String TEST_NAME = "test010GetResource"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummyResourceAndSchemaCaching.class.getName() + "." + TEST_NAME); @@ -133,7 +133,6 @@ public void test010GetResource() throws Exception { @Test public void test011GetResourceAgain() throws Exception { final String TEST_NAME = "test011GetResourceAgain"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummyResourceAndSchemaCaching.class.getName() + "." + TEST_NAME); @@ -204,7 +203,6 @@ public void test011GetResourceAgain() throws Exception { @Test public void test012AddAccountGetResource() throws Exception { final String TEST_NAME = "test012AddAccountGetResource"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummyResourceAndSchemaCaching.class.getName() + "." + TEST_NAME); @@ -247,7 +245,6 @@ public void test012AddAccountGetResource() throws Exception { @Test public void test013GetResourceNoFetch() throws Exception { final String TEST_NAME = "test013GetResourceNoFetch"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummyResourceAndSchemaCaching.class.getName() + "." + TEST_NAME); @@ -321,7 +318,6 @@ public void test013GetResourceNoFetch() throws Exception { @Test public void test020ModifyAndGetResource() throws Exception { final String TEST_NAME = "test020ModifyAndGetResource"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummyResourceAndSchemaCaching.class.getName() + "." + TEST_NAME); @@ -383,7 +379,6 @@ public void test020ModifyAndGetResource() throws Exception { @Test public void test022GetAccountGetResource() throws Exception { final String TEST_NAME = "test012AddAccountGetResource"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummyResourceAndSchemaCaching.class.getName() + "." + TEST_NAME); @@ -434,7 +429,6 @@ public void test022GetAccountGetResource() throws Exception { @Test public void test023ModifyRepoAndGetResource() throws Exception { final String TEST_NAME = "test023ModifyRepoAndGetResource"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummyResourceAndSchemaCaching.class.getName() + "." + TEST_NAME); @@ -496,7 +490,6 @@ public void test023ModifyRepoAndGetResource() throws Exception { @Test public void test030ModifyConnectorConfigAndGetResource() throws Exception { final String TEST_NAME = "test030ModifyConnectorConfigAndGetResource"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummyResourceAndSchemaCaching.class.getName() + "." + TEST_NAME); @@ -527,7 +520,6 @@ public void test030ModifyConnectorConfigAndGetResource() throws Exception { @Test public void test031ModifyConnectorConfigRepoAndGetResource() throws Exception { final String TEST_NAME = "test031ModifyConnectorConfigRepoAndGetResource"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummyResourceAndSchemaCaching.class.getName() + "." + TEST_NAME); @@ -552,7 +544,6 @@ public void test031ModifyConnectorConfigRepoAndGetResource() throws Exception { @Test public void test900DeleteResource() throws Exception { final String TEST_NAME = "test900DeleteResource"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummyResourceAndSchemaCaching.class.getName() + "." + TEST_NAME); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySchemaless.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySchemaless.java index c4e9c1733c6..df5c9e827b5 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySchemaless.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySchemaless.java @@ -266,7 +266,6 @@ public void test020ResourceStaticSchemaTest() throws Exception { } public void resourceStaticSchemaTest(final String TEST_NAME, int expectedConnectorInitCount) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -356,7 +355,6 @@ public void test030ResourceStatciSchemaResourceAndConnectorCaching() throws Exce } public void resourceStatciSchemaResourceAndConnectorCaching(final String TEST_NAME) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestOpenDj.class.getName() + "." + TEST_NAME); @@ -455,7 +453,6 @@ public void resourceStatciSchemaResourceAndConnectorCaching(final String TEST_NA @Test public void test040ReAddResourceStaticSchema() throws Exception { final String TEST_NAME = "test040ReAddResourceStaticSchema"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -698,7 +695,6 @@ private void assertStaticSchemaSanity(ResourceSchema resorceSchema) { @Test public void test107Capabilities() throws Exception { final String TEST_NAME = "test107Capabilities"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/manual/AbstractManualResourceTest.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/manual/AbstractManualResourceTest.java index ed66a1e6687..dbd3cb1f121 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/manual/AbstractManualResourceTest.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/manual/AbstractManualResourceTest.java @@ -354,7 +354,6 @@ public void test006Capabilities() throws Exception { @Test public void test100AddAccountWill() throws Exception { final String TEST_NAME = "test100AddAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -427,7 +426,6 @@ public void test100AddAccountWill() throws Exception { @Test public void test102GetAccountWillFuture() throws Exception { final String TEST_NAME = "test102GetAccountWillFuture"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -462,7 +460,6 @@ public void test102GetAccountWillFuture() throws Exception { @Test public void test104RefreshAccountWill() throws Exception { final String TEST_NAME = "test104RefreshAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -517,7 +514,6 @@ protected void backingStoreAddWill() throws IOException { @Test public void test106AddToBackingStoreAndGetAccountWill() throws Exception { final String TEST_NAME = "test106AddToBackingStoreAndGetAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -559,7 +555,6 @@ public void test106AddToBackingStoreAndGetAccountWill() throws Exception { @Test public void test108GetAccountWillFuture() throws Exception { final String TEST_NAME = "test108GetAccountWillFuture"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -603,7 +598,6 @@ public void test108GetAccountWillFuture() throws Exception { @Test public void test109GetAccountWillFutureNoFetch() throws Exception { final String TEST_NAME = "test109GetAccountWillFutureNoFetch"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -645,7 +639,6 @@ public void test109GetAccountWillFutureNoFetch() throws Exception { @Test public void test110CloseCaseAndRefreshAccountWill() throws Exception { final String TEST_NAME = "test110CloseCaseAndRefreshAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -708,7 +701,6 @@ public void test110CloseCaseAndRefreshAccountWill() throws Exception { @Test public void test120RefreshAccountWillAfter5min() throws Exception { final String TEST_NAME = "test120RefreshAccountWillAfter5min"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -761,7 +753,6 @@ public void test120RefreshAccountWillAfter5min() throws Exception { @Test public void test130RefreshAccountWillAfter16min() throws Exception { final String TEST_NAME = "test130RefreshAccountWillAfter16min"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -814,7 +805,6 @@ public void test130RefreshAccountWillAfter16min() throws Exception { @Test public void test132RefreshAccountWillAfter27min() throws Exception { final String TEST_NAME = "test132RefreshAccountWillAfter27min"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -854,7 +844,6 @@ public void test132RefreshAccountWillAfter27min() throws Exception { @Test public void test200ModifyAccountWillFullname() throws Exception { final String TEST_NAME = "test200ModifyAccountWillFullname"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -937,7 +926,6 @@ public void test200ModifyAccountWillFullname() throws Exception { @Test public void test202RefreshAccountWill() throws Exception { final String TEST_NAME = "test202RefreshAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1018,7 +1006,6 @@ public void test202RefreshAccountWill() throws Exception { @Test public void test204CloseCaseAndRefreshAccountWill() throws Exception { final String TEST_NAME = "test204CloseCaseAndRefreshAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1112,7 +1099,6 @@ public void test204CloseCaseAndRefreshAccountWill() throws Exception { @Test public void test210RefreshAccountWillAfter5min() throws Exception { final String TEST_NAME = "test210RefreshAccountWillAfter5min"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1181,7 +1167,6 @@ protected void backingStoreUpdateWill(String newFullName, ActivationStatusType n @Test public void test212UpdateBackingStoreAndGetAccountWill() throws Exception { final String TEST_NAME = "test212UpdateBackingStoreAndGetAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1246,7 +1231,6 @@ public void test212UpdateBackingStoreAndGetAccountWill() throws Exception { @Test public void test220ModifyAccountWillDisable() throws Exception { final String TEST_NAME = "test220ModifyAccountWillDisable"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1330,7 +1314,6 @@ public void test220ModifyAccountWillDisable() throws Exception { @Test public void test230ModifyAccountWillChangePasswordAndEnable() throws Exception { final String TEST_NAME = "test230ModifyAccountWillChangePasswordAndEnable"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1421,7 +1404,6 @@ public void test230ModifyAccountWillChangePasswordAndEnable() throws Exception { @Test public void test240CloseDisableCaseAndReadAccountWill() throws Exception { final String TEST_NAME = "test240CloseDisableCaseAndReadAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1533,7 +1515,6 @@ public void test240CloseDisableCaseAndReadAccountWill() throws Exception { @Test public void test250RefreshAccountWillAfter5min() throws Exception { final String TEST_NAME = "test250RefreshAccountWillAfter5min"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1621,7 +1602,6 @@ public void test250RefreshAccountWillAfter5min() throws Exception { @Test public void test252UpdateBackingStoreAndGetAccountWill() throws Exception { final String TEST_NAME = "test252UpdateBackingStoreAndGetAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1687,7 +1667,6 @@ public void test252UpdateBackingStoreAndGetAccountWill() throws Exception { @Test public void test260ClosePasswordChangeCaseAndRefreshAccountWill() throws Exception { final String TEST_NAME = "test260ClosePasswordChangeCaseAndRefreshAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1787,7 +1766,6 @@ public void test260ClosePasswordChangeCaseAndRefreshAccountWill() throws Excepti @Test public void test270RefreshAccountWillAfter7min() throws Exception { final String TEST_NAME = "test270RefreshAccountWillAfter7min"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1886,7 +1864,6 @@ public void test270RefreshAccountWillAfter7min() throws Exception { @Test public void test271RefreshAccountWillAfter12min() throws Exception { final String TEST_NAME = "test271RefreshAccountWillAfter12min"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1982,7 +1959,6 @@ public void test271RefreshAccountWillAfter12min() throws Exception { @Test public void test272UpdateBackingStoreAndGetAccountWill() throws Exception { final String TEST_NAME = "test272UpdateBackingStoreAndGetAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2047,7 +2023,6 @@ public void test272UpdateBackingStoreAndGetAccountWill() throws Exception { @Test public void test280RefreshAccountWillAfter5min() throws Exception { final String TEST_NAME = "test132RefreshAccountWillAfter10min"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2136,7 +2111,6 @@ public void test280RefreshAccountWillAfter5min() throws Exception { @Test public void test290RefreshAccountWillAfter5min() throws Exception { final String TEST_NAME = "test134RefreshAccountWillAfter5min"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2202,7 +2176,6 @@ public void test290RefreshAccountWillAfter5min() throws Exception { @Test public void test300DeleteAccountWill() throws Exception { final String TEST_NAME = "test300DeleteAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2272,7 +2245,6 @@ public void test300DeleteAccountWill() throws Exception { @Test public void test302GetAccountWillFuture() throws Exception { final String TEST_NAME = "test302GetAccountWillFuture"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2298,7 +2270,6 @@ public void test302GetAccountWillFuture() throws Exception { @Test public void test303GetAccountWillFutureNoFetch() throws Exception { final String TEST_NAME = "test303GetAccountWillFutureNoFetch"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2331,7 +2302,6 @@ public void test303GetAccountWillFutureNoFetch() throws Exception { @Test public void test310CloseCaseAndRefreshAccountWill() throws Exception { final String TEST_NAME = "test310CloseCaseAndRefreshAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2398,7 +2368,6 @@ public void test310CloseCaseAndRefreshAccountWill() throws Exception { @Test public void test320RefreshAccountWillAfter5min() throws Exception { final String TEST_NAME = "test320RefreshAccountWillAfter5min"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDj.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDj.java index 24bf857d3e4..b99ed112e95 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDj.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDj.java @@ -35,6 +35,7 @@ import com.evolveum.midpoint.prism.query.*; import com.evolveum.midpoint.schema.processor.*; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import org.apache.commons.lang.StringUtils; import org.opends.server.types.Entry; @@ -205,7 +206,6 @@ public static void stopLdap() throws Exception { @Test public void test003Connection() throws Exception { final String TEST_NAME = "test003Connection"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -262,7 +262,6 @@ public void test003Connection() throws Exception { @Test public void test004ResourceAndConnectorCaching() throws Exception { final String TEST_NAME = "test004ResourceAndConnectorCaching"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -306,7 +305,6 @@ public void test004ResourceAndConnectorCaching() throws Exception { @Test public void test005Capabilities() throws Exception { final String TEST_NAME = "test005Capabilities"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -382,7 +380,6 @@ protected void assertPasswordCapability(PasswordCapabilityType capPassword) { @Test public void test006Schema() throws Exception { final String TEST_NAME = "test006RefinedSchema"; - displayTestTitle(TEST_NAME); // GIVEN // WHEN @@ -569,7 +566,6 @@ protected void assertPolyStringType(String attrName, ResourceAttributeDefinition @Test public void test007RefinedSchema() throws Exception { final String TEST_NAME = "test007RefinedSchema"; - displayTestTitle(TEST_NAME); // GIVEN // WHEN @@ -686,7 +682,6 @@ public void test007RefinedSchema() throws Exception { @Test public void test020ListResourceObjects() throws Exception { final String TEST_NAME = "test020ListResourceObjects"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -707,7 +702,6 @@ public void test020ListResourceObjects() throws Exception { @Test public void test110GetObject() throws Exception { final String TEST_NAME = "test110GetObject"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -799,7 +793,6 @@ protected void assertShadowPassword(ShadowType provisioningShadow) throws Except @Test public void test111GetObjectNotFoundRepo() throws Exception { final String TEST_NAME = "test111GetObjectNotFoundRepo"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -834,7 +827,6 @@ public void test111GetObjectNotFoundRepo() throws Exception { @Test public void test112GetObjectNotFoundResource() throws Exception { final String TEST_NAME = "test112GetObjectNotFoundResource"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -853,7 +845,6 @@ public void test112GetObjectNotFoundResource() throws Exception { @Test public void test119Cleanup() throws Exception { final String TEST_NAME = "test119Cleanup"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -867,7 +858,6 @@ public void test119Cleanup() throws Exception { @Test public void test120AddAccountWill() throws Exception { final String TEST_NAME = "test120AddAccountWill"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -900,7 +890,6 @@ public void test120AddAccountWill() throws Exception { @Test public void test121RenameAccountWillOnResource() throws Exception{ String TEST_NAME = "test121RenameAccountWillOnResource"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -929,7 +918,6 @@ public void test121RenameAccountWillOnResource() throws Exception{ @Test public void test125AddObjectNull() throws Exception { final String TEST_NAME = "test125AddObjectNull"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -952,7 +940,6 @@ public void test125AddObjectNull() throws Exception { @Test public void test130AddDeleteAccountSparrow() throws Exception { final String TEST_NAME = "test130AddDeleteAccountSparrow"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -997,7 +984,6 @@ public void test130AddDeleteAccountSparrow() throws Exception { @Test public void test140AddAndModifyAccountJack() throws Exception { final String TEST_NAME = "test140AddAndModifyAccountJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1069,7 +1055,6 @@ public void test140AddAndModifyAccountJack() throws Exception { @Test public void test145ModifyAccountJackJpegPhoto() throws Exception { final String TEST_NAME = "test145ModifyAccountJackJpegPhoto"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1126,7 +1111,6 @@ public void test145ModifyAccountJackJpegPhoto() throws Exception { @Test public void test147ModifyAccountJackGivenNameDuplicit() throws Exception { final String TEST_NAME = "test147ModifyAccountJackGivenNameDuplicit"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1178,7 +1162,6 @@ public void test147ModifyAccountJackGivenNameDuplicit() throws Exception { @Test public void test150ChangePassword() throws Exception { final String TEST_NAME = "test150ChangePassword"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1233,7 +1216,6 @@ public void test150ChangePassword() throws Exception { @Test public void test151AddObjectWithPassword() throws Exception { final String TEST_NAME = "test151AddObjectWithPassword"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1281,7 +1263,6 @@ public void test151AddObjectWithPassword() throws Exception { @Test public void test160SearchAccountsIterative() throws Exception { final String TEST_NAME = "test160SearchAccountsIterative"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1346,7 +1327,6 @@ public boolean handle(PrismObject prismObject, OperationResult paren @Test public void test161SearchAccountsIterativeOffset2Page3() throws Exception { final String TEST_NAME = "test161SearchAccountsIterativeOffset2Page3"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1394,7 +1374,6 @@ public boolean handle(PrismObject prismObject, OperationResult paren @Test public void test162SearchAccountsIterativeOffsetNullPage5() throws Exception { final String TEST_NAME = "test162SearchAccountsIterativeOffsetNullPage5"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1455,7 +1434,6 @@ protected void assertShadows(int expectedCount) throws SchemaException { @Test public void test170DisableAccount() throws Exception{ final String TEST_NAME = "test170DisableAccount"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1514,7 +1492,6 @@ public void test170DisableAccount() throws Exception{ @Test public void test175AddDisabledAccount() throws Exception { final String TEST_NAME = "test175AddDisabledAccount"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1565,7 +1542,6 @@ public void test175AddDisabledAccount() throws Exception { @Test public void test176AddEnabledAccount() throws Exception { final String TEST_NAME = "test176AddEnabledAccount"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1602,7 +1578,6 @@ public void test176AddEnabledAccount() throws Exception { @Test public void test180GetUnlockedAccount() throws Exception { final String TEST_NAME = "test180GetUnlockedAccount"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1622,7 +1597,6 @@ public void test180GetUnlockedAccount() throws Exception { @Test public void test182GetLockedAccount() throws Exception { final String TEST_NAME = "test182GetLockedAccount"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1649,7 +1623,6 @@ public void test182GetLockedAccount() throws Exception { @Test public void test184UnlockAccount() throws Exception{ final String TEST_NAME = "test184UnlockAccount"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1689,7 +1662,6 @@ public void test184UnlockAccount() throws Exception{ @Test public void test200SearchObjectsIterative() throws Exception { final String TEST_NAME = "test200SearchObjectsIterative"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1732,7 +1704,6 @@ public boolean handle(PrismObject object, OperationResult parentResu @Test public void test201SearchObjects() throws Exception { final String TEST_NAME = "test201SearchObjects"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1769,7 +1740,6 @@ public void test201SearchObjects() throws Exception { @Test public void test202SearchObjectsCompexFilter() throws Exception { final String TEST_NAME = "test202SearchObjectsCompexFilter"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1805,7 +1775,6 @@ public void test202SearchObjectsCompexFilter() throws Exception { @Test public void test203SearchObjectsByDnExists() throws Exception { final String TEST_NAME = "test203SearchObjectsByDnExists"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1846,7 +1815,6 @@ public void test203SearchObjectsByDnExists() throws Exception { @Test public void test205SearchObjectsByDnNotExists() throws Exception { final String TEST_NAME = "test205SearchObjectsByDnNotExists"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1883,7 +1851,6 @@ public void test205SearchObjectsByDnNotExists() throws Exception { @Test public void test206SearchObjectsCompexFilterStartsWith() throws Exception { final String TEST_NAME = "test206SearchObjectsCompexFilterStartsWith"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1919,7 +1886,6 @@ public void test206SearchObjectsCompexFilterStartsWith() throws Exception { @Test public void test230SearchObjectsPagedNoOffset() throws Exception { final String TEST_NAME = "test230SearchObjectsPagedNoOffset"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1955,7 +1921,6 @@ public void test230SearchObjectsPagedNoOffset() throws Exception { @Test public void test231SearchObjectsPagedOffsetZero() throws Exception { final String TEST_NAME = "test231SearchObjectsPagedOffsetZero"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1991,7 +1956,6 @@ public void test231SearchObjectsPagedOffsetZero() throws Exception { @Test public void test232SearchObjectsPagedOffset() throws Exception { final String TEST_NAME = "test232SearchObjectsPagedOffset"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2028,7 +1992,6 @@ public void test232SearchObjectsPagedOffset() throws Exception { @Test public void test233SearchObjectsPagedNoOffsetSortSn() throws Exception { final String TEST_NAME = "test233SearchObjectsPagedNoOffsetSortSn"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2067,7 +2030,6 @@ public void test233SearchObjectsPagedNoOffsetSortSn() throws Exception { @Test public void test234SearchObjectsPagedOffsetSortSn() throws Exception { final String TEST_NAME = "test234SearchObjectsPagedOffsetSortSn"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2120,7 +2082,6 @@ private void assertSearchResults(List> searchResults, St @Test public void test250CountAccounts() throws Exception { final String TEST_NAME = "test250CountAccounts"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2147,7 +2108,6 @@ public void test250CountAccounts() throws Exception { @Test public void test252CountLdapGroups() throws Exception { final String TEST_NAME = "test252CountLdapGroups"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2178,7 +2138,6 @@ protected Integer getExpectedLdapGroupCountTest25x() { @Test public void test300AddObjectObjectAlreadyExistResource() throws Exception { final String TEST_NAME = "test300AddObjectObjectAlreadyExistResource"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2207,7 +2166,6 @@ public void test300AddObjectObjectAlreadyExistResource() throws Exception { @Test public void test310AddObjectNoSn() throws Exception { final String TEST_NAME = "test310AddObjectNoSn"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2239,7 +2197,6 @@ public void test310AddObjectNoSn() throws Exception { @Test public void test320AddAccountPosix() throws Exception { final String TEST_NAME = "test320AddAccountPosix"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2290,7 +2247,6 @@ public void test320AddAccountPosix() throws Exception { @Test public void test322ModifyAccountPosix() throws Exception { final String TEST_NAME = "test322ModifyAccountPosix"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2336,7 +2292,6 @@ public void test322ModifyAccountPosix() throws Exception { @Test public void test329DeleteAccountPosix() throws Exception { final String TEST_NAME = "test329DeleteAccountPosix"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2374,7 +2329,6 @@ public void test329DeleteAccountPosix() throws Exception { @Test public void test330SearchForPosixAccount() throws Exception { final String TEST_NAME = "test330SearchForPosixAccount"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2422,7 +2376,6 @@ public void test330SearchForPosixAccount() throws Exception { @Test public void test400AddGroupSwashbucklers() throws Exception { final String TEST_NAME = "test400AddGroupSwashbucklers"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2464,7 +2417,6 @@ public void test400AddGroupSwashbucklers() throws Exception { @Test public void test402AddAccountMorganWithAssociation() throws Exception { final String TEST_NAME = "test402AddAccountMorganWithAssociation"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2519,7 +2471,6 @@ public void test402AddAccountMorganWithAssociation() throws Exception { @Test public void test403modifyMorganReplaceAssociation() throws Exception { final String TEST_NAME = "test403modifyMorganReplaceAssociation"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2573,7 +2524,6 @@ public void test403modifyMorganReplaceAssociation() throws Exception { @Test public void test405GetGroupSwashbucklers() throws Exception { final String TEST_NAME = "test405GetGroupSwashbucklers"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2606,7 +2556,6 @@ public void test405GetGroupSwashbucklers() throws Exception { @Test public void test410CreateLdapGroupAndSearchGroups() throws Exception { final String TEST_NAME = "test410CreateLdapGroupAndSearchGroups"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2640,7 +2589,6 @@ public void test410CreateLdapGroupAndSearchGroups() throws Exception { @Test public void test412CreateLdapGroupWithMemberAndGet() throws Exception { final String TEST_NAME = "test412CreateLdapGroupWithMemberAndGet"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2678,7 +2626,6 @@ public void test412CreateLdapGroupWithMemberAndGet() throws Exception { @Test public void test414AddGroupCorsairsAssociateUser() throws Exception { final String TEST_NAME = "test414AddGroupCorsairsAssociateUser"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2705,7 +2652,6 @@ public void test414AddGroupCorsairsAssociateUser() throws Exception { @Test public void test416AssociateUserToCorsairs() throws Exception { final String TEST_NAME = "test416AssociateUserToCorsairs"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2734,7 +2680,6 @@ public void test416AssociateUserToCorsairs() throws Exception { @Test public void test418GetMorgan() throws Exception { final String TEST_NAME = "test418GetMorgan"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2762,7 +2707,6 @@ public void test418GetMorgan() throws Exception { @Test public void test429DeleteAccountMorgan() throws Exception { final String TEST_NAME = "test429DeleteAccountMorgan"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2802,7 +2746,6 @@ public void test429DeleteAccountMorgan() throws Exception { @Test public void test450ListGroupsObjectclass() throws Exception { final String TEST_NAME = "test450ListGroupsObjectclass"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2829,7 +2772,6 @@ public void test450ListGroupsObjectclass() throws Exception { @Test public void test452ListLdapGroupsKindIntent() throws Exception { final String TEST_NAME = "test452ListLdapGroupsKindIntent"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2856,7 +2798,6 @@ public void test452ListLdapGroupsKindIntent() throws Exception { @Test public void test454ListSpecialGroupsKindIntent() throws Exception { final String TEST_NAME = "test454ListSpecialGroupsKindIntent"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2885,7 +2826,6 @@ public void test454ListSpecialGroupsKindIntent() throws Exception { @Test public void test456AddGroupSpecialists() throws Exception { final String TEST_NAME = "test456AddGroupSpecialists"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2927,7 +2867,6 @@ public void test456AddGroupSpecialists() throws Exception { @Test public void test457ListLdapGroupsKindIntent() throws Exception { final String TEST_NAME = "test457ListLdapGroupsKindIntent"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2954,7 +2893,6 @@ public void test457ListLdapGroupsKindIntent() throws Exception { @Test public void test458ListSpecialGroupsKindIntent() throws Exception { final String TEST_NAME = "test458ListSpecialGroupsKindIntent"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -2989,7 +2927,6 @@ public void test458ListSpecialGroupsKindIntent() throws Exception { @Test public void test460ListOrganizationalUnitPeopleKindIntent() throws Exception { final String TEST_NAME = "test460ListOrganizationalUnitPeopleKindIntent"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -3021,7 +2958,6 @@ public void test460ListOrganizationalUnitPeopleKindIntent() throws Exception { @Test public void test470AddAccountPolyDescription() throws Exception { final String TEST_NAME = "test470AddAccountPolyDescription"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -3068,7 +3004,6 @@ public void test470AddAccountPolyDescription() throws Exception { @Test public void test472ModifyAccountJackDescriptionOrig() throws Exception { final String TEST_NAME = "test472ModifyAccountJackDescriptionOrig"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -3119,7 +3054,6 @@ public void test472ModifyAccountJackDescriptionOrig() throws Exception { @Test public void test474ModifyAccountJackDescriptionLangEnSk() throws Exception { final String TEST_NAME = "test474ModifyAccountJackDescriptionLangEnSk"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -3172,7 +3106,6 @@ public void test474ModifyAccountJackDescriptionLangEnSk() throws Exception { @Test public void test476ModifyAccountJackDescriptionLangEnSkRuHr() throws Exception { final String TEST_NAME = "test476ModifyAccountJackDescriptionLangEnSkRuHr"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -3225,7 +3158,6 @@ public void test476ModifyAccountJackDescriptionLangEnSkRuHr() throws Exception { @Test public void test478ModifyAccountJackDescriptionLangEnSkRuHr() throws Exception { final String TEST_NAME = "test478ModifyAccountJackDescriptionLangEnSkRuHr"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -3277,7 +3209,6 @@ public void test478ModifyAccountJackDescriptionLangEnSkRuHr() throws Exception { @Test public void test478bModifyAccountJackDeleteDescription() throws Exception { final String TEST_NAME = "test478bModifyAccountJackDeleteDescription"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -3331,7 +3262,6 @@ public void test478bModifyAccountJackDeleteDescription() throws Exception { @Test public void test479ModifyAccountJackDescriptionJack() throws Exception { final String TEST_NAME = "test479ModifyAccountJackDescriptionJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -3378,7 +3308,6 @@ public void test479ModifyAccountJackDescriptionJack() throws Exception { @Test public void test480AddOuSuper() throws Exception { final String TEST_NAME = "test480AddOuSuper"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -3426,7 +3355,6 @@ public void test480AddOuSuper() throws Exception { @Test public void test489DeleteOuSuperWithSub() throws Exception { final String TEST_NAME = "test489DeleteOuSuperWithSub"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -3533,7 +3461,6 @@ public void test704ConfiguredCapabilityNoUpdate() throws Exception{ @Test public void test710AddResourceOpenDjBadCredentials() throws Exception { final String TEST_NAME = "test710AddResourceOpenDjBadCredentials"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -3555,7 +3482,6 @@ public void test710AddResourceOpenDjBadCredentials() throws Exception { @Test public void test713ConnectionBadCredentials() throws Exception { final String TEST_NAME = "test713ConnectionBadCredentials"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -3577,7 +3503,6 @@ public void test713ConnectionBadCredentials() throws Exception { @Test public void test720AddResourceOpenDjBadBindDn() throws Exception { final String TEST_NAME = "test720AddResourceOpenDjBadBindDn"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -3599,7 +3524,6 @@ public void test720AddResourceOpenDjBadBindDn() throws Exception { @Test public void test723ConnectionBadBindDn() throws Exception { final String TEST_NAME = "test723ConnectionBadBindDn"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjDumber.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjDumber.java index 8895a93fd58..2338a60c98c 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjDumber.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjDumber.java @@ -84,7 +84,6 @@ protected void assertTimestamp(String attrName, Object timestampValue) { @Override public void test489DeleteOuSuperWithSub() throws Exception { final String TEST_NAME = "test489DeleteOuSuperWithSub"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjNegative.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjNegative.java index 5ce9c6962e9..d9608a050b8 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjNegative.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjNegative.java @@ -49,6 +49,7 @@ import com.evolveum.midpoint.schema.util.ResourceTypeUtil; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.task.api.TaskManager; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.asserter.ShadowAsserter; import com.evolveum.midpoint.test.util.TestUtil; @@ -106,7 +107,6 @@ public static void stoptLdap() throws Exception { @Test public void test003Connection() throws Exception { final String TEST_NAME = "test003Connection"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -189,7 +189,6 @@ public void test004ResourceAndConnectorCaching() throws Exception { @Test public void test110GetObjectNoShadow() throws Exception { final String TEST_NAME = "test110GetObjectNoShadow"; - displayTestTitle(TEST_NAME); OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME); @@ -216,7 +215,6 @@ public void test110GetObjectNoShadow() throws Exception { @Test public void test111GetObjectShadow() throws Exception { final String TEST_NAME = "test111GetObjectShadow"; - displayTestTitle(TEST_NAME); OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME); @@ -239,7 +237,6 @@ public void test111GetObjectShadow() throws Exception { @Test public void test120ListResourceObjects() throws Exception { final String TEST_NAME = "test120ListResourceObjects"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME); @@ -263,7 +260,6 @@ public void test120ListResourceObjects() throws Exception { public void test121SearchAccounts() throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, Exception { final String TEST_NAME = "test121SearchAccounts"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME); @@ -293,7 +289,6 @@ public void test121SearchAccounts() throws SchemaException, ObjectNotFoundExcept public void test122SearchAccountsIterative() throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, Exception { final String TEST_NAME = "test122SearchAccountsIterative"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME); @@ -329,7 +324,6 @@ public boolean handle(PrismObject prismObject, OperationResult paren @Test public void test130AddAccountWill() throws Exception { final String TEST_NAME = "test130AddAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME); @@ -356,7 +350,6 @@ public void test130AddAccountWill() throws Exception { @Test public void test140AddDeleteAccountSparrow() throws Exception { final String TEST_NAME = "test140AddDeleteAccountSparrow"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME); @@ -379,7 +372,6 @@ public void test140AddDeleteAccountSparrow() throws Exception { @Test public void test150ModifyObject() throws Exception { final String TEST_NAME = "test150ModifyObject"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME); @@ -406,7 +398,6 @@ public void test150ModifyObject() throws Exception { @Test public void test190Synchronize() throws Exception { final String TEST_NAME = "test190Synhronize"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestOpenDjNegative.class.getName() + "." + TEST_NAME); @@ -439,7 +430,6 @@ public void test190Synchronize() throws Exception { @Test public void test500ReplaceResource() throws Exception { final String TEST_NAME = "test500ReplaceResource"; - displayTestTitle(TEST_NAME); OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME); @@ -464,7 +454,6 @@ public void test500ReplaceResource() throws Exception { @Test public void test510GetObjectNoShadow() throws Exception { final String TEST_NAME = "test510GetObjectNoShadow"; - displayTestTitle(TEST_NAME); OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME); @@ -492,7 +481,6 @@ public void test510GetObjectNoShadow() throws Exception { @Test public void test511GetObjectShadow() throws Exception { final String TEST_NAME = "test511GetObjectShadow"; - displayTestTitle(TEST_NAME); OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME); @@ -520,7 +508,6 @@ public void test511GetObjectShadow() throws Exception { @Test public void test520ListResourceObjects() throws Exception { final String TEST_NAME = "test520ListResourceObjects"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME); @@ -543,7 +530,6 @@ public void test520ListResourceObjects() throws Exception { public void test521SearchAccounts() throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, Exception { final String TEST_NAME = "test521SearchAccounts"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME); @@ -572,7 +558,6 @@ public void test521SearchAccounts() throws SchemaException, ObjectNotFoundExcept public void test522SearchAccountsIterative() throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, Exception { final String TEST_NAME = "test522SearchAccountsIterative"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME); @@ -607,7 +592,6 @@ public boolean handle(PrismObject prismObject, OperationResult paren @Test public void test530AddAccountWill() throws Exception { final String TEST_NAME = "test530AddAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -657,7 +641,6 @@ public void test530AddAccountWill() throws Exception { @Test public void test540DeleteObject() throws Exception { final String TEST_NAME = "test540DeleteObject"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -695,7 +678,6 @@ public void test540DeleteObject() throws Exception { @Test public void test550ModifyObject() throws Exception { final String TEST_NAME = "test150ModifyObject"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -738,7 +720,6 @@ public void test550ModifyObject() throws Exception { @Test public void test590Synchronize() throws Exception { final String TEST_NAME = "test590Synhronize"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestOpenDjNegative.class.getName() + "." + TEST_NAME); diff --git a/repo/repo-common/src/test/java/com/evolveum/midpoint/repo/common/commandline/TestCommandLine.java b/repo/repo-common/src/test/java/com/evolveum/midpoint/repo/common/commandline/TestCommandLine.java index e7b2ba70565..b8cb6bda4dd 100644 --- a/repo/repo-common/src/test/java/com/evolveum/midpoint/repo/common/commandline/TestCommandLine.java +++ b/repo/repo-common/src/test/java/com/evolveum/midpoint/repo/common/commandline/TestCommandLine.java @@ -56,7 +56,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100PlainExecuteEcho() throws Exception { final String TEST_NAME = "test100PlainExecuteEcho"; - displayTestTitle(TEST_NAME); if (!isOsUnix()) { displaySkip(TEST_NAME); @@ -81,7 +80,6 @@ public void test100PlainExecuteEcho() throws Exception { @Test public void test110RedirExecuteEcho() throws Exception { final String TEST_NAME = "test110RedirExecuteEcho"; - displayTestTitle(TEST_NAME); if (!isOsUnix()) { displaySkip(TEST_NAME); 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 2d89fe1eb20..5057130da57 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 @@ -1787,10 +1787,6 @@ protected PrismObject parseObject(File file) throws Sc return prismContext.parseObject(file); } - protected void displayTestTitle(String testName) { - TestUtil.displayTestTitle(this, testName); - } - protected void displayWhen() { displayWhen(getTestNameShort()); } diff --git a/repo/security-impl/src/test/java/com/evolveum/midpoint/security/impl/TestEmpty.java b/repo/security-impl/src/test/java/com/evolveum/midpoint/security/impl/TestEmpty.java index bd31481ce81..8d518981e21 100644 --- a/repo/security-impl/src/test/java/com/evolveum/midpoint/security/impl/TestEmpty.java +++ b/repo/security-impl/src/test/java/com/evolveum/midpoint/security/impl/TestEmpty.java @@ -84,7 +84,6 @@ public void test000Sanity() throws Exception { @Test public void test020GuiProfiledPrincipalManagerMockUsername() throws Exception { final String TEST_NAME = "test020GuiProfiledPrincipalManagerMockUsername"; - displayTestTitle(TEST_NAME); MidPointPrincipal principal = userProfileService.getPrincipal(USER_JACK_USERNAME, UserType.class); assertPrincipalJack(principal); diff --git a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdap.java b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdap.java index c7a7e0027f4..042ca5c7d51 100644 --- a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdap.java +++ b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdap.java @@ -45,6 +45,7 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.ObjectQueryUtil; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.ldap.OpenDJController; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; @@ -150,7 +151,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); assertUsers(NUM_INITIAL_USERS); } @@ -162,7 +162,6 @@ public void test000Sanity() throws Exception { @Test public void test200AssignRolePiratesToBarbossa() throws Exception { final String TEST_NAME = "test200AssignRolePiratesToBarbossa"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -190,7 +189,6 @@ public void test200AssignRolePiratesToBarbossa() throws Exception { @Test public void test202AssignLdapAccountToGuybrush() throws Exception { final String TEST_NAME = "test202AssignLdapAccountToGuybrush"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -249,7 +247,6 @@ public void test202AssignLdapAccountToGuybrush() throws Exception { @Test public void test204AssignRolePiratesToGuybrush() throws Exception { final String TEST_NAME = "test204AssignRolePiratesToGuybrush"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -280,7 +277,6 @@ public void test204AssignRolePiratesToGuybrush() throws Exception { @Test public void test400RenameLeChuckConflicting() throws Exception { final String TEST_NAME = "test400RenameLeChuckConflicting"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -318,7 +314,6 @@ public void test400RenameLeChuckConflicting() throws Exception { @Test public void test800BigLdapSearch() throws Exception { final String TEST_NAME = "test800BigLdapSearch"; - displayTestTitle(TEST_NAME); // GIVEN @@ -363,7 +358,6 @@ public boolean handle(PrismObject shadow, OperationResult parentResu @Test public void test810BigImport() throws Exception { final String TEST_NAME = "test810BigImport"; - displayTestTitle(TEST_NAME); // GIVEN @@ -399,7 +393,6 @@ public void test810BigImport() throws Exception { @Test public void test820BigReconciliation() throws Exception { final String TEST_NAME = "test820BigReconciliation"; - displayTestTitle(TEST_NAME); // GIVEN @@ -437,7 +430,6 @@ public void test820BigReconciliation() throws Exception { @Test public void test900DeleteShadows() throws Exception { final String TEST_NAME = "test900DeleteShadows"; - displayTestTitle(TEST_NAME); // GIVEN @@ -487,7 +479,6 @@ public void test900DeleteShadows() throws Exception { @Test public void test910DeleteAccounts() throws Exception { final String TEST_NAME = "test910DeleteAccounts"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); diff --git a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdapComplex.java b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdapComplex.java index 1bf1bc43103..622aec1be00 100644 --- a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdapComplex.java +++ b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdapComplex.java @@ -29,6 +29,7 @@ import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; @@ -133,7 +134,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100BigImport() throws Exception { final String TEST_NAME = "test100BigImport"; - displayTestTitle(TEST_NAME); // GIVEN @@ -175,7 +175,6 @@ private void assertUser(String name, Task task, OperationResult result) throws c @Test(enabled = false) public void test120BigReconciliation() throws Exception { final String TEST_NAME = "test120BigReconciliation"; - displayTestTitle(TEST_NAME); // GIVEN @@ -214,7 +213,6 @@ public void test120BigReconciliation() throws Exception { @Test public void test500GuybrushAssignSecurity() throws Exception { final String TEST_NAME = "test500GuybrushAssignSecurity"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -245,7 +243,6 @@ public void test500GuybrushAssignSecurity() throws Exception { @Test public void test502RuinGuybrushAccountAndReconcile() throws Exception { final String TEST_NAME = "test502RuinGuybrushAccountAndReconcile"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); diff --git a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestRunAs.java b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestRunAs.java index a135632e7ea..1c24f0461fd 100644 --- a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestRunAs.java +++ b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestRunAs.java @@ -26,6 +26,7 @@ import com.evolveum.icf.dummy.resource.DummyAccount; import com.evolveum.midpoint.model.api.ModelService; import com.evolveum.midpoint.model.impl.sync.ReconciliationTaskHandler; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.util.MiscUtil; import com.evolveum.midpoint.util.aspect.ProfilingDataManager; @@ -160,7 +161,6 @@ public void test000Sanity() throws Exception { @Test public void test100AssignAccountDummyToBarbossa() throws Exception { final String TEST_NAME = "test100AssignAccountDummyToBarbossa"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -192,7 +192,6 @@ public void test100AssignAccountDummyToBarbossa() throws Exception { @Test public void test109UnassignAccountDummyFromBarbossa() throws Exception { final String TEST_NAME = "test109UnassignAccountDummyFromBarbossa"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -216,7 +215,6 @@ public void test109UnassignAccountDummyFromBarbossa() throws Exception { @Test public void test200CleanupPlain() throws Exception { final String TEST_NAME = "test200CleanupPlain"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -256,7 +254,6 @@ public void test205WarmUp() throws Exception { @Test public void test210BarbossaSetOrganizationPlain() throws Exception { final String TEST_NAME = "test210BarbossaSetOrganizationPlain"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -289,7 +286,6 @@ public void test210BarbossaSetOrganizationPlain() throws Exception { @Test public void test300CleanupRunAs() throws Exception { final String TEST_NAME = "test300CleanupRunAs"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -329,7 +325,6 @@ public void test305WarmUp() throws Exception { @Test public void test310BarbossaSetOrganizationRunAs() throws Exception { final String TEST_NAME = "test310BarbossaSetOrganizationRunAs"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -371,7 +366,6 @@ public void test310BarbossaSetOrganizationRunAs() throws Exception { } private void warmUp(final String TEST_NAME) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); diff --git a/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestAbstractRestService.java b/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestAbstractRestService.java index b1b5ba53c00..d84891bbd92 100644 --- a/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestAbstractRestService.java +++ b/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestAbstractRestService.java @@ -19,16 +19,12 @@ import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; -import com.evolveum.midpoint.gui.test.TestMidPointSpringApplication; import com.evolveum.midpoint.model.api.ModelExecuteOptions; import com.evolveum.midpoint.task.api.Task; import org.apache.commons.lang.BooleanUtils; import org.apache.commons.lang.StringUtils; import org.apache.cxf.jaxrs.client.WebClient; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ActiveProfiles; import org.testng.AssertJUnit; import org.testng.annotations.Test; @@ -143,7 +139,6 @@ public TestAbstractRestService() { @Test public void test001GetUserAdministrator() { final String TEST_NAME = "test001GetUserAdministrator"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/" + SystemObjectsType.USER_ADMINISTRATOR.value()); @@ -167,7 +162,6 @@ public void test001GetUserAdministrator() { @Test public void test002GetNonExistingUser() { final String TEST_NAME = "test002GetNonExistingUser"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/12345"); @@ -192,7 +186,6 @@ public void test002GetNonExistingUser() { @Test public void test003GetNoAuthHeaders() { final String TEST_NAME = "test003GetNoAuthHeaders"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(null, null); client.path("/users/" + SystemObjectsType.USER_ADMINISTRATOR.value()); @@ -213,7 +206,6 @@ public void test003GetNoAuthHeaders() { @Test public void test004GetAuthBadUsernameNullPassword() { final String TEST_NAME = "test004GetAuthBadUsernameNullPassword"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient("NoSUCHuser", null); client.path("/users/" + SystemObjectsType.USER_ADMINISTRATOR.value()); @@ -234,7 +226,6 @@ public void test004GetAuthBadUsernameNullPassword() { @Test public void test005GetAuthBadUsernameEmptyPassword() { final String TEST_NAME = "test005GetAuthBadUsernameEmptyPassword"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient("NoSUCHuser", ""); client.path("/users/" + SystemObjectsType.USER_ADMINISTRATOR.value()); @@ -255,7 +246,6 @@ public void test005GetAuthBadUsernameEmptyPassword() { @Test public void test006GetAuthBadUsernameBadPassword() { final String TEST_NAME = "test006GetAuthBadUsernameBadPassword"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient("NoSUCHuser", "NoSuchPassword"); client.path("/users/" + SystemObjectsType.USER_ADMINISTRATOR.value()); @@ -276,7 +266,6 @@ public void test006GetAuthBadUsernameBadPassword() { @Test public void test007GetAuthNoPassword() { final String TEST_NAME = "test007GetAuthNoPassword"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(USER_ADMINISTRATOR_USERNAME, null); client.path("/users/" + SystemObjectsType.USER_ADMINISTRATOR.value()); @@ -297,7 +286,6 @@ public void test007GetAuthNoPassword() { @Test public void test016GetAuthBadPassword() { final String TEST_NAME = "test016GetAuthBadPassword"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(USER_ADMINISTRATOR_USERNAME, "forgot"); client.path("/users/" + SystemObjectsType.USER_ADMINISTRATOR.value()); @@ -318,7 +306,6 @@ public void test016GetAuthBadPassword() { @Test public void test017GetUnauthorizedUser() { final String TEST_NAME = "test017GetUnauthorizedUser"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(USER_NOBODY_USERNAME, USER_NOBODY_PASSWORD); client.path("/users/" + SystemObjectsType.USER_ADMINISTRATOR.value()); @@ -339,7 +326,6 @@ public void test017GetUnauthorizedUser() { @Test public void test018GetUserAdministratorByCyclops() { final String TEST_NAME = "test018GetUserAdministratorByCyclops"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(USER_CYCLOPS_USERNAME, USER_CYCLOPS_PASSWORD); client.path("/users/" + SystemObjectsType.USER_ADMINISTRATOR.value()); @@ -360,7 +346,6 @@ public void test018GetUserAdministratorByCyclops() { @Test public void test019GetUserAdministratorBySomebody() { final String TEST_NAME = "test019GetUserAdministratorBySomebody"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(USER_SOMEBODY_USERNAME, USER_SOMEBODY_PASSWORD); client.path("/users/" + SystemObjectsType.USER_ADMINISTRATOR.value()); @@ -386,7 +371,6 @@ public void test019GetUserAdministratorBySomebody() { @Test public void test102AddUserTemplate() throws Exception { final String TEST_NAME = "test102AddUserTemplate"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/objectTemplates/"); @@ -410,7 +394,6 @@ public void test102AddUserTemplate() throws Exception { @Test public void test103AddUserBadTargetCollection() throws Exception { final String TEST_NAME = "test103AddUserBadTargetCollection"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/objectTemplates"); @@ -437,7 +420,6 @@ public void test103AddUserBadTargetCollection() throws Exception { @Test public void test104AddAccountRawResourceDoesNotExist() throws Exception { final String TEST_NAME = "test104AddAccountRaw"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/shadows"); @@ -478,7 +460,6 @@ public void test104AddAccountRawResourceDoesNotExist() throws Exception { @Test public void test120AddRoleAdder() throws Exception { final String TEST_NAME = "test120AddRoleAdder"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/roles"); @@ -501,7 +482,6 @@ public void test120AddRoleAdder() throws Exception { @Test public void test121AddUserDarthAdder() throws Exception { final String TEST_NAME = "test121AddUserDarthAdder"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users"); @@ -524,7 +504,6 @@ public void test121AddUserDarthAdder() throws Exception { @Test public void test122AddRoleModifierAsDarthAdder() throws Exception { final String TEST_NAME = "test122AddRoleModifierAsDarthAdder"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(USER_DARTHADDER_USERNAME, USER_DARTHADDER_PASSWORD); client.path("/roles"); @@ -547,7 +526,6 @@ public void test122AddRoleModifierAsDarthAdder() throws Exception { @Test public void test123DarthAdderAssignModifierHimself() throws Exception { final String TEST_NAME = "test123DarthAdderAssignModifierHimself"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(USER_DARTHADDER_USERNAME, USER_DARTHADDER_PASSWORD); client.path("/users/"+USER_DARTHADDER_OID); @@ -574,7 +552,6 @@ public void test123DarthAdderAssignModifierHimself() throws Exception { @Test public void test124DarthAdderAssignModifierByAdministrator() throws Exception { final String TEST_NAME = "test124DarthAdderAssignModifierByAdministrator"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/"+USER_DARTHADDER_OID); @@ -601,7 +578,6 @@ public void test124DarthAdderAssignModifierByAdministrator() throws Exception { @Test public void test130DarthAdderDisableHimself() throws Exception { final String TEST_NAME = "test130DarthAdderDisableHimself"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(USER_DARTHADDER_USERNAME, USER_DARTHADDER_PASSWORD); client.path("/users/"+USER_DARTHADDER_OID); @@ -628,7 +604,6 @@ public void test130DarthAdderDisableHimself() throws Exception { @Test public void test131GetUserAdministratorByDarthAdder() { final String TEST_NAME = "test131GetUserAdministratorByDarthAdder"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(USER_DARTHADDER_USERNAME, USER_DARTHADDER_PASSWORD); client.path("/users/" + SystemObjectsType.USER_ADMINISTRATOR.value()); @@ -650,7 +625,6 @@ public void test131GetUserAdministratorByDarthAdder() { @Test public void test132DarthAdderEnableByAdministrator() throws Exception { final String TEST_NAME = "test132DarthAdderEnableByAdministrator"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/"+USER_DARTHADDER_OID); @@ -677,7 +651,6 @@ public void test132DarthAdderEnableByAdministrator() throws Exception { @Test public void test133GetUserAdministratorByDarthAdder() { final String TEST_NAME = "test133GetUserAdministratorByDarthAdder"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(USER_DARTHADDER_USERNAME, USER_DARTHADDER_PASSWORD); client.path("/users/" + SystemObjectsType.USER_ADMINISTRATOR.value()); @@ -701,7 +674,6 @@ public void test133GetUserAdministratorByDarthAdder() { @Test public void test135AddUserNopasswordAsDarthAdder() throws Exception { final String TEST_NAME = "test135AddUserNopasswordAsDarthAdder"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(USER_DARTHADDER_USERNAME, USER_DARTHADDER_PASSWORD); client.path("/users"); @@ -724,7 +696,6 @@ public void test135AddUserNopasswordAsDarthAdder() throws Exception { @Test public void test140GetUserAdministratorByNopassword() { final String TEST_NAME = "test140GetUserAdministratorByNopassword"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(USER_NOPASSWORD_USERNAME, null); client.path("/users/" + SystemObjectsType.USER_ADMINISTRATOR.value()); @@ -746,7 +717,6 @@ public void test140GetUserAdministratorByNopassword() { @Test public void test141GetUserAdministratorByNopasswordBadPassword() { final String TEST_NAME = "test140GetUserAdministratorByNopassword"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(USER_NOPASSWORD_USERNAME, "bad"); client.path("/users/" + SystemObjectsType.USER_ADMINISTRATOR.value()); @@ -768,7 +738,6 @@ public void test141GetUserAdministratorByNopasswordBadPassword() { @Test public void test200searchAllUsers() { final String TEST_NAME = "test200searchAllUsers"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/search"); @@ -791,7 +760,6 @@ public void test200searchAllUsers() { @Test public void test401AddUserTemplateOverwrite() throws Exception { final String TEST_NAME = "test401AddUserTemplateOverwrite"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/objectTemplates"); @@ -826,7 +794,6 @@ public void test401AddUserTemplateOverwrite() throws Exception { @Test public void test410AddFunctionLibraryHello() throws Exception { final String TEST_NAME = "test410AddFunctionLibraryHello"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/functionLibraries"); @@ -858,7 +825,6 @@ public void test410AddFunctionLibraryHello() throws Exception { @Test public void test412GetFunctionLibraryHello() { final String TEST_NAME = "test412GetFunctionLibraryHello"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/functionLibraries/" + FUNCTION_LIBRARY_HELLO_OID); @@ -888,7 +854,6 @@ public void test412GetFunctionLibraryHello() { @Test public void test501generateValue() throws Exception { final String TEST_NAME = "test501generateValue"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/" + USER_DARTHADDER_OID + "/generate"); @@ -913,7 +878,6 @@ public void test501generateValue() throws Exception { @Test public void test502generateValueBadPath() throws Exception { final String TEST_NAME = "test502generateValueBadPath"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/" + USER_DARTHADDER_OID + "/generate"); @@ -936,7 +900,6 @@ public void test502generateValueBadPath() throws Exception { @Test public void test503generateValueExecute() throws Exception { final String TEST_NAME = "test503generateValueExecute"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/" + USER_DARTHADDER_OID + "/generate"); @@ -964,7 +927,6 @@ public void test503generateValueExecute() throws Exception { @Test public void test504checkGeneratedValue() throws Exception { final String TEST_NAME = "test503generateValueExecute"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/" + USER_DARTHADDER_OID ); @@ -986,7 +948,6 @@ public void test504checkGeneratedValue() throws Exception { @Test public void test505generatePasswordExecute() throws Exception { final String TEST_NAME = "test505generatePasswordExecute"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/" + USER_DARTHADDER_OID + "/generate"); @@ -1013,7 +974,6 @@ public void test505generatePasswordExecute() throws Exception { @Test public void test506generateHonorificPrefixNameExecute() throws Exception { final String TEST_NAME = "test506generateHonorificPrefixNameExecute"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/" + USER_DARTHADDER_OID + "/generate"); @@ -1080,7 +1040,6 @@ private void assertLocalizableMessage(LocalizableMessageType localizableMessage) @Test public void test510validateValueExplicit() throws Exception { final String TEST_NAME = "test510validateValueExplicit"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/rpc/validate"); @@ -1105,7 +1064,6 @@ public void test510validateValueExplicit() throws Exception { @Test public void test511validateValueExplicitConflict() throws Exception { final String TEST_NAME = "test511validateValueExplicitConflict"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/rpc/validate"); @@ -1130,7 +1088,6 @@ public void test511validateValueExplicitConflict() throws Exception { @Test public void test512validateValueImplicitSingle() throws Exception { final String TEST_NAME = "test512validateValueImplicitSingle"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/" + USER_DARTHADDER_OID + "/validate"); @@ -1154,7 +1111,6 @@ public void test512validateValueImplicitSingle() throws Exception { @Test public void test513validateValueImplicitMulti() throws Exception { final String TEST_NAME = "test513validateValueImplicitMulti"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/" + USER_DARTHADDER_OID + "/validate"); @@ -1178,7 +1134,6 @@ public void test513validateValueImplicitMulti() throws Exception { @Test public void test514validateValueImplicitMultiConflict() throws Exception { final String TEST_NAME = "test514validateValueImplicitMultiConflict"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/" + USER_DARTHADDER_OID + "/validate"); @@ -1203,7 +1158,6 @@ public void test514validateValueImplicitMultiConflict() throws Exception { @Test public void test515validatePasswordHistoryConflict() throws Exception { final String TEST_NAME = "test515validatePasswordHistoryConflict"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/" + USER_DARTHADDER_OID + "/validate"); @@ -1228,7 +1182,6 @@ public void test515validatePasswordHistoryConflict() throws Exception { @Test public void test516validateValueExplicitNoValuePolicy() throws Exception { final String TEST_NAME = "test516validateValueExplicitNoValuePolicy"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/rpc/validate"); @@ -1253,7 +1206,6 @@ public void test516validateValueExplicitNoValuePolicy() throws Exception { @Test public void test517generateValueExplicit() throws Exception { final String TEST_NAME = "test517generateValueExplicit"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/rpc/generate"); @@ -1278,7 +1230,6 @@ public void test517generateValueExplicit() throws Exception { @Test public void test518validateValueImplicitPassword() throws Exception { final String TEST_NAME = "test518validateValueImplicitPassword"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1313,7 +1264,6 @@ public void test518validateValueImplicitPassword() throws Exception { @Test public void test520GeneratePasswordsUsingScripting() throws Exception { final String TEST_NAME = "test520GeneratePasswordsUsingScripting"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/rpc/executeScript"); @@ -1368,7 +1318,6 @@ public void test520GeneratePasswordsUsingScripting() throws Exception { @Test public void test530ModifyValidToUsingScripting() throws Exception { final String TEST_NAME = "test530ModifyValidToUsingScripting"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/rpc/executeScript"); @@ -1501,7 +1450,6 @@ private List> extractI @Test public void test600ModifySecurityQuestionReplaceAnswerId1Existing() throws Exception { final String TEST_NAME = "test600ModifySecurityQuestionReplaceAnswerId1Existing"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/" + USER_DARTHADDER_OID); @@ -1546,7 +1494,6 @@ private UserType getUserRest(String oid) { @Test public void test602ModifySecurityQuestionReplaceTwoAnswersExisting() throws Exception { final String TEST_NAME = "test602ModifySecurityQuestionReplaceTwoAnswersExisting"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/" + USER_DARTHADDER_OID); @@ -1583,7 +1530,6 @@ public void test602ModifySecurityQuestionReplaceTwoAnswersExisting() throws Exce @Test public void test604ModifySecurityQuestionReplaceNoAnswer() throws Exception { final String TEST_NAME = "test604ModifySecurityQuestionReplaceNoAnswer"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/" + USER_DARTHADDER_OID); @@ -1620,7 +1566,6 @@ public void test604ModifySecurityQuestionReplaceNoAnswer() throws Exception { @Test public void test606ModifySecurityQuestionReplaceAnswer() throws Exception { final String TEST_NAME = "test606ModifySecurityQuestionReplaceAnswer"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/" + USER_DARTHADDER_OID); @@ -1654,7 +1599,6 @@ public void test606ModifySecurityQuestionReplaceAnswer() throws Exception { @Test public void test607validateSecurityAnswerCheckExpressionFail() throws Exception { final String TEST_NAME = "test607validateSecurityAnswerCheckExpressionFail"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/" + USER_DARTHADDER_OID + "/validate"); @@ -1679,7 +1623,6 @@ public void test607validateSecurityAnswerCheckExpressionFail() throws Exception @Test public void test608validateSecurityAnswerCheckExpression() throws Exception { final String TEST_NAME = "test607validateSecurityAnswerCheckExpression"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/" + USER_DARTHADDER_OID + "/validate"); @@ -1753,7 +1696,6 @@ private void assertSecurityQuestionAnswer(List secQu @Test public void test610ModifyPasswordForceChange() throws Exception { final String TEST_NAME = "test610ModifyPasswordForceChange"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/" + USER_DARTHADDER_OID); @@ -1794,7 +1736,6 @@ public void test610ModifyPasswordForceChange() throws Exception { @Test public void test612ResetPassword() throws Exception { final String TEST_NAME = "test612ResetPassword"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/" + USER_DARTHADDER_OID + "/credential"); @@ -1842,7 +1783,6 @@ public void test612ResetPassword() throws Exception { @Test // MID-4928 public void test650SuspendNonExistingTask() { final String TEST_NAME = "test650SuspendNonExistingTask"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/tasks/123456/suspend"); @@ -1859,7 +1799,6 @@ public void test650SuspendNonExistingTask() { @Test // MID-4928 public void test652SuspendWrongObject() { final String TEST_NAME = "test652SuspendWrongObject"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/tasks/00000000-0000-0000-0000-000000000002/suspend"); @@ -1876,7 +1815,6 @@ public void test652SuspendWrongObject() { @Test // MID-4928 public void test660ResumeNonExistingTask() { final String TEST_NAME = "test660ResumeNonExistingTask"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/tasks/123456/resume"); @@ -1893,7 +1831,6 @@ public void test660ResumeNonExistingTask() { @Test // MID-4928 public void test662ResumeWrongObject() { final String TEST_NAME = "test662ResumeWrongObject"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/tasks/00000000-0000-0000-0000-000000000002/resume"); @@ -1910,7 +1847,6 @@ public void test662ResumeWrongObject() { @Test // MID-4928 public void test670ScheduleNonExistingTask() { final String TEST_NAME = "test670ScheduleNonExistingTask"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/tasks/123456/run"); @@ -1927,7 +1863,6 @@ public void test670ScheduleNonExistingTask() { @Test // MID-4928 public void test672ScheduleWrongObject() { final String TEST_NAME = "test672ScheduleWrongObject"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/tasks/00000000-0000-0000-0000-000000000002/run"); @@ -1944,7 +1879,6 @@ public void test672ScheduleWrongObject() { @Test // MID-4928 public void test680DeleteNonExistingTask() { final String TEST_NAME = "test680DeleteNonExistingTask"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/tasks/123456"); @@ -1961,7 +1895,6 @@ public void test680DeleteNonExistingTask() { @Test // MID-4928 public void test682DeleteWrongObject() { final String TEST_NAME = "test682DeleteWrongObject"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/tasks/00000000-0000-0000-0000-000000000002"); diff --git a/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestRestServiceProxyAuthentication.java b/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestRestServiceProxyAuthentication.java index 78151460b61..52a6967499d 100644 --- a/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestRestServiceProxyAuthentication.java +++ b/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestRestServiceProxyAuthentication.java @@ -7,7 +7,6 @@ package com.evolveum.midpoint.testing.rest; import com.evolveum.midpoint.common.rest.MidpointAbstractProvider; -import com.evolveum.midpoint.gui.test.TestMidPointSpringApplication; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.internals.InternalMonitor; import com.evolveum.midpoint.schema.result.OperationResult; @@ -20,10 +19,6 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; import org.apache.commons.lang.StringUtils; import org.apache.cxf.jaxrs.client.WebClient; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.annotation.DirtiesContext.ClassMode; -import org.springframework.test.context.ActiveProfiles; import org.testng.AssertJUnit; import org.testng.annotations.Test; @@ -77,7 +72,6 @@ public void initSystem(Task initTask, OperationResult result) throws Exception { @Test public void test001getUserSelfBySomebody() { final String TEST_NAME = "test001getUserSelfBySomebody"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(USER_SOMEBODY_OID); client.path("/self/"); @@ -101,7 +95,6 @@ public void test001getUserSelfBySomebody() { @Test public void test002getUserSelfByEgoist() { final String TEST_NAME = "test002getUserSelfByEgoist"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(USER_EGOIST_OID); client.path("/self/"); @@ -129,7 +122,6 @@ public void test002getUserSelfByEgoist() { @Test public void test003getUserAdministratorByEgoist() { final String TEST_NAME = "test003getUserAdministratorByEgoist"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(USER_EGOIST_OID); client.path("/users/" + SystemObjectsType.USER_ADMINISTRATOR.value()); @@ -153,7 +145,6 @@ public void test003getUserAdministratorByEgoist() { @Test public void test004getUserSelfByHead() { final String TEST_NAME = "test004getUserSelfByHead"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(null); client.path("/self"); @@ -181,7 +172,6 @@ public void test004getUserSelfByHead() { @Test public void test005getUserSelfByProxyHead() { final String TEST_NAME = "test005getUserSelfByProxyHead"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(USER_HEAD_OID); client.path("/self"); diff --git a/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java b/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java index 38a6ab7b8ce..b8d1a8c9ad0 100644 --- a/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java +++ b/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java @@ -433,7 +433,6 @@ public void test000Integrity() throws Exception { @Test public void test001SelfTests() throws Exception { final String TEST_NAME = "test001SelfTests"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestSanity.class.getName()+"."+TEST_NAME); @@ -463,7 +462,6 @@ public void test001SelfTests() throws Exception { @Test public void test001TestConnectionOpenDJ() throws Exception { final String TEST_NAME = "test001TestConnectionOpenDJ"; - displayTestTitle(TEST_NAME); // GIVEN try{ @@ -639,7 +637,6 @@ private void checkOpenResourceConfiguration(PrismObject resource, @Test public void test002AddDerbyResource() throws Exception { final String TEST_NAME = "test002AddDerbyResource"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestSanity.class.getName() + "." + TEST_NAME); @@ -934,7 +931,6 @@ public void test006reimportResourceDummy() throws Exception{ @Test public void test010AddUser() throws Exception { final String TEST_NAME = "test010AddUser"; - displayTestTitle(TEST_NAME); // GIVEN checkRepoOpenDjResource(); @@ -986,7 +982,6 @@ public void test010AddUser() throws Exception { @Test public void test013AddOpenDjAccountToUser() throws Exception { final String TEST_NAME = "test013AddOpenDjAccountToUser"; - displayTestTitle(TEST_NAME); try{ // GIVEN checkRepoOpenDjResource(); @@ -1322,7 +1317,6 @@ public boolean handle(PrismObject prismObject, OperationResult paren @Test public void test020ModifyUser() throws Exception { final String TEST_NAME = "test020ModifyUser"; - displayTestTitle(TEST_NAME); // GIVEN assertNoRepoCache(); @@ -1420,7 +1414,6 @@ private Entry assertOpenDJAccountJack(Entry entry, String uid, String givenName) @Test public void test022ChangeUserPassword() throws Exception { final String TEST_NAME = "test022ChangeUserPassword"; - displayTestTitle(TEST_NAME); // GIVEN ObjectDeltaType objectChange = unmarshallValueFromFile( @@ -1442,7 +1435,6 @@ public void test022ChangeUserPassword() throws Exception { @Test public void test023ChangeUserPasswordJAXB() throws Exception { final String TEST_NAME = "test023ChangeUserPasswordJAXB"; - displayTestTitle(TEST_NAME); // GIVEN final String NEW_PASSWORD = "abandonSHIP"; @@ -1535,7 +1527,6 @@ public void test028ModifyAccountDjExplicitType() throws Exception { } public void testModifyAccountDjRoomNumber(final String TEST_NAME, File reqFile, String expectedVal) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN assertNoRepoCache(); @@ -1572,7 +1563,6 @@ public void testModifyAccountDjRoomNumber(final String TEST_NAME, File reqFile, @Test public void test029ModifyAccountDjBadPath() throws Exception { final String TEST_NAME = "test029ModifyAccountDjBadPath"; - displayTestTitle(TEST_NAME); // GIVEN assertNoRepoCache(); @@ -1621,7 +1611,6 @@ public void test029ModifyAccountDjBadPath() throws Exception { @Test public void test030DisableUser() throws Exception { final String TEST_NAME = "test030DisableUser"; - displayTestTitle(TEST_NAME); // GIVEN ObjectDeltaType objectChange = unmarshallValueFromFile( @@ -1734,7 +1723,6 @@ public void test030DisableUser() throws Exception { @Test public void test031EnableUser() throws Exception { final String TEST_NAME = "test031EnableUser"; - displayTestTitle(TEST_NAME); // GIVEN ObjectDeltaType objectChange = unmarshallValueFromFile( @@ -1938,7 +1926,6 @@ private OperationResultType deleteObjectViaModelWS(QName typeQName, String oid) @Test public void test047RenameUser() throws Exception { final String TEST_NAME = "test047RenameUser"; - displayTestTitle(TEST_NAME); // GIVEN assertNoRepoCache(); @@ -2003,7 +1990,6 @@ public void test047RenameUser() throws Exception { @Test public void test048ModifyUserRemoveGivenName() throws Exception { final String TEST_NAME = "test048ModifyUserRemoveGivenName"; - displayTestTitle(TEST_NAME); // GIVEN assertNoRepoCache(); @@ -2109,7 +2095,6 @@ public void test049DeleteUser() throws SchemaException, FaultMessage, DirectoryE @Test public void test100AssignRolePirate() throws Exception { final String TEST_NAME = "test100AssignRolePirate"; - displayTestTitle(TEST_NAME); // GIVEN @@ -2205,7 +2190,6 @@ public void test100AssignRolePirate() throws Exception { @Test public void test101AccountOwnerAfterRole() throws Exception { final String TEST_NAME = "test101AccountOwnerAfterRole"; - displayTestTitle(TEST_NAME); // GIVEN @@ -2232,7 +2216,6 @@ public void test101AccountOwnerAfterRole() throws Exception { @Test public void test102AssignRoleCaptain() throws Exception { final String TEST_NAME = "test102AssignRoleCaptain"; - displayTestTitle(TEST_NAME); // GIVEN @@ -2314,7 +2297,6 @@ public void test102AssignRoleCaptain() throws Exception { @Test public void test103AssignRoleCaptainAgain() throws Exception { final String TEST_NAME = "test103AssignRoleCaptainAgain"; - displayTestTitle(TEST_NAME); // GIVEN @@ -2393,7 +2375,6 @@ public void test103AssignRoleCaptainAgain() throws Exception { @Test public void test105ModifyAccount() throws Exception { final String TEST_NAME = "test105ModifyAccount"; - displayTestTitle(TEST_NAME); // GIVEN @@ -2478,7 +2459,6 @@ public void test105ModifyAccount() throws Exception { @Test public void test104AssignRoleJudge() throws Exception { final String TEST_NAME = "test104AssignRoleJudge"; - displayTestTitle(TEST_NAME); // GIVEN @@ -2523,7 +2503,6 @@ public void test104AssignRoleJudge() throws Exception { @Test public void test107UnassignRolePirate() throws Exception { final String TEST_NAME = "test107UnassignRolePirate"; - displayTestTitle(TEST_NAME); // GIVEN @@ -2606,7 +2585,6 @@ public void test107UnassignRolePirate() throws Exception { @Test public void test108UnassignRoleCaptain() throws Exception { final String TEST_NAME = "test108UnassignRoleCaptain"; - displayTestTitle(TEST_NAME); // GIVEN @@ -2694,7 +2672,6 @@ public void test108UnassignRoleCaptain() throws Exception { @Test public void test109UnassignRoleCaptainAgain() throws Exception { final String TEST_NAME = "test109UnassignRoleCaptainAgain"; - displayTestTitle(TEST_NAME); // GIVEN @@ -2761,7 +2738,6 @@ public void test109UnassignRoleCaptainAgain() throws Exception { @Test public void test300LiveSyncInit() throws Exception { final String TEST_NAME = "test300LiveSyncInit"; - displayTestTitle(TEST_NAME); // Now it is the right time to add task definition to the repository // We don't want it there any sooner, as it may interfere with the // previous tests @@ -2872,7 +2848,6 @@ public void timeout() { @Test public void test301LiveSyncCreate() throws Exception { final String TEST_NAME = "test301LiveSyncCreate"; - displayTestTitle(TEST_NAME); // Sync task should be running (tested in previous test), so just create // new LDAP object. @@ -2912,7 +2887,6 @@ public void test301LiveSyncCreate() throws Exception { @Test public void test302LiveSyncModify() throws Exception { final String TEST_NAME = "test302LiveSyncModify"; - displayTestTitle(TEST_NAME); final OperationResult result = new OperationResult(TestSanity.class.getName() + "." + TEST_NAME); @@ -2945,7 +2919,6 @@ public void test302LiveSyncModify() throws Exception { @Test public void test303LiveSyncLink() throws Exception { final String TEST_NAME = "test303LiveSyncLink"; - displayTestTitle(TEST_NAME); // GIVEN assertNoRepoCache(); @@ -3011,7 +2984,6 @@ public void test303LiveSyncLink() throws Exception { @Test public void test304LiveSyncCreateNoLocation() throws Exception { final String TEST_NAME = "test304LiveSyncCreateNoLocation"; - displayTestTitle(TEST_NAME); // Sync task should be running (tested in previous test), so just create // new LDAP object. @@ -3085,7 +3057,6 @@ private Object findSyncTokenObject(Task syncCycle) { @Test public void test399LiveSyncCleanup() throws Exception { final String TEST_NAME = "test399LiveSyncCleanup"; - displayTestTitle(TEST_NAME); final OperationResult result = new OperationResult(TestSanity.class.getName() + "." + TEST_NAME); @@ -3097,7 +3068,6 @@ public void test399LiveSyncCleanup() throws Exception { @Test public void test400ImportFromResource() throws Exception { final String TEST_NAME = "test400ImportFromResource"; - displayTestTitle(TEST_NAME); // GIVEN checkAllShadows(); assertNoRepoCache(); @@ -3313,7 +3283,6 @@ private String getUserLocality(UserType user){ @Test public void test420RecomputeUsers() throws Exception { final String TEST_NAME = "test420RecomputeUsers"; - displayTestTitle(TEST_NAME); // GIVEN final OperationResult result = new OperationResult(TestSanity.class.getName() @@ -3456,7 +3425,6 @@ public void timeout() { @Test public void test440ReconcileResourceOpenDj() throws Exception { final String TEST_NAME = "test440ReconcileResourceOpenDj"; - displayTestTitle(TEST_NAME); // GIVEN final OperationResult result = new OperationResult(TestSanity.class.getName() @@ -3677,7 +3645,6 @@ public void timeout() { @Test public void test480ListResources() throws Exception { final String TEST_NAME = "test480ListResources"; - displayTestTitle(TEST_NAME); // GIVEN OperationResultType result = new OperationResultType(); Holder resultHolder = new Holder<>(result); @@ -3738,7 +3705,6 @@ public void test485ListResourcesWithBrokenResource() throws Exception { @Test public void test500NotifyChangeCreateAccount() throws Exception{ final String TEST_NAME = "test500NotifyChangeCreateAccount"; - displayTestTitle(TEST_NAME); Entry ldifEntry = openDJController.addEntryFromLdifFile(LDIF_ANGELIKA_FILENAME); display("Entry from LDIF", ldifEntry); @@ -3805,7 +3771,6 @@ public void test500NotifyChangeCreateAccount() throws Exception{ @Test public void test501NotifyChangeModifyAccount() throws Exception{ final String TEST_NAME = "test501NotifyChangeModifyAccount"; - displayTestTitle(TEST_NAME); OperationResult parentResult = new OperationResult(TEST_NAME); PrismObject userAngelika = findUserByUsername(ANGELIKA_NAME); @@ -3862,7 +3827,6 @@ public void test501NotifyChangeModifyAccount() throws Exception{ @Test public void test502NotifyChangeModifyAccountPassword() throws Exception{ final String TEST_NAME = "test502NotifyChangeModifyAccountPassword"; - displayTestTitle(TEST_NAME); PrismObject userAngelika = findUserByUsername(ANGELIKA_NAME); assertNotNull("User with the name angelika must exist.", userAngelika); @@ -3919,7 +3883,6 @@ public void test502NotifyChangeModifyAccountPassword() throws Exception{ @Test public void test503NotifyChangeDeleteAccount() throws Exception{ final String TEST_NAME = "test503NotifyChangeDeleteAccount"; - displayTestTitle(TEST_NAME); PrismObject userAngelika = findUserByUsername(ANGELIKA_NAME); assertNotNull("User with the name angelika must exist.", userAngelika); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConfiguredCapabilitiesActivation.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConfiguredCapabilitiesActivation.java index 22bcd60a1b5..bf4356b3f8a 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConfiguredCapabilitiesActivation.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConfiguredCapabilitiesActivation.java @@ -7,12 +7,10 @@ package com.evolveum.midpoint.testing.story; import com.evolveum.icf.dummy.resource.DummyAccount; -import com.evolveum.icf.dummy.resource.DummyResource; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.asserter.UserAsserter; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; @@ -83,7 +81,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100ImportAccount() throws Exception { final String TEST_NAME = "test100ImportAccount"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -108,7 +105,6 @@ public void test100ImportAccount() throws Exception { @Test public void test110AssignJackPirate() throws Exception { String TEST_NAME = "test110AssignJackPirate"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -169,7 +165,6 @@ public void test110AssignJackPirate() throws Exception { @Test public void test112ModifyActivationJack() throws Exception { String TEST_NAME = "test112ModifyActivationJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConsistencyMechanism.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConsistencyMechanism.java index 43eb8517f16..6ce5b69c9d4 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConsistencyMechanism.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConsistencyMechanism.java @@ -19,7 +19,6 @@ import java.io.File; import java.io.IOException; -import java.time.Duration; import java.util.*; import javax.xml.bind.JAXBElement; @@ -30,10 +29,8 @@ import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl; import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.delta.*; -import com.evolveum.midpoint.prism.impl.PrismPropertyValueImpl; import com.evolveum.midpoint.prism.path.ItemName; import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.provisioning.api.ProvisioningOperationOptions; import com.evolveum.midpoint.schema.*; import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.constants.ObjectTypes; @@ -77,12 +74,10 @@ import com.evolveum.midpoint.schema.util.SchemaTestConstants; import com.evolveum.midpoint.schema.util.ShadowUtil; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.Checker; import com.evolveum.midpoint.test.ldap.OpenDJController; import com.evolveum.midpoint.test.util.MidPointAsserts; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.exception.CommonException; import com.evolveum.midpoint.util.exception.CommunicationException; import com.evolveum.midpoint.util.exception.ConfigurationException; import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; @@ -317,7 +312,6 @@ public static void stopResources() throws Exception { @Test public void test000Integrity() throws Exception { final String TEST_NAME = "test000Integrity"; - displayTestTitle(TEST_NAME); assertNotNull(modelWeb); assertNotNull(modelService); assertNotNull(repositoryService); @@ -358,7 +352,6 @@ public void test000Integrity() throws Exception { @Test public void test001TestConnectionOpenDJ() throws Exception { final String TEST_NAME = "test001TestConnectionOpenDJ"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(); // GIVEN @@ -445,7 +438,6 @@ public void test100AddUser() throws Exception { @Test public void test110PrepareOpenDjWithJackieAccounts() throws Exception { final String TEST_NAME = "test110PrepareOpenDjWithJackieAccounts"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult parentResult = task.getResult(); @@ -501,7 +493,6 @@ public void test110PrepareOpenDjWithJackieAccounts() throws Exception { @Test public void test111prepareOpenDjWithDenielsAccounts() throws Exception { final String TEST_NAME = "test111prepareOpenDjWithDenielsAccounts"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult parentResult = task.getResult(); @@ -547,7 +538,6 @@ public void test111prepareOpenDjWithDenielsAccounts() throws Exception { @Test public void test120AddAccountAlreadyExistLinked() throws Exception { final String TEST_NAME = "test120AddAccountAlreadyExistLinked"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(); OperationResult parentResult = new OperationResult("Add account already exist linked"); @@ -605,7 +595,6 @@ public void test120AddAccountAlreadyExistLinked() throws Exception { @Test public void test122AddAccountAlreadyExistUnlinked() throws Exception { final String TEST_NAME = "test122AddAccountAlreadyExistUnlinked"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult parentResult = new OperationResult("Add account already exist unlinked."); @@ -654,7 +643,6 @@ public void test122AddAccountAlreadyExistUnlinked() throws Exception { @Test(enabled = false) public void test124AddAccountDirectAlreadyExists() throws Exception { final String TEST_NAME = "test124AddAccountDirectAlreadyExists"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult parentResult = task.getResult(); @@ -745,7 +733,6 @@ public void test124AddAccountDirectAlreadyExists() throws Exception { @Test public void test130DeleteObjectNotFound() throws Exception { final String TEST_NAME = "test130DeleteObjectNotFound"; - displayTestTitle(TEST_NAME); OperationResult parentResult = new OperationResult(TEST_NAME); repoAddShadowFromFile(ACCOUNT_GUYBRUSH_FILE, parentResult); @@ -798,7 +785,6 @@ public void test130DeleteObjectNotFound() throws Exception { @Test public void test140ModifyObjectNotFoundLinkedAccount() throws Exception { final String TEST_NAME = "test140ModifyObjectNotFoundLinkedAccount"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -865,7 +851,6 @@ public void test140ModifyObjectNotFoundLinkedAccount() throws Exception { @Test public void test142ModifyObjectNotFoundAssignedAccount() throws Exception { final String TEST_NAME = "test142ModifyObjectNotFoundAssignedAccountq"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult parentResult = new OperationResult(TEST_NAME); @@ -928,7 +913,6 @@ public void test142ModifyObjectNotFoundAssignedAccount() throws Exception { @Test public void test144GetObjectNotFoundAssignedAccount() throws Exception { final String TEST_NAME = "test144GetObjectNotFoundAssignedAccount"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult parentResult = new OperationResult(TEST_NAME); @@ -969,7 +953,6 @@ public void test144GetObjectNotFoundAssignedAccount() throws Exception { @Test public void test150RecomputeUserAccountNotFound() throws Exception { final String TEST_NAME = "test150RecomputeUserAccountNotFound"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TEST_NAME); @@ -1025,7 +1008,6 @@ public void test150RecomputeUserAccountNotFound() throws Exception { @Test public void test152RecomputeUserAccountAndShadowNotFound() throws Exception { final String TEST_NAME = "test152RecomputeUserAccountAndShadowNotFound"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TEST_NAME); @@ -1074,7 +1056,6 @@ public void test152RecomputeUserAccountAndShadowNotFound() throws Exception { @Test public void test159DeleteUSerGuybrush() throws Exception { final String TEST_NAME = "test159DeleteUSerGuybrush"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TEST_NAME); @@ -1105,7 +1086,6 @@ public void test159DeleteUSerGuybrush() throws Exception { @Test public void test200StopOpenDj() throws Exception { final String TEST_NAME = "test200StopOpenDj"; - displayTestTitle(TEST_NAME); openDJController.stop(); assertEquals("Resource is running", false, EmbeddedUtils.isRunning()); @@ -1114,7 +1094,6 @@ public void test200StopOpenDj() throws Exception { @Test public void test210AddObjectCommunicationProblem() throws Exception { final String TEST_NAME = "test210AddObjectCommunicationProblem"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeStopped(); @@ -1171,7 +1150,6 @@ public void test210AddObjectCommunicationProblem() throws Exception { @Test public void test212AddModifyObjectCommunicationProblem() throws Exception { final String TEST_NAME = "test212AddModifyObjectCommunicationProblem"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeStopped(); @@ -1245,7 +1223,6 @@ private ItemPath createAttributePath(QName itemName) { @Test public void test214ModifyObjectCommunicationProblem() throws Exception { final String TEST_NAME = "test214ModifyObjectCommunicationProblem"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeStopped(); @@ -1309,7 +1286,6 @@ public void test214ModifyObjectCommunicationProblem() throws Exception { @Test public void test220DeleteObjectCommunicationProblem() throws Exception { final String TEST_NAME = "test220DeleteObjectCommunicationProblem"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeStopped(); @@ -1361,7 +1337,6 @@ public void test220DeleteObjectCommunicationProblem() throws Exception { @Test public void test230GetAccountCommunicationProblem() throws Exception { final String TEST_NAME = "test230GetAccountCommunicationProblem"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeStopped(); @@ -1397,7 +1372,6 @@ public void test230GetAccountCommunicationProblem() throws Exception { @Test public void test240AddObjectCommunicationProblemAlreadyExists() throws Exception{ final String TEST_NAME = "test240AddObjectCommunicationProblemAlreadyExists"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeRunning(); @@ -1471,7 +1445,6 @@ public void test240AddObjectCommunicationProblemAlreadyExists() throws Exception @Test public void test250ModifyFocusCommunicationProblem() throws Exception { final String TEST_NAME = "test250ModifyFocusCommunicationProblem"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeStopped(); @@ -1555,7 +1528,6 @@ public void test250ModifyFocusCommunicationProblem() throws Exception { @Test public void test251ModifyFocusCommunicationProblemSecondTime() throws Exception { final String TEST_NAME = "test251ModifyFocusCommunicationProblemSecondTime"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeStopped(); @@ -1671,7 +1643,6 @@ public void test251ModifyFocusCommunicationProblemSecondTime() throws Exception @Test public void test260GetDiscoveryAddCommunicationProblem() throws Exception { final String TEST_NAME = "test260GetDiscoveryAddCommunicationProblem"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeStopped(); @@ -1738,7 +1709,6 @@ public void test260GetDiscoveryAddCommunicationProblem() throws Exception { @Test public void test262GetDiscoveryModifyCommunicationProblem() throws Exception { final String TEST_NAME = "test262GetDiscoveryModifyCommunicationProblem"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeRunning(); @@ -1831,7 +1801,6 @@ public void test262GetDiscoveryModifyCommunicationProblem() throws Exception { @Test public void test264GetDiscoveryModifyUserPasswordCommunicationProblem() throws Exception { final String TEST_NAME = "test264GetDiscoveryModifyUserPasswordCommunicationProblem"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeStopped(); @@ -1922,7 +1891,6 @@ public void test264GetDiscoveryModifyUserPasswordCommunicationProblem() throws E @Test public void test265ModifyUserPasswordCommunicationProblemRecon() throws Exception { final String TEST_NAME = "test265ModifyUserPasswordCommunicationProblemRecon"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeStopped(); @@ -1998,7 +1966,6 @@ public void test265ModifyUserPasswordCommunicationProblemRecon() throws Exceptio @Test public void test270ModifyDiscoveryAddCommunicationProblem() throws Exception { final String TEST_NAME = "test270ModifyDiscoveryAddCommunicationProblem"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeStopped(); @@ -2054,7 +2021,6 @@ public void test270ModifyDiscoveryAddCommunicationProblem() throws Exception { @Test public void test280ModifyObjectCommunicationProblemWeakMapping() throws Exception{ final String TEST_NAME = "test280ModifyObjectCommunicationProblemWeakMapping"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeRunning(); @@ -2104,7 +2070,6 @@ public void test280ModifyObjectCommunicationProblemWeakMapping() throws Exceptio @Test public void test282ModifyObjectCommunicationProblemWeakAndStrongMapping() throws Exception { final String TEST_NAME = "test282ModifyObjectCommunicationProblemWeakAndStrongMapping"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeRunning(); @@ -2172,7 +2137,6 @@ public void test282ModifyObjectCommunicationProblemWeakAndStrongMapping() throws @Test public void test283GetObjectNoFetchShadowAndRecompute() throws Exception { final String TEST_NAME = "test283GetObjectNoFetchShadowAndRecompute"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeRunning(); @@ -2212,7 +2176,6 @@ public void test283GetObjectNoFetchShadowAndRecompute() throws Exception { @Test public void test284ModifyObjectAssignToGroupCommunicationProblem() throws Exception { final String TEST_NAME = "test284ModifyObjectAssignToGroupCommunicationProblem"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(); OperationResult parentResult = new OperationResult(TEST_NAME); // GIVEN @@ -2286,7 +2249,6 @@ public void test284ModifyObjectAssignToGroupCommunicationProblem() throws Except @Test(enabled = false) public void test400GetDiscoveryAddCommunicationProblemAlreadyExists() throws Exception{ final String TEST_NAME = "test400GetDiscoveryAddCommunicationProblemAlreadyExists"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeStopped(); @@ -2332,7 +2294,6 @@ public void test400GetDiscoveryAddCommunicationProblemAlreadyExists() throws Exc @Test public void test500AddUserMorganWithAssignment() throws Exception { final String TEST_NAME = "test500AddUserMorganWithAssignment"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeRunning(); @@ -2379,7 +2340,6 @@ public void test500AddUserMorganWithAssignment() throws Exception { @Test public void test501AddUserChuckWithAssignment() throws Exception { final String TEST_NAME = "test501AddUserChuckWithAssignment"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeRunning(); @@ -2437,7 +2397,6 @@ public void test501AddUserChuckWithAssignment() throws Exception { @Test public void test502AssignAccountToHerman() throws Exception { final String TEST_NAME = "test502AssignAccountToHerman"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeRunning(); @@ -2498,7 +2457,6 @@ public void test502AssignAccountToHerman() throws Exception { @Test public void test510UnlinkAndUnassignAccountMorgan() throws Exception { final String TEST_NAME = "test510UnlinkAndUnassignAccountMorgan"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeRunning(); @@ -2569,7 +2527,6 @@ public void test510UnlinkAndUnassignAccountMorgan() throws Exception { @Test public void test511AssignAccountMorgan() throws Exception { final String TEST_NAME = "test511AssignAccountMorgan"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeRunning(); @@ -2644,7 +2601,6 @@ public void test511AssignAccountMorgan() throws Exception { @Test public void test600DeleteUserAlice() throws Exception { String TEST_NAME = "test600DeleteUserAlice"; - displayTestTitle(TEST_NAME); openDJController.assumeRunning(); Task task = taskManager.createTaskInstance(TEST_NAME); @@ -2668,7 +2624,6 @@ public void test600DeleteUserAlice() throws Exception { @Test public void test601GetDiscoveryModifyCommunicationProblemDirectAccount() throws Exception { String TEST_NAME = "test601GetDiscoveryModifyCommunicationProblemDirectAccount"; - displayTestTitle(TEST_NAME); openDJController.assumeRunning(); OperationResult parentResult = new OperationResult(TEST_NAME); @@ -2724,7 +2679,6 @@ public void test601GetDiscoveryModifyCommunicationProblemDirectAccount() throws @Test//(enabled = false) public void test800Reconciliation() throws Exception { final String TEST_NAME = "test800Reconciliation"; - displayTestTitle(TEST_NAME); openDJController.assumeRunning(); @@ -2822,7 +2776,6 @@ public void test800Reconciliation() throws Exception { @Test//(enabled = false) public void test801TestReconciliationRename() throws Exception { final String TEST_NAME = "test801TestReconciliationRename"; - displayTestTitle(TEST_NAME); openDJController.assumeRunning(); Task task = createTask(TEST_NAME); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelayedEnable.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelayedEnable.java index 67794beef45..268ba5642d0 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelayedEnable.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelayedEnable.java @@ -31,6 +31,7 @@ import com.evolveum.midpoint.schema.internals.InternalCounters; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.asserter.UserAsserter; import com.evolveum.midpoint.test.util.MidPointTestConstants; @@ -110,7 +111,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100AddUserMancomb() throws Exception { final String TEST_NAME = "test100AddUserMancomb"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -141,7 +141,6 @@ public void test100AddUserMancomb() throws Exception { @Test public void test102UserMancombTriggerScannerAgain() throws Exception { final String TEST_NAME = "test102UserMancombTriggerScannerAgain"; - displayTestTitle(TEST_NAME); displayCurrentTime(); // WHEN @@ -164,7 +163,6 @@ public void test102UserMancombTriggerScannerAgain() throws Exception { @Test public void test104UserMancombRecompute() throws Exception { final String TEST_NAME = "test104UserMancombRecompute"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -209,7 +207,6 @@ private void assertMancombCreated() throws Exception { @Test public void test110UserMancombRunTriggerScannerDay1() throws Exception { final String TEST_NAME = "test110UserMancombRunTriggerScannerDay1"; - displayTestTitle(TEST_NAME); clockForward("P1D"); @@ -233,7 +230,6 @@ public void test110UserMancombRunTriggerScannerDay1() throws Exception { @Test public void test112UserMancombRecomputeDay1() throws Exception { final String TEST_NAME = "test112UserMancombRecomputeDay1"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -273,7 +269,6 @@ private void assertMancombEnabled() throws Exception { @Test public void test114UserMancombRunTriggerScannerDay1Again() throws Exception { final String TEST_NAME = "test114UserMancombRunTriggerScannerDay1Again"; - displayTestTitle(TEST_NAME); // WHEN displayWhen(TEST_NAME); @@ -294,7 +289,6 @@ public void test114UserMancombRunTriggerScannerDay1Again() throws Exception { @Test public void test116UserMancombRecomputeDay1Again() throws Exception { final String TEST_NAME = "test116UserMancombRecomputeDay1Again"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -320,7 +314,6 @@ public void test116UserMancombRecomputeDay1Again() throws Exception { @Test public void test120UserMancombHrDisable() throws Exception { final String TEST_NAME = "test120UserMancombHrDisable"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -362,7 +355,6 @@ private void assertMancombHalfDisabled() throws Exception { @Test public void test122UserMancombRecompute() throws Exception { final String TEST_NAME = "test122UserMancombRecompute"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -384,7 +376,6 @@ public void test122UserMancombRecompute() throws Exception { @Test public void test124UserMancombDay1TriggerScanner() throws Exception { final String TEST_NAME = "test124UserMancombDay1TriggerScanner"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -410,7 +401,6 @@ public void test124UserMancombDay1TriggerScanner() throws Exception { @Test public void test130UserMancombTriggerScannerDay2() throws Exception { final String TEST_NAME = "test130UserMancombTriggerScannerDay2"; - displayTestTitle(TEST_NAME); clockForward("P1D"); @@ -451,7 +441,6 @@ private void assertMancombDisabled() throws Exception { @Test public void test132UserMancombRecomputeDay2() throws Exception { final String TEST_NAME = "test132UserMancombRecomputeDay2"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -473,7 +462,6 @@ public void test132UserMancombRecomputeDay2() throws Exception { @Test public void test132UserMancombRecomputeDay2Again() throws Exception { final String TEST_NAME = "test132UserMancombRecomputeDay2Again"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -499,7 +487,6 @@ public void test132UserMancombRecomputeDay2Again() throws Exception { @Test public void test140UserMancombRecomputeDay3() throws Exception { final String TEST_NAME = "test140UserMancombRecomputeDay3"; - displayTestTitle(TEST_NAME); clockForward("P1D"); @@ -546,7 +533,6 @@ public void test200HrLivesyncTask() throws Exception { @Test public void test210HrAddUserGuybrush() throws Exception { final String TEST_NAME = "test210HrAddUserGuybrush"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -580,7 +566,6 @@ public void test210HrAddUserGuybrush() throws Exception { @Test public void test212HrUserGuybrushSyncAgain() throws Exception { final String TEST_NAME = "test212HrUserGuybrushSyncAgain"; - displayTestTitle(TEST_NAME); clockForward("PT1H"); @@ -604,7 +589,6 @@ public void test212HrUserGuybrushSyncAgain() throws Exception { @Test public void test214HrUserGuybrushRunTriggers() throws Exception { final String TEST_NAME = "test214HrUserGuybrushRunTriggers"; - displayTestTitle(TEST_NAME); clockForward("PT1H"); @@ -628,7 +612,6 @@ public void test214HrUserGuybrushRunTriggers() throws Exception { @Test public void test216HrUserGuybrushRecompute() throws Exception { final String TEST_NAME = "test216HrUserGuybrushRecompute"; - displayTestTitle(TEST_NAME); clockForward("PT1H"); @@ -652,7 +635,6 @@ public void test216HrUserGuybrushRecompute() throws Exception { @Test public void test218HrUserGuybrushReconcile() throws Exception { final String TEST_NAME = "test218HrUserGuybrushReconcile"; - displayTestTitle(TEST_NAME); clockForward("PT1H"); @@ -695,7 +677,6 @@ private UserAsserter assertGuybrushCreated(UserAsserter userAsserter @Test public void test220HrUserGuybrushDay1() throws Exception { final String TEST_NAME = "test220HrUserGuybrushDay1"; - displayTestTitle(TEST_NAME); clockForward("P1D"); @@ -715,7 +696,6 @@ public void test220HrUserGuybrushDay1() throws Exception { @Test public void test222HrUserGuybrushDay1SyncAgain() throws Exception { final String TEST_NAME = "test222HrUserGuybrushDay1SyncAgain"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -737,7 +717,6 @@ public void test222HrUserGuybrushDay1SyncAgain() throws Exception { @Test public void test224HrUserGuybrushDay1TriggerScanAgain() throws Exception { final String TEST_NAME = "test224HrUserGuybrushDay1TriggerScanAgain"; - displayTestTitle(TEST_NAME); clockForward("PT1H"); @@ -761,7 +740,6 @@ public void test224HrUserGuybrushDay1TriggerScanAgain() throws Exception { @Test public void test226HrUserGuybrushDay1Recompute() throws Exception { final String TEST_NAME = "test226HrUserGuybrushDay1Recompute"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -783,7 +761,6 @@ public void test226HrUserGuybrushDay1Recompute() throws Exception { @Test public void test228HrUserGuybrushDay1Reconcile() throws Exception { final String TEST_NAME = "test228HrUserGuybrushDay1Reconcile"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -820,7 +797,6 @@ private void assertGuybrushEnabled() throws Exception { @Test public void test230HrDisableGuybrush() throws Exception { final String TEST_NAME = "test230HrDisableGuybrush"; - displayTestTitle(TEST_NAME); getDummyResourceHr() .getAccountByUsername(ACCOUNT_GUYBRUSH_USERNAME) @@ -846,7 +822,6 @@ public void test230HrDisableGuybrush() throws Exception { @Test public void test232GuybrushHrSyncAgain() throws Exception { final String TEST_NAME = "test232GuybrushHrSyncAgain"; - displayTestTitle(TEST_NAME); // WHEN displayWhen(TEST_NAME); @@ -864,7 +839,6 @@ public void test232GuybrushHrSyncAgain() throws Exception { @Test public void test234GuybrushRecompute() throws Exception { final String TEST_NAME = "test232GuybrushHrSyncAgain"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -886,7 +860,6 @@ public void test234GuybrushRecompute() throws Exception { @Test public void test236GuybrushReconcile() throws Exception { final String TEST_NAME = "test236GuybrushReconcile"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -908,7 +881,6 @@ public void test236GuybrushReconcile() throws Exception { @Test public void test238GuybrushrunTriggersAgain() throws Exception { final String TEST_NAME = "test238GuybrushrunTriggersAgain"; - displayTestTitle(TEST_NAME); clockForward("PT1H"); @@ -945,7 +917,6 @@ private void assertGuybrushHalfDisabled() throws Exception { @Test public void test240HrUserGuybrushDay2() throws Exception { final String TEST_NAME = "test240HrUserGuybrushDay2"; - displayTestTitle(TEST_NAME); clockForward("P1D"); @@ -965,7 +936,6 @@ public void test240HrUserGuybrushDay2() throws Exception { @Test public void test242GuybrushRecompute() throws Exception { final String TEST_NAME = "test242GuybrushRecompute"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -987,7 +957,6 @@ public void test242GuybrushRecompute() throws Exception { @Test public void test244GuybrushHrSyncAgain() throws Exception { final String TEST_NAME = "test244GuybrushHrSyncAgain"; - displayTestTitle(TEST_NAME); // WHEN displayWhen(TEST_NAME); @@ -1005,7 +974,6 @@ public void test244GuybrushHrSyncAgain() throws Exception { @Test public void test246GuybrushReconcile() throws Exception { final String TEST_NAME = "test246GuybrushReconcile"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestEntertainment.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestEntertainment.java index eec90b77070..ce008f700cc 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestEntertainment.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestEntertainment.java @@ -88,7 +88,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestEntertainment.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -110,7 +109,6 @@ public void test000Sanity() throws Exception { @Test public void test001AddParentOrg() throws Exception { final String TEST_NAME = "test001AddParentOrg"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestEntertainment.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -142,7 +140,6 @@ public void test001AddParentOrg() throws Exception { @Test public void test002AddChildOrg() throws Exception { final String TEST_NAME = "test002AddChildOrg"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestEntertainment.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestExistentialIssues.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestExistentialIssues.java index ce10d295b7c..a3443858ae4 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestExistentialIssues.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestExistentialIssues.java @@ -60,7 +60,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100DisableUserDescartes() throws Exception { final String TEST_NAME = "test100DisableUserDescartes"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -89,7 +88,6 @@ public void test100DisableUserDescartes() throws Exception { @Test public void test110DescartesAssignLazyAccount() throws Exception { final String TEST_NAME = "test110DescartesAssignLazyAccount"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -118,7 +116,6 @@ public void test110DescartesAssignLazyAccount() throws Exception { @Test public void test112EnableDescartes() throws Exception { final String TEST_NAME = "test112EnableDescartes"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -147,7 +144,6 @@ public void test112EnableDescartes() throws Exception { @Test public void test114DisableDescartes() throws Exception { final String TEST_NAME = "test112EnableDescartes"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -176,7 +172,6 @@ public void test114DisableDescartes() throws Exception { @Test public void test116ReenableDescartes() throws Exception { final String TEST_NAME = "test116ReenableDescartes"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -205,7 +200,6 @@ public void test116ReenableDescartes() throws Exception { @Test public void test120DescartesUnassignLazyAccount() throws Exception { final String TEST_NAME = "test120DescartesUnassignLazyAccount"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -234,7 +228,6 @@ public void test120DescartesUnassignLazyAccount() throws Exception { @Test public void test129DeleteDescartes() throws Exception { final String TEST_NAME = "test129DeleteDescartes"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestImportGroups.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestImportGroups.java index 942a8b397c4..261e7d291ac 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestImportGroups.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestImportGroups.java @@ -12,6 +12,7 @@ import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; @@ -74,7 +75,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test001importGroups() throws Exception { String TEST_NAME = "test001importGroups"; - displayTestTitle(TEST_NAME); addObject(TASK_IMPORT_GROUPS); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInboundOutboundAssociation.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInboundOutboundAssociation.java index dacd8aa2bf1..d5c19739e01 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInboundOutboundAssociation.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInboundOutboundAssociation.java @@ -7,7 +7,6 @@ package com.evolveum.midpoint.testing.story; import java.io.File; -import java.util.Collection; import java.util.function.Consumer; import javax.xml.namespace.QName; @@ -24,7 +23,6 @@ import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.asserter.RoleAsserter; @@ -32,7 +30,6 @@ import com.evolveum.midpoint.util.exception.CommonException; import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType; import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAssociationType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; @@ -101,7 +98,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100ImportGroupPirates() throws Exception { final String TEST_NAME = "test100ImportGroupPirates"; - displayTestTitle(TEST_NAME); DummyGroup group = new DummyGroup(GROUP_PIRATES_NAME); getDummyResourceDir().addGroup(group); @@ -136,7 +132,6 @@ public void test100ImportGroupPirates() throws Exception { @Test public void test110AssignJackDirAccount() throws Exception { final String TEST_NAME = "test110AssignJackDirAccount"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -168,7 +163,6 @@ public void test110AssignJackDirAccount() throws Exception { @Test public void test115Stability() throws Exception { final String TEST_NAME = "test110AssignJackDirAccount"; - displayTestTitle(TEST_NAME); // WHEN displayWhen(TEST_NAME); @@ -193,7 +187,6 @@ public void test115Stability() throws Exception { @Test public void test120AddJackToGroupPirates() throws Exception { final String TEST_NAME = "test120AddJackToGroupPirates"; - displayTestTitle(TEST_NAME); getDummyResourceDir().getGroupByName(GROUP_PIRATES_NAME) .addMember(USER_JACK_USERNAME); @@ -230,7 +223,6 @@ public void test120AddJackToGroupPirates() throws Exception { @Test public void test130JackUnassignRolePirates() throws Exception { final String TEST_NAME = "test120AddJackToGroupPirates"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -260,7 +252,6 @@ public void test130JackUnassignRolePirates() throws Exception { @Test public void test140JackAssignRolePirates() throws Exception { final String TEST_NAME = "test140JackAssignRolePirates"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -298,7 +289,6 @@ public void test140JackAssignRolePirates() throws Exception { @Test public void test142JackUnAssignDirAccount() throws Exception { final String TEST_NAME = "test140JackAssignRolePirates"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -334,7 +324,6 @@ public void test142JackUnAssignDirAccount() throws Exception { @Test public void test149JackUnassignRolePirates() throws Exception { final String TEST_NAME = "test149JackUnassignRolePirates"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -362,7 +351,6 @@ public void test149JackUnassignRolePirates() throws Exception { @Test public void test150AssignJackDirAccount() throws Exception { final String TEST_NAME = "test150AssignJackDirAccount"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -391,7 +379,6 @@ public void test150AssignJackDirAccount() throws Exception { @Test public void test152JackAssignRolePirates() throws Exception { final String TEST_NAME = "test152JackAssignRolePirates"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -427,7 +414,6 @@ public void test152JackAssignRolePirates() throws Exception { @Test public void test153JackUnassignRolePiratesPreview() throws Exception { final String TEST_NAME = "test153JackUnassignRolePiratesPreview"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -476,7 +462,6 @@ public void test153JackUnassignRolePiratesPreview() throws Exception { @Test public void test154JackUnassignRolePirates() throws Exception { final String TEST_NAME = "test154JackUnassignRolePirates"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -509,7 +494,6 @@ public void test154JackUnassignRolePirates() throws Exception { @Test public void test159JackUnassignDirAccount() throws Exception { final String TEST_NAME = "test159JackUnassignDirAccount"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -540,7 +524,6 @@ public void test159JackUnassignDirAccount() throws Exception { @Test public void test200MancombAssignAccount() throws Exception { final String TEST_NAME = "test200MancombAssignAccount"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInducement.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInducement.java index 1a306e296c1..04306a69a77 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInducement.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInducement.java @@ -73,7 +73,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); //no resource, no extension definition //anything to check? @@ -86,7 +85,6 @@ public void test000Sanity() throws Exception { @Test public void test010InducementConditionsTrue() throws Exception { final String TEST_NAME = "test010InducementConditionsTrue"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -117,7 +115,6 @@ public void test010InducementConditionsTrue() throws Exception { @Test public void test020InducementRole2ConditionFalse() throws Exception { final String TEST_NAME = "test020InducementRole2ConditionFalse"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -149,7 +146,6 @@ public void test020InducementRole2ConditionFalse() throws Exception { @Test public void test030InducementRole3ConditionFalse() throws Exception { final String TEST_NAME = "test030InducementRole3ConditionFalse"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -180,7 +176,6 @@ public void test030InducementRole3ConditionFalse() throws Exception { @Test public void test040Recomputed() throws Exception { final String TEST_NAME = "test040Recomputed"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -210,7 +205,6 @@ public void test040Recomputed() throws Exception { @Test public void test050InducementRole3ConditionTrue() throws Exception { final String TEST_NAME = "test050InducementRole3ConditionTrue"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -240,7 +234,6 @@ public void test050InducementRole3ConditionTrue() throws Exception { @Test public void test060Recomputed() throws Exception { final String TEST_NAME = "test060Recomputed"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -267,7 +260,6 @@ public void test060Recomputed() throws Exception { @Test public void test070DeleteUser() throws Exception { final String TEST_NAME = "test070DeleteUser"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLimitedResources.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLimitedResources.java index a7db1ed7aed..892586130d0 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLimitedResources.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLimitedResources.java @@ -28,7 +28,6 @@ import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.AddRemoveAttributeValuesCapabilityType; import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.UpdateCapabilityType; /** @@ -69,7 +68,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -93,7 +91,6 @@ public void test000Sanity() throws Exception { @Test public void test100AssignJackAccountNoAttributeAddDelete() throws Exception { final String TEST_NAME = "test100AssignJackAccountNoAttributeAddDelete"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -116,7 +113,6 @@ public void test100AssignJackAccountNoAttributeAddDelete() throws Exception { @Test public void test102AddJackOrganizationalUnitTreasureHunt() throws Exception { final String TEST_NAME = "test102AddJackOrganizationalUnitTreasureHunt"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -140,7 +136,6 @@ public void test102AddJackOrganizationalUnitTreasureHunt() throws Exception { @Test public void test104AddJackOrganizationalUnitLootingSailing() throws Exception { final String TEST_NAME = "test104AddJackOrganizationalUnitLootingSailing"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -164,7 +159,6 @@ public void test104AddJackOrganizationalUnitLootingSailing() throws Exception { @Test public void test106DeleteJackOrganizationalUnitLooting() throws Exception { final String TEST_NAME = "test106DeleteJackOrganizationalUnitLooting"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -191,7 +185,6 @@ public void test106DeleteJackOrganizationalUnitLooting() throws Exception { @Test public void test108DeleteJackOrganizationalUnitTreasureHuntSailing() throws Exception { final String TEST_NAME = "test108DeleteJackOrganizationalUnitTreasureHuntSailing"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -215,7 +208,6 @@ public void test108DeleteJackOrganizationalUnitTreasureHuntSailing() throws Exce @Test public void test109UnassignJackAccountNoAttributeAddDelete() throws Exception { final String TEST_NAME = "test109UnassignJackAccountNoAttributeAddDelete"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -242,7 +234,6 @@ public void test109UnassignJackAccountNoAttributeAddDelete() throws Exception { @Test public void test110AssignJackAccountNoCreate() throws Exception { final String TEST_NAME = "test110AssignJackAccountNoCreate"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -266,7 +257,6 @@ public void test110AssignJackAccountNoCreate() throws Exception { @Test public void test119UnassignJackAccountNoCreate() throws Exception { final String TEST_NAME = "test119UnassignJackAccountNoCreate"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLiveSyncMadness.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLiveSyncMadness.java index f78e64521d4..0bca6e4c2be 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLiveSyncMadness.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLiveSyncMadness.java @@ -7,15 +7,13 @@ package com.evolveum.midpoint.testing.story; import com.evolveum.icf.dummy.resource.*; -import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; + import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; @@ -99,7 +97,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult testResultHr = modelService.testResource(RESOURCE_DUMMY_HR_OID, task); @@ -116,7 +113,6 @@ public void test000Sanity() throws Exception { @Test public void test100AddHrAccountHerman() throws Exception { final String TEST_NAME = "test100AddHrAccountHerman"; - displayTestTitle(TEST_NAME); dummyAuditService.clear(); @@ -156,7 +152,6 @@ public void test100AddHrAccountHerman() throws Exception { @Test public void test110RenameHrAccountHerman() throws Exception { final String TEST_NAME = "test110RenameHrAccountHerman"; - displayTestTitle(TEST_NAME); dummyAuditService.clear(); @@ -199,7 +194,6 @@ public void test110RenameHrAccountHerman() throws Exception { @Test public void test112HrAccountHermanEmptyDelta() throws Exception { final String TEST_NAME = "test112HrAccountHermanEmptyDelta"; - displayTestTitle(TEST_NAME); dummyAuditService.clear(); dummyResourceHr.recordEmptyDeltaForAccountByUsername(ACCOUNT_HERMAN_USERNAME, DummyDeltaType.MODIFY); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMachineIntelligence.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMachineIntelligence.java index 1351841a61a..8a28ebabba3 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMachineIntelligence.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMachineIntelligence.java @@ -105,7 +105,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); Object[] newRealValue = { sourceFilePath }; diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMapleLeaf.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMapleLeaf.java index d67f2119eca..7a21ebb6649 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMapleLeaf.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMapleLeaf.java @@ -135,7 +135,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestMapleLeaf.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -157,8 +156,6 @@ public void test000Sanity() throws Exception { @Test public void test001addUser() throws Exception { final String TEST_NAME = "test001addUser"; - displayTestTitle(TEST_NAME); - //when displayWhen(TEST_NAME); @@ -190,8 +187,6 @@ public void test001addUser() throws Exception { @Test public void test002assignRoleSquirrel() throws Exception { final String TEST_NAME = "test002assignRoleSquirrel"; - displayTestTitle(TEST_NAME); - //when displayWhen(TEST_NAME); @@ -223,7 +218,6 @@ public void test002assignRoleSquirrel() throws Exception { @Test public void test003unassignRoleSquirrel() throws Exception { final String TEST_NAME = "test003unassignRoleSquirrel"; - displayTestTitle(TEST_NAME); //when displayWhen(TEST_NAME); @@ -256,7 +250,6 @@ public void test003unassignRoleSquirrel() throws Exception { @Test public void test004assignRoleMapleLeafFaculty() throws Exception { final String TEST_NAME = "test004assignRoleMapleLeafFaculty"; - displayTestTitle(TEST_NAME); //when displayWhen(TEST_NAME); @@ -297,7 +290,6 @@ private boolean containRoleMemebrShip(List roleMemberships, @Test public void test005assignRoleMapleLeafGraduate() throws Exception { final String TEST_NAME = "test005assignRoleMapleLeafGraduate"; - displayTestTitle(TEST_NAME); //when displayWhen(TEST_NAME); @@ -330,7 +322,6 @@ public void test005assignRoleMapleLeafGraduate() throws Exception { @Test public void test006unassignRoleMapleLeafFaculty() throws Exception { final String TEST_NAME = "test006unassignRoleMapleLeafFaculty"; - displayTestTitle(TEST_NAME); //when displayWhen(TEST_NAME); @@ -363,7 +354,6 @@ public void test006unassignRoleMapleLeafFaculty() throws Exception { @Test public void test100changePasswordForceChange() throws Exception { final String TEST_NAME = "test100changePasswordForceChange"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -419,7 +409,6 @@ public void test100changePasswordForceChange() throws Exception { @Test public void test101resetPassword() throws Exception { final String TEST_NAME = "test101resetPassword"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -454,7 +443,6 @@ public void test101resetPassword() throws Exception { @Test public void test200setArchivedAdministrativeStatus() throws Exception { final String TEST_NAME = "test200setArchivedAdministrativeStatus"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -474,7 +462,6 @@ public void test200setArchivedAdministrativeStatus() throws Exception { @Test public void test201SetUndefinedAdministrativeStatus() throws Exception { final String TEST_NAME = "test201SetUndefinedAdministrativeStatus"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMappingMadness.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMappingMadness.java index 6a8a6f7f480..be62d1590ff 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMappingMadness.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMappingMadness.java @@ -83,7 +83,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100AssignJackDummyAccounts() throws Exception { final String TEST_NAME = "test100AssignJackDummyAccounts"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -113,7 +112,6 @@ public void test100AssignJackDummyAccounts() throws Exception { @Test public void test105ModifyJackTitleCaptain() throws Exception { final String TEST_NAME = "test105ModifyJackTitleCaptain"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -186,7 +184,6 @@ public void test105ModifyJackTitleCaptain() throws Exception { @Test public void test110ModifyJackTitleWhatever() throws Exception { final String TEST_NAME = "test110ModifyJackTitleWhatever"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -260,7 +257,6 @@ private void assertNoAttributes(DummyAccountAsserter asserter) { @Test public void test112ReconcileJackWhatever() throws Exception { final String TEST_NAME = "test112ReconcileJackWhatever"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -316,7 +312,6 @@ public void test112ReconcileJackWhatever() throws Exception { @Test public void test120MadJack() throws Exception { final String TEST_NAME = "test120MadJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -355,7 +350,6 @@ public void test120MadJack() throws Exception { @Test public void test130ModifyJackTitleWhateverLower() throws Exception { final String TEST_NAME = "test130ModifyJackTitleWhateverLower"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -386,7 +380,6 @@ public void test130ModifyJackTitleWhateverLower() throws Exception { @Test public void test140ModifyJackTitleEmpty() throws Exception { final String TEST_NAME = "test140ModifyJackTitleEmpty"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -422,7 +415,6 @@ public void test140ModifyJackTitleEmpty() throws Exception { @Test public void test199UnassignJackDummyAccount() throws Exception { final String TEST_NAME = "test199UnassignJackDummyAccount"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMisbehavingResources.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMisbehavingResources.java index c53e0f4a457..c537dfe4a6e 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMisbehavingResources.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMisbehavingResources.java @@ -23,6 +23,7 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; @@ -53,7 +54,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test010SanityAssignJackDummyAccount() throws Exception { final String TEST_NAME = "test010SanityAssignJackDummyAccount"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -74,7 +74,6 @@ public void test010SanityAssignJackDummyAccount() throws Exception { @Test public void test019SanityUnassignJackDummyAccount() throws Exception { final String TEST_NAME = "test010SanityAssignJackDummyAccount"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -97,7 +96,6 @@ public void test019SanityUnassignJackDummyAccount() throws Exception { @Test public void test100AssignJackDummyAccountTimeout() throws Exception { final String TEST_NAME = "test100AssignJackDummyAccountTimeout"; - displayTestTitle(TEST_NAME); getDummyResource().setOperationDelayOffset(3000); @@ -119,7 +117,6 @@ public void test100AssignJackDummyAccountTimeout() throws Exception { @Test public void test102AssignJackDummyAccounRetry() throws Exception { final String TEST_NAME = "test102AssignJackDummyAccounRetry"; - displayTestTitle(TEST_NAME); getDummyResource().setOperationDelayOffset(0); clockForward("P1D"); @@ -146,7 +143,6 @@ public void test102AssignJackDummyAccounRetry() throws Exception { @Test public void test110ModifyJackDummyAccountTimeout() throws Exception { final String TEST_NAME = "test110ModifyJackDummyAccountTimeout"; - displayTestTitle(TEST_NAME); getDummyResource().setOperationDelayOffset(3000); @@ -170,7 +166,6 @@ public void test110ModifyJackDummyAccountTimeout() throws Exception { @Test public void test112ModifyJackDummyAccounRetry() throws Exception { final String TEST_NAME = "test112ModifyJackDummyAccounRetry"; - displayTestTitle(TEST_NAME); getDummyResource().setOperationDelayOffset(0); clockForward("P1D"); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNormalizers.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNormalizers.java index 401bfe3ab76..6424a34503c 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNormalizers.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNormalizers.java @@ -78,7 +78,6 @@ protected File getSystemConfigurationFile() { @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); PolyStringNormalizer prismNormalizer = prismContext.getDefaultPolyStringNormalizer(); assertTrue("Wrong normalizer class, expected Ascii7PolyStringNormalizer, but was "+prismNormalizer.getClass(), @@ -88,7 +87,6 @@ public void test000Sanity() throws Exception { @Test public void test100AddUserJack() throws Exception { final String TEST_NAME = "test100AddUserJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -109,7 +107,6 @@ public void test100AddUserJack() throws Exception { @Test public void test110AddUserTeleke() throws Exception { final String TEST_NAME = "test110AddUserTeleke"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNullAttribute.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNullAttribute.java index efc6d3e0740..9c22a4b9d0d 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNullAttribute.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNullAttribute.java @@ -27,6 +27,7 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; @@ -124,7 +125,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestNullAttribute.class.getName() + "." + TEST_NAME); OperationResult testResult = modelService.testResource(RESOURCE_DUMMY_OID, task); @@ -146,7 +146,6 @@ public void test000Sanity() throws Exception { @Test public void test010UserSmackAssignAccountOnlyRole() throws Exception { final String TEST_NAME = "test010UserSmackAssignAccountOnlyRole"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -190,9 +189,8 @@ public void test010UserSmackAssignAccountOnlyRole() throws Exception { @Test public void test020UserSmackSetAttribute() throws Exception { final String TEST_NAME = "test020UserSmackSetAttribute"; - displayTestTitle(TEST_NAME); - // GIVEN + // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -244,9 +242,8 @@ public void test020UserSmackSetAttribute() throws Exception { @Test // MID-3325 public void test030UserSmackRemoveAttribute() throws Exception { final String TEST_NAME = "test030UserSmackRemoveAttribute"; - displayTestTitle(TEST_NAME); - // GIVEN + // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); dummyAuditService.clear(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationCounts.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationCounts.java index 9c07a80fc72..53121d402ba 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationCounts.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationCounts.java @@ -112,7 +112,6 @@ protected void importSystemTasks(OperationResult initResult) { @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestOperationCounts.class.getName() + "." + TEST_NAME); OperationResult testResultOne = modelService.testResource(RESOURCE_DUMMY_ONE_OID, task); @@ -126,7 +125,6 @@ public void test000Sanity() throws Exception { @Test public void test100AddAlice() throws Exception { final String TEST_NAME = "test100AddAlice"; - displayTestTitle(TEST_NAME); Task task = createTracedTask(TEST_NAME); OperationResult result = task.getResult(); @@ -174,7 +172,6 @@ public void test100AddAlice() throws Exception { @Test public void test110AddBob() throws Exception { final String TEST_NAME = "test110AddBob"; - displayTestTitle(TEST_NAME); Task task = createTracedTask(TEST_NAME); OperationResult result = task.getResult(); @@ -219,7 +216,6 @@ public void test110AddBob() throws Exception { @Test public void test120ModifyBob() throws Exception { final String TEST_NAME = "test120ModifyBob"; - displayTestTitle(TEST_NAME); Task task = createTracedTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationPerf.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationPerf.java index 795c70c1363..c9e04ab400d 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationPerf.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationPerf.java @@ -89,7 +89,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); assertObjects(RoleType.class, NUMBER_OF_GENERATED_EMPTY_ROLES + NUMBER_OF_ORDINARY_ROLES); @@ -110,7 +109,6 @@ public void test110AddBob() throws Exception { } public void testAddUser(final String TEST_NAME, File userFile, String userOid, int roles) throws Exception { - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOrgSync.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOrgSync.java index 532dee425f8..99444a9c62a 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOrgSync.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOrgSync.java @@ -41,6 +41,7 @@ import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.util.MidPointTestConstants; @@ -290,7 +291,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult testResultHr = modelService.testResource(RESOURCE_DUMMY_HR_OID, task); @@ -312,7 +312,6 @@ public void test000Sanity() throws Exception { @Test public void test100AddHrAccountHerman() throws Exception { final String TEST_NAME = "test100AddHrAccountHerman"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); DummyAccount newAccount = new DummyAccount(ACCOUNT_HERMAN_USERNAME); @@ -352,7 +351,6 @@ public void test100AddHrAccountHerman() throws Exception { @Test public void test105AddHrAccountLemonhead() throws Exception { final String TEST_NAME = "test105AddHrAccountLemonhead"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); DummyAccount newAccount = new DummyAccount(ACCOUNT_LEMONHEAD_USERNAME); @@ -397,7 +395,6 @@ public void test105AddHrAccountLemonhead() throws Exception { @Test public void test106AddHrAccountSharptooth() throws Exception { final String TEST_NAME = "test106AddHrAccountSharptooth"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); DummyAccount newAccount = new DummyAccount(ACCOUNT_SHARPTOOTH_USERNAME); @@ -441,7 +438,6 @@ public void test106AddHrAccountSharptooth() throws Exception { @Test public void test107AddHrAccountRedskull() throws Exception { final String TEST_NAME = "test107AddHrAccountRedskull"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); DummyAccount newAccount = new DummyAccount(ACCOUNT_REDSKULL_USERNAME); @@ -484,7 +480,6 @@ public void test107AddHrAccountRedskull() throws Exception { @Test public void test108RedskullGoesVegetarian() throws Exception { final String TEST_NAME = "test108RedskullGoesVegetarian"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); DummyAccount account = dummyResourceHr.getAccountByUsername(ACCOUNT_REDSKULL_USERNAME); @@ -525,7 +520,6 @@ public void test108RedskullGoesVegetarian() throws Exception { @Test public void test109HrDeleteRedskull() throws Exception { final String TEST_NAME = "test109HrDeleteRedskull"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); // WHEN @@ -555,7 +549,6 @@ public void test109HrDeleteRedskull() throws Exception { @Test public void test110AddHrAccountGuybrush() throws Exception { final String TEST_NAME = "test110AddHrAccountGuybrush"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); DummyAccount newAccount = new DummyAccount(ACCOUNT_GUYBRUSH_USERNAME); @@ -601,7 +594,6 @@ public void test110AddHrAccountGuybrush() throws Exception { @Test public void test115AddHrAccountMancomb() throws Exception { final String TEST_NAME = "test115AddHrAccountMancomb"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); DummyAccount newAccount = new DummyAccount(ACCOUNT_MANCOMB_USERNAME); @@ -648,7 +640,6 @@ public void test115AddHrAccountMancomb() throws Exception { @Test public void test117AddHrAccountCobb() throws Exception { final String TEST_NAME = "test117AddHrAccountCobb"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); DummyAccount newAccount = new DummyAccount(ACCOUNT_COBB_USERNAME); @@ -695,7 +686,6 @@ public void test117AddHrAccountCobb() throws Exception { @Test public void test130AddHrAccountLargo() throws Exception { final String TEST_NAME = "test130AddHrAccountLargo"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); DummyAccount newAccount = new DummyAccount(ACCOUNT_LARGO_USERNAME); @@ -748,7 +738,6 @@ public void test130AddHrAccountLargo() throws Exception { @Test public void test140AddHrAccountWally() throws Exception { final String TEST_NAME = "test140AddHrAccountWally"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); DummyAccount newAccount = new DummyAccount(ACCOUNT_WALLY_USERNAME); @@ -792,7 +781,6 @@ public void test140AddHrAccountWally() throws Exception { @Test public void test142AddHrAccountAugustus() throws Exception { final String TEST_NAME = "test142AddHrAccountAugustus"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); DummyAccount newAccount = new DummyAccount(ACCOUNT_AUGUSTUS_USERNAME); @@ -836,7 +824,6 @@ public void test142AddHrAccountAugustus() throws Exception { @Test public void test185AddHrAccountStan() throws Exception { final String TEST_NAME = "test185AddHrAccountStan"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); DummyAccount newAccount = new DummyAccount(ACCOUNT_STAN_USERNAME); @@ -882,7 +869,6 @@ public void test185AddHrAccountStan() throws Exception { @Test public void test186AddHrAccountCapsize() throws Exception { final String TEST_NAME = "test186AddHrAccountCapsize"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); DummyAccount newAccount = new DummyAccount(ACCOUNT_CAPSIZE_USERNAME); @@ -928,7 +914,6 @@ public void test186AddHrAccountCapsize() throws Exception { @Test public void test187AddHrAccountRogersSr() throws Exception { final String TEST_NAME = "test187AddHrAccountRogersSr"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); DummyAccount newAccount = new DummyAccount(ACCOUNT_ROGERSSR_USERNAME); @@ -975,7 +960,6 @@ public void test187AddHrAccountRogersSr() throws Exception { @Test public void test190AddHrAccountTeleke() throws Exception { final String TEST_NAME = "test190AddHrAccountTeleke"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); DummyAccount newAccount = new DummyAccount(ACCOUNT_TELEKE_USERNAME); @@ -1018,7 +1002,6 @@ public void test190AddHrAccountTeleke() throws Exception { @Test public void test500ReconcileOpenDJDefault() throws Exception { final String TEST_NAME = "test500ReconcileOpenDJDefault"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1063,7 +1046,6 @@ public void test500ReconcileOpenDJDefault() throws Exception { @Test public void test502ReconcileOpenDJDefaultAgain() throws Exception { final String TEST_NAME = "test502ReconcileOpenDJDefaultAgain"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1100,7 +1082,6 @@ public void test502ReconcileOpenDJDefaultAgain() throws Exception { @Test public void test510ReconcileOpenDJLdapGroup() throws Exception { final String TEST_NAME = "test510ReconcileOpenDJLdapGroup"; - displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); @@ -1144,7 +1125,6 @@ public void test510ReconcileOpenDJLdapGroup() throws Exception { @Test public void test550ReconcileOpenDJAfterMembershipChange() throws Exception { final String TEST_NAME = "test550ReconcileOpenDJAfterMembershipChange"; - displayTestTitle(TEST_NAME); // We manually remove Lemonhead from R_canibalism group // And check whether reconciliation re-adds him again diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestPlentyOfAssignments.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestPlentyOfAssignments.java index 433e4582bc0..a68fee231b8 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestPlentyOfAssignments.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestPlentyOfAssignments.java @@ -43,6 +43,7 @@ import com.evolveum.midpoint.schema.util.ObjectTypeUtil; import com.evolveum.midpoint.schema.util.ShadowUtil; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.util.MidPointTestConstants; @@ -163,7 +164,6 @@ private String formatGroupName(int num) { @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); assertObjects(RoleType.class, NUMBER_OF_GENERATED_EMPTY_ROLES + NUMBER_OF_GENERATED_DUMMY_ROLES + NUMBER_OF_ORDINARY_ROLES); @@ -174,7 +174,6 @@ public void test000Sanity() throws Exception { @Test public void test100AddCheese() throws Exception { final String TEST_NAME = "test100AddCheese"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -218,7 +217,6 @@ public void test100AddCheese() throws Exception { @Test public void test110RecomputeCheese() throws Exception { final String TEST_NAME = "test110RecomputeCheese"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -260,7 +258,6 @@ public void test110RecomputeCheese() throws Exception { @Test public void test120CheesePreviewChanges() throws Exception { final String TEST_NAME = "test120CheesePreviewChanges"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -329,7 +326,6 @@ private void assertCheeseRoleMembershipRef(PrismObject cheese) { @Test public void test200DummyGroups() throws Exception { final String TEST_NAME = "test200DummyGroups"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -404,7 +400,6 @@ public void test200DummyGroups() throws Exception { @Test public void test210AddBob() throws Exception { final String TEST_NAME = "test210AddBob"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -453,7 +448,6 @@ public void test210AddBob() throws Exception { @Test public void test212RecomputeBob() throws Exception { final String TEST_NAME = "test212RecomputeBob"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -498,7 +492,6 @@ public void test212RecomputeBob() throws Exception { @Test public void test2124ReconcileBob() throws Exception { final String TEST_NAME = "test212RecomputeBob"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -561,7 +554,6 @@ private void assertBobDummy(int expectedBottlesOfRum) throws Exception { @Test public void test220AddAlice() throws Exception { final String TEST_NAME = "test220AddAlice"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -612,7 +604,6 @@ public void test220AddAlice() throws Exception { @Test public void test222RecomputeAlice() throws Exception { final String TEST_NAME = "test222RecomputeAlice"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -657,7 +648,6 @@ public void test222RecomputeAlice() throws Exception { @Test public void test224ReconcileAlice() throws Exception { final String TEST_NAME = "test224ReconcileAlice"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestReconNullValue.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestReconNullValue.java index 05ec44dc24a..835bc71809e 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestReconNullValue.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestReconNullValue.java @@ -33,6 +33,7 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.CommunicationException; @@ -182,9 +183,8 @@ public void test100CreateUsers() throws Exception { @Test public void test130AddHonorificPrefix() throws Exception { final String TEST_NAME = "test140AddHonorificPrefix"; - displayTestTitle(TEST_NAME); - // GIVEN + // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -239,9 +239,8 @@ public void test130AddHonorificPrefix() throws Exception { @Test public void test140dDeleteHonorificPrefixGivenName() throws Exception { final String TEST_NAME = "test140dDeleteHonorificPrefixGivenName"; - displayTestTitle(TEST_NAME); - // GIVEN + // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -299,9 +298,8 @@ public void test140dDeleteHonorificPrefixGivenName() throws Exception { @Test public void test150RemoveTitleRA() throws Exception { final String TEST_NAME = "test150RemoveTitleRA"; - displayTestTitle(TEST_NAME); - // GIVEN + // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -359,9 +357,8 @@ public void test150RemoveTitleRA() throws Exception { @Test //MID-4567 public void test160SetGivenNameAttributeAndReconcile() throws Exception { final String TEST_NAME = "test160SetGivenNameAttributeAndReconcile"; - displayTestTitle(TEST_NAME); - // GIVEN + // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -415,9 +412,8 @@ public void test160SetGivenNameAttributeAndReconcile() throws Exception { @Test //MID-4567 public void test170ReplaceGivenNameEmpty() throws Exception { final String TEST_NAME = "test170ReplaceGivenNameEmpty"; - displayTestTitle(TEST_NAME); - // GIVEN + // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); dummyAuditService.clear(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestScience.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestScience.java index 036e6fb305d..72251dc6857 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestScience.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestScience.java @@ -31,6 +31,7 @@ import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.MiscUtil; @@ -153,7 +154,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult testResultStats = modelService.testResource(RESOURCE_DUMMY_STATS_OID, task); @@ -172,7 +172,6 @@ public void test000Sanity() throws Exception { @Test public void test100JackAssignRoleStatistics() throws Exception { final String TEST_NAME = "test100JackAssignRoleStatistics"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -221,7 +220,6 @@ public void test100JackAssignRoleStatistics() throws Exception { @Test public void test101UnassignRoleStats() throws Exception{ final String TEST_NAME = "test101UnassignRoleStats"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -273,7 +271,6 @@ public void test101UnassignRoleStats() throws Exception{ @Test public void test102AssignRoleStats() throws Exception{ final String TEST_NAME = "test102AssignRoleStats"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -321,7 +318,6 @@ public void test102AssignRoleStats() throws Exception{ @Test public void test200DelteUserJack() throws Exception { final String TEST_NAME = "test200DelteUserJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccounts.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccounts.java index 592e1d0dfeb..2662abd9bb9 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccounts.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccounts.java @@ -84,7 +84,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100StartSyncTask() throws Exception { final String TEST_NAME = "test100StartSyncTask"; - displayTestTitle(TEST_NAME); assertUsers(getNumberOfUsers()); assertServices(0); @@ -106,7 +105,6 @@ public void test100StartSyncTask() throws Exception { @Test public void test101AddServiceAccountSync() throws Exception { final String TEST_NAME = "test101AddServiceAccountSync"; - displayTestTitle(TEST_NAME); // Preconditions assertServices(0); @@ -150,7 +148,6 @@ public void test101AddServiceAccountSync() throws Exception { @Test public void test102ModifyServiceAccount() throws Exception { final String TEST_NAME = "test102ModifyServiceAccount"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -199,7 +196,6 @@ serviceAccountShadowOid, getDummyResourceController().getAttributeFullnamePath() @Test public void test104DeleteServiceAccount() throws Exception { final String TEST_NAME = "test104DeleteServiceAccount"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -247,7 +243,6 @@ public void test104DeleteServiceAccount() throws Exception { @Test public void test108DeleteServiceAccountSync() throws Exception { final String TEST_NAME = "test108DeleteServiceAccountSync"; - displayTestTitle(TEST_NAME); // Preconditions assertServices(1); @@ -269,7 +264,6 @@ public void test108DeleteServiceAccountSync() throws Exception { @Test public void test109StopLivesyncTask() throws Exception { final String TEST_NAME = "test109StopLivesyncTask"; - displayTestTitle(TEST_NAME); // Preconditions assertServices(0); @@ -287,7 +281,6 @@ public void test109StopLivesyncTask() throws Exception { @Test public void test120StartReconTask() throws Exception { final String TEST_NAME = "test120StartReconTask"; - displayTestTitle(TEST_NAME); assertUsers(getNumberOfUsers()); assertServices(0); @@ -309,7 +302,6 @@ public void test120StartReconTask() throws Exception { @Test public void test121AddServiceAccountRecon() throws Exception { final String TEST_NAME = "test121AddServiceAccountRecon"; - displayTestTitle(TEST_NAME); // Preconditions assertServices(0); @@ -341,7 +333,6 @@ public void test121AddServiceAccountRecon() throws Exception { @Test public void test128DeleteServiceAccountRecon() throws Exception { final String TEST_NAME = "test128DeleteServiceAccountRecon"; - displayTestTitle(TEST_NAME); // Preconditions assertServices(1); @@ -362,7 +353,6 @@ public void test128DeleteServiceAccountRecon() throws Exception { public void test129StopReconTask() throws Exception { final String TEST_NAME = "test129StopReconTask"; - displayTestTitle(TEST_NAME); // Preconditions assertServices(1); @@ -385,7 +375,6 @@ public void test129StopReconTask() throws Exception { @Test public void test140CreateServiceAccount() throws Exception { final String TEST_NAME = "test140CreateServiceAccount"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccountsClassifier.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccountsClassifier.java index d2fb657fe0d..0c02a83d75d 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccountsClassifier.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccountsClassifier.java @@ -26,6 +26,7 @@ import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.asserter.ShadowAsserter; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.xml.ns._public.common.common_3.ServiceType; @@ -79,7 +80,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test001assigneJackEmployeeRole() throws Exception { final String TEST_NAME = "test001assigneJackEmployeeRole"; - displayTestTitle(TEST_NAME); //WHEN displayWhen(TEST_NAME); @@ -95,7 +95,6 @@ public void test001assigneJackEmployeeRole() throws Exception { @Test public void test100createServiceJira() throws Exception { final String TEST_NAME = "test100createServiceJira"; - displayTestTitle(TEST_NAME); //WHEN addObject(SERVICE_JIRA_FILE); @@ -112,7 +111,6 @@ public void test100createServiceJira() throws Exception { @Test public void test101jiraAssignResourceNoneEnforcement() throws Exception { final String TEST_NAME = "test101jiraAssignResourceNoneEnforcement"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -135,7 +133,6 @@ public void test101jiraAssignResourceNoneEnforcement() throws Exception { @Test public void test150StartReconTask() throws Exception { final String TEST_NAME = "test150StartReconTask"; - displayTestTitle(TEST_NAME); assertUsers(getNumberOfUsers()); assertServices(1); @@ -157,7 +154,6 @@ public void test150StartReconTask() throws Exception { @Test public void test151LinkServiceAccountRecon() throws Exception { final String TEST_NAME = "test151LinkServiceAccountRecon"; - displayTestTitle(TEST_NAME); // Preconditions assertServices(1); @@ -187,7 +183,6 @@ public void test151LinkServiceAccountRecon() throws Exception { @Test public void test152InactivateUnmatchedAccountRecon() throws Exception { final String TEST_NAME = "test152InactivateUnmatchedAccountRecon"; - displayTestTitle(TEST_NAME); // Preconditions assertServices(1); @@ -214,7 +209,6 @@ public void test152InactivateUnmatchedAccountRecon() throws Exception { @Test public void test200createServiceGithub() throws Exception { final String TEST_NAME = "test200createServiceGithub"; - displayTestTitle(TEST_NAME); //WHEN addObject(SERVICE_GITHUB_FILE); @@ -231,7 +225,6 @@ public void test200createServiceGithub() throws Exception { @Test public void test210createAccountGithub() throws Exception { final String TEST_NAME = "test210createAccountGithub"; - displayTestTitle(TEST_NAME); //WHEN displayWhen(TEST_NAME); @@ -251,7 +244,6 @@ public void test210createAccountGithub() throws Exception { @Test public void test215githubAssignResourceNoneEnforcement() throws Exception { final String TEST_NAME = "test101jiraAssignResourceNoneEnforcement"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -274,7 +266,6 @@ public void test215githubAssignResourceNoneEnforcement() throws Exception { @Test public void test220linkAccountGithubAndFixIntent() throws Exception { final String TEST_NAME = "test220linkAccountGithubAndFixIntent"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestShadowsPerformance.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestShadowsPerformance.java index abcfadeeb85..e5328d535a2 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestShadowsPerformance.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestShadowsPerformance.java @@ -24,6 +24,7 @@ import com.evolveum.midpoint.schema.internals.InternalsConfig; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyAuditService; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.util.MidPointTestConstants; @@ -98,7 +99,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test010Sanity() throws Exception { final String TEST_NAME = "test010Sanity"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); @@ -115,7 +115,6 @@ public void test010Sanity() throws Exception { @Test public void test100ImportAccounts() throws Exception { final String TEST_NAME = "test100ImportAccounts"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -147,7 +146,6 @@ public void test100ImportAccounts() throws Exception { @Test(enabled = false) public void test200DeleteAccountsAndReconcile() throws Exception { final String TEST_NAME = "test200DeleteAccountsAndReconcile"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -178,7 +176,6 @@ public void test200DeleteAccountsAndReconcile() throws Exception { @Test public void test210DeleteShadows() throws Exception { final String TEST_NAME = "test210DeleteShadows"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -209,7 +206,6 @@ public void test210DeleteShadows() throws Exception { @Test public void test900Summarize() { final String TEST_NAME = "test900Summarize"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestStrings.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestStrings.java index 1591059f9c6..b14c46bc4d6 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestStrings.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestStrings.java @@ -197,7 +197,6 @@ protected PrismObject getDefaultActor() { @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); // TODO @@ -207,7 +206,6 @@ public void test000Sanity() throws Exception { @Test public void test100SimpleAssignmentStart() throws Exception { final String TEST_NAME = "test100SimpleAssignmentStart"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -273,7 +271,6 @@ public void test100SimpleAssignmentStart() throws Exception { @Test public void test102SimpleAssignmentApproveByLechuck() throws Exception { final String TEST_NAME = "test102SimpleAssignmentApproveByLechuck"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -362,7 +359,6 @@ public void test102SimpleAssignmentApproveByLechuck() throws Exception { @Test public void test104SimpleAssignmentApproveByAdministrator() throws Exception { final String TEST_NAME = "test104SimpleAssignmentApproveByAdministrator"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -443,7 +439,6 @@ public void test104SimpleAssignmentApproveByAdministrator() throws Exception { @Test public void test106SimpleAssignmentApproveByCheese() throws Exception { final String TEST_NAME = "test106SimpleAssignmentApproveByCheese"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -502,7 +497,6 @@ public void test106SimpleAssignmentApproveByCheese() throws Exception { @Test public void test108SimpleAssignmentApproveByChef() throws Exception { final String TEST_NAME = "test108SimpleAssignmentApproveByChef"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -580,7 +574,6 @@ public void test108SimpleAssignmentApproveByChef() throws Exception { @Test public void test200EscalatedApprovalStart() throws Exception { final String TEST_NAME = "test200EscalatedApprovalStart"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -628,7 +621,6 @@ public void test200EscalatedApprovalStart() throws Exception { @Test public void test202FourDaysLater() throws Exception { final String TEST_NAME = "test202FourDaysLater"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -661,7 +653,6 @@ public void test202FourDaysLater() throws Exception { @Test public void test204SixDaysLater() throws Exception { final String TEST_NAME = "test204SixDaysLater"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -729,7 +720,6 @@ public void test204SixDaysLater() throws Exception { @Test public void test205EightDaysLater() throws Exception { final String TEST_NAME = "test205EightDaysLater"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -781,7 +771,6 @@ public void test205EightDaysLater() throws Exception { @Test public void test206ApproveByCheese() throws Exception { final String TEST_NAME = "test206ApproveByCheese"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -875,7 +864,6 @@ public void test206ApproveByCheese() throws Exception { @Test public void test208SixDaysLater() throws Exception { final String TEST_NAME = "test208SixDaysLater"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -917,7 +905,6 @@ public void test208SixDaysLater() throws Exception { @Test public void test209EightDaysLater() throws Exception { final String TEST_NAME = "test209EightDaysLater"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -974,7 +961,6 @@ private void checkTwoCompleted(List lifecycleMessages) { @Test public void test220FormRoleAssignmentStart() throws Exception { final String TEST_NAME = "test220FormRoleAssignmentStart"; - displayTestTitle(TEST_NAME); PrismObject bob = getUserFromRepo(userBobOid); login(bob); @@ -1019,7 +1005,6 @@ public void test220FormRoleAssignmentStart() throws Exception { @Test public void test221FormApproveByLechuck() throws Exception { final String TEST_NAME = "test221FormApproveByLechuck"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1065,7 +1050,6 @@ public void test221FormApproveByLechuck() throws Exception { @Test public void test222FormApproveByCheese() throws Exception { final String TEST_NAME = "test222FormApproveByCheese"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1136,7 +1120,6 @@ public void test222FormApproveByCheese() throws Exception { @Test public void test250ApproverAssignment() throws Exception { final String TEST_NAME = "test250ApproverAssignment"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholds.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholds.java index 7d10f5ddcae..faca622cb15 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholds.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholds.java @@ -102,7 +102,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test001testImportBaseUsers() throws Exception { final String TEST_NAME = "test001testImportBaseUsers"; - displayTestTitle(TEST_NAME); OperationResult result = new OperationResult(TEST_NAME); importObjectFromFile(TASK_IMPORT_BASE_USERS_FILE); @@ -143,7 +142,6 @@ protected int getNumberOfUsers() { @Test public void test100assignPolicyRuleCreateToTask() throws Exception { final String TEST_NAME = "test100assignPolicyRuleCreateToTask"; - displayTestTitle(TEST_NAME); // WHEN Task task = taskManager.createTaskInstance(TEST_NAME); @@ -162,7 +160,6 @@ public void test100assignPolicyRuleCreateToTask() throws Exception { @Test public void test110importAccounts() throws Exception { final String TEST_NAME = "test110importAccountsSimulate"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -188,7 +185,6 @@ public void test110importAccounts() throws Exception { @Test public void test111importAccountsAgain() throws Exception { final String TEST_NAME = "test111importAccountsAgain"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -215,7 +211,6 @@ public void test111importAccountsAgain() throws Exception { @Test public void test500chageTaskPolicyRule() throws Exception { final String TEST_NAME = "test500chageTaskPolicyRule"; - displayTestTitle(TEST_NAME); //WHEN Task task = taskManager.createTaskInstance(TEST_NAME); @@ -235,7 +230,6 @@ public void test500chageTaskPolicyRule() throws Exception { @Test public void test520changeActivationThreeAccounts() throws Exception { final String TEST_NAME = "test520changeActivationThreeAccounts"; - displayTestTitle(TEST_NAME); OperationResult result = new OperationResult(TEST_NAME); //GIVEN diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsReconFull.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsReconFull.java index 91559396d76..28507be8936 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsReconFull.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsReconFull.java @@ -69,7 +69,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test600chageTaskPolicyRule() throws Exception { final String TEST_NAME = "test600chageTaskPolicyRule"; - displayTestTitle(TEST_NAME); //WHEN Task task = taskManager.createTaskInstance(TEST_NAME); @@ -88,7 +87,6 @@ public void test600chageTaskPolicyRule() throws Exception { @Test public void test610testFullRecon() throws Exception { final String TEST_NAME = "test610testFullRecon"; - displayTestTitle(TEST_NAME); OperationResult result = new OperationResult(TEST_NAME); //WHEN @@ -109,7 +107,6 @@ public void test610testFullRecon() throws Exception { @Test public void test611testFullRecon() throws Exception { final String TEST_NAME = "test611testFullRecon"; - displayTestTitle(TEST_NAME); OperationResult result = new OperationResult(TEST_NAME); openDJController.delete("uid=user10,ou=People,dc=example,dc=com"); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnix.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnix.java index df9e68910fe..9a73370262f 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnix.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnix.java @@ -55,6 +55,7 @@ import com.evolveum.midpoint.schema.util.ObjectQueryUtil; import com.evolveum.midpoint.schema.util.ShadowUtil; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; @@ -295,7 +296,6 @@ protected String getResourceOid() { @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult testResultOpenDj = modelService.testResource(getResourceOid(), task); @@ -308,7 +308,6 @@ public void test000Sanity() throws Exception { @Test public void test010Schema() throws Exception { final String TEST_NAME = "test010Schema"; - displayTestTitle(TEST_NAME); resourceOpenDj = getObject(ResourceType.class, getResourceOid()); resourceOpenDjType = resourceOpenDj.asObjectable(); @@ -342,7 +341,6 @@ public void test010Schema() throws Exception { @Test public void test100AddUserHermanBasic() throws Exception { final String TEST_NAME = "test100AddUserHermanBasic"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -370,7 +368,6 @@ public void test100AddUserHermanBasic() throws Exception { @Test public void test110AddUserMancombUnix() throws Exception { final String TEST_NAME = "test110AddUserMancombUnix"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -398,7 +395,6 @@ public void test110AddUserMancombUnix() throws Exception { @Test public void test111AccountMancombEditObjectClassDefinition() throws Exception { final String TEST_NAME = "test111AccountMancombEditObjectClassDefinition"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -428,7 +424,6 @@ public void test111AccountMancombEditObjectClassDefinition() throws Exception { @Test public void test119DeleteUserMancombUnix() throws Exception { final String TEST_NAME = "test119DeleteUserMancombUnix"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -454,7 +449,6 @@ public void test119DeleteUserMancombUnix() throws Exception { @Test public void test120AddUserLargo() throws Exception { final String TEST_NAME = "test120AddUserLargo"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -478,7 +472,6 @@ public void test120AddUserLargo() throws Exception { @Test public void test122AssignUserLargoBasic() throws Exception { final String TEST_NAME = "test122AssignUserLargoBasic"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -507,7 +500,6 @@ public void test122AssignUserLargoBasic() throws Exception { @Test public void test124AssignUserLargoUnix() throws Exception { final String TEST_NAME = "test124AssignUserLargoUnix"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -542,7 +534,6 @@ public void test124AssignUserLargoUnix() throws Exception { @Test public void test125RecomputeUserLargo() throws Exception { final String TEST_NAME = "test125RecomputeUserLargo"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -571,7 +562,6 @@ public void test125RecomputeUserLargo() throws Exception { @Test public void test126UnAssignUserLargoUnix() throws Exception { final String TEST_NAME = "test126UnAssignUserLargoUnix"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -600,7 +590,6 @@ public void test126UnAssignUserLargoUnix() throws Exception { @Test public void test127RecomputeUserLargo() throws Exception { final String TEST_NAME = "test127RecomputeUserLargo"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -629,7 +618,6 @@ public void test127RecomputeUserLargo() throws Exception { @Test public void test128UnAssignUserLargoBasic() throws Exception { final String TEST_NAME = "test128UnAssignUserLargoBasic"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -657,7 +645,6 @@ public void test128UnAssignUserLargoBasic() throws Exception { @Test public void test129RecomputeUserLargo() throws Exception { final String TEST_NAME = "test129RecomputeUserLargo"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -685,7 +672,6 @@ public void test129RecomputeUserLargo() throws Exception { @Test public void test130AssignUserLargoUnix() throws Exception { final String TEST_NAME = "test130AssignUserLargoUnix"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -714,7 +700,6 @@ public void test130AssignUserLargoUnix() throws Exception { @Test public void test131ReconcileUserLargo() throws Exception { final String TEST_NAME = "test131ReconcileUserLargo"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -754,7 +739,6 @@ public void test131ReconcileUserLargo() throws Exception { @Test public void test132MeddleWithAccountAndReconcileUserLargo() throws Exception { final String TEST_NAME = "test132MeddleWithAccountAndReconcileUserLargo"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -822,7 +806,6 @@ protected void assertTest132Audit() { @Test public void test133ReconcileUserLargoAgain() throws Exception { final String TEST_NAME = "test133ReconcileUserLargoAgain"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -861,7 +844,6 @@ public void test133ReconcileUserLargoAgain() throws Exception { @Test public void test134AssignUserLargoBasic() throws Exception { final String TEST_NAME = "test134AssignUserLargoBasic"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -898,7 +880,6 @@ public void test134AssignUserLargoBasic() throws Exception { @Test public void test135UnAssignUserLargoUnix() throws Exception { final String TEST_NAME = "test135UnAssignUserLargoUnix"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -944,7 +925,6 @@ protected void assertTest135Audit() { @Test // MID-2883 public void test136MeddleWithAccountAndReconcileUserLargo() throws Exception { final String TEST_NAME = "test136MeddleWithAccountAndReconcileUserLargo"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1004,7 +984,6 @@ protected void assertAccountTest136(PrismObject shadow) throws Excep @Test public void test137ReconcileUserLargoAgain() throws Exception { final String TEST_NAME = "test137ReconcileUserLargoAgain"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1051,7 +1030,6 @@ protected void assertTest137Account(PrismObject shadow) throws Excep @Test public void test138UnAssignUserLargoBasic() throws Exception { final String TEST_NAME = "test138UnAssignUserLargoUnix"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1081,7 +1059,6 @@ public void test138UnAssignUserLargoBasic() throws Exception { @Test public void test200AddLdapGroupMonkeyIsland() throws Exception { final String TEST_NAME = "test200AddLdapGroupMonkeyIsland"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1110,7 +1087,6 @@ public void test200AddLdapGroupMonkeyIsland() throws Exception { @Test public void test202AssignUserHermanMonkeyIsland() throws Exception { final String TEST_NAME = "test202AssignUserHermanMonkeyIsland"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1139,7 +1115,6 @@ public void test202AssignUserHermanMonkeyIsland() throws Exception { @Test public void test210AddUnixGroupVillains() throws Exception { final String TEST_NAME = "test210AddUnixGroupVillains"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1168,7 +1143,6 @@ public void test210AddUnixGroupVillains() throws Exception { @Test public void test211AssignUserLargoUnix() throws Exception { final String TEST_NAME = "test211AssignUserLargoUnix"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1197,7 +1171,6 @@ public void test211AssignUserLargoUnix() throws Exception { @Test public void test212AssignUserLargoVillains() throws Exception { final String TEST_NAME = "test212AssignUserLargoVillains"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1228,7 +1201,6 @@ public void test212AssignUserLargoVillains() throws Exception { @Test public void test250AddUserRangerBasic() throws Exception { final String TEST_NAME = "test250AddUserRangerBasic"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1256,7 +1228,6 @@ public void test250AddUserRangerBasic() throws Exception { @Test public void test251AssignUserRangerBasic() throws Exception { final String TEST_NAME = "test251AssignUserRangerBasic"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1285,7 +1256,6 @@ public void test251AssignUserRangerBasic() throws Exception { @Test public void test252AddUnixGroupRangers() throws Exception { final String TEST_NAME = "test252AddUnixGroupRangers"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1314,7 +1284,6 @@ public void test252AddUnixGroupRangers() throws Exception { @Test public void test253AddUnixGroupSeals() throws Exception { final String TEST_NAME = "test253AddUnixGroupSeals"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1345,7 +1314,6 @@ public void test253AddUnixGroupSeals() throws Exception { @Test public void test254AssignUserRangerRangers() throws Exception { final String TEST_NAME = "test254AssignUserRangerRangers"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1387,7 +1355,6 @@ public void test254AssignUserRangerRangers() throws Exception { @Test public void test255AssignUserRangerSeals() throws Exception { final String TEST_NAME = "test255AssignUserRangerSeals"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1421,7 +1388,6 @@ public void test255AssignUserRangerSeals() throws Exception { @Test public void test256UnAssignUserRangerSealsKeepRangers() throws Exception { final String TEST_NAME = "test256UnAssignUserRangerSealsKeepRangers"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1460,7 +1426,6 @@ public void test256UnAssignUserRangerSealsKeepRangers() throws Exception { @Test public void test257RenameUserAndAccountsCheckGroupmembership() throws Exception { final String TEST_NAME = "test257RenameUserAndAccountsCheckGroupmembership"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1500,7 +1465,6 @@ public void test257RenameUserAndAccountsCheckGroupmembership() throws Exception @Test public void test260DeleteUserUsrangerUnix() throws Exception { final String TEST_NAME = "test260DeleteUserUsrangerUnix"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1529,7 +1493,6 @@ public void test260DeleteUserUsrangerUnix() throws Exception { @Test public void test270RenameUnixGroupSeals() throws Exception { final String TEST_NAME = "test270RenameUnixGroupSeals"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1558,7 +1521,6 @@ public void test270RenameUnixGroupSeals() throws Exception { @Test public void test300AddUserCapsizeUnixFail() throws Exception { final String TEST_NAME = "test300AddUserCapsizeUnixFail"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1603,7 +1565,6 @@ public void test300AddUserCapsizeUnixFail() throws Exception { @Test public void test310AddUserWallyUnix() throws Exception { final String TEST_NAME = "test310AddUserWallyUnix"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1644,7 +1605,6 @@ public void test310AddUserWallyUnix() throws Exception { @Test public void test312AccountWallyRemovePosixObjectclassNative() throws Exception { final String TEST_NAME = "test312AccountWallyRemovePosixObjectclassNative"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1695,7 +1655,6 @@ public void test312AccountWallyRemovePosixObjectclassNative() throws Exception { @Test public void test314AccountWallyAddPosixObjectclassNative() throws Exception { final String TEST_NAME = "test314AccountWallyAddPosixObjectclassNative"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1742,7 +1701,6 @@ public void test314AccountWallyAddPosixObjectclassNative() throws Exception { @Test public void test400ListAllAccountsObjectClass() throws Exception { final String TEST_NAME = "test400ListAllAccountsObjectClass"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1765,7 +1723,6 @@ public void test400ListAllAccountsObjectClass() throws Exception { @Test public void test401ListAllAccountsKindIntent() throws Exception { final String TEST_NAME = "test401ListAllAccountsKindIntent"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1789,7 +1746,6 @@ public void test401ListAllAccountsKindIntent() throws Exception { @Test public void test402ListLdapGroupsKindIntent() throws Exception { final String TEST_NAME = "test402ListLdapGroupsKindIntent"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1813,7 +1769,6 @@ public void test402ListLdapGroupsKindIntent() throws Exception { @Test public void test403ListUnixGroupsKindIntent() throws Exception { final String TEST_NAME = "test403ListUnixGroupsKindIntent"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1836,7 +1791,6 @@ public void test403ListUnixGroupsKindIntent() throws Exception { @Test public void test500AddUserStan() throws Exception { final String TEST_NAME = "test500AddUserStan"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1870,7 +1824,6 @@ public void test500AddUserStan() throws Exception { @Test public void test510StanDisablePosixAssocAndReconcile() throws Exception { final String TEST_NAME = "test510StanDisablePosixAssocAndReconcile"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnixTolerantAux.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnixTolerantAux.java index f9daa719c26..f1717f6dc5a 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnixTolerantAux.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnixTolerantAux.java @@ -112,7 +112,6 @@ protected void assertTest137Account(PrismObject shadow) throws Excep @Test public void test140AssignUserLargoBasic() throws Exception { final String TEST_NAME = "test140AssignUserLargoBasic"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -146,7 +145,6 @@ public void test140AssignUserLargoBasic() throws Exception { @Test public void test142MeddleWithAccountAndReconcileUserLargo() throws Exception { final String TEST_NAME = "test142MeddleWithAccountAndReconcileUserLargo"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -194,7 +192,6 @@ public void test142MeddleWithAccountAndReconcileUserLargo() throws Exception { @Test public void test144AssignUserLargoUnix() throws Exception { final String TEST_NAME = "test144AssignUserLargoUnix"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -225,7 +222,6 @@ public void test144AssignUserLargoUnix() throws Exception { @Test public void test146UnassignUserLargoUnix() throws Exception { final String TEST_NAME = "test146UnassignUserLargoUnix"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -256,7 +252,6 @@ public void test146UnassignUserLargoUnix() throws Exception { @Test public void test149UnAssignUserLargoBasic() throws Exception { final String TEST_NAME = "test149UnAssignUserLargoBasic"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestVillage.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestVillage.java index dbe870d7fec..ef3c1d418f1 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestVillage.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestVillage.java @@ -26,6 +26,7 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.ObjectQueryUtil; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.asserter.UserAsserter; @@ -264,7 +265,6 @@ protected File getSystemConfigurationFile() { @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); OperationResult testResultHr = modelService.testResource(RESOURCE_DUMMY_SOURCE_OID, task); @@ -288,7 +288,6 @@ public void test000Sanity() throws Exception { @Test public void test020ResourceOpenDjGet() throws Exception { final String TEST_NAME = "test020ResourceOpenDjGet"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -326,7 +325,6 @@ public void test020ResourceOpenDjGet() throws Exception { @Test public void test022ResourceOpenDjRefinedSchema() throws Exception { final String TEST_NAME = "test022ResourceOpenDjRefinedSchema"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -379,7 +377,6 @@ public void test022ResourceOpenDjRefinedSchema() throws Exception { @Test public void test100AddSrcAccountHerman() throws Exception { final String TEST_NAME = "test100AddSrcAccountHerman"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); DummyAccount newAccount = new DummyAccount(ACCOUNT_HERMAN_USERNAME); @@ -401,7 +398,6 @@ public void test100AddSrcAccountHerman() throws Exception { @Test public void test101HermanAssignBasicRole() throws Exception { final String TEST_NAME = "test101HermanAssignBasicRole"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); PrismObject user = findUserByUsername(USER_HERMAN_NAME); @@ -419,7 +415,6 @@ public void test101HermanAssignBasicRole() throws Exception { @Test public void test102HermanUnAssignBasicRole() throws Exception { final String TEST_NAME = "test102HermanUnAssignBasicRole"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); PrismObject user = findUserByUsername(USER_HERMAN_NAME); @@ -437,7 +432,6 @@ public void test102HermanUnAssignBasicRole() throws Exception { @Test public void test103HermanAssignBasicAndSimpleRole() throws Exception { final String TEST_NAME = "test103HermanAssignBasicAndSimpleRole"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); PrismObject user = findUserByUsername(USER_HERMAN_NAME); @@ -457,7 +451,6 @@ public void test103HermanAssignBasicAndSimpleRole() throws Exception { @Test public void test104HermanUnAssignSimpleRoleThenBasic() throws Exception { final String TEST_NAME = "test104HermanUnAssignSimpleRoleThenBasic"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); PrismObject user = findUserByUsername(USER_HERMAN_NAME); @@ -486,7 +479,6 @@ public void test104HermanUnAssignSimpleRoleThenBasic() throws Exception { @Test public void test105ModifySrcAccountHermanRemoveLoc() throws Exception { final String TEST_NAME = "test105ModifySrcAccountHermanRemoveLoc"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); DummyAccount account = dummyResourceSrc.getAccountByUsername(ACCOUNT_HERMAN_USERNAME); @@ -504,7 +496,6 @@ public void test105ModifySrcAccountHermanRemoveLoc() throws Exception { @Test public void test106HermanAssignBasicRole() throws Exception { final String TEST_NAME = "test106HermanAssignBasicRole"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); PrismObject user = findUserByUsername(USER_HERMAN_NAME); @@ -522,7 +513,6 @@ public void test106HermanAssignBasicRole() throws Exception { @Test public void test107ModifySrcAccountHermanAddLoc() throws Exception { final String TEST_NAME = "test107ModifySrcAccountHermanAddLoc"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); DummyAccount account = dummyResourceSrc.getAccountByUsername(ACCOUNT_HERMAN_USERNAME); @@ -541,7 +531,6 @@ public void test107ModifySrcAccountHermanAddLoc() throws Exception { @Test public void test108ModifySrcAccountHermanRemoveLoc() throws Exception { final String TEST_NAME = "test108ModifySrcAccountHermanRemoveLoc"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); DummyAccount account = dummyResourceSrc.getAccountByUsername(ACCOUNT_HERMAN_USERNAME); @@ -560,7 +549,6 @@ public void test108ModifySrcAccountHermanRemoveLoc() throws Exception { @Test public void test109HermanUnAssignBasicRole() throws Exception { final String TEST_NAME = "test109HermanUnAssignBasicRole"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); PrismObject user = findUserByUsername(USER_HERMAN_NAME); @@ -578,7 +566,6 @@ public void test109HermanUnAssignBasicRole() throws Exception { @Test public void test110AddSrcAccountLemonhead() throws Exception { final String TEST_NAME = "test110AddSrcAccountLemonhead"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); DummyAccount newAccount = new DummyAccount(ACCOUNT_LEMONHEAD_USERNAME); @@ -605,7 +592,6 @@ public void test110AddSrcAccountLemonhead() throws Exception { @Test public void test120AddSrcAccountWally() throws Exception { final String TEST_NAME = "test120AddSrcAccountWally"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); DummyAccount newAccount = new DummyAccount(ACCOUNT_WALLY_USERNAME); @@ -625,7 +611,6 @@ public void test120AddSrcAccountWally() throws Exception { @Test public void test121WallyAssignBasicRole() throws Exception { final String TEST_NAME = "test121WallyAssignBasicRole"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); PrismObject user = findUserByUsername(USER_WALLY_NAME); @@ -642,7 +627,6 @@ public void test121WallyAssignBasicRole() throws Exception { @Test public void test122WallyUnAssignBasicRole() throws Exception { final String TEST_NAME = "test122WallyUnAssignBasicRole"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); PrismObject user = findUserByUsername(USER_WALLY_NAME); @@ -662,7 +646,6 @@ public void test122WallyUnAssignBasicRole() throws Exception { @Test public void test130AddSrcAccountMancomb() throws Exception { final String TEST_NAME = "test130AddSrcAccountMancomb"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); DummyAccount newAccount = new DummyAccount(ACCOUNT_MANCOMB_USERNAME); @@ -684,7 +667,6 @@ public void test130AddSrcAccountMancomb() throws Exception { @Test public void test131MancombAssignBasicRole() throws Exception { final String TEST_NAME = "test131WallyAssignBasicRole"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); PrismObject user = findUserByUsername(USER_MANCOMB_NAME); @@ -701,7 +683,6 @@ public void test131MancombAssignBasicRole() throws Exception { @Test public void test132MancombUnAssignBasicRole() throws Exception { final String TEST_NAME = "test132MancombUnAssignBasicRole"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); PrismObject user = findUserByUsername(USER_MANCOMB_NAME); @@ -722,7 +703,6 @@ public void test132MancombUnAssignBasicRole() throws Exception { @Test public void test150ModifySrcAccountHermanReplaceOrg() throws Exception { final String TEST_NAME = "test150ModifySrcAccountHermanReplaceOrg"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); DummyAccount account = dummyResourceSrc.getAccountByUsername(ACCOUNT_HERMAN_USERNAME); @@ -746,7 +726,6 @@ public void test150ModifySrcAccountHermanReplaceOrg() throws Exception { @Test public void test152ModifySrcAccountHermanDeleteOrg() throws Exception { final String TEST_NAME = "test152ModifySrcAccountHermanDeleteOrg"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); DummyAccount account = dummyResourceSrc.getAccountByUsername(ACCOUNT_HERMAN_USERNAME); @@ -771,7 +750,6 @@ public void test152ModifySrcAccountHermanDeleteOrg() throws Exception { @Test public void test200CreateUserAssignOrgPwdPolicy() throws Exception { final String TEST_NAME = "test200CreateUserAssignOrgPwdPolicy"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = new OperationResult(TEST_NAME); @@ -814,7 +792,6 @@ public void test200CreateUserAssignOrgPwdPolicy() throws Exception { @Test public void test201unassignRole() throws Exception{ final String TEST_NAME = "test201unassignRole"; - displayTestTitle(TEST_NAME); unassignRole(USER_MIKE_OID, ROLE_BASIC_OID); //TODO: assertions } @@ -822,7 +799,6 @@ public void test201unassignRole() throws Exception{ @Test public void test202assignRoleOrgPwdPolicy() throws Exception{ final String TEST_NAME = "test202assignRoleOrgPwdPolicy"; - displayTestTitle(TEST_NAME); //this will throw exception, if incorrect pwd policy is selected...but some assertion will be nice :) Task task = createTask(TEST_NAME); @@ -836,7 +812,6 @@ public void test202assignRoleOrgPwdPolicy() throws Exception{ @Test public void test300AddProjectJollyRoger() throws Exception { final String TEST_NAME = "test300AddProjectJollyRoger"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -863,7 +838,6 @@ public void test300AddProjectJollyRoger() throws Exception { @Test public void test310ProjectJollyRogerNestedGroup() throws Exception { final String TEST_NAME = "test310ProjectJollyRogerNestedGroup"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -901,7 +875,6 @@ ShadowType.F_ATTRIBUTES, new QName(RESOURCE_OPENDJ_NAMESPACE, "cn")).eq("admins" @Test public void test319DeleteProjectJollyRoger() throws Exception { final String TEST_NAME = "test319DeleteProjectJollyRoger"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -926,7 +899,6 @@ public void test319DeleteProjectJollyRoger() throws Exception { @Test public void test350AddRepoUserNoEmployeeNumberRecompute() throws Exception { final String TEST_NAME = "test350AddRepoUserNoEmployeeNumberRecompute"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestWriter.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestWriter.java index 6363fb895b7..b8adb2046f8 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestWriter.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestWriter.java @@ -61,7 +61,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult testResultWriter = modelService.testResource(RESOURCE_WRITER_OID, task); @@ -71,7 +70,6 @@ public void test000Sanity() throws Exception { @Test public void test100AssignJackDummyAccount() throws Exception { final String TEST_NAME = "test100AssignJackDummyAccount"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -97,7 +95,6 @@ public void test100AssignJackDummyAccount() throws Exception { @Test public void test110ModifyCaptainJack() throws Exception { final String TEST_NAME = "test110ModifyCaptainJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapAssociationPerformance.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapAssociationPerformance.java index 4f89c712928..4e3d1afa1fe 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapAssociationPerformance.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapAssociationPerformance.java @@ -147,7 +147,6 @@ protected String getLdapResourceOid() { @Test public void test000ClonePerformance() throws SchemaException { final String TEST_NAME = "test000ClonePerformance"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -166,7 +165,6 @@ public void test000ClonePerformance() throws SchemaException { @Test public void test010Sanity() throws Exception { final String TEST_NAME = "test010Sanity"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -191,7 +189,6 @@ public void test010Sanity() throws Exception { @Test public void test020GenerateRoles() throws Exception { final String TEST_NAME = "test020GenerateRoles"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -240,7 +237,6 @@ private void resetPerformanceCollectors() { @Test public void test100AddUsers() throws Exception { final String TEST_NAME = "test100AddUsers"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -310,7 +306,6 @@ private void dumpRepoSnapshot(String label, PerformanceInformation performanceIn @Test public void test110RecomputeUsers() throws Exception { final String TEST_NAME = "test110RecomputeUsers"; - displayTestTitle(TEST_NAME); rememberConnectorResourceCounters(); @@ -355,7 +350,6 @@ public void test110RecomputeUsers() throws Exception { @Test public void test120RecomputeUsersNoRoleAndShadowCache() throws Exception { final String TEST_NAME = "test120RecomputeUsersNoRoleAndShadowCache"; - displayTestTitle(TEST_NAME); rememberConnectorResourceCounters(); @@ -400,7 +394,6 @@ public void test120RecomputeUsersNoRoleAndShadowCache() throws Exception { @Test public void test130RecomputeUsersMultinode() throws Exception { final String TEST_NAME = "test130RecomputeUsersMultinode"; - displayTestTitle(TEST_NAME); rememberConnectorResourceCounters(); @@ -449,7 +442,6 @@ public void test130RecomputeUsersMultinode() throws Exception { @Test public void test140RecomputeUsersMultinodeMultithreaded() throws Exception { final String TEST_NAME = "test140RecomputeUsersMultinodeMultithreaded"; - displayTestTitle(TEST_NAME); rememberConnectorResourceCounters(); @@ -499,7 +491,6 @@ public void test140RecomputeUsersMultinodeMultithreaded() throws Exception { @Test public void test200RecomputeUsersNoDefaultRoleCache() throws Exception { final String TEST_NAME = "test200RecomputeUsersNoDefaultRoleCache"; - displayTestTitle(TEST_NAME); rememberConnectorResourceCounters(); @@ -547,7 +538,6 @@ public void test200RecomputeUsersNoDefaultRoleCache() throws Exception { @Test public void test900Summarize() throws Exception { final String TEST_NAME = "test900Summarize"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapComplex.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapComplex.java index 1f0be677313..b5fbb78fd27 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapComplex.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapComplex.java @@ -182,7 +182,6 @@ protected String getLdapResourceOid() { @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult testResultOpenDj = modelService.testResource(RESOURCE_OPENDJ_OID, task); @@ -199,7 +198,6 @@ public void test000Sanity() throws Exception { @Test public void test010Shadows() throws Exception { final String TEST_NAME = "test010Shadows"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -223,7 +221,6 @@ public void test010Shadows() throws Exception { @Test public void test050AssignAccountOpenDjSimple() throws Exception { final String TEST_NAME = "test050AssignAccountOpenDjSimple"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -257,7 +254,6 @@ public void test050AssignAccountOpenDjSimple() throws Exception { @Test public void test055Shadows() throws Exception { final String TEST_NAME = "test055Shadows"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -279,7 +275,6 @@ public void test055Shadows() throws Exception { @Test public void test059UnassignAccountOpenDjSimple() throws Exception { final String TEST_NAME = "test059UnassignAccountOpenDjSimple"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -310,7 +305,6 @@ public void test059UnassignAccountOpenDjSimple() throws Exception { @Test public void test100ModifyJackFullNameLang() throws Exception { final String TEST_NAME = "test100ModifyJackFullNameLang"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -344,7 +338,6 @@ public void test100ModifyJackFullNameLang() throws Exception { @Test public void test110AssignAccountOpenDjLang() throws Exception { final String TEST_NAME = "test110AssignAccountOpenDjLang"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -380,7 +373,6 @@ public void test110AssignAccountOpenDjLang() throws Exception { @Test public void test112ModifyJackFullNameLangEnSkRuHr() throws Exception { final String TEST_NAME = "test112ModifyJackFullNameLangEnSkRuHr"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -418,7 +410,6 @@ public void test112ModifyJackFullNameLangEnSkRuHr() throws Exception { @Test public void test114ModifyJackFullNameLangCzHr() throws Exception { final String TEST_NAME = "test114ModifyJackFullNameLangCzHr"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -456,7 +447,6 @@ public void test114ModifyJackFullNameLangCzHr() throws Exception { @Test public void test116ModifyJackFullNameLangCaptain() throws Exception { final String TEST_NAME = "test116ModifyJackFullNameLangCaptain"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -493,7 +483,6 @@ public void test116ModifyJackFullNameLangCaptain() throws Exception { @Test public void test118ModifyJackFullNameCaptain() throws Exception { final String TEST_NAME = "test118ModifyJackFullNameCaptain"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -526,7 +515,6 @@ public void test118ModifyJackFullNameCaptain() throws Exception { @Test public void test119UnassignAccountOpenDjLang() throws Exception { final String TEST_NAME = "test119UnassignAccountOpenDjLang"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -557,7 +545,6 @@ public void test119UnassignAccountOpenDjLang() throws Exception { @Test public void test120ModifyJackTitleMap() throws Exception { final String TEST_NAME = "test120ModifyJackTitleMap"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -595,7 +582,6 @@ public void test120ModifyJackTitleMap() throws Exception { @Test public void test130AssignAccountOpenDjTitleMap() throws Exception { final String TEST_NAME = "test130AssignAccountOpenDjTitleMap"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -636,7 +622,6 @@ public void test130AssignAccountOpenDjTitleMap() throws Exception { @Test public void test132AssignAccountOpenDjTitleMapAdd() throws Exception { final String TEST_NAME = "test132AssignAccountOpenDjTitleMapAdd"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -684,7 +669,6 @@ public void test132AssignAccountOpenDjTitleMapAdd() throws Exception { @Test public void test134AssignAccountOpenDjTitleMapDelete() throws Exception { final String TEST_NAME = "test134AssignAccountOpenDjTitleMapDelete"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -732,7 +716,6 @@ public void test134AssignAccountOpenDjTitleMapDelete() throws Exception { @Test public void test138AssignAccountOpenDjTitleMapReplace() throws Exception { final String TEST_NAME = "test138AssignAccountOpenDjTitleMapReplace"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -776,7 +759,6 @@ public void test138AssignAccountOpenDjTitleMapReplace() throws Exception { @Test public void test139UnassignAccountOpenDjTitleMap() throws Exception { final String TEST_NAME = "test139UnassignAccountOpenDjTitleMap"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -806,7 +788,6 @@ public void test139UnassignAccountOpenDjTitleMap() throws Exception { @Test public void test150AssignAccountOpenDj() throws Exception { final String TEST_NAME = "test150AssignAccountOpenDj"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -851,7 +832,6 @@ public void test150AssignAccountOpenDj() throws Exception { @Test public void test152JackMultivalueDescriptionGet() throws Exception { final String TEST_NAME = "test152JackMultivalueDescriptionGet"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -906,7 +886,6 @@ public void test152JackMultivalueDescriptionGet() throws Exception { @Test public void test300Shadows() throws Exception { final String TEST_NAME = "test300Shadows"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -931,7 +910,6 @@ public void test300Shadows() throws Exception { @Test public void test310SearchLdapAccounts() throws Exception { final String TEST_NAME = "test310SearchLdapAccounts"; - displayTestTitle(TEST_NAME); ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, ShadowKindType.ACCOUNT, SchemaConstants.INTENT_DEFAULT, prismContext); @@ -948,7 +926,6 @@ public void test310SearchLdapAccounts() throws Exception { @Test public void test312Shadows() throws Exception { final String TEST_NAME = "test312Shadows"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -986,7 +963,6 @@ public void test312Shadows() throws Exception { @Test public void test320SearchLdapAccountsBelow() throws Exception { final String TEST_NAME = "test320SearchLdapAccountsBelow"; - displayTestTitle(TEST_NAME); openDJController.addEntry("dn: ou=below,ou=People,dc=example,dc=com\n" + "ou: below\n" + @@ -1018,7 +994,6 @@ public void test320SearchLdapAccountsBelow() throws Exception { @Test public void test400SearchLdapProjectGroups() throws Exception { final String TEST_NAME = "test400SearchLdapProjectGroups"; - displayTestTitle(TEST_NAME); ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, ShadowKindType.ENTITLEMENT, INTENT_LDAP_PROJECT_GROUP, prismContext); @@ -1036,7 +1011,6 @@ public void test400SearchLdapProjectGroups() throws Exception { @Test public void test401SearchLdapOrgGroups() throws Exception { final String TEST_NAME = "test401SearchLdapOrgGroups"; - displayTestTitle(TEST_NAME); ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, ShadowKindType.ENTITLEMENT, INTENT_LDAP_ORG_GROUP, prismContext); @@ -1052,7 +1026,6 @@ public void test401SearchLdapOrgGroups() throws Exception { @Test public void test410CreateProjectKeelhaul() throws Exception { final String TEST_NAME = "test410CreateProjectKeelhaul"; - displayTestTitle(TEST_NAME); PrismObject projectKeelhaul = createObject(OrgType.class, PROJECT_KEELHAUL_NAME); projectKeelhaul.asObjectable() @@ -1082,7 +1055,6 @@ public void test410CreateProjectKeelhaul() throws Exception { @Test public void test412CreateProjectWalkThePlank() throws Exception { final String TEST_NAME = "test412CreateProjectWalkThePlank"; - displayTestTitle(TEST_NAME); PrismObject projectKeelhaul = createObject(OrgType.class, PROJECT_WALK_THE_PLANK_NAME); projectKeelhaul.asObjectable() @@ -1115,7 +1087,6 @@ public void test412CreateProjectWalkThePlank() throws Exception { @Test public void test415CreateOrgRumDepartment() throws Exception { final String TEST_NAME = "test415CreateOrgRumDepartment"; - displayTestTitle(TEST_NAME); PrismObject orgBefore = createObject(OrgType.class, ORG_RUM_DEPARTMENT_NAME); orgBefore.asObjectable() @@ -1150,7 +1121,6 @@ public void test415CreateOrgRumDepartment() throws Exception { @Test public void test420AssignJackToKeelhaul() throws Exception { final String TEST_NAME = "test412AssignJackToKeelhaul"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1191,7 +1161,6 @@ public void test420AssignJackToKeelhaul() throws Exception { @Test public void test422AssignJackToWalkThePlank() throws Exception { final String TEST_NAME = "test414AssignJackToWalkThePlank"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1232,7 +1201,6 @@ public void test422AssignJackToWalkThePlank() throws Exception { @Test public void test424AssignJackToRumDepartment() throws Exception { final String TEST_NAME = "test424AssignJackToRumDepartment"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapDependency.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapDependency.java index 89dd36a3357..3c18594b75c 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapDependency.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapDependency.java @@ -139,7 +139,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestLdapDependency.class.getName() + "." + TEST_NAME); OperationResult testResultOpenDj = modelService.testResource(RESOURCE_OPENDJ_OID, task); @@ -152,7 +151,6 @@ public void test000Sanity() throws Exception { @Test public void test100AddOrgIT() throws Exception { final String TEST_NAME = "test100AddOrgIT"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -180,7 +178,6 @@ public void test100AddOrgIT() throws Exception { @Test public void test150AssignFunctionalRoleToITOrg() throws Exception { final String TEST_NAME = "test150AssignFunctionalRoleToITOrg"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -210,7 +207,6 @@ public void test150AssignFunctionalRoleToITOrg() throws Exception { @Test public void test170UnassignFunctionalRoleFromITOrg() throws Exception { final String TEST_NAME = "test170UnassignFunctionalRoleFromITOrg"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -241,7 +237,6 @@ public void test170UnassignFunctionalRoleFromITOrg() throws Exception { @Test public void test200AddOrgHR() throws Exception { final String TEST_NAME = "test200AddOrgHR"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -269,7 +264,6 @@ public void test200AddOrgHR() throws Exception { @Test public void test250AssignFunctionalAndVipRoleToHROrg() throws Exception { final String TEST_NAME = "test250AssignFunctionalAndVipRoleToHROrg"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -302,7 +296,6 @@ public void test250AssignFunctionalAndVipRoleToHROrg() throws Exception { @Test public void test270UnassignVipRoleFromHROrg() throws Exception { final String TEST_NAME = "test270UnassignVipRoleFromHROrg"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -335,7 +328,6 @@ public void test270UnassignVipRoleFromHROrg() throws Exception { @Test public void test280AssignVipAndSuperVipRoleToHROrg() throws Exception { final String TEST_NAME = "test280AssignVipAndSuperVipRoleToHROrg"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -369,7 +361,6 @@ public void test280AssignVipAndSuperVipRoleToHROrg() throws Exception { @Test public void test290UnassignVipRoleFromHROrg() throws Exception { final String TEST_NAME = "test290UnassignVipRoleFromHROrg"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapMutilated.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapMutilated.java index 9acf388802c..84634a79918 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapMutilated.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapMutilated.java @@ -14,13 +14,10 @@ import static org.testng.AssertJUnit.assertEquals; import java.io.File; -import java.util.ArrayList; -import java.util.List; import javax.xml.namespace.QName; import org.apache.commons.lang3.StringUtils; -import org.opends.server.types.DirectoryException; import org.opends.server.types.Entry; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; @@ -28,13 +25,7 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.Test; -import com.evolveum.midpoint.prism.PrismContainerValue; import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.PrismProperty; -import com.evolveum.midpoint.prism.delta.ObjectDelta; -import com.evolveum.midpoint.prism.path.ItemName; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.schema.SearchResultList; import com.evolveum.midpoint.schema.constants.MidPointConstants; @@ -42,16 +33,11 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.ObjectQueryUtil; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.ldap.OpenDJController; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DebugUtil; -import com.evolveum.midpoint.util.MiscUtil; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; /** * LDAP Tests with LDAP content that is completely mutilated. It is all wrong. @@ -110,7 +96,6 @@ protected String getLdapResourceOid() { @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult testResultOpenDj = modelService.testResource(RESOURCE_OPENDJ_OID, task); @@ -127,7 +112,6 @@ public void test000Sanity() throws Exception { @Test public void test010Shadows() throws Exception { final String TEST_NAME = "test010Shadows"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -151,7 +135,6 @@ public void test010Shadows() throws Exception { @Test public void test100AssignAccountOpenDjSimple() throws Exception { final String TEST_NAME = "test100AssignAccountOpenDjSimple"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -183,7 +166,6 @@ public void test100AssignAccountOpenDjSimple() throws Exception { @Test public void test105Shadows() throws Exception { final String TEST_NAME = "test105Shadows"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -205,7 +187,6 @@ public void test105Shadows() throws Exception { @Test public void test109UnassignAccountOpenDjSimple() throws Exception { final String TEST_NAME = "test109UnassignAccountOpenDjSimple"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -237,7 +218,6 @@ public void test109UnassignAccountOpenDjSimple() throws Exception { @Test public void test300Shadows() throws Exception { final String TEST_NAME = "test300Shadows"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -262,7 +242,6 @@ public void test300Shadows() throws Exception { @Test public void test310SearchLdapAccounts() throws Exception { final String TEST_NAME = "test310SearchLdapAccounts"; - displayTestTitle(TEST_NAME); ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, ShadowKindType.ACCOUNT, SchemaConstants.INTENT_DEFAULT, prismContext); @@ -278,7 +257,6 @@ public void test310SearchLdapAccounts() throws Exception { @Test public void test312Shadows() throws Exception { final String TEST_NAME = "test312Shadows"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -314,7 +292,6 @@ public void test312Shadows() throws Exception { @Test public void test320AssignAccountOpenDj() throws Exception { final String TEST_NAME = "test320AssignAccountOpenDj"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -345,7 +322,6 @@ public void test320AssignAccountOpenDj() throws Exception { @Test public void test322SearchLdapAccounts() throws Exception { final String TEST_NAME = "test310SearchLdapAccounts"; - displayTestTitle(TEST_NAME); ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, ShadowKindType.ACCOUNT, SchemaConstants.INTENT_DEFAULT, prismContext); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapReconPerformance.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapReconPerformance.java index 498c51b1df7..fa1b814ebd9 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapReconPerformance.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapReconPerformance.java @@ -105,7 +105,6 @@ protected String getLdapResourceOid() { @Test public void test010GenerateUsers() throws Exception { final String TEST_NAME = "test010GenerateUsers"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -148,7 +147,6 @@ public void test010GenerateUsers() throws Exception { @Test public void test100Reconcile1ThreadLdap0() throws Exception { final String TEST_NAME = "test100Reconcile1ThreadLdap0"; - displayTestTitle(TEST_NAME); rememberConnectorResourceCounters(); @@ -192,7 +190,6 @@ public void test120Reconcile1ThreadLdap2() throws Exception { @Test public void test200ReconcileLdap0() throws Exception { final String TEST_NAME = "test200ReconcileLdap0"; - displayTestTitle(TEST_NAME); rememberConnectorResourceCounters(); @@ -236,7 +233,6 @@ public void test230ReconcileLdap3() throws Exception { @Test public void test310ReconcileLdapX1() throws Exception { final String TEST_NAME = "test310ReconcileLdapX1"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestLdapReconPerformance.class.getName() + "." + TEST_NAME); OperationResult testResultOpenDj = modelService.testResource(RESOURCE_OPENDJ_OID, task); @@ -257,7 +253,6 @@ public void test330ReconcileLdapX3() throws Exception { } private long testReconcileLdapRestart1Thread(final String TEST_NAME) throws Exception { - displayTestTitle(TEST_NAME); long duration = testReconcileLdapRestartWhen(TEST_NAME, TASK_RECON_1_OPENDJ_OID); @@ -267,7 +262,6 @@ private long testReconcileLdapRestart1Thread(final String TEST_NAME) throws Exce } private long testReconcileLdapRestart(final String TEST_NAME) throws Exception { - displayTestTitle(TEST_NAME); long duration = testReconcileLdapRestartWhen(TEST_NAME, TASK_RECON_4_OPENDJ_OID); @@ -307,7 +301,6 @@ private long testReconcileLdapRestartWhen(final String TEST_NAME, String taskOid @Test public void test900Summarize() throws Exception { final String TEST_NAME = "test900Summarize"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapSyncMassive.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapSyncMassive.java index 83ad1220697..0cee4a664be 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapSyncMassive.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapSyncMassive.java @@ -26,6 +26,7 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.ObjectTypeUtil; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.util.ParallelTestThread; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.*; @@ -120,7 +121,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult testResultOpenDj = modelService.testResource(RESOURCE_OPENDJ_OID, task); @@ -134,7 +134,6 @@ public void test000Sanity() throws Exception { @Test public void test080ImportSyncTask() throws Exception { final String TEST_NAME = "test080ImportSyncTask"; - displayTestTitle(TEST_NAME); // WHEN displayWhen(TEST_NAME); @@ -165,7 +164,6 @@ public void test080ImportSyncTask() throws Exception { @Test public void test110SyncAddWill() throws Exception { final String TEST_NAME = "test110SyncAddWill"; - displayTestTitle(TEST_NAME); Entry entry = openDJController.addEntryFromLdifFile(ACCOUNT_WILL_LDIF_FILE); display("Entry from LDIF", entry); @@ -207,7 +205,6 @@ public void test110SyncAddWill() throws Exception { @Test public void test112SyncAddGoods() throws Exception { final String TEST_NAME = "test112SyncAddGoods"; - displayTestTitle(TEST_NAME); // WHEN displayWhen(TEST_NAME); @@ -236,7 +233,6 @@ public void test112SyncAddGoods() throws Exception { @Test public void test150AddGoblins() throws Exception { final String TEST_NAME = "test150AddGoblins"; - displayTestTitle(TEST_NAME); // WHEN displayWhen(TEST_NAME); @@ -284,7 +280,6 @@ private String goblinUsername(int i) { @Test public void test200SyncAddKraken() throws Exception { final String TEST_NAME = "test200SyncAddKraken"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -311,7 +306,6 @@ public void test200SyncAddKraken() throws Exception { @Test public void test210SyncAddKraken() throws Exception { final String TEST_NAME = "test210SyncAddKraken"; - displayTestTitle(TEST_NAME); Entry entry = openDJController.addEntryFromLdifFile(ACCOUNT_KRAKEN_LDIF_FILE); display("Entry from LDIF", entry); @@ -350,7 +344,6 @@ public void test210SyncAddKraken() throws Exception { @Test public void test212SyncAddBads() throws Exception { final String TEST_NAME = "test212SyncAddBads"; - displayTestTitle(TEST_NAME); // WHEN displayWhen(TEST_NAME); @@ -373,7 +366,6 @@ public void test212SyncAddBads() throws Exception { @Test public void test219StopSyncTask() throws Exception { final String TEST_NAME = "test219StopSyncTask"; - displayTestTitle(TEST_NAME); // WHEN displayWhen(TEST_NAME); @@ -392,7 +384,6 @@ public void test219StopSyncTask() throws Exception { @Test public void test230UserRecomputeSequential() throws Exception { final String TEST_NAME = "test230UserRecomputeSequential"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -416,7 +407,6 @@ public void test230UserRecomputeSequential() throws Exception { @Test public void test232UserRecomputeParallel() throws Exception { final String TEST_NAME = "test232UserRecomputeParallel"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/hierarchy/AbstractLdapHierarchyTest.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/hierarchy/AbstractLdapHierarchyTest.java index b37859774be..e7abd2feefb 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/hierarchy/AbstractLdapHierarchyTest.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/hierarchy/AbstractLdapHierarchyTest.java @@ -158,7 +158,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(AbstractLdapHierarchyTest.class.getName() + "." + TEST_NAME); OperationResult testResultOpenDj = modelService.testResource(RESOURCE_OPENDJ_OID, task); @@ -171,7 +170,6 @@ public void test000Sanity() throws Exception { @Test public void test100AddOrgRoyulaCarpathia() throws Exception { final String TEST_NAME = "test100AddOrgRoyulaCarpathia"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -200,7 +198,6 @@ public void test100AddOrgRoyulaCarpathia() throws Exception { @Test public void test110AddUserTeleke() throws Exception { final String TEST_NAME = "test110AddUserTeleke"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -231,7 +228,6 @@ public void test110AddUserTeleke() throws Exception { @Test public void test200AddOrgCortuvHrad() throws Exception { final String TEST_NAME = "test200AddOrgCortuvHrad"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -261,7 +257,6 @@ public void test200AddOrgCortuvHrad() throws Exception { @Test public void test210AddUserGorc() throws Exception { final String TEST_NAME = "test210AddUserGorc"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -288,7 +283,6 @@ public void test210AddUserGorc() throws Exception { @Test public void test220AddOrgVysneVlkodlaky() throws Exception { final String TEST_NAME = "test220AddOrgVysneVlkodlaky"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -318,7 +312,6 @@ public void test220AddOrgVysneVlkodlaky() throws Exception { @Test public void test230AddUserViljaDezi() throws Exception { final String TEST_NAME = "test230AddUserViljaDezi"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -344,7 +337,6 @@ public void test230AddUserViljaDezi() throws Exception { @Test public void test300RenameOrgCortuvHrad() throws Exception { final String TEST_NAME = "test300RenameOrgCortuvHrad"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -377,7 +369,6 @@ public void test300RenameOrgCortuvHrad() throws Exception { @Test public void test310RenameUserGorc() throws Exception { final String TEST_NAME = "test310RenameUserGorc"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -401,7 +392,6 @@ public void test310RenameUserGorc() throws Exception { @Test public void test320AddOrgRoyulaDiabolica() throws Exception { final String TEST_NAME = "test320AddOrgRoyulaDiabolica"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -431,7 +421,6 @@ public void test320AddOrgRoyulaDiabolica() throws Exception { @Test public void test322MoveOrgZblo() throws Exception { final String TEST_NAME = "test322MoveOrgZblo"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/AbstractNotoriousTest.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/AbstractNotoriousTest.java index 88c9c170ccf..fe71f42e040 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/AbstractNotoriousTest.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/AbstractNotoriousTest.java @@ -162,7 +162,6 @@ private String generateRoleBOid(int num) { @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); assertObjects(RoleType.class, NUMBER_OF_LEVEL_A_ROLES + NUMBER_OF_LEVEL_B_ROLES + NUMBER_OF_ORDINARY_ROLES + getNumberOfExtraRoles()); assertObjects(OrgType.class, getNumberOfExtraOrgs()); @@ -174,7 +173,6 @@ public void test000Sanity() throws Exception { @Test public void test100AssignRa0ToJack() throws Exception { final String TEST_NAME = "test100AssignRa0ToJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -211,7 +209,6 @@ public void test100AssignRa0ToJack() throws Exception { @Test public void test102RecomputeJack() throws Exception { final String TEST_NAME = "test102RecomputeJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -244,7 +241,6 @@ public void test102RecomputeJack() throws Exception { @Test public void test104PreviewChangesJack() throws Exception { final String TEST_NAME = "test104PreviewChangesJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -284,7 +280,6 @@ public void test104PreviewChangesJack() throws Exception { @Test public void test109UnassignRa0FromJack() throws Exception { final String TEST_NAME = "test109UnassignRa0FromJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -318,7 +313,6 @@ public void test109UnassignRa0FromJack() throws Exception { @Test public void test110Assign5ARolesToJack() throws Exception { final String TEST_NAME = "test110AssignAllARolesToJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -351,7 +345,6 @@ public void test110Assign5ARolesToJack() throws Exception { @Test public void test112RecomputeJack() throws Exception { final String TEST_NAME = "test112RecomputeJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -384,7 +377,6 @@ public void test112RecomputeJack() throws Exception { @Test public void test119Unassign5ARolesFromJack() throws Exception { final String TEST_NAME = "test119Unassign5ARolesFromJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -418,7 +410,6 @@ public void test119Unassign5ARolesFromJack() throws Exception { @Test public void test120AssignAllARolesToJack() throws Exception { final String TEST_NAME = "test120AssignAllARolesToJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -451,7 +442,6 @@ public void test120AssignAllARolesToJack() throws Exception { @Test public void test122RecomputeJack() throws Exception { final String TEST_NAME = "test122RecomputeJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -484,7 +474,6 @@ public void test122RecomputeJack() throws Exception { @Test public void test124PreviewChangesJack() throws Exception { final String TEST_NAME = "test124PreviewChangesJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -524,7 +513,6 @@ public void test124PreviewChangesJack() throws Exception { @Test public void test129UnassignAllARolesFromJack() throws Exception { final String TEST_NAME = "test129UnassignAllARolesFromJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -558,7 +546,6 @@ public void test129UnassignAllARolesFromJack() throws Exception { @Test public void test130AssignRb0ToJack() throws Exception { final String TEST_NAME = "test130AssignRb0ToJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -601,7 +588,6 @@ public void test130AssignRb0ToJack() throws Exception { @Test public void test132AssignRa0ToJack() throws Exception { final String TEST_NAME = "test132AssignRa0ToJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -638,7 +624,6 @@ public void test132AssignRa0ToJack() throws Exception { @Test public void test134RecomputeJack() throws Exception { final String TEST_NAME = "test134RecomputeJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -673,7 +658,6 @@ public void test134RecomputeJack() throws Exception { @Test public void test136UnassignRb0FromJack() throws Exception { final String TEST_NAME = "test136UnassignRb0FromJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -710,7 +694,6 @@ public void test136UnassignRb0FromJack() throws Exception { @Test public void test138AssignRb0ToJackAgain() throws Exception { final String TEST_NAME = "test138AssignRb0ToJackAgain"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -747,7 +730,6 @@ public void test138AssignRb0ToJackAgain() throws Exception { @Test public void test140RecomputeJackAgain() throws Exception { final String TEST_NAME = "test140RecomputeJackAgain"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -782,7 +764,6 @@ public void test140RecomputeJackAgain() throws Exception { @Test public void test142RecomputeJackAlt() throws Exception { final String TEST_NAME = "test142RecomputeJackAlt"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -818,7 +799,6 @@ public void test142RecomputeJackAlt() throws Exception { @Test public void test144UnassignRa0FromJack() throws Exception { final String TEST_NAME = "test144UnassignRa0FromJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -855,7 +835,6 @@ public void test144UnassignRa0FromJack() throws Exception { @Test public void test149UnassignRb0FromJack() throws Exception { final String TEST_NAME = "test149UnassignRb0FromJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -897,7 +876,6 @@ public void test149UnassignRb0FromJack() throws Exception { @Test public void test150AssignNotoriousDefaultToJack() throws Exception { final String TEST_NAME = "test150AssignNotoriousDefaultToJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -940,7 +918,6 @@ public void test150AssignNotoriousDefaultToJack() throws Exception { @Test public void test152AssignNotoriousAltRelationToJack() throws Exception { final String TEST_NAME = "test152AssignNotoriousAltRelationToJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -984,7 +961,6 @@ public void test152AssignNotoriousAltRelationToJack() throws Exception { @Test public void test154RecomputeJack() throws Exception { final String TEST_NAME = "test154RecomputeJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1031,7 +1007,6 @@ protected int getTest15xRoleEvaluationIncrement() { @Test public void test156RecomputeJackAlt() throws Exception { final String TEST_NAME = "test156RecomputeJackAlt"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1074,7 +1049,6 @@ public void test156RecomputeJackAlt() throws Exception { @Test public void test158UnassignNotoriousDefaultFromJack() throws Exception { final String TEST_NAME = "test156UnassignNotoriousDefaultFromJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -1116,7 +1090,6 @@ protected void assertTest158RoleMembershipRef(PrismObject userAfter) { @Test public void test159UnassignNotoriousAltRelationFromJack() throws Exception { final String TEST_NAME = "test159UnassignNotoriousAltRelationFromJack"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/TestSupernotoriousOrg.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/TestSupernotoriousOrg.java index 2b56951f7bf..1b562cc5785 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/TestSupernotoriousOrg.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/TestSupernotoriousOrg.java @@ -75,7 +75,6 @@ protected void fillLevelBRole(RoleType roleType, int i) { @Test public void test010LevelBRolesSanity() throws Exception { final String TEST_NAME = "test010LevelBRolesSanity"; - displayTestTitle(TEST_NAME); ObjectQuery query = queryFor(RoleType.class).item(RoleType.F_ROLE_TYPE).eq(ROLE_LEVEL_B_ROLETYPE).build(); searchObjectsIterative(RoleType.class, query, diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/perf/TestImport.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/perf/TestImport.java index bdc63bb74b4..ecdb647c77c 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/perf/TestImport.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/perf/TestImport.java @@ -12,6 +12,7 @@ import com.evolveum.midpoint.schema.internals.InternalsConfig; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyAuditService; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; @@ -110,7 +111,6 @@ protected void importSystemTasks(OperationResult initResult) { @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestImport.class.getName() + "." + TEST_NAME); OperationResult testResultHr = modelService.testResource(RESOURCE_SOURCE_OID, task); @@ -124,7 +124,6 @@ public void test000Sanity() throws Exception { @Test public void test100RunImport() throws Exception { final String TEST_NAME = "test100RunImport"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestImport.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestPrivacy.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestPrivacy.java index 4a28155092a..98c82915e7c 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestPrivacy.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestPrivacy.java @@ -25,6 +25,7 @@ import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.testing.story.AbstractStoryTest; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; @@ -73,7 +74,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100AutzJackReadSearch() throws Exception { final String TEST_NAME = "test100AutzJackReadSearch"; - displayTestTitle(TEST_NAME); assignRole(USER_JACK_OID, ROLE_PRIVACY_END_USER_OID); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestRoleMembers.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestRoleMembers.java index b47140cf67f..079f8d6289d 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestRoleMembers.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestRoleMembers.java @@ -40,7 +40,6 @@ import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.util.exception.SecurityViolationException; import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; /** @@ -87,7 +86,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); // WHEN displayWhen(TEST_NAME); @@ -136,7 +134,6 @@ public void test000Sanity() throws Exception { @Test public void test100AutzGuybrushNoMembers() throws Exception { final String TEST_NAME = "test100AutzGuybrushNoMembers"; - displayTestTitle(TEST_NAME); login(USER_GUYBRUSH_USERNAME); @@ -197,7 +194,6 @@ private ModelContext previewUser(String userOid) throws SchemaExceptio @Test public void test105AutzElaineMembers() throws Exception { final String TEST_NAME = "test105AutzElaineMembers"; - displayTestTitle(TEST_NAME); login(USER_ELAINE_USERNAME); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/uuid/AbstractUuidTest.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/uuid/AbstractUuidTest.java index 3e4441c70bc..049f83382d5 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/uuid/AbstractUuidTest.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/uuid/AbstractUuidTest.java @@ -7,23 +7,17 @@ */ import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.PrismReferenceValue; -import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.testing.story.AbstractStoryTest; -import com.evolveum.midpoint.util.exception.*; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; -import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; -import org.opends.server.types.DirectoryException; + import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; -import org.testng.AssertJUnit; import org.testng.annotations.AfterClass; import org.testng.annotations.Listeners; import org.testng.annotations.Test; @@ -93,7 +87,6 @@ protected File getSystemConfigurationFile() { @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult testResultOpenDj = modelService.testResource(RESOURCE_OPENDJ_OID, task); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/uuid/TestUuidClient.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/uuid/TestUuidClient.java index 91c5f683226..7c869705d3c 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/uuid/TestUuidClient.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/uuid/TestUuidClient.java @@ -12,6 +12,7 @@ import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; @@ -102,7 +103,6 @@ protected File getSystemConfigurationFile() { @Test public void test100AddUserRapp() throws Exception { final String TEST_NAME = "test100AddUserRapp"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -123,7 +123,6 @@ public void test100AddUserRapp() throws Exception { @Test public void test101RappAssignRoleClient() throws Exception { final String TEST_NAME = "test101RappAssignRoleClient"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -144,7 +143,6 @@ public void test101RappAssignRoleClient() throws Exception { @Test public void test107RappUnAssignRoleClient() throws Exception { final String TEST_NAME = "test107RappUnAssignRoleClient"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); // WHEN @@ -159,7 +157,6 @@ public void test107RappUnAssignRoleClient() throws Exception { @Test public void test110AddMancombWithRoleClient() throws Exception { final String TEST_NAME = "test110AddMancombWithRoleClient"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -184,7 +181,6 @@ public void test110AddMancombWithRoleClient() throws Exception { @Test public void test112RenameMancomb() throws Exception { final String TEST_NAME = "test112RenameMancomb"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -207,7 +203,6 @@ public void test112RenameMancomb() throws Exception { @Test public void test119MancombDelete() throws Exception { final String TEST_NAME = "test119MancombDelete"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -227,7 +222,6 @@ public void test119MancombDelete() throws Exception { @Test public void test120AddKateWithRoleClient() throws Exception { final String TEST_NAME = "test120AddKateWithRoleClient"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -250,7 +244,6 @@ public void test120AddKateWithRoleClient() throws Exception { @Test public void test122AddWallyWithRoleClient() throws Exception { final String TEST_NAME = "test122AddWallyWithRoleClient"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -273,7 +266,6 @@ public void test122AddWallyWithRoleClient() throws Exception { @Test public void test124AddRogersWithRoleClient() throws Exception { final String TEST_NAME = "test124AddMartyWithRoleClient"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -296,7 +288,6 @@ public void test124AddRogersWithRoleClient() throws Exception { @Test public void test126AddMartyWithRoleClient() throws Exception { final String TEST_NAME = "test124AddMartyWithRoleClient"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/uuid/TestUuidExtension.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/uuid/TestUuidExtension.java index 52026c6e59e..471242fc1ff 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/uuid/TestUuidExtension.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/uuid/TestUuidExtension.java @@ -8,15 +8,9 @@ import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.PrismReferenceValue; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.IntegrationTestTools; -import com.evolveum.midpoint.test.util.MidPointTestConstants; -import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.testing.story.AbstractStoryTest; import com.evolveum.midpoint.util.exception.*; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; @@ -24,8 +18,6 @@ import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; -import org.testng.AssertJUnit; -import org.testng.annotations.AfterClass; import org.testng.annotations.Listeners; import org.testng.annotations.Test; @@ -82,7 +74,6 @@ protected File getSystemConfigurationFile() { @Test public void test100AddUserRapp() throws Exception { final String TEST_NAME = "test100AddUserRapp"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -103,7 +94,6 @@ public void test100AddUserRapp() throws Exception { @Test public void test101RappAssignRoleEmployee() throws Exception { final String TEST_NAME = "test101RappAssignRoleEmployee"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -123,7 +113,6 @@ public void test101RappAssignRoleEmployee() throws Exception { @Test public void test107RappUnAssignRoleEmployee() throws Exception { final String TEST_NAME = "test107RappUnAssignRoleEmployee"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); // WHEN @@ -141,7 +130,6 @@ public void test107RappUnAssignRoleEmployee() throws Exception { @Test public void test110AddKateWithRoleEmployee() throws Exception { final String TEST_NAME = "test110AddKateWithRoleEmployee"; - displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); From 50e93f9eaaf5210baec26b306507de666b81cee9 Mon Sep 17 00:00:00 2001 From: kate Date: Tue, 25 Feb 2020 23:53:12 +0100 Subject: [PATCH 09/97] fix for refreshing panel --- .../midpoint/web/page/admin/server/PageTask.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTask.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTask.java index 30f7e23f7d9..21a7ff968ed 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTask.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTask.java @@ -234,7 +234,7 @@ private boolean canSuspend() { PrismObject task = getObjectWrapper().getObject(); TaskType taskType = task.asObjectable(); return isAuthorized(ModelAuthorizationAction.SUSPEND_TASK, task) - && isRunnable(taskType) || isRunning(taskType) + && isRunnable(taskType) || isRunning() && !isWorkflow(task.asObjectable()); } @@ -259,8 +259,10 @@ private boolean isRunnable(TaskType task) { return TaskExecutionStatusType.RUNNABLE == task.getExecutionStatus(); } - private boolean isRunning(TaskType task) { - return task.getNodeAsObserved() != null; + private boolean isRunning() { + PrismObject task = getObjectWrapper().getObject(); + TaskType taskType = task.asObjectable(); + return taskType.getNodeAsObserved() != null; } private boolean isSuspended(TaskType task) { @@ -453,9 +455,7 @@ private ItemVisibility getBasicTabVisibility(ItemPath path) { } private ItemEditabilityHandler getTaskEditabilityHandler(){ - PrismObject task = getObjectWrapper().getObject(); - TaskType taskType = task.asObjectable(); - ItemEditabilityHandler editableHandler = wrapper -> !isRunning(taskType); + ItemEditabilityHandler editableHandler = wrapper -> !isRunning(); return editableHandler; } @@ -486,6 +486,7 @@ protected void onPostProcessTarget(AjaxRequestTarget target) { @Override protected boolean shouldTrigger() { + PageTask.this.getObjectModel().reset(); return isRefreshEnabled(); } }; @@ -534,7 +535,7 @@ public void refresh(AjaxRequestTarget target) { public boolean isRefreshEnabled() { if (refreshEnabled == null) { - return isRunning(getObjectWrapper().getObject().asObjectable()); + return isRunning(); } return refreshEnabled; From 5ceb8a8021132598cccb03b170bc011bdf70a18f Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Wed, 26 Feb 2020 11:14:32 +0100 Subject: [PATCH 10/97] prism-impl/TestPerformance: code cleanup + dump replaced with assert Changes include: - pioneer AssertJ usages - simplified double division + constant introduction (magic number e-e) - PerfRecorder sum is double, not Double (not a good accumulator type) --- infra/prism-impl/pom.xml | 6 +++- .../evolveum/midpoint/prism/PerfRecorder.java | 26 ++++++++------- .../midpoint/prism/TestPerformance.java | 33 +++++++++---------- 3 files changed, 36 insertions(+), 29 deletions(-) diff --git a/infra/prism-impl/pom.xml b/infra/prism-impl/pom.xml index d9f2ca04839..2250f23165e 100644 --- a/infra/prism-impl/pom.xml +++ b/infra/prism-impl/pom.xml @@ -46,7 +46,6 @@ com.sun.xml.bind jaxb-xjc - org.apache.cxf @@ -148,5 +147,10 @@ test-ng test + + org.assertj + assertj-core + test + diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/PerfRecorder.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/PerfRecorder.java index 07bac06e321..995d95e4e11 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/PerfRecorder.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/PerfRecorder.java @@ -6,11 +6,10 @@ */ package com.evolveum.midpoint.prism; -import org.testng.AssertJUnit; +import static org.assertj.core.api.Assertions.assertThat; /** * @author semancik - * */ public class PerfRecorder { @@ -18,16 +17,16 @@ public class PerfRecorder { private int count = 0; private Double min = null; private Double max = null; - private Double sum = 0D; + private double sum = 0d; public PerfRecorder(String name) { super(); this.name = name; } - public void record(int index, Double value) { + public void record(int index, double value) { sum += value; - count ++; + count++; if (min == null || value < min) { min = value; } @@ -53,20 +52,25 @@ public Double getSum() { } public double getAverage() { - return sum/count; + return sum / count; } public void assertAverageBelow(double expected) { - AssertJUnit.assertTrue(name+ ": Expected average below "+expected+" but was "+getAverage(), getAverage() < expected); + assertThat(getAverage()) + .as("average for %s", name) + .isLessThan(expected); + // remove in 2022 if everybody's happy: original without AssertJ +// AssertJUnit.assertTrue(name + ": Expected average below " + expected + " but was " + getAverage(), getAverage() < expected); } public void assertMaxBelow(double expected) { - AssertJUnit.assertTrue(name+ ": Expected maximum below "+expected+" but was "+max, max < expected); + assertThat(max) + .as("maximum for %s", name) + .isLessThan(expected); } - public String dump() { - return name + ": min / avg / max = "+min+" / "+getAverage()+" / "+max + " (sum="+sum+", count="+count+")"; + return name + ": min / avg / max = " + min + " / " + getAverage() + " / " + max + + " (sum=" + sum + ", count=" + count + ")"; } - } diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPerformance.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPerformance.java index 6306791170e..4c649b8941d 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPerformance.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPerformance.java @@ -6,6 +6,8 @@ */ package com.evolveum.midpoint.prism; +import static org.assertj.core.api.Assertions.assertThat; + import static com.evolveum.midpoint.prism.PrismInternalTestUtil.*; import javax.xml.namespace.QName; @@ -19,12 +21,12 @@ /** * @author semancik - * */ public class TestPerformance { - private static final int ITERATIONS = 10000; + private static final int ITERATIONS = 10_000; + private static final double NANOS_TO_MILLIS_DOUBLE = 1_000_000d; @BeforeSuite public void setupDebug() { @@ -42,7 +44,7 @@ public void testPerfContainerNewValue() throws Exception { // GIVEN PrismContext ctx = constructInitializedPrismContext(); - PrismObjectDefinition userDefinition = getFooSchema(ctx).findObjectDefinitionByElementName(new QName(NS_FOO,"user")); + PrismObjectDefinition userDefinition = getFooSchema(ctx).findObjectDefinitionByElementName(new QName(NS_FOO, "user")); PrismObject user = userDefinition.instantiate(); PrismContainer assignmentContainer = user.findOrCreateContainer(UserType.F_ASSIGNMENT); PerfRecorder recorderCreateNewValue = new PerfRecorder("createNewValue"); @@ -50,7 +52,7 @@ public void testPerfContainerNewValue() throws Exception { PerfRecorder recorderSetRealValue = new PerfRecorder("setRealValue"); // WHEN - for (int i=0; i < ITERATIONS; i++) { + for (int i = 0; i < ITERATIONS; i++) { long tsStart = System.nanoTime(); PrismContainerValue newValue = assignmentContainer.createNewValue(); @@ -61,15 +63,15 @@ public void testPerfContainerNewValue() throws Exception { long ts2 = System.nanoTime(); - descriptionProperty.setRealValue("ass "+i); + descriptionProperty.setRealValue("ass " + i); long tsEnd = System.nanoTime(); - recorderCreateNewValue.record(i, ((double)(ts1 - tsStart))/1000000); - recorderFindOrCreateProperty.record(i, ((double)(ts2 - ts1))/1000000); - recorderSetRealValue.record(i, ((double)(tsEnd - ts2))/1000000); + recorderCreateNewValue.record(i, (ts1 - tsStart) / NANOS_TO_MILLIS_DOUBLE); + recorderFindOrCreateProperty.record(i, (ts2 - ts1) / NANOS_TO_MILLIS_DOUBLE); + recorderSetRealValue.record(i, (tsEnd - ts2) / NANOS_TO_MILLIS_DOUBLE); - System.out.println("Run "+i+": total "+(((double)(tsEnd - tsStart))/1000000)+"ms"); + System.out.println("Run " + i + ": total " + ((tsEnd - tsStart) / NANOS_TO_MILLIS_DOUBLE) + "ms"); } // THEN @@ -79,14 +81,11 @@ public void testPerfContainerNewValue() throws Exception { // Do not assert maximum here. The maximum values may jump around // quite wildly (e.g. because of garbage collector runs?) - recorderCreateNewValue.assertAverageBelow(0.05D); - - recorderFindOrCreateProperty.assertAverageBelow(0.1D); + recorderCreateNewValue.assertAverageBelow(0.05d); + recorderFindOrCreateProperty.assertAverageBelow(0.1d); + recorderCreateNewValue.assertAverageBelow(0.05d); - recorderCreateNewValue.assertAverageBelow(0.05D); - - System.out.println("User:"); - System.out.println(user.debugDump()); + assertThat(assignmentContainer.size()).isEqualTo(ITERATIONS); + // we skip the 20k-line dump, it's heavy on some (*cough*Windows) consoles and crashes JVM } - } From eb4ba490869267da2a30814a898b782f7174267a Mon Sep 17 00:00:00 2001 From: lskublik Date: Wed, 26 Feb 2020 14:29:09 +0100 Subject: [PATCH 11/97] fix for css style of dropdown menu with more buttons --- .../static/less/admin-lte/less/dropdown.less | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/gui/admin-gui/src/main/resources/static/less/admin-lte/less/dropdown.less b/gui/admin-gui/src/main/resources/static/less/admin-lte/less/dropdown.less index 7ac1db48b4d..6ce3c7ff657 100644 --- a/gui/admin-gui/src/main/resources/static/less/admin-lte/less/dropdown.less +++ b/gui/admin-gui/src/main/resources/static/less/admin-lte/less/dropdown.less @@ -26,9 +26,26 @@ .auto-width { white-space: nowrap; + max-width: 20vw; + width: max-content; > li { + padding-left: 10px; + padding-right: 10px; display: inline-block; + + .btn:first-child { + margin-left: -1px; + } + + .btn:last-child { + margin-right: -1px; + } + + .btn { + float: left; + margin-bottom: -1px; + } } } @@ -357,3 +374,21 @@ } } } + +@media (min-width: @screen-sm-max) and (max-width: @screen-md-max) { + .auto-width { + max-width: 30vw; + } +} + +@media (min-width: @screen-xs-max) and (max-width: @screen-sm-max) { + .auto-width { + max-width: 30vw; + } +} + +@media (max-width: @screen-xs-max) { + .auto-width { + max-width: 50vw; + } +} From 32896643ed11a8c2782c808ca4a06bf31d8fabb2 Mon Sep 17 00:00:00 2001 From: kate Date: Wed, 26 Feb 2020 14:57:57 +0100 Subject: [PATCH 12/97] task refresing changes --- .../com/evolveum/midpoint/web/page/admin/server/PageTask.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTask.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTask.java index d9e2e03a89e..4612e0d10b8 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTask.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTask.java @@ -139,7 +139,6 @@ private void afterOperation(AjaxRequestTarget target, OperationResult result) { showResult(result); getObjectModel().reset(); refresh(target); - target.add(PageTask.this); } @@ -521,6 +520,8 @@ public void refresh(AjaxRequestTarget target) { // getObjectModel().reset(); target.add(getSummaryPanel()); target.add(getOperationalButtonsPanel()); + target.add(getFeedbackPanel()); + target.add(getMainPanel()); for (Component component : getMainPanel().getTabbedPanel()) { if (component instanceof TaskTabPanel) { From 5ceeaa40df3f28c832ef837a6e3394298d997436 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Wed, 26 Feb 2020 15:23:52 +0100 Subject: [PATCH 13/97] TestUtil.java: simpler/better footer formatting for stdout + log I'm still not happy with the log, especially the long suffix which goes way to the right when the name of the test (class.method) is long. --- .../main/java/com/evolveum/midpoint/test/util/TestUtil.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/TestUtil.java b/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/TestUtil.java index d92ad24ff9b..553992f4d69 100644 --- a/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/TestUtil.java +++ b/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/TestUtil.java @@ -66,6 +66,8 @@ public class TestUtil { public static final String TEST_LOG_SUFFIX = " ]======================================"; public static final String TEST_OUT_PREFIX = "\n\n=====[ "; public static final String TEST_OUT_SUFFIX = " ]======================================\n"; + public static final String TEST_OUT_FOOTER_PREFIX = "====== "; + public static final String TEST_OUT_FOOTER_SUFFIX = "\n"; public static final String TEST_OUT_SECTION_PREFIX = "\n\n----- "; public static final String TEST_OUT_SECTION_SUFFIX = " --------------------------------------\n"; public static final String TEST_LOG_SECTION_PREFIX = "----- "; @@ -173,8 +175,8 @@ public static void displayTestTitle(Object testCase, String testName) { } public static void displayFooter(String footerText) { - System.out.println(TEST_OUT_PREFIX + footerText); - LOGGER.info(TEST_LOG_PREFIX + footerText); + System.out.println(TEST_OUT_FOOTER_PREFIX + footerText + TEST_OUT_FOOTER_SUFFIX); + LOGGER.info(TEST_LOG_PREFIX + footerText + TEST_LOG_SUFFIX); } public static void displayWhen(String testName) { From a002155a01630638935d9d0d1262ba858a598964 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Wed, 26 Feb 2020 15:29:36 +0100 Subject: [PATCH 14/97] AbstractIntegrationTest: more start/finishTestContext changes + more... - MidpointTestMethodContext stores testClass as well - AbstractIntegrationTest.initializedClasses considered useless? - initSystemConditional is @PostConstruct, not @AfterMethod (class-wide) All the changes are not cleaned-up yet... have to consult them first. --- repo/repo-test-util/pom.xml | 4 + .../test/AbstractIntegrationTest.java | 592 +++++++++--------- .../test/MidpointTestMethodContext.java | 29 +- 3 files changed, 331 insertions(+), 294 deletions(-) diff --git a/repo/repo-test-util/pom.xml b/repo/repo-test-util/pom.xml index 421d5215b58..01e6273de5c 100644 --- a/repo/repo-test-util/pom.xml +++ b/repo/repo-test-util/pom.xml @@ -128,6 +128,10 @@ org.testng testng + + javax.annotation + javax.annotation-api + org.springframework spring-test 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 5057130da57..79d0d03e6da 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 @@ -23,6 +23,7 @@ import java.util.function.BiConsumer; import java.util.function.Consumer; import java.util.stream.Collectors; +import javax.annotation.PostConstruct; import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManagerFactory; import javax.net.ssl.X509TrustManager; @@ -44,9 +45,12 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.security.crypto.password.LdapShaPasswordEncoder; import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; -import org.testng.*; +import org.testng.Assert; +import org.testng.AssertJUnit; +import org.testng.ITestResult; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; +import org.testng.annotations.BeforeTest; import org.testng.annotations.Listeners; import org.w3c.dom.Element; @@ -139,14 +143,15 @@ public abstract class AbstractIntegrationTest extends AbstractTestNGSpringContex protected LdapShaPasswordEncoder ldapShaPasswordEncoder = new LdapShaPasswordEncoder(); - private Map lastCountMap = new HashMap<>(); + private Map lastCountMap = new HashMap<>(); private CachingStatistics lastResourceCacheStats; @Autowired @Qualifier("cacheRepositoryService") protected RepositoryService repositoryService; - protected static Set> initializedClasses = new HashSet<>(); + // TODO removed after consultation +// protected static Set> initializedClasses = new HashSet<>(); private long lastDummyResourceGroupMembersReadCount; private long lastDummyResourceWriteOperationCount; @@ -164,8 +169,7 @@ public abstract class AbstractIntegrationTest extends AbstractTestNGSpringContex protected SimpleObjectResolver repoSimpleObjectResolver; // Controllers for embedded OpenDJ and Derby. The abstract test will configure it, but - // it will not start - // only tests that need OpenDJ or derby should start it + // it will not start only tests that need OpenDJ or derby should start it protected static OpenDJController openDJController = new OpenDJController(); protected static DerbyController derbyController = new DerbyController(); @@ -175,23 +179,22 @@ public abstract class AbstractIntegrationTest extends AbstractTestNGSpringContex */ protected PredefinedTestMethodTracing predefinedTestMethodTracing; - // We need this complicated init as we want to initialize repo only once. - // JUnit will - // create new class instance for every test, so @Before and @PostInit will - // not work - // directly. We also need to init the repo after spring autowire is done, so - // @BeforeClass won't work either. - // TODO with TestNG we can use @BeforeClass again I guess (Virgo) - @BeforeMethod + /** + * With TestNG+Spring we can use {@code PostConstruct} for class-wide initialization. + * All test methods run on a single instance (unlike with JUnit). + * Using {@code BeforeClass} is not good as the Spring wiring happens later. + */ + @PostConstruct public void initSystemConditional() throws Exception { + LOGGER.trace("initSystemConditional: initializing class {}", getClass().getName()); + // Check whether we are already initialized assertNotNull("Repository is not wired properly", repositoryService); assertNotNull("Task manager is not wired properly", taskManager); - LOGGER.trace("initSystemConditional: {} systemInitialized={}", this.getClass(), isSystemInitialized()); - if (!isSystemInitialized()) { +// LOGGER.trace("initSystemConditional: {} systemInitialized={}", this.getClass(), isSystemInitialized()); +// if (!isSystemInitialized()) { PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); PrismTestUtil.setPrismContext(prismContext); - LOGGER.trace("initSystemConditional: invoking initSystem"); Task initTask = taskManager.createTaskInstance(this.getClass().getName() + ".initSystem"); initTask.setChannel(SchemaConstants.CHANNEL_GUI_INIT_URI); OperationResult result = initTask.getResult(); @@ -200,7 +203,7 @@ public void initSystemConditional() throws Exception { InternalsConfig.setPrismMonitoring(true); prismContext.setMonitor(new InternalMonitor()); - ((LocalizationServiceImpl)localizationService).setOverrideLocale(Locale.US); + ((LocalizationServiceImpl) localizationService).setOverrideLocale(Locale.US); initSystem(initTask, result); @@ -210,45 +213,52 @@ public void initSystemConditional() throws Exception { IntegrationTestTools.display("initSystem result", result); TestUtil.assertSuccessOrWarning("initSystem failed (result)", result, 1); - setSystemInitialized(); - } +// setSystemInitialized(); +// } } + @Deprecated protected boolean isSystemInitialized() { - return initializedClasses.contains(this.getClass()); + return true; +// return initializedClasses.contains(this.getClass()); } + @Deprecated private void setSystemInitialized() { - initializedClasses.add(this.getClass()); +// initializedClasses.add(this.getClass()); } + @Deprecated protected void unsetSystemInitialized() { - initializedClasses.remove(this.getClass()); +// initializedClasses.remove(this.getClass()); } /** * Creates appropriate task and result and set it into MidpointTestMethodContext. */ @BeforeMethod - public void startTestContext(ITestContext ctx, Method testMethod) throws SchemaException { - String testShortName = testMethod.getDeclaringClass().getSimpleName() + "." + testMethod.getName(); - String testFullName = testMethod.getDeclaringClass().getName() + "." + testMethod.getName(); - TestUtil.displayTestTitle(testShortName); - Task task = createTask(testFullName); + public void startTestContext(ITestResult testResult) throws SchemaException { + Class testClass = testResult.getMethod().getTestClass().getRealClass(); + String testMethodName = testResult.getMethod().getMethodName(); + + TestUtil.displayTestTitle(testClass.getSimpleName() + "." + testMethodName); + + Task task = createTask(testClass.getName() + "." + testMethodName); OperationResult rootResult = task.getResult(); TracingProfileType tracingProfile = getTestMethodTracingProfile(); CompiledTracingProfile compiledTracingProfile = tracingProfile != null ? tracer.compileProfile(tracingProfile, rootResult) : null; - OperationResult result = rootResult.subresult(testFullName + "Run") - .tracingProfile(compiledTracingProfile) - .build(); + // TODO do we need that subresult? :-) (Virgo's brave new world) +// OperationResult result = rootResult.subresult(task.getName() + "Run") +// .tracingProfile(compiledTracingProfile) +// .build(); // This is quite a hack. We need to provide traced result to all clients that need to access it via the task. // (I.e. not via the test context.) - task.setResult(result); +// task.setResult(result); - MidpointTestMethodContext.create(testMethod.getName(), task, result); + MidpointTestMethodContext.create(testClass, testMethodName, task, task.getResult()); } /** @@ -282,10 +292,17 @@ protected TracingProfileType getTestMethodTracingProfile() { } else { TracingProfileType profile; switch (predefinedTestMethodTracing) { - case MODEL_LOGGING: profile = createModelLoggingTracingProfile(); break; - case MODEL_WORKFLOW_LOGGING: profile = createModelAndWorkflowLoggingTracingProfile(); break; - case MODEL_PROVISIONING_LOGGING: profile = createModelAndProvisioningLoggingTracingProfile(); break; - default: throw new AssertionError(predefinedTestMethodTracing.toString()); + case MODEL_LOGGING: + profile = createModelLoggingTracingProfile(); + break; + case MODEL_WORKFLOW_LOGGING: + profile = createModelAndWorkflowLoggingTracingProfile(); + break; + case MODEL_PROVISIONING_LOGGING: + profile = createModelAndProvisioningLoggingTracingProfile(); + break; + default: + throw new AssertionError(predefinedTestMethodTracing.toString()); } return profile .fileNamePattern(TEST_METHOD_TRACING_FILENAME_PATTERN); @@ -307,7 +324,7 @@ protected Task getTask() { protected String getTestNameShort() { MidpointTestMethodContext ctx = MidpointTestMethodContext.get(); if (ctx != null) { - return ctx.getMethodName(); + return ctx.getTestNameShort(); } else { // TODO simplify if passes throw new IllegalStateException("getTestNameShort called while MidpointTestMethodContext is null"); @@ -318,7 +335,7 @@ protected String getTestNameShort() { /** * Retrieves the task from thread-local test method context; creating the appropriately named ad-hoc context * if it does not exist. - * + *

* We expect this method to be called from places where we really don't know if the context exists or not. Hence its name. */ protected Task getOrCreateTestTask(String methodName) { @@ -334,7 +351,7 @@ protected Task getOrCreateTestTask(String methodName) { /** * Retrieves the task from thread-local test method context; creating the task (but NOT the context) if it does not exist. - * + *

* The difference to getTask/getOrCreateTestTask is that we use taskManager.createTaskInstance instead of test-specific * createTask method. So the task created is a simple, plain one -- without all the be bells and whistles provided * by createTask method. @@ -373,14 +390,6 @@ protected OperationResult getResult() { } } - @NotNull - private MidpointTestMethodContext createAdHocTestContext(String methodName) { - LOGGER.warn("No test context for current thread: creating new"); - System.out.println("No test context for current thread: creating new"); - Task task = createTask(methodName); - return MidpointTestMethodContext.create(methodName, task, task.getResult()); - } - abstract public void initSystem(Task initTask, OperationResult initResult) throws Exception; /** @@ -389,7 +398,9 @@ private MidpointTestMethodContext createAdHocTestContext(String methodName) { */ protected void postInitSystem(Task initTask, OperationResult initResult) throws Exception { // Nothing to do by default - }; + } + + ; public S_ItemEntry deltaFor(Class objectClass) throws SchemaException { return prismContext.deltaFor(objectClass); @@ -436,7 +447,7 @@ protected PrismObject repoAddObjectFromFile( try { object = prismContext.parseObject(file); } catch (SchemaException e) { - throw new SchemaException("Error parsing file "+file.getPath()+": "+e.getMessage(), e); + throw new SchemaException("Error parsing file " + file.getPath() + ": " + e.getMessage(), e); } if (metadata) { @@ -444,7 +455,7 @@ protected PrismObject repoAddObjectFromFile( } LOGGER.trace("Adding object:\n{}", object.debugDump()); - repoAddObject(object, "from file "+file, result); + repoAddObject(object, "from file " + file, result); result.recordSuccess(); return object; } @@ -459,7 +470,7 @@ protected PrismObject repoAddShadowFromFile(File file, OperationResu PrismObject object = prismContext.parseObject(file); PrismContainer attrCont = object.findContainer(ShadowType.F_ATTRIBUTES); - for (PrismProperty attr: attrCont.getValue().getProperties()) { + for (PrismProperty attr : attrCont.getValue().getProperties()) { if (attr.getDefinition() == null) { ResourceAttributeDefinition attrDef = ObjectFactory.createResourceAttributeDefinition(attr.getElementName(), DOMUtil.XSD_STRING, prismContext); @@ -470,7 +481,7 @@ protected PrismObject repoAddShadowFromFile(File file, OperationResu addBasicMetadata(object); LOGGER.trace("Adding object:\n{}", object.debugDump()); - repoAddObject(object, "from file "+file, result); + repoAddObject(object, "from file " + file, result); result.recordSuccess(); return object; } @@ -482,8 +493,9 @@ protected void addBasicMetadata(PrismObject object) { object.asObjectable().setMetadata(metaData); } - protected void repoAddObject(PrismObject object, - OperationResult result) throws SchemaException, ObjectAlreadyExistsException, EncryptionException { + protected void repoAddObject( + PrismObject object, OperationResult result) + throws SchemaException, ObjectAlreadyExistsException, EncryptionException { repoAddObject(object, null, result); } @@ -500,12 +512,12 @@ protected void repoAddObject( } } else { Assert.assertNotNull(repositoryService, "Repository service is not initialized"); - try{ + try { CryptoUtil.encryptValues(protector, object); String oid = repositoryService.addObject(object, null, result); object.setOid(oid); - } catch(ObjectAlreadyExistsException | SchemaException | EncryptionException ex){ - result.recordFatalError(ex.getMessage()+" while adding "+object+(contextDesc==null?"":" "+contextDesc), ex); + } catch (ObjectAlreadyExistsException | SchemaException | EncryptionException ex) { + result.recordFatalError(ex.getMessage() + " while adding " + object + (contextDesc == null ? "" : " " + contextDesc), ex); throw ex; } } @@ -543,9 +555,11 @@ protected List> repoAddObjectsFromFile( } // these objects can be of various types - protected List repoAddObjectsFromFile(File file, OperationResult parentResult) throws SchemaException, ObjectAlreadyExistsException, IOException, EncryptionException { - OperationResult result = parentResult.createSubresult(AbstractIntegrationTest.class.getName() - + ".addObjectsFromFile"); + protected List repoAddObjectsFromFile(File file, OperationResult parentResult) + throws SchemaException, ObjectAlreadyExistsException, IOException, EncryptionException { + + OperationResult result = parentResult.createSubresult( + AbstractIntegrationTest.class.getName() + ".addObjectsFromFile"); result.addParam("file", file.getPath()); LOGGER.trace("addObjectsFromFile: {}", file); List objects = (List) prismContext.parserFor(file).parseObjects(); @@ -604,7 +618,7 @@ protected PrismObject addResourceFromFile(File file, String connec } protected PrismObject addResourceFromFile(File file, List connectorTypes, boolean overwrite, OperationResult result) - throws JAXBException, SchemaException, ObjectAlreadyExistsException, EncryptionException, IOException { + throws SchemaException, ObjectAlreadyExistsException, EncryptionException, IOException { LOGGER.trace("addObjectFromFile: {}, connector types {}", file, connectorTypes); PrismObject resource = prismContext.parseObject(file); return addResourceFromObject(resource, connectorTypes, overwrite, result); @@ -620,13 +634,13 @@ protected PrismObject addResourceFromObject(PrismObject findConnectorByTypeAndVersion(String connec .build(); List> connectors = repositoryService.searchObjects(ConnectorType.class, query, null, result); if (connectors.size() != 1) { - throw new IllegalStateException("Cannot find connector type " + connectorType + ", version "+connectorVersion+", got " + throw new IllegalStateException("Cannot find connector type " + connectorType + ", version " + connectorVersion + ", got " + connectors); } return connectors.get(0); } - protected void fillInConnectorRef(PrismObject resource, String connectorType, OperationResult result) throws SchemaException { ResourceType resourceType = resource.asObjectable(); @@ -676,7 +689,7 @@ protected void fillInAdditionalConnectorRef(PrismObject resource, throws SchemaException { ResourceType resourceType = resource.asObjectable(); PrismObject connectorPrism = findConnectorByType(connectorType, result); - for (ConnectorInstanceSpecificationType additionalConnector: resourceType.getAdditionalConnector()) { + for (ConnectorInstanceSpecificationType additionalConnector : resourceType.getAdditionalConnector()) { if (connectorName.equals(additionalConnector.getName())) { ObjectReferenceType ref = new ObjectReferenceType().oid(connectorPrism.getOid()); additionalConnector.setConnectorRef(ref); @@ -693,8 +706,8 @@ protected void fillInAdditionalConnectorRef(PrismObject resource, additionalConnector.setConnectorRef(ref); } - protected SystemConfigurationType getSystemConfiguration() throws ObjectNotFoundException, SchemaException { - OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName()+".getSystemConfiguration"); + protected SystemConfigurationType getSystemConfiguration() throws SchemaException { + OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName() + ".getSystemConfiguration"); try { PrismObject sysConf = repositoryService.getObject(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), null, result); result.computeStatus(); @@ -734,7 +747,7 @@ protected void assumeConflictResolutionAction(ConflictResolutionActionType actio if (current.size() != 1 || current.get(0).getConflictResolution().getAction() != action) { ObjectPolicyConfigurationType newPolicy = new ObjectPolicyConfigurationType(prismContext) .beginConflictResolution() - .action(action) + .action(action) .end(); itemDeltas.add(prismContext.deltaFor(SystemConfigurationType.class) .item(SystemConfigurationType.F_DEFAULT_OBJECT_POLICY_CONFIGURATION) @@ -746,7 +759,7 @@ protected void assumeConflictResolutionAction(ConflictResolutionActionType actio ObjectPolicyConfigurationType newPolicyForTasks = new ObjectPolicyConfigurationType(prismContext) .type(TaskType.COMPLEX_TYPE) .beginConflictResolution() - .action(ACTION_FOR_TASKS) + .action(ACTION_FOR_TASKS) .end(); itemDeltas.add(prismContext.deltaFor(SystemConfigurationType.class) .item(SystemConfigurationType.F_DEFAULT_OBJECT_POLICY_CONFIGURATION) @@ -764,14 +777,14 @@ protected void assumeConflictResolutionAction(ConflictResolutionActionType actio } } - protected void assumeResourceAssigmentPolicy(String resourceOid, AssignmentPolicyEnforcementType policy, boolean legalize) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException{ + protected void assumeResourceAssigmentPolicy(String resourceOid, AssignmentPolicyEnforcementType policy, boolean legalize) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { ProjectionPolicyType syncSettings = new ProjectionPolicyType(); syncSettings.setAssignmentPolicyEnforcement(policy); syncSettings.setLegalize(legalize); applySyncSettings(ResourceType.class, resourceOid, ResourceType.F_PROJECTION, syncSettings); } - protected void deleteResourceAssigmentPolicy(String oid, AssignmentPolicyEnforcementType policy, boolean legalize) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException{ + protected void deleteResourceAssigmentPolicy(String oid, AssignmentPolicyEnforcementType policy, boolean legalize) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { ProjectionPolicyType syncSettings = new ProjectionPolicyType(); syncSettings.setAssignmentPolicyEnforcement(policy); syncSettings.setLegalize(legalize); @@ -821,29 +834,29 @@ protected void invalidateSystemObjectsCache() { } protected void assertNoChanges(ObjectDelta delta) { - assertNull("Unexpected changes: "+ delta, delta); + assertNull("Unexpected changes: " + delta, delta); } protected void assertNoChanges(String desc, ObjectDelta delta) { - assertNull("Unexpected changes in "+desc+": "+ delta, delta); + assertNull("Unexpected changes in " + desc + ": " + delta, delta); } - protected void assertEffectiveActivation(PrismObject focus, ActivationStatusType expected) { + protected void assertEffectiveActivation(PrismObject focus, ActivationStatusType expected) { ActivationType activationType = focus.asObjectable().getActivation(); - assertNotNull("No activation in "+focus, activationType); - assertEquals("Wrong effectiveStatus in activation in "+focus, expected, activationType.getEffectiveStatus()); + assertNotNull("No activation in " + focus, activationType); + assertEquals("Wrong effectiveStatus in activation in " + focus, expected, activationType.getEffectiveStatus()); } - protected void assertEffectiveActivation(AssignmentType assignmentType, ActivationStatusType expected) { + protected void assertEffectiveActivation(AssignmentType assignmentType, ActivationStatusType expected) { ActivationType activationType = assignmentType.getActivation(); - assertNotNull("No activation in "+assignmentType, activationType); - assertEquals("Wrong effectiveStatus in activation in "+assignmentType, expected, activationType.getEffectiveStatus()); + assertNotNull("No activation in " + assignmentType, activationType); + assertEquals("Wrong effectiveStatus in activation in " + assignmentType, expected, activationType.getEffectiveStatus()); } - protected void assertValidityStatus(PrismObject focus, TimeIntervalStatusType expected) { + protected void assertValidityStatus(PrismObject focus, TimeIntervalStatusType expected) { ActivationType activationType = focus.asObjectable().getActivation(); - assertNotNull("No activation in "+focus, activationType); - assertEquals("Wrong validityStatus in activation in "+focus, expected, activationType.getValidityStatus()); + assertNotNull("No activation in " + focus, activationType); + assertEquals("Wrong validityStatus in activation in " + focus, expected, activationType.getValidityStatus()); } /** @@ -873,10 +886,10 @@ protected void assertUser(PrismObject user, String oid, String name, S assertEquals("Wrong " + user + " OID (prism)", oid, user.getOid()); assertEquals("Wrong " + user + " OID (jaxb)", oid, userType.getOid()); } - PrismAsserts.assertEqualsPolyString("Wrong "+user+" name", name, userType.getName()); - PrismAsserts.assertEqualsPolyString("Wrong "+user+" fullName", fullName, userType.getFullName()); - PrismAsserts.assertEqualsPolyString("Wrong "+user+" givenName", givenName, userType.getGivenName()); - PrismAsserts.assertEqualsPolyString("Wrong "+user+" familyName", familyName, userType.getFamilyName()); + PrismAsserts.assertEqualsPolyString("Wrong " + user + " name", name, userType.getName()); + PrismAsserts.assertEqualsPolyString("Wrong " + user + " fullName", fullName, userType.getFullName()); + PrismAsserts.assertEqualsPolyString("Wrong " + user + " givenName", givenName, userType.getGivenName()); + PrismAsserts.assertEqualsPolyString("Wrong " + user + " familyName", familyName, userType.getFamilyName()); if (location != null) { PrismAsserts.assertEqualsPolyString("Wrong " + user + " location", location, @@ -885,7 +898,7 @@ protected void assertUser(PrismObject user, String oid, String name, S } protected void assertSubtype(PrismObject object, String subtype) { - assertTrue("Object "+object+" does not have subtype "+subtype, FocusTypeUtil.hasSubtype(object, subtype)); + assertTrue("Object " + object + " does not have subtype " + subtype, FocusTypeUtil.hasSubtype(object, subtype)); } protected void assertShadowCommon(PrismObject accountShadow, String oid, String username, ResourceType resourceType, QName objectClass) throws SchemaException { @@ -897,8 +910,8 @@ protected void assertAccountShadowCommon(PrismObject accountShadow, } protected void assertAccountShadowCommon(PrismObject accountShadow, String oid, String username, ResourceType resourceType, - MatchingRule nameMatchingRule, boolean requireNormalizedIdentfiers) throws SchemaException { - assertShadowCommon(accountShadow,oid,username,resourceType,getAccountObjectClass(resourceType),nameMatchingRule, requireNormalizedIdentfiers); + MatchingRule nameMatchingRule, boolean requireNormalizedIdentfiers) throws SchemaException { + assertShadowCommon(accountShadow, oid, username, resourceType, getAccountObjectClass(resourceType), nameMatchingRule, requireNormalizedIdentfiers); } protected QName getAccountObjectClass(ResourceType resourceType) { @@ -915,7 +928,7 @@ protected void assertShadowCommon(PrismObject shadow, String oid, St } protected void assertShadowCommon(PrismObject shadow, String oid, String username, ResourceType resourceType, - QName objectClass, final MatchingRule nameMatchingRule, boolean requireNormalizedIdentfiers, boolean useMatchingRuleForShadowName) throws SchemaException { + QName objectClass, final MatchingRule nameMatchingRule, boolean requireNormalizedIdentfiers, boolean useMatchingRuleForShadowName) throws SchemaException { assertShadowSanity(shadow); if (oid != null) { assertEquals("Shadow OID mismatch (prism)", oid, shadow.getOid()); @@ -927,8 +940,8 @@ protected void assertShadowCommon(PrismObject shadow, String oid, St assertEquals("Shadow objectclass", objectClass, resourceObjectShadowType.getObjectClass()); assertEquals("Shadow resourceRef OID", resourceType.getOid(), shadow.asObjectable().getResourceRef().getOid()); PrismContainer attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES); - assertNotNull("Null attributes in shadow for "+username, attributesContainer); - assertFalse("Empty attributes in shadow for "+username, attributesContainer.isEmpty()); + assertNotNull("Null attributes in shadow for " + username, attributesContainer); + assertFalse("Empty attributes in shadow for " + username, attributesContainer.isEmpty()); if (useMatchingRuleForShadowName) { MatchingRule polyMatchingRule = new MatchingRule() { @@ -969,14 +982,14 @@ public PolyString normalize(PolyString original) throws SchemaException { if (ocDef.getSecondaryIdentifiers().isEmpty()) { ResourceAttributeDefinition idDef = ocDef.getPrimaryIdentifiers().iterator().next(); PrismProperty idProp = attributesContainer.findProperty(idDef.getItemName()); - assertNotNull("No primary identifier ("+idDef.getItemName()+") attribute in shadow for "+username, idProp); + assertNotNull("No primary identifier (" + idDef.getItemName() + ") attribute in shadow for " + username, idProp); if (nameMatchingRule == null) { - assertEquals("Unexpected primary identifier in shadow for "+username, username, idProp.getRealValue()); + assertEquals("Unexpected primary identifier in shadow for " + username, username, idProp.getRealValue()); } else { if (requireNormalizedIdentfiers) { - assertEquals("Unexpected primary identifier in shadow for "+username, nameMatchingRule.normalize(username), idProp.getRealValue()); + assertEquals("Unexpected primary identifier in shadow for " + username, nameMatchingRule.normalize(username), idProp.getRealValue()); } else { - PrismAsserts.assertEquals("Unexpected primary identifier in shadow for "+username, nameMatchingRule, username, idProp.getRealValue()); + PrismAsserts.assertEquals("Unexpected primary identifier in shadow for " + username, nameMatchingRule, username, idProp.getRealValue()); } } } else { @@ -986,10 +999,10 @@ public PolyString normalize(PolyString original) throws SchemaException { expected = nameMatchingRule.normalize(username); } List wasValues = new ArrayList<>(); - for (ResourceAttributeDefinition idSecDef: ocDef.getSecondaryIdentifiers()) { + for (ResourceAttributeDefinition idSecDef : ocDef.getSecondaryIdentifiers()) { PrismProperty idProp = attributesContainer.findProperty(idSecDef.getItemName()); wasValues.addAll(idProp.getRealValues()); - assertNotNull("No secondary identifier ("+idSecDef.getItemName()+") attribute in shadow for "+username, idProp); + assertNotNull("No secondary identifier (" + idSecDef.getItemName() + ") attribute in shadow for " + username, idProp); if (nameMatchingRule == null) { if (username.equals(idProp.getRealValue())) { found = true; @@ -1008,7 +1021,7 @@ public PolyString normalize(PolyString original) throws SchemaException { } } if (!found) { - fail("Unexpected secondary identifier in shadow for "+username+", expected "+expected+" but was "+wasValues); + fail("Unexpected secondary identifier in shadow for " + username + ", expected " + expected + " but was " + wasValues); } } } @@ -1019,17 +1032,17 @@ protected void assertShadowSecondaryIdentifier(PrismObject shadow, S ResourceAttributeDefinition idSecDef = ocDef.getSecondaryIdentifiers().iterator().next(); PrismContainer attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES); PrismProperty idProp = attributesContainer.findProperty(idSecDef.getItemName()); - assertNotNull("No secondary identifier ("+idSecDef.getItemName()+") attribute in shadow for "+expectedIdentifier, idProp); + assertNotNull("No secondary identifier (" + idSecDef.getItemName() + ") attribute in shadow for " + expectedIdentifier, idProp); if (nameMatchingRule == null) { - assertEquals("Unexpected secondary identifier in shadow for "+expectedIdentifier, expectedIdentifier, idProp.getRealValue()); + assertEquals("Unexpected secondary identifier in shadow for " + expectedIdentifier, expectedIdentifier, idProp.getRealValue()); } else { - PrismAsserts.assertEquals("Unexpected secondary identifier in shadow for "+expectedIdentifier, nameMatchingRule, expectedIdentifier, idProp.getRealValue()); + PrismAsserts.assertEquals("Unexpected secondary identifier in shadow for " + expectedIdentifier, nameMatchingRule, expectedIdentifier, idProp.getRealValue()); } } protected void assertShadowName(PrismObject shadow, String expectedName) { - PrismAsserts.assertEqualsPolyString("Shadow name is wrong in "+shadow, expectedName, shadow.asObjectable().getName()); + PrismAsserts.assertEqualsPolyString("Shadow name is wrong in " + shadow, expectedName, shadow.asObjectable().getName()); } protected void assertShadowName(ShadowType shadowType, String expectedName) { @@ -1037,7 +1050,7 @@ protected void assertShadowName(ShadowType shadowType, String expectedName) { } protected void assertShadowRepo(String oid, String username, ResourceType resourceType, QName objectClass) throws ObjectNotFoundException, SchemaException { - OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName()+".assertShadowRepo"); + OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName() + ".assertShadowRepo"); PrismObject shadow = repositoryService.getObject(ShadowType.class, oid, null, result); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1045,11 +1058,11 @@ protected void assertShadowRepo(String oid, String username, ResourceType resour } protected void assertAccountShadowRepo(String oid, String username, ResourceType resourceType) throws ObjectNotFoundException, SchemaException { - assertShadowRepo(oid,username,resourceType,getAccountObjectClass(resourceType)); + assertShadowRepo(oid, username, resourceType, getAccountObjectClass(resourceType)); } protected void assertShadowRepo(PrismObject accountShadow, String oid, String username, ResourceType resourceType, - QName objectClass) throws SchemaException { + QName objectClass) throws SchemaException { assertShadowRepo(accountShadow, oid, username, resourceType, objectClass, null); } @@ -1062,10 +1075,10 @@ protected void assertAccountShadowRepo(PrismObject accountShadow, St } protected void assertShadowRepo(PrismObject accountShadow, String oid, String username, ResourceType resourceType, - QName objectClass, MatchingRule nameMatchingRule) throws SchemaException { + QName objectClass, MatchingRule nameMatchingRule) throws SchemaException { assertShadowCommon(accountShadow, oid, username, resourceType, objectClass, nameMatchingRule, true); PrismContainer attributesContainer = accountShadow.findContainer(ShadowType.F_ATTRIBUTES); - Collection> attributes = attributesContainer.getValue().getItems(); + Collection> attributes = attributesContainer.getValue().getItems(); // Collection secIdentifiers = ShadowUtil.getSecondaryIdentifiers(accountShadow); RefinedResourceSchema refinedSchema = null; try { @@ -1075,27 +1088,26 @@ protected void assertShadowRepo(PrismObject accountShadow, String oi } ObjectClassComplexTypeDefinition objClassDef = refinedSchema.getRefinedDefinition(objectClass); Collection secIdentifiers = objClassDef.getSecondaryIdentifiers(); - if (secIdentifiers == null){ + if (secIdentifiers == null) { AssertJUnit.fail("No secondary identifiers in repo shadow"); } // repo shadow should contains all secondary identifiers + ICF_UID - assertRepoShadowAttributes(attributes, secIdentifiers.size()+1); + assertRepoShadowAttributes(attributes, secIdentifiers.size() + 1); } - protected void assertRepoShadowAttributes(Collection> attributes, int expectedNumberOfIdentifiers) { + protected void assertRepoShadowAttributes(Collection> attributes, int expectedNumberOfIdentifiers) { assertEquals("Unexpected number of attributes in repo shadow", expectedNumberOfIdentifiers, attributes.size()); } protected String getIcfUid(PrismObject shadow) { PrismContainer attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES); - assertNotNull("Null attributes in "+shadow, attributesContainer); - assertFalse("Empty attributes in "+shadow, attributesContainer.isEmpty()); + assertNotNull("Null attributes in " + shadow, attributesContainer); + assertFalse("Empty attributes in " + shadow, attributesContainer.isEmpty()); PrismProperty icfUidProp = attributesContainer.findProperty(new ItemName(SchemaConstants.NS_ICF_SCHEMA, "uid")); - assertNotNull("No ICF name attribute in "+shadow, icfUidProp); + assertNotNull("No ICF name attribute in " + shadow, icfUidProp); return icfUidProp.getRealValue(); } - protected void rememberCounter(InternalCounters counter) { lastCountMap.put(counter, InternalMonitor.getCount(counter)); } @@ -1116,21 +1128,21 @@ protected long getCounterIncrement(InternalCounters counter) { protected void assertCounterIncrement(InternalCounters counter, int expectedIncrement) { long currentCount = InternalMonitor.getCount(counter); long actualIncrement = currentCount - getLastCount(counter); - assertEquals("Unexpected increment in "+counter.getLabel(), (long)expectedIncrement, actualIncrement); + assertEquals("Unexpected increment in " + counter.getLabel(), (long) expectedIncrement, actualIncrement); lastCountMap.put(counter, currentCount); } protected void assertCounterIncrement(InternalCounters counter, int expectedIncrementMin, int expectedIncrementMax) { long currentCount = InternalMonitor.getCount(counter); long actualIncrement = currentCount - getLastCount(counter); - assertTrue("Unexpected increment in "+counter.getLabel()+". Expected " - +expectedIncrementMin+"-"+expectedIncrementMax+" but was "+actualIncrement, - actualIncrement >= expectedIncrementMin && actualIncrement <= expectedIncrementMax); + assertTrue("Unexpected increment in " + counter.getLabel() + ". Expected " + + expectedIncrementMin + "-" + expectedIncrementMax + " but was " + actualIncrement, + actualIncrement >= expectedIncrementMin && actualIncrement <= expectedIncrementMax); lastCountMap.put(counter, currentCount); } protected void rememberResourceCacheStats() { - lastResourceCacheStats = InternalMonitor.getResourceCacheStats().clone(); + lastResourceCacheStats = InternalMonitor.getResourceCacheStats().clone(); } protected void assertResourceCacheHitsIncrement(int expectedIncrement) { @@ -1143,13 +1155,13 @@ protected void assertResourceCacheMissesIncrement(int expectedIncrement) { protected void assertCacheHits(CachingStatistics lastStats, CachingStatistics currentStats, String desc, int expectedIncrement) { long actualIncrement = currentStats.getHits() - lastStats.getHits(); - assertEquals("Unexpected increment in "+desc+" hit count", (long)expectedIncrement, actualIncrement); + assertEquals("Unexpected increment in " + desc + " hit count", (long) expectedIncrement, actualIncrement); lastStats.setHits(currentStats.getHits()); } protected void assertCacheMisses(CachingStatistics lastStats, CachingStatistics currentStats, String desc, int expectedIncrement) { long actualIncrement = currentStats.getMisses() - lastStats.getMisses(); - assertEquals("Unexpected increment in "+desc+" miss count", (long)expectedIncrement, actualIncrement); + assertEquals("Unexpected increment in " + desc + " miss count", (long) expectedIncrement, actualIncrement); lastStats.setMisses(currentStats.getMisses()); } @@ -1176,24 +1188,24 @@ protected void rememberSteadyResources() { } protected void rememberDummyResourceGroupMembersReadCount(String instanceName) { - lastDummyResourceGroupMembersReadCount = DummyResource.getInstance(instanceName).getGroupMembersReadCount(); + lastDummyResourceGroupMembersReadCount = DummyResource.getInstance(instanceName).getGroupMembersReadCount(); } protected void assertDummyResourceGroupMembersReadCountIncrement(String instanceName, int expectedIncrement) { long currentDummyResourceGroupMembersReadCount = DummyResource.getInstance(instanceName).getGroupMembersReadCount(); long actualIncrement = currentDummyResourceGroupMembersReadCount - lastDummyResourceGroupMembersReadCount; - assertEquals("Unexpected increment in group members read count in dummy resource '"+instanceName+"'", (long)expectedIncrement, actualIncrement); + assertEquals("Unexpected increment in group members read count in dummy resource '" + instanceName + "'", (long) expectedIncrement, actualIncrement); lastDummyResourceGroupMembersReadCount = currentDummyResourceGroupMembersReadCount; } protected void rememberDummyResourceWriteOperationCount(String instanceName) { - lastDummyResourceWriteOperationCount = DummyResource.getInstance(instanceName).getWriteOperationCount(); + lastDummyResourceWriteOperationCount = DummyResource.getInstance(instanceName).getWriteOperationCount(); } protected void assertDummyResourceWriteOperationCountIncrement(String instanceName, int expectedIncrement) { long currentCount = DummyResource.getInstance(instanceName).getWriteOperationCount(); long actualIncrement = currentCount - lastDummyResourceWriteOperationCount; - assertEquals("Unexpected increment in write operation count in dummy resource '"+instanceName+"'", (long)expectedIncrement, actualIncrement); + assertEquals("Unexpected increment in write operation count in dummy resource '" + instanceName + "'", (long) expectedIncrement, actualIncrement); lastDummyResourceWriteOperationCount = currentCount; } @@ -1220,13 +1232,13 @@ protected PrismObject createShadow(PrismObject resourc shadowType.setObjectClass(objectClassDefinition.getTypeName()); ResourceAttributeContainer attrContainer = ShadowUtil.getOrCreateAttributesContainer(shadow, objectClassDefinition); if (uid != null) { - RefinedAttributeDefinition uidAttrDef = objectClassDefinition.findAttributeDefinition(new QName(SchemaConstants.NS_ICF_SCHEMA,"uid")); + RefinedAttributeDefinition uidAttrDef = objectClassDefinition.findAttributeDefinition(new QName(SchemaConstants.NS_ICF_SCHEMA, "uid")); ResourceAttribute uidAttr = uidAttrDef.instantiate(); uidAttr.setRealValue(uid); attrContainer.add(uidAttr); } if (name != null) { - RefinedAttributeDefinition nameAttrDef = objectClassDefinition.findAttributeDefinition(new QName(SchemaConstants.NS_ICF_SCHEMA,"name")); + RefinedAttributeDefinition nameAttrDef = objectClassDefinition.findAttributeDefinition(new QName(SchemaConstants.NS_ICF_SCHEMA, "name")); ResourceAttribute nameAttr = nameAttrDef.instantiate(); nameAttr.setRealValue(name); attrContainer.add(nameAttr); @@ -1240,19 +1252,19 @@ protected PrismObject findAccountShadowByUsername(String username, P if (accounts.isEmpty()) { return null; } - assert accounts.size() == 1 : "Too many accounts found for username "+username+" on "+resource+": "+accounts; + assert accounts.size() == 1 : "Too many accounts found for username " + username + " on " + resource + ": " + accounts; return accounts.iterator().next(); } protected PrismObject findShadowByName(ShadowKindType kind, String intent, String name, PrismObject resource, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException { RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource); - RefinedObjectClassDefinition rOcDef = rSchema.getRefinedDefinition(kind,intent); + RefinedObjectClassDefinition rOcDef = rSchema.getRefinedDefinition(kind, intent); ObjectQuery query = createShadowQuerySecondaryIdentifier(rOcDef, name, resource); List> shadows = repositoryService.searchObjects(ShadowType.class, query, null, result); if (shadows.isEmpty()) { return null; } - assert shadows.size() == 1 : "Too many shadows found for name "+name+" on "+resource+": "+shadows; + assert shadows.size() == 1 : "Too many shadows found for name " + name + " on " + resource + ": " + shadows; return shadows.iterator().next(); } @@ -1264,7 +1276,7 @@ protected PrismObject findShadowByName(QName objectClass, String nam if (shadows.isEmpty()) { return null; } - assert shadows.size() == 1 : "Too many shadows found for name "+name+" on "+resource+": "+shadows; + assert shadows.size() == 1 : "Too many shadows found for name " + name + " on " + resource + ": " + shadows; return shadows.iterator().next(); } @@ -1272,7 +1284,7 @@ protected ObjectQuery createAccountShadowQuery(String identifier, PrismObject identifierDefs = rAccount.getPrimaryIdentifiers(); - assert identifierDefs.size() == 1 : "Unexpected identifier set in "+resource+" refined schema: "+identifierDefs; + assert identifierDefs.size() == 1 : "Unexpected identifier set in " + resource + " refined schema: " + identifierDefs; ResourceAttributeDefinition identifierDef = identifierDefs.iterator().next(); //TODO: set matching rule instead of null return prismContext.queryFor(ShadowType.class) @@ -1290,7 +1302,7 @@ protected ObjectQuery createAccountShadowQuerySecondaryIdentifier(String identif protected ObjectQuery createShadowQuerySecondaryIdentifier(ObjectClassComplexTypeDefinition rAccount, String identifier, PrismObject resource) throws SchemaException { Collection identifierDefs = rAccount.getSecondaryIdentifiers(); - assert identifierDefs.size() == 1 : "Unexpected identifier set in "+resource+" refined schema: "+identifierDefs; + assert identifierDefs.size() == 1 : "Unexpected identifier set in " + resource + " refined schema: " + identifierDefs; ResourceAttributeDefinition identifierDef = identifierDefs.iterator().next(); //TODO: set matching rule instead of null return prismContext.queryFor(ShadowType.class) @@ -1339,9 +1351,9 @@ protected PrismObjectDefinition getShadowDefinition() { // objectClassName may be null protected RefinedAttributeDefinition getAttributeDefinition(ResourceType resourceType, - ShadowKindType kind, - QName objectClassName, - String attributeLocalName) throws SchemaException { + ShadowKindType kind, + QName objectClassName, + String attributeLocalName) throws SchemaException { RefinedResourceSchema refinedResourceSchema = RefinedResourceSchemaImpl.getRefinedSchema(resourceType); RefinedObjectClassDefinition refinedObjectClassDefinition = refinedResourceSchema.findRefinedDefinitionByObjectClassQName(kind, objectClassName); @@ -1350,34 +1362,34 @@ protected RefinedAttributeDefinition getAttributeDefinition(ResourceType resourc protected void assertPassword(ShadowType shadow, String expectedPassword) throws SchemaException, EncryptionException { CredentialsType credentials = shadow.getCredentials(); - assertNotNull("No credentials in "+shadow, credentials); + assertNotNull("No credentials in " + shadow, credentials); PasswordType password = credentials.getPassword(); - assertNotNull("No password in "+shadow, password); + assertNotNull("No password in " + shadow, password); ProtectedStringType passwordValue = password.getValue(); - assertNotNull("No password value in "+shadow, passwordValue); + assertNotNull("No password value in " + shadow, passwordValue); protector.decrypt(passwordValue); - assertEquals("Wrong password in "+shadow, expectedPassword, passwordValue.getClearValue()); + assertEquals("Wrong password in " + shadow, expectedPassword, passwordValue.getClearValue()); } protected void assertPasswordDelta(ObjectDelta shadowDelta) { ItemDelta passwordDelta = shadowDelta.findItemDelta(SchemaConstants.PATH_PASSWORD_VALUE); - assertNotNull("No password delta in "+shadowDelta, passwordDelta); + assertNotNull("No password delta in " + shadowDelta, passwordDelta); } protected void assertFilter(ObjectFilter filter, Class expectedClass) { if (expectedClass == null) { - assertNull("Expected that filter is null, but it was "+filter, filter); + assertNull("Expected that filter is null, but it was " + filter, filter); } else { - assertNotNull("Expected that filter is of class "+expectedClass.getName()+", but it was null", filter); + assertNotNull("Expected that filter is of class " + expectedClass.getName() + ", but it was null", filter); if (!(expectedClass.isAssignableFrom(filter.getClass()))) { - AssertJUnit.fail("Expected that filter is of class "+expectedClass.getName()+", but it was "+filter); + AssertJUnit.fail("Expected that filter is of class " + expectedClass.getName() + ", but it was " + filter); } } } protected void assertSyncToken(String syncTaskOid, Object expectedValue) throws ObjectNotFoundException, SchemaException { - OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName()+".assertSyncToken"); + OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName() + ".assertSyncToken"); Task task = taskManager.getTask(syncTaskOid, result); assertSyncToken(task, expectedValue, result); result.computeStatus(); @@ -1396,8 +1408,8 @@ protected void assertSyncToken(Task task, Object expectedValue, OperationResult } Object syncTokenPropertyValue = syncTokenProperty.getAnyRealValue(); if (!MiscUtil.equals(expectedValue, syncTokenPropertyValue)) { - AssertJUnit.fail("Wrong sync token, expected: " + expectedValue + (expectedValue==null?"":(", "+expectedValue.getClass().getName())) + - ", was: "+ syncTokenPropertyValue + (syncTokenPropertyValue==null?"":(", "+syncTokenPropertyValue.getClass().getName()))); + AssertJUnit.fail("Wrong sync token, expected: " + expectedValue + (expectedValue == null ? "" : (", " + expectedValue.getClass().getName())) + + ", was: " + syncTokenPropertyValue + (syncTokenPropertyValue == null ? "" : (", " + syncTokenPropertyValue.getClass().getName()))); } } @@ -1424,15 +1436,15 @@ protected void assertShadows(int expected, OperationResult result) throws Schema } protected void assertShadowDead(PrismObject shadow) { - assertEquals("Shadow not dead: "+shadow, Boolean.TRUE, shadow.asObjectable().isDead()); + assertEquals("Shadow not dead: " + shadow, Boolean.TRUE, shadow.asObjectable().isDead()); } protected void assertShadowNotDead(PrismObject shadow) { - assertTrue("Shadow not dead, but should not be: "+shadow, shadow.asObjectable().isDead() == null || Boolean.FALSE.equals(shadow.asObjectable().isDead())); + assertTrue("Shadow not dead, but should not be: " + shadow, shadow.asObjectable().isDead() == null || Boolean.FALSE.equals(shadow.asObjectable().isDead())); } protected void assertShadowExists(PrismObject shadow, Boolean expectedValue) { - assertEquals("Wrong shadow 'exists': "+shadow, expectedValue, shadow.asObjectable().isExists()); + assertEquals("Wrong shadow 'exists': " + shadow, expectedValue, shadow.asObjectable().isExists()); } protected void assertActivationAdministrativeStatus(PrismObject shadow, ActivationStatusType expectedStatus) { @@ -1441,10 +1453,10 @@ protected void assertActivationAdministrativeStatus(PrismObject shad if (expectedStatus == null) { return; } else { - AssertJUnit.fail("Expected activation administrative status of "+shadow+" to be "+expectedStatus+", but there was no activation administrative status"); + AssertJUnit.fail("Expected activation administrative status of " + shadow + " to be " + expectedStatus + ", but there was no activation administrative status"); } } else { - assertEquals("Wrong activation administrative status of "+shadow, expectedStatus, activationType.getAdministrativeStatus()); + assertEquals("Wrong activation administrative status of " + shadow, expectedStatus, activationType.getAdministrativeStatus()); } } @@ -1454,10 +1466,10 @@ protected void assertShadowLockout(PrismObject shadow, LockoutStatus if (expectedStatus == null) { return; } else { - AssertJUnit.fail("Expected lockout status of "+shadow+" to be "+expectedStatus+", but there was no lockout status"); + AssertJUnit.fail("Expected lockout status of " + shadow + " to be " + expectedStatus + ", but there was no lockout status"); } } else { - assertEquals("Wrong lockout status of "+shadow, expectedStatus, activationType.getLockoutStatus()); + assertEquals("Wrong lockout status of " + shadow, expectedStatus, activationType.getLockoutStatus()); } } @@ -1467,10 +1479,10 @@ protected void assertUserLockout(PrismObject user, LockoutStatusType e if (expectedStatus == null) { return; } else { - AssertJUnit.fail("Expected lockout status of "+user+" to be "+expectedStatus+", but there was no lockout status"); + AssertJUnit.fail("Expected lockout status of " + user + " to be " + expectedStatus + ", but there was no lockout status"); } } else { - assertEquals("Wrong lockout status of "+user, expectedStatus, activationType.getLockoutStatus()); + assertEquals("Wrong lockout status of " + user, expectedStatus, activationType.getLockoutStatus()); } } @@ -1490,12 +1502,12 @@ protected ItemPath getExtensionPath(QName propName) { protected void assertNumberOfAttributes(PrismObject shadow, Integer expectedNumberOfAttributes) { PrismContainer attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES); - assertNotNull("No attributes in repo shadow "+shadow, attributesContainer); - Collection> attributes = attributesContainer.getValue().getItems(); + assertNotNull("No attributes in repo shadow " + shadow, attributesContainer); + Collection> attributes = attributesContainer.getValue().getItems(); - assertFalse("Empty attributes in repo shadow "+shadow, attributes.isEmpty()); + assertFalse("Empty attributes in repo shadow " + shadow, attributes.isEmpty()); if (expectedNumberOfAttributes != null) { - assertEquals("Unexpected number of attributes in repo shadow "+shadow, (int)expectedNumberOfAttributes, attributes.size()); + assertEquals("Unexpected number of attributes in repo shadow " + shadow, (int) expectedNumberOfAttributes, attributes.size()); } } @@ -1532,7 +1544,7 @@ protected CredentialsStorageTypeType getPasswordHistoryStorageType() { } protected void assertEncryptedUserPassword(String userOid, String expectedClearPassword) throws EncryptionException, ObjectNotFoundException, SchemaException { - OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName()+".assertEncryptedUserPassword"); + OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName() + ".assertEncryptedUserPassword"); PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1550,11 +1562,11 @@ protected PasswordType assertUserPassword(PrismObject user, String exp protected PasswordType assertUserPassword(PrismObject user, String expectedClearPassword, CredentialsStorageTypeType storageType) throws EncryptionException, SchemaException { UserType userType = user.asObjectable(); CredentialsType creds = userType.getCredentials(); - assertNotNull("No credentials in "+user, creds); + assertNotNull("No credentials in " + user, creds); PasswordType password = creds.getPassword(); - assertNotNull("No password in "+user, password); + assertNotNull("No password in " + user, password); ProtectedStringType protectedActualPassword = password.getValue(); - assertProtectedString("Password for "+user, expectedClearPassword, protectedActualPassword, storageType); + assertProtectedString("Password for " + user, expectedClearPassword, protectedActualPassword, storageType); return password; } @@ -1564,7 +1576,7 @@ protected void assertUserNoPassword(PrismObject user) { if (creds != null) { PasswordType password = creds.getPassword(); if (password != null) { - assertNull("Unexpected password value in "+user, password.getValue()); + assertNull("Unexpected password value in " + user, password.getValue()); } } } @@ -1601,16 +1613,16 @@ protected boolean compareProtectedString(String expectedClearValue, ProtectedStr return protector.compareCleartext(actualValue, expectedPs); default: - throw new IllegalArgumentException("Unknown storage "+storageType); + throw new IllegalArgumentException("Unknown storage " + storageType); } } protected void assertPasswordHistoryEntries(PrismObject focus, String... changedPasswords) { CredentialsType credentials = focus.asObjectable().getCredentials(); - assertNotNull("Null credentials in "+focus, credentials); + assertNotNull("Null credentials in " + focus, credentials); PasswordType passwordType = credentials.getPassword(); - assertNotNull("Null passwordType in "+focus, passwordType); + assertNotNull("Null passwordType in " + focus, passwordType); assertPasswordHistoryEntries(focus.toString(), passwordType.getHistoryEntry(), getPasswordHistoryStorageType(), changedPasswords); } @@ -1632,8 +1644,8 @@ protected void assertPasswordHistoryEntries(String message, List historyEntriesType) { return historyEntriesType.stream() - .map(historyEntry -> { - try { - return getHumanReadablePassword(historyEntry.getValue()); - } catch (EncryptionException e) { - throw new SystemException(e.getMessage(), e); - } - }) - .collect(Collectors.joining(", ")); + .map(historyEntry -> { + try { + return getHumanReadablePassword(historyEntry.getValue()); + } catch (EncryptionException e) { + throw new SystemException(e.getMessage(), e); + } + }) + .collect(Collectors.joining(", ")); } protected String getHumanReadablePassword(ProtectedStringType ps) throws EncryptionException { @@ -1676,24 +1688,24 @@ protected String getHumanReadablePassword(ProtectedStringType ps) throws Encrypt return null; } if (ps.isEncrypted()) { - return "[E:"+protector.decryptString(ps)+"]"; + return "[E:" + protector.decryptString(ps) + "]"; } if (ps.isHashed()) { - return "[H:"+ps.getHashedDataType().getDigestValue().length*8+"bit]"; + return "[H:" + ps.getHashedDataType().getDigestValue().length * 8 + "bit]"; } return ps.getClearValue(); } protected void logTrustManagers() throws NoSuchAlgorithmException, KeyStoreException { TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); - trustManagerFactory.init((KeyStore)null); + trustManagerFactory.init((KeyStore) null); for (TrustManager trustManager : trustManagerFactory.getTrustManagers()) { if (trustManager instanceof X509TrustManager) { - X509TrustManager x509TrustManager = (X509TrustManager)trustManager; + X509TrustManager x509TrustManager = (X509TrustManager) trustManager; LOGGER.debug("TrustManager(X509): {}", x509TrustManager); X509Certificate[] acceptedIssuers = x509TrustManager.getAcceptedIssuers(); if (acceptedIssuers != null) { - for (X509Certificate acceptedIssuer: acceptedIssuers) { + for (X509Certificate acceptedIssuer : acceptedIssuers) { LOGGER.debug(" acceptedIssuer: {}", acceptedIssuer); } } @@ -1722,13 +1734,13 @@ protected void setPassword(PrismObject user, String password) { protected void assertIncompleteShadowPassword(PrismObject shadow) { PrismProperty passValProp = shadow.findProperty(SchemaConstants.PATH_PASSWORD_VALUE); - assertNotNull("No password value property in "+shadow, passValProp); - assertTrue("Password value property does not have 'incomplete' flag in "+shadow, passValProp.isIncomplete()); + assertNotNull("No password value property in " + shadow, passValProp); + assertTrue("Password value property does not have 'incomplete' flag in " + shadow, passValProp.isIncomplete()); } protected void assertNoShadowPassword(PrismObject shadow) { PrismProperty passValProp = shadow.findProperty(SchemaConstants.PATH_PASSWORD_VALUE); - assertNull("Unexpected password value property in "+shadow+": "+passValProp, passValProp); + assertNull("Unexpected password value property in " + shadow + ": " + passValProp, passValProp); } protected PrismObject instantiateObject(Class type) throws SchemaException { @@ -1766,12 +1778,12 @@ protected void assertMetadata(String message, MetadataType metadataType, boolean protected void assertShadowPasswordMetadata(PrismObject shadow, boolean passwordCreated, XMLGregorianCalendar startCal, XMLGregorianCalendar endCal, String actorOid, String channel) { CredentialsType creds = shadow.asObjectable().getCredentials(); - assertNotNull("No credentials in shadow "+shadow, creds); + assertNotNull("No credentials in shadow " + shadow, creds); PasswordType password = creds.getPassword(); - assertNotNull("No password in shadow "+shadow, password); + assertNotNull("No password in shadow " + shadow, password); MetadataType metadata = password.getMetadata(); - assertNotNull("No metadata in shadow "+shadow, metadata); - assertMetadata("Password metadata in "+shadow, metadata, passwordCreated, false, startCal, endCal, actorOid, channel); + assertNotNull("No metadata in shadow " + shadow, metadata); + assertMetadata("Password metadata in " + shadow, metadata, passwordCreated, false, startCal, endCal, actorOid, channel); } protected void assertLastProvisioningTimestamp( @@ -1796,7 +1808,7 @@ protected void displayWhen(String testName) { } protected void displayWhen(String testName, String stage) { - TestUtil.displayWhen(testName + " ("+stage+")"); + TestUtil.displayWhen(testName + " (" + stage + ")"); } protected void displayThen() { @@ -1808,7 +1820,7 @@ protected void displayThen(String testName) { } protected void displayThen(String testName, String stage) { - TestUtil.displayThen(testName + " ("+stage+")"); + TestUtil.displayThen(testName + " (" + stage + ")"); } protected void displayCleanup(String testName) { @@ -1923,7 +1935,7 @@ protected void assertBetween(String message, Long start, Long end, } protected void assertFloat(String message, Integer expectedIntPercentage, Float actualPercentage) { - assertFloat(message, expectedIntPercentage==null?null:new Float(expectedIntPercentage), actualPercentage); + assertFloat(message, expectedIntPercentage == null ? null : new Float(expectedIntPercentage), actualPercentage); } protected void assertFloat(String message, Float expectedPercentage, Float actualPercentage) { @@ -1931,12 +1943,12 @@ protected void assertFloat(String message, Float expectedPercentage, Float actua if (actualPercentage == null) { return; } else { - fail(message + ", expected: " + expectedPercentage + ", but was "+actualPercentage); + fail(message + ", expected: " + expectedPercentage + ", but was " + actualPercentage); } } //noinspection ConstantConditions if (actualPercentage > expectedPercentage + FLOAT_EPSILON || (actualPercentage < (expectedPercentage - FLOAT_EPSILON))) { - fail(message + ", expected: " + expectedPercentage + ", but was "+actualPercentage); + fail(message + ", expected: " + expectedPercentage + ", but was " + actualPercentage); } } @@ -1979,18 +1991,18 @@ protected void setTracing(Task task, TracingProfileType profile) { protected TracingProfileType createModelLoggingTracingProfile() { return createDefaultTracingProfile() .beginLoggingOverride() - .beginLevelOverride() - .logger("com.evolveum.midpoint.model") - .level(LoggingLevelType.TRACE) - .end() + .beginLevelOverride() + .logger("com.evolveum.midpoint.model") + .level(LoggingLevelType.TRACE) + .end() .end(); } protected TracingProfileType addWorkflowLogging(TracingProfileType profile) { return profile.getLoggingOverride() .beginLevelOverride() - .logger("com.evolveum.midpoint.wf") - .level(LoggingLevelType.TRACE) + .logger("com.evolveum.midpoint.wf") + .level(LoggingLevelType.TRACE) .end() .end(); } @@ -1998,8 +2010,8 @@ protected TracingProfileType addWorkflowLogging(TracingProfileType profile) { protected TracingProfileType addNotificationsLogging(TracingProfileType profile) { return profile.getLoggingOverride() .beginLevelOverride() - .logger("com.evolveum.midpoint.notifications") - .level(LoggingLevelType.TRACE) + .logger("com.evolveum.midpoint.notifications") + .level(LoggingLevelType.TRACE) .end() .end(); } @@ -2015,8 +2027,8 @@ protected TracingProfileType createModelAndProvisioningLoggingTracingProfile() { protected TracingProfileType addProvisioningLogging(TracingProfileType profile) { return profile.getLoggingOverride() .beginLevelOverride() - .logger("com.evolveum.midpoint.provisioning") - .level(LoggingLevelType.TRACE) + .logger("com.evolveum.midpoint.provisioning") + .level(LoggingLevelType.TRACE) .end() .end(); } @@ -2024,14 +2036,14 @@ protected TracingProfileType addProvisioningLogging(TracingProfileType profile) protected TracingProfileType createHibernateLoggingTracingProfile() { return createDefaultTracingProfile() .beginLoggingOverride() - .beginLevelOverride() - .logger("org.hibernate.SQL") - .level(LoggingLevelType.TRACE) - .end() - .beginLevelOverride() - .logger("org.hibernate.type") - .level(LoggingLevelType.TRACE) - .end() + .beginLevelOverride() + .logger("org.hibernate.SQL") + .level(LoggingLevelType.TRACE) + .end() + .beginLevelOverride() + .logger("org.hibernate.type") + .level(LoggingLevelType.TRACE) + .end() .end(); } @@ -2039,7 +2051,7 @@ protected TracingProfileType createDefaultTracingProfile() { return new TracingProfileType() .collectLogEntries(true) .beginTracingTypeProfile() - .level(TracingLevelType.NORMAL) + .level(TracingLevelType.NORMAL) .end() .fileNamePattern(DEFAULT_TRACING_FILENAME_PATTERN); } @@ -2047,7 +2059,7 @@ protected TracingProfileType createDefaultTracingProfile() { protected TracingProfileType createPerformanceTracingProfile() { return new TracingProfileType() .beginTracingTypeProfile() - .level(TracingLevelType.MINIMAL) + .level(TracingLevelType.MINIMAL) .end() .fileNamePattern(DEFAULT_TRACING_FILENAME_PATTERN); } @@ -2069,7 +2081,7 @@ protected Task createTracedTask(String operationName) { // .end() // .end() .beginTracingTypeProfile() - .level(TracingLevelType.NORMAL) + .level(TracingLevelType.NORMAL) .end() .fileNamePattern(DEFAULT_TRACING_FILENAME_PATTERN)); return task; @@ -2123,7 +2135,7 @@ protected String assertInProgress(OperationResult result) { } if (!OperationResultStatus.IN_PROGRESS.equals(result.getStatus())) { String message = "Expected operation " + result.getOperation() + " status IN_PROGRESS, but result status was " + result.getStatus(); - display (message, result); + display(message, result); fail(message); } return result.getAsynchronousOperationReference(); @@ -2169,7 +2181,7 @@ protected void assertTestResourceNotApplicable(OperationResult testResult, Conne protected void assertAttribute(ShadowType shadow, QName attrQname, T... expectedValues) { List actualValues = ShadowUtil.getAttributeValues(shadow, attrQname); - PrismAsserts.assertSets("attribute "+attrQname+" in " + shadow, actualValues, expectedValues); + PrismAsserts.assertSets("attribute " + attrQname + " in " + shadow, actualValues, expectedValues); } protected void assertAttribute(ResourceType resourceType, ShadowType shadowType, String attrName, @@ -2186,7 +2198,7 @@ protected void assertAttribute(PrismObject resource, ShadowTyp protected void assertAttribute(PrismObject resource, ShadowType shadow, MatchingRule matchingRule, QName attrQname, T... expectedValues) throws SchemaException { List actualValues = ShadowUtil.getAttributeValues(shadow, attrQname); - PrismAsserts.assertSets("attribute "+attrQname+" in " + shadow, matchingRule, actualValues, expectedValues); + PrismAsserts.assertSets("attribute " + attrQname + " in " + shadow, matchingRule, actualValues, expectedValues); } protected void assertNoAttribute(ShadowType shadow, QName attrQname) { @@ -2195,7 +2207,7 @@ protected void assertNoAttribute(ShadowType shadow, QName attrQname) { return; } PrismProperty attribute = attributesContainer.findProperty(ItemName.fromQName(attrQname)); - assertNull("Unexpected attribute "+attrQname+" in "+shadow+": "+attribute, attribute); + assertNull("Unexpected attribute " + attrQname + " in " + shadow + ": " + attribute, attribute); } protected void assertNoAttribute(PrismObject resource, ShadowType shadow, String attrName) { @@ -2205,7 +2217,7 @@ protected void assertNoAttribute(PrismObject resource, ShadowType protected void assertNoPendingOperation(PrismObject shadow) { List pendingOperations = shadow.asObjectable().getPendingOperation(); - assertEquals("Wrong number of pending operations in "+shadow, 0, pendingOperations.size()); + assertEquals("Wrong number of pending operations in " + shadow, 0, pendingOperations.size()); } protected void assertCaseState(String oid, String expectedState) throws ObjectNotFoundException, SchemaException { @@ -2255,7 +2267,7 @@ protected void addAccountLinkRef(PrismObject user, File accountFile) t protected void assertLinks(PrismObject focus, int expectedNumLinks) throws ObjectNotFoundException, SchemaException { PrismReference linkRef = focus.findReference(FocusType.F_LINK_REF); if (linkRef == null) { - assert expectedNumLinks == 0 : "Expected "+expectedNumLinks+" but "+focus+" has no linkRef"; + assert expectedNumLinks == 0 : "Expected " + expectedNumLinks + " but " + focus + " has no linkRef"; return; } assertEquals("Wrong number of links in " + focus, expectedNumLinks, linkRef.size()); @@ -2277,9 +2289,9 @@ protected void assertLinked(PrismObject focus, PrismObj protected void assertLinked(PrismObject focus, String projectionOid) throws ObjectNotFoundException, SchemaException { PrismReference linkRef = focus.findReference(FocusType.F_LINK_REF); - assertNotNull("No linkRefs in "+focus, linkRef); + assertNotNull("No linkRefs in " + focus, linkRef); boolean found = false; - for (PrismReferenceValue val: linkRef.getValues()) { + for (PrismReferenceValue val : linkRef.getValues()) { if (val.getOid().equals(projectionOid)) { found = true; } @@ -2303,7 +2315,7 @@ protected void assertNotLinked(PrismObject user, String return; } boolean found = false; - for (PrismReferenceValue val: linkRef.getValues()) { + for (PrismReferenceValue val : linkRef.getValues()) { if (val.getOid().equals(accountOid)) { found = true; } @@ -2316,14 +2328,14 @@ protected void assertNoLinkedAccount(PrismObject user) if (accountRef == null) { return; } - assert accountRef.isEmpty() : "Expected that "+user+" has no linked account but it has "+accountRef.size()+" linked accounts: " - + accountRef.getValues(); + assert accountRef.isEmpty() : "Expected that " + user + " has no linked account but it has " + accountRef.size() + " linked accounts: " + + accountRef.getValues(); } protected void assertPersonaLinks(PrismObject focus, int expectedNumLinks) throws ObjectNotFoundException, SchemaException { PrismReference linkRef = focus.findReference(FocusType.F_PERSONA_REF); if (linkRef == null) { - assert expectedNumLinks == 0 : "Expected "+expectedNumLinks+" but "+focus+" has no personaRef"; + assert expectedNumLinks == 0 : "Expected " + expectedNumLinks + " but " + focus + " has no personaRef"; return; } assertEquals("Wrong number of persona links in " + focus, expectedNumLinks, linkRef.size()); @@ -2343,18 +2355,18 @@ protected void removeLinks(PrismObject focus) throws Ob } protected void assertObjectOids(String message, Collection> objects, String... oids) { - List objectOids = objects.stream().map( o -> o.getOid()).collect(Collectors.toList()); + List objectOids = objects.stream().map(o -> o.getOid()).collect(Collectors.toList()); PrismAsserts.assertEqualsCollectionUnordered(message, objectOids, oids); } protected void assertExpression(PrismProperty prop, String evaluatorName) { PrismPropertyValue pval = prop.getValue(); ExpressionWrapper expressionWrapper = pval.getExpression(); - assertNotNull("No expression wrapper in "+prop, expressionWrapper); + assertNotNull("No expression wrapper in " + prop, expressionWrapper); Object expressionObj = expressionWrapper.getExpression(); - assertNotNull("No expression in "+prop, expressionObj); - assertTrue("Wrong expression type: " +expressionObj.getClass(), expressionObj instanceof ExpressionType); - ExpressionType expressionType = (ExpressionType)expressionObj; + assertNotNull("No expression in " + prop, expressionObj); + assertTrue("Wrong expression type: " + expressionObj.getClass(), expressionObj instanceof ExpressionType); + ExpressionType expressionType = (ExpressionType) expressionObj; JAXBElement evaluatorElement = expressionType.getExpressionEvaluator().iterator().next(); assertEquals("Wrong expression evaluator name", evaluatorName, evaluatorElement.getName().getLocalPart()); } @@ -2368,7 +2380,7 @@ protected void assertNoRepoObject(Class type, String o try { PrismObject object = repositoryService.getObject(type, oid, null, result); - AssertJUnit.fail("Expected that "+object+" does not exist, in repo but it does"); + AssertJUnit.fail("Expected that " + object + " does not exist, in repo but it does"); } catch (ObjectNotFoundException e) { // This is expected return; @@ -2385,24 +2397,24 @@ protected void assertNoAssociation(PrismObject shadow, QName associa protected void assertRoleMembershipRef(PrismObject focus, String... roleOids) { List refOids = new ArrayList<>(); - for (ObjectReferenceType ref: focus.asObjectable().getRoleMembershipRef()) { + for (ObjectReferenceType ref : focus.asObjectable().getRoleMembershipRef()) { refOids.add(ref.getOid()); - assertNotNull("Missing type in roleMembershipRef "+ref.getOid()+" in "+focus, ref.getType()); + assertNotNull("Missing type in roleMembershipRef " + ref.getOid() + " in " + focus, ref.getType()); // Name is not stored now // assertNotNull("Missing name in roleMembershipRef "+ref.getOid()+" in "+focus, ref.getTargetName()); } - PrismAsserts.assertSets("Wrong values in roleMembershipRef in "+focus, refOids, roleOids); + PrismAsserts.assertSets("Wrong values in roleMembershipRef in " + focus, refOids, roleOids); } protected void assertRoleMembershipRefs(PrismObject focus, Collection roleOids) { List refOids = new ArrayList<>(); - for (ObjectReferenceType ref: focus.asObjectable().getRoleMembershipRef()) { + for (ObjectReferenceType ref : focus.asObjectable().getRoleMembershipRef()) { refOids.add(ref.getOid()); - assertNotNull("Missing type in roleMembershipRef "+ref.getOid()+" in "+focus, ref.getType()); + assertNotNull("Missing type in roleMembershipRef " + ref.getOid() + " in " + focus, ref.getType()); // Name is not stored now // assertNotNull("Missing name in roleMembershipRef "+ref.getOid()+" in "+focus, ref.getTargetName()); } - PrismAsserts.assertSets("Wrong values in roleMembershipRef in "+focus, refOids, roleOids); + PrismAsserts.assertSets("Wrong values in roleMembershipRef in " + focus, refOids, roleOids); } protected void assertRoleMembershipRef(PrismObject focus, QName relation, String... roleOids) { @@ -2416,35 +2428,35 @@ protected void assertRoleMembershipRef(PrismObject focu } return true; })) { - AssertJUnit.fail("Wrong values in roleMembershipRef in "+focus - +", expected relation "+relation+", OIDs "+Arrays.toString(roleOids) - +", but was "+focus.asObjectable().getRoleMembershipRef()); + AssertJUnit.fail("Wrong values in roleMembershipRef in " + focus + + ", expected relation " + relation + ", OIDs " + Arrays.toString(roleOids) + + ", but was " + focus.asObjectable().getRoleMembershipRef()); } } protected void assertRoleMembershipRefs(PrismObject focus, int expectedNumber) { List roleMembershipRefs = focus.asObjectable().getRoleMembershipRef(); - assertEquals("Wrong number of roleMembershipRefs in "+focus, expectedNumber, roleMembershipRefs.size()); + assertEquals("Wrong number of roleMembershipRefs in " + focus, expectedNumber, roleMembershipRefs.size()); } protected void assertNoRoleMembershipRef(PrismObject focus) { PrismReference memRef = focus.findReference(FocusType.F_ROLE_MEMBERSHIP_REF); - assertNull("No roleMembershipRef expected in "+focus+", but found: "+memRef, memRef); + assertNull("No roleMembershipRef expected in " + focus + ", but found: " + memRef, memRef); } - protected void generateRoles(int numberOfRoles, String nameFormat, String oidFormat, BiConsumer mutator, OperationResult result) throws Exception { + protected void generateRoles(int numberOfRoles, String nameFormat, String oidFormat, BiConsumer mutator, OperationResult result) throws Exception { generateObjects(RoleType.class, numberOfRoles, nameFormat, oidFormat, mutator, role -> repositoryService.addObject(role, null, result), result); } - protected void generateUsers(int numberOfUsers, String nameFormat, String oidFormat, BiConsumer mutator, OperationResult result) throws Exception { + protected void generateUsers(int numberOfUsers, String nameFormat, String oidFormat, BiConsumer mutator, OperationResult result) throws Exception { generateObjects(UserType.class, numberOfUsers, nameFormat, oidFormat, mutator, user -> repositoryService.addObject(user, null, result), result); } - protected void generateObjects(Class type, int numberOfObjects, String nameFormat, String oidFormat, BiConsumer mutator, FailableProcessor> adder, OperationResult result) throws Exception { + protected void generateObjects(Class type, int numberOfObjects, String nameFormat, String oidFormat, BiConsumer mutator, FailableProcessor> adder, OperationResult result) throws Exception { long startMillis = System.currentTimeMillis(); PrismObjectDefinition objectDefinition = getObjectDefinition(type); - for(int i=0; i < numberOfObjects; i++) { + for (int i = 0; i < numberOfObjects; i++) { PrismObject object = objectDefinition.instantiate(); O objectType = object.asObjectable(); String name = String.format(nameFormat, i); @@ -2462,26 +2474,26 @@ protected void generateObjects(Class type, int numberO long endMillis = System.currentTimeMillis(); long duration = (endMillis - startMillis); - display(type.getSimpleName() + " import", "import of "+numberOfObjects+" roles took "+(duration/1000)+" seconds ("+(duration/numberOfObjects)+"ms per object)"); + display(type.getSimpleName() + " import", "import of " + numberOfObjects + " roles took " + (duration / 1000) + " seconds (" + (duration / numberOfObjects) + "ms per object)"); } protected String assignmentSummary(PrismObject user) { - Map assignmentRelations = new HashMap<>(); - for (AssignmentType assignment: user.asObjectable().getAssignment()) { + Map assignmentRelations = new HashMap<>(); + for (AssignmentType assignment : user.asObjectable().getAssignment()) { relationToMap(assignmentRelations, assignment.getTargetRef()); } - Map memRelations = new HashMap<>(); - for (ObjectReferenceType ref: user.asObjectable().getRoleMembershipRef()) { + Map memRelations = new HashMap<>(); + for (ObjectReferenceType ref : user.asObjectable().getRoleMembershipRef()) { relationToMap(memRelations, ref); } - Map parents = new HashMap<>(); - for (ObjectReferenceType ref: user.asObjectable().getParentOrgRef()) { + Map parents = new HashMap<>(); + for (ObjectReferenceType ref : user.asObjectable().getParentOrgRef()) { relationToMap(parents, ref); } - return "User "+user - +"\n "+user.asObjectable().getAssignment().size()+" assignments\n "+assignmentRelations - +"\n "+user.asObjectable().getRoleMembershipRef().size()+" roleMembershipRefs\n "+memRelations - +"\n "+user.asObjectable().getParentOrgRef().size()+" parentOrgRefs\n "+parents; + return "User " + user + + "\n " + user.asObjectable().getAssignment().size() + " assignments\n " + assignmentRelations + + "\n " + user.asObjectable().getRoleMembershipRef().size() + " roleMembershipRefs\n " + memRelations + + "\n " + user.asObjectable().getParentOrgRef().size() + " parentOrgRefs\n " + parents; } private void relationToMap(Map map, ObjectReferenceType ref) { @@ -2505,19 +2517,19 @@ protected S_FilterEntryOrEmpty queryFor(Class queryClas protected void displayCounters(InternalCounters... counters) { StringBuilder sb = new StringBuilder(); - for (InternalCounters counter: counters) { + for (InternalCounters counter : counters) { sb - .append(" ") - .append(counter.getLabel()).append(": ") - .append("+").append(getCounterIncrement(counter)) - .append(" (").append(InternalMonitor.getCount(counter)).append(")") - .append("\n"); + .append(" ") + .append(counter.getLabel()).append(": ") + .append("+").append(getCounterIncrement(counter)) + .append(" (").append(InternalMonitor.getCount(counter)).append(")") + .append("\n"); } display("Counters", sb.toString()); } protected void assertMessageContains(String message, String string) { - assert message.contains(string) : "Expected message to contain '"+string+"' but it does not; message: " + message; + assert message.contains(string) : "Expected message to contain '" + string + "' but it does not; message: " + message; } protected void assertExceptionUserFriendly(CommonException e, String expectedMessage) { @@ -2608,7 +2620,7 @@ protected PropertyDelta createAttributeReplaceDelta(PrismObject PropertyDelta createAttributeReplaceDelta(PrismObject resource, QName attributeQName, T... newRealValue) throws SchemaException { PrismPropertyDefinition attributeDefinition = getAttributeDefinition(resource, attributeQName); if (attributeDefinition == null) { - throw new SchemaException("No definition for attribute "+ attributeQName+ " in " + resource); + throw new SchemaException("No definition for attribute " + attributeQName + " in " + resource); } return prismContext.deltaFactory().property().createModificationReplaceProperty(ItemPath.create(ShadowType.F_ATTRIBUTES, attributeQName), attributeDefinition, newRealValue); @@ -2621,7 +2633,7 @@ protected PropertyDelta createAttributeAddDelta(PrismObject protected PropertyDelta createAttributeAddDelta(PrismObject resource, QName attributeQName, T... newRealValue) throws SchemaException { PrismPropertyDefinition attributeDefinition = getAttributeDefinition(resource, attributeQName); if (attributeDefinition == null) { - throw new SchemaException("No definition for attribute "+ attributeQName+ " in " + resource); + throw new SchemaException("No definition for attribute " + attributeQName + " in " + resource); } return prismContext.deltaFactory().property().createModificationAddProperty(ItemPath.create(ShadowType.F_ATTRIBUTES, attributeQName), attributeDefinition, newRealValue); @@ -2634,7 +2646,7 @@ protected PropertyDelta createAttributeDeleteDelta(PrismObject PropertyDelta createAttributeDeleteDelta(PrismObject resource, QName attributeQName, T... newRealValue) throws SchemaException { PrismPropertyDefinition attributeDefinition = getAttributeDefinition(resource, attributeQName); if (attributeDefinition == null) { - throw new SchemaException("No definition for attribute "+ attributeQName+ " in " + resource); + throw new SchemaException("No definition for attribute " + attributeQName + " in " + resource); } return prismContext.deltaFactory().property().createModificationDeleteProperty(ItemPath.create(ShadowType.F_ATTRIBUTES, attributeQName), attributeDefinition, newRealValue); @@ -2643,7 +2655,7 @@ protected PropertyDelta createAttributeDeleteDelta(PrismObject resource, QName attributeName) throws SchemaException { RefinedResourceSchema refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource); if (refinedSchema == null) { - throw new SchemaException("No refined schema for "+resource); + throw new SchemaException("No refined schema for " + resource); } RefinedObjectClassDefinition accountDefinition = refinedSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT); return accountDefinition.findAttributeDefinition(attributeName); @@ -2672,7 +2684,7 @@ protected ObjectDelta createAccountPaswordDelta(String shadowOid, St oldPasswordPs.setClearValue(oldPassword); } return deltaFor(ShadowType.class) - .item(SchemaConstants.PATH_PASSWORD_VALUE) + .item(SchemaConstants.PATH_PASSWORD_VALUE) .oldRealValue(oldPasswordPs) .replace(newPasswordPs) .asObjectDelta(shadowOid); @@ -2690,7 +2702,7 @@ protected PrismObject getShadowRepo(String shadowOid) throws ObjectN } protected Collection> createDetlaCollection(ObjectDelta... deltas) { - return (Collection)MiscUtil.createCollection(deltas); + return (Collection) MiscUtil.createCollection(deltas); } public static String getAttributeValue(ShadowType repoShadow, QName name) { @@ -2707,13 +2719,13 @@ protected T getAttributeValue(PrismObject shadow, QNam return (T) value; } if (expectedClass.isAssignableFrom(value.getClass())) { - return (T)value; + return (T) value; } if (value instanceof RawType) { - T parsedRealValue = ((RawType)value).getParsedRealValue(expectedClass); + T parsedRealValue = ((RawType) value).getParsedRealValue(expectedClass); return parsedRealValue; } - fail("Expected that attribute "+attrName+" is "+expectedClass+", but it was "+value.getClass()+": "+value); + fail("Expected that attribute " + attrName + " is " + expectedClass + ", but it was " + value.getClass() + ": " + value); return null; // not reached } @@ -2722,7 +2734,7 @@ protected void assertApproxNumberOfAllResults(SearchResultMetadata searchMetadat if (searchMetadata == null) { return; } - assertNull("Unexpected approximate number of search results in search metadata, expected null but was "+searchMetadata.getApproxNumberOfAllResults(), searchMetadata.getApproxNumberOfAllResults()); + assertNull("Unexpected approximate number of search results in search metadata, expected null but was " + searchMetadata.getApproxNumberOfAllResults(), searchMetadata.getApproxNumberOfAllResults()); } else { assertEquals("Wrong approximate number of search results in search metadata", expectedNumber, searchMetadata.getApproxNumberOfAllResults()); } @@ -2733,7 +2745,7 @@ protected void assertEqualTime(String message, String isoTime, ZonedDateTime act } protected void assertEqualTime(String message, ZonedDateTime expectedTime, ZonedDateTime actualTime) { - assertTrue(message+"; expected "+expectedTime+", but was "+actualTime, expectedTime.isEqual(actualTime)); + assertTrue(message + "; expected " + expectedTime + ", but was " + actualTime, expectedTime.isEqual(actualTime)); } protected XMLGregorianCalendar getTimestamp(String duration) { @@ -2749,8 +2761,8 @@ protected void clockForward(String duration) { protected void assertRelationDef(List relations, QName qname, String expectedLabel) { RelationDefinitionType relDef = ObjectTypeUtil.findRelationDefinition(relations, qname); - assertNotNull("No definition for relation "+qname, relDef); - assertEquals("Wrong relation "+qname+" label", expectedLabel, relDef.getDisplay().getLabel().getOrig()); + assertNotNull("No definition for relation " + qname, relDef); + assertEquals("Wrong relation " + qname + " label", expectedLabel, relDef.getDisplay().getLabel().getOrig()); } protected void initializeAsserter(AbstractAsserter asserter) { @@ -2768,8 +2780,8 @@ protected PolyStringAsserter assertPolyString(PolyString polystring, Strin protected RefinedResourceSchemaAsserter assertRefinedResourceSchema(PrismObject resource, String details) throws SchemaException { RefinedResourceSchema refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource, prismContext); - assertNotNull("No refined schema for "+resource+" ("+details+")", refinedSchema); - RefinedResourceSchemaAsserter asserter = new RefinedResourceSchemaAsserter(refinedSchema, resource.toString() + " ("+details+")"); + assertNotNull("No refined schema for " + resource + " (" + details + ")", refinedSchema); + RefinedResourceSchemaAsserter asserter = new RefinedResourceSchemaAsserter(refinedSchema, resource.toString() + " (" + details + ")"); initializeAsserter(asserter); return asserter; } @@ -2793,7 +2805,7 @@ protected void assertNoRepoShadow(String oid) throws SchemaException { OperationResult result = new OperationResult("assertNoRepoShadow"); try { PrismObject shadow = repositoryService.getObject(ShadowType.class, oid, GetOperationOptions.createRawCollection(), result); - fail("Expected that shadow "+oid+" will not be in the repo. But it was: "+shadow); + fail("Expected that shadow " + oid + " will not be in the repo. But it was: " + shadow); } catch (ObjectNotFoundException e) { // Expected assertFailure(result); @@ -2845,8 +2857,8 @@ protected GetOperationOptionsBuilder getOperationOptionsBuilder() { @NotNull protected Collection> retrieveTaskResult() { return getOperationOptionsBuilder() - .item(TaskType.F_RESULT).retrieve() - .build(); + .item(TaskType.F_RESULT).retrieve() + .build(); } // use only if necessary (use ItemPath.create instead) diff --git a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/MidpointTestMethodContext.java b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/MidpointTestMethodContext.java index cb02dede71d..dfdf346909f 100644 --- a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/MidpointTestMethodContext.java +++ b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/MidpointTestMethodContext.java @@ -20,6 +20,11 @@ public final class MidpointTestMethodContext { private static final ThreadLocal TEST_CONTEXT_THREAD_LOCAL = new ThreadLocal<>(); + /** + * Actual test class - not abstract (where method may be implemented) but executed test class. + */ + private final Class testClass; + /** * Test method name. */ @@ -35,13 +40,26 @@ public final class MidpointTestMethodContext { */ private final OperationResult result; - private MidpointTestMethodContext(String methodName, Task task, OperationResult result) { + private MidpointTestMethodContext( + Class testClass, String methodName, Task task, OperationResult result) { + + this.testClass = testClass; this.methodName = methodName; this.task = task; this.result = result; } - public String getMethodName() { + /** + * Returns name of the test - which is "class-simple-name.method". + */ + public String getTestName() { + return testClass.getSimpleName() + "." + methodName; + } + + /** + * Returns short name of the test - which is method name. + */ + public String getTestNameShort() { return methodName; } @@ -53,8 +71,11 @@ public OperationResult getResult() { return result; } - public static MidpointTestMethodContext create(String methodName, Task task, OperationResult result) { - MidpointTestMethodContext ctx = new MidpointTestMethodContext(methodName, task, result); + public static MidpointTestMethodContext create( + Class testClass, String methodName, Task task, OperationResult result) { + + MidpointTestMethodContext ctx = + new MidpointTestMethodContext(testClass, methodName, task, result); TEST_CONTEXT_THREAD_LOCAL.set(ctx); return ctx; } From 7629f70e4eb5feca1e1070233e2374e43ba7e155 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Wed, 26 Feb 2020 15:54:08 +0100 Subject: [PATCH 15/97] TestPolicyRules, TestPasswordAuthenticationEvaluator: cosmetics/cleanup --- .../model/impl/lens/TestPolicyRules.java | 34 ------------------- .../TestPasswordAuthenticationEvaluator.java | 19 +++++------ 2 files changed, 8 insertions(+), 45 deletions(-) diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules.java index 906016b1bf8..a5601a2d364 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules.java @@ -72,11 +72,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); InternalMonitor.reset(); -// InternalMonitor.setTraceShadowFetchOperation(true); - -// DebugUtil.setPrettyPrintBeansAs(PrismContext.LANG_YAML); - -// setPredefinedTestMethodTracing(MODEL_LOGGING); } @Test @@ -105,7 +100,6 @@ public void test005JackAttemptAssignRoleJudge() throws Exception { TestUtil.assertSuccess(result); dumpPolicyRules(context); - //dumpPolicySituations(context); assertEvaluatedTargetPolicyRules(context, 7); assertTargetTriggers(context, PolicyConstraintKindType.OBJECT_STATE, 2); @@ -141,7 +135,6 @@ public void test007JackAttemptAssignRoleJudgeAsOwner() throws Exception { TestUtil.assertSuccess(result); dumpPolicyRules(context); - //dumpPolicySituations(context); assertEvaluatedTargetPolicyRules(context, 4); assertTargetTriggers(context, PolicyConstraintKindType.ASSIGNMENT_MODIFICATION, 0); @@ -239,10 +232,6 @@ public void test100AssignRoleMutinierToJack() throws Exception { assertAssignAccountToJack(context); -// DeltaSetTriple> evaluatedAssignmentTriple = -// (DeltaSetTriple)context.getEvaluatedAssignmentTriple(); -// display("Output evaluatedAssignmentTriple", evaluatedAssignmentTriple); - dumpPolicyRules(context); dumpPolicySituations(context); assertEvaluatedTargetPolicyRules(context, 7); @@ -276,10 +265,6 @@ public void test110AssignRolePirateToJack() throws Exception { assertAssignAccountToJack(context); -// DeltaSetTriple> evaluatedAssignmentTriple = -// (DeltaSetTriple)context.getEvaluatedAssignmentTriple(); -// display("Output evaluatedAssignmentTriple", evaluatedAssignmentTriple); - dumpPolicyRules(context); dumpPolicySituations(context); assertEvaluatedTargetPolicyRules(context, 7); @@ -323,10 +308,6 @@ public void test112AssignRolePirateWithExceptionToJack() throws Exception { assertAssignAccountToJack(context); -// DeltaSetTriple> evaluatedAssignmentTriple = -// (DeltaSetTriple)context.getEvaluatedAssignmentTriple(); -// display("Output evaluatedAssignmentTriple", evaluatedAssignmentTriple); - dumpPolicyRules(context); dumpPolicySituations(context); List evaluatedRules = assertEvaluatedTargetPolicyRules(context, 7); @@ -366,17 +347,9 @@ public void test120AssignRoleConstableToJack() throws Exception { display("Output context", context); -// DeltaSetTriple> evaluatedAssignmentTriple = -// (DeltaSetTriple)context.getEvaluatedAssignmentTriple(); -// display("Output evaluatedAssignmentTriple", evaluatedAssignmentTriple); - dumpPolicyRules(context); dumpPolicySituations(context); assertEvaluatedTargetPolicyRules(context, 8); - // conflicting assignment was pruned, so the exclusion is no longer present here -// EvaluatedExclusionTrigger trigger = (EvaluatedExclusionTrigger) assertTriggeredTargetPolicyRule(context, null, PolicyConstraintKindType.EXCLUSION, 1, true); -// assertNotNull("No conflicting assignment in trigger", trigger.getConflictingAssignment()); -// assertEquals("Wrong conflicting assignment in trigger", ROLE_JUDGE_OID, trigger.getConflictingAssignment().getTarget().getOid()); ObjectDelta focusSecondaryDelta = context.getFocusContext().getSecondaryDelta(); PrismAsserts.assertIsModify(focusSecondaryDelta); @@ -497,9 +470,6 @@ public void test210AssignRoleEmployeeToJack() throws Exception { result.computeStatus(); TestUtil.assertSuccess(result); -// DeltaSetTriple> evaluatedAssignmentTriple = context.getEvaluatedAssignmentTriple(); - //display("Output evaluatedAssignmentTriple", evaluatedAssignmentTriple); - dumpPolicyRules(context); dumpPolicySituations(context); @@ -541,9 +511,6 @@ public void test220AssignRoleEngineerToJack() throws Exception { result.computeStatus(); TestUtil.assertSuccess(result); -// DeltaSetTriple> evaluatedAssignmentTriple = context.getEvaluatedAssignmentTriple(); - //display("Output evaluatedAssignmentTriple", evaluatedAssignmentTriple); - dumpPolicyRules(context); dumpPolicySituations(context); @@ -646,7 +613,6 @@ public void test400AssignRoleLocalized() throws Exception { TestUtil.assertSuccess(result); dumpPolicyRules(context); - //dumpPolicySituations(context); Locale SLOVAK = Locale.forLanguageTag("sk-SK"); assertNotNull("No Slovak locale", SLOVAK); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/security/TestPasswordAuthenticationEvaluator.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/security/TestPasswordAuthenticationEvaluator.java index c9738744e1e..9753c0d9667 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/security/TestPasswordAuthenticationEvaluator.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/security/TestPasswordAuthenticationEvaluator.java @@ -15,22 +15,15 @@ import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; -import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.PolicyViolationException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SecurityViolationException; +import com.evolveum.midpoint.util.exception.*; import com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractCredentialType; import com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; -public class TestPasswordAuthenticationEvaluator extends TestAbstractAuthenticationEvaluator>{ +public class TestPasswordAuthenticationEvaluator extends TestAbstractAuthenticationEvaluator> { - @Autowired(required=true) + @Autowired private AuthenticationEvaluator passwordAuthenticationEvaluator; @Override @@ -80,7 +73,11 @@ private ProtectedStringType getGuybrushPassword() { } @Override - public void modifyUserCredential(Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + public void modifyUserCredential(Task task, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, + CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserReplace(USER_GUYBRUSH_OID, SchemaConstants.PATH_PASSWORD_VALUE, task, result, getGuybrushPassword()); } From 3965755085507f141fe7b319d9819bd5944d2052 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Wed, 26 Feb 2020 15:55:38 +0100 Subject: [PATCH 16/97] POM: removed javax.annotation declaration, let's inherit from Boot --- pom.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pom.xml b/pom.xml index ca0fdf806f4..756dbaa48d7 100644 --- a/pom.xml +++ b/pom.xml @@ -573,11 +573,6 @@ jsr250-api 1.0 - - javax.annotation - javax.annotation-api - 1.2 - javax.jws jsr181-api From a0a3f9e52e409961dad85d44f31a611a0b8f343d Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Wed, 26 Feb 2020 15:57:11 +0100 Subject: [PATCH 17/97] POM: more mvn command examples + more typical times on slowish notebook --- pom.xml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 756dbaa48d7..d79851157ad 100644 --- a/pom.xml +++ b/pom.xml @@ -30,11 +30,14 @@ "Quick" build with unit tests only and checkstyle (~30m): mvn clean install -P -dist -DskipITs -Dmaven.javadoc.skip - "Quick" build with smaller integration test set and output to stdout (~?): - mvn clean install -P -dist -DintegrationTestSuite=fast -Dmaven.javadoc.skip -DredirectTestOutputToFile=false + "Quick" build with smaller integration test set and output to stdout (~1h20m): + mvn clean install -P -dist -DintegrationTestSuite=fast -Dmaven.javadoc.skip + + Running tests of a selected module (-pl) with output to stdout (don't use stdout for complete build, it's too much): + mvn clean install -DredirectTestOutputToFile=false -pl model/model-intest Long test run (with 16g on CI server, but this should work too - isn't Xmx even unnecessary?), - runs just under 900 tests (~?): + runs just under 900 tests (~1h50m): mvn -P tomcat,extratest clean install -Dsurefire.args="-Xmx8g" -Dfailsafe.args="-Xmx8g -Duser.language=en" Comprehensive quick build/dist with normally excluded modules including checkstyle, but no tests/javadoc (~13m): From 4ab32e0dfaf2f369520131942a499c984419562d Mon Sep 17 00:00:00 2001 From: lskublik Date: Wed, 26 Feb 2020 16:15:29 +0100 Subject: [PATCH 18/97] fix for change height to max for conditional panel --- .../midpoint/gui/impl/factory/ConditionPanelFactory.java | 7 ++++++- .../web/page/admin/reports/component/AceEditorPanel.java | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/factory/ConditionPanelFactory.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/factory/ConditionPanelFactory.java index 82f8aac111e..4737c3a234f 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/factory/ConditionPanelFactory.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/factory/ConditionPanelFactory.java @@ -35,7 +35,12 @@ public void register() { @Override protected Panel getPanel(PrismPropertyPanelContext panelCtx) { - AceEditorPanel conditionPanel = new AceEditorPanel(panelCtx.getComponentId(), null, new ConditionExpressionModel(panelCtx.getRealValueModel(), panelCtx.getPageBase()), 200); + AceEditorPanel conditionPanel = new AceEditorPanel(panelCtx.getComponentId(), null, new ConditionExpressionModel(panelCtx.getRealValueModel(), panelCtx.getPageBase()), 200){ + @Override + protected boolean isResizeToMaxHeight() { + return false; + } + }; // conditionPanel.getEditor().add(new OnChangeAjaxBehavior() { // @Override // protected void onUpdate(AjaxRequestTarget ajaxRequestTarget) { diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/reports/component/AceEditorPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/reports/component/AceEditorPanel.java index c7a4e3859a9..5d8bd914567 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/reports/component/AceEditorPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/reports/component/AceEditorPanel.java @@ -54,10 +54,15 @@ public boolean isVisible() { if (minSize > 0) { editor.setMinHeight(minSize); } + editor.setResizeToMaxHeight(isResizeToMaxHeight()); add(editor); } public AceEditor getEditor(){ return (AceEditor)get(ID_EDITOR); } + + protected boolean isResizeToMaxHeight() { + return true; + } } From 54c6d67a356288272f0d105dfc480678a8cdaac6 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Wed, 26 Feb 2020 19:40:30 +0100 Subject: [PATCH 19/97] Add midpoint.getParentOrgByArchetype method (MID-5370) --- .../model/api/expr/MidpointFunctions.java | 47 +++++- .../model/api/expr/OrgStructFunctions.java | 8 +- .../impl/expr/MidpointFunctionsImpl.java | 149 ++++++++++-------- .../impl/expr/OrgStructFunctionsImpl.java | 41 +++-- 4 files changed, 163 insertions(+), 82 deletions(-) diff --git a/model/model-api/src/main/java/com/evolveum/midpoint/model/api/expr/MidpointFunctions.java b/model/model-api/src/main/java/com/evolveum/midpoint/model/api/expr/MidpointFunctions.java index a8e151a79c1..129d344a10f 100644 --- a/model/model-api/src/main/java/com/evolveum/midpoint/model/api/expr/MidpointFunctions.java +++ b/model/model-api/src/main/java/com/evolveum/midpoint/model/api/expr/MidpointFunctions.java @@ -54,7 +54,7 @@ import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; /** - * @author mederly + * */ @SuppressWarnings("unused") public interface MidpointFunctions { @@ -888,6 +888,8 @@ int countObjects(Class type, ObjectQuery query) List toList(String... s); + long getSequenceCounter(String sequenceOid) throws ObjectNotFoundException, SchemaException; + Collection getManagersOids(UserType user) throws SchemaException, ObjectNotFoundException, SecurityViolationException; Collection getManagersOidsExceptUser(UserType user) throws SchemaException, ObjectNotFoundException, SecurityViolationException, ExpressionEvaluationException; @@ -937,15 +939,25 @@ Collection getManagersOidsExceptUser(@NotNull Collection getParentOrgs(ObjectType object, QName relation, String orgType) throws SchemaException, SecurityViolationException; /** - * Returns parent orgs of the specified object that have a specific orgType. + * Returns parent org of the specified object that have a specific orgType. * @param object base object * @param orgType orgType to select - * @return parent orgs of the specified object that have a specific orgType + * @return parent org of the specified object that have a specific orgType * @throws SchemaException Internal schema error * @throws SecurityViolationException Security violation */ OrgType getParentOrgByOrgType(ObjectType object, String orgType) throws SchemaException, SecurityViolationException; + /** + * Returns parent org of the specified object that have a specific archetype. + * @param object base object + * @param archetypeOid archetype OID to select (null means "any archetype") + * @return parent org of the specified object that have a specific archetype + * @throws SchemaException Internal schema error + * @throws SecurityViolationException Security violation + */ + OrgType getParentOrgByArchetype(ObjectType object, String archetypeOid) throws SchemaException, SecurityViolationException; + /** * Returns parent orgs of the specified object that have a specific relation. * @param object base object @@ -1009,6 +1021,10 @@ Collection getManagersOidsExceptUser(@NotNull Collection lensContext) throws SchemaException; + + boolean hasLinkedAccount(String resourceOid); + boolean isDirectlyAssigned(F focusType, String targetOid); boolean isDirectlyAssigned(String targetOid); @@ -1118,6 +1134,31 @@ TaskType executeChangesAsynchronously(Collection> deltas, ModelEx String translate(LocalizableMessageType message); + Integer countAccounts(String resourceOid, QName attributeName, T attributeValue) + throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, + SecurityViolationException, ExpressionEvaluationException; + + Integer countAccounts(ResourceType resourceType, QName attributeName, T attributeValue) + throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, + SecurityViolationException, ExpressionEvaluationException; + + Integer countAccounts(ResourceType resourceType, String attributeName, T attributeValue) + throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, + SecurityViolationException, ExpressionEvaluationException; + + boolean isUniquePropertyValue(ObjectType objectType, String propertyPathString, T propertyValue) + throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, + SecurityViolationException, ExpressionEvaluationException; + + List getObjectsInConflictOnPropertyValue(O objectType, String propertyPathString, + T propertyValue, boolean getAllConflicting) + throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, + SecurityViolationException, ExpressionEvaluationException; + + boolean isUniqueAccountValue(ResourceType resourceType, ShadowType shadowType, String attributeName, + T attributeValue) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, + SecurityViolationException, ExpressionEvaluationException; + ModelContext getModelContext(); ModelElementContext getFocusContext(); diff --git a/model/model-api/src/main/java/com/evolveum/midpoint/model/api/expr/OrgStructFunctions.java b/model/model-api/src/main/java/com/evolveum/midpoint/model/api/expr/OrgStructFunctions.java index c470acd25f1..97400b22e55 100644 --- a/model/model-api/src/main/java/com/evolveum/midpoint/model/api/expr/OrgStructFunctions.java +++ b/model/model-api/src/main/java/com/evolveum/midpoint/model/api/expr/OrgStructFunctions.java @@ -16,9 +16,10 @@ import javax.xml.namespace.QName; import java.util.Collection; +import java.util.function.Predicate; /** - * @author mederly + * */ public interface OrgStructFunctions { @@ -48,6 +49,8 @@ Collection getManagersOidsExceptUser(@NotNull Collection getParentOrgsByRelation(ObjectType object, QName relation, boolean preAuthorized) throws SchemaException, SecurityViolationException; Collection getParentOrgsByRelation(ObjectType object, String relation, boolean preAuthorized) throws SchemaException, SecurityViolationException; @@ -58,6 +61,9 @@ Collection getManagersOidsExceptUser(@NotNull Collection getParentOrgs(ObjectType object, QName relation, String orgType, boolean preAuthorized) throws SchemaException, SecurityViolationException; + Collection getParentOrgs(ObjectType object, QName relation, @NotNull Predicate predicate, boolean preAuthorized) + throws SchemaException, SecurityViolationException; + Collection getManagersOfOrg(String orgOid, boolean preAuthorized) throws SchemaException, SecurityViolationException; boolean isManagerOf(UserType user, String orgOid, boolean preAuthorized); diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/expr/MidpointFunctionsImpl.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/expr/MidpointFunctionsImpl.java index c7cfc637ca0..a6b522be59b 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/expr/MidpointFunctionsImpl.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/expr/MidpointFunctionsImpl.java @@ -83,8 +83,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; -import org.springframework.web.context.request.RequestContextHolder; -import org.springframework.web.context.request.ServletRequestAttributes; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.Context; @@ -236,6 +234,7 @@ private void takePasswordsFromItemDelta(List passwords, Ite if (itemDelta.getPath().equivalent(PATH_CREDENTIALS_PASSWORD_VALUE)) { LOGGER.trace("Found password value add/modify delta"); + //noinspection unchecked Collection> values = itemDelta.isAdd() ? itemDelta.getValuesToAdd() : itemDelta.getValuesToReplace(); @@ -244,6 +243,7 @@ private void takePasswordsFromItemDelta(List passwords, Ite } } else if (itemDelta.getPath().equivalent(PATH_CREDENTIALS_PASSWORD)) { LOGGER.trace("Found password add/modify delta"); + //noinspection unchecked Collection> values = itemDelta.isAdd() ? itemDelta.getValuesToAdd() : itemDelta.getValuesToReplace(); @@ -254,6 +254,7 @@ private void takePasswordsFromItemDelta(List passwords, Ite } } else if (itemDelta.getPath().equivalent(ShadowType.F_CREDENTIALS)) { LOGGER.trace("Found credentials add/modify delta"); + //noinspection unchecked Collection> values = itemDelta.isAdd() ? itemDelta.getValuesToAdd() : itemDelta.getValuesToReplace(); @@ -293,6 +294,7 @@ public String getPlaintextUserPasswordFromDeltas(List> obj } } + @Override public boolean hasLinkedAccount(String resourceOid) { LensContext ctx = ModelExpressionThreadLocalHolder.getLensContext(); if (ctx == null) { @@ -415,6 +417,7 @@ public boolean isDirectlyAssigned(ObjectType target) { } // EXPERIMENTAL!! + @SuppressWarnings("unused") @Experimental public boolean hasActiveAssignmentTargetSubtype(String roleSubtype) { LensContext lensContext = ModelExpressionThreadLocalHolder.getLensContext(); @@ -426,14 +429,12 @@ public boolean hasActiveAssignmentTargetSubtype(String roleSubtype) { throw new UnsupportedOperationException("hasActiveAssignmentRoleSubtype works only with evaluatedAssignmentTriple"); } Collection> nonNegativeEvaluatedAssignments = evaluatedAssignmentTriple.getNonNegativeValues(); - if (nonNegativeEvaluatedAssignments == null) { - return false; - } for (EvaluatedAssignmentImpl nonNegativeEvaluatedAssignment : nonNegativeEvaluatedAssignments) { PrismObject target = nonNegativeEvaluatedAssignment.getTarget(); if (target == null) { continue; } + //noinspection unchecked Collection targetSubtypes = FocusTypeUtil.determineSubTypes((PrismObject) target); if (targetSubtypes.contains(roleSubtype)) { return true; @@ -564,6 +565,7 @@ public boolean isProjectionExists() { return projectionContext.isExists(); } + @Override public Integer countAccounts(String resourceOid, QName attributeName, T attributeValue) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { @@ -572,6 +574,7 @@ public Integer countAccounts(String resourceOid, QName attributeName, T attr return countAccounts(resourceType, attributeName, attributeValue, getCurrentTask(), result); } + @Override public Integer countAccounts(ResourceType resourceType, QName attributeName, T attributeValue) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { @@ -579,6 +582,7 @@ public Integer countAccounts(ResourceType resourceType, QName attributeName, return countAccounts(resourceType, attributeName, attributeValue, getCurrentTask(), result); } + @Override public Integer countAccounts(ResourceType resourceType, String attributeName, T attributeValue) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { @@ -591,17 +595,11 @@ private Integer countAccounts(ResourceType resourceType, QName attributeName OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resourceType); - RefinedObjectClassDefinition rAccountDef = rSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT); - RefinedAttributeDefinition attrDef = rAccountDef.findAttributeDefinition(attributeName); - ObjectQuery query = prismContext.queryFor(ShadowType.class) - .itemWithDef(attrDef, ShadowType.F_ATTRIBUTES, attrDef.getItemName()).eq(attributeValue) - .and().item(ShadowType.F_OBJECT_CLASS).eq(rAccountDef.getObjectClassDefinition().getTypeName()) - .and().item(ShadowType.F_RESOURCE_REF).ref(resourceType.getOid()) - .build(); + ObjectQuery query = createAttributeQuery(resourceType, attributeName, attributeValue); return modelObjectResolver.countObjects(ShadowType.class, query, null, task, result); } + @Override public boolean isUniquePropertyValue(ObjectType objectType, String propertyPathString, T propertyValue) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { @@ -620,6 +618,7 @@ private boolean isUniquePropertyValue(final ObjectType objectType, ItemPath return conflictingObjects.isEmpty(); } + @Override public List getObjectsInConflictOnPropertyValue(O objectType, String propertyPathString, T propertyValue, boolean getAllConflicting) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, @@ -664,31 +663,30 @@ private List getObjectsInConflictOnPropertyValue(fi } final List conflictingObjects = new ArrayList<>(); - ResultHandler handler = new ResultHandler() { - @Override - public boolean handle(PrismObject object, OperationResult parentResult) { - if (objectType.getOid() == null) { - // We have found a conflicting object + ResultHandler handler = (object, parentResult) -> { + if (objectType.getOid() == null) { + // We have found a conflicting object + conflictingObjects.add(object.asObjectable()); + return getAllConflicting; + } else { + if (objectType.getOid().equals(object.getOid())) { + // We have found ourselves. No conflict (yet). Just go on. + return true; + } else { + // We have found someone else. Conflict. conflictingObjects.add(object.asObjectable()); return getAllConflicting; - } else { - if (objectType.getOid().equals(object.getOid())) { - // We have found ourselves. No conflict (yet). Just go on. - return true; - } else { - // We have found someone else. Conflict. - conflictingObjects.add(object.asObjectable()); - return getAllConflicting; - } } } }; + //noinspection unchecked modelObjectResolver.searchIterative((Class) objectType.getClass(), query, null, handler, task, result); return conflictingObjects; } + @Override public boolean isUniqueAccountValue(ResourceType resourceType, ShadowType shadowType, String attributeName, T attributeValue) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { @@ -706,35 +704,24 @@ private boolean isUniqueAccountValue(ResourceType resourceType, final Shadow Validate.notNull(shadowType, "Null shadow"); Validate.notNull(attributeName, "Null attribute name"); Validate.notNull(attributeValue, "Null attribute value"); - RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resourceType); - RefinedObjectClassDefinition rAccountDef = rSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT); - RefinedAttributeDefinition attrDef = rAccountDef.findAttributeDefinition(attributeName); - ObjectQuery query = prismContext.queryFor(ShadowType.class) - .itemWithDef(attrDef, ShadowType.F_ATTRIBUTES, attrDef.getItemName()).eq(attributeValue) - .and().item(ShadowType.F_OBJECT_CLASS).eq(rAccountDef.getObjectClassDefinition().getTypeName()) - .and().item(ShadowType.F_RESOURCE_REF).ref(resourceType.getOid()) - .build(); - if (LOGGER.isTraceEnabled()) { - LOGGER.trace("Determining uniqueness of attribute {} using query:\n{}", attributeName, query.debugDump()); - } + + ObjectQuery query = createAttributeQuery(resourceType, attributeName, attributeValue); + LOGGER.trace("Determining uniqueness of attribute {} using query:\n{}", attributeName, query.debugDumpLazily()); final Holder isUniqueHolder = new Holder<>(true); - ResultHandler handler = new ResultHandler() { - @Override - public boolean handle(PrismObject object, OperationResult parentResult) { - if (shadowType == null || shadowType.getOid() == null) { - // We have found a conflicting object + ResultHandler handler = (object, parentResult) -> { + if (shadowType.getOid() == null) { + // We have found a conflicting object + isUniqueHolder.setValue(false); + return false; + } else { + if (shadowType.getOid().equals(object.getOid())) { + // We have found ourselves. No conflict (yet). Just go on. + return true; + } else { + // We have found someone else. Conflict. isUniqueHolder.setValue(false); return false; - } else { - if (shadowType.getOid().equals(object.getOid())) { - // We have found ourselves. No conflict (yet). Just go on. - return true; - } else { - // We have found someone else. Conflict. - isUniqueHolder.setValue(false); - return false; - } } } }; @@ -744,6 +731,20 @@ public boolean handle(PrismObject object, OperationResult parentResu return isUniqueHolder.getValue(); } + private ObjectQuery createAttributeQuery(ResourceType resourceType, QName attributeName, T attributeValue) throws SchemaException { + RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resourceType); + RefinedObjectClassDefinition rAccountDef = rSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT); + RefinedAttributeDefinition attrDef = rAccountDef.findAttributeDefinition(attributeName); + if (attrDef == null) { + throw new SchemaException("No attribute '" + attributeName + "' in " + rAccountDef); + } + return prismContext.queryFor(ShadowType.class) + .itemWithDef(attrDef, ShadowType.F_ATTRIBUTES, attrDef.getItemName()).eq(attributeValue) + .and().item(ShadowType.F_OBJECT_CLASS).eq(rAccountDef.getObjectClassDefinition().getTypeName()) + .and().item(ShadowType.F_RESOURCE_REF).ref(resourceType.getOid()) + .build(); + } + @Override public ModelContext getModelContext() { return ModelExpressionThreadLocalHolder.getLensContext(); @@ -755,6 +756,7 @@ public ModelElementContext getFocusContext() { if (lensContext == null) { return null; } + //noinspection unchecked return (ModelElementContext) lensContext.getFocusContext(); } @@ -814,8 +816,9 @@ public ModelContext unwrapModelContext(LensContextType lensContextType) getCurrentResult(MidpointFunctions.class.getName() + "getObject")); } - public LensContextType wrapModelContext(LensContext lensContext) throws SchemaException { - return lensContext.toLensContextType(); + @Override + public LensContextType wrapModelContext(ModelContext lensContext) throws SchemaException { + return ((LensContext) lensContext).toLensContextType(); } // Convenience functions @@ -921,8 +924,9 @@ public void executeChanges( modelService.executeChanges(deltas, null, getCurrentTask(), getCurrentResult()); } + @SafeVarargs @Override - public void executeChanges(ObjectDelta... deltas) + public final void executeChanges(ObjectDelta... deltas) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, @@ -1037,6 +1041,7 @@ public PrismObject findShadowOwner(String accountOid) public PrismObject searchShadowOwner(String accountOid) throws ObjectNotFoundException, SecurityViolationException, SchemaException, ConfigurationException, ExpressionEvaluationException, CommunicationException { + //noinspection unchecked return (PrismObject) modelService.searchShadowOwner(accountOid, null, getCurrentTask(), getCurrentResult()); } @@ -1171,6 +1176,7 @@ public ObjectDeltaType getResourceDelta(ModelContext context, String resourceOid return DeltaConvertor.toObjectDeltaType(sum); } + @Override public long getSequenceCounter(String sequenceOid) throws ObjectNotFoundException, SchemaException { return SequentialValueExpressionEvaluator.getSequenceCounter(sequenceOid, repositoryService, getCurrentResult()); } @@ -1179,7 +1185,7 @@ public long getSequenceCounter(String sequenceOid) throws ObjectNotFoundExceptio @Override public Collection getManagersOids(UserType user) - throws SchemaException, ObjectNotFoundException, SecurityViolationException { + throws SchemaException, SecurityViolationException { return orgStructFunctions.getManagersOids(user, false); } @@ -1193,6 +1199,11 @@ public OrgType getParentOrgByOrgType(ObjectType object, String orgType) throws S return orgStructFunctions.getParentOrgByOrgType(object, orgType, false); } + @Override + public OrgType getParentOrgByArchetype(ObjectType object, String archetypeOid) throws SchemaException, SecurityViolationException { + return orgStructFunctions.getParentOrgByArchetype(object, archetypeOid, false); + } + @Override public OrgType getOrgByOid(String oid) throws SchemaException { return orgStructFunctions.getOrgByOid(oid, false); @@ -1219,14 +1230,13 @@ public boolean isManagerOfOrgType(UserType user, String orgType) throws SchemaEx } @Override - public Collection getManagers(UserType user) - throws SchemaException, ObjectNotFoundException, SecurityViolationException { + public Collection getManagers(UserType user) throws SchemaException, SecurityViolationException { return orgStructFunctions.getManagers(user, false); } @Override public Collection getManagersByOrgType(UserType user, String orgType) - throws SchemaException, ObjectNotFoundException, SecurityViolationException { + throws SchemaException, SecurityViolationException { return orgStructFunctions.getManagersByOrgType(user, orgType, false); } @@ -1243,7 +1253,7 @@ public Collection getParentOrgsByRelation(ObjectType object, String rel @Override public Collection getManagers(UserType user, String orgType, boolean allowSelf) - throws SchemaException, ObjectNotFoundException, SecurityViolationException { + throws SchemaException, SecurityViolationException { return orgStructFunctions.getManagers(user, orgType, allowSelf, false); } @@ -1255,7 +1265,7 @@ public Collection getParentOrgs(ObjectType object, String relation, Str @Override public Collection getManagersOidsExceptUser(UserType user) - throws SchemaException, ObjectNotFoundException, SecurityViolationException { + throws SchemaException, SecurityViolationException { return orgStructFunctions.getManagersOidsExceptUser(user, false); } @@ -1316,7 +1326,7 @@ public Map parseXmlToMap(String xml) { while (eventReader.hasNext()) { XMLEvent event = eventReader.nextEvent(); - Integer code = event.getEventType(); + int code = event.getEventType(); if (code == XMLStreamConstants.START_ELEMENT) { StartElement startElement = event.asStartElement(); @@ -1332,9 +1342,9 @@ public Map parseXmlToMap(String xml) { StringBuilder valueBuilder; if (value != null) { - valueBuilder = new StringBuilder(value).append(" ").append(characters.getData().toString()); + valueBuilder = new StringBuilder(value).append(" ").append(characters.getData()); } else { - valueBuilder = new StringBuilder(characters.getData().toString()); + valueBuilder = new StringBuilder(characters.getData()); } value = valueBuilder.toString(); } @@ -1439,10 +1449,12 @@ public WorkflowService getWorkflowService() { public List getShadowsToActivate(Collection projectionContexts) { List shadows = new ArrayList<>(); + //noinspection unchecked for (ModelElementContext projectionCtx : projectionContexts) { - List executedShadowDelas = projectionCtx.getExecutedDeltas(); - for (ObjectDeltaOperation shadowDelta : executedShadowDelas) { + List executedShadowDeltas = projectionCtx.getExecutedDeltas(); + //noinspection unchecked + for (ObjectDeltaOperation shadowDelta : executedShadowDeltas) { if (shadowDelta.getExecutionResult().getStatus() == OperationResultStatus.SUCCESS && shadowDelta.getObjectDelta().getChangeType() == ChangeType.ADD) { PrismObject shadow = shadowDelta.getObjectDelta().getObjectToAdd(); @@ -1530,7 +1542,7 @@ private String createPrefixLinkByAuthSequence(String channel, String nameOfSeque } private SecurityPolicyType resolveSecurityPolicy(PrismObject user) { - SecurityPolicyType securityPolicy = securityContextManager.runPrivileged(new Producer() { + return securityContextManager.runPrivileged(new Producer() { private static final long serialVersionUID = 1L; @Override @@ -1553,7 +1565,6 @@ public SecurityPolicyType run() { } }); - return securityPolicy; } private String getPublicHttpUrlPattern() { @@ -1943,11 +1954,13 @@ public MessageWrapper wrap(AsyncUpdateMessageType message) { } // temporary + @SuppressWarnings("unused") public Map getMessageBodyAsMap(AsyncUpdateMessageType message) throws IOException { return wrap(message).getBodyAsMap(); } // temporary + @SuppressWarnings("unused") public Item getMessageBodyAsPrismItem(AsyncUpdateMessageType message) throws SchemaException { return wrap(message).getBodyAsPrismItem(PrismContext.LANG_XML); } diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/expr/OrgStructFunctionsImpl.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/expr/OrgStructFunctionsImpl.java index 027a915b140..ee324dd66c3 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/expr/OrgStructFunctionsImpl.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/expr/OrgStructFunctionsImpl.java @@ -35,6 +35,7 @@ import javax.xml.namespace.QName; import java.util.*; +import java.util.function.Predicate; import static com.evolveum.midpoint.schema.util.FocusTypeUtil.determineSubTypes; @@ -214,11 +215,11 @@ public OrgType getOrgByName(String name, boolean preAuthorized) throws SchemaExc List> result = searchObjects(OrgType.class, q, midpointFunctions.getCurrentResult(), preAuthorized); if (result.isEmpty()) { return null; - } - if (result.size() > 1) { + } else if (result.size() > 1) { throw new IllegalStateException("More than one organizational unit with the name '" + name + "' (there are " + result.size() + " of them)"); + } else { + return result.get(0).asObjectable(); } - return result.get(0).asObjectable(); } @Override @@ -226,16 +227,29 @@ public OrgType getParentOrgByOrgType(ObjectType object, String orgType, boolean Collection parentOrgs = getParentOrgs(object, PrismConstants.Q_ANY, orgType, preAuthorized); if (parentOrgs.isEmpty()) { return null; - } - if (parentOrgs.size() > 1) { + } else if (parentOrgs.size() > 1) { throw new IllegalArgumentException("Expected that there will be just one parent org of type "+orgType+" for "+object+", but there were "+parentOrgs.size()); + } else { + return parentOrgs.iterator().next(); + } + } + + @Override + public OrgType getParentOrgByArchetype(ObjectType object, String archetypeOid, boolean preAuthorized) throws SchemaException, SecurityViolationException { + Collection parentOrgs = getParentOrgs(object, PrismConstants.Q_ANY, org -> archetypeOid == null + || ObjectTypeUtil.hasArchetype(org, archetypeOid), preAuthorized); + if (parentOrgs.isEmpty()) { + return null; + } else if (parentOrgs.size() > 1) { + throw new IllegalArgumentException("Expected that there will be just one parent org of archetype "+archetypeOid+" for "+object+", but there were "+parentOrgs.size()); + } else { + return parentOrgs.iterator().next(); } - return parentOrgs.iterator().next(); } @Override public Collection getParentOrgsByRelation(ObjectType object, QName relation, boolean preAuthorized) throws SchemaException, SecurityViolationException { - return getParentOrgs(object, relation, null, preAuthorized); + return getParentOrgs(object, relation, org -> true, preAuthorized); } @Override @@ -245,7 +259,7 @@ public Collection getParentOrgsByRelation(ObjectType object, String rel @Override public Collection getParentOrgs(ObjectType object, boolean preAuthorized) throws SchemaException, SecurityViolationException { - return getParentOrgs(object, PrismConstants.Q_ANY, null, preAuthorized); + return getParentOrgs(object, PrismConstants.Q_ANY, org -> true, preAuthorized); } @Override @@ -254,7 +268,14 @@ public Collection getParentOrgs(ObjectType object, String relation, Str } @Override - public Collection getParentOrgs(ObjectType object, QName relation, String orgType, boolean preAuthorized) throws SchemaException, SecurityViolationException { + public Collection getParentOrgs(ObjectType object, QName relation, String orgType, boolean preAuthorized) + throws SchemaException, SecurityViolationException { + return getParentOrgs(object, relation, org -> orgType == null || determineSubTypes(org).contains(orgType), preAuthorized); + } + + @Override + public Collection getParentOrgs(ObjectType object, QName relation, @NotNull Predicatepredicate, boolean preAuthorized) + throws SchemaException, SecurityViolationException { List parentOrgRefs = object.getParentOrgRef(); List parentOrgs = new ArrayList<>(parentOrgRefs.size()); for (ObjectReferenceType parentOrgRef: parentOrgRefs) { @@ -272,7 +293,7 @@ public Collection getParentOrgs(ObjectType object, QName relation, Stri // This should not happen. throw new SystemException(e.getMessage(), e); } - if (orgType == null || determineSubTypes(parentOrg).contains(orgType)) { + if (predicate.test(parentOrg)) { parentOrgs.add(parentOrg); } } From 07cb6c2615f8046264112fd8e08a6424c2608410 Mon Sep 17 00:00:00 2001 From: Katarina Valalikova Date: Wed, 26 Feb 2020 23:05:53 +0100 Subject: [PATCH 20/97] resource operational state - extending information with nodeId, message and timestamp. support for operational state history.. (max 5 records) --- .../provisioning/impl/ResourceManager.java | 89 +++++++++++++++++-- 1 file changed, 83 insertions(+), 6 deletions(-) diff --git a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ResourceManager.java b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ResourceManager.java index ff8de0db549..6a69eb71e0a 100644 --- a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ResourceManager.java +++ b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ResourceManager.java @@ -9,8 +9,12 @@ import java.util.*; +import javax.xml.datatype.DatatypeConstants; +import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; +import com.evolveum.midpoint.common.Clock; +import com.evolveum.midpoint.common.Utils; import com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition; import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl; import com.evolveum.midpoint.prism.*; @@ -18,6 +22,8 @@ import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.schema.MutablePrismSchema; import com.evolveum.midpoint.schema.processor.*; +import com.evolveum.midpoint.task.api.TaskManager; +import com.evolveum.midpoint.util.MiscUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.SchemaDefinitionType; @@ -85,11 +91,14 @@ public class ResourceManager { @Autowired private ConnectorManager connectorManager; @Autowired private PrismContext prismContext; @Autowired private ExpressionFactory expressionFactory; + @Autowired private TaskManager taskManager; + @Autowired private Clock clock; private static final Trace LOGGER = TraceManager.getTrace(ResourceManager.class); private static final String OP_COMPLETE_RESOURCE = ResourceManager.class.getName() + ".completeResource"; + private static final int MAX_OPERATIONAL_HISOTRY_SIZE = 5; /** * Completes a resource that has been - we expect - just retrieved from the repository, usually by a search operation. */ @@ -1018,15 +1027,16 @@ public void modifyResourceAvailabilityStatus(String resourceOid, AvailabilitySta AvailabilityStatusType currentStatus; String description; + PrismObject resource = null; if (skipGetResource) { currentStatus = null; description = "resource " + resourceOid; } else { - PrismObject resource; try { resource = getResource(resourceOid, GetOperationOptions.createNoFetch(), task, result); } catch (SchemaException | ExpressionEvaluationException | ConfigurationException | CommunicationException e) { // We actually do not expect any of these exceptions here. The resource is most probably in use + result.recordFatalError("Unexpected exception: " + e.getMessage(), e); throw new SystemException("Unexpected exception: " + e.getMessage(), e); } ResourceType resourceBean = resource.asObjectable(); @@ -1038,8 +1048,10 @@ public void modifyResourceAvailabilityStatus(String resourceOid, AvailabilitySta //info becasue it's for diagnosing the issues with resource availability LOGGER.info("Availability status changed from {} to {} for {} because {}", currentStatus, newStatus, description, operationCtx); try { - List> modifications = singletonList(createResourceAvailabilityStatusDelta(newStatus)); + String message = "Availability status changed from " + currentStatus + " to " + newStatus + " for " + description + " because " +operationCtx; + List> modifications = createOperationalStateDelta(newStatus, message, resource);//singletonList(createResourceAvailabilityStatusDelta(newStatus)); repositoryService.modifyObject(ResourceType.class, resourceOid, modifications, result); + result.computeStatusIfUnknown(); InternalMonitor.recordCount(InternalCounters.RESOURCE_REPOSITORY_MODIFY_COUNT); } catch (SchemaException | ObjectAlreadyExistsException e) { throw new SystemException("Unexpected exception: " + e.getMessage(), e); @@ -1047,13 +1059,78 @@ public void modifyResourceAvailabilityStatus(String resourceOid, AvailabilitySta } } - private ContainerDelta createOperationalStateDelta(AvailabilityStatusType status, String message) { + private List> createOperationalStateDelta(AvailabilityStatusType status, String message, PrismObject resource) throws SchemaException { OperationalStateType state = new OperationalStateType(prismContext); state.setMessage(message); state.setLastAvailabilityStatus(status); -// state.setNodeId(); -// state.setTimestamp(); - return null; + state.setNodeId(taskManager.getNodeId()); + state.setTimestamp(clock.currentTimeXMLGregorianCalendar()); + + ItemDelta lastAvailabilityStatus = prismContext.deltaFor(ResourceType.class).item(ResourceType.F_OPERATIONAL_STATE).replace(state).asItemDelta(); + + List> deltas = new ArrayList<>(); + deltas.add(lastAvailabilityStatus); + addHistoryDeltas(resource, state, deltas); + return deltas; + } + + private void addHistoryDeltas(PrismObject resource, OperationalStateType newState, List> deltas) throws SchemaException { + cleanupHistoryDeltas(resource, deltas); + + ItemDelta addNewDelta = prismContext.deltaFor(ResourceType.class).item(ResourceType.F_OPERATIONAL_STATE_HISTORY).add(newState.clone()).asItemDelta(); + deltas.add(addNewDelta); + } + + private void cleanupHistoryDeltas(PrismObject resource, List> deltas) throws SchemaException { + if (resource == null) { + return; + } + + List history = new ArrayList<>(resource.asObjectable().getOperationalStateHistory()); + int historySize = history.size(); + if (historySize >= MAX_OPERATIONAL_HISOTRY_SIZE) { + Comparator timestampCompare = (r1, r2) -> { + OperationalStateType state1 = (OperationalStateType) r1; + OperationalStateType state2 = (OperationalStateType) r2; + if (state1 == null) { + return (state2 == null ? DatatypeConstants.EQUAL : DatatypeConstants.GREATER); + } + + if (state2 == null) { + return (state1 == null ? DatatypeConstants.EQUAL : DatatypeConstants.LESSER); + } + + XMLGregorianCalendar gc1 = state1.getTimestamp(); + XMLGregorianCalendar gc2 = state2.getTimestamp(); + + Long t1 = MiscUtil.asLong(gc1); + Long t2 = MiscUtil.asLong(gc2); + return t2.compareTo(t1); + }; + + Collections.sort(history, timestampCompare); + if (MAX_OPERATIONAL_HISOTRY_SIZE == historySize) { + ItemDelta deleteOldDelta = prismContext.deltaFor(ResourceType.class) + .item(ResourceType.F_OPERATIONAL_STATE_HISTORY) + .delete(history.get(historySize - 1).clone()) + .asItemDelta(); + deltas.add(deleteOldDelta); + } + + // in case the resource was not available last time we updated history + // there might me more then MAX_OPERATIONAL_HISOTY_SIZE records, so + // just remove them now. + if (MAX_OPERATIONAL_HISOTRY_SIZE < historySize) { + int recordsToDelete = historySize - MAX_OPERATIONAL_HISOTRY_SIZE + 1; + for (int i = 1; i <= recordsToDelete; i++) { + ItemDelta deleteOldDelta = prismContext.deltaFor(ResourceType.class) + .item(ResourceType.F_OPERATIONAL_STATE_HISTORY) + .delete(history.get(historySize - i).clone()) + .asItemDelta(); + deltas.add(deleteOldDelta); + } + } + } } private ItemDelta createResourceAvailabilityStatusDelta(AvailabilityStatusType status) throws SchemaException { From 94393236fbd41a1ce9f9543dd4754cb368688045 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Thu, 27 Feb 2020 01:50:35 +0100 Subject: [PATCH 21/97] TestOpenDj: openDJController.addEntry moved from #init to #startLdap Change was necessary after changing AbstractIT#init to @PostConstruct. --- .../provisioning/impl/opendj/TestOpenDj.java | 75 ++++++------------- 1 file changed, 23 insertions(+), 52 deletions(-) diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDj.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDj.java index b99ed112e95..ef57a767bec 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDj.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDj.java @@ -6,37 +6,16 @@ */ package com.evolveum.midpoint.provisioning.impl.opendj; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.*; import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; - +import java.util.*; import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; -import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl; -import com.evolveum.midpoint.prism.*; - -import com.evolveum.midpoint.prism.delta.*; -import com.evolveum.midpoint.prism.path.ItemName; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.prism.polystring.PolyString; -import com.evolveum.midpoint.prism.query.*; -import com.evolveum.midpoint.schema.processor.*; - -import com.evolveum.midpoint.test.AbstractIntegrationTest; -import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import org.apache.commons.lang.StringUtils; import org.opends.server.types.Entry; import org.opends.server.util.LDIFException; @@ -53,25 +32,29 @@ import com.evolveum.midpoint.common.refinery.RefinedAttributeDefinition; import com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition; import com.evolveum.midpoint.common.refinery.RefinedResourceSchema; +import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl; +import com.evolveum.midpoint.prism.*; +import com.evolveum.midpoint.prism.delta.ItemDelta; +import com.evolveum.midpoint.prism.delta.ObjectDelta; +import com.evolveum.midpoint.prism.delta.PropertyDelta; +import com.evolveum.midpoint.prism.path.ItemName; +import com.evolveum.midpoint.prism.path.ItemPath; +import com.evolveum.midpoint.prism.polystring.PolyString; +import com.evolveum.midpoint.prism.query.ObjectPaging; +import com.evolveum.midpoint.prism.query.ObjectQuery; +import com.evolveum.midpoint.prism.query.OrderDirection; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.prism.xml.XmlTypeConverter; import com.evolveum.midpoint.provisioning.impl.ProvisioningTestUtil; -import com.evolveum.midpoint.schema.CapabilityUtil; -import com.evolveum.midpoint.schema.DeltaConvertor; -import com.evolveum.midpoint.schema.GetOperationOptions; -import com.evolveum.midpoint.schema.ResultHandler; -import com.evolveum.midpoint.schema.SearchResultList; -import com.evolveum.midpoint.schema.SearchResultMetadata; +import com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance; +import com.evolveum.midpoint.schema.*; import com.evolveum.midpoint.schema.constants.ConnectorTestOperation; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.internals.InternalCounters; +import com.evolveum.midpoint.schema.processor.*; import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.schema.util.MiscSchemaUtil; -import com.evolveum.midpoint.schema.util.ObjectQueryUtil; -import com.evolveum.midpoint.schema.util.ShadowUtil; -import com.evolveum.midpoint.schema.util.ResourceTypeUtil; -import com.evolveum.midpoint.schema.util.SchemaDebugUtil; +import com.evolveum.midpoint.schema.util.*; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.task.api.TaskManager; import com.evolveum.midpoint.test.IntegrationTestTools; @@ -90,20 +73,12 @@ import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType; import com.evolveum.midpoint.xml.ns._public.common.api_types_3.PropertyReferenceListType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CreateCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.DeleteCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.PagedSearchCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.PasswordCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ReadCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ScriptCapabilityType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; +import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.*; import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ScriptCapabilityType.Host; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.UpdateCapabilityType; import com.evolveum.prism.xml.ns._public.query_3.QueryType; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; -import com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance; /** * Test for provisioning service implementation. @@ -166,13 +141,6 @@ protected int getNumberOfBaseContextShadows() { @Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { super.initSystem(initTask, initResult); - - openDJController.addEntry("dn: ou=specialgroups,dc=example,dc=com\n"+ - "objectclass: organizationalUnit\n"+ - "ou: specialgroups\n"); - - // This is useful when debugging polystring issues, but too much noise otherwise -// DebugUtil.setDetailedDebugDump(true); } @BeforeClass @@ -181,7 +149,10 @@ public static void startLdap() throws Exception { LOGGER.info("START: ProvisioningServiceImplOpenDJTest"); LOGGER.info("------------------------------------------------------------------------------"); try { - openDJController.startCleanServer(); + openDJController.startCleanServer(); + openDJController.addEntry("dn: ou=specialgroups,dc=example,dc=com\n" + + "objectclass: organizationalUnit\n" + + "ou: specialgroups\n"); } catch (IOException ex) { LOGGER.error("Couldn't start LDAP.", ex); throw ex; From e224733683a05b14562a480ff7d74a92b5d2324b Mon Sep 17 00:00:00 2001 From: lskublik Date: Thu, 27 Feb 2020 08:56:01 +0100 Subject: [PATCH 22/97] adding of new column with actual node to table on PageNodes (MID-1913) --- .../web/page/admin/server/PageNodes.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageNodes.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageNodes.java index 8d90f10c33b..e826d50367f 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageNodes.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageNodes.java @@ -11,6 +11,7 @@ import com.evolveum.midpoint.gui.api.component.MainObjectListPanel; import com.evolveum.midpoint.gui.api.util.WebComponentUtil; import com.evolveum.midpoint.prism.delta.ObjectDelta; +import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.result.OperationResultStatus; import com.evolveum.midpoint.security.api.AuthorizationConstants; @@ -27,8 +28,10 @@ import com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem; import com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem; import com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction; +import com.evolveum.midpoint.web.component.util.EnableBehaviour; import com.evolveum.midpoint.web.component.util.SelectableBean; import com.evolveum.midpoint.web.component.util.SelectableBeanImpl; +import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour; import com.evolveum.midpoint.web.page.admin.PageAdmin; import com.evolveum.midpoint.web.session.UserProfileStorage; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; @@ -38,12 +41,14 @@ import org.apache.wicket.AttributeModifier; import org.apache.wicket.Component; import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.markup.html.form.AjaxCheckBox; import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator; import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn; import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.repeater.Item; import org.apache.wicket.model.IModel; +import org.apache.wicket.model.Model; import javax.xml.datatype.XMLGregorianCalendar; import java.util.ArrayList; @@ -122,6 +127,34 @@ protected String translate(Enum en) { } }); + columns.add(new CheckBoxColumn>(createStringResource("pageTasks.node.actualNode")) { + private static final long serialVersionUID = 1L; + + @Override + protected IModel getEnabled(IModel> rowModel) { + return Model.of(Boolean.FALSE); + } + + @Override + protected IModel getCheckBoxValueModel(IModel> rowModel) { + return new IModel() { + + private static final long serialVersionUID = 1L; + + @Override + public Boolean getObject() { + if (getTaskManager().getNodeId() != null && rowModel != null + && rowModel.getObject() != null && rowModel.getObject().getValue() != null + && getTaskManager().getNodeId().equals(rowModel.getObject().getValue().getNodeIdentifier())) { + return Boolean.TRUE; + } + + return Boolean.FALSE; + } + }; + } + }); + columns.add(new AbstractColumn, String>(createStringResource("pageTasks.node.contact")) { @Override From b2d9ea7732d98128bb1b61906e6c91532fe1cdcb Mon Sep 17 00:00:00 2001 From: kate Date: Thu, 27 Feb 2020 13:43:13 +0100 Subject: [PATCH 23/97] redirect from resource accounts tab to tasks page --- .../admin/resources/ResourceContentPanel.java | 139 +++++++++--------- .../web/page/admin/server/PageTasks.java | 16 +- .../xml/ns/public/common/common-core-3.xsd | 14 ++ 3 files changed, 102 insertions(+), 67 deletions(-) diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/ResourceContentPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/ResourceContentPanel.java index e24d0566d1d..7b5789e06ec 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/ResourceContentPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/ResourceContentPanel.java @@ -14,6 +14,7 @@ import javax.xml.namespace.QName; import com.evolveum.midpoint.gui.api.component.PendingOperationPanel; +import com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView; import com.evolveum.midpoint.prism.delta.*; import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.query.QueryFactory; @@ -22,6 +23,7 @@ import com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem; import com.evolveum.midpoint.web.component.util.SelectableBean; import com.evolveum.midpoint.web.page.admin.server.PageTask; +import com.evolveum.midpoint.web.page.admin.server.PageTasks; import com.evolveum.midpoint.web.security.util.SecurityUtils; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; @@ -322,72 +324,21 @@ public boolean isVisible() { } }); - OperationResult result = new OperationResult(OPERATION_SEARCH_TASKS_FOR_RESOURCE); - - List> importTasks = WebModelServiceUtils - .searchObjects(TaskType.class, - getPageBase().getPrismContext().queryFor(TaskType.class) - .block() - .item(TaskType.F_OBJECT_REF).ref(getResourceModel().getObject().getOid()) - .and() - .item(TaskType.F_CATEGORY).eq(TaskCategory.IMPORTING_ACCOUNTS) - .endBlock() -// .or() //todo uncomment when archetype oid is fixed -// .item(AssignmentHolderType.F_ARCHETYPE_REF).ref(SystemObjectsType.ARCHETYPE_RECONCILIATION_TASK.value()) //TODO fix archetype ref - .build(), - result, getPageBase()); - - List> reconTasks = WebModelServiceUtils - .searchObjects(TaskType.class, - getPageBase().getPrismContext().queryFor(TaskType.class) - .block() - .item(TaskType.F_OBJECT_REF).ref(getResourceModel().getObject().getOid()) - .and() - .item(TaskType.F_CATEGORY).eq(TaskCategory.RECONCILIATION) - .endBlock() - .or() - .item(AssignmentHolderType.F_ARCHETYPE_REF).ref(SystemObjectsType.ARCHETYPE_RECONCILIATION_TASK.value()) - .build(), - result, getPageBase()); - - List> syncTasks = WebModelServiceUtils - .searchObjects(TaskType.class, - getPageBase().getPrismContext().queryFor(TaskType.class) - .block() - .item(TaskType.F_OBJECT_REF).ref(getResourceModel().getObject().getOid()) - .and() - .item(TaskType.F_CATEGORY).eq(TaskCategory.LIVE_SYNCHRONIZATION) - .endBlock() -// .or() //todo uncomment when archetype oid is fixed -// .item(AssignmentHolderType.F_ARCHETYPE_REF).ref(SystemObjectsType.ARCHETYPE_RECONCILIATION_TASK.value()) //TODO fix archetype ref - .build(), - result, getPageBase()); - -// List tasksForKind = getTasksForKind(importTasks); - -// List importTasks = new ArrayList<>(); -// List syncTasks = new ArrayList<>(); -// List reconTasks = new ArrayList<>(); -// for (TaskType task : tasksForKind) { -// if (TaskCategory.RECONCILIATION.equals(task.getCategory())) { -// reconTasks.add(task); -// } else if (TaskCategory.LIVE_SYNCHRONIZATION.equals(task.getCategory())) { -// syncTasks.add(task); -// } else if (TaskCategory.IMPORTING_ACCOUNTS.equals(task.getCategory())) { -// importTasks.add(task); -// } -// } - initButton(ID_IMPORT, "Import", " fa-download", TaskCategory.IMPORTING_ACCOUNTS, "", getTasksForKind(importTasks)); - initButton(ID_RECONCILIATION, "Reconciliation", " fa-link", TaskCategory.RECONCILIATION, SystemObjectsType.ARCHETYPE_RECONCILIATION_TASK.value(), getTasksForKind(reconTasks)); - initButton(ID_LIVE_SYNC, "Live Sync", " fa-refresh", TaskCategory.LIVE_SYNCHRONIZATION, "", getTasksForKind(syncTasks)); + initButton(ID_IMPORT, "Import", " fa-download", TaskCategory.IMPORTING_ACCOUNTS, SystemObjectsType.ARCHETYPE_IMPORT_TASK.value()); + initButton(ID_RECONCILIATION, "Reconciliation", " fa-link", TaskCategory.RECONCILIATION, SystemObjectsType.ARCHETYPE_RECONCILIATION_TASK.value()); + initButton(ID_LIVE_SYNC, "Live Sync", " fa-refresh", TaskCategory.LIVE_SYNCHRONIZATION, SystemObjectsType.ARCHETYPE_LIVE_SYNCH_TASK.value()); initCustomLayout(); } protected abstract void initShadowStatistics(WebMarkupContainer totals); - private void initButton(String id, String label, String icon, final String category, final String archetypeOid, - final List tasks) { + private void initButton(String id, String label, String icon, String category, String archetypeOid) { + + ObjectQuery existingTasksQuery = getExistingTasksQuery(archetypeOid); + OperationResult result = new OperationResult(OPERATION_SEARCH_TASKS_FOR_RESOURCE); + List> tasksList = WebModelServiceUtils.searchObjects(TaskType.class, existingTasksQuery, + result, getPageBase()); List items = new ArrayList<>(); @@ -402,7 +353,8 @@ public InlineMenuItemAction initAction() { @Override public void onClick(AjaxRequestTarget target) { - runTask(tasks, target); + List filteredByKindIntentTasks = getTasksForKind(tasksList); + redirectToTasksListPage(createInTaskOidQuery(filteredByKindIntentTasks), archetypeOid, target); } }; } @@ -427,7 +379,7 @@ public void onClick(AjaxRequestTarget target) { items.add(item); DropdownButtonPanel button = new DropdownButtonPanel(id, - new DropdownButtonDto(String.valueOf(tasks.size()), icon, label, items)) { + new DropdownButtonDto(String.valueOf(tasksList != null ? tasksList.size() : 0), icon, label, items)) { @Override protected String getSpecialDropdownMenuClass() { return "pull-left"; @@ -472,12 +424,41 @@ private void newTaskPerformed(String category, String archetypeOid, AjaxRequestT setResponsePage(new PageTask(taskType.asPrismObject(), true)); } - private void runTask(List tasks, AjaxRequestTarget target) { + private ObjectQuery createInTaskOidQuery(List tasksList){ + if (tasksList == null){ + return null; + } + List taskOids = new ArrayList<>(); + tasksList.forEach(task -> taskOids.add(task.getOid())); + return getPageBase().getPrismContext().queryFor(TaskType.class) + .id(taskOids.toArray(new String[0])) + .build(); + } + private void redirectToTasksListPage(ObjectQuery tasksQuery, String archetypeOid, AjaxRequestTarget target) { + String taskCollectionViewName = getTaskCollectionViewNameByArchetypeOid(archetypeOid); + PageParameters pageParameters = new PageParameters(); + if (StringUtils.isNotEmpty(taskCollectionViewName)){ + pageParameters.add(PageBase.PARAMETER_OBJECT_COLLECTION_NAME, taskCollectionViewName); + PageTasks pageTasks = new PageTasks(tasksQuery, pageParameters); + getPageBase().setResponsePage(pageTasks); + } else { + getPageBase().setResponsePage(PageTasks.class); + } - ResourceTasksPanel tasksPanel = new ResourceTasksPanel(getPageBase().getMainPopupBodyId(), - new ListModel(tasks), getPageBase()); - getPageBase().showMainPopup(tasksPanel, target); + } + private String getTaskCollectionViewNameByArchetypeOid(String archetypeOid) { + if (StringUtils.isEmpty(archetypeOid)) { + return ""; + } + List taskCollectionViews = + getPageBase().getCompiledGuiProfile().findAllApplicableArchetypeViews(TaskType.COMPLEX_TYPE); + for (CompiledObjectCollectionView view : taskCollectionViews) { + if (archetypeOid.equals(view.getCollection().getCollectionRef().getOid())) { + return view.getViewIdentifier(); + } + } + return ""; } private List getTasksForKind(List> tasks) { @@ -1167,6 +1148,32 @@ private List getSelectedShadowsList(ShadowType shadow) { return selectedShadow; } + private ObjectQuery getExistingTasksQuery(String archetypeRefOid){ + return getPageBase().getPrismContext().queryFor(TaskType.class) + .item(AssignmentHolderType.F_ARCHETYPE_REF).ref(archetypeRefOid) + .build(); + } + + private QName getTaskObjectClass(){ + QName objectClass = getObjectClass(); + if (objectClass == null) { + LOGGER.trace("Trying to determine objectClass for kind: {}, intent: {}", getKind(), getIntent()); + RefinedObjectClassDefinition objectClassDef = null; + try { + objectClassDef = getDefinitionByKind(); + } catch (SchemaException e) { + LOGGER.error("Failed to search for objectClass definition. Reason: {}", e.getMessage(), e); + } + if (objectClassDef == null) { + LOGGER.warn("Cannot find any definition for kind: {}, intent: {}", getKind(), getIntent()); + return null; + } + + objectClass = objectClassDef.getTypeName(); + } + return objectClass; + } + protected abstract GetOperationOptionsBuilder addAdditionalOptions(GetOperationOptionsBuilder builder); protected abstract boolean isUseObjectCounting(); diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTasks.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTasks.java index 72514637255..1ff15955a20 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTasks.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTasks.java @@ -9,6 +9,7 @@ import com.evolveum.midpoint.gui.api.page.PageBase; import com.evolveum.midpoint.gui.api.util.WebComponentUtil; +import com.evolveum.midpoint.prism.query.ObjectFilter; import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.prism.xml.XmlTypeConverter; import com.evolveum.midpoint.schema.GetOperationOptions; @@ -37,6 +38,7 @@ import org.apache.wicket.model.IModel; import org.apache.wicket.model.Model; import org.apache.wicket.request.mapper.parameter.PageParameters; +import org.apache.wicket.util.string.StringValue; import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; @@ -57,6 +59,7 @@ label = "PageTasks.auth.tasks.label", description = "PageTasks.auth.tasks.description")}) public class PageTasks extends PageAdmin { + private static final long serialVersionUID = 1L; private static final String ID_TABLE = "table"; @@ -73,15 +76,23 @@ public PageTasks() { } public PageTasks(PageParameters params) { + this(null, params); + } + + public PageTasks(ObjectQuery predefinedQuery, PageParameters params) { super(params); TaskTablePanel tablePanel = new TaskTablePanel(ID_TABLE, UserProfileStorage.TableId.TABLE_TASKS, createOperationOptions()) { + private static final long serialVersionUID = 1L; @Override protected ObjectQuery addFilterToContentQuery(ObjectQuery query) { if (query == null) { query = getPrismContext().queryFactory().createQuery(); } + if (predefinedQuery != null){ + query.addFilter(predefinedQuery.getFilter()); + } query.addFilter(getPrismContext().queryFor(TaskType.class) .item(TaskType.F_PARENT) .isNull() @@ -101,6 +112,7 @@ protected List, String>> createColumns() { private Collection, String>> addCustomColumns(List, String>> columns) { columns.add(2, new ObjectReferenceColumn>(createStringResource("pageTasks.task.objectRef"), SelectableBeanImpl.F_VALUE+"."+TaskType.F_OBJECT_REF.getLocalPart()){ + private static final long serialVersionUID = 1L; @Override public IModel extractDataModel(IModel> rowModel) { SelectableBean bean = rowModel.getObject(); @@ -110,12 +122,14 @@ public IModel extractDataModel(IModel(createStringResource("pageTasks.task.executingAt"), SelectableBeanImpl.F_VALUE + "." + TaskType.F_NODE_AS_OBSERVED.getLocalPart())); columns.add(4, new AbstractExportableColumn, String>(createStringResource("pageTasks.task.currentRunTime"), TaskType.F_COMPLETION_TIMESTAMP.getLocalPart()) { + private static final long serialVersionUID = 1L; @Override public void populateItem(final Item>> item, final String componentId, final IModel> rowModel) { DateLabelComponent dateLabel = new DateLabelComponent(componentId, new IModel() { + private static final long serialVersionUID = 1L; @Override public Date getObject() { @@ -151,6 +165,7 @@ public IModel getDataModel(IModel> rowModel) { } }); columns.add(5, new AbstractExportableColumn, String>(createStringResource("pageTasks.task.scheduledToRunAgain")) { + private static final long serialVersionUID = 1L; @Override public void populateItem(Item>> item, String componentId, @@ -166,7 +181,6 @@ public IModel getDataModel(IModel> rowModel) { return columns; } - private Collection> createOperationOptions() { List propertiesToGet = new ArrayList<>(); propertiesToGet.add(TaskType.F_NODE_AS_OBSERVED); diff --git a/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd b/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd index 4562d755453..06d1834c39a 100755 --- a/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd +++ b/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd @@ -21396,6 +21396,20 @@ + + + + + + + + + + + + + + From 5ab2070306c3b95330381403dc3edc18796a8481 Mon Sep 17 00:00:00 2001 From: lskublik Date: Thu, 27 Feb 2020 14:05:08 +0100 Subject: [PATCH 24/97] fix for detail of new object in table --- .../gui/impl/component/MultivalueContainerListPanel.java | 2 +- .../midpoint/gui/impl/prism/PrismContainerValuePanel.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/component/MultivalueContainerListPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/component/MultivalueContainerListPanel.java index 93fd29bbe81..0d8c27597df 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/component/MultivalueContainerListPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/component/MultivalueContainerListPanel.java @@ -455,7 +455,7 @@ public List> getPerformedSelectedItems(IModel createNewItemContainerValueWrapper( PrismContainerValue newItem, PrismContainerWrapper model, AjaxRequestTarget target) { diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/prism/PrismContainerValuePanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/prism/PrismContainerValuePanel.java index 98a0a5a1e4d..869fb2830ff 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/prism/PrismContainerValuePanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/prism/PrismContainerValuePanel.java @@ -107,7 +107,8 @@ public boolean isVisible() { return false; } - if (!((PrismContainerWrapper) parent).isExpanded() && parent.isMultiValue()) { + + if (!isShowOnTopLevel() && !((PrismContainerWrapper) parent).isExpanded() && parent.isMultiValue()) { return false; } return true; From 6ff50963be62643d1ee7fffe3b8cdec0dc8a51fa Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Thu, 27 Feb 2020 15:00:44 +0100 Subject: [PATCH 25/97] further integration tests init/task/context cleanup AbstractIntegrationTest changes: - remnants of initializedClasses are gone - postInitSystem considered @Deprecated (initSystem should suffice) - createTask replaced by overridable customizeTask(task) - createTask usages replaced by getTestTask() - getOrCreateTestTask gone/calls replaced by getTestTask() - getOrCreateSimpleTask ditto There is much more cleanup to do in inherited tests, of course, e.g. many test name constants are useless now. --- .../TestIntegrationObjectWrapperFactory.java | 7 +- ...AbstractInitializedGuiIntegrationTest.java | 4 +- .../midpoint/web/ObjectWrapperTest.java | 11 - .../midpoint/web/TestCleanStartup.java | 4 - .../midpoint/web/TestIntegrationSecurity.java | 1 - .../model/impl/lens/TestAssignedMappings.java | 30 +- .../impl/lens/TestAssignmentProcessor.java | 1 - .../impl/lens/TestAssignmentProcessor2.java | 46 +-- .../model/impl/lens/TestClockwork.java | 8 +- .../model/impl/lens/TestPasswordPolicy.java | 18 +- .../lens/TestPasswordPolicyProcessor.java | 16 +- .../model/impl/lens/TestPolicyRules.java | 28 +- .../impl/lens/TestPolicyStateRecording.java | 1 - .../model/impl/lens/TestProjector.java | 46 ++- .../impl/misc/ShadowIntegrityCheckerTest.java | 2 +- .../TestAbstractAuthenticationEvaluator.java | 42 ++- .../impl/sync/TestSynchronizationService.java | 41 ++- .../model/impl/visualizer/TestVisualizer.java | 28 +- .../midpoint/model/intest/TestActivation.java | 36 +-- .../midpoint/model/intest/TestAudit.java | 38 +-- .../midpoint/model/intest/TestCaseIgnore.java | 1 - .../model/intest/TestConnectorDummyFake.java | 30 +- .../intest/TestConnectorMultiInstance.java | 6 +- .../model/intest/TestConsistencySimple.java | 4 +- .../midpoint/model/intest/TestDeputy.java | 72 ++--- .../model/intest/TestEntitlements.java | 156 +++++----- .../midpoint/model/intest/TestInbounds.java | 38 +-- .../midpoint/model/intest/TestIntent.java | 10 +- .../midpoint/model/intest/TestIteration.java | 73 +++-- .../midpoint/model/intest/TestLifecycle.java | 14 +- .../midpoint/model/intest/TestMerge.java | 1 - .../intest/TestModelServiceContract.java | 78 ++--- .../model/intest/TestNotifications.java | 1 - .../intest/TestOptimizingTriggerCreator.java | 3 +- .../model/intest/TestPreviewChanges.java | 78 ++--- .../model/intest/TestRaceConditions.java | 3 +- .../midpoint/model/intest/TestResources.java | 38 +-- .../model/intest/TestSchemalessResource.java | 4 +- .../model/intest/TestStrangeCases.java | 72 ++--- .../model/intest/TestTolerantAttributes.java | 3 +- .../model/intest/TestTriggerTask.java | 39 ++- .../model/intest/TestUserTemplate.java | 179 ++++++----- .../intest/TestUserTemplateWithRanges.java | 27 +- .../midpoint/model/intest/TestVolatility.java | 21 +- .../intest/archetypes/TestArchetypes.java | 50 ++-- .../intest/archetypes/TestCollections.java | 14 +- .../async/TestAsyncUpdateGrouperJson.java | 3 +- .../async/TestAsyncUpdateTaskMechanics.java | 6 +- .../gensync/TestAssociationInbound.java | 3 +- .../model/intest/gensync/TestEditSchema.java | 72 ++--- .../intest/gensync/TestRoleEntitlement.java | 48 +-- .../AbstractDirectManualResourceTest.java | 73 +++-- .../AbstractGroupingManualResourceTest.java | 30 +- .../manual/AbstractManualResourceTest.java | 76 ++--- .../manual/TestDummyItsmIntegration.java | 31 +- .../model/intest/manual/TestSemiManual.java | 8 +- .../intest/manual/TestSemiManualDisable.java | 7 +- .../intest/manual/TestSemiManualGrouping.java | 3 +- .../TestSemiManualGroupingProposed.java | 7 +- .../model/intest/mapping/TestMapping.java | 182 +++++------ .../mapping/TestMappingAutoInbound.java | 25 +- .../intest/mapping/TestMappingInbound.java | 34 +-- .../midpoint/model/intest/misc/TestMisc.java | 40 +-- .../intest/misc/TestUuidNonUniqueName.java | 32 +- .../model/intest/multi/TestMultiAccount.java | 19 +- .../multi/TestMultiConnectorResources.java | 4 +- .../model/intest/multi/TestMultiResource.java | 129 ++++---- .../intest/negative/TestAssignmentErrors.java | 22 +- .../intest/negative/TestBrokenResources.java | 64 ++-- .../model/intest/orgstruct/TestOrgStruct.java | 100 +++---- .../intest/password/AbstractPasswordTest.java | 208 ++++++------- .../intest/password/TestPasswordDefault.java | 1 - .../password/TestPasswordDefaultHashing.java | 8 +- .../intest/persona/AbstractPersonaTest.java | 20 +- .../intest/persona/TestPersonaPassword.java | 3 +- .../intest/rbac/TestAssignmentValidity.java | 98 +++--- .../model/intest/rbac/TestAutoassign.java | 15 +- .../model/intest/rbac/TestMetaMeta.java | 30 +- .../midpoint/model/intest/rbac/TestRbac.java | 282 +++++++++--------- .../intest/rbac/TestSegregationOfDuties.java | 119 ++++---- .../intest/scripting/TestScriptingBasic.java | 72 ++--- .../intest/security/AbstractSecurityTest.java | 2 +- .../intest/security/TestSecurityAdvanced.java | 16 +- .../intest/security/TestSecurityBasic.java | 13 +- .../security/TestSecurityMultitenant.java | 3 +- .../security/TestSecurityPrincipal.java | 12 +- .../intest/sync/AbstractInboundSyncTest.java | 30 +- .../sync/AbstractObjTemplateSyncTest.java | 7 +- .../AbstractSynchronizationStoryTest.java | 49 +-- .../model/intest/sync/TestImportRecon.java | 72 ++--- .../intest/sync/TestInboundLiveSyncTask.java | 3 +- .../intest/sync/TestInboundReconTask.java | 8 +- .../model/intest/sync/TestLiveSyncTask.java | 3 +- .../sync/TestLiveSyncTaskMechanics.java | 31 +- .../intest/sync/TestParallelDiscovery.java | 2 +- .../sync/TestParallelSynchronization.java | 3 +- .../intest/sync/TestProgressReporting.java | 4 +- .../model/intest/sync/TestRecomputeTask.java | 8 +- .../midpoint/model/intest/sync/TestUuid.java | 12 +- .../sync/TestValidityRecomputeTask.java | 77 ++--- .../test/AbstractModelIntegrationTest.java | 65 ++-- .../evolveum/midpoint/report/TestReport.java | 9 +- .../midpoint/report/TestReportWebService.java | 3 +- .../wf/impl/AbstractWfTestPolicy.java | 4 +- .../AbstractTestAssignmentApproval.java | 16 +- .../TestAssignmentApprovalGlobal.java | 3 +- .../assignments/TestAssignmentsAdvanced.java | 28 +- .../impl/association/TestAddAssociation.java | 6 - .../AbstractTestObjectLifecycleApproval.java | 8 +- .../objects/TestObjectLifecycleAdvanced.java | 11 +- .../TestObjectLifecycleApprovalGlobal.java | 8 +- .../wf/impl/other/ManualResourceTest.java | 6 +- .../wf/impl/other/TestDelegation.java | 11 +- .../wf/impl/other/TestEscalation.java | 14 +- .../midpoint/wf/impl/other/TestEvents.java | 3 +- .../wf/impl/other/TestMiscellaneous.java | 14 +- .../wf/impl/other/TestParallelApprovals.java | 18 +- .../midpoint/wf/impl/other/TestSoD.java | 24 +- .../AbstractProvisioningIntegrationTest.java | 12 +- .../provisioning/impl/TestDBTable.java | 2 +- .../impl/async/TestAsyncUpdate.java | 18 +- .../impl/csv/AbstractCsvTest.java | 10 +- .../impl/dummy/AbstractBasicDummyTest.java | 20 +- .../impl/dummy/AbstractDummyTest.java | 3 +- .../provisioning/impl/dummy/TestDummy.java | 78 ++--- .../impl/dummy/TestDummyConsistency.java | 109 ++++--- .../impl/dummy/TestDummyExpression.java | 4 - .../impl/dummy/TestDummyExtra.java | 8 +- .../impl/dummy/TestDummyHacks.java | 28 +- .../impl/dummy/TestDummyLegacy.java | 6 +- .../impl/dummy/TestDummyLimited.java | 1 - .../impl/dummy/TestDummyNegative.java | 4 +- .../impl/dummy/TestDummyParallelism.java | 36 +-- .../impl/dummy/TestDummySchemaless.java | 8 +- .../dummy/TestDummyUuidNonUniqueName.java | 5 +- .../manual/AbstractManualResourceTest.java | 64 ++-- .../impl/opendj/AbstractOpenDjTest.java | 1 - .../provisioning/impl/opendj/TestOpenDj.java | 188 ++++++------ .../impl/opendj/TestOpenDjDumber.java | 2 +- .../impl/opendj/TestOpenDjNegative.java | 7 +- .../common/commandline/TestCommandLine.java | 4 +- .../test/AbstractIntegrationTest.java | 218 +++++--------- .../midpoint/task/api/TaskManager.java | 2 +- .../midpoint/testing/longtest/TestLdap.java | 19 +- .../testing/longtest/TestLdapComplex.java | 11 +- .../midpoint/testing/longtest/TestRunAs.java | 60 +--- .../testing/rest/TestAbstractRestService.java | 2 +- .../samples/test/AbstractSampleTest.java | 16 +- .../samples/test/TestSampleImport.java | 3 +- .../midpoint/testing/sanity/TestSanity.java | 1 - .../TestConfiguredCapabilitiesActivation.java | 6 +- .../story/TestConsistencyMechanism.java | 11 +- .../testing/story/TestDelayedEnable.java | 51 ++-- .../midpoint/testing/story/TestDelivery.java | 12 +- .../testing/story/TestExistentialIssues.java | 14 +- .../testing/story/TestImportGroups.java | 6 +- .../story/TestInboundOutboundAssociation.java | 22 +- .../testing/story/TestInducement.java | 14 +- .../testing/story/TestLargeGroups.java | 6 +- .../testing/story/TestLimitedResources.java | 18 +- .../testing/story/TestLiveSyncMadness.java | 2 +- .../story/TestMachineIntelligence.java | 2 +- .../testing/story/TestManyThreads.java | 6 +- .../testing/story/TestMappingMadness.java | 16 +- .../story/TestMisbehavingResources.java | 13 +- .../testing/story/TestNormalizers.java | 4 +- .../testing/story/TestNullAttribute.java | 7 +- .../testing/story/TestOperationPerf.java | 2 +- .../midpoint/testing/story/TestOrgSync.java | 14 +- .../testing/story/TestPhotoAssignment.java | 3 +- .../story/TestPlentyOfAssignments.java | 22 +- .../testing/story/TestReconNullValue.java | 11 +- .../testing/story/TestRetirement.java | 4 +- .../midpoint/testing/story/TestScience.java | 11 +- .../testing/story/TestServiceAccounts.java | 6 +- .../story/TestServiceAccountsClassifier.java | 7 +- .../testing/story/TestShadowsPerformance.java | 11 +- .../midpoint/testing/story/TestStrings.java | 34 +-- .../midpoint/testing/story/TestUnix.java | 96 +++--- .../testing/story/TestUnixTolerantAux.java | 10 +- .../midpoint/testing/story/TestVillage.java | 7 +- .../midpoint/testing/story/TestWriter.java | 6 +- .../story/grouper/TestGrouperAsyncUpdate.java | 34 +-- .../grouper/TestGrouperLargeGroupImport.java | 5 +- .../TestGrouperLargeGroupReconciliation.java | 7 +- .../testing/story/ldap/AbstractLdapTest.java | 11 +- .../ldap/TestLdapAssociationPerformance.java | 20 +- .../testing/story/ldap/TestLdapComplex.java | 50 ++-- .../story/ldap/TestLdapDependency.java | 16 +- .../testing/story/ldap/TestLdapMutilated.java | 16 +- .../story/ldap/TestLdapReconPerformance.java | 10 +- .../story/ldap/TestLdapSyncMassive.java | 12 +- .../hierarchy/AbstractLdapHierarchyTest.java | 24 +- .../notorious/AbstractNotoriousTest.java | 52 ++-- .../testing/story/perf/TestImport.java | 1 - .../testing/story/security/TestPrivacy.java | 1 - .../story/security/TestRoleMembers.java | 2 +- .../testing/story/uuid/AbstractUuidTest.java | 2 +- .../testing/story/uuid/TestUuidClient.java | 25 +- .../testing/story/uuid/TestUuidExtension.java | 8 +- 200 files changed, 2669 insertions(+), 2934 deletions(-) diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestIntegrationObjectWrapperFactory.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestIntegrationObjectWrapperFactory.java index 3860eef11e3..3c827bcdd24 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestIntegrationObjectWrapperFactory.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestIntegrationObjectWrapperFactory.java @@ -576,7 +576,7 @@ public void test160CreateWrapperOrgScummBar() throws Exception { public void test220AssignRoleLandluberToWally() throws Exception { final String TEST_NAME = "test220AssignRoleLandluberToWally"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyGroup mapmakers = new DummyGroup(GROUP_DUMMY_MAPMAKERS_NAME); @@ -892,14 +892,13 @@ public void test800EditSchemaJackPropReadAllModifySomeUser() throws Exception { assignRole(USER_JACK_OID, ROLE_PROP_READ_ALL_MODIFY_SOME_USER_OID); login(USER_JACK_USERNAME); - Task task = createTask(TEST_NAME); PrismObject user = getUser(USER_JACK_OID); display("user before", user); // WHEN displayWhen(TEST_NAME); - PrismObjectWrapper objectWrapper = createObjectWrapper(task, user, ItemStatus.NOT_CHANGED); + PrismObjectWrapper objectWrapper = createObjectWrapper(getTestTask(), user, ItemStatus.NOT_CHANGED); // THEN displayThen(TEST_NAME); @@ -964,7 +963,7 @@ public void test802EditSchemaJackPropReadSomeModifySomeUser() throws Exception { assignRole(USER_JACK_OID, ROLE_PROP_READ_SOME_MODIFY_SOME_USER_OID); login(USER_JACK_USERNAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); PrismObject user = getUser(USER_JACK_OID); display("user before", user); diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/AbstractInitializedGuiIntegrationTest.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/AbstractInitializedGuiIntegrationTest.java index 26d5596a154..6aec3cd0ec0 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/AbstractInitializedGuiIntegrationTest.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/AbstractInitializedGuiIntegrationTest.java @@ -10,14 +10,12 @@ import static com.evolveum.midpoint.web.AdminGuiTestConstants.*; -import com.evolveum.midpoint.prism.path.ItemName; import org.testng.annotations.Test; import com.evolveum.icf.dummy.resource.DummyResource; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.logging.Trace; @@ -75,7 +73,7 @@ public void test000PreparationAndSanity() throws Exception { final String TEST_NAME = "test000PreparationAndSanity"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertNotNull("No model service", modelService); diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/ObjectWrapperTest.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/ObjectWrapperTest.java index e39bd80413b..c14a3499f5c 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/ObjectWrapperTest.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/ObjectWrapperTest.java @@ -7,22 +7,11 @@ package com.evolveum.midpoint.web; -import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.PrismPropertyValue; -import com.evolveum.midpoint.prism.delta.ObjectDelta; -import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.web.component.prism.*; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; -import org.testng.AssertJUnit; -import org.testng.annotations.Test; - -import java.io.File; -import java.lang.reflect.Field; /** * @author lazyman diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestCleanStartup.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestCleanStartup.java index 1c4921e9c0f..d7894f10001 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestCleanStartup.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestCleanStartup.java @@ -8,7 +8,6 @@ import java.util.Collection; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; @@ -16,9 +15,6 @@ import org.testng.annotations.Test; import com.evolveum.midpoint.common.LoggingConfigurationManager; -import com.evolveum.midpoint.init.InfraInitialSetup; -import com.evolveum.midpoint.init.InitialDataImport; -import com.evolveum.midpoint.init.ModelInitialSetup; import com.evolveum.midpoint.model.test.AbstractModelIntegrationTest; import com.evolveum.midpoint.schema.internals.InternalsConfig; import com.evolveum.midpoint.schema.result.OperationResult; diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestIntegrationSecurity.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestIntegrationSecurity.java index e8934d7e9ff..f462e18d9d4 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestIntegrationSecurity.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestIntegrationSecurity.java @@ -14,7 +14,6 @@ import java.util.ArrayList; import java.util.Collection; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType; import org.springframework.beans.factory.annotation.Autowired; diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignedMappings.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignedMappings.java index 2130f5e7103..c39fc150e5a 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignedMappings.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignedMappings.java @@ -145,7 +145,8 @@ public void test100AssignSimpleToJim() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestAssignedMappings.class.getName() + "." + TEST_NAME); + TestAssignedMappings.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -192,7 +193,8 @@ public void test110AssignRingToFrodo() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestAssignedMappings.class.getName() + "." + TEST_NAME); + TestAssignedMappings.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -242,7 +244,8 @@ public void test120AssignStingToFrodo() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestAssignedMappings.class.getName() + "." + TEST_NAME); + TestAssignedMappings.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -291,7 +294,8 @@ public void test130UnassignRingFromFrodo() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestAssignedMappings.class.getName() + "." + TEST_NAME); + TestAssignedMappings.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -347,7 +351,8 @@ public void test200AssignRolesToAdam() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestAssignedMappings.class.getName() + "." + TEST_NAME); + TestAssignedMappings.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -405,7 +410,8 @@ public void test210AssignRolesToBenjamin() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestAssignedMappings.class.getName() + "." + TEST_NAME); + TestAssignedMappings.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -490,7 +496,8 @@ public void test220AdamConditionFalseToTrue() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestAssignedMappings.class.getName() + "." + TEST_NAME); + TestAssignedMappings.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -569,7 +576,8 @@ public void test230BenjaminConditionTrueToFalse() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestAssignedMappings.class.getName() + "." + TEST_NAME); + TestAssignedMappings.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -603,7 +611,8 @@ public void test280UnassignRolesFromAdam() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestAssignedMappings.class.getName() + "." + TEST_NAME); + TestAssignedMappings.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -633,7 +642,8 @@ public void test290UnassignRolesFromBenjamin() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestAssignedMappings.class.getName() + "." + TEST_NAME); + TestAssignedMappings.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor.java index 2c34c33244f..8e31e728d46 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor.java @@ -22,7 +22,6 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.ObjectTypeUtil; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor2.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor2.java index 3b62cb5d907..965cc04207d 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor2.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor2.java @@ -167,7 +167,7 @@ public void test000Sanity() throws Exception { @Test(enabled = FIRST_PART) public void test010AssignR1ToJack() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); LensContext context = createContextForRoleAssignment(USER_JACK_OID, ROLE_R1_OID, null, null, result); @@ -225,7 +225,7 @@ private void processAssignments(LensContext context, OperationResult r @Test(enabled = FIRST_PART) public void test020AssignMR1ToR1() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); LensContext context = createContextForAssignment(RoleType.class, ROLE_R1_OID, RoleType.class, ROLE_MR1_OID, null, null, result); @@ -271,7 +271,7 @@ public void test020AssignMR1ToR1() throws Exception { @Test(enabled = FIRST_PART) public void test030AssignR1ToJackProjectorDisabled() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); LensContext context = createContextForRoleAssignment(USER_JACK_OID, ROLE_R1_OID, null, @@ -300,7 +300,7 @@ public void test030AssignR1ToJackProjectorDisabled() throws Exception { @Test(enabled = FIRST_PART) public void test040AssignR1ToJackAsApprover() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); LensContext context = createContextForRoleAssignment(USER_JACK_OID, ROLE_R1_OID, SchemaConstants.ORG_APPROVER, null, result); @@ -354,7 +354,7 @@ public void test040AssignR1ToJackAsApprover() throws Exception { @Test(enabled = FIRST_PART) public void test050JackDeputyOfBarbossa() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); AssignmentType policyRuleAssignment = new AssignmentType(prismContext); @@ -433,7 +433,7 @@ public void test050JackDeputyOfBarbossa() throws Exception { @Test(enabled = FIRST_PART) public void test060JackDeputyOfGuybrushDeputyOfBarbossa() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); AssignmentType deputyOfBarbossaAssignment = ObjectTypeUtil.createAssignmentTo(USER_BARBOSSA_OID, ObjectTypes.USER, prismContext); @@ -497,7 +497,7 @@ public void test060JackDeputyOfGuybrushDeputyOfBarbossa() throws Exception { @Test(enabled = FIRST_PART) public void test062JackDeputyOfGuybrushDeputyOfBarbossaInLoginMode() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject jack = getUser(USER_JACK_OID); @@ -584,7 +584,7 @@ public void test062JackDeputyOfGuybrushDeputyOfBarbossaInLoginMode() throws Exce @Test(enabled = FIRST_PART) public void test070JackDeputyOfBarbossaApproverOfR1() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); unassignAllRoles(USER_JACK_OID); @@ -661,7 +661,7 @@ public void test070JackDeputyOfBarbossaApproverOfR1() throws Exception { @Test(enabled = FIRST_PART) public void test100DisableSomeRoles() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -675,7 +675,7 @@ public void test100DisableSomeRoles() throws Exception { @Test(enabled = FIRST_PART) public void test110AssignR1ToJack() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); LensContext context = createContextForRoleAssignment(USER_JACK_OID, ROLE_R1_OID, null, null, result); @@ -733,7 +733,7 @@ public void test110AssignR1ToJack() throws Exception { @Test(enabled = FIRST_PART) public void test150DisableSomeAssignments() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -745,7 +745,7 @@ public void test150DisableSomeAssignments() throws Exception { @Test(enabled = FIRST_PART) public void test160AssignR1ToJack() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); LensContext context = createContextForRoleAssignment(USER_JACK_OID, ROLE_R1_OID, null, null, result); @@ -803,7 +803,7 @@ public void test160AssignR1ToJack() throws Exception { @Test(enabled = FIRST_PART) public void test200AddConditions() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -821,7 +821,7 @@ public void test200AddConditions() throws Exception { @Test(enabled = FIRST_PART) public void test210AssignR1ToJack() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); LensContext context = createContextForRoleAssignment(USER_JACK_OID, ROLE_R1_OID, null, null, result); @@ -884,7 +884,7 @@ public void test210AssignR1ToJack() throws Exception { @Test(enabled = SECOND_PART) public void test300AssignR7ToJack() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); createObjectsInSecondPart(false, task, result, null); @@ -1024,7 +1024,7 @@ public void test300AssignR7ToJack() throws Exception { @Test(enabled = THIRD_PART) public void test400AssignJackPirate() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); createObjectsInThirdPart(false, task, result, () -> { @@ -1487,7 +1487,7 @@ public static void finishCallback(String desc) { @Test(enabled = FOURTH_PART) public void test500AssignJackOrg11() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); createObjectsInFourthPart(false, task, result, null); @@ -1545,7 +1545,7 @@ public void test500AssignJackOrg11() throws Exception { @Test(enabled = FOURTH_PART) public void test505AssignJackOrg11AsManager() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); LensContext context = createContextForAssignment(UserType.class, USER_JACK_OID, OrgType.class, ORG11_OID, SchemaConstants.ORG_MANAGER, null, result); @@ -1600,7 +1600,7 @@ public void test505AssignJackOrg11AsManager() throws Exception { @Test(enabled = FOURTH_PART) public void test507AssignJackOrg11AsApprover() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); LensContext context = createContextForAssignment(UserType.class, USER_JACK_OID, OrgType.class, ORG11_OID, SchemaConstants.ORG_APPROVER, null, result); @@ -1654,7 +1654,7 @@ public void test507AssignJackOrg11AsApprover() throws Exception { @Test(enabled = FOURTH_PART) public void test510AssignJackOrg21() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); LensContext context = createContextForAssignment(UserType.class, USER_JACK_OID, OrgType.class, ORG21_OID, @@ -1707,7 +1707,7 @@ public void test510AssignJackOrg21() throws Exception { @Test(enabled = FOURTH_PART) public void test515AssignJackOrg21AsManager() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); LensContext context = createContextForAssignment(UserType.class, USER_JACK_OID, OrgType.class, ORG21_OID, @@ -1774,7 +1774,7 @@ public void test515AssignJackOrg21AsManager() throws Exception { @Test(enabled = FOURTH_PART) public void test520AssignJackOrg41AsApprover() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); LensContext context = createContextForAssignment(UserType.class, USER_JACK_OID, OrgType.class, ORG41_OID, @@ -1838,7 +1838,7 @@ public void test520AssignJackOrg41AsApprover() throws Exception { @Test(enabled = FIFTH_PART) public void test600AssignA1ToJack() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); createObjectsInFifthPart(false, task, result, null); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestClockwork.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestClockwork.java index 3f4dfa5aa80..73cdf7c4f2a 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestClockwork.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestClockwork.java @@ -92,7 +92,7 @@ public void test010SerializeAddUserBarbossa() throws Exception { final String TEST_NAME = "test010SerializeAddUserBarbossa"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); LensContext context = createUserLensContext(); @@ -133,7 +133,7 @@ public void test020AssignAccountToJackSync() throws Exception { try { // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); LensContext context = createJackAssignAccountContext(result); @@ -209,7 +209,7 @@ public void test053ModifyUserBarbossaDisable() throws Exception { final String TEST_NAME = "test053ModifyUserBarbossaDisable"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); LensContext context = createUserLensContext(); @@ -265,7 +265,7 @@ public void test053ModifyUserBarbossaDisable() throws Exception { private void assignAccountToJackAsync(String testName, boolean serialize) throws Exception { // GIVEN - Task task = createTask(testName); + Task task = getTestTask(); OperationResult result = task.getResult(); assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPasswordPolicy.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPasswordPolicy.java index 7b6df49a5f6..7c75465d5a7 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPasswordPolicy.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPasswordPolicy.java @@ -101,7 +101,7 @@ public void testPasswordGeneratorComplexNegative() throws Exception { final String TEST_NAME = "testPasswordGeneratorComplexNegative"; TestUtil.displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); File file = new File(TEST_DIR, "password-policy-complex.xml"); @@ -161,7 +161,7 @@ public void testValueGenerateRandomPin() throws Exception { final String TEST_NAME = "testValueGenerateRandomPin"; TestUtil.displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ValuePolicyType pp = parsePasswordPolicy("value-policy-random-pin.xml"); @@ -185,7 +185,7 @@ public void testValueGenerate() throws Exception { final String TEST_NAME = "testValueGenerate"; TestUtil.displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ValuePolicyType pp = parsePasswordPolicy("value-policy-generate.xml"); @@ -209,7 +209,7 @@ public void testValueGenerateEmpty() throws Exception { final String TEST_NAME = "testValueGenerateEmpty"; TestUtil.displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); File file = new File(TEST_DIR, "value-policy-generate-empty.xml"); @@ -232,7 +232,7 @@ public void testValueGenerateEmpty() throws Exception { public void passwordGeneratorTest(final String TEST_NAME, String policyFilename) throws JAXBException, SchemaException, IOException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException { TestUtil.displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); File file = new File(TEST_DIR, policyFilename); @@ -273,7 +273,7 @@ private void assertPassword(String passwd, ValuePolicyType pp) throws SchemaExce } private void assertPassword(String passwd, ValuePolicyType pp, PrismObject object) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { - Task task = createTask("assertPassword"); + Task task = getTestTask(); OperationResult result = task.getResult(); boolean isValid = valuePolicyProcessor.validateValue(passwd, pp, createUserOriginResolver(object), "assertPassword", task, result); result.computeStatus(); @@ -328,7 +328,7 @@ public void testUsername() throws Exception { TestUtil.displayWhen(TEST_NAME); for (int i = 0; i < USERNAME_ATTEMPTS; i++) { - Task task = createTask(TEST_NAME+":"+i); + Task task = getTestTask(); OperationResult result = task.getResult(); String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, true, createUserOriginResolver(user), TEST_NAME, task, result); @@ -362,7 +362,7 @@ public void testUserProps() throws Exception { TestUtil.displayWhen(TEST_NAME); for (int i = 0; i < USER_PROPS_ATTEMPTS; i++) { - Task task = createTask(TEST_NAME+":"+i); + Task task = getTestTask(); OperationResult result = task.getResult(); String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, true, createUserOriginResolver(user), TEST_NAME, task, result); @@ -398,7 +398,7 @@ private ValuePolicyType parsePasswordPolicy(String filename) throws SchemaExcept } private boolean pwdValidHelper(String password, ValuePolicyType pp) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { - Task task = createTask("pwdValidHelper"); + Task task = getTestTask(); OperationResult result = task.getResult(); valuePolicyProcessor.validateValue(password, pp, null, "pwdValidHelper", task, result); result.computeStatus(); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPasswordPolicyProcessor.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPasswordPolicyProcessor.java index c5430f15938..5e371fdf8e6 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPasswordPolicyProcessor.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPasswordPolicyProcessor.java @@ -67,7 +67,7 @@ public void test000initPasswordPolicyForHistory() throws Exception { @Test public void test100CreateFocusWithPassword() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -87,7 +87,7 @@ private PrismObject getFocus() throws Exception { @Test public void test110ModifyPassword() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -110,7 +110,7 @@ public void test110ModifyPassword() throws Exception { @Test public void test120ModifyPasswordSecondTime() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -133,7 +133,7 @@ public void test120ModifyPasswordSecondTime() throws Exception { @Test public void test130ModifyPasswordThirdTime() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -170,7 +170,7 @@ public void test160ModifyPasswordSamePassword3() throws Exception { } private void doTestModifyPasswordExpectFailure(String password) throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); try { @@ -206,7 +206,7 @@ public void test201deleteFocus() throws Exception { @Test public void test210CreateFocusNoPasswordHistory() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -237,7 +237,7 @@ public void test230ModifySamePasswordNoPasswordHistory() throws Exception { } private void modifyPasswordNoHistory() throws Exception{ - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -268,7 +268,7 @@ private void assertPasswords(String password, ProtectedStringType passwordAfterC } private void setPasswordHistoryLength(int historyLength) throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); modifyObjectReplaceProperty(SecurityPolicyType.class, SECURITY_POLICY_OID, SchemaConstants.PATH_CREDENTIALS_PASSWORD_HISTORY_LENGTH, task, result, historyLength); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules.java index a5601a2d364..7aa34e05eb6 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules.java @@ -76,7 +76,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test005JackAttemptAssignRoleJudge() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // GIVEN @@ -109,7 +109,7 @@ public void test005JackAttemptAssignRoleJudge() throws Exception { @Test(enabled = false) public void test007JackAttemptAssignRoleJudgeAsOwner() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // GIVEN @@ -146,7 +146,7 @@ public void test007JackAttemptAssignRoleJudgeAsOwner() throws Exception { */ @Test public void test010JackAssignRoleJudge() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // GIVEN @@ -170,7 +170,7 @@ public void test010JackAssignRoleJudge() throws Exception { */ @Test public void test020JackUnassignRoleJudge() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // GIVEN @@ -207,7 +207,7 @@ public void test020JackUnassignRoleJudge() throws Exception { */ @Test public void test100AssignRoleMutinierToJack() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // GIVEN @@ -240,7 +240,7 @@ public void test100AssignRoleMutinierToJack() throws Exception { @Test(enabled = false) // after MID-4797 the projector.project now raises PolicyViolationException on conflicting roles public void test110AssignRolePirateToJack() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // GIVEN @@ -278,7 +278,7 @@ public void test110AssignRolePirateToJack() throws Exception { */ @Test public void test112AssignRolePirateWithExceptionToJack() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // GIVEN @@ -322,7 +322,7 @@ public void test112AssignRolePirateWithExceptionToJack() throws Exception { @Test public void test120AssignRoleConstableToJack() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // GIVEN @@ -373,7 +373,7 @@ public void test120AssignRoleConstableToJack() throws Exception { */ @Test public void test150AssignRoleThiefToJack() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // GIVEN @@ -423,7 +423,7 @@ public void test150AssignRoleThiefToJack() throws Exception { */ @Test public void test200JackAssignRoleContractor() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // GIVEN @@ -447,7 +447,7 @@ public void test200JackAssignRoleContractor() throws Exception { */ @Test public void test210AssignRoleEmployeeToJack() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // GIVEN @@ -488,7 +488,7 @@ public void test210AssignRoleEmployeeToJack() throws Exception { */ @Test public void test220AssignRoleEngineerToJack() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // GIVEN @@ -554,7 +554,7 @@ public void test220AssignRoleEngineerToJack() throws Exception { */ @Test public void test300DrakeChangeEmployeeType() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // GIVEN @@ -590,7 +590,7 @@ public void test300DrakeChangeEmployeeType() throws Exception { */ @Test public void test400AssignRoleLocalized() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // GIVEN diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyStateRecording.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyStateRecording.java index bb75daaedc9..7a752c8c2e2 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyStateRecording.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyStateRecording.java @@ -13,7 +13,6 @@ import com.evolveum.midpoint.schema.internals.InternalMonitor; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DebugUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import org.springframework.test.annotation.DirtiesContext; diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjector.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjector.java index 052eae93ce2..3fbb62895fc 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjector.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjector.java @@ -10,7 +10,6 @@ import static org.testng.AssertJUnit.*; import java.io.File; -import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; @@ -41,7 +40,6 @@ import com.evolveum.midpoint.schema.util.ResourceTypeUtil; import com.evolveum.midpoint.schema.util.SchemaTestConstants; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.util.TestUtil; @@ -61,10 +59,8 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType; import com.evolveum.midpoint.xml.ns._public.common.common_3.TriggerType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType; /** * @author semancik @@ -102,7 +98,7 @@ public void test010BasicContextOperations() throws Exception { final String TEST_NAME = "test010BasicContextOperations"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -187,7 +183,7 @@ public void test100AddAccountToJackDirect() throws Exception { final String TEST_NAME = "test100AddAccountToJackDirect"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -254,7 +250,7 @@ public void test110AssignAccountToJack() throws Exception { final String TEST_NAME = "test110AssignAccountToJack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -282,7 +278,7 @@ public void test111AssignAccountToJackBroken() throws Exception { final String TEST_NAME = "test111AssignAccountToJackBroken"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -345,7 +341,7 @@ public void test250ModifyUserBarbossaLocality() throws Exception { final String TEST_NAME = "test250ModifyUserBarbossaLocality"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -395,7 +391,7 @@ public void test251ModifyUserBarbossaFullname() throws Exception { final String TEST_NAME = "test251ModifyUserBarbossaFullname"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -446,7 +442,7 @@ public void test254ModifyUserBarbossaDisable() throws Exception { final String TEST_NAME = "test254ModifyUserBarbossaDisable"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -508,7 +504,7 @@ public void test255ModifyUserBarbossaAssignment() throws Exception { final String TEST_NAME = "test255ModifyUserBarbossaAssignment"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -561,7 +557,7 @@ public void test260ModifyAccountBarbossaDrinkReplace() throws Exception { final String TEST_NAME = "test260ModifyAccountBarbossaDrinkReplace"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -597,7 +593,7 @@ public void test261ModifyAccountBarbossaQuoteReplace() throws Exception { final String TEST_NAME = "test261ModifyAccountBarbossaQuoteReplace"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -658,7 +654,7 @@ public void test269DeleteBarbossaDummyAccount() throws Exception { final String TEST_NAME = "test269DeleteBarbossaDummyAccount"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -694,7 +690,7 @@ public void test270AddUserBarbossaAssignmentBrethren() throws Exception { final String TEST_NAME = "test270AddUserBarbossaAssignmentBrethren"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -740,7 +736,7 @@ public void test275DeleteUserBarbossaAssignmentBrethren() throws Exception { final String TEST_NAME = "test275DeleteUserBarbossaAssignmentBrethren"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -788,7 +784,7 @@ public void test280AddUserBarbossaAssignmentMutinier() throws Exception { final String TEST_NAME = "test280AddUserBarbossaAssignmentMutinier"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -835,7 +831,7 @@ public void test301AssignConflictingAccountToJack() throws Exception { final String TEST_NAME = "test301AssignConflictingAccountToJack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -883,7 +879,7 @@ public void test400ImportHermanDummy() throws Exception { final String TEST_NAME = "test400ImportHermanDummy"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -940,7 +936,7 @@ public void test401ImportHermanDummy() throws Exception { final String TEST_NAME = "test401ImportHermanDummy"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -986,7 +982,7 @@ public void test450GuybrushInboundFromDelta() throws Exception { final String TEST_NAME = "test450GuybrushInboundFromDelta"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -1020,7 +1016,7 @@ public void test451GuybrushInboundFromAbsolute() throws Exception { final String TEST_NAME = "test451GuybrushInboundFromAbsolute"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -1061,7 +1057,7 @@ public void test500ReconcileGuybrushDummy() throws Exception { final String TEST_NAME = "test500ReconcileGuybrushDummy"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -1125,7 +1121,7 @@ public void test600AddLargo() throws Exception { final String TEST_NAME = "test600AddLargo"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/misc/ShadowIntegrityCheckerTest.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/misc/ShadowIntegrityCheckerTest.java index 18ff09c9839..d32dab7ba5d 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/misc/ShadowIntegrityCheckerTest.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/misc/ShadowIntegrityCheckerTest.java @@ -69,7 +69,7 @@ public void test100FixDuplicatesWithDifferentObjectClasses() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); login(userAdministrator); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // GIVEN diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/security/TestAbstractAuthenticationEvaluator.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/security/TestAbstractAuthenticationEvaluator.java index 9ea1784ab2d..3b67399b656 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/security/TestAbstractAuthenticationEvaluator.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/security/TestAbstractAuthenticationEvaluator.java @@ -681,7 +681,8 @@ public void test138UnlockUserGoodPassword() throws Exception { TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TestAbstractAuthenticationEvaluator.class.getName() + "." + TEST_NAME); + TestAbstractAuthenticationEvaluator.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); ConnectionEnvironment connEnv = createConnectionEnvironment(); @@ -726,7 +727,8 @@ public void test139TryToLockByModelService() throws Exception { TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TestAbstractAuthenticationEvaluator.class.getName() + "." + TEST_NAME); + TestAbstractAuthenticationEvaluator.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -757,7 +759,8 @@ public void test150PasswordLoginDisabledGoodPassword() throws Exception { TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TestAbstractAuthenticationEvaluator.class.getName() + "." + TEST_NAME); + TestAbstractAuthenticationEvaluator.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_JACK_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.DISABLED); @@ -770,7 +773,8 @@ public void test152PasswordLoginEnabledGoodPassword() throws Exception { TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TestAbstractAuthenticationEvaluator.class.getName() + "." + TEST_NAME); + TestAbstractAuthenticationEvaluator.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_JACK_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.ENABLED); @@ -783,7 +787,8 @@ public void test154PasswordLoginNotValidYetGoodPassword() throws Exception { TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TestAbstractAuthenticationEvaluator.class.getName() + "." + TEST_NAME); + TestAbstractAuthenticationEvaluator.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); XMLGregorianCalendar validFrom = XmlTypeConverter.addDuration(clock.currentTimeXMLGregorianCalendar(), "PT1H"); @@ -804,7 +809,8 @@ public void test155PasswordLoginValidGoodPassword() throws Exception { // GIVEN clock.overrideDuration("PT2H"); - Task task = createTask(TestAbstractAuthenticationEvaluator.class.getName() + "." + TEST_NAME); + TestAbstractAuthenticationEvaluator.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); loginJackGoodPasswordExpectSuccess(TEST_NAME, task, result); @@ -818,7 +824,8 @@ public void test156PasswordLoginNotValidAnyLongerGoodPassword() throws Exception // GIVEN clock.overrideDuration("P2D"); - Task task = createTask(TestAbstractAuthenticationEvaluator.class.getName() + "." + TEST_NAME); + TestAbstractAuthenticationEvaluator.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); loginJackGoodPasswordExpectDenied(TEST_NAME, task, result); @@ -830,7 +837,8 @@ public void test159PasswordLoginNoLongerValidEnabledGoodPassword() throws Except TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TestAbstractAuthenticationEvaluator.class.getName() + "." + TEST_NAME); + TestAbstractAuthenticationEvaluator.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_JACK_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.ENABLED); @@ -843,7 +851,8 @@ public void test160PasswordLoginLifecycleActiveGoodPassword() throws Exception { TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TestAbstractAuthenticationEvaluator.class.getName() + "." + TEST_NAME); + TestAbstractAuthenticationEvaluator.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_JACK_OID, UserType.F_LIFECYCLE_STATE, task, result, @@ -858,7 +867,8 @@ public void test162PasswordLoginLifecycleDraftGoodPassword() throws Exception { TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TestAbstractAuthenticationEvaluator.class.getName() + "." + TEST_NAME); + TestAbstractAuthenticationEvaluator.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_JACK_OID, UserType.F_LIFECYCLE_STATE, task, result, @@ -873,7 +883,8 @@ public void test164PasswordLoginLifecycleDeprecatedGoodPassword() throws Excepti TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TestAbstractAuthenticationEvaluator.class.getName() + "." + TEST_NAME); + TestAbstractAuthenticationEvaluator.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_JACK_OID, UserType.F_LIFECYCLE_STATE, task, result, @@ -888,7 +899,8 @@ public void test166PasswordLoginLifecycleProposedGoodPassword() throws Exception TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TestAbstractAuthenticationEvaluator.class.getName() + "." + TEST_NAME); + TestAbstractAuthenticationEvaluator.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_JACK_OID, UserType.F_LIFECYCLE_STATE, task, result, @@ -903,7 +915,8 @@ public void test168PasswordLoginLifecycleArchivedGoodPassword() throws Exception TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TestAbstractAuthenticationEvaluator.class.getName() + "." + TEST_NAME); + TestAbstractAuthenticationEvaluator.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_JACK_OID, UserType.F_LIFECYCLE_STATE, task, result, @@ -918,7 +931,8 @@ public void test200UserGuybrushSetCredentials() throws Exception { TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TestAbstractAuthenticationEvaluator.class.getName() + "." + TEST_NAME); + TestAbstractAuthenticationEvaluator.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/sync/TestSynchronizationService.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/sync/TestSynchronizationService.java index be9c54ec707..3926c63e98a 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/sync/TestSynchronizationService.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/sync/TestSynchronizationService.java @@ -88,10 +88,8 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test010AddedAccountJack() throws Exception { - final String TEST_NAME = "test010AddedAccountJack"; - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); setDebugListener(); @@ -148,7 +146,7 @@ public void test020ModifyLootAbsolute() throws Exception { final String TEST_NAME = "test020ModifyLootAbsolute"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); setDebugListener(); @@ -202,10 +200,8 @@ public void test020ModifyLootAbsolute() throws Exception { @Test public void test021ModifyLootAbsoluteEmpty() throws Exception { - final String TEST_NAME = "test021ModifyLootAbsoluteEmpty"; - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); setDebugListener(); @@ -263,10 +259,8 @@ public void test021ModifyLootAbsoluteEmpty() throws Exception { */ @Test public void test030Reconcile() throws Exception { - final String TEST_NAME = "test030Reconcile"; - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); setDebugListener(); @@ -312,7 +306,7 @@ public void test039DeletedAccountJack() throws Exception { final String TEST_NAME = "test039DeletedAccountJack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject shadowRepo = repositoryService.getObject(ShadowType.class, accountShadowJackDummyOid, null, result); @@ -336,9 +330,8 @@ public void test039DeletedAccountJack() throws Exception { .assertIterationToken("") .assertSynchronizationSituation(SynchronizationSituationType.LINKED); - // In fact, it is responsibility of provisioning to mark shadow dead before invoking - // sync service. This is unit test, therefore we have to simulate behavior of provisioning - // here. + // In fact, it is responsibility of provisioning to mark shadow dead before invoking sync + // service. This is unit test, therefore we have to simulate behavior of provisioning here. markShadowTombstone(accountShadowJackDummyOid); shadowRepo = repositoryService.getObject(ShadowType.class, accountShadowJackDummyOid, null, result); @@ -414,7 +407,7 @@ public void test050AddedAccountCalypso() throws Exception { final String TEST_NAME = "test050AddedAccountCalypso"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); setDebugListener(); @@ -464,7 +457,7 @@ public void test051CalypsoRecon() throws Exception { final String TEST_NAME = "test051CalypsoRecon"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); setDebugListener(); @@ -509,7 +502,7 @@ public void test100AddedAccountJack() throws Exception { final String TEST_NAME = "test100AddedAccountJack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertUserBefore(USER_JACK_OID) @@ -580,7 +573,7 @@ public void test199DeletedAccountJackTotal() throws Exception { final String TEST_NAME = "test199DeletedAccountJackTotal"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); setDebugListener(); @@ -637,7 +630,7 @@ public void test200AddedAccountJackSchemaViolation() throws Exception { final String TEST_NAME = "test200AddedAccountJackSchemaViolation"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -710,7 +703,7 @@ public void test202UpdatedAccountJackSchemaViolation() throws Exception { final String TEST_NAME = "test202UpdatedAccountJackSchemaViolation"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -772,7 +765,7 @@ public void test210AssignJackDummy() throws Exception { final String TEST_NAME = "test210AssignJackDummy"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); setDebugListener(); @@ -820,7 +813,7 @@ public void test212AssignJackDummyLimited() throws Exception { final String TEST_NAME = "test212AssignJackDummyLimited"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); setDebugListener(); @@ -878,7 +871,7 @@ public void test214UpdatedAccountJackLimited() throws Exception { final String TEST_NAME = "test214UpdatedAccountJackLimited"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -963,7 +956,7 @@ public void test300AddedGroupPirates() throws Exception { final String TEST_NAME = "test300AddedGroupPirates"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); setDebugListener(); getDummyResource().resetBreakMode(); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/visualizer/TestVisualizer.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/visualizer/TestVisualizer.java index b9688ec850c..7592dd358c0 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/visualizer/TestVisualizer.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/visualizer/TestVisualizer.java @@ -67,7 +67,7 @@ public void setup() throws SchemaException, SAXException, IOException { @Test public void test100UserBasic() throws Exception { final String TEST_NAME = "test100UserBasic"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); PrismObject u = prismContext.createObject(UserType.class); u.setOid("123"); @@ -88,7 +88,7 @@ public void test100UserBasic() throws Exception { @Test public void test110UserWithContainers() throws Exception { final String TEST_NAME = "test101UserWithContainers"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); PrismObject u = prismContext.createObject(UserType.class); UserType ut = u.asObjectable(); @@ -126,7 +126,7 @@ public void test110UserWithContainers() throws Exception { @Test public void test200UserDeltaBasic() throws Exception { final String TEST_NAME = "test200UserDeltaBasic"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); ObjectDelta delta = deltaFor(UserType.class) .item(UserType.F_NAME).replace("admin") @@ -146,7 +146,7 @@ public void test200UserDeltaBasic() throws Exception { @Test public void test210UserDeltaContainers() throws Exception { final String TEST_NAME = "test210UserDeltaContainers"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); AssignmentType ass1 = new AssignmentType(prismContext); ass1.setActivation(new ActivationType(prismContext)); @@ -176,7 +176,7 @@ public void test210UserDeltaContainers() throws Exception { @Test public void test212UserDeltaContainerSimple() throws Exception { final String TEST_NAME = "test212UserDeltaContainerSimple"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); ObjectDelta delta = deltaFor(UserType.class) .item(UserType.F_ACTIVATION, ActivationType.F_EFFECTIVE_STATUS).replace(ActivationStatusType.ENABLED) @@ -197,7 +197,7 @@ public void test212UserDeltaContainerSimple() throws Exception { @Test public void test220UserContainerReplace() throws Exception { final String TEST_NAME = "test220UserContainerReplace"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); AssignmentType ass1 = new AssignmentType(prismContext); ass1.setActivation(new ActivationType(prismContext)); @@ -228,7 +228,7 @@ public void test220UserContainerReplace() throws Exception { @Test public void test230UserContainerDelete() throws Exception { final String TEST_NAME = "test230UserContainerDelete"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); AssignmentType ass1 = new AssignmentType(prismContext); ass1.setId(1L); @@ -255,7 +255,7 @@ public void test230UserContainerDelete() throws Exception { @Test public void test300UserAssignmentPreview() throws Exception { final String TEST_NAME = "test300UserAssignmentPreview"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); PrismObject jack = getUser(USER_JACK_OID); display("jack", jack); @@ -291,7 +291,7 @@ public void test300UserAssignmentPreview() throws Exception { @Test public void test305UserAssignmentAdd() throws Exception { final String TEST_NAME = "test305UserAssignmentAdd"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); display("jack", getUser(USER_JACK_OID)); @@ -320,7 +320,7 @@ public void test305UserAssignmentAdd() throws Exception { @Test public void test307UserDisablePreview() throws Exception { final String TEST_NAME = "test307UserDisablePreview"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); ObjectDelta delta = deltaFor(UserType.class) .item(UserType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS).replace(ActivationStatusType.DISABLED) @@ -365,7 +365,7 @@ protected void fillDeltas(ModelContext modelContext, List delta = deltaFor(UserType.class) .item(UserType.F_LINK_REF).add(createObjectRef(dummyAccountOid, SHADOW).asReferenceValue()) @@ -409,7 +409,7 @@ public void test320UserLinkRefAdd() throws Exception { @Test public void test330UserLinkRefReplaceNoOp() throws Exception { final String TEST_NAME = "test330UserLinkRefReplaceNoOp"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); ObjectDelta delta = deltaFor(UserType.class) .item(UserType.F_LINK_REF).replace(createObjectRef(dummyAccountOid, SHADOW).asReferenceValue()) @@ -429,7 +429,7 @@ public void test330UserLinkRefReplaceNoOp() throws Exception { @Test public void test340UserLinkRefReplaceOp() throws Exception { final String TEST_NAME = "test340UserLinkRefReplaceOp"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); ObjectDelta delta = deltaFor(UserType.class) .item(UserType.F_LINK_REF).replace(createObjectRef("777", SHADOW).asReferenceValue()) diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestActivation.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestActivation.java index c370531f50e..a8ca5836a83 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestActivation.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestActivation.java @@ -28,7 +28,6 @@ import com.evolveum.midpoint.prism.delta.*; import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.schema.util.ObjectTypeUtil; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.TestResource; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; @@ -806,7 +805,7 @@ public void test120ModifyUserJackAssignAccountDummyRed() throws Exception { final String TEST_NAME = "test120ModifyUserJackAssignAccountDummyRed"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -1004,7 +1003,7 @@ public void test140ModifyUserJackAssignAccountDummyRed() throws Exception { final String TEST_NAME = "test140ModifyUserJackAssignAccountDummyRed"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -1053,7 +1052,7 @@ public void test147ModifyUserJackUnassignAccountDummyRedRaw() throws Exception { final String TEST_NAME = "test147ModifyUserJackUnassignAccountDummyRedRaw"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -1100,7 +1099,7 @@ public void test149RecomputeJack() throws Exception { final String TEST_NAME = "test149RecomputeJack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -1148,7 +1147,7 @@ public void test150ModifyUserJackAssignYellowAccount() throws Exception { final String TEST_NAME = "test150ModifyUserJackAssignYellowAccount"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -1198,7 +1197,7 @@ public void test151ReconcileJack() throws Exception { final String TEST_NAME = "test151ReconcileJack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -1238,7 +1237,7 @@ public void test152ModifyAccountsJackDisable() throws Exception { final String TEST_NAME = "test152ModifyAccountsJackDisable"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -1354,7 +1353,7 @@ public void test160ModifyUserJackAssignAccountKhaki() throws Exception { final String TEST_NAME = "test160ModifyUserJackAssignAccountKhaki"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -1938,7 +1937,7 @@ public void test231JackRecomputeReconcile() throws Exception { public void test240AddUserRappDraft() throws Exception { final String TEST_NAME = "test240AddUserRappDraft"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = PrismTestUtil.parseObject(USER_RAPP_FILE); @@ -1995,7 +1994,7 @@ public void test240AddUserRappDraft() throws Exception { public void test241RecomputeRappDraft() throws Exception { final String TEST_NAME = "test240AddUserRappDraft"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -2037,7 +2036,7 @@ public void test241RecomputeRappDraft() throws Exception { public void test242RappAssignCaptain() throws Exception { final String TEST_NAME = "test242RappAssignCaptain"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -2074,7 +2073,7 @@ public void test242RappAssignCaptain() throws Exception { public void test245ActivateRapp() throws Exception { final String TEST_NAME = "test245ActivateRapp"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -2116,7 +2115,7 @@ public void test245ActivateRapp() throws Exception { public void test248DeactivateRapp() throws Exception { final String TEST_NAME = "test248DeactivateRapp"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -2152,7 +2151,7 @@ public void test248DeactivateRapp() throws Exception { public void test249DeleteUserRapp() throws Exception { final String TEST_NAME = "test249DeleteUserRapp"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -2177,7 +2176,7 @@ public void test300AddDummyGreenAccountMancomb() throws Exception { final String TEST_NAME = "test300AddDummyGreenAccountMancomb"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyAccount account = new DummyAccount(ACCOUNT_MANCOMB_DUMMY_USERNAME); @@ -2217,7 +2216,8 @@ public void test310ImportAccountsFromDummyGreen() throws Exception { final String TEST_NAME = "test310ImportAccountsFromDummyGreen"; // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // Preconditions @@ -2601,7 +2601,7 @@ public void test600AddUser1() throws Exception { final String TEST_NAME = "test600AddUser1"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user1 = prismContext.createObject(UserType.class); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestAudit.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestAudit.java index 8b7d7196d72..64c399bc357 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestAudit.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestAudit.java @@ -101,7 +101,7 @@ public void test000Sanity() throws Exception { assertTrue(modelAuditService.supportsRetrieval()); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -131,7 +131,7 @@ public void test010SanityJack() throws Exception { public void test100ModifyUserJackKid() throws Exception { final String TEST_NAME = "test100ModifyUserJackKid"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); initialTs = getTimeSafely(); @@ -159,7 +159,7 @@ public void test100ModifyUserJackKid() throws Exception { public void test105CreateUserHerman() throws Exception { final String TEST_NAME = "test105CreateUserHerman"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userHermanBefore = PrismTestUtil.parseObject(USER_HERMAN_FILE); @@ -190,7 +190,7 @@ public void test105CreateUserHerman() throws Exception { public void test110ModifyUserJackSailor() throws Exception { final String TEST_NAME = "test110ModifyUserJackSailor"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); @@ -222,7 +222,7 @@ public void test110ModifyUserJackSailor() throws Exception { public void test115ModifyUserHermanMarooned() throws Exception { final String TEST_NAME = "test115ModifyUserHermanMarooned"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta objectDelta = createModifyUserReplaceDelta(USER_HERMAN_OID, UserType.F_TITLE, @@ -252,7 +252,7 @@ public void test115ModifyUserHermanMarooned() throws Exception { public void test120ModifyUserJackCaptain() throws Exception { final String TEST_NAME = "test120ModifyUserJackCaptain"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta objectDelta = createModifyUserReplaceDelta(USER_JACK_OID, UserType.F_TITLE, @@ -282,7 +282,7 @@ public void test120ModifyUserJackCaptain() throws Exception { public void test125ModifyUserHermanHermit() throws Exception { final String TEST_NAME = "test125ModifyUserHermanHermit"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta objectDelta = createModifyUserReplaceDelta(USER_HERMAN_OID, UserType.F_TITLE, @@ -318,7 +318,7 @@ public void test125ModifyUserHermanHermit() throws Exception { public void test135ModifyUserHermanCivilisedHermit() throws Exception { final String TEST_NAME = "test135ModifyUserHermanCivilisedHermit"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta objectDelta = createModifyUserReplaceDelta(USER_HERMAN_OID, UserType.F_TITLE, @@ -349,7 +349,7 @@ public void test135ModifyUserHermanCivilisedHermit() throws Exception { public void test200ReconstructJackSailor() throws Exception { final String TEST_NAME = "test200ReconstructJackSailor"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -379,7 +379,7 @@ public void test200ReconstructJackSailor() throws Exception { public void test210ReconstructJackKid() throws Exception { final String TEST_NAME = "test210ReconstructJackKid"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -411,7 +411,7 @@ public void test210ReconstructJackKid() throws Exception { public void test250ReconstructHermanCreated() throws Exception { final String TEST_NAME = "test250ReconstructHermanCreated"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_HERMAN_OID); @@ -450,7 +450,7 @@ public void test250ReconstructHermanCreated() throws Exception { public void test252ReconstructHermanMarooned() throws Exception { final String TEST_NAME = "test252ReconstructHermanMarooned"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -482,7 +482,7 @@ public void test252ReconstructHermanMarooned() throws Exception { public void test254ReconstructHermanHermit() throws Exception { final String TEST_NAME = "test254ReconstructHermanHermit"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -512,7 +512,7 @@ public void test254ReconstructHermanHermit() throws Exception { public void test300QueryUnknown() throws Exception { final String TEST_NAME = "test300QueryUnknown"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -536,7 +536,7 @@ public void test300QueryUnknown() throws Exception { } private String assertObjectAuditRecords(String oid, int expectedNumberOfRecords) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - Task task = createTask("assertObjectAuditRecords"); + Task task = getTestTask(); OperationResult result = task.getResult(); List auditRecords = getObjectAuditRecords(oid, task, result); display("Object records", auditRecords); @@ -546,7 +546,7 @@ private String assertObjectAuditRecords(String oid, int expectedNumberOfRecords) private void assertRecordsFromPrevious(XMLGregorianCalendar from, XMLGregorianCalendar to, int expectedNumberOfRecords) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - Task task = createTask("assertRecordsFromPrevious"); + Task task = getTestTask(); OperationResult result = task.getResult(); List auditRecordsSincePrevious = getAuditRecordsFromTo(from, to, task, result); display("From/to records (previous)", auditRecordsSincePrevious); @@ -554,7 +554,7 @@ private void assertRecordsFromPrevious(XMLGregorianCalendar from, XMLGregorianCa } private void assertRecordsFromInitial(XMLGregorianCalendar to, int expectedNumberOfRecords) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - Task task = createTask("assertRecordsFromInitial"); + Task task = getTestTask(); OperationResult result = task.getResult(); List auditRecordsSincePrevious = getAuditRecordsFromTo(initialTs, to, task, result); display("From/to records (initial)", auditRecordsSincePrevious); @@ -594,7 +594,7 @@ public void test300ConcurrentAudits() throws Exception { Thread thread = new Thread(() -> { try { login(userAdministrator); - Task threadTask = createTask(TEST_NAME); + Task threadTask = getTestTask(); OperationResult threadResult = threadTask.getResult(); for (int iteration = 0; iteration < ITERATIONS; iteration++) { display("Executing iteration " + iteration + " on user " + index); @@ -665,7 +665,7 @@ public void test310ConcurrentAuditsRaw() throws Exception { Thread thread = new Thread(() -> { try { login(userAdministrator); - Task threadTask = createTask(TEST_NAME); + Task threadTask = getTestTask(); OperationResult threadResult = threadTask.getResult(); for (int iteration = 0; iteration < ITERATIONS; iteration++) { display("Executing iteration " + iteration + " in worker " + index); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestCaseIgnore.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestCaseIgnore.java index e2fd2e47c80..1e8a37b2670 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestCaseIgnore.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestCaseIgnore.java @@ -25,7 +25,6 @@ import com.evolveum.midpoint.schema.util.ObjectQueryUtil; import com.evolveum.midpoint.schema.util.ResourceTypeUtil; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DOMUtil; diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConnectorDummyFake.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConnectorDummyFake.java index 2467b678cfc..b5a9d804ce5 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConnectorDummyFake.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConnectorDummyFake.java @@ -88,7 +88,7 @@ public void test010ListConnectors() throws Exception { final String TEST_NAME = "test010ListConnectors"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -125,7 +125,7 @@ public void test020ImportFakeResource() throws Exception { final String TEST_NAME = "test020ImportFakeResource"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -149,7 +149,7 @@ public void test021TestFakeResource() throws Exception { final String TEST_NAME = "test021TestFakeResource"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -165,7 +165,7 @@ public void test022ListAccountsFakeResource() throws Exception { final String TEST_NAME = "test022ListAccountsFakeResource"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -184,7 +184,7 @@ public void test030ImportDummyResource() throws Exception { final String TEST_NAME = "test030ImportDummyResource"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -208,7 +208,7 @@ public void test031TestDummyResource() throws Exception { final String TEST_NAME = "test031TestDummyResource"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -224,7 +224,7 @@ public void test032ListAccountsDummyResource() throws Exception { final String TEST_NAME = "test032ListAccountsDummyResource"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -245,7 +245,7 @@ public void test100UpgradeModelAddDelete() throws Exception { final String TEST_NAME = "test100UpgradeModelAddDelete"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject dummyResourceModelBefore = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result); @@ -279,7 +279,7 @@ public void test150DowngradeModelAddDelete() throws Exception { final String TEST_NAME = "test150DowngradeModelAddDelete"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject dummyResourceModelBefore = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result); @@ -308,7 +308,7 @@ public void test200UpgradeModelReplace() throws Exception { final String TEST_NAME = "test200UpgradeModelReplace"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject dummyResourceModelBefore = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result); @@ -335,7 +335,7 @@ public void test250DowngradeModelReplace() throws Exception { final String TEST_NAME = "test250DowngradeModelReplace"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject dummyResourceModelBefore = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result); @@ -361,7 +361,7 @@ public void test300UpgradeRawAddDelete() throws Exception { final String TEST_NAME = "test300UpgradeRawAddDelete"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject dummyResourceModelBefore = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result); @@ -393,7 +393,7 @@ public void test350DowngradeRawAddDelete() throws Exception { final String TEST_NAME = "test350DowngradeRawAddDelete"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject dummyResourceModelBefore = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result); @@ -427,7 +427,7 @@ public void test400UpgradeRawReplace() throws Exception { final String TEST_NAME = "test400UpgradeRawReplace"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject dummyResourceModelBefore = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result); @@ -459,7 +459,7 @@ public void test450DowngradeRawReplace() throws Exception { final String TEST_NAME = "test450DowngradeRawReplace"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject dummyResourceModelBefore = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConnectorMultiInstance.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConnectorMultiInstance.java index ef6d9523301..970a2a46bbd 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConnectorMultiInstance.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConnectorMultiInstance.java @@ -84,7 +84,7 @@ public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); // WHEN OperationResult testResult = modelService.testResource(RESOURCE_DUMMY_YELLOW_OID, task); @@ -101,7 +101,7 @@ public void test100JackAssignDummyYellow() throws Exception { final String TEST_NAME = "test100JackAssignDummyYellow"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -321,7 +321,7 @@ public void test200GuybrushAssignDummyBlack() throws Exception { final String TEST_NAME = "test200GuybrushAssignDummyBlack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConsistencySimple.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConsistencySimple.java index c5c9c924ad7..3973ebdcb26 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConsistencySimple.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConsistencySimple.java @@ -148,7 +148,7 @@ private void executeTest(final String TEST_NAME, FocusOperation focusOperation, ResourceObjectOperation resourceObjectOperation) throws Exception { // GIVEN - Task task = createTask(TEST_NAME + ".given"); + Task task = getTestTask(); OperationResult result = task.getResult(); cleanUpBeforeTest(task, result); @@ -194,7 +194,7 @@ private void executeTest(final String TEST_NAME, FocusOperation focusOperation, assertDummyAccount(null, "jack"); } - task = createTask(TEST_NAME); + task = getTestTask(); result = task.getResult(); // WHEN diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestDeputy.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestDeputy.java index a380f859620..5a881bec058 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestDeputy.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestDeputy.java @@ -24,7 +24,6 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType; import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType; @@ -76,7 +75,7 @@ public void test000Sanity() throws Exception { public void test100AssignDeputyNoBigDeal() throws Exception { final String TEST_NAME = "test100AssignDeputyNoBigDeal"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -112,7 +111,7 @@ public void test100AssignDeputyNoBigDeal() throws Exception { public void test109UnassignDeputyNoBigDeal() throws Exception { final String TEST_NAME = "test109UnassignDeputyNoBigDeal"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -147,7 +146,7 @@ public void test109UnassignDeputyNoBigDeal() throws Exception { public void test110AssignJackPirate() throws Exception { final String TEST_NAME = "test110AssignJackPirate"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -184,7 +183,7 @@ public void test110AssignJackPirate() throws Exception { public void test112AssignDeputyPirate() throws Exception { final String TEST_NAME = "test112AssignDeputyPirate"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -226,7 +225,7 @@ public void test112AssignDeputyPirate() throws Exception { public void test119UnassignDeputyPirate() throws Exception { final String TEST_NAME = "test119UnassignDeputyPirate"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -263,7 +262,7 @@ public void test119UnassignDeputyPirate() throws Exception { public void test120AssignbarbossaDeputyOfGuybrush() throws Exception { final String TEST_NAME = "test120AssignbarbossaDeputyOfGuybrush"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userGuybrushBefore = getUser(USER_GUYBRUSH_OID); @@ -305,7 +304,7 @@ public void test120AssignbarbossaDeputyOfGuybrush() throws Exception { public void test122AssignGuybrushPirate() throws Exception { final String TEST_NAME = "test122AssignGuybrushPirate"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -343,7 +342,7 @@ public void test122AssignGuybrushPirate() throws Exception { public void test124RecomputeBarbossa() throws Exception { final String TEST_NAME = "test124RecomputeBarbossa"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -383,7 +382,7 @@ public void test124RecomputeBarbossa() throws Exception { public void test126UnassignGuybrushPirate() throws Exception { final String TEST_NAME = "test126UnassignGuybrushPirate"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -420,7 +419,7 @@ public void test126UnassignGuybrushPirate() throws Exception { public void test128RecomputeBarbossa() throws Exception { final String TEST_NAME = "test128RecomputeBarbossa"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -453,7 +452,7 @@ public void test128RecomputeBarbossa() throws Exception { public void test129UnassignBarbossaDeputyOfGuybrush() throws Exception { final String TEST_NAME = "test129UnassignBarbossaDeputyOfGuybrush"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -488,7 +487,7 @@ public void test129UnassignBarbossaDeputyOfGuybrush() throws Exception { public void test150AssignJackMoreRoles() throws Exception { final String TEST_NAME = "test150AssignJackMoreRoles"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta userDelta = createAssignmentUserDelta(USER_JACK_OID, ROLE_PIRATE_OID, RoleType.COMPLEX_TYPE, @@ -541,7 +540,7 @@ public void test150AssignJackMoreRoles() throws Exception { public void test152AssignbarbossaDeputyLimitedDeputy() throws Exception { final String TEST_NAME = "test152AssignbarbossaDeputyLimitedDeputy"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -577,7 +576,7 @@ public void test152AssignbarbossaDeputyLimitedDeputy() throws Exception { public void test154UnassignbarbossaDeputyLimitedDeputy() throws Exception { final String TEST_NAME = "test154UnassignbarbossaDeputyLimitedDeputy"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -610,7 +609,7 @@ public void test154UnassignbarbossaDeputyLimitedDeputy() throws Exception { public void test156AssignbarbossaDeputyLimitedDeputyRed() throws Exception { final String TEST_NAME = "test156AssignbarbossaDeputyLimitedDeputyRed"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -647,7 +646,7 @@ public void test156AssignbarbossaDeputyLimitedDeputyRed() throws Exception { public void test159UnassignbarbossaDeputyLimitedDeputyRed() throws Exception { final String TEST_NAME = "test159UnassignbarbossaDeputyLimitedDeputyRed"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -688,7 +687,7 @@ public void test159UnassignbarbossaDeputyLimitedDeputyRed() throws Exception { public void test160AssignbarbossaDeputyLimitedDeputyEmpty() throws Exception { final String TEST_NAME = "test160AssignbarbossaDeputyLimitedDeputyEmpty"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -724,7 +723,7 @@ public void test160AssignbarbossaDeputyLimitedDeputyEmpty() throws Exception { public void test162UnassignbarbossaDeputyLimitedDeputyEmpty() throws Exception { final String TEST_NAME = "test162UnassignbarbossaDeputyLimitedDeputyEmpty"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -763,7 +762,7 @@ public void test162UnassignbarbossaDeputyLimitedDeputyEmpty() throws Exception { public void test170AddRoleDrinker() throws Exception { final String TEST_NAME = "test170AssignJackRoleDrinker"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject role = PrismTestUtil.parseObject(ROLE_DRINKER_FILE); @@ -787,7 +786,7 @@ public void test170AddRoleDrinker() throws Exception { public void test172AssignJackRoleDrinker() throws Exception { final String TEST_NAME = "test170AssignJackRoleDrinker"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -816,7 +815,7 @@ public void test172AssignJackRoleDrinker() throws Exception { public void test174AssignBarbossaDeputyLimitedDeputyDrinker() throws Exception { final String TEST_NAME = "test174AssignBarbossaDeputyLimitedDeputyDrinker"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -854,7 +853,7 @@ public void test174AssignBarbossaDeputyLimitedDeputyDrinker() throws Exception { public void test176AssignbarGuybrushLimitedDeputyOfBarbossa() throws Exception { final String TEST_NAME = "test176AssignbarGuybrushLimitedDeputyOfBarbossa"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userGuybrushBefore = getUser(USER_GUYBRUSH_OID); @@ -891,7 +890,7 @@ public void test176AssignbarGuybrushLimitedDeputyOfBarbossa() throws Exception { public void test178UnassignBarbossaDeputyLimitedDeputyDrinker() throws Exception { final String TEST_NAME = "test178UnassignBsarbossaDeputyLimitedDeputyDrinker"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -937,7 +936,7 @@ public void test178UnassignBarbossaDeputyLimitedDeputyDrinker() throws Exception public void test179UnassignbarGuybrushLimitedDeputyOfBarbossa() throws Exception { final String TEST_NAME = "test179UnassignbarGuybrushLimitedDeputyOfBarbossa"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -965,7 +964,7 @@ public void test179UnassignbarGuybrushLimitedDeputyOfBarbossa() throws Exception public void test180AssignBarbossaDeputyOfJack() throws Exception { final String TEST_NAME = "test180AssignBarbossaDeputyOfJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -993,7 +992,7 @@ public void test180AssignBarbossaDeputyOfJack() throws Exception { public void test182AssignGuybrushLimitedDeputyOfBarbossa() throws Exception { final String TEST_NAME = "test182AssignGuybrushLimitedDeputyOfBarbossa"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userGuybrushBefore = getUser(USER_GUYBRUSH_OID); @@ -1028,7 +1027,7 @@ public void test182AssignGuybrushLimitedDeputyOfBarbossa() throws Exception { public void test184UnassignGuybrushLimitedDeputyOfBarbossa() throws Exception { final String TEST_NAME = "test182AssignGuybrushLimitedDeputyOfBarbossa"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1056,7 +1055,7 @@ public void test184UnassignGuybrushLimitedDeputyOfBarbossa() throws Exception { public void test186AssignGuybrushDeputyOfBarbossa() throws Exception { final String TEST_NAME = "test182AssignGuybrushLimitedDeputyOfBarbossa"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userGuybrushBefore = getUser(USER_GUYBRUSH_OID); @@ -1089,7 +1088,7 @@ public void test186AssignGuybrushDeputyOfBarbossa() throws Exception { public void test188UnassignGuybrushDeputyOfBarbossa() throws Exception { final String TEST_NAME = "test188UnassignGuybrushDeputyOfBarbossa"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1112,7 +1111,7 @@ public void test188UnassignGuybrushDeputyOfBarbossa() throws Exception { public void test189UnassignBarbossaDeputyOfJack() throws Exception { final String TEST_NAME = "test189UnassignBarbossaDeputyOfJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1135,7 +1134,7 @@ public void test189UnassignBarbossaDeputyOfJack() throws Exception { public void test190AssignBarbossaDeputyLimitedDeputyEmptyDrinker() throws Exception { final String TEST_NAME = "test190AssignBarbossaDeputyLimitedDeputyEmptyDrinker"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1172,7 +1171,7 @@ public void test190AssignBarbossaDeputyLimitedDeputyEmptyDrinker() throws Except public void test192UnassignbarbossaDeputyLimitedDeputyEmptyDrinker() throws Exception { final String TEST_NAME = "test192UnassignbarbossaDeputyLimitedDeputyEmptyDrinker"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -1214,7 +1213,8 @@ public void test800ImportValidityScannerTask() throws Exception { final String TEST_NAME = "test800ImportValidityScannerTask"; // GIVEN - Task task = createTask(TestValidityRecomputeTask.class.getName() + "." + TEST_NAME); + TestValidityRecomputeTask.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); XMLGregorianCalendar startCal = clock.currentTimeXMLGregorianCalendar(); @@ -1240,7 +1240,7 @@ public void test800ImportValidityScannerTask() throws Exception { public void test802AssignBarbossaDeputyOfJack() throws Exception { final String TEST_NAME = "test802AssignBarbossaDeputyOfJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userJackBefore = getUser(USER_JACK_OID); @@ -1293,7 +1293,7 @@ public void test802AssignBarbossaDeputyOfJack() throws Exception { public void test804BarbosaThreeHoursLater() throws Exception { final String TEST_NAME = "test804BarbosaThreeHoursLater"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clock.overrideDuration("PT3H"); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestEntitlements.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestEntitlements.java index 8c95ab7c472..d0c7ddfc54e 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestEntitlements.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestEntitlements.java @@ -23,10 +23,8 @@ import com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition; import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition; import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.schema.util.ObjectQueryUtil; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.util.TestUtil; @@ -148,7 +146,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti public void test100AddGroupShadowSwashbucklers() throws Exception { final String TEST_NAME = "test100AddGroupShadowSwashbucklers"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertSteadyResources(); @@ -176,7 +174,7 @@ public void test100AddGroupShadowSwashbucklers() throws Exception { public void test101GetGroupShadowSwashbucklers() throws Exception { final String TEST_NAME = "test101GetGroupShadowSwashbucklers"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -198,7 +196,7 @@ public void test101GetGroupShadowSwashbucklers() throws Exception { public void test110AssociateGuybrushToSwashbucklers() throws Exception { final String TEST_NAME = "test110AssociateGuybrushToSwashbucklers"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = IntegrationTestTools.createEntitleDelta(ACCOUNT_SHADOW_GUYBRUSH_OID, @@ -222,7 +220,7 @@ public void test110AssociateGuybrushToSwashbucklers() throws Exception { public void test200AssignRoleSwashbucklerToJack() throws Exception { final String TEST_NAME = "test200AssignRoleSwashbucklerToJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -252,7 +250,7 @@ public void test200AssignRoleSwashbucklerToJack() throws Exception { public void test209UnAssignRoleSwashbucklerFromJack() throws Exception { final String TEST_NAME = "test209UnAssignRoleSwashbucklerFromJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -285,7 +283,7 @@ public void test209UnAssignRoleSwashbucklerFromJack() throws Exception { public void test220AssignRoleLandluberToWally() throws Exception { final String TEST_NAME = "test220AssignRoleLandluberToWally"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); addObject(SHADOW_GROUP_DUMMY_LANDLUBERS_FILE); @@ -314,7 +312,7 @@ public void test220AssignRoleLandluberToWally() throws Exception { public void test222AssignRoleMapmakerToWally() throws Exception { final String TEST_NAME = "test222AssignRoleMapmakerToWally"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyGroup mapmakers = new DummyGroup(GROUP_DUMMY_MAPMAKERS_NAME); @@ -356,7 +354,7 @@ public void test222AssignRoleMapmakerToWally() throws Exception { public void test224UnassignRoleMapmakerFromWally() throws Exception { final String TEST_NAME = "test224UnassignRoleMapmakerFromWally"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = findUserByUsername(USER_WALLY_NAME); @@ -380,7 +378,7 @@ public void test224UnassignRoleMapmakerFromWally() throws Exception { public void test300AddRoleWimp() throws Exception { final String TEST_NAME = "test300AddRoleWimp"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -412,7 +410,7 @@ public void test300AddRoleWimp() throws Exception { public void test302AddRoleBrute() throws Exception { final String TEST_NAME = "test302AddRoleBrute"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -439,7 +437,7 @@ public void test302AddRoleBrute() throws Exception { public void test304AddRoleThug() throws Exception { final String TEST_NAME = "test304AddRoleThug"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -466,7 +464,7 @@ public void test304AddRoleThug() throws Exception { public void test310AssignRoleWimpToLargo() throws Exception { final String TEST_NAME = "test310AssignRoleWimpToLargo"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); addObject(USER_LARGO_FILE); @@ -492,7 +490,7 @@ public void test310AssignRoleWimpToLargo() throws Exception { public void test312AssignRoleBruteToLargo() throws Exception { final String TEST_NAME = "test312AssignRoleBruteToLargo"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -516,7 +514,7 @@ public void test312AssignRoleBruteToLargo() throws Exception { public void test313UnAssignRoleBruteFromLargo() throws Exception { final String TEST_NAME = "test313UnAssignRoleBruteFromLargo"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -550,7 +548,7 @@ public void test313UnAssignRoleBruteFromLargo() throws Exception { public void test314AssignRoleThugToLargo() throws Exception { final String TEST_NAME = "test314AssignRoleThugToLargo"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -574,7 +572,7 @@ public void test314AssignRoleThugToLargo() throws Exception { public void test315UnAssignRoleThugFromLargo() throws Exception { final String TEST_NAME = "test315UnAssignRoleThugFromLargo"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -611,7 +609,7 @@ public void test315UnAssignRoleThugFromLargo() throws Exception { public void test317RenameLargo() throws Exception { final String TEST_NAME = "test317RenameLargo"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -642,7 +640,7 @@ public void test317RenameLargo() throws Exception { public void test319UnassignRoleWimpFromLargo() throws Exception { final String TEST_NAME = "test319UnassignRoleWimpFromLargo"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -678,7 +676,7 @@ public void test319UnassignRoleWimpFromLargo() throws Exception { public void test320AssignRoleBruteToRapp() throws Exception { final String TEST_NAME = "test320AssignRoleBruteToRapp"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); addObject(USER_RAPP_FILE); @@ -704,7 +702,7 @@ public void test320AssignRoleBruteToRapp() throws Exception { public void test322AssignRoleWimpToRapp() throws Exception { final String TEST_NAME = "test322AssignRoleWimpToRapp"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -735,7 +733,7 @@ public void test322AssignRoleWimpToRapp() throws Exception { public void test324AssignRoleThugToRapp() throws Exception { final String TEST_NAME = "test324AssignRoleThugToRapp"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -773,7 +771,7 @@ public void test324AssignRoleThugToRapp() throws Exception { public void test327UnassignRoleWimpFromRapp() throws Exception { final String TEST_NAME = "test327UnassignRoleWimpFromRapp"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -814,7 +812,7 @@ public void test327UnassignRoleWimpFromRapp() throws Exception { public void test328UnassignRoleThugFromRapp() throws Exception { final String TEST_NAME = "test328UnassignRoleThugFromRapp"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -858,7 +856,7 @@ public void test328UnassignRoleThugFromRapp() throws Exception { public void test329UnAssignRoleBruteFromRapp() throws Exception { final String TEST_NAME = "test329UnAssignRoleBruteFromRapp"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -896,7 +894,7 @@ public void test329UnAssignRoleBruteFromRapp() throws Exception { public void test350AssignOrangeAccountToGuybrushAndRapp() throws Exception { final String TEST_NAME = "test350AssignOrangeAccountToGuybrushAndRapp"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -921,7 +919,7 @@ public void test350AssignOrangeAccountToGuybrushAndRapp() throws Exception { public void test351AssignRoleCrewOfGuybrushToRapp() throws Exception { final String TEST_NAME = "test351AssignRoleCrewOfGuybrushToRapp"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userRappBefore = getUser(USER_RAPP_OID); @@ -965,7 +963,7 @@ public void test351AssignRoleCrewOfGuybrushToRapp() throws Exception { public void test358UnassignRoleCrewOfGuybrushToRapp() throws Exception { final String TEST_NAME = "test358UnassignRoleCrewOfGuybrushToRapp"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userRappBefore = getUser(USER_RAPP_OID); @@ -1004,7 +1002,7 @@ public void test358UnassignRoleCrewOfGuybrushToRapp() throws Exception { public void test359UnassignOrangeAccountFromGuybrushAndRapp() throws Exception { final String TEST_NAME = "test359UnassignOrangeAccountFromGuybrushAndRapp"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1026,7 +1024,7 @@ public void test359UnassignOrangeAccountFromGuybrushAndRapp() throws Exception { public void test600AssignRolePirateToJack() throws Exception { final String TEST_NAME = "test600AssignRolePirateToJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1060,7 +1058,7 @@ public void test600AssignRolePirateToJack() throws Exception { public void test610AssignRoleSwashbucklerToJack() throws Exception { final String TEST_NAME = "test610AssignRoleSwashbucklerToJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1093,7 +1091,7 @@ public void test610AssignRoleSwashbucklerToJack() throws Exception { public void test620UnAssignSwashbucklerFromJack() throws Exception { final String TEST_NAME = "test620UnAssignSwashbucklerFromJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1130,7 +1128,7 @@ public void test620UnAssignSwashbucklerFromJack() throws Exception { public void test630AssignRoleSwashbucklerToJackValidity() throws Exception { final String TEST_NAME = "test630AssignRoleSwashbucklerToJackValidity"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); jackSwashbucklerAssignmentActivation = new ActivationType(); @@ -1173,7 +1171,7 @@ public void test630AssignRoleSwashbucklerToJackValidity() throws Exception { public void test640JackRoleSwashbucklerBecomesValid() throws Exception { final String TEST_NAME = "test640JackRoleSwashbucklerBecomesValid"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clock.overrideDuration("PT2H"); @@ -1208,7 +1206,7 @@ public void test640JackRoleSwashbucklerBecomesValid() throws Exception { public void test645JackRoleSwashbucklerIsValid() throws Exception { final String TEST_NAME = "test645JackRoleSwashbucklerIsValid"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1239,7 +1237,7 @@ public void test645JackRoleSwashbucklerIsValid() throws Exception { public void test650JackRoleSwashbucklerBecomesInvalid() throws Exception { final String TEST_NAME = "test650JackRoleSwashbucklerBecomesInvalid"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clock.overrideDuration("PT2H"); @@ -1274,7 +1272,7 @@ public void test650JackRoleSwashbucklerBecomesInvalid() throws Exception { public void test659UnassignRoleSwashbucklerFromJack() throws Exception { final String TEST_NAME = "test659UnassignRoleSwashbucklerFromJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1313,7 +1311,7 @@ public void test659UnassignRoleSwashbucklerFromJack() throws Exception { public void test699UnassignRolePirateFromJack() throws Exception { final String TEST_NAME = "test699UnassignRolePirateFromJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1338,7 +1336,7 @@ public void test699UnassignRolePirateFromJack() throws Exception { public void test700ReconcileGuybrush() throws Exception { final String TEST_NAME = "test700ReconcileGuybrush"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clock.resetOverride(); @@ -1371,7 +1369,7 @@ public void test700ReconcileGuybrush() throws Exception { public void test710AssociateGuybrushToLandlubers() throws Exception { final String TEST_NAME = "test710AssociateGuybrushToLandlubers"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = @@ -1396,7 +1394,7 @@ public void test710AssociateGuybrushToLandlubers() throws Exception { public void test715AssociateGuybrushToThugs() throws Exception { final String TEST_NAME = "test715AssociateGuybrushToThugs"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // GIVEN @@ -1439,7 +1437,7 @@ public void test715AssociateGuybrushToThugs() throws Exception { public void test720ReconcileGuybrush() throws Exception { final String TEST_NAME = "test720ReconcileGuybrush"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dumpUserAndAccounts(USER_GUYBRUSH_OID); @@ -1464,7 +1462,7 @@ public void test720ReconcileGuybrush() throws Exception { public void test729CleanupGuybrush() throws Exception { final String TEST_NAME = "test729CleanupGuybrush"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -1495,7 +1493,7 @@ public void test729CleanupGuybrush() throws Exception { public void test750PrepareGuybrushFuturePerfect() throws Exception { final String TEST_NAME = "test750PrepareGuybrushFuturePerfect"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -1537,7 +1535,7 @@ private String orgGroupName(String ou) { public void test752GuybrushFuturePerfect() throws Exception { final String TEST_NAME = "test752GuybrushFuturePerfect"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); getDummyResourceController().addGroup(orgGroupName(OU_CLUB_SCI_FI)); @@ -1562,7 +1560,7 @@ public void test752GuybrushFuturePerfect() throws Exception { public void test759CleanupGuybrush() throws Exception { final String TEST_NAME = "test759CleanupGuybrush"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dumpUserAndAccounts(USER_GUYBRUSH_OID); @@ -1588,7 +1586,7 @@ public void test759CleanupGuybrush() throws Exception { public void test760GuybrushOrgGroupsRepo() throws Exception { final String TEST_NAME = "test760GuybrushOrgGroupsRepo"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = dumpUserAndAccounts(USER_GUYBRUSH_OID); @@ -1615,7 +1613,7 @@ public void test760GuybrushOrgGroupsRepo() throws Exception { public void test765ReconcileGuybrush() throws Exception { final String TEST_NAME = "test765ReconcileGuybrush"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -1646,7 +1644,7 @@ public void test765ReconcileGuybrush() throws Exception { public void test769CleanupGuybrush() throws Exception { final String TEST_NAME = "test769CleanupGuybrush"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dumpUserAndAccounts(USER_GUYBRUSH_OID); @@ -1672,7 +1670,7 @@ public void test769CleanupGuybrush() throws Exception { public void test780AssignGuybrushSwashbuckler() throws Exception { final String TEST_NAME = "test780AssignGuybrushSwashbuckler"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1696,7 +1694,7 @@ public void test780AssignGuybrushSwashbuckler() throws Exception { public void test781GuybrushTheLostSwashbuckler() throws Exception { final String TEST_NAME = "test781GuybrushTheLostSwashbuckler"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyGroup dummyGroup = getDummyResource().getGroupByName(GROUP_DUMMY_SWASHBUCKLERS_NAME); @@ -1719,7 +1717,7 @@ public void test781GuybrushTheLostSwashbuckler() throws Exception { public void test784UnassignGuybrushSwashbuckler() throws Exception { final String TEST_NAME = "test784UnassignGuybrushSwashbuckler"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1738,7 +1736,7 @@ public void test784UnassignGuybrushSwashbuckler() throws Exception { public void test785AssignGuybrushBlueSwashbuckler() throws Exception { final String TEST_NAME = "test785AssignGuybrushBlueSwashbuckler"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject group = prismContext.parseObject(SHADOW_GROUP_DUMMY_SWASHBUCKLERS_BLUE_FILE); @@ -1765,7 +1763,7 @@ public void test785AssignGuybrushBlueSwashbuckler() throws Exception { public void test786GuybrushTheLostBlueSwashbuckler() throws Exception { final String TEST_NAME = "test786GuybrushTheLostBlueSwashbuckler"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyGroup dummyGroup = getDummyResource(RESOURCE_DUMMY_BLUE_NAME).getGroupByName(GROUP_DUMMY_SWASHBUCKLERS_NAME); @@ -1788,7 +1786,7 @@ public void test786GuybrushTheLostBlueSwashbuckler() throws Exception { public void test789UnassignGuybrushBlueSwashbuckler() throws Exception { final String TEST_NAME = "test789UnassignGuybrushBlueSwashbuckler"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1810,7 +1808,7 @@ public void test789UnassignGuybrushBlueSwashbuckler() throws Exception { public void test800AssignRoleSwashbucklerToJackNone() throws Exception { final String TEST_NAME = "test800AssignRoleSwashbucklerToJackNone"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -1843,7 +1841,7 @@ public void test800AssignRoleSwashbucklerToJackNone() throws Exception { public void test805ReconcileJackNone() throws Exception { final String TEST_NAME = "test805ReconcileJackNone"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -1871,7 +1869,7 @@ public void test805ReconcileJackNone() throws Exception { public void test809UnAssignRoleSwashbucklerFromJackNone() throws Exception { final String TEST_NAME = "test809UnAssignRoleSwashbucklerFromJackNone"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -1898,7 +1896,7 @@ public void test809UnAssignRoleSwashbucklerFromJackNone() throws Exception { public void test810AssignRoleSwashbucklerToJackPositive() throws Exception { final String TEST_NAME = "test810AssignRoleSwashbucklerToJackPositive"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -1929,7 +1927,7 @@ public void test810AssignRoleSwashbucklerToJackPositive() throws Exception { public void test815ReconcileJackPositive() throws Exception { final String TEST_NAME = "test815ReconcileJackPositive"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -1957,7 +1955,7 @@ public void test815ReconcileJackPositive() throws Exception { public void test817UnAssignRoleSwashbucklerFromJackPositive() throws Exception { final String TEST_NAME = "test817UnAssignRoleSwashbucklerFromJackPositive"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -1984,7 +1982,7 @@ public void test817UnAssignRoleSwashbucklerFromJackPositive() throws Exception { public void test819ReconcileJackPositive() throws Exception { final String TEST_NAME = "test819ReconcileJackPositive"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -2016,7 +2014,7 @@ public void test819ReconcileJackPositive() throws Exception { public void test820RecomputeJackFull() throws Exception { final String TEST_NAME = "test820RecomputeJackFull"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -2046,7 +2044,7 @@ public void test820RecomputeJackFull() throws Exception { public void test822AssignRoleSwashbucklerToJackFull() throws Exception { final String TEST_NAME = "test822AssignRoleSwashbucklerToJackFull"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -2077,7 +2075,7 @@ public void test822AssignRoleSwashbucklerToJackFull() throws Exception { public void test825ReconcileJackFull() throws Exception { final String TEST_NAME = "test825ReconcileJackFull"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -2105,7 +2103,7 @@ public void test825ReconcileJackFull() throws Exception { public void test827UnAssignRoleSwashbucklerFromJackFull() throws Exception { final String TEST_NAME = "test827UnAssignRoleSwashbucklerFromJackFull"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -2132,7 +2130,7 @@ public void test827UnAssignRoleSwashbucklerFromJackFull() throws Exception { public void test829ReconcileJackFull() throws Exception { final String TEST_NAME = "test829ReconcileJackFull"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -2160,7 +2158,7 @@ public void test829ReconcileJackFull() throws Exception { public void test830AssignJackAccountDummy() throws Exception { final String TEST_NAME = "test830AssignJackAccountDummy"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -2190,7 +2188,7 @@ public void test830AssignJackAccountDummy() throws Exception { public void test840AssignRoleSwashbucklerToJackNone() throws Exception { final String TEST_NAME = "test840AssignRoleSwashbucklerToJackNone"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -2221,7 +2219,7 @@ public void test840AssignRoleSwashbucklerToJackNone() throws Exception { public void test849UnassignRoleSwashbucklerFromJackNone() throws Exception { final String TEST_NAME = "test849UnassignRoleSwashbucklerFromJackNone"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -2248,7 +2246,7 @@ public void test849UnassignRoleSwashbucklerFromJackNone() throws Exception { public void test850AssignRoleSwashbucklerToJackPositive() throws Exception { final String TEST_NAME = "test850AssignRoleSwashbucklerToJackPositive"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -2279,7 +2277,7 @@ public void test850AssignRoleSwashbucklerToJackPositive() throws Exception { public void test859UnassignRoleSwashbucklerToJackPositive() throws Exception { final String TEST_NAME = "test859UnassignRoleSwashbucklerToJackPositive"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -2308,7 +2306,7 @@ public void test859UnassignRoleSwashbucklerToJackPositive() throws Exception { public void test860RecomputeJackFull() throws Exception { final String TEST_NAME = "test860RecomputeJackFull"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -2335,7 +2333,7 @@ public void test860RecomputeJackFull() throws Exception { public void test862AssignRoleSwashbucklerToJackFull() throws Exception { final String TEST_NAME = "test862AssignRoleSwashbucklerToJackFull"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -2366,7 +2364,7 @@ public void test862AssignRoleSwashbucklerToJackFull() throws Exception { public void test869UnassignRoleSwashbucklerToJackFull() throws Exception { final String TEST_NAME = "test869UnassignRoleSwashbucklerToJackFull"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -2393,7 +2391,7 @@ public void test869UnassignRoleSwashbucklerToJackFull() throws Exception { public void test899UnAssignAccountJackDummy() throws Exception { final String TEST_NAME = "test899UnAssignAccountJackDummy"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -2483,7 +2481,7 @@ private void dumpUsersAndTheirAccounts(Task task, OperationResult result) throws private void dumpUserAndAccounts(PrismObject user) throws ConfigurationException, ObjectNotFoundException, SchemaException, CommunicationException, SecurityViolationException, ExpressionEvaluationException { - Task task = createTask("dumpUserAndAccounts"); + Task task = getTestTask(); OperationResult result = task.getResult(); dumpUserAndAccounts(user, task, result); } @@ -2491,7 +2489,7 @@ private void dumpUserAndAccounts(PrismObject user) private PrismObject dumpUserAndAccounts(String userOid) throws ConfigurationException, ObjectNotFoundException, SchemaException, CommunicationException, SecurityViolationException, ExpressionEvaluationException { - Task task = createTask("dumpUserAndAccounts"); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = getUser(userOid); dumpUserAndAccounts(user, task, result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestInbounds.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestInbounds.java index 1147a4a463d..6fe98bcc6d6 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestInbounds.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestInbounds.java @@ -59,7 +59,7 @@ public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); // WHEN displayWhen(TEST_NAME); @@ -78,7 +78,7 @@ public void test101ModifyUserSubtypePirate() throws Exception { final String TEST_NAME = "test101ModifyUserSubtypePirate"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta userDelta = prismContext.deltaFactory().object().createModificationReplaceProperty(UserType.class, @@ -121,7 +121,7 @@ public void test102ModifyUserSubtypeBuccaneer() throws Exception { final String TEST_NAME = "test102ModifyUserSubtypeBuccaneer"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta userDelta = prismContext.deltaFactory().object().createModificationReplaceProperty(UserType.class, @@ -155,7 +155,7 @@ public void test103DeleteUserEmployeeTypeBartender() throws Exception { final String TEST_NAME = "test103ModifyUserEmployeeTypeBartender"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> deltas = new ArrayList<>(); @@ -195,7 +195,7 @@ public void test200AssignAccountOrange() throws Exception { final String TEST_NAME = "test200AssignAccountOrange"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -237,7 +237,7 @@ public void test202ModifyAccountOrangeGossip() throws Exception { final String TEST_NAME = "test202ModifyAccountOrangeGossip"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -281,7 +281,7 @@ public void test204AssignAccountOrangeAgain() throws Exception { final String TEST_NAME = "test204AssignAccountOrangeAgain"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -324,7 +324,7 @@ public void test209ModifyAccountOrangeGossipRemove() throws Exception { final String TEST_NAME = "test209ModifyAccountOrangeGossipRemove"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -369,7 +369,7 @@ public void test210ModifyAccountOrangeQuoteMonkey() throws Exception { final String TEST_NAME = "test210ModifyAccountOrangeQuoteMonkey"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -419,7 +419,7 @@ public void test211ModifyAccountOrangeQuotePirate() throws Exception { final String TEST_NAME = "test211ModifyAccountOrangeQuotePirate"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -469,7 +469,7 @@ public void test214ModifyAccountOrangeQuoteWoodchuck() throws Exception { final String TEST_NAME = "test214ModifyAccountOrangeQuoteWoodchuck"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -515,7 +515,7 @@ public void test250UnlinkAccountDefaultDummy() throws Exception { final String TEST_NAME = "test250UnlinkAccountDefaultDummy"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -559,7 +559,7 @@ public void test252ModifyAccountOrangeGossipRecon() throws Exception { final String TEST_NAME = "test252ModifyAccountOrangeGossipRecon"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -604,7 +604,7 @@ public void test259ModifyAccountOrangeGossipRemoveRecon() throws Exception { final String TEST_NAME = "test259ModifyAccountOrangeGossipRemoveRecon"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -650,7 +650,7 @@ public void test260ModifyAccountOrangeQuoteMonkeyRecon() throws Exception { final String TEST_NAME = "test260ModifyAccountOrangeQuoteMonkeyRecon"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -704,7 +704,7 @@ public void test261ModifyAccountOrangeQuotePirateRecon() throws Exception { final String TEST_NAME = "test261ModifyAccountOrangeQuotePirateRecon"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -753,7 +753,7 @@ public void test264ModifyAccountOrangeQuoteWoodchuckRecon() throws Exception { final String TEST_NAME = "test264ModifyAccountOrangeQuoteWoodchuckRecon"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -800,7 +800,7 @@ public void test297ModifyAccountOrangeGossipRecon() throws Exception { final String TEST_NAME = "test297ModifyAccountOrangeGossipRecon"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -841,7 +841,7 @@ public void test299UnassignAccountOrange() throws Exception { final String TEST_NAME = "test299UnassignAccountOrange"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIntent.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIntent.java index a1eedd432f6..772623f459e 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIntent.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIntent.java @@ -57,7 +57,7 @@ public void test131ModifyUserJackAssignAccountDefault() throws Exception { final String TEST_NAME="test131ModifyUserJackAssignAccountDefault"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.RELATIVE); @@ -116,7 +116,7 @@ public void test132ModifyUserJackAssignAccountTest() throws Exception { final String TEST_NAME="test132ModifyUserJackAssignAccountTest"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.RELATIVE); @@ -188,7 +188,7 @@ public void test135ModifyUserJackFullName() throws Exception { final String TEST_NAME="test135ModifyUserJackFullName"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.RELATIVE); @@ -249,7 +249,7 @@ public void test147ModifyUserJackUnAssignAccountDefault() throws Exception { final String TEST_NAME="test147ModifyUserJackUnAssignAccountDefault"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.RELATIVE); @@ -308,7 +308,7 @@ public void test149ModifyUserJackUnassignAccountTest() throws Exception { final String TEST_NAME = "test149ModifyUserJackUnassignAccountTest"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.RELATIVE); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIteration.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIteration.java index 65d1aa2cb60..cbb80a1db49 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIteration.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIteration.java @@ -21,7 +21,6 @@ import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.schema.SearchResultList; import com.evolveum.midpoint.schema.constants.SchemaConstants; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType; @@ -230,7 +229,7 @@ public void test100JackAssignAccountDummyConflicting() throws Exception { final String TEST_NAME = "test100JackAssignAccountDummyConflicting"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -284,7 +283,7 @@ public void test200JackAssignAccountDummyPinkConflicting() throws Exception { final String TEST_NAME = "test200JackAssignAccountDummyPinkConflicting"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -367,7 +366,7 @@ public void test210GuybrushAssignAccountDummyPink() throws Exception { final String TEST_NAME = "test210GuybrushAssignAccountDummyPink"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -419,7 +418,7 @@ public void test220DeWattAssignAccountDummyPinkCaseIgnore() throws Exception { final String TEST_NAME = "test220DeWattAssignAccountDummyPinkCaseIgnore"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userDeWatt = createUser(USER_DEWATT_NAME, "Augustus DeWatt", true); @@ -485,7 +484,7 @@ public void test230ScroogeAddAccountDummyConflictingNoShadow() throws Exception final String TEST_NAME = "test230ScroogeAddAccountDummyConflictingNoShadow"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -536,7 +535,7 @@ public void test235HackerAddAccountDummyEternalConflict() throws Exception { final String TEST_NAME = "test235HackerAddAccountDummyEternalConflict"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -581,7 +580,7 @@ public void test240LargoAssignAccountDummyConflictingNoShadow() throws Exception final String TEST_NAME = "test240LargoAssignAccountDummyConflictingNoShadow"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -648,7 +647,7 @@ public void test260JupiterConflictNoShadowSyncBack() throws Exception { final String TEST_NAME = "test260JupiterConflictNoShadowSyncBack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -708,7 +707,7 @@ public void test262JupiterCleanup() throws Exception { protected void cleanUpJupiter(String TEST_NAME) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, SchemaViolationException, ConflictException, InterruptedException { // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -748,7 +747,7 @@ public void test264JupiterConflictNoShadowSyncBackSeparate() throws Exception { final String TEST_NAME = "test264JupiterConflictNoShadowSyncBackSeparate"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -813,7 +812,7 @@ public void test270JupiterConflictOtherNoShadowSyncBack() throws Exception { final String TEST_NAME = "test270JupiterConflictOtherNoShadowSyncBack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -894,7 +893,7 @@ public void test280RenameBobNoShadow() throws Exception { final String TEST_NAME = "test280RenameBobNoShadow"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBob = createUser(USER_BOB_NAME, "Bob Andrews", true); @@ -954,7 +953,7 @@ public void test282RenamePeterNoShadowSync() throws Exception { final String TEST_NAME = "test282RenamePeterNoShadowSync"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userPeter = createUser("peter", "Peter Crenshaw", true); @@ -1030,7 +1029,7 @@ public void test290AlfredConflictNoShadowSyncBackAdd() throws Exception { final String TEST_NAME = "test290AlfredConflictNoShadowSyncBackAdd"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -1081,7 +1080,7 @@ public void test300JackAssignAccountDummyVioletConflicting() throws Exception { final String TEST_NAME = "test300JackAssignAccountDummyVioletConflicting"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -1147,7 +1146,7 @@ public void test350GuybrushAssignAccountDummyViolet() throws Exception { final String TEST_NAME = "test350GuybrushAssignAccountDummyViolet"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -1203,7 +1202,7 @@ public void test360HermanAssignAccountDummyViolet() throws Exception { final String TEST_NAME = "test360HermanAssignAccountDummyViolet"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); addObject(USER_HERMAN_FILE); @@ -1262,7 +1261,7 @@ public void test400RenameAngelicaConflicting() throws Exception { final String TEST_NAME = "test400RenameAngelicaConflicting"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userLechuck = createUser(USER_ANGELICA_NAME, "Angelica", true); @@ -1295,7 +1294,7 @@ public void test500JackAssignAccountDummyMagenta() throws Exception { final String TEST_NAME = "test500JackAssignAccountDummyMagenta"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -1363,7 +1362,7 @@ public void test510DrakeAssignAccountDummyMagenta() throws Exception { final String TEST_NAME = "test510DrakeAssignAccountDummyMagenta"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userDrake = PrismTestUtil.parseObject(USER_DRAKE_FILE); @@ -1442,7 +1441,7 @@ public void test520DrakeModifyLocality() throws Exception { final String TEST_NAME = "test520DrakeModifyLocality"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -1506,7 +1505,7 @@ public void test530GuybrushAssignAccountDummyMagenta() throws Exception { final String TEST_NAME = "test530GuybrushAssignAccountDummyMagenta"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -1572,7 +1571,7 @@ public void test532GuybrushModifyDescription() throws Exception { final String TEST_NAME = "test532GuybrushModifyDescription"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -1635,7 +1634,7 @@ public void test600JackRename() throws Exception { final String TEST_NAME = "test600JackRename"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -1902,7 +1901,7 @@ public void test730DarkVioletAddBarbossa() throws Exception { final String TEST_NAME = "test730DarkVioletAddBarbossa"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -1934,7 +1933,7 @@ public void test732DarkVioletAddBarbossa() throws Exception { final String TEST_NAME = "test732DarkVioletAddBarbossa"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -1961,7 +1960,7 @@ public void test750DarkVioletAddMatusalem() throws Exception { final String TEST_NAME = "test750DarkVioletAddMatusalem"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -1994,7 +1993,7 @@ public void test752DarkVioletAddDiplomatico() throws Exception { final String TEST_NAME = "test752DarkVioletAddDiplomatico"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -2028,7 +2027,7 @@ public void test754DarkVioletAddMilionario() throws Exception { final String TEST_NAME = "test754DarkVioletAddMilionario"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -2059,7 +2058,7 @@ public void test756DarkVioletDeleteDiplomatico() throws Exception { final String TEST_NAME = "test756DarkVioletDeleteDiplomatico"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -2082,7 +2081,7 @@ public void test760DarkVioletModifyMillonarioLocation() throws Exception { final String TEST_NAME = "test760DarkVioletModifyMillonarioLocation"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -2111,7 +2110,7 @@ public void test762DarkVioletModifyMillonarioFullName() throws Exception { final String TEST_NAME = "test762DarkVioletModifyMillonarioFullName"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -2141,7 +2140,7 @@ public void test764DarkVioletModifyMatusalemFullName() throws Exception { final String TEST_NAME = "test764DarkVioletModifyMatusalemFullName"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -2174,7 +2173,7 @@ public void test800UniqeEmailAddUserAlfredoFettucini() throws Exception { final String TEST_NAME = "test800UniqeEmailAddUserAlfredoFettucini"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -2211,7 +2210,7 @@ public void test802UniqeEmailAddUserBillFettucini() throws Exception { final String TEST_NAME = "test802UniqeEmailAddUserBillFettucini"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -2247,7 +2246,7 @@ public void test820SubtypeSetByInbound() throws Exception { final String TEST_NAME = "test820SubtypeSetByInbound"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestLifecycle.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestLifecycle.java index edc26ee0806..fa66933a13a 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestLifecycle.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestLifecycle.java @@ -89,7 +89,7 @@ protected File getSystemConfigurationFile() { public void test050SetupJack() throws Exception { final String TEST_NAME = "test050SetupJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -142,7 +142,7 @@ public void test052PrincipalJackDraft() throws Exception { public void test060TransitionJackToProposed() throws Exception { final String TEST_NAME = "test060TransitionJackToProposed"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -196,7 +196,7 @@ public void test062PrincipalJackProposed() throws Exception { public void test090TransitionJackToDefaultActive() throws Exception { final String TEST_NAME = "test090TransitionJackToDefaultActive"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -248,7 +248,7 @@ protected void assertLifecycleState(PrismObject object public void test100AssignJackCaretaker() throws Exception { final String TEST_NAME = "test100AssignJackCaretaker"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -272,7 +272,7 @@ public void test100AssignJackCaretaker() throws Exception { public void test102UnassignJackHeadmaster() throws Exception { final String TEST_NAME = "test102UnassignJackHeadmaster"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -300,7 +300,7 @@ public void test102UnassignJackHeadmaster() throws Exception { public void test110UnassignJackCaretaker() throws Exception { final String TEST_NAME = "test110UnassignJackCaretaker"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -327,7 +327,7 @@ public void test110UnassignJackCaretaker() throws Exception { public void test112UnassignJackCaretaker() throws Exception { final String TEST_NAME = "test110UnassignJackCaretaker"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestMerge.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestMerge.java index 48ae6e10fb5..4c793db9b3f 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestMerge.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestMerge.java @@ -24,7 +24,6 @@ import com.evolveum.midpoint.schema.util.FocusTypeUtil; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; /** diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelServiceContract.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelServiceContract.java index 8829a1deb24..f156ecfc67b 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelServiceContract.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelServiceContract.java @@ -117,7 +117,7 @@ public void initSystem(Task initTask, OperationResult initResult) public void test050GetUserJack() throws Exception { final String TEST_NAME = "test050GetUserJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -138,7 +138,7 @@ public void test050GetUserJack() throws Exception { public void test051GetUserBarbossa() throws Exception { final String TEST_NAME = "test051GetUserBarbossa"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -162,7 +162,7 @@ public void test099ModifyUserAddAccountFailing() throws Exception { final String TEST_NAME = "test099ModifyUserAddAccountFailing"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -238,7 +238,7 @@ public void test100ModifyUserAddAccount() throws Exception { final String TEST_NAME = "test100ModifyUserAddAccount"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); getDummyResource().resetBreakMode(); @@ -327,7 +327,7 @@ public void test101GetAccount() throws Exception { final String TEST_NAME = "test101GetAccount"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -550,7 +550,7 @@ public void test109ModifyUserAddAccountAgain() throws Exception { final String TEST_NAME = "test109ModifyUserAddAccountAgain"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -600,7 +600,7 @@ public void test110GetUserResolveAccount() throws Exception { final String TEST_NAME = "test110GetUserResolveAccount"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -639,7 +639,7 @@ public void test111GetUserResolveAccountResource() throws Exception { final String TEST_NAME = "test111GetUserResolveAccountResource"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -681,7 +681,7 @@ public void test112GetUserResolveAccountNoFetch() throws Exception { final String TEST_NAME = "test112GetUserResolveAccountNoFetch"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -723,7 +723,7 @@ public void test119ModifyUserDeleteAccount() throws Exception { final String TEST_NAME = "test119ModifyUserDeleteAccount"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -871,7 +871,7 @@ public void test121ModifyUserAddAccountRef() throws Exception { final String TEST_NAME = "test121ModifyUserAddAccountRef"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -1111,7 +1111,7 @@ public void test131ModifyUserJackAssignAccount() throws Exception { final String TEST_NAME="test131ModifyUserJackAssignAccount"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.FULL); @@ -1192,7 +1192,7 @@ public void test132ModifyAccountJackDummy() throws Exception { final String TEST_NAME = "test132ModifyAccountJackDummy"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.FULL); @@ -1283,7 +1283,7 @@ public void test135ModifyUserJackAssignAccountAgain() throws Exception { final String TEST_NAME="test135ModifyUserJackAssignAccountAgain"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.FULL); @@ -1346,7 +1346,7 @@ public void test136JackRecomputeNoChange() throws Exception { final String TEST_NAME="test136JackRecomputeNoChange"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.FULL); @@ -1408,7 +1408,7 @@ public void test139ModifyUserJackUnassignAccount() throws Exception { final String TEST_NAME = "test139ModifyUserJackUnassignAccount"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.FULL); @@ -1470,7 +1470,7 @@ public void test141ModifyUserJackAssignAccountPositiveEnforcement() throws Excep final String TEST_NAME = "test141ModifyUserJackAssignAccountPositiveEnforcement"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -1554,7 +1554,7 @@ public void test148ModifyUserJackUnassignAccountPositiveEnforcement() throws Exc final String TEST_NAME = "test148ModifyUserJackUnassignAccountPositiveEnforcement"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.FULL); @@ -1649,7 +1649,7 @@ public void test149ModifyUserJackDeleteAccount() throws Exception { final String TEST_NAME = "test149ModifyUserJackDeleteAccount"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -1721,7 +1721,7 @@ public void test151ModifyUserJackAssignAccountRelativeEnforcement() throws Excep final String TEST_NAME = "test151ModifyUserJackAssignAccountRelativeEnforcement"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.RELATIVE); @@ -1862,7 +1862,7 @@ public void test161ModifyUserJackAssignAccountNoneEnforcement() throws Exception final String TEST_NAME = "test161ModifyUserJackAssignAccountNoneEnforcement"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.NONE); @@ -1924,7 +1924,7 @@ public void test163ModifyUserJackAddAccountNoneEnforcement() throws Exception { final String TEST_NAME = "test163ModifyUserJackAddAccountNoneEnforcement"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.NONE); @@ -2071,7 +2071,7 @@ public void test169ModifyUserJackDeleteAccountNoneEnforcement() throws Exception final String TEST_NAME = "test169ModifyUserJackDeleteAccountNoneEnforcement"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.NONE); @@ -2138,7 +2138,7 @@ public void test180ModifyUserAddAccountFullEnforcement() throws Exception { final String TEST_NAME = "test180ModifyUserAddAccountFullEnforcement"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.FULL); @@ -2199,7 +2199,7 @@ public void test182ModifyUserAddAndAssignAccountPositiveEnforcement() throws Exc final String TEST_NAME = "test182ModifyUserAddAndAssignAccountPositiveEnforcement"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -2333,7 +2333,7 @@ public void test190ModifyUserJackAssignAccountAndModify() throws Exception { final String TEST_NAME = "test190ModifyUserJackAssignAccountAndModify"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.FULL); @@ -2418,7 +2418,7 @@ public void test191ModifyUserJackModifyAssignment() throws Exception { final String TEST_NAME = "test191ModifyUserJackModifyAssignment"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> deltas = new ArrayList<>(); @@ -2532,7 +2532,7 @@ public void test192ModifyUserJack() throws Exception { final String TEST_NAME = "test192ModifyUserJack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.FULL); @@ -2604,7 +2604,7 @@ public void test193ModifyUserJackLocationEmpty() throws Exception { final String TEST_NAME = "test193ModifyUserJackLocationEmpty"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.FULL); @@ -2670,7 +2670,7 @@ public void test194ModifyUserJackLocationNull() throws Exception { final String TEST_NAME = "test194ModifyUserJackLocationNull"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.FULL); @@ -2703,7 +2703,7 @@ public void test195ModifyUserJackLocationSea() throws Exception { final String TEST_NAME = "test195ModifyUserJackLocationSea"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.FULL); @@ -2887,7 +2887,7 @@ public void test200AddUserBlackbeardWithAccount() throws Exception { final String TEST_NAME = "test200AddUserBlackbeardWithAccount"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); // Use custom channel to trigger a special outbound mapping task.setChannel("http://pirates.net/avast"); OperationResult result = task.getResult(); @@ -2972,7 +2972,7 @@ public void test210AddUserMorganWithAssignment() throws Exception { final String TEST_NAME = "test210AddUserMorganWithAssignment"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.FULL); @@ -3053,7 +3053,7 @@ public void test212RenameUserMorgan() throws Exception { final String TEST_NAME = "test212RenameUserMorgan"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.FULL); @@ -3138,7 +3138,7 @@ public void test240AddUserCharlesRaw() throws Exception { final String TEST_NAME = "test240AddUserCharlesRaw"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.FULL); @@ -3182,7 +3182,7 @@ public void test241DeleteUserCharlesRaw() throws Exception { final String TEST_NAME = "test241DeleteUserCharlesRaw"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.FULL); @@ -3221,7 +3221,7 @@ public void test300AddUserJackWithAssignmentBlue() throws Exception { final String TEST_NAME="test300AddUserJackWithAssignmentBlue"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.RELATIVE); @@ -3290,7 +3290,7 @@ public void test302ModifyAccountJackDummyBlue() throws Exception { final String TEST_NAME = "test302ModifyAccountJackDummyBlue"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.FULL); @@ -3358,7 +3358,7 @@ public void test400RemoveExtensionProtectedStringValue() throws Exception { TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.FULL); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestNotifications.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestNotifications.java index 3ddf06de60d..a9f5fb4e091 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestNotifications.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestNotifications.java @@ -49,7 +49,6 @@ import java.net.URI; import java.nio.charset.StandardCharsets; import java.util.*; -import java.util.concurrent.Executor; import static java.util.Collections.singletonList; import static org.testng.AssertJUnit.*; diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestOptimizingTriggerCreator.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestOptimizingTriggerCreator.java index 946d4a7f7a7..345a3d2b6cb 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestOptimizingTriggerCreator.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestOptimizingTriggerCreator.java @@ -53,7 +53,8 @@ public void test110CreateTriggersWithUserDeletion() throws Exception { final String TEST_NAME = "test110CreateTriggersWithUserDeletion"; TestUtil.displayTestTitle(this, TEST_NAME); - Task task = createTask(TestTriggerTask.class.getName() + "." + TEST_NAME); + TestTriggerTask.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); OptimizingTriggerCreator creator = libraryMidpointFunctions.getOptimizingTriggerCreator(60000, 2000); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestPreviewChanges.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestPreviewChanges.java index 3d5aab0e4ea..d94f642f7f8 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestPreviewChanges.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestPreviewChanges.java @@ -145,7 +145,7 @@ private void modifyUserAddAccountImplicit(String bundleName, ObjectSource account = accountSource.get(); @@ -166,7 +166,7 @@ private void modifyUserAddAccountExplicit(String bundleName, ObjectSource account = accountSource.get(); @@ -184,7 +184,7 @@ private void modifyUserAddAccountImplicitExplicitSame(String bundleName, final String TEST_NAME = bundleName + "ImplicitExplicitSame"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject account = accountSource.get(); @@ -206,7 +206,7 @@ private void modifyUserAddAccountImplicitExplicitSameReverse(String bundleName, final String TEST_NAME = bundleName + "ImplicitExplicitSameReverse"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject account = accountSource.get(); @@ -228,7 +228,7 @@ private void modifyUserAddAccountImplicitExplicitEqual(String bundleName, final String TEST_NAME = bundleName + "ImplicitExplicitEqual"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject account = accountSource.get(); @@ -250,7 +250,7 @@ private void modifyUserAddAccountImplicitExplicitEqualReverse(String bundleName, final String TEST_NAME = bundleName + "ImplicitExplicitEqualReverse"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject account = accountSource.get(); @@ -272,7 +272,7 @@ private void modifyUserAddAccountImplicitExplicitNotEqual(String bundleName, final String TEST_NAME = bundleName + "ImplicitExplicitNotEqual"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject account = accountSource.get(); @@ -296,7 +296,7 @@ private void modifyUserAddAccountImplicitExplicitNotEqualReverse(String bundleNa final String TEST_NAME = bundleName + "ImplicitExplicitNotEqualReverse"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject account = accountSource.get(); @@ -396,7 +396,7 @@ public void test130GetCompiledGuiProfile() throws Exception { final String TEST_NAME = "test130GetCompiledGuiProfile"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -424,7 +424,7 @@ public void test150GetGuybrushRefinedObjectClassDef() throws Exception { final String TEST_NAME = "test150GetGuybrushRefinedObjectClassDef"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject shadow = getShadowModel(ACCOUNT_SHADOW_GUYBRUSH_OID); @@ -448,7 +448,7 @@ public void test200ModifyUserGuybrushDeleteAccount() throws Exception { final String TEST_NAME = "test200ModifyUserGuybrushDeleteAccount"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -497,7 +497,7 @@ public void test210GuybrushAddAccount() throws Exception { final String TEST_NAME = "test210GuybrushAddAccount"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -547,7 +547,7 @@ public void test212ModifyUserAddAccountRef() throws Exception { final String TEST_NAME = "test212ModifyUserAddAccountRef"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -604,7 +604,7 @@ public void test220PreviewJackAssignRolePirate() throws Exception { final String TEST_NAME = "test220PreviewJackAssignRolePirate"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -631,7 +631,7 @@ public void test221PreviewJackAssignRolePirateReconcile() throws Exception { final String TEST_NAME = "test221PreviewJackAssignRolePirateReconcile"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -734,7 +734,7 @@ public void test230GuybrushAssignAccountDummy() throws Exception { final String TEST_NAME = "test230GuybrushAssignAccountDummy"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -771,7 +771,7 @@ public void test231PreviewGuybrushModifyAccountFullName() throws Exception { final String TEST_NAME = "test231PreviewGuybrushModifyAccountFullName"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta accountDelta = prismContext.deltaFactory().object().createModificationReplaceProperty(ShadowType.class, @@ -823,7 +823,7 @@ public void test232PreviewGuybrushModifyAccountShip() throws Exception { final String TEST_NAME = "test232PreviewGuybrushModifyAccountShip"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta accountDelta = prismContext.deltaFactory().object().createModificationReplaceProperty(ShadowType.class, @@ -874,7 +874,7 @@ public void test233PreviewGuybrushAddRolePirate() throws Exception { final String TEST_NAME = "test233PreviewGuybrushAddRolePirate"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -940,7 +940,7 @@ public void test234PreviewGuybrushAddRolePirateRecon() throws Exception { final String TEST_NAME = "test234PreviewGuybrushAddRolePirateRecon"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -1008,7 +1008,7 @@ public void test236PreviewGuybrushAddRoleSailor() throws Exception { final String TEST_NAME = "test236PreviewGuybrushAddRoleSailor"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -1061,7 +1061,7 @@ public void test238PreviewGuybrushAddRoleSailorOwner() throws Exception { final String TEST_NAME = "test238PreviewGuybrushAddRoleSailorOwner"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -1098,7 +1098,7 @@ public void test239GuybrushUnAssignAccountDummy() throws Exception { final String TEST_NAME = "test239GuybrushUnAssignAccountDummy"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -1123,7 +1123,7 @@ public void test240GuybrushAssignAccountDummyRelative() throws Exception { final String TEST_NAME = "test240GuybrushAssignAccountDummyRelative"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -1151,7 +1151,7 @@ public void test242PreviewGuybrushAddRolePirateRelative() throws Exception { final String TEST_NAME = "test242PreviewGuybrushAddRolePirateRelative"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -1218,7 +1218,7 @@ public void test244PreviewGuybrushAddRolePirateRelativeRecon() throws Exception final String TEST_NAME = "test244PreviewGuybrushAddRolePirateRelativeRecon"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -1282,7 +1282,7 @@ public void test249GuybrushUnAssignAccountDummyRelative() throws Exception { final String TEST_NAME = "test249GuybrushUnAssignAccountDummyRelative"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -1335,7 +1335,7 @@ public void test300ModifyElaineAccountDummyReplace() throws Exception { final String TEST_NAME = "test300ModifyElaineAccountDummyReplace"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -1390,7 +1390,7 @@ public void test301ModifyElaineAccountDummyDeleteAdd() throws Exception { final String TEST_NAME = "test301ModifyElaineAccountDummyDeleteAdd"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -1450,7 +1450,7 @@ public void test400ModifyElaineAccountDummyRedReplace() throws Exception { final String TEST_NAME = "test400ModifyElaineAccountDummyRedReplace"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -1480,7 +1480,7 @@ public void test401ModifyElaineAccountDummyRedDeleteAdd() throws Exception { final String TEST_NAME = "test401ModifyElaineAccountDummyRedDeleteAdd"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -1512,7 +1512,7 @@ public void test500ModifyElaineAccountDummyBlueReplace() throws Exception { final String TEST_NAME = "test500ModifyElaineAccountDummyBlueReplace"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -1567,7 +1567,7 @@ public void test501ModifyElaineAccountDummyBlueDeleteAdd() throws Exception { final String TEST_NAME = "test501ModifyElaineAccountDummyBlueDeleteAdd"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -1630,7 +1630,7 @@ public void test600ModifyElaineUserDummyReplace() throws Exception { final String TEST_NAME = "test600ModifyElaineUserDummyReplace"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -1722,7 +1722,7 @@ public void test610ModifyElaineUserAccountDummyReplace() throws Exception { final String TEST_NAME = "test610ModifyElaineUserAccountDummyReplace"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -1825,7 +1825,7 @@ public void test620AddUserCapsize() throws Exception { final String TEST_NAME = "test620AddUserCapsize"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -1915,7 +1915,7 @@ public void test630AddUserRogers() throws Exception { final String TEST_NAME = "test630AddUserRogers"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -2012,7 +2012,7 @@ public void test700DisableElaineAccountTwoResources() throws Exception { final String TEST_NAME = "test700DisableElaineAccountTwoResources"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -2088,7 +2088,7 @@ public void test710PreviewGuybrushHavingRoleSailorOwner() throws Exception { final String TEST_NAME = "test710PreviewGuybrushHavingRoleSailorOwner"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestRaceConditions.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestRaceConditions.java index 7f17ee2f80b..51ac5ec4c90 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestRaceConditions.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestRaceConditions.java @@ -13,7 +13,6 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.ObjectTypeUtil; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.SystemException; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; @@ -54,7 +53,7 @@ public void test100AssignRoles() throws Exception { final String TEST_NAME="test100AssignRoles"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestResources.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestResources.java index 802ca522136..46616682912 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestResources.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestResources.java @@ -148,7 +148,7 @@ public void test050GetResourceRaw() throws Exception { final String TEST_NAME = "test050GetResourceRaw"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -197,7 +197,7 @@ public void test052GetResourceNoFetch() throws Exception { final String TEST_NAME = "test052GetResourceNoFetch"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -248,7 +248,7 @@ public void test053GetResourceNoFetchAgain() throws Exception { final String TEST_NAME = "test053GetResourceNoFetchAgain"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -301,7 +301,7 @@ public void test055GetResourceNoFetchReadOnly() throws Exception { final String TEST_NAME = "test055GetResourceNoFetchReadOnly"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -355,7 +355,7 @@ public void test100SearchResourcesNoFetch() throws Exception { final String TEST_NAME = "test100SearchResourcesNoFetch"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -403,7 +403,7 @@ public void test102SearchResourcesNoFetchReadOnly() throws Exception { final String TEST_NAME = "test102SearchResourcesNoFetchReadOnly"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -453,7 +453,7 @@ public void test105SearchResourcesIterativeNoFetch() throws Exception { final String TEST_NAME = "test105SearchResourcesIterativeNoFetch"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -504,7 +504,7 @@ public void test107SearchResourcesIterativeNoFetchReadOnly() throws Exception { final String TEST_NAME = "test107SearchResourcesIterativeNoFetchReadOnly"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -554,7 +554,7 @@ public void test110GetResourceDummy() throws Exception { final String TEST_NAME = "test110GetResourceDummy"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -596,7 +596,7 @@ public void test112GetResourceDummyReadOnly() throws Exception { final String TEST_NAME = "test112GetResourceDummyReadOnly"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -825,7 +825,7 @@ public void test210GetResourceDummyRed() throws Exception { final String TEST_NAME = "test210GetResourceDummyRed"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -860,7 +860,7 @@ public void test750GetResourceRaw() throws Exception { final String TEST_NAME = "test750GetResourceRaw"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -902,7 +902,7 @@ public void test752GetResourceDummy() throws Exception { final String TEST_NAME = "test752GetResourceDummy"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -934,7 +934,7 @@ public void test752GetResourceDummy() throws Exception { public void test760ModifyConfigurationString() throws Exception { final String TEST_NAME = "test760ModifyConfigurationString"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta resourceDelta = createConfigurationPropertyDelta(IntegrationTestTools.RESOURCE_DUMMY_CONFIGURATION_USELESS_STRING_ELEMENT_NAME, @@ -960,7 +960,7 @@ public void test760ModifyConfigurationString() throws Exception { public void test761ModifyConfigurationStringRaw() throws Exception { final String TEST_NAME = "test761ModifyConfigurationStringRaw"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta resourceDelta = createConfigurationPropertyDelta(IntegrationTestTools.RESOURCE_DUMMY_CONFIGURATION_USELESS_STRING_ELEMENT_NAME, @@ -1028,7 +1028,7 @@ public void handleGlobalError(OperationResult currentResult) { private void modifyConfigurationDiffExpressionRaw(final String TEST_NAME, FailableFunction> parser) throws Exception { - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject resourceBefore = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result); @@ -1101,7 +1101,7 @@ public void test800GetResourceDummy() throws Exception { final String TEST_NAME = "test800GetResourceDummy"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -1133,7 +1133,7 @@ public void test800GetResourceDummy() throws Exception { public void test820SingleDescriptionModify() throws Exception { final String TEST_NAME = "test820SingleDescriptionModify"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); singleModify(descriptionAnt, -1, task, result); @@ -1154,7 +1154,7 @@ public void test820SingleDescriptionModify() throws Exception { public void test840RandomModifySequence() throws Exception { final String TEST_NAME = "test840RandomModifySequence"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); for(int i=0; i <= MAX_RANDOM_SEQUENCE_ITERATIONS; i++) { diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestSchemalessResource.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestSchemalessResource.java index f73d6ddc4d1..1e5d18ce9f6 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestSchemalessResource.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestSchemalessResource.java @@ -46,7 +46,7 @@ public void test001GetObject() throws Exception { final String TEST_NAME = "test001GetObject"; TestUtil.displayTestTitle(this, TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -61,7 +61,7 @@ public void test002TestConnection() throws Exception { final String TEST_NAME = "test002TestConnection"; TestUtil.displayTestTitle(this, TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); // WHEN OperationResult testResult = modelService.testResource(RESOURCE_DUMMY_SCHEMALESS_OID, task); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestStrangeCases.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestStrangeCases.java index fdd89056082..9e588e4d339 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestStrangeCases.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestStrangeCases.java @@ -198,7 +198,7 @@ public void test010SanityAdministrator() throws Exception { @Test public void test050AddRoleRecursionAssignment() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -231,7 +231,7 @@ public void test050AddRoleRecursionAssignment() throws Exception { @Test public void test060AddRoleStupidAssignment() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -254,7 +254,7 @@ public void test060AddRoleStupidAssignment() throws Exception { @Test public void test100ModifyUserGuybrushAddAccountDummyRedNoAttributesConflict() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -357,7 +357,7 @@ public void test100ModifyUserGuybrushAddAccountDummyRedNoAttributesConflict() th @Test public void test180DeleteHalfAssignmentFromUser() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -408,7 +408,7 @@ public void test180DeleteHalfAssignmentFromUser() throws Exception { @Test public void test190DeleteHalfAssignedUser() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -462,7 +462,7 @@ public void test190DeleteHalfAssignedUser() throws Exception { @Test public void test200ModifyUserJackBrokenAccountRefAndPolyString() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -506,7 +506,7 @@ public void test200ModifyUserJackBrokenAccountRefAndPolyString() throws Exceptio @Test public void test210ModifyUserAddAccount() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -536,7 +536,7 @@ public void test210ModifyUserAddAccount() throws Exception { @Test public void test212ModifyUserAddAccountRed() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -569,7 +569,7 @@ public void test212ModifyUserAddAccountRed() throws Exception { @Test public void test212ModifyUserJackBrokenSchemaViolationPolyString() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); @@ -611,7 +611,7 @@ public void test212ModifyUserJackBrokenSchemaViolationPolyString() throws Except @Test public void test214ModifyUserJackBrokenPassword() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); @@ -653,7 +653,7 @@ public void test214ModifyUserJackBrokenPassword() throws Exception { @Test public void test220ModifyUserJackBrokenConflict() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); @@ -699,7 +699,7 @@ public void test220ModifyUserJackBrokenConflict() throws Exception { @Test public void test230ModifyUserJackUserTemplatePolicyViolation() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); getDummyResource().setModifyBreakMode(BreakMode.NONE); @@ -752,7 +752,7 @@ public void test300ExtensionSanity() { @Test public void test301AddUserDeGhoulash() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -828,7 +828,7 @@ public void test317SearchDeGhoulashByFuneralTimestamp() throws Exception { private void searchDeGhoulash(QName propName, T propValue) throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -880,7 +880,7 @@ private void assertBasicDeGhoulashExtension(PrismObject userDeGhoulash @Test public void test330AssignDeGhoulashIdiot() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -906,7 +906,7 @@ public void test330AssignDeGhoulashIdiot() throws Exception { @Test public void test332AssignDeGhoulashRecursion() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -942,7 +942,7 @@ public void test332AssignDeGhoulashRecursion() throws Exception { @Test public void test334AssignDeGhoulashStupidAssignment() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -971,7 +971,7 @@ public void test334AssignDeGhoulashStupidAssignment() throws Exception { @Test public void test336UnassignDeGhoulashStupidAssignment() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -992,7 +992,7 @@ public void test336UnassignDeGhoulashStupidAssignment() throws Exception { @Test public void test340AssignDeGhoulashConstructionNonExistentResource() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -1017,7 +1017,7 @@ public void test340AssignDeGhoulashConstructionNonExistentResource() throws Exce @Test public void test349UnAssignDeGhoulashConstructionNonExistentResource() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -1041,7 +1041,7 @@ public void test349UnAssignDeGhoulashConstructionNonExistentResource() throws Ex @Test public void test350AssignDeGhoulashRoleBadConstructionResourceRef() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -1068,7 +1068,7 @@ public void test350AssignDeGhoulashRoleBadConstructionResourceRef() throws Excep @Test public void test351UnAssignDeGhoulashRoleBadConstructionResourceRef() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -1095,7 +1095,7 @@ public void test351UnAssignDeGhoulashRoleBadConstructionResourceRef() throws Exc @Test public void test355AssignDeGhoulashRoleBadConstructionResourceRefLax() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -1118,7 +1118,7 @@ public void test355AssignDeGhoulashRoleBadConstructionResourceRefLax() throws Ex @Test public void test356UnAssignDeGhoulashRoleBadConstructionResourceRefLax() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -1141,7 +1141,7 @@ public void test356UnAssignDeGhoulashRoleBadConstructionResourceRefLax() throws @Test public void test360AddRoleTargetBadConstructionResourceRef() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -1183,7 +1183,7 @@ public void test400ImportJackMockTask() throws Exception { @Test public void test401ListTasks() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -1229,7 +1229,7 @@ public void test401ListTasks() throws Exception { @Test public void test410DeleteJack() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -1282,7 +1282,7 @@ public void test410DeleteJack() throws Exception { @Test public void test450AddApprovalCase() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); @@ -1318,7 +1318,7 @@ public void test500EnumerationExtension() { @Test public void test502EnumerationStoreGood() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObjectDefinition userDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class); @@ -1358,7 +1358,7 @@ public void test510EnumerationGetBad() throws Exception { } // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); @@ -1384,7 +1384,7 @@ public void test510EnumerationGetBad() throws Exception { @Test public void test520ShipReadBadTolerateRawData() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); @@ -1424,7 +1424,7 @@ private void changeDefinition(QName piracyShip, ItemName piracyShipBroken) { @Test public void test522ShipReadBadRaw() { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); @@ -1447,7 +1447,7 @@ public void test522ShipReadBadRaw() { @Test public void test524ShipReadBadPlain() { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); @@ -1474,7 +1474,7 @@ public void test529FixSchema() { @Test public void test550AssignCircus() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); try { @@ -1494,7 +1494,7 @@ public void test550AssignCircus() throws Exception { @Test public void test600AddUserGuybrushAssignAccount() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -1535,7 +1535,7 @@ public void test600AddUserGuybrushAssignAccount() throws Exception { @Test(enabled=false) // MID-2880 public void test610GetAccountGuybrushRogueAttribute() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); getDummyResource().setEnforceSchema(false); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTolerantAttributes.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTolerantAttributes.java index 7e8839c7ac9..bf06307c48c 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTolerantAttributes.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTolerantAttributes.java @@ -32,7 +32,6 @@ import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.MiscUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType; @@ -125,7 +124,7 @@ public void test101ModifyAddAttributesIntolerantPattern() throws Exception { final String TEST_NAME = "test101ModifyAddAttributesIntolerantPattern"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTriggerTask.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTriggerTask.java index 8b86659685e..afd9dbe083e 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTriggerTask.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTriggerTask.java @@ -83,7 +83,8 @@ public void test100ImportScannerTask() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestTriggerTask.class.getName() + "." + TEST_NAME); + TestTriggerTask.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // Make sure there is an object with a trigger set to a long time ago. @@ -117,7 +118,8 @@ public void test105NoTrigger() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestTriggerTask.class.getName() + "." + TEST_NAME); + TestTriggerTask.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); testTriggerHandler.reset(); @@ -145,7 +147,8 @@ public void test110TriggerCalledAgain() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestTriggerTask.class.getName() + "." + TEST_NAME); + TestTriggerTask.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); testTriggerHandler.reset(); @@ -176,7 +179,8 @@ public void test120TwoTriggers() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestTriggerTask.class.getName() + "." + TEST_NAME); + TestTriggerTask.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); testTriggerHandler.reset(); @@ -210,7 +214,8 @@ public void test130TwoTriggersSame() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestTriggerTask.class.getName() + "." + TEST_NAME); + TestTriggerTask.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); testTriggerHandler.reset(); @@ -240,7 +245,8 @@ public void test135TwoTriggersSamePlusOne() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestTriggerTask.class.getName() + "." + TEST_NAME); + TestTriggerTask.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); testTriggerHandler.reset(); @@ -272,7 +278,8 @@ public void test140TwoTriggersSameAggregable() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestTriggerTask.class.getName() + "." + TEST_NAME); + TestTriggerTask.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); testTriggerHandler.reset(); @@ -303,7 +310,8 @@ public void test145TwoTriggersSamePlusOneAggregable() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestTriggerTask.class.getName() + "." + TEST_NAME); + TestTriggerTask.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); testMultipleTriggersHandler.reset(); @@ -337,7 +345,8 @@ public void test147TwoTriggersIdempotent() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestTriggerTask.class.getName() + "." + TEST_NAME); + TestTriggerTask.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); testTriggerHandler.reset(); testTriggerHandler.setIdempotent(true); @@ -374,7 +383,8 @@ public void test150NoTriggerAgain() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestTriggerTask.class.getName() + "." + TEST_NAME); + TestTriggerTask.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); testTriggerHandler.reset(); @@ -403,7 +413,8 @@ public void test160TwoTriggersFirstFails() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestTriggerTask.class.getName() + "." + TEST_NAME); + TestTriggerTask.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); testTriggerHandler.reset(); @@ -460,7 +471,8 @@ public void test200TwoDistantTriggers() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestTriggerTask.class.getName() + "." + TEST_NAME); + TestTriggerTask.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); testTriggerHandler.reset(); @@ -493,7 +505,8 @@ public void test210InterruptedScanner() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestTriggerTask.class.getName() + "." + TEST_NAME); + TestTriggerTask.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); testTriggerHandler.reset(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplate.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplate.java index 0a05d237a8b..2e6cb54c5d8 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplate.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplate.java @@ -21,7 +21,6 @@ import com.evolveum.midpoint.prism.ItemFactory; import com.evolveum.midpoint.prism.delta.*; import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.TestResource; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; @@ -128,7 +127,7 @@ protected int getNumberOfRoles() { @Test public void test000Sanity() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -168,7 +167,7 @@ private void assertObjectTemplate(List defaultObj @Test public void test100ModifyUserGivenName() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); Collection> deltas = new ArrayList<>(); @@ -210,7 +209,7 @@ public void test100ModifyUserGivenName() throws Exception { @Test public void test101ModifyUserEmployeeTypePirate() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); Collection> deltas = new ArrayList<>(); @@ -258,7 +257,7 @@ public void test101ModifyUserEmployeeTypePirate() throws Exception { @Test public void test102ModifyUserEmployeeTypeBuccaneer() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); Collection> deltas = new ArrayList<>(); @@ -296,7 +295,7 @@ public void test102ModifyUserEmployeeTypeBuccaneer() throws Exception { @Test public void test103ModifyUserEmployeeTypeBartender() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); Collection> deltas = new ArrayList<>(); @@ -336,7 +335,7 @@ public void test103ModifyUserEmployeeTypeBartender() throws Exception { @Test public void test104ModifyUserCostCenter() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); Collection> deltas = new ArrayList<>(); @@ -372,7 +371,7 @@ public void test104ModifyUserCostCenter() throws Exception { @Test public void test105ModifyUserTelephoneNumber() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); Collection> deltas = new ArrayList<>(); @@ -410,7 +409,7 @@ public void test105ModifyUserTelephoneNumber() throws Exception { @Test public void test106ModifyUserRemoveTelephoneNumber() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); Collection> deltas = new ArrayList<>(); @@ -448,7 +447,7 @@ public void test106ModifyUserRemoveTelephoneNumber() throws Exception { @Test public void test107ModifyUserSetTelephoneNumber() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -485,7 +484,7 @@ public void test107ModifyUserSetTelephoneNumber() throws Exception { @Test public void test120ReconcileUser() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -525,7 +524,7 @@ public void test120ReconcileUser() throws Exception { @Test public void test121ModifyUserReplaceLocality() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -561,7 +560,7 @@ public void test121ModifyUserReplaceLocality() throws Exception { @Test public void test140AssignDummy() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -593,7 +592,7 @@ public void test140AssignDummy() throws Exception { @Test public void test149UnAssignDummy() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -624,7 +623,7 @@ public void test149UnAssignDummy() throws Exception { @Test public void test150ModifyJackOrganizationalUnitRum() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -658,7 +657,7 @@ public void test150ModifyJackOrganizationalUnitRum() throws Exception { @Test public void test151ModifyJackOrganizationalUnitOffense() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -692,7 +691,7 @@ public void test151ModifyJackOrganizationalUnitOffense() throws Exception { @Test public void test152ModifyJackOrganizationalUnitAddRum() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -729,7 +728,7 @@ public void test152ModifyJackOrganizationalUnitAddRum() throws Exception { @Test public void test153ModifyJackOrganizationalUnitDeleteOffense() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -765,7 +764,7 @@ public void test153ModifyJackOrganizationalUnitDeleteOffense() throws Exception @Test public void test155ModifyJackOrganizationalUnitFD001() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -804,7 +803,7 @@ public void test155ModifyJackOrganizationalUnitFD001() throws Exception { @Test public void test156ReconcileJack() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -842,7 +841,7 @@ public void test156ReconcileJack() throws Exception { @Test public void test157ModifyJackOrganizationalUnitFD0023() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -882,7 +881,7 @@ public void test157ModifyJackOrganizationalUnitFD0023() throws Exception { @Test public void test159ModifyJackDeleteOrganizationalUnitFD002() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -923,7 +922,7 @@ public void test159ModifyJackDeleteOrganizationalUnitFD002() throws Exception { @Test public void test160ModifyUserGivenNameAgain() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); @@ -966,7 +965,7 @@ public void test160ModifyUserGivenNameAgain() throws Exception { @Test public void test162ModifyUserGivenNameAgainPhantomChange() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result); @@ -1004,7 +1003,7 @@ public void test162ModifyUserGivenNameAgainPhantomChange() throws Exception { @Test public void test165ModifyUserGivenNameAgainAgain() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result); @@ -1051,7 +1050,7 @@ private void assertOnDemandOrgAssigned(String orgName, PrismObject use @Test public void test170ModifyUserGuybrushEmployeeTypeThief() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -1079,7 +1078,7 @@ public void test170ModifyUserGuybrushEmployeeTypeThief() throws Exception { @Test public void test172ModifyUserGuybrushHonorificPrefix() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -1109,7 +1108,7 @@ public void test172ModifyUserGuybrushHonorificPrefix() throws Exception { @Test public void test174ModifyUserGuybrushHonorificPrefixNone() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -1138,7 +1137,7 @@ public void test174ModifyUserGuybrushHonorificPrefixNone() throws Exception { @Test public void test180ModifyUserGuybrushEmployeeTypeMarooned() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -1168,7 +1167,7 @@ public void test180ModifyUserGuybrushEmployeeTypeMarooned() throws Exception { @Test public void test184ModifyUserGuybrushEmployeeTypeNone() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -1200,7 +1199,7 @@ public void test184ModifyUserGuybrushEmployeeTypeNone() throws Exception { @Test public void test185ModifyUserGuybrushSubtypeMarooned() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -1226,7 +1225,7 @@ public void test185ModifyUserGuybrushSubtypeMarooned() throws Exception { @Test public void test189ModifyUserGuybrushSubtypeNone() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -1260,7 +1259,7 @@ public void test189ModifyUserGuybrushSubtypeNone() throws Exception { @Test public void test190ModifyUserGuybrushOrganizationWhateveric() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -1291,7 +1290,7 @@ public void test190ModifyUserGuybrushOrganizationWhateveric() throws Exception { @Test public void test191ModifyUserGuybrushOrganizationAutomatic() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -1327,7 +1326,7 @@ public void test191ModifyUserGuybrushOrganizationAutomatic() throws Exception { @Test public void test192ModifyUserGuybrushOrganizationAddMixed() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -1375,7 +1374,7 @@ public void test192ModifyUserGuybrushOrganizationAddMixed() throws Exception { @Test public void test193ModifyUserGuybrushOrganizationAddOutOfDomain() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -1423,7 +1422,7 @@ public void test193ModifyUserGuybrushOrganizationAddOutOfDomain() throws Excepti @Test public void test194ModifyUserGuybrushOrganizationDeleteMixed() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -1467,7 +1466,7 @@ public void test194ModifyUserGuybrushOrganizationDeleteMixed() throws Exception @Test public void test195ModifyUserGuybrushOrganizationDeleteOutOfDomain() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -1508,7 +1507,7 @@ public void test195ModifyUserGuybrushOrganizationDeleteOutOfDomain() throws Exce @Test public void test196GuybrushAssignCaptain() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -1547,7 +1546,7 @@ public void test196GuybrushAssignCaptain() throws Exception { @Test public void test197ModifyGuybrushEmployeeTypePirate() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -1583,7 +1582,7 @@ public void test197ModifyGuybrushEmployeeTypePirate() throws Exception { @Test public void test198AModifyUserGuybrushOrganizationAddInDomain() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -1630,7 +1629,7 @@ public void test198AModifyUserGuybrushOrganizationAddInDomain() throws Exception @Test public void test198BModifyUserGuybrushOrganizationDeleteMixed() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -1673,7 +1672,7 @@ public void test198BModifyUserGuybrushOrganizationDeleteMixed() throws Exception @Test public void test199AGuyBrushModifyEmployeeTypeWannabe() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -1712,7 +1711,7 @@ public void test199AGuyBrushModifyEmployeeTypeWannabe() throws Exception { @Test public void test199BGuyBrushUnassignCaptain() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -1750,7 +1749,7 @@ public void test199BGuyBrushUnassignCaptain() throws Exception { @Test public void test199CModifyUserGuybrushOrganizationCleanup() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -1778,7 +1777,7 @@ public void test199CModifyUserGuybrushOrganizationCleanup() throws Exception { @Test public void test200AddUserRapp() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject user = PrismTestUtil.parseObject(USER_RAPP_FILE); @@ -1812,7 +1811,7 @@ public void test200AddUserRapp() throws Exception { @Test public void test201AddUserLargo() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // This simulates IMPORT to trigger the channel-limited mapping task.setChannel(QNameUtil.qNameToUri(SchemaConstants.CHANGE_CHANNEL_IMPORT)); @@ -1857,7 +1856,7 @@ public void test201AddUserLargo() throws Exception { @Test public void test202AddUserMonkey() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject user = PrismTestUtil.parseObject(USER_THREE_HEADED_MONKEY_FILE); @@ -1895,7 +1894,7 @@ public void test202AddUserMonkey() throws Exception { @Test public void test204AddUserHerman() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject user = PrismTestUtil.parseObject(USER_HERMAN_FILE); @@ -1928,7 +1927,7 @@ public void test204AddUserHerman() throws Exception { @Test public void test220AssignRoleSailorToUserRapp() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -1960,7 +1959,7 @@ public void test220AssignRoleSailorToUserRapp() throws Exception { @Test public void test229UnassignRoleSailorFromUserRapp() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -1994,7 +1993,7 @@ public void test229UnassignRoleSailorFromUserRapp() throws Exception { @Test public void test230AssignRoleCaptainToUserRapp() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -2026,7 +2025,7 @@ public void test230AssignRoleCaptainToUserRapp() throws Exception { @Test public void test232ModifyUserRappCostCenter() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -2059,7 +2058,7 @@ public void test232ModifyUserRappCostCenter() throws Exception { @Test public void test239UnassignRoleCaptainFromUserRapp() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -2088,7 +2087,7 @@ public void test239UnassignRoleCaptainFromUserRapp() throws Exception { @Test public void test240ModifyUserRappLocalityScabb() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = modelService.getObject(UserType.class, USER_RAPP_OID, null, task, result); @@ -2133,7 +2132,7 @@ public void test240ModifyUserRappLocalityScabb() throws Exception { @Test public void test242AssignRoleRastamanToUserRapp() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -2171,7 +2170,7 @@ public void test242AssignRoleRastamanToUserRapp() throws Exception { @Test public void test244ModifyUserRappLocalityCoffin() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = modelService.getObject(UserType.class, USER_RAPP_OID, null, task, result); @@ -2209,7 +2208,7 @@ public void test244ModifyUserRappLocalityCoffin() throws Exception { @Test public void test245ModifyUserRappLocalityUnderReconcile() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = modelService.getObject(UserType.class, USER_RAPP_OID, null, task, result); @@ -2254,7 +2253,7 @@ public void test245ModifyUserRappLocalityUnderReconcile() throws Exception { @Test public void test246ModifyUserRappTimezoneMonkey() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = modelService.getObject(UserType.class, USER_RAPP_OID, null, task, result); @@ -2294,7 +2293,7 @@ public void test246ModifyUserRappTimezoneMonkey() throws Exception { @Test public void test247ModifyUserRappLocaleMI() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = modelService.getObject(UserType.class, USER_RAPP_OID, null, task, result); @@ -2331,7 +2330,7 @@ public void test247ModifyUserRappLocaleMI() throws Exception { @Test public void test249UnassignRoleRastamanFromUserRapp() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -2368,7 +2367,7 @@ public void test249UnassignRoleRastamanFromUserRapp() throws Exception { @Test public void test300ImportStanFromEmeraldResource() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -2410,7 +2409,7 @@ public void test300ImportStanFromEmeraldResource() throws Exception { @Test public void test302ModifyStanAccountAndReimport() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -2449,7 +2448,7 @@ public void test302ModifyStanAccountAndReimport() throws Exception { @Test public void test800NullTimeFrom() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -2475,7 +2474,7 @@ public void test800NullTimeFrom() throws Exception { @Test public void test802FuneralTimestamp() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); funeralTimestamp = clock.currentTimeXMLGregorianCalendar(); @@ -2641,7 +2640,7 @@ public void test813TalesBoomRecompute() throws Exception { @Test public void test820TalesUnBoom() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); modifyUserReplace(USER_JACK_OID, getExtensionPath(PIRACY_TALES), task, result /* no value */); @@ -2690,7 +2689,7 @@ public void test820TalesUnBoom() throws Exception { @Test public void test830PreLootBoom() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); modifyUserReplace(USER_JACK_OID, UserType.F_DESCRIPTION, task, result, "Rum is gone"); @@ -2785,7 +2784,7 @@ public void test832LootBoomConditionFalse() throws Exception { @Test public void test835LootBoom() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -2819,7 +2818,7 @@ public void test835LootBoom() throws Exception { @Test public void test840ResetFuneralTimestamp() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); modifyUserReplace(USER_JACK_OID, getExtensionPath(PIRACY_FUNERAL_TIMESTAMP), task, result /* no value */); @@ -2847,7 +2846,7 @@ public void test840ResetFuneralTimestamp() throws Exception { @Test public void test843UnLoot() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -2882,7 +2881,7 @@ public void test843UnLoot() throws Exception { @Test public void test845ReLoot() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -2917,7 +2916,7 @@ public void test845ReLoot() throws Exception { @Test public void test850AddCannibalLemonhead() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -2945,7 +2944,7 @@ public void test850AddCannibalLemonhead() throws Exception { @Test public void test852AddCanibalRedSkull() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -2977,7 +2976,7 @@ public void test852AddCanibalRedSkull() throws Exception { @Test public void test854AddCanibalShaprtooth() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -3010,7 +3009,7 @@ public void test854AddCanibalShaprtooth() throws Exception { @Test public void test856AddCanibalOrangeskin() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -3041,7 +3040,7 @@ public void test856AddCanibalOrangeskin() throws Exception { @Test public void test858AddCanibalCherrybrain() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -3074,7 +3073,7 @@ public void test858AddCanibalCherrybrain() throws Exception { @Test public void test859AddCanibalPineapplenose() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -3108,7 +3107,7 @@ public void test859AddCanibalPineapplenose() throws Exception { @Test public void test860AddCannibalRottenLemonhead() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -3136,7 +3135,7 @@ public void test860AddCannibalRottenLemonhead() throws Exception { @Test public void test862AddCanibalRottenRedSkull() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -3168,7 +3167,7 @@ public void test862AddCanibalRottenRedSkull() throws Exception { @Test public void test864AddCanibalRottenShaprtooth() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -3211,7 +3210,7 @@ public void test864AddCanibalRottenShaprtooth() throws Exception { @Test public void test866AddCanibalRottenOrangeskin() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -3245,7 +3244,7 @@ public void test866AddCanibalRottenOrangeskin() throws Exception { @Test public void test868AddCanibalRottenCherrybrain() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -3276,7 +3275,7 @@ public void test868AddCanibalRottenCherrybrain() throws Exception { @Test public void test869AddCanibalRottenPineapplenose() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -3311,7 +3310,7 @@ public void test869AddCanibalRottenPineapplenose() throws Exception { @Test public void test870AddCanibalRottenPotatoleg() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -3363,7 +3362,7 @@ private PrismObject createCannibal(String name, String funeralDateOffs @Test public void test900DeleteUser() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -3395,7 +3394,7 @@ public void test950CreateUserJackWithoutTemplate() throws Exception { // GIVEN setDefaultUserTemplate(null); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -3425,7 +3424,7 @@ public void test950CreateUserJackWithoutTemplate() throws Exception { @Test public void test952ModifyJackOrganizationalUnitFD004() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -3456,7 +3455,7 @@ public void test960ReconcileUserJackWithTemplate() throws Exception { // GIVEN setDefaultUserTemplate(USER_TEMPLATE_COMPLEX_OID); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -3483,7 +3482,7 @@ public void test960ReconcileUserJackWithTemplate() throws Exception { @Test public void test970ModifyUserGuybrushEmployeeTypeUseless() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -3511,7 +3510,7 @@ public void test970ModifyUserGuybrushEmployeeTypeUseless() throws Exception { @Test public void test980DeleteUserGivenName() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); UserType user = new UserType(prismContext) diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplateWithRanges.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplateWithRanges.java index 3c9547f3411..f02cbc1b174 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplateWithRanges.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplateWithRanges.java @@ -14,7 +14,6 @@ import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.*; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; @@ -205,7 +204,7 @@ public void test200SimpleOrgUnitAddition() throws Exception { final String TEST_NAME = "test200SimpleOrgUnitAddition"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -247,7 +246,7 @@ public void test210RemoveUnit1() throws Exception { final String TEST_NAME = "test210RemoveUnit1"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -287,7 +286,7 @@ public void test220RemoveUnit2AndNumber() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -326,7 +325,7 @@ public void test230RestoreNumber() throws Exception { final String TEST_NAME = "test230RestoreNumber"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -361,7 +360,7 @@ public void test300GuybrushBloodyNose() throws Exception { final String TEST_NAME = "test300GuybrushBloodyNose"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -392,7 +391,7 @@ public void test309GuybrushNotBloody() throws Exception { final String TEST_NAME = "test309GuybrushNotBloody"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -419,7 +418,7 @@ public void test310GuybrushBloodyNoseFuneral() throws Exception { final String TEST_NAME = "test310GuybrushBloodyNoseFuneral"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_GUYBRUSH_OID, getExtensionPath(PIRACY_FUNERAL_TIMESTAMP), task, result, @@ -453,7 +452,7 @@ public void test319GuybrushNoBloodyNoseFuneral() throws Exception { final String TEST_NAME = "test319GuybrushNoBloodyNoseFuneral"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -480,7 +479,7 @@ public void test320GuybrushBloodyNose() throws Exception { final String TEST_NAME = "test320GuybrushBloodyNose"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_GUYBRUSH_OID, getExtensionPath(PIRACY_FUNERAL_TIMESTAMP), task, result @@ -514,7 +513,7 @@ public void test322GuybrushSetFuneral() throws Exception { final String TEST_NAME = "test322GuybrushSetFuneral"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -542,7 +541,7 @@ public void test324GuybrushSetFuneral22222() throws Exception { final String TEST_NAME = "test324GuybrushSetFuneral22222"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -572,7 +571,7 @@ public void test326GuybrushNoFuneral() throws Exception { final String TEST_NAME = "test326GuybrushNoFuneral"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -599,7 +598,7 @@ public void test329GuybrushNoBloodyNose() throws Exception { final String TEST_NAME = "test329GuybrushNoBloodyNose"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestVolatility.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestVolatility.java index eee126385ec..35b017df9ce 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestVolatility.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestVolatility.java @@ -95,7 +95,8 @@ public void test100ImportLiveSyncTaskDummyHr() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestVolatility.class.getName() + "." + TEST_NAME); + TestVolatility.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); /// WHEN @@ -114,7 +115,8 @@ public void test110AddDummyHrAccountMancomb() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestVolatility.class.getName() + "." + TEST_NAME); + TestVolatility.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // Preconditions @@ -178,7 +180,8 @@ public void test120UpdateDummyHrAccountMancomb() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestVolatility.class.getName() + "." + TEST_NAME); + TestVolatility.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); /// WHEN @@ -244,7 +247,8 @@ public void test200ModifyGuybrushAssignAccount() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestVolatility.class.getName() + "." + TEST_NAME); + TestVolatility.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // Preconditions @@ -297,7 +301,8 @@ public void test300AddLargo() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestVolatility.class.getName() + "." + TEST_NAME); + TestVolatility.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // Preconditions @@ -352,7 +357,8 @@ public void test400AddHerman() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestVolatility.class.getName() + "." + TEST_NAME); + TestVolatility.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = PrismTestUtil.parseObject(USER_HERMAN_FILE); @@ -394,7 +400,8 @@ public void test402ModifyHermanMonster() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestVolatility.class.getName() + "." + TEST_NAME); + TestVolatility.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestArchetypes.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestArchetypes.java index 969b5827c4e..f13441a432d 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestArchetypes.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestArchetypes.java @@ -127,7 +127,7 @@ protected File getSystemConfigurationFile() { public void test020SanityJack() throws Exception { final String TEST_NAME = "test020SanityJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = assertUserBefore(USER_JACK_OID) @@ -141,7 +141,7 @@ public void test020SanityJack() throws Exception { public void test050AddArchetypeTest() throws Exception { final String TEST_NAME = "test050AddArchetypeTest"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -160,7 +160,7 @@ public void test050AddArchetypeTest() throws Exception { public void test060AddArchetypesAndRoles() throws Exception { final String TEST_NAME = "test060AddArchetypesAndRoles"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -199,7 +199,7 @@ public void test060AddArchetypesAndRoles() throws Exception { public void test070AssignGuybrushUserAdministrator() throws Exception { final String TEST_NAME = "test070AssignGuybrushUserAdministrator"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -218,7 +218,7 @@ public void test070AssignGuybrushUserAdministrator() throws Exception { public void test100AssignJackArchetypeEmployee() throws Exception { final String TEST_NAME = "test100AssignJackArchetypeEmployee"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -261,7 +261,7 @@ private String costCenterEmployee() { public void test102SearchEmployeeArchetypeRef() throws Exception { final String TEST_NAME = "test102SearchEmployeeArchetypeRef"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = queryFor(UserType.class) @@ -301,7 +301,7 @@ public void test104GetGuybryshCompiledGuiProfile() throws Exception { // GIVEN login(USER_GUYBRUSH_USERNAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -365,7 +365,7 @@ public void test109UnassignJackArchetypeEmployee() throws Exception { loginAdministrator(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -397,7 +397,7 @@ public void test109UnassignJackArchetypeEmployee() throws Exception { public void test110AssignJackRoleEmployeeBase() throws Exception { final String TEST_NAME = "test110AssignJackRoleEmployeeBase"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -452,7 +452,7 @@ public void test110AssignJackRoleEmployeeBase() throws Exception { public void test115UnassignJackRoleEmployeeBase() throws Exception { final String TEST_NAME = "test115UnassignJackRoleEmployeeBase"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -495,7 +495,7 @@ public void test115UnassignJackRoleEmployeeBase() throws Exception { public void test120AssignJackArchetypeTest() throws Exception { final String TEST_NAME = "test120AssignJackArchetypeTest"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -530,7 +530,7 @@ public void test120AssignJackArchetypeTest() throws Exception { public void test129UnassignJackArchetypeTest() throws Exception { final String TEST_NAME = "test129UnassignJackArchetypeTest"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -561,7 +561,7 @@ public void test129UnassignJackArchetypeTest() throws Exception { public void test130AssignJackArchetypeContractor() throws Exception { final String TEST_NAME = "test130AssignJackArchetypeContractor"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -593,7 +593,7 @@ public void test130AssignJackArchetypeContractor() throws Exception { public void test132JackContractorRecompute() throws Exception { final String TEST_NAME = "test132JackContractorRecompute"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -626,7 +626,7 @@ public void test132JackContractorRecompute() throws Exception { public void test135UnassignJackArchetypeContractor() throws Exception { final String TEST_NAME = "test135UnassignJackArchetypeContractor"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -660,7 +660,7 @@ public void test135UnassignJackArchetypeContractor() throws Exception { public void test137JackEmpnoAndRecompute() throws Exception { final String TEST_NAME = "test137JackEmpnoAndRecompute"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_JACK_OID, UserType.F_EMPLOYEE_NUMBER, task, result, "Number ONE"); @@ -696,7 +696,7 @@ public void test137JackEmpnoAndRecompute() throws Exception { public void test140AddMeathookContractor() throws Exception { final String TEST_NAME = "test140AddMeathookContractor"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -730,7 +730,7 @@ public void test140AddMeathookContractor() throws Exception { public void test150AddWannabe() throws Exception { final String TEST_NAME = "test150AddWannabe"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -765,7 +765,7 @@ public void test150AddWannabe() throws Exception { public void test160AddSelfMadeMan() throws Exception { final String TEST_NAME = "test160AddSelfMadeMan"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -798,7 +798,7 @@ public void test160AddSelfMadeMan() throws Exception { public void test162AddFraudster() throws Exception { final String TEST_NAME = "test162AddFraudster"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // precondition @@ -827,7 +827,7 @@ public void test162AddFraudster() throws Exception { public void test200AssignJackBarbossaArchetypeEmployee() throws Exception { final String TEST_NAME = "test200AssignJackBarbossaArchetypeEmployee"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -855,7 +855,7 @@ public void test202GetGuybryshCompiledGuiProfileActiveEmployeesView() throws Exc // GIVEN login(USER_GUYBRUSH_USERNAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -888,7 +888,7 @@ public void test202GetGuybryshCompiledGuiProfileActiveEmployeesView() throws Exc public void test203DisableBarbossa() throws Exception { final String TEST_NAME = "test203DisableBarbossa"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -915,7 +915,7 @@ public void test205GetGuybryshCompiledGuiProfileActiveEmployeesView() throws Exc // GIVEN login(USER_GUYBRUSH_USERNAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -948,7 +948,7 @@ public void test205GetGuybryshCompiledGuiProfileActiveEmployeesView() throws Exc public void test300jackAssignArchetypeRaw() throws Exception { final String TEST_NAME = "test300jackAssignArchetypeRaw"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestCollections.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestCollections.java index 0509e0808d6..ef8c8e23a5f 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestCollections.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestCollections.java @@ -66,7 +66,7 @@ public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -85,7 +85,7 @@ public void test100CompileCollectionView() throws Exception { final String TEST_NAME = "test100CompileCollectionView"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -112,7 +112,7 @@ public void test102SearchCollectionUsers() throws Exception { final String TEST_NAME = "test102SearchCollectionUsers"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -131,7 +131,7 @@ public void test110CollectionStatsAllEnabled() throws Exception { final String TEST_NAME = "test110CollectionStatsAllEnabled"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -154,7 +154,7 @@ public void test112EvaluateRulesAllEnabled() throws Exception { final String TEST_NAME = "test112EvaluateRulesAllEnabled"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -175,7 +175,7 @@ public void test120CollectionStatsOneDisabled() throws Exception { final String TEST_NAME = "test120CollectionStatsOneDisabled"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_GUYBRUSH_OID, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, task, result, ActivationStatusType.DISABLED); @@ -201,7 +201,7 @@ public void test122EvaluateRulesOneDisabled() throws Exception { final String TEST_NAME = "test122EvaluateRulesOneDisabled"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateGrouperJson.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateGrouperJson.java index bd46b088079..56e5d961125 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateGrouperJson.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateGrouperJson.java @@ -83,7 +83,8 @@ public void test000Sanity() throws Exception { } private Task createTestTask(String TEST_NAME) { - return createTask(TestAsyncUpdateGrouperJson.class.getName() + "." + TEST_NAME); + TestAsyncUpdateGrouperJson.class.getName(); + return getTestTask(); } /** diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateTaskMechanics.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateTaskMechanics.java index 98346a3b961..d7ab4d81d5b 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateTaskMechanics.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateTaskMechanics.java @@ -81,13 +81,13 @@ public void stop() { @Test public void test000Sanity() throws ObjectNotFoundException { - Task task = getTask(); + Task task = getTestTask(); assertSuccess(modelService.testResource(RESOURCE_HR.oid, task)); } @Test public void test100SmallTaskNoWorkers() throws IOException, TimeoutException, CommonException { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); int usersBefore = getObjectCount(UserType.class); @@ -112,7 +112,7 @@ public void test100SmallTaskNoWorkers() throws IOException, TimeoutException, Co @Test public void test110SmallTaskOneWorker() throws IOException, TimeoutException, CommonException { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); int usersBefore = getObjectCount(UserType.class); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestAssociationInbound.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestAssociationInbound.java index c7d198ab053..1e8f7b62c7a 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestAssociationInbound.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestAssociationInbound.java @@ -12,7 +12,6 @@ import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; @@ -77,7 +76,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti public void test100AssociationInboundMateForOrangeResource() throws Exception { final String TEST_NAME = "test100AssociationInboundMateForOrangeResource"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject resource = getDummyResourceObject(RESOURCE_DUMMY_PURPLE_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestEditSchema.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestEditSchema.java index bfdfe8f858a..c49c370a2e5 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestEditSchema.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestEditSchema.java @@ -99,7 +99,7 @@ public void test100LookupLanguagesGet() throws Exception { final String TEST_NAME="test100LookupLanguagesGet"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -125,7 +125,7 @@ public void test102LookupLanguagesGetExclude() throws Exception { final String TEST_NAME="test102LookupLanguagesGetExclude"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> options = schemaHelper.getOperationOptionsBuilder() @@ -155,7 +155,7 @@ public void test110LookupLanguagesGetAll() throws Exception { final String TEST_NAME="test110LookupLanguagesGetAll"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -177,7 +177,7 @@ public void test120LookupLanguagesGetByKeyExact() throws Exception { final String TEST_NAME="test120LookupLanguagesGetByKeyExact"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -203,7 +203,7 @@ public void test121LookupLanguagesGetByKeyStartingWith() throws Exception { final String TEST_NAME="test121LookupLanguagesGetByKeyStartingWith"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -230,7 +230,7 @@ public void test122LookupLanguagesGetByKeyContaining() throws Exception { final String TEST_NAME="test122LookupLanguagesGetByKeyContaining"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -256,7 +256,7 @@ public void test123LookupLanguagesGetByKeyContainingWithPaging() throws Exceptio final String TEST_NAME="test123LookupLanguagesGetByKeyContainingWithPaging"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -285,7 +285,7 @@ public void test124LookupLanguagesGetByKeyContainingReturningNothing() throws Ex final String TEST_NAME="test124LookupLanguagesGetByKeyContainingReturningNothing"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -318,7 +318,7 @@ public void test130LookupLanguagesGetByValueExact() throws Exception { final String TEST_NAME="test130LookupLanguagesGetByValueExact"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -348,7 +348,7 @@ public void test131LookupLanguagesGetByLabelStartingWith() throws Exception { final String TEST_NAME="test131LookupLanguagesGetByLabelStartingWith"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -376,7 +376,7 @@ public void test133LookupLanguagesGetByValueContainingWithPaging() throws Except final String TEST_NAME="test123LookupLanguagesGetByKeyContainingWithPaging"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -408,7 +408,7 @@ public void test140LookupLanguagesGetByIdExisting() throws Exception { final String TEST_NAME="test140LookupLanguagesGetByIdExisting"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -448,7 +448,7 @@ public void test150LookupLanguagesAddRowFull() throws Exception { final String TEST_NAME="test150LookupLanguagesAddRow"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); LookupTableRowType row = new LookupTableRowType(); @@ -495,7 +495,7 @@ public void test152LookupLanguagesAddRowKeyLabel() throws Exception { final String TEST_NAME="test152LookupLanguagesAddRowKeyLabel"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); LookupTableRowType row = new LookupTableRowType(); @@ -542,7 +542,7 @@ public void test154LookupLanguagesAddRowKeyValue() throws Exception { final String TEST_NAME="test154LookupLanguagesAddRowKeyValue"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); LookupTableRowType row = new LookupTableRowType(); @@ -590,7 +590,7 @@ public void test156LookupLanguagesAddRowExistingKey() throws Exception { final String TEST_NAME="test156LookupLanguagesAddRowExistingKey"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); LookupTableRowType row = new LookupTableRowType(); @@ -615,7 +615,7 @@ public void test156LookupLanguagesAddRowExistingKey() throws Exception { result.computeStatus(); TestUtil.assertSuccess(result); - task = createTask(TEST_NAME); + task = getTestTask(); result = task.getResult(); PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); @@ -650,7 +650,7 @@ public void test162LookupLanguagesDeleteRowFullNoId() throws Exception { final String TEST_NAME="test162LookupLanguagesDeleteRowFullNoId"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); LookupTableRowType row = new LookupTableRowType(); @@ -697,7 +697,7 @@ public void test164LookupLanguagesDeleteRowFullId() throws Exception { final String TEST_NAME="test164LookupLanguagesDeleteRowFullId"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); LookupTableRowType row = new LookupTableRowType(); @@ -742,7 +742,7 @@ public void test166LookupLanguagesDeleteRowIdOnly() throws Exception { final String TEST_NAME="test166LookupLanguagesDeleteRowIdOnly"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); LookupTableRowType row = new LookupTableRowType(); @@ -783,7 +783,7 @@ public void test168LookupLanguagesDeleteRowByKey() throws Exception { final String TEST_NAME="test168LookupLanguagesDeleteRowByKey"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); LookupTableRowType row = new LookupTableRowType(); @@ -823,7 +823,7 @@ public void test170LookupLanguagesReplaceRows() throws Exception { final String TEST_NAME="test170LookupLanguagesReplaceRows"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); LookupTableRowType row1 = new LookupTableRowType(); @@ -878,7 +878,7 @@ public void test180LookupLanguagesReplaceObject() throws Exception { final String TEST_NAME="test180LookupLanguagesReplaceObject"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject replacement = PrismTestUtil.parseObject(LOOKUP_LANGUAGES_REPLACEMENT_FILE); @@ -917,7 +917,7 @@ public void test182LookupLanguagesReimport() throws Exception { final String TEST_NAME="test182LookupLanguagesReimport"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ImportOptionsType options = new ImportOptionsType(); @@ -979,7 +979,7 @@ public void test200EditSchemaUser() throws Exception { final String TEST_NAME="test200EditSchemaUser"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObjectDefinition userDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class); @@ -1056,7 +1056,7 @@ public void test210UserDefinition() throws Exception { final String TEST_NAME="test210UserDefinition"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1124,7 +1124,7 @@ public void test213ModifiedUserJack() throws Exception { final String TEST_NAME="test213ModifiedUserJack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyObjectReplaceProperty(UserType.class, USER_JACK_OID, UserType.F_PREFERRED_LANGUAGE, task, result, "en_PR"); @@ -1182,7 +1182,7 @@ public void test250EditSchemaRole() throws Exception { final String TEST_NAME="test250EditSchemaRole"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObjectDefinition roleDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(RoleType.class); @@ -1208,7 +1208,7 @@ public void test260EditShadowSchemaKindIntent() throws Exception { final String TEST_NAME="test260EditShadowSchemaKindIntent"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ResourceShadowDiscriminator discr = new ResourceShadowDiscriminator(RESOURCE_DUMMY_OID, ShadowKindType.ACCOUNT, null, null, false); @@ -1249,7 +1249,7 @@ public void test261EditShadowSchemaObjectclass() throws Exception { final String TEST_NAME="test261EditShadowSchemaObjectclass"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ResourceShadowDiscriminator discr = new ResourceShadowDiscriminator(RESOURCE_DUMMY_OID, dummyResourceCtl.getAccountObjectClassQName()); @@ -1281,7 +1281,7 @@ public void test263EditShadowSchemaEmpty() throws Exception { final String TEST_NAME="test263EditShadowSchemaEmpty"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ResourceShadowDiscriminator discr = new ResourceShadowDiscriminator(null, null); @@ -1311,7 +1311,7 @@ public void test265EditShadowSchemaNull() throws Exception { final String TEST_NAME="test265EditShadowSchemaNull"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1340,7 +1340,7 @@ public void test265EditShadowSchemaNull() throws Exception { public void test310CustomRelations() throws Exception { final String TEST_NAME="test310CustomRelations"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1367,7 +1367,7 @@ public void test800OtisEditSchemaUser() throws Exception { // GIVEN login(USER_OTIS_USERNAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObjectDefinition userDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class); @@ -1436,7 +1436,7 @@ public void test810OtisGetJack() throws Exception { // GIVEN login(USER_OTIS_USERNAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1519,7 +1519,7 @@ public void test820OtisSearchUsers() throws Exception { // GIVEN login(USER_OTIS_USERNAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestRoleEntitlement.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestRoleEntitlement.java index 44df4ca5d3a..528582eb342 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestRoleEntitlement.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestRoleEntitlement.java @@ -62,7 +62,7 @@ public class TestRoleEntitlement extends AbstractGenericSyncTest { public void test050GetRolePirate() throws Exception { final String TEST_NAME = "test050GetRolePirate"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -89,7 +89,7 @@ public void test100ModifyRoleAddEntitlement() throws Exception { final String TEST_NAME = "test100ModifyRoleAddEntitlement"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -155,7 +155,7 @@ public void test101GetGroup() throws Exception { final String TEST_NAME = "test101GetGroup"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -184,7 +184,7 @@ public void test102GetGroupNoFetch() throws Exception { final String TEST_NAME = "test102GetGroupNoFetch"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -209,7 +209,7 @@ public void test103GetGroupRaw() throws Exception { final String TEST_NAME = "test103GetGroupRaw"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); Collection> options = SelectorOptions.createCollection(GetOperationOptions.createRaw()); @@ -233,7 +233,7 @@ public void test108ModifyRoleAddEntitlementAgain() throws Exception { final String TEST_NAME = "test108ModifyRoleAddEntitlementAgain"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -279,7 +279,7 @@ public void test110GetRoleResolveEntitlement() throws Exception { final String TEST_NAME = "test110GetRoleResolveEntitlement"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -307,7 +307,7 @@ public void test111GetRoleResolveEntitlement() throws Exception { final String TEST_NAME = "test111GetRoleResolveEntitlement"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -339,7 +339,7 @@ public void test112GetRoleResolveEntitlementNoFetch() throws Exception { final String TEST_NAME = "test112GetRoleResolveEntitlementNoFetch"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -370,7 +370,7 @@ public void test119ModifyRoleDeleteEntitlement() throws Exception { final String TEST_NAME = "test119ModifyRoleDeleteEntitlement"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(AssignmentPolicyEnforcementType.POSITIVE); @@ -427,7 +427,7 @@ public void test120AddEntitlement() throws Exception { final String TEST_NAME = "test120AddEntitlement"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(AssignmentPolicyEnforcementType.POSITIVE); @@ -481,7 +481,7 @@ public void test121ModifyRoleLinkEntitlement() throws Exception { final String TEST_NAME = "test121ModifyRoleLinkEntitlement"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(AssignmentPolicyEnforcementType.POSITIVE); @@ -533,7 +533,7 @@ public void test128ModifyRoleUnlinkEntitlement() throws Exception { final String TEST_NAME = "test128ModifyRoleUnlinkEntitlement"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(AssignmentPolicyEnforcementType.POSITIVE); @@ -585,7 +585,7 @@ public void test129DeleteEntitlement() throws Exception { final String TEST_NAME = "test129DeleteEntitlement"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(AssignmentPolicyEnforcementType.POSITIVE); @@ -626,7 +626,7 @@ public void test131ModifyRoleAssignEntitlement() throws Exception { final String TEST_NAME = "test131ModifyRoleAssignEntitlement"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(AssignmentPolicyEnforcementType.FULL); @@ -687,7 +687,7 @@ public void test132ModifyEntitlement() throws Exception { final String TEST_NAME = "test132ModifyEntitlement"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(AssignmentPolicyEnforcementType.FULL); @@ -751,7 +751,7 @@ public void test139ModifyRoleUnassignEntitlement() throws Exception { final String TEST_NAME = "test139ModifyRoleUnassignEntitlement"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(AssignmentPolicyEnforcementType.FULL); @@ -800,7 +800,7 @@ public void test151ModifyRoleAssignEntitlementRelativeEnforcement() throws Excep final String TEST_NAME = "test151ModifyRoleAssignEntitlementRelativeEnforcement"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(AssignmentPolicyEnforcementType.RELATIVE); @@ -910,7 +910,7 @@ public void test160ModifyRolePropertyAndAssignEntitlement() throws Exception { final String TEST_NAME = "test160ModifyRolePropertyAndAssignEntitlement"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(AssignmentPolicyEnforcementType.RELATIVE); @@ -971,7 +971,7 @@ public void test161ModifyRole() throws Exception { final String TEST_NAME = "test161ModifyRole"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(AssignmentPolicyEnforcementType.RELATIVE); @@ -1027,7 +1027,7 @@ public void test180RenameRole() throws Exception { final String TEST_NAME = "test180RenameRole"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(AssignmentPolicyEnforcementType.FULL); @@ -1089,7 +1089,7 @@ public void test199DeleteRole() throws Exception { final String TEST_NAME = "test199DeleteRole"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(AssignmentPolicyEnforcementType.RELATIVE); @@ -1143,7 +1143,7 @@ public void test200AddRoleSwashbuckler() throws Exception { final String TEST_NAME = "test200AddRoleSwashbuckler"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(AssignmentPolicyEnforcementType.RELATIVE); @@ -1208,7 +1208,7 @@ public void test210ModifyRoleSwashbucklerRiskLevel() throws Exception { final String TEST_NAME = "test210ModifyRoleSwashbucklerRiskLevel"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(AssignmentPolicyEnforcementType.RELATIVE); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractDirectManualResourceTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractDirectManualResourceTest.java index 06af0fa9f33..29084ee3047 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractDirectManualResourceTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractDirectManualResourceTest.java @@ -13,7 +13,6 @@ import javax.xml.datatype.XMLGregorianCalendar; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.prism.xml.ns._public.types_3.RawType; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; @@ -127,7 +126,7 @@ protected boolean isDirect() { public void test220ModifyUserWillDisable() throws Exception { final String TEST_NAME = "test220ModifyUserWillDisable"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); @@ -204,7 +203,7 @@ public void test220ModifyUserWillDisable() throws Exception { public void test230ModifyAccountWillChangePasswordAndEnable() throws Exception { final String TEST_NAME = "test230ModifyAccountWillChangePasswordAndEnable"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object().createModificationReplaceProperty(UserType.class, @@ -292,7 +291,7 @@ public void test230ModifyAccountWillChangePasswordAndEnable() throws Exception { public void test240CloseDisableCaseAndReadAccountWill() throws Exception { final String TEST_NAME = "test240CloseDisableCaseAndReadAccountWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); closeCase(willLastCaseOid); @@ -382,7 +381,7 @@ public void test240CloseDisableCaseAndReadAccountWill() throws Exception { public void test250RecomputeWillAfter5min() throws Exception { final String TEST_NAME = "test250RecomputeWillAfter5min"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT5M"); @@ -469,7 +468,7 @@ public void test250RecomputeWillAfter5min() throws Exception { public void test252UpdateBackingStoreAndGetAccountWill() throws Exception { final String TEST_NAME = "test252UpdateBackingStoreAndGetAccountWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); backingStoreUpdateWill(USER_WILL_FULL_NAME_PIRATE, INTEREST_ONE, ActivationStatusType.DISABLED, USER_WILL_PASSWORD_OLD); @@ -527,7 +526,7 @@ public void test252UpdateBackingStoreAndGetAccountWill() throws Exception { public void test260ClosePasswordChangeCaseAndRecomputeWill() throws Exception { final String TEST_NAME = "test260ClosePasswordChangeCaseAndRecomputeWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); closeCase(willSecondLastCaseOid); @@ -631,7 +630,7 @@ public void test260ClosePasswordChangeCaseAndRecomputeWill() throws Exception { public void test270RecomputeWillAfter7min() throws Exception { final String TEST_NAME = "test130RefreshAccountWillAfter7min"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT7M"); @@ -729,7 +728,7 @@ public void test270RecomputeWillAfter7min() throws Exception { public void test272UpdateBackingStoreAndGetAccountWill() throws Exception { final String TEST_NAME = "test272UpdateBackingStoreAndGetAccountWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); backingStoreUpdateWill(USER_WILL_FULL_NAME_PIRATE, INTEREST_ONE, ActivationStatusType.ENABLED, USER_WILL_PASSWORD_NEW); @@ -787,7 +786,7 @@ public void test272UpdateBackingStoreAndGetAccountWill() throws Exception { public void test274RecomputeWillAfter22min() throws Exception { final String TEST_NAME = "test292RecomputeWillAfter22min"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT15M"); @@ -872,7 +871,7 @@ public void test274RecomputeWillAfter22min() throws Exception { public void test280RecomputeWillAfter27min() throws Exception { final String TEST_NAME = "test280RecomputeWillAfter27min"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT5M"); @@ -945,7 +944,7 @@ public void test280RecomputeWillAfter27min() throws Exception { public void test290RecomputeWillAfter32min() throws Exception { final String TEST_NAME = "test290RecomputeWillAfter32min"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT5M"); @@ -1007,7 +1006,7 @@ public void test290RecomputeWillAfter32min() throws Exception { public void test300UnassignAccountWill() throws Exception { final String TEST_NAME = "test300UnassignAccountWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertSteadyResources(); @@ -1083,7 +1082,7 @@ public void test300UnassignAccountWill() throws Exception { public void test302RecomputeWill() throws Exception { final String TEST_NAME = "test302RecomputeWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1153,7 +1152,7 @@ public void test302RecomputeWill() throws Exception { public void test310CloseCaseAndReconcileWill() throws Exception { final String TEST_NAME = "test310CloseCaseAndReconcileWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); closeCase(willLastCaseOid); @@ -1218,7 +1217,7 @@ protected void assertUnassignedShadow(ShadowAsserter shadowModelAsserter, boo public void test320RecomputeWillAfter5min() throws Exception { final String TEST_NAME = "test320RecomputeWillAfter5min"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT5M"); @@ -1271,7 +1270,7 @@ public void test320RecomputeWillAfter5min() throws Exception { public void test330UpdateBackingStoreAndRecomputeWill() throws Exception { final String TEST_NAME = "test330UpdateBackingStoreAndRecomputeWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); backingStoreDeprovisionWill(); @@ -1334,7 +1333,7 @@ public void test330UpdateBackingStoreAndRecomputeWill() throws Exception { public void test340RecomputeWillAfter25min() throws Exception { final String TEST_NAME = "test340RecomputeWillAfter25min"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT20M"); @@ -1375,7 +1374,7 @@ public void test340RecomputeWillAfter25min() throws Exception { public void test342RecomputeWillAfter35min() throws Exception { final String TEST_NAME = "test342RecomputeWillAfter35min"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT10M"); @@ -1413,7 +1412,7 @@ public void test342RecomputeWillAfter35min() throws Exception { public void test344RecomputeWillAfter165min() throws Exception { final String TEST_NAME = "test344RecomputeWillAfter165min"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT130M"); @@ -1478,7 +1477,7 @@ public void test500AssignWillRoleOne() throws Exception { public void test510UnassignWillRoleOne() throws Exception { final String TEST_NAME = "test510UnassignWillRoleOne"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); accountWillSecondReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); @@ -1548,7 +1547,7 @@ public void test510UnassignWillRoleOne() throws Exception { public void test512ReconcileWill() throws Exception { final String TEST_NAME = "test512ReconcileWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1618,7 +1617,7 @@ public void test512ReconcileWill() throws Exception { public void test515CloseCasesAndReconcileWill() throws Exception { final String TEST_NAME = "test515CloseCasesAndReconcileWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); closeCase(willLastCaseOid); @@ -1718,7 +1717,7 @@ protected void assertWillUnassignPendingOperationCompleted(ShadowAsserter public void test516RecomputeWillAfter20min() throws Exception { final String TEST_NAME = "test516RecomputeWillAfter20min"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT20M"); @@ -1752,7 +1751,7 @@ public void test516RecomputeWillAfter20min() throws Exception { public void test517RecomputeWillAfter50min() throws Exception { final String TEST_NAME = "test517RecomputeWillAfter50min"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT15M"); @@ -1788,7 +1787,7 @@ public void test517RecomputeWillAfter50min() throws Exception { public void test518RecomputeWillAfter180min() throws Exception { final String TEST_NAME = "test518RecomputeWillAfter180min"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT130M"); @@ -1818,7 +1817,7 @@ public void test518RecomputeWillAfter180min() throws Exception { @Test public void test519CleanUp() throws Exception { final String TEST_NAME = "test519CleanUp"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); cleanupUser(TEST_NAME, userWillOid, USER_WILL_NAME, accountWillOid); @@ -1849,7 +1848,7 @@ public void test520AssignWillRoleOne() throws Exception { public void test522AssignWillRoleTwoValidFrom() throws Exception { final String TEST_NAME = "test522AssignWillRoleTwoValidFrom"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ActivationType activationType = new ActivationType(); @@ -1885,7 +1884,7 @@ public void test524TwoHoursForRoleTwo() throws Exception { clockForward("PT2H5M"); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); accountWillSecondReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); @@ -1950,7 +1949,7 @@ public void test524TwoHoursForRoleTwo() throws Exception { public void test525CloseCasesAndReconcileWill() throws Exception { final String TEST_NAME = "test525CloseCasesAndReconcileWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); closeCase(willLastCaseOid); @@ -1987,7 +1986,7 @@ public void test525CloseCasesAndReconcileWill() throws Exception { public void test526UnassignWillBothRoles() throws Exception { final String TEST_NAME = "test526UnassignWillBothRoles"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(userWillOid); @@ -2046,7 +2045,7 @@ protected void assertTest526Deltas(PrismObject shadowRepo, Operation public void test528CloseCaseAndRecomputeWill() throws Exception { final String TEST_NAME = "test528CloseCaseAndRecomputeWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); closeCase(willLastCaseOid); @@ -2104,7 +2103,7 @@ protected void assertTest528Deltas(PrismObject shadowRepo, Operation @Test public void test529CleanUp() throws Exception { final String TEST_NAME = "test529CleanUp"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); cleanupUser(TEST_NAME, userWillOid, USER_WILL_NAME, accountWillOid); @@ -2142,7 +2141,7 @@ public void test800ImportShadowRefreshTask() throws Exception { public void test810AssignAccountWill() throws Exception { final String TEST_NAME = "test810AssignAccountWill"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertUserBefore(userWillOid) @@ -2165,7 +2164,7 @@ public void test810AssignAccountWill() throws Exception { public void test820AssignAccountJack() throws Exception { final String TEST_NAME = "test820AssignAccountJack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT5M"); @@ -2202,7 +2201,7 @@ public void test820AssignAccountJack() throws Exception { public void test830CloseCaseWillAndWaitForRefresh() throws Exception { final String TEST_NAME = "test830CloseCaseWillAndWaitForRefresh"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); closeCase(willLastCaseOid); @@ -2229,7 +2228,7 @@ public void test830CloseCaseWillAndWaitForRefresh() throws Exception { public void test840AddToBackingStoreAndGetAccountWill() throws Exception { final String TEST_NAME = "test840AddToBackingStoreAndGetAccountWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); backingStoreProvisionWill(INTEREST_ONE); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractGroupingManualResourceTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractGroupingManualResourceTest.java index ad6e3a582f2..8a36f9f1cf1 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractGroupingManualResourceTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractGroupingManualResourceTest.java @@ -164,7 +164,7 @@ public void test100AssignWillRoleOne() throws Exception { public void test220ModifyUserWillDisable() throws Exception { final String TEST_NAME = "test220ModifyUserWillDisable"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); @@ -244,7 +244,7 @@ public void test220ModifyUserWillDisable() throws Exception { public void test230ModifyAccountWillChangePasswordAndEnable() throws Exception { final String TEST_NAME = "test230ModifyAccountWillChangePasswordAndEnable"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object().createModificationReplaceProperty(UserType.class, @@ -272,7 +272,7 @@ public void test230ModifyAccountWillChangePasswordAndEnable() throws Exception { } protected void assertAccountWillAfterChangePasswordAndEnable(final String TEST_NAME) throws Exception { - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject shadowRepo = repositoryService.getObject(ShadowType.class, accountWillOid, null, result); @@ -337,7 +337,7 @@ protected void assertAccountWillAfterChangePasswordAndEnable(final String TEST_N public void test232RunPropagationBeforeInterval() throws Exception { final String TEST_NAME = "test235RunPropagationAfterInterval"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -358,7 +358,7 @@ public void test232RunPropagationBeforeInterval() throws Exception { public void test235RunPropagationAfterInterval() throws Exception { final String TEST_NAME = "test235RunPropagationAfterInterval"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT2M"); @@ -465,7 +465,7 @@ public void test235RunPropagationAfterInterval() throws Exception { public void test240CloseCaseAndReadAccountWill() throws Exception { final String TEST_NAME = "test240CloseCaseAndReadAccountWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); closeCase(willLastCaseOid); @@ -494,7 +494,7 @@ public void test240CloseCaseAndReadAccountWill() throws Exception { public void test250RecomputeWillAfter5min() throws Exception { final String TEST_NAME = "test250RecomputeWillAfter5min"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT5M"); @@ -521,7 +521,7 @@ public void test250RecomputeWillAfter5min() throws Exception { public void test272UpdateBackingStoreAndGetAccountWill() throws Exception { final String TEST_NAME = "test272UpdateBackingStoreAndGetAccountWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // ff 7min. Refresh. Oldest delta over grace. But not expired yet. @@ -578,7 +578,7 @@ public void test272UpdateBackingStoreAndGetAccountWill() throws Exception { public void test273GetAccountWill() throws Exception { final String TEST_NAME = "test273GetAccountWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // ff 15min. Oldest delta should expire. @@ -633,7 +633,7 @@ public void test273GetAccountWill() throws Exception { public void test290RecomputeWillAfter15min() throws Exception { final String TEST_NAME = "test290RecomputeWillAfter15min"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT15M"); @@ -692,7 +692,7 @@ public void test290RecomputeWillAfter15min() throws Exception { public void test300UnassignAccountWill() throws Exception { final String TEST_NAME = "test300UnassignAccountWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); @@ -767,7 +767,7 @@ public void test300UnassignAccountWill() throws Exception { public void test302RunPropagationAfterInterval() throws Exception { final String TEST_NAME = "test302RunPropagationAfterInterval"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT2M"); @@ -842,7 +842,7 @@ public void test302RunPropagationAfterInterval() throws Exception { public void test310CloseCaseAndRecomputeWill() throws Exception { final String TEST_NAME = "test310CloseCaseAndRecomputeWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); closeCase(willLastCaseOid); @@ -893,7 +893,7 @@ public void test310CloseCaseAndRecomputeWill() throws Exception { public void test330UpdateBackingStoreAndRecomputeWill() throws Exception { final String TEST_NAME = "test330UpdateBackingStoreAndRecomputeWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); backingStoreDeprovisionWill(); @@ -951,7 +951,7 @@ protected void assertUnassignedShadow(PrismObject shadow, Activation } protected void assertAccountWillAfterChangePasswordAndEnableCaseClosed(final String TEST_NAME, PrismObject shadowModel) throws Exception { - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject shadowRepo = repositoryService.getObject(ShadowType.class, accountWillOid, null, result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractManualResourceTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractManualResourceTest.java index ee9a8e86e04..a705c75c300 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractManualResourceTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractManualResourceTest.java @@ -299,7 +299,7 @@ public void test012TestConnection() throws Exception { public void testConnection(final String TEST_NAME, boolean initialized) throws Exception { // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Check that there is a schema, but no capabilities before test (pre-condition) @@ -501,7 +501,7 @@ public void test018ResourceCaching() throws Exception { public void testResourceCaching(final String TEST_NAME) throws Exception { // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject resourceReadonlyBefore = modelService.getObject( @@ -534,7 +534,7 @@ public void testResourceCaching(final String TEST_NAME) throws Exception { public void test020ReimportResource() throws Exception { final String TEST_NAME = "test020ReimportResource"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ImportOptionsType options = new ImportOptionsType(); @@ -574,7 +574,7 @@ public void test028ResourceCaching() throws Exception { public void test030ReimportResourceAgain() throws Exception { final String TEST_NAME = "test030ReimportResourceAgain"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ImportOptionsType options = new ImportOptionsType(); @@ -594,7 +594,7 @@ public void test030ReimportResourceAgain() throws Exception { public void test032UseResource() throws Exception { final String TEST_NAME = "test032UseResource"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(getResourceOid(), ShadowKindType.ACCOUNT, null, prismContext); @@ -686,7 +686,7 @@ public void test100AssignWillRoleOne() throws Exception { public void test101GetAccountWillFuture() throws Exception { final String TEST_NAME = "test101GetAccountWillFuture"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); @@ -719,7 +719,7 @@ public void test101GetAccountWillFuture() throws Exception { public void test102RecomputeWill() throws Exception { final String TEST_NAME = "test102RecomputeWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -742,7 +742,7 @@ public void test102RecomputeWill() throws Exception { public void test103RunPropagation() throws Exception { final String TEST_NAME = "test103RunPropagation"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT2M"); @@ -768,7 +768,7 @@ public void test103RunPropagation() throws Exception { public void test104RecomputeWill() throws Exception { final String TEST_NAME = "test104RecomputeWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberCounter(InternalCounters.CONNECTOR_MODIFICATION_COUNT); @@ -818,7 +818,7 @@ public void test105RunPropagationAgain() throws Exception { public void test106AddToBackingStoreAndGetAccountWill() throws Exception { final String TEST_NAME = "test106AddToBackingStoreAndGetAccountWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); backingStoreProvisionWill(INTEREST_ONE); @@ -862,7 +862,7 @@ public void test106AddToBackingStoreAndGetAccountWill() throws Exception { public void test108GetAccountWillFuture() throws Exception { final String TEST_NAME = "test108GetAccountWillFuture"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); @@ -909,7 +909,7 @@ public void test108GetAccountWillFuture() throws Exception { public void test110CloseCaseAndRecomputeWill() throws Exception { final String TEST_NAME = "test110CloseCaseAndRecomputeWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); closeCase(willLastCaseOid); @@ -963,7 +963,7 @@ public void test114RunPropagation() throws Exception { public void test120RecomputeWillAfter5min() throws Exception { final String TEST_NAME = "test120RecomputeWillAfter5min"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT5M"); @@ -1005,7 +1005,7 @@ public void test120RecomputeWillAfter5min() throws Exception { public void test130RecomputeWillAfter25min() throws Exception { final String TEST_NAME = "test130RecomputeWillAfter25min"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT20M"); @@ -1047,7 +1047,7 @@ public void test130RecomputeWillAfter25min() throws Exception { public void test132RecomputeWillAfter32min() throws Exception { final String TEST_NAME = "test132RecomputeWillAfter32min"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT7M"); @@ -1077,7 +1077,7 @@ public void test132RecomputeWillAfter32min() throws Exception { public void test200ModifyUserWillFullname() throws Exception { final String TEST_NAME = "test200ModifyUserWillFullname"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object().createModificationReplaceProperty(ShadowType.class, @@ -1107,7 +1107,7 @@ public void test200ModifyUserWillFullname() throws Exception { public void test202RecomputeWill() throws Exception { final String TEST_NAME = "test202RecomputeWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1146,7 +1146,7 @@ public void test203RunPropagation() throws Exception { public void test204RecomputeWill() throws Exception { final String TEST_NAME = "test204RecomputeWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1169,7 +1169,7 @@ public void test204RecomputeWill() throws Exception { public void test206CloseCaseAndRecomputeWill() throws Exception { final String TEST_NAME = "test206CloseCaseAndRecomputeWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); closeCase(willLastCaseOid); @@ -1246,7 +1246,7 @@ public void test206CloseCaseAndRecomputeWill() throws Exception { public void test210RecomputeWillAfter5min() throws Exception { final String TEST_NAME = "test210RecomputeWillAfter5min"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT5M"); @@ -1305,7 +1305,7 @@ public void test210RecomputeWillAfter5min() throws Exception { public void test212UpdateBackingStoreAndGetAccountWill() throws Exception { final String TEST_NAME = "test212UpdateBackingStoreAndGetAccountWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); backingStoreUpdateWill(USER_WILL_FULL_NAME_PIRATE, INTEREST_ONE, ActivationStatusType.ENABLED, USER_WILL_PASSWORD_OLD); @@ -1366,7 +1366,7 @@ public void test212UpdateBackingStoreAndGetAccountWill() throws Exception { public void test400PhantomAccount() throws Exception { final String TEST_NAME = "test400PhantomAccount"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); setupPhantom(TEST_NAME); @@ -1420,7 +1420,7 @@ public void test400PhantomAccount() throws Exception { protected void setupPhantom(final String TEST_NAME) throws Exception { // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); addObject(USER_PHANTOM_FILE); @@ -1439,7 +1439,7 @@ protected void setupPhantom(final String TEST_NAME) throws Exception { public void test410AssignPhoenixAccount() throws Exception { final String TEST_NAME = "test410AssignPhoenixAccount"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); addObject(USER_PHOENIX_FILE); @@ -1485,7 +1485,7 @@ public void test410AssignPhoenixAccount() throws Exception { public void test412AddPhoenixToBackingStoreAndCloseTicket() throws Exception { final String TEST_NAME = "test412AddPhoenixToBackingStoreAndCloseTicket"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); backingStoreAddPhoenix(); @@ -1523,7 +1523,7 @@ public void test412AddPhoenixToBackingStoreAndCloseTicket() throws Exception { public void test413PhoenixLetOperationsExpire() throws Exception { final String TEST_NAME = "test413PhoenixLetOperationsExpire"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT1H"); @@ -1560,7 +1560,7 @@ public void test413PhoenixLetOperationsExpire() throws Exception { public void test414UnassignPhoenixAccount() throws Exception { final String TEST_NAME = "test414UnassignPhoenixAccount"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1603,7 +1603,7 @@ public void test414UnassignPhoenixAccount() throws Exception { public void test416PhoenixAccountUnassignCloseCase() throws Exception { final String TEST_NAME = "test416PhoenixAccountUnassignCloseCase"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); closeCase(phoenixLastCaseOid); @@ -1650,7 +1650,7 @@ public void test416PhoenixAccountUnassignCloseCase() throws Exception { public void test418AssignPhoenixAccountAgain() throws Exception { final String TEST_NAME = "test418AssignPhoenixAccountAgain"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1739,7 +1739,7 @@ public void test900SetUpRoles() throws Exception { } // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); SystemConfigurationType systemConfiguration = getSystemConfiguration(); @@ -1789,7 +1789,7 @@ public void test910ConcurrentRolesAssign() throws Exception { } // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); int numberOfCasesBefore = getObjectCount(CaseType.class); @@ -1805,7 +1805,7 @@ public void test910ConcurrentRolesAssign() throws Exception { ParallelTestThread[] threads = multithread(TEST_NAME, (i) -> { login(userAdministrator); - Task localTask = createTask(TEST_NAME + ".local"); + Task localTask = getTestTask(); assignRole(USER_DRAKE_OID, getRoleOid(i), localTask, localTask.getResult()); @@ -1867,7 +1867,7 @@ public void test919ConcurrentRoleUnassign() throws Exception { } // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); int numberOfCasesBefore = getObjectCount(CaseType.class); @@ -1884,7 +1884,7 @@ public void test919ConcurrentRoleUnassign() throws Exception { (i) -> { display("Thread "+Thread.currentThread().getName()+" START"); login(userAdministrator); - Task localTask = createTask(TEST_NAME + ".local"); + Task localTask = getTestTask(); OperationResult localResult = localTask.getResult(); unassignRole(USER_DRAKE_OID, getRoleOid(i), localTask, localResult); @@ -1965,7 +1965,7 @@ protected void assertTest919ShadowFuture(PrismObject shadowModelFutu } protected void assertAccountWillAfterFullNameModification(final String TEST_NAME, PendingOperationExecutionStatusType executionStage) throws Exception { - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject shadowRepo = repositoryService.getObject(ShadowType.class, accountWillOid, null, result); @@ -2063,7 +2063,7 @@ protected void backingStoreAddPhoenix() throws IOException { protected void assignWillRoleOne(final String TEST_NAME, String expectedFullName, PendingOperationExecutionStatusType executionStage) throws Exception { // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); @@ -2158,7 +2158,7 @@ protected boolean caseShouldExist(PendingOperationExecutionStatusType executionS protected void assertAccountJackAfterAssign(final String TEST_NAME) throws Exception { - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject shadowRepo = repositoryService.getObject(ShadowType.class, accountJackOid, null, result); @@ -2194,7 +2194,7 @@ protected void assertAccountJackAfterAssign(final String TEST_NAME) throws Excep } protected void assertWillAfterCreateCaseClosed(final String TEST_NAME, boolean backingStoreUpdated) throws Exception { - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ShadowAsserter shadowRepoAsserter = assertRepoShadow(accountWillOid) diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestDummyItsmIntegration.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestDummyItsmIntegration.java index 97e541fc411..28c9f88c645 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestDummyItsmIntegration.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestDummyItsmIntegration.java @@ -28,7 +28,6 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.result.OperationResultStatus; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.CommunicationException; @@ -122,7 +121,7 @@ public void test000Sanity() throws Exception { public void test012TestConnection() throws Exception { final String TEST_NAME = "test012TestConnection"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -150,7 +149,7 @@ public void test012TestConnection() throws Exception { public void test100AssignAccountToJack() throws Exception { final String TEST_NAME = "test100AssignAccountToJack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -179,7 +178,7 @@ public void test100AssignAccountToJack() throws Exception { public void test102CloseTicketAndRecomputeJack() throws Exception { final String TEST_NAME = "test102CloseTicketAndRecomputeJack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); closeDummyTicket(jackLastTicketIdentifier); @@ -205,7 +204,7 @@ public void test102CloseTicketAndRecomputeJack() throws Exception { public void test104UnassignAccountFromJack() throws Exception { final String TEST_NAME = "test104UnassignAccountFromJack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -235,7 +234,7 @@ public void test104UnassignAccountFromJack() throws Exception { public void test108CloseTicketAndRecomputeJack() throws Exception { final String TEST_NAME = "test108CloseTicketAndRecomputeJack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); closeDummyTicket(jackLastTicketIdentifier); @@ -271,7 +270,7 @@ public void test108CloseTicketAndRecomputeJack() throws Exception { public void test109LetItExpire() throws Exception { final String TEST_NAME = "test109LetItExpire"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT3H"); @@ -295,7 +294,7 @@ public void test109LetItExpire() throws Exception { public void test110AssignItsmAccountToJackCommunicationError() throws Exception { final String TEST_NAME = "test110AssignItsmAccountToJackCommunicationError"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyItsm.getInstance().setFailureClass(CommunicationException.class); @@ -330,7 +329,7 @@ public void test110AssignItsmAccountToJackCommunicationError() throws Exception public void test111ReconcileJackFixed() throws Exception { final String TEST_NAME = "test111ReconcileJackFixed"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Give consistency a time re-try operation again. @@ -374,7 +373,7 @@ public void test111ReconcileJackFixed() throws Exception { public void test112CloseTicketAndRecomputeJackCommunicationError() throws Exception { final String TEST_NAME = "test112CloseTicketAndRecomputeJackCommunicationError"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); closeDummyTicket(jackLastTicketIdentifier); @@ -411,7 +410,7 @@ public void test112CloseTicketAndRecomputeJackCommunicationError() throws Except public void test113RecomputeJackFixed() throws Exception { final String TEST_NAME = "test113RecomputeJackFixed"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyItsm.getInstance().clearFailureClass(); @@ -445,7 +444,7 @@ public void test113RecomputeJackFixed() throws Exception { public void test114UnassignAccountFromJackCommunicationError() throws Exception { final String TEST_NAME = "test114UnassignAccountFromJackCommunicationError"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyItsm.getInstance().setFailureClass(CommunicationException.class); @@ -497,7 +496,7 @@ public void test114UnassignAccountFromJackCommunicationError() throws Exception public void test115ReconcileJackFixed() throws Exception { final String TEST_NAME = "test115ReconcileJackFixed"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Give consistency a time re-try operation again. @@ -541,7 +540,7 @@ public void test115ReconcileJackFixed() throws Exception { public void test117CloseTicketAndRecomputeJackCommunicationError() throws Exception { final String TEST_NAME = "test117CloseTicketAndRecomputeJackCommunicationError"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); closeDummyTicket(jackLastTicketIdentifier); @@ -578,7 +577,7 @@ public void test117CloseTicketAndRecomputeJackCommunicationError() throws Except public void test118RecomputeJackFixed() throws Exception { final String TEST_NAME = "test118RecomputeJackFixed"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyItsm.getInstance().clearFailureClass(); @@ -619,7 +618,7 @@ public void test118RecomputeJackFixed() throws Exception { public void test119LetItExpire() throws Exception { final String TEST_NAME = "test119LetItExpire"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT3H"); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManual.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManual.java index 5bbe839880b..fbe7fc74894 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManual.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManual.java @@ -118,7 +118,7 @@ protected int getNumberOfAccountAttributeDefinitions() { public void test700AssignAccountJackExisting() throws Exception { final String TEST_NAME = "test700AssignAccountJack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); if (accountJackOid != null) { @@ -177,7 +177,7 @@ public void test700AssignAccountJackExisting() throws Exception { public void test710UnassignAccountJack() throws Exception { final String TEST_NAME = "test710UnassignAccountJack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clock.overrideDuration("PT5M"); @@ -232,7 +232,7 @@ public void test710UnassignAccountJack() throws Exception { public void test712CloseCaseAndRecomputeJack() throws Exception { final String TEST_NAME = "test712CloseCaseAndRecomputeJack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); backingStoreDeleteJack(); @@ -289,7 +289,7 @@ public void test712CloseCaseAndRecomputeJack() throws Exception { public void test717RecomputeJackAfter130min() throws Exception { final String TEST_NAME = "test717RecomputeJackAfter130min"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clock.overrideDuration("PT130M"); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualDisable.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualDisable.java index 98055435221..49cf336af4b 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualDisable.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualDisable.java @@ -21,7 +21,6 @@ import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.asserter.ShadowAsserter; import com.evolveum.midpoint.test.asserter.UserAsserter; import com.evolveum.midpoint.util.exception.ObjectNotFoundException; @@ -153,7 +152,7 @@ protected void assertWillUnassignPendingOperationCompleted(ShadowAsserter @Override protected void cleanupUser(final String TEST_NAME, String userOid, String username, String accountOid) throws Exception { - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); backingStore.deleteAccount(username); @@ -178,7 +177,7 @@ protected void cleanupUser(final String TEST_NAME, String userOid, String userna public void test416PhoenixAccountUnassignCloseCase() throws Exception { final String TEST_NAME = "test416PhoenixAccountUnassignCloseCase"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); closeCase(phoenixLastCaseOid); @@ -223,7 +222,7 @@ public void test416PhoenixAccountUnassignCloseCase() throws Exception { public void test418AssignPhoenixAccountAgain() throws Exception { final String TEST_NAME = "test418AssignPhoenixAccountAgain"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGrouping.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGrouping.java index be7f6f14269..1df6a87b84b 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGrouping.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGrouping.java @@ -28,7 +28,6 @@ import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.asserter.ShadowAsserter; import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.PendingOperationExecutionStatusType; @@ -125,7 +124,7 @@ protected void assertShadowPassword(PrismObject shadow) { public void test400PhantomAccount() throws Exception { final String TEST_NAME = "test400PhantomAccount"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); setupPhantom(TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGroupingProposed.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGroupingProposed.java index 15a396162b9..41804e13ab0 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGroupingProposed.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGroupingProposed.java @@ -15,7 +15,6 @@ import java.io.File; import com.evolveum.midpoint.prism.query.FilterUtil; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.prism.xml.ns._public.types_3.RawType; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; @@ -78,7 +77,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti public void test020ResourcesSanity() throws Exception { final String TEST_NAME = "test020ResourcesSanity"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); SearchResultList> resources = repositoryService.searchObjects(ResourceType.class, null, null, result); @@ -121,7 +120,7 @@ protected void assertFinishedPropagationTask(Task finishedTask, OperationResultS public void test500AssignBigmouthRoleOne() throws Exception { final String TEST_NAME = "test500AssignBigmouthRoleOne"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = createUser(USER_BIGMOUTH_NAME, USER_BIGMOUTH_FULLNAME, true); @@ -177,7 +176,7 @@ public void test500AssignBigmouthRoleOne() throws Exception { public void test502RunPropagation() throws Exception { final String TEST_NAME = "test502RunPropagation"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT20M"); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMapping.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMapping.java index 04779794a12..881d6b5e7f4 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMapping.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMapping.java @@ -178,7 +178,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100ModifyUserAssignAccountDummyBlue() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); @@ -232,7 +232,7 @@ public void test100ModifyUserAssignAccountDummyBlue() throws Exception { @Test public void test101ModifyUserFullName() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); @@ -268,7 +268,7 @@ public void test101ModifyUserFullName() throws Exception { @Test public void test102ModifyUserFullNameRecon() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); @@ -308,7 +308,7 @@ public void test102ModifyUserFullNameRecon() throws Exception { @Test public void test104ModifyUserOrganizationalUnit() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); @@ -339,7 +339,7 @@ public void test104ModifyUserOrganizationalUnit() throws Exception { @Test public void test105ModifyAccountShip() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); @@ -382,7 +382,7 @@ accountOid, getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).getAttributePat @Test public void test106ModifyAccountShipReplaceEmpty() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); @@ -421,7 +421,7 @@ accountOid, getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).getAttributePat @Test public void test107ModifyAccountShipAgain() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); @@ -464,7 +464,7 @@ accountOid, getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).getAttributePat @Test public void test108ModifyAccountShipDelete() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); @@ -508,7 +508,7 @@ accountOid, getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).getAttributePat @Test public void test110AssignBlueTitanic() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -527,7 +527,7 @@ public void test110AssignBlueTitanic() throws Exception { @Test public void test111Recompute() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -551,7 +551,7 @@ public void test111Recompute() throws Exception { @Test public void test112DisableBlueTitanicAssignment() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -578,7 +578,7 @@ public void test112DisableBlueTitanicAssignment() throws Exception { @Test public void test113Recompute() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -600,7 +600,7 @@ public void test113Recompute() throws Exception { @Test public void test114Reconcile() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -623,7 +623,7 @@ public void test114Reconcile() throws Exception { @Test public void test115EnableBlueTitanicAssignment() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -647,7 +647,7 @@ public void test115EnableBlueTitanicAssignment() throws Exception { @Test public void test118UnassignBlueTitanic() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -676,7 +676,7 @@ public void test118UnassignBlueTitanic() throws Exception { @Test public void test120AssignBluePoetry() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assertDummyAccountAttribute(RESOURCE_DUMMY_BLUE_NAME, ACCOUNT_JACK_DUMMY_USERNAME, @@ -700,7 +700,7 @@ public void test120AssignBluePoetry() throws Exception { @Test public void test121Recompute() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -723,7 +723,7 @@ public void test121Recompute() throws Exception { @Test public void test122DisableBlueTitanicAssignment() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -753,7 +753,7 @@ public void test122DisableBlueTitanicAssignment() throws Exception { @Test public void test123Recompute() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -777,7 +777,7 @@ public void test123Recompute() throws Exception { @Test public void test124Reconcile() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -802,7 +802,7 @@ public void test124Reconcile() throws Exception { @Test public void test125EnableBluePoetryAssignment() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -828,7 +828,7 @@ public void test125EnableBluePoetryAssignment() throws Exception { @Test public void test128UnassignBluePoetry() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -854,7 +854,7 @@ public void test128UnassignBluePoetry() throws Exception { @Test public void test129ModifyUserUnassignAccountBlue() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); @@ -893,7 +893,7 @@ public void test129ModifyUserUnassignAccountBlue() throws Exception { @Test public void test140AssignCobaltAccount() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -925,7 +925,7 @@ public void test140AssignCobaltAccount() throws Exception { @Test public void test141DestroyAndRecompute() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_COBALT_NAME, ACCOUNT_JACK_DUMMY_USERNAME); @@ -956,7 +956,7 @@ public void test141DestroyAndRecompute() throws Exception { @Test public void test142DestroyAndReconcile() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_COBALT_NAME, ACCOUNT_JACK_DUMMY_USERNAME); @@ -987,7 +987,7 @@ public void test142DestroyAndReconcile() throws Exception { @Test public void test143ClearAndRecompute() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_COBALT_NAME, ACCOUNT_JACK_DUMMY_USERNAME); @@ -1021,7 +1021,7 @@ public void test143ClearAndRecompute() throws Exception { @Test public void test150AssignCobaltNeverland() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -1042,7 +1042,7 @@ public void test150AssignCobaltNeverland() throws Exception { @Test public void test151Recompute() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -1065,7 +1065,7 @@ public void test151Recompute() throws Exception { @Test public void test152DisableCobalNeverlandAssignment() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1094,7 +1094,7 @@ public void test152DisableCobalNeverlandAssignment() throws Exception { @Test public void test153Recompute() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -1117,7 +1117,7 @@ public void test153Recompute() throws Exception { @Test public void test154Reconcile() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -1141,7 +1141,7 @@ public void test154Reconcile() throws Exception { @Test public void test155DestroyAndRecompute() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_COBALT_NAME, ACCOUNT_JACK_DUMMY_USERNAME); @@ -1172,7 +1172,7 @@ public void test155DestroyAndRecompute() throws Exception { @Test public void test156ClearAndRecompute() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_COBALT_NAME, ACCOUNT_JACK_DUMMY_USERNAME); @@ -1203,7 +1203,7 @@ public void test156ClearAndRecompute() throws Exception { @Test public void test157EnableCobaltNeverlandAssignment() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1229,7 +1229,7 @@ public void test157EnableCobaltNeverlandAssignment() throws Exception { @Test public void test158UnassignCobaltNeverland() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1253,7 +1253,7 @@ public void test158UnassignCobaltNeverland() throws Exception { @Test public void test159UnassignCobaltAccount() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1279,7 +1279,7 @@ public void test159UnassignCobaltAccount() throws Exception { @Test public void test160ModifyUserAssignAccountDummyRed() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); @@ -1329,7 +1329,7 @@ public void test160ModifyUserAssignAccountDummyRed() throws Exception { @Test public void test161ModifyUserFullName() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); @@ -1360,7 +1360,7 @@ public void test161ModifyUserFullName() throws Exception { @Test public void test162ModifyUserOrganizationalUnit() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); @@ -1391,7 +1391,7 @@ public void test162ModifyUserOrganizationalUnit() throws Exception { @Test public void test163ModifyAccountShip() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); @@ -1435,7 +1435,7 @@ accountOid, getDummyResourceController(RESOURCE_DUMMY_RED_NAME).getAttributePath @Test public void test164ModifyAccountShipReplaceEmpty() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); @@ -1474,7 +1474,7 @@ accountOid, getDummyResourceController(RESOURCE_DUMMY_RED_NAME).getAttributePath @Test public void test166ModifyAccountShipDelete() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); @@ -1518,7 +1518,7 @@ accountOid, getDummyResourceController(RESOURCE_DUMMY_RED_NAME).getAttributePath @Test public void test168ModifyUserOrganization() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); @@ -1552,7 +1552,7 @@ public void test168ModifyUserOrganization() throws Exception { @Test public void test178ModifyUserUnassignAccountRed() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); @@ -1608,7 +1608,7 @@ public void test178ModifyUserUnassignAccountRed() throws Exception { @Test public void test179DeleteAccountRed() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); @@ -1652,7 +1652,7 @@ public void test179DeleteAccountRed() throws Exception { @Test public void test180ModifyUserAssignAccountDummyDefault() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); @@ -1702,7 +1702,7 @@ public void test180ModifyUserAssignAccountDummyDefault() throws Exception { @Test public void test181ModifyUserFullName() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); @@ -1736,7 +1736,7 @@ public void test181ModifyUserFullName() throws Exception { @Test public void test182ModifyUserLocality() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); @@ -1767,7 +1767,7 @@ public void test182ModifyUserLocality() throws Exception { @Test public void test183ModifyAccountLocation() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); @@ -1812,7 +1812,7 @@ public void test183ModifyAccountLocation() throws Exception { @Test public void test184ModifyAccountLocationReplaceEmpty() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); @@ -1851,7 +1851,7 @@ public void test184ModifyAccountLocationReplaceEmpty() throws Exception { @Test public void test185ModifyAccountLocationDelete() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); @@ -1890,7 +1890,7 @@ public void test185ModifyAccountLocationDelete() throws Exception { @Test public void test188ModifyUserRename() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); @@ -1922,7 +1922,7 @@ public void test188ModifyUserRename() throws Exception { @Test public void test189ModifyUserUnassignAccountDummy() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); @@ -2018,7 +2018,7 @@ private void assertAccount(PrismObject userJack, String expectedFullNa @Test public void test200ModifyUserAssignAccountDummyCrimson() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -2049,7 +2049,7 @@ public void test200ModifyUserAssignAccountDummyCrimson() throws Exception { @Test public void test202NativeModifyDummyCrimsonThenReconcile() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); @@ -2090,7 +2090,7 @@ public void test202NativeModifyDummyCrimsonThenReconcile() throws Exception { @Test public void test204DummyCrimsonReconcile() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); @@ -2133,7 +2133,7 @@ public void test204DummyCrimsonReconcile() throws Exception { @Test public void test206DummyCrimsonReconcileIOError() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); @@ -2182,7 +2182,7 @@ public void test206DummyCrimsonReconcileIOError() throws Exception { @Test public void test208DummyCrimsonReconcileAgain() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); getDummyResource(RESOURCE_DUMMY_CRIMSON_NAME).resetBreakMode(); @@ -2225,7 +2225,7 @@ public void test208DummyCrimsonReconcileAgain() throws Exception { @Test public void test210ModifyUserLocality() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); getDummyResource(RESOURCE_DUMMY_CRIMSON_NAME).resetBreakMode(); @@ -2268,7 +2268,7 @@ public void test210ModifyUserLocality() throws Exception { @Test public void test212ModifyUserLocalityRecon() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); getDummyResource(RESOURCE_DUMMY_CRIMSON_NAME).resetBreakMode(); @@ -2315,7 +2315,7 @@ public void test212ModifyUserLocalityRecon() throws Exception { @Test public void test214ModifyUserLocalityIOError() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); getDummyResource(RESOURCE_DUMMY_CRIMSON_NAME).resetBreakMode(); @@ -2365,7 +2365,7 @@ public void test214ModifyUserLocalityIOError() throws Exception { @Test public void test220NativeModifyDummyCrimsonThenChangePassword() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); getDummyResource(RESOURCE_DUMMY_CRIMSON_NAME).resetBreakMode(); @@ -2416,7 +2416,7 @@ public void test220NativeModifyDummyCrimsonThenChangePassword() throws Exception @Test public void test229ModifyUserUnassignAccountDummyCrimson() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -2442,7 +2442,7 @@ public void test229ModifyUserUnassignAccountDummyCrimson() throws Exception { @Test public void test250ModifyUserAssignAccountDummyLightCrimson() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // preconditions @@ -2479,7 +2479,7 @@ public void test250ModifyUserAssignAccountDummyLightCrimson() throws Exception { @Test public void test252NativeModifyDummyLightCrimsonThenReconcile() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); @@ -2520,7 +2520,7 @@ public void test252NativeModifyDummyLightCrimsonThenReconcile() throws Exception @Test public void test254DummyLightCrimsonReconcile() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); @@ -2564,7 +2564,7 @@ public void test254DummyLightCrimsonReconcile() throws Exception { @Test public void test256DummyLightCrimsonReconcileIOError() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); @@ -2613,7 +2613,7 @@ public void test256DummyLightCrimsonReconcileIOError() throws Exception { @Test public void test258DummyLightCrimsonReconcileAgain() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); getDummyResource(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME).resetBreakMode(); @@ -2656,7 +2656,7 @@ public void test258DummyLightCrimsonReconcileAgain() throws Exception { @Test public void test260ModifyUserLocality() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); getDummyResource(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME).resetBreakMode(); @@ -2699,7 +2699,7 @@ public void test260ModifyUserLocality() throws Exception { @Test public void test262ModifyUserLocalityRecon() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); getDummyResource(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME).resetBreakMode(); @@ -2746,7 +2746,7 @@ public void test262ModifyUserLocalityRecon() throws Exception { @Test public void test264ModifyUserLocalityIOError() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); getDummyResource(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME).resetBreakMode(); @@ -2796,7 +2796,7 @@ public void test264ModifyUserLocalityIOError() throws Exception { @Test public void test270NativeModifyDummyLightCrimsonThenChangePassword() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); getDummyResource(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME).resetBreakMode(); @@ -2847,7 +2847,7 @@ public void test270NativeModifyDummyLightCrimsonThenChangePassword() throws Exce @Test public void test279ModifyUserUnassignAccountDummyLightCrimson() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -2877,7 +2877,7 @@ public void test279ModifyUserUnassignAccountDummyLightCrimson() throws Exception @Test public void test300AssignGuybrushDummyYellow() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -2911,7 +2911,7 @@ public void test300AssignGuybrushDummyYellow() throws Exception { @Test public void test302ModifyGuybrushLocality() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -2939,7 +2939,7 @@ public void test302ModifyGuybrushLocality() throws Exception { @Test public void test309UnassignGuybrushDummyYellow() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -2964,7 +2964,7 @@ public void test309UnassignGuybrushDummyYellow() throws Exception { @Test public void test400ModifyUserAssignAccountDummyCrimsonCustomFunction() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -2990,7 +2990,7 @@ public void test400ModifyUserAssignAccountDummyCrimsonCustomFunction() throws Ex @Test public void test401ModifyUserLocalityDummyCrisomCustomFunction() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -3017,7 +3017,7 @@ public void test401ModifyUserLocalityDummyCrisomCustomFunction() throws Exceptio @Test public void test402ModifyDrinkDummyCustomFunctionCrimson() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -3052,7 +3052,7 @@ public void test402ModifyDrinkDummyCustomFunctionCrimson() throws Exception { @Test public void test420AssignAntinihilistToJack() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -3090,7 +3090,7 @@ public void test420AssignAntinihilistToJack() throws Exception { @Test public void test422AssignAccountAndAntinihilistToJack() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null); @@ -3121,7 +3121,7 @@ public void test422AssignAccountAndAntinihilistToJack() throws Exception { @Test public void test425UnassignAntinihilistFromJack() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -3150,7 +3150,7 @@ public void test425UnassignAntinihilistFromJack() throws Exception { @Test public void test427UnassignAccountFromJack() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -3203,7 +3203,7 @@ public void test500AssignmentsCombinationSingle() throws Exception { @Test public void test510AssignmentsCombinationCouple() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject jim = findUserByUsername(USER_JIM_NAME); @@ -3227,7 +3227,7 @@ public void test510AssignmentsCombinationCouple() throws Exception { @Test public void test520DeleteUserAssignment() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject jim = findUserByUsername(USER_JIM_NAME); @@ -3258,7 +3258,7 @@ public void test520DeleteUserAssignment() throws Exception { @Test public void test600AddService() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); final String PASSWORD = "pwd1234"; @@ -3288,7 +3288,7 @@ public void test600AddService() throws Exception { @Test public void test610ModifyServicePassword() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); final String NEW_PASSWORD = "dummy"; @@ -3325,7 +3325,7 @@ public void test610ModifyServicePassword() throws Exception { @Test public void test650ImportFromInboundPwdCopy() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); final String PASSWORD = "secret"; @@ -3377,7 +3377,7 @@ public void test660ImportFromInboundPwdCopyModifyPassword() throws Exception { @Test public void test670ImportFromInboundPwdGenerate() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); final String PASSWORD = "secret-gw"; @@ -3434,7 +3434,7 @@ public void test680ImportFromInboundPwdGenerateModifyPassword() throws Exception @Test public void test700TimedOutbound() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); UserType user = new UserType(prismContext) diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingAutoInbound.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingAutoInbound.java index 4e8fa32168a..66088642675 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingAutoInbound.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingAutoInbound.java @@ -14,7 +14,6 @@ import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType; @@ -67,7 +66,7 @@ public void test100ImportFromResource() throws Exception { final String TEST_NAME = "test100ImportFromResource"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyAccount accountHerman = new DummyAccount(USER_HERMAN_USERNAME); @@ -115,7 +114,7 @@ public void test110ModifyAccountTitleCraticAndReconcile() throws Exception { final String TEST_NAME = "test110ModifyAccountTitleCraticAndReconcile"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyAccount accountHerman = getDummyResource(RESOURCE_DUMMY_AUTOGREEN_NAME).getAccountByUsername(USER_HERMAN_USERNAME); @@ -143,7 +142,7 @@ public void test112ModifyAccountTitleDidacticGraphicAndReconcile() throws Except final String TEST_NAME = "test112ModifyAccountTitleDidacticGraphicAndReconcile"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyAccount accountHerman = getDummyResource(RESOURCE_DUMMY_AUTOGREEN_NAME).getAccountByUsername(USER_HERMAN_USERNAME); @@ -175,7 +174,7 @@ public void test200ImportFromResourceAssociations() throws Exception { assumeResourceAssigmentPolicy(RESOURCE_DUMMY_AUTOGREEN_OID, AssignmentPolicyEnforcementType.RELATIVE, false); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyGroup dummyGroup = new DummyGroup(GROUP_DUMMY_TESTERS_NAME); @@ -223,7 +222,7 @@ public void test300ModifyAccountDirectAssign() throws Exception { final String TEST_NAME = "test300ModifyAccountDirectAssign"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -252,7 +251,7 @@ public void test301removeUserFromAutoGroup() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyGroup craticGroup = getDummyResource(RESOURCE_DUMMY_AUTOGREEN_NAME).getGroupByName(GROUP_DUMMY_CRATIC_NAME); @@ -304,7 +303,7 @@ public void test402assignAutoGroupDirectly() throws Exception { assertDummyGroupMember(RESOURCE_DUMMY_AUTOGREEN_NAME, GROUP_DUMMY_TESTERS_NAME, USER_HERMAN_USERNAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -337,7 +336,7 @@ public void test403removeAllAssignments() throws Exception { DummyAccount hermanAccount = getDummyAccount(RESOURCE_DUMMY_AUTOGREEN_NAME, USER_HERMAN_USERNAME); hermanAccount.removeAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, Arrays.asList("graphic", "cratic")); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -368,7 +367,7 @@ public void test404importAssociationAutotesters() throws Exception { testersGroup.addMember(USER_HERMAN_USERNAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -398,7 +397,7 @@ public void test405assignRoleAutocraticDirectly() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -426,7 +425,7 @@ public void test406unassignRoleAutocraticDirectly() throws Exception { assumeResourceAssigmentPolicy(RESOURCE_DUMMY_AUTOGREEN_OID, AssignmentPolicyEnforcementType.FULL, true); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -457,7 +456,7 @@ public void test407addHermanToTestersReconcile() throws Exception { craticGroup.addMember(USER_HERMAN_USERNAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingInbound.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingInbound.java index b9625946651..46872bffd89 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingInbound.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingInbound.java @@ -94,7 +94,7 @@ public void test010SanitySchema() throws Exception { final String TEST_NAME = "test010SanitySchema"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); /// WHEN displayWhen(TEST_NAME); @@ -121,7 +121,7 @@ public void test100ImportLiveSyncTaskDummyTeaGreen() throws Exception { final String TEST_NAME = "test100ImportLiveSyncTaskDummyTeaGreen"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); /// WHEN @@ -139,7 +139,7 @@ public void test110AddDummyTeaGreenAccountMancomb() throws Exception { final String TEST_NAME = "test110AddDummyTeaGreenAccountMancomb"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Preconditions @@ -200,7 +200,7 @@ public void test120ModifyMancombPhotoSource() throws Exception { final String TEST_NAME = "test120ModifyMancombPhotoSource"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); /// WHEN @@ -235,7 +235,7 @@ public void test130ModifyMancombPhotoSourceAndReconcile() throws Exception { final String TEST_NAME = "test130ModifyMancombPhotoSourceAndReconcile"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); /// WHEN @@ -274,7 +274,7 @@ public void test140ModifyMancombPhotoInRepo() throws Exception { final String TEST_NAME = "test140ModifyMancombPhotoInRepo"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); /// WHEN @@ -310,7 +310,7 @@ public void test150UserReconcile() throws Exception { final String TEST_NAME = "test150UserReconcile"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -368,7 +368,7 @@ public void test300DeleteDummyTeaGreenAccountMancomb() throws Exception { final String TEST_NAME = "test300DeleteDummyTeaGreenAccountMancomb"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); /// WHEN @@ -406,7 +406,7 @@ public void test399DeleteDummyTeaGreenAccountMancomb() throws Exception { final String TEST_NAME = "test399DeleteDummyTeaGreenAccountMancomb"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); /// WHEN @@ -424,7 +424,7 @@ public void test400AddUserLeeloo() throws Exception { final String TEST_NAME = "test400AddUserLeeloo"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -477,7 +477,7 @@ public void test402UserLeelooRecompute() throws Exception { final String TEST_NAME = "test402UserLeelooRecompute"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -510,7 +510,7 @@ public void test404UserLeelooReconcile() throws Exception { final String TEST_NAME = "test404UserLeelooReconcile"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -547,7 +547,7 @@ public void test410UserLeeloominaiReconcile() throws Exception { final String TEST_NAME = "test410UserLeeloominaiReconcile"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyAccount account = getDummyResource(RESOURCE_DUMMY_TEA_GREEN_NAME).getAccountByUsername(ACCOUNT_LEELOO_USERNAME); @@ -589,7 +589,7 @@ public void test412UserLeeloominaiRecompute() throws Exception { final String TEST_NAME = "test412UserLeeloominaiRecompute"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -622,7 +622,7 @@ public void test414UserLeeloominaiReconcile() throws Exception { final String TEST_NAME = "test414UserLeeloominaiReconcile"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -659,7 +659,7 @@ public void test420UserLeelooStrangeReconcile() throws Exception { final String TEST_NAME = "test420UserLeelooStrangeReconcile"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyAccount account = getDummyResource(RESOURCE_DUMMY_TEA_GREEN_NAME).getAccountByUsername(ACCOUNT_LEELOO_USERNAME); @@ -702,7 +702,7 @@ public void test424UserLeelooStrangeReconcile() throws Exception { final String TEST_NAME = "test424UserLeelooStrangeReconcile"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestMisc.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestMisc.java index 70160b9ceff..6e94312fd0a 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestMisc.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestMisc.java @@ -94,7 +94,7 @@ public void test100GetRepositoryDiag() throws Exception { final String TEST_NAME = "test100GetRepositoryDiag"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -116,7 +116,7 @@ public void test110RepositorySelfTest() throws Exception { final String TEST_NAME = "test110RepositorySelfTest"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); // WHEN displayWhen(TEST_NAME); @@ -135,7 +135,7 @@ public void test200ExportUsers() throws Exception { final String TEST_NAME = "test200ExportUsers"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -177,7 +177,7 @@ public void test210SearchUsersMatchingRulesPolystringNorm() throws Exception { final String TEST_NAME = "test210SearchUsersMatchingRulesPolystringNorm"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = queryFor(UserType.class) @@ -210,7 +210,7 @@ public void test212SearchUsersMatchingRulesPolystringIgnoreCase() throws Excepti final String TEST_NAME = "test212SearchUsersMatchingRulesPolystringIgnoreCase"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = queryFor(UserType.class) @@ -239,7 +239,7 @@ public void test214SearchUsersMatchingRulesStringIgnoreCase() throws Exception { final String TEST_NAME = "test214SearchUsersMatchingRulesStringIgnoreCase"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = queryFor(UserType.class) @@ -272,7 +272,7 @@ public void test216SearchUsersMatchingRulesStringNorm() throws Exception { final String TEST_NAME = "test216SearchUsersMatchingRulesStringNorm"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = queryFor(UserType.class) @@ -301,7 +301,7 @@ public void test300RecomputeJack() throws Exception { final String TEST_NAME = "test300RecomputeJack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -325,7 +325,7 @@ public void test302UpdateKeyJack() throws Exception { final String TEST_NAME = "test302UpdateKeyJack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -346,7 +346,7 @@ public void test310AddUserClean() throws Exception { final String TEST_NAME = "test310AddUserClean"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = createUser(USER_CLEAN_NAME, USER_CLEAN_GIVEN_NAME, USER_CLEAN_FAMILY_NAME, true); @@ -374,7 +374,7 @@ public void test312UpdateBinaryIdClean() throws Exception { final String TEST_NAME = "test312UpdateBinaryIdClean"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -397,7 +397,7 @@ public void test312UpdateBinaryIdClean() throws Exception { public void test320DefaultRelations() throws Exception { final String TEST_NAME="test320DefaultRelations"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -420,7 +420,7 @@ public void test400ImportRoleWithFilters() throws Exception { final String TEST_NAME = "test400ImportRoleWithFilters"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -444,7 +444,7 @@ public void test500AddHocProvisioningScriptAssignJackResourceScripty() throws Ex final String TEST_NAME = "test500AddHocProvisioningScriptAssignJackResourceScripty"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -477,7 +477,7 @@ public void test502GetAccountJackResourceScripty() throws Exception { final String TEST_NAME = "test502GetAccountJackResourceScripty"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -509,7 +509,7 @@ public void test504GetAccountJackResourceScriptyAgain() throws Exception { final String TEST_NAME = "test504GetAccountJackResourceScriptyAgain"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -546,7 +546,7 @@ public void test506ModifyResourceGetAccountJackResourceScripty() throws Exceptio final String TEST_NAME = "test506ModifyResourceGetAccountJackResourceScripty"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -590,7 +590,7 @@ public void test600jackAssignRoleShip() throws Exception { final String TEST_NAME = "test600jackAssignRoleShip"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); @@ -619,7 +619,7 @@ public void test601jackUnassignResourceAccount() throws Exception { final String TEST_NAME = "test601jackUnassignResourceAccount"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -649,7 +649,7 @@ public void test602jackUnssigndRoleShip() throws Exception { final String TEST_NAME = "test602jackUnssigndRoleShip"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestUuidNonUniqueName.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestUuidNonUniqueName.java index c942c450f17..3b7718a0a1e 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestUuidNonUniqueName.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestUuidNonUniqueName.java @@ -12,42 +12,20 @@ import static org.testng.AssertJUnit.assertEquals; import java.io.File; -import java.util.List; - -import javax.xml.transform.dom.DOMSource; -import javax.xml.validation.Schema; -import javax.xml.validation.Validator; - -import com.evolveum.midpoint.prism.PrismContext; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import org.w3c.dom.Document; import com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest; -import com.evolveum.midpoint.prism.Objectable; import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.PrismReference; -import com.evolveum.midpoint.prism.util.PrismAsserts; -import com.evolveum.midpoint.schema.GetOperationOptions; -import com.evolveum.midpoint.schema.RepositoryDiag; -import com.evolveum.midpoint.schema.SelectorOptions; import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.schema.util.ShadowUtil; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; -import com.evolveum.midpoint.test.DummyResourceContoller; -import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.RelationDefinitionType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; /** * Test with a resource that has unique primary identifier (ConnId UID), but non-unique secondary @@ -91,7 +69,7 @@ public void test010TestResourceConnection() throws Exception { final String TEST_NAME = "test010TestResourceConnection"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); // WHEN displayWhen(TEST_NAME); @@ -111,7 +89,7 @@ public void test020RefinedSchema() throws Exception { final String TEST_NAME = "test020RefinedSchema"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -145,7 +123,7 @@ public void test100AssignAccountToJackSparrow() throws Exception { final String TEST_NAME = "test100AssignAccountToJackSparrow"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -177,7 +155,7 @@ public void test102GetAccountJackSparrow() throws Exception { final String TEST_NAME = "test102GetAccountJackSparrow"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); String accountJackSparrowOid = assertUserBefore(USER_JACK_OID) @@ -209,7 +187,7 @@ public void test110AssignAccountToJackSkellington() throws Exception { final String TEST_NAME = "test110AssignAccountToJackSkellington"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertEquals(USER_SKELLINGTON_GIVEN_NAME, USER_JACK_GIVEN_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiAccount.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiAccount.java index aed70a48c4b..17c822c2448 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiAccount.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiAccount.java @@ -26,7 +26,6 @@ import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; @@ -94,7 +93,8 @@ public void test010ImportAccountsFromDummyMultiGreen() throws Exception { final String TEST_NAME = "test010ImportAccountsFromDummyMultiGreen"; // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // Preconditions @@ -119,7 +119,8 @@ public void test020ImportPaulAtreides() throws Exception { final String TEST_NAME = "test020ImportPaulAtreides"; // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyAccount account = new DummyAccount(ACCOUNT_PAUL_ATREIDES_USERNAME); @@ -163,7 +164,8 @@ public void test100ImportMuadDib() throws Exception { final String TEST_NAME = "test100ImportMuadDib"; // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyAccount account = new DummyAccount(ACCOUNT_MUAD_DIB_USERNAME); @@ -217,7 +219,8 @@ public void test102ReconcileUserPaul() throws Exception { final String TEST_NAME = "test102ReconcileUserPaul"; // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); userPaulOid = findUserByUsername(ACCOUNT_PAUL_ATREIDES_USERNAME).getOid(); @@ -269,7 +272,8 @@ public void test200ImportDuke() throws Exception { final String TEST_NAME = "test200ImportDuke"; // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyAccount account = new DummyAccount(ACCOUNT_DUKE_USERNAME); @@ -336,7 +340,8 @@ public void test210ImportMahdi() throws Exception { final String TEST_NAME = "test210ImportMahdi"; // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyAccount account = new DummyAccount(ACCOUNT_MAHDI_USERNAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiConnectorResources.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiConnectorResources.java index 635dfb6779c..14c0d929d51 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiConnectorResources.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiConnectorResources.java @@ -70,7 +70,7 @@ public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); // WHEN OperationResult testResult = modelService.testResource(RESOURCE_DUMMY_OPALINE_OID, task); @@ -89,7 +89,7 @@ public void test100JackAssignDummyOpaline() throws Exception { final String TEST_NAME = "test100JackAssignDummyOpaline"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiResource.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiResource.java index 5b33902fe41..6b7c7173395 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiResource.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiResource.java @@ -33,7 +33,6 @@ import com.evolveum.midpoint.schema.result.OperationResultStatus; import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.asserter.UserAsserter; import com.evolveum.midpoint.test.util.TestUtil; @@ -241,7 +240,7 @@ public void test120JackAssignRoleDummiesRelative() throws Exception { getDummyResource().resetBreakMode(); // Clean up user - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result); @@ -260,7 +259,7 @@ public void test121JackTryDeleteAccount() throws Exception { getDummyResource().resetBreakMode(); // Clean up user - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userJack = getUser(USER_JACK_OID); String accountJackDummyOid = getLinkRefOid(userJack, RESOURCE_DUMMY_OID); @@ -302,7 +301,7 @@ public void test200JackAssignDummyIvory() throws Exception { final String TEST_NAME = "test200JackAssignDummyIvory"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -336,7 +335,7 @@ public void test209JackUnAssignDummyIvory() throws Exception { final String TEST_NAME = "test209JackUnAssignDummyIvory"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -368,7 +367,7 @@ public void test210JackAssignDummyBeige() throws Exception { final String TEST_NAME = "test210JackAssignDummyBeige"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -405,7 +404,7 @@ public void test219JackUnAssignDummyBeige() throws Exception { final String TEST_NAME = "test219JackUnAssignDummyBeige"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -439,7 +438,7 @@ public void test220JackAssignDummyBeigeAndDefault() throws Exception { final String TEST_NAME = "test220JackAssignDummyBeigeAndDefault"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -477,7 +476,7 @@ public void test221JackRecompute() throws Exception { final String TEST_NAME = "test221JackRecompute"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -510,7 +509,7 @@ public void test223JackKillDefaultDummyAccounAndRecompute() throws Exception { final String TEST_NAME = "test223JackKillDefaultDummyAccounAndRecompute"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); getDummyResource().deleteAccountByName(ACCOUNT_JACK_DUMMY_USERNAME); @@ -548,7 +547,7 @@ public void test224JackKillBeigeAccounAndRecompute() throws Exception { final String TEST_NAME = "test224JackKillBeigeAccounAndRecompute"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); getDummyResource(RESOURCE_DUMMY_BEIGE_NAME).deleteAccountByName(ACCOUNT_JACK_DUMMY_USERNAME); @@ -606,7 +605,7 @@ public void test225ForceDeleteDeadShadow() throws Exception { final String TEST_NAME = "test225ForceDeleteDeadShadow"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); String deadBeigeShadowOid = assertUserBefore(USER_JACK_OID) @@ -660,7 +659,7 @@ public void test226JackKillBothAccountsAndRecompute() throws Exception { final String TEST_NAME = "test226JackKillBothAccountsAndRecompute"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertUserBefore(USER_JACK_OID) @@ -866,7 +865,7 @@ public void test229JackUnassignDummyBeigeAndDefault() throws Exception { final String TEST_NAME = "test229JackUnassignDummyBeigeAndDefault"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); getDummyResource().resetBreakMode(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -916,7 +915,7 @@ public void test250JackAssignDummyLavender() throws Exception { final String TEST_NAME = "test250JackAssignDummyLavender"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -951,7 +950,7 @@ public void test250JackAssignDummyLavender() throws Exception { */ public void jackAssignRoleDummies(final String TEST_NAME) throws Exception { - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clearJackOrganizationalUnit(task, result); @@ -1005,7 +1004,7 @@ public void jackAssignRoleDummies(final String TEST_NAME) throws Exception { public void jackRename(final String TEST_NAME) throws Exception { - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); jackRename(TEST_NAME, "jackie", "Jackie Sparrow", task, result); @@ -1062,7 +1061,7 @@ public void jackRename(final String TEST_NAME, String toName, String toFullName, public void jackUnAssignRoleDummies(final String TEST_NAME) throws Exception { - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); List linkOidsBefore = assertUserBefore(USER_JACK_OID) @@ -1100,7 +1099,7 @@ public void jackUnAssignRoleDummies(final String TEST_NAME) throws Exception { public void jackAssignRoleDummiesError(final String TEST_NAME, String roleOid, String dummyResourceName, boolean expectAccount) throws Exception { - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clearJackOrganizationalUnit(task, result); @@ -1143,7 +1142,7 @@ private void clearJackOrganizationalUnit(Task task, OperationResult result) thro public void jackUnassignRoleDummiesError(final String TEST_NAME, String roleOid, String otherResourceOid) throws Exception { - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); UserAsserter userBeforeAsserter = assertUserBefore(USER_JACK_OID); @@ -1219,7 +1218,7 @@ public void test300AddAndAssignRelative() throws Exception { final String TEST_NAME = "test300AddAndAssignRelative"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Add default dummy account to jack without assigning it. @@ -1278,7 +1277,7 @@ public void test310AddedAccountAndUnassignRelative() throws Exception { final String TEST_NAME = "test310AddedAccountAndUnassignRelative"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1318,7 +1317,7 @@ public void test319UnassignDummyRelative() throws Exception { final String TEST_NAME = "test319UnassignDummyRelative"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1353,7 +1352,7 @@ public void test350AddAccountLavender() throws Exception { final String TEST_NAME = "test350AddAccountLavender"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserAddDummyAccount(USER_JACK_OID, RESOURCE_DUMMY_LAVENDER_NAME); @@ -1383,7 +1382,7 @@ public void test352AddAccountIvory() throws Exception { final String TEST_NAME = "test352AddAccountIvory"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserAddDummyAccount(USER_JACK_OID, RESOURCE_DUMMY_IVORY_NAME); @@ -1406,7 +1405,7 @@ public void test354AddAccountBeige() throws Exception { final String TEST_NAME = "test354AddAccountBeige"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserAddDummyAccount(USER_JACK_OID, RESOURCE_DUMMY_BEIGE_NAME); @@ -1429,7 +1428,7 @@ public void test360AddAccountDummy() throws Exception { final String TEST_NAME = "test360AddAccountDummy"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserAddAccount(USER_JACK_OID, getDummyResourceObject()); @@ -1455,7 +1454,7 @@ public void test362AddAccountLavender() throws Exception { final String TEST_NAME = "test362AddAccountLavender"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserAddDummyAccount(USER_JACK_OID, RESOURCE_DUMMY_LAVENDER_NAME); @@ -1481,7 +1480,7 @@ public void test370DeleteAccountDummy() throws Exception { final String TEST_NAME = "test370DeleteAccountDummy"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserDeleteAccount(USER_JACK_OID, getDummyResourceObject()); @@ -1517,7 +1516,7 @@ public void test372UnlinkAccountDummy() throws Exception { final String TEST_NAME = "test372UnlinkAccountDummy"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserUnlinkAccount(USER_JACK_OID, getDummyResourceObject()); @@ -1549,7 +1548,7 @@ public void test374DeleteAccountLavender() throws Exception { final String TEST_NAME = "test374DeleteAccountLavender"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserDeleteDummyAccount(USER_JACK_OID, RESOURCE_DUMMY_LAVENDER_NAME); @@ -1577,7 +1576,7 @@ public void test376DeleteAccountDummy() throws Exception { final String TEST_NAME = "test376DeleteAccountDummy"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserDeleteAccount(USER_JACK_OID, getDummyResourceObject()); @@ -1602,7 +1601,7 @@ public void test378DeleteAccountBeige() throws Exception { final String TEST_NAME = "test378DeleteAccountBeige"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserDeleteDummyAccount(USER_JACK_OID, RESOURCE_DUMMY_BEIGE_NAME); @@ -1628,7 +1627,7 @@ public void test379DeleteAccountIvory() throws Exception { final String TEST_NAME = "test379DeleteAccountIvory"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserDeleteDummyAccount(USER_JACK_OID, RESOURCE_DUMMY_IVORY_NAME); @@ -1659,7 +1658,7 @@ public void test380AddAccountPeru() throws Exception { // precondition assertEncryptedUserPassword(USER_JACK_OID, USER_JACK_PASSWORD); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserAddDummyAccount(USER_JACK_OID, RESOURCE_DUMMY_PERU_NAME); @@ -1681,7 +1680,7 @@ public void test382AddAccountYellow() throws Exception { final String TEST_NAME = "test382AddAccountYellow"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserAddDummyAccount(USER_JACK_OID, RESOURCE_DUMMY_YELLOW_NAME); @@ -1748,7 +1747,7 @@ public void test389DeleteAccountPeru() throws Exception { final String TEST_NAME = "test389DeleteAccountPeru"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserDeleteDummyAccount(USER_JACK_OID, RESOURCE_DUMMY_PERU_NAME); @@ -1776,7 +1775,7 @@ public void test400DavidAndGoliathAssignRole() throws Exception { // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = createUser(USER_WORLD_NAME, USER_WORLD_FULL_NAME, true); @@ -1861,7 +1860,7 @@ public void test401DavidAndGoliathModifyOu() throws Exception { // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_WORLD_NAME); @@ -1907,7 +1906,7 @@ public void test403DavidAndGoliathDisableUser() throws Exception { // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_WORLD_NAME); @@ -1945,7 +1944,7 @@ public void test404DavidAndGoliathEnableUser() throws Exception { // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_WORLD_NAME); @@ -1982,7 +1981,7 @@ public void test405DavidAndGoliathDisableAccountDavid() throws Exception { // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_WORLD_NAME); @@ -2021,7 +2020,7 @@ public void test406DavidAndGoliathRecompute() throws Exception { // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_WORLD_NAME); @@ -2050,7 +2049,7 @@ public void test408DavidAndGoliathEnableAccountDavid() throws Exception { // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_WORLD_NAME); @@ -2086,7 +2085,7 @@ public void test410DavidAndGoliathRename() throws Exception { // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_WORLD_NAME); @@ -2132,7 +2131,7 @@ public void test419DavidAndGoliathUnassignRole() throws Exception { // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_FIELD_NAME); @@ -2175,7 +2174,7 @@ public void test420DavidAndGoliathAssignRoleGoliathDown() throws Exception { // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_FIELD_NAME); @@ -2255,7 +2254,7 @@ public void test421DavidAndGoliathAssignRoleGoliathUpRecompute() throws Exceptio getDummyResource(RESOURCE_DUMMY_GOLIATH_NAME).resetBreakMode(); dummyAuditService.clear(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_FIELD_NAME); @@ -2311,7 +2310,7 @@ public void test422DavidAndGoliathAssignRoleGoliathUpRecompute() throws Exceptio clockForward("PT1H"); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_FIELD_NAME); @@ -2362,7 +2361,7 @@ public void test423DavidAndGoliathAssignRoleGoliathUpReconcile() throws Exceptio getDummyResource(RESOURCE_DUMMY_GOLIATH_NAME).resetBreakMode(); dummyAuditService.clear(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_FIELD_NAME); @@ -2391,7 +2390,7 @@ public void test428DavidAndGoliathUnassignRole() throws Exception { getDummyResource(RESOURCE_DUMMY_GOLIATH_NAME).resetBreakMode(); dummyAuditService.clear(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_FIELD_NAME); @@ -2447,7 +2446,7 @@ public void test429ExpireDeadShadow() throws Exception { clockForward("P10D"); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -2476,7 +2475,7 @@ public void test430DavidAndGoliathAssignRoleDavidDown() throws Exception { // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_FIELD_NAME); @@ -2539,7 +2538,7 @@ public void test440DavidAndGoliathAssignRoleAndCreateUserInOneStep() throws Exce getDummyResource(RESOURCE_DUMMY_GOLIATH_NAME).resetBreakMode(); getDummyResource(RESOURCE_DUMMY_DAVID_NAME).resetBreakMode(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // delete user and his roles which were added before @@ -2622,7 +2621,7 @@ public void test500PrepareJack() throws Exception { final String TEST_NAME = "test500PrepareJack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -2657,7 +2656,7 @@ public void test501JackAssignDummyDarkYellow() throws Exception { final String TEST_NAME = "test501JackAssignDummyDarkYellow"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -2687,7 +2686,7 @@ public void test502JackAssignDummyDarkPeru() throws Exception { final String TEST_NAME = "test502JackAssignDummyDarkPeru"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -2718,7 +2717,7 @@ public void test504JackUnassignDummyDarkPeru() throws Exception { final String TEST_NAME = "test504JackUnassignDummyDarkPeru"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -2746,7 +2745,7 @@ public void test507JackUnassignDummyDarkYellow() throws Exception { final String TEST_NAME = "test507JackUnassignDummyDarkYellow"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -2774,7 +2773,7 @@ public void test508JackDeleteDummyDarkYellowAccount() throws Exception { final String TEST_NAME = "test508JackDeleteDummyDarkYellowAccount"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -2802,7 +2801,7 @@ public void test509JackDeleteDummyDarkPeruAccount() throws Exception { final String TEST_NAME = "test509JackDeleteDummyDarkPeruAccount"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -2830,7 +2829,7 @@ public void test510JackAssignRoleDarkYellowPeru() throws Exception { final String TEST_NAME = "test510JackAssignRoleDarkYellowPeru"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -2866,7 +2865,7 @@ public void test519JackUnassignDarkRoleYellowPeru() throws Exception { final String TEST_NAME = "test519JackUnassignDarkRoleYellowPeru"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -2894,7 +2893,7 @@ public void test520JackAssignRoleDarkYellowPeru() throws Exception { final String TEST_NAME = "test520JackAssignRoleDarkYellowPeru"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -2930,7 +2929,7 @@ public void test529JackUnassignRoleDarkYellowPeru() throws Exception { final String TEST_NAME = "test529JackUnassignRoleDarkYellowPeru"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestAssignmentErrors.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestAssignmentErrors.java index 96601193d4c..5250db08b21 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestAssignmentErrors.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestAssignmentErrors.java @@ -167,7 +167,7 @@ public void test100UserJackAssignBlankAccount() throws Exception { final String TEST_NAME = "test100UserJackAssignBlankAccount"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -209,7 +209,7 @@ public void test101AddUserCharlesAssignBlankAccount() throws Exception { final String TEST_NAME = "test101AddUserCharlesAssignBlankAccount"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -251,7 +251,7 @@ public void test200UserLemonheadAssignAccountBrokenNetwork() throws Exception { final String TEST_NAME = "test200UserLemonheadAssignAccountBrokenNetwork"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -329,7 +329,7 @@ public void test210UserSharptoothAssignAccountBrokenGeneric() throws Exception { final String TEST_NAME = "test210UserSharptoothAssignAccountBrokenGeneric"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -398,7 +398,7 @@ public void test212UserSharptoothAssignAccountRecovery() throws Exception { final String TEST_NAME = "test212UserSharptoothAssignAccountRecovery"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -471,7 +471,7 @@ public void test215UserSharptoothChangePasswordGenericError() throws Exception { public void testUserSharptoothChangePasswordError(final String TEST_NAME, BreakMode breakMode, String oldPassword, String newPassword, OperationResultStatus expectedResultStatus) throws Exception { // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -511,7 +511,7 @@ public void test220UserAssignAccountDeletedShadowRecomputeSync() throws Exceptio PrismObject user = setupUserAssignAccountDeletedShadowRecompute(TEST_NAME, RESOURCE_DUMMY_OID, null, USER_AFET_NAME, USER_AFET_FULLNAME); String shadowOidBefore = getSingleLinkOid(user); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -533,7 +533,7 @@ public void test220UserAssignAccountDeletedShadowRecomputeSync() throws Exceptio // ... and again ... - task = createTask(TEST_NAME); + task = getTestTask(); result = task.getResult(); // WHEN @@ -623,7 +623,7 @@ public void test224UserAssignAccountDeletedShadowRecomputeReducedSync() throws E RESOURCE_DUMMY_YELLOW_OID, RESOURCE_DUMMY_YELLOW_NAME, USER_CFET_NAME, USER_CFET_FULLNAME); String shadowOidBefore = getSingleLinkOid(user); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -645,7 +645,7 @@ public void test224UserAssignAccountDeletedShadowRecomputeReducedSync() throws E // ... and again ... - task = createTask(TEST_NAME); + task = getTestTask(); result = task.getResult(); // WHEN @@ -669,7 +669,7 @@ private PrismObject setupUserAssignAccountDeletedShadowRecompute(final String dummyResourceName, String userName, String userFullName) throws Exception { // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); getDummyResource().resetBreakMode(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestBrokenResources.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestBrokenResources.java index 1bf59ea038e..ebd35b71994 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestBrokenResources.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestBrokenResources.java @@ -168,7 +168,7 @@ public void test010TestResourceBroken() throws Exception { final String TEST_NAME = "test010TestResourceBroken"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -184,7 +184,7 @@ public void test020GetResourceBroken() throws Exception { final String TEST_NAME = "test020GetResourceBroken"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -214,7 +214,7 @@ public void test100GetAccountMurray() throws Exception { final String TEST_NAME = "test100GetAccountMurray"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); try { @@ -240,7 +240,7 @@ public void test101GetAccountMurrayNoFetch() throws Exception { final String TEST_NAME = "test101GetAccountMurrayNoFetch"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch()); @@ -399,7 +399,7 @@ public void test320GetResourceNoJars() throws Exception { final String TEST_NAME = "test320GetResourceNoJars"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -424,7 +424,7 @@ public void test350AddResourceWrongConnectorOid() throws Exception { final String TEST_NAME = "test350AddResourceWrongConnectorOid"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject resource = PrismTestUtil.parseObject(RESOURCE_DUMMY_WRONG_CONNECTOR_OID_FILE); @@ -455,7 +455,7 @@ public void test352AddResourceWrongConnectorOidRaw() throws Exception { final String TEST_NAME = "test352AddResourceWrongConnectorOidRaw"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject resource = PrismTestUtil.parseObject(RESOURCE_DUMMY_WRONG_CONNECTOR_OID_FILE); @@ -487,7 +487,7 @@ public void test355AddResourceWrongConnectorOidRepo() throws Exception { final String TEST_NAME = "test355AddResourceWrongConnectorOidRepo"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject resource = PrismTestUtil.parseObject(RESOURCE_DUMMY_WRONG_CONNECTOR_OID_FILE); @@ -505,7 +505,7 @@ public void test358GetResourceWrongConnectorOid() throws Exception { final String TEST_NAME = "test358GetResourceWrongConnectorOid"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -530,7 +530,7 @@ public void test359DeleteResourceWrongConnectorOid() throws Exception { final String TEST_NAME = "test359DeleteResourceWrongConnectorOid"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object() @@ -554,7 +554,7 @@ public void test360AddResourceNoConfiguration() throws Exception { final String TEST_NAME = "test360AddResourceNoConfiguration"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject resource = PrismTestUtil.parseObject(RESOURCE_DUMMY_NO_CONFIGURATION_FILE); @@ -577,7 +577,7 @@ public void test362GetResourceNoConfiguration() throws Exception { final String TEST_NAME = "test362GetResourceNoConfiguration"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -608,7 +608,7 @@ public void test369DeleteResourceNoConfiguration() throws Exception { final String TEST_NAME = "test369DeleteResourceNoConfiguration"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object() @@ -637,7 +637,7 @@ public void test371ImportUnaccessibleResource() throws Exception { final String TEST_NAME = "test371ImportUnaccessibleResource"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -657,7 +657,7 @@ public void test372GetUnaccessibleResourceNoFetch() throws Exception { final String TEST_NAME = "test372GetUnaccessibleResourceNoFetch"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberCounter(InternalCounters.RESOURCE_SCHEMA_FETCH_COUNT); @@ -715,7 +715,7 @@ public void test375ListResources() throws Exception { public void testListResources(final String TEST_NAME, int expectedNumber, Collection> options) throws Exception { // GIVEN (1) - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN (1) @@ -736,7 +736,7 @@ public void testListResources(final String TEST_NAME, int expectedNumber, Collec // GIVEN (2) resources.clear(); - task = createTask(TEST_NAME); + task = getTestTask(); result = task.getResult(); ResultHandler handler = new ResultHandler() { @@ -770,7 +770,7 @@ public void test377GetResourceNoConfiguration() throws Exception { final String TEST_NAME = "test377GetResourceNoConfiguration"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -802,7 +802,7 @@ public void test400AssignTwoResouresNotFound() throws Exception { final String TEST_NAME = "test400AssignTwoResoures"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -833,7 +833,7 @@ public void test401AssignTwoResouresBroken() throws Exception { final String TEST_NAME = "test401AssignTwoResouresBroken"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -876,7 +876,7 @@ public void test500AssignResourceBlack() throws Exception { final String TEST_NAME = "test500AssignResourceBlack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest5xx(); @@ -913,7 +913,7 @@ public void test502ModifyUserEmployeeNumberNone() throws Exception { final String TEST_NAME = "test502ModifyUserEmployeeNumberNone"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest5xx(); @@ -945,7 +945,7 @@ public void test509UnassignResourceBlack() throws Exception { final String TEST_NAME = "test509UnassignResourceBlack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest5xx(); @@ -977,7 +977,7 @@ public void test510AssignResourceBlackError() throws Exception { final String TEST_NAME = "test510AssignResourceBlackError"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest5xx(); @@ -1023,7 +1023,7 @@ public void test512ReconcileUser() throws Exception { final String TEST_NAME = "test512ReconcileUser"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest5xx(); @@ -1054,7 +1054,7 @@ public void test514ModifyUserEmployeeNumberRuntime() throws Exception { final String TEST_NAME = "test514ModifyUserEmployeeNumberRuntime"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest5xx(); @@ -1094,7 +1094,7 @@ public void test518UnassignResourceBlack() throws Exception { final String TEST_NAME = "test518UnassignResourceBlack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest5xx(); @@ -1135,7 +1135,7 @@ public void test519ReconcileUser() throws Exception { final String TEST_NAME = "test519ReconcileUser"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest5xx(); @@ -1165,7 +1165,7 @@ public void test520AssignResourceEbonyError() throws Exception { final String TEST_NAME = "test520AssignResourceEbonyError"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest5xx(); @@ -1205,7 +1205,7 @@ public void test524ModifyUserEmployeeNumberRuntime() throws Exception { final String TEST_NAME = "test524ModifyUserEmployeeNumberRuntime"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest5xx(); @@ -1237,7 +1237,7 @@ public void test528UnassignResourceEbony() throws Exception { final String TEST_NAME = "test528UnassignResourceEbony"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest5xx(); @@ -1289,7 +1289,7 @@ public void test600GuybrushAssignAccountDummyViolet() throws Exception { final String TEST_NAME = "test600GuybrushAssignAccountDummyViolet"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStruct.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStruct.java index 6a1b1d5f34e..5e460cf2937 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStruct.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStruct.java @@ -143,7 +143,7 @@ public void test052RootOrgQuery() throws Exception { final String TEST_NAME = "test052RootOrgQuery"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createRootOrgQuery(prismContext); @@ -162,7 +162,7 @@ public void test052RootOrgQuery() throws Exception { public void test100JackAssignOrgtarget() throws Exception { final String TEST_NAME = "test100JackAssignOrgtarget"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Precondition @@ -190,7 +190,7 @@ public void test100JackAssignOrgtarget() throws Exception { public void test101JackAssignScummBar() throws Exception { final String TEST_NAME = "test101JackAssignScummBar"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Precondition @@ -216,7 +216,7 @@ public void test101JackAssignScummBar() throws Exception { public void test102JackUnassignScummBar() throws Exception { final String TEST_NAME = "test102JackUnassignScummBar"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -241,7 +241,7 @@ public void test102JackUnassignScummBar() throws Exception { public void test201JackAssignScummBarAndSaveElaine() throws Exception { final String TEST_NAME = "test201JackAssignScummBarAndSaveElaine"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> modifications = new ArrayList<>(); @@ -272,7 +272,7 @@ public void test201JackAssignScummBarAndSaveElaine() throws Exception { public void test202JackAssignMinistryOfOffense() throws Exception { final String TEST_NAME = "test202JackAssignMinistryOfOffense"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -293,7 +293,7 @@ public void test202JackAssignMinistryOfOffense() throws Exception { public void test207JackUnAssignScummBar() throws Exception { final String TEST_NAME = "test207JackUnAssignScummBar"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -314,7 +314,7 @@ public void test207JackUnAssignScummBar() throws Exception { public void test208JackUnassignAll() throws Exception { final String TEST_NAME = "test208JackUnassignAll"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -340,7 +340,7 @@ public void test208JackUnassignAll() throws Exception { public void test210JackAssignMinistryOfOffenseMember() throws Exception { final String TEST_NAME = "test210JackAssignMinistryOfOffenseMember"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> modifications = new ArrayList<>(); @@ -370,7 +370,7 @@ public void test210JackAssignMinistryOfOffenseMember() throws Exception { public void test211JackAssignMinistryOfOffenseMinister() throws Exception { final String TEST_NAME = "test211JackAssignMinistryOfOffenseMinister"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -397,7 +397,7 @@ public void test211JackAssignMinistryOfOffenseMinister() throws Exception { public void test212JackUnassignMinistryOfOffenseMember() throws Exception { final String TEST_NAME = "test212JackUnassignMinistryOfOffenseMember"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -421,7 +421,7 @@ public void test212JackUnassignMinistryOfOffenseMember() throws Exception { public void test213JackUnassignMinistryOfOffenseManager() throws Exception { final String TEST_NAME = "test213JackUnassignMinistryOfOffenseManager"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -443,7 +443,7 @@ public void test213JackUnassignMinistryOfOffenseManager() throws Exception { public void test220JackAssignMinistryOfOffenseMemberAgain() throws Exception { final String TEST_NAME = "test220JackAssignMinistryOfOffenseMemberAgain"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -471,7 +471,7 @@ public void test220JackAssignMinistryOfOffenseMemberAgain() throws Exception { public void test221JackAssignScummBarAndSaveElaine() throws Exception { final String TEST_NAME = "test221JackAssignScummBarAndSaveElaine"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> modifications = new ArrayList<>(); @@ -501,7 +501,7 @@ public void test221JackAssignScummBarAndSaveElaine() throws Exception { public void test223JackChangeMinistryOfOffenseMemberToManager() throws Exception { final String TEST_NAME = "test221JackChangeMinistryOfOffenseMemberToManager"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject jack = getUser(USER_JACK_OID); @@ -562,7 +562,7 @@ public void test223JackChangeMinistryOfOffenseMemberToManager() throws Exception public void test230JackRecompute() throws Exception { final String TEST_NAME = "test230JackRecompute"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); @@ -587,7 +587,7 @@ public void test230JackRecompute() throws Exception { public void test232JackDestroyRefsAndRecompute() throws Exception { final String TEST_NAME = "test232JackDestroyRefsAndRecompute"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clearUserOrgAndRoleRefs(USER_JACK_OID); @@ -620,7 +620,7 @@ public void test232JackDestroyRefsAndRecompute() throws Exception { public void test234JackDestroyRefsAndLightRecompute() throws Exception { final String TEST_NAME = "test234JackDestroyRefsAndLightRecompute"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clearUserOrgAndRoleRefs(USER_JACK_OID); @@ -681,7 +681,7 @@ private Long findAssignmentIdForTarget(PrismObject user, String target public void test300JackUnassignAllOrgs() throws Exception { final String TEST_NAME = "test300JackUnassignAllOrgs"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> modifications = new ArrayList<>(); @@ -713,7 +713,7 @@ public void test300JackUnassignAllOrgs() throws Exception { public void test301JackAssignMinistryOfOffense() throws Exception { final String TEST_NAME = "test301JackAssignMinistryOfOffense"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -738,7 +738,7 @@ public void test301JackAssignMinistryOfOffense() throws Exception { public void test305JackConflictZeroAndMinus() throws Exception { final String TEST_NAME = "test305JackConflictZeroAndMinus"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> modifications = new ArrayList<>(); @@ -773,7 +773,7 @@ public void test307JackConflictPlusAndMinus() throws Exception { } protected void executeConflictPlusAndMinus(String TEST_NAME) throws Exception { - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> modifications = new ArrayList<>(); @@ -807,7 +807,7 @@ protected void executeConflictPlusAndMinus(String TEST_NAME) throws Exception { public void test308JackUnassignRoleDefender() throws Exception { final String TEST_NAME = "test308JackUnassignRoleDefender"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -856,7 +856,7 @@ public void test309JackConflictPlusAndMinusAgain() throws Exception { public void test310JackConflictParentOrgRefAndAssignmentsAddOrg() throws Exception { final String TEST_NAME = "test310JackConflictParentOrgRefAndAssignmentsAddOrg"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject orgBefore = createObject(OrgType.class, "Cheaters"); @@ -893,7 +893,7 @@ public void test349DeleteJack() throws Exception { } protected void executeDeleteJack(String TEST_NAME) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta userDelta = prismContext.deltaFactory().object().createDeleteDelta(UserType.class, USER_JACK_OID @@ -922,7 +922,7 @@ protected void executeDeleteJack(String TEST_NAME) throws ObjectAlreadyExistsExc public void test350AddJackAsMinistryOfOffenseManager() throws Exception { final String TEST_NAME = "test350AddJackAsMinistryOfOffenseManager"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userJack = prismContext.parseObject(USER_JACK_FILE); @@ -971,7 +971,7 @@ public void test350AddJackAsMinistryOfOffenseManager() throws Exception { public void test360ElaineAssignGovernor() throws Exception { final String TEST_NAME = "test360ElaineAssignGovernor"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1007,7 +1007,7 @@ public void test360ElaineAssignGovernor() throws Exception { public void test362ElaineAssignGovernmentMember() throws Exception { final String TEST_NAME = "test362ElaineAssignGovernmentMember"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1044,7 +1044,7 @@ public void test362ElaineAssignGovernmentMember() throws Exception { public void test365GuybrushAssignSwashbucklerMember() throws Exception { final String TEST_NAME = "test365GuybrushAssignSwashbucklerMember"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1087,7 +1087,7 @@ public void test365GuybrushAssignSwashbucklerMember() throws Exception { public void test368GuybrushAssignSwashbucklerManager() throws Exception { final String TEST_NAME = "test368GuybrushAssignSwashbucklerManager"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1132,7 +1132,7 @@ public void test368GuybrushAssignSwashbucklerManager() throws Exception { public void test370BarbossaAssignOffenseMember() throws Exception { final String TEST_NAME = "test370BarbossaAssignOffenseMember"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1182,7 +1182,7 @@ public void test370BarbossaAssignOffenseMember() throws Exception { public void test372HermanAssignSwashbucklerMember() throws Exception { final String TEST_NAME = "test365GuybrushAssignSwashbucklerMember"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userHerman = getUser(USER_HERMAN_OID); assertHasNoOrg(userHerman); @@ -1251,7 +1251,7 @@ public void test399DeleteJack() throws Exception { public void test400AddJackWithOrgUnit() throws Exception { final String TEST_NAME = "test400AddJackWithOrgUnit"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); OrgType minOffense = getObject(OrgType.class, ORG_MINISTRY_OF_OFFENSE_OID).asObjectable(); @@ -1279,7 +1279,7 @@ public void test400AddJackWithOrgUnit() throws Exception { public void test402JackChangeMinistryOfOffenseMemberToManagerByAddingRemovingAssignment() throws Exception { final String TEST_NAME = "test402JackChangeMinistryOfOffenseMemberToManagerByAddingRemovingAssignment"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject jack = getUser(USER_JACK_OID); @@ -1314,7 +1314,7 @@ public void test402JackChangeMinistryOfOffenseMemberToManagerByAddingRemovingAss public void test404JackChangeMinistryOfOffenseManagerToMemberByAddingRemovingAssignment() throws Exception { final String TEST_NAME = "test404JackChangeMinistryOfOffenseManagerToMemberByAddingRemovingAssignment"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject jack = getUser(USER_JACK_OID); @@ -1358,7 +1358,7 @@ public void test409DeleteJack() throws Exception { public void test410AddJackWithOrgUnit() throws Exception { final String TEST_NAME = "test400AddJackWithOrgUnit"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); OrgType minOffense = getObject(OrgType.class, ORG_MINISTRY_OF_OFFENSE_OID).asObjectable(); @@ -1387,7 +1387,7 @@ public void test410AddJackWithOrgUnit() throws Exception { public void test412JackChangeMinistryOfOffenseMemberToManagerByModifyingAssignment() throws Exception { final String TEST_NAME = "test412JackChangeMinistryOfOffenseMemberToManagerByModifyingAssignment"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject jack = getUser(USER_JACK_OID); @@ -1428,7 +1428,7 @@ public void test412JackChangeMinistryOfOffenseMemberToManagerByModifyingAssignme public void test420JackAssignTempOrg() throws Exception { final String TEST_NAME = "test420JackAssignTempOrg"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); addObject(ORG_TEMP_FILE); @@ -1451,7 +1451,7 @@ public void test420JackAssignTempOrg() throws Exception { public void test425JackUnassignDeletedOrg() throws Exception { final String TEST_NAME = "test425JackUnassignDeletedOrg"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); deleteObject(OrgType.class, ORG_TEMP_OID, task, result); @@ -1479,7 +1479,7 @@ public void test425JackUnassignDeletedOrg() throws Exception { public void test430JackAssignMetaroleOffender() throws Exception { final String TEST_NAME = "test430JackAssignMetaroleOffender"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userJackBefore = getUser(USER_JACK_OID); @@ -1514,7 +1514,7 @@ public void test430JackAssignMetaroleOffender() throws Exception { public void test431JackAssignMetaroleOffenderAdmin() throws Exception { final String TEST_NAME = "test431JackAssignMetaroleOffenderAdmin"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> modifications = new ArrayList<>(); @@ -1542,7 +1542,7 @@ public void test431JackAssignMetaroleOffenderAdmin() throws Exception { public void test437JackUnassignOffender() throws Exception { final String TEST_NAME = "test437JackUnassignOffender"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1569,7 +1569,7 @@ public void test437JackUnassignOffender() throws Exception { public void test438JackUnassignOffenderAdmin() throws Exception { final String TEST_NAME = "test438JackUnassignOffenderAdmin"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1595,7 +1595,7 @@ public void test438JackUnassignOffenderAdmin() throws Exception { public void test439JackCleanup() throws Exception { final String TEST_NAME = "test439JackCleanup"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1624,7 +1624,7 @@ public void test439JackCleanup() throws Exception { public void test440JackModifyEmployeeTypeRolePirate() throws Exception { final String TEST_NAME = "test440JackModifyEmployeeTypeRolePirate"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1653,7 +1653,7 @@ public void test440JackModifyEmployeeTypeRolePirate() throws Exception { public void test441JackModifyEmployeeTypeRoleCaptain() throws Exception { final String TEST_NAME = "test441JackModifyEmployeeTypeRoleCaptain"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1679,7 +1679,7 @@ public void test441JackModifyEmployeeTypeRoleCaptain() throws Exception { public void test443JackModifyEmployeeTypeRoleNotExist() throws Exception { final String TEST_NAME = "test443JackModifyEmployeeTypeRoleNotExist"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1706,7 +1706,7 @@ public void test443JackModifyEmployeeTypeRoleNotExist() throws Exception { public void test449JackModifyEmployeeTypeNull() throws Exception { final String TEST_NAME = "test449JackModifyEmployeeTypeNull"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1728,7 +1728,7 @@ public void test449JackModifyEmployeeTypeNull() throws Exception { public void test500JackEndPirate() throws Exception { final String TEST_NAME = "test500JackEndPirate"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // preconditions @@ -1765,7 +1765,7 @@ public void test510JackEndPirate() throws Exception { login(USER_JACK_USERNAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/AbstractPasswordTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/AbstractPasswordTest.java index 0e3d427b55a..83a2cca49e3 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/AbstractPasswordTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/AbstractPasswordTest.java @@ -15,7 +15,6 @@ import javax.xml.datatype.XMLGregorianCalendar; import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.util.MidPointTestConstants; @@ -184,7 +183,7 @@ public void test010AddPasswordPolicy() throws Exception { final String TEST_NAME = "test010AddPasswordPolicy"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -206,7 +205,7 @@ public void test012AddSecurityPolicy() throws Exception { final String TEST_NAME = "test012AddSecurityPolicy"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -231,7 +230,7 @@ public void test050CheckJackPassword() throws Exception { // this happens during test initialization when user-jack.xml is added // THEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userJack = getUser(USER_JACK_OID); @@ -248,7 +247,7 @@ public void test051ModifyUserJackPassword() throws Exception { final String TEST_NAME = "test051ModifyUserJackPassword"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -286,7 +285,8 @@ public void test060CheckJackPasswordModelInteraction() throws Exception { } // GIVEN - Task task = createTask(AbstractPasswordTest.class.getName() + "." + TEST_NAME); + AbstractPasswordTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN, THEN @@ -314,7 +314,7 @@ public void test070AddUserHerman() throws Exception { final String TEST_NAME = "test070AddUserHerman"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -348,7 +348,7 @@ public void test100JackAssignAccountDummy() throws Exception { final String TEST_NAME = "test100JackAssignAccountDummy"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -401,7 +401,7 @@ public void test110ModifyUserJackPassword() throws Exception { final String TEST_NAME = "test110ModifyUserJackPassword"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -450,7 +450,7 @@ public void test111ModifyAccountJackPassword() throws Exception { final String TEST_NAME = "test111ModifyAccountJackPassword"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -485,7 +485,7 @@ public void test112ModifyJackPasswordUserAndAccount() throws Exception { final String TEST_NAME = "test112ModifyJackPasswordUserAndAccount"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -535,7 +535,7 @@ public void test120JackAssignAccountDummyRedAndUgly() throws Exception { final String TEST_NAME = "test120JackAssignAccountDummyRedAndUgly"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -585,7 +585,7 @@ public void test121ModifyJackPasswordUserAndAccountRed() throws Exception { final String TEST_NAME = "test121ModifyJackPasswordUserAndAccountRed"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -645,7 +645,8 @@ public void test122ModifyAccountUglyJackPasswordBad() throws Exception { prepareTest(); // GIVEN - Task task = createTask(AbstractPasswordTest.class.getName() + "." + TEST_NAME); + AbstractPasswordTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -673,7 +674,7 @@ public void test125ModifyJackEmployeeNumberBad() throws Exception { final String TEST_NAME = "test125ModifyJackEmployeeNumberBad"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -712,7 +713,7 @@ public void test128ModifyJackEmployeeNumberGood() throws Exception { final String TEST_NAME = "test128ModifyJackEmployeeNumberGood"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -749,7 +750,7 @@ public void test130JackAssignAccountDummyBlack() throws Exception { final String TEST_NAME = "test130JackAssignAccountDummyBlack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -791,7 +792,8 @@ public void test132ModifyAccountBlackJackPasswordBad() throws Exception { final String TEST_NAME = "test132ModifyAccountBlackJackPasswordBad"; // GIVEN - Task task = createTask(AbstractPasswordTest.class.getName() + "." + TEST_NAME); + AbstractPasswordTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -814,7 +816,7 @@ public void test139JackUnassignAccountDummyBlack() throws Exception { final String TEST_NAME = "test139JackUnassignAccountDummyBlack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -856,7 +858,7 @@ public void test140JackAssignAccountDummyYellow() throws Exception { final String TEST_NAME = "test140JackAssignAccountDummyYellow"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -903,7 +905,7 @@ public void test142ModifyUserJackPasswordAA() throws Exception { final String TEST_NAME = "test142ModifyUserJackPasswordAA"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -958,7 +960,7 @@ public void test150AssignMonkeyDummyAccount() throws Exception { final String TEST_NAME = "test150AssignMonkeyDummyAccount"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -989,7 +991,7 @@ public void test152ModifyUserMonkeyPassword() throws Exception { final String TEST_NAME = "test152ModifyUserMonkeyPassword"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -1020,7 +1022,7 @@ public void test154ModifyUserMonkeyPasswordA() throws Exception { final String TEST_NAME = "test154ModifyUserMonkeyPasswordA"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -1043,7 +1045,7 @@ public void test200ApplyPasswordPolicyHistoryLength() throws Exception { final String TEST_NAME = "test200ApplyPasswordPolicyHistoryLength"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -1070,7 +1072,7 @@ public void test204UnassignAccountRed() throws Exception { final String TEST_NAME = "test204UnassignAccountRed"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -1125,7 +1127,7 @@ public void test206ReconcileUserJack() throws Exception { final String TEST_NAME = "test206ReconcileUserJack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -1179,7 +1181,7 @@ public void test212ReconcileUserJack() throws Exception { final String TEST_NAME = "test212ReconcileUserJack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -1202,7 +1204,7 @@ public void test214RecomputeUserJack() throws Exception { final String TEST_NAME = "test214RecomputeUserJack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -1235,7 +1237,7 @@ public void test222ModifyUserJackPasswordBadContainer() throws Exception { final String TEST_NAME = "test222ModifyUserJackPasswordBadContainer"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -1361,7 +1363,7 @@ private void doTestModifyUserJackPasswordSuccessWithHistory(final String TEST_NA String newPassword, String... expectedPasswordHistory) throws Exception { // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -1388,7 +1390,7 @@ private void doTestModifyUserJackPasswordFailureWithHistory(final String TEST_NA String newPassword, String oldPassword, String... expectedPasswordHistory) throws Exception { // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -1443,7 +1445,7 @@ public void test300TwoParentOrgRefs() throws Exception { final String TEST_NAME = "test300TwoParentOrgRefs"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -1505,7 +1507,7 @@ public void test310PreparePasswordStrengthTests() throws Exception { final String TEST_NAME = "test310PreparePasswordStrengthTests"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -1559,7 +1561,7 @@ public void test312ChangeUserPassword() throws Exception { final String TEST_NAME = "test312ChangeUserPassword"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -1620,7 +1622,7 @@ public void test314RemovePasswordFail() throws Exception { final String TEST_NAME = "test314RemovePasswordFail"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -1657,7 +1659,7 @@ public void test315RemovePassword() throws Exception { final String TEST_NAME = "test315RemovePassword"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -1704,7 +1706,7 @@ public void test316UserRecompute() throws Exception { final String TEST_NAME = "test316UserRecompute"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -1754,7 +1756,7 @@ public void test318ChangeUserPassword() throws Exception { final String TEST_NAME = "test318ChangeUserPassword"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -1805,7 +1807,7 @@ public void test320ChangeEmployeeNumber() throws Exception { final String TEST_NAME = "test320ChangeEmployeeNumber"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -1838,7 +1840,7 @@ public void test330RemoveEmployeeNumber() throws Exception { final String TEST_NAME = "test330RemoveEmployeeNumber"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -1876,7 +1878,7 @@ public void test340ModifyUserMonkeyPasswordAA() throws Exception { final String TEST_NAME = "test340ModifyUserMonkeyPasswordAA"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -1912,7 +1914,7 @@ public void test341RecomputeMonkey() throws Exception { final String TEST_NAME = "test341RecomputeMonkey"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -1940,7 +1942,7 @@ public void test342ReconcileMonkey() throws Exception { final String TEST_NAME = "test342ReconcileMonkey"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -1968,7 +1970,7 @@ public void test343ModifyUserMonkeyDescription() throws Exception { final String TEST_NAME = "test343ModifyUserMonkeyDescription"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -2004,7 +2006,7 @@ public void test344ModifyUserMonkeyLocality() throws Exception { final String TEST_NAME = "test343ModifyUserMonkeyDescription"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -2038,7 +2040,7 @@ public void test345AssignMonkeyAccountBlue() throws Exception { final String TEST_NAME = "test345AssignMonkeyAccountBlue"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -2068,7 +2070,7 @@ public void test346UnassignMonkeyAccountBlue() throws Exception { final String TEST_NAME = "test346UnassignMonkeyAccountBlue"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -2101,7 +2103,7 @@ public void test347AssignMonkeyAccountYellow() throws Exception { final String TEST_NAME = "test347AssignMonkeyAccountYellow"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -2129,7 +2131,7 @@ public void test348UnassignMonkeyAccountYellow() throws Exception { final String TEST_NAME = "test348UnassignMonkeyAccountYellow"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -2163,7 +2165,7 @@ public void test349AssignMonkeyPirate() throws Exception { final String TEST_NAME = "test349AssignMonkeyPirate"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -2198,7 +2200,7 @@ public void test350DisableMonkey() throws Exception { final String TEST_NAME = "test350DisableMonkey"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -2233,7 +2235,7 @@ public void test351EnableMonkey() throws Exception { final String TEST_NAME = "test351EnableMonkey"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -2268,7 +2270,7 @@ public void test352UnassignMonkeyPirate() throws Exception { final String TEST_NAME = "test352UnassignMonkeyPirate"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -2302,7 +2304,7 @@ public void test354ModifyUserMonkeyPasswordValid1() throws Exception { final String TEST_NAME = "test354ModifyUserMonkeyPasswordValid1"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -2330,7 +2332,7 @@ public void test355ModifyUserMonkeyDescriptionAgain() throws Exception { final String TEST_NAME = "test355ModifyUserMonkeyDescriptionAgain"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -2357,7 +2359,7 @@ public void test400AddUserRappWithAssignment() throws Exception { final String TEST_NAME = "test400AddUserRappWithAssignment"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = PrismTestUtil.parseObject(USER_RAPP_FILE); @@ -2407,7 +2409,7 @@ public void test401UserRappRecompute() throws Exception { final String TEST_NAME = "test401UserRappRecompute"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -2448,7 +2450,7 @@ public void test402AssignRappDummyRed() throws Exception { final String TEST_NAME = "test402AssignRappDummyRed"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -2512,7 +2514,7 @@ public void test403UserRappRecompute() throws Exception { final String TEST_NAME = "test403UserRappRecompute"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -2574,7 +2576,7 @@ public void test404InitializeRappDummyRed() throws Exception { final String TEST_NAME = "test404InitializeRappDummyRed"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -2639,7 +2641,7 @@ public void test405UserRappRecompute() throws Exception { final String TEST_NAME = "test405UserRappRecompute"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -2702,7 +2704,7 @@ public void test410AssignRappDummyLifecycle() throws Exception { final String TEST_NAME = "test410AssignRappDummyLifecycle"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -2749,7 +2751,7 @@ public void test412InitializeRappDummyLifecycle() throws Exception { final String TEST_NAME = "test412InitializeRappDummyLifecycle"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -2826,7 +2828,7 @@ public void test414UserRappRecompute() throws Exception { final String TEST_NAME = "test414UserRappRecompute"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -2896,7 +2898,7 @@ public void test416UserRappSubtypeWreck() throws Exception { final String TEST_NAME = "test416UserRappSubtypeWreck"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -2972,7 +2974,7 @@ public void test420AddUserDrakeWithAssignment() throws Exception { final String TEST_NAME = "test420AddUserDrakeWithAssignment"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = PrismTestUtil.parseObject(USER_DRAKE_FILE); @@ -3013,7 +3015,7 @@ public void test500JackAssignResourceSouvenir() throws Exception { final String TEST_NAME = "test500JackAssignResourceSouvenir"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -3075,7 +3077,7 @@ public void test502JackInitializeAccountSouvenir() throws Exception { final String TEST_NAME = "test502JackInitializeAccountSouvenir"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -3120,7 +3122,7 @@ public void test510JackAssignResourceMaverick() throws Exception { final String TEST_NAME = "test510JackAssignResourceMaverick"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -3165,7 +3167,7 @@ public void test512JackInitializeAccountMaverickAlligator() throws Exception { final String TEST_NAME = "test512JackInitializeAccountMaverick"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -3201,7 +3203,7 @@ public void test514JackInitializeAccountMaverickCrododile() throws Exception { final String TEST_NAME = "test514JackInitializeAccountMaverickCrododile"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -3241,7 +3243,7 @@ public void test516JackChangePasswordResourceMaverickAlligator() throws Exceptio final String TEST_NAME = "test516JackChangePasswordResourceMaverickAlligator"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -3271,7 +3273,7 @@ public void test518JackChangePasswordResourceMaverickGiantLizard() throws Except final String TEST_NAME = "test518JackChangePasswordResourceMaverickGiantLizard"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -3300,7 +3302,7 @@ public void test530JackUnassignResourceSouvenir() throws Exception { final String TEST_NAME = "test530JackUnassignResourceSouvenir"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -3337,7 +3339,7 @@ public void test532JackChangePasswordResourceBlueAlligator() throws Exception { final String TEST_NAME = "test532JackChangePasswordResourceBlueAlligator"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -3376,7 +3378,7 @@ public void test535ModifyUserJackPasswordAlligator() throws Exception { final String TEST_NAME = "test535ModifyUserJackPasswordAlligator"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -3406,7 +3408,7 @@ public void test539JackUnassignResourceMaverick() throws Exception { final String TEST_NAME = "test539JackUnassignResourceMaverick"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -3470,7 +3472,7 @@ public void testJackManyPasswordChanges(final String TEST_NAME, String passwordP } private void testJackManyPasswordChangesAttempt(String TEST_NAME, String passwordPrefix, CredentialsStorageTypeType storageType, int i) throws Exception { - Task task = createTask(TEST_NAME + "-" + i); + Task task = getTestTask(); OperationResult result = task.getResult(); String newPassword = passwordPrefix + i; @@ -3794,7 +3796,7 @@ public void test900ModifyUserElainePassword() throws Exception { final String TEST_NAME = "test900ModifyUserElainePassword"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -3829,7 +3831,7 @@ public void test902SetPasswordMinAge() throws Exception { final String TEST_NAME = "test900SetPasswordMinAge"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -3860,7 +3862,7 @@ public void test904ModifyUserElainePasswordAgain() throws Exception { final String TEST_NAME = "test904ModifyUserElainePasswordAgain"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -3893,7 +3895,7 @@ public void test906ModifyUserElainePasswordLater() throws Exception { final String TEST_NAME = "test906ModifyUserElainePasswordLater"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -3931,7 +3933,7 @@ public void test910AddUserWithNoPasswordFail() throws Exception { final String TEST_NAME = "test910AddUserWithNoPasswordFail"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -3961,7 +3963,7 @@ public void test920AddCredentials() throws Exception { final String TEST_NAME = "test920AddCredentials"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -4001,7 +4003,7 @@ public void test922ReplaceCredentials() throws Exception { final String TEST_NAME = "test922ReplaceCredentials"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -4041,7 +4043,7 @@ public void test924AddPassword() throws Exception { final String TEST_NAME = "test924AddPassword"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -4078,7 +4080,7 @@ public void test926ReplacePassword() throws Exception { final String TEST_NAME = "test926ReplacePassword"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -4115,7 +4117,7 @@ public void test928AddPasswordValue() throws Exception { final String TEST_NAME = "test928AddPasswordValue"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -4151,7 +4153,7 @@ public void test929ReplacePasswordValue() throws Exception { final String TEST_NAME = "test929ReplacePasswordValue"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -4190,7 +4192,7 @@ public void test950RemoveGlobalPasswordPolicy() throws Exception { final String TEST_NAME = "test950RemoveGlobalPasswordPolicy"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -4228,7 +4230,7 @@ public void test952SetupOrgPolicy() throws Exception { final String TEST_NAME = "test952SetupOrgPolicy"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -4276,7 +4278,7 @@ public void test954ModifyUserMonkeyPasswordAA() throws Exception { final String TEST_NAME = "test954ModifyUserMonkeyPasswordAA"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -4311,7 +4313,7 @@ public void test956ModifyUserJackPasswordAA() throws Exception { final String TEST_NAME = "test956ModifyUserJackPasswordAA"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -4340,7 +4342,7 @@ public void test961RecomputeMonkey() throws Exception { final String TEST_NAME = "test961RecomputeMonkey"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -4368,7 +4370,7 @@ public void test962ReconcileMonkey() throws Exception { final String TEST_NAME = "test962ReconcileMonkey"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -4396,7 +4398,7 @@ public void test964ModifyUserMonkeyLocality() throws Exception { final String TEST_NAME = "test964ModifyUserMonkeyLocality"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -4430,7 +4432,7 @@ public void test965AssignMonkeyAccountBlue() throws Exception { final String TEST_NAME = "test965AssignMonkeyAccountBlue"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -4464,7 +4466,7 @@ public void test966AssignMonkeyAccountYellow() throws Exception { final String TEST_NAME = "test966AssignMonkeyAccountYellow"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -4497,7 +4499,7 @@ public void test970ReapplyGlobalPasswordPolicy() throws Exception { final String TEST_NAME = "test970ReapplyGlobalPasswordPolicy"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -4540,7 +4542,7 @@ public void test972ChangePasswordJack() throws Exception { final String TEST_NAME = "test970ReapplyGlobalPasswordPolicy"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -4582,7 +4584,7 @@ public void test974ChangePasswordJack() throws Exception { final String TEST_NAME = "test970ReapplyGlobalPasswordPolicy"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -4615,7 +4617,7 @@ public void test974ChangePasswordJack() throws Exception { private void modifyUserChangePasswordPolicyViolation(String userOid, String newPassword) throws CommonException { - Task task = createTask("modifyUserChangePasswordPolicyViolation"); + Task task = getTestTask(); OperationResult result = task.getResult(); try { modifyUserChangePassword(userOid, newPassword, task, result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefault.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefault.java index d0f17aeb03b..3e688e97d2d 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefault.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefault.java @@ -16,7 +16,6 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.exception.PolicyViolationException; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefaultHashing.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefaultHashing.java index ab142a8a0b6..55ec6095dca 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefaultHashing.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefaultHashing.java @@ -16,9 +16,7 @@ import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.exception.PolicyViolationException; import com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsStorageTypeType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; @@ -149,7 +147,7 @@ public void test345AssignMonkeyAccountBlue() throws Exception { final String TEST_NAME = "test345AssignMonkeyAccountBlue"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -197,7 +195,7 @@ public void test347AssignMonkeyAccountYellow() throws Exception { final String TEST_NAME = "test347AssignMonkeyYellow"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -247,7 +245,7 @@ public void test966AssignMonkeyAccountYellow() throws Exception { final String TEST_NAME = "test966AssignMonkeyAccountYellow"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/AbstractPersonaTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/AbstractPersonaTest.java index 348635c6345..6896cbc8772 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/AbstractPersonaTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/AbstractPersonaTest.java @@ -60,7 +60,7 @@ public void test100AssignRolePersonaAdminToJack() throws Exception { final String TEST_NAME = "test100AssignRolePersonaAdminToJack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -96,7 +96,7 @@ public void test102RecomputeUserJack() throws Exception { final String TEST_NAME = "test102RecomputeUserJack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -115,7 +115,7 @@ public void test103ReconcileUserJack() throws Exception { final String TEST_NAME = "test103ReconcileUserJack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -134,7 +134,7 @@ public void test104RecomputeJackAdminPersona() throws Exception { final String TEST_NAME = "test104RecomputeJackAdminPersona"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -153,7 +153,7 @@ public void test105ReconcileJackAdminPersona() throws Exception { final String TEST_NAME = "test105ReconcileJackAdminPersona"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -189,7 +189,7 @@ public void test120ModifyJackGivenName() throws Exception { final String TEST_NAME = "test120ModifyJackGivenName"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -226,7 +226,7 @@ public void test140ModifyUserJackPassword() throws Exception { final String TEST_NAME = "test140ModifyUserJackPassword"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); XMLGregorianCalendar startCal = clock.currentTimeXMLGregorianCalendar(); @@ -260,7 +260,7 @@ public void test142ModifyPersonaPassword() throws Exception { final String TEST_NAME = "test142ModifyPersonaPassword"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -300,7 +300,7 @@ public void test145ModifyPersonaPasswordBack() throws Exception { final String TEST_NAME = "test145ModifyPersonaPasswordBack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -340,7 +340,7 @@ public void test199UnassignRolePersonaAdminFromJack() throws Exception { final String TEST_NAME = "test199UnassignRolePersonaAdminFromJack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/TestPersonaPassword.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/TestPersonaPassword.java index aa2f367061f..c9937298746 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/TestPersonaPassword.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/TestPersonaPassword.java @@ -20,7 +20,6 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.util.exception.PolicyViolationException; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; @@ -73,7 +72,7 @@ public void test145ModifyPersonaPasswordBack() throws Exception { final String TEST_NAME = "test145ModifyPersonaPasswordBack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestAssignmentValidity.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestAssignmentValidity.java index f3d19046df1..e65e83aed69 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestAssignmentValidity.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestAssignmentValidity.java @@ -50,7 +50,7 @@ public void initSystem(Task initTask, OperationResult initResult) public void test100JackAssignRolePirateValidTo() throws Exception { final String TEST_NAME = "test100JackAssignRolePirateValidTo"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -91,7 +91,7 @@ public void test100JackAssignRolePirateValidTo() throws Exception { public void test102Forward15min() throws Exception { final String TEST_NAME = "test102Forward15min"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT15M"); @@ -122,7 +122,7 @@ public void test102Forward15min() throws Exception { public void test104JackAssignRolePirateAgain() throws Exception { final String TEST_NAME = "test104JackAssignRolePirateAgain"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -157,7 +157,7 @@ public void test104JackAssignRolePirateAgain() throws Exception { public void test106JackUnassignRolePirateValid() throws Exception { final String TEST_NAME = "test106JackUnassignRolePirateValid"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -195,7 +195,7 @@ public void test109JackUnassignAll() throws Exception { public void test110JackAssignRolePirateValidToRaw() throws Exception { final String TEST_NAME = "test110JackAssignRolePirateValidToRaw"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -234,7 +234,7 @@ public void test110JackAssignRolePirateValidToRaw() throws Exception { public void test111RecomputeJack() throws Exception { final String TEST_NAME = "test111RecomputeJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -267,7 +267,7 @@ public void test111RecomputeJack() throws Exception { public void test112Forward15min() throws Exception { final String TEST_NAME = "test102Forward15min"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT15M"); @@ -298,7 +298,7 @@ public void test112Forward15min() throws Exception { public void test114JackAssignRolePirateAgain() throws Exception { final String TEST_NAME = "test114JackAssignRolePirateAgain"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -341,7 +341,7 @@ public void test119JackUnassignAll() throws Exception { public void test120JackAssignRoleSailorValidTo() throws Exception { final String TEST_NAME = "test120JackAssignRoleSailorValidTo"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -382,7 +382,7 @@ public void test120JackAssignRoleSailorValidTo() throws Exception { public void test122Forward15min() throws Exception { final String TEST_NAME = "test122Forward15min"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT15M"); @@ -413,7 +413,7 @@ public void test122Forward15min() throws Exception { public void test124JackAssignRoleSailorAgain() throws Exception { final String TEST_NAME = "test124JackAssignRoleSailorAgain"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -457,7 +457,7 @@ public void test129JackUnassignAll() throws Exception { public void test130JackAssignRoleSailorValidToRaw() throws Exception { final String TEST_NAME = "test130JackAssignRoleSailorValidToRaw"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -496,7 +496,7 @@ public void test130JackAssignRoleSailorValidToRaw() throws Exception { public void test131RecomputeJack() throws Exception { final String TEST_NAME = "test131RecomputeJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -529,7 +529,7 @@ public void test131RecomputeJack() throws Exception { public void test132Forward15min() throws Exception { final String TEST_NAME = "test132Forward15min"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT15M"); @@ -560,7 +560,7 @@ public void test132Forward15min() throws Exception { public void test134JackAssignRoleSailorAgain() throws Exception { final String TEST_NAME = "test134JackAssignRoleSailorAgain"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -604,7 +604,7 @@ public void test139JackUnassignAll() throws Exception { public void test140JackAssignRoleSailorValidToRaw() throws Exception { final String TEST_NAME = "test140JackAssignRoleSailorValidToRaw"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -644,7 +644,7 @@ public void test140JackAssignRoleSailorValidToRaw() throws Exception { public void test142Forward15min() throws Exception { final String TEST_NAME = "test142Forward15min"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); // WHEN displayWhen(TEST_NAME); @@ -672,7 +672,7 @@ public void test142Forward15min() throws Exception { public void test144JackAssignRoleSailorAgain() throws Exception { final String TEST_NAME = "test144JackAssignRoleSailorAgain"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -714,7 +714,7 @@ public void test149JackUnassignAll() throws Exception { public void test150JackAssignRolePirate() throws Exception { final String TEST_NAME = "test150JackAssignRolePirate"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -749,7 +749,7 @@ public void test150JackAssignRolePirate() throws Exception { public void test151JackAssignRoleSailorValidTo() throws Exception { final String TEST_NAME = "test151JackAssignRoleSailorValidTo"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -790,7 +790,7 @@ public void test151JackAssignRoleSailorValidTo() throws Exception { public void test153Forward15min() throws Exception { final String TEST_NAME = "test153Forward15min"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT15M"); @@ -823,7 +823,7 @@ public void test153Forward15min() throws Exception { public void test154JackAssignRoleSailorAgain() throws Exception { final String TEST_NAME = "test154JackAssignRoleSailorAgain"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -861,7 +861,7 @@ public void test159JackUnassignAll() throws Exception { public void test160JackAssignRolePirate() throws Exception { final String TEST_NAME = "test160JackAssignRolePirate"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -895,7 +895,7 @@ public void test160JackAssignRolePirate() throws Exception { public void test161JackAssignRoleSailorValidToRaw() throws Exception { final String TEST_NAME = "test161JackAssignRoleSailorValidToRaw"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -940,7 +940,7 @@ public void test161JackAssignRoleSailorValidToRaw() throws Exception { public void test162RecomputeJack() throws Exception { final String TEST_NAME = "test162RecomputeJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -981,7 +981,7 @@ public void test162RecomputeJack() throws Exception { public void test163Forward15min() throws Exception { final String TEST_NAME = "test163Forward15min"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT15M"); @@ -1014,7 +1014,7 @@ public void test163Forward15min() throws Exception { public void test164JackAssignRoleSailorAgain() throws Exception { final String TEST_NAME = "test164JackAssignRoleSailorAgain"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1052,7 +1052,7 @@ public void test169JackUnassignAll() throws Exception { public void test170JackAssignRolePirate() throws Exception { final String TEST_NAME = "test170JackAssignRolePirate"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1086,7 +1086,7 @@ public void test170JackAssignRolePirate() throws Exception { public void test171JackAssignRoleWeakSingerValidTo() throws Exception { final String TEST_NAME = "test171JackAssignRoleWeakSingerValidTo"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1127,7 +1127,7 @@ public void test171JackAssignRoleWeakSingerValidTo() throws Exception { public void test173Forward15min() throws Exception { final String TEST_NAME = "test173Forward15min"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT15M"); @@ -1161,7 +1161,7 @@ public void test173Forward15min() throws Exception { public void test174JackAssignRoleSingerAgain() throws Exception { final String TEST_NAME = "test174JackAssignRoleSingerAgain"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1200,7 +1200,7 @@ public void test179JackUnassignAll() throws Exception { public void test180JackAssignRoleSailorValidToRaw() throws Exception { final String TEST_NAME = "test180JackAssignRoleSailorValidToRaw"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1237,7 +1237,7 @@ public void test180JackAssignRoleSailorValidToRaw() throws Exception { public void test182Forward15minAndAssignRaw() throws Exception { final String TEST_NAME = "test142Forward15min"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT15M"); @@ -1265,7 +1265,7 @@ public void test182Forward15minAndAssignRaw() throws Exception { public void test184RecomputeJack() throws Exception { final String TEST_NAME = "test184RecomputeJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1303,7 +1303,7 @@ public void test189JackUnassignAll() throws Exception { public void test200JackAssignCurrentPirateFutureSailor() throws Exception { final String TEST_NAME = "test200JackAssignCurrentPirateFutureSailor"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1339,7 +1339,7 @@ public void test200JackAssignCurrentPirateFutureSailor() throws Exception { public void test202RecomputeJack() throws Exception { final String TEST_NAME = "test202RecomputeJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1369,7 +1369,7 @@ public void test202RecomputeJack() throws Exception { public void test204ReconcileJack() throws Exception { final String TEST_NAME = "test204ReconcileJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1406,7 +1406,7 @@ public void test209JackUnassignAll() throws Exception { public void test210JackAssignCurrentPirateFutureRichSailor() throws Exception { final String TEST_NAME = "test210JackAssignCurrentPirateFutureRichSailor"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1442,7 +1442,7 @@ public void test210JackAssignCurrentPirateFutureRichSailor() throws Exception { public void test212RecomputeJack() throws Exception { final String TEST_NAME = "test212RecomputeJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1472,7 +1472,7 @@ public void test212RecomputeJack() throws Exception { public void test214ReconcileJack() throws Exception { final String TEST_NAME = "test214ReconcileJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1507,7 +1507,7 @@ public void test219JackUnassignAll() throws Exception { public void test220JackAssignFutureRichSailor() throws Exception { final String TEST_NAME = "test220JackAssignFutureRichSailor"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); unassignAll(TEST_NAME); @@ -1550,7 +1550,7 @@ public void test229JackUnassignAll() throws Exception { public void test230JackAssignRoleStrongRichSailorValidTo() throws Exception { final String TEST_NAME = "test230JackAssignRoleStrongRichSailorValidTo"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1594,7 +1594,7 @@ public void test230JackAssignRoleStrongRichSailorValidTo() throws Exception { public void test232Forward15min() throws Exception { final String TEST_NAME = "test232Forward15min"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT15M"); @@ -1631,7 +1631,7 @@ public void test239JackUnassignAll() throws Exception { public void test240JackAssignRoleRichSailorValidTo() throws Exception { final String TEST_NAME = "test240JackAssignRoleRichSailorValidTo"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1675,7 +1675,7 @@ public void test240JackAssignRoleRichSailorValidTo() throws Exception { public void test242Forward15min() throws Exception { final String TEST_NAME = "test242Forward15min"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT15M"); @@ -1711,7 +1711,7 @@ public void test249JackUnassignAll() throws Exception { public void test250JackAssignFocusExistsResource() throws Exception { final String TEST_NAME = "test250JackAssignFocusExistsResource"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1747,7 +1747,7 @@ public void test250JackAssignFocusExistsResource() throws Exception { public void test252RecomputeJack() throws Exception { final String TEST_NAME = "test252RecomputeJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1776,7 +1776,7 @@ public void test252RecomputeJack() throws Exception { public void test254ReconcileJack() throws Exception { final String TEST_NAME = "test254ReconcileJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1877,7 +1877,7 @@ private void assertJackDummyPirateSingerAccount() throws Exception { private void unassignAll(final String TEST_NAME) throws Exception { - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestAutoassign.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestAutoassign.java index 1d73e66b757..46a6a598f28 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestAutoassign.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestAutoassign.java @@ -10,20 +10,15 @@ import javax.xml.datatype.XMLGregorianCalendar; -import com.evolveum.midpoint.prism.path.ItemPath; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.delta.ObjectDelta; -import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.xml.XmlTypeConverter; import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleManagementConfigurationType; import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; @@ -88,7 +83,7 @@ public void test100ModifyUnitWorker() throws Exception { final String TEST_NAME = "test100ModifyUnitWorker"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -121,7 +116,7 @@ public void test109ModifyUniNull() throws Exception { final String TEST_NAME = "test109ModifyUniNull"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -149,7 +144,7 @@ public void test110ModifyUnitSleepwalker() throws Exception { final String TEST_NAME = "test110ModifyUnitSleepwalker"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -189,7 +184,7 @@ public void test112ModifyUnitSleeperToWorker() throws Exception { final String TEST_NAME = "test112ModifyUnitSleeperToWorker"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta objectDelta = prismContext.deltaFactory().object().createModificationAddProperty(UserType.class, @@ -225,7 +220,7 @@ public void test114ModifyUnitAddSleeper() throws Exception { final String TEST_NAME = "test114ModifyUnitAddSleeper"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestMetaMeta.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestMetaMeta.java index 0f48bb7ad98..7c0dbc41837 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestMetaMeta.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestMetaMeta.java @@ -103,7 +103,7 @@ public void test050AddMetaMeta() throws Exception { final String TEST_NAME = "test050AddMetaMeta"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -138,7 +138,7 @@ public void test100AddGreeks() throws Exception { final String TEST_NAME = "test100AddGreeks"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -156,7 +156,7 @@ public void test110AddRomans() throws Exception { final String TEST_NAME = "test110AddRomans"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -174,7 +174,7 @@ public void test200CreateAlpha() throws Exception { final String TEST_NAME = "test200CreateAlpha"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -193,7 +193,7 @@ public void test202CreateBeta() throws Exception { final String TEST_NAME = "test202CreateBeta"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -211,7 +211,7 @@ public void test210CreateA() throws Exception { final String TEST_NAME = "test210CreateA"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -232,7 +232,7 @@ public void test300AssignAlphaToJack() throws Exception { final String TEST_NAME = "test300AssignAlphaToJack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -251,7 +251,7 @@ public void test309UnassignAlphaFromJack() throws Exception { final String TEST_NAME = "test309UnassignAlphaFromJack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -279,7 +279,7 @@ public void test310AssignAToJack() throws Exception { final String TEST_NAME = "test310AssignAToJack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -301,7 +301,7 @@ public void test312AssignBetaToJack() throws Exception { final String TEST_NAME = "test312AssignBetaToJack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -320,7 +320,7 @@ public void test319UnassignBetaAFromJack() throws Exception { final String TEST_NAME = "test319UnassignBetaAFromJack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta focusDelta = createAssignmentFocusDelta(UserType.class, USER_JACK_OID, getGroupRoleOid(GROUP_BETA_NAME), RoleType.COMPLEX_TYPE, null, (Consumer)null, false); @@ -350,7 +350,7 @@ public void test900LegacyAddMetaMeta() throws Exception { final String TEST_NAME = "test900LegacyAddMetaMeta"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -385,7 +385,7 @@ public void test910LegacyAddMetaLegacyOne() throws Exception { final String TEST_NAME = "test910LegacyAddMetaLegacyOne"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -421,7 +421,7 @@ public void test920LegacyCreateGroupOne() throws Exception { final String TEST_NAME = "test920LegacyCreateGroupOne"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject roleBefore = createObject(RoleType.class, GROUP_ONE_NAME); RoleType roleType = roleBefore.asObjectable(); @@ -461,7 +461,7 @@ public void test930LegacyAssignGroupOneToJack() throws Exception { final String TEST_NAME = "test930LegacyAssignGroupOneToJack"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestRbac.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestRbac.java index 8007bc6eb2d..4a963bff043 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestRbac.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestRbac.java @@ -81,7 +81,7 @@ public void initSystem(Task initTask, OperationResult initResult) public void test000SanityRolePirate() throws Exception { final String TEST_NAME = "test000SanityRolePirate"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -99,7 +99,7 @@ public void test000SanityRolePirate() throws Exception { public void test001SanityRoleProjectOmnimanager() throws Exception { final String TEST_NAME = "test001SanityRoleProjectOmnimanager"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -119,7 +119,7 @@ public void test001SanityRoleProjectOmnimanager() throws Exception { public void test010SearchRequestableRoles() throws Exception { final String TEST_NAME = "test010SearchRequestableRoles"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = prismContext.queryFor(RoleType.class) @@ -139,7 +139,7 @@ public void test010SearchRequestableRoles() throws Exception { public void test101JackAssignRolePirate() throws Exception { final String TEST_NAME = "test101JackAssignRolePirate"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -189,7 +189,7 @@ protected ModelExecuteOptions getDefaultOptions() { public void test102JackModifyUserLocality() throws Exception { final String TEST_NAME = "test102JackModifyUserLocality"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // gossip is a tolerant attribute. Make sure there there is something to tolerate @@ -230,7 +230,7 @@ public void test102JackModifyUserLocality() throws Exception { public void test110UnAssignRolePirate() throws Exception { final String TEST_NAME = "test110UnAssignRolePirate"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -253,7 +253,7 @@ public void test120JackAssignRolePirateWhileAlreadyHasAccount() throws Exception final String TEST_NAME = "test120JackAssignRolePirateWhileAlreadyHasAccount"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject account = PrismTestUtil.parseObject(ACCOUNT_JACK_DUMMY_FILE); @@ -320,7 +320,7 @@ public void test121JackAssignAccountImplicitIntent() throws Exception { final String TEST_NAME = "test121JackAssignAccountImplicitIntent"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Precondition (simplified) @@ -353,7 +353,7 @@ public void test122JackAssignAccountExplicitIntent() throws Exception { final String TEST_NAME = "test122JackAssignAccountExplicitIntent"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Precondition (simplified) @@ -385,7 +385,7 @@ public void test122JackAssignAccountExplicitIntent() throws Exception { public void test127UnAssignAccountImplicitIntent() throws Exception { final String TEST_NAME = "test127UnAssignAccountImplicitIntent"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -413,7 +413,7 @@ public void test127UnAssignAccountImplicitIntent() throws Exception { public void test128UnAssignAccountExplicitIntent() throws Exception { final String TEST_NAME = "test128UnAssignAccountExplicitIntent"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -441,7 +441,7 @@ public void test128UnAssignAccountExplicitIntent() throws Exception { public void test129UnAssignRolePirate() throws Exception { final String TEST_NAME = "test129UnAssignRolePirate"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -463,7 +463,7 @@ public void test129UnAssignRolePirate() throws Exception { public void test130JackAssignRolePirateWithSeaInAssignment() throws Exception { final String TEST_NAME = "test130JackAssignRolePirateWithSeaInAssignment"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismContainer extension = getAssignmentExtensionInstance(); @@ -500,7 +500,7 @@ public void test130JackAssignRolePirateWithSeaInAssignment() throws Exception { public void test132JackUnAssignRolePirateWithSeaInAssignment() throws Exception { final String TEST_NAME = "test132JackUnAssignRolePirateWithSeaInAssignment"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismContainer extension = getAssignmentExtensionInstance(); @@ -532,7 +532,7 @@ public void test132JackUnAssignRolePirateWithSeaInAssignment() throws Exception public void test134JackAssignRoleAdriaticPirate() throws Exception { final String TEST_NAME = "test134JackAssignRoleAdriaticPirate"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -565,7 +565,7 @@ public void test134JackAssignRoleAdriaticPirate() throws Exception { public void test135PreviewChangesEmptyDelta() throws Exception { final String TEST_NAME = "test135PreviewChangesEmptyDelta"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = getUser(USER_JACK_OID); ObjectDelta delta = user.createModifyDelta(); @@ -597,7 +597,7 @@ public void test135PreviewChangesEmptyDelta() throws Exception { public void test136JackUnAssignRoleAdriaticPirate() throws Exception { final String TEST_NAME = "test136JackUnAssignRoleAdriaticPirate"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -623,7 +623,7 @@ public void test136JackUnAssignRoleAdriaticPirate() throws Exception { public void test137JackAssignRoleAdriaticPirateWithSeaInAssignment() throws Exception { final String TEST_NAME = "test137JackAssignRoleAdriaticPirateWithSeaInAssignment"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismContainer extension = getAssignmentExtensionInstance(); @@ -660,7 +660,7 @@ public void test137JackAssignRoleAdriaticPirateWithSeaInAssignment() throws Exce public void test139JackUnAssignRoleAdriaticPirateWithSeaInAssignment() throws Exception { final String TEST_NAME = "test139JackUnAssignRoleAdriaticPirateWithSeaInAssignment"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismContainer extension = getAssignmentExtensionInstance(); @@ -689,7 +689,7 @@ public void test139JackUnAssignRoleAdriaticPirateWithSeaInAssignment() throws Ex public void test144JackAssignRoleBlackSeaPirate() throws Exception { final String TEST_NAME = "test144JackAssignRoleBlackSeaPirate"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -719,7 +719,7 @@ public void test144JackAssignRoleBlackSeaPirate() throws Exception { public void test146JackUnAssignRoleBlackSeaPirate() throws Exception { final String TEST_NAME = "test146JackUnAssignRoleBlackSeaPirate"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -741,7 +741,7 @@ public void test146JackUnAssignRoleBlackSeaPirate() throws Exception { public void test147JackAssignRoleBlackSeaPirateWithSeaInAssignment() throws Exception { final String TEST_NAME = "test147JackAssignRoleBlackSeaPirateWithSeaInAssignment"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismContainer extension = getAssignmentExtensionInstance(); @@ -779,7 +779,7 @@ public void test147JackAssignRoleBlackSeaPirateWithSeaInAssignment() throws Exce public void test149JackUnAssignRoleBlackSeaPirateWithSeaInAssignment() throws Exception { final String TEST_NAME = "test149JackUnAssignRoleBlackSeaPirateWithSeaInAssignment"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismContainer extension = getAssignmentExtensionInstance(); @@ -808,7 +808,7 @@ public void test149JackUnAssignRoleBlackSeaPirateWithSeaInAssignment() throws Ex public void test154JackAssignRoleIndianOceanPirate() throws Exception { final String TEST_NAME = "test154JackAssignRoleIndianOceanPirate"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -842,7 +842,7 @@ public void test154JackAssignRoleIndianOceanPirate() throws Exception { public void test156JackUnAssignRoleIndianOceanPirate() throws Exception { final String TEST_NAME = "test156JackUnAssignRoleIndianOceanPirate"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -915,7 +915,7 @@ public void test169JackUnassignRolePirateComplicated() throws Exception { public void testJackAssignRolePirateRelationNoPrivs(final String TEST_NAME, QName relation) throws Exception { - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -957,7 +957,7 @@ private void assertJackAssignRolePirateRelationNoPrivs(QName relation) throws Ex public void testJackUnassignRolePirateRelationNoPrivs(final String TEST_NAME, QName relation) throws Exception { - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -991,7 +991,7 @@ public void testJackUnassignRolePirateRelationNoPrivs(final String TEST_NAME, QN public void test200ImportRoleAllTreasure() throws Exception { final String TEST_NAME = "test200ImportRoleAllTreasure"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1013,7 +1013,7 @@ public void test200ImportRoleAllTreasure() throws Exception { public void test202JackAssignRoleAllTreasure() throws Exception { final String TEST_NAME = "test202JackAssignRoleAllTreasure"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1046,7 +1046,7 @@ public void test202JackAssignRoleAllTreasure() throws Exception { public void test204AddGoldTreasureAndRecomputeJack() throws Exception { final String TEST_NAME = "test204AddGoldTreasureAndRecomputeJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); addObject(ROLE_TREASURE_GOLD_FILE); @@ -1076,7 +1076,7 @@ public void test204AddGoldTreasureAndRecomputeJack() throws Exception { public void test206JackAssignRoleAllLoot() throws Exception { final String TEST_NAME = "test206JackAssignRoleAllLoot"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1102,7 +1102,7 @@ public void test206JackAssignRoleAllLoot() throws Exception { public void test208JackUnassignRoleAllLoot() throws Exception { final String TEST_NAME = "test208JackUnassignRoleAllLoot"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1127,7 +1127,7 @@ public void test208JackUnassignRoleAllLoot() throws Exception { public void test209JackUnassignRoleAllTreasure() throws Exception { final String TEST_NAME = "test209JackUnassignRoleAllTreasure"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1150,7 +1150,7 @@ public void test209JackUnassignRoleAllTreasure() throws Exception { public void test210JackAssignRoleAllYouCanGet() throws Exception { final String TEST_NAME = "test210JackAssignRoleAllYouCanGet"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1176,7 +1176,7 @@ public void test210JackAssignRoleAllYouCanGet() throws Exception { public void test219JackUnassignRoleAllYouCanGet() throws Exception { final String TEST_NAME = "test219JackUnassignRoleAllYouCanGet"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1203,7 +1203,7 @@ public void test501JackAssignRolePirate() throws Exception { // IMPORTANT: Changing the assignment policy assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1236,7 +1236,7 @@ public void test501JackAssignRolePirate() throws Exception { public void test502JackModifyUserLocality() throws Exception { final String TEST_NAME = "test502JackModifyUserLocality"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // gossip is a tolerant attribute. Make sure there there is something to tolerate @@ -1275,7 +1275,7 @@ public void test502JackModifyUserLocality() throws Exception { public void test510UnAssignRolePirate() throws Exception { final String TEST_NAME = "test510UnAssignRolePirate"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1303,7 +1303,7 @@ public void test510UnAssignRolePirate() throws Exception { public void test511DeleteAccount() throws Exception { final String TEST_NAME = "test511DeleteAccount"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userJack = getUser(USER_JACK_OID); @@ -1337,7 +1337,7 @@ public void test520JackAssignRolePirate() throws Exception { // IMPORTANT: Changing the assignment policy assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1369,7 +1369,7 @@ public void test521JackUnassignRolePirateDeleteAccount() throws Exception { // IMPORTANT: Changing the assignment policy assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> modifications = new ArrayList<>(); @@ -1402,7 +1402,7 @@ public void test530JackAssignRoleCleric() throws Exception { final String TEST_NAME = "test530JackAssignRoleCleric"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1419,7 +1419,7 @@ public void test532JackModifyAssignmentRoleCleric() throws Exception { final String TEST_NAME = "test532JackModifyAssignmentRoleCleric"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = getObject(UserType.class, USER_JACK_OID); @@ -1453,7 +1453,7 @@ public void test539JackUnAssignRoleCleric() throws Exception { final String TEST_NAME = "test539JackUnAssignRoleCleric"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = getObject(UserType.class, USER_JACK_OID); @@ -1489,7 +1489,7 @@ public void test540JackAssignRoleWannabe() throws Exception { final String TEST_NAME = "test540JackAssignRoleWannabe"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1518,7 +1518,7 @@ public void test541JackRemoveHonorificSuffixWannabe() throws Exception { final String TEST_NAME = "test541JackRemoveHonorificSuffixWannabe"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1546,7 +1546,7 @@ public void test542JackModifySubtypeWannabe() throws Exception { final String TEST_NAME = "test542JackModifySubtypeWannabe"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1575,7 +1575,7 @@ public void test543JackRemoveHonorificPrefixWannabe() throws Exception { final String TEST_NAME = "test543JackRemoveHonorificPrefixWannabe"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1603,7 +1603,7 @@ public void test544JackSetHonorificSuffixWannabe() throws Exception { final String TEST_NAME = "test544JackSetHonorificSuffixWannabe"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1634,7 +1634,7 @@ public void test545JackRestoreHonorificPrefixWannabe() throws Exception { final String TEST_NAME = "test545JackRestoreHonorificPrefixWannabe"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1664,7 +1664,7 @@ public void test549JackUnassignRoleWannabe() throws Exception { final String TEST_NAME = "test549JackUnassignRoleWannabe"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1689,7 +1689,7 @@ public void test600JackAssignRoleJudge() throws Exception { final String TEST_NAME = "test600JackAssignRoleJudge"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1725,7 +1725,7 @@ public void test602JackAssignRolePirate() throws Exception { final String TEST_NAME = "test602JackAssignRolePirate"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); try { @@ -1760,7 +1760,7 @@ public void test605JackUnAssignRoleJudgeAssignRolePirate() throws Exception { final String TEST_NAME = "test605JackUnAssignRoleJudgeAssignRolePirate"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta userDelta = createAssignmentUserDelta(USER_JACK_OID, ROLE_JUDGE_OID, RoleType.COMPLEX_TYPE, null, null, false); @@ -1797,7 +1797,7 @@ public void test609JackUnAssignRolePirate() throws Exception { final String TEST_NAME = "test609JackUnAssignRolePirate"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1817,7 +1817,7 @@ public void test610ElaineAssignRoleGovernor() throws Exception { final String TEST_NAME = "test610ElaineAssignRoleGovernor"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_ELAINE_OID); @@ -1854,7 +1854,7 @@ public void test612JackAssignRoleGovernor() throws Exception { final String TEST_NAME = "test612JackAssignRoleGovernor"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); try { @@ -1890,7 +1890,7 @@ public void test613JackAssignRoleGovernorAsApprover() throws Exception { final String TEST_NAME = "test613JackAssignRoleGovernorAsApprover"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); try { @@ -1923,7 +1923,7 @@ public void test620LemonheadAssignRoleCanibal() throws Exception { final String TEST_NAME = "test620LemonheadAssignRoleCanibal"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = createUser(USER_LEMONHEAD_NAME, USER_LEMONHEAD_FULLNAME, true); @@ -1953,7 +1953,7 @@ public void test622SharptoothAssignRoleCanibal() throws Exception { final String TEST_NAME = "test622SharptoothAssignRoleCanibal"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = createUser(USER_SHARPTOOTH_NAME, USER_SHARPTOOTH_FULLNAME, true); @@ -1983,7 +1983,7 @@ public void test624RedskullAssignRoleCanibal() throws Exception { final String TEST_NAME = "test624RedskullAssignRoleCanibal"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = createUser(USER_REDSKULL_NAME, USER_REDSKULL_FULLNAME, true); @@ -2013,7 +2013,7 @@ public void test625BignoseAssignRoleCanibal() throws Exception { final String TEST_NAME = "test625BignoseAssignRoleCanibal"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = createUser(USER_BIGNOSE_NAME, USER_BIGNOSE_FULLNAME, true); @@ -2049,7 +2049,7 @@ public void test627SharptoothUnassignRoleCanibal() throws Exception { final String TEST_NAME = "test627SharptoothUnassignRoleCanibal"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertAssignees(ROLE_CANNIBAL_OID, 3); @@ -2074,7 +2074,7 @@ public void test628RedskullUnassignRoleCanibal() throws Exception { final String TEST_NAME = "test628RedskullUnassignRoleCanibal"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertAssignees(ROLE_CANNIBAL_OID, 2); @@ -2113,7 +2113,7 @@ public void test630RappAssignRoleCannibalAsOwner() throws Exception { final String TEST_NAME = "test630RappAssignRoleCannibalAsOwner"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertAssignees(ROLE_CANNIBAL_OID, 2); @@ -2142,7 +2142,7 @@ public void test632RappUnassignRoleCannibalAsOwner() throws Exception { final String TEST_NAME = "test632RappUnassignRoleCannibalAsOwner"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertAssignees(ROLE_CANNIBAL_OID, 2); @@ -2182,7 +2182,7 @@ public void test634BignoseAssignRoleCannibalAsOwner() throws Exception { final String TEST_NAME = "test634BignoseAssignRoleCannibalAsOwner"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertAssignees(ROLE_CANNIBAL_OID, 2); @@ -2217,7 +2217,7 @@ public void test636BignoseUnassignRoleCannibalAsOwner() throws Exception { final String TEST_NAME = "test636BignoseUnassignRoleCannibalAsOwner"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertAssignees(ROLE_CANNIBAL_OID, 2); @@ -2243,7 +2243,7 @@ public void test649ElaineUnassignRoleGovernor() throws Exception { final String TEST_NAME = "test649ElaineUnassignRoleGovernor"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_ELAINE_OID); @@ -2275,7 +2275,7 @@ public void test650BignoseAssignRoleCannibalAsOwner() throws Exception { .assignments() .assertNone(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -2297,7 +2297,7 @@ public void test651BignoseAssignRoleCannibalAsApprover() throws Exception { final String TEST_NAME = "test651BignoseAssignRoleCannibalAsApprover"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -2323,7 +2323,7 @@ public void test655BignoseAssignRoleCannibal() throws Exception { final String TEST_NAME = "test655BignoseAssignRoleCannibal"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -2347,7 +2347,7 @@ public void test656BignoseUnassignRoleCannibal() throws Exception { final String TEST_NAME = "test656BignoseUnassignRoleCannibal"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -2370,7 +2370,7 @@ public void test658BignoseUnassignRoleCannibalAsOwner() throws Exception { final String TEST_NAME = "test658BignoseUnassignRoleCannibalAsOwner"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> modifications = new ArrayList<>(); @@ -2396,7 +2396,7 @@ public void test700JackAssignRoleJudge() throws Exception { final String TEST_NAME = "test700JackModifyJudgeRecompute"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -2421,7 +2421,7 @@ public void test701JackModifyJudgeDeleteConstructionRecompute() throws Exception final String TEST_NAME = "test701JackModifyJudgeDeleteConstructionRecompute"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -2451,7 +2451,7 @@ public void test702JackModifyJudgeAddInducementHonorabilityRecompute() throws Ex final String TEST_NAME = "test702JackModifyJudgeAddInducementHonorabilityRecompute"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -2486,7 +2486,7 @@ public void test703JackModifyJudgeDeleteInducementHonorabilityRecompute() throws final String TEST_NAME = "test703JackModifyJudgeDeleteInducementHonorabilityRecompute"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -2521,7 +2521,7 @@ public void test709JackUnAssignRoleJudge() throws Exception { final String TEST_NAME = "test709JackUnAssignRoleJudge"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -2545,7 +2545,7 @@ public void test710JackAssignRoleEmpty() throws Exception { final String TEST_NAME = "test710JackAssignRoleEmpty"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -2570,7 +2570,7 @@ public void test712JackModifyEmptyRoleAddInducementPirateRecompute() throws Exce final String TEST_NAME = "test712JackModifyEmptyRoleAddInducementPirateRecompute"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -2602,7 +2602,7 @@ public void test714JackModifyEmptyRoleDeleteInducementPirateRecompute() throws E final String TEST_NAME = "test714JackModifyEmptyRoleDeleteInducementPirateRecompute"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -2629,7 +2629,7 @@ public void test719JackUnAssignRoleEmpty() throws Exception { final String TEST_NAME = "test719JackUnAssignRoleEmpty"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -2653,7 +2653,7 @@ public void test720JackAssignRoleGovernorTenantRef() throws Exception { final String TEST_NAME = "test720JackAssignRoleGovernorTenantRef"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -2684,7 +2684,7 @@ public void test729JackUnassignRoleGovernorTenantRef() throws Exception { final String TEST_NAME = "test729JackUnassignRoleGovernorTenantRef"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -2716,7 +2716,7 @@ public void test750JackAssignRoleOmnimanager() throws Exception { final String TEST_NAME = "test750JackAssignRoleOmnimanager"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -2747,7 +2747,7 @@ public void test755AddProjectAndRecomputeJack() throws Exception { final String TEST_NAME = "test755AddProjectAndRecomputeJack"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -2782,7 +2782,7 @@ public void test759JackUnassignRoleOmnimanager() throws Exception { final String TEST_NAME = "test759JackUnassignRoleOmnimanager"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -2813,7 +2813,7 @@ public void test760JackAssignRoleWeakGossiper() throws Exception { final String TEST_NAME = "test760JackAssignRoleWeakGossiper"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -2849,7 +2849,7 @@ public void test761JackRecompute() throws Exception { final String TEST_NAME = "test761JackRecompute"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -2882,7 +2882,7 @@ public void test762JackReconcile() throws Exception { final String TEST_NAME = "test762JackReconcile"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -2914,7 +2914,7 @@ public void test762JackReconcile() throws Exception { public void test763PreviewChanges() throws Exception { final String TEST_NAME = "test763PreviewChanges"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -2974,7 +2974,7 @@ public void test764JackAssignRoleSailor() throws Exception { final String TEST_NAME = "test764JackAssignRoleSailor"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3013,7 +3013,7 @@ public void test765JackRecompute() throws Exception { final String TEST_NAME = "test765JackRecompute"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3051,7 +3051,7 @@ public void test766JackReconcile() throws Exception { final String TEST_NAME = "test766JackReconcile"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3091,7 +3091,7 @@ public void test767JackUnAssignRoleWeakGossiper() throws Exception { final String TEST_NAME = "test767JackUnAssignRoleWeakGossiper"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3128,7 +3128,7 @@ public void test768JackRecompute() throws Exception { final String TEST_NAME = "test768JackRecompute"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3165,7 +3165,7 @@ public void test769JackUnAssignRoleSailor() throws Exception { final String TEST_NAME = "test762JackAssignRoleSailor"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3199,7 +3199,7 @@ public void test770JackAssignRoleSailor() throws Exception { final String TEST_NAME = "test770JackAssignRoleSailor"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3238,7 +3238,7 @@ public void test772JackAssignRoleGossiper() throws Exception { final String TEST_NAME = "test772JackAssignRoleGossiper"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3278,7 +3278,7 @@ public void test774JackUnAssignRoleSailor() throws Exception { final String TEST_NAME = "test774JackUnAssignRoleSailor"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3312,7 +3312,7 @@ public void test775JackUnAssignRoleGossiper() throws Exception { final String TEST_NAME = "test775JackUnAssignRoleGossiper"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3347,7 +3347,7 @@ public void test778JackAssignRoleGossiperAndSailor() throws Exception { final String TEST_NAME = "test778JackAssignRoleGossiperAndSailor"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3393,7 +3393,7 @@ public void test779JackUnassignRoleGossiperAndSailor() throws Exception { final String TEST_NAME = "test779JackUnassignRoleGossiperAndSailor"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3433,7 +3433,7 @@ public void test780JackAssignRoleWeakSinger() throws Exception { final String TEST_NAME = "test780JackAssignRoleWeakSinger"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3470,7 +3470,7 @@ public void test781JackAssignRoleWeakGossiper() throws Exception { final String TEST_NAME = "test781JackAssignRoleWeakGossiper"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3507,7 +3507,7 @@ public void test782JackAssignRoleSailor() throws Exception { final String TEST_NAME = "test782JackAssignRoleSailor"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3549,7 +3549,7 @@ public void test783JackUnassignRoleSailor() throws Exception { final String TEST_NAME = "test783JackUnassignRoleSailor"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3583,7 +3583,7 @@ public void test784JackUnAssignRoleWeakSinger() throws Exception { final String TEST_NAME = "test784JackUnAssignRoleWeakSinger"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3619,7 +3619,7 @@ public void test785JackUnAssignRoleGossiper() throws Exception { final String TEST_NAME = "test785JackUnAssignRoleGossiper"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3653,7 +3653,7 @@ public void test786JackAssignRoleGossiperAndSinger() throws Exception { final String TEST_NAME = "test786JackAssignRoleGossiperAndSinger"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3694,7 +3694,7 @@ public void test788JackUnassignRoleGossiperAndSinger() throws Exception { final String TEST_NAME = "test788JackUnassignRoleGossiperAndSinger"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3735,7 +3735,7 @@ public void test790JackAssignRoleWeakSinger() throws Exception { final String TEST_NAME = "test780JackAssignRoleWeakSinger"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3774,7 +3774,7 @@ public void test791JackSwitchRolesGossiperAndSinger() throws Exception { final String TEST_NAME = "test791JackSwitchRolesGossiperAndSinger"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3816,7 +3816,7 @@ public void test792JackAssignRoleSailor() throws Exception { final String TEST_NAME = "test792JackAssignRoleSailor"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3860,7 +3860,7 @@ public void test793JackSwitchRolesSingerAndGossiper() throws Exception { final String TEST_NAME = "test793JackSwitchRolesSingerAndGossiper"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3906,7 +3906,7 @@ public void test794JackSwitchRolesSailorAndGossiper() throws Exception { final String TEST_NAME = "test793JackSwitchRolesSingerAndGossiper"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3946,7 +3946,7 @@ public void test795JackSwitchRolesSingerAndSailor() throws Exception { final String TEST_NAME = "test795JackSwitchRolesSingerAndSailor"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3992,7 +3992,7 @@ public void test796JackSwitchRolesSailorAndGovernor() throws Exception { final String TEST_NAME = "test796JackSwitchRolesSailorAndGovernor"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -4039,7 +4039,7 @@ public void test799JackUnassignGovernorAndWeakGossiper() throws Exception { final String TEST_NAME = "test799JackUnassignGovernorAndWeakGossiper"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -4074,7 +4074,7 @@ public void test800ModifyRoleImmutable() throws Exception { final String TEST_NAME = "test800ModifyRoleImmutable"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); try { @@ -4104,7 +4104,7 @@ public void test802AddGlobalImmutableRole() throws Exception { final String TEST_NAME = "test802AddGlobalImmutableRole"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject role = PrismTestUtil.parseObject(ROLE_IMMUTABLE_GLOBAL_FILE); @@ -4129,7 +4129,7 @@ public void test804ModifyRoleImmutableGlobalIdentifier() throws Exception { final String TEST_NAME = "test804ModifyRoleImmutableGlobalIdentifier"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); try { @@ -4156,7 +4156,7 @@ public void test805ModifyRoleImmutableGlobalDescription() throws Exception { final String TEST_NAME = "test805ModifyRoleImmutableGlobalDescription"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); try { @@ -4187,7 +4187,7 @@ public void test812AddGlobalImmutableDescriptionRole() throws Exception { final String TEST_NAME = "test812AddGlobalImmutableDescriptionRole"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject role = PrismTestUtil.parseObject(ROLE_IMMUTABLE_DESCRIPTION_GLOBAL_FILE); @@ -4215,7 +4215,7 @@ public void test814ModifyRoleImmutableDescriptionGlobalIdentifier() throws Excep final String TEST_NAME = "test814ModifyRoleImmutableDescriptionGlobalIdentifier"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -4239,7 +4239,7 @@ public void test815ModifyRoleImmutableGlobalDescription() throws Exception { final String TEST_NAME = "test815ModifyRoleImmutableGlobalDescription"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); try { @@ -4265,7 +4265,7 @@ public void test826AddNonCreateableRole() throws Exception { final String TEST_NAME = "test826AddNonCreateableRole"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject role = PrismTestUtil.parseObject(ROLE_NON_CREATEABLE_FILE); @@ -4292,7 +4292,7 @@ public void test826bAddCreateableRole() throws Exception { final String TEST_NAME = "test826bAddCreateableRole"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject role = PrismTestUtil.parseObject(ROLE_CREATEABLE_FILE); @@ -4316,7 +4316,7 @@ public void test827AddImmutableAssignRole() throws Exception { final String TEST_NAME = "test827AddImmutableAssignRole"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject role = PrismTestUtil.parseObject(ROLE_IMMUTABLE_ASSIGN_FILE); @@ -4348,7 +4348,7 @@ public void test828ModifyUntouchableMetarole() throws Exception { final String TEST_NAME = "test828ModifyUntouchableMetarole"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -4370,7 +4370,7 @@ public void test830ModifyRoleJudge() throws Exception { final String TEST_NAME = "test830ModifyRoleJudge"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -4392,7 +4392,7 @@ public void test840AssignRoleNonAssignable() throws Exception { final String TEST_NAME = "test840AssignRoleNonAssignable"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userJackBefore = getUser(USER_JACK_OID); @@ -4422,7 +4422,7 @@ public void test850JackAssignRoleBloodyFool() throws Exception { final String TEST_NAME = "test850JackAssignRoleBloodyFool"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -4459,7 +4459,7 @@ public void test855JackModifyFoolMetaroleDeleteInducement() throws Exception { final String TEST_NAME = "test855JackModifyFoolMetaroleDeleteInducement"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -4486,7 +4486,7 @@ public void test857JackReconcile() throws Exception { final String TEST_NAME = "test857JackReconcile"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -4528,7 +4528,7 @@ public void test870AssignRoleScreaming() throws Exception { notificationManager.setDisabled(false); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userJackBefore = getUser(USER_JACK_OID); @@ -4563,7 +4563,7 @@ public void test880GlobalRuleOnChange() throws Exception { final String TEST_NAME = "test880GlobalRuleOnChange"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userJackBefore = getUser(USER_JACK_OID); @@ -4584,7 +4584,7 @@ public void test890DeleteRoleUndeletable() throws Exception { final String TEST_NAME = "test890DeleteRoleUndeletable"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); try { @@ -4605,7 +4605,7 @@ public void test892DeleteRoleUndeletableGlobal() throws Exception { final String TEST_NAME = "test892DeleteRoleUndeletableGlobal"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); try { @@ -4627,7 +4627,7 @@ public void test900ModifyDetectingRole() throws Exception { final String TEST_NAME = "test900ModifyDetectingRole"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestSegregationOfDuties.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestSegregationOfDuties.java index baf70d05de2..813b527f2c6 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestSegregationOfDuties.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestSegregationOfDuties.java @@ -36,7 +36,6 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.CommunicationException; @@ -189,7 +188,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti public void test110SimpleExclusion1() throws Exception { final String TEST_NAME = "test110SimpleExclusion1"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // This should go well @@ -221,7 +220,7 @@ public void test110SimpleExclusion1() throws Exception { public void test120SimpleExclusion2() throws Exception { final String TEST_NAME = "test120SimpleExclusion2"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // This should go well @@ -245,7 +244,7 @@ public void test120SimpleExclusion2() throws Exception { public void test130SimpleExclusionBoth1() throws Exception { final String TEST_NAME = "test130SimpleExclusionBoth1"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> modifications = new ArrayList<>(); @@ -269,7 +268,7 @@ public void test130SimpleExclusionBoth1() throws Exception { public void test140SimpleExclusionBoth2() throws Exception { final String TEST_NAME = "test140SimpleExclusionBoth2"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> modifications = new ArrayList<>(); @@ -293,7 +292,7 @@ public void test140SimpleExclusionBoth2() throws Exception { public void test150SimpleExclusionBothBidirectional1() throws Exception { final String TEST_NAME = "test150SimpleExclusionBothBidirectional1"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> modifications = new ArrayList<>(); @@ -317,7 +316,7 @@ public void test150SimpleExclusionBothBidirectional1() throws Exception { public void test160SimpleExclusionBothBidirectional2() throws Exception { final String TEST_NAME = "test160SimpleExclusionBothBidirectional2"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> modifications = new ArrayList<>(); @@ -341,7 +340,7 @@ public void test160SimpleExclusionBothBidirectional2() throws Exception { public void test171SimpleExclusion1WithPolicyException() throws Exception { final String TEST_NAME = "test171SimpleExclusion1WithPolicyException"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assignRole(USER_JACK_OID, ROLE_JUDGE_OID, task, result); @@ -362,7 +361,7 @@ public void test171SimpleExclusion1WithPolicyException() throws Exception { public void test172SimpleExclusion2WithPolicyException() throws Exception { final String TEST_NAME = "test172SimpleExclusion2WithPolicyException"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, null, getJudgeExceptionBlock(ROLE_PIRATE_NAME), task, result); @@ -383,7 +382,7 @@ public void test172SimpleExclusion2WithPolicyException() throws Exception { public void test173SimpleExclusion3WithPolicyException() throws Exception { final String TEST_NAME = "test173SimpleExclusion3WithPolicyException"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); @@ -404,7 +403,7 @@ public void test173SimpleExclusion3WithPolicyException() throws Exception { public void test174SimpleExclusion4WithPolicyException() throws Exception { final String TEST_NAME = "test174SimpleExclusion4WithPolicyException"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assignRole(USER_JACK_OID, ROLE_JUDGE_OID, null, getJudgeExceptionBlock(ROLE_PIRATE_NAME), task, result); @@ -430,7 +429,7 @@ public void test174SimpleExclusion4WithPolicyException() throws Exception { public void test180JudgeExceptionalPirateAndThief() throws Exception { final String TEST_NAME = "test180JudgeExceptionalPirateAndThief"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assignRole(USER_JACK_OID, ROLE_JUDGE_OID, task, result); @@ -469,7 +468,7 @@ private Consumer getJudgeExceptionBlock(String excludedRoleName) public void test190DifferentRelations() throws Exception { final String TEST_NAME = "test190DifferentRelations"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> modifications = new ArrayList<>(); @@ -492,7 +491,7 @@ public void test190DifferentRelations() throws Exception { public void test193BothRelationsApprover() throws Exception { final String TEST_NAME = "test193BothRelationsApprover"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> modifications = new ArrayList<>(); @@ -515,7 +514,7 @@ public void test193BothRelationsApprover() throws Exception { public void test194MemberAndManager() throws Exception { final String TEST_NAME = "test194MemberAndManager"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> modifications = new ArrayList<>(); @@ -546,7 +545,7 @@ public void test200GuybrushAssignRoleGold() throws Exception { final String TEST_NAME = "test200GuybrushAssignRoleGold"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -579,7 +578,7 @@ public void test202GuybrushAssignRoleSilver() throws Exception { final String TEST_NAME = "test202GuybrushAssignRoleSilver"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -613,7 +612,7 @@ public void test204GuybrushAssignRoleSailor() throws Exception { final String TEST_NAME = "test204GuybrushAssignRoleSailor"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -648,7 +647,7 @@ public void test206GuybrushAssignRoleBronze() throws Exception { final String TEST_NAME = "test206GuybrushAssignRoleBronze"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -682,7 +681,7 @@ public void test208GuybrushUnassignRoleBronze() throws Exception { final String TEST_NAME = "test208GuybrushUnassignRoleSilver"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -714,7 +713,7 @@ public void test209GuybrushUnassignRoleSailor() throws Exception { final String TEST_NAME = "test209GuybrushUnassignRoleSailor"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -744,7 +743,7 @@ public void test209aGuybrushAssignRoleGoldAndSilverEnforced() throws Exception { final String TEST_NAME = "test209aGuybrushAssignRoleGoldAndSilverEnforced"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -776,7 +775,7 @@ public void test209bGuybrushAssignRoleGoldAndSilver() throws Exception { final String TEST_NAME = "test209bGuybrushAssignRoleGoldAndSilver"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -808,7 +807,7 @@ public void test210GuybrushAssignRoleRed() throws Exception { final String TEST_NAME = "test210GuybrushAssignRoleRed"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -839,7 +838,7 @@ public void test212GuybrushAssignRoleGreen() throws Exception { final String TEST_NAME = "test212GuybrushAssignRoleGreen"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -871,7 +870,7 @@ public void test214GuybrushAssignRoleColorNone() throws Exception { final String TEST_NAME = "test214GuybrushAssignRoleColorNone"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -901,7 +900,7 @@ public void test216GuybrushAssignRoleBlue() throws Exception { final String TEST_NAME = "test216GuybrushAssignRoleBlue"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -930,7 +929,7 @@ public void test219GuybrushUnassignRoleBlue() throws Exception { final String TEST_NAME = "test219GuybrushUnassignRoleBlue"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -957,7 +956,7 @@ public void test220GuybrushAssignRoleBlue() throws Exception { final String TEST_NAME = "test220GuybrushAssignRoleBlue"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -989,7 +988,7 @@ public void test221GuybrushDestroyAndRecompute() throws Exception { final String TEST_NAME = "test221GuybrushDestroyAndRecompute"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -1029,7 +1028,7 @@ public void test222GuybrushDestroyAndAssignRoleRed() throws Exception { final String TEST_NAME = "test222GuybrushDestroyAndAssignRoleRed"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -1066,7 +1065,7 @@ public void test229GuybrushUnassignRoleRed() throws Exception { final String TEST_NAME = "test229GuybrushUnassignRoleRed"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1096,7 +1095,7 @@ public void test230GuybrushAssignRoleRedAndBlueAndGreen() throws Exception { final String TEST_NAME = "test230GuybrushAssignRoleRedAndBlueAndGreen"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1129,7 +1128,7 @@ public void test240GuybrushAssignRoleExecutiveOne() throws Exception { final String TEST_NAME = "test240GuybrushAssignRoleExecutiveOne"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1153,7 +1152,7 @@ public void test242GuybrushAssignRoleControllingOne() throws Exception { final String TEST_NAME = "test242GuybrushAssignRoleControllingOne"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1171,7 +1170,7 @@ public void test244GuybrushAssignRoleExecutiveTwo() throws Exception { final String TEST_NAME = "test244GuybrushAssignRoleExecutiveTwo"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1196,7 +1195,7 @@ public void test245GuybrushAssignRoleControllingTwo() throws Exception { final String TEST_NAME = "test245GuybrushAssignRoleControllingTwo"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1216,7 +1215,7 @@ public void test246GuybrushUnassignRoleExecutiveOne() throws Exception { final String TEST_NAME = "test246GuybrushUnassignRoleExecutiveOne"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1240,7 +1239,7 @@ public void test247GuybrushAssignRoleControllingOne() throws Exception { final String TEST_NAME = "test247GuybrushAssignRoleControllingOne"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1260,7 +1259,7 @@ public void test249GuybrushUnassignRoleExecutiveTwo() throws Exception { final String TEST_NAME = "test249GuybrushUnassignRoleExecutiveTwo"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1287,7 +1286,7 @@ public void test250GuybrushAssignRoleControllingOne() throws Exception { final String TEST_NAME = "test250GuybrushAssignRoleControllingOne"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1311,7 +1310,7 @@ public void test252GuybrushAssignRoleExecutiveOne() throws Exception { final String TEST_NAME = "test252GuybrushAssignRoleExecutiveOne"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1329,7 +1328,7 @@ public void test259GuybrushUnassignRoleControllingOne() throws Exception { final String TEST_NAME = "test259GuybrushUnassignRoleControllingOne"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1353,7 +1352,7 @@ public void test800ApplyGlobalPolicyRulesExclusion() throws Exception { final String TEST_NAME = "test800ApplyGlobalPolicyRulesExclusion"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1374,7 +1373,7 @@ public void test810GuybrushAssignRoleCitizenSk() throws Exception { final String TEST_NAME = "test810GuybrushAssignRoleCitizenSk"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1395,7 +1394,7 @@ public void test812GuybrushAssignRoleCitizenUs() throws Exception { final String TEST_NAME = "test812GuybrushAssignRoleCitizenUs"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1413,7 +1412,7 @@ public void test814GuybrushAssignRoleEmpty() throws Exception { final String TEST_NAME = "test814GuybrushAssignRoleEmpty"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1435,7 +1434,7 @@ public void test818GuybrushUnassignRoleCitizenSk() throws Exception { final String TEST_NAME = "test818GuybrushUnassignRoleCitizenSk"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1459,7 +1458,7 @@ public void test819GuybrushUnassignRoleEmpty() throws Exception { final String TEST_NAME = "test818GuybrushUnassignRoleCitizenSk"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1484,7 +1483,7 @@ public void test820GuybrushAssignRoleCriminal() throws Exception { final String TEST_NAME = "test820GuybrushAssignRoleCriminal"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1509,7 +1508,7 @@ public void test822GuybrushAssignRoleMinister() throws Exception { final String TEST_NAME = "test822GuybrushAssignRoleMinister"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1533,7 +1532,7 @@ public void test826GuybrushUnassignRoleCriminal() throws Exception { final String TEST_NAME = "test826GuybrushUnassignRoleCriminal"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1555,7 +1554,7 @@ public void test829GuybrushUnassignRoleMinister() throws Exception { final String TEST_NAME = "test829GuybrushUnassignRoleMinister"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1577,7 +1576,7 @@ public void test900ApplyGlobalPolicyRulesSoDApproval() throws Exception { final String TEST_NAME = "test900ApplyGlobalPolicyRulesSoDApproval"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1603,7 +1602,7 @@ public void test920GuybrushAssignRoleCriminal() throws Exception { final String TEST_NAME = "test920GuybrushAssignRoleCriminal"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1632,7 +1631,7 @@ public void test922GuybrushPreviewAssignRoleMinister() throws Exception { final String TEST_NAME = "test922GuybrushPreviewAssignRoleMinister"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = createAssignmentAssignmentHolderDelta(UserType.class, USER_GUYBRUSH_OID, @@ -1709,7 +1708,7 @@ public void test929GuybrushUnassignRoleCriminal() throws Exception { final String TEST_NAME = "test929GuybrushUnassignRoleCriminal"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1737,7 +1736,7 @@ public void test929GuybrushUnassignRoleCriminal() throws Exception { public void test950JackSelfExclusion() throws Exception { final String TEST_NAME = "test950JackSelfExclusion"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // This should go well @@ -1768,7 +1767,7 @@ public void test950JackSelfExclusion() throws Exception { public void test952JackSelfExclusionManagerMember() throws Exception { final String TEST_NAME = "test952JackSelfExclusionManagerMember"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // This should go well @@ -1798,7 +1797,7 @@ public void test952JackSelfExclusionManagerMember() throws Exception { public void test960JimGoldByMapping() throws Exception { final String TEST_NAME = "test960JimGoldByMapping"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // GIVEN diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/scripting/TestScriptingBasic.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/scripting/TestScriptingBasic.java index d8a71676fe5..21e11841c53 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/scripting/TestScriptingBasic.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/scripting/TestScriptingBasic.java @@ -150,7 +150,7 @@ public void test100EmptySequence() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ExpressionSequenceType sequence = new ExpressionSequenceType(); @@ -170,7 +170,7 @@ public void test110EmptyPipeline() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ExpressionPipelineType pipeline = new ExpressionPipelineType(); @@ -213,7 +213,7 @@ public void test120Log() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty logAction = parseAnyData(LOG_FILE); @@ -247,7 +247,7 @@ public void test200SearchUser() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(SEARCH_FOR_USERS_FILE); @@ -268,7 +268,7 @@ public void test202SearchUserWithExpressions() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ExecuteScriptType executeScript = prismContext.parserFor(SEARCH_FOR_USERS_WITH_EXPRESSIONS_FILE).parseRealValue(); VariablesMap variables = new VariablesMap(); @@ -295,7 +295,7 @@ public void test205SearchForResources() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(SEARCH_FOR_RESOURCES_FILE); @@ -315,7 +315,7 @@ public void test206SearchForRoles() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(SEARCH_FOR_ROLES_FILE); @@ -335,7 +335,7 @@ public void test210SearchForShadows() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(SEARCH_FOR_SHADOWS_FILE); @@ -356,7 +356,7 @@ public void test215SearchForShadowsNoFetch() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(SEARCH_FOR_SHADOWS_NOFETCH_FILE); @@ -377,7 +377,7 @@ public void test220SearchForUsersAccounts() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(SEARCH_FOR_USERS_ACCOUNTS_FILE); @@ -398,7 +398,7 @@ public void test225SearchForUsersAccountsNoFetch() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(SEARCH_FOR_USERS_ACCOUNTS_NOFETCH_FILE); @@ -419,7 +419,7 @@ public void test300DisableJack() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(DISABLE_JACK_FILE); @@ -441,7 +441,7 @@ public void test310EnableJack() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(ENABLE_JACK_FILE); @@ -463,7 +463,7 @@ public void test320DeleteAndAddJack() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(DELETE_AND_ADD_JACK_FILE); @@ -485,7 +485,7 @@ public void test330ModifyJack() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(MODIFY_JACK_FILE); @@ -507,7 +507,7 @@ public void test340ModifyJackBack() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(MODIFY_JACK_BACK_FILE); @@ -529,7 +529,7 @@ public void test350RecomputeJack() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(RECOMPUTE_JACK_FILE); @@ -550,7 +550,7 @@ public void test360AssignToJack() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(ASSIGN_TO_JACK_FILE); @@ -626,7 +626,7 @@ public void test390AssignToWill() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(ASSIGN_TO_WILL_FILE); @@ -649,7 +649,7 @@ public void test391UnassignFromWill() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(UNASSIGN_FROM_WILL_FILE); @@ -674,7 +674,7 @@ public void test392UnassignFromWill2() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(UNASSIGN_FROM_WILL_2_FILE); @@ -699,7 +699,7 @@ public void test393UnassignFromWill3() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(UNASSIGN_FROM_WILL_3_FILE); @@ -726,7 +726,7 @@ public void test394AssignToWill2() throws Exception { // GIVEN QName customRelation = new QName("http://midpoint.evolveum.com/xml/ns/samples/piracy", "piracy:captain"); - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(ASSIGN_TO_WILL_2_FILE); @@ -761,7 +761,7 @@ public void test400PurgeSchema() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(PURGE_DUMMY_BLACK_SCHEMA_FILE); @@ -796,7 +796,7 @@ public void test410TestResource() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(TEST_DUMMY_RESOURCE_FILE); @@ -819,7 +819,7 @@ public void test420NotificationAboutJack() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(NOTIFICATION_ABOUT_JACK_FILE); prepareNotifications(); @@ -847,7 +847,7 @@ public void test430NotificationAboutJackType2() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(NOTIFICATION_ABOUT_JACK_TYPE2_FILE); prepareNotifications(); @@ -880,7 +880,7 @@ public void test500ScriptingUsers() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(SCRIPTING_USERS_FILE); @@ -912,7 +912,7 @@ public void test505ScriptingUsersInBackground() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); ExecuteScriptType exec = prismContext.parserFor(SCRIPTING_USERS_IN_BACKGROUND_FILE).parseRealValue(); @@ -957,7 +957,7 @@ public void test507ScriptingUsersInBackgroundAssign() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); ExecuteScriptType exec = prismContext.parserFor(SCRIPTING_USERS_IN_BACKGROUND_ASSIGN_FILE).parseRealValue(); @@ -996,7 +996,7 @@ public void test510GeneratePasswords() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(GENERATE_PASSWORDS_FILE); @@ -1106,7 +1106,7 @@ public void test540SearchUserResolveNamesForRoleMembershipRef() throws Exception TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(SEARCH_FOR_USERS_RESOLVE_NAMES_FOR_ROLE_MEMBERSHIP_REF_FILE); @@ -1132,7 +1132,7 @@ public void test545SearchUserResolveRoleMembershipRef() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(SEARCH_FOR_USERS_RESOLVE_ROLE_MEMBERSHIP_REF_FILE); @@ -1189,7 +1189,7 @@ public void test560StartTaskFromTemplate() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); repoAddObjectFromFile(SCRIPTING_USERS_IN_BACKGROUND_TASK_FILE, result); @@ -1238,7 +1238,7 @@ public void test570IterativeScriptingTask() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); String taskOid = repoAddObjectFromFile(SCRIPTING_USERS_IN_BACKGROUND_ITERATIVE_TASK_FILE, result).getOid(); @@ -1260,7 +1260,7 @@ public void test575ResumeTask() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/AbstractSecurityTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/AbstractSecurityTest.java index e6581d957ae..4a087fed9c8 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/AbstractSecurityTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/AbstractSecurityTest.java @@ -1102,7 +1102,7 @@ protected void assertCanSearchRoleMembers(String roleOid, boolean expectedResult } protected void assertCanSearch(String message, Class resultType, Class objectType, String objectOid, boolean includeSpecial, ObjectQuery query, boolean expectedResult) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = createTask("assertCanSearch"); + Task task = getTestTask(); OperationResult result = task.getResult(); String opName = "canSearch("+message+")"; logAttempt(opName); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityAdvanced.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityAdvanced.java index 0496c54a452..52da63f9549 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityAdvanced.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityAdvanced.java @@ -15,7 +15,6 @@ import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; @@ -23,7 +22,6 @@ import org.testng.annotations.Test; import com.evolveum.midpoint.model.api.ModelAuthorizationAction; -import com.evolveum.midpoint.model.api.RoleSelectionSpecification; import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.query.ObjectFilter; import com.evolveum.midpoint.prism.query.ObjectQuery; @@ -1382,7 +1380,7 @@ public void test222AutzJackRoleExpressionConstCenterBusiness() throws Exception cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_EXPRESSION_READ_ROLES_OID); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_JACK_OID, UserType.F_COST_CENTER, task, result, "business"); @@ -1440,7 +1438,7 @@ public void test230AttorneyCaribbeanUnlimited() throws Exception { assertModifyDeny(); assertDeleteDeny(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectFilter donorFilterAll = modelInteractionService.getDonorFilter(UserType.class, null, null, task, result); @@ -1512,7 +1510,7 @@ public void test232ManagerAttorneyNoOrg() throws Exception { assertModifyDeny(); assertDeleteDeny(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectFilter donorFilterAll = modelInteractionService.getDonorFilter(UserType.class, null, null, task, result); @@ -1558,7 +1556,7 @@ public void test234ManagerAttorneyRum() throws Exception { assertModifyDeny(); assertDeleteDeny(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectFilter donorFilterAll = modelInteractionService.getDonorFilter(UserType.class, null, null, task, result); @@ -1626,7 +1624,7 @@ public void test235ManagerAttorneyRumRogersEntitled() throws Exception { assertModifyDeny(); assertDeleteDeny(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectFilter donorFilterAll = modelInteractionService.getDonorFilter(UserType.class, null, null, task, result); @@ -1696,7 +1694,7 @@ public void test236ManagerAttorneyCaribbeanRum() throws Exception { assertModifyDeny(); assertDeleteDeny(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectFilter donorFilterAll = modelInteractionService.getDonorFilter(UserType.class, null, null, task, result); @@ -3278,7 +3276,7 @@ private ObjectQuery createOrgSubtreeAndNameQuery(String orgOid, String name) { } private void modifyJackValidTo() throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - Task task = createTask("modifyJackValidTo"); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_JACK_OID, SchemaConstants.PATH_ACTIVATION_VALID_TO, task, result, JACK_VALID_TO_LONG_AHEAD); assertSuccess(result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityBasic.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityBasic.java index 2a18ec03177..9e47a51c047 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityBasic.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityBasic.java @@ -19,7 +19,6 @@ import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.query.ObjectFilter; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; @@ -1037,7 +1036,7 @@ public void test219AutzJackPropReadSomeModifySomeFullName() throws Exception { .item(UserType.F_GIVEN_NAME).replace(createPolyString("Jackie")) .asObjectDelta(USER_JACK_OID); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN: preview changes @@ -1835,7 +1834,7 @@ public void test255AutzJackSelfAccountsReadWrite() throws Exception { PrismObject shadow = getObject(ShadowType.class, accountOid); display("Jack's shadow", shadow); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); RefinedObjectClassDefinition rOcDef = modelInteractionService.getEditObjectClassDefinition(shadow, getDummyResourceObject(), null, task, task.getResult()); display("Refined objectclass def", rOcDef); assertAttributeFlags(rOcDef, SchemaConstants.ICFS_UID, true, false, false); @@ -1901,7 +1900,7 @@ public void test256AutzJackSelfAccountsPartialControl() throws Exception { PrismObject shadow = getObject(ShadowType.class, accountOid); display("Jack's shadow", shadow); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); RefinedObjectClassDefinition rOcDef = modelInteractionService.getEditObjectClassDefinition(shadow, getDummyResourceObject(), null, task, result); display("Refined objectclass def", rOcDef); @@ -1983,7 +1982,7 @@ public void test258AutzJackSelfAccountsPartialControlPassword() throws Exception PrismObject shadow = getObject(ShadowType.class, accountOid); display("Jack's shadow", shadow); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); RefinedObjectClassDefinition rOcDef = modelInteractionService.getEditObjectClassDefinition(shadow, getDummyResourceObject(), null, task, result); display("Refined objectclass def", rOcDef); @@ -2046,7 +2045,7 @@ public void test259AutzJackSelfAccountsPartialControl() throws Exception { PrismObject shadow = getObject(ShadowType.class, accountOid); display("Jack's shadow", shadow); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObjectDefinition rOcDef = modelInteractionService.getEditObjectDefinition(shadow, null, task, result); shadow.applyDefinition(rOcDef, true); @@ -2135,7 +2134,7 @@ public void test260AutzJackObjectFilterLocationShadowRole() throws Exception { displayCleanup(TEST_NAME); login(USER_ADMINISTRATOR_USERNAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); PrismObject account = PrismTestUtil.parseObject(ACCOUNT_JACK_DUMMY_RED_FILE); account.setOid(accountRedOid); ObjectDelta userDelta = prismContext.deltaFactory().object() diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityMultitenant.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityMultitenant.java index abbe2596080..116f3759ad7 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityMultitenant.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityMultitenant.java @@ -19,7 +19,6 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.security.api.AuthorizationConstants; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.util.exception.CommunicationException; import com.evolveum.midpoint.util.exception.ConfigurationException; import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; @@ -243,7 +242,7 @@ public void test010ImportOrgstruct() throws Exception { final String TEST_NAME = "test010ImportOrgstruct"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityPrincipal.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityPrincipal.java index ced0b420ff9..e6259b8fa8c 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityPrincipal.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityPrincipal.java @@ -148,7 +148,7 @@ public void test061GuybrushConditionalRoleTrue() throws Exception { final String TEST_NAME = "test061GuybrushConditionalRoleTrue"; login(USER_ADMINISTRATOR_USERNAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_SUBTYPE, task, result, "special"); @@ -204,7 +204,7 @@ public void test100JackRolePirate() throws Exception { final String TEST_NAME = "test100JackRolePirate"; // GIVEN login(USER_ADMINISTRATOR_USERNAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); @@ -237,7 +237,7 @@ public void test109JackUnassignRolePirate() throws Exception { final String TEST_NAME = "test109JackUnassignRolePirate"; // GIVEN login(USER_ADMINISTRATOR_USERNAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); unassignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); @@ -267,7 +267,7 @@ public void test110GuybrushRoleNicePirate() throws Exception { final String TEST_NAME = "test110GuybrushRoleNicePirate"; // GIVEN login(USER_ADMINISTRATOR_USERNAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assignRole(USER_GUYBRUSH_OID, ROLE_NICE_PIRATE_OID, task, result); @@ -291,7 +291,7 @@ public void test111GuybrushRoleCaptain() throws Exception { final String TEST_NAME = "test111GuybrushRoleCaptain"; // GIVEN login(USER_ADMINISTRATOR_USERNAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assignRole(USER_GUYBRUSH_OID, ROLE_CAPTAIN_OID, task, result); @@ -315,7 +315,7 @@ public void test119GuybrushUnassignRoles() throws Exception { final String TEST_NAME = "test119GuybrushUnassignRoles"; // GIVEN login(USER_ADMINISTRATOR_USERNAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); unassignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); unassignRole(USER_JACK_OID, ROLE_CAPTAIN_OID, task, result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractInboundSyncTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractInboundSyncTest.java index cfa017da3bc..05007a027b4 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractInboundSyncTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractInboundSyncTest.java @@ -97,7 +97,8 @@ public void test100ImportLiveSyncTaskDummyEmerald() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(AbstractInboundSyncTest.class.getName() + "." + TEST_NAME); + AbstractInboundSyncTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); /// WHEN @@ -116,7 +117,8 @@ public void test110AddDummyEmeraldAccountMancomb() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(AbstractInboundSyncTest.class.getName() + "." + TEST_NAME); + AbstractInboundSyncTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); @@ -174,7 +176,8 @@ public void test120ModifyDummyEmeraldAccountMancombSeepbad() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(AbstractInboundSyncTest.class.getName() + "." + TEST_NAME); + AbstractInboundSyncTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); @@ -229,7 +232,8 @@ public void test122ModifyDummyEmeraldAccountMancombSeepNULL() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(AbstractInboundSyncTest.class.getName() + "." + TEST_NAME); + AbstractInboundSyncTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); @@ -284,7 +288,8 @@ public void test124ModifyDummyEmeraldAccountMancombSeepevil() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(AbstractInboundSyncTest.class.getName() + "." + TEST_NAME); + AbstractInboundSyncTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); @@ -339,7 +344,8 @@ public void test126ModifyDummyEmeraldAccountMancombTitlePirate() throws Exceptio TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(AbstractInboundSyncTest.class.getName() + "." + TEST_NAME); + AbstractInboundSyncTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); @@ -395,7 +401,8 @@ public void test127ModifyDummyEmeraldAccountMancombTitlePirateNull() throws Exce TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(AbstractInboundSyncTest.class.getName() + "." + TEST_NAME); + AbstractInboundSyncTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); @@ -451,7 +458,8 @@ public void test129ModifyDummyEmeraldAccountMancombSeepgood() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(AbstractInboundSyncTest.class.getName() + "." + TEST_NAME); + AbstractInboundSyncTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); @@ -516,7 +524,8 @@ public void test300AddDummyEmeraldAccountPosixUser() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(AbstractInboundSyncTest.class.getName() + "." + TEST_NAME); + AbstractInboundSyncTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); @@ -574,7 +583,8 @@ public void test310ModifyDummyEmeraldAccountPosixUserUidNumber() throws Exceptio TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(AbstractInboundSyncTest.class.getName() + "." + TEST_NAME); + AbstractInboundSyncTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractObjTemplateSyncTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractObjTemplateSyncTest.java index b8e13a1b2e2..1225ebf6448 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractObjTemplateSyncTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractObjTemplateSyncTest.java @@ -13,7 +13,6 @@ import com.evolveum.midpoint.prism.xml.XmlTypeConverter; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.MiscUtil; @@ -113,7 +112,8 @@ public void test100ImportLiveSyncTaskDummyByzantine() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(AbstractObjTemplateSyncTest.class.getName() + "." + TEST_NAME); + AbstractObjTemplateSyncTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); /// WHEN @@ -132,7 +132,8 @@ public void test110AddDummyByzantineAccountMancomb() throws Exception { final String TEST_NAME = "test110AddDummyByzantineAccountMancomb"; // GIVEN - Task task = createTask(AbstractObjTemplateSyncTest.class.getName() + "." + TEST_NAME); + AbstractObjTemplateSyncTest.class.getName(); + Task task = getTestTask(); rememberTimeBeforeSync(); prepareNotifications(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractSynchronizationStoryTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractSynchronizationStoryTest.java index 8c695447c32..b345d59b4f9 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractSynchronizationStoryTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractSynchronizationStoryTest.java @@ -19,7 +19,6 @@ import javax.xml.namespace.QName; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; @@ -108,7 +107,8 @@ public void test100ImportLiveSyncTaskDummyGreen() throws Exception { final String TEST_NAME = "test100ImportLiveSyncTaskDummyGreen"; // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); /// WHEN @@ -126,7 +126,8 @@ public void test110AddDummyGreenAccountMancomb() throws Exception { final String TEST_NAME = "test110AddDummyGreenAccountMancomb"; // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); @@ -192,7 +193,8 @@ public void test200ImportLiveSyncTaskDummyBlue() throws Exception { final String TEST_NAME = "test200ImportLiveSyncTaskDummyBlue"; // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); /// WHEN @@ -213,7 +215,8 @@ public void test210AddDummyGreenAccountWally() throws Exception { final String TEST_NAME = "test210AddDummyGreenAccountWally"; // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); @@ -264,7 +267,8 @@ public void test220AddDummyBlueAccountWally() throws Exception { final String TEST_NAME = "test220AddDummyBlueAccountWally"; // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); @@ -327,7 +331,8 @@ public void test315AddDummyBlueAccountMancomb() throws Exception { final String TEST_NAME = "test315AddDummyBlueAccountMancomb"; // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); @@ -383,7 +388,8 @@ public void test350ImportLiveSyncTaskDummyDefault() throws Exception { final String TEST_NAME = "test350ImportLiveSyncTaskDummyDefault"; // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); /// WHEN @@ -410,7 +416,8 @@ public void test360ModifyUserAddDummyDefaultAccount() throws Exception { final String TEST_NAME = "test360ModifyUserAddDummyDefaultAccount"; // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); @@ -525,7 +532,8 @@ public void test370ModifyDummyGreenAccountWally() throws Exception { final String TEST_NAME = "test370ModifyDummyGreenAccountWally"; // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); repoAddObjectFromFile(USER_TEMPLATE_SYNC_FILENAME, result); @@ -610,7 +618,8 @@ public void test380ModifyUserWallyFullName() throws Exception { final String TEST_NAME = "test380ModifyUserWallyFullName"; // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); @@ -679,7 +688,8 @@ public void test382ModifyUserWallyLocality() throws Exception { final String TEST_NAME = "test382ModifyUserWallyLocality"; // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); @@ -759,7 +769,8 @@ public void test400DeleteDummyDefaultAccount() throws Exception { final String TEST_NAME = "test400DeleteDummyDefaultAccount"; // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); @@ -827,7 +838,8 @@ public void test410DeleteDummyGreenAccount() throws Exception { final String TEST_NAME = "test410DeleteDummyGreenAccount"; // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareNotifications(); @@ -921,7 +933,8 @@ public void test510AddDummyGreenAccountWallyUserTemplate() throws Exception { final String TEST_NAME = "test510AddDummyGreenAccountWallyUserTemplate"; // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); @@ -964,7 +977,8 @@ public void test600AddDummyGreenAccountCalypso() throws Exception { final String TEST_NAME = "test600AddDummyGreenAccountCalypso"; // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); @@ -1009,7 +1023,8 @@ public void test700AddDummyGreenAccountXjojo() throws Exception { final String TEST_NAME = "test700AddDummyGreenAccountXjojo"; // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestImportRecon.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestImportRecon.java index 0d83abda207..7103f287906 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestImportRecon.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestImportRecon.java @@ -362,7 +362,7 @@ public void test100ImportStanFromResourceDummy() throws Exception { final String TEST_NAME = "test100ImportStanFromResourceDummy"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -410,7 +410,7 @@ public void test150ImportFromResourceDummy() throws Exception { final String TEST_NAME = "test150ImportFromResourceDummy"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -479,7 +479,7 @@ public void test155ImportFromResourceDummyAgain() throws Exception { final String TEST_NAME = "test155ImportFromResourceDummyAgain"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -538,7 +538,7 @@ public void test160ImportFromResourceDummyLime() throws Exception { final String TEST_NAME = "test160ImportFromResourceDummyLime"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -610,7 +610,7 @@ public void test162ImportFromResourceDummyLimeRappOrganizationScummBar() throws final String TEST_NAME = "test162ImportFromResourceDummyLimeRappOrganizationScummBar"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -693,7 +693,7 @@ public void test164ImportFromResourceDummyLimeRappOrganizationNull() throws Exce final String TEST_NAME = "test164ImportFromResourceDummyLimeRappOrganizationNull"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -775,7 +775,7 @@ public void test200ReconcileDummy() throws Exception { // GIVEN loginAdministrator(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -894,7 +894,7 @@ public void test210ReconcileDummyBroken() throws Exception { final String TEST_NAME = "test210ReconcileDummyBroken"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -965,7 +965,7 @@ public void test219ReconcileDummyFixed() throws Exception { final String TEST_NAME = "test219ReconcileDummyFixed"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -1044,7 +1044,7 @@ public void test220ReconcileDummyBrokenGuybrush() throws Exception { final String TEST_NAME = "test220ReconcileDummyBrokenGuybrush"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -1118,7 +1118,7 @@ public void test229ReconcileDummyFixed() throws Exception { final String TEST_NAME = "test229ReconcileDummyFixed"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -1200,7 +1200,7 @@ public void test230ReconcileDummyRename() throws Exception { final String TEST_NAME = "test230ReconcileDummyRename"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -1323,7 +1323,7 @@ public void test300ReconcileDummyAzureAddAccountOtis() throws Exception { final String TEST_NAME = "test300ReconcileDummyAzureAddAccountOtis"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); getDummyResource().setBreakMode(BreakMode.NONE); @@ -1387,7 +1387,7 @@ public void test310ReconcileDummyAzureAgain() throws Exception { final String TEST_NAME = "test310ReconcileDummyAzureAgain"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); getDummyResource().setBreakMode(BreakMode.NONE); @@ -1453,7 +1453,7 @@ public void test320ReconcileDummyAzureDeleteOtis() throws Exception { final String TEST_NAME = "test320ReconcileDummyAzureDeleteOtis"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); getDummyResource().setBreakMode(BreakMode.NONE); @@ -1525,7 +1525,7 @@ public void test330ReconcileDummyAzureAddAccountRapp() throws Exception { final String TEST_NAME = "test330ReconcileDummyAzureAddAccountRapp"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); getDummyResource().setBreakMode(BreakMode.NONE); @@ -1621,7 +1621,7 @@ public void test332ModifyUserRappAndReconcileDummyAzure() throws Exception { final String TEST_NAME = "test332ModifyUserRappAndReconcileDummyAzure"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); getDummyResource().setBreakMode(BreakMode.NONE); @@ -1704,7 +1704,7 @@ public void test334AssignRoleCorpseToRappAndReconcileDummyAzure() throws Excepti final String TEST_NAME = "test334AssignRoleCorpseToRappAndReconcileDummyAzure"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); getDummyResource().setBreakMode(BreakMode.NONE); @@ -1772,7 +1772,7 @@ public void test339ReconcileDummyAzureDeleteRapp() throws Exception { final String TEST_NAME = "test339ReconcileDummyAzureDeleteRapp"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); getDummyResource().setBreakMode(BreakMode.NONE); @@ -1848,7 +1848,7 @@ public void test400ReconcileDummyLimeAddAccount() throws Exception { final String TEST_NAME = "test400ReconcileDummyLimeAddAccount"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -1901,7 +1901,7 @@ public void test401ReconcileDummyLimeKateOnlyEmpty() throws Exception { final String TEST_NAME = "test401ReconcileDummyLimeKateOnlyEmpty"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -1950,7 +1950,7 @@ public void test402ReconcileDummyLimeKateOnlyGrog() throws Exception { final String TEST_NAME = "test402ReconcileDummyLimeKateOnlyGrog"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -1997,7 +1997,7 @@ public void test403ReconcileDummyLimeKateOnlyNoValue() throws Exception { final String TEST_NAME = "test403ReconcileDummyLimeKateOnlyNoValue"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -2043,7 +2043,7 @@ public void test404ReconcileDummyLimeKateOnlyRum() throws Exception { final String TEST_NAME = "test404ReconcileDummyLimeKateOnlyRum"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -2090,7 +2090,7 @@ public void test405ReconcileDummyLimeKateOnlyEmpty() throws Exception { final String TEST_NAME = "test405ReconcileDummyLimeKateOnlyEmpty"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -2137,7 +2137,7 @@ public void test406ReconcileDummyLimeKateOnlyEmptyAgain() throws Exception { final String TEST_NAME = "test406ReconcileDummyLimeKateOnlyEmptyAgain"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -2179,7 +2179,7 @@ public void test410ReconcileDummyLimeKatePassword() throws Exception { final String TEST_NAME = "test410ReconcileDummyLimeKatePassword"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -2225,7 +2225,7 @@ public void test420ReconcileDummyLimeDeleteLinkedAccount() throws Exception { final String TEST_NAME = "test420ReconcileDummyLimeDeleteLinkedAccount"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -2278,7 +2278,7 @@ public void test500ImportTAugustusFromResourceDummy() throws Exception { final String TEST_NAME = "test500ImportTAugustusFromResourceDummy"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -2343,7 +2343,7 @@ public void test502ImportAugustusFromResourceDummy() throws Exception { final String TEST_NAME = "test502ImportAugustusFromResourceDummy"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -2412,7 +2412,7 @@ public void test510ImportFromResourceDummy() throws Exception { final String TEST_NAME = "test510ImportFromResourceDummy"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -2509,7 +2509,7 @@ public void test520ReconResourceDummyFilter() throws Exception { final String TEST_NAME = "test520ReconResourceDummyFilter"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); // Preconditions @@ -2545,7 +2545,7 @@ public void test600SearchAllDummyAccounts() throws Exception { // GIVEN loginAdministrator(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(RESOURCE_DUMMY_OID, @@ -2570,7 +2570,7 @@ public void test610SearchDummyAccountsNameSubstring() throws Exception { final String TEST_NAME = "test610SearchDummyAccountsNameSubstring"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = @@ -2599,7 +2599,7 @@ public void test900DeleteDummyShadows() throws Exception { final String TEST_NAME = "test900DeleteDummyShadows"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Preconditions @@ -2644,7 +2644,7 @@ public void test910DeleteDummyAccounts() throws Exception { final String TEST_NAME = "test910DeleteDummyAccounts"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Preconditions diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundLiveSyncTask.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundLiveSyncTask.java index 97d089cdfc2..10dac92a5be 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundLiveSyncTask.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundLiveSyncTask.java @@ -62,7 +62,8 @@ public void test199DeleteDummyEmeraldAccountMancomb() throws Exception { final String TEST_NAME = "test199DeleteDummyEmeraldAccountMancomb"; // GIVEN - Task task = createTask(AbstractInboundSyncTest.class.getName() + "." + TEST_NAME); + AbstractInboundSyncTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundReconTask.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundReconTask.java index 574aaa87c13..416037f5304 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundReconTask.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundReconTask.java @@ -20,8 +20,6 @@ import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.MiscUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; @@ -69,7 +67,8 @@ public void test180NoChange() throws Exception { final String TEST_NAME = "test180NoChange"; // GIVEN - Task task = createTask(AbstractInboundSyncTest.class.getName() + "." + TEST_NAME); + AbstractInboundSyncTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); rememberTimeBeforeSync(); @@ -111,7 +110,8 @@ public void test199DeleteDummyEmeraldAccountMancomb() throws Exception { final String TEST_NAME = "test199DeleteDummyEmeraldAccountMancomb"; // GIVEN - Task task = createTask(AbstractInboundSyncTest.class.getName() + "." + TEST_NAME); + AbstractInboundSyncTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTask.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTask.java index e0172bbb0f9..f7ab748795e 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTask.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTask.java @@ -83,7 +83,8 @@ public void test999DeletingNotUpdatedShadowDummyGreen() throws Exception { // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTaskMechanics.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTaskMechanics.java index a3b9d2074ed..205ffd9b3b1 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTaskMechanics.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTaskMechanics.java @@ -24,7 +24,6 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.task.api.TaskExecutionStatus; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.TestResource; import com.evolveum.midpoint.util.exception.ObjectNotFoundException; import com.evolveum.midpoint.util.exception.SchemaException; @@ -151,7 +150,8 @@ public void test100SuspendWhileIcfSync() throws Exception { final String TEST_NAME = "test100SuspendWhileIcfSync"; // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // Resource gives out changes slowly now. @@ -181,7 +181,8 @@ public void test105SuspendWhileIcfSyncImprecise() throws Exception { final String TEST_NAME = "test105SuspendWhileIcfSyncImprecise"; // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // Resource gives out changes slowly now. @@ -215,7 +216,8 @@ public void test110SuspendWhileProcessing() throws Exception { final String TEST_NAME = "test110SuspendWhileProcessing"; // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = getStartsWithQuery(USER_P); @@ -270,7 +272,8 @@ public void test115SuspendWhileProcessingImprecise() throws Exception { final String TEST_NAME = "test115SuspendWhileProcessingImprecise"; // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = getStartsWithQuery(USER_I); @@ -313,7 +316,8 @@ public void test120Batched() throws Exception { final String TEST_NAME = "test120Batched"; // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = getStartsWithQuery(USER_P); @@ -380,7 +384,8 @@ public void test125BatchedImprecise() throws Exception { final String TEST_NAME = "test125BatchedImprecise"; // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = getStartsWithQuery(USER_I); @@ -426,7 +431,8 @@ public void test130Error() throws Exception { final String TEST_NAME = "test130Error"; // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = getStartsWithQuery(USER_P); @@ -486,7 +492,8 @@ public void test135ErrorImprecise() throws Exception { final String TEST_NAME = "test135ErrorImprecise"; // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = getStartsWithQuery(USER_I); @@ -552,7 +559,8 @@ public void test140DryRun() throws Exception { final String TEST_NAME = "test140DryRun"; // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = getStartsWithQuery(USER_P); @@ -590,7 +598,8 @@ public void test150DryRunWithUpdate() throws Exception { final String TEST_NAME = "test150DryRunWithUpdate"; // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = getStartsWithQuery(USER_P); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelDiscovery.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelDiscovery.java index 3ab56ed33b2..bb6239b076f 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelDiscovery.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelDiscovery.java @@ -231,7 +231,7 @@ public void test100Synchronize() throws Exception { final String TEST_NAME = "test100Synchronize"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelSynchronization.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelSynchronization.java index 2a4000d7da8..462db5b3a75 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelSynchronization.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelSynchronization.java @@ -20,7 +20,6 @@ import com.evolveum.midpoint.schema.processor.ResourceSchema; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType; @@ -196,7 +195,7 @@ public void test100Synchronize() throws Exception { final String TEST_NAME = "test100Synchronize"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestProgressReporting.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestProgressReporting.java index 80c25f85788..da7da82a910 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestProgressReporting.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestProgressReporting.java @@ -82,7 +82,7 @@ public void test110ReconciliationSuspensionMultiNode() throws Exception { } private void executeReconciliation(TestResource reconciliationTask, String accountPrefix, int workers) throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // GIVEN @@ -162,7 +162,7 @@ public void test160RecomputationSuspensionMultiNode() throws Exception { } private void executeRecomputation(TestResource recomputationTask, String rolePrefix, int workers) throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // GIVEN diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestRecomputeTask.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestRecomputeTask.java index f7021037572..0bfb8f7cb14 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestRecomputeTask.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestRecomputeTask.java @@ -92,7 +92,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100RecomputeAll() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // Preconditions @@ -253,7 +253,7 @@ private void displayRoles(Task task, OperationResult result) throws ObjectNotFou @Test public void test110RecomputeSome() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // Preconditions @@ -309,7 +309,7 @@ public void test110RecomputeSome() throws Exception { @Test public void test120RecomputeByExpression() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); prepareNotifications(); @@ -368,7 +368,7 @@ public void test120RecomputeByExpression() throws Exception { @Test public void test130RecomputeLight() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // Preconditions diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestUuid.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestUuid.java index 4bf2faab8cd..6393de457aa 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestUuid.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestUuid.java @@ -123,7 +123,8 @@ public void test200ReconcileDummyUuid() throws Exception { final String TEST_NAME = "test200ReconcileDummyUuid"; // GIVEN - Task task = createTask(TestUuid.class.getName() + "." + TEST_NAME); + TestUuid.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -172,7 +173,8 @@ public void test210ReconcileDummyUuidAddAugustus() throws Exception { final String TEST_NAME = "test210ReconcileDummyUuidAddAugustus"; // GIVEN - Task task = createTask(TestUuid.class.getName() + "." + TEST_NAME); + TestUuid.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -239,7 +241,8 @@ public void test220ReconcileDummyUuidDeleteAddAugustus() throws Exception { final String TEST_NAME = "test220ReconcileDummyUuidDeleteAddAugustus"; // GIVEN - Task task = createTask(TestUuid.class.getName() + "." + TEST_NAME); + TestUuid.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -328,7 +331,8 @@ public void test230ReconcileDummyUuidDeleteAugustusAddAugustina() throws Excepti final String TEST_NAME = "test230ReconcileDummyUuidDeleteAugustusAddAugustina"; // GIVEN - Task task = createTask(TestUuid.class.getName() + "." + TEST_NAME); + TestUuid.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestValidityRecomputeTask.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestValidityRecomputeTask.java index 3bf20bd52af..14405e2e69c 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestValidityRecomputeTask.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestValidityRecomputeTask.java @@ -85,7 +85,7 @@ public void test100ImportValidityScannerTask() throws Exception { final String TEST_NAME = "test100ImportValidityScannerTask"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Pretend that the user was added a long time ago @@ -121,7 +121,7 @@ public void test110JackAssignJudgeDisabled() throws Exception { final String TEST_NAME = "test110JackAssignJudgeDisabled"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ActivationType activationType = new ActivationType(); @@ -135,7 +135,7 @@ public void test111JackAssignJudgeNotYetValid() throws Exception { final String TEST_NAME = "test111JackAssignJudgeNotYetValid"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ActivationType activationType = new ActivationType(); @@ -151,7 +151,7 @@ public void test112JackAssignJudgeAfterValidity() throws Exception { final String TEST_NAME = "test112JackAssignJudgeAfterValidity"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ActivationType activationType = new ActivationType(); @@ -167,7 +167,7 @@ public void test115JackAssignJudgeEnabled() throws Exception { final String TEST_NAME = "test115JackAssignJudgeEnabled"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ActivationType activationType = new ActivationType(); @@ -181,7 +181,7 @@ public void test115JackAssignJudgeValid() throws Exception { final String TEST_NAME = "test115JackAssignJudgeValid"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ActivationType activationType = new ActivationType(); @@ -270,7 +270,7 @@ public void test120JackDisableAssignmentJudge() throws Exception { final String TEST_NAME = "test120JackDisableAssignmentJudge"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ActivationType activationType = new ActivationType(); @@ -301,7 +301,7 @@ public void test122JackReplaceNullAdministrativeStatusAssignmentJudge() throws E final String TEST_NAME = "test122JackReplaceNullAdministrativeStatusAssignmentJudge"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertNoDummyAccount(null, USER_JACK_USERNAME); @@ -325,7 +325,7 @@ public void test123JackDisableAssignmentJudge() throws Exception { final String TEST_NAME = "test123JackDisableAssignmentJudge"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertDummyAccount(null, USER_JACK_USERNAME); @@ -349,7 +349,7 @@ public void test124JackEnableAssignmentJudge() throws Exception { final String TEST_NAME = "test124JackEnableAssignmentJudge"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertNoDummyAccount(null, USER_JACK_USERNAME); @@ -373,7 +373,7 @@ public void test125JackDeleteAdministrativeStatusAssignmentJudge() throws Except final String TEST_NAME = "test125JackDeleteAdministrativeStatusAssignmentJudge"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertDummyAccount(null, USER_JACK_USERNAME); @@ -399,7 +399,7 @@ public void test126JackAddAdministrativeStatusAssignmentJudge() throws Exception final String TEST_NAME = "test126JackAddAdministrativeStatusAssignmentJudge"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertDummyAccount(null, USER_JACK_USERNAME); @@ -425,7 +425,7 @@ public void test127JackDeleteActivationAssignmentJudge() throws Exception { final String TEST_NAME = "test127JackDeleteActivationAssignmentJudge"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertDummyAccount(null, USER_JACK_USERNAME); @@ -452,7 +452,7 @@ public void test128JackAssignmentJudgeValidToSetInvalid() throws Exception { final String TEST_NAME = "test128JackAssignmentJudgeValidToSetInvalid"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertDummyAccount(null, USER_JACK_USERNAME); @@ -481,7 +481,7 @@ public void test129JackAssignmentJudgeValidToSetValid() throws Exception { final String TEST_NAME = "test129JackAssignmentJudgeValidToSetValid"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertNoDummyAccount(null, USER_JACK_USERNAME); @@ -523,7 +523,7 @@ public void test130BarbossaAssignJudgeEnabled() throws Exception { final String TEST_NAME = "test130BarbossaAssignJudgeEnabled"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // preconditions @@ -568,7 +568,7 @@ public void test131BarbossaAssignSailorEnabled() throws Exception { final String TEST_NAME = "test131BarbossaAssignSailorEnabled"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ActivationType activationType = new ActivationType(); @@ -609,7 +609,7 @@ public void test132BarbossaDisableAssignmentJudge() throws Exception { final String TEST_NAME = "test132BarbossaDisableAssignmentJudge"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); AssignmentType assignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_JUDGE_OID); @@ -649,7 +649,7 @@ public void test133BarbossaDisableAssignmentSailor() throws Exception { final String TEST_NAME = "test133BarbossaDisableAssignmentSailor"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); AssignmentType assignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_SAILOR_OID); @@ -684,7 +684,7 @@ public void test134BarbossaEnableAssignmentJudge() throws Exception { final String TEST_NAME = "test134BarbossaEnableAssignmentJudge"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); AssignmentType assignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_JUDGE_OID); @@ -721,7 +721,7 @@ public void test135BarbossaEnableAssignmentSailor() throws Exception { final String TEST_NAME = "test135BarbossaEnableAssignmentSailor"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); AssignmentType assignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_SAILOR_OID); @@ -758,7 +758,7 @@ public void test136BarbossaDisableBothAssignments() throws Exception { final String TEST_NAME = "test136BarbossaDisableBothAssignments"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); AssignmentType judgeAssignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_JUDGE_OID); @@ -803,7 +803,7 @@ public void test137BarbossaEnableBothAssignments() throws Exception { final String TEST_NAME = "test137BarbossaEnableBothAssignments"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); AssignmentType judgeAssignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_JUDGE_OID); @@ -863,7 +863,7 @@ public void test139BarbossaDisableBothAssignmentsUnassign() throws Exception { final String TEST_NAME = "test139BarbossaDisableBothAssignmentsUnassign"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); AssignmentType judgeAssignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_JUDGE_OID); @@ -942,7 +942,7 @@ public void test140BarbossaAssignRedJudgeEnabled() throws Exception { final String TEST_NAME = "test140BarbossaAssignRedJudgeEnabled"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // preconditions @@ -991,7 +991,7 @@ public void test141BarbossaAssignRedSailorEnabled() throws Exception { final String TEST_NAME = "test141BarbossaAssignRedSailorEnabled"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ActivationType activationType = new ActivationType(); @@ -1032,7 +1032,7 @@ public void test142BarbossaDisableAssignmentRedJudge() throws Exception { final String TEST_NAME = "test142BarbossaDisableAssignmentRedJudge"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); AssignmentType assignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_RED_JUDGE_OID); @@ -1072,7 +1072,7 @@ public void test143BarbossaDisableAssignmentRedSailor() throws Exception { final String TEST_NAME = "test143BarbossaDisableAssignmentRedSailor"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); AssignmentType assignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_RED_SAILOR_OID); @@ -1111,7 +1111,7 @@ public void test144BarbossaEnableAssignmentRedJudge() throws Exception { final String TEST_NAME = "test144BarbossaEnableAssignmentRedJudge"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); AssignmentType assignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_RED_JUDGE_OID); @@ -1148,7 +1148,7 @@ public void test145BarbossaEnableAssignmentRedSailor() throws Exception { final String TEST_NAME = "test145BarbossaEnableAssignmentRedSailor"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); AssignmentType assignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_RED_SAILOR_OID); @@ -1185,7 +1185,7 @@ public void test146BarbossaDisableBothRedAssignments() throws Exception { final String TEST_NAME = "test146BarbossaDisableBothRedAssignments"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); AssignmentType judgeAssignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_RED_JUDGE_OID); @@ -1240,7 +1240,7 @@ public void test147BarbossaEnableBothRedAssignments() throws Exception { final String TEST_NAME = "test147BarbossaEnableBothRedAssignments"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); AssignmentType judgeAssignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_RED_JUDGE_OID); @@ -1300,7 +1300,7 @@ public void test149BarbossaDisableBothRedAssignmentsUnassign() throws Exception final String TEST_NAME = "test149BarbossaDisableBothRedAssignmentsUnassign"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); AssignmentType judgeAssignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_RED_JUDGE_OID); @@ -1379,7 +1379,7 @@ public void test190HermanGoesInvalid() throws Exception { final String TEST_NAME = "test190HermanGoesInvalid"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); XMLGregorianCalendar startCal = clock.currentTimeXMLGregorianCalendar(); @@ -1415,7 +1415,8 @@ public void test200ImportTriggerScannerTask() throws Exception { final String TEST_NAME = "test200ImportTriggerScannerTask"; // GIVEN - Task task = createTask(TestTriggerTask.class.getName() + "." + TEST_NAME); + TestTriggerTask.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); XMLGregorianCalendar startCal = clock.currentTimeXMLGregorianCalendar(); @@ -1794,7 +1795,7 @@ public void test300HermanAssignJudgeNotYetValid() throws Exception { final String TEST_NAME = "test300HermanAssignJudgeNotYetValid"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ActivationType activationType = new ActivationType(); @@ -1821,7 +1822,7 @@ public void test310HermanAssignJudgeBecomesValid() throws Exception { final String TEST_NAME = "test310HermanAssignJudgeBecomesValid"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = getUser(USER_HERMAN_OID); @@ -1843,7 +1844,7 @@ public void test315HermanAssignJudgeBecomesInValid() throws Exception { final String TEST_NAME = "test315HermanAssignJudgeBecomesInValid"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); XMLGregorianCalendar start = (XMLGregorianCalendar) judgeAssignmentValidTo.clone(); diff --git a/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java b/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java index 2f1035c13c1..f463bf9cf99 100644 --- a/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java +++ b/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java @@ -662,7 +662,7 @@ protected ObjectDelta createOldNewPasswordDelta(String oid, String old } protected void modifyUserChangePassword(String userOid, String newPassword) throws CommonException { - Task task = createTask("modifyUserChangePassword"); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserChangePassword(userOid, newPassword, task, result); assertSuccess(result); @@ -696,7 +696,7 @@ protected void modifyAccountChangePassword(String accountOid, String newPassword } protected void clearUserPassword(String userOid) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = createTask("clearUserPassword"); + Task task = getTestTask(); OperationResult result = task.getResult(); List> itemDeltas = prismContext.deltaFor(UserType.class) .item(SchemaConstants.PATH_PASSWORD).replace() @@ -710,7 +710,7 @@ protected void renameObject(Class type, String oid, St } protected void recomputeUser(String userOid) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { - Task task = createTask("recomputeUser"); + Task task = getTestTask(); OperationResult result = task.getResult(); modelService.recompute(UserType.class, userOid, null, task, result); assertSuccess(result); @@ -836,7 +836,7 @@ protected void assignRole(String userOid, String roleOid, QName relation, Consum } protected void unassignRole(String userOid, String roleOid) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - Task task = createTask("unassignRole"); + Task task = getTestTask(); OperationResult result = task.getResult(); unassignRole(userOid, roleOid, task, result); result.computeStatus(); @@ -923,7 +923,7 @@ protected void unassignAllRoles(String userOid) throws ObjectNotFoundException, protected void unassignAllRoles(String userOid, boolean useRawPlusRecompute) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - Task task = getOrCreateSimpleTask("unassignAllRoles"); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = modelService.getObject(UserType.class, userOid, null, task, result); Collection> modifications = new ArrayList<>(); @@ -1021,7 +1021,8 @@ protected void assignOrg(String userOid, String orgOid, QName relation) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - Task task = createTask(AbstractIntegrationTest.class.getName()+".assignOrg"); + AbstractIntegrationTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); assignOrg(userOid, orgOid, relation, task, result); result.computeStatus(); @@ -1210,7 +1211,7 @@ protected void unlinkUser(String userOid, String targetOid) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - Task task = createTask("unlinkUser"); + Task task = getTestTask(); OperationResult result = task.getResult(); unlink(UserType.class, userOid, targetOid, task, result); assertSuccess(result); @@ -1646,7 +1647,7 @@ protected PrismObject getUserFromRepo(String userOid) throws ObjectNot } protected PrismObject findObjectByName(Class type, String name) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = getOrCreateSimpleTask("findObjectByName"); + Task task = getTestTask(); OperationResult result = task.getResult(); List> objects = modelService.searchObjects(type, createNameQuery(name), null, task, result); if (objects.isEmpty()) { @@ -1748,7 +1749,8 @@ protected PrismObject getShadowModel(String shadowOid, GetOperationO } protected void assertNoObject(Class type, String oid) throws SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = createTask(AbstractModelIntegrationTest.class.getName() + ".assertNoObject"); + AbstractModelIntegrationTest.class.getName(); + Task task = getTestTask(); assertNoObject(type, oid, task, task.getResult()); } @@ -3939,7 +3941,8 @@ protected void deleteObjectRaw(Class type, String oid, } protected void deleteObject(Class type, String oid) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = createTask(AbstractModelIntegrationTest.class.getName() + ".deleteObject"); + AbstractModelIntegrationTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object().createDeleteDelta(type, oid); executeChanges(delta, null, task, result); @@ -3955,7 +3958,8 @@ protected void deleteObjectRepo(Class type, String oid } protected void forceDeleteShadow(String oid) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = createTask(AbstractModelIntegrationTest.class.getName() + ".forceDeleteShadow"); + AbstractModelIntegrationTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); forceDeleteObject(ShadowType.class, oid, task, result); assertSuccess(result); @@ -4596,9 +4600,6 @@ protected PrismObject getSecurityContextPrincipalFocus() { } if (principal instanceof MidPointPrincipal) { FocusType focusType = ((MidPointPrincipal)principal).getFocus(); - if (focusType == null) { - return null; - } return focusType.asPrismObject(); } else { return null; @@ -4743,25 +4744,24 @@ protected PrismObject getDefaultActor() { return null; } - protected Task createTask(String operationName) { - Task task = super.createTask(operationName); + protected void customizeTask(Task task) { PrismObject defaultActor = getDefaultActor(); if (defaultActor != null) { task.setOwner(defaultActor); } task.setChannel(DEFAULT_CHANNEL); - return task; } protected Task createTask(String operationName, MidPointPrincipal principal) { - Task task = super.createTask(operationName); + Task task = getTestTask(); task.setOwner(principal.getFocus().asPrismObject()); task.setChannel(DEFAULT_CHANNEL); return task; } protected void modifyRoleAddConstruction(String roleOid, long inducementId, String resourceOid) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = createTask(AbstractModelIntegrationTest.class.getName() + ".modifyRoleAddConstruction"); + AbstractModelIntegrationTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); ConstructionType construction = new ConstructionType(); ObjectReferenceType resourceRedRef = new ObjectReferenceType(); @@ -4779,7 +4779,8 @@ protected void modifyRoleAddConstruction(String roleOid, long inducementId, Stri protected void modifyRoleAddInducementTarget(String roleOid, String targetOid, boolean reconcileAffected, ModelExecuteOptions defaultOptions, Task task) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { if (task == null) { - task = createTask(AbstractModelIntegrationTest.class.getName() + ".modifyRoleAddInducementTarget"); + AbstractModelIntegrationTest.class.getName(); + task = getTestTask(); } OperationResult result = task.getResult(); AssignmentType inducement = new AssignmentType(); @@ -4922,7 +4923,8 @@ protected AssignmentType findAssignmentByTargetRequired(PrismObject role = modelService.getObject(RoleType.class, roleOid, null, task, result); for (AssignmentType inducement: role.asObjectable().getInducement()) { @@ -4936,7 +4938,8 @@ protected AssignmentType findInducementByTarget(String roleOid, String targetOid protected void modifyRoleDeleteInducementTarget(String roleOid, String targetOid, ModelExecuteOptions options) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = createTask(AbstractModelIntegrationTest.class.getName() + ".modifyRoleDeleteInducementTarget"); + AbstractModelIntegrationTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); AssignmentType inducement = findInducementByTarget(roleOid, targetOid); ObjectDelta roleDelta = prismContext.deltaFactory().object() @@ -4950,7 +4953,8 @@ protected void modifyRoleDeleteInducementTarget(String roleOid, String targetOid protected void modifyRoleDeleteInducement(String roleOid, long inducementId, boolean reconcileAffected, ModelExecuteOptions defaultOptions, Task task) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { if (task == null) { - task = createTask(AbstractModelIntegrationTest.class.getName() + ".modifyRoleDeleteInducement"); + AbstractModelIntegrationTest.class.getName(); + task = getTestTask(); } OperationResult result = task.getResult(); @@ -5168,7 +5172,8 @@ protected RoleSelectionSpecificationAsserter getAuditRecords(int maxRecords, Task task, Oper } protected List getObjectAuditRecords(String oid) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - Task task = createTask("getObjectAuditRecords"); + Task task = getTestTask(); OperationResult result = task.getResult(); return getObjectAuditRecords(oid, task, result); } @@ -5320,7 +5325,7 @@ protected List getParamAuditRecords(String paramName, String p } protected List getAuditRecordsFromTo(XMLGregorianCalendar from, XMLGregorianCalendar to) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - Task task = createTask("getAuditRecordsFromTo"); + Task task = getTestTask(); OperationResult result = task.getResult(); return getAuditRecordsFromTo(from, to, task, result); } @@ -5422,7 +5427,7 @@ protected boolean assignmentExists(List assignmentList, String t // just guessing (good enough for testing) protected boolean isH2() { - Task task = createTask("isH2"); + Task task = getTestTask(); RepositoryDiag diag = modelDiagnosticService.getRepositoryDiag(task, task.getResult()); return diag.isEmbedded() || "org.h2.Driver".equals(diag.getDriverShortName()); } @@ -5615,7 +5620,7 @@ protected void applyPasswordPolicy(String passwordPolicyOid, String securityPoli } protected void assertPasswordCompliesWithPolicy(PrismObject user, String passwordPolicyOid) throws EncryptionException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { - Task task = createTask("assertPasswordCompliesWithPolicy"); + Task task = getTestTask(); OperationResult result = task.getResult(); assertPasswordCompliesWithPolicy(user, passwordPolicyOid, task, result); assertSuccess(result); @@ -6093,7 +6098,7 @@ protected ShadowAsserter assertModelShadowFutureNoFetch(String oid) throws } protected void assertNoModelShadow(String oid) throws SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = createTask("assertNoModelShadow"); + Task task = getTestTask(); OperationResult result = task.getResult(); try { PrismObject shadow = modelService.getObject(ShadowType.class, oid, null, task, result); @@ -6105,7 +6110,7 @@ protected void assertNoModelShadow(String oid) throws SchemaException, SecurityV } protected void assertNoModelShadowFuture(String oid) throws SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = createTask("assertNoModelShadowFuture"); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); try { diff --git a/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReport.java b/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReport.java index 3e637064eee..af231e8aea6 100644 --- a/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReport.java +++ b/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReport.java @@ -28,7 +28,6 @@ import com.evolveum.midpoint.schema.SearchResultList; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.CommunicationException; @@ -70,7 +69,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti public void test100ReportUserList() throws Exception { final String TEST_NAME = "test100ReportUserList"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject report = getObject(ReportType.class, REPORT_USER_LIST_OID); @@ -134,7 +133,7 @@ public void test200ReportUserListScript() throws Exception { return; } - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject report = getObject(ReportType.class, REPORT_USER_LIST_SCRIPT_OID); @@ -197,7 +196,7 @@ protected void testReportListUsersCsvFailure(final String TEST_NAME, String repo } protected PrismObject runReport(final String TEST_NAME, PrismObject report, boolean errorOk) throws Exception { - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -227,7 +226,7 @@ protected void checkCsvUserReport(PrismObject report) throws IOExcep display("Report content ("+lines.size()+" lines)", String.join("\n", lines)); outputFile.renameTo(new File(outputFile.getParentFile(), "processed-"+outputFile.getName())); - Task task = createTask("checkCsvUserReport"); + Task task = getTestTask(); OperationResult result = task.getResult(); SearchResultList> currentUsers = modelService.searchObjects(UserType.class, null, null, task, result); display("Current users in midPoint ("+currentUsers.size()+" users)", currentUsers.toString()); diff --git a/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReportWebService.java b/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReportWebService.java index 6bdaf3554d3..731d5194a5a 100644 --- a/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReportWebService.java +++ b/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReportWebService.java @@ -21,7 +21,6 @@ import com.evolveum.midpoint.schema.SearchResultList; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.util.exception.CommunicationException; import com.evolveum.midpoint.util.exception.ConfigurationException; import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; @@ -229,7 +228,7 @@ private RemoteReportParametersType createReportParameters() { } private void assertUserList(ObjectListType userList) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = createTask("assertUserList"); + Task task = getTestTask(); OperationResult result = task.getResult(); SearchResultList> currentUsers = modelService.searchObjects(UserType.class, null, null, task, result); display("Current users in midPoint ("+currentUsers.size()+" users)", currentUsers.toString()); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/AbstractWfTestPolicy.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/AbstractWfTestPolicy.java index 4edb532b255..1a92307e866 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/AbstractWfTestPolicy.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/AbstractWfTestPolicy.java @@ -133,9 +133,7 @@ protected OperationResult executeTest(String testNameExpli prepareNotifications(); dummyAuditService.clear(); - String testName = testNameExplicit != null ? testNameExplicit : getTestNameShort(); - - Task opTask = getOrCreateTestTask(testName); + Task opTask = getTestTask(); boolean USE_FULL_TRACING = false; //noinspection ConstantConditions diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/AbstractTestAssignmentApproval.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/AbstractTestAssignmentApproval.java index 9fa34099446..91367ea0c0b 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/AbstractTestAssignmentApproval.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/AbstractTestAssignmentApproval.java @@ -154,7 +154,7 @@ public void test010AddRole1Assignment() throws Exception { public void test020DeleteRole1Assignment() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); LensContext context = createUserLensContext(); @@ -180,7 +180,7 @@ public void test020DeleteRole1Assignment() throws Exception { public void test030AddRole1AssignmentAgain() throws Exception { login(userAdministrator); - importLead10(getTask(), getResult()); + importLead10(getTestTask(), getResult()); executeAssignRole1ToJack(false, false, null, null, false); } @@ -269,7 +269,7 @@ public void test072AddRoles123AssignmentYYYImmediate() throws Exception { public void test100AddCreateDelegation() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); task.setOwner(userAdministrator); OperationResult result = getResult(); @@ -294,7 +294,7 @@ public void test100AddCreateDelegation() throws Exception { public void test130AddRole1aAssignmentWithDeputy() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); importLead1Deputies(task, getResult()); unassignAllRoles(userJackOid); @@ -431,7 +431,7 @@ private void assertActiveWorkItems(String approverOid, int expectedCount) throws if (approverOid == null && expectedCount == 0) { return; } - Task task = createTask("query"); + Task task = getTestTask(); ObjectQuery query = prismContext.queryFor(CaseWorkItemType.class) .item(CaseWorkItemType.F_ASSIGNEE_REF).ref(getPotentialAssignees(getUser(approverOid))) .and().item(CaseWorkItemType.F_CLOSE_TIMESTAMP).isNull() @@ -574,12 +574,6 @@ public void test300ApprovalAndEnforce() throws Exception { // ignored by default (put here so that zzzMarkAsNotInitialized() will be executed after this one!) } - @Test - public void zzzMarkAsNotInitialized() { - display("Setting class as not initialized"); - unsetSystemInitialized(); - } - private void importLead10(Task task, OperationResult result) throws Exception { addAndRecomputeUser(USER_LEAD10_FILE, task, result); } diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentApprovalGlobal.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentApprovalGlobal.java index 1d55dc58530..81fbc9006e4 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentApprovalGlobal.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentApprovalGlobal.java @@ -9,7 +9,6 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.PolicyViolationException; import com.evolveum.midpoint.xml.ns._public.common.common_3.CaseWorkItemType; @@ -63,7 +62,7 @@ protected String getRoleName(int number) { */ public void test300ApprovalAndEnforce() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); task.setOwner(userAdministrator); OperationResult result = getResult(); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentsAdvanced.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentsAdvanced.java index aae16adb69a..58593529b23 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentsAdvanced.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentsAdvanced.java @@ -278,7 +278,7 @@ public void test230DeleteRoles123AssignmentYById() throws Exception { @Test public void test300ApprovalAndEnforce() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); try { @@ -326,7 +326,7 @@ public void test420AddRoles123AssignmentPreviewImmediate() throws Exception { @Test public void test500NoApprovers() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assignRole(userJackOid, roleRole26Oid, task, result); @@ -352,7 +352,7 @@ public void test500NoApprovers() throws Exception { @Test public void test600AssignRole29() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -592,7 +592,7 @@ protected void afterFirstClockworkRun(CaseType rootCase, List subcases @Test public void test630UnassignRole29() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -934,7 +934,7 @@ protected void afterFirstClockworkRun(CaseType rootCase, List subcases @Test public void test800AssignRole27() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -956,7 +956,7 @@ public void test800AssignRole27() throws Exception { @Test public void test810ModifyAssignmentOfRole27() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -981,7 +981,7 @@ public void test810ModifyAssignmentOfRole27() throws Exception { @Test public void test820UnassignRole27() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -998,7 +998,7 @@ public void test820UnassignRole27() throws Exception { @Test // MID-5827 public void test900AssignIdempotentRole() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -1038,7 +1038,7 @@ public void test900AssignIdempotentRole() throws Exception { @Test public void test910AssignRoleWithIdempotentMetarole() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -1077,7 +1077,7 @@ public void test910AssignRoleWithIdempotentMetarole() throws Exception { private void executeAssignRoles123ToJack(boolean immediate, boolean approve1, boolean approve2, boolean approve3a, boolean approve3b, boolean securityDeputy) throws Exception { - Task task = getTask(); + Task task = getTestTask(); String testName = getTestNameShort(); PrismObject jack = getUser(userJackOid); ObjectDelta addRole1Delta = prismContext @@ -1218,7 +1218,7 @@ public List getApprovalSequence() { private void previewAssignRolesToJack(boolean immediate, boolean also24) throws Exception { String testName = getTestNameShort(); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); boolean TRACE = false; //noinspection ConstantConditions @@ -1491,12 +1491,6 @@ private AssignmentType toDelete(AssignmentType assignment, boolean byId) { } } - @Test - public void zzzMarkAsNotInitialized() { - display("Setting class as not initialized"); - unsetSystemInitialized(); - } - private static class ExpectedStagePreview { @SuppressWarnings({ "FieldCanBeLocal", "unused" }) private int number; private final Set definitionApproverOids; diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/association/TestAddAssociation.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/association/TestAddAssociation.java index 3637f60e4f4..55f67f2bce0 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/association/TestAddAssociation.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/association/TestAddAssociation.java @@ -354,12 +354,6 @@ public void assertHasAssociation(ShadowType shadow, QName associationName, Strin AssertJUnit.fail("No association of type " + associationName + " of " + entitlementOid + " in " + ObjectTypeUtil.toShortString(shadow)); } - @Test - public void zzzMarkAsNotInitialized() { - display("Setting class as not initialized"); - unsetSystemInitialized(); - } - abstract static class TestDetails { abstract int subcasesCount(); abstract boolean immediate(); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/AbstractTestObjectLifecycleApproval.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/AbstractTestObjectLifecycleApproval.java index 8850facb20b..fa21ff7c6a1 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/AbstractTestObjectLifecycleApproval.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/AbstractTestObjectLifecycleApproval.java @@ -93,7 +93,7 @@ protected boolean approveObjectAdd() { public void test010CreateRolePirate() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); RoleType pirate = new RoleType(prismContext); @@ -168,12 +168,6 @@ public void test200DeleteRolePirate() throws Exception { Collections.singletonList(expectedTask), Collections.singletonList(expectedWorkItem)); } - @Test - public void zzzMarkAsNotInitialized() { - display("Setting class as not initialized"); - unsetSystemInitialized(); - } - private void createObject(ObjectType object, boolean immediate, boolean approve, String assigneeOid) throws Exception { //noinspection unchecked ObjectDelta addObjectDelta = DeltaFactory.Object.createAddDelta((PrismObject) object.asPrismObject()); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/TestObjectLifecycleAdvanced.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/TestObjectLifecycleAdvanced.java index 205e89fa278..565677d3067 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/TestObjectLifecycleAdvanced.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/TestObjectLifecycleAdvanced.java @@ -19,7 +19,6 @@ import com.evolveum.midpoint.schema.util.ObjectTypeUtil; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.asserter.prism.PrismObjectAsserter; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DebugUtil; import com.evolveum.midpoint.util.exception.PolicyViolationException; import com.evolveum.midpoint.util.logging.Trace; @@ -87,7 +86,7 @@ protected PrismObject getDefaultActor() { public void test010CreateRoleEmployee() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject employee = prismContext.parseObject(ROLE_EMPLOYEE_FILE); @@ -169,7 +168,7 @@ protected Boolean decideOnApproval(CaseWorkItemType caseWorkItem) throws Excepti public void test020ActivateIncompleteRole() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); @SuppressWarnings({ "raw"}) @@ -203,7 +202,7 @@ public void test020ActivateIncompleteRole() throws Exception { public void test030ActivateIncompleteRoleAgain() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); @SuppressWarnings({ "raw"}) @@ -235,7 +234,7 @@ public void test030ActivateIncompleteRoleAgain() throws Exception { public void test040AddApprover() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assignRole(userEmployeeOwnerOid, roleEmployeeOid, SchemaConstants.ORG_APPROVER, task, result); @@ -248,7 +247,7 @@ public void test040AddApprover() throws Exception { public void test045ActivateCompleteRole() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); @SuppressWarnings({ "raw"}) diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/TestObjectLifecycleApprovalGlobal.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/TestObjectLifecycleApprovalGlobal.java index ed9aef415e9..3f8163b3557 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/TestObjectLifecycleApprovalGlobal.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/TestObjectLifecycleApprovalGlobal.java @@ -74,7 +74,7 @@ protected void updateSystemConfiguration(SystemConfigurationType systemConfigura public void test500CreateRoleJudge() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); RoleType judge = new RoleType(prismContext) @@ -692,10 +692,4 @@ public List getApprovalSequence() { } // TODO test that contains task0 that adds an object (i.e. rule for 'add' is not applied) - - @Test - public void zzzMarkAsNotInitialized() { - display("Setting class as not initialized"); - unsetSystemInitialized(); - } } diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/ManualResourceTest.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/ManualResourceTest.java index 8e813cefc63..deb85220b55 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/ManualResourceTest.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/ManualResourceTest.java @@ -151,7 +151,7 @@ public void test000Sanity() throws Exception { @Test public void test012TestConnection() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); // WHEN displayWhen(); @@ -166,7 +166,7 @@ public void test012TestConnection() throws Exception { @Test public void test100AssignWillRoleOne() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); @@ -197,7 +197,7 @@ public void test100AssignWillRoleOne() throws Exception { @Test public void test110CloseCaseAndRecomputeWill() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestDelegation.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestDelegation.java index 2089bde404f..ed9181d2ab0 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestDelegation.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestDelegation.java @@ -15,7 +15,6 @@ import com.evolveum.midpoint.schema.util.CaseWorkItemUtil; import com.evolveum.midpoint.schema.util.WorkItemId; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DebugUtil; import com.evolveum.midpoint.util.exception.SecurityViolationException; import com.evolveum.midpoint.wf.impl.AbstractWfTestPolicy; @@ -76,7 +75,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti public void test100CreateTask() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assignRole(userJackOid, ROLE_PRINCE_OID, task, result); // should start approval process @@ -96,7 +95,7 @@ public void test100CreateTask() throws Exception { public void test110DelegateToGirthUnauthorized() throws Exception { login(getUserFromRepo(USER_KEEN_OID)); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); try { @@ -117,7 +116,7 @@ public void test110DelegateToGirthUnauthorized() throws Exception { public void test120DelegateToGirth() throws Exception { login(getUserFromRepo(USER_LONGSHANKS_OID)); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); WorkItemDelegationRequestType request = new WorkItemDelegationRequestType(prismContext) @@ -149,7 +148,7 @@ public void test120DelegateToGirth() throws Exception { public void test130DelegateToKeenByReplace() throws Exception { login(getUserFromRepo(USER_LONGSHANKS_OID)); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); WorkItemDelegationRequestType request = new WorkItemDelegationRequestType(prismContext) @@ -178,7 +177,7 @@ public void test130DelegateToKeenByReplace() throws Exception { public void test140DelegateToNoneByReplace() throws Exception { login(getUserFromRepo(USER_KEEN_OID)); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); WorkItemDelegationRequestType request = new WorkItemDelegationRequestType(prismContext) diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestEscalation.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestEscalation.java index 23d3ecb718b..69fd8d76e48 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestEscalation.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestEscalation.java @@ -89,7 +89,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti public void test100CreateE1ApprovalCase() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assignRole(userJackOid, ROLE_E1_OID, task, result); // should start approval process @@ -117,7 +117,7 @@ public void test100CreateE1ApprovalCase() throws Exception { public void test110NotifyAfter5Days() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); clock.overrideDuration("P5DT1H"); // at P5D there's a notify action @@ -139,7 +139,7 @@ public void test110NotifyAfter5Days() throws Exception { public void test120EscalateAfter12Days() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); clock.resetOverride(); @@ -161,7 +161,7 @@ public void test120EscalateAfter12Days() throws Exception { public void test130CompleteAfter14Days() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); clock.resetOverride(); @@ -183,7 +183,7 @@ public void test130CompleteAfter14Days() throws Exception { public void test200CreateE2ApprovalCase() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); clock.resetOverride(); @@ -212,7 +212,7 @@ public void test200CreateE2ApprovalCase() throws Exception { public void test210EscalateAfter3Days() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); @@ -245,7 +245,7 @@ public void test210EscalateAfter3Days() throws Exception { public void test220Reject() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); dummyAuditService.clear(); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestEvents.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestEvents.java index 9fcf3036aa0..9e658bfa1a0 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestEvents.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestEvents.java @@ -13,7 +13,6 @@ import com.evolveum.midpoint.schema.util.CaseWorkItemUtil; import com.evolveum.midpoint.schema.util.WorkItemId; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DebugUtil; import com.evolveum.midpoint.wf.impl.AbstractWfTestPolicy; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; @@ -58,7 +57,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti public void test100CreateTask() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assignRole(userJackOid, roleNoApproversOid, task, result); // should start approval process diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestMiscellaneous.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestMiscellaneous.java index acc5c9e0950..e0c5c7c1679 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestMiscellaneous.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestMiscellaneous.java @@ -102,7 +102,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti public void test100RequesterComment() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // GIVEN @@ -167,7 +167,7 @@ public void test100RequesterComment() throws Exception { public void test105RequesterCommentImmediate() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // GIVEN @@ -234,7 +234,7 @@ public void test105RequesterCommentImmediate() throws Exception { public void test110RequestPrunedRole() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // GIVEN @@ -272,7 +272,7 @@ public void test110RequestPrunedRole() throws Exception { public void test200GetRoleByTemplate() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // GIVEN @@ -295,7 +295,7 @@ public void test200GetRoleByTemplate() throws Exception { public void test210GetRoleByTemplateAfterAssignments() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // GIVEN @@ -319,7 +319,7 @@ public void test210GetRoleByTemplateAfterAssignments() throws Exception { public void test220GetRoleByFocusMappings() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // GIVEN @@ -341,7 +341,7 @@ public void test220GetRoleByFocusMappings() throws Exception { public void test250SkippingApprovals() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // GIVEN diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestParallelApprovals.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestParallelApprovals.java index f939a8c927e..70e39859742 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestParallelApprovals.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestParallelApprovals.java @@ -117,7 +117,7 @@ protected void updateSystemConfiguration(SystemConfigurationType systemConfigura public void test100ParallelApprovals() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -165,7 +165,7 @@ public void test100ParallelApprovals() throws Exception { public void test110ParallelApprovalsAdd() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); if (listener != null) { @@ -222,9 +222,9 @@ public void test120ParallelApprovalsInTwoOperations() throws Exception { String testName = getTestNameShort(); - Task task0 = createTask(testName); - Task task1 = createTask(testName); - Task task2 = createTask(testName); + Task task0 = getTestTask(); + Task task1 = getTestTask(); + Task task2 = getTestTask(); OperationResult result0 = task0.getResult(); OperationResult result1 = task1.getResult(); OperationResult result2 = task2.getResult(); @@ -288,10 +288,10 @@ public void test130ParallelApprovalsInThreeSummarizingOperations() throws Except String testName = getTestNameShort(); - Task task0 = createTask(testName); - Task task1 = createTask(testName); - Task task2 = createTask(testName); - Task task3 = createTask(testName); + Task task0 = getTestTask(); + Task task1 = getTestTask(); + Task task2 = getTestTask(); + Task task3 = getTestTask(); OperationResult result0 = task0.getResult(); OperationResult result1 = task1.getResult(); OperationResult result2 = task2.getResult(); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestSoD.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestSoD.java index a864bd75a84..d17da338e86 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestSoD.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestSoD.java @@ -12,8 +12,6 @@ import com.evolveum.midpoint.schema.constants.ObjectTypes; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.wf.impl.AbstractWfTestPolicy; @@ -82,7 +80,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti public void test010AssignRoleJudge() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -100,7 +98,7 @@ public void test010AssignRoleJudge() throws Exception { public void test020AssignRolePirate() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); PrismObject jack = getUser(userJackOid); @@ -119,12 +117,12 @@ public void test020AssignRolePirate() throws Exception { // WHEN+THEN executeTest2(null, new TestDetails2() { @Override - protected PrismObject getFocus(OperationResult result) throws Exception { + protected PrismObject getFocus(OperationResult result) { return jack.clone(); } @Override - protected ObjectDelta getFocusDelta() throws SchemaException { + protected ObjectDelta getFocusDelta() { return primaryDelta.clone(); } @@ -214,7 +212,7 @@ protected Boolean decideOnApproval(CaseWorkItemType caseWorkItem) throws Excepti public void test030AssignRoleRespectable() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // GIVEN @@ -223,7 +221,6 @@ public void test030AssignRoleRespectable() throws Exception { // WHEN+THEN PrismObject jack = getUser(userJackOid); - @SuppressWarnings("unchecked") ObjectDelta addRespectableDelta = prismContext .deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT).add(createAssignmentTo(roleRespectableOid, ObjectTypes.ROLE, prismContext)) @@ -232,12 +229,12 @@ public void test030AssignRoleRespectable() throws Exception { // WHEN+THEN executeTest2(null, new TestDetails2() { @Override - protected PrismObject getFocus(OperationResult result) throws Exception { + protected PrismObject getFocus(OperationResult result) { return jack.clone(); } @Override - protected ObjectDelta getFocusDelta() throws SchemaException { + protected ObjectDelta getFocusDelta() { return addRespectableDelta.clone(); } @@ -308,11 +305,4 @@ protected Boolean decideOnApproval(CaseWorkItemType caseWorkItem) throws Excepti assertAssignedRole(userJackOid, roleJudgeOid, task, result); assertAssignedRole(userJackOid, roleRespectableOid, task, result); } - - @Test - public void zzzMarkAsNotInitialized() { - display("Setting class as not initialized"); - unsetSystemInitialized(); - } - } diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/AbstractProvisioningIntegrationTest.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/AbstractProvisioningIntegrationTest.java index 5149f203ffa..855bb0dab77 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/AbstractProvisioningIntegrationTest.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/AbstractProvisioningIntegrationTest.java @@ -235,7 +235,7 @@ protected PrismObject getResource() { } protected void assertProvisioningNotFound(String oid) throws CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = createTask("assertProvisioningNotFound"); + Task task = getTestTask(); OperationResult result = task.getResult(); try { provisioningService.getObject(ShadowType.class, oid, null, task, result); @@ -247,7 +247,7 @@ protected void assertProvisioningNotFound(String oid) throws CommunicationExcept } protected void assertProvisioningFutureNotFound(String oid) throws CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = createTask("assertProvisioningFutureNotFound"); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); try { @@ -260,7 +260,7 @@ protected void assertProvisioningFutureNotFound(String oid) throws Communication } protected ShadowAsserter assertShadowProvisioning(String oid) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = createTask("assertShadowProvisioning"); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject shadow = provisioningService.getObject(ShadowType.class, oid, null, task, result); assertSuccess(result); @@ -271,7 +271,7 @@ protected ShadowAsserter assertShadowProvisioning(String oid) throws Objec } protected ShadowAsserter assertShadowNoFetch(String oid) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = createTask("assertShadowProvisioning"); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch()); PrismObject shadow = provisioningService.getObject(ShadowType.class, oid, options, task, result); @@ -283,7 +283,7 @@ protected ShadowAsserter assertShadowNoFetch(String oid) throws ObjectNotF } protected ShadowAsserter assertShadowFuture(String oid) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = createTask("assertShadowFuture"); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); PrismObject shadow = provisioningService.getObject(ShadowType.class, oid, options, task, result); @@ -295,7 +295,7 @@ protected ShadowAsserter assertShadowFuture(String oid) throws ObjectNotFo } protected ShadowAsserter assertShadowFutureNoFetch(String oid) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = createTask("assertShadowFutureNoFetch"); + Task task = getTestTask(); OperationResult result = task.getResult(); GetOperationOptions rootOptions = GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE); rootOptions.setNoFetch(true); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestDBTable.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestDBTable.java index bfbe3bb3ac8..10f98d45516 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestDBTable.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestDBTable.java @@ -125,7 +125,7 @@ public void test000Integrity() throws ObjectNotFoundException, SchemaException { public void test001Connection() throws Exception { final String TEST_NAME = "test001Connection"; TestUtil.displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/async/TestAsyncUpdate.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/async/TestAsyncUpdate.java index 21e6eebd078..1adb255a8d0 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/async/TestAsyncUpdate.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/async/TestAsyncUpdate.java @@ -136,7 +136,7 @@ public void test000Sanity() throws Exception { @Test public void test003Connection() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // Check that there is a schema, but no capabilities before test (pre-condition) @@ -223,7 +223,7 @@ public void test005ParsedSchema() throws Exception { @Test public void test100ListeningForShadowAdd() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // GIVEN @@ -255,7 +255,7 @@ public void test100ListeningForShadowAdd() throws Exception { @Test public void test110ListeningForValueAdd() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); prepareMessage(CHANGE_110); @@ -293,7 +293,7 @@ public void test110ListeningForValueAdd() throws Exception { @Test public void test112ListeningForValueAddMore() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); prepareMessage(CHANGE_112); @@ -331,7 +331,7 @@ public void test112ListeningForValueAddMore() throws Exception { @Test // MID-5832 public void test115ListeningForValueDelete() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); prepareMessage(CHANGE_115); @@ -369,7 +369,7 @@ public void test115ListeningForValueDelete() throws Exception { @Test // MID-5832 public void test117ListeningForValueReplace() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); prepareMessage(CHANGE_117); @@ -407,7 +407,7 @@ public void test117ListeningForValueReplace() throws Exception { @Test public void test120ListeningForShadowReplace() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); prepareMessage(CHANGE_120); @@ -434,7 +434,7 @@ public void test120ListeningForShadowReplace() throws Exception { @Test public void test125ListeningForNotificationOnly() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); if (!hasReadCapability()) { @@ -468,7 +468,7 @@ public void test125ListeningForNotificationOnly() throws Exception { @Test public void test130ListeningForShadowDelete() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); prepareMessage(CHANGE_130); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/AbstractCsvTest.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/AbstractCsvTest.java index 764ef24ee12..3e2a8ae6f96 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/AbstractCsvTest.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/AbstractCsvTest.java @@ -153,7 +153,7 @@ public void test003Connection() throws Exception { final String TEST_NAME = "test003Connection"; TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Check that there is no schema before test (pre-condition) ResourceType resourceBefore = repositoryService.getObject(ResourceType.class, getResourceOid(), @@ -203,7 +203,7 @@ public void test004Configuration() throws Exception { final String TEST_NAME = "test004Configuration"; TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -312,7 +312,7 @@ public void test100AddAccountJack() throws Exception { final String TEST_NAME = "test100AddAccountJack"; TestUtil.displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject shadowBefore = parseObject(getAccountJackFile()); @@ -331,7 +331,7 @@ public void test110GetAccountJack() throws Exception { final String TEST_NAME = "test110GetAccountJack"; TestUtil.displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -369,7 +369,7 @@ public void test120ModifyShadowPrimaryIdentifier() throws Exception { final String TEST_NAME = "test120ModifyShadowPrimaryIdentifier"; TestUtil.displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject shadowBefore = parseObject(getAccountJackFile()); 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 ba3e30b76b5..46e83e3734c 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 @@ -300,7 +300,7 @@ public void test015ListResourcesNoFetch() throws Exception { public void test020Connection() throws Exception { final String TEST_NAME = "test020Connection"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyResource.assertNoConnections(); @@ -781,7 +781,7 @@ public void test029CapabilitiesRepo() throws Exception { public void test030ResourceAndConnectorCachingTestConnection() throws Exception { final String TEST_NAME = "test030ResourceAndConnectorCachingTestConnection"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); // WHEN OperationResult testResult = provisioningService.testResource(RESOURCE_DUMMY_OID, task); @@ -952,7 +952,7 @@ public void test040ApplyDefinitionShadow() throws Exception { final String TEST_NAME = "test040ApplyDefinitionShadow"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject account = PrismTestUtil.parseObject(getAccountWillFile()); @@ -977,7 +977,7 @@ public void test041ApplyDefinitionAddShadowDelta() throws Exception { final String TEST_NAME = "test041ApplyDefinitionAddShadowDelta"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject account = PrismTestUtil.parseObject(getAccountWillFile()); @@ -1003,7 +1003,7 @@ public void test042ApplyDefinitionResource() throws Exception { final String TEST_NAME = "test042ApplyDefinitionResource"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject resource = PrismTestUtil.parseObject(getResourceDummyFile()); @@ -1032,7 +1032,7 @@ public void test043ApplyDefinitionAddResourceDelta() throws Exception { final String TEST_NAME = "test043ApplyDefinitionAddResourceDelta"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject resource = PrismTestUtil.parseObject(getResourceDummyFile()); @@ -1063,7 +1063,7 @@ public void test050SelfTest() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult testResult = new OperationResult(AbstractBasicDummyTest.class + "." + TEST_NAME); // WHEN @@ -1114,7 +1114,7 @@ public void test080TestAttributesToReturn() throws Exception { public void test090ConnectorStatsAfterSomeUse() throws Exception { final String TEST_NAME = "test090ConnectorStatsAfterSomeUse"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1146,7 +1146,7 @@ public void test090ConnectorStatsAfterSomeUse() throws Exception { public void test100AddAccountWill() throws Exception { final String TEST_NAME = "test100AddAccountWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1375,7 +1375,7 @@ public void test105ApplyDefinitionModifyDelta() throws Exception { final String TEST_NAME = "test105ApplyDefinitionModifyDelta"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectModificationType changeAddRoleCaptain = PrismTestUtil.parseAtomicValue(MODIFY_ACCOUNT_FILE, diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/AbstractDummyTest.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/AbstractDummyTest.java index aefc077a7f1..36b03b41744 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/AbstractDummyTest.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/AbstractDummyTest.java @@ -427,7 +427,8 @@ protected void checkRepoAccountShadow(PrismObject shadowFromRepo) { } protected void assertDummyConnectorInstances(int expectedConnectorInstances) throws NumberFormatException, IOException, InterruptedException, SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = createTask(AbstractDummyTest.class.getName() + ".assertDummyConnectorInstances"); + AbstractDummyTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); List stats = provisioningService.getConnectorOperationalStatus(RESOURCE_DUMMY_OID, task, result); display("Resource connector stats", stats); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummy.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummy.java index c9590a8679a..405f01ad361 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummy.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummy.java @@ -899,7 +899,7 @@ public void test119SearchAllAccountsMaxStaleness() throws Exception { public void test120ModifyWillReplaceFullname() throws Exception { final String TEST_NAME = "test120ModifyWillReplaceFullname"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -930,7 +930,7 @@ public void test120ModifyWillReplaceFullname() throws Exception { public void test121ModifyObjectAddPirate() throws Exception { final String TEST_NAME = "test121ModifyObjectAddPirate"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -964,7 +964,7 @@ public void test121ModifyObjectAddPirate() throws Exception { public void test122ModifyObjectAddCaptain() throws Exception { final String TEST_NAME = "test122ModifyObjectAddCaptain"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -998,7 +998,7 @@ public void test122ModifyObjectAddCaptain() throws Exception { public void test123ModifyObjectDeletePirate() throws Exception { final String TEST_NAME = "test123ModifyObjectDeletePirate"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1035,7 +1035,7 @@ public void test123ModifyObjectDeletePirate() throws Exception { public void test124ModifyAccountWillAddCaptainAgain() throws Exception { final String TEST_NAME = "test124ModifyAccountWillAddCaptainAgain"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1084,7 +1084,7 @@ public void test125CompareAccountWillPassword() throws Exception { public void test126ModifyAccountWillPassword() throws Exception { final String TEST_NAME = "test126ModifyAccountWillPassword"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1134,7 +1134,7 @@ public void test127CompareAccountWillPassword() throws Exception { } protected void testComparePassword(final String TEST_NAME, String tag, String shadowOid, String expectedPassword, ItemComparisonResult expectedResult) throws Exception { - Task task = createTask(TEST_NAME+".tag"); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1160,7 +1160,7 @@ protected void testComparePassword(final String TEST_NAME, String tag, String sh public void test129NullAttributeValue() throws Exception { final String TEST_NAME = "test129NullAttributeValue"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1242,7 +1242,7 @@ public void test131AddScript() throws Exception { public void test132ModifyScript() throws Exception { final String TEST_NAME = "test132ModifyScript"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); dummyResource.purgeScriptHistory(); @@ -2805,7 +2805,7 @@ public void test221GetPirateWill() throws Exception { public void test222EntitleAccountWillPillage() throws Exception { final String TEST_NAME = "test222EntitleAccountWillPillage"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberDummyResourceGroupMembersReadCount(null); @@ -2860,7 +2860,7 @@ public void test222EntitleAccountWillPillage() throws Exception { public void test223EntitleAccountWillBargain() throws Exception { final String TEST_NAME = "test223EntitleAccountWillBargain"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -2908,7 +2908,7 @@ public void test223EntitleAccountWillBargain() throws Exception { public void test224GetPillagingPirateWill() throws Exception { final String TEST_NAME = "test224GetPillagingPirateWill"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberDummyResourceGroupMembersReadCount(null); @@ -2961,7 +2961,7 @@ public void test225GetFoolishPirateWill() throws Exception { final String TEST_NAME = "test225GetFoolishPirateWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyGroup groupFools = new DummyGroup("fools"); @@ -3030,7 +3030,7 @@ public void test225GetFoolishPirateWill() throws Exception { public void test226WillNonsensePrivilege() throws Exception { final String TEST_NAME = "test226WillNonsensePrivilege"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyAccount dummyAccount = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid); @@ -3089,7 +3089,7 @@ public void test226WillNonsensePrivilege() throws Exception { public void test230DetitleAccountWillPirates() throws Exception { final String TEST_NAME = "test230DetitleAccountWillPirates"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberDummyResourceGroupMembersReadCount(null); @@ -3121,7 +3121,7 @@ public void test230DetitleAccountWillPirates() throws Exception { public void test232EntitleAccountWillPiratesIdentifiersName() throws Exception { final String TEST_NAME = "test232EntitleAccountWillPiratesIdentifiersName"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberDummyResourceGroupMembersReadCount(null); @@ -3153,7 +3153,7 @@ public void test232EntitleAccountWillPiratesIdentifiersName() throws Exception { public void test233DetitleAccountWillPiratesIdentifiersName() throws Exception { final String TEST_NAME = "test233DetitleAccountWillPiratesIdentifiersName"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberDummyResourceGroupMembersReadCount(null); @@ -3185,7 +3185,7 @@ public void test233DetitleAccountWillPiratesIdentifiersName() throws Exception { public void test234EntitleAccountWillPiratesIdentifiersUid() throws Exception { final String TEST_NAME = "test234EntitleAccountWillPiratesIdentifiersUid"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberDummyResourceGroupMembersReadCount(null); @@ -3217,7 +3217,7 @@ public void test234EntitleAccountWillPiratesIdentifiersUid() throws Exception { public void test235DetitleAccountWillPiratesIdentifiersUid() throws Exception { final String TEST_NAME = "test235DetitleAccountWillPiratesIdentifiersUid"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberDummyResourceGroupMembersReadCount(null); @@ -3269,7 +3269,7 @@ private void assertAccountPiratesDetitled() throws Exception { assertDummyResourceGroupMembersReadCountIncrement(null, 0); syncServiceMock.assertNotifySuccessOnly(); - Task task = createTask("assertAccountPiratesDetitled"); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result); display("Shadow after", shadow); @@ -3307,7 +3307,7 @@ private void assertAccountPiratesEntitled() throws Exception { assertDummyResourceGroupMembersReadCountIncrement(null, 0); syncServiceMock.assertNotifySuccessOnly(); - Task task = createTask("assertAccountPiratesDetitled"); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result); display("Shadow after", shadow); @@ -3322,7 +3322,7 @@ private void assertAccountPiratesEntitled() throws Exception { public void test238DetitleAccountWillPillage() throws Exception { final String TEST_NAME = "test238DetitleAccountWillPillage"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -3370,7 +3370,7 @@ public void test238DetitleAccountWillPillage() throws Exception { public void test239DetitleAccountWillBargain() throws Exception { final String TEST_NAME = "test239DetitleAccountWillBargain"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -3416,7 +3416,7 @@ public void test239DetitleAccountWillBargain() throws Exception { public void test260AddAccountLeChuck() throws Exception { final String TEST_NAME = "test260AddAccountLeChuck"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -3500,7 +3500,7 @@ public void test260AddAccountLeChuck() throws Exception { public void test265DeleteAccountLeChuck() throws Exception { final String TEST_NAME = "test265DeleteAccountLeChuck"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -3550,7 +3550,7 @@ public void test265DeleteAccountLeChuck() throws Exception { public void test298DeletePrivPillage() throws Exception { final String TEST_NAME = "test298DeletePrivPillage"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -3589,7 +3589,7 @@ public void test298DeletePrivPillage() throws Exception { public void test299DeleteGroupPirates() throws Exception { final String TEST_NAME = "test299DeleteGroupPirates"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -3628,7 +3628,7 @@ public void test299DeleteGroupPirates() throws Exception { public void test300AccountRename() throws Exception { final String TEST_NAME = "test300AccountRename"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -3681,7 +3681,7 @@ public void test300AccountRename() throws Exception { public void test310ModifyMorganEnlistTimestamp() throws Exception { final String TEST_NAME = "test310ModifyMorganEnlistTimestamp"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -3721,7 +3721,7 @@ public void test310ModifyMorganEnlistTimestamp() throws Exception { public void test330ModifyAccountWillPasswordSelfService() throws Exception { final String TEST_NAME = "test330ModifyAccountWillPasswordSelfService"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -3771,7 +3771,7 @@ public void test330ModifyAccountWillPasswordSelfService() throws Exception { public void test340ModifyWillReplaceGossipBloodAvast() throws Exception { final String TEST_NAME = "test340ModifyWillReplaceGossipBloodAvast"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); // This turns on recording of the operations @@ -3803,7 +3803,7 @@ public void test340ModifyWillReplaceGossipBloodAvast() throws Exception { public void test342ModifyWillAddGossipEunuch() throws Exception { final String TEST_NAME = "test342ModifyWillAddGossipEunuch"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); // This turns on recording of the operations @@ -3835,7 +3835,7 @@ public void test342ModifyWillAddGossipEunuch() throws Exception { public void test344ModifyWillDeleteGossipAvast() throws Exception { final String TEST_NAME = "test344ModifyWillDeleteGossipAvast"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); // This turns on recording of the operations @@ -3915,7 +3915,7 @@ public void test500AddProtectedAccount() throws Exception { public void test501GetProtectedAccountShadow() throws Exception { final String TEST_NAME = "test501GetProtectedAccountShadow"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -3938,7 +3938,7 @@ public void test501GetProtectedAccountShadow() throws Exception { public void test502ModifyProtectedAccountShadowAttributes() throws Exception { final String TEST_NAME = "test502ModifyProtectedAccountShadowAttributes"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -4008,7 +4008,7 @@ public void test503ModifyProtectedAccountShadowProperty() throws Exception { public void test509DeleteProtectedAccountShadow() throws Exception { final String TEST_NAME = "test509DeleteProtectedAccountShadow"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -4073,7 +4073,7 @@ private PrismObject createAccountShadow(String username) throws Sche } protected void testAddProtectedAccount(final String TEST_NAME, String username) throws Exception { - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -4100,7 +4100,7 @@ protected void testAddProtectedAccount(final String TEST_NAME, String username) } private void testAddAccount(final String TEST_NAME, String username) throws Exception { - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -4130,7 +4130,7 @@ private void testAddAccount(final String TEST_NAME, String username) throws Exce public void test520MigrationPrimaryIdentifierValueRefresh() throws Exception { final String TEST_NAME = "test520MigrationPrimaryIdentifierValueRefresh"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyConsistency.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyConsistency.java index 4564b94b458..886fe77cd9a 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyConsistency.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyConsistency.java @@ -107,7 +107,7 @@ protected File getResourceDummyFile() { public void test000Integrity() throws Exception { final String TEST_NAME = "test000Integrity"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); display("Dummy resource instance", dummyResource.toString()); @@ -129,7 +129,7 @@ public void test000Integrity() throws Exception { public void test050AddAccountWill() throws Exception { final String TEST_NAME = "test050AddAccountWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -184,7 +184,7 @@ public void test050AddAccountWill() throws Exception { public void test100AddAccountMorganCommunicationFailure() throws Exception { final String TEST_NAME = "test100AddAccountMorganCommunicationFailure"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -225,7 +225,7 @@ public void test100AddAccountMorganCommunicationFailure() throws Exception { public void test102GetAccountMorganRecovery() throws Exception { final String TEST_NAME = "test102GetAccountMorganRecovery"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -252,7 +252,7 @@ public void test102GetAccountMorganRecovery() throws Exception { public void test104RefreshAccountMorganCommunicationFailure() throws Exception { final String TEST_NAME = "test104RefreshAccountMorganCommunicationFailure"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -283,7 +283,7 @@ public void test104RefreshAccountMorganCommunicationFailure() throws Exception { public void test105GetForceRefreshAccountMorganCommunicationFailure() throws Exception { final String TEST_NAME = "test105GetForceRefreshAccountMorganCommunicationFailure"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -322,7 +322,7 @@ public void test105GetForceRefreshAccountMorganCommunicationFailure() throws Exc public void test106RefreshAccountMorganCommunicationFailureRetry() throws Exception { final String TEST_NAME = "test106RefreshAccountMorganCommunicationFailureRetry"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT17M"); @@ -361,7 +361,7 @@ public void test106RefreshAccountMorganCommunicationFailureRetry() throws Except public void test108RefreshAccountMorganCommunicationFailureRetryAgain() throws Exception { final String TEST_NAME = "test108RefreshAccountMorganCommunicationFailureRetryAgain"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT17M"); @@ -486,7 +486,7 @@ private void assertMorganDead() throws Exception { public void test109RefreshAccountMorganDead() throws Exception { final String TEST_NAME = "test109RefreshAccountMorganDead"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT17M"); @@ -517,7 +517,7 @@ public void test109RefreshAccountMorganDead() throws Exception { public void test110AddAccountMorganAgainCommunicationFailure() throws Exception { final String TEST_NAME = "test110AddAccountMorganAgainCommunicationFailure"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -557,7 +557,7 @@ public void test110AddAccountMorganAgainCommunicationFailure() throws Exception public void test114RefreshAccountMorganCommunicationFailure() throws Exception { final String TEST_NAME = "test114RefreshAccountMorganCommunicationFailure"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -590,7 +590,7 @@ public void test114RefreshAccountMorganCommunicationFailure() throws Exception { public void test116RefreshAccountMorganRetrySuccess() throws Exception { final String TEST_NAME = "test116RefreshAccountMorganRetrySuccess"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT17M"); @@ -625,7 +625,7 @@ public void test116RefreshAccountMorganRetrySuccess() throws Exception { public void test120ModifyMorganFullNameCommunicationFailure() throws Exception { final String TEST_NAME = "test120ModifyMorganFullNameCommunicationFailure"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -662,7 +662,7 @@ public void test120ModifyMorganFullNameCommunicationFailure() throws Exception { public void test124RefreshAccountMorganCommunicationFailure() throws Exception { final String TEST_NAME = "test124RefreshAccountMorganCommunicationFailure"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -693,7 +693,7 @@ public void test124RefreshAccountMorganCommunicationFailure() throws Exception { public void test126RefreshAccountMorganCommunicationFailureRetry() throws Exception { final String TEST_NAME = "test126RefreshAccountMorganCommunicationFailureRetry"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT17M"); @@ -732,7 +732,7 @@ public void test126RefreshAccountMorganCommunicationFailureRetry() throws Except public void test128RefreshAccountMorganCommunicationFailureRetryAgain() throws Exception { final String TEST_NAME = "test128RefreshAccountMorganCommunicationFailureRetryAgain"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT17M"); @@ -768,7 +768,7 @@ public void test128RefreshAccountMorganCommunicationFailureRetryAgain() throws E public void test129RefreshAccountMorganFailed() throws Exception { final String TEST_NAME = "test129RefreshAccountMorganFailed"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT17M"); @@ -796,7 +796,7 @@ public void test129RefreshAccountMorganFailed() throws Exception { public void test130ModifyMorganFullNameAgainCommunicationFailure() throws Exception { final String TEST_NAME = "test130ModifyMorganFullNameAgainCommunicationFailure"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); dummyResource.setBreakMode(BreakMode.NETWORK); @@ -834,7 +834,7 @@ public void test130ModifyMorganFullNameAgainCommunicationFailure() throws Except public void test132GetAccountMorganCommunicationFailure() throws Exception { final String TEST_NAME = "test132GetAccountMorganCommunicationFailure"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT17M"); @@ -869,7 +869,7 @@ public void test132GetAccountMorganCommunicationFailure() throws Exception { public void test133GetAccountMorganStalenessZeroCommunicationFailure() throws Exception { final String TEST_NAME = "test133GetAccountMorganStalenessZeroCommunicationFailure"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -910,7 +910,7 @@ public void test133GetAccountMorganStalenessZeroCommunicationFailure() throws Ex public void test134GetAccountMorganForceRefreshRetryCommunicationFailure() throws Exception { final String TEST_NAME = "test134GetAccountMorganForceRefreshRetryCommunicationFailure"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -944,7 +944,7 @@ public void test134GetAccountMorganForceRefreshRetryCommunicationFailure() throw public void test136RefreshAccountMorganRetrySuccess() throws Exception { final String TEST_NAME = "test136RefreshAccountMorganRetrySuccess"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT17M"); @@ -979,7 +979,7 @@ public void test136RefreshAccountMorganRetrySuccess() throws Exception { public void test170DeleteMorganCommunicationFailure() throws Exception { final String TEST_NAME = "test170DeleteMorganCommunicationFailure"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1015,7 +1015,7 @@ public void test170DeleteMorganCommunicationFailure() throws Exception { public void test174RefreshAccountMorganCommunicationFailure() throws Exception { final String TEST_NAME = "test174RefreshAccountMorganCommunicationFailure"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1046,7 +1046,7 @@ public void test174RefreshAccountMorganCommunicationFailure() throws Exception { public void test176RefreshAccountMorganCommunicationFailureRetry() throws Exception { final String TEST_NAME = "test176RefreshAccountMorganCommunicationFailureRetry"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT17M"); @@ -1085,7 +1085,7 @@ public void test176RefreshAccountMorganCommunicationFailureRetry() throws Except public void test178RefreshAccountMorganCommunicationFailureRetryAgain() throws Exception { final String TEST_NAME = "test178RefreshAccountMorganCommunicationFailureRetryAgain"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT17M"); @@ -1120,7 +1120,7 @@ public void test178RefreshAccountMorganCommunicationFailureRetryAgain() throws E public void test179RefreshAccountMorganFailed() throws Exception { final String TEST_NAME = "test179RefreshAccountMorganFailed"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT17M"); @@ -1148,7 +1148,7 @@ public void test179RefreshAccountMorganFailed() throws Exception { public void test180DeleteMorganCommunicationFailureAgain() throws Exception { final String TEST_NAME = "test180DeleteMorganCommunicationFailureAgain"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1185,7 +1185,7 @@ public void test180DeleteMorganCommunicationFailureAgain() throws Exception { public void test186RefreshAccountMorganRetrySuccess() throws Exception { final String TEST_NAME = "test186RefreshAccountMorganRetrySuccess"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT17M"); @@ -1227,7 +1227,7 @@ public void test186RefreshAccountMorganRetrySuccess() throws Exception { public void test190AccountMorganDeadExpireOperation() throws Exception { final String TEST_NAME = "test190AccountMorganDeadExpireOperation"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("P1D"); @@ -1311,7 +1311,7 @@ public void test190AccountMorganDeadExpireOperation() throws Exception { public void test192AccountMorganSecondDeadExpireOperation() throws Exception { final String TEST_NAME = "test192AccountMorganSecondDeadExpireOperation"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("P1D"); @@ -1378,7 +1378,7 @@ public void test192AccountMorganSecondDeadExpireOperation() throws Exception { public void test194AccountMorganDeadExpireShadow() throws Exception { final String TEST_NAME = "test194AccountMorganDeadExpireShadow"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("P10D"); @@ -1414,7 +1414,7 @@ public void test194AccountMorganDeadExpireShadow() throws Exception { public void test196AccountMorganSecondDeadExpireShadow() throws Exception { final String TEST_NAME = "test196AccountMorganSecondDeadExpireShadow"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("P1D"); @@ -1451,7 +1451,7 @@ public void test196AccountMorganSecondDeadExpireShadow() throws Exception { public void test800AddAccountMorganAlreadyExists() throws Exception { final String TEST_NAME = "test800AddAccountMorganAlreadyExists"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1530,7 +1530,7 @@ public void test800AddAccountMorganAlreadyExists() throws Exception { public void test802AddAccountMorganAlreadyExistsAgain() throws Exception { final String TEST_NAME = "test802AddAccountMorganAlreadyExistsAgain"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1614,7 +1614,7 @@ public void test802AddAccountMorganAlreadyExistsAgain() throws Exception { public void test804AddAccountElizabeth() throws Exception { final String TEST_NAME = "test804AddAccountElizabeth"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1647,7 +1647,7 @@ public void test804AddAccountElizabeth() throws Exception { public void test806RenameAccountElizabethAlreadyExists() throws Exception { final String TEST_NAME = "test806RenameAccountElizabethAlreadyExists"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1726,7 +1726,7 @@ public void test806RenameAccountElizabethAlreadyExists() throws Exception { public void test808RenameAccountElizabethAlreadyExistsAgain() throws Exception { final String TEST_NAME = "test808RenameAccountElizabethAlreadyExistsAgain"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1818,7 +1818,7 @@ public void test808RenameAccountElizabethAlreadyExistsAgain() throws Exception { public void test810GetAccountMorganNotFound() throws Exception { final String TEST_NAME = "test810GetAccountMorganNotFound"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1884,7 +1884,7 @@ public void test810GetAccountMorganNotFound() throws Exception { public void test812ModifyAccountWillNotFound() throws Exception { final String TEST_NAME = "test812ModifyAccountWillNotFound"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1956,7 +1956,7 @@ public void test812ModifyAccountWillNotFound() throws Exception { public void test814DeleteAccountElizabethNotFound() throws Exception { final String TEST_NAME = "test814DeleteAccountElizabethNotFound"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -2019,7 +2019,7 @@ public void test814DeleteAccountElizabethNotFound() throws Exception { public void test816AddAccountElizabethAfterDeathAlreadyExists() throws Exception { final String TEST_NAME = "test816AddAccountElizabethAfterDeathAlreadyExists"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -2086,7 +2086,7 @@ public void test816AddAccountElizabethAfterDeathAlreadyExists() throws Exception public void test900GetAccountMurrayPending() throws Exception { final String TEST_NAME = "test900GetAccountMurrayPending"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); dummyResource.resetBreakMode(); @@ -2324,8 +2324,7 @@ private void assertUnmodifiedMorgan(int expectedAttemptNumber, int expectenNumbe .assertHasSecondaryIdentifier() .assertSize(2); - - Task task = createTask("assertUnmodifiedMorgan"); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject accountProvisioning = provisioningService.getObject(ShadowType.class, shadowMorganOid, null, task, result); assertPartialError(result); @@ -2433,8 +2432,7 @@ private void assertModifiedMorgan(int expectedAttemptNumber, int expectenNumberO .assertHasSecondaryIdentifier() .assertSize(2); - - Task task = createTask("assertModifiedMorgan"); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject accountProvisioning = provisioningService.getObject(ShadowType.class, shadowMorganOid, null, task, result); assertSuccess(result); @@ -2533,8 +2531,7 @@ private void assertMorganModifyFailed() throws Exception { .assertHasSecondaryIdentifier() .assertSize(2); - - Task task1 = createTask("assertUnmodifiedMorgan"); + Task task1 = getTestTask(); OperationResult result1 = task1.getResult(); PrismObject accountProvisioning = provisioningService.getObject(ShadowType.class, shadowMorganOid, null, task1, result1); assertPartialError(result1); @@ -2635,8 +2632,7 @@ private void assertUndeletedMorgan(int expectedAttemptNumber, int expectenNumber .assertHasSecondaryIdentifier() .assertSize(2); - - Task task = createTask("assertUnmodifiedMorgan"); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject accountProvisioning = provisioningService.getObject(ShadowType.class, shadowMorganOid, null, task, result); assertPartialError(result); @@ -2738,8 +2734,7 @@ private void assertMorganDeleteFailed() throws Exception { .assertHasSecondaryIdentifier() .assertSize(2); - - Task task = createTask("assertUnmodifiedMorgan"); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject accountProvisioning = provisioningService.getObject(ShadowType.class, shadowMorganOid, null, task, result); assertPartialError(result); @@ -2861,7 +2856,7 @@ private void assertResourceStatusChangeCounterIncrements() { } private void assertGetUncreatedShadow(String oid) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = createTask("assertGetUncreatedShadow"); + Task task = getTestTask(); OperationResult result = task.getResult(); try { PrismObject shadow = provisioningService.getObject(ShadowType.class, @@ -2873,7 +2868,7 @@ private void assertGetUncreatedShadow(String oid) throws ObjectNotFoundException } private PrismObject getShadowNoFetch(String oid) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = createTask("getShadowNoFetch"); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch()); PrismObject shadow = provisioningService.getObject(ShadowType.class, @@ -2883,7 +2878,7 @@ private PrismObject getShadowNoFetch(String oid) throws ObjectNotFou } private PrismObject getShadowFuture(String oid) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = createTask("getShadowFuture"); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); PrismObject shadow = provisioningService.getObject(ShadowType.class, @@ -2893,7 +2888,7 @@ private PrismObject getShadowFuture(String oid) throws ObjectNotFoun } private PrismObject getShadowFuturePartialError(String oid) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = createTask("getShadowFuture"); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); PrismObject shadow = provisioningService.getObject(ShadowType.class, diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyExpression.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyExpression.java index 4a7bd5049c2..b8e4067bd42 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyExpression.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyExpression.java @@ -15,10 +15,6 @@ import org.testng.annotations.Test; import com.evolveum.midpoint.prism.PrismProperty; -import com.evolveum.midpoint.prism.query.ObjectPaging; -import com.evolveum.midpoint.prism.query.OrderDirection; -import com.evolveum.midpoint.schema.SearchResultMetadata; -import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CountObjectsSimulateType; 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 ec5d3d621aa..e25844e9799 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 @@ -106,7 +106,7 @@ protected void assertNativeCredentialsCapability(CredentialsCapabilityType capCr public void test400AddAccountElizabeth() throws Exception { final String TEST_NAME = "test400AddAccountElizabeth"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -156,7 +156,7 @@ public void test410AssociateCrewWillElizabeth() throws Exception { final String TEST_NAME = "test410AssociateCrewWillElizabeth"; TestUtil.displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -202,7 +202,7 @@ public void test419DisassociateCrewWillElizabeth() throws Exception { final String TEST_NAME = "test419DisassociateCrewWillElizabeth"; TestUtil.displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -246,7 +246,7 @@ public void test419DisassociateCrewWillElizabeth() throws Exception { public void test499DeleteAccountElizabeth() throws Exception { final String TEST_NAME = "test499DeleteAccountElizabeth"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyHacks.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyHacks.java index 7dac4309c2f..ac46a644ba7 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyHacks.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyHacks.java @@ -11,43 +11,17 @@ import java.io.File; -import javax.xml.namespace.QName; - -import com.evolveum.midpoint.prism.PrismContext; - import com.evolveum.midpoint.prism.delta.PlusMinusZero; -import com.evolveum.midpoint.schema.processor.ResourceSchemaImpl; -import org.springframework.beans.factory.annotation.Autowired; + import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; -import org.testng.AssertJUnit; -import org.testng.annotations.Test; -import org.w3c.dom.Element; -import com.evolveum.icf.dummy.resource.DummyObjectClass; -import com.evolveum.icf.dummy.resource.DummyResource; -import com.evolveum.midpoint.prism.ComplexTypeDefinition; import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.util.PrismAsserts; -import com.evolveum.midpoint.provisioning.api.ProvisioningService; -import com.evolveum.midpoint.provisioning.impl.ConnectorManager; -import com.evolveum.midpoint.provisioning.impl.ProvisioningTestUtil; -import com.evolveum.midpoint.provisioning.impl.mock.SynchronizationServiceMock; -import com.evolveum.midpoint.schema.constants.SchemaConstants; -import com.evolveum.midpoint.schema.processor.ResourceSchema; import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.schema.util.ObjectTypeUtil; -import com.evolveum.midpoint.schema.util.ResourceTypeUtil; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; -import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.common_3.CachingMetadataType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.XmlSchemaType; /** * The test of Provisioning service on the API level. The test is using dummy resource for speed and flexibility. diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyLegacy.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyLegacy.java index dce8cb08e67..6c5cad67ebf 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyLegacy.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyLegacy.java @@ -110,7 +110,7 @@ public void test100NativeIntegrity() throws Exception { assertNotNull("Resource is null", resourceNative); assertNotNull("ResourceType is null", resourceTypeNative); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ResourceType resource = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_NATIVE_OID, null, result) @@ -123,7 +123,7 @@ public void test103NativeTestResource() throws Exception { TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Check that there is no schema before test (pre-condition) ResourceType resourceBefore = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_NATIVE_OID, null, result) @@ -209,7 +209,7 @@ public void test203LegacyTestResource() throws Exception { TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Check that there is no schema before test (pre-condition) ResourceType resourceBefore = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_LEGACY_OID, null, result) diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyLimited.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyLimited.java index 5817c747302..1568690cf39 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyLimited.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyLimited.java @@ -31,7 +31,6 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.LockoutStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationProvisioningScriptsType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.AddRemoveAttributeValuesCapabilityType; import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CountObjectsSimulateType; import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.RunAsCapabilityType; diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyNegative.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyNegative.java index 45b97196d82..1ba9d31b8f4 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyNegative.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyNegative.java @@ -107,7 +107,7 @@ public void testGetResourceBrokenSchema(BreakMode breakMode, String testName) th public void test190GetResource() throws Exception { final String TEST_NAME = "test190GetResource"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyResource.setSchemaBreakMode(BreakMode.NONE); syncServiceMock.reset(); @@ -128,7 +128,7 @@ public void test190GetResource() throws Exception { public void test200AddAccountNullAttributes() throws Exception { final String TEST_NAME = "test200AddAccountNullAttributes"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyParallelism.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyParallelism.java index ed5cff814e2..b720febdf6d 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyParallelism.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyParallelism.java @@ -143,7 +143,7 @@ protected void assertWillRepoShadowAfterCreate(PrismObject repoShado public void test120ModifyWillReplaceFullname() throws Exception { final String TEST_NAME = "test120ModifyWillReplaceFullname"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -182,7 +182,7 @@ public void test120ModifyWillReplaceFullname() throws Exception { public void test190DeleteWill() throws Exception { final String TEST_NAME = "test190DeleteWill"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -221,7 +221,7 @@ public void test190DeleteWill() throws Exception { public void test200ParallelCreate() throws Exception { final String TEST_NAME = "test200ParallelCreate"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); final Counter successCounter = new Counter(); @@ -234,7 +234,7 @@ public void test200ParallelCreate() throws Exception { ParallelTestThread[] threads = multithread(TEST_NAME, (i) -> { - Task localTask = createTask(TEST_NAME + ".local"); + Task localTask = getTestTask(); OperationResult localResult = localTask.getResult(); ShadowType account = parseObjectType(ACCOUNT_MORGAN_FILE, ShadowType.class); @@ -315,7 +315,7 @@ public void test204ParallelModifyDisable() throws Exception { private PrismObject parallelModifyTest(final String TEST_NAME, FailableProducer> deltaProducer) throws Exception { // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); final Counter successCounter = new Counter(); @@ -326,7 +326,7 @@ private PrismObject parallelModifyTest(final String TEST_NAME, Faila ParallelTestThread[] threads = multithread(TEST_NAME, (i) -> { - Task localTask = createTask(TEST_NAME + ".local"); + Task localTask = getTestTask(); OperationResult localResult = localTask.getResult(); RepositoryCache.enter(cacheConfigurationManager); @@ -384,7 +384,7 @@ public void test209ParallelDelete() throws Exception { ParallelTestThread[] threads = multithread(TEST_NAME, (i) -> { - Task localTask = createTask(TEST_NAME + ".local"); + Task localTask = getTestTask(); OperationResult localResult = localTask.getResult(); RepositoryCache.enter(cacheConfigurationManager); @@ -433,7 +433,7 @@ public void test209ParallelDelete() throws Exception { public void test210ParallelCreateSlow() throws Exception { final String TEST_NAME = "test210ParallelCreateSlow"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); final Counter successCounter = new Counter(); @@ -444,7 +444,7 @@ public void test210ParallelCreateSlow() throws Exception { ParallelTestThread[] threads = multithread(TEST_NAME, (i) -> { - Task localTask = createTask(TEST_NAME + ".local"); + Task localTask = getTestTask(); OperationResult localResult = localTask.getResult(); RepositoryCache.enter(cacheConfigurationManager); @@ -522,7 +522,7 @@ public void test214ParallelModifyDisableSlow() throws Exception { private PrismObject parallelModifyTestSlow(final String TEST_NAME, FailableProducer> deltaProducer) throws Exception { // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); final Counter successCounter = new Counter(); @@ -533,7 +533,7 @@ private PrismObject parallelModifyTestSlow(final String TEST_NAME, F ParallelTestThread[] threads = multithread(TEST_NAME, (i) -> { - Task localTask = createTask(TEST_NAME + ".local"); + Task localTask = getTestTask(); OperationResult localResult = localTask.getResult(); RepositoryCache.enter(cacheConfigurationManager); @@ -592,7 +592,7 @@ public void test229ParallelDeleteSlow() throws Exception { ParallelTestThread[] threads = multithread(TEST_NAME, (i) -> { - Task localTask = createTask(TEST_NAME + ".local"); + Task localTask = getTestTask(); OperationResult localResult = localTask.getResult(); RepositoryCache.enter(cacheConfigurationManager); @@ -652,7 +652,7 @@ public void test229ParallelDeleteSlow() throws Exception { public void test230ParallelGroupSearch() throws Exception { final String TEST_NAME = "test230ParallelGroupSearch"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyGroup groupScum = new DummyGroup(GROUP_SCUM_NAME); @@ -668,7 +668,7 @@ public void test230ParallelGroupSearch() throws Exception { ParallelTestThread[] threads = multithread(TEST_NAME, (i) -> { - Task localTask = createTask(TEST_NAME + ".local"); + Task localTask = getTestTask(); OperationResult localResult = localTask.getResult(); ObjectQuery query = createGroupNameQuery(GROUP_SCUM_NAME); @@ -743,7 +743,7 @@ private ObjectQuery createGroupNameQuery(String groupName) throws SchemaExceptio public void test800ParallelReadAndModifyResource() throws Exception { final String TEST_NAME = "test800ParallelReadAndModifyResource"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Previous test will max out the connector pool @@ -790,7 +790,7 @@ public void test800ParallelReadAndModifyResource() throws Exception { for (int i = 0; /* neverending */ ; i++) { - Task localTask = createTask(TEST_NAME + ".test."+i); + Task localTask = getTestTask(); LOGGER.debug("PAR: TESTing "+threadIndex+"."+i); @@ -814,7 +814,7 @@ public void test800ParallelReadAndModifyResource() throws Exception { try { for (int i = 0; i < MESS_RESOURCE_ITERATIONS; i++) { - Task localTask = createTask(TEST_NAME + ".op."+i); + Task localTask = getTestTask(); OperationResult localResult = localTask.getResult(); LOGGER.debug("PAR: OPing "+threadIndex+"."+i); @@ -879,7 +879,7 @@ private Object doResourceOperation(int threadIndex, int i, Task task, OperationR } private void messResource(final String TEST_NAME, int threadIndex, int i) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, PolicyViolationException, ObjectAlreadyExistsException, ExpressionEvaluationException { - Task task = createTask(TEST_NAME+".mess."+threadIndex+"."+i); + Task task = getTestTask(); OperationResult result = task.getResult(); List> deltas = deltaFor(ResourceType.class) .item(ResourceType.F_DESCRIPTION).replace("Iter "+threadIndex+"."+i) diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySchemaless.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySchemaless.java index df5c9e827b5..fef999bffc9 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySchemaless.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySchemaless.java @@ -190,7 +190,7 @@ public void test003ConnectionSchemaless() throws Exception { final String TEST_NAME = "test003ConnectionSchemaless"; TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Check that there is no schema before test (pre-condition) ResourceType resourceBefore = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_NO_SCHEMA_OID, null, result) @@ -267,7 +267,7 @@ public void test020ResourceStaticSchemaTest() throws Exception { public void resourceStaticSchemaTest(final String TEST_NAME, int expectedConnectorInitCount) throws Exception { // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Some connector initialization and other things might happen in previous tests. @@ -454,7 +454,7 @@ public void resourceStatciSchemaResourceAndConnectorCaching(final String TEST_NA public void test040ReAddResourceStaticSchema() throws Exception { final String TEST_NAME = "test040ReAddResourceStaticSchema"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject resourceNew = prismContext.parseObject(RESOURCE_DUMMY_STATIC_SCHEMA_FILE); @@ -509,7 +509,7 @@ public void test103ConnectionStaticSchema() throws Exception { final String TEST_NAME = "test103ConnectionStaticSchema"; TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Check that there a schema before test (pre-condition) diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyUuidNonUniqueName.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyUuidNonUniqueName.java index bac9d424bdf..34034279e27 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyUuidNonUniqueName.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyUuidNonUniqueName.java @@ -119,7 +119,7 @@ public void test600AddAccountAlreadyExist() throws Exception { private String addFettucini(final String TEST_NAME, File file, String oid, String expectedFullName) throws Exception { // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -179,7 +179,8 @@ private String addFettucini(final String TEST_NAME, File file, String oid, Strin } private void searchFettucini(int expectedNumberOfFettucinis) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = createTask(TestDummy.class.getName() + ".searchFettucini"); + TestDummy.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = prismContext.queryFor(ShadowType.class) .item(ShadowType.F_RESOURCE_REF).ref(resource.getOid()) diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/manual/AbstractManualResourceTest.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/manual/AbstractManualResourceTest.java index dbd3cb1f121..20ffc38d28d 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/manual/AbstractManualResourceTest.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/manual/AbstractManualResourceTest.java @@ -191,7 +191,7 @@ public void test003Connection() throws Exception { final String TEST_NAME = "test003Connection"; TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Check that there is a schema, but no capabilities before test (pre-condition) @@ -355,7 +355,7 @@ public void test006Capabilities() throws Exception { public void test100AddAccountWill() throws Exception { final String TEST_NAME = "test100AddAccountWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -427,7 +427,7 @@ public void test100AddAccountWill() throws Exception { public void test102GetAccountWillFuture() throws Exception { final String TEST_NAME = "test102GetAccountWillFuture"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -461,7 +461,7 @@ public void test102GetAccountWillFuture() throws Exception { public void test104RefreshAccountWill() throws Exception { final String TEST_NAME = "test104RefreshAccountWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -515,7 +515,7 @@ protected void backingStoreAddWill() throws IOException { public void test106AddToBackingStoreAndGetAccountWill() throws Exception { final String TEST_NAME = "test106AddToBackingStoreAndGetAccountWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); backingStoreAddWill(); @@ -556,7 +556,7 @@ public void test106AddToBackingStoreAndGetAccountWill() throws Exception { public void test108GetAccountWillFuture() throws Exception { final String TEST_NAME = "test108GetAccountWillFuture"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -599,7 +599,7 @@ public void test108GetAccountWillFuture() throws Exception { public void test109GetAccountWillFutureNoFetch() throws Exception { final String TEST_NAME = "test109GetAccountWillFutureNoFetch"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); GetOperationOptions options = GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE); @@ -640,7 +640,7 @@ public void test109GetAccountWillFutureNoFetch() throws Exception { public void test110CloseCaseAndRefreshAccountWill() throws Exception { final String TEST_NAME = "test110CloseCaseAndRefreshAccountWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -702,7 +702,7 @@ public void test110CloseCaseAndRefreshAccountWill() throws Exception { public void test120RefreshAccountWillAfter5min() throws Exception { final String TEST_NAME = "test120RefreshAccountWillAfter5min"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -754,7 +754,7 @@ public void test120RefreshAccountWillAfter5min() throws Exception { public void test130RefreshAccountWillAfter16min() throws Exception { final String TEST_NAME = "test130RefreshAccountWillAfter16min"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -806,7 +806,7 @@ public void test130RefreshAccountWillAfter16min() throws Exception { public void test132RefreshAccountWillAfter27min() throws Exception { final String TEST_NAME = "test132RefreshAccountWillAfter27min"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -845,7 +845,7 @@ public void test132RefreshAccountWillAfter27min() throws Exception { public void test200ModifyAccountWillFullname() throws Exception { final String TEST_NAME = "test200ModifyAccountWillFullname"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -927,7 +927,7 @@ public void test200ModifyAccountWillFullname() throws Exception { public void test202RefreshAccountWill() throws Exception { final String TEST_NAME = "test202RefreshAccountWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1007,7 +1007,7 @@ public void test202RefreshAccountWill() throws Exception { public void test204CloseCaseAndRefreshAccountWill() throws Exception { final String TEST_NAME = "test204CloseCaseAndRefreshAccountWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1100,7 +1100,7 @@ public void test204CloseCaseAndRefreshAccountWill() throws Exception { public void test210RefreshAccountWillAfter5min() throws Exception { final String TEST_NAME = "test210RefreshAccountWillAfter5min"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1168,7 +1168,7 @@ protected void backingStoreUpdateWill(String newFullName, ActivationStatusType n public void test212UpdateBackingStoreAndGetAccountWill() throws Exception { final String TEST_NAME = "test212UpdateBackingStoreAndGetAccountWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1232,7 +1232,7 @@ public void test212UpdateBackingStoreAndGetAccountWill() throws Exception { public void test220ModifyAccountWillDisable() throws Exception { final String TEST_NAME = "test220ModifyAccountWillDisable"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1315,7 +1315,7 @@ public void test220ModifyAccountWillDisable() throws Exception { public void test230ModifyAccountWillChangePasswordAndEnable() throws Exception { final String TEST_NAME = "test230ModifyAccountWillChangePasswordAndEnable"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1405,7 +1405,7 @@ public void test230ModifyAccountWillChangePasswordAndEnable() throws Exception { public void test240CloseDisableCaseAndReadAccountWill() throws Exception { final String TEST_NAME = "test240CloseDisableCaseAndReadAccountWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1516,7 +1516,7 @@ public void test240CloseDisableCaseAndReadAccountWill() throws Exception { public void test250RefreshAccountWillAfter5min() throws Exception { final String TEST_NAME = "test250RefreshAccountWillAfter5min"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1603,7 +1603,7 @@ public void test250RefreshAccountWillAfter5min() throws Exception { public void test252UpdateBackingStoreAndGetAccountWill() throws Exception { final String TEST_NAME = "test252UpdateBackingStoreAndGetAccountWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1668,7 +1668,7 @@ public void test252UpdateBackingStoreAndGetAccountWill() throws Exception { public void test260ClosePasswordChangeCaseAndRefreshAccountWill() throws Exception { final String TEST_NAME = "test260ClosePasswordChangeCaseAndRefreshAccountWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1767,7 +1767,7 @@ public void test260ClosePasswordChangeCaseAndRefreshAccountWill() throws Excepti public void test270RefreshAccountWillAfter7min() throws Exception { final String TEST_NAME = "test270RefreshAccountWillAfter7min"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1865,7 +1865,7 @@ public void test270RefreshAccountWillAfter7min() throws Exception { public void test271RefreshAccountWillAfter12min() throws Exception { final String TEST_NAME = "test271RefreshAccountWillAfter12min"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1960,7 +1960,7 @@ public void test271RefreshAccountWillAfter12min() throws Exception { public void test272UpdateBackingStoreAndGetAccountWill() throws Exception { final String TEST_NAME = "test272UpdateBackingStoreAndGetAccountWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -2024,7 +2024,7 @@ public void test272UpdateBackingStoreAndGetAccountWill() throws Exception { public void test280RefreshAccountWillAfter5min() throws Exception { final String TEST_NAME = "test132RefreshAccountWillAfter10min"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -2112,7 +2112,7 @@ public void test280RefreshAccountWillAfter5min() throws Exception { public void test290RefreshAccountWillAfter5min() throws Exception { final String TEST_NAME = "test134RefreshAccountWillAfter5min"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -2177,7 +2177,7 @@ public void test290RefreshAccountWillAfter5min() throws Exception { public void test300DeleteAccountWill() throws Exception { final String TEST_NAME = "test300DeleteAccountWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -2246,7 +2246,7 @@ public void test300DeleteAccountWill() throws Exception { public void test302GetAccountWillFuture() throws Exception { final String TEST_NAME = "test302GetAccountWillFuture"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -2271,7 +2271,7 @@ public void test302GetAccountWillFuture() throws Exception { public void test303GetAccountWillFutureNoFetch() throws Exception { final String TEST_NAME = "test303GetAccountWillFutureNoFetch"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); GetOperationOptions options = GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE); @@ -2303,7 +2303,7 @@ public void test303GetAccountWillFutureNoFetch() throws Exception { public void test310CloseCaseAndRefreshAccountWill() throws Exception { final String TEST_NAME = "test310CloseCaseAndRefreshAccountWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -2369,7 +2369,7 @@ public void test310CloseCaseAndRefreshAccountWill() throws Exception { public void test320RefreshAccountWillAfter5min() throws Exception { final String TEST_NAME = "test320RefreshAccountWillAfter5min"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/AbstractOpenDjTest.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/AbstractOpenDjTest.java index 203d757bd99..5e34f210be5 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/AbstractOpenDjTest.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/AbstractOpenDjTest.java @@ -25,7 +25,6 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.ResourceTypeUtil; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.ldap.OpenDJController; import com.evolveum.midpoint.util.DOMUtil; diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDj.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDj.java index ef57a767bec..c7db08f133b 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDj.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDj.java @@ -138,11 +138,6 @@ protected int getNumberOfBaseContextShadows() { return 0; } - @Override - public void initSystem(Task initTask, OperationResult initResult) throws Exception { - super.initSystem(initTask, initResult); - } - @BeforeClass public static void startLdap() throws Exception { LOGGER.info("------------------------------------------------------------------------------"); @@ -160,7 +155,7 @@ public static void startLdap() throws Exception { } @AfterClass - public static void stopLdap() throws Exception { + public static void stopLdap() { openDJController.stop(); LOGGER.info("------------------------------------------------------------------------------"); LOGGER.info("STOP: ProvisioningServiceImplOpenDJTest"); @@ -176,9 +171,7 @@ public static void stopLdap() throws Exception { */ @Test public void test003Connection() throws Exception { - final String TEST_NAME = "test003Connection"; - - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ResourceType resourceTypeBefore = repositoryService.getObject(ResourceType.class,RESOURCE_OPENDJ_OID, null, result).asObjectable(); assertNotNull("No connector ref",resourceTypeBefore.getConnectorRef()); @@ -234,7 +227,7 @@ public void test003Connection() throws Exception { public void test004ResourceAndConnectorCaching() throws Exception { final String TEST_NAME = "test004ResourceAndConnectorCaching"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); resource = provisioningService.getObject(ResourceType.class,RESOURCE_OPENDJ_OID, null, null, result); @@ -256,19 +249,19 @@ public void test004ResourceAndConnectorCaching() throws Exception { PrismContainer configurationContainer = resource.findContainer(ResourceType.F_CONNECTOR_CONFIGURATION); PrismContainer configurationContainerAgain = resourceAgain.findContainer(ResourceType.F_CONNECTOR_CONFIGURATION); assertTrue("Configurations not equivalent", configurationContainer.equivalent(configurationContainerAgain)); - assertTrue("Configurations not equals", configurationContainer.equals(configurationContainerAgain)); + assertEquals("Configurations not equals", configurationContainerAgain, configurationContainer); ResourceSchema resourceSchemaAgain = RefinedResourceSchemaImpl.getResourceSchema(resourceAgain, prismContext); assertNotNull("No resource schema (again)", resourceSchemaAgain); assertEquals("Schema serial number mismatch", resourceType.getSchema().getCachingMetadata().getSerialNumber(), resourceTypeAgain.getSchema().getCachingMetadata().getSerialNumber()); - assertTrue("Resource schema was not cached", resourceSchema == resourceSchemaAgain); + assertSame("Resource schema was not cached", resourceSchema, resourceSchemaAgain); // Now we stick our nose deep inside the provisioning impl. But we need to make sure that the // configured connector is properly cached ConnectorInstance configuredConnectorInstanceAgain = resourceManager.getConfiguredConnectorInstance( resourceAgain, ReadCapabilityType.class, false, result); - assertTrue("Connector instance was not cached", configuredConnectorInstance == configuredConnectorInstanceAgain); + assertSame("Connector instance was not cached", configuredConnectorInstance, configuredConnectorInstanceAgain); assertShadows(1); } @@ -278,7 +271,7 @@ public void test005Capabilities() throws Exception { final String TEST_NAME = "test005Capabilities"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -344,8 +337,7 @@ public void test005Capabilities() throws Exception { } protected void assertPasswordCapability(PasswordCapabilityType capPassword) { - assertTrue("Wrong password capability readable flag: "+capPassword.isReadable(), - capPassword.isReadable() != Boolean.TRUE); + assertNotSame("Wrong password capability readable flag: " + capPassword.isReadable(), capPassword.isReadable(), Boolean.TRUE); } @Test @@ -403,7 +395,7 @@ public void test006Schema() throws Exception { assertTrue("No jpegPhoto create", jpegPhoto.canAdd()); assertTrue("No jpegPhoto update", jpegPhoto.canModify()); assertTrue("No jpegPhoto read", jpegPhoto.canRead()); - assertEquals("Wrong jpegPhoto matching rule", null, jpegPhoto.getMatchingRuleQName()); + assertNull("Wrong jpegPhoto matching rule", jpegPhoto.getMatchingRuleQName()); ResourceAttributeDefinition dsDef = accountDef.findAttributeDefinition("ds-pwp-account-disabled"); assertNotNull("No definition for ds-pwp-account-disabled", dsDef); @@ -431,7 +423,7 @@ public void test006Schema() throws Exception { assertTrue("No labeledUri create", labeledUriDef.canAdd()); assertTrue("No labeledUri update", labeledUriDef.canModify()); assertTrue("No labeledUri read", labeledUriDef.canRead()); - assertEquals("Wrong labeledUri matching rule", null, labeledUriDef.getMatchingRuleQName()); + assertNull("Wrong labeledUri matching rule", labeledUriDef.getMatchingRuleQName()); ResourceAttributeDefinition secretaryDef = accountDef.findAttributeDefinition("secretary"); assertNotNull("No definition for secretary", secretaryDef); @@ -450,7 +442,7 @@ public void test006Schema() throws Exception { assertTrue("No createTimestamp read", createTimestampDef.canRead()); assertFalse("Bad createTimestamp create", createTimestampDef.canAdd()); assertFalse("Bad createTimestamp update", createTimestampDef.canModify()); - assertEquals("Wrong createTimestamp matching rule", null, createTimestampDef.getMatchingRuleQName()); + assertNull("Wrong createTimestamp matching rule", createTimestampDef.getMatchingRuleQName()); // MID-5210 ResourceAttributeDefinition descriptionDef = accountDef.findAttributeDefinition(ATTRIBUTE_DESCRIPTION_NAME); @@ -461,7 +453,7 @@ public void test006Schema() throws Exception { assertTrue("No description read", descriptionDef.canRead()); assertTrue("Bad description create", descriptionDef.canAdd()); assertTrue("Bad description update", descriptionDef.canModify()); - assertEquals("Wrong description matching rule", null, descriptionDef.getMatchingRuleQName()); + assertNull("Wrong description matching rule", descriptionDef.getMatchingRuleQName()); assertNull("The _PASSSWORD_ attribute sneaked into schema", accountDef.findAttributeDefinition(new QName(SchemaConstants.NS_ICF_SCHEMA, "password"))); @@ -536,7 +528,6 @@ protected void assertPolyStringType(String attrName, ResourceAttributeDefinition @Test public void test007RefinedSchema() throws Exception { - final String TEST_NAME = "test007RefinedSchema"; // GIVEN // WHEN @@ -547,8 +538,7 @@ public void test007RefinedSchema() throws Exception { // all over again // Not equals() but == ... we want to really know if exactly the same // object instance is returned - assertTrue("Broken caching", - refinedSchema == RefinedResourceSchemaImpl.getRefinedSchema(resourceType, prismContext)); + assertSame("Broken caching", refinedSchema, RefinedResourceSchemaImpl.getRefinedSchema(resourceType, prismContext)); RefinedObjectClassDefinition accountDef = refinedSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT); assertNotNull("Account definition is missing", accountDef); @@ -654,7 +644,7 @@ public void test007RefinedSchema() throws Exception { public void test020ListResourceObjects() throws Exception { final String TEST_NAME = "test020ListResourceObjects"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -674,7 +664,7 @@ public void test020ListResourceObjects() throws Exception { public void test110GetObject() throws Exception { final String TEST_NAME = "test110GetObject"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ShadowType objectToAdd = parseObjectType(ACCOUNT_JBOND_FILE, ShadowType.class); @@ -765,7 +755,7 @@ protected void assertShadowPassword(ShadowType provisioningShadow) throws Except public void test111GetObjectNotFoundRepo() throws Exception { final String TEST_NAME = "test111GetObjectNotFoundRepo"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); try { @@ -799,7 +789,7 @@ public void test111GetObjectNotFoundRepo() throws Exception { public void test112GetObjectNotFoundResource() throws Exception { final String TEST_NAME = "test112GetObjectNotFoundResource"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -817,7 +807,7 @@ public void test112GetObjectNotFoundResource() throws Exception { public void test119Cleanup() throws Exception { final String TEST_NAME = "test119Cleanup"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); repositoryService.deleteObject(ShadowType.class, ACCOUNT_BAD_OID, result); @@ -830,7 +820,7 @@ public void test119Cleanup() throws Exception { public void test120AddAccountWill() throws Exception { final String TEST_NAME = "test120AddAccountWill"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject accountBefore = parseObject(ACCOUNT_WILL_FILE); @@ -862,7 +852,7 @@ public void test120AddAccountWill() throws Exception { public void test121RenameAccountWillOnResource() throws Exception{ String TEST_NAME = "test121RenameAccountWillOnResource"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); openDJController.executeRenameChange(new File(TEST_DIR, "rename.ldif").getPath()); @@ -890,7 +880,7 @@ public void test121RenameAccountWillOnResource() throws Exception{ public void test125AddObjectNull() throws Exception { final String TEST_NAME = "test125AddObjectNull"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); String addedObjectOid = null; @@ -912,7 +902,7 @@ public void test125AddObjectNull() throws Exception { public void test130AddDeleteAccountSparrow() throws Exception { final String TEST_NAME = "test130AddDeleteAccountSparrow"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ShadowType object = parseObjectType(ACCOUNT_SPARROW_FILE, ShadowType.class); @@ -956,7 +946,7 @@ public void test130AddDeleteAccountSparrow() throws Exception { public void test140AddAndModifyAccountJack() throws Exception { final String TEST_NAME = "test140AddAndModifyAccountJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ShadowType object = unmarshallValueFromFile(ACCOUNT_JACK_FILE, ShadowType.class); @@ -1027,7 +1017,7 @@ public void test140AddAndModifyAccountJack() throws Exception { public void test145ModifyAccountJackJpegPhoto() throws Exception { final String TEST_NAME = "test145ModifyAccountJackJpegPhoto"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); byte[] bytesIn = Files.readAllBytes(Paths.get(ProvisioningTestUtil.DOT_JPG_FILENAME)); @@ -1083,7 +1073,7 @@ public void test145ModifyAccountJackJpegPhoto() throws Exception { public void test147ModifyAccountJackGivenNameDuplicit() throws Exception { final String TEST_NAME = "test147ModifyAccountJackGivenNameDuplicit"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PropertyDelta givenNameDelta = prismContext.deltaFactory().property().create( @@ -1134,7 +1124,7 @@ public void test147ModifyAccountJackGivenNameDuplicit() throws Exception { public void test150ChangePassword() throws Exception { final String TEST_NAME = "test150ChangePassword"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ShadowType object = parseObjectType(ACCOUNT_MODIFY_PASSWORD_FILE, ShadowType.class); @@ -1188,7 +1178,7 @@ public void test150ChangePassword() throws Exception { public void test151AddObjectWithPassword() throws Exception { final String TEST_NAME = "test151AddObjectWithPassword"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ShadowType object = parseObjectType(ACCOUNT_NEW_WITH_PASSWORD_FILE, ShadowType.class); @@ -1236,7 +1226,7 @@ public void test160SearchAccountsIterative() throws Exception { final String TEST_NAME = "test160SearchAccountsIterative"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); final String resourceNamespace = ResourceTypeUtil.getResourceNamespace(resource); @@ -1300,7 +1290,7 @@ public void test161SearchAccountsIterativeOffset2Page3() throws Exception { final String TEST_NAME = "test161SearchAccountsIterativeOffset2Page3"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); final String resourceNamespace = ResourceTypeUtil.getResourceNamespace(resource); @@ -1347,7 +1337,7 @@ public void test162SearchAccountsIterativeOffsetNullPage5() throws Exception { final String TEST_NAME = "test162SearchAccountsIterativeOffsetNullPage5"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); final String resourceNamespace = ResourceTypeUtil.getResourceNamespace(resource); @@ -1406,7 +1396,7 @@ protected void assertShadows(int expectedCount) throws SchemaException { public void test170DisableAccount() throws Exception{ final String TEST_NAME = "test170DisableAccount"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ShadowType object = parseObjectType(ACCOUNT_DISABLE_SIMULATED_FILE, ShadowType.class); @@ -1464,7 +1454,7 @@ public void test170DisableAccount() throws Exception{ public void test175AddDisabledAccount() throws Exception { final String TEST_NAME = "test175AddDisabledAccount"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ShadowType object = parseObjectType(ACCOUNT_NEW_DISABLED_FILE, ShadowType.class); @@ -1514,7 +1504,7 @@ public void test175AddDisabledAccount() throws Exception { public void test176AddEnabledAccount() throws Exception { final String TEST_NAME = "test176AddEnabledAccount"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ShadowType object = parseObjectType(ACCOUNT_NEW_ENABLED_FILE, ShadowType.class); @@ -1550,7 +1540,7 @@ public void test176AddEnabledAccount() throws Exception { public void test180GetUnlockedAccount() throws Exception { final String TEST_NAME = "test180GetUnlockedAccount"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1569,7 +1559,7 @@ public void test180GetUnlockedAccount() throws Exception { public void test182GetLockedAccount() throws Exception { final String TEST_NAME = "test182GetLockedAccount"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); openDJController.executeLdifChange( @@ -1595,7 +1585,7 @@ public void test182GetLockedAccount() throws Exception { public void test184UnlockAccount() throws Exception{ final String TEST_NAME = "test184UnlockAccount"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object().createModificationReplaceProperty(ShadowType.class, @@ -1634,7 +1624,7 @@ public void test184UnlockAccount() throws Exception{ public void test200SearchObjectsIterative() throws Exception { final String TEST_NAME = "test200SearchObjectsIterative"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ShadowType object = parseObjectType(ACCOUNT_SEARCH_ITERATIVE_FILE, ShadowType.class); @@ -1676,7 +1666,7 @@ public boolean handle(PrismObject object, OperationResult parentResu public void test201SearchObjects() throws Exception { final String TEST_NAME = "test201SearchObjects"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ShadowType object = parseObjectType(ACCOUNT_SEARCH_FILE, ShadowType.class); @@ -1712,7 +1702,7 @@ public void test201SearchObjects() throws Exception { public void test202SearchObjectsCompexFilter() throws Exception { final String TEST_NAME = "test202SearchObjectsCompexFilter"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_COMPLEX_FILTER_FILE, QueryType.COMPLEX_TYPE); @@ -1747,7 +1737,7 @@ public void test202SearchObjectsCompexFilter() throws Exception { public void test203SearchObjectsByDnExists() throws Exception { final String TEST_NAME = "test203SearchObjectsByDnExists"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = createAccountShadowQuerySecondaryIdentifier(ACCOUNT_BARBOSSA_DN, resource); @@ -1787,7 +1777,7 @@ public void test203SearchObjectsByDnExists() throws Exception { public void test205SearchObjectsByDnNotExists() throws Exception { final String TEST_NAME = "test205SearchObjectsByDnNotExists"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = createAccountShadowQuerySecondaryIdentifier( @@ -1823,7 +1813,7 @@ public void test205SearchObjectsByDnNotExists() throws Exception { public void test206SearchObjectsCompexFilterStartsWith() throws Exception { final String TEST_NAME = "test206SearchObjectsCompexFilterStartsWith"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_COMPLEX_FILTER_STARTS_WITH_FILE, QueryType.COMPLEX_TYPE); @@ -1858,7 +1848,7 @@ public void test206SearchObjectsCompexFilterStartsWith() throws Exception { public void test230SearchObjectsPagedNoOffset() throws Exception { final String TEST_NAME = "test230SearchObjectsPagedNoOffset"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_ALL_ACCOUNTS_FILE, QueryType.COMPLEX_TYPE); @@ -1893,7 +1883,7 @@ public void test230SearchObjectsPagedNoOffset() throws Exception { public void test231SearchObjectsPagedOffsetZero() throws Exception { final String TEST_NAME = "test231SearchObjectsPagedOffsetZero"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_ALL_ACCOUNTS_FILE, QueryType.COMPLEX_TYPE); @@ -1928,7 +1918,7 @@ public void test231SearchObjectsPagedOffsetZero() throws Exception { public void test232SearchObjectsPagedOffset() throws Exception { final String TEST_NAME = "test232SearchObjectsPagedOffset"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_ALL_ACCOUNTS_FILE, QueryType.COMPLEX_TYPE); @@ -1964,7 +1954,7 @@ public void test232SearchObjectsPagedOffset() throws Exception { public void test233SearchObjectsPagedNoOffsetSortSn() throws Exception { final String TEST_NAME = "test233SearchObjectsPagedNoOffsetSortSn"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_ALL_ACCOUNTS_FILE, QueryType.COMPLEX_TYPE); @@ -2002,7 +1992,7 @@ public void test233SearchObjectsPagedNoOffsetSortSn() throws Exception { public void test234SearchObjectsPagedOffsetSortSn() throws Exception { final String TEST_NAME = "test234SearchObjectsPagedOffsetSortSn"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_ALL_ACCOUNTS_FILE, QueryType.COMPLEX_TYPE); @@ -2054,7 +2044,7 @@ private void assertSearchResults(List> searchResults, St public void test250CountAccounts() throws Exception { final String TEST_NAME = "test250CountAccounts"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_ALL_ACCOUNTS_FILE, QueryType.COMPLEX_TYPE); @@ -2080,7 +2070,7 @@ public void test250CountAccounts() throws Exception { public void test252CountLdapGroups() throws Exception { final String TEST_NAME = "test252CountLdapGroups"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_ALL_LDAP_GROUPS_FILE, QueryType.COMPLEX_TYPE); @@ -2110,7 +2100,7 @@ protected Integer getExpectedLdapGroupCountTest25x() { public void test300AddObjectObjectAlreadyExistResource() throws Exception { final String TEST_NAME = "test300AddObjectObjectAlreadyExistResource"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject account = PrismTestUtil.parseObject(ACCOUNT_SEARCH_FILE); @@ -2138,7 +2128,7 @@ public void test300AddObjectObjectAlreadyExistResource() throws Exception { public void test310AddObjectNoSn() throws Exception { final String TEST_NAME = "test310AddObjectNoSn"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject account = PrismTestUtil.parseObject(ACCOUNT_NO_SN_FILE); @@ -2169,7 +2159,7 @@ public void test310AddObjectNoSn() throws Exception { public void test320AddAccountPosix() throws Exception { final String TEST_NAME = "test320AddAccountPosix"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ShadowType object = parseObjectType(ACCOUNT_POSIX_MCMUTTON_FILE, ShadowType.class); @@ -2219,7 +2209,7 @@ public void test320AddAccountPosix() throws Exception { public void test322ModifyAccountPosix() throws Exception { final String TEST_NAME = "test322ModifyAccountPosix"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectModificationType objectChange = PrismTestUtil.parseAtomicValue(ACCOUNT_POSIX_MCMUTTON_CHANGE_FILE, ObjectModificationType.COMPLEX_TYPE); @@ -2264,7 +2254,7 @@ public void test322ModifyAccountPosix() throws Exception { public void test329DeleteAccountPosix() throws Exception { final String TEST_NAME = "test329DeleteAccountPosix"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -2301,7 +2291,7 @@ public void test329DeleteAccountPosix() throws Exception { public void test330SearchForPosixAccount() throws Exception { final String TEST_NAME = "test330SearchForPosixAccount"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_VANHELGEN_FILE, @@ -2348,7 +2338,7 @@ public void test330SearchForPosixAccount() throws Exception { public void test400AddGroupSwashbucklers() throws Exception { final String TEST_NAME = "test400AddGroupSwashbucklers"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ShadowType object = parseObjectType(GROUP_SWASHBUCKLERS_FILE, ShadowType.class); @@ -2389,7 +2379,7 @@ public void test400AddGroupSwashbucklers() throws Exception { public void test402AddAccountMorganWithAssociation() throws Exception { final String TEST_NAME = "test402AddAccountMorganWithAssociation"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ShadowType object = parseObjectType(ACCOUNT_MORGAN_FILE, ShadowType.class); @@ -2443,7 +2433,7 @@ public void test402AddAccountMorganWithAssociation() throws Exception { public void test403modifyMorganReplaceAssociation() throws Exception { final String TEST_NAME = "test403modifyMorganReplaceAssociation"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -2496,7 +2486,7 @@ public void test403modifyMorganReplaceAssociation() throws Exception { public void test405GetGroupSwashbucklers() throws Exception { final String TEST_NAME = "test405GetGroupSwashbucklers"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -2528,7 +2518,7 @@ public void test405GetGroupSwashbucklers() throws Exception { public void test410CreateLdapGroupAndSearchGroups() throws Exception { final String TEST_NAME = "test410CreateLdapGroupAndSearchGroups"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); openDJController.addEntry("dn: cn=seadogs,ou=groups,dc=EXAMPLE,dc=com\n" + @@ -2561,7 +2551,7 @@ public void test410CreateLdapGroupAndSearchGroups() throws Exception { public void test412CreateLdapGroupWithMemberAndGet() throws Exception { final String TEST_NAME = "test412CreateLdapGroupWithMemberAndGet"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); openDJController.addEntry("dn: cn=sailor,ou=Groups,dc=example,dc=com\n" + @@ -2598,7 +2588,7 @@ public void test412CreateLdapGroupWithMemberAndGet() throws Exception { public void test414AddGroupCorsairsAssociateUser() throws Exception { final String TEST_NAME = "test414AddGroupCorsairsAssociateUser"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ShadowType object = parseObjectType(GROUP_CORSAIRS_FILE, ShadowType.class); @@ -2624,7 +2614,7 @@ public void test414AddGroupCorsairsAssociateUser() throws Exception { public void test416AssociateUserToCorsairs() throws Exception { final String TEST_NAME = "test416AssociateUserToCorsairs"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = IntegrationTestTools.createEntitleDelta(ACCOUNT_MORGAN_OID, @@ -2652,7 +2642,7 @@ public void test416AssociateUserToCorsairs() throws Exception { public void test418GetMorgan() throws Exception { final String TEST_NAME = "test418GetMorgan"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -2679,7 +2669,7 @@ public void test418GetMorgan() throws Exception { public void test429DeleteAccountMorgan() throws Exception { final String TEST_NAME = "test429DeleteAccountMorgan"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -2718,7 +2708,7 @@ public void test429DeleteAccountMorgan() throws Exception { public void test450ListGroupsObjectclass() throws Exception { final String TEST_NAME = "test450ListGroupsObjectclass"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(RESOURCE_OPENDJ_OID, @@ -2744,7 +2734,7 @@ public void test450ListGroupsObjectclass() throws Exception { public void test452ListLdapGroupsKindIntent() throws Exception { final String TEST_NAME = "test452ListLdapGroupsKindIntent"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, @@ -2770,7 +2760,7 @@ public void test452ListLdapGroupsKindIntent() throws Exception { public void test454ListSpecialGroupsKindIntent() throws Exception { final String TEST_NAME = "test454ListSpecialGroupsKindIntent"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, @@ -2798,7 +2788,7 @@ public void test454ListSpecialGroupsKindIntent() throws Exception { public void test456AddGroupSpecialists() throws Exception { final String TEST_NAME = "test456AddGroupSpecialists"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ShadowType object = parseObjectType(GROUP_SPECIALISTS_FILE, ShadowType.class); @@ -2839,7 +2829,7 @@ public void test456AddGroupSpecialists() throws Exception { public void test457ListLdapGroupsKindIntent() throws Exception { final String TEST_NAME = "test457ListLdapGroupsKindIntent"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, @@ -2865,7 +2855,7 @@ public void test457ListLdapGroupsKindIntent() throws Exception { public void test458ListSpecialGroupsKindIntent() throws Exception { final String TEST_NAME = "test458ListSpecialGroupsKindIntent"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, @@ -2899,7 +2889,7 @@ public void test458ListSpecialGroupsKindIntent() throws Exception { public void test460ListOrganizationalUnitPeopleKindIntent() throws Exception { final String TEST_NAME = "test460ListOrganizationalUnitPeopleKindIntent"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, @@ -2930,7 +2920,7 @@ public void test460ListOrganizationalUnitPeopleKindIntent() throws Exception { public void test470AddAccountPolyDescription() throws Exception { final String TEST_NAME = "test470AddAccountPolyDescription"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject accountBefore = parseObject(ACCOUNT_POLY_FILE); @@ -2976,7 +2966,7 @@ public void test470AddAccountPolyDescription() throws Exception { public void test472ModifyAccountJackDescriptionOrig() throws Exception { final String TEST_NAME = "test472ModifyAccountJackDescriptionOrig"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PolyString descriptionBefore = new PolyString("Bar"); @@ -3026,7 +3016,7 @@ public void test472ModifyAccountJackDescriptionOrig() throws Exception { public void test474ModifyAccountJackDescriptionLangEnSk() throws Exception { final String TEST_NAME = "test474ModifyAccountJackDescriptionLangEnSk"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PolyString descriptionBefore = new PolyString(USER_JACK_FULL_NAME); @@ -3078,7 +3068,7 @@ public void test474ModifyAccountJackDescriptionLangEnSk() throws Exception { public void test476ModifyAccountJackDescriptionLangEnSkRuHr() throws Exception { final String TEST_NAME = "test476ModifyAccountJackDescriptionLangEnSkRuHr"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PolyString descriptionBefore = new PolyString(USER_JACK_FULL_NAME); @@ -3130,7 +3120,7 @@ public void test476ModifyAccountJackDescriptionLangEnSkRuHr() throws Exception { public void test478ModifyAccountJackDescriptionLangEnSkRuHr() throws Exception { final String TEST_NAME = "test478ModifyAccountJackDescriptionLangEnSkRuHr"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PolyString descriptionBefore = new PolyString(USER_JACK_FULL_NAME); @@ -3181,7 +3171,7 @@ public void test478ModifyAccountJackDescriptionLangEnSkRuHr() throws Exception { public void test478bModifyAccountJackDeleteDescription() throws Exception { final String TEST_NAME = "test478bModifyAccountJackDeleteDescription"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PolyString descriptionBefore = new PolyString(USER_JACK_FULL_NAME); @@ -3234,7 +3224,7 @@ public void test478bModifyAccountJackDeleteDescription() throws Exception { public void test479ModifyAccountJackDescriptionJack() throws Exception { final String TEST_NAME = "test479ModifyAccountJackDescriptionJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PolyString descriptionBefore = new PolyString(USER_JACK_FULL_NAME); @@ -3280,7 +3270,7 @@ public void test479ModifyAccountJackDescriptionJack() throws Exception { public void test480AddOuSuper() throws Exception { final String TEST_NAME = "test480AddOuSuper"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ShadowType object = parseObjectType(OU_SUPER_FILE, ShadowType.class); @@ -3327,7 +3317,7 @@ public void test480AddOuSuper() throws Exception { public void test489DeleteOuSuperWithSub() throws Exception { final String TEST_NAME = "test489DeleteOuSuperWithSub"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); createSubOrg(); @@ -3356,7 +3346,7 @@ protected void createSubOrg() throws IOException, LDIFException { public void test701ConfiguredCapabilityNoRead() throws Exception{ final String TEST_NAME = "test701ConfiguredCapabilityNoRead"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); addResourceFromFile(new File(TEST_DIR, "resource-opendj-no-read.xml"), IntegrationTestTools.CONNECTOR_LDAP_TYPE, true, result); @@ -3375,7 +3365,7 @@ public void test701ConfiguredCapabilityNoRead() throws Exception{ public void test702ConfiguredCapabilityNoCreate() throws Exception{ final String TEST_NAME = "test702ConfiguredCapabilityNoCreate"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); addResourceFromFile(new File(TEST_DIR, "/resource-opendj-no-create.xml"), IntegrationTestTools.CONNECTOR_LDAP_TYPE, true, result); @@ -3395,7 +3385,7 @@ public void test702ConfiguredCapabilityNoCreate() throws Exception{ public void test703ConfiguredCapabilityNoDelete() throws Exception{ final String TEST_NAME = "test703ConfiguredCapabilityNoDelete"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); addResourceFromFile(new File(TEST_DIR, "/resource-opendj-no-delete.xml"), IntegrationTestTools.CONNECTOR_LDAP_TYPE, true, result); @@ -3413,7 +3403,7 @@ public void test703ConfiguredCapabilityNoDelete() throws Exception{ public void test704ConfiguredCapabilityNoUpdate() throws Exception{ final String TEST_NAME = "test704ConfiguredCapabilityNoUpdate"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); addResourceFromFile(new File(TEST_DIR, "/resource-opendj-no-update.xml"), IntegrationTestTools.CONNECTOR_LDAP_TYPE, true, result); @@ -3433,7 +3423,7 @@ public void test704ConfiguredCapabilityNoUpdate() throws Exception{ public void test710AddResourceOpenDjBadCredentials() throws Exception { final String TEST_NAME = "test710AddResourceOpenDjBadCredentials"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject resource = prismContext.parseObject(RESOURCE_OPENDJ_BAD_CREDENTIALS_FILE); @@ -3454,7 +3444,7 @@ public void test710AddResourceOpenDjBadCredentials() throws Exception { public void test713ConnectionBadCredentials() throws Exception { final String TEST_NAME = "test713ConnectionBadCredentials"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -3475,7 +3465,7 @@ public void test713ConnectionBadCredentials() throws Exception { public void test720AddResourceOpenDjBadBindDn() throws Exception { final String TEST_NAME = "test720AddResourceOpenDjBadBindDn"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject resource = prismContext.parseObject(RESOURCE_OPENDJ_BAD_BIND_DN_FILE); @@ -3496,7 +3486,7 @@ public void test720AddResourceOpenDjBadBindDn() throws Exception { public void test723ConnectionBadBindDn() throws Exception { final String TEST_NAME = "test723ConnectionBadBindDn"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjDumber.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjDumber.java index 2338a60c98c..5b3316d20bd 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjDumber.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjDumber.java @@ -85,7 +85,7 @@ protected void assertTimestamp(String attrName, Object timestampValue) { public void test489DeleteOuSuperWithSub() throws Exception { final String TEST_NAME = "test489DeleteOuSuperWithSub"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); createSubOrg(); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjNegative.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjNegative.java index d9608a050b8..dd394529e1a 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjNegative.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjNegative.java @@ -32,7 +32,6 @@ import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.query.ObjectQuery; -import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.provisioning.api.GenericConnectorException; import com.evolveum.midpoint.schema.DeltaConvertor; @@ -49,7 +48,6 @@ import com.evolveum.midpoint.schema.util.ResourceTypeUtil; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.task.api.TaskManager; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.asserter.ShadowAsserter; import com.evolveum.midpoint.test.util.TestUtil; @@ -62,7 +60,6 @@ import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.FailedOperationTypeType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType; @@ -108,7 +105,7 @@ public static void stoptLdap() throws Exception { public void test003Connection() throws Exception { final String TEST_NAME = "test003Connection"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ResourceType resourceTypeBefore = repositoryService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, result).asObjectable(); display("Resource before testResource (repository)", resourceTypeBefore); @@ -594,7 +591,7 @@ public void test530AddAccountWill() throws Exception { final String TEST_NAME = "test530AddAccountWill"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject object = parseObject(ACCOUNT_WILL_FILE); diff --git a/repo/repo-common/src/test/java/com/evolveum/midpoint/repo/common/commandline/TestCommandLine.java b/repo/repo-common/src/test/java/com/evolveum/midpoint/repo/common/commandline/TestCommandLine.java index b8cb6bda4dd..7f214b7b3fa 100644 --- a/repo/repo-common/src/test/java/com/evolveum/midpoint/repo/common/commandline/TestCommandLine.java +++ b/repo/repo-common/src/test/java/com/evolveum/midpoint/repo/common/commandline/TestCommandLine.java @@ -62,7 +62,7 @@ public void test100PlainExecuteEcho() throws Exception { return; } - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); CommandLineScriptType scriptType = getScript(REPORT_PLAIN_ECHO_FILE); @@ -86,7 +86,7 @@ public void test110RedirExecuteEcho() throws Exception { return; } - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); CommandLineScriptType scriptType = getScript(REPORT_REDIR_ECHO_FILE); 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 79d0d03e6da..cb91045c2b8 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 @@ -50,7 +50,6 @@ import org.testng.ITestResult; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; -import org.testng.annotations.BeforeTest; import org.testng.annotations.Listeners; import org.w3c.dom.Element; @@ -93,7 +92,6 @@ import com.evolveum.midpoint.schema.internals.InternalsConfig; import com.evolveum.midpoint.schema.processor.ObjectFactory; import com.evolveum.midpoint.schema.processor.*; -import com.evolveum.midpoint.schema.result.CompiledTracingProfile; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.result.OperationResultStatus; import com.evolveum.midpoint.schema.util.*; @@ -150,13 +148,19 @@ public abstract class AbstractIntegrationTest extends AbstractTestNGSpringContex @Autowired @Qualifier("cacheRepositoryService") protected RepositoryService repositoryService; - // TODO removed after consultation -// protected static Set> initializedClasses = new HashSet<>(); + private long lastDummyResourceGroupMembersReadCount; private long lastDummyResourceWriteOperationCount; @Autowired protected Tracer tracer; + + /** + * Task manager should not be used directly in subclasses, better use provided methods, + * even better just utilize prepared method-test-scoped task via {@link #getTestTask()}. + * TODO: can the goal be to make this private and only access it through behaviour (method)? + */ @Autowired protected TaskManager taskManager; + @Autowired protected Protector protector; @Autowired protected Clock clock; @Autowired protected PrismContext prismContext; @@ -191,65 +195,59 @@ public void initSystemConditional() throws Exception { // Check whether we are already initialized assertNotNull("Repository is not wired properly", repositoryService); assertNotNull("Task manager is not wired properly", taskManager); -// LOGGER.trace("initSystemConditional: {} systemInitialized={}", this.getClass(), isSystemInitialized()); -// if (!isSystemInitialized()) { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.setPrismContext(prismContext); - Task initTask = taskManager.createTaskInstance(this.getClass().getName() + ".initSystem"); - initTask.setChannel(SchemaConstants.CHANNEL_GUI_INIT_URI); - OperationResult result = initTask.getResult(); - - InternalMonitor.reset(); - InternalsConfig.setPrismMonitoring(true); - prismContext.setMonitor(new InternalMonitor()); - - ((LocalizationServiceImpl) localizationService).setOverrideLocale(Locale.US); - - initSystem(initTask, result); + PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); + PrismTestUtil.setPrismContext(prismContext); + Task initTask = taskManager.createTaskInstance(getClass().getName() + ".initSystem"); + initTask.setChannel(SchemaConstants.CHANNEL_GUI_INIT_URI); + OperationResult result = initTask.getResult(); - postInitSystem(initTask, result); + InternalMonitor.reset(); + InternalsConfig.setPrismMonitoring(true); + prismContext.setMonitor(new InternalMonitor()); - result.computeStatus(); - IntegrationTestTools.display("initSystem result", result); - TestUtil.assertSuccessOrWarning("initSystem failed (result)", result, 1); + ((LocalizationServiceImpl) localizationService).setOverrideLocale(Locale.US); -// setSystemInitialized(); -// } - } + initSystem(initTask, result); + postInitSystem(initTask, result); - @Deprecated - protected boolean isSystemInitialized() { - return true; -// return initializedClasses.contains(this.getClass()); + result.computeStatus(); + IntegrationTestTools.display("initSystem result", result); + TestUtil.assertSuccessOrWarning("initSystem failed (result)", result, 1); } - @Deprecated - private void setSystemInitialized() { -// initializedClasses.add(this.getClass()); + /** + * Test class initialization. + */ + protected void initSystem(Task task, OperationResult initResult) throws Exception { + // nothing by default } - @Deprecated - protected void unsetSystemInitialized() { -// initializedClasses.remove(this.getClass()); + /** + * May be used to clean up initialized objects as all of the initialized objects should be + * available at this time. + */ + @Deprecated // let's try to use initSystem only + protected void postInitSystem(Task initTask, OperationResult initResult) throws Exception { + // Nothing to do by default } /** * Creates appropriate task and result and set it into MidpointTestMethodContext. */ @BeforeMethod - public void startTestContext(ITestResult testResult) throws SchemaException { + public void startTestContext(ITestResult testResult) { Class testClass = testResult.getMethod().getTestClass().getRealClass(); String testMethodName = testResult.getMethod().getMethodName(); TestUtil.displayTestTitle(testClass.getSimpleName() + "." + testMethodName); - Task task = createTask(testClass.getName() + "." + testMethodName); - OperationResult rootResult = task.getResult(); - - TracingProfileType tracingProfile = getTestMethodTracingProfile(); - CompiledTracingProfile compiledTracingProfile = tracingProfile != null ? - tracer.compileProfile(tracingProfile, rootResult) : null; + Task task = taskManager.createTaskInstance(testClass.getName() + "." + testMethodName); // TODO do we need that subresult? :-) (Virgo's brave new world) + // maybe it doesn't break tests, but changes traceability/maintenance? +// OperationResult rootResult = task.getResult(); +// TracingProfileType tracingProfile = getTestMethodTracingProfile(); +// CompiledTracingProfile compiledTracingProfile = tracingProfile != null ? +// tracer.compileProfile(tracingProfile, rootResult) : null; // OperationResult result = rootResult.subresult(task.getName() + "Run") // .tracingProfile(compiledTracingProfile) // .build(); @@ -261,6 +259,13 @@ public void startTestContext(ITestResult testResult) throws SchemaException { MidpointTestMethodContext.create(testClass, testMethodName, task, task.getResult()); } + /** + * Subclasses may override this if test task needs additional customization. + */ + protected void customizeTask(Task task) { + // nothing by default + } + /** * Finish and destroy the test context, output duration and store the operation trace. */ @@ -317,91 +322,31 @@ public void setPredefinedTestMethodTracing(PredefinedTestMethodTracing predefine this.predefinedTestMethodTracing = predefinedTestMethodTracing; } - protected Task getTask() { + /** + * Returns default pre-created test-method-scoped {@link Task}. + */ + protected Task getTestTask() { return MidpointTestMethodContext.get().getTask(); } protected String getTestNameShort() { - MidpointTestMethodContext ctx = MidpointTestMethodContext.get(); - if (ctx != null) { - return ctx.getTestNameShort(); - } else { - // TODO simplify if passes - throw new IllegalStateException("getTestNameShort called while MidpointTestMethodContext is null"); -// return createAdHocTestContext(UNKNOWN_METHOD).getMethodName(); - } + return MidpointTestMethodContext.get().getTestNameShort(); } /** - * Retrieves the task from thread-local test method context; creating the appropriately named ad-hoc context - * if it does not exist. - *

- * We expect this method to be called from places where we really don't know if the context exists or not. Hence its name. + * Creates new subresult for default pre-created test-method-scoped {@link Task}. */ - protected Task getOrCreateTestTask(String methodName) { - // TODO if OK, replace with getTask() - MidpointTestMethodContext ctx = MidpointTestMethodContext.get(); - if (ctx != null) { - return ctx.getTask(); - } else { - throw new IllegalStateException("getOrCreateTestTask called while MidpointTestMethodContext is null"); -// return createAdHocTestContext(methodName).getTask(); - } + protected OperationResult createSubresult(String subresultSuffix) { + return getResult().createSubresult(getTestNameShort() + "." + subresultSuffix); } /** - * Retrieves the task from thread-local test method context; creating the task (but NOT the context) if it does not exist. - *

- * The difference to getTask/getOrCreateTestTask is that we use taskManager.createTaskInstance instead of test-specific - * createTask method. So the task created is a simple, plain one -- without all the be bells and whistles provided - * by createTask method. + * Returns default {@link OperationResult} for pre-created test-method-scoped {@link Task}. */ - protected Task getOrCreateSimpleTask(String operationName) { - // TODO if OK, replace with getTask() - MidpointTestMethodContext ctx = MidpointTestMethodContext.get(); - if (ctx != null) { - return ctx.getTask(); - } else { - throw new IllegalStateException("getOrCreateSimpleTask called while MidpointTestMethodContext is null"); -// return taskManager.createTaskInstance(this.getClass().getName() + "." + operationName); - } - } - - protected OperationResult createSubresult(String methodName) { - String className = this.getClass().getName(); - MidpointTestMethodContext ctx = MidpointTestMethodContext.get(); - OperationResult parent; - if (ctx != null) { - parent = ctx.getResult(); - } else { - parent = new OperationResult(className + ".parent"); - } - return parent.createSubresult(className + "." + methodName); - } - protected OperationResult getResult() { - MidpointTestMethodContext ctx = MidpointTestMethodContext.get(); - if (ctx != null) { - return ctx.getResult(); - } else { - // TODO simplify if OK - throw new IllegalStateException("getResult called while MidpointTestMethodContext is null"); -// return createAdHocTestContext(UNKNOWN_METHOD).getResult(); - } - } - - abstract public void initSystem(Task initTask, OperationResult initResult) throws Exception; - - /** - * May be used to clean up initialized objects as all of the initialized objects should be - * available at this time. - */ - protected void postInitSystem(Task initTask, OperationResult initResult) throws Exception { - // Nothing to do by default + return MidpointTestMethodContext.get().getResult(); } - ; - public S_ItemEntry deltaFor(Class objectClass) throws SchemaException { return prismContext.deltaFor(objectClass); } @@ -1952,13 +1897,6 @@ protected void assertFloat(String message, Float expectedPercentage, Float actua } } - protected Task createTask(String operationName) { - if (!operationName.contains(".")) { - operationName = this.getClass().getName() + "." + operationName; - } - return taskManager.createTaskInstance(operationName); - } - protected void setDefaultTracing(Task task) { setTracing(task, createDefaultTracingProfile()); } @@ -2065,21 +2003,11 @@ protected TracingProfileType createPerformanceTracingProfile() { } protected Task createTracedTask(String operationName) { - Task task = createTask(operationName); + Task task = getTestTask(); task.addTracingRequest(TracingRootType.CLOCKWORK_RUN); task.setTracingProfile(new TracingProfileType() .collectLogEntries(true) .createRepoObject(false) // to avoid influencing repo statistics -// .beginLoggingOverride() -// .beginLevelOverride() -// .logger("org.hibernate.SQL") -// .level(LoggingLevelType.TRACE) -// .end() -// .beginLevelOverride() -// .logger("org.hibernate.type") -// .level(LoggingLevelType.TRACE) -// .end() -// .end() .beginTracingTypeProfile() .level(TracingLevelType.NORMAL) .end() @@ -2264,7 +2192,7 @@ protected void addAccountLinkRef(PrismObject user, File accountFile) t user.asObjectable().getLinkRef().add(linkRef); } - protected void assertLinks(PrismObject focus, int expectedNumLinks) throws ObjectNotFoundException, SchemaException { + protected void assertLinks(PrismObject focus, int expectedNumLinks) { PrismReference linkRef = focus.findReference(FocusType.F_LINK_REF); if (linkRef == null) { assert expectedNumLinks == 0 : "Expected " + expectedNumLinks + " but " + focus + " has no linkRef"; @@ -2287,7 +2215,7 @@ protected void assertLinked(PrismObject focus, PrismObj assertLinked(focus, projection.getOid()); } - protected void assertLinked(PrismObject focus, String projectionOid) throws ObjectNotFoundException, SchemaException { + protected void assertLinked(PrismObject focus, String projectionOid) { PrismReference linkRef = focus.findReference(FocusType.F_LINK_REF); assertNotNull("No linkRefs in " + focus, linkRef); boolean found = false; @@ -2309,7 +2237,7 @@ protected void assertNotLinked(PrismObject user, PrismO assertNotLinked(user, account.getOid()); } - protected void assertNotLinked(PrismObject user, String accountOid) throws ObjectNotFoundException, SchemaException { + protected void assertNotLinked(PrismObject user, String accountOid) { PrismReference linkRef = user.findReference(FocusType.F_LINK_REF); if (linkRef == null) { return; @@ -2332,7 +2260,7 @@ protected void assertNoLinkedAccount(PrismObject user) + accountRef.getValues(); } - protected void assertPersonaLinks(PrismObject focus, int expectedNumLinks) throws ObjectNotFoundException, SchemaException { + protected void assertPersonaLinks(PrismObject focus, int expectedNumLinks) { PrismReference linkRef = focus.findReference(FocusType.F_PERSONA_REF); if (linkRef == null) { assert expectedNumLinks == 0 : "Expected " + expectedNumLinks + " but " + focus + " has no personaRef"; @@ -2371,19 +2299,14 @@ protected void assertExpression(PrismProperty prop, String evaluatorName) assertEquals("Wrong expression evaluator name", evaluatorName, evaluatorElement.getName().getLocalPart()); } - protected void assertNoRepoObject(Class type, String oid) throws SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = createTask(AbstractIntegrationTest.class.getName() + ".assertNoRepoObject"); - assertNoRepoObject(type, oid, task, task.getResult()); - } - - protected void assertNoRepoObject(Class type, String oid, Task task, OperationResult result) throws SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + protected void assertNoRepoObject(Class type, String oid) throws SchemaException { try { + OperationResult result = createSubresult("assertNoRepoObject"); PrismObject object = repositoryService.getObject(type, oid, null, result); AssertJUnit.fail("Expected that " + object + " does not exist, in repo but it does"); } catch (ObjectNotFoundException e) { // This is expected - return; } } @@ -2600,7 +2523,7 @@ protected ObjectDelta createModifyAccountShadowReplaceAttributeDelta return createModifyAccountShadowReplaceDelta(accountOid, resource, ItemPath.create(ShadowType.F_ATTRIBUTES, attributeName), newRealValue); } - protected ObjectDelta createModifyAccountShadowReplaceDelta(String accountOid, PrismObject resource, ItemPath itemPath, Object... newRealValue) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException { + protected ObjectDelta createModifyAccountShadowReplaceDelta(String accountOid, PrismObject resource, ItemPath itemPath, Object... newRealValue) throws SchemaException { if (itemPath.startsWithName(ShadowType.F_ATTRIBUTES)) { PropertyDelta attributeDelta = createAttributeReplaceDelta(resource, ItemPath.toName(itemPath.last()), newRealValue); ObjectDelta accountDelta = prismContext.deltaFactory().object() @@ -2786,7 +2709,7 @@ protected RefinedResourceSchemaAsserter assertRefinedResourceSchema(PrismO return asserter; } - protected ShadowAsserter assertShadow(PrismObject shadow, String details) throws ObjectNotFoundException, SchemaException { + protected ShadowAsserter assertShadow(PrismObject shadow, String details) throws ObjectNotFoundException { ShadowAsserter asserter = ShadowAsserter.forShadow(shadow, details); initializeAsserter(asserter); asserter.display(); @@ -2812,13 +2735,8 @@ protected void assertNoRepoShadow(String oid) throws SchemaException { } } - protected RawType rawize(QName attrName, T value) { - return new RawType(prismContext.itemFactory().createPropertyValue(value), attrName, prismContext); - } - protected void markShadowTombstone(String oid) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { - Task task = createTask("markShadowTombstone"); - OperationResult result = task.getResult(); + OperationResult result = createSubresult("markShadowTombstone"); List> deadModifications = deltaFor(ShadowType.class) .item(ShadowType.F_DEAD).replace(true) .item(ShadowType.F_EXISTS).replace(false) diff --git a/repo/task-api/src/main/java/com/evolveum/midpoint/task/api/TaskManager.java b/repo/task-api/src/main/java/com/evolveum/midpoint/task/api/TaskManager.java index 36813c22268..cb8510e7a85 100644 --- a/repo/task-api/src/main/java/com/evolveum/midpoint/task/api/TaskManager.java +++ b/repo/task-api/src/main/java/com/evolveum/midpoint/task/api/TaskManager.java @@ -218,7 +218,7 @@ void modifyTask(String oid, Collection modifications, Opera /** * Creates new transient, running task instance. * - * This is fact creates usual "synchronous" task. + * This in fact creates usual "synchronous" task. * * This is useful for normal day-to-day tasks that are either * synchronous or start as a synchronous and are switched to diff --git a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdap.java b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdap.java index 042ca5c7d51..35930151dca 100644 --- a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdap.java +++ b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdap.java @@ -45,7 +45,6 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.ObjectQueryUtil; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.ldap.OpenDJController; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; @@ -164,7 +163,7 @@ public void test200AssignRolePiratesToBarbossa() throws Exception { final String TEST_NAME = "test200AssignRolePiratesToBarbossa"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -191,7 +190,7 @@ public void test202AssignLdapAccountToGuybrush() throws Exception { final String TEST_NAME = "test202AssignLdapAccountToGuybrush"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); byte[] photoIn = Files.readAllBytes(Paths.get(DOT_JPG_FILENAME)); @@ -249,7 +248,7 @@ public void test204AssignRolePiratesToGuybrush() throws Exception { final String TEST_NAME = "test204AssignRolePiratesToGuybrush"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); openDJController.executeLdifChange( "dn: cn=Pirates,ou=groups,dc=example,dc=com\n" + @@ -279,7 +278,7 @@ public void test400RenameLeChuckConflicting() throws Exception { final String TEST_NAME = "test400RenameLeChuckConflicting"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userLechuck = createUser(USER_LECHUCK_NAME, "LeChuck", true); @@ -321,7 +320,7 @@ public void test800BigLdapSearch() throws Exception { loadLdapEntries("a", NUM_LDAP_ENTRIES); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -365,7 +364,7 @@ public void test810BigImport() throws Exception { loadLdapEntries("u", NUM_LDAP_ENTRIES); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -396,7 +395,7 @@ public void test820BigReconciliation() throws Exception { // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // System.out.println("openDJController.isRunning = " + openDJController.isRunning()); @@ -433,7 +432,7 @@ public void test900DeleteShadows() throws Exception { // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -481,7 +480,7 @@ public void test910DeleteAccounts() throws Exception { final String TEST_NAME = "test910DeleteAccounts"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); diff --git a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdapComplex.java b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdapComplex.java index 622aec1be00..2a1f982f3e3 100644 --- a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdapComplex.java +++ b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdapComplex.java @@ -11,12 +11,10 @@ import static org.testng.AssertJUnit.assertEquals; import java.io.File; -import java.io.IOException; import javax.xml.namespace.QName; import org.opends.server.types.Entry; -import org.opends.server.util.LDIFException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; @@ -29,7 +27,6 @@ import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; @@ -139,7 +136,7 @@ public void test100BigImport() throws Exception { loadLdapEntries("u", NUM_LDAP_ENTRIES); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -178,7 +175,7 @@ public void test120BigReconciliation() throws Exception { // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -215,7 +212,7 @@ public void test500GuybrushAssignSecurity() throws Exception { final String TEST_NAME = "test500GuybrushAssignSecurity"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); addObject(USER_GUYBRUSH_FILE); @@ -245,7 +242,7 @@ public void test502RuinGuybrushAccountAndReconcile() throws Exception { final String TEST_NAME = "test502RuinGuybrushAccountAndReconcile"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Entry entryOrig = openDJController.searchByUid(USER_GUYBRUSH_USERNAME); diff --git a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestRunAs.java b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestRunAs.java index 1c24f0461fd..03c54b023bf 100644 --- a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestRunAs.java +++ b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestRunAs.java @@ -12,73 +12,27 @@ import static org.testng.AssertJUnit.assertTrue; import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.Arrays; -import java.util.Collection; import java.util.HashMap; -import java.util.List; import java.util.Map; -import javax.xml.namespace.QName; - import com.evolveum.icf.dummy.resource.DummyAccount; -import com.evolveum.midpoint.model.api.ModelService; -import com.evolveum.midpoint.model.impl.sync.ReconciliationTaskHandler; -import com.evolveum.midpoint.test.AbstractIntegrationTest; -import com.evolveum.midpoint.util.MiscUtil; import com.evolveum.midpoint.util.aspect.ProfilingDataManager; -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang.mutable.MutableInt; -import org.opends.server.types.Entry; -import org.opends.server.types.LDIFImportConfig; -import org.opends.server.util.LDIFException; -import org.opends.server.util.LDIFReader; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; -import org.testng.annotations.AfterClass; import org.testng.annotations.Test; -import com.evolveum.midpoint.model.test.AbstractModelIntegrationTest; -import com.evolveum.midpoint.prism.PrismContainer; import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.PrismProperty; import com.evolveum.midpoint.prism.polystring.PolyString; -import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.prism.util.PrismAsserts; -import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.GetOperationOptions; -import com.evolveum.midpoint.schema.ResultHandler; -import com.evolveum.midpoint.schema.RetrieveOption; -import com.evolveum.midpoint.schema.SelectorOptions; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.internals.InternalCounters; import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.schema.util.ObjectQueryUtil; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.DummyResourceContoller; -import com.evolveum.midpoint.test.IntegrationTestTools; -import com.evolveum.midpoint.test.ldap.OpenDJController; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; -import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SecurityViolationException; import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemObjectsType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; /** @@ -163,7 +117,7 @@ public void test100AssignAccountDummyToBarbossa() throws Exception { final String TEST_NAME = "test100AssignAccountDummyToBarbossa"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -194,7 +148,7 @@ public void test109UnassignAccountDummyFromBarbossa() throws Exception { final String TEST_NAME = "test109UnassignAccountDummyFromBarbossa"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -217,7 +171,7 @@ public void test200CleanupPlain() throws Exception { final String TEST_NAME = "test200CleanupPlain"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -256,7 +210,7 @@ public void test210BarbossaSetOrganizationPlain() throws Exception { final String TEST_NAME = "test210BarbossaSetOrganizationPlain"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberCounter(InternalCounters.REPOSITORY_READ_COUNT); @@ -288,7 +242,7 @@ public void test300CleanupRunAs() throws Exception { final String TEST_NAME = "test300CleanupRunAs"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -327,7 +281,7 @@ public void test310BarbossaSetOrganizationRunAs() throws Exception { final String TEST_NAME = "test310BarbossaSetOrganizationRunAs"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberCounter(InternalCounters.REPOSITORY_READ_COUNT); @@ -368,7 +322,7 @@ public void test310BarbossaSetOrganizationRunAs() throws Exception { private void warmUp(final String TEST_NAME) throws Exception { // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberCounter(InternalCounters.REPOSITORY_READ_COUNT); diff --git a/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestAbstractRestService.java b/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestAbstractRestService.java index d84891bbd92..0b8da50ac39 100644 --- a/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestAbstractRestService.java +++ b/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestAbstractRestService.java @@ -1231,7 +1231,7 @@ public void test517generateValueExplicit() throws Exception { public void test518validateValueImplicitPassword() throws Exception { final String TEST_NAME = "test518validateValueImplicitPassword"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject secPolicyNoHistory = parseObject(SECURITY_POLICY_NO_HISTORY); addObject(secPolicyNoHistory, ModelExecuteOptions.createOverwrite(), task, result); diff --git a/testing/samples-test/src/test/java/com/evolveum/midpoint/samples/test/AbstractSampleTest.java b/testing/samples-test/src/test/java/com/evolveum/midpoint/samples/test/AbstractSampleTest.java index 649b41cc086..66fcdc403df 100644 --- a/testing/samples-test/src/test/java/com/evolveum/midpoint/samples/test/AbstractSampleTest.java +++ b/testing/samples-test/src/test/java/com/evolveum/midpoint/samples/test/AbstractSampleTest.java @@ -6,33 +6,19 @@ */ package com.evolveum.midpoint.samples.test; -import com.evolveum.midpoint.model.api.ModelService; import com.evolveum.midpoint.model.test.AbstractModelIntegrationTest; -import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.schema.util.MiscSchemaUtil; -import com.evolveum.midpoint.schema.util.ObjectQueryUtil; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -import org.springframework.beans.factory.annotation.Autowired; + import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; -import org.testng.annotations.Test; -import javax.xml.bind.JAXBException; import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.util.List; import static org.testng.AssertJUnit.assertEquals; diff --git a/testing/samples-test/src/test/java/com/evolveum/midpoint/samples/test/TestSampleImport.java b/testing/samples-test/src/test/java/com/evolveum/midpoint/samples/test/TestSampleImport.java index b6262e49772..b5a7d7127e9 100644 --- a/testing/samples-test/src/test/java/com/evolveum/midpoint/samples/test/TestSampleImport.java +++ b/testing/samples-test/src/test/java/com/evolveum/midpoint/samples/test/TestSampleImport.java @@ -66,7 +66,8 @@ public void importOpenDJAdvanced() throws FileNotFoundException, SchemaException public void importSample(File sampleFile, Class type, String objectName) throws FileNotFoundException, SchemaException { TestUtil.displayTestTitle(this, "Import sample "+sampleFile.getPath()); // GIVEN - Task task = createTask(sampleFile.getName()); + sampleFile.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); result.addParam("file", sampleFile.getPath()); FileInputStream stream = new FileInputStream(sampleFile); diff --git a/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java b/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java index b8d1a8c9ad0..02ff3f8f5a6 100644 --- a/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java +++ b/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java @@ -394,7 +394,6 @@ public void test000Integrity() throws Exception { assertNotNull(modelWeb); assertNotNull(modelService); assertNotNull(repositoryService); - assertTrue(isSystemInitialized()); assertNotNull(taskManager); assertNotNull(prismContext); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConfiguredCapabilitiesActivation.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConfiguredCapabilitiesActivation.java index bf4356b3f8a..c28cf5b22a9 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConfiguredCapabilitiesActivation.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConfiguredCapabilitiesActivation.java @@ -82,7 +82,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti public void test100ImportAccount() throws Exception { final String TEST_NAME = "test100ImportAccount"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -106,7 +106,7 @@ public void test100ImportAccount() throws Exception { public void test110AssignJackPirate() throws Exception { String TEST_NAME = "test110AssignJackPirate"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); //GIVEN @@ -166,7 +166,7 @@ public void test110AssignJackPirate() throws Exception { public void test112ModifyActivationJack() throws Exception { String TEST_NAME = "test112ModifyActivationJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userJack = getUser(USER_JACK_OID); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConsistencyMechanism.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConsistencyMechanism.java index 6ce5b69c9d4..f81aec662e1 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConsistencyMechanism.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConsistencyMechanism.java @@ -315,7 +315,6 @@ public void test000Integrity() throws Exception { assertNotNull(modelWeb); assertNotNull(modelService); assertNotNull(repositoryService); - assertTrue(isSystemInitialized()); assertNotNull(taskManager); assertNotNull(prismContext); @@ -439,7 +438,7 @@ public void test100AddUser() throws Exception { public void test110PrepareOpenDjWithJackieAccounts() throws Exception { final String TEST_NAME = "test110PrepareOpenDjWithJackieAccounts"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult parentResult = task.getResult(); // adding jackie shadow directly and then, linking this shadow to the user jack. we need to do linking on repository level, to skip clockwork execution @@ -494,7 +493,7 @@ public void test110PrepareOpenDjWithJackieAccounts() throws Exception { public void test111prepareOpenDjWithDenielsAccounts() throws Exception { final String TEST_NAME = "test111prepareOpenDjWithDenielsAccounts"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult parentResult = task.getResult(); addObject(ACCOUNT_DENIELS_FILE, task, parentResult); @@ -643,7 +642,7 @@ public void test122AddAccountAlreadyExistUnlinked() throws Exception { @Test(enabled = false) public void test124AddAccountDirectAlreadyExists() throws Exception { final String TEST_NAME = "test124AddAccountDirectAlreadyExists"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult parentResult = task.getResult(); @@ -785,7 +784,7 @@ public void test130DeleteObjectNotFound() throws Exception { @Test public void test140ModifyObjectNotFoundLinkedAccount() throws Exception { final String TEST_NAME = "test140ModifyObjectNotFoundLinkedAccount"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); repoAddShadowFromFile(ACCOUNT_GUYBRUSH_FILE, result); @@ -2778,7 +2777,7 @@ public void test801TestReconciliationRename() throws Exception { final String TEST_NAME = "test801TestReconciliationRename"; openDJController.assumeRunning(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); final OperationResult result = task.getResult(); LOGGER.info("starting rename"); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelayedEnable.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelayedEnable.java index 268ba5642d0..c82e14018e1 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelayedEnable.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelayedEnable.java @@ -31,7 +31,6 @@ import com.evolveum.midpoint.schema.internals.InternalCounters; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.asserter.UserAsserter; import com.evolveum.midpoint.test.util.MidPointTestConstants; @@ -112,7 +111,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti public void test100AddUserMancomb() throws Exception { final String TEST_NAME = "test100AddUserMancomb"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); hrCreateTsStart = clock.currentTimeXMLGregorianCalendar(); @@ -164,7 +163,7 @@ public void test102UserMancombTriggerScannerAgain() throws Exception { public void test104UserMancombRecompute() throws Exception { final String TEST_NAME = "test104UserMancombRecompute"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); displayCurrentTime(); @@ -231,7 +230,7 @@ public void test110UserMancombRunTriggerScannerDay1() throws Exception { public void test112UserMancombRecomputeDay1() throws Exception { final String TEST_NAME = "test112UserMancombRecomputeDay1"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("P1D"); @@ -290,7 +289,7 @@ public void test114UserMancombRunTriggerScannerDay1Again() throws Exception { public void test116UserMancombRecomputeDay1Again() throws Exception { final String TEST_NAME = "test116UserMancombRecomputeDay1Again"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -315,7 +314,7 @@ public void test116UserMancombRecomputeDay1Again() throws Exception { public void test120UserMancombHrDisable() throws Exception { final String TEST_NAME = "test120UserMancombHrDisable"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); hrModifyTsStart = clock.currentTimeXMLGregorianCalendar(); @@ -356,7 +355,7 @@ private void assertMancombHalfDisabled() throws Exception { public void test122UserMancombRecompute() throws Exception { final String TEST_NAME = "test122UserMancombRecompute"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -377,7 +376,7 @@ public void test122UserMancombRecompute() throws Exception { public void test124UserMancombDay1TriggerScanner() throws Exception { final String TEST_NAME = "test124UserMancombDay1TriggerScanner"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -404,7 +403,7 @@ public void test130UserMancombTriggerScannerDay2() throws Exception { clockForward("P1D"); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -442,7 +441,7 @@ private void assertMancombDisabled() throws Exception { public void test132UserMancombRecomputeDay2() throws Exception { final String TEST_NAME = "test132UserMancombRecomputeDay2"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -463,7 +462,7 @@ public void test132UserMancombRecomputeDay2() throws Exception { public void test132UserMancombRecomputeDay2Again() throws Exception { final String TEST_NAME = "test132UserMancombRecomputeDay2Again"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -490,7 +489,7 @@ public void test140UserMancombRecomputeDay3() throws Exception { clockForward("P1D"); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -513,7 +512,7 @@ public void test140UserMancombRecomputeDay3() throws Exception { public void test200HrLivesyncTask() throws Exception { final String TEST_NAME = "test200HrLivesyncTask"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -534,7 +533,7 @@ public void test200HrLivesyncTask() throws Exception { public void test210HrAddUserGuybrush() throws Exception { final String TEST_NAME = "test210HrAddUserGuybrush"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyAccount accountGuybrushBefore = new DummyAccount(ACCOUNT_GUYBRUSH_USERNAME); @@ -569,7 +568,7 @@ public void test212HrUserGuybrushSyncAgain() throws Exception { clockForward("PT1H"); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -592,7 +591,7 @@ public void test214HrUserGuybrushRunTriggers() throws Exception { clockForward("PT1H"); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -615,7 +614,7 @@ public void test216HrUserGuybrushRecompute() throws Exception { clockForward("PT1H"); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -638,7 +637,7 @@ public void test218HrUserGuybrushReconcile() throws Exception { clockForward("PT1H"); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -697,7 +696,7 @@ public void test220HrUserGuybrushDay1() throws Exception { public void test222HrUserGuybrushDay1SyncAgain() throws Exception { final String TEST_NAME = "test222HrUserGuybrushDay1SyncAgain"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -720,7 +719,7 @@ public void test224HrUserGuybrushDay1TriggerScanAgain() throws Exception { clockForward("PT1H"); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -741,7 +740,7 @@ public void test224HrUserGuybrushDay1TriggerScanAgain() throws Exception { public void test226HrUserGuybrushDay1Recompute() throws Exception { final String TEST_NAME = "test226HrUserGuybrushDay1Recompute"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -762,7 +761,7 @@ public void test226HrUserGuybrushDay1Recompute() throws Exception { public void test228HrUserGuybrushDay1Reconcile() throws Exception { final String TEST_NAME = "test228HrUserGuybrushDay1Reconcile"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -840,7 +839,7 @@ public void test232GuybrushHrSyncAgain() throws Exception { public void test234GuybrushRecompute() throws Exception { final String TEST_NAME = "test232GuybrushHrSyncAgain"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -861,7 +860,7 @@ public void test234GuybrushRecompute() throws Exception { public void test236GuybrushReconcile() throws Exception { final String TEST_NAME = "test236GuybrushReconcile"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -937,7 +936,7 @@ public void test240HrUserGuybrushDay2() throws Exception { public void test242GuybrushRecompute() throws Exception { final String TEST_NAME = "test242GuybrushRecompute"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -975,7 +974,7 @@ public void test244GuybrushHrSyncAgain() throws Exception { public void test246GuybrushReconcile() throws Exception { final String TEST_NAME = "test246GuybrushReconcile"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelivery.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelivery.java index a5ba6d7a196..0ec78ca81c6 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelivery.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelivery.java @@ -173,7 +173,7 @@ protected PrismObject getDefaultActor() { @Test public void test100Assign_IT_2_failure() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); try { @@ -186,7 +186,7 @@ public void test100Assign_IT_2_failure() throws Exception { @Test public void test110Assign_IT_2_success() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assignRole(userBarkeeperOid, roleIt2Oid, task, result); // hard constraint @@ -198,7 +198,7 @@ public void test110Assign_IT_2_success() throws Exception { @Test public void test120Assign_IT_1() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assignRole(userBobOid, roleIt1Oid, task, result); // approval constraint @@ -224,7 +224,7 @@ public void test120Assign_IT_1() throws Exception { */ @Test public void test130Assign_IT_3() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assignRole(userCarlaOid, roleIt3Oid, task, result); // two approval constraints @@ -259,7 +259,7 @@ public void test130Assign_IT_3() throws Exception { */ @Test public void test140Assign_IT_4() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assignRole(userBarkeeperOid, roleIt4Oid, task, result); // approval constraint @@ -285,7 +285,7 @@ public void test140Assign_IT_4() throws Exception { */ @Test public void test150Assign_IT_5() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); assignRole(userBarkeeperOid, roleIt5Oid, task, result); // approval constraint diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestExistentialIssues.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestExistentialIssues.java index a3443858ae4..3aa01fb2c32 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestExistentialIssues.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestExistentialIssues.java @@ -60,7 +60,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100DisableUserDescartes() throws Exception { final String TEST_NAME = "test100DisableUserDescartes"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -88,7 +88,7 @@ public void test100DisableUserDescartes() throws Exception { @Test public void test110DescartesAssignLazyAccount() throws Exception { final String TEST_NAME = "test110DescartesAssignLazyAccount"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -116,7 +116,7 @@ public void test110DescartesAssignLazyAccount() throws Exception { @Test public void test112EnableDescartes() throws Exception { final String TEST_NAME = "test112EnableDescartes"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -144,7 +144,7 @@ public void test112EnableDescartes() throws Exception { @Test public void test114DisableDescartes() throws Exception { final String TEST_NAME = "test112EnableDescartes"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -172,7 +172,7 @@ public void test114DisableDescartes() throws Exception { @Test public void test116ReenableDescartes() throws Exception { final String TEST_NAME = "test116ReenableDescartes"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -200,7 +200,7 @@ public void test116ReenableDescartes() throws Exception { @Test public void test120DescartesUnassignLazyAccount() throws Exception { final String TEST_NAME = "test120DescartesUnassignLazyAccount"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -228,7 +228,7 @@ public void test120DescartesUnassignLazyAccount() throws Exception { @Test public void test129DeleteDescartes() throws Exception { final String TEST_NAME = "test129DeleteDescartes"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestImportGroups.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestImportGroups.java index 261e7d291ac..6077ec64523 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestImportGroups.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestImportGroups.java @@ -6,17 +6,13 @@ */ package com.evolveum.midpoint.testing.story; -import com.evolveum.icf.dummy.resource.DummySyncStyle; import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; + import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.AfterClass; diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInboundOutboundAssociation.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInboundOutboundAssociation.java index d5c19739e01..831f89c6eec 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInboundOutboundAssociation.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInboundOutboundAssociation.java @@ -133,7 +133,7 @@ public void test100ImportGroupPirates() throws Exception { public void test110AssignJackDirAccount() throws Exception { final String TEST_NAME = "test110AssignJackDirAccount"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -224,7 +224,7 @@ public void test120AddJackToGroupPirates() throws Exception { public void test130JackUnassignRolePirates() throws Exception { final String TEST_NAME = "test120AddJackToGroupPirates"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -253,7 +253,7 @@ public void test130JackUnassignRolePirates() throws Exception { public void test140JackAssignRolePirates() throws Exception { final String TEST_NAME = "test140JackAssignRolePirates"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -290,7 +290,7 @@ public void test140JackAssignRolePirates() throws Exception { public void test142JackUnAssignDirAccount() throws Exception { final String TEST_NAME = "test140JackAssignRolePirates"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -325,7 +325,7 @@ public void test142JackUnAssignDirAccount() throws Exception { public void test149JackUnassignRolePirates() throws Exception { final String TEST_NAME = "test149JackUnassignRolePirates"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -352,7 +352,7 @@ public void test149JackUnassignRolePirates() throws Exception { public void test150AssignJackDirAccount() throws Exception { final String TEST_NAME = "test150AssignJackDirAccount"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -380,7 +380,7 @@ public void test150AssignJackDirAccount() throws Exception { public void test152JackAssignRolePirates() throws Exception { final String TEST_NAME = "test152JackAssignRolePirates"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -415,7 +415,7 @@ public void test152JackAssignRolePirates() throws Exception { public void test153JackUnassignRolePiratesPreview() throws Exception { final String TEST_NAME = "test153JackUnassignRolePiratesPreview"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta focusDelta = createAssignmentFocusDelta( @@ -463,7 +463,7 @@ public void test153JackUnassignRolePiratesPreview() throws Exception { public void test154JackUnassignRolePirates() throws Exception { final String TEST_NAME = "test154JackUnassignRolePirates"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -495,7 +495,7 @@ public void test154JackUnassignRolePirates() throws Exception { public void test159JackUnassignDirAccount() throws Exception { final String TEST_NAME = "test159JackUnassignDirAccount"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -525,7 +525,7 @@ public void test159JackUnassignDirAccount() throws Exception { public void test200MancombAssignAccount() throws Exception { final String TEST_NAME = "test200MancombAssignAccount"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInducement.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInducement.java index 04306a69a77..bc7a26d397a 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInducement.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInducement.java @@ -87,7 +87,7 @@ public void test010InducementConditionsTrue() throws Exception { final String TEST_NAME = "test010InducementConditionsTrue"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -117,7 +117,7 @@ public void test020InducementRole2ConditionFalse() throws Exception { final String TEST_NAME = "test020InducementRole2ConditionFalse"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -148,7 +148,7 @@ public void test030InducementRole3ConditionFalse() throws Exception { final String TEST_NAME = "test030InducementRole3ConditionFalse"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -178,7 +178,7 @@ public void test040Recomputed() throws Exception { final String TEST_NAME = "test040Recomputed"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -207,7 +207,7 @@ public void test050InducementRole3ConditionTrue() throws Exception { final String TEST_NAME = "test050InducementRole3ConditionTrue"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -236,7 +236,7 @@ public void test060Recomputed() throws Exception { final String TEST_NAME = "test060Recomputed"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -262,7 +262,7 @@ public void test070DeleteUser() throws Exception { final String TEST_NAME = "test070DeleteUser"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLargeGroups.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLargeGroups.java index d89316239a8..d3f41c4f2ce 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLargeGroups.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLargeGroups.java @@ -84,7 +84,7 @@ protected TracingProfileType getTestMethodTracingProfile() { @Test public void test000Sanity() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult testResult = modelService.testResource(RESOURCE_DUMMY_OID, task); TestUtil.assertSuccess(testResult); @@ -95,7 +95,7 @@ public void test000Sanity() throws Exception { */ @Test public void test100GetLargeGroup(ITestContext ctx) throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); final int MEMBERS = 20000; @@ -122,7 +122,7 @@ private void assert100LargeGroupSearch( ITestContext ctx, Collection> options, final int MEMBERS) throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); ResourceAttributeDefinition nameDefinition = libraryMidpointFunctions .getAttributeDefinition(resourceDummy, dummyResourceCtl.getGroupObjectClass(), SchemaConstants.ICFS_NAME); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLimitedResources.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLimitedResources.java index 892586130d0..392bc586825 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLimitedResources.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLimitedResources.java @@ -69,7 +69,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -92,7 +92,7 @@ public void test000Sanity() throws Exception { public void test100AssignJackAccountNoAttributeAddDelete() throws Exception { final String TEST_NAME = "test100AssignJackAccountNoAttributeAddDelete"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -114,7 +114,7 @@ public void test100AssignJackAccountNoAttributeAddDelete() throws Exception { public void test102AddJackOrganizationalUnitTreasureHunt() throws Exception { final String TEST_NAME = "test102AddJackOrganizationalUnitTreasureHunt"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -137,7 +137,7 @@ public void test102AddJackOrganizationalUnitTreasureHunt() throws Exception { public void test104AddJackOrganizationalUnitLootingSailing() throws Exception { final String TEST_NAME = "test104AddJackOrganizationalUnitLootingSailing"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -160,7 +160,7 @@ public void test104AddJackOrganizationalUnitLootingSailing() throws Exception { public void test106DeleteJackOrganizationalUnitLooting() throws Exception { final String TEST_NAME = "test106DeleteJackOrganizationalUnitLooting"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -186,7 +186,7 @@ public void test106DeleteJackOrganizationalUnitLooting() throws Exception { public void test108DeleteJackOrganizationalUnitTreasureHuntSailing() throws Exception { final String TEST_NAME = "test108DeleteJackOrganizationalUnitTreasureHuntSailing"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -209,7 +209,7 @@ public void test108DeleteJackOrganizationalUnitTreasureHuntSailing() throws Exce public void test109UnassignJackAccountNoAttributeAddDelete() throws Exception { final String TEST_NAME = "test109UnassignJackAccountNoAttributeAddDelete"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -235,7 +235,7 @@ public void test109UnassignJackAccountNoAttributeAddDelete() throws Exception { public void test110AssignJackAccountNoCreate() throws Exception { final String TEST_NAME = "test110AssignJackAccountNoCreate"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -258,7 +258,7 @@ public void test110AssignJackAccountNoCreate() throws Exception { public void test119UnassignJackAccountNoCreate() throws Exception { final String TEST_NAME = "test119UnassignJackAccountNoCreate"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLiveSyncMadness.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLiveSyncMadness.java index 0bca6e4c2be..ea41c74b141 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLiveSyncMadness.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLiveSyncMadness.java @@ -97,7 +97,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult testResultHr = modelService.testResource(RESOURCE_DUMMY_HR_OID, task); TestUtil.assertSuccess(testResultHr); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMachineIntelligence.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMachineIntelligence.java index 8a28ebabba3..f0b2c578ffc 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMachineIntelligence.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMachineIntelligence.java @@ -105,7 +105,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Object[] newRealValue = { sourceFilePath }; diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestManyThreads.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestManyThreads.java index bffda86e1fa..25be6e96eec 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestManyThreads.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestManyThreads.java @@ -65,14 +65,14 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { - Task task = getTask(); + Task task = getTestTask(); assertSuccess(modelService.testResource(RESOURCE_DUMMY.oid, task)); } @Test public void test100SearchResourceObjects() throws Exception { - Task globalTask = getTask(); + Task globalTask = getTestTask(); OperationResult globalResult = getResult(); dummyResource.addAccount(new DummyAccount("jack")); @@ -91,7 +91,7 @@ public void test100SearchResourceObjects() throws Exception { ThreadTestExecutor executor = new ThreadTestExecutor(20, 60000L); executor.execute(() -> { login(userAdministrator.clone()); - Task localTask = createTask("execute"); + Task localTask = getTestTask(); OperationResult localResult = localTask.getResult(); ObjectQuery query = prismContext.queryFor(ShadowType.class) diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMappingMadness.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMappingMadness.java index be62d1590ff..0ba103f53a1 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMappingMadness.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMappingMadness.java @@ -84,7 +84,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti public void test100AssignJackDummyAccounts() throws Exception { final String TEST_NAME = "test100AssignJackDummyAccounts"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -113,7 +113,7 @@ public void test100AssignJackDummyAccounts() throws Exception { public void test105ModifyJackTitleCaptain() throws Exception { final String TEST_NAME = "test105ModifyJackTitleCaptain"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); setAccountQuotes(); @@ -185,7 +185,7 @@ public void test105ModifyJackTitleCaptain() throws Exception { public void test110ModifyJackTitleWhatever() throws Exception { final String TEST_NAME = "test110ModifyJackTitleWhatever"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -258,7 +258,7 @@ private void assertNoAttributes(DummyAccountAsserter asserter) { public void test112ReconcileJackWhatever() throws Exception { final String TEST_NAME = "test112ReconcileJackWhatever"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -313,7 +313,7 @@ public void test112ReconcileJackWhatever() throws Exception { public void test120MadJack() throws Exception { final String TEST_NAME = "test120MadJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Make sure that quotes are re-set. Especially in the nontolerant resource. @@ -351,7 +351,7 @@ public void test120MadJack() throws Exception { public void test130ModifyJackTitleWhateverLower() throws Exception { final String TEST_NAME = "test130ModifyJackTitleWhateverLower"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -381,7 +381,7 @@ public void test130ModifyJackTitleWhateverLower() throws Exception { public void test140ModifyJackTitleEmpty() throws Exception { final String TEST_NAME = "test140ModifyJackTitleEmpty"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -416,7 +416,7 @@ public void test140ModifyJackTitleEmpty() throws Exception { public void test199UnassignJackDummyAccount() throws Exception { final String TEST_NAME = "test199UnassignJackDummyAccount"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMisbehavingResources.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMisbehavingResources.java index c537dfe4a6e..e82ee85527b 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMisbehavingResources.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMisbehavingResources.java @@ -23,7 +23,6 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; @@ -55,7 +54,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti public void test010SanityAssignJackDummyAccount() throws Exception { final String TEST_NAME = "test010SanityAssignJackDummyAccount"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -75,7 +74,7 @@ public void test010SanityAssignJackDummyAccount() throws Exception { public void test019SanityUnassignJackDummyAccount() throws Exception { final String TEST_NAME = "test010SanityAssignJackDummyAccount"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -99,7 +98,7 @@ public void test100AssignJackDummyAccountTimeout() throws Exception { getDummyResource().setOperationDelayOffset(3000); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -121,7 +120,7 @@ public void test102AssignJackDummyAccounRetry() throws Exception { getDummyResource().setOperationDelayOffset(0); clockForward("P1D"); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -146,7 +145,7 @@ public void test110ModifyJackDummyAccountTimeout() throws Exception { getDummyResource().setOperationDelayOffset(3000); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -170,7 +169,7 @@ public void test112ModifyJackDummyAccounRetry() throws Exception { getDummyResource().setOperationDelayOffset(0); clockForward("P1D"); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNormalizers.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNormalizers.java index 6424a34503c..95bab2bfbc2 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNormalizers.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNormalizers.java @@ -87,7 +87,7 @@ public void test000Sanity() throws Exception { @Test public void test100AddUserJack() throws Exception { final String TEST_NAME = "test100AddUserJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -107,7 +107,7 @@ public void test100AddUserJack() throws Exception { @Test public void test110AddUserTeleke() throws Exception { final String TEST_NAME = "test110AddUserTeleke"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNullAttribute.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNullAttribute.java index 9c22a4b9d0d..821fd823d36 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNullAttribute.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNullAttribute.java @@ -27,7 +27,6 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; @@ -148,7 +147,7 @@ public void test010UserSmackAssignAccountOnlyRole() throws Exception { final String TEST_NAME = "test010UserSmackAssignAccountOnlyRole"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -191,7 +190,7 @@ public void test020UserSmackSetAttribute() throws Exception { final String TEST_NAME = "test020UserSmackSetAttribute"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -244,7 +243,7 @@ public void test030UserSmackRemoveAttribute() throws Exception { final String TEST_NAME = "test030UserSmackRemoveAttribute"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationPerf.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationPerf.java index c9e04ab400d..a21a60538f9 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationPerf.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationPerf.java @@ -110,7 +110,7 @@ public void test110AddBob() throws Exception { public void testAddUser(final String TEST_NAME, File userFile, String userOid, int roles) throws Exception { - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = parseObject(userFile); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOrgSync.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOrgSync.java index 99444a9c62a..5d9b7e8d50c 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOrgSync.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOrgSync.java @@ -13,7 +13,6 @@ import static org.testng.AssertJUnit.assertTrue; import java.io.File; -import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -21,7 +20,6 @@ import org.opends.server.types.DirectoryException; import org.opends.server.types.Entry; -import org.opends.server.types.SearchResultEntry; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; @@ -41,8 +39,6 @@ import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; -import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; @@ -291,7 +287,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult testResultHr = modelService.testResource(RESOURCE_DUMMY_HR_OID, task); TestUtil.assertSuccess(testResultHr); @@ -1004,7 +1000,7 @@ public void test500ReconcileOpenDJDefault() throws Exception { final String TEST_NAME = "test500ReconcileOpenDJDefault"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -1048,7 +1044,7 @@ public void test502ReconcileOpenDJDefaultAgain() throws Exception { final String TEST_NAME = "test502ReconcileOpenDJDefaultAgain"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -1084,7 +1080,7 @@ public void test510ReconcileOpenDJLdapGroup() throws Exception { final String TEST_NAME = "test510ReconcileOpenDJLdapGroup"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -1130,7 +1126,7 @@ public void test550ReconcileOpenDJAfterMembershipChange() throws Exception { // And check whether reconciliation re-adds him again // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestPhotoAssignment.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestPhotoAssignment.java index 12b46427d0e..4d5373c6f15 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestPhotoAssignment.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestPhotoAssignment.java @@ -62,7 +62,8 @@ public void test100AssignJoeCard() throws Exception { final String TEST_NAME = "test100AssignJoeCard"; TestUtil.displayTestTitle(TEST_NAME); - Task task = createTask(TestPhotoAssignment.class.getName() + "." + TEST_NAME); + TestPhotoAssignment.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); assignService(USER_JOE.oid, SERVICE_CARD_10001.oid, task, result); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestPlentyOfAssignments.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestPlentyOfAssignments.java index a68fee231b8..4299ac1329f 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestPlentyOfAssignments.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestPlentyOfAssignments.java @@ -34,7 +34,6 @@ import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.internals.InternalCounters; import com.evolveum.midpoint.schema.internals.InternalMonitor; -import com.evolveum.midpoint.schema.internals.InternalOperationClasses; import com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition; import com.evolveum.midpoint.schema.processor.ResourceAttribute; import com.evolveum.midpoint.schema.processor.ResourceAttributeContainer; @@ -43,7 +42,6 @@ import com.evolveum.midpoint.schema.util.ObjectTypeUtil; import com.evolveum.midpoint.schema.util.ShadowUtil; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.util.MidPointTestConstants; @@ -175,7 +173,7 @@ public void test000Sanity() throws Exception { public void test100AddCheese() throws Exception { final String TEST_NAME = "test100AddCheese"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject cheeseBefore = prepareCheese(); @@ -218,7 +216,7 @@ public void test100AddCheese() throws Exception { public void test110RecomputeCheese() throws Exception { final String TEST_NAME = "test110RecomputeCheese"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject cheeseBefore = prepareCheese(); @@ -259,7 +257,7 @@ public void test110RecomputeCheese() throws Exception { public void test120CheesePreviewChanges() throws Exception { final String TEST_NAME = "test120CheesePreviewChanges"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject cheeseBefore = prepareCheese(); @@ -327,7 +325,7 @@ private void assertCheeseRoleMembershipRef(PrismObject cheese) { public void test200DummyGroups() throws Exception { final String TEST_NAME = "test200DummyGroups"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -401,7 +399,7 @@ public void test200DummyGroups() throws Exception { public void test210AddBob() throws Exception { final String TEST_NAME = "test210AddBob"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = PrismTestUtil.parseObject(USER_BOB_FILE); @@ -449,7 +447,7 @@ public void test210AddBob() throws Exception { public void test212RecomputeBob() throws Exception { final String TEST_NAME = "test212RecomputeBob"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); inspector.reset(); @@ -493,7 +491,7 @@ public void test212RecomputeBob() throws Exception { public void test2124ReconcileBob() throws Exception { final String TEST_NAME = "test212RecomputeBob"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); inspector.reset(); @@ -555,7 +553,7 @@ private void assertBobDummy(int expectedBottlesOfRum) throws Exception { public void test220AddAlice() throws Exception { final String TEST_NAME = "test220AddAlice"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = PrismTestUtil.parseObject(USER_ALICE_FILE); @@ -605,7 +603,7 @@ public void test220AddAlice() throws Exception { public void test222RecomputeAlice() throws Exception { final String TEST_NAME = "test222RecomputeAlice"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); inspector.reset(); @@ -649,7 +647,7 @@ public void test222RecomputeAlice() throws Exception { public void test224ReconcileAlice() throws Exception { final String TEST_NAME = "test224ReconcileAlice"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); inspector.reset(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestReconNullValue.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestReconNullValue.java index 835bc71809e..04de11fe7f2 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestReconNullValue.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestReconNullValue.java @@ -33,7 +33,6 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.CommunicationException; @@ -185,7 +184,7 @@ public void test130AddHonorificPrefix() throws Exception { final String TEST_NAME = "test140AddHonorificPrefix"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -241,7 +240,7 @@ public void test140dDeleteHonorificPrefixGivenName() throws Exception { final String TEST_NAME = "test140dDeleteHonorificPrefixGivenName"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -300,7 +299,7 @@ public void test150RemoveTitleRA() throws Exception { final String TEST_NAME = "test150RemoveTitleRA"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -359,7 +358,7 @@ public void test160SetGivenNameAttributeAndReconcile() throws Exception { final String TEST_NAME = "test160SetGivenNameAttributeAndReconcile"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -414,7 +413,7 @@ public void test170ReplaceGivenNameEmpty() throws Exception { final String TEST_NAME = "test170ReplaceGivenNameEmpty"; // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestRetirement.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestRetirement.java index 86472ee6681..86a0c4e8b6d 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestRetirement.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestRetirement.java @@ -568,7 +568,7 @@ private void assertNoGroupMembers(PrismObject org) throws Exception { } private void reconcileAllUsers() throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - final Task task = createTask("reconcileAllUsers"); + final Task task = getTestTask(); OperationResult result = task.getResult(); ResultHandler handler = new ResultHandler() { @Override @@ -589,7 +589,7 @@ public boolean handle(PrismObject object, OperationResult parentResult } private void reconcileAllOrgs() throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - final Task task = createTask("reconcileAllOrgs"); + final Task task = getTestTask(); OperationResult result = task.getResult(); ResultHandler handler = new ResultHandler() { @Override diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestScience.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestScience.java index 72251dc6857..07498de65d2 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestScience.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestScience.java @@ -31,7 +31,6 @@ import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.MiscUtil; @@ -154,7 +153,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult testResultStats = modelService.testResource(RESOURCE_DUMMY_STATS_OID, task); TestUtil.assertSuccess(testResultStats); @@ -172,7 +171,7 @@ public void test000Sanity() throws Exception { @Test public void test100JackAssignRoleStatistics() throws Exception { final String TEST_NAME = "test100JackAssignRoleStatistics"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -220,7 +219,7 @@ public void test100JackAssignRoleStatistics() throws Exception { @Test public void test101UnassignRoleStats() throws Exception{ final String TEST_NAME = "test101UnassignRoleStats"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); @@ -271,7 +270,7 @@ public void test101UnassignRoleStats() throws Exception{ @Test public void test102AssignRoleStats() throws Exception{ final String TEST_NAME = "test102AssignRoleStats"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); @@ -318,7 +317,7 @@ public void test102AssignRoleStats() throws Exception{ @Test public void test200DelteUserJack() throws Exception { final String TEST_NAME = "test200DelteUserJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccounts.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccounts.java index 2662abd9bb9..dd6eea3a55f 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccounts.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccounts.java @@ -149,7 +149,7 @@ public void test101AddServiceAccountSync() throws Exception { public void test102ModifyServiceAccount() throws Exception { final String TEST_NAME = "test102ModifyServiceAccount"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object().createModificationReplaceProperty(ShadowType.class, @@ -197,7 +197,7 @@ serviceAccountShadowOid, getDummyResourceController().getAttributeFullnamePath() public void test104DeleteServiceAccount() throws Exception { final String TEST_NAME = "test104DeleteServiceAccount"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object().createDeleteDelta(ShadowType.class, @@ -376,7 +376,7 @@ public void test129StopReconTask() throws Exception { public void test140CreateServiceAccount() throws Exception { final String TEST_NAME = "test140CreateServiceAccount"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); addObject(SERVICE_BARELLIUM_FILE); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccountsClassifier.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccountsClassifier.java index 0c02a83d75d..4bda950f28d 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccountsClassifier.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccountsClassifier.java @@ -26,7 +26,6 @@ import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.asserter.ShadowAsserter; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.xml.ns._public.common.common_3.ServiceType; @@ -111,7 +110,7 @@ public void test100createServiceJira() throws Exception { @Test public void test101jiraAssignResourceNoneEnforcement() throws Exception { final String TEST_NAME = "test101jiraAssignResourceNoneEnforcement"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); //GIVEN @@ -244,7 +243,7 @@ public void test210createAccountGithub() throws Exception { @Test public void test215githubAssignResourceNoneEnforcement() throws Exception { final String TEST_NAME = "test101jiraAssignResourceNoneEnforcement"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); //GIVEN @@ -266,7 +265,7 @@ public void test215githubAssignResourceNoneEnforcement() throws Exception { @Test public void test220linkAccountGithubAndFixIntent() throws Exception { final String TEST_NAME = "test220linkAccountGithubAndFixIntent"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // GIVEN diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestShadowsPerformance.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestShadowsPerformance.java index e5328d535a2..400df5342ca 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestShadowsPerformance.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestShadowsPerformance.java @@ -24,7 +24,6 @@ import com.evolveum.midpoint.schema.internals.InternalsConfig; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyAuditService; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.util.MidPointTestConstants; @@ -100,7 +99,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti public void test010Sanity() throws Exception { final String TEST_NAME = "test010Sanity"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); // WHEN displayWhen(TEST_NAME); @@ -116,7 +115,7 @@ public void test010Sanity() throws Exception { public void test100ImportAccounts() throws Exception { final String TEST_NAME = "test100ImportAccounts"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); for (int i = 0; i < NUMBER_OF_GENERATED_USERS; i++) { @@ -147,7 +146,7 @@ public void test100ImportAccounts() throws Exception { public void test200DeleteAccountsAndReconcile() throws Exception { final String TEST_NAME = "test200DeleteAccountsAndReconcile"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); for (DummyAccount account : new ArrayList<>(dummyResourceCtl.getDummyResource().listAccounts())) { @@ -177,7 +176,7 @@ public void test200DeleteAccountsAndReconcile() throws Exception { public void test210DeleteShadows() throws Exception { final String TEST_NAME = "test210DeleteShadows"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); for (DummyAccount account : new ArrayList<>(dummyResourceCtl.getDummyResource().listAccounts())) { @@ -207,7 +206,7 @@ public void test210DeleteShadows() throws Exception { public void test900Summarize() { final String TEST_NAME = "test900Summarize"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); StringBuilder sb = new StringBuilder(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestStrings.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestStrings.java index b14c46bc4d6..fbbe63257ff 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestStrings.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestStrings.java @@ -197,7 +197,7 @@ protected PrismObject getDefaultActor() { @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); // TODO } @@ -206,7 +206,7 @@ public void test000Sanity() throws Exception { @Test public void test100SimpleAssignmentStart() throws Exception { final String TEST_NAME = "test100SimpleAssignmentStart"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -271,7 +271,7 @@ public void test100SimpleAssignmentStart() throws Exception { @Test public void test102SimpleAssignmentApproveByLechuck() throws Exception { final String TEST_NAME = "test102SimpleAssignmentApproveByLechuck"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -359,7 +359,7 @@ public void test102SimpleAssignmentApproveByLechuck() throws Exception { @Test public void test104SimpleAssignmentApproveByAdministrator() throws Exception { final String TEST_NAME = "test104SimpleAssignmentApproveByAdministrator"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -439,7 +439,7 @@ public void test104SimpleAssignmentApproveByAdministrator() throws Exception { @Test public void test106SimpleAssignmentApproveByCheese() throws Exception { final String TEST_NAME = "test106SimpleAssignmentApproveByCheese"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -497,7 +497,7 @@ public void test106SimpleAssignmentApproveByCheese() throws Exception { @Test public void test108SimpleAssignmentApproveByChef() throws Exception { final String TEST_NAME = "test108SimpleAssignmentApproveByChef"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // GIVEN @@ -574,7 +574,7 @@ public void test108SimpleAssignmentApproveByChef() throws Exception { @Test public void test200EscalatedApprovalStart() throws Exception { final String TEST_NAME = "test200EscalatedApprovalStart"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -621,7 +621,7 @@ public void test200EscalatedApprovalStart() throws Exception { @Test public void test202FourDaysLater() throws Exception { final String TEST_NAME = "test202FourDaysLater"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -653,7 +653,7 @@ public void test202FourDaysLater() throws Exception { @Test public void test204SixDaysLater() throws Exception { final String TEST_NAME = "test204SixDaysLater"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -720,7 +720,7 @@ public void test204SixDaysLater() throws Exception { @Test public void test205EightDaysLater() throws Exception { final String TEST_NAME = "test205EightDaysLater"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -771,7 +771,7 @@ public void test205EightDaysLater() throws Exception { @Test public void test206ApproveByCheese() throws Exception { final String TEST_NAME = "test206ApproveByCheese"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -864,7 +864,7 @@ public void test206ApproveByCheese() throws Exception { @Test public void test208SixDaysLater() throws Exception { final String TEST_NAME = "test208SixDaysLater"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -905,7 +905,7 @@ public void test208SixDaysLater() throws Exception { @Test public void test209EightDaysLater() throws Exception { final String TEST_NAME = "test209EightDaysLater"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -964,7 +964,7 @@ public void test220FormRoleAssignmentStart() throws Exception { PrismObject bob = getUserFromRepo(userBobOid); login(bob); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(bob); OperationResult result = task.getResult(); @@ -1005,7 +1005,7 @@ public void test220FormRoleAssignmentStart() throws Exception { @Test public void test221FormApproveByLechuck() throws Exception { final String TEST_NAME = "test221FormApproveByLechuck"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -1050,7 +1050,7 @@ public void test221FormApproveByLechuck() throws Exception { @Test public void test222FormApproveByCheese() throws Exception { final String TEST_NAME = "test222FormApproveByCheese"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -1120,7 +1120,7 @@ public void test222FormApproveByCheese() throws Exception { @Test public void test250ApproverAssignment() throws Exception { final String TEST_NAME = "test250ApproverAssignment"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnix.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnix.java index 9a73370262f..a11ff1859e6 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnix.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnix.java @@ -29,7 +29,6 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.Test; -import com.evolveum.midpoint.common.Utils; import com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition; import com.evolveum.midpoint.common.refinery.RefinedResourceSchema; import com.evolveum.midpoint.model.impl.sync.ReconciliationTaskHandler; @@ -55,7 +54,6 @@ import com.evolveum.midpoint.schema.util.ObjectQueryUtil; import com.evolveum.midpoint.schema.util.ShadowUtil; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; @@ -296,7 +294,7 @@ protected String getResourceOid() { @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult testResultOpenDj = modelService.testResource(getResourceOid(), task); TestUtil.assertSuccess(testResultOpenDj); @@ -341,7 +339,7 @@ public void test010Schema() throws Exception { @Test public void test100AddUserHermanBasic() throws Exception { final String TEST_NAME = "test100AddUserHermanBasic"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = createUser(USER_HERMAN_USERNAME, USER_HERMAN_FIST_NAME, USER_HERMAN_LAST_NAME, ROLE_BASIC_OID); @@ -368,7 +366,7 @@ public void test100AddUserHermanBasic() throws Exception { @Test public void test110AddUserMancombUnix() throws Exception { final String TEST_NAME = "test110AddUserMancombUnix"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = createUser(USER_MANCOMB_USERNAME, USER_MANCOMB_FIST_NAME, USER_MANCOMB_LAST_NAME, ROLE_UNIX_OID); @@ -395,7 +393,7 @@ public void test110AddUserMancombUnix() throws Exception { @Test public void test111AccountMancombEditObjectClassDefinition() throws Exception { final String TEST_NAME = "test111AccountMancombEditObjectClassDefinition"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject shadow = getShadowModel(accountMancombOid); @@ -424,7 +422,7 @@ public void test111AccountMancombEditObjectClassDefinition() throws Exception { @Test public void test119DeleteUserMancombUnix() throws Exception { final String TEST_NAME = "test119DeleteUserMancombUnix"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_MANCOMB_USERNAME); @@ -449,7 +447,7 @@ public void test119DeleteUserMancombUnix() throws Exception { @Test public void test120AddUserLargo() throws Exception { final String TEST_NAME = "test120AddUserLargo"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = createUser(USER_LARGO_USERNAME, USER_LARGO_FIST_NAME, USER_LARGO_LAST_NAME, (String)null); @@ -472,7 +470,7 @@ public void test120AddUserLargo() throws Exception { @Test public void test122AssignUserLargoBasic() throws Exception { final String TEST_NAME = "test122AssignUserLargoBasic"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); @@ -500,7 +498,7 @@ public void test122AssignUserLargoBasic() throws Exception { @Test public void test124AssignUserLargoUnix() throws Exception { final String TEST_NAME = "test124AssignUserLargoUnix"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); @@ -534,7 +532,7 @@ public void test124AssignUserLargoUnix() throws Exception { @Test public void test125RecomputeUserLargo() throws Exception { final String TEST_NAME = "test125RecomputeUserLargo"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); @@ -562,7 +560,7 @@ public void test125RecomputeUserLargo() throws Exception { @Test public void test126UnAssignUserLargoUnix() throws Exception { final String TEST_NAME = "test126UnAssignUserLargoUnix"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); @@ -590,7 +588,7 @@ public void test126UnAssignUserLargoUnix() throws Exception { @Test public void test127RecomputeUserLargo() throws Exception { final String TEST_NAME = "test127RecomputeUserLargo"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); @@ -618,7 +616,7 @@ public void test127RecomputeUserLargo() throws Exception { @Test public void test128UnAssignUserLargoBasic() throws Exception { final String TEST_NAME = "test128UnAssignUserLargoBasic"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); @@ -645,7 +643,7 @@ public void test128UnAssignUserLargoBasic() throws Exception { @Test public void test129RecomputeUserLargo() throws Exception { final String TEST_NAME = "test129RecomputeUserLargo"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); @@ -672,7 +670,7 @@ public void test129RecomputeUserLargo() throws Exception { @Test public void test130AssignUserLargoUnix() throws Exception { final String TEST_NAME = "test130AssignUserLargoUnix"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); @@ -700,7 +698,7 @@ public void test130AssignUserLargoUnix() throws Exception { @Test public void test131ReconcileUserLargo() throws Exception { final String TEST_NAME = "test131ReconcileUserLargo"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); @@ -739,7 +737,7 @@ public void test131ReconcileUserLargo() throws Exception { @Test public void test132MeddleWithAccountAndReconcileUserLargo() throws Exception { final String TEST_NAME = "test132MeddleWithAccountAndReconcileUserLargo"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); @@ -806,7 +804,7 @@ protected void assertTest132Audit() { @Test public void test133ReconcileUserLargoAgain() throws Exception { final String TEST_NAME = "test133ReconcileUserLargoAgain"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); @@ -844,7 +842,7 @@ public void test133ReconcileUserLargoAgain() throws Exception { @Test public void test134AssignUserLargoBasic() throws Exception { final String TEST_NAME = "test134AssignUserLargoBasic"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); @@ -880,7 +878,7 @@ public void test134AssignUserLargoBasic() throws Exception { @Test public void test135UnAssignUserLargoUnix() throws Exception { final String TEST_NAME = "test135UnAssignUserLargoUnix"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); @@ -925,7 +923,7 @@ protected void assertTest135Audit() { @Test // MID-2883 public void test136MeddleWithAccountAndReconcileUserLargo() throws Exception { final String TEST_NAME = "test136MeddleWithAccountAndReconcileUserLargo"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); @@ -984,7 +982,7 @@ protected void assertAccountTest136(PrismObject shadow) throws Excep @Test public void test137ReconcileUserLargoAgain() throws Exception { final String TEST_NAME = "test137ReconcileUserLargoAgain"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); @@ -1030,7 +1028,7 @@ protected void assertTest137Account(PrismObject shadow) throws Excep @Test public void test138UnAssignUserLargoBasic() throws Exception { final String TEST_NAME = "test138UnAssignUserLargoUnix"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); @@ -1059,7 +1057,7 @@ public void test138UnAssignUserLargoBasic() throws Exception { @Test public void test200AddLdapGroupMonkeyIsland() throws Exception { final String TEST_NAME = "test200AddLdapGroupMonkeyIsland"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject role = createLdapGroupRole(ROLE_MONKEY_ISLAND_NAME); @@ -1087,7 +1085,7 @@ public void test200AddLdapGroupMonkeyIsland() throws Exception { @Test public void test202AssignUserHermanMonkeyIsland() throws Exception { final String TEST_NAME = "test202AssignUserHermanMonkeyIsland"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = findUserByUsername(USER_HERMAN_USERNAME); @@ -1115,7 +1113,7 @@ public void test202AssignUserHermanMonkeyIsland() throws Exception { @Test public void test210AddUnixGroupVillains() throws Exception { final String TEST_NAME = "test210AddUnixGroupVillains"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject role = createUnixGroupRole(ROLE_VILLAINS_NAME, ROLE_META_UNIXGROUP_OID); @@ -1143,7 +1141,7 @@ public void test210AddUnixGroupVillains() throws Exception { @Test public void test211AssignUserLargoUnix() throws Exception { final String TEST_NAME = "test211AssignUserLargoUnix"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); @@ -1171,7 +1169,7 @@ public void test211AssignUserLargoUnix() throws Exception { @Test public void test212AssignUserLargoVillains() throws Exception { final String TEST_NAME = "test212AssignUserLargoVillains"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = findUserByUsername(USER_LARGO_USERNAME); @@ -1201,7 +1199,7 @@ public void test212AssignUserLargoVillains() throws Exception { @Test public void test250AddUserRangerBasic() throws Exception { final String TEST_NAME = "test250AddUserRangerBasic"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = createUser(USER_RANGER_USERNAME, USER_RANGER_FIST_NAME, USER_RANGER_LAST_NAME, ROLE_BASIC_OID); @@ -1228,7 +1226,7 @@ public void test250AddUserRangerBasic() throws Exception { @Test public void test251AssignUserRangerBasic() throws Exception { final String TEST_NAME = "test251AssignUserRangerBasic"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_RANGER_USERNAME); @@ -1256,7 +1254,7 @@ public void test251AssignUserRangerBasic() throws Exception { @Test public void test252AddUnixGroupRangers() throws Exception { final String TEST_NAME = "test252AddUnixGroupRangers"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject role = createUnixGroupRole(ROLE_RANGERS_NAME, ROLE_META_UNIXGROUP2_OID); @@ -1284,7 +1282,7 @@ public void test252AddUnixGroupRangers() throws Exception { @Test public void test253AddUnixGroupSeals() throws Exception { final String TEST_NAME = "test253AddUnixGroupSeals"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject role = createUnixGroupRole(ROLE_SEALS_NAME, ROLE_META_UNIXGROUP2_OID); @@ -1314,7 +1312,7 @@ public void test253AddUnixGroupSeals() throws Exception { @Test public void test254AssignUserRangerRangers() throws Exception { final String TEST_NAME = "test254AssignUserRangerRangers"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = findUserByUsername(USER_RANGER_USERNAME); @@ -1355,7 +1353,7 @@ public void test254AssignUserRangerRangers() throws Exception { @Test public void test255AssignUserRangerSeals() throws Exception { final String TEST_NAME = "test255AssignUserRangerSeals"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = findUserByUsername(USER_RANGER_USERNAME); @@ -1388,7 +1386,7 @@ public void test255AssignUserRangerSeals() throws Exception { @Test public void test256UnAssignUserRangerSealsKeepRangers() throws Exception { final String TEST_NAME = "test256UnAssignUserRangerSealsKeepRangers"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_RANGER_USERNAME); @@ -1426,7 +1424,7 @@ public void test256UnAssignUserRangerSealsKeepRangers() throws Exception { @Test public void test257RenameUserAndAccountsCheckGroupmembership() throws Exception { final String TEST_NAME = "test257RenameUserAndAccountsCheckGroupmembership"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_RANGER_USERNAME); @@ -1465,7 +1463,7 @@ public void test257RenameUserAndAccountsCheckGroupmembership() throws Exception @Test public void test260DeleteUserUsrangerUnix() throws Exception { final String TEST_NAME = "test260DeleteUserUsrangerUnix"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_RANGER_USERNAME_RENAMED); @@ -1493,7 +1491,7 @@ public void test260DeleteUserUsrangerUnix() throws Exception { @Test public void test270RenameUnixGroupSeals() throws Exception { final String TEST_NAME = "test270RenameUnixGroupSeals"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1521,7 +1519,7 @@ public void test270RenameUnixGroupSeals() throws Exception { @Test public void test300AddUserCapsizeUnixFail() throws Exception { final String TEST_NAME = "test300AddUserCapsizeUnixFail"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject sequenceBefore = getObject(SequenceType.class, SEQUENCE_UIDNUMBER_OID); @@ -1565,7 +1563,7 @@ public void test300AddUserCapsizeUnixFail() throws Exception { @Test public void test310AddUserWallyUnix() throws Exception { final String TEST_NAME = "test310AddUserWallyUnix"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject sequenceBefore = getObject(SequenceType.class, SEQUENCE_UIDNUMBER_OID); @@ -1605,7 +1603,7 @@ public void test310AddUserWallyUnix() throws Exception { @Test public void test312AccountWallyRemovePosixObjectclassNative() throws Exception { final String TEST_NAME = "test312AccountWallyRemovePosixObjectclassNative"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); openDJController.executeLdifChange("dn: "+accountWallyDn+"\n"+ @@ -1655,7 +1653,7 @@ public void test312AccountWallyRemovePosixObjectclassNative() throws Exception { @Test public void test314AccountWallyAddPosixObjectclassNative() throws Exception { final String TEST_NAME = "test314AccountWallyAddPosixObjectclassNative"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); openDJController.executeLdifChange("dn: "+accountWallyDn+"\n"+ @@ -1701,7 +1699,7 @@ public void test314AccountWallyAddPosixObjectclassNative() throws Exception { @Test public void test400ListAllAccountsObjectClass() throws Exception { final String TEST_NAME = "test400ListAllAccountsObjectClass"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), @@ -1723,7 +1721,7 @@ public void test400ListAllAccountsObjectClass() throws Exception { @Test public void test401ListAllAccountsKindIntent() throws Exception { final String TEST_NAME = "test401ListAllAccountsKindIntent"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(getResourceOid(), @@ -1746,7 +1744,7 @@ public void test401ListAllAccountsKindIntent() throws Exception { @Test public void test402ListLdapGroupsKindIntent() throws Exception { final String TEST_NAME = "test402ListLdapGroupsKindIntent"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(getResourceOid(), @@ -1769,7 +1767,7 @@ public void test402ListLdapGroupsKindIntent() throws Exception { @Test public void test403ListUnixGroupsKindIntent() throws Exception { final String TEST_NAME = "test403ListUnixGroupsKindIntent"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(getResourceOid(), @@ -1791,7 +1789,7 @@ public void test403ListUnixGroupsKindIntent() throws Exception { @Test public void test500AddUserStan() throws Exception { final String TEST_NAME = "test500AddUserStan"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = createUser(USER_STAN_USERNAME, USER_STAN_FIST_NAME, USER_STAN_LAST_NAME, roleRangersOid); @@ -1824,7 +1822,7 @@ public void test500AddUserStan() throws Exception { @Test public void test510StanDisablePosixAssocAndReconcile() throws Exception { final String TEST_NAME = "test510StanDisablePosixAssocAndReconcile"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userStan = findUserByUsername(USER_STAN_USERNAME); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnixTolerantAux.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnixTolerantAux.java index f1717f6dc5a..a63b39df6b3 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnixTolerantAux.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnixTolerantAux.java @@ -112,7 +112,7 @@ protected void assertTest137Account(PrismObject shadow) throws Excep @Test public void test140AssignUserLargoBasic() throws Exception { final String TEST_NAME = "test140AssignUserLargoBasic"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); @@ -145,7 +145,7 @@ public void test140AssignUserLargoBasic() throws Exception { @Test public void test142MeddleWithAccountAndReconcileUserLargo() throws Exception { final String TEST_NAME = "test142MeddleWithAccountAndReconcileUserLargo"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); @@ -192,7 +192,7 @@ public void test142MeddleWithAccountAndReconcileUserLargo() throws Exception { @Test public void test144AssignUserLargoUnix() throws Exception { final String TEST_NAME = "test144AssignUserLargoUnix"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); @@ -222,7 +222,7 @@ public void test144AssignUserLargoUnix() throws Exception { @Test public void test146UnassignUserLargoUnix() throws Exception { final String TEST_NAME = "test146UnassignUserLargoUnix"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); @@ -252,7 +252,7 @@ public void test146UnassignUserLargoUnix() throws Exception { @Test public void test149UnAssignUserLargoBasic() throws Exception { final String TEST_NAME = "test149UnAssignUserLargoBasic"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestVillage.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestVillage.java index ef3c1d418f1..e73a6ab3fe2 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestVillage.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestVillage.java @@ -26,7 +26,6 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.ObjectQueryUtil; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.asserter.UserAsserter; @@ -750,7 +749,7 @@ public void test152ModifySrcAccountHermanDeleteOrg() throws Exception { @Test public void test200CreateUserAssignOrgPwdPolicy() throws Exception { final String TEST_NAME = "test200CreateUserAssignOrgPwdPolicy"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = new OperationResult(TEST_NAME); //prepare password policies @@ -801,7 +800,7 @@ public void test202assignRoleOrgPwdPolicy() throws Exception{ final String TEST_NAME = "test202assignRoleOrgPwdPolicy"; //this will throw exception, if incorrect pwd policy is selected...but some assertion will be nice :) - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assignRole(USER_MIKE_OID, ROLE_BASIC_OID, task, result); assertPartialError(result); @@ -812,7 +811,7 @@ public void test202assignRoleOrgPwdPolicy() throws Exception{ @Test public void test300AddProjectJollyRoger() throws Exception { final String TEST_NAME = "test300AddProjectJollyRoger"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestWriter.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestWriter.java index b8adb2046f8..15d2efa1610 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestWriter.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestWriter.java @@ -61,7 +61,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult testResultWriter = modelService.testResource(RESOURCE_WRITER_OID, task); TestUtil.assertSuccess(testResultWriter); @@ -71,7 +71,7 @@ public void test000Sanity() throws Exception { public void test100AssignJackDummyAccount() throws Exception { final String TEST_NAME = "test100AssignJackDummyAccount"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_JACK_OID, UserType.F_LOCALITY, task, result, createPolyString(USER_JACK_LOCALITY)); @@ -96,7 +96,7 @@ public void test100AssignJackDummyAccount() throws Exception { public void test110ModifyCaptainJack() throws Exception { final String TEST_NAME = "test110ModifyCaptainJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperAsyncUpdate.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperAsyncUpdate.java index 33469878fe1..6b924082f22 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperAsyncUpdate.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperAsyncUpdate.java @@ -69,7 +69,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { - Task task = getTask(); + Task task = getTestTask(); assertSuccess(modelService.testResource(RESOURCE_LDAP.oid, task)); assertSuccess(modelService.testResource(RESOURCE_GROUPER.oid, task)); @@ -77,7 +77,7 @@ public void test000Sanity() throws Exception { @Test public void test010CreateUsers() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); addObject(USER_BANDERSON, task, result); @@ -94,7 +94,7 @@ public void test010CreateUsers() throws Exception { */ @Test public void test110AddAlumni() throws Exception { - Task task = getTask(); + Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); OperationResult result = getResult(); @@ -146,7 +146,7 @@ public void test110AddAlumni() throws Exception { */ @Test public void test115AddStaff() throws Exception { - Task task = getTask(); + Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); OperationResult result = getResult(); @@ -197,7 +197,7 @@ public void test115AddStaff() throws Exception { */ @Test public void test200AddAlumniForAnderson() throws Exception { - Task task = getTask(); + Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); OperationResult result = getResult(); @@ -234,7 +234,7 @@ public void test200AddAlumniForAnderson() throws Exception { */ @Test public void test202RecomputeAnderson() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -263,7 +263,7 @@ public void test202RecomputeAnderson() throws Exception { */ @Test public void test210AddStaffForAnderson() throws Exception { - Task task = getTask(); + Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); OperationResult result = getResult(); @@ -295,7 +295,7 @@ public void test210AddStaffForAnderson() throws Exception { */ @Test public void test212RecomputeAnderson() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -327,7 +327,7 @@ public void test212RecomputeAnderson() throws Exception { */ @Test public void test220AddAlumniForLewis() throws Exception { - Task task = getTask(); + Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); OperationResult result = getResult(); @@ -358,7 +358,7 @@ public void test220AddAlumniForLewis() throws Exception { */ @Test public void test221AddStaffForLewis() throws Exception { - Task task = getTask(); + Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); OperationResult result = getResult(); @@ -390,7 +390,7 @@ public void test221AddStaffForLewis() throws Exception { */ @Test public void test222RecomputeLewis() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -421,7 +421,7 @@ public void test222RecomputeLewis() throws Exception { */ @Test public void test230AddAlumniForNobody() throws Exception { - Task task = getTask(); + Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); OperationResult result = getResult(); @@ -448,7 +448,7 @@ public void test230AddAlumniForNobody() throws Exception { */ @Test public void test250DeleteAlumniForAnderson() throws Exception { - Task task = getTask(); + Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); OperationResult result = getResult(); @@ -479,7 +479,7 @@ public void test250DeleteAlumniForAnderson() throws Exception { */ @Test public void test252RecomputeAnderson() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // WHEN @@ -508,7 +508,7 @@ public void test252RecomputeAnderson() throws Exception { */ @Test public void test305RenameStaff() throws Exception { - Task task = getTask(); + Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); OperationResult result = getResult(); @@ -566,7 +566,7 @@ public void test305RenameStaff() throws Exception { */ @Test public void test310DeleteStaff() throws Exception { - Task task = getTask(); + Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); OperationResult result = getResult(); @@ -617,7 +617,7 @@ public void test310DeleteStaff() throws Exception { */ @Test public void test312ScavengeGroups() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); // GIVEN diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperLargeGroupImport.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperLargeGroupImport.java index 4ca614ab583..d2bd3c71cfc 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperLargeGroupImport.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperLargeGroupImport.java @@ -6,7 +6,6 @@ */ package com.evolveum.midpoint.testing.story.grouper; -import com.evolveum.icf.dummy.resource.DummyGroup; import com.evolveum.midpoint.schema.internals.InternalsConfig; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; @@ -46,7 +45,7 @@ protected void importSystemTasks(OperationResult initResult) { @Test public void test000Sanity() throws Exception { - Task task = getTask(); + Task task = getTestTask(); assertSuccess(modelService.testResource(RESOURCE_LDAP.oid, task)); assertSuccess(modelService.testResource(RESOURCE_GROUPER.oid, task)); @@ -54,7 +53,7 @@ public void test000Sanity() throws Exception { @Test public void test100ImportGroups() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); task.setOwner(userAdministrator); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperLargeGroupReconciliation.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperLargeGroupReconciliation.java index 4c609363f41..55f0b77fd5b 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperLargeGroupReconciliation.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperLargeGroupReconciliation.java @@ -6,7 +6,6 @@ */ package com.evolveum.midpoint.testing.story.grouper; -import com.evolveum.icf.dummy.resource.DummyGroup; import com.evolveum.midpoint.schema.internals.InternalsConfig; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; @@ -46,7 +45,7 @@ protected void importSystemTasks(OperationResult initResult) { @Test public void test000Sanity() throws Exception { - Task task = getTask(); + Task task = getTestTask(); assertSuccess(modelService.testResource(RESOURCE_LDAP.oid, task)); assertSuccess(modelService.testResource(RESOURCE_GROUPER.oid, task)); @@ -54,7 +53,7 @@ public void test000Sanity() throws Exception { @Test public void test100ReconcileGroups() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); task.setOwner(userAdministrator); @@ -68,7 +67,7 @@ public void test100ReconcileGroups() throws Exception { @Test public void test110ReconcileGroupsAgain() throws Exception { - Task task = getTask(); + Task task = getTestTask(); OperationResult result = getResult(); task.setOwner(userAdministrator); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/AbstractLdapTest.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/AbstractLdapTest.java index a7153141701..63cfd3e2954 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/AbstractLdapTest.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/AbstractLdapTest.java @@ -25,8 +25,6 @@ import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; import org.testng.AssertJUnit; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Test; import com.evolveum.midpoint.util.exception.PolicyViolationException; import com.evolveum.midpoint.prism.PrismContainer; @@ -35,14 +33,12 @@ import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.path.ItemName; import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus; import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.ldap.OpenDJController; import com.evolveum.midpoint.test.util.MidPointTestConstants; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.testing.story.AbstractStoryTest; import com.evolveum.midpoint.util.exception.CommunicationException; import com.evolveum.midpoint.util.exception.ConfigurationException; @@ -57,11 +53,7 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; /** * Testing dependencies: @@ -173,7 +165,8 @@ protected void assertLdapConnectorInstances(int expectedConnectorInstances) thro } protected void assertLdapConnectorInstances(int expectedConnectorInstancesMin, int expectedConnectorInstancesMax) throws NumberFormatException, IOException, InterruptedException, SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = createTask(TestLdapSyncMassive.class.getName() + ".assertLdapConnectorInstances"); + TestLdapSyncMassive.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); List stats = provisioningService.getConnectorOperationalStatus(getLdapResourceOid(), task, result); display("Resource connector stats", stats); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapAssociationPerformance.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapAssociationPerformance.java index 4e3d1afa1fe..cba853e5d87 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapAssociationPerformance.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapAssociationPerformance.java @@ -148,7 +148,7 @@ protected String getLdapResourceOid() { public void test000ClonePerformance() throws SchemaException { final String TEST_NAME = "test000ClonePerformance"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject systemConfiguration = systemObjectCache.getSystemConfiguration(result); @@ -166,7 +166,7 @@ public void test000ClonePerformance() throws SchemaException { public void test010Sanity() throws Exception { final String TEST_NAME = "test010Sanity"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -190,7 +190,7 @@ public void test010Sanity() throws Exception { public void test020GenerateRoles() throws Exception { final String TEST_NAME = "test020GenerateRoles"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -238,7 +238,7 @@ private void resetPerformanceCollectors() { public void test100AddUsers() throws Exception { final String TEST_NAME = "test100AddUsers"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -309,7 +309,7 @@ public void test110RecomputeUsers() throws Exception { rememberConnectorResourceCounters(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -353,7 +353,7 @@ public void test120RecomputeUsersNoRoleAndShadowCache() throws Exception { rememberConnectorResourceCounters(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -397,7 +397,7 @@ public void test130RecomputeUsersMultinode() throws Exception { rememberConnectorResourceCounters(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -445,7 +445,7 @@ public void test140RecomputeUsersMultinodeMultithreaded() throws Exception { rememberConnectorResourceCounters(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -494,7 +494,7 @@ public void test200RecomputeUsersNoDefaultRoleCache() throws Exception { rememberConnectorResourceCounters(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -539,7 +539,7 @@ public void test200RecomputeUsersNoDefaultRoleCache() throws Exception { public void test900Summarize() throws Exception { final String TEST_NAME = "test900Summarize"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); StringBuilder sb = new StringBuilder(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapComplex.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapComplex.java index b5fbb78fd27..b8d1fc594ba 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapComplex.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapComplex.java @@ -182,7 +182,7 @@ protected String getLdapResourceOid() { @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult testResultOpenDj = modelService.testResource(RESOURCE_OPENDJ_OID, task); TestUtil.assertSuccess(testResultOpenDj); @@ -198,7 +198,7 @@ public void test000Sanity() throws Exception { @Test public void test010Shadows() throws Exception { final String TEST_NAME = "test010Shadows"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceQuery(RESOURCE_OPENDJ_OID, prismContext); @@ -221,7 +221,7 @@ public void test010Shadows() throws Exception { @Test public void test050AssignAccountOpenDjSimple() throws Exception { final String TEST_NAME = "test050AssignAccountOpenDjSimple"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -254,7 +254,7 @@ public void test050AssignAccountOpenDjSimple() throws Exception { @Test public void test055Shadows() throws Exception { final String TEST_NAME = "test055Shadows"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceQuery(RESOURCE_OPENDJ_OID, prismContext); @@ -275,7 +275,7 @@ public void test055Shadows() throws Exception { @Test public void test059UnassignAccountOpenDjSimple() throws Exception { final String TEST_NAME = "test059UnassignAccountOpenDjSimple"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -305,7 +305,7 @@ public void test059UnassignAccountOpenDjSimple() throws Exception { @Test public void test100ModifyJackFullNameLang() throws Exception { final String TEST_NAME = "test100ModifyJackFullNameLang"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PolyString newFullName = new PolyString(USER_JACK_FULL_NAME); @@ -338,7 +338,7 @@ public void test100ModifyJackFullNameLang() throws Exception { @Test public void test110AssignAccountOpenDjLang() throws Exception { final String TEST_NAME = "test110AssignAccountOpenDjLang"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -373,7 +373,7 @@ public void test110AssignAccountOpenDjLang() throws Exception { @Test public void test112ModifyJackFullNameLangEnSkRuHr() throws Exception { final String TEST_NAME = "test112ModifyJackFullNameLangEnSkRuHr"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PolyString newFullName = new PolyString(USER_JACK_FULL_NAME); @@ -410,7 +410,7 @@ public void test112ModifyJackFullNameLangEnSkRuHr() throws Exception { @Test public void test114ModifyJackFullNameLangCzHr() throws Exception { final String TEST_NAME = "test114ModifyJackFullNameLangCzHr"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PolyString newFullName = new PolyString(USER_JACK_FULL_NAME); @@ -447,7 +447,7 @@ public void test114ModifyJackFullNameLangCzHr() throws Exception { @Test public void test116ModifyJackFullNameLangCaptain() throws Exception { final String TEST_NAME = "test116ModifyJackFullNameLangCaptain"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PolyString newFullName = new PolyString(USER_JACK_FULL_NAME_CAPTAIN); @@ -483,7 +483,7 @@ public void test116ModifyJackFullNameLangCaptain() throws Exception { @Test public void test118ModifyJackFullNameCaptain() throws Exception { final String TEST_NAME = "test118ModifyJackFullNameCaptain"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PolyString newFullName = new PolyString(USER_JACK_FULL_NAME_CAPTAIN); @@ -515,7 +515,7 @@ public void test118ModifyJackFullNameCaptain() throws Exception { @Test public void test119UnassignAccountOpenDjLang() throws Exception { final String TEST_NAME = "test119UnassignAccountOpenDjLang"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -545,7 +545,7 @@ public void test119UnassignAccountOpenDjLang() throws Exception { @Test public void test120ModifyJackTitleMap() throws Exception { final String TEST_NAME = "test120ModifyJackTitleMap"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); List> cvals = createTitleMapValues(TITLE_EN_SK_RU); @@ -582,7 +582,7 @@ public void test120ModifyJackTitleMap() throws Exception { @Test public void test130AssignAccountOpenDjTitleMap() throws Exception { final String TEST_NAME = "test130AssignAccountOpenDjTitleMap"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -622,7 +622,7 @@ public void test130AssignAccountOpenDjTitleMap() throws Exception { @Test public void test132AssignAccountOpenDjTitleMapAdd() throws Exception { final String TEST_NAME = "test132AssignAccountOpenDjTitleMapAdd"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); List> cvals = createTitleMapValues(TITLE_HR); @@ -669,7 +669,7 @@ public void test132AssignAccountOpenDjTitleMapAdd() throws Exception { @Test public void test134AssignAccountOpenDjTitleMapDelete() throws Exception { final String TEST_NAME = "test134AssignAccountOpenDjTitleMapDelete"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); List> cvals = createTitleMapValues(TITLE_RU); @@ -716,7 +716,7 @@ public void test134AssignAccountOpenDjTitleMapDelete() throws Exception { @Test public void test138AssignAccountOpenDjTitleMapReplace() throws Exception { final String TEST_NAME = "test138AssignAccountOpenDjTitleMapReplace"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); List> cvals = createTitleMapValues(TITLE_EN_SK_RU); @@ -759,7 +759,7 @@ public void test138AssignAccountOpenDjTitleMapReplace() throws Exception { @Test public void test139UnassignAccountOpenDjTitleMap() throws Exception { final String TEST_NAME = "test139UnassignAccountOpenDjTitleMap"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -788,7 +788,7 @@ public void test139UnassignAccountOpenDjTitleMap() throws Exception { @Test public void test150AssignAccountOpenDj() throws Exception { final String TEST_NAME = "test150AssignAccountOpenDj"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -832,7 +832,7 @@ public void test150AssignAccountOpenDj() throws Exception { @Test public void test152JackMultivalueDescriptionGet() throws Exception { final String TEST_NAME = "test152JackMultivalueDescriptionGet"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Let's ruing Jack's description in LDAP. @@ -886,7 +886,7 @@ public void test152JackMultivalueDescriptionGet() throws Exception { @Test public void test300Shadows() throws Exception { final String TEST_NAME = "test300Shadows"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceQuery(RESOURCE_OPENDJ_OID, prismContext); @@ -926,7 +926,7 @@ public void test310SearchLdapAccounts() throws Exception { @Test public void test312Shadows() throws Exception { final String TEST_NAME = "test312Shadows"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceQuery(RESOURCE_OPENDJ_OID, prismContext); @@ -1122,7 +1122,7 @@ public void test415CreateOrgRumDepartment() throws Exception { public void test420AssignJackToKeelhaul() throws Exception { final String TEST_NAME = "test412AssignJackToKeelhaul"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); String accountJackOid = assertUserBefore(USER_JACK_OID) @@ -1162,7 +1162,7 @@ public void test420AssignJackToKeelhaul() throws Exception { public void test422AssignJackToWalkThePlank() throws Exception { final String TEST_NAME = "test414AssignJackToWalkThePlank"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); String accountJackOid = assertUserBefore(USER_JACK_OID) @@ -1202,7 +1202,7 @@ public void test422AssignJackToWalkThePlank() throws Exception { public void test424AssignJackToRumDepartment() throws Exception { final String TEST_NAME = "test424AssignJackToRumDepartment"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); String accountJackOid = assertUserBefore(USER_JACK_OID) diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapDependency.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapDependency.java index 3c18594b75c..b4d5b7db9a8 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapDependency.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapDependency.java @@ -151,7 +151,7 @@ public void test000Sanity() throws Exception { @Test public void test100AddOrgIT() throws Exception { final String TEST_NAME = "test100AddOrgIT"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject orgBefore = createOrg(ORG_IT_NAME, ORG_TOP_OID); @@ -178,7 +178,7 @@ public void test100AddOrgIT() throws Exception { @Test public void test150AssignFunctionalRoleToITOrg() throws Exception { final String TEST_NAME = "test150AssignFunctionalRoleToITOrg"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject orgBefore = getOrg(ORG_IT_NAME); @@ -207,7 +207,7 @@ public void test150AssignFunctionalRoleToITOrg() throws Exception { @Test public void test170UnassignFunctionalRoleFromITOrg() throws Exception { final String TEST_NAME = "test170UnassignFunctionalRoleFromITOrg"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject orgBefore = getOrg(ORG_IT_NAME); @@ -237,7 +237,7 @@ public void test170UnassignFunctionalRoleFromITOrg() throws Exception { @Test public void test200AddOrgHR() throws Exception { final String TEST_NAME = "test200AddOrgHR"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject orgBefore = createOrg(ORG_HR_NAME, ORG_TOP_OID); @@ -264,7 +264,7 @@ public void test200AddOrgHR() throws Exception { @Test public void test250AssignFunctionalAndVipRoleToHROrg() throws Exception { final String TEST_NAME = "test250AssignFunctionalAndVipRoleToHROrg"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject orgBefore = getOrg(ORG_HR_NAME); @@ -296,7 +296,7 @@ public void test250AssignFunctionalAndVipRoleToHROrg() throws Exception { @Test public void test270UnassignVipRoleFromHROrg() throws Exception { final String TEST_NAME = "test270UnassignVipRoleFromHROrg"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject orgBefore = getOrg(ORG_HR_NAME); @@ -328,7 +328,7 @@ public void test270UnassignVipRoleFromHROrg() throws Exception { @Test public void test280AssignVipAndSuperVipRoleToHROrg() throws Exception { final String TEST_NAME = "test280AssignVipAndSuperVipRoleToHROrg"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject orgBefore = getOrg(ORG_HR_NAME); @@ -361,7 +361,7 @@ public void test280AssignVipAndSuperVipRoleToHROrg() throws Exception { @Test public void test290UnassignVipRoleFromHROrg() throws Exception { final String TEST_NAME = "test290UnassignVipRoleFromHROrg"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject orgBefore = getOrg(ORG_HR_NAME); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapMutilated.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapMutilated.java index 84634a79918..e50862689d3 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapMutilated.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapMutilated.java @@ -96,7 +96,7 @@ protected String getLdapResourceOid() { @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult testResultOpenDj = modelService.testResource(RESOURCE_OPENDJ_OID, task); TestUtil.assertSuccess(testResultOpenDj); @@ -112,7 +112,7 @@ public void test000Sanity() throws Exception { @Test public void test010Shadows() throws Exception { final String TEST_NAME = "test010Shadows"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceQuery(RESOURCE_OPENDJ_OID, prismContext); @@ -135,7 +135,7 @@ public void test010Shadows() throws Exception { @Test public void test100AssignAccountOpenDjSimple() throws Exception { final String TEST_NAME = "test100AssignAccountOpenDjSimple"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -166,7 +166,7 @@ public void test100AssignAccountOpenDjSimple() throws Exception { @Test public void test105Shadows() throws Exception { final String TEST_NAME = "test105Shadows"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceQuery(RESOURCE_OPENDJ_OID, prismContext); @@ -187,7 +187,7 @@ public void test105Shadows() throws Exception { @Test public void test109UnassignAccountOpenDjSimple() throws Exception { final String TEST_NAME = "test109UnassignAccountOpenDjSimple"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -218,7 +218,7 @@ public void test109UnassignAccountOpenDjSimple() throws Exception { @Test public void test300Shadows() throws Exception { final String TEST_NAME = "test300Shadows"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceQuery(RESOURCE_OPENDJ_OID, prismContext); @@ -257,7 +257,7 @@ public void test310SearchLdapAccounts() throws Exception { @Test public void test312Shadows() throws Exception { final String TEST_NAME = "test312Shadows"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceQuery(RESOURCE_OPENDJ_OID, prismContext); @@ -292,7 +292,7 @@ public void test312Shadows() throws Exception { @Test public void test320AssignAccountOpenDj() throws Exception { final String TEST_NAME = "test320AssignAccountOpenDj"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapReconPerformance.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapReconPerformance.java index fa1b814ebd9..2ccd3be452e 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapReconPerformance.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapReconPerformance.java @@ -106,7 +106,7 @@ protected String getLdapResourceOid() { public void test010GenerateUsers() throws Exception { final String TEST_NAME = "test010GenerateUsers"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); long startMillis = System.currentTimeMillis(); @@ -150,7 +150,7 @@ public void test100Reconcile1ThreadLdap0() throws Exception { rememberConnectorResourceCounters(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -193,7 +193,7 @@ public void test200ReconcileLdap0() throws Exception { rememberConnectorResourceCounters(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -271,7 +271,7 @@ private long testReconcileLdapRestart(final String TEST_NAME) throws Exception { } private long testReconcileLdapRestartWhen(final String TEST_NAME, String taskOid) throws Exception { - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ruinLdapAccounts(); @@ -302,7 +302,7 @@ private long testReconcileLdapRestartWhen(final String TEST_NAME, String taskOid public void test900Summarize() throws Exception { final String TEST_NAME = "test900Summarize"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); StringBuilder sb = new StringBuilder(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapSyncMassive.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapSyncMassive.java index 0cee4a664be..53f4a518bf8 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapSyncMassive.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapSyncMassive.java @@ -26,7 +26,6 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.ObjectTypeUtil; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.util.ParallelTestThread; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.*; @@ -121,7 +120,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult testResultOpenDj = modelService.testResource(RESOURCE_OPENDJ_OID, task); TestUtil.assertSuccess(testResultOpenDj); @@ -281,7 +280,7 @@ private String goblinUsername(int i) { public void test200SyncAddKraken() throws Exception { final String TEST_NAME = "test200SyncAddKraken"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ImportOptionsType options = new ImportOptionsType() @@ -385,7 +384,7 @@ public void test219StopSyncTask() throws Exception { public void test230UserRecomputeSequential() throws Exception { final String TEST_NAME = "test230UserRecomputeSequential"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); SearchResultList> users = modelService.searchObjects(UserType.class, null, null, task, result); @@ -408,7 +407,7 @@ public void test230UserRecomputeSequential() throws Exception { public void test232UserRecomputeParallel() throws Exception { final String TEST_NAME = "test232UserRecomputeParallel"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); SearchResultList> users = modelService.searchObjects(UserType.class, null, null, task, result); @@ -436,7 +435,8 @@ public void test232UserRecomputeParallel() throws Exception { } private void reconcile(final String TEST_NAME, PrismObject user) throws CommunicationException, ObjectAlreadyExistsException, ExpressionEvaluationException, PolicyViolationException, SchemaException, SecurityViolationException, ConfigurationException, ObjectNotFoundException { - Task task = createTask(TEST_NAME+".user."+user.getName()); + user.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); reconcileUser(user.getOid(), task, result); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/hierarchy/AbstractLdapHierarchyTest.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/hierarchy/AbstractLdapHierarchyTest.java index e7abd2feefb..691e754deb6 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/hierarchy/AbstractLdapHierarchyTest.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/hierarchy/AbstractLdapHierarchyTest.java @@ -170,7 +170,7 @@ public void test000Sanity() throws Exception { @Test public void test100AddOrgRoyulaCarpathia() throws Exception { final String TEST_NAME = "test100AddOrgRoyulaCarpathia"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject orgBefore = createOrg(ORG_ROYULA_CARPATHIA_NAME, ORG_TOP_OID); @@ -198,7 +198,7 @@ public void test100AddOrgRoyulaCarpathia() throws Exception { @Test public void test110AddUserTeleke() throws Exception { final String TEST_NAME = "test110AddUserTeleke"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = createUser(USER_TELEKE_USERNAME, @@ -228,7 +228,7 @@ public void test110AddUserTeleke() throws Exception { @Test public void test200AddOrgCortuvHrad() throws Exception { final String TEST_NAME = "test200AddOrgCortuvHrad"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject orgBefore = createOrg(ORG_CORTUV_HRAD_NAME, orgRolyulaCarpathiaOid); @@ -257,7 +257,7 @@ public void test200AddOrgCortuvHrad() throws Exception { @Test public void test210AddUserGorc() throws Exception { final String TEST_NAME = "test210AddUserGorc"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = createUser(USER_GORC_USERNAME, @@ -283,7 +283,7 @@ public void test210AddUserGorc() throws Exception { @Test public void test220AddOrgVysneVlkodlaky() throws Exception { final String TEST_NAME = "test220AddOrgVysneVlkodlaky"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject orgBefore = createOrg(ORG_VYSNE_VLKODLAKY_NAME, orgCortuvHradOid); @@ -312,7 +312,7 @@ public void test220AddOrgVysneVlkodlaky() throws Exception { @Test public void test230AddUserViljaDezi() throws Exception { final String TEST_NAME = "test230AddUserViljaDezi"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = createUser(USER_DEZI_USERNAME, @@ -337,7 +337,7 @@ public void test230AddUserViljaDezi() throws Exception { @Test public void test300RenameOrgCortuvHrad() throws Exception { final String TEST_NAME = "test300RenameOrgCortuvHrad"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject orgBefore = createOrg(ORG_CORTUV_HRAD_NAME, orgRolyulaCarpathiaOid); @@ -369,7 +369,7 @@ public void test300RenameOrgCortuvHrad() throws Exception { @Test public void test310RenameUserGorc() throws Exception { final String TEST_NAME = "test310RenameUserGorc"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = createUser(USER_GORC_USERNAME, @@ -392,7 +392,7 @@ public void test310RenameUserGorc() throws Exception { @Test public void test320AddOrgRoyulaDiabolica() throws Exception { final String TEST_NAME = "test320AddOrgRoyulaDiabolica"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject orgBefore = createOrg(ORG_ROYULA_DIABOLICA_NAME, ORG_TOP_OID); @@ -421,7 +421,7 @@ public void test320AddOrgRoyulaDiabolica() throws Exception { @Test public void test322MoveOrgZblo() throws Exception { final String TEST_NAME = "test322MoveOrgZblo"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject orgBefore = getOrg(ORG_CORTUV_HRAD_NAME2); @@ -586,7 +586,7 @@ protected void assertNoGroupMembers(PrismObject org) throws Exception { } protected void reconcileAllUsers() throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - final Task task = createTask("reconcileAllUsers"); + final Task task = getTestTask(); OperationResult result = task.getResult(); ResultHandler handler = new ResultHandler() { @Override @@ -607,7 +607,7 @@ public boolean handle(PrismObject object, OperationResult parentResult } protected void reconcileAllOrgs() throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - final Task task = createTask("reconcileAllOrgs"); + final Task task = getTestTask(); OperationResult result = task.getResult(); ResultHandler handler = new ResultHandler() { @Override diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/AbstractNotoriousTest.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/AbstractNotoriousTest.java index fe71f42e040..57bfbcede2b 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/AbstractNotoriousTest.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/AbstractNotoriousTest.java @@ -174,7 +174,7 @@ public void test000Sanity() throws Exception { public void test100AssignRa0ToJack() throws Exception { final String TEST_NAME = "test100AssignRa0ToJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -210,7 +210,7 @@ public void test100AssignRa0ToJack() throws Exception { public void test102RecomputeJack() throws Exception { final String TEST_NAME = "test102RecomputeJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -242,7 +242,7 @@ public void test102RecomputeJack() throws Exception { public void test104PreviewChangesJack() throws Exception { final String TEST_NAME = "test104PreviewChangesJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -281,7 +281,7 @@ public void test104PreviewChangesJack() throws Exception { public void test109UnassignRa0FromJack() throws Exception { final String TEST_NAME = "test109UnassignRa0FromJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -314,7 +314,7 @@ public void test109UnassignRa0FromJack() throws Exception { public void test110Assign5ARolesToJack() throws Exception { final String TEST_NAME = "test110AssignAllARolesToJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -346,7 +346,7 @@ public void test110Assign5ARolesToJack() throws Exception { public void test112RecomputeJack() throws Exception { final String TEST_NAME = "test112RecomputeJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -378,7 +378,7 @@ public void test112RecomputeJack() throws Exception { public void test119Unassign5ARolesFromJack() throws Exception { final String TEST_NAME = "test119Unassign5ARolesFromJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -411,7 +411,7 @@ public void test119Unassign5ARolesFromJack() throws Exception { public void test120AssignAllARolesToJack() throws Exception { final String TEST_NAME = "test120AssignAllARolesToJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -443,7 +443,7 @@ public void test120AssignAllARolesToJack() throws Exception { public void test122RecomputeJack() throws Exception { final String TEST_NAME = "test122RecomputeJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -475,7 +475,7 @@ public void test122RecomputeJack() throws Exception { public void test124PreviewChangesJack() throws Exception { final String TEST_NAME = "test124PreviewChangesJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -514,7 +514,7 @@ public void test124PreviewChangesJack() throws Exception { public void test129UnassignAllARolesFromJack() throws Exception { final String TEST_NAME = "test129UnassignAllARolesFromJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -547,7 +547,7 @@ public void test129UnassignAllARolesFromJack() throws Exception { public void test130AssignRb0ToJack() throws Exception { final String TEST_NAME = "test130AssignRb0ToJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -589,7 +589,7 @@ public void test130AssignRb0ToJack() throws Exception { public void test132AssignRa0ToJack() throws Exception { final String TEST_NAME = "test132AssignRa0ToJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -625,7 +625,7 @@ public void test132AssignRa0ToJack() throws Exception { public void test134RecomputeJack() throws Exception { final String TEST_NAME = "test134RecomputeJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -659,7 +659,7 @@ public void test134RecomputeJack() throws Exception { public void test136UnassignRb0FromJack() throws Exception { final String TEST_NAME = "test136UnassignRb0FromJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -695,7 +695,7 @@ public void test136UnassignRb0FromJack() throws Exception { public void test138AssignRb0ToJackAgain() throws Exception { final String TEST_NAME = "test138AssignRb0ToJackAgain"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -731,7 +731,7 @@ public void test138AssignRb0ToJackAgain() throws Exception { public void test140RecomputeJackAgain() throws Exception { final String TEST_NAME = "test140RecomputeJackAgain"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -765,7 +765,7 @@ public void test140RecomputeJackAgain() throws Exception { public void test142RecomputeJackAlt() throws Exception { final String TEST_NAME = "test142RecomputeJackAlt"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -800,7 +800,7 @@ public void test142RecomputeJackAlt() throws Exception { public void test144UnassignRa0FromJack() throws Exception { final String TEST_NAME = "test144UnassignRa0FromJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -836,7 +836,7 @@ public void test144UnassignRa0FromJack() throws Exception { public void test149UnassignRb0FromJack() throws Exception { final String TEST_NAME = "test149UnassignRb0FromJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -877,7 +877,7 @@ public void test149UnassignRb0FromJack() throws Exception { public void test150AssignNotoriousDefaultToJack() throws Exception { final String TEST_NAME = "test150AssignNotoriousDefaultToJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -919,7 +919,7 @@ public void test150AssignNotoriousDefaultToJack() throws Exception { public void test152AssignNotoriousAltRelationToJack() throws Exception { final String TEST_NAME = "test152AssignNotoriousAltRelationToJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -962,7 +962,7 @@ public void test152AssignNotoriousAltRelationToJack() throws Exception { public void test154RecomputeJack() throws Exception { final String TEST_NAME = "test154RecomputeJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -1008,7 +1008,7 @@ protected int getTest15xRoleEvaluationIncrement() { public void test156RecomputeJackAlt() throws Exception { final String TEST_NAME = "test156RecomputeJackAlt"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -1050,7 +1050,7 @@ public void test156RecomputeJackAlt() throws Exception { public void test158UnassignNotoriousDefaultFromJack() throws Exception { final String TEST_NAME = "test156UnassignNotoriousDefaultFromJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -1091,7 +1091,7 @@ protected void assertTest158RoleMembershipRef(PrismObject userAfter) { public void test159UnassignNotoriousAltRelationFromJack() throws Exception { final String TEST_NAME = "test159UnassignNotoriousAltRelationFromJack"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/perf/TestImport.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/perf/TestImport.java index ecdb647c77c..36289b0e5a6 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/perf/TestImport.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/perf/TestImport.java @@ -12,7 +12,6 @@ import com.evolveum.midpoint.schema.internals.InternalsConfig; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyAuditService; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestPrivacy.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestPrivacy.java index 98c82915e7c..03744d74f8c 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestPrivacy.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestPrivacy.java @@ -25,7 +25,6 @@ import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.testing.story.AbstractStoryTest; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestRoleMembers.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestRoleMembers.java index 079f8d6289d..c5eac7dfc49 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestRoleMembers.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestRoleMembers.java @@ -175,7 +175,7 @@ public void test100AutzGuybrushNoMembers() throws Exception { } private ModelContext previewUser(String userOid) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { - Task task = createTask("previewUser"); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta emptyMancombDelta = deltaFor(UserType.class).asObjectDelta(userOid); ModelContext previewContext = modelInteractionService.previewChanges(Collections.singleton(emptyMancombDelta), null, task, result); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/uuid/AbstractUuidTest.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/uuid/AbstractUuidTest.java index 049f83382d5..a8d9e8a11b6 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/uuid/AbstractUuidTest.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/uuid/AbstractUuidTest.java @@ -87,7 +87,7 @@ protected File getSystemConfigurationFile() { @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult testResultOpenDj = modelService.testResource(RESOURCE_OPENDJ_OID, task); TestUtil.assertSuccess(testResultOpenDj); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/uuid/TestUuidClient.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/uuid/TestUuidClient.java index 7c869705d3c..802a7e30ca0 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/uuid/TestUuidClient.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/uuid/TestUuidClient.java @@ -9,14 +9,10 @@ import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.PrismReferenceValue; import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.IntegrationTestTools; -import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.testing.story.AbstractStoryTest; import com.evolveum.midpoint.util.exception.*; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; @@ -25,7 +21,6 @@ import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; import org.testng.AssertJUnit; -import org.testng.annotations.AfterClass; import org.testng.annotations.Listeners; import org.testng.annotations.Test; @@ -103,7 +98,7 @@ protected File getSystemConfigurationFile() { @Test public void test100AddUserRapp() throws Exception { final String TEST_NAME = "test100AddUserRapp"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = createNoNameUser(USER_RAPP_GIVEN_NAME, USER_RAPP_FAMILY_NAME, true); @@ -123,7 +118,7 @@ public void test100AddUserRapp() throws Exception { @Test public void test101RappAssignRoleClient() throws Exception { final String TEST_NAME = "test101RappAssignRoleClient"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -143,7 +138,7 @@ public void test101RappAssignRoleClient() throws Exception { @Test public void test107RappUnAssignRoleClient() throws Exception { final String TEST_NAME = "test107RappUnAssignRoleClient"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); // WHEN unassignRole(userRappOid, ROLE_CLIENT_OID); @@ -157,7 +152,7 @@ public void test107RappUnAssignRoleClient() throws Exception { @Test public void test110AddMancombWithRoleClient() throws Exception { final String TEST_NAME = "test110AddMancombWithRoleClient"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = createClientUser(null, null, USER_MANCOMB_GIVEN_NAME, USER_MANCOMB_FAMILY_NAME, true); @@ -181,7 +176,7 @@ public void test110AddMancombWithRoleClient() throws Exception { @Test public void test112RenameMancomb() throws Exception { final String TEST_NAME = "test112RenameMancomb"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); try { @@ -203,7 +198,7 @@ public void test112RenameMancomb() throws Exception { @Test public void test119MancombDelete() throws Exception { final String TEST_NAME = "test119MancombDelete"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -222,7 +217,7 @@ public void test119MancombDelete() throws Exception { @Test public void test120AddKateWithRoleClient() throws Exception { final String TEST_NAME = "test120AddKateWithRoleClient"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = createClientUser(null, USER_KATE_NAME, USER_KATE_GIVEN_NAME, USER_KATE_FAMILY_NAME, true); @@ -244,7 +239,7 @@ public void test120AddKateWithRoleClient() throws Exception { @Test public void test122AddWallyWithRoleClient() throws Exception { final String TEST_NAME = "test122AddWallyWithRoleClient"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = createClientUser(USER_WALLY_OID, null, USER_WALLY_GIVEN_NAME, USER_WALLY_FAMILY_NAME, true); @@ -266,7 +261,7 @@ public void test122AddWallyWithRoleClient() throws Exception { @Test public void test124AddRogersWithRoleClient() throws Exception { final String TEST_NAME = "test124AddMartyWithRoleClient"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = createClientUser(USER_ROGERS_OID, USER_ROGERS_OID, USER_ROGERS_GIVEN_NAME, USER_ROGERS_FAMILY_NAME, true); @@ -288,7 +283,7 @@ public void test124AddRogersWithRoleClient() throws Exception { @Test public void test126AddMartyWithRoleClient() throws Exception { final String TEST_NAME = "test124AddMartyWithRoleClient"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = createClientUser(USER_MARTY_OID, USER_MARTY_NAME, USER_MARTY_GIVEN_NAME, USER_MARTY_FAMILY_NAME, true); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/uuid/TestUuidExtension.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/uuid/TestUuidExtension.java index 471242fc1ff..cd333743932 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/uuid/TestUuidExtension.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/uuid/TestUuidExtension.java @@ -74,7 +74,7 @@ protected File getSystemConfigurationFile() { @Test public void test100AddUserRapp() throws Exception { final String TEST_NAME = "test100AddUserRapp"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = createUser(USER_RAPP_NAME, USER_RAPP_GIVEN_NAME, USER_RAPP_FAMILY_NAME, true); @@ -94,7 +94,7 @@ public void test100AddUserRapp() throws Exception { @Test public void test101RappAssignRoleEmployee() throws Exception { final String TEST_NAME = "test101RappAssignRoleEmployee"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -113,7 +113,7 @@ public void test101RappAssignRoleEmployee() throws Exception { @Test public void test107RappUnAssignRoleEmployee() throws Exception { final String TEST_NAME = "test107RappUnAssignRoleEmployee"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); // WHEN unassignRole(userRappOid, ROLE_EMPLOYEE_OID); @@ -130,7 +130,7 @@ public void test107RappUnAssignRoleEmployee() throws Exception { @Test public void test110AddKateWithRoleEmployee() throws Exception { final String TEST_NAME = "test110AddKateWithRoleEmployee"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = createEmployeeUser(USER_KATE_NAME, USER_KATE_GIVEN_NAME, USER_KATE_FAMILY_NAME, true); From f54f5b473372687031630500242878a128d769c2 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Thu, 27 Feb 2020 15:01:50 +0100 Subject: [PATCH 26/97] POM: quick build comment fix --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d79851157ad..c52c665f450 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ "Quick" build with unit tests only and checkstyle (~30m): mvn clean install -P -dist -DskipITs -Dmaven.javadoc.skip - "Quick" build with smaller integration test set and output to stdout (~1h20m): + "Quick" build with smaller integration test (~1h20m): mvn clean install -P -dist -DintegrationTestSuite=fast -Dmaven.javadoc.skip Running tests of a selected module (-pl) with output to stdout (don't use stdout for complete build, it's too much): From bd3332dc46e0538160b1470c0125c3fc298bb512 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Thu, 27 Feb 2020 15:02:22 +0100 Subject: [PATCH 27/97] MidPointPrincipal: removed obsolete TODO about user->focus change --- .../com/evolveum/midpoint/security/api/MidPointPrincipal.java | 1 - 1 file changed, 1 deletion(-) diff --git a/repo/security-api/src/main/java/com/evolveum/midpoint/security/api/MidPointPrincipal.java b/repo/security-api/src/main/java/com/evolveum/midpoint/security/api/MidPointPrincipal.java index a4af5dfb74c..f8bf19e454a 100644 --- a/repo/security-api/src/main/java/com/evolveum/midpoint/security/api/MidPointPrincipal.java +++ b/repo/security-api/src/main/java/com/evolveum/midpoint/security/api/MidPointPrincipal.java @@ -30,7 +30,6 @@ public class MidPointPrincipal implements UserDetails, DebugDumpable, ShortDumpable { private static final long serialVersionUID = 8299738301872077768L; - // TODO: user may be switched to FocusType later (MID-4205) @NotNull private final FocusType focus; private Collection authorizations = new ArrayList<>(); private ActivationStatusType effectiveActivationStatus; From 828b71c35c352c67fe6a6d68216a6933421f92c1 Mon Sep 17 00:00:00 2001 From: kate Date: Thu, 27 Feb 2020 15:23:37 +0100 Subject: [PATCH 28/97] set util task archetype for save in background tasks --- .../midpoint/web/component/progress/ProgressPanel.java | 10 ++++++++++ .../resources/xml/ns/public/common/common-core-3.xsd | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/progress/ProgressPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/progress/ProgressPanel.java index 3e711501e5d..28b328038da 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/progress/ProgressPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/progress/ProgressPanel.java @@ -15,6 +15,7 @@ import com.evolveum.midpoint.model.api.ModelPublicConstants; import com.evolveum.midpoint.model.api.ModelService; import com.evolveum.midpoint.model.api.context.ModelContext; +import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.PrismProperty; import com.evolveum.midpoint.prism.PrismPropertyDefinition; import com.evolveum.midpoint.prism.delta.DeltaFactory; @@ -465,6 +466,15 @@ public void executeChangesInBackground(Collection taskType = task.getUpdatedTaskObject(); + AssignmentType archetypeAssignment = new AssignmentType(); + archetypeAssignment.setTargetRef(WebComponentUtil.createObjectRef(SystemObjectsType.ARCHETYPE_UTILITY_TASK.value(), + null, ArchetypeType.COMPLEX_TYPE)); + taskType.asObjectable().getAssignment().add(archetypeAssignment); + taskType.asObjectable().getArchetypeRef().add(WebComponentUtil.createObjectRef(SystemObjectsType.ARCHETYPE_UTILITY_TASK.value(), + null, ArchetypeType.COMPLEX_TYPE)); + taskManager.switchToBackground(task, result); result.setBackgroundTaskOid(task.getOid()); } catch (Exception e) { diff --git a/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd b/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd index 06d1834c39a..c545ac76e0e 100755 --- a/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd +++ b/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd @@ -21410,6 +21410,13 @@ + + + + + + + From 0f54703b2c40f4e461e0f9d49b89a8b4cbffc0e8 Mon Sep 17 00:00:00 2001 From: Hiroyuki Wada Date: Thu, 27 Feb 2020 13:12:42 +0900 Subject: [PATCH 29/97] MID-6085 fix time change error in Internals configuration page --- .../configuration/InternalsClockPanel.java | 5 ++ .../page/InternalsConfigurationPageTest.java | 61 +++++++++++++++++ .../component/configuration/ClockTab.java | 66 +++++++++++++++++++ .../midpoint/schrodinger/page/BasicPage.java | 30 +++++++-- .../InternalsConfigurationPage.java | 15 ++++- 5 files changed, 168 insertions(+), 9 deletions(-) create mode 100644 testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/InternalsConfigurationPageTest.java diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/configuration/InternalsClockPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/configuration/InternalsClockPanel.java index 59cc532d345..51fac38f711 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/configuration/InternalsClockPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/configuration/InternalsClockPanel.java @@ -8,8 +8,10 @@ import javax.xml.datatype.XMLGregorianCalendar; +import com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.markup.html.form.Form; +import org.apache.wicket.markup.html.form.FormComponent; import org.apache.wicket.model.IModel; import org.apache.wicket.spring.injection.annot.SpringBean; @@ -47,6 +49,9 @@ protected void onInitialize() { add(form); DatePanel offset = new DatePanel(ID_OFFSET, getModel()); + for (FormComponent formComponent : offset.getFormComponents()) { + formComponent.add(new EmptyOnBlurAjaxFormUpdatingBehaviour()); + } form.add(offset); AjaxSubmitButton saveButton = new AjaxSubmitButton(ID_BUTTON_SAVE, createStringResource("PageInternals.button.changeTime")) { diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/InternalsConfigurationPageTest.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/InternalsConfigurationPageTest.java new file mode 100644 index 00000000000..35ed1a1be85 --- /dev/null +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/InternalsConfigurationPageTest.java @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2010-2019 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ +package com.evolveum.midpoint.testing.schrodinger.page; + +import com.evolveum.midpoint.schrodinger.component.configuration.ClockTab; +import com.evolveum.midpoint.schrodinger.page.configuration.InternalsConfigurationPage; +import com.evolveum.midpoint.testing.schrodinger.TestBase; +import org.testng.Assert; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +/** + * @author Hiroyuki Wada + */ +public class InternalsConfigurationPageTest extends TestBase { + + private InternalsConfigurationPage configPage; + + @BeforeMethod + private void openPage() { + configPage = basicPage.internalsConfiguration(); + } + + @AfterClass + private void cleanup() { + // Reset time because TestBase#afterClass() doesn't reset the clock. + configPage = basicPage.internalsConfiguration(); + configPage.clockTab().resetTime(); + } + + @Test + public void changeTime() { + ClockTab clockTab = configPage.clockTab(); + + clockTab.changeTime("5/15/2099", "10", "30", ClockTab.AmOrPmChoice.PM); + + Assert.assertTrue(basicPage.feedback().isSuccess()); + + basicPage.aboutPage(); + clockTab = basicPage.internalsConfiguration().clockTab(); + + Assert.assertEquals(clockTab.date(), "5/15/2099"); + Assert.assertEquals(clockTab.hours(), "10"); + Assert.assertEquals(clockTab.minutes(), "30"); + Assert.assertEquals(clockTab.amOrPmChoice(), ClockTab.AmOrPmChoice.PM.name()); + } + + @Test + public void resetTime() { + ClockTab clockTab = configPage.clockTab(); + + clockTab.resetTime(); + + Assert.assertTrue(basicPage.feedback().isSuccess()); + } +} diff --git a/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/component/configuration/ClockTab.java b/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/component/configuration/ClockTab.java index 3f6ee9e211c..5c1858a662a 100644 --- a/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/component/configuration/ClockTab.java +++ b/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/component/configuration/ClockTab.java @@ -6,17 +6,83 @@ */ package com.evolveum.midpoint.schrodinger.component.configuration; +import com.codeborne.selenide.Condition; import com.codeborne.selenide.SelenideElement; +import com.evolveum.midpoint.schrodinger.MidPoint; import com.evolveum.midpoint.schrodinger.component.Component; import com.evolveum.midpoint.schrodinger.page.configuration.InternalsConfigurationPage; +import com.evolveum.midpoint.schrodinger.util.Schrodinger; + +import static com.codeborne.selenide.Selenide.$; /** * Created by Viliam Repan (lazyman). */ public class ClockTab extends Component { + public enum AmOrPmChoice { + AM, PM + } + public ClockTab(InternalsConfigurationPage parent, SelenideElement parentElement) { super(parent, parentElement); } + + public void changeTime(String date, String hours, String minutes, AmOrPmChoice amOrPmChoice) { + SelenideElement dateEle = findDate(); + dateEle.click(); + dateEle.clear(); + dateEle.setValue(date); + + SelenideElement hoursEle = findHours(); + hoursEle.doubleClick(); + hoursEle.sendKeys(hours); + + SelenideElement minutesEle = findMinutes(); + minutesEle.doubleClick(); + minutesEle.sendKeys(minutes); + + SelenideElement amOrPmChoiceEle = findAmOrPmChoice(); + amOrPmChoiceEle.click(); + amOrPmChoiceEle.selectOption(amOrPmChoice.name()); + + $(Schrodinger.byDataId("save")).waitUntil(Condition.visible, MidPoint.TIMEOUT_DEFAULT_2_S).click(); + } + + public void resetTime() { + $(Schrodinger.byDataId("reset")).waitUntil(Condition.visible, MidPoint.TIMEOUT_DEFAULT_2_S).click(); + } + + public String date() { + return findDate().getValue(); + } + + public String hours() { + return findHours().getValue(); + } + + public String minutes() { + return findMinutes().getValue(); + } + + public String amOrPmChoice() { + return findAmOrPmChoice().getSelectedText(); + } + + private SelenideElement findDate() { + return $(Schrodinger.byDataId("date")).waitUntil(Condition.visible, MidPoint.TIMEOUT_DEFAULT_2_S); + } + + private SelenideElement findHours() { + return $(Schrodinger.byDataId("hours")).waitUntil(Condition.visible, MidPoint.TIMEOUT_DEFAULT_2_S); + } + + private SelenideElement findMinutes() { + return $(Schrodinger.byDataId("minutes")).waitUntil(Condition.visible, MidPoint.TIMEOUT_DEFAULT_2_S); + } + + private SelenideElement findAmOrPmChoice() { + return $(Schrodinger.byDataId("amOrPmChoice")).waitUntil(Condition.visible, MidPoint.TIMEOUT_DEFAULT_2_S); + } } diff --git a/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/page/BasicPage.java b/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/page/BasicPage.java index 40cde842f1a..353a1f485c1 100644 --- a/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/page/BasicPage.java +++ b/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/page/BasicPage.java @@ -314,7 +314,7 @@ public RoleManagementTab roleManagement() { } public InternalsConfigurationPage internalsConfiguration() { - clickConfigurationMenu("PageAdmin.menu.top.configuration.internals", null); + clickConfigurationMenu("PageAdmin.menu.top.configuration.internals", null, 1); return new InternalsConfigurationPage(); } @@ -341,7 +341,11 @@ public String getAdministrationMenuItemIconClass(String mainMenuKey, String menu } private void clickConfigurationMenu(String mainMenuKey, String menuItemKey) { - clickMenuItem("PageAdmin.menu.top.configuration", mainMenuKey, menuItemKey); + clickConfigurationMenu(mainMenuKey, menuItemKey, 0); + } + + private void clickConfigurationMenu(String mainMenuKey, String menuItemKey, int index) { + clickMenuItem("PageAdmin.menu.top.configuration", mainMenuKey, menuItemKey, index); } public FeedbackBox feedback() { @@ -350,11 +354,19 @@ public FeedbackBox feedback() { } private void clickMenuItem(String topLevelMenuKey, String mainMenuKey, String menuItemKey) { - getMenuItemElement(topLevelMenuKey, mainMenuKey, menuItemKey).click(); + clickMenuItem(topLevelMenuKey, mainMenuKey, menuItemKey, 0); } - public SelenideElement getMenuItemElement(String topLevelMenuKey, String mainMenuKey, String menuItemKey){ - SelenideElement mainMenu = getMainMenuItemElement(topLevelMenuKey, mainMenuKey); + private void clickMenuItem(String topLevelMenuKey, String mainMenuKey, String menuItemKey, int index) { + getMenuItemElement(topLevelMenuKey, mainMenuKey, menuItemKey, index).click(); + } + + public SelenideElement getMenuItemElement(String topLevelMenuKey, String mainMenuKey, String menuItemKey) { + return getMenuItemElement(topLevelMenuKey, mainMenuKey, menuItemKey, 0); + } + + public SelenideElement getMenuItemElement(String topLevelMenuKey, String mainMenuKey, String menuItemKey, int index){ + SelenideElement mainMenu = getMainMenuItemElement(topLevelMenuKey, mainMenuKey, index); if (menuItemKey == null){ return mainMenu; } @@ -375,7 +387,11 @@ public SelenideElement getMenuItemElementByMenuLabelText(String topLevelMenuKey, return menuItem; } - private SelenideElement getMainMenuItemElement(String topLevelMenuKey, String mainMenuKey){ + private SelenideElement getMainMenuItemElement(String topLevelMenuKey, String mainMenuKey) { + return getMainMenuItemElement(topLevelMenuKey, mainMenuKey, 0); + } + + private SelenideElement getMainMenuItemElement(String topLevelMenuKey, String mainMenuKey, int index){ SelenideElement topLevelMenu = $(Schrodinger.byDataResourceKey(topLevelMenuKey)); topLevelMenu.shouldBe(Condition.visible); @@ -385,7 +401,7 @@ private SelenideElement getMainMenuItemElement(String topLevelMenuKey, String ma topLevelMenuChevron.shouldHave(Condition.cssClass("fa-chevron-down")).waitUntil(Condition.cssClass("fa-chevron-down"), MidPoint.TIMEOUT_DEFAULT_2_S); } - SelenideElement mainMenu = topLevelMenu.$(Schrodinger.byDataResourceKey(mainMenuKey)); + SelenideElement mainMenu = topLevelMenu.$(Schrodinger.byDataResourceKey(mainMenuKey), index); mainMenu.shouldBe(Condition.visible); SelenideElement mainMenuLi = mainMenu.parent().parent(); diff --git a/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/page/configuration/InternalsConfigurationPage.java b/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/page/configuration/InternalsConfigurationPage.java index 593bc15a997..1984de62c66 100644 --- a/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/page/configuration/InternalsConfigurationPage.java +++ b/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/page/configuration/InternalsConfigurationPage.java @@ -6,9 +6,15 @@ */ package com.evolveum.midpoint.schrodinger.page.configuration; +import com.codeborne.selenide.Condition; import com.codeborne.selenide.SelenideElement; +import com.evolveum.midpoint.schrodinger.MidPoint; +import com.evolveum.midpoint.schrodinger.component.common.TabPanel; import com.evolveum.midpoint.schrodinger.component.configuration.*; import com.evolveum.midpoint.schrodinger.page.BasicPage; +import com.evolveum.midpoint.schrodinger.util.Schrodinger; + +import static com.codeborne.selenide.Selenide.$; /** * Created by Viliam Repan (lazyman). @@ -16,8 +22,7 @@ public class InternalsConfigurationPage extends BasicPage { public ClockTab clockTab() { - //todo implement - SelenideElement element = null; + SelenideElement element = findTabPanel().clickTab("PageInternals.tab.clock"); return new ClockTab(this, element); } @@ -44,4 +49,10 @@ public CountersTab countersTab() { SelenideElement element = null; return new CountersTab(this, element); } + + protected TabPanel findTabPanel() { + SelenideElement tabPanelElement = $(Schrodinger.byDataId("div", "tabPanel")) + .waitUntil(Condition.appear, MidPoint.TIMEOUT_DEFAULT_2_S); + return new TabPanel<>(this, tabPanelElement); + } } From 12ae77446748daede49b42f9774b3c552610db1c Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Thu, 27 Feb 2020 19:23:26 +0100 Subject: [PATCH 30/97] Revert adding default Item.add method This fixes TestArchetypes. The ultimate reason of the issue was the mess related to various add(..) methods in Item type hierarchy that lead to incorrect method being called (after creation of the default add(value) implementation). --- .../src/main/java/com/evolveum/midpoint/prism/Item.java | 4 +--- .../main/java/com/evolveum/midpoint/prism/impl/ItemImpl.java | 4 ++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/Item.java b/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/Item.java index 36bc3d9d707..4c593a51c06 100644 --- a/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/Item.java +++ b/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/Item.java @@ -282,9 +282,7 @@ default V getAnyValue() { * * @return true if this item changed as a result of the call (i.e. if the value was really added) */ - default boolean add(@NotNull V newValue) throws SchemaException { - return add(newValue, true); - } + boolean add(@NotNull V newValue) throws SchemaException; /** * Adds a given value, unless an equivalent one is already there. It is the same as calling add with checkUniqueness=true. diff --git a/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/ItemImpl.java b/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/ItemImpl.java index b8ddfd3831a..f51a392c987 100644 --- a/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/ItemImpl.java +++ b/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/ItemImpl.java @@ -457,6 +457,10 @@ public boolean addAll(Collection newValues, boolean checkUniqueness, Equivale return changed; } + public boolean add(@NotNull V newValue) throws SchemaException { + return add(newValue, true, getEqualsHashCodeStrategy()); + } + @Override public boolean add(@NotNull V newValue, @NotNull EquivalenceStrategy equivalenceStrategy) throws SchemaException { return add(newValue, true, equivalenceStrategy); From 0327196701336181409d5755c464c8e2b6a7bd98 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Thu, 27 Feb 2020 20:02:07 +0100 Subject: [PATCH 31/97] Re-add default Item.add method ...and fix MID-5002 the correct way. Also added a test related to the original scenario described in that issue to make sure it passes. --- .../midpoint/web/TestIntegrationSecurity.java | 49 ++++++++++++----- .../security/role-authorization-1.xml | 14 +++++ .../security/role-authorization-2.xml | 14 +++++ .../com/evolveum/midpoint/prism/Item.java | 4 +- .../midpoint/prism/impl/ItemImpl.java | 4 -- .../xml/ns/public/common/common-core-3.xsd | 53 ++++++++++--------- .../impl/security/GuiProfileCompiler.java | 2 +- 7 files changed, 95 insertions(+), 45 deletions(-) create mode 100644 gui/admin-gui/src/test/resources/security/role-authorization-1.xml create mode 100644 gui/admin-gui/src/test/resources/security/role-authorization-2.xml diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestIntegrationSecurity.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestIntegrationSecurity.java index 596395b8ee8..a9a65824752 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestIntegrationSecurity.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestIntegrationSecurity.java @@ -14,6 +14,7 @@ import java.util.ArrayList; import java.util.Collection; +import com.evolveum.midpoint.test.TestResource; import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType; import org.springframework.beans.factory.annotation.Autowired; @@ -52,16 +53,19 @@ @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public class TestIntegrationSecurity extends AbstractInitializedGuiIntegrationTest { - public static final File TEST_DIR = new File("src/test/resources/security"); + private static final File TEST_DIR = new File("src/test/resources/security"); - protected static final File ROLE_UI_ALLOW_ALL_FILE = new File(TEST_DIR, "role-ui-allow-all.xml"); - protected static final String ROLE_UI_ALLOW_ALL_OID = "d8f78cfe-d05d-11e7-8ee6-038ce21862f3"; + private static final File ROLE_UI_ALLOW_ALL_FILE = new File(TEST_DIR, "role-ui-allow-all.xml"); + private static final String ROLE_UI_ALLOW_ALL_OID = "d8f78cfe-d05d-11e7-8ee6-038ce21862f3"; - protected static final File ROLE_UI_DENY_ALL_FILE = new File(TEST_DIR, "role-ui-deny-all.xml"); - protected static final String ROLE_UI_DENY_ALL_OID = "c4a5923c-d02b-11e7-9ac5-13b0d906fa81"; + private static final File ROLE_UI_DENY_ALL_FILE = new File(TEST_DIR, "role-ui-deny-all.xml"); + private static final String ROLE_UI_DENY_ALL_OID = "c4a5923c-d02b-11e7-9ac5-13b0d906fa81"; - protected static final File ROLE_UI_DENY_ALLOW_FILE = new File(TEST_DIR, "role-ui-deny-allow.xml"); - protected static final String ROLE_UI_DENY_ALLOW_OID = "da47fcf6-d02b-11e7-9e78-f31ae9aa0674"; + private static final File ROLE_UI_DENY_ALLOW_FILE = new File(TEST_DIR, "role-ui-deny-allow.xml"); + private static final String ROLE_UI_DENY_ALLOW_OID = "da47fcf6-d02b-11e7-9e78-f31ae9aa0674"; + + private static final TestResource ROLE_AUTHORIZATION_1 = new TestResource(TEST_DIR, "role-authorization-1.xml", "97984277-e809-4a86-ae9b-d5c40e09df0b"); + private static final TestResource ROLE_AUTHORIZATION_2 = new TestResource(TEST_DIR, "role-authorization-2.xml", "96b02d58-5147-4f5a-852c-0f415230ce2c"); private static final Trace LOGGER = TraceManager.getTrace(TestIntegrationSecurity.class); @@ -78,12 +82,8 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti repoAddObjectFromFile(ROLE_UI_ALLOW_ALL_FILE, initResult); repoAddObjectFromFile(ROLE_UI_DENY_ALL_FILE, initResult); repoAddObjectFromFile(ROLE_UI_DENY_ALLOW_FILE, initResult); - - // Temporary ... until initial object load is fixed -// ch.qos.logback.classic.Logger l = (ch.qos.logback.classic.Logger)org.slf4j.LoggerFactory.getLogger("com.evolveum.midpoint.web"); -// l.setLevel(ch.qos.logback.classic.Level.TRACE); -// l = (ch.qos.logback.classic.Logger)org.slf4j.LoggerFactory.getLogger("com.evolveum.midpoint.test"); -// l.setLevel(ch.qos.logback.classic.Level.TRACE); + repoAdd(ROLE_AUTHORIZATION_1, initResult); + repoAdd(ROLE_AUTHORIZATION_2, initResult); } @@ -205,6 +205,29 @@ public void test200DecideRoleUiDenyAllow() throws Exception { } + /** + * MID-5002 + */ + @Test + public void test300ConflictingAuthorizationIds() throws Exception { + final String TEST_NAME = "test300ConflictingAuthorizationIds"; + displayTestTitle(TEST_NAME); + // GIVEN + cleanupAutzTest(USER_JACK_OID); + assignRole(USER_JACK_OID, ROLE_AUTHORIZATION_1.oid); + assignRole(USER_JACK_OID, ROLE_AUTHORIZATION_2.oid); + PrismObject user = getUser(USER_JACK_OID); + display("user before", user); + + // WHEN + displayWhen(TEST_NAME); + login(USER_JACK_USERNAME); + + // THEN + displayThen(TEST_NAME); + assertLoggedInUsername(USER_JACK_USERNAME); + } + private void assertAllow(Authentication authentication, String path) { try { LOGGER.debug("*** Attempt to DECIDE {} (expected allow)", path); diff --git a/gui/admin-gui/src/test/resources/security/role-authorization-1.xml b/gui/admin-gui/src/test/resources/security/role-authorization-1.xml new file mode 100644 index 00000000000..de44ca0b8dc --- /dev/null +++ b/gui/admin-gui/src/test/resources/security/role-authorization-1.xml @@ -0,0 +1,14 @@ + + + + + UI Authorization 1 + + http://midpoint.evolveum.com/xml/ns/public/security/authorization-model-3#read + + diff --git a/gui/admin-gui/src/test/resources/security/role-authorization-2.xml b/gui/admin-gui/src/test/resources/security/role-authorization-2.xml new file mode 100644 index 00000000000..2438e378967 --- /dev/null +++ b/gui/admin-gui/src/test/resources/security/role-authorization-2.xml @@ -0,0 +1,14 @@ + + + + + UI Authorization 2 + + http://midpoint.evolveum.com/xml/ns/public/security/authorization-model-3#modify + + diff --git a/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/Item.java b/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/Item.java index 4c593a51c06..36bc3d9d707 100644 --- a/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/Item.java +++ b/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/Item.java @@ -282,7 +282,9 @@ default V getAnyValue() { * * @return true if this item changed as a result of the call (i.e. if the value was really added) */ - boolean add(@NotNull V newValue) throws SchemaException; + default boolean add(@NotNull V newValue) throws SchemaException { + return add(newValue, true); + } /** * Adds a given value, unless an equivalent one is already there. It is the same as calling add with checkUniqueness=true. diff --git a/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/ItemImpl.java b/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/ItemImpl.java index f51a392c987..b8ddfd3831a 100644 --- a/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/ItemImpl.java +++ b/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/ItemImpl.java @@ -457,10 +457,6 @@ public boolean addAll(Collection newValues, boolean checkUniqueness, Equivale return changed; } - public boolean add(@NotNull V newValue) throws SchemaException { - return add(newValue, true, getEqualsHashCodeStrategy()); - } - @Override public boolean add(@NotNull V newValue, @NotNull EquivalenceStrategy equivalenceStrategy) throws SchemaException { return add(newValue, true, equivalenceStrategy); diff --git a/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd b/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd index c545ac76e0e..555cf1d4fae 100755 --- a/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd +++ b/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd @@ -24193,32 +24193,33 @@ 3.7 - - - - - AbstractObjectTypeConfigurationType.type - - - - - - -

- Definition of object with respect to subject relation to a role. - Used to specify role approvers, owners and so on. -

-

- EXPERIMENTAL. Use at your own risk. -

-
- - 3.9 - -
-
- -
+ + + + + AbstractObjectTypeConfigurationType.type + + + + + + +

+ Definition of object with respect to subject relation to a role. + Used to specify role approvers, owners and so on. +

+

+ EXPERIMENTAL. Use at your own risk. +

+
+ + 3.9 + +
+
+ +
+ diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/security/GuiProfileCompiler.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/security/GuiProfileCompiler.java index 00ffa05c566..227106b5e92 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/security/GuiProfileCompiler.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/security/GuiProfileCompiler.java @@ -449,7 +449,7 @@ private void compileSearchBox(CompiledObjectCollectionView existingView, GuiObje private void joinForms(ObjectFormsType objectForms, ObjectFormType newForm) { objectForms.getObjectForm().removeIf(currentForm -> isTheSameObjectForm(currentForm, newForm)); - objectForms.getObjectForm().add(newForm.clone()); + objectForms.getObjectForm().add(newForm.clone().id(null)); } private void joinObjectDetails(GuiObjectDetailsSetType objectDetailsSet, GuiObjectDetailsPageType newObjectDetails) { From 82af2fde0d2a1b4eb6d06cb16dbf218c82d062da Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Thu, 27 Feb 2020 23:03:52 +0100 Subject: [PATCH 32/97] AbstractIntegrationTest: logger as instance field (uses getClass()) --- .../test/AbstractIntegrationTest.java | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) 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 cb91045c2b8..4dfee58dd10 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 @@ -131,7 +131,10 @@ public abstract class AbstractIntegrationTest extends AbstractTestNGSpringContex protected static final String OPENDJ_PEOPLE_SUFFIX = "ou=people,dc=example,dc=com"; protected static final String OPENDJ_GROUPS_SUFFIX = "ou=groups,dc=example,dc=com"; - private static final Trace LOGGER = TraceManager.getTrace(AbstractIntegrationTest.class); + /** + * Hides parent's logger, but that one is from commons-logging and we don't want that. + */ + protected final Trace logger = TraceManager.getTrace(getClass()); protected static final Random RND = new Random(); @@ -190,7 +193,7 @@ public abstract class AbstractIntegrationTest extends AbstractTestNGSpringContex */ @PostConstruct public void initSystemConditional() throws Exception { - LOGGER.trace("initSystemConditional: initializing class {}", getClass().getName()); + logger.trace("initSystemConditional: initializing class {}", getClass().getName()); // Check whether we are already initialized assertNotNull("Repository is not wired properly", repositoryService); @@ -387,7 +390,7 @@ protected PrismObject repoAddObjectFromFile( OperationResult result = parentResult.createSubresult(AbstractIntegrationTest.class.getName() + ".repoAddObjectFromFile"); result.addParam("file", file.getPath()); - LOGGER.debug("addObjectFromFile: {}", file); + logger.debug("addObjectFromFile: {}", file); PrismObject object; try { object = prismContext.parseObject(file); @@ -399,7 +402,7 @@ protected PrismObject repoAddObjectFromFile( addBasicMetadata(object); } - LOGGER.trace("Adding object:\n{}", object.debugDump()); + logger.trace("Adding object:\n{}", object.debugDump()); repoAddObject(object, "from file " + file, result); result.recordSuccess(); return object; @@ -411,7 +414,7 @@ protected PrismObject repoAddShadowFromFile(File file, OperationResu OperationResult result = parentResult.createSubresult(AbstractIntegrationTest.class.getName() + ".repoAddShadowFromFile"); result.addParam("file", file.getPath()); - LOGGER.debug("addShadowFromFile: {}", file); + logger.debug("addShadowFromFile: {}", file); PrismObject object = prismContext.parseObject(file); PrismContainer attrCont = object.findContainer(ShadowType.F_ATTRIBUTES); @@ -425,7 +428,7 @@ protected PrismObject repoAddShadowFromFile(File file, OperationResu addBasicMetadata(object); - LOGGER.trace("Adding object:\n{}", object.debugDump()); + logger.trace("Adding object:\n{}", object.debugDump()); repoAddObject(object, "from file " + file, result); result.recordSuccess(); return object; @@ -482,7 +485,7 @@ protected List> repoAddObjectsFromFile( OperationResult result = parentResult.createSubresult(AbstractIntegrationTest.class.getName() + ".addObjectsFromFile"); result.addParam("file", file.getPath()); - LOGGER.trace("addObjectsFromFile: {}", file); + logger.trace("addObjectsFromFile: {}", file); List> objects = (List) prismContext.parserFor(file).parseObjects(); for (PrismObject object : objects) { try { @@ -506,7 +509,7 @@ protected List repoAddObjectsFromFile(File file, OperationResult pa OperationResult result = parentResult.createSubresult( AbstractIntegrationTest.class.getName() + ".addObjectsFromFile"); result.addParam("file", file.getPath()); - LOGGER.trace("addObjectsFromFile: {}", file); + logger.trace("addObjectsFromFile: {}", file); List objects = (List) prismContext.parserFor(file).parseObjects(); for (PrismObject object : objects) { try { @@ -564,7 +567,7 @@ protected PrismObject addResourceFromFile(File file, String connec protected PrismObject addResourceFromFile(File file, List connectorTypes, boolean overwrite, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, EncryptionException, IOException { - LOGGER.trace("addObjectFromFile: {}, connector types {}", file, connectorTypes); + logger.trace("addObjectFromFile: {}, connector types {}", file, connectorTypes); PrismObject resource = prismContext.parseObject(file); return addResourceFromObject(resource, connectorTypes, overwrite, result); } @@ -1647,15 +1650,15 @@ protected void logTrustManagers() throws NoSuchAlgorithmException, KeyStoreExcep for (TrustManager trustManager : trustManagerFactory.getTrustManagers()) { if (trustManager instanceof X509TrustManager) { X509TrustManager x509TrustManager = (X509TrustManager) trustManager; - LOGGER.debug("TrustManager(X509): {}", x509TrustManager); + logger.debug("TrustManager(X509): {}", x509TrustManager); X509Certificate[] acceptedIssuers = x509TrustManager.getAcceptedIssuers(); if (acceptedIssuers != null) { for (X509Certificate acceptedIssuer : acceptedIssuers) { - LOGGER.debug(" acceptedIssuer: {}", acceptedIssuer); + logger.debug(" acceptedIssuer: {}", acceptedIssuer); } } } else { - LOGGER.debug("TrustManager: {}", trustManager); + logger.debug("TrustManager: {}", trustManager); } } } @@ -2391,7 +2394,7 @@ protected void generateObjects(Class type, int numberO if (mutator != null) { mutator.accept(objectType, i); } - LOGGER.info("Adding {}:\n{}", object, object.debugDump(1)); + logger.info("Adding {}:\n{}", object, object.debugDump(1)); adder.process(object); } @@ -2617,9 +2620,9 @@ protected PrismObject getShadowRepo(String shadowOid) throws ObjectN OperationResult result = new OperationResult("getShadowRepo"); // We need to read the shadow as raw, so repo will look for some kind of rudimentary attribute // definitions here. Otherwise we will end up with raw values for non-indexed (cached) attributes - LOGGER.info("Getting repo shadow {}", shadowOid); + logger.info("Getting repo shadow {}", shadowOid); PrismObject shadow = repositoryService.getObject(ShadowType.class, shadowOid, GetOperationOptions.createRawCollection(), result); - LOGGER.info("Got repo shadow\n{}", shadow.debugDumpLazily(1)); + logger.info("Got repo shadow\n{}", shadow.debugDumpLazily(1)); assertSuccess(result); return shadow; } From 7c1e252951659a87c4a7fb9f21fad5b8a7be4c31 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Thu, 27 Feb 2020 23:06:24 +0100 Subject: [PATCH 33/97] AbstractIntegrationTest: reintroduced createTask + customizeTask fix customizeTask was prepared, but it was missing in startTestContext --- .../midpoint/test/AbstractIntegrationTest.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) 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 4dfee58dd10..302e026abf7 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 @@ -200,7 +200,7 @@ public void initSystemConditional() throws Exception { assertNotNull("Task manager is not wired properly", taskManager); PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); PrismTestUtil.setPrismContext(prismContext); - Task initTask = taskManager.createTaskInstance(getClass().getName() + ".initSystem"); + Task initTask = createTask(getClass().getName() + ".initSystem"); initTask.setChannel(SchemaConstants.CHANNEL_GUI_INIT_URI); OperationResult result = initTask.getResult(); @@ -244,7 +244,8 @@ public void startTestContext(ITestResult testResult) { TestUtil.displayTestTitle(testClass.getSimpleName() + "." + testMethodName); - Task task = taskManager.createTaskInstance(testClass.getName() + "." + testMethodName); + Task task = createTask(testClass.getName() + "." + testMethodName); + customizeTask(task); // TODO do we need that subresult? :-) (Virgo's brave new world) // maybe it doesn't break tests, but changes traceability/maintenance? // OperationResult rootResult = task.getResult(); @@ -336,6 +337,17 @@ protected String getTestNameShort() { return MidpointTestMethodContext.get().getTestNameShort(); } + /** + * Creates the new {@link Task}. + * For most tests this should be unnecessary and the default test-method-scoped task + * that can be obtained with {@link #getTestTask()} should be enough. + * Even for multi-threaded tests we may not need a new task and new subresult + * (using {@link #createSubresult(String)} should suffice. + */ + protected Task createTask(String operationName) { + return taskManager.createTaskInstance(operationName); + } + /** * Creates new subresult for default pre-created test-method-scoped {@link Task}. */ From f09a7fae4e4c69b619c596b402387f30fb04bef8 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Thu, 27 Feb 2020 23:09:38 +0100 Subject: [PATCH 34/97] AbstractIntegrationTest: added explicit util displayExpectedException() Compared to display(String, e) it does NOT scare with the stack trace. --- .../midpoint/test/AbstractIntegrationTest.java | 4 ++++ .../evolveum/midpoint/test/IntegrationTestTools.java | 12 ++++++++++++ 2 files changed, 16 insertions(+) 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 302e026abf7..c5efd9a2ca0 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 @@ -1868,6 +1868,10 @@ public static void display(String title, Throwable e) { IntegrationTestTools.display(title, e); } + public static void displayExpectedException(Throwable e) { + IntegrationTestTools.displayExpectedException(e); + } + public static void displayPrismValuesCollection(String message, Collection collection) { IntegrationTestTools.displayPrismValuesCollection(message, collection); } diff --git a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/IntegrationTestTools.java b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/IntegrationTestTools.java index 32d4a77e23e..717a5755c3a 100644 --- a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/IntegrationTestTools.java +++ b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/IntegrationTestTools.java @@ -531,6 +531,10 @@ public static void display(String title, Containerable value) { } } + /** + * Displays throwable with title including full stacktrace. + * Use for "bad" exceptions, for expected exceptions use {@link #displayExpectedException}. + */ public static void display(String title, Throwable e) { String stackTrace = ExceptionUtils.getStackTrace(e); println(OBJECT_TITLE_OUT_PREFIX + title + ": "+e.getClass() + " " + e.getMessage()); @@ -538,6 +542,14 @@ public static void display(String title, Throwable e) { LOGGER.debug("{}{}: {} {}\n{}", OBJECT_TITLE_LOG_PREFIX, title, e.getClass(), e.getMessage(), stackTrace); } + /** + * Displays expected exception without stacktrace (seeing it is rather confusing/disturbing). + */ + public static void displayExpectedException(Throwable e) { + println(OBJECT_TITLE_OUT_PREFIX + "Expected exception: " + e.getClass() + " " + e.getMessage()); + LOGGER.debug("{}Expected exception: {} {}", OBJECT_TITLE_LOG_PREFIX, e.getClass(), e.getMessage()); + } + public static void displayPrismValuesCollection(String message, Collection collection) { println(OBJECT_TITLE_OUT_PREFIX + message); LOGGER.debug(OBJECT_TITLE_LOG_PREFIX + message); From 10da159edf57f1fb8cfff71f0a8905bf01e25567 Mon Sep 17 00:00:00 2001 From: kate Date: Fri, 28 Feb 2020 00:02:53 +0100 Subject: [PATCH 35/97] operational buttons to clean up task results and env. performance --- .../midpoint/gui/api/GuiStyleConstants.java | 2 + .../web/page/admin/server/PageTask.java | 81 ++++++++++++++++++- 2 files changed, 82 insertions(+), 1 deletion(-) diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/GuiStyleConstants.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/GuiStyleConstants.java index 140ff62ead3..89e93703589 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/GuiStyleConstants.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/GuiStyleConstants.java @@ -217,5 +217,7 @@ public class GuiStyleConstants { public static final String CLASS_ICON_CLAIM = "fa fa-paper-plane-o"; public static final String CLASS_ICON_TEXT = "fa fa-text-width"; + public static final String CLASS_ICON_TRASH = "fa fa-trash-o"; + } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTask.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTask.java index 4612e0d10b8..6bcfacc066e 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTask.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTask.java @@ -1,21 +1,25 @@ package com.evolveum.midpoint.web.page.admin.server; +import com.evolveum.midpoint.gui.api.GuiStyleConstants; import com.evolveum.midpoint.gui.api.model.LoadableModel; import com.evolveum.midpoint.gui.api.prism.ItemWrapper; import com.evolveum.midpoint.gui.api.prism.PrismContainerWrapper; import com.evolveum.midpoint.gui.api.prism.PrismObjectWrapper; +import com.evolveum.midpoint.gui.api.util.WebComponentUtil; import com.evolveum.midpoint.gui.impl.prism.ItemEditabilityHandler; import com.evolveum.midpoint.gui.impl.prism.ItemPanelSettingsBuilder; import com.evolveum.midpoint.gui.impl.prism.ItemVisibilityHandler; import com.evolveum.midpoint.model.api.ModelAuthorizationAction; import com.evolveum.midpoint.prism.Containerable; import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.schema.GetOperationOptions; import com.evolveum.midpoint.schema.SelectorOptions; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.security.api.AuthorizationConstants; +import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.task.api.TaskCategory; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.util.logging.Trace; @@ -33,6 +37,7 @@ import com.evolveum.midpoint.web.page.admin.server.dto.TaskDtoExecutionStatus; import com.evolveum.midpoint.web.util.OnePageParameterEncoder; import com.evolveum.midpoint.web.util.TaskOperationUtils; +import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationStatsType; import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskExecutionStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskRecurrenceType; import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType; @@ -74,6 +79,8 @@ public class PageTask extends PageAdminObjectDetails implements Refres private static final long serialVersionUID = 1L; private static final transient Trace LOGGER = TraceManager.getTrace(PageTask.class); + private static final String DOT_CLASS = PageTask.class.getName() + "."; + protected static final String OPERATION_EXECUTE_TASK_CHANGES = DOT_CLASS + "executeTaskChanges"; private static final int REFRESH_INTERVAL_IF_RUNNING = 2000; private static final int REFRESH_INTERVAL_IF_RUNNABLE = 2000; @@ -204,8 +211,57 @@ public void onClick(AjaxRequestTarget target) { resumePauseRefreshing.add(AttributeAppender.append("class", "btn btn-default btn-margin-left btn-sm")); repeatingView.add(resumePauseRefreshing); - setOutputMarkupId(true); + AjaxIconButton cleanupPerformance = new AjaxIconButton(repeatingView.newChildId(), new Model<>(GuiStyleConstants.CLASS_ICON_TRASH), + createStringResource("operationalButtonsPanel.cleanupEnvironmentalPerformance")) { + + @Override + public void onClick(AjaxRequestTarget target) { + try { + getObjectWrapper().findProperty(ItemPath.create(TaskType.F_OPERATION_STATS, + OperationStatsType.F_ENVIRONMENTAL_PERFORMANCE_INFORMATION)).getValue().setRealValue(null); + } catch (SchemaException e){ + LOGGER.error("Cannot clear task results: {}", e.getMessage()); + } + saveTaskChanges(); + refresh(target); + } + }; + cleanupPerformance.add(AttributeAppender.append("class", "btn btn-default btn-margin-left btn-sm")); + cleanupPerformance.add(new VisibleBehaviour(this::isNotRunning)); + repeatingView.add(cleanupPerformance); + + AjaxIconButton cleanupResults = new AjaxIconButton(repeatingView.newChildId(), new Model<>(GuiStyleConstants.CLASS_ICON_TRASH), + createStringResource("operationalButtonsPanel.cleanupResults")) { + + @Override + public void onClick(AjaxRequestTarget target) { + try { + getObjectWrapper().findProperty(TaskType.F_RESULT).getValue().setRealValue(null); + getObjectWrapper().findProperty(TaskType.F_RESULT_STATUS).getValue().setRealValue(null); + } catch (SchemaException e){ + LOGGER.error("Cannot clear task results: {}", e.getMessage()); + } + saveTaskChanges(); + refresh(target); + } + }; + cleanupResults.add(new VisibleBehaviour(this::isNotRunning)); + cleanupResults.add(AttributeAppender.append("class", "btn btn-default btn-margin-left btn-sm")); + repeatingView.add(cleanupResults); + +// AjaxIconButton cleanupErrors = new AjaxIconButton(repeatingView.newChildId(), new Model<>(GuiStyleConstants.CLASS_ICON_TRASH), +// createStringResource("operationalButtonsPanel.cleanupErrors")) { +// +// @Override +// public void onClick(AjaxRequestTarget target) { +// refresh(target); +// } +// }; +// cleanupErrors.add(AttributeAppender.append("class", "btn btn-default btn-margin-left btn-sm")); +// cleanupErrors.add(new VisibleBehaviour(this::isNotRunning)); +// repeatingView.add(cleanupErrors); + setOutputMarkupId(true); final Label status = new Label(repeatingView.newChildId(), () -> createRefreshingLabel()); status.setOutputMarkupId(true); @@ -213,6 +269,22 @@ public void onClick(AjaxRequestTarget target) { } + private void saveTaskChanges(){ + OperationResult result = new OperationResult(OPERATION_EXECUTE_TASK_CHANGES); + Task task = createSimpleTask(OPERATION_EXECUTE_TASK_CHANGES); + try { + ObjectDelta taskDelta = getObjectWrapper().getObjectDelta(); + if (!taskDelta.isEmpty()) { + taskDelta.revive(getPrismContext()); + getModelService().executeChanges(WebComponentUtil.createDeltaCollection(taskDelta), null, task, result); + result.computeStatus(); + getObjectModel().reset(); + } + } catch (Exception e) { + LOGGER.error("Cannot save tasks changes: {}", e.getMessage()); + } + showResult(result); + } private String createRefreshingLabel() { if (isRefreshEnabled()) { @@ -264,6 +336,10 @@ private boolean isRunning() { return taskType.getNodeAsObserved() != null; } + private boolean isNotRunning(){ + return !isRunning(); + } + private boolean isSuspended(TaskType task) { return TaskExecutionStatusType.SUSPENDED == task.getExecutionStatus(); } @@ -280,6 +356,9 @@ private boolean isWorkflow(TaskType task) { return TaskCategory.WORKFLOW.equals(task.getCategory()); } + private TaskType getTask(){ + return getObjectWrapper().getObject().asObjectable(); + } private IModel createSummaryPanelModel() { return isEditingFocus() ? From 556d6b04b9991f2618e4836477ccf2855f115016 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Fri, 28 Feb 2020 00:03:52 +0100 Subject: [PATCH 36/97] IntegrationTestTools.java: code cleanup, better asserts, reformat --- .../midpoint/test/IntegrationTestTools.java | 428 +++++++++--------- 1 file changed, 216 insertions(+), 212 deletions(-) diff --git a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/IntegrationTestTools.java b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/IntegrationTestTools.java index 717a5755c3a..55e39b0dce6 100644 --- a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/IntegrationTestTools.java +++ b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/IntegrationTestTools.java @@ -6,6 +6,22 @@ */ package com.evolveum.midpoint.test; +import static org.testng.AssertJUnit.*; + +import java.io.IOException; +import java.io.RandomAccessFile; +import java.util.*; +import java.util.stream.Collectors; +import javax.xml.namespace.QName; + +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.exception.ExceptionUtils; +import org.opends.server.types.Entry; +import org.opends.server.types.SearchResultEntry; +import org.testng.AssertJUnit; +import org.w3c.dom.Element; + import com.evolveum.icf.dummy.resource.DummyGroup; import com.evolveum.icf.dummy.resource.ScriptHistoryEntry; import com.evolveum.midpoint.common.refinery.RefinedResourceSchema; @@ -14,13 +30,13 @@ import com.evolveum.midpoint.prism.crypto.EncryptionException; import com.evolveum.midpoint.prism.crypto.Protector; import com.evolveum.midpoint.prism.delta.ObjectDelta; +import com.evolveum.midpoint.prism.impl.schema.PrismSchemaImpl; import com.evolveum.midpoint.prism.match.MatchingRule; import com.evolveum.midpoint.prism.path.ItemName; import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.prism.schema.PrismSchema; -import com.evolveum.midpoint.prism.impl.schema.PrismSchemaImpl; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.prism.util.PrismUtil; @@ -30,56 +46,26 @@ import com.evolveum.midpoint.schema.SearchResultList; import com.evolveum.midpoint.schema.constants.ConnectorTestOperation; import com.evolveum.midpoint.schema.constants.SchemaConstants; -import com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition; -import com.evolveum.midpoint.schema.processor.ResourceAttribute; -import com.evolveum.midpoint.schema.processor.ResourceAttributeContainer; -import com.evolveum.midpoint.schema.processor.ResourceAttributeContainerDefinition; -import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition; -import com.evolveum.midpoint.schema.processor.ResourceSchema; +import com.evolveum.midpoint.schema.processor.*; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.result.OperationResultStatus; -import com.evolveum.midpoint.schema.util.ConnectorTypeUtil; -import com.evolveum.midpoint.schema.util.ObjectTypeUtil; -import com.evolveum.midpoint.schema.util.ShadowUtil; -import com.evolveum.midpoint.schema.util.ResourceTypeUtil; -import com.evolveum.midpoint.schema.util.SchemaDebugUtil; -import com.evolveum.midpoint.schema.util.SchemaTestConstants; +import com.evolveum.midpoint.schema.util.*; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.DebugDumpable; import com.evolveum.midpoint.util.DebugUtil; -import com.evolveum.midpoint.util.exception.*; +import com.evolveum.midpoint.util.exception.CommonException; +import com.evolveum.midpoint.util.exception.SchemaException; +import com.evolveum.midpoint.util.exception.SystemException; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.exception.ExceptionUtils; -import org.opends.server.types.Entry; -import org.opends.server.types.SearchResultEntry; -import org.testng.AssertJUnit; -import org.w3c.dom.Element; - -import javax.xml.namespace.QName; - -import java.io.IOException; -import java.io.RandomAccessFile; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.stream.Collectors; - -import static org.testng.AssertJUnit.*; - /** * @author Radovan Semancik - * */ public class IntegrationTestTools { @@ -95,7 +81,7 @@ public class IntegrationTestTools { public static final String LDAP_CONNECTOR_TYPE = "com.evolveum.polygon.connector.ldap.LdapConnector"; public static final String NS_RESOURCE_DUMMY_CONFIGURATION = "http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/com.evolveum.icf.dummy/com.evolveum.icf.dummy.connector.DummyConnector"; - public static final QName RESOURCE_DUMMY_CONFIGURATION_USELESS_STRING_ELEMENT_NAME = new QName(NS_RESOURCE_DUMMY_CONFIGURATION ,"uselessString"); + public static final QName RESOURCE_DUMMY_CONFIGURATION_USELESS_STRING_ELEMENT_NAME = new QName(NS_RESOURCE_DUMMY_CONFIGURATION, "uselessString"); // public and not final - to allow changing it in tests public static final Trace LOGGER = TraceManager.getTrace(IntegrationTestTools.class); @@ -120,20 +106,20 @@ private static List getConnectorSubresults(OperationResult test public static void assertTestResourceSuccess(OperationResult testResult, ConnectorTestOperation operation) { OperationResult opResult = testResult.findSubresult(operation.getOperation()); - assertNotNull("No result for "+operation, opResult); - TestUtil.assertSuccess("Test resource failed (result): "+operation, opResult, 1); + assertNotNull("No result for " + operation, opResult); + TestUtil.assertSuccess("Test resource failed (result): " + operation, opResult, 1); } public static void assertTestResourceFailure(OperationResult testResult, ConnectorTestOperation operation) { OperationResult opResult = testResult.findSubresult(operation.getOperation()); - assertNotNull("No result for "+operation, opResult); - TestUtil.assertFailure("Test resource succeeded while expected failure (result): "+operation, opResult); + assertNotNull("No result for " + operation, opResult); + TestUtil.assertFailure("Test resource succeeded while expected failure (result): " + operation, opResult); } public static void assertTestResourceNotApplicable(OperationResult testResult, ConnectorTestOperation operation) { OperationResult opResult = testResult.findSubresult(operation.getOperation()); - assertNotNull("No result for "+operation, opResult); - assertEquals("Test resource status is not 'not applicable', it is "+opResult.getStatus()+": "+operation, + assertNotNull("No result for " + operation, opResult); + assertEquals("Test resource status is not 'not applicable', it is " + opResult.getStatus() + ": " + operation, OperationResultStatus.NOT_APPLICABLE, opResult.getStatus()); } @@ -169,8 +155,8 @@ public static void assertNotEmpty(String s) { public static void assertNotEmpty(String message, QName qname) { assertNotNull(message, qname); - assertNotEmpty(message,qname.getNamespaceURI()); - assertNotEmpty(message,qname.getLocalPart()); + assertNotEmpty(message, qname.getNamespaceURI()); + assertNotEmpty(message, qname.getLocalPart()); } public static void assertNotEmpty(QName qname) { @@ -179,57 +165,68 @@ public static void assertNotEmpty(QName qname) { assertNotEmpty(qname.getLocalPart()); } - public static void assertAttribute(ShadowType shadow, ResourceType resource, String name, - T... expectedValues) { - assertAttribute("Wrong attribute " + name + " in "+shadow, shadow, + @SafeVarargs + public static void assertAttribute( + ShadowType shadow, ResourceType resource, String name, T... expectedValues) { + assertAttribute("Wrong attribute " + name + " in " + shadow, shadow, new QName(ResourceTypeUtil.getResourceNamespace(resource), name), expectedValues); } - public static void assertAttribute(PrismObject shadow, ResourceType resource, String name, - T... expectedValues) { - assertAttribute("Wrong attribute " + name + " in "+shadow, shadow, + @SafeVarargs + public static void assertAttribute(PrismObject shadow, + ResourceType resource, String name, T... expectedValues) { + assertAttribute("Wrong attribute " + name + " in " + shadow, shadow, new QName(ResourceTypeUtil.getResourceNamespace(resource), name), expectedValues); } + @SafeVarargs public static void assertAttribute(ShadowType shadowType, QName name, T... expectedValues) { assertAttribute(shadowType.asPrismObject(), name, expectedValues); } - public static void assertAttribute(PrismObject shadow, QName name, T... expectedValues) { + @SafeVarargs + public static void assertAttribute( + PrismObject shadow, QName name, T... expectedValues) { Collection values = getAttributeValues(shadow, name); - assertEqualsCollection("Wrong value for attribute "+name+" in "+shadow, expectedValues, values); + assertEqualsCollection("Wrong value for attribute " + name + " in " + shadow, expectedValues, values); } - public static void assertAttribute(String message, ShadowType repoShadow, QName name, T... expectedValues) { + @SafeVarargs + public static void assertAttribute( + String message, ShadowType repoShadow, QName name, T... expectedValues) { Collection values = getAttributeValues(repoShadow, name); assertEqualsCollection(message, expectedValues, values); } - public static void assertAttribute(String message, PrismObject repoShadow, QName name, T... expectedValues) { + @SafeVarargs + public static void assertAttribute(String message, + PrismObject repoShadow, QName name, T... expectedValues) { Collection values = getAttributeValues(repoShadow, name); assertEqualsCollection(message, expectedValues, values); } - public static void assertNoAttribute(PrismObject shadow, QName name) { - assertNull("Found attribute "+name+" in "+shadow+" while not expecting it", getAttributeValues(shadow, name)); + public static void assertNoAttribute(PrismObject shadow, QName name) { + assertNull("Found attribute " + name + " in " + shadow + " while not expecting it", getAttributeValues(shadow, name)); } public static void assertEqualsCollection(String message, Collection expectedValues, Collection actualValues) { if (expectedValues == null && actualValues == null) { return; } - assert !(expectedValues == null && actualValues != null) : "Expecting null values but got "+actualValues; - assert actualValues != null : message+": Expecting "+expectedValues+" but got null"; - assertEquals(message+": Wrong number of values in " + actualValues, expectedValues.size(), actualValues.size()); - for (T actualValue: actualValues) { + + assert !(expectedValues == null) : "Expecting null values but got " + actualValues; + assert actualValues != null : message + ": Expecting " + expectedValues + " but got null"; + assertEquals(message + ": Wrong number of values in " + actualValues, expectedValues.size(), actualValues.size()); + for (T actualValue : actualValues) { boolean found = false; - for (T value: expectedValues) { + for (T value : expectedValues) { if (value.equals(actualValue)) { found = true; + break; } } if (!found) { - fail(message + ": Unexpected value "+actualValue+"; expected "+expectedValues+"; has "+actualValues); + fail(message + ": Unexpected value " + actualValue + "; expected " + expectedValues + "; has " + actualValues); } } } @@ -256,13 +253,13 @@ public static String getSecondaryIdentifier(PrismObject shadow) { return null; } if (secondaryIdentifiers.size() > 1) { - throw new IllegalArgumentException("Too many secondary indentifiers in "+shadow); + throw new IllegalArgumentException("Too many secondary indentifiers in " + shadow); } return (String) secondaryIdentifiers.iterator().next().getRealValue(); } public static void assertSecondaryIdentifier(PrismObject repoShadow, String value) { - assertEquals("Wrong secondary indetifier in "+repoShadow, value, getSecondaryIdentifier(repoShadow)); + assertEquals("Wrong secondary indetifier in " + repoShadow, value, getSecondaryIdentifier(repoShadow)); } public static void assertIcfsNameAttribute(ShadowType repoShadow, String value) { @@ -275,21 +272,21 @@ public static void assertIcfsNameAttribute(PrismObject repoShadow, S public static void assertAttributeNotNull(PrismObject repoShadow, QName name) { Collection values = getAttributeValues(repoShadow, name); - assertFalse("No values for "+name+" in "+repoShadow, values == null || values.isEmpty()); + assertFalse("No values for " + name + " in " + repoShadow, values == null || values.isEmpty()); assertEquals(1, values.size()); assertNotNull(values.iterator().next()); } public static void assertAttributeNotNull(ShadowType repoShadow, QName name) { Collection values = getAttributeValues(repoShadow, name); - assertFalse("No values for "+name+" in "+repoShadow, values == null || values.isEmpty()); + assertFalse("No values for " + name + " in " + repoShadow, values == null || values.isEmpty()); assertEquals(1, values.size()); assertNotNull(values.iterator().next()); } public static void assertAttributeNotNull(String message, ShadowType repoShadow, QName name) { Collection values = getAttributeValues(repoShadow, name); - assertFalse("No values for "+name+" in "+repoShadow, values == null || values.isEmpty()); + assertFalse("No values for " + name + " in " + repoShadow, values == null || values.isEmpty()); assertEquals(message, 1, values.size()); assertNotNull(message, values.iterator().next()); } @@ -298,48 +295,48 @@ public static void assertAttributeDefinition(ResourceAttribute attr, QName ex boolean canRead, boolean canCreate, boolean canUpdate, Class expectedAttributeDefinitionClass) { ResourceAttributeDefinition definition = attr.getDefinition(); QName attrName = attr.getElementName(); - assertNotNull("No definition for attribute "+attrName, definition); + assertNotNull("No definition for attribute " + attrName, definition); //assertEquals("Wrong class of definition for attribute"+attrName, expetcedAttributeDefinitionClass, definition.getClass()); - assertTrue("Wrong class of definition for attribute"+attrName+" (expected: " + expectedAttributeDefinitionClass - + ", real: " + definition.getClass() + ")", + assertTrue("Wrong class of definition for attribute" + attrName + " (expected: " + expectedAttributeDefinitionClass + + ", real: " + definition.getClass() + ")", expectedAttributeDefinitionClass.isAssignableFrom(definition.getClass())); - assertEquals("Wrong type in definition for attribute"+attrName, expectedType, definition.getTypeName()); - assertEquals("Wrong minOccurs in definition for attribute"+attrName, minOccurs, definition.getMinOccurs()); - assertEquals("Wrong maxOccurs in definition for attribute"+attrName, maxOccurs, definition.getMaxOccurs()); - assertEquals("Wrong canRead in definition for attribute"+attrName, canRead, definition.canRead()); - assertEquals("Wrong canCreate in definition for attribute"+attrName, canCreate, definition.canAdd()); - assertEquals("Wrong canUpdate in definition for attribute"+attrName, canUpdate, definition.canModify()); + assertEquals("Wrong type in definition for attribute" + attrName, expectedType, definition.getTypeName()); + assertEquals("Wrong minOccurs in definition for attribute" + attrName, minOccurs, definition.getMinOccurs()); + assertEquals("Wrong maxOccurs in definition for attribute" + attrName, maxOccurs, definition.getMaxOccurs()); + assertEquals("Wrong canRead in definition for attribute" + attrName, canRead, definition.canRead()); + assertEquals("Wrong canCreate in definition for attribute" + attrName, canCreate, definition.canAdd()); + assertEquals("Wrong canUpdate in definition for attribute" + attrName, canUpdate, definition.canModify()); } public static void assertProvisioningAccountShadow(PrismObject account, ResourceType resourceType, Class expetcedAttributeDefinitionClass) { - assertProvisioningShadow(account,resourceType,expetcedAttributeDefinitionClass, - new QName(ResourceTypeUtil.getResourceNamespace(resourceType), SchemaTestConstants.ICF_ACCOUNT_OBJECT_CLASS_LOCAL_NAME)); + assertProvisioningShadow(account, expetcedAttributeDefinitionClass, + new QName(ResourceTypeUtil.getResourceNamespace(resourceType), SchemaTestConstants.ICF_ACCOUNT_OBJECT_CLASS_LOCAL_NAME)); } - public static void assertProvisioningShadow(PrismObject account, ResourceType resourceType, - Class expetcedAttributeDefinitionClass, QName objectClass) { + public static void assertProvisioningShadow(PrismObject account, + Class expectedAttributeDefinitionClass, QName objectClass) { // Check attribute definition PrismContainer attributesContainer = account.findContainer(ShadowType.F_ATTRIBUTES); PrismAsserts.assertClass("Wrong attributes container class", ResourceAttributeContainer.class, attributesContainer); - ResourceAttributeContainer rAttributesContainer = (ResourceAttributeContainer)attributesContainer; + ResourceAttributeContainer rAttributesContainer = (ResourceAttributeContainer) attributesContainer; PrismContainerDefinition attrsDef = attributesContainer.getDefinition(); assertNotNull("No attributes container definition", attrsDef); - assertTrue("Wrong attributes definition class "+attrsDef.getClass().getName(), attrsDef instanceof ResourceAttributeContainerDefinition); - ResourceAttributeContainerDefinition rAttrsDef = (ResourceAttributeContainerDefinition)attrsDef; + assertTrue("Wrong attributes definition class " + attrsDef.getClass().getName(), attrsDef instanceof ResourceAttributeContainerDefinition); + ResourceAttributeContainerDefinition rAttrsDef = (ResourceAttributeContainerDefinition) attrsDef; ObjectClassComplexTypeDefinition objectClassDef = rAttrsDef.getComplexTypeDefinition(); assertNotNull("No object class definition in attributes definition", objectClassDef); assertEquals("Wrong object class in attributes definition", objectClass, objectClassDef.getTypeName()); ResourceAttributeDefinition primaryIdDef = objectClassDef.getPrimaryIdentifiers().iterator().next(); ResourceAttribute primaryIdAttr = rAttributesContainer.findAttribute(primaryIdDef.getItemName()); - assertNotNull("No primary ID "+primaryIdDef.getItemName()+" in "+account, primaryIdAttr); - assertAttributeDefinition(primaryIdAttr, DOMUtil.XSD_STRING, 0, 1, true, false, false, expetcedAttributeDefinitionClass); + assertNotNull("No primary ID " + primaryIdDef.getItemName() + " in " + account, primaryIdAttr); + assertAttributeDefinition(primaryIdAttr, DOMUtil.XSD_STRING, 0, 1, true, false, false, expectedAttributeDefinitionClass); ResourceAttributeDefinition secondaryIdDef = objectClassDef.getSecondaryIdentifiers().iterator().next(); ResourceAttribute secondaryIdAttr = rAttributesContainer.findAttribute(secondaryIdDef.getItemName()); - assertNotNull("No secondary ID "+secondaryIdDef.getItemName()+" in "+account, secondaryIdAttr); - assertAttributeDefinition(secondaryIdAttr, DOMUtil.XSD_STRING, 1, 1, true, true, true, expetcedAttributeDefinitionClass); + assertNotNull("No secondary ID " + secondaryIdDef.getItemName() + " in " + account, secondaryIdAttr); + assertAttributeDefinition(secondaryIdAttr, DOMUtil.XSD_STRING, 1, 1, true, true, true, expectedAttributeDefinitionClass); } public static Collection getAttributeValues(ShadowType shadowType, QName name) { @@ -365,10 +362,10 @@ public static String getAttributeValue(ShadowType repoShadow, QName name) { Collection values = getAttributeValues(repoShadow, name); if (values == null || values.isEmpty()) { - AssertJUnit.fail("Attribute "+name+" not found in shadow "+ObjectTypeUtil.toShortString(repoShadow)); + AssertJUnit.fail("Attribute " + name + " not found in shadow " + ObjectTypeUtil.toShortString(repoShadow)); } if (values.size() > 1) { - AssertJUnit.fail("Too many values for attribute "+name+" in shadow "+ObjectTypeUtil.toShortString(repoShadow)); + AssertJUnit.fail("Too many values for attribute " + name + " in shadow " + ObjectTypeUtil.toShortString(repoShadow)); } return values.iterator().next(); } @@ -399,11 +396,11 @@ public static void waitFor(String message, Checker checker, long startTime, long } } // we have timeout - println("Timeout while "+message); + println("Timeout while " + message); LOGGER.error(LOG_MESSAGE_PREFIX + "Timeout while " + message); // Invoke callback checker.timeout(); - throw new RuntimeException("Timeout while "+message); + throw new RuntimeException("Timeout while " + message); } public static void displayJaxb(String title, Object o, QName defaultElementName) throws SchemaException { @@ -432,7 +429,7 @@ public static void display(Entry response) { public static void display(String message, Task task) { println(OBJECT_TITLE_OUT_PREFIX + message); println(task.debugDump()); - LOGGER.debug(OBJECT_TITLE_LOG_PREFIX + message + "\n" + LOGGER.debug(OBJECT_TITLE_LOG_PREFIX + message + "\n" + task.debugDump()); } @@ -450,8 +447,8 @@ public static void display(String message, Collection collection) { } else { dump = " (" + collection.size() + ")\n" + DebugUtil.dump(collection); } - println(OBJECT_TITLE_OUT_PREFIX + message + dump); - LOGGER.debug(OBJECT_TITLE_LOG_PREFIX + message + dump); + println(OBJECT_TITLE_OUT_PREFIX + message + dump); + LOGGER.debug(OBJECT_TITLE_LOG_PREFIX + message + dump); } public static void display(String title, Entry entry) { @@ -461,7 +458,7 @@ public static void display(String title, Entry entry) { ldif = entry.toLDIFString(); } println(ldif); - LOGGER.debug(OBJECT_TITLE_LOG_PREFIX + title + "\n" + LOGGER.debug(OBJECT_TITLE_LOG_PREFIX + title + "\n" + ldif); } @@ -473,14 +470,14 @@ public static void display(String message, PrismContainer propertyContainer) } public static void display(OperationResult result) { - display("Result of "+result.getOperation(), result); + display("Result of " + result.getOperation(), result); } public static void display(String title, OperationResult result) { println(OBJECT_TITLE_OUT_PREFIX + title); String debugDump = result != null ? result.debugDump() : "(null)"; println(debugDump); - LOGGER.debug(OBJECT_TITLE_LOG_PREFIX + title + "\n" + LOGGER.debug(OBJECT_TITLE_LOG_PREFIX + title + "\n" + debugDump); } @@ -491,7 +488,7 @@ public static void display(String title, OperationResultType result) throws Sche public static void display(String title, List elements) { println(OBJECT_TITLE_OUT_PREFIX + title); LOGGER.debug(OBJECT_TITLE_LOG_PREFIX + title); - for(Element e : elements) { + for (Element e : elements) { String s = DOMUtil.serializeDOMToString(e); println(s); LOGGER.debug(s); @@ -501,7 +498,7 @@ public static void display(String title, List elements) { public static void display(String title, DebugDumpable dumpable) { println(OBJECT_TITLE_OUT_PREFIX + title); println(dumpable == null ? "null" : dumpable.debugDump(1)); - LOGGER.debug(OBJECT_TITLE_LOG_PREFIX + title + "\n" + LOGGER.debug(OBJECT_TITLE_LOG_PREFIX + title + "\n" + (dumpable == null ? "null" : dumpable.debugDump(1))); } @@ -537,7 +534,7 @@ public static void display(String title, Containerable value) { */ public static void display(String title, Throwable e) { String stackTrace = ExceptionUtils.getStackTrace(e); - println(OBJECT_TITLE_OUT_PREFIX + title + ": "+e.getClass() + " " + e.getMessage()); + println(OBJECT_TITLE_OUT_PREFIX + title + ": " + e.getClass() + " " + e.getMessage()); println(stackTrace); LOGGER.debug("{}{}: {} {}\n{}", OBJECT_TITLE_LOG_PREFIX, title, e.getClass(), e.getMessage(), stackTrace); } @@ -598,22 +595,23 @@ public static void displayObjectTypeCollection(String message, Collection void assertSearchResultNames(SearchResultList> resultList, MatchingRule matchingRule, String... expectedNames) throws SchemaException { List names = new ArrayList<>(expectedNames.length); - for(PrismObject obj: resultList) { + for (PrismObject obj : resultList) { names.add(obj.asObjectable().getName().getOrig()); } PrismAsserts.assertSets("Unexpected search result", matchingRule, names, expectedNames); } - public static void assertSearchResultNames(SearchResultList> resultList, String... expectedNames) { + public static void assertSearchResultNames( + SearchResultList> resultList, String... expectedNames) { List names = new ArrayList<>(expectedNames.length); - for(PrismObject obj: resultList) { + for (PrismObject obj : resultList) { names.add(obj.asObjectable().getName().getOrig()); } PrismAsserts.assertSets("Unexpected search result", names, expectedNames); } public static void checkAllShadows(ResourceType resourceType, RepositoryService repositoryService, - ObjectChecker checker, PrismContext prismContext) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException { + ObjectChecker checker, PrismContext prismContext) throws SchemaException { OperationResult result = new OperationResult(IntegrationTestTools.class.getName() + ".checkAllShadows"); ObjectQuery query = createAllShadowsQuery(resourceType, prismContext); @@ -621,29 +619,29 @@ public static void checkAllShadows(ResourceType resourceType, RepositoryService List> allShadows = repositoryService.searchObjects(ShadowType.class, query, GetOperationOptions.createRawCollection(), result); LOGGER.trace("Checking {} shadows, query:\n{}", allShadows.size(), query.debugDump()); - for (PrismObject shadow: allShadows) { + for (PrismObject shadow : allShadows) { checkShadow(shadow.asObjectable(), resourceType, repositoryService, checker, prismContext, result); } } - public static ObjectQuery createAllShadowsQuery(ResourceType resourceType, PrismContext prismContext) throws SchemaException { + public static ObjectQuery createAllShadowsQuery(ResourceType resourceType, PrismContext prismContext) { return prismContext.queryFor(ShadowType.class) .item(ShadowType.F_RESOURCE_REF).ref(resourceType.getOid()) .build(); } - public static ObjectQuery createAllShadowsQuery(ResourceType resourceType, QName objectClass, PrismContext prismContext) throws SchemaException { + public static ObjectQuery createAllShadowsQuery(ResourceType resourceType, QName objectClass, PrismContext prismContext) { return prismContext.queryFor(ShadowType.class) .item(ShadowType.F_RESOURCE_REF).ref(resourceType.getOid()) .and().item(ShadowType.F_OBJECT_CLASS).eq(objectClass) .build(); } - public static ObjectQuery createAllShadowsQuery(ResourceType resourceType, String objectClassLocalName, PrismContext prismContext) throws SchemaException { + public static ObjectQuery createAllShadowsQuery( + ResourceType resourceType, String objectClassLocalName, PrismContext prismContext) { return createAllShadowsQuery(resourceType, new QName(ResourceTypeUtil.getResourceNamespace(resourceType), objectClassLocalName), prismContext); } - public static void checkAccountShadow(ShadowType shadowType, ResourceType resourceType, RepositoryService repositoryService, ObjectChecker checker, PrismContext prismContext, OperationResult parentResult) throws SchemaException { checkAccountShadow(shadowType, resourceType, repositoryService, checker, null, prismContext, parentResult); @@ -675,52 +673,52 @@ public static void checkShadow(ShadowType shadowType, ResourceType resourceType, public static void checkShadow(ShadowType shadowType, ResourceType resourceType, RepositoryService repositoryService, ObjectChecker checker, MatchingRule uidMatchingRule, PrismContext prismContext, OperationResult parentResult) throws SchemaException { - LOGGER.trace("Checking shadow:\n{}",shadowType.asPrismObject().debugDump()); + LOGGER.trace("Checking shadow:\n{}", shadowType.asPrismObject().debugDump()); shadowType.asPrismObject().checkConsistence(true, true, ConsistencyCheckScope.THOROUGH); - assertNotNull("no OID",shadowType.getOid()); - assertNotNull("no name",shadowType.getName()); + assertNotNull("no OID", shadowType.getOid()); + assertNotNull("no name", shadowType.getName()); assertEquals(resourceType.getOid(), shadowType.getResourceRef().getOid()); PrismContainer attrs = shadowType.asPrismObject().findContainer(ShadowType.F_ATTRIBUTES); - assertNotNull("no attributes",attrs); - assertFalse("empty attributes",attrs.isEmpty()); + assertNotNull("no attributes", attrs); + assertFalse("empty attributes", attrs.isEmpty()); RefinedResourceSchema rschema = RefinedResourceSchemaImpl.getRefinedSchema(resourceType); ObjectClassComplexTypeDefinition objectClassDef = rschema.findObjectClassDefinition(shadowType); - assertNotNull("cannot determine object class for "+shadowType, objectClassDef); + assertNotNull("cannot determine object class for " + shadowType, objectClassDef); String icfUid = ShadowUtil.getSingleStringAttributeValue(shadowType, SchemaTestConstants.ICFS_UID); if (icfUid == null) { Collection identifierDefs = objectClassDef.getPrimaryIdentifiers(); - assertFalse("No identifiers for "+objectClassDef, identifierDefs == null || identifierDefs.isEmpty()); - for (ResourceAttributeDefinition idDef: identifierDefs) { + assertFalse("No identifiers for " + objectClassDef, identifierDefs == null || identifierDefs.isEmpty()); + for (ResourceAttributeDefinition idDef : identifierDefs) { String id = ShadowUtil.getSingleStringAttributeValue(shadowType, idDef.getItemName()); - assertNotNull("No identifier "+idDef.getItemName()+" in "+shadowType, id); + assertNotNull("No identifier " + idDef.getItemName() + " in " + shadowType, id); } } String resourceOid = ShadowUtil.getResourceOid(shadowType); - assertNotNull("No resource OID in "+shadowType, resourceOid); + assertNotNull("No resource OID in " + shadowType, resourceOid); - assertNotNull("Null OID in "+shadowType, shadowType.getOid()); + assertNotNull("Null OID in " + shadowType, shadowType.getOid()); PrismObject repoShadow = null; try { repoShadow = repositoryService.getObject(ShadowType.class, shadowType.getOid(), null, parentResult); } catch (Exception e) { - AssertJUnit.fail("Got exception while trying to read "+shadowType+ - ": "+e.getCause()+": "+e.getMessage()); + AssertJUnit.fail("Got exception while trying to read " + shadowType + + ": " + e.getCause() + ": " + e.getMessage()); } checkShadowUniqueness(shadowType, objectClassDef, repositoryService, uidMatchingRule, prismContext, parentResult); String repoResourceOid = ShadowUtil.getResourceOid(repoShadow.asObjectable()); - assertNotNull("No resource OID in the repository shadow "+repoShadow); + assertNotNull("No resource OID in the repository shadow " + repoShadow, repoResourceOid); assertEquals("Resource OID mismatch", resourceOid, repoResourceOid); try { repositoryService.getObject(ResourceType.class, resourceOid, null, parentResult); } catch (Exception e) { - AssertJUnit.fail("Got exception while trying to read resource "+resourceOid+" as specified in current shadow "+shadowType+ - ": "+e.getCause()+": "+e.getMessage()); + AssertJUnit.fail("Got exception while trying to read resource " + resourceOid + " as specified in current shadow " + shadowType + + ": " + e.getCause() + ": " + e.getMessage()); } if (checker != null) { @@ -738,13 +736,13 @@ private static void checkShadowUniqueness(ShadowType resourceShadow, ObjectClass List> results = repositoryService.searchObjects(ShadowType.class, query, null, parentResult); LOGGER.trace("Shadow check with filter\n{}\n found {} objects", query.debugDump(), results.size()); if (results.size() == 0) { - AssertJUnit.fail("No shadow found with query:\n"+query.debugDump()); + AssertJUnit.fail("No shadow found with query:\n" + query.debugDump()); } if (results.size() == 1) { return; } if (results.size() > 1) { - for (PrismObject result: results) { + for (PrismObject result : results) { LOGGER.trace("Search result:\n{}", result.debugDump()); } LOGGER.error("More than one shadows found for " + resourceShadow); @@ -756,13 +754,16 @@ private static void checkShadowUniqueness(ShadowType resourceShadow, ObjectClass } } - private static ObjectQuery createShadowQuery(ShadowType resourceShadow, ObjectClassComplexTypeDefinition objectClassDef, MatchingRule uidMatchingRule, PrismContext prismContext) throws SchemaException { + private static ObjectQuery createShadowQuery( + ShadowType resourceShadow, ObjectClassComplexTypeDefinition objectClassDef, + MatchingRule uidMatchingRule, PrismContext prismContext) + throws SchemaException { PrismContainer attributesContainer = resourceShadow.asPrismObject().findContainer(ShadowType.F_ATTRIBUTES); QName identifierName = objectClassDef.getPrimaryIdentifiers().iterator().next().getItemName(); PrismProperty identifier = attributesContainer.findProperty(ItemName.fromQName(identifierName)); if (identifier == null) { - throw new SchemaException("No identifier in "+resourceShadow); + throw new SchemaException("No identifier in " + resourceShadow); } String identifierValue = identifier.getRealValue(); if (uidMatchingRule != null) { @@ -782,7 +783,7 @@ public static void applyResourceSchema(ShadowType accountType, ResourceType reso } public static void assertInMessageRecursive(Throwable e, String substring) { - assert hasInMessageRecursive(e, substring) : "The substring '"+substring+"' was NOT found in the message of exception "+e+" (including cause exceptions)"; + assert hasInMessageRecursive(e, substring) : "The substring '" + substring + "' was NOT found in the message of exception " + e + " (including cause exceptions)"; } public static boolean hasInMessageRecursive(Throwable e, String substring) { @@ -796,7 +797,7 @@ public static boolean hasInMessageRecursive(Throwable e, String substring) { } public static void assertNotInMessageRecursive(Throwable e, String substring) { - assert !e.getMessage().contains(substring) : "The substring '"+substring+"' was found in the message of exception "+e+": "+e.getMessage(); + assert !e.getMessage().contains(substring) : "The substring '" + substring + "' was found in the message of exception " + e + ": " + e.getMessage(); if (e.getCause() != null) { assertNotInMessageRecursive(e.getCause(), substring); } @@ -812,7 +813,7 @@ public static void assertScripts(List scriptsHistory, Provis displayScripts(scriptsHistory); assertEquals("Wrong number of scripts executed", expectedScripts.length, scriptsHistory.size()); Iterator historyIter = scriptsHistory.iterator(); - for (ProvisioningScriptSpec expecedScript: expectedScripts) { + for (ProvisioningScriptSpec expecedScript : expectedScripts) { ScriptHistoryEntry actualScript = historyIter.next(); assertEquals("Wrong script code", expecedScript.getCode(), actualScript.getCode()); if (expecedScript.getLanguage() == null) { @@ -821,10 +822,10 @@ public static void assertScripts(List scriptsHistory, Provis assertEquals("Wrong script language", expecedScript.getLanguage(), actualScript.getLanguage()); } assertEquals("Wrong number of arguments", expecedScript.getArgs().size(), actualScript.getParams().size()); - for (java.util.Map.Entry expectedEntry: expecedScript.getArgs().entrySet()) { + for (java.util.Map.Entry expectedEntry : expecedScript.getArgs().entrySet()) { Object expectedValue = expectedEntry.getValue(); Object actualVal = actualScript.getParams().get(expectedEntry.getKey()); - assertEquals("Wrong value for argument '"+expectedEntry.getKey()+"'", expectedValue, actualVal); + assertEquals("Wrong value for argument '" + expectedEntry.getKey() + "'", expectedValue, actualVal); } } } @@ -835,23 +836,25 @@ public static void displayScripts(List scriptsHistory) { } } - public static void assertExtensionProperty(PrismObject object, QName propertyName, T... expectedValues) { + public static void assertExtensionProperty( + PrismObject object, QName propertyName, T... expectedValues) { PrismContainer extension = object.getExtension(); PrismAsserts.assertPropertyValue(extension, ItemName.fromQName(propertyName), expectedValues); } - public static void assertNoExtensionProperty(PrismObject object, QName propertyName) { + public static void assertNoExtensionProperty( + PrismObject object, QName propertyName) { PrismContainer extension = object.getExtension(); PrismAsserts.assertNoItem(extension, ItemName.fromQName(propertyName)); } public static void assertIcfResourceSchemaSanity(ResourceSchema resourceSchema, ResourceType resourceType) { - assertNotNull("No resource schema in "+resourceType, resourceSchema); + assertNotNull("No resource schema in " + resourceType, resourceSchema); QName objectClassQname = new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "AccountObjectClass"); ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findObjectClassDefinition(objectClassQname); - assertNotNull("No object class definition for "+objectClassQname+" in resource schema", accountDefinition); + assertNotNull("No object class definition for " + objectClassQname + " in resource schema", accountDefinition); ObjectClassComplexTypeDefinition accountDef = resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT); - assertTrue("Mismatched account definition: "+accountDefinition+" <-> "+accountDef, accountDefinition == accountDef); + assertSame("Mismatched account definition: " + accountDefinition + " <-> " + accountDef, accountDefinition, accountDef); assertNotNull("No object class definition " + objectClassQname, accountDefinition); assertEquals("Object class " + objectClassQname + " is not account", ShadowKindType.ACCOUNT, accountDefinition.getKind()); @@ -863,24 +866,23 @@ public static void assertIcfResourceSchemaSanity(ResourceSchema resourceSchema, assertNotNull("Null identifiers for " + objectClassQname, identifiers); assertFalse("Empty identifiers for " + objectClassQname, identifiers.isEmpty()); - ResourceAttributeDefinition uidAttributeDefinition = accountDefinition.findAttributeDefinition(SchemaTestConstants.ICFS_UID); - assertNotNull("No definition for attribute "+SchemaTestConstants.ICFS_UID, uidAttributeDefinition); - assertTrue("Attribute "+SchemaTestConstants.ICFS_UID+" in not an identifier",uidAttributeDefinition.isPrimaryIdentifier(accountDefinition)); - assertTrue("Attribute "+SchemaTestConstants.ICFS_UID+" in not in identifiers list",identifiers.contains(uidAttributeDefinition)); - assertEquals("Wrong displayName for attribute "+SchemaTestConstants.ICFS_UID, "ConnId UID", uidAttributeDefinition.getDisplayName()); - assertEquals("Wrong displayOrder for attribute "+SchemaTestConstants.ICFS_UID, (Integer)100, uidAttributeDefinition.getDisplayOrder()); + assertNotNull("No definition for attribute " + SchemaTestConstants.ICFS_UID, uidAttributeDefinition); + assertTrue("Attribute " + SchemaTestConstants.ICFS_UID + " in not an identifier", uidAttributeDefinition.isPrimaryIdentifier(accountDefinition)); + assertTrue("Attribute " + SchemaTestConstants.ICFS_UID + " in not in identifiers list", identifiers.contains(uidAttributeDefinition)); + assertEquals("Wrong displayName for attribute " + SchemaTestConstants.ICFS_UID, "ConnId UID", uidAttributeDefinition.getDisplayName()); + assertEquals("Wrong displayOrder for attribute " + SchemaTestConstants.ICFS_UID, (Integer) 100, uidAttributeDefinition.getDisplayOrder()); Collection secondaryIdentifiers = accountDefinition.getSecondaryIdentifiers(); assertNotNull("Null secondary identifiers for " + objectClassQname, secondaryIdentifiers); assertFalse("Empty secondary identifiers for " + objectClassQname, secondaryIdentifiers.isEmpty()); ResourceAttributeDefinition nameAttributeDefinition = accountDefinition.findAttributeDefinition(SchemaTestConstants.ICFS_NAME); - assertNotNull("No definition for attribute "+SchemaTestConstants.ICFS_NAME, nameAttributeDefinition); - assertTrue("Attribute "+SchemaTestConstants.ICFS_NAME+" in not an identifier",nameAttributeDefinition.isSecondaryIdentifier(accountDefinition)); - assertTrue("Attribute "+SchemaTestConstants.ICFS_NAME+" in not in identifiers list",secondaryIdentifiers.contains(nameAttributeDefinition)); - assertEquals("Wrong displayName for attribute "+SchemaTestConstants.ICFS_NAME, "ConnId Name", nameAttributeDefinition.getDisplayName()); - assertEquals("Wrong displayOrder for attribute "+SchemaTestConstants.ICFS_NAME, (Integer)110, nameAttributeDefinition.getDisplayOrder()); + assertNotNull("No definition for attribute " + SchemaTestConstants.ICFS_NAME, nameAttributeDefinition); + assertTrue("Attribute " + SchemaTestConstants.ICFS_NAME + " in not an identifier", nameAttributeDefinition.isSecondaryIdentifier(accountDefinition)); + assertTrue("Attribute " + SchemaTestConstants.ICFS_NAME + " in not in identifiers list", secondaryIdentifiers.contains(nameAttributeDefinition)); + assertEquals("Wrong displayName for attribute " + SchemaTestConstants.ICFS_NAME, "ConnId Name", nameAttributeDefinition.getDisplayName()); + assertEquals("Wrong displayOrder for attribute " + SchemaTestConstants.ICFS_NAME, (Integer) 110, nameAttributeDefinition.getDisplayOrder()); assertNotNull("Null identifiers in account", accountDef.getPrimaryIdentifiers()); assertFalse("Empty identifiers in account", accountDef.getPrimaryIdentifiers().isEmpty()); @@ -895,11 +897,11 @@ public static void assertIcfResourceSchemaSanity(ResourceSchema resourceSchema, assertEquals(0, uidDef.getMinOccurs()); assertFalse("No UID display name", StringUtils.isBlank(uidDef.getDisplayName())); assertFalse("UID has create", uidDef.canAdd()); - assertFalse("UID has update",uidDef.canModify()); - assertTrue("No UID read",uidDef.canRead()); + assertFalse("UID has update", uidDef.canModify()); + assertTrue("No UID read", uidDef.canRead()); assertTrue("UID definition not in identifiers", accountDef.getPrimaryIdentifiers().contains(uidDef)); - assertEquals("Wrong refined displayName for attribute "+SchemaTestConstants.ICFS_UID, "ConnId UID", uidDef.getDisplayName()); - assertEquals("Wrong refined displayOrder for attribute "+SchemaTestConstants.ICFS_UID, (Integer)100, uidDef.getDisplayOrder()); + assertEquals("Wrong refined displayName for attribute " + SchemaTestConstants.ICFS_UID, "ConnId UID", uidDef.getDisplayName()); + assertEquals("Wrong refined displayOrder for attribute " + SchemaTestConstants.ICFS_UID, (Integer) 100, uidDef.getDisplayOrder()); ResourceAttributeDefinition nameDef = accountDef .findAttributeDefinition(SchemaTestConstants.ICFS_NAME); @@ -907,13 +909,13 @@ public static void assertIcfResourceSchemaSanity(ResourceSchema resourceSchema, assertEquals(1, nameDef.getMinOccurs()); assertFalse("No NAME displayName", StringUtils.isBlank(nameDef.getDisplayName())); assertTrue("No NAME create", nameDef.canAdd()); - assertTrue("No NAME update",nameDef.canModify()); - assertTrue("No NAME read",nameDef.canRead()); + assertTrue("No NAME update", nameDef.canModify()); + assertTrue("No NAME read", nameDef.canRead()); assertTrue("NAME definition not in identifiers", accountDef.getSecondaryIdentifiers().contains(nameDef)); - assertEquals("Wrong refined displayName for attribute "+SchemaTestConstants.ICFS_NAME, "ConnId Name", nameDef.getDisplayName()); - assertEquals("Wrong refined displayOrder for attribute "+SchemaTestConstants.ICFS_NAME, (Integer)110, nameDef.getDisplayOrder()); + assertEquals("Wrong refined displayName for attribute " + SchemaTestConstants.ICFS_NAME, "ConnId Name", nameDef.getDisplayName()); + assertEquals("Wrong refined displayOrder for attribute " + SchemaTestConstants.ICFS_NAME, (Integer) 110, nameDef.getDisplayOrder()); - assertNull("The _PASSSWORD_ attribute sneaked into schema", accountDef.findAttributeDefinition(new QName(SchemaTestConstants.NS_ICFS,"password"))); + assertNull("The _PASSSWORD_ attribute sneaked into schema", accountDef.findAttributeDefinition(new QName(SchemaTestConstants.NS_ICFS, "password"))); } //TODO: add language parameter..for now, use xml serialization @@ -978,16 +980,16 @@ public static void assertGroupMember(DummyGroup group, String accountId) { public static void assertGroupMember(DummyGroup group, String accountId, boolean caseIgnore) { Collection members = group.getMembers(); - assertNotNull("No members in group "+group.getName()+", expected that "+accountId+" will be there", members); + assertNotNull("No members in group " + group.getName() + ", expected that " + accountId + " will be there", members); if (caseIgnore) { - for (String member: members) { + for (String member : members) { if (StringUtils.equalsIgnoreCase(accountId, member)) { return; } } - AssertJUnit.fail("Account "+accountId+" is not member of group "+group.getName()+", members: "+members); + AssertJUnit.fail("Account " + accountId + " is not member of group " + group.getName() + ", members: " + members); } else { - assertTrue("Account "+accountId+" is not member of group "+group.getName()+", members: "+members, members.contains(accountId)); + assertTrue("Account " + accountId + " is not member of group " + group.getName() + ", members: " + members, members.contains(accountId)); } } @@ -996,27 +998,27 @@ public static void assertNoGroupMember(DummyGroup group, String accountId) { if (members == null) { return; } - assertFalse("Account "+accountId+" IS member of group "+group.getName()+" while not expecting it, members: "+members, members.contains(accountId)); + assertFalse("Account " + accountId + " IS member of group " + group.getName() + " while not expecting it, members: " + members, members.contains(accountId)); } public static void assertNoGroupMembers(DummyGroup group) { Collection members = group.getMembers(); - assertTrue("Group "+group.getName()+" has members while not expecting it, members: "+members, members == null || members.isEmpty()); + assertTrue("Group " + group.getName() + " has members while not expecting it, members: " + members, members == null || members.isEmpty()); } public static ShadowAssociationType assertAssociation(PrismObject shadow, QName associationName, String entitlementOid) { ShadowType accountType = shadow.asObjectable(); List associations = accountType.getAssociation(); - assertNotNull("Null associations in "+shadow, associations); - assertFalse("Empty associations in "+shadow, associations.isEmpty()); - for (ShadowAssociationType association: associations) { + assertNotNull("Null associations in " + shadow, associations); + assertFalse("Empty associations in " + shadow, associations.isEmpty()); + for (ShadowAssociationType association : associations) { if (associationName.equals(association.getName()) && association.getShadowRef() != null && entitlementOid.equals(association.getShadowRef().getOid())) { return association; } } - AssertJUnit.fail("No association for entitlement "+entitlementOid+" in "+shadow); + AssertJUnit.fail("No association for entitlement " + entitlementOid + " in " + shadow); throw new IllegalStateException("not reached"); } @@ -1026,16 +1028,16 @@ public static void assertNoAssociation(PrismObject shadow, QName ass if (associations == null) { return; } - for (ShadowAssociationType association: associations) { + for (ShadowAssociationType association : associations) { if (associationName.equals(association.getName()) && entitlementOid.equals(association.getShadowRef().getOid())) { - AssertJUnit.fail("Unexpected association for entitlement "+entitlementOid+" in "+shadow); + AssertJUnit.fail("Unexpected association for entitlement " + entitlementOid + " in " + shadow); } } } public static void assertNoSchema(ResourceType resourceType) { - assertNoSchema("Found schema in resource "+resourceType+" while not expecting it", resourceType); + assertNoSchema("Found schema in resource " + resourceType + " while not expecting it", resourceType); } public static void assertNoSchema(String message, ResourceType resourceType) { @@ -1045,44 +1047,44 @@ public static void assertNoSchema(String message, ResourceType resourceType) { public static void assertConnectorSchemaSanity(ConnectorType conn, PrismContext prismContext) throws SchemaException { XmlSchemaType xmlSchemaType = conn.getSchema(); - assertNotNull("xmlSchemaType is null",xmlSchemaType); + assertNotNull("xmlSchemaType is null", xmlSchemaType); Element connectorXsdSchemaElement = ConnectorTypeUtil.getConnectorXsdSchema(conn); assertNotNull("No schema", connectorXsdSchemaElement); Element xsdElement = ObjectTypeUtil.findXsdElement(xmlSchemaType); - assertNotNull("No xsd:schema element in xmlSchemaType",xsdElement); - display("XSD schema of "+conn, DOMUtil.serializeDOMToString(xsdElement)); + assertNotNull("No xsd:schema element in xmlSchemaType", xsdElement); + display("XSD schema of " + conn, DOMUtil.serializeDOMToString(xsdElement)); // Try to parse the schema - PrismSchema schema = null; + PrismSchema schema; try { - schema = PrismSchemaImpl.parse(xsdElement, true, "schema of "+conn, prismContext); + schema = PrismSchemaImpl.parse(xsdElement, true, "schema of " + conn, prismContext); } catch (SchemaException e) { - throw new SchemaException("Error parsing schema of "+conn+": "+e.getMessage(),e); + throw new SchemaException("Error parsing schema of " + conn + ": " + e.getMessage(), e); } assertConnectorSchemaSanity(schema, conn.toString(), SchemaConstants.ICF_FRAMEWORK_URI.equals(conn.getFramework())); } public static void assertConnectorSchemaSanity(PrismSchema schema, String connectorDescription, boolean expectConnIdSchema) { - assertNotNull("Cannot parse connector schema of "+connectorDescription,schema); - assertFalse("Empty connector schema in "+connectorDescription,schema.isEmpty()); - display("Parsed connector schema of "+connectorDescription,schema); + assertNotNull("Cannot parse connector schema of " + connectorDescription, schema); + assertFalse("Empty connector schema in " + connectorDescription, schema.isEmpty()); + display("Parsed connector schema of " + connectorDescription, schema); // Local schema namespace is used here. PrismContainerDefinition configurationDefinition = - schema.findItemDefinition(ResourceType.F_CONNECTOR_CONFIGURATION.getLocalPart(), PrismContainerDefinition.class); - assertNotNull("Definition of property container not found in connector schema of "+connectorDescription, + schema.findItemDefinition(ResourceType.F_CONNECTOR_CONFIGURATION.getLocalPart(), PrismContainerDefinition.class); + assertNotNull("Definition of property container not found in connector schema of " + connectorDescription, configurationDefinition); - assertFalse("Empty definition of property container in connector schema of "+connectorDescription, + assertFalse("Empty definition of property container in connector schema of " + connectorDescription, configurationDefinition.isEmpty()); if (expectConnIdSchema) { // ICFC schema is used on other elements PrismContainerDefinition configurationPropertiesDefinition = - configurationDefinition.findContainerDefinition(SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME); - assertNotNull("Definition of property container not found in connector schema of "+connectorDescription, + configurationDefinition.findContainerDefinition(SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME); + assertNotNull("Definition of property container not found in connector schema of " + connectorDescription, configurationPropertiesDefinition); - assertFalse("Empty definition of property container in connector schema of "+connectorDescription, + assertFalse("Empty definition of property container in connector schema of " + connectorDescription, configurationPropertiesDefinition.isEmpty()); - assertFalse("No definitions in in "+connectorDescription, configurationPropertiesDefinition.getDefinitions().isEmpty()); + assertFalse("No definitions in in " + connectorDescription, configurationPropertiesDefinition.getDefinitions().isEmpty()); // TODO: other elements } @@ -1099,58 +1101,60 @@ public static void assertProtectedString(String message, String expectedClearVal switch (storageType) { case NONE: - assertNull(message+": unexpected value: "+actualValue, actualValue); + assertNull(message + ": unexpected value: " + actualValue, actualValue); break; case ENCRYPTION: - assertNotNull(message+": no value", actualValue); - assertTrue(message+": unencrypted value: "+actualValue, actualValue.isEncrypted()); + assertNotNull(message + ": no value", actualValue); + assertTrue(message + ": unencrypted value: " + actualValue, actualValue.isEncrypted()); String actualClearPassword = protector.decryptString(actualValue); - assertEquals(message+": wrong value", expectedClearValue, actualClearPassword); - assertFalse(message+": unexpected hashed value: "+actualValue, actualValue.isHashed()); - assertNull(message+": unexpected clear value: "+actualValue, actualValue.getClearValue()); + assertEquals(message + ": wrong value", expectedClearValue, actualClearPassword); + assertFalse(message + ": unexpected hashed value: " + actualValue, actualValue.isHashed()); + assertNull(message + ": unexpected clear value: " + actualValue, actualValue.getClearValue()); break; case HASHING: - assertNotNull(message+": no value", actualValue); - assertTrue(message+": value not hashed: "+actualValue, actualValue.isHashed()); + assertNotNull(message + ": no value", actualValue); + assertTrue(message + ": value not hashed: " + actualValue, actualValue.isHashed()); ProtectedStringType expectedPs = new ProtectedStringType(); expectedPs.setClearValue(expectedClearValue); - assertTrue(message+": hash does not match, expected "+expectedClearValue+", but was "+actualValue, + assertTrue(message + ": hash does not match, expected " + expectedClearValue + ", but was " + actualValue, protector.compareCleartext(actualValue, expectedPs)); - assertFalse(message+": unexpected encrypted value: "+actualValue, actualValue.isEncrypted()); - assertNull(message+": unexpected clear value: "+actualValue, actualValue.getClearValue()); + assertFalse(message + ": unexpected encrypted value: " + actualValue, actualValue.isEncrypted()); + assertNull(message + ": unexpected clear value: " + actualValue, actualValue.getClearValue()); break; default: - throw new IllegalArgumentException("Unknown storage "+storageType); + throw new IllegalArgumentException("Unknown storage " + storageType); } } - public static void assertHasProtectedString(String message, ProtectedStringType actualValue, CredentialsStorageTypeType storageType, Protector protector) throws EncryptionException, SchemaException { + public static void assertHasProtectedString(String message, + ProtectedStringType actualValue, CredentialsStorageTypeType storageType, Protector protector) + throws EncryptionException { switch (storageType) { case NONE: - assertNull(message+": unexpected value: "+actualValue, actualValue); + assertNull(message + ": unexpected value: " + actualValue, actualValue); break; case ENCRYPTION: - assertNotNull(message+": no value", actualValue); - assertTrue(message+": unencrypted value: "+actualValue, actualValue.isEncrypted()); + assertNotNull(message + ": no value", actualValue); + assertTrue(message + ": unencrypted value: " + actualValue, actualValue.isEncrypted()); protector.decryptString(actualValue); // just checking it can be decrypted - assertFalse(message+": unexpected hashed value: "+actualValue, actualValue.isHashed()); - assertNull(message+": unexpected clear value: "+actualValue, actualValue.getClearValue()); + assertFalse(message + ": unexpected hashed value: " + actualValue, actualValue.isHashed()); + assertNull(message + ": unexpected clear value: " + actualValue, actualValue.getClearValue()); break; case HASHING: - assertNotNull(message+": no value", actualValue); - assertTrue(message+": value not hashed: "+actualValue, actualValue.isHashed()); - assertFalse(message+": unexpected encrypted value: "+actualValue, actualValue.isEncrypted()); - assertNull(message+": unexpected clear value: "+actualValue, actualValue.getClearValue()); + assertNotNull(message + ": no value", actualValue); + assertTrue(message + ": value not hashed: " + actualValue, actualValue.isHashed()); + assertFalse(message + ": unexpected encrypted value: " + actualValue, actualValue.isEncrypted()); + assertNull(message + ": unexpected clear value: " + actualValue, actualValue.getClearValue()); break; default: - throw new IllegalArgumentException("Unknown storage "+storageType); + throw new IllegalArgumentException("Unknown storage " + storageType); } } From ad9851db0d8a2ea71ca577a2ad3e113e69ac61d7 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Fri, 28 Feb 2020 00:04:46 +0100 Subject: [PATCH 37/97] AbstractIntegrationTest/TestUtil: better WHEN output experiment --- .../evolveum/midpoint/test/util/TestUtil.java | 16 +++++++++++----- .../midpoint/test/AbstractIntegrationTest.java | 11 +++++++++-- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/TestUtil.java b/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/TestUtil.java index 553992f4d69..b42f23215d8 100644 --- a/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/TestUtil.java +++ b/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/TestUtil.java @@ -179,16 +179,21 @@ public static void displayFooter(String footerText) { LOGGER.info(TEST_LOG_PREFIX + footerText + TEST_LOG_SUFFIX); } - public static void displayWhen(String testName) { - System.out.println(TEST_OUT_SECTION_PREFIX + " WHEN " + testName + TEST_OUT_SECTION_SUFFIX); - LOGGER.info(TEST_LOG_SECTION_PREFIX + " WHEN " + testName + TEST_LOG_SECTION_SUFFIX); + @Deprecated // use version with separate testName and description + public static void displayWhen(String what) { + System.out.println(TEST_OUT_SECTION_PREFIX + " WHEN " + what + TEST_OUT_SECTION_SUFFIX); + LOGGER.info(TEST_LOG_SECTION_PREFIX + " WHEN " + what + TEST_LOG_SECTION_SUFFIX); } public static void displayWhen(String testName, String part) { - System.out.println(TEST_OUT_SECTION_PREFIX + " WHEN " + testName + " (" + part + ")" + TEST_OUT_SECTION_SUFFIX); - LOGGER.info(TEST_LOG_SECTION_PREFIX + " WHEN " + testName + " (" + part + ")" + TEST_LOG_SECTION_SUFFIX); + if (part == null) { + part = ""; + } + System.out.println(TEST_OUT_SECTION_PREFIX + testName + ": WHEN " + part + TEST_OUT_SECTION_SUFFIX); + LOGGER.info(TEST_LOG_SECTION_PREFIX + testName + ": WHEN " + part + TEST_LOG_SECTION_SUFFIX); } + // TODO change like when public static void displayThen(String testName) { System.out.println(TEST_OUT_SECTION_PREFIX + " THEN " + testName + TEST_OUT_SECTION_SUFFIX); LOGGER.info(TEST_LOG_SECTION_PREFIX + " THEN " + testName + TEST_LOG_SECTION_SUFFIX); @@ -659,6 +664,7 @@ private static void assertNoPermission(File f, Set permissi public static ParallelTestThread[] multithread(final String TEST_NAME, MultithreadRunner lambda, int numberOfThreads, Integer randomStartDelayRange) { ParallelTestThread[] threads = new ParallelTestThread[numberOfThreads]; + System.out.println("Going to create " + numberOfThreads + " threads..."); for (int i = 0; i < numberOfThreads; i++) { threads[i] = new ParallelTestThread(i, (ii) -> { 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 c5efd9a2ca0..1fd79152a6a 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 @@ -1759,12 +1759,19 @@ protected PrismObject parseObject(File file) throws Sc return prismContext.parseObject(file); } + /** + * Displays "when" subsection header with test name. + * Even better, use {@link #displayWhen(String)} and provide human readable description. + */ protected void displayWhen() { displayWhen(getTestNameShort()); } - protected void displayWhen(String testName) { - TestUtil.displayWhen(testName); + /** + * Displays "when" subsection header with test name and provided description (nullable). + */ + protected void displayWhen(String description) { + TestUtil.displayWhen(getTestNameShort(), description); } protected void displayWhen(String testName, String stage) { From cfafbc83a1c73e29380135883575f549c1846e24 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Fri, 28 Feb 2020 00:08:30 +0100 Subject: [PATCH 38/97] provisioning-impl: fixes of tests after task/result changes --- .../test/TestAdHocCertification.java | 4 +- .../test/TestCertificationBasic.java | 4 +- .../test/TestManualEscalation.java | 47 ++- .../test/AbstractModelIntegrationTest.java | 2 +- .../AbstractProvisioningIntegrationTest.java | 139 +++------ .../provisioning/impl/dummy/TestDummy.java | 28 +- .../impl/dummy/TestDummyConsistency.java | 276 ++++++++++-------- .../impl/dummy/TestDummyParallelism.java | 266 ++++++++--------- .../impl/opendj/TestOpenDjDumber.java | 4 - .../opendj/TestOpenDjReadablePassword.java | 4 - 10 files changed, 349 insertions(+), 425 deletions(-) diff --git a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestAdHocCertification.java b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestAdHocCertification.java index 930df67ede9..ab59b1345ae 100644 --- a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestAdHocCertification.java +++ b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestAdHocCertification.java @@ -73,7 +73,7 @@ public void test010HireIndigo() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); assignOrg(USER_INDIGO_OID, ORG_LABORATORY_OID, task, result); // THEN @@ -103,7 +103,7 @@ public void test020ModifyIndigo() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); @SuppressWarnings({ "unchecked", "raw" }) ObjectDelta delta = prismContext.deltaFor(UserType.class) .item(UserType.F_DESCRIPTION).replace("new description") diff --git a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestCertificationBasic.java b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestCertificationBasic.java index ab0075df339..8ab72408ed3 100644 --- a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestCertificationBasic.java +++ b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestCertificationBasic.java @@ -86,7 +86,7 @@ public void test001CreateForeignCampaign() throws Exception { AccessCertificationDefinitionType.class, result).asObjectable(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); AccessCertificationCampaignType campaign = certificationService.createCampaign(roleInducementCertDefinition.getOid(), task, result); @@ -116,7 +116,7 @@ public void test002OpenFirstForeignStage() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); certificationService.openNextStage(roleInducementCampaignOid, task, result); // THEN diff --git a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestManualEscalation.java b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestManualEscalation.java index 6da245eb852..6e3e93f548f 100644 --- a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestManualEscalation.java +++ b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestManualEscalation.java @@ -7,6 +7,21 @@ package com.evolveum.midpoint.certification.test; +import static org.testng.AssertJUnit.*; + +import static com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationResponseType.ACCEPT; +import static com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationResponseType.NO_RESPONSE; +import static com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType.ENABLED; + +import java.io.File; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.ContextConfiguration; +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; @@ -15,19 +30,6 @@ import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DebugUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.testng.annotations.Test; - -import java.io.File; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import static com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationResponseType.ACCEPT; -import static com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationResponseType.NO_RESPONSE; -import static com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType.ENABLED; -import static org.testng.AssertJUnit.*; /** * Very simple certification test. @@ -35,12 +37,12 @@ * * @author mederly */ -@ContextConfiguration(locations = {"classpath:ctx-certification-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-certification-test-main.xml" }) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) public class TestManualEscalation extends AbstractCertificationTest { - protected static final File CERT_DEF_USER_ASSIGNMENT_BASIC_FILE = new File(COMMON_DIR, "certification-of-eroot-user-assignments.xml"); - protected static final String CERT_DEF_USER_ASSIGNMENT_BASIC_OID = "33333333-0000-0000-0000-000000000001"; + protected static final File CERT_DEF_USER_ASSIGNMENT_BASIC_FILE = + new File(COMMON_DIR, "certification-of-eroot-user-assignments.xml"); protected AccessCertificationDefinitionType certificationDefinition; @@ -95,10 +97,6 @@ public void test013SearchAllCasesAllowed() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_BOB_OID)); - searchWithNoCasesExpected(TEST_NAME); - } - - protected void searchWithNoCasesExpected(String TEST_NAME) throws Exception { // GIVEN Task task = taskManager.createTaskInstance(TestManualEscalation.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -238,7 +236,7 @@ public void test100RecordDecision() throws Exception { assertSingleDecision(superuserCase, ACCEPT, "no comment", 1, 1, USER_ADMINISTRATOR_OID, ACCEPT, false); AccessCertificationCampaignType campaign = getCampaignWithCases(campaignOid); - assertPercentCompleteAll(campaign, Math.round(100.0f/7.0f), Math.round(100.0f/7.0f), Math.round(100.0f/7.0f)); // 1 reviewer per case (always administrator) + assertPercentCompleteAll(campaign, Math.round(100.0f / 7.0f), Math.round(100.0f / 7.0f), Math.round(100.0f / 7.0f)); // 1 reviewer per case (always administrator) } @Test @@ -287,7 +285,7 @@ public void test110Escalate() throws Exception { assertEquals("Wrong new escalation level", NEW_ESCALATION_LEVEL, event.getNewEscalationLevel()); AccessCertificationCampaignType campaign = getCampaignWithCases(campaignOid); - assertPercentCompleteAll(campaign, Math.round(100.0f/7.0f), Math.round(100.0f/7.0f), Math.round(100.0f/7.0f)); + assertPercentCompleteAll(campaign, Math.round(100.0f / 7.0f), Math.round(100.0f / 7.0f), Math.round(100.0f / 7.0f)); } @Test @@ -337,7 +335,7 @@ public void test120EscalateAgain() throws Exception { assertEquals("Wrong new escalation level", NEW_ESCALATION_LEVEL, event.getNewEscalationLevel()); AccessCertificationCampaignType campaign = getCampaignWithCases(campaignOid); - assertPercentCompleteAll(campaign, Math.round(100.0f/7.0f), Math.round(100.0f/7.0f), Math.round(100.0f/7.0f)); + assertPercentCompleteAll(campaign, Math.round(100.0f / 7.0f), Math.round(100.0f / 7.0f), Math.round(100.0f / 7.0f)); } @Test @@ -393,7 +391,7 @@ public void test130Delegate() throws Exception { assertEquals("Wrong old escalation level", OLD_ESCALATION_LEVEL, event.getEscalationLevel()); AccessCertificationCampaignType campaign = getCampaignWithCases(campaignOid); - assertPercentCompleteAll(campaign, Math.round(100.0f/7.0f), Math.round(100.0f/7.0f), Math.round(100.0f/7.0f)); + assertPercentCompleteAll(campaign, Math.round(100.0f / 7.0f), Math.round(100.0f / 7.0f), Math.round(100.0f / 7.0f)); } protected void checkAllCases(Collection caseList, String campaignOid) { @@ -416,5 +414,4 @@ protected void checkAllWorkItems(Collection wor checkWorkItemSanity(workItems, USER_JACK_OID, ORG_EROOT_OID, userJack); } - } diff --git a/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java b/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java index f463bf9cf99..ddf12bbf018 100644 --- a/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java +++ b/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java @@ -2916,7 +2916,7 @@ protected void assertShadowModel(PrismObject accountShadow, String o protected void assertShadowModel(PrismObject accountShadow, String oid, String username, ResourceType resourceType, QName objectClass, MatchingRule nameMatchingRule) throws SchemaException { assertShadowCommon(accountShadow, oid, username, resourceType, objectClass, nameMatchingRule, false); - IntegrationTestTools.assertProvisioningShadow(accountShadow, resourceType, RefinedAttributeDefinition.class, objectClass); + IntegrationTestTools.assertProvisioningShadow(accountShadow, RefinedAttributeDefinition.class, objectClass); } protected ObjectDelta createModifyUserAddDummyAccount(String userOid, String dummyResourceName) throws SchemaException { diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/AbstractProvisioningIntegrationTest.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/AbstractProvisioningIntegrationTest.java index 855bb0dab77..f1b5cbb5766 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/AbstractProvisioningIntegrationTest.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/AbstractProvisioningIntegrationTest.java @@ -6,9 +6,7 @@ */ package com.evolveum.midpoint.provisioning.impl; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.*; import java.io.File; import java.util.Collection; @@ -20,10 +18,8 @@ import org.w3c.dom.Element; import com.evolveum.midpoint.common.refinery.RefinedResourceSchema; -import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.provisioning.api.ProvisioningService; -import com.evolveum.midpoint.provisioning.impl.dummy.TestDummyResourceAndSchemaCaching; import com.evolveum.midpoint.provisioning.impl.mock.SynchronizationServiceMock; import com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance; import com.evolveum.midpoint.schema.GetOperationOptions; @@ -40,19 +36,10 @@ import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.asserter.ShadowAsserter; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SecurityViolationException; +import com.evolveum.midpoint.util.exception.*; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.common_3.CachingMetadataType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.XmlSchemaType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ReadCapabilityType; /** @@ -84,16 +71,15 @@ public abstract class AbstractProvisioningIntegrationTest extends AbstractIntegr private ResourceSchema lastResourceSchema = null; private RefinedResourceSchema lastRefinedResourceSchema; - @Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { InternalsConfig.encryptionChecks = false; - repositoryService.postInit(initResult); // initialize caches here + repositoryService.postInit(initResult); // initialize caches here provisioningService.postInit(initResult); } protected void assertVersion(PrismObject object, String expectedVersion) { - assertEquals("Wrong version of "+object, expectedVersion, object.asObjectable().getVersion()); + assertEquals("Wrong version of " + object, expectedVersion, object.asObjectable().getVersion()); } protected void rememberResourceVersion(String version) { @@ -107,7 +93,7 @@ protected void assertResourceVersionIncrement(PrismObject resource protected void assertResourceVersionIncrement(String currentVersion, int expectedIncrement) { long currentVersionLong = parseVersion(currentVersion); long actualIncrement = currentVersionLong - lastResourceVersion; - assertEquals("Unexpected increment in resource version", (long)expectedIncrement, actualIncrement); + assertEquals("Unexpected increment in resource version", expectedIncrement, actualIncrement); lastResourceVersion = currentVersionLong; } @@ -146,7 +132,7 @@ protected void rememberResourceSchema(ResourceSchema resourceSchema) { protected void assertResourceSchemaUnchanged(ResourceSchema currentResourceSchema) { // We really want == there. We want to make sure that this is actually the same instance and that // it was properly cached - assertTrue("Resource schema has changed", lastResourceSchema == currentResourceSchema); + assertSame("Resource schema has changed", lastResourceSchema, currentResourceSchema); } protected void rememberRefinedResourceSchema(RefinedResourceSchema rResourceSchema) { @@ -154,64 +140,49 @@ protected void rememberRefinedResourceSchema(RefinedResourceSchema rResourceSche } protected void assertRefinedResourceSchemaUnchanged(RefinedResourceSchema currentRefinedResourceSchema) { - // We really want == there. We want to make sure that this is actually the same instance and that - // it was properly cached - assertTrue("Refined resource schema has changed", lastRefinedResourceSchema == currentRefinedResourceSchema); + // We really want == (identity test) here. + // We want to make sure that this is actually the same instance and that it was properly cached. + assertSame("Refined resource schema has changed", lastRefinedResourceSchema, currentRefinedResourceSchema); } protected void assertHasSchema(PrismObject resource, String desc) throws SchemaException { ResourceType resourceType = resource.asObjectable(); - display("Resource "+desc, resourceType); + display("Resource " + desc, resourceType); XmlSchemaType xmlSchemaTypeAfter = resourceType.getSchema(); - assertNotNull("No schema in "+desc, xmlSchemaTypeAfter); + assertNotNull("No schema in " + desc, xmlSchemaTypeAfter); Element resourceXsdSchemaElementAfter = ResourceTypeUtil.getResourceXsdSchema(resourceType); - assertNotNull("No schema XSD element in "+desc, resourceXsdSchemaElementAfter); - - String resourceXml = prismContext.serializeObjectToString(resource, PrismContext.LANG_XML); -// display("Resource XML", resourceXml); + assertNotNull("No schema XSD element in " + desc, resourceXsdSchemaElementAfter); CachingMetadataType cachingMetadata = xmlSchemaTypeAfter.getCachingMetadata(); - assertNotNull("No caching metadata in "+desc, cachingMetadata); - assertNotNull("No retrievalTimestamp in "+desc, cachingMetadata.getRetrievalTimestamp()); - assertNotNull("No serialNumber in "+desc, cachingMetadata.getSerialNumber()); + assertNotNull("No caching metadata in " + desc, cachingMetadata); + assertNotNull("No retrievalTimestamp in " + desc, cachingMetadata.getRetrievalTimestamp()); + assertNotNull("No serialNumber in " + desc, cachingMetadata.getSerialNumber()); Element xsdElement = ObjectTypeUtil.findXsdElement(xmlSchemaTypeAfter); ResourceSchema parsedSchema = ResourceSchemaImpl.parse(xsdElement, resource.toString(), prismContext); - assertNotNull("No schema after parsing in "+desc, parsedSchema); + assertNotNull("No schema after parsing in " + desc, parsedSchema); } - protected void rememberConnectorInstance(PrismObject resource) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException { - OperationResult result = new OperationResult(TestDummyResourceAndSchemaCaching.class.getName() + ".rememberConnectorInstance"); + protected void rememberConnectorInstance(PrismObject resource) throws SchemaException { rememberConnectorInstance(resourceManager.getConfiguredConnectorInstanceFromCache(resource, ReadCapabilityType.class)); } - protected void rememberConnectorInstance(ConnectorInstance currentConnectorInstance) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException { + protected void rememberConnectorInstance(ConnectorInstance currentConnectorInstance) { LOGGER.debug("Remembering connector instance {}", currentConnectorInstance); lastConfiguredConnectorInstance = currentConnectorInstance; } - protected void assertConnectorInstanceUnchanged(PrismObject resource) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException { + protected void assertConnectorInstanceUnchanged(PrismObject resource) throws SchemaException { if (lastConfiguredConnectorInstance == null) { return; } - OperationResult result = new OperationResult(TestDummyResourceAndSchemaCaching.class.getName() - + ".assertConnectorInstanceUnchanged"); ConnectorInstance currentConfiguredConnectorInstance = resourceManager.getConfiguredConnectorInstanceFromCache( resource, ReadCapabilityType.class); - assertTrue("Connector instance has changed", lastConfiguredConnectorInstance == currentConfiguredConnectorInstance); + assertSame("Connector instance has changed", lastConfiguredConnectorInstance, currentConfiguredConnectorInstance); } - protected void assertConnectorInstanceChanged(PrismObject resource) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException { - OperationResult result = new OperationResult(TestDummyResourceAndSchemaCaching.class.getName() - + ".rememberConnectorInstance"); - ConnectorInstance currentConfiguredConnectorInstance = resourceManager.getConfiguredConnectorInstanceFromCache( - resource, ReadCapabilityType.class); - assertTrue("Connector instance has NOT changed", lastConfiguredConnectorInstance != currentConfiguredConnectorInstance); - lastConfiguredConnectorInstance = currentConfiguredConnectorInstance; - } - - protected void assertSteadyResource() throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException { + protected void assertSteadyResource() throws SchemaException { assertCounterIncrement(InternalCounters.RESOURCE_SCHEMA_FETCH_COUNT, 0); assertCounterIncrement(InternalCounters.CONNECTOR_CAPABILITIES_FETCH_COUNT, 0); assertCounterIncrement(InternalCounters.CONNECTOR_SCHEMA_PARSE_COUNT, 0); @@ -234,63 +205,36 @@ protected PrismObject getResource() { return null; } - protected void assertProvisioningNotFound(String oid) throws CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = getTestTask(); - OperationResult result = task.getResult(); - try { - provisioningService.getObject(ShadowType.class, oid, null, task, result); - assertNotReached(); - } catch (ObjectNotFoundException e) { - // expected - } - assertFailure(result); - } - - protected void assertProvisioningFutureNotFound(String oid) throws CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = getTestTask(); - OperationResult result = task.getResult(); - Collection> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); - try { - provisioningService.getObject(ShadowType.class, oid, options, task, result); - assertNotReached(); - } catch (ObjectNotFoundException e) { - // expected - } - assertFailure(result); - } - protected ShadowAsserter assertShadowProvisioning(String oid) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = getTestTask(); - OperationResult result = task.getResult(); - PrismObject shadow = provisioningService.getObject(ShadowType.class, oid, null, task, result); + OperationResult result = createSubresult("assertShadowProvisioning"); + PrismObject shadow = provisioningService.getObject(ShadowType.class, oid, null, getTestTask(), result); assertSuccess(result); ShadowAsserter asserter = ShadowAsserter.forShadow(shadow, "provisioning"); - asserter - .display(); + asserter.display(); return asserter; } - protected ShadowAsserter assertShadowNoFetch(String oid) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = getTestTask(); - OperationResult result = task.getResult(); - Collection> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch()); - PrismObject shadow = provisioningService.getObject(ShadowType.class, oid, options, task, result); + protected ShadowAsserter assertShadowNoFetch(String oid) + throws ObjectNotFoundException, CommunicationException, SchemaException, + ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + OperationResult result = createSubresult("assertShadowNoFetch-" + oid); + Collection> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch()); + PrismObject shadow = provisioningService.getObject(ShadowType.class, oid, options, getTestTask(), result); assertSuccess(result); ShadowAsserter asserter = ShadowAsserter.forShadow(shadow, "noFetch"); - asserter - .display(); + asserter.display(); return asserter; } - protected ShadowAsserter assertShadowFuture(String oid) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = getTestTask(); - OperationResult result = task.getResult(); - Collection> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); - PrismObject shadow = provisioningService.getObject(ShadowType.class, oid, options, task, result); + protected ShadowAsserter assertShadowFuture(String oid) + throws ObjectNotFoundException, CommunicationException, SchemaException, + ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + OperationResult result = createSubresult("assertShadowFuture-" + oid); + Collection> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); + PrismObject shadow = provisioningService.getObject(ShadowType.class, oid, options, getTestTask(), result); assertSuccess(result); ShadowAsserter asserter = ShadowAsserter.forShadow(shadow, "future"); - asserter - .display(); + asserter.display(); return asserter; } @@ -299,12 +243,11 @@ protected ShadowAsserter assertShadowFutureNoFetch(String oid) throws Obje OperationResult result = task.getResult(); GetOperationOptions rootOptions = GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE); rootOptions.setNoFetch(true); - Collection> options = SelectorOptions.createCollection(rootOptions); + Collection> options = SelectorOptions.createCollection(rootOptions); PrismObject shadow = provisioningService.getObject(ShadowType.class, oid, options, task, result); assertSuccess(result); ShadowAsserter asserter = ShadowAsserter.forShadow(shadow, "future,noFetch"); - asserter - .display(); + asserter.display(); return asserter; } } diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummy.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummy.java index 405f01ad361..2fc61e7f7be 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummy.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummy.java @@ -119,8 +119,6 @@ public class TestDummy extends AbstractBasicDummyTest { private static final String GROUP_CORSAIRS_NAME = "corsairs"; - private static final Trace LOGGER = TraceManager.getTrace(TestDummy.class); - private String drakeAccountOid; protected String morganIcfUid; @@ -448,7 +446,7 @@ public void test109ModifiedAccountCleanup() throws Exception { } @Test - public void test110SeachIterative() throws Exception { + public void test110SearchIterative() throws Exception { final String TEST_NAME = "test110SeachIterative"; // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() @@ -4042,17 +4040,17 @@ public void test510AddProtectedAccounts() throws Exception { testAddProtectedAccount(TEST_NAME, "Xavier"); testAddProtectedAccount(TEST_NAME, "Xenophobia"); testAddProtectedAccount(TEST_NAME, "nobody-adm"); - testAddAccount(TEST_NAME, "abcadm"); - testAddAccount(TEST_NAME, "piXel"); - testAddAccount(TEST_NAME, "supernaturalius"); + testAddAccount("abcadm"); + testAddAccount("piXel"); + testAddAccount("supernaturalius"); } @Test public void test511AddProtectedAccountCaseIgnore() throws Exception { final String TEST_NAME = "test511AddProtectedAccountCaseIgnore"; // GIVEN - testAddAccount(TEST_NAME, "xaxa"); - testAddAccount(TEST_NAME, "somebody-ADM"); + testAddAccount("xaxa"); + testAddAccount("somebody-ADM"); } private PrismObject createAccountShadow(String username) throws SchemaException { @@ -4084,8 +4082,7 @@ protected void testAddProtectedAccount(final String TEST_NAME, String username) provisioningService.addObject(shadow, null, null, task, result); AssertJUnit.fail("Expected security exception while adding '"+username+"' account"); } catch (SecurityViolationException e) { - // This is expected - display("Expected exception", e); + displayExpectedException(e); } result.computeStatus(); @@ -4094,20 +4091,17 @@ protected void testAddProtectedAccount(final String TEST_NAME, String username) syncServiceMock.assertNotifyFailureOnly(); -// checkConsistency(); - assertSteadyResource(); } - private void testAddAccount(final String TEST_NAME, String username) throws Exception { - Task task = getTestTask(); - OperationResult result = task.getResult(); + private void testAddAccount(String username) throws Exception { + OperationResult result = createSubresult("addAccount"); syncServiceMock.reset(); PrismObject shadow = createAccountShadow(username); // WHEN - provisioningService.addObject(shadow, null, null, task, result); + provisioningService.addObject(shadow, null, null, getTestTask(), result); result.computeStatus(); display("addObject result (expected failure)", result); @@ -4115,8 +4109,6 @@ private void testAddAccount(final String TEST_NAME, String username) throws Exce syncServiceMock.assertNotifySuccessOnly(); -// checkConsistency(); - assertSteadyResource(); } diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyConsistency.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyConsistency.java index 886fe77cd9a..7d3b7e3332c 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyConsistency.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyConsistency.java @@ -6,16 +6,12 @@ */ package com.evolveum.midpoint.provisioning.impl.dummy; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.*; import java.io.File; import java.util.Collection; - import javax.xml.datatype.XMLGregorianCalendar; -import com.evolveum.midpoint.prism.path.ItemPath; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Listeners; @@ -25,6 +21,7 @@ import com.evolveum.icf.dummy.resource.DummyAccount; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.delta.ObjectDelta; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.provisioning.api.GenericConnectorException; import com.evolveum.midpoint.schema.GetOperationOptions; import com.evolveum.midpoint.schema.PointInTimeType; @@ -37,28 +34,15 @@ import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.asserter.ShadowAsserter; import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; -import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SecurityViolationException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultStatusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.PendingOperationExecutionStatusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.PendingOperationTypeType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; +import com.evolveum.midpoint.util.exception.*; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.ChangeTypeType; /** * Test for various aspects of provisioning failure handling * (aka "consistency mechanism"). - * - * MID-3603 + *

+ * MID-3603 * * @author Radovan Semancik */ @@ -73,8 +57,6 @@ public class TestDummyConsistency extends AbstractDummyTest { protected static final String ACCOUNT_MORGAN_FULLNAME_HM = "Henry Morgan"; protected static final String ACCOUNT_MORGAN_FULLNAME_CHM = "Captain Henry Morgan"; - private static final Trace LOGGER = TraceManager.getTrace(TestDummyConsistency.class); - private static final String ACCOUNT_JP_MORGAN_FULLNAME = "J.P. Morgan"; private static final String ACCOUNT_BETTY_USERNAME = "betty"; private static final String ACCOUNT_BETTY_FULLNAME = "Betty Rubble"; @@ -94,8 +76,6 @@ public class TestDummyConsistency extends AbstractDummyTest { @Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { super.initSystem(initTask, initResult); -// DebugUtil.setDetailedDebugDump(true); -// InternalMonitor.setTraceConnectorOperation(true); } @Override @@ -105,8 +85,6 @@ protected File getResourceDummyFile() { @Test public void test000Integrity() throws Exception { - final String TEST_NAME = "test000Integrity"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -151,10 +129,12 @@ public void test050AddAccountWill() throws Exception { ACCOUNT_WILL_OID, null, task, result); display("Account provisioning", accountProvisioning); + // @formatter:off ShadowAsserter.forShadow(accountProvisioning) .assertNoLegacyConsistency() .pendingOperations() .assertNone(); + // @formatter:on DummyAccount dummyAccount = dummyResource.getAccountByUsername(transformNameFromResource(ACCOUNT_WILL_USERNAME)); assertNotNull("No dummy account", dummyAccount); @@ -169,10 +149,12 @@ public void test050AddAccountWill() throws Exception { display("Repository shadow", shadowFromRepo); checkRepoAccountShadow(shadowFromRepo); + // @formatter:off ShadowAsserter.forShadow(shadowFromRepo) .assertNoLegacyConsistency() .pendingOperations() .assertNone(); + // @formatter:on checkUniqueness(accountProvisioning); assertSteadyResources(); @@ -223,20 +205,17 @@ public void test100AddAccountMorganCommunicationFailure() throws Exception { */ @Test public void test102GetAccountMorganRecovery() throws Exception { - final String TEST_NAME = "test102GetAccountMorganRecovery"; // GIVEN - Task task = getTestTask(); - OperationResult result = task.getResult(); syncServiceMock.reset(); dummyResource.resetBreakMode(); // WHEN - displayWhen(TEST_NAME); + displayWhen(); assertGetUncreatedShadow(ACCOUNT_MORGAN_OID); // THEN - displayThen(TEST_NAME); + displayThen(); syncServiceMock.assertNoNotifcations(); assertUncreatedMorgan(1); @@ -393,6 +372,7 @@ private void assertMorganDead() throws Exception { PrismObject repoShadow = getShadowRepo(ACCOUNT_MORGAN_OID); assertNotNull("Shadow was not created in the repository", repoShadow); + // @formatter:off assertRepoShadow(ACCOUNT_MORGAN_OID) .pendingOperations() .singleOperation() @@ -462,6 +442,7 @@ private void assertMorganDead() throws Exception { .assertNoPrimaryIdentifier() .assertHasSecondaryIdentifier() .end(); + // @formatter:on dummyResource.resetBreakMode(); @@ -865,7 +846,7 @@ public void test132GetAccountMorganCommunicationFailure() throws Exception { * Get operation should throw an error, as there is explicit staleness=0 option. * MID-4796 */ - @Test(enabled=false) // MID-4796 + @Test(enabled = false) // MID-4796 public void test133GetAccountMorganStalenessZeroCommunicationFailure() throws Exception { final String TEST_NAME = "test133GetAccountMorganStalenessZeroCommunicationFailure"; // GIVEN @@ -900,7 +881,6 @@ public void test133GetAccountMorganStalenessZeroCommunicationFailure() throws Ex assertSteadyResources(); } - /** * Use forceRefresh option with get operation to force refresh. * We are over retry interval, therefore provisioning should re-try the operation. @@ -1248,6 +1228,7 @@ public void test190AccountMorganDeadExpireOperation() throws Exception { assertSuccess(result); syncServiceMock.assertNoNotifcations(); + // @formatter:off assertRepoShadow(ACCOUNT_MORGAN_OID) .assertKind(ShadowKindType.ACCOUNT) .assertDead() @@ -1281,7 +1262,6 @@ public void test190AccountMorganDeadExpireOperation() throws Exception { .assertHasSecondaryIdentifier() .end(); - assertShadowFutureNoFetch(ACCOUNT_MORGAN_OID) .assertTombstone() .assertNoLegacyConsistency() @@ -1290,6 +1270,7 @@ public void test190AccountMorganDeadExpireOperation() throws Exception { .assertNoPrimaryIdentifier() .assertHasSecondaryIdentifier() .end(); + // @formatter:on dummyResource.resetBreakMode(); @@ -1332,6 +1313,7 @@ public void test192AccountMorganSecondDeadExpireOperation() throws Exception { assertSuccess(result); syncServiceMock.assertNoNotifcations(); + // @formatter:off assertRepoShadow(shadowMorganOid) .assertKind(ShadowKindType.ACCOUNT) .assertTombstone() @@ -1362,6 +1344,7 @@ public void test192AccountMorganSecondDeadExpireOperation() throws Exception { assertShadowFutureNoFetch(shadowMorganOid) .assertTombstone(); + // @formatter:on dummyResource.resetBreakMode(); @@ -1480,6 +1463,7 @@ public void test800AddAccountMorganAlreadyExists() throws Exception { PrismObject conflictingShadowRepo = findAccountShadowByUsername(ACCOUNT_MORGAN_NAME, getResource(), result); assertNotNull("Shadow for conflicting object was not created in the repository", conflictingShadowRepo); + // @formatter:off ShadowAsserter.forShadow(conflictingShadowRepo,"confligting repo shadow") .display() .assertBasicRepoProperties() @@ -1515,6 +1499,7 @@ public void test800AddAccountMorganAlreadyExists() throws Exception { .end() .pendingOperations() .assertNone(); + // @formatter:on shadowMorganOid = conflictingShadowRepo.getOid(); @@ -1555,8 +1540,9 @@ public void test802AddAccountMorganAlreadyExistsAgain() throws Exception { assertFailure(result); account.checkConsistence(); + // @formatter:off PrismObject conflictingShadowRepo = getShadowRepo(shadowMorganOid); - ShadowAsserter.forShadow(conflictingShadowRepo,"confligting repo shadow") + ShadowAsserter.forShadow(conflictingShadowRepo,"conflicting repo shadow") .display() .assertBasicRepoProperties() .assertOid(shadowMorganOid) @@ -1605,6 +1591,7 @@ public void test802AddAccountMorganAlreadyExistsAgain() throws Exception { .end() .pendingOperations() .assertNone(); + // @formatter:on assertNoRepoShadow(ACCOUNT_MORGAN_OID); assertSteadyResources(); @@ -1634,7 +1621,7 @@ public void test804AddAccountElizabeth() throws Exception { account.checkConsistence(); dummyResourceCtl.assertAccountByUsername(ACCOUNT_ELIZABETH_USERNAME) - .assertAttribute(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, ACCOUNT_ELIZABETH_FULLNAME); + .assertAttribute(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, ACCOUNT_ELIZABETH_FULLNAME); assertSteadyResources(); } @@ -1675,7 +1662,8 @@ public void test806RenameAccountElizabethAlreadyExists() throws Exception { PrismObject conflictingShadowRepo = findAccountShadowByUsername(ACCOUNT_BETTY_USERNAME, getResource(), result); assertNotNull("Shadow for conflicting object was not created in the repository", conflictingShadowRepo); - ShadowAsserter.forShadow(conflictingShadowRepo,"confligting repo shadow") + // @formatter:off + ShadowAsserter.forShadow(conflictingShadowRepo,"conflicting repo shadow") .display() .assertBasicRepoProperties() .assertOidDifferentThan(ACCOUNT_ELIZABETH_OID) @@ -1715,6 +1703,7 @@ public void test806RenameAccountElizabethAlreadyExists() throws Exception { dummyResourceCtl.assertAccountByUsername(ACCOUNT_BETTY_USERNAME) .assertAttribute(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, ACCOUNT_BETTY_FULLNAME); + // @formatter:on assertSteadyResources(); } @@ -1752,7 +1741,8 @@ public void test808RenameAccountElizabethAlreadyExistsAgain() throws Exception { PrismObject conflictingShadowRepo = findAccountShadowByUsername(ACCOUNT_BETTY_USERNAME, getResource(), result); assertNotNull("Shadow for conflicting object was not created in the repository", conflictingShadowRepo); - ShadowAsserter.forShadow(conflictingShadowRepo,"confligting repo shadow") + // @formatter:off + ShadowAsserter.forShadow(conflictingShadowRepo, "conflicting repo shadow") .display() .assertBasicRepoProperties() .assertOidDifferentThan(ACCOUNT_ELIZABETH_OID) @@ -1804,6 +1794,7 @@ public void test808RenameAccountElizabethAlreadyExistsAgain() throws Exception { dummyResourceCtl.assertAccountByUsername(ACCOUNT_BETTY_USERNAME) .assertAttribute(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, ACCOUNT_BETTY_FULLNAME); + // @formatter:on assertSteadyResources(); } @@ -1833,6 +1824,7 @@ public void test810GetAccountMorganNotFound() throws Exception { displayThen(TEST_NAME); assertSuccess(result); + // @formatter:off syncServiceMock .assertNotifyChange() .assertNotifyChangeCalls(1) @@ -1869,6 +1861,7 @@ public void test810GetAccountMorganNotFound() throws Exception { ShadowAsserter.forShadow(provisioningShadow, "provisioning") .assertTombstone(); + // @formatter:on assertNoRepoShadow(ACCOUNT_MORGAN_OID); assertSteadyResources(); @@ -1908,6 +1901,7 @@ public void test812ModifyAccountWillNotFound() throws Exception { display("Result", result); assertFailure(result); + // @formatter:off syncServiceMock .assertNotifyChange() .assertNotifyChangeCalls(1) @@ -1942,6 +1936,7 @@ public void test812ModifyAccountWillNotFound() throws Exception { .assertIsNotExists() .pendingOperations() .assertNone(); + // @formatter:on assertSteadyResources(); } @@ -1972,6 +1967,7 @@ public void test814DeleteAccountElizabethNotFound() throws Exception { display("Result", result); assertHadnledError(result); + // @formatter:off syncServiceMock .assertNotifyChange() .assertNotifyChangeCalls(1) @@ -2006,6 +2002,7 @@ public void test814DeleteAccountElizabethNotFound() throws Exception { .assertIsNotExists() .pendingOperations() .assertNone(); + // @formatter:on assertSteadyResources(); } @@ -2045,6 +2042,7 @@ public void test816AddAccountElizabethAfterDeathAlreadyExists() throws Exception displayThen(TEST_NAME); assertFailure(result); + // @formatter:off syncServiceMock .assertNotifyFailureOnly() .assertNotifyChange() @@ -2069,9 +2067,10 @@ public void test816AddAccountElizabethAfterDeathAlreadyExists() throws Exception .end() .pendingOperations() .assertNone(); + // @formatter:on dummyResourceCtl.assertAccountByUsername(ACCOUNT_ELIZABETH_USERNAME) - .assertAttribute(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, ACCOUNT_ELIZABETH2_FULLNAME); + .assertAttribute(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, ACCOUNT_ELIZABETH2_FULLNAME); assertSteadyResources(); } @@ -2111,6 +2110,7 @@ public void test900GetAccountMurrayPending() throws Exception { private void assertUncreatedMorgan(int expectedAttemptNumber) throws Exception { + // @formatter:off assertRepoShadow(shadowMorganOid) .assertKind(ShadowKindType.ACCOUNT) .assertIsNotExists() @@ -2159,7 +2159,7 @@ private void assertUncreatedMorgan(int expectedAttemptNumber) throws Exception { .delta() .assertAdd(); - ShadowAsserter asserterFuture = assertShadowFuture(shadowMorganOid) + ShadowAsserter asserterFuture = assertShadowFuture(shadowMorganOid) .assertIsExists() .assertNotDead() .assertNoPrimaryIdentifierValue() @@ -2171,6 +2171,7 @@ private void assertUncreatedMorgan(int expectedAttemptNumber) throws Exception { .assertSize(5) .assertValue(dummyResourceCtl.getAttributeFullnameQName(), ACCOUNT_MORGAN_FULLNAME) .end(); + // @formatter:on // Check if the shadow is still in the repo (e.g. that the consistency or sync haven't removed it) checkUniqueness(asserterFuture.getObject()); @@ -2178,6 +2179,7 @@ private void assertUncreatedMorgan(int expectedAttemptNumber) throws Exception { private void assertCreatedMorgan(int expectedAttemptNumber) throws Exception { + // @formatter:off assertRepoShadow(shadowMorganOid) .assertKind(ShadowKindType.ACCOUNT) .assertIsExists() @@ -2238,7 +2240,7 @@ private void assertCreatedMorgan(int expectedAttemptNumber) throws Exception { .assertSize(6) .assertValue(dummyResourceCtl.getAttributeFullnameQName(), ACCOUNT_MORGAN_FULLNAME); - ShadowAsserter asserterFuture = assertShadowFuture(shadowMorganOid) + ShadowAsserter asserterFuture = assertShadowFuture(shadowMorganOid) .assertIsExists() .assertNotDead() .assertPrimaryIdentifierValue(ACCOUNT_MORGAN_NAME) @@ -2250,6 +2252,7 @@ private void assertCreatedMorgan(int expectedAttemptNumber) throws Exception { .assertSize(6) .assertValue(dummyResourceCtl.getAttributeFullnameQName(), ACCOUNT_MORGAN_FULLNAME) .end(); + // @formatter:on dummyResource.resetBreakMode(); @@ -2257,18 +2260,21 @@ private void assertCreatedMorgan(int expectedAttemptNumber) throws Exception { checkUniqueness(asserterFuture.getObject()); dummyResourceCtl.assertAccountByUsername(ACCOUNT_MORGAN_NAME) - .assertName(ACCOUNT_MORGAN_NAME) - .assertFullName(ACCOUNT_MORGAN_FULLNAME) - .assertEnabled() - .assertPassword(ACCOUNT_MORGAN_PASSWORD); + .assertName(ACCOUNT_MORGAN_NAME) + .assertFullName(ACCOUNT_MORGAN_FULLNAME) + .assertEnabled() + .assertPassword(ACCOUNT_MORGAN_PASSWORD); } - private void assertUnmodifiedMorgan(int expectedAttemptNumber, int expectenNumberOfPendingOperations, String expectedFullName) throws Exception { + private void assertUnmodifiedMorgan( + int expectedAttemptNumber, int expectenNumberOfPendingOperations, String expectedFullName) + throws Exception { PrismObject repoShadow = getShadowRepo(shadowMorganOid); assertNotNull("Shadow was not created in the repository", repoShadow); - ShadowAsserter shadowAsserter = ShadowAsserter.forShadow(repoShadow, "repository"); + // @formatter:off + ShadowAsserter shadowAsserter = ShadowAsserter.forShadow(repoShadow, "repository"); shadowAsserter .display() .pendingOperations() @@ -2325,10 +2331,10 @@ private void assertUnmodifiedMorgan(int expectedAttemptNumber, int expectenNumbe .assertSize(2); Task task = getTestTask(); - OperationResult result = task.getResult(); + OperationResult result = createSubresult("assertUnmodifiedMorgan"); PrismObject accountProvisioning = provisioningService.getObject(ShadowType.class, shadowMorganOid, null, task, result); assertPartialError(result); - shadowAsserter = ShadowAsserter.forShadow(accountProvisioning,"current"); + shadowAsserter = ShadowAsserter.forShadow(accountProvisioning, "current"); shadowAsserter .display() .assertIsExists() @@ -2343,7 +2349,7 @@ private void assertUnmodifiedMorgan(int expectedAttemptNumber, int expectenNumbe // TODO: assert caching metadata? PrismObject accountProvisioningFuture = getShadowFuturePartialError(shadowMorganOid); - shadowAsserter = ShadowAsserter.forShadow(accountProvisioningFuture,"future"); + shadowAsserter = ShadowAsserter.forShadow(accountProvisioningFuture, "future"); shadowAsserter .display() .assertIsExists() @@ -2356,24 +2362,28 @@ private void assertUnmodifiedMorgan(int expectedAttemptNumber, int expectenNumbe .assertHasSecondaryIdentifier() .assertSize(3) .assertValue(dummyResourceCtl.getAttributeFullnameQName(), expectedFullName); + // @formatter:on // Check if the shadow is still in the repo (e.g. that the consistency or sync haven't removed it) checkUniqueness(accountProvisioningFuture); dummyResource.resetBreakMode(); dummyResourceCtl.assertAccountByUsername(ACCOUNT_MORGAN_NAME) - .assertName(ACCOUNT_MORGAN_NAME) - .assertFullName(ACCOUNT_MORGAN_FULLNAME) - .assertEnabled() - .assertPassword(ACCOUNT_MORGAN_PASSWORD); + .assertName(ACCOUNT_MORGAN_NAME) + .assertFullName(ACCOUNT_MORGAN_FULLNAME) + .assertEnabled() + .assertPassword(ACCOUNT_MORGAN_PASSWORD); } - private void assertModifiedMorgan(int expectedAttemptNumber, int expectenNumberOfPendingOperations, String expectedFullName) throws Exception { + private void assertModifiedMorgan( + int expectedAttemptNumber, int expectenNumberOfPendingOperations, String expectedFullName) + throws Exception { PrismObject repoShadow = getShadowRepo(shadowMorganOid); assertNotNull("Shadow was not created in the repository", repoShadow); - ShadowAsserter shadowAsserter = ShadowAsserter.forShadow(repoShadow, "repository"); + // @formatter:off + ShadowAsserter shadowAsserter = ShadowAsserter.forShadow(repoShadow, "repository"); shadowAsserter .display() .pendingOperations() @@ -2432,11 +2442,11 @@ private void assertModifiedMorgan(int expectedAttemptNumber, int expectenNumberO .assertHasSecondaryIdentifier() .assertSize(2); - Task task = getTestTask(); - OperationResult result = task.getResult(); - PrismObject accountProvisioning = provisioningService.getObject(ShadowType.class, shadowMorganOid, null, task, result); + OperationResult result = createSubresult("assertModifiedMorgan"); + PrismObject accountProvisioning = provisioningService.getObject( + ShadowType.class, shadowMorganOid, null, getTestTask(), result); assertSuccess(result); - shadowAsserter = ShadowAsserter.forShadow(accountProvisioning,"current"); + shadowAsserter = ShadowAsserter.forShadow(accountProvisioning, "current"); shadowAsserter .display() .assertIsExists() @@ -2450,7 +2460,7 @@ private void assertModifiedMorgan(int expectedAttemptNumber, int expectenNumberO .assertValue(dummyResourceCtl.getAttributeFullnameQName(), expectedFullName); PrismObject accountProvisioningFuture = getShadowFuture(shadowMorganOid); - shadowAsserter = ShadowAsserter.forShadow(accountProvisioningFuture,"future"); + shadowAsserter = ShadowAsserter.forShadow(accountProvisioningFuture, "future"); shadowAsserter .display() .assertIsExists() @@ -2462,23 +2472,25 @@ private void assertModifiedMorgan(int expectedAttemptNumber, int expectenNumberO .assertHasSecondaryIdentifier() .assertSize(6) .assertValue(dummyResourceCtl.getAttributeFullnameQName(), expectedFullName); + // @formatter:on // Check if the shadow is still in the repo (e.g. that the consistency or sync haven't removed it) checkUniqueness(accountProvisioningFuture); dummyResource.resetBreakMode(); dummyResourceCtl.assertAccountByUsername(ACCOUNT_MORGAN_NAME) - .assertName(ACCOUNT_MORGAN_NAME) - .assertFullName(expectedFullName) - .assertEnabled() - .assertPassword(ACCOUNT_MORGAN_PASSWORD); + .assertName(ACCOUNT_MORGAN_NAME) + .assertFullName(expectedFullName) + .assertEnabled() + .assertPassword(ACCOUNT_MORGAN_PASSWORD); } private void assertMorganModifyFailed() throws Exception { PrismObject repoShadow = getShadowRepo(shadowMorganOid); assertNotNull("Shadow was not created in the repository", repoShadow); - ShadowAsserter shadowAsserter = ShadowAsserter.forShadow(repoShadow, "repository"); + // @formatter:off + ShadowAsserter shadowAsserter = ShadowAsserter.forShadow(repoShadow, "repository"); shadowAsserter .display() .pendingOperations() @@ -2531,11 +2543,11 @@ private void assertMorganModifyFailed() throws Exception { .assertHasSecondaryIdentifier() .assertSize(2); - Task task1 = getTestTask(); - OperationResult result1 = task1.getResult(); - PrismObject accountProvisioning = provisioningService.getObject(ShadowType.class, shadowMorganOid, null, task1, result1); - assertPartialError(result1); - shadowAsserter = ShadowAsserter.forShadow(accountProvisioning,"current"); + OperationResult result = createSubresult("assertMorganModifyFailed"); + PrismObject accountProvisioning = provisioningService.getObject( + ShadowType.class, shadowMorganOid, null, getTestTask(), result); + assertPartialError(result); + shadowAsserter = ShadowAsserter.forShadow(accountProvisioning, "current"); shadowAsserter .display() .assertIsExists() @@ -2560,16 +2572,17 @@ private void assertMorganModifyFailed() throws Exception { .assertHasPrimaryIdentifier() .assertHasSecondaryIdentifier() .assertSize(2); + // @formatter:on // Check if the shadow is still in the repo (e.g. that the consistency or sync haven't removed it) checkUniqueness(accountProvisioningFuture); dummyResource.resetBreakMode(); dummyResourceCtl.assertAccountByUsername(ACCOUNT_MORGAN_NAME) - .assertName(ACCOUNT_MORGAN_NAME) - .assertFullName(ACCOUNT_MORGAN_FULLNAME) - .assertEnabled() - .assertPassword(ACCOUNT_MORGAN_PASSWORD); + .assertName(ACCOUNT_MORGAN_NAME) + .assertFullName(ACCOUNT_MORGAN_FULLNAME) + .assertEnabled() + .assertPassword(ACCOUNT_MORGAN_PASSWORD); } private void assertUndeletedMorgan(int expectedAttemptNumber, int expectenNumberOfPendingOperations) throws Exception { @@ -2577,7 +2590,8 @@ private void assertUndeletedMorgan(int expectedAttemptNumber, int expectenNumber PrismObject repoShadow = getShadowRepo(shadowMorganOid); assertNotNull("Shadow was not created in the repository", repoShadow); - ShadowAsserter shadowAsserter = ShadowAsserter.forShadow(repoShadow, "repository"); + // @formatter:off + ShadowAsserter shadowAsserter = ShadowAsserter.forShadow(repoShadow, "repository"); shadowAsserter .display() .pendingOperations() @@ -2632,11 +2646,11 @@ private void assertUndeletedMorgan(int expectedAttemptNumber, int expectenNumber .assertHasSecondaryIdentifier() .assertSize(2); - Task task = getTestTask(); - OperationResult result = task.getResult(); - PrismObject accountProvisioning = provisioningService.getObject(ShadowType.class, shadowMorganOid, null, task, result); + OperationResult result = createSubresult("assertUndeletedMorgan"); + PrismObject accountProvisioning = provisioningService.getObject( + ShadowType.class, shadowMorganOid, null, getTestTask(), result); assertPartialError(result); - shadowAsserter = ShadowAsserter.forShadow(accountProvisioning,"current"); + shadowAsserter = ShadowAsserter.forShadow(accountProvisioning, "current"); shadowAsserter .display() .assertIsExists() @@ -2651,7 +2665,7 @@ private void assertUndeletedMorgan(int expectedAttemptNumber, int expectenNumber // TODO: assert caching metadata? PrismObject accountProvisioningFuture = getShadowFuturePartialError(shadowMorganOid); - shadowAsserter = ShadowAsserter.forShadow(accountProvisioningFuture,"future"); + shadowAsserter = ShadowAsserter.forShadow(accountProvisioningFuture, "future"); shadowAsserter .display() .assertIsNotExists() @@ -2662,23 +2676,24 @@ private void assertUndeletedMorgan(int expectedAttemptNumber, int expectenNumber .assertHasPrimaryIdentifier() .assertHasSecondaryIdentifier() .assertSize(2); + // @formatter:on // Check if the shadow is still in the repo (e.g. that the consistency or sync haven't removed it) checkUniqueness(accountProvisioningFuture); dummyResource.resetBreakMode(); dummyResourceCtl.assertAccountByUsername(ACCOUNT_MORGAN_NAME) - .assertName(ACCOUNT_MORGAN_NAME) - .assertFullName(ACCOUNT_MORGAN_FULLNAME_CHM) - .assertEnabled() - .assertPassword(ACCOUNT_MORGAN_PASSWORD); + .assertName(ACCOUNT_MORGAN_NAME) + .assertFullName(ACCOUNT_MORGAN_FULLNAME_CHM) + .assertEnabled() + .assertPassword(ACCOUNT_MORGAN_PASSWORD); } private void assertMorganDeleteFailed() throws Exception { - PrismObject repoShadow = getShadowRepo(shadowMorganOid); assertNotNull("Shadow was not created in the repository", repoShadow); + // @formatter:off ShadowAsserter shadowAsserter = ShadowAsserter.forShadow(repoShadow, "repository"); shadowAsserter .display() @@ -2734,11 +2749,11 @@ private void assertMorganDeleteFailed() throws Exception { .assertHasSecondaryIdentifier() .assertSize(2); - Task task = getTestTask(); - OperationResult result = task.getResult(); - PrismObject accountProvisioning = provisioningService.getObject(ShadowType.class, shadowMorganOid, null, task, result); + OperationResult result = createSubresult("assertMorganDeleteFailed"); + PrismObject accountProvisioning = provisioningService.getObject( + ShadowType.class, shadowMorganOid, null, getTestTask(), result); assertPartialError(result); - shadowAsserter = ShadowAsserter.forShadow(accountProvisioning,"current"); + shadowAsserter = ShadowAsserter.forShadow(accountProvisioning, "current"); shadowAsserter .display() .assertIsExists() @@ -2753,7 +2768,7 @@ private void assertMorganDeleteFailed() throws Exception { // TODO: assert caching metadata? PrismObject accountProvisioningFuture = getShadowFuturePartialError(shadowMorganOid); - shadowAsserter = ShadowAsserter.forShadow(accountProvisioningFuture,"future"); + shadowAsserter = ShadowAsserter.forShadow(accountProvisioningFuture, "future"); shadowAsserter .display() .assertIsExists() @@ -2765,16 +2780,17 @@ private void assertMorganDeleteFailed() throws Exception { .assertHasPrimaryIdentifier() .assertHasSecondaryIdentifier() .assertSize(2); + // @formatter:on // Check if the shadow is still in the repo (e.g. that the consistency or sync haven't removed it) checkUniqueness(accountProvisioningFuture); dummyResource.resetBreakMode(); dummyResourceCtl.assertAccountByUsername(ACCOUNT_MORGAN_NAME) - .assertName(ACCOUNT_MORGAN_NAME) - .assertFullName(ACCOUNT_MORGAN_FULLNAME_CHM) - .assertEnabled() - .assertPassword(ACCOUNT_MORGAN_PASSWORD); + .assertName(ACCOUNT_MORGAN_NAME) + .assertFullName(ACCOUNT_MORGAN_FULLNAME_CHM) + .assertEnabled() + .assertPassword(ACCOUNT_MORGAN_PASSWORD); } private void assertDeletedMorgan(int expectedAttemptNumber, int expectenNumberOfPendingOperations) throws Exception { @@ -2782,7 +2798,8 @@ private void assertDeletedMorgan(int expectedAttemptNumber, int expectenNumberOf PrismObject repoShadow = getShadowRepo(shadowMorganOid); assertNotNull("Shadow was not created in the repository", repoShadow); - ShadowAsserter shadowAsserter = ShadowAsserter.forShadow(repoShadow, "repository"); + // @formatter:off + ShadowAsserter shadowAsserter = ShadowAsserter.forShadow(repoShadow, "repository"); shadowAsserter .display() .pendingOperations() @@ -2834,70 +2851,77 @@ private void assertDeletedMorgan(int expectedAttemptNumber, int expectenNumberOf .assertLastAttemptTimestamp(lastAttemptStartTs, lastAttemptEndTs) .delta() .assertDelete(); + // @formatter:on assertShadowProvisioning(shadowMorganOid) - .assertTombstone(); + .assertTombstone(); assertShadowFuture(shadowMorganOid) - .assertTombstone(); + .assertTombstone(); assertShadowFutureNoFetch(shadowMorganOid) - .assertTombstone(); + .assertTombstone(); dummyResource.resetBreakMode(); dummyResourceCtl.assertNoAccountByUsername(ACCOUNT_MORGAN_NAME); } - private void assertResourceStatusChangeCounterIncrements() { assertCounterIncrement(InternalCounters.RESOURCE_REPOSITORY_MODIFY_COUNT, 1); assertCounterIncrement(InternalCounters.RESOURCE_REPOSITORY_READ_COUNT, 1); assertCounterIncrement(InternalCounters.RESOURCE_SCHEMA_PARSE_COUNT, 1); } - private void assertGetUncreatedShadow(String oid) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = getTestTask(); - OperationResult result = task.getResult(); + private void assertGetUncreatedShadow(String oid) + throws ObjectNotFoundException, CommunicationException, SchemaException, + ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + OperationResult result = createSubresult("assertGetUncreatedShadow"); try { - PrismObject shadow = provisioningService.getObject(ShadowType.class, - oid, null, task, result); - fail("Expected that get of uncreated shadow fails, but it was successful: "+shadow); + PrismObject shadow = provisioningService.getObject( + ShadowType.class, oid, null, getTestTask(), result); + fail("Expected that get of uncreated shadow fails, but it was successful: " + shadow); } catch (GenericConnectorException e) { // Expected } } - private PrismObject getShadowNoFetch(String oid) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = getTestTask(); - OperationResult result = task.getResult(); - Collection> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch()); + private PrismObject getShadowNoFetch(String oid) + throws ObjectNotFoundException, CommunicationException, SchemaException, + ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + OperationResult result = createSubresult("getShadowNoFetch"); + Collection> options = + SelectorOptions.createCollection(GetOperationOptions.createNoFetch()); PrismObject shadow = provisioningService.getObject(ShadowType.class, - oid, options, task, result); + oid, options, getTestTask(), result); assertSuccess(result); return shadow; } - private PrismObject getShadowFuture(String oid) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = getTestTask(); - OperationResult result = task.getResult(); - Collection> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); - PrismObject shadow = provisioningService.getObject(ShadowType.class, - oid, options, task, result); + private PrismObject getShadowFuture(String oid) + throws ObjectNotFoundException, CommunicationException, SchemaException, + ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + OperationResult result = createSubresult("getShadowFuture"); + Collection> options = + SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); + PrismObject shadow = provisioningService.getObject( + ShadowType.class, oid, options, getTestTask(), result); assertSuccess(result); return shadow; } - private PrismObject getShadowFuturePartialError(String oid) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = getTestTask(); - OperationResult result = task.getResult(); - Collection> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); - PrismObject shadow = provisioningService.getObject(ShadowType.class, - oid, options, task, result); + private PrismObject getShadowFuturePartialError(String oid) + throws ObjectNotFoundException, CommunicationException, SchemaException, + ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + OperationResult result = createSubresult("getShadowFuturePartialError"); + Collection> options = + SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); + PrismObject shadow = provisioningService.getObject( + ShadowType.class, oid, options, getTestTask(), result); assertPartialError(result); return shadow; } - // TODO: shadow with legacy postponed operation: shoudl be cleaned up + // TODO: shadow with legacy postponed operation: should be cleaned up // TODO: retries of propagated operations } diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyParallelism.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyParallelism.java index b720febdf6d..3f29e9fdd5f 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyParallelism.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyParallelism.java @@ -12,10 +12,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; - import javax.xml.namespace.QName; -import com.evolveum.midpoint.schema.cache.CacheConfigurationManager; import org.apache.commons.lang.mutable.MutableBoolean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.annotation.DirtiesContext; @@ -33,6 +31,7 @@ import com.evolveum.midpoint.repo.cache.RepositoryCache; import com.evolveum.midpoint.schema.ResultHandler; import com.evolveum.midpoint.schema.SearchResultList; +import com.evolveum.midpoint.schema.cache.CacheConfigurationManager; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition; import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition; @@ -48,30 +47,16 @@ import com.evolveum.midpoint.test.util.Counter; import com.evolveum.midpoint.test.util.ParallelTestThread; import com.evolveum.midpoint.util.FailableProducer; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; -import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.PolicyViolationException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SecurityViolationException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationProvisioningScriptsType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.PendingOperationExecutionStatusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; +import com.evolveum.midpoint.util.exception.*; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; /** * The test of Provisioning service on the API level. - * + *

* This test is focused on parallelism and race conditions. * The resource is configured to use proposed shadows and to record all * operations. - * + *

* The test is using dummy resource for speed and flexibility. * * @author Radovan Semancik @@ -81,8 +66,6 @@ @Listeners({ com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class }) public class TestDummyParallelism extends AbstractBasicDummyTest { - private static final Trace LOGGER = TraceManager.getTrace(TestDummyParallelism.class); - @Autowired private CacheConfigurationManager cacheConfigurationManager; public static final File TEST_DIR = new File(TEST_DIR_DUMMY, "dummy-parallelism"); @@ -93,29 +76,28 @@ public class TestDummyParallelism extends AbstractBasicDummyTest { private static final long WAIT_TIMEOUT = 60000L; private static final int DUMMY_OPERATION_DELAY_RANGE = 1500; - - private static final int MESS_RESOURCE_ITERATIONS = 200; + private static final int MESS_RESOURCE_ITERATIONS = 100; private static final Random RND = new Random(); + /** + * Typical base thread count for non-heavy tasks. + */ + protected static final int CONCURRENT_TEST_THREAD_COUNT = 4; + protected static final int CONCURRENT_TEST_THREAD_COUNT_MAX = 15; + protected static final int CONCURRENT_TEST_THREAD_COUNT_HIGH = Math.min( + CONCURRENT_TEST_THREAD_COUNT + Runtime.getRuntime().availableProcessors() / 2, + CONCURRENT_TEST_THREAD_COUNT_MAX); + + protected static final int CONCURRENT_TEST_MAX_START_DELAY_FAST = 10; + protected static final int CONCURRENT_TEST_MAX_START_DELAY_SLOW = 150; + private String accountMorganOid; private String accountElizabethOid; private String accountWallyOid; private String groupScumOid; - protected int getConcurrentTestNumberOfThreads() { - return 5; - } - - protected int getConcurrentTestFastRandomStartDelayRange() { - return 10; - } - - protected int getConcurrentTestSlowRandomStartDelayRange() { - return 150; - } - @Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { super.initSystem(initTask, initResult); @@ -131,12 +113,12 @@ protected File getResourceDummyFile() { protected void assertWillRepoShadowAfterCreate(PrismObject repoShadow) { ShadowAsserter.forShadow(repoShadow, "repo") - .assertActiveLifecycleState() - .pendingOperations() + .assertActiveLifecycleState() + .pendingOperations() .singleOperation() - .assertExecutionStatus(PendingOperationExecutionStatusType.COMPLETED) - .delta() - .assertAdd(); + .assertExecutionStatus(PendingOperationExecutionStatusType.COMPLETED) + .delta() + .assertAdd(); } @Test @@ -162,16 +144,16 @@ public void test120ModifyWillReplaceFullname() throws Exception { assertSuccess(result); assertDummyAccount(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid) - .assertAttribute(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Pirate Will Turner"); + .assertAttribute(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Pirate Will Turner"); assertRepoShadow(ACCOUNT_WILL_OID) - .assertActiveLifecycleState() - .pendingOperations() + .assertActiveLifecycleState() + .pendingOperations() .assertOperations(2) .modifyOperation() - .assertExecutionStatus(PendingOperationExecutionStatusType.COMPLETED) - .delta() - .assertModify(); + .assertExecutionStatus(PendingOperationExecutionStatusType.COMPLETED) + .delta() + .assertModify(); syncServiceMock.assertNotifySuccessOnly(); @@ -198,17 +180,17 @@ public void test190DeleteWill() throws Exception { assertNoDummyAccount(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid); assertRepoShadow(ACCOUNT_WILL_OID) - .assertDead() - .assertIsNotExists() - .pendingOperations() + .assertDead() + .assertIsNotExists() + .pendingOperations() .assertOperations(3) .deleteOperation() - .assertExecutionStatus(PendingOperationExecutionStatusType.COMPLETED) - .delta() - .assertDelete(); + .assertExecutionStatus(PendingOperationExecutionStatusType.COMPLETED) + .delta() + .assertDelete(); assertShadowProvisioning(ACCOUNT_WILL_OID) - .assertTombstone(); + .assertTombstone(); assertSteadyResource(); } @@ -234,13 +216,13 @@ public void test200ParallelCreate() throws Exception { ParallelTestThread[] threads = multithread(TEST_NAME, (i) -> { - Task localTask = getTestTask(); - OperationResult localResult = localTask.getResult(); + OperationResult localResult = task.getResult().createSubresult("thread-" + i); ShadowType account = parseObjectType(ACCOUNT_MORGAN_FILE, ShadowType.class); try { - String thisAccountMorganOid = provisioningService.addObject(account.asPrismObject(), null, null, localTask, localResult); + String thisAccountMorganOid = provisioningService.addObject( + account.asPrismObject(), null, null, task, localResult); successCounter.click(); synchronized (dummyResource) { @@ -252,10 +234,10 @@ public void test200ParallelCreate() throws Exception { } } catch (ObjectAlreadyExistsException e) { // this is expected ... sometimes - LOGGER.info("Exception (maybe expected): {}: {}", e.getClass().getSimpleName(), e.getMessage()); + logger.info("Exception (maybe expected): {}: {}", e.getClass().getSimpleName(), e.getMessage()); } - }, 15, getConcurrentTestFastRandomStartDelayRange()); + }, CONCURRENT_TEST_THREAD_COUNT_HIGH, CONCURRENT_TEST_MAX_START_DELAY_FAST); // THEN displayThen(TEST_NAME); @@ -276,7 +258,7 @@ public void test200ParallelCreate() throws Exception { /** * Create a lot parallel modifications for the same property and the same value. * These should all be eliminated - except for one of them. - * + *

* There is a slight chance that one of the thread starts after the first operation * is finished. But the threads are fast and the operations are slow. So this is * a very slim chance. @@ -295,7 +277,7 @@ public void test202ParallelModifyCaptainMorgan() throws Exception { /** * Create a lot parallel modifications for the same property and the same value. * These should all be eliminated - except for one of them. - * + *

* There is a slight chance that one of the thread starts after the first operation * is finished. But the threads are fast and the operations are slow. So this is * a very slim chance. @@ -326,23 +308,22 @@ private PrismObject parallelModifyTest(final String TEST_NAME, Faila ParallelTestThread[] threads = multithread(TEST_NAME, (i) -> { - Task localTask = getTestTask(); - OperationResult localResult = localTask.getResult(); + OperationResult localResult = task.getResult().createSubresult("thread-" + i); RepositoryCache.enter(cacheConfigurationManager); // Playing with cache, trying to make a worst case PrismObject shadowBefore = repositoryService.getObject(ShadowType.class, accountMorganOid, null, localResult); - randomDelay(getConcurrentTestSlowRandomStartDelayRange()); - LOGGER.info("{} starting to do some work", Thread.currentThread().getName()); + randomDelay(CONCURRENT_TEST_MAX_START_DELAY_SLOW); + logger.info("{} starting to do some work", Thread.currentThread().getName()); ObjectDelta delta = deltaProducer.run(); display("ObjectDelta", delta); - provisioningService.modifyObject(ShadowType.class, accountMorganOid, delta.getModifications(), null, null, localTask, localResult); + provisioningService.modifyObject(ShadowType.class, accountMorganOid, delta.getModifications(), null, null, task, localResult); localResult.computeStatus(); - display("Thread "+Thread.currentThread().getName()+" DONE, result", localResult); + display("Thread " + Thread.currentThread().getName() + " DONE, result", localResult); if (localResult.isSuccess()) { successCounter.click(); } else if (localResult.isInProgress()) { @@ -353,7 +334,7 @@ private PrismObject parallelModifyTest(final String TEST_NAME, Faila RepositoryCache.exit(); - }, getConcurrentTestNumberOfThreads(), getConcurrentTestFastRandomStartDelayRange()); + }, CONCURRENT_TEST_THREAD_COUNT, CONCURRENT_TEST_MAX_START_DELAY_FAST); // THEN displayThen(TEST_NAME); @@ -382,18 +363,18 @@ public void test209ParallelDelete() throws Exception { // WHEN displayWhen(TEST_NAME); + Task task = getTestTask(); ParallelTestThread[] threads = multithread(TEST_NAME, (i) -> { - Task localTask = getTestTask(); - OperationResult localResult = localTask.getResult(); + OperationResult localResult = task.getResult().createSubresult("thread-" + i); RepositoryCache.enter(cacheConfigurationManager); try { - display("Thread "+Thread.currentThread().getName()+" START"); - provisioningService.deleteObject(ShadowType.class, accountMorganOid, null, null, localTask, localResult); + display("Thread " + Thread.currentThread().getName() + " START"); + provisioningService.deleteObject(ShadowType.class, accountMorganOid, null, null, task, localResult); localResult.computeStatus(); - display("Thread "+Thread.currentThread().getName()+" DONE, result", localResult); + display("Thread " + Thread.currentThread().getName() + " DONE, result", localResult); if (localResult.isSuccess()) { successCounter.click(); } else if (localResult.isInProgress()) { @@ -405,12 +386,12 @@ public void test209ParallelDelete() throws Exception { } } catch (ObjectNotFoundException e) { // this is expected ... sometimes - LOGGER.info("Exception (maybe expected): {}: {}", e.getClass().getSimpleName(), e.getMessage()); + logger.info("Exception (maybe expected): {}: {}", e.getClass().getSimpleName(), e.getMessage()); } finally { RepositoryCache.exit(); } - }, getConcurrentTestNumberOfThreads(), getConcurrentTestFastRandomStartDelayRange()); + }, CONCURRENT_TEST_THREAD_COUNT, CONCURRENT_TEST_MAX_START_DELAY_FAST); // THEN displayThen(TEST_NAME); @@ -419,10 +400,10 @@ public void test209ParallelDelete() throws Exception { successCounter.assertCount("Wrong number of successful operations", 1); assertRepoShadow(accountMorganOid) - .assertTombstone(); + .assertTombstone(); assertShadowProvisioning(accountMorganOid) - .assertTombstone(); + .assertTombstone(); assertDummyResourceWriteOperationCountIncrement(null, 1); @@ -444,27 +425,26 @@ public void test210ParallelCreateSlow() throws Exception { ParallelTestThread[] threads = multithread(TEST_NAME, (i) -> { - Task localTask = getTestTask(); - OperationResult localResult = localTask.getResult(); + OperationResult localResult = task.getResult().createSubresult("thread-" + i); RepositoryCache.enter(cacheConfigurationManager); - randomDelay(getConcurrentTestSlowRandomStartDelayRange()); - LOGGER.info("{} starting to do some work", Thread.currentThread().getName()); + randomDelay(CONCURRENT_TEST_MAX_START_DELAY_SLOW); + logger.info("{} starting to do some work", Thread.currentThread().getName()); ShadowType account = parseObjectType(ACCOUNT_ELIZABETH_FILE, ShadowType.class); try { - accountElizabethOid = provisioningService.addObject(account.asPrismObject(), null, null, localTask, localResult); + accountElizabethOid = provisioningService.addObject(account.asPrismObject(), null, null, task, localResult); successCounter.click(); } catch (ObjectAlreadyExistsException e) { // this is expected ... sometimes - LOGGER.info("Exception (maybe expected): {}: {}", e.getClass().getSimpleName(), e.getMessage()); + logger.info("Exception (maybe expected): {}: {}", e.getClass().getSimpleName(), e.getMessage()); } finally { RepositoryCache.exit(); } - }, getConcurrentTestNumberOfThreads(), null); + }, CONCURRENT_TEST_THREAD_COUNT, null); // THEN displayThen(TEST_NAME); @@ -483,7 +463,7 @@ public void test210ParallelCreateSlow() throws Exception { /** * Create a lot parallel modifications for the same property and the same value. * These should all be eliminated - except for one of them. - * + *

* There is a slight chance that one of the thread starts after the first operation * is finished. But the threads are fast and the operations are slow. So this is * a very slim chance. @@ -502,7 +482,7 @@ public void test212ParallelModifyElizabethSlow() throws Exception { /** * Create a lot parallel modifications for the same property and the same value. * These should all be eliminated - except for one of them. - * + *

* There is a slight chance that one of the thread starts after the first operation * is finished. But the threads are fast and the operations are slow. So this is * a very slim chance. @@ -533,23 +513,22 @@ private PrismObject parallelModifyTestSlow(final String TEST_NAME, F ParallelTestThread[] threads = multithread(TEST_NAME, (i) -> { - Task localTask = getTestTask(); - OperationResult localResult = localTask.getResult(); + OperationResult localResult = task.getResult().createSubresult("thread-" + i); RepositoryCache.enter(cacheConfigurationManager); // Playing with cache, trying to make a worst case PrismObject shadowBefore = repositoryService.getObject(ShadowType.class, accountElizabethOid, null, localResult); - randomDelay(getConcurrentTestSlowRandomStartDelayRange()); - LOGGER.info("{} starting to do some work", Thread.currentThread().getName()); + randomDelay(CONCURRENT_TEST_MAX_START_DELAY_SLOW); + logger.info("{} starting to do some work", Thread.currentThread().getName()); ObjectDelta delta = deltaProducer.run(); display("ObjectDelta", delta); - provisioningService.modifyObject(ShadowType.class, accountElizabethOid, delta.getModifications(), null, null, localTask, localResult); + provisioningService.modifyObject(ShadowType.class, accountElizabethOid, delta.getModifications(), null, null, task, localResult); localResult.computeStatus(); - display("Thread "+Thread.currentThread().getName()+" DONE, result", localResult); + display("Thread " + Thread.currentThread().getName() + " DONE, result", localResult); if (localResult.isSuccess()) { successCounter.click(); } else if (localResult.isInProgress()) { @@ -560,7 +539,7 @@ private PrismObject parallelModifyTestSlow(final String TEST_NAME, F RepositoryCache.exit(); - }, getConcurrentTestNumberOfThreads(), null); + }, CONCURRENT_TEST_THREAD_COUNT, null); // THEN displayThen(TEST_NAME); @@ -578,7 +557,6 @@ private PrismObject parallelModifyTestSlow(final String TEST_NAME, F return shadowAfter; } - @Test public void test229ParallelDeleteSlow() throws Exception { final String TEST_NAME = "test229ParallelDeleteSlow"; @@ -590,23 +568,23 @@ public void test229ParallelDeleteSlow() throws Exception { // WHEN displayWhen(TEST_NAME); + Task task = getTestTask(); ParallelTestThread[] threads = multithread(TEST_NAME, (i) -> { - Task localTask = getTestTask(); - OperationResult localResult = localTask.getResult(); + OperationResult localResult = task.getResult().createSubresult("thread-" + i); RepositoryCache.enter(cacheConfigurationManager); // Playing with cache, trying to make a worst case PrismObject shadowBefore = repositoryService.getObject(ShadowType.class, accountElizabethOid, null, localResult); - randomDelay(getConcurrentTestSlowRandomStartDelayRange()); - LOGGER.info("{} starting to do some work", Thread.currentThread().getName()); + randomDelay(CONCURRENT_TEST_MAX_START_DELAY_SLOW); + logger.info("{} starting to do some work", Thread.currentThread().getName()); try { - display("Thread "+Thread.currentThread().getName()+" START"); - provisioningService.deleteObject(ShadowType.class, accountElizabethOid, null, null, localTask, localResult); + display("Thread " + Thread.currentThread().getName() + " START"); + provisioningService.deleteObject(ShadowType.class, accountElizabethOid, null, null, task, localResult); localResult.computeStatus(); - display("Thread "+Thread.currentThread().getName()+" DONE, result", localResult); + display("Thread " + Thread.currentThread().getName() + " DONE, result", localResult); if (localResult.isSuccess()) { successCounter.click(); } else if (localResult.isInProgress()) { @@ -616,12 +594,12 @@ public void test229ParallelDeleteSlow() throws Exception { } } catch (ObjectNotFoundException e) { // this is expected ... sometimes - LOGGER.info("Exception (maybe expected): {}: {}", e.getClass().getSimpleName(), e.getMessage()); + logger.info("Exception (maybe expected): {}: {}", e.getClass().getSimpleName(), e.getMessage()); } finally { RepositoryCache.exit(); } - }, getConcurrentTestNumberOfThreads(), null); + }, CONCURRENT_TEST_THREAD_COUNT, null); // THEN displayThen(TEST_NAME); @@ -630,10 +608,10 @@ public void test229ParallelDeleteSlow() throws Exception { successCounter.assertCount("Wrong number of successful operations", 1); assertRepoShadow(accountElizabethOid) - .assertTombstone(); + .assertTombstone(); assertShadowProvisioning(accountElizabethOid) - .assertTombstone(); + .assertTombstone(); assertDummyResourceWriteOperationCountIncrement(null, 1); @@ -645,7 +623,7 @@ public void test229ParallelDeleteSlow() throws Exception { * Do that in several threads at once. The group will be "discovered" * by the threads at the same time, each thread trying to create shadow. * There is a chance that the shadows get duplicated. - * + *

* MID-5237 */ @Test @@ -668,13 +646,10 @@ public void test230ParallelGroupSearch() throws Exception { ParallelTestThread[] threads = multithread(TEST_NAME, (i) -> { - Task localTask = getTestTask(); - OperationResult localResult = localTask.getResult(); - ObjectQuery query = createGroupNameQuery(GROUP_SCUM_NAME); SearchResultList> foundObjects = provisioningService.searchObjects(ShadowType.class, query, null, task, result); - assertEquals("Unexpected number of shadows found: "+foundObjects, 1, foundObjects.size()); + assertEquals("Unexpected number of shadows found: " + foundObjects, 1, foundObjects.size()); successCounter.click(); PrismObject groupShadow = foundObjects.get(0); @@ -736,7 +711,7 @@ private ObjectQuery createGroupNameQuery(String groupName) throws SchemaExceptio * Several threads reading from resource. Couple other threads try to get into the way * by modifying the resource, hence forcing connector re-initialization. * The goal is to detect connector initialization race conditions. - * + *

* MID-5068 */ @Test @@ -760,7 +735,7 @@ public void test800ParallelReadAndModifyResource() throws Exception { result.computeStatus(); if (result.getStatus() != OperationResultStatus.SUCCESS) { display("Failed read result (precondition)", result); - fail("Unexpected read status (precondition): "+result.getStatus()); + fail("Unexpected read status (precondition): " + result.getStatus()); } // WHEN @@ -772,62 +747,57 @@ public void test800ParallelReadAndModifyResource() throws Exception { ParallelTestThread[] threads = multithread(TEST_NAME, (threadIndex) -> { - if (threadIndex <= 6) { - + // roughly half the threads will try to mess with the resource + if (threadIndex < CONCURRENT_TEST_THREAD_COUNT_HIGH / 2) { for (int i = 0; /* neverending */ ; i++) { - messResource(TEST_NAME, threadIndex, i); - display("T +"+(System.currentTimeMillis() - t0)); + display("T +" + (System.currentTimeMillis() - t0)); if (readFinished.booleanValue()) { break; } - } - } else if (threadIndex == 7) { - + } else if (threadIndex == CONCURRENT_TEST_THREAD_COUNT_HIGH / 2) { for (int i = 0; /* neverending */ ; i++) { - - Task localTask = getTestTask(); - - LOGGER.debug("PAR: TESTing "+threadIndex+"."+i); - + Task localTask = createTask(TEST_NAME + ".test." + i); OperationResult testResult = provisioningService.testResource(RESOURCE_DUMMY_OID, localTask); - display("PAR: TESTed "+threadIndex+"."+i+": "+testResult.getStatus()); + logger.debug("PAR: TESTing " + threadIndex + "." + i); + + display("PAR: TESTed " + threadIndex + "." + i + ": " + testResult.getStatus()); if (testResult.getStatus() != OperationResultStatus.SUCCESS) { display("Failed test resource result", testResult); readFinished.setValue(true); - fail("Unexpected test resource result status: "+testResult.getStatus()); + fail("Unexpected test resource result status: " + testResult.getStatus()); } if (readFinished.booleanValue()) { break; } - } } else { - + // the rest nearly half of the threads will try to do operations try { + // TODO: why is the constant MESS_RESOURCE_ITERATIONS used for operations? for (int i = 0; i < MESS_RESOURCE_ITERATIONS; i++) { - Task localTask = getTestTask(); + Task localTask = createTask(TEST_NAME + ".op." + i); OperationResult localResult = localTask.getResult(); - LOGGER.debug("PAR: OPing "+threadIndex+"."+i); + logger.debug("PAR: OPing " + threadIndex + "." + i); - Object out = doResourceOperation(threadIndex, i, localTask, localResult); + Object out = doResourceOperation(task, localResult); localResult.computeStatus(); - display("PAR: OPed "+threadIndex+"."+i+": " + out.toString() + ": "+localResult.getStatus()); + display("PAR: OPed " + threadIndex + "." + i + ": " + out.toString() + ": " + localResult.getStatus()); if (localResult.getStatus() != OperationResultStatus.SUCCESS) { display("Failed read result", localResult); readFinished.setValue(true); - fail("Unexpected read status: "+localResult.getStatus()); + fail("Unexpected read status: " + localResult.getStatus()); } if (readFinished.booleanValue()) { @@ -839,9 +809,9 @@ public void test800ParallelReadAndModifyResource() throws Exception { } } - display("mischief managed ("+threadIndex+")"); + display("mischief managed (" + threadIndex + ")"); - }, 15, getConcurrentTestFastRandomStartDelayRange()); + }, CONCURRENT_TEST_THREAD_COUNT_HIGH, CONCURRENT_TEST_MAX_START_DELAY_FAST); // THEN displayThen(TEST_NAME); @@ -858,7 +828,7 @@ public void test800ParallelReadAndModifyResource() throws Exception { assertDummyConnectorInstances(dummyResource.getConnectionCount()); } - private Object doResourceOperation(int threadIndex, int i, Task task, OperationResult result) throws Exception { + private Object doResourceOperation(Task task, OperationResult result) throws Exception { int op = RND.nextInt(3); if (op == 0) { @@ -867,7 +837,10 @@ private Object doResourceOperation(int threadIndex, int i, Task task, OperationR } else if (op == 1) { ObjectQuery query = ObjectQueryUtil.createResourceAndKind(RESOURCE_DUMMY_OID, ShadowKindType.ACCOUNT, prismContext); List> list = new ArrayList<>(); - ResultHandler handler = (o,or) -> { list.add(o); return true; }; + ResultHandler handler = (o, or) -> { + list.add(o); + return true; + }; provisioningService.searchObjectsIterative(ShadowType.class, query, null, handler, task, result); return list; @@ -878,23 +851,26 @@ private Object doResourceOperation(int threadIndex, int i, Task task, OperationR return null; } - private void messResource(final String TEST_NAME, int threadIndex, int i) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, PolicyViolationException, ObjectAlreadyExistsException, ExpressionEvaluationException { - Task task = getTestTask(); + private void messResource(final String TEST_NAME, int threadIndex, int i) + throws ObjectNotFoundException, SchemaException, CommunicationException, + ConfigurationException, SecurityViolationException, PolicyViolationException, + ObjectAlreadyExistsException, ExpressionEvaluationException { + Task task = createTask(TEST_NAME + ".mess." + threadIndex + "." + i); OperationResult result = task.getResult(); - List> deltas = deltaFor(ResourceType.class) - .item(ResourceType.F_DESCRIPTION).replace("Iter "+threadIndex+"."+i) - .asItemDeltas(); + List> deltas = deltaFor(ResourceType.class) + .item(ResourceType.F_DESCRIPTION).replace("Iter " + threadIndex + "." + i) + .asItemDeltas(); - LOGGER.debug("PAR: MESSing "+threadIndex+"."+i); + logger.debug("PAR: MESSing " + threadIndex + "." + i); provisioningService.modifyObject(ResourceType.class, RESOURCE_DUMMY_OID, deltas, null, null, task, result); result.computeStatus(); - display("PAR: MESSed "+threadIndex+"."+i+": "+result.getStatus()); + display("PAR: MESSed " + threadIndex + "." + i + ": " + result.getStatus()); if (result.getStatus() != OperationResultStatus.SUCCESS) { display("Failed mess resource result", result); - fail("Unexpected mess resource result status: "+result.getStatus()); + fail("Unexpected mess resource result status: " + result.getStatus()); } } } diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjDumber.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjDumber.java index 5b3316d20bd..6c1fc9748dc 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjDumber.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjDumber.java @@ -20,8 +20,6 @@ import com.evolveum.midpoint.schema.internals.InternalCounters; import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition; import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import org.testng.annotations.Test; /** @@ -37,8 +35,6 @@ public class TestOpenDjDumber extends TestOpenDj { protected static final File RESOURCE_OPENDJ_DUMBER_FILE = new File(TEST_DIR, "resource-opendj-dumber.xml"); - private static final Trace LOGGER = TraceManager.getTrace(TestOpenDjDumber.class); - @Override protected File getResourceOpenDjFile() { return RESOURCE_OPENDJ_DUMBER_FILE; diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjReadablePassword.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjReadablePassword.java index 6f6e2b65e30..b4728ad35f5 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjReadablePassword.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjReadablePassword.java @@ -17,8 +17,6 @@ import com.evolveum.midpoint.prism.PrismContainerValue; import com.evolveum.midpoint.prism.PrismProperty; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType; import com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; @@ -37,8 +35,6 @@ public class TestOpenDjReadablePassword extends TestOpenDj { protected static final File RESOURCE_OPENDJ_READABLE_PASSWORD_FILE = new File(TEST_DIR, "resource-opendj-readable-password.xml"); - private static final Trace LOGGER = TraceManager.getTrace(TestOpenDjReadablePassword.class); - @Override protected File getResourceOpenDjFile() { return RESOURCE_OPENDJ_READABLE_PASSWORD_FILE; From dd25e869ef8cd1ec55c7435a975b707b43d46471 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Fri, 28 Feb 2020 00:09:17 +0100 Subject: [PATCH 39/97] .editorconfig: ij_formatter_tags_enabled = true (I forgot it before) --- .editorconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.editorconfig b/.editorconfig index 5092bd92234..e69d9ac9836 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,7 +10,7 @@ trim_trailing_whitespace = true ij_continuation_indent_size = 8 ij_formatter_off_tag = @formatter:off ij_formatter_on_tag = @formatter:on -ij_formatter_tags_enabled = false +ij_formatter_tags_enabled = true ij_smart_tabs = false ij_visual_guides = 100,130,150,180 ij_wrap_on_typing = false @@ -156,7 +156,7 @@ ij_java_keep_first_column_comment = true ij_java_keep_indents_on_empty_lines = false ij_java_keep_line_breaks = true ij_java_keep_multiple_expressions_in_one_line = false -ij_java_keep_simple_blocks_in_one_line = false +ij_java_keep_simple_blocks_in_one_line = true ij_java_keep_simple_classes_in_one_line = false ij_java_keep_simple_lambdas_in_one_line = false ij_java_keep_simple_methods_in_one_line = false From 3b336604b34b957c77d498f4d72055032a912060 Mon Sep 17 00:00:00 2001 From: lskublik Date: Fri, 28 Feb 2020 10:46:21 +0100 Subject: [PATCH 40/97] adding fix for basic expression field --- .../impl/factory/ConditionPanelFactory.java | 5 +- ...ressionModel.java => ExpressionModel.java} | 195 +++++++++--------- .../component/ExpressionPropertyPanel.html | 4 +- .../component/ExpressionPropertyPanel.java | 14 +- .../midpoint/web/util/ExpressionUtil.java | 2 +- 5 files changed, 113 insertions(+), 107 deletions(-) rename gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/factory/{ConditionExpressionModel.java => ExpressionModel.java} (86%) diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/factory/ConditionPanelFactory.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/factory/ConditionPanelFactory.java index 4737c3a234f..527f86fd86e 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/factory/ConditionPanelFactory.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/factory/ConditionPanelFactory.java @@ -11,14 +11,11 @@ import com.evolveum.midpoint.gui.impl.prism.PrismPropertyWrapper; import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.util.QNameUtil; -import com.evolveum.midpoint.web.component.AceEditor; import com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour; import com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior; import com.evolveum.midpoint.web.page.admin.reports.component.AceEditorPanel; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.ajax.form.OnChangeAjaxBehavior; import org.apache.wicket.markup.html.panel.Panel; import org.springframework.stereotype.Component; @@ -35,7 +32,7 @@ public void register() { @Override protected Panel getPanel(PrismPropertyPanelContext panelCtx) { - AceEditorPanel conditionPanel = new AceEditorPanel(panelCtx.getComponentId(), null, new ConditionExpressionModel(panelCtx.getRealValueModel(), panelCtx.getPageBase()), 200){ + AceEditorPanel conditionPanel = new AceEditorPanel(panelCtx.getComponentId(), null, new ExpressionModel(panelCtx.getRealValueModel(), panelCtx.getPageBase()), 200){ @Override protected boolean isResizeToMaxHeight() { return false; diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/factory/ConditionExpressionModel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/factory/ExpressionModel.java similarity index 86% rename from gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/factory/ConditionExpressionModel.java rename to gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/factory/ExpressionModel.java index e5bab8b7c48..feb187dc796 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/factory/ConditionExpressionModel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/factory/ExpressionModel.java @@ -1,99 +1,96 @@ -/* - * Copyright (c) 2020 Evolveum and contributors - * - * This work is dual-licensed under the Apache License 2.0 - * and European Union Public License. See LICENSE file for details. - */ -package com.evolveum.midpoint.gui.impl.factory; - -import com.evolveum.midpoint.web.util.ExpressionUtil; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType; - -import com.evolveum.prism.xml.ns._public.types_3.RawType; - -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.wicket.model.IModel; - -import com.evolveum.midpoint.gui.api.page.PageBase; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.logging.LoggingUtils; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.prism.xml.ns._public.query_3.SearchFilterType; - -import javax.xml.bind.JAXBElement; -import java.util.List; - -public class ConditionExpressionModel implements IModel { - - private static final Trace LOGGER = TraceManager.getTrace(ConditionExpressionModel.class); - - private static final long serialVersionUID = 1L; - - private IModel baseModel; - private PageBase pageBase; - - public ConditionExpressionModel(IModel valueWrapper, PageBase pageBase) { - this.baseModel = valueWrapper; - this.pageBase = pageBase; - } - - @Override - public void detach() { - // TODO Auto-generated method stub - - } - - @Override - public String getObject() { - try { - ExpressionType value = baseModel.getObject(); - if (value == null) { - return null; - } - - List> evaluatros = value.getExpressionEvaluator(); - //should be one - if (CollectionUtils.isEmpty(evaluatros)) { - return null; - } - if (evaluatros.size() > 1) { - LOGGER.warn("More than one evaluator found. getting first of them"); - } - - JAXBElement evaluator = evaluatros.get(0); - if (evaluator == null) { - return null; - } - - return ExpressionUtil.serialize(evaluator, pageBase.getPrismContext()); - - } catch (SchemaException e) { - // TODO handle!!!! - LoggingUtils.logUnexpectedException(LOGGER, "Cannot serialize filter", e); -// getSession().error("Cannot serialize filter"); - } - return null; - } - - @Override - public void setObject(String object) { - if (StringUtils.isBlank(object)) { - baseModel.setObject(null); - return; - } - - try { - ExpressionType condition = new ExpressionType(); - ExpressionUtil.parseExpressionEvaluators(object, condition, pageBase.getPrismContext()); -// ExpressionType condition = pageBase.getPrismContext().parserFor(object).parseRealValue(); - baseModel.setObject(condition); - } catch (Exception e) { - // TODO handle!!!! - LoggingUtils.logUnexpectedException(LOGGER, "Cannot parse filter", e); -// getSession().error("Cannot parse filter"); - } - - } -} +/* + * Copyright (c) 2020 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ +package com.evolveum.midpoint.gui.impl.factory; + +import com.evolveum.midpoint.web.util.ExpressionUtil; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType; + +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.wicket.model.IModel; + +import com.evolveum.midpoint.gui.api.page.PageBase; +import com.evolveum.midpoint.util.exception.SchemaException; +import com.evolveum.midpoint.util.logging.LoggingUtils; +import com.evolveum.midpoint.util.logging.Trace; +import com.evolveum.midpoint.util.logging.TraceManager; + +import javax.xml.bind.JAXBElement; +import java.util.List; + +public class ExpressionModel implements IModel { + + private static final Trace LOGGER = TraceManager.getTrace(ExpressionModel.class); + + private static final long serialVersionUID = 1L; + + private IModel baseModel; + private PageBase pageBase; + + public ExpressionModel(IModel valueWrapper, PageBase pageBase) { + this.baseModel = valueWrapper; + this.pageBase = pageBase; + } + + @Override + public void detach() { + // TODO Auto-generated method stub + + } + + @Override + public String getObject() { + try { + ExpressionType value = baseModel.getObject(); + if (value == null) { + return null; + } + + List> evaluatros = value.getExpressionEvaluator(); + //should be one + if (CollectionUtils.isEmpty(evaluatros)) { + return null; + } + if (evaluatros.size() > 1) { + LOGGER.warn("More than one evaluator found. getting first of them"); + } + + JAXBElement evaluator = evaluatros.get(0); + if (evaluator == null) { + return null; + } + + return ExpressionUtil.serialize(evaluator, pageBase.getPrismContext()); + + } catch (SchemaException e) { + // TODO handle!!!! + LoggingUtils.logUnexpectedException(LOGGER, "Cannot serialize filter", e); +// getSession().error("Cannot serialize filter"); + } + return null; + } + + @Override + public void setObject(String object) { + if (StringUtils.isBlank(object)) { + baseModel.setObject(null); + return; + } + + try { + ExpressionType condition = new ExpressionType(); + ExpressionUtil.parseExpressionEvaluators(object, condition, pageBase.getPrismContext()); +// ExpressionType condition = pageBase.getPrismContext().parserFor(object).parseRealValue(); + baseModel.setObject(condition); + } catch (Exception e) { + // TODO handle!!!! + LoggingUtils.logUnexpectedException(LOGGER, "Cannot parse filter", e); +// getSession().error("Cannot parse filter"); + } + + } +} diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/prism/component/ExpressionPropertyPanel.html b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/prism/component/ExpressionPropertyPanel.html index 3367af4a3eb..d2882ee6181 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/prism/component/ExpressionPropertyPanel.html +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/prism/component/ExpressionPropertyPanel.html @@ -8,9 +8,9 @@ -

+
-
+
diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/prism/component/ExpressionPropertyPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/prism/component/ExpressionPropertyPanel.java index 9e0be30ae2d..c9dcd24c706 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/prism/component/ExpressionPropertyPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/prism/component/ExpressionPropertyPanel.java @@ -8,6 +8,7 @@ import com.evolveum.midpoint.gui.api.factory.GuiComponentFactory; import com.evolveum.midpoint.gui.api.model.ReadOnlyValueModel; +import com.evolveum.midpoint.gui.impl.factory.ExpressionModel; import com.evolveum.midpoint.gui.impl.factory.ItemRealValueModel; import com.evolveum.midpoint.gui.impl.factory.WrapperContext; import com.evolveum.midpoint.gui.impl.prism.*; @@ -20,6 +21,9 @@ import com.evolveum.midpoint.web.component.input.TextPanel; import com.evolveum.midpoint.web.component.prism.ValueStatus; import com.evolveum.midpoint.web.component.util.VisibleBehaviour; +import com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour; +import com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior; +import com.evolveum.midpoint.web.page.admin.reports.component.AceEditorPanel; import com.evolveum.midpoint.web.util.ExpressionUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType; import org.apache.commons.collections.CollectionUtils; @@ -99,7 +103,15 @@ protected Component createValuePanel(ListItem isExpanded)); item.add(expressionPanel); } else { - expressionPanel = new TextPanel(ID_EXPRESSION_PANEL, Model.of(getModelObject().getItem().getRealValue())); + ItemRealValueModel realValueModel = new ItemRealValueModel(item.getModel()); + expressionPanel = new AceEditorPanel(ID_EXPRESSION_PANEL, null, new ExpressionModel(realValueModel, getPageBase()), 200){ + @Override + protected boolean isResizeToMaxHeight() { + return false; + } + }; + ((AceEditorPanel)expressionPanel).getEditor().add(new EmptyOnBlurAjaxFormUpdatingBehaviour()); + ((AceEditorPanel)expressionPanel).getEditor().add(new EmptyOnChangeAjaxFormUpdatingBehavior()); expressionPanel.add(new VisibleBehaviour(() -> isExpanded)); item.add(expressionPanel); } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/util/ExpressionUtil.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/util/ExpressionUtil.java index c7227bae653..5d104600b62 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/util/ExpressionUtil.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/util/ExpressionUtil.java @@ -272,7 +272,7 @@ public static void parseExpressionEvaluators(String xml, ExpressionType expressi expressionObject.getExpressionEvaluator().clear(); if (StringUtils.isNotBlank(xml)) { xml = WebXmlUtil.wrapInElement("expression", xml, true); - LOGGER.info("Expression to serialize: {}", xml); + LOGGER.trace("Expression to serialize: {}", xml); JAXBElement newElement = context.parserFor(xml).xml().parseRealValueToJaxbElement(); expressionObject.getExpressionEvaluator().addAll(((ExpressionType) (newElement.getValue())).getExpressionEvaluator()); } From 8996a93ba22cdaeb97a2f5f11e7171ca7e96a427 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Fri, 28 Feb 2020 11:24:02 +0100 Subject: [PATCH 41/97] Add MutableComplexTypeDefinition.delete method --- .../evolveum/midpoint/gui/impl/prism/ItemWrapperImpl.java | 2 +- .../prism/ProfilingClassLoggerContainerWrapperImpl.java | 2 ++ .../midpoint/prism/MutableComplexTypeDefinition.java | 3 ++- .../midpoint/prism/impl/ComplexTypeDefinitionImpl.java | 7 +++++++ .../java/com/evolveum/midpoint/util/TransientCache.java | 4 ++++ 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/prism/ItemWrapperImpl.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/prism/ItemWrapperImpl.java index 3ae3f229e16..fbfc689f9bc 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/prism/ItemWrapperImpl.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/prism/ItemWrapperImpl.java @@ -450,7 +450,7 @@ ItemStatus getItemStatus() { return status; } - + @NotNull @Override public ItemName getItemName() { return getItemDefinition().getItemName(); diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/prism/ProfilingClassLoggerContainerWrapperImpl.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/prism/ProfilingClassLoggerContainerWrapperImpl.java index e7ab81addd8..e690056ad70 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/prism/ProfilingClassLoggerContainerWrapperImpl.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/prism/ProfilingClassLoggerContainerWrapperImpl.java @@ -25,6 +25,7 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingConfigurationType; import com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingLevelType; import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType; +import org.jetbrains.annotations.NotNull; /** * @author skublik @@ -38,6 +39,7 @@ public ProfilingClassLoggerContainerWrapperImpl(PrismContainerValueWrapper pa super(parent, item, status); } + @NotNull @Override public ItemName getItemName() { return ItemName.fromQName(ProfilingClassLoggerWrapperFactoryImpl.PROFILING_LOGGER_PATH); diff --git a/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/MutableComplexTypeDefinition.java b/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/MutableComplexTypeDefinition.java index 0e72e461f8b..d4eb1304348 100644 --- a/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/MutableComplexTypeDefinition.java +++ b/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/MutableComplexTypeDefinition.java @@ -7,7 +7,6 @@ package com.evolveum.midpoint.prism; -import com.evolveum.midpoint.prism.path.ItemName; import org.jetbrains.annotations.NotNull; import javax.xml.namespace.QName; @@ -20,6 +19,8 @@ public interface MutableComplexTypeDefinition extends ComplexTypeDefinition, Mut void add(ItemDefinition definition); + void delete(QName itemName); + MutablePrismPropertyDefinition createPropertyDefinition(QName name, QName typeName); MutablePrismPropertyDefinition createPropertyDefinition(String name, QName typeName); diff --git a/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/ComplexTypeDefinitionImpl.java b/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/ComplexTypeDefinitionImpl.java index 9140ff11777..292c21855fd 100644 --- a/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/ComplexTypeDefinitionImpl.java +++ b/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/ComplexTypeDefinitionImpl.java @@ -553,6 +553,13 @@ public void trimTo(@NotNull Collection paths) { } } + @Override + public void delete(QName itemName) { + checkMutable(); + itemDefinitions.removeIf(def -> def.getItemName().equals(itemName)); + cachedLocalDefinitionQueries.remove(itemName); + } + @Override public MutableComplexTypeDefinition toMutable() { checkMutableOnExposing(); diff --git a/infra/util/src/main/java/com/evolveum/midpoint/util/TransientCache.java b/infra/util/src/main/java/com/evolveum/midpoint/util/TransientCache.java index d2bf4f91d97..99210e91fff 100644 --- a/infra/util/src/main/java/com/evolveum/midpoint/util/TransientCache.java +++ b/infra/util/src/main/java/com/evolveum/midpoint/util/TransientCache.java @@ -39,6 +39,10 @@ public void put(K name, V value) { cache.put(name, value); } + public void remove(K name) { + cache.remove(name); + } + // used to provide a new object when deserializing private Object readResolve() { return new TransientCache<>(); From d7c9bfc6b8734751fa4b96c5a33b45fa6bf8f86b Mon Sep 17 00:00:00 2001 From: Radovan Semancik Date: Fri, 28 Feb 2020 11:48:46 +0100 Subject: [PATCH 42/97] PrismContainerDefinitionAsserter, test for MID-6043, WIP --- .../prism/PrismContainerDefinition.java | 112 +- .../ModelInteractionServiceImpl.java | 18 +- .../impl/controller/SchemaTransformer.java | 3 +- ...bstractConfiguredModelIntegrationTest.java | 1701 +- ...stractInitializedModelIntegrationTest.java | 867 +- .../model/intest/gensync/TestEditSchema.java | 3499 ++-- .../common/archetype-task-reconciliation.xml | 104 + .../resources/common/task-reconcile-dummy.xml | 76 +- .../test/AbstractModelIntegrationTest.java | 13369 ++++++++-------- .../prism/ComplexTypeDefinitionAsserter.java | 137 +- .../PrismContainerDefinitionAsserter.java | 73 + 11 files changed, 10081 insertions(+), 9878 deletions(-) create mode 100644 model/model-intest/src/test/resources/common/archetype-task-reconciliation.xml create mode 100644 repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/prism/PrismContainerDefinitionAsserter.java diff --git a/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/PrismContainerDefinition.java b/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/PrismContainerDefinition.java index ca8cefc9f9c..3865aee3857 100644 --- a/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/PrismContainerDefinition.java +++ b/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/PrismContainerDefinition.java @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2010-2019 Evolveum and contributors - * - * This work is dual-licensed under the Apache License 2.0 - * and European Union Public License. See LICENSE file for details. - */ - -package com.evolveum.midpoint.prism; - -import com.evolveum.midpoint.prism.delta.ContainerDelta; -import com.evolveum.midpoint.prism.path.ItemPath; -import org.jetbrains.annotations.NotNull; - -import javax.xml.namespace.QName; -import java.util.List; - -/** - * @author mederly - */ -public interface PrismContainerDefinition extends ItemDefinition>, LocalDefinitionStore { - - Class getCompileTimeClass(); - - ComplexTypeDefinition getComplexTypeDefinition(); - - String getDefaultNamespace(); - - List getIgnoredNamespaces(); - - List getDefinitions(); - - List getPropertyDefinitions(); - - @Override - ContainerDelta createEmptyDelta(ItemPath path); - - @NotNull - @Override - PrismContainerDefinition clone(); - - PrismContainerDefinition cloneWithReplacedDefinition(QName itemName, ItemDefinition newDefinition); - - void replaceDefinition(QName itemName, ItemDefinition newDefinition); - - PrismContainerValue createValue(); - - boolean isEmpty(); - - boolean canRepresent(@NotNull QName type); - - @Override - MutablePrismContainerDefinition toMutable(); - - @Override - Class getTypeClass(); -} +/* + * Copyright (c) 2010-2019 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ + +package com.evolveum.midpoint.prism; + +import com.evolveum.midpoint.prism.delta.ContainerDelta; +import com.evolveum.midpoint.prism.path.ItemPath; +import org.jetbrains.annotations.NotNull; + +import javax.xml.namespace.QName; +import java.util.List; + +/** + * @author mederly + */ +public interface PrismContainerDefinition extends ItemDefinition>, LocalDefinitionStore { + + Class getCompileTimeClass(); + + ComplexTypeDefinition getComplexTypeDefinition(); + + String getDefaultNamespace(); + + List getIgnoredNamespaces(); + + List getDefinitions(); + + List getPropertyDefinitions(); + + @Override + ContainerDelta createEmptyDelta(ItemPath path); + + @NotNull + @Override + PrismContainerDefinition clone(); + + PrismContainerDefinition cloneWithReplacedDefinition(QName itemName, ItemDefinition newDefinition); + + void replaceDefinition(QName itemName, ItemDefinition newDefinition); + + PrismContainerValue createValue(); + + boolean isEmpty(); + + boolean canRepresent(@NotNull QName type); + + @Override + MutablePrismContainerDefinition toMutable(); + + @Override + Class getTypeClass(); +} diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelInteractionServiceImpl.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelInteractionServiceImpl.java index 4c890a63256..493d7e7a9b8 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelInteractionServiceImpl.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelInteractionServiceImpl.java @@ -27,6 +27,7 @@ import com.evolveum.midpoint.TerminateSessionEvent; import com.evolveum.midpoint.model.api.authentication.*; import com.evolveum.midpoint.model.common.stringpolicy.*; +import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.schema.cache.CacheConfigurationManager; import com.evolveum.midpoint.schema.util.*; import com.evolveum.midpoint.security.enforcer.api.FilterGizmo; @@ -84,20 +85,6 @@ import com.evolveum.midpoint.model.impl.security.SecurityHelper; import com.evolveum.midpoint.model.impl.security.GuiProfileCompiler; import com.evolveum.midpoint.model.impl.visualizer.Visualizer; -import com.evolveum.midpoint.prism.Containerable; -import com.evolveum.midpoint.prism.Item; -import com.evolveum.midpoint.prism.ItemDefinition; -import com.evolveum.midpoint.prism.PrismConstants; -import com.evolveum.midpoint.prism.PrismContainer; -import com.evolveum.midpoint.prism.PrismContainerDefinition; -import com.evolveum.midpoint.prism.PrismContainerValue; -import com.evolveum.midpoint.prism.PrismContext; -import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.PrismObjectDefinition; -import com.evolveum.midpoint.prism.PrismProperty; -import com.evolveum.midpoint.prism.PrismPropertyDefinition; -import com.evolveum.midpoint.prism.PrismPropertyValue; -import com.evolveum.midpoint.prism.PrismReferenceValue; import com.evolveum.midpoint.prism.crypto.EncryptionException; import com.evolveum.midpoint.prism.crypto.Protector; import com.evolveum.midpoint.prism.delta.DeltaFactory; @@ -271,6 +258,7 @@ public ModelContext unwrapModelContext(LensContextType public PrismObjectDefinition getEditObjectDefinition(PrismObject object, AuthorizationPhaseType phase, Task task, OperationResult parentResult) throws SchemaException, ConfigurationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, SecurityViolationException { OperationResult result = parentResult.createMinorSubresult(GET_EDIT_OBJECT_DEFINITION); PrismObjectDefinition objectDefinition = object.getDefinition().deepClone(true, schemaTransformer::setFullAccessFlags ); + MutablePrismContainerDefinition mutableObjectDefinition = objectDefinition.toMutable(); try { @@ -298,7 +286,7 @@ public PrismObjectDefinition getEditObjectDefinition(P ArchetypePolicyType archetypePolicy = archetypeManager.determineArchetypePolicy(object, result); if (archetypePolicy != null) { - schemaTransformer.applyItemsConstraints(objectDefinition, archetypePolicy, result); + schemaTransformer.applyItemsConstraints(mutableObjectDefinition, archetypePolicy, result); ObjectReferenceType objectTemplateRef = archetypePolicy.getObjectTemplateRef(); if (objectTemplateRef != null) { diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/SchemaTransformer.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/SchemaTransformer.java index c0c330745c4..910d5cf342b 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/SchemaTransformer.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/SchemaTransformer.java @@ -796,7 +796,7 @@ private void applyObjectTempla } } - public void applyItemsConstraints(PrismObjectDefinition objectDefinition, ArchetypePolicyType archetypePolicy, OperationResult result) throws ObjectNotFoundException, SchemaException { + public void applyItemsConstraints(MutablePrismContainerDefinition objectDefinition, ArchetypePolicyType archetypePolicy, OperationResult result) throws ObjectNotFoundException, SchemaException { if (archetypePolicy == null) { return; } @@ -833,6 +833,7 @@ private UserInterfaceElementVisibilityType reduceItems(PrismContainerDefinition PrismContainerDefinition subContainerDef = (PrismContainerDefinition)subDefinition; UserInterfaceElementVisibilityType itemVisibility = reduceItems(subContainerDef, itemPath, visibilityMap); if (subContainerDef.isEmpty() && itemVisibility != UserInterfaceElementVisibilityType.VISIBLE) { + subDefinition.toMutable().set iterator.remove(); } } else { diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/AbstractConfiguredModelIntegrationTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/AbstractConfiguredModelIntegrationTest.java index 3b121835506..100dc092a6f 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/AbstractConfiguredModelIntegrationTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/AbstractConfiguredModelIntegrationTest.java @@ -1,849 +1,852 @@ -/* - * Copyright (c) 2010-2017 Evolveum and contributors - * - * This work is dual-licensed under the Apache License 2.0 - * and European Union Public License. See LICENSE file for details. - */ -package com.evolveum.midpoint.model.intest; - -import static org.testng.AssertJUnit.assertNotNull; - -import com.evolveum.midpoint.model.api.context.EvaluatedAssignmentTarget; -import com.evolveum.midpoint.model.test.AbstractModelIntegrationTest; -import com.evolveum.midpoint.prism.PrismContainer; -import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.PrismProperty; -import com.evolveum.midpoint.prism.PrismReferenceValue; -import com.evolveum.midpoint.prism.crypto.EncryptionException; -import com.evolveum.midpoint.prism.delta.ReferenceDelta; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.prism.path.ItemName; -import com.evolveum.midpoint.prism.schema.PrismSchema; -import com.evolveum.midpoint.provisioning.ucf.impl.builtin.ManualConnectorInstance; -import com.evolveum.midpoint.schema.constants.MidPointConstants; -import com.evolveum.midpoint.schema.constants.SchemaConstants; -import com.evolveum.midpoint.schema.internals.InternalsConfig; -import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.DummyResourceContoller; -import com.evolveum.midpoint.test.IntegrationTestTools; -import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.MiscUtil; -import com.evolveum.midpoint.util.QNameUtil; -import com.evolveum.midpoint.util.exception.*; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.common_3.*; - -import org.jetbrains.annotations.NotNull; -import org.testng.AssertJUnit; -import org.testng.IHookCallBack; -import org.testng.ITestResult; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; - -import java.io.File; -import java.io.IOException; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; - -import javax.xml.datatype.XMLGregorianCalendar; -import javax.xml.namespace.QName; - -/** - * @author semancik - * - */ -public class AbstractConfiguredModelIntegrationTest extends AbstractModelIntegrationTest { - - public static final File SYSTEM_CONFIGURATION_FILE = new File(COMMON_DIR, "system-configuration.xml"); - public static final String SYSTEM_CONFIGURATION_OID = SystemObjectsType.SYSTEM_CONFIGURATION.value(); - - protected static final int NUMBER_OF_GLOBAL_POLICY_RULES = 7; - - public static final File USER_ADMINISTRATOR_FILE = new File(COMMON_DIR, "user-administrator.xml"); - protected static final String USER_ADMINISTRATOR_OID = "00000000-0000-0000-0000-000000000002"; - - protected static final String USER_TEMPLATE_FILENAME = COMMON_DIR + "/user-template.xml"; - protected static final String USER_TEMPLATE_OID = "10000000-0000-0000-0000-000000000002"; - - protected static final File USER_TEMPLATE_COMPLEX_FILE = new File(COMMON_DIR, "user-template-complex.xml"); - protected static final String USER_TEMPLATE_COMPLEX_OID = "10000000-0000-0000-0000-000000000222"; - - protected static final File USER_TEMPLATE_SCHEMA_CONSTRAINTS_FILE = new File(COMMON_DIR, "user-template-schema-constraints.xml"); - protected static final String USER_TEMPLATE_SCHEMA_CONSTRAINTS_OID = "c2e52c79-a0ea-42ec-8853-1e9ea16175a9"; - - protected static final String USER_TEMPLATE_INBOUNDS_FILENAME = COMMON_DIR + "/user-template-inbounds.xml"; - protected static final String USER_TEMPLATE_INBOUNDS_OID = "10000000-0000-0000-0000-000000000555"; - - protected static final String USER_TEMPLATE_COMPLEX_INCLUDE_FILENAME = COMMON_DIR + "/user-template-complex-include.xml"; - protected static final String USER_TEMPLATE_COMPLEX_INCLUDE_OID = "10000000-0000-0000-0000-000000000223"; - - protected static final String USER_TEMPLATE_SYNC_FILENAME = COMMON_DIR + "/user-template-sync.xml"; - protected static final String USER_TEMPLATE_SYNC_OID = "10000000-0000-0000-0000-000000000333"; - - protected static final String USER_TEMPLATE_ORG_ASSIGNMENT_FILENAME = COMMON_DIR + "/user-template-org-assignment.xml"; - protected static final String USER_TEMPLATE_ORG_ASSIGNMENT_OID = "10000000-0000-0000-0000-000000000444"; - - protected static final String USER_TEMPLATE_CARTHESIAN_FILENAME = COMMON_DIR + "/user-template-carthesian.xml"; - protected static final String USER_TEMPLATE_CARTHESIAN_OID = "8e47c2b2-dde6-44a9-a7c0-de21a14cb70d"; - - protected static final File OBJECT_TEMPLATE_PERSONA_ADMIN_FILE = new File(COMMON_DIR, "object-template-persona-admin.xml"); - protected static final String OBJECT_TEMPLATE_PERSONA_ADMIN_OID = "894ea1a8-2c0a-11e7-a950-ff2047b0c053"; - - protected static final String CONNECTOR_LDAP_FILENAME = COMMON_DIR + "/connector-ldap.xml"; - - protected static final String CONNECTOR_DBTABLE_FILENAME = COMMON_DIR + "/connector-dbtable.xml"; - - protected static final String CONNECTOR_DUMMY_FILENAME = COMMON_DIR + "/connector-dummy.xml"; - - protected static final File RESOURCE_DUMMY_FILE = new File(COMMON_DIR, "resource-dummy.xml"); - protected static final File RESOURCE_DUMMY_CACHING_FILE = new File(COMMON_DIR, "resource-dummy-caching.xml"); - protected static final String RESOURCE_DUMMY_OID = "10000000-0000-0000-0000-000000000004"; - protected static final String RESOURCE_DUMMY_NAMESPACE = "http://midpoint.evolveum.com/xml/ns/public/resource/instance/10000000-0000-0000-0000-000000000004"; - protected static final String RESOURCE_DUMMY_DRINK = "rum"; - protected static final String RESOURCE_DUMMY_QUOTE = "Arr!"; - protected static final String RESOURCE_DUMMY_USELESS_STRING = "USEless"; - protected static final QName RESOURCE_DUMMY_GROUP_OBJECTCLASS = new QName(RESOURCE_DUMMY_NAMESPACE, "GroupObjectClass"); - protected static final QName RESOURCE_DUMMY_ASSOCIATION_GROUP_QNAME = new QName(RESOURCE_DUMMY_NAMESPACE, "group"); - protected static final QName RESOURCE_DUMMY_ASSOCIATION_PRIV_QNAME = new QName(RESOURCE_DUMMY_NAMESPACE, "priv"); - - // RED resource has STRONG mappings - protected static final File RESOURCE_DUMMY_RED_FILE = new File(COMMON_DIR, "resource-dummy-red.xml"); - protected static final String RESOURCE_DUMMY_RED_OID = "10000000-0000-0000-0000-000000000104"; - protected static final String RESOURCE_DUMMY_RED_NAME = "red"; - protected static final String RESOURCE_DUMMY_RED_NAMESPACE = MidPointConstants.NS_RI; - protected static final String RESOURCE_DUMMY_RED_USELESS_STRING = IntegrationTestTools.CONST_USELESS; - - // BLUE resource has WEAK mappings, outbound/inbound - protected static final File RESOURCE_DUMMY_BLUE_FILE = new File(COMMON_DIR, "resource-dummy-blue.xml"); - protected static final File RESOURCE_DUMMY_BLUE_CACHING_FILE = new File(COMMON_DIR, "resource-dummy-blue-caching.xml"); - protected static final String RESOURCE_DUMMY_BLUE_OID = "10000000-0000-0000-0000-000000000204"; - protected static final String RESOURCE_DUMMY_BLUE_NAME = "blue"; - protected static final String RESOURCE_DUMMY_BLUE_NAMESPACE = MidPointConstants.NS_RI; - - // CYAN has WEAK mappings, outbound only - protected static final File RESOURCE_DUMMY_CYAN_FILE = new File(COMMON_DIR, "resource-dummy-cyan.xml"); - protected static final String RESOURCE_DUMMY_CYAN_OID = "10000000-0000-0000-0000-00000000c204"; - protected static final String RESOURCE_DUMMY_CYAN_NAME = "cyan"; - protected static final String RESOURCE_DUMMY_CYAN_NAMESPACE = MidPointConstants.NS_RI; - - // WHITE dummy resource has almost no configuration: no schema, no schemahandling, no synchronization, ... - protected static final String RESOURCE_DUMMY_WHITE_FILENAME = COMMON_DIR + "/resource-dummy-white.xml"; - protected static final String RESOURCE_DUMMY_WHITE_OID = "10000000-0000-0000-0000-000000000304"; - protected static final String RESOURCE_DUMMY_WHITE_NAME = "white"; - protected static final String RESOURCE_DUMMY_WHITE_NAMESPACE = MidPointConstants.NS_RI; - - // YELLOW dummy resource is almost the same as default one but with strong asIs administrativeStatus mapping - // it also has minimal password length - protected static final File RESOURCE_DUMMY_YELLOW_FILE = new File(COMMON_DIR, "resource-dummy-yellow.xml"); - protected static final String RESOURCE_DUMMY_YELLOW_OID = "10000000-0000-0000-0000-000000000704"; - protected static final String RESOURCE_DUMMY_YELLOW_NAME = "yellow"; - protected static final String RESOURCE_DUMMY_YELLOW_NAMESPACE = MidPointConstants.NS_RI; - - // Green dummy resource is authoritative - protected static final File RESOURCE_DUMMY_GREEN_FILE = new File(COMMON_DIR, "resource-dummy-green.xml"); - protected static final File RESOURCE_DUMMY_GREEN_CACHING_FILE = new File(COMMON_DIR, "resource-dummy-green-caching.xml"); - protected static final String RESOURCE_DUMMY_GREEN_OID = "10000000-0000-0000-0000-000000000404"; - protected static final String RESOURCE_DUMMY_GREEN_NAME = "green"; - protected static final String RESOURCE_DUMMY_GREEN_NAMESPACE = MidPointConstants.NS_RI; - - // This is authoritative resource similar to green resource but it has a bit wilder inbound mappings. - protected static final File RESOURCE_DUMMY_EMERALD_FILE = new File(COMMON_DIR, "resource-dummy-emerald.xml"); - protected static final String RESOURCE_DUMMY_EMERALD_OID = "10000000-0000-0000-0000-00000000e404"; - protected static final String RESOURCE_DUMMY_EMERALD_NAME = "emerald"; - protected static final String RESOURCE_DUMMY_EMERALD_NAMESPACE = MidPointConstants.NS_RI; - - // Black dummy resource for testing tolerant attributes - protected static final File RESOURCE_DUMMY_BLACK_FILE = new File(COMMON_DIR, "resource-dummy-black.xml"); - protected static final String RESOURCE_DUMMY_BLACK_OID = "10000000-0000-0000-0000-000000000305"; - protected static final String RESOURCE_DUMMY_BLACK_NAME = "black"; - protected static final String RESOURCE_DUMMY_BLACK_NAMESPACE = MidPointConstants.NS_RI; - - // Black dummy resource for testing tolerant attributes - protected static final File RESOURCE_DUMMY_RELATIVE_FILE = new File(COMMON_DIR, "resource-dummy-relative.xml"); - protected static final String RESOURCE_DUMMY_RELATIVE_OID = "adcd4654-0f15-11e7-8337-0bdf60ad7bcd"; - protected static final String RESOURCE_DUMMY_RELATIVE_NAME = "relative"; - protected static final String RESOURCE_DUMMY_RELATIVE_NAMESPACE = MidPointConstants.NS_RI; - - // Orange dummy resource for testing associations with resource-provided referential integrity - // It also have very little outbound expressions and it has some strange inbound expressions. - protected static final File RESOURCE_DUMMY_ORANGE_FILE = new File(COMMON_DIR, "resource-dummy-orange.xml"); - protected static final String RESOURCE_DUMMY_ORANGE_OID = "10000000-0000-0000-0000-000000001104"; - protected static final String RESOURCE_DUMMY_ORANGE_NAME = "orange"; - protected static final String RESOURCE_DUMMY_ORANGE_NAMESPACE = MidPointConstants.NS_RI; - protected static final QName RESOURCE_DUMMY_ORANGE_ASSOCIATION_CREW_QNAME = new QName(RESOURCE_DUMMY_ORANGE_NAMESPACE, "crew"); - - protected static final String RESOURCE_DUMMY_SCHEMALESS_FILENAME = COMMON_DIR + "/resource-dummy-schemaless-no-schema.xml"; - protected static final String RESOURCE_DUMMY_SCHEMALESS_OID = "ef2bc95b-76e0-59e2-86d6-9999dddd0000"; - protected static final String RESOURCE_DUMMY_SCHEMALESS_NAME = "schemaless"; - protected static final String RESOURCE_DUMMY_SCHEMALESS_NAMESPACE = MidPointConstants.NS_RI; - - // Upcase resource turns all names to upper case. It is also caseInsensitive resource - protected static final File RESOURCE_DUMMY_UPCASE_FILE = new File(COMMON_DIR, "resource-dummy-upcase.xml"); - protected static final String RESOURCE_DUMMY_UPCASE_OID = "10000000-0000-0000-0000-000000001204"; - protected static final String RESOURCE_DUMMY_UPCASE_NAME = "upcase"; - protected static final String RESOURCE_DUMMY_UPCASE_NAMESPACE = MidPointConstants.NS_RI; - protected static final QName RESOURCE_DUMMY_UPCASE_ASSOCIATION_GROUP_QNAME = new QName(RESOURCE_DUMMY_UPCASE_NAMESPACE, "group"); - - protected static final String RESOURCE_DUMMY_FAKE_FILENAME = COMMON_DIR + "/resource-dummy-fake.xml"; - protected static final String RESOURCE_DUMMY_FAKE_OID = "10000000-0000-0000-0000-00000000000f"; - - public static final File ROLE_SUPERUSER_FILE = new File(COMMON_DIR, "role-superuser.xml"); - protected static final String ROLE_SUPERUSER_OID = "00000000-0000-0000-0000-000000000004"; - - protected static final File ROLE_PIRATE_FILE = new File(COMMON_DIR, "role-pirate.xml"); - protected static final String ROLE_PIRATE_OID = "12345678-d34d-b33f-f00d-555555556666"; - protected static final String ROLE_PIRATE_NAME = "Pirate"; - protected static final String ROLE_PIRATE_DESCRIPTION = "Scurvy Pirates"; - protected static final String ROLE_PIRATE_TITLE = "Bloody Pirate"; - protected static final String ROLE_PIRATE_WEAPON = "cutlass"; - - protected static final File ROLE_CARIBBEAN_PIRATE_FILE = new File(COMMON_DIR, "role-caribbean-pirate.xml"); - protected static final String ROLE_CARIBBEAN_PIRATE_OID = "0719ec66-edd9-11e6-bd70-03a74157ff9e"; - - protected static final File ROLE_PIRATE_GREEN_FILE = new File(COMMON_DIR, "role-pirate-green.xml"); - protected static final String ROLE_PIRATE_GREEN_OID = "12345678-d34d-b33f-f00d-555555557777"; - protected static final String ROLE_PIRATE_GREEN_NAME = "Pirate Green"; - protected static final String ROLE_PIRATE_GREEN_DESCRIPTION = "Scurvy Pirates"; - - protected static final File ROLE_PIRATE_RELATIVE_FILE = new File(COMMON_DIR, "role-pirate-relative.xml"); - protected static final String ROLE_PIRATE_RELATIVE_OID = "4a579cd0-0f17-11e7-967c-130ecd6fb7dc"; - protected static final String ROLE_PIRAT_RELATIVEE_NAME = "Relative Pirate"; - - protected static final File ROLE_BUCCANEER_GREEN_FILE = new File(COMMON_DIR, "role-buccaneer-green.xml"); - protected static final String ROLE_BUCCANEER_GREEN_OID = "12345678-d34d-b33f-f00d-555555558888"; - protected static final String ROLE_BUCCANEER_GREEN_NAME = "Bucaneers Green"; - protected static final String ROLE_BUCCANEER_GREEN_DESCRIPTION = "Scurvy Bucaneers"; - - protected static final String ROLE_NICE_PIRATE_FILENAME = COMMON_DIR + "/role-nice-pirate.xml"; - protected static final String ROLE_NICE_PIRATE_OID = "12345678-d34d-b33f-f00d-555555556677"; - - protected static final String ROLE_CAPTAIN_FILENAME = COMMON_DIR + "/role-captain.xml"; - protected static final String ROLE_CAPTAIN_OID = "12345678-d34d-b33f-f00d-55555555cccc"; - - // Excludes role "pirate" - protected static final File ROLE_JUDGE_FILE = new File(COMMON_DIR, "role-judge.xml"); - protected static final String ROLE_JUDGE_OID = "12345111-1111-2222-1111-121212111111"; - protected static final String ROLE_JUDGE_TITLE = "Honorable Justice"; - protected static final String ROLE_JUDGE_DRINK = "tea"; - protected static final String ROLE_JUDGE_DESCRIPTION = "Role with role exclusions"; - protected static final String ROLE_JUDGE_POLICY_RULE_EXCLUSION_PREFIX = "criminal exclusion: "; - - protected static final File ROLE_THIEF_FILE = new File(COMMON_DIR, "role-thief.xml"); - protected static final String ROLE_THIEF_OID = "b189fcb8-1ff9-11e5-8912-001e8c717e5b"; - - protected static final File ROLE_EMPTY_FILE = new File(COMMON_DIR, "role-empty.xml"); - protected static final String ROLE_EMPTY_OID = "12345111-1111-2222-1111-121212111112"; - - protected static final File ROLE_USELESS_FILE = new File(COMMON_DIR, "role-useless.xml"); - protected static final String ROLE_USELESS_OID = "12345111-1111-2222-1111-831209543124"; - - protected static final File ROLE_SAILOR_FILE = new File(COMMON_DIR, "role-sailor.xml"); - protected static final String ROLE_SAILOR_OID = "12345111-1111-2222-1111-121212111113"; - protected static final String ROLE_SAILOR_DRINK = "grog"; - - protected static final File ROLE_RED_SAILOR_FILE = new File(COMMON_DIR, "role-red-sailor.xml"); - protected static final String ROLE_RED_SAILOR_OID = "12345111-1111-2222-1111-121212111223"; - - protected static final File ROLE_CYAN_SAILOR_FILE = new File(COMMON_DIR, "role-cyan-sailor.xml"); - protected static final String ROLE_CYAN_SAILOR_OID = "d3abd794-9c30-11e6-bb5a-af14bf2cc29b"; - - protected static final File ROLE_STRONG_SAILOR_FILE = new File(COMMON_DIR, "role-strong-sailor.xml"); - protected static final String ROLE_STRONG_SAILOR_OID = "0bf7532e-7d15-11e7-8594-7bff6e0adc6e"; - - protected static final File ROLE_DRINKER_FILE = new File(COMMON_DIR, "role-drinker.xml"); - protected static final String ROLE_DRINKER_OID = "0abbde4c-ab3f-11e6-910d-d7dabf5f09f0"; - - protected static final File ROLE_PERSONA_ADMIN_FILE = new File(COMMON_DIR, "role-persona-admin.xml"); - protected static final String ROLE_PERSONA_ADMIN_OID = "16813ae6-2c0a-11e7-91fc-8333c244329e"; - - protected static final File ROLE_AUTOMATIC_FILE = new File(COMMON_DIR, "role-automatic.xml"); - protected static final String ROLE_AUTOMATIC_OID = "8fdb56d8-e3f3-11e6-8be9-cb9862ab7c04"; - - protected static final File ROLE_AUTOCRATIC_FILE = new File(COMMON_DIR, "role-autocratic.xml"); - protected static final String ROLE_AUTOCRATIC_OID = "4a678382-e3f4-11e6-8c3d-cfd3dba8168f"; - - protected static final File ROLE_AUTODIDACTIC_FILE = new File(COMMON_DIR, "role-autodidactic.xml"); - protected static final String ROLE_AUTODIDACTIC_OID = "a4f941dc-e3f4-11e6-8eba-9fe432784017"; - - protected static final File ROLE_AUTOGRAPHIC_FILE = new File(COMMON_DIR, "role-autographic.xml"); - protected static final String ROLE_AUTOGRAPHIC_OID = "be835a70-e3f4-11e6-82cb-9b47ebe57b11"; - - protected static final File ROLE_AUTOTESTERS_FILE = new File(COMMON_DIR, "role-autotesters.xml"); - protected static final String ROLE_AUTOTESTERS_OID = "be835a70-e3f4-11e6-82cb-9b47ecb57v14"; - - protected static final File ROLE_ADMINS_FILE = new File(COMMON_DIR, "role-admins.xml"); - protected static final String ROLE_ADMINS_OID = "be835a70-e3f4-11e6-82cb-9b47ecb57v15"; - - protected static final File ROLE_END_USER_FILE = new File(COMMON_DIR, "role-end-user.xml"); - protected static final String ROLE_END_USER_OID = "00000000-0000-0000-0000-00000000aa0f"; - - public static final File USER_JACK_FILE = new File(COMMON_DIR, "user-jack.xml"); - public static final String USER_JACK_OID = "c0c010c0-d34d-b33f-f00d-111111111111"; - public static final String USER_JACK_USERNAME = "jack"; - public static final String USER_JACK_FULL_NAME = "Jack Sparrow"; - public static final String USER_JACK_GIVEN_NAME = "Jack"; - public static final String USER_JACK_FAMILY_NAME = "Sparrow"; - public static final String USER_JACK_ADDITIONAL_NAME = "Jackie"; - public static final String USER_JACK_DESCRIPTION = "Where's the rum?"; - public static final String USER_JACK_SUBTYPE = "captain"; - public static final String USER_JACK_EMPLOYEE_NUMBER = "emp1234"; - public static final String USER_JACK_LOCALITY = "Caribbean"; - public static final String USER_JACK_PASSWORD = "deadmentellnotales"; - - protected static final File USER_BARBOSSA_FILE = new File(COMMON_DIR, "user-barbossa.xml"); - protected static final String USER_BARBOSSA_OID = "c0c010c0-d34d-b33f-f00d-111111111112"; - protected static final String USER_BARBOSSA_USERNAME = "barbossa"; - protected static final String USER_BARBOSSA_FULL_NAME = "Hector Barbossa"; - - protected static final File USER_GUYBRUSH_FILE = new File (COMMON_DIR, "user-guybrush.xml"); - protected static final String USER_GUYBRUSH_OID = "c0c010c0-d34d-b33f-f00d-111111111116"; - protected static final String USER_GUYBRUSH_USERNAME = "guybrush"; - protected static final String USER_GUYBRUSH_FULL_NAME = "Guybrush Threepwood"; - protected static final String USER_GUYBRUSH_GIVEN_NAME = "Guybrush"; - protected static final String USER_GUYBRUSH_FAMILY_NAME = "Threepwood"; - protected static final String USER_GUYBRUSH_LOCALITY = "Melee Island"; - - public static final File USER_WILL_FILE = new File(COMMON_DIR, "user-will.xml"); - public static final String USER_WILL_OID = "c0c010c0-d34d-b33f-f00d-111111145118"; - - // Largo does not have a full name set, employeeType=PIRATE - protected static final File USER_LARGO_FILE = new File(COMMON_DIR, "user-largo.xml"); - protected static final String USER_LARGO_OID = "c0c010c0-d34d-b33f-f00d-111111111118"; - protected static final String USER_LARGO_USERNAME = "largo"; - - // Rapp does not have a full name set, employeeType=COOK - protected static final File USER_RAPP_FILE = new File(COMMON_DIR, "user-rapp.xml"); - protected static final String USER_RAPP_OID = "c0c010c0-d34d-b33f-f00d-11111111c008"; - protected static final String USER_RAPP_USERNAME = "rapp"; - protected static final String USER_RAPP_FULLNAME = "Rapp Scallion"; - - // Herman has a validity dates set in the activation part - protected static final File USER_HERMAN_FILE = new File(COMMON_DIR, "user-herman.xml"); - protected static final String USER_HERMAN_OID = "c0c010c0-d34d-b33f-f00d-111111111122"; - protected static final String USER_HERMAN_USERNAME = "herman"; - protected static final String USER_HERMAN_GIVEN_NAME = "Herman"; - protected static final String USER_HERMAN_FAMILY_NAME = "Toothrot"; - protected static final String USER_HERMAN_FULL_NAME = "Herman Toothrot"; - protected static final String USER_HERMAN_PASSWORD = "m0nk3y"; - protected static final Date USER_HERMAN_VALID_FROM_DATE = MiscUtil.asDate(1700, 5, 30, 11, 0, 0); - protected static final Date USER_HERMAN_VALID_TO_DATE = MiscUtil.asDate(2233, 3, 23, 18, 30, 0); - - // Has null name, doesn not have given name, no employeeType - protected static final File USER_THREE_HEADED_MONKEY_FILE = new File(COMMON_DIR, "/user-three-headed-monkey.xml"); - protected static final String USER_THREE_HEADED_MONKEY_OID = "c0c010c0-d34d-b33f-f00d-110011001133"; - protected static final String USER_THREE_HEADED_MONKEY_NAME = "monkey"; - protected static final String USER_THREE_HEADED_MONKEY_FULL_NAME = "Three-Headed Monkey"; - - // User with no OID - protected static final File USER_NOOID_FILE = new File(COMMON_DIR, "user-nooid.xml"); - protected static final String USER_NOOID_USERNAME = "nooid"; - - // Elaine has account on the dummy resources (default, red, blue) - // The accounts are also assigned - protected static final File USER_ELAINE_FILE = new File (COMMON_DIR, "user-elaine.xml"); - protected static final String USER_ELAINE_OID = "c0c010c0-d34d-b33f-f00d-11111111111e"; - protected static final String USER_ELAINE_USERNAME = "elaine"; - - // Captain Kate Capsize does not exist in the repo. This user is designed to be added. - // She has account on dummy resources (default, red, blue) - // The accounts are also assigned - static final File USER_CAPSIZE_FILE = new File(COMMON_DIR, "user-capsize.xml"); - protected static final String USER_CAPSIZE_OID = "c0c010c0-d34d-b33f-f00d-11c1c1c1c11c"; - protected static final String USER_CAPSIZE_USERNAME = "capsize"; - static final File ACCOUNT_CAPSIZE_DUMMY_DEFAULT_FILE = new File(COMMON_DIR, "account-capsize-dummy-default.xml"); - static final File ACCOUNT_CAPSIZE_DUMMY_RED_FILE = new File(COMMON_DIR, "account-capsize-dummy-red.xml"); - static final File ACCOUNT_CAPSIZE_DUMMY_BLUE_FILE = new File(COMMON_DIR, "account-capsize-dummy-blue.xml"); - - protected static final File USER_DRAKE_FILE = new File(COMMON_DIR, "user-drake.xml"); - protected static final String USER_DRAKE_OID = "c0c010c0-d34d-b33f-f00d-11d1d1d1d1d1"; - protected static final String USER_DRAKE_USERNAME = "drake"; - protected static final String USER_DRAKE_FULLNAME = "Francis Drake"; - - public static final File ACCOUNT_JACK_DUMMY_FILE = new File(COMMON_DIR, "account-jack-dummy.xml"); - public static final File ACCOUNT_JACK_DUMMY_RED_FILE = new File(COMMON_DIR, "account-jack-dummy-red.xml"); - public static final String ACCOUNT_JACK_DUMMY_USERNAME = "jack"; - public static final String ACCOUNT_JACK_DUMMY_FULLNAME = "Jack Sparrow"; - - public static final File ACCOUNT_HERMAN_DUMMY_FILE = new File(COMMON_DIR, "account-herman-dummy.xml"); - public static final String ACCOUNT_HERMAN_DUMMY_OID = "22220000-2200-0000-0000-444400004444"; - public static final String ACCOUNT_HERMAN_DUMMY_USERNAME = "ht"; - - public static final File ACCOUNT_SHADOW_GUYBRUSH_DUMMY_FILE = new File(COMMON_DIR, "account-shadow-guybrush-dummy.xml"); - public static final String ACCOUNT_SHADOW_GUYBRUSH_OID = "22226666-2200-6666-6666-444400004444"; - public static final String ACCOUNT_GUYBRUSH_DUMMY_USERNAME = "guybrush"; - public static final String ACCOUNT_GUYBRUSH_DUMMY_FULLNAME = "Guybrush Threepwood"; - public static final String ACCOUNT_GUYBRUSH_DUMMY_LOCATION = "Melee Island"; - public static final File ACCOUNT_GUYBRUSH_DUMMY_FILE = new File (COMMON_DIR, "account-guybrush-dummy.xml"); - public static final File ACCOUNT_GUYBRUSH_DUMMY_RED_FILE = new File(COMMON_DIR, "account-guybrush-dummy-red.xml"); - - public static final String ACCOUNT_SHADOW_JACK_DUMMY_FILENAME = COMMON_DIR + "/account-shadow-jack-dummy.xml"; - - public static final String ACCOUNT_DAVIEJONES_DUMMY_USERNAME = "daviejones"; - public static final String ACCOUNT_CALYPSO_DUMMY_USERNAME = "calypso"; - - public static final File ACCOUNT_SHADOW_ELAINE_DUMMY_FILE = new File(COMMON_DIR, "account-elaine-dummy.xml"); - public static final String ACCOUNT_SHADOW_ELAINE_DUMMY_OID = "c0c010c0-d34d-b33f-f00d-22220004000e"; - public static final String ACCOUNT_ELAINE_DUMMY_USERNAME = USER_ELAINE_USERNAME; - public static final String ACCOUNT_ELAINE_DUMMY_FULLNAME = "Elaine Marley"; - - public static final File ACCOUNT_SHADOW_ELAINE_DUMMY_RED_FILE = new File(COMMON_DIR, "account-elaine-dummy-red.xml"); - public static final String ACCOUNT_SHADOW_ELAINE_DUMMY_RED_OID = "c0c010c0-d34d-b33f-f00d-22220104000e"; - public static final String ACCOUNT_ELAINE_DUMMY_RED_USERNAME = USER_ELAINE_USERNAME; - - public static final File ACCOUNT_SHADOW_ELAINE_DUMMY_BLUE_FILE = new File(COMMON_DIR, "account-elaine-dummy-blue.xml"); - public static final String ACCOUNT_SHADOW_ELAINE_DUMMY_BLUE_OID = "c0c010c0-d34d-b33f-f00d-22220204000e"; - public static final String ACCOUNT_ELAINE_DUMMY_BLUE_USERNAME = USER_ELAINE_USERNAME; - - public static final File GROUP_PIRATE_DUMMY_FILE = new File(COMMON_DIR, "group-pirate-dummy.xml"); - public static final String GROUP_PIRATE_DUMMY_NAME = "pirate"; - public static final String GROUP_PIRATE_DUMMY_DESCRIPTION = "Scurvy pirates"; - - public static final File SHADOW_GROUP_DUMMY_TESTERS_FILE = new File(COMMON_DIR, "group-testers-dummy.xml"); - public static final String SHADOW_GROUP_DUMMY_TESTERS_OID = "20000000-0000-0000-3333-000000000002"; - public static final String GROUP_DUMMY_TESTERS_NAME = "testers"; - public static final String GROUP_DUMMY_TESTERS_DESCRIPTION = "To boldly go where no pirate has gone before"; - - public static final File GROUP_SHADOW_JOKER_DUMMY_UPCASE_FILE = new File(COMMON_DIR, "group-shadow-dummy-upcase-joker.xml"); - public static final String GROUP_SHADOW_JOKER_DUMMY_UPCASE_OID = "bc2a1d98-9ca4-11e4-a600-001e8c717e5b"; - public static final String GROUP_SHADOW_JOKER_DUMMY_UPCASE_NAME = "joker"; - public static final String GROUP_JOKER_DUMMY_UPCASE_NAME = "JOKER"; - - public static final String DUMMY_ORG_TOP_NAME = DummyResourceContoller.ORG_TOP_NAME; - - protected static final File PASSWORD_POLICY_GLOBAL_FILE = new File(COMMON_DIR, "password-policy-global.xml"); - protected static final String PASSWORD_POLICY_GLOBAL_OID = "12344321-0000-0000-0000-000000000003"; - - protected static final File PASSWORD_POLICY_BENEVOLENT_FILE = new File(COMMON_DIR, "password-policy-benevolent.xml"); - protected static final String PASSWORD_POLICY_BENEVOLENT_OID = "ed8026dc-569a-11e7-abdf-4fce56706755"; - - protected static final File ORG_MONKEY_ISLAND_FILE = new File(COMMON_DIR, "org-monkey-island.xml"); - protected static final String ORG_GOVERNOR_OFFICE_OID = "00000000-8888-6666-0000-100000000001"; - protected static final String ORG_SCUMM_BAR_OID = "00000000-8888-6666-0000-100000000006"; - protected static final String ORG_SCUMM_BAR_NAME = "F0006"; - protected static final String ORG_SCUMM_BAR_DISPLAY_NAME = "Scumm Bar"; - protected static final String ORG_MINISTRY_OF_OFFENSE_OID = "00000000-8888-6666-0000-100000000003"; - protected static final String ORG_MINISTRY_OF_OFFENSE_NAME = "F0003"; - protected static final String ORG_MINISTRY_OF_DEFENSE_OID = "00000000-8888-6666-0000-100000000002"; - protected static final String ORG_MINISTRY_OF_DEFENSE_NAME = "F0002"; - protected static final String ORG_MINISTRY_OF_RUM_OID = "00000000-8888-6666-0000-100000000004"; - protected static final String ORG_MINISTRY_OF_RUM_NAME = "F0004"; - protected static final String ORG_SWASHBUCKLER_SECTION_OID = "00000000-8888-6666-0000-100000000005"; - protected static final String ORG_PROJECT_ROOT_OID = "00000000-8888-6666-0000-200000000000"; - protected static final String ORG_SAVE_ELAINE_OID = "00000000-8888-6666-0000-200000000001"; - protected static final String ORG_KIDNAP_AND_MARRY_ELAINE_OID = "00000000-8888-6666-0000-200000000002"; - - protected static final String ORG_TYPE_FUNCTIONAL = "functional"; - protected static final String ORG_TYPE_PROJECT = "project"; - - protected static final File CUSTOM_LIBRARY_FILE = new File(COMMON_DIR, "custom-library.xml"); - - protected static final File SERVICE_SHIP_SEA_MONKEY_FILE = new File(COMMON_DIR, "service-ship-sea-monkey.xml"); - protected static final String SERVICE_SHIP_SEA_MONKEY_OID = "914b94be-1901-11e6-9269-972ee32cd8db"; - - protected static final String TASK_RECONCILE_DUMMY_FILENAME = COMMON_DIR + "/task-reconcile-dummy.xml"; - protected static final String TASK_RECONCILE_DUMMY_OID = "10000000-0000-0000-5656-565600000004"; - - protected static final String TASK_RECONCILE_DUMMY_BLUE_FILENAME = COMMON_DIR + "/task-reconcile-dummy-blue.xml"; - protected static final String TASK_RECONCILE_DUMMY_BLUE_OID = "10000000-0000-0000-5656-565600000204"; - - protected static final String TASK_RECONCILE_DUMMY_GREEN_FILENAME = COMMON_DIR + "/task-reconcile-dummy-green.xml"; - protected static final String TASK_RECONCILE_DUMMY_GREEN_OID = "10000000-0000-0000-5656-565600000404"; - - protected static final String TASK_LIVE_SYNC_DUMMY_FILENAME = COMMON_DIR + "/task-dumy-livesync.xml"; - protected static final String TASK_LIVE_SYNC_DUMMY_OID = "10000000-0000-0000-5555-555500000004"; - - protected static final String TASK_LIVE_SYNC_DUMMY_BLUE_FILENAME = COMMON_DIR + "/task-dumy-blue-livesync.xml"; - protected static final String TASK_LIVE_SYNC_DUMMY_BLUE_OID = "10000000-0000-0000-5555-555500000204"; - - protected static final String TASK_LIVE_SYNC_DUMMY_GREEN_FILENAME = COMMON_DIR + "/task-dumy-green-livesync.xml"; - protected static final String TASK_LIVE_SYNC_DUMMY_GREEN_OID = "10000000-0000-0000-5555-555500000404"; - - protected static final String TASK_VALIDITY_SCANNER_FILENAME = COMMON_DIR + "/task-validity-scanner.xml"; - protected static final String TASK_PARTITIONED_VALIDITY_SCANNER_FILENAME = COMMON_DIR + "/task-partitioned-validity-scanner.xml"; - protected static final String TASK_VALIDITY_SCANNER_OID = "10000000-0000-0000-5555-555505060400"; - - protected static final File TASK_TRIGGER_SCANNER_FILE = new File(COMMON_DIR, "task-trigger-scanner.xml"); - protected static final String TASK_TRIGGER_SCANNER_OID = "00000000-0000-0000-0000-000000000007"; - - protected static final File TASK_MOCK_JACK_FILE = new File(COMMON_DIR, "task-mock-jack.xml"); - protected static final String TASK_MOCK_JACK_OID = "10000000-0000-0000-5656-565674633311"; - - protected static final String TASK_DELETE_NOT_UPDATED_SHADOWS = COMMON_DIR + "/task-delete-not-updated-shadows.xml"; - protected static final String TASK_DELETE_NOT_UPDATED_SHADOWS_OID = "5b2ba49f-6d4f-4618-afdf-4d138117e40a"; - - public static final File LOOKUP_LANGUAGES_FILE = new File(COMMON_DIR, "lookup-languages.xml"); - public static final String LOOKUP_LANGUAGES_OID = "70000000-0000-0000-1111-000000000001"; - public static final String LOOKUP_LANGUAGES_NAME = "Languages"; - - protected static final File SECURITY_POLICY_FILE = new File(COMMON_DIR, "security-policy.xml"); - protected static final String SECURITY_POLICY_OID = "28bf845a-b107-11e3-85bc-001e8c717e5b"; - - protected static final File ARCHETYPE_EMPLOYEE_FILE = new File(COMMON_DIR, "archetype-employee.xml"); - protected static final String ARCHETYPE_EMPLOYEE_OID = "7135e68c-ee53-11e8-8025-170b77da3fd6"; - protected static final String ARCHETYPE_EMPLOYEE_DISPLAY_LABEL = "Employee"; - protected static final String ARCHETYPE_EMPLOYEE_DISPLAY_PLURAL_LABEL = "Employees"; - - protected static final File ARCHETYPE_APPROVAL_CASE_FILE = new File(COMMON_DIR, "archetype-approval-case.xml"); - protected static final String ARCHETYPE_APPROVAL_CASE_OID = "00000000-0000-0000-0000-000000000342"; - - protected static final String NS_PIRACY = "http://midpoint.evolveum.com/xml/ns/samples/piracy"; - protected static final ItemName PIRACY_SHIP = new ItemName(NS_PIRACY, "ship"); - protected static final ItemName PIRACY_SHIP_BROKEN = new ItemName(NS_PIRACY, "ship-broken"); - protected static final ItemName PIRACY_TALES = new ItemName(NS_PIRACY, "tales"); - protected static final ItemName PIRACY_WEAPON = new ItemName(NS_PIRACY, "weapon"); - protected static final ItemName PIRACY_LOOT = new ItemName(NS_PIRACY, "loot"); - protected static final ItemName PIRACY_BAD_LUCK = new ItemName(NS_PIRACY, "badLuck"); - protected static final ItemName PIRACY_FUNERAL_TIMESTAMP = new ItemName(NS_PIRACY, "funeralTimestamp"); - protected static final ItemName PIRACY_SEA_QNAME = new ItemName(NS_PIRACY, "sea"); - protected static final ItemName PIRACY_COLORS = new ItemName(NS_PIRACY, "colors"); - protected static final ItemName PIRACY_MARK = new ItemName(NS_PIRACY, "mark"); - protected static final ItemName PIRACY_KEY = new ItemName(NS_PIRACY, "key"); - protected static final ItemName PIRACY_BINARY_ID = new ItemName(NS_PIRACY, "binaryId"); - protected static final ItemName PIRACY_COST_CENTER = new ItemName(NS_PIRACY, "costCenter"); - protected static final ItemName PIRACY_RISK_VECTOR = new ItemName(NS_PIRACY, "riskVector"); - protected static final ItemName PIRACY_RISK_VECTOR_RISK = new ItemName(NS_PIRACY, "risk"); - protected static final ItemName PIRACY_RISK_VECTOR_VALUE = new ItemName(NS_PIRACY, "value"); - protected static final ItemName RELATION_PIRACY_CAPTAIN = new ItemName(NS_PIRACY, "captain"); - protected static final ItemName PIRACY_LOCKER = new ItemName(NS_PIRACY, "locker"); - - protected static final ItemPath ROLE_EXTENSION_COST_CENTER_PATH = ItemPath - .create(RoleType.F_EXTENSION, new QName(NS_PIRACY, "costCenter")); - - protected static final String DUMMY_ACCOUNT_ATTRIBUTE_SEA_NAME = "sea"; - protected static final String DUMMY_ACCOUNT_ATTRIBUTE_MATE_NAME = "mate"; - protected static final String DUMMY_ACCOUNT_ATTRIBUTE_LOCKER_NAME = "locker"; - protected static final String DUMMY_ACCOUNT_ATTRIBUTE_PROOF_NAME = "proof"; - - protected static final String INTENT_TEST = "test"; - protected static final String INTENT_DUMMY_GROUP = "group"; - protected static final String INTENT_DUMMY_PRIVILEGE = "privilege"; - - // Authorizations - - protected static final String NS_TEST_AUTZ = "http://midpoint.evolveum.com/xml/ns/test/authorization"; - protected static final QName AUTZ_LOOT_QNAME = new QName(NS_TEST_AUTZ, "loot"); - protected static final String AUTZ_LOOT_URL = QNameUtil.qNameToUri(AUTZ_LOOT_QNAME); - protected static final QName AUTZ_COMMAND_QNAME = new QName(NS_TEST_AUTZ, "command"); - protected static final String AUTZ_COMMAND_URL = QNameUtil.qNameToUri(AUTZ_COMMAND_QNAME); - protected static final QName AUTZ_PUNISH_QNAME = new QName(NS_TEST_AUTZ, "punish"); - protected static final String AUTZ_PUNISH_URL = QNameUtil.qNameToUri(AUTZ_PUNISH_QNAME); - protected static final QName AUTZ_CAPSIZE_QNAME = new QName(NS_TEST_AUTZ, "capsize"); - protected static final String AUTZ_CAPSIZE_URL = QNameUtil.qNameToUri(AUTZ_CAPSIZE_QNAME); - protected static final QName AUTZ_SUPERSPECIAL_QNAME = new QName(NS_TEST_AUTZ, "superspecial"); - protected static final String AUTZ_SUPERSPECIAL_URL = QNameUtil.qNameToUri(AUTZ_SUPERSPECIAL_QNAME); - protected static final QName AUTZ_NONSENSE_QNAME = new QName(NS_TEST_AUTZ, "nonsense"); - protected static final String AUTZ_NONSENSE_URL = QNameUtil.qNameToUri(AUTZ_NONSENSE_QNAME); - protected static final QName AUTZ_SAIL_QNAME = new QName(NS_TEST_AUTZ, "sail"); - protected static final String AUTZ_SAIL_URL = QNameUtil.qNameToUri(AUTZ_SAIL_QNAME); - protected static final QName AUTZ_DRINK_QNAME = new QName(NS_TEST_AUTZ, "drink"); - protected static final String AUTZ_DRINK_URL = QNameUtil.qNameToUri(AUTZ_DRINK_QNAME); - protected static final QName AUTZ_APPARATE_QNAME = new QName(NS_TEST_AUTZ, "apparate"); - protected static final String AUTZ_APPARATE_URL = QNameUtil.qNameToUri(AUTZ_APPARATE_QNAME); - protected static final QName AUTZ_GAMBLE_QNAME = new QName(NS_TEST_AUTZ, "gamble"); - protected static final String AUTZ_GAMBLE_URL = QNameUtil.qNameToUri(AUTZ_GAMBLE_QNAME); - protected static final QName AUTZ_CROUPIER_QNAME = new QName(NS_TEST_AUTZ, "croupier"); - protected static final String AUTZ_CROUPIER_URL = QNameUtil.qNameToUri(AUTZ_CROUPIER_QNAME); - protected static final QName AUTZ_PIT_BOSS_QNAME = new QName(NS_TEST_AUTZ, "pitBoss"); - protected static final String AUTZ_PIT_BOSS_URL = QNameUtil.qNameToUri(AUTZ_PIT_BOSS_QNAME); - - protected static final String NOTIFIER_ACCOUNT_PASSWORD_NAME = "accountPasswordNotifier"; - protected static final String NOTIFIER_USER_PASSWORD_NAME = "userPasswordNotifier"; - protected static final String NOTIFIER_ACCOUNT_ACTIVATION_NAME = "accountActivationNotifier"; - - private static final Trace LOGGER = TraceManager.getTrace(AbstractConfiguredModelIntegrationTest.class); - - protected PrismObject userAdministrator; - - public AbstractConfiguredModelIntegrationTest() { - super(); - } - - @Override - public void initSystem(Task initTask, OperationResult initResult) throws Exception { - LOGGER.trace("initSystem"); - - // We want logging config from logback-test.xml and not from system config object (unless suppressed) - InternalsConfig.setAvoidLoggingChange(isAvoidLoggingChange()); - super.initSystem(initTask, initResult); - - modelService.postInit(initResult); - ManualConnectorInstance.setRandomDelayRange(0); - - // System Configuration - PrismObject configuration; - try { - File systemConfigurationFile = getSystemConfigurationFile(); - if (systemConfigurationFile != null) { - configuration = repoAddObjectFromFile(systemConfigurationFile, initResult); - } else { - configuration = addSystemConfigurationObject(initResult); - } - } catch (ObjectAlreadyExistsException e) { - throw new ObjectAlreadyExistsException("System configuration already exists in repository;" + - "looks like the previous test haven't cleaned it up", e); - } - if (configuration != null) { - relationRegistry.applyRelationsConfiguration(configuration.asObjectable()); - } - - // Users - userAdministrator = repoAddObjectFromFile(USER_ADMINISTRATOR_FILE, UserType.class, initResult); - repoAddObjectFromFile(ROLE_SUPERUSER_FILE, initResult); - login(userAdministrator); - } - - protected int getNumberOfUsers() { - return 1; // Administrator - } - - protected int getNumberOfRoles() { - return 1; // Superuser role - } - - protected File getSystemConfigurationFile() { - return SYSTEM_CONFIGURATION_FILE; - } - - // to be used in very specific cases only (it is invoked when getSystemConfigurationFile returns null). - protected PrismObject addSystemConfigurationObject(OperationResult initResult) throws IOException, CommonException, - EncryptionException { - return null; - } - - protected PrismObject getDefaultActor() { - return userAdministrator; - } - - @Override - public void run(@NotNull IHookCallBack callBack, ITestResult testResult) { - long time = System.currentTimeMillis(); - LOGGER.info("###>>> run start"); - super.run(callBack, testResult); - LOGGER.info("###>>> run end ({}ms)", new Object[]{(System.currentTimeMillis() - time)}); - } - - @AfterClass - @Override - protected void springTestContextAfterTestClass() throws Exception { - long time = System.currentTimeMillis(); - LOGGER.info("###>>> springTestContextAfterTestClass start"); - super.springTestContextAfterTestClass(); - - nullAllFields(this, getClass()); - - LOGGER.info("###>>> springTestContextAfterTestClass end ({}ms)", new Object[]{(System.currentTimeMillis() - time)}); - } - - /** - * This method null all fields which are not static, final or primitive type. - * - * All this is just to make GC work during DirtiesContext after every test class, - * because memory consumption is too big. Test class instances can't be GCed - * immediately. If they holds autowired fields like sessionFactory (for example - * through SqlRepositoryService impl), their memory footprint is getting big. - */ - public static void nullAllFields(Object object, Class forClass) throws Exception{ - if (forClass.getSuperclass() != null) { - nullAllFields(object, forClass.getSuperclass()); - } - - for (Field field : forClass.getDeclaredFields()) { - if (Modifier.isFinal(field.getModifiers()) - || Modifier.isStatic(field.getModifiers()) - || field.getType().isPrimitive()) { - continue; - } - - nullField(object, field); - } - } - - private static void nullField(Object obj, Field field) throws Exception { - LOGGER.info("Setting {} to null on {}.", new Object[]{field.getName(), obj.getClass().getSimpleName()}); - boolean accessible = field.isAccessible(); - if (!accessible) { - field.setAccessible(true); - } - field.set(obj, null); - field.setAccessible(accessible); - } - - @AfterMethod - @Override - protected void springTestContextAfterTestMethod(@NotNull Method testMethod) throws Exception { - long time = System.currentTimeMillis(); - LOGGER.info("###>>> springTestContextAfterTestMethod start"); - super.springTestContextAfterTestMethod(testMethod); - LOGGER.info("###>>> springTestContextAfterTestMethod end ({}ms)", new Object[]{(System.currentTimeMillis() - time)}); - } - - @BeforeClass - @Override - protected void springTestContextBeforeTestClass() throws Exception { - long time = System.currentTimeMillis(); - LOGGER.info("###>>> springTestContextBeforeTestClass start"); - super.springTestContextBeforeTestClass(); - LOGGER.info("###>>> springTestContextBeforeTestClass end ({}ms)", new Object[]{(System.currentTimeMillis() - time)}); - } - - @BeforeMethod - @Override - protected void springTestContextBeforeTestMethod(@NotNull Method testMethod) throws Exception { - long time = System.currentTimeMillis(); - LOGGER.info("###>>> springTestContextBeforeTestMethod start"); - super.springTestContextBeforeTestMethod(testMethod); - LOGGER.info("###>>> springTestContextBeforeTestMethod end ({}ms)", new Object[]{(System.currentTimeMillis() - time)}); - } - - @BeforeClass - @Override - protected void springTestContextPrepareTestInstance() throws Exception { - long time = System.currentTimeMillis(); - LOGGER.info("###>>> springTestContextPrepareTestInstance start"); - super.springTestContextPrepareTestInstance(); - LOGGER.info("###>>> springTestContextPrepareTestInstance end ({}ms)", new Object[]{(System.currentTimeMillis() - time)}); - } - - protected PrismSchema getPiracySchema() { - return prismContext.getSchemaRegistry().findSchemaByNamespace(NS_PIRACY); - } - - protected void assertLastScanTimestamp(String taskOid, XMLGregorianCalendar startCal, XMLGregorianCalendar endCal) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - XMLGregorianCalendar lastScanTimestamp = getLastScanTimestamp(taskOid); - assertNotNull("null lastScanTimestamp", lastScanTimestamp); - TestUtil.assertBetween("lastScanTimestamp", startCal, endCal, lastScanTimestamp); - } - - protected XMLGregorianCalendar getLastScanTimestamp(String taskOid) - throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, - ConfigurationException, ExpressionEvaluationException { - PrismObject task = getTask(taskOid); - display("Task", task); - PrismContainer taskExtension = task.getExtension(); - assertNotNull("No task extension", taskExtension); - PrismProperty lastScanTimestampProp = taskExtension.findProperty(SchemaConstants.MODEL_EXTENSION_LAST_SCAN_TIMESTAMP_PROPERTY_NAME); - assertNotNull("no lastScanTimestamp property", lastScanTimestampProp); - return lastScanTimestampProp.getRealValue(); - } - - protected void assertPasswordMetadata(PrismObject user, boolean create, XMLGregorianCalendar start, XMLGregorianCalendar end) { - assertPasswordMetadata(user, create, start, end, USER_ADMINISTRATOR_OID, SchemaConstants.CHANNEL_GUI_USER_URI); - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - protected void clearUserOrgAndRoleRefs(String userOid) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - OperationResult result = new OperationResult("clearUserOrgAndRoleRefs"); - Collection modifications = new ArrayList<>(); - ReferenceDelta parentOrgRefDelta = prismContext.deltaFactory().reference().createModificationReplace( - UserType.F_PARENT_ORG_REF, getUserDefinition(), (PrismReferenceValue)null); - modifications.add(parentOrgRefDelta); - ReferenceDelta roleMembershipRefDelta = prismContext.deltaFactory().reference().createModificationReplace( - UserType.F_ROLE_MEMBERSHIP_REF, getUserDefinition(), (PrismReferenceValue)null); - modifications.add(roleMembershipRefDelta); - repositoryService.modifyObject(UserType.class, userOid, modifications, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - PrismObject userBefore = getUser(userOid); - display("User before", userBefore); - } - - protected void assertEvaluatedRole(Collection evaluatedRoles, - String expectedRoleOid) { - for (EvaluatedAssignmentTarget evalRole: evaluatedRoles) { - if (expectedRoleOid.equals(evalRole.getTarget().getOid())) { - return; - } - } - AssertJUnit.fail("Role "+expectedRoleOid+" no present in evaluated roles "+evaluatedRoles); - } - - protected void assertSingleAccountPasswordNotification(String dummyResourceName, String username, - String password) { - assertAccountPasswordNotifications(1); - assertSingleDummyTransportMessage(NOTIFIER_ACCOUNT_PASSWORD_NAME, - getExpectedAccountPasswordNotificationBody(dummyResourceName, username, password)); - } - - protected void assertSingleUserPasswordNotification(String username, String password) { - assertUserPasswordNotifications(1); - assertSingleDummyTransportMessage(NOTIFIER_USER_PASSWORD_NAME, - getExpectedUserPasswordNotificationBody(username, password)); - } - - protected void assertAccountPasswordNotifications(int expected) { - checkDummyTransportMessages(NOTIFIER_ACCOUNT_PASSWORD_NAME, expected); - } - - protected void assertUserPasswordNotifications(int expected) { - checkDummyTransportMessages(NOTIFIER_USER_PASSWORD_NAME, expected); - } - - protected void assertNoAccountPasswordNotifications() { - checkDummyTransportMessages(NOTIFIER_ACCOUNT_PASSWORD_NAME, 0); - } - - protected void assertNoUserPasswordNotifications() { - checkDummyTransportMessages(NOTIFIER_USER_PASSWORD_NAME, 0); - } - - protected void assertHasAccountPasswordNotification(String dummyResourceName, String username, - String password) { - assertHasDummyTransportMessage(NOTIFIER_ACCOUNT_PASSWORD_NAME, - getExpectedAccountPasswordNotificationBody(dummyResourceName, username, password)); - } - - protected void assertSingleAccountPasswordNotificationGenerated(String dummyResourceName, String username) { - assertAccountPasswordNotifications(1); - String body = getDummyTransportMessageBody(NOTIFIER_ACCOUNT_PASSWORD_NAME, 0); - String expectedPrefix = getExpectedAccountPasswordNotificationBodyPrefix(dummyResourceName, username); - if (!body.startsWith(expectedPrefix)) { - fail("Expected that "+dummyResourceName+" dummy password notification message starts with prefix '"+expectedPrefix+"', but it was: "+body); - } - String suffix = body.substring(expectedPrefix.length()); - if (suffix.isEmpty()) { - fail("Empty password in "+dummyResourceName+" dummy password notification message"); - } - } - - protected String getExpectedAccountPasswordNotificationBody(String dummyResourceName, String username, - String password) { - return getExpectedAccountPasswordNotificationBodyPrefix(dummyResourceName, username) + password; - } - - protected String getExpectedAccountPasswordNotificationBodyPrefix(String dummyResourceName, String username) { - String resourceName = getDummyResourceType(dummyResourceName).getName().getOrig(); - return "Password for account "+username+" on "+resourceName+" is: "; - } - - protected String getExpectedUserPasswordNotificationBody(String username, String password) { - return getExpectedUserPasswordNotificationBodyPrefix(username) + password; - } - - protected String getExpectedUserPasswordNotificationBodyPrefix(String username) { - return "Password for user "+username+" is: "; - } - - protected void displayAccountPasswordNotifications() { - displayNotifications(NOTIFIER_ACCOUNT_PASSWORD_NAME); - } - - protected void displayUserPasswordNotifications() { - displayNotifications(NOTIFIER_USER_PASSWORD_NAME); - } - - protected Object getQuote(String description, String fullName) { - return description + " -- " + fullName; - } - - protected void loginAdministrator() throws SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - login(userAdministrator); - } -} +/* + * Copyright (c) 2010-2017 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ +package com.evolveum.midpoint.model.intest; + +import static org.testng.AssertJUnit.assertNotNull; + +import com.evolveum.midpoint.model.api.context.EvaluatedAssignmentTarget; +import com.evolveum.midpoint.model.test.AbstractModelIntegrationTest; +import com.evolveum.midpoint.prism.PrismContainer; +import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.prism.PrismProperty; +import com.evolveum.midpoint.prism.PrismReferenceValue; +import com.evolveum.midpoint.prism.crypto.EncryptionException; +import com.evolveum.midpoint.prism.delta.ReferenceDelta; +import com.evolveum.midpoint.prism.path.ItemPath; +import com.evolveum.midpoint.prism.path.ItemName; +import com.evolveum.midpoint.prism.schema.PrismSchema; +import com.evolveum.midpoint.provisioning.ucf.impl.builtin.ManualConnectorInstance; +import com.evolveum.midpoint.schema.constants.MidPointConstants; +import com.evolveum.midpoint.schema.constants.SchemaConstants; +import com.evolveum.midpoint.schema.internals.InternalsConfig; +import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.DummyResourceContoller; +import com.evolveum.midpoint.test.IntegrationTestTools; +import com.evolveum.midpoint.test.util.TestUtil; +import com.evolveum.midpoint.util.MiscUtil; +import com.evolveum.midpoint.util.QNameUtil; +import com.evolveum.midpoint.util.exception.*; +import com.evolveum.midpoint.util.logging.Trace; +import com.evolveum.midpoint.util.logging.TraceManager; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; + +import org.jetbrains.annotations.NotNull; +import org.testng.AssertJUnit; +import org.testng.IHookCallBack; +import org.testng.ITestResult; +import org.testng.annotations.AfterClass; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; + +import javax.xml.datatype.XMLGregorianCalendar; +import javax.xml.namespace.QName; + +/** + * @author semancik + * + */ +public class AbstractConfiguredModelIntegrationTest extends AbstractModelIntegrationTest { + + public static final File SYSTEM_CONFIGURATION_FILE = new File(COMMON_DIR, "system-configuration.xml"); + public static final String SYSTEM_CONFIGURATION_OID = SystemObjectsType.SYSTEM_CONFIGURATION.value(); + + protected static final int NUMBER_OF_GLOBAL_POLICY_RULES = 7; + + public static final File USER_ADMINISTRATOR_FILE = new File(COMMON_DIR, "user-administrator.xml"); + protected static final String USER_ADMINISTRATOR_OID = "00000000-0000-0000-0000-000000000002"; + + protected static final String USER_TEMPLATE_FILENAME = COMMON_DIR + "/user-template.xml"; + protected static final String USER_TEMPLATE_OID = "10000000-0000-0000-0000-000000000002"; + + protected static final File USER_TEMPLATE_COMPLEX_FILE = new File(COMMON_DIR, "user-template-complex.xml"); + protected static final String USER_TEMPLATE_COMPLEX_OID = "10000000-0000-0000-0000-000000000222"; + + protected static final File USER_TEMPLATE_SCHEMA_CONSTRAINTS_FILE = new File(COMMON_DIR, "user-template-schema-constraints.xml"); + protected static final String USER_TEMPLATE_SCHEMA_CONSTRAINTS_OID = "c2e52c79-a0ea-42ec-8853-1e9ea16175a9"; + + protected static final String USER_TEMPLATE_INBOUNDS_FILENAME = COMMON_DIR + "/user-template-inbounds.xml"; + protected static final String USER_TEMPLATE_INBOUNDS_OID = "10000000-0000-0000-0000-000000000555"; + + protected static final String USER_TEMPLATE_COMPLEX_INCLUDE_FILENAME = COMMON_DIR + "/user-template-complex-include.xml"; + protected static final String USER_TEMPLATE_COMPLEX_INCLUDE_OID = "10000000-0000-0000-0000-000000000223"; + + protected static final String USER_TEMPLATE_SYNC_FILENAME = COMMON_DIR + "/user-template-sync.xml"; + protected static final String USER_TEMPLATE_SYNC_OID = "10000000-0000-0000-0000-000000000333"; + + protected static final String USER_TEMPLATE_ORG_ASSIGNMENT_FILENAME = COMMON_DIR + "/user-template-org-assignment.xml"; + protected static final String USER_TEMPLATE_ORG_ASSIGNMENT_OID = "10000000-0000-0000-0000-000000000444"; + + protected static final String USER_TEMPLATE_CARTHESIAN_FILENAME = COMMON_DIR + "/user-template-carthesian.xml"; + protected static final String USER_TEMPLATE_CARTHESIAN_OID = "8e47c2b2-dde6-44a9-a7c0-de21a14cb70d"; + + protected static final File OBJECT_TEMPLATE_PERSONA_ADMIN_FILE = new File(COMMON_DIR, "object-template-persona-admin.xml"); + protected static final String OBJECT_TEMPLATE_PERSONA_ADMIN_OID = "894ea1a8-2c0a-11e7-a950-ff2047b0c053"; + + protected static final String CONNECTOR_LDAP_FILENAME = COMMON_DIR + "/connector-ldap.xml"; + + protected static final String CONNECTOR_DBTABLE_FILENAME = COMMON_DIR + "/connector-dbtable.xml"; + + protected static final String CONNECTOR_DUMMY_FILENAME = COMMON_DIR + "/connector-dummy.xml"; + + protected static final File RESOURCE_DUMMY_FILE = new File(COMMON_DIR, "resource-dummy.xml"); + protected static final File RESOURCE_DUMMY_CACHING_FILE = new File(COMMON_DIR, "resource-dummy-caching.xml"); + protected static final String RESOURCE_DUMMY_OID = "10000000-0000-0000-0000-000000000004"; + protected static final String RESOURCE_DUMMY_NAMESPACE = "http://midpoint.evolveum.com/xml/ns/public/resource/instance/10000000-0000-0000-0000-000000000004"; + protected static final String RESOURCE_DUMMY_DRINK = "rum"; + protected static final String RESOURCE_DUMMY_QUOTE = "Arr!"; + protected static final String RESOURCE_DUMMY_USELESS_STRING = "USEless"; + protected static final QName RESOURCE_DUMMY_GROUP_OBJECTCLASS = new QName(RESOURCE_DUMMY_NAMESPACE, "GroupObjectClass"); + protected static final QName RESOURCE_DUMMY_ASSOCIATION_GROUP_QNAME = new QName(RESOURCE_DUMMY_NAMESPACE, "group"); + protected static final QName RESOURCE_DUMMY_ASSOCIATION_PRIV_QNAME = new QName(RESOURCE_DUMMY_NAMESPACE, "priv"); + + // RED resource has STRONG mappings + protected static final File RESOURCE_DUMMY_RED_FILE = new File(COMMON_DIR, "resource-dummy-red.xml"); + protected static final String RESOURCE_DUMMY_RED_OID = "10000000-0000-0000-0000-000000000104"; + protected static final String RESOURCE_DUMMY_RED_NAME = "red"; + protected static final String RESOURCE_DUMMY_RED_NAMESPACE = MidPointConstants.NS_RI; + protected static final String RESOURCE_DUMMY_RED_USELESS_STRING = IntegrationTestTools.CONST_USELESS; + + // BLUE resource has WEAK mappings, outbound/inbound + protected static final File RESOURCE_DUMMY_BLUE_FILE = new File(COMMON_DIR, "resource-dummy-blue.xml"); + protected static final File RESOURCE_DUMMY_BLUE_CACHING_FILE = new File(COMMON_DIR, "resource-dummy-blue-caching.xml"); + protected static final String RESOURCE_DUMMY_BLUE_OID = "10000000-0000-0000-0000-000000000204"; + protected static final String RESOURCE_DUMMY_BLUE_NAME = "blue"; + protected static final String RESOURCE_DUMMY_BLUE_NAMESPACE = MidPointConstants.NS_RI; + + // CYAN has WEAK mappings, outbound only + protected static final File RESOURCE_DUMMY_CYAN_FILE = new File(COMMON_DIR, "resource-dummy-cyan.xml"); + protected static final String RESOURCE_DUMMY_CYAN_OID = "10000000-0000-0000-0000-00000000c204"; + protected static final String RESOURCE_DUMMY_CYAN_NAME = "cyan"; + protected static final String RESOURCE_DUMMY_CYAN_NAMESPACE = MidPointConstants.NS_RI; + + // WHITE dummy resource has almost no configuration: no schema, no schemahandling, no synchronization, ... + protected static final String RESOURCE_DUMMY_WHITE_FILENAME = COMMON_DIR + "/resource-dummy-white.xml"; + protected static final String RESOURCE_DUMMY_WHITE_OID = "10000000-0000-0000-0000-000000000304"; + protected static final String RESOURCE_DUMMY_WHITE_NAME = "white"; + protected static final String RESOURCE_DUMMY_WHITE_NAMESPACE = MidPointConstants.NS_RI; + + // YELLOW dummy resource is almost the same as default one but with strong asIs administrativeStatus mapping + // it also has minimal password length + protected static final File RESOURCE_DUMMY_YELLOW_FILE = new File(COMMON_DIR, "resource-dummy-yellow.xml"); + protected static final String RESOURCE_DUMMY_YELLOW_OID = "10000000-0000-0000-0000-000000000704"; + protected static final String RESOURCE_DUMMY_YELLOW_NAME = "yellow"; + protected static final String RESOURCE_DUMMY_YELLOW_NAMESPACE = MidPointConstants.NS_RI; + + // Green dummy resource is authoritative + protected static final File RESOURCE_DUMMY_GREEN_FILE = new File(COMMON_DIR, "resource-dummy-green.xml"); + protected static final File RESOURCE_DUMMY_GREEN_CACHING_FILE = new File(COMMON_DIR, "resource-dummy-green-caching.xml"); + protected static final String RESOURCE_DUMMY_GREEN_OID = "10000000-0000-0000-0000-000000000404"; + protected static final String RESOURCE_DUMMY_GREEN_NAME = "green"; + protected static final String RESOURCE_DUMMY_GREEN_NAMESPACE = MidPointConstants.NS_RI; + + // This is authoritative resource similar to green resource but it has a bit wilder inbound mappings. + protected static final File RESOURCE_DUMMY_EMERALD_FILE = new File(COMMON_DIR, "resource-dummy-emerald.xml"); + protected static final String RESOURCE_DUMMY_EMERALD_OID = "10000000-0000-0000-0000-00000000e404"; + protected static final String RESOURCE_DUMMY_EMERALD_NAME = "emerald"; + protected static final String RESOURCE_DUMMY_EMERALD_NAMESPACE = MidPointConstants.NS_RI; + + // Black dummy resource for testing tolerant attributes + protected static final File RESOURCE_DUMMY_BLACK_FILE = new File(COMMON_DIR, "resource-dummy-black.xml"); + protected static final String RESOURCE_DUMMY_BLACK_OID = "10000000-0000-0000-0000-000000000305"; + protected static final String RESOURCE_DUMMY_BLACK_NAME = "black"; + protected static final String RESOURCE_DUMMY_BLACK_NAMESPACE = MidPointConstants.NS_RI; + + // Black dummy resource for testing tolerant attributes + protected static final File RESOURCE_DUMMY_RELATIVE_FILE = new File(COMMON_DIR, "resource-dummy-relative.xml"); + protected static final String RESOURCE_DUMMY_RELATIVE_OID = "adcd4654-0f15-11e7-8337-0bdf60ad7bcd"; + protected static final String RESOURCE_DUMMY_RELATIVE_NAME = "relative"; + protected static final String RESOURCE_DUMMY_RELATIVE_NAMESPACE = MidPointConstants.NS_RI; + + // Orange dummy resource for testing associations with resource-provided referential integrity + // It also have very little outbound expressions and it has some strange inbound expressions. + protected static final File RESOURCE_DUMMY_ORANGE_FILE = new File(COMMON_DIR, "resource-dummy-orange.xml"); + protected static final String RESOURCE_DUMMY_ORANGE_OID = "10000000-0000-0000-0000-000000001104"; + protected static final String RESOURCE_DUMMY_ORANGE_NAME = "orange"; + protected static final String RESOURCE_DUMMY_ORANGE_NAMESPACE = MidPointConstants.NS_RI; + protected static final QName RESOURCE_DUMMY_ORANGE_ASSOCIATION_CREW_QNAME = new QName(RESOURCE_DUMMY_ORANGE_NAMESPACE, "crew"); + + protected static final String RESOURCE_DUMMY_SCHEMALESS_FILENAME = COMMON_DIR + "/resource-dummy-schemaless-no-schema.xml"; + protected static final String RESOURCE_DUMMY_SCHEMALESS_OID = "ef2bc95b-76e0-59e2-86d6-9999dddd0000"; + protected static final String RESOURCE_DUMMY_SCHEMALESS_NAME = "schemaless"; + protected static final String RESOURCE_DUMMY_SCHEMALESS_NAMESPACE = MidPointConstants.NS_RI; + + // Upcase resource turns all names to upper case. It is also caseInsensitive resource + protected static final File RESOURCE_DUMMY_UPCASE_FILE = new File(COMMON_DIR, "resource-dummy-upcase.xml"); + protected static final String RESOURCE_DUMMY_UPCASE_OID = "10000000-0000-0000-0000-000000001204"; + protected static final String RESOURCE_DUMMY_UPCASE_NAME = "upcase"; + protected static final String RESOURCE_DUMMY_UPCASE_NAMESPACE = MidPointConstants.NS_RI; + protected static final QName RESOURCE_DUMMY_UPCASE_ASSOCIATION_GROUP_QNAME = new QName(RESOURCE_DUMMY_UPCASE_NAMESPACE, "group"); + + protected static final String RESOURCE_DUMMY_FAKE_FILENAME = COMMON_DIR + "/resource-dummy-fake.xml"; + protected static final String RESOURCE_DUMMY_FAKE_OID = "10000000-0000-0000-0000-00000000000f"; + + public static final File ROLE_SUPERUSER_FILE = new File(COMMON_DIR, "role-superuser.xml"); + protected static final String ROLE_SUPERUSER_OID = "00000000-0000-0000-0000-000000000004"; + + protected static final File ROLE_PIRATE_FILE = new File(COMMON_DIR, "role-pirate.xml"); + protected static final String ROLE_PIRATE_OID = "12345678-d34d-b33f-f00d-555555556666"; + protected static final String ROLE_PIRATE_NAME = "Pirate"; + protected static final String ROLE_PIRATE_DESCRIPTION = "Scurvy Pirates"; + protected static final String ROLE_PIRATE_TITLE = "Bloody Pirate"; + protected static final String ROLE_PIRATE_WEAPON = "cutlass"; + + protected static final File ROLE_CARIBBEAN_PIRATE_FILE = new File(COMMON_DIR, "role-caribbean-pirate.xml"); + protected static final String ROLE_CARIBBEAN_PIRATE_OID = "0719ec66-edd9-11e6-bd70-03a74157ff9e"; + + protected static final File ROLE_PIRATE_GREEN_FILE = new File(COMMON_DIR, "role-pirate-green.xml"); + protected static final String ROLE_PIRATE_GREEN_OID = "12345678-d34d-b33f-f00d-555555557777"; + protected static final String ROLE_PIRATE_GREEN_NAME = "Pirate Green"; + protected static final String ROLE_PIRATE_GREEN_DESCRIPTION = "Scurvy Pirates"; + + protected static final File ROLE_PIRATE_RELATIVE_FILE = new File(COMMON_DIR, "role-pirate-relative.xml"); + protected static final String ROLE_PIRATE_RELATIVE_OID = "4a579cd0-0f17-11e7-967c-130ecd6fb7dc"; + protected static final String ROLE_PIRAT_RELATIVEE_NAME = "Relative Pirate"; + + protected static final File ROLE_BUCCANEER_GREEN_FILE = new File(COMMON_DIR, "role-buccaneer-green.xml"); + protected static final String ROLE_BUCCANEER_GREEN_OID = "12345678-d34d-b33f-f00d-555555558888"; + protected static final String ROLE_BUCCANEER_GREEN_NAME = "Bucaneers Green"; + protected static final String ROLE_BUCCANEER_GREEN_DESCRIPTION = "Scurvy Bucaneers"; + + protected static final String ROLE_NICE_PIRATE_FILENAME = COMMON_DIR + "/role-nice-pirate.xml"; + protected static final String ROLE_NICE_PIRATE_OID = "12345678-d34d-b33f-f00d-555555556677"; + + protected static final String ROLE_CAPTAIN_FILENAME = COMMON_DIR + "/role-captain.xml"; + protected static final String ROLE_CAPTAIN_OID = "12345678-d34d-b33f-f00d-55555555cccc"; + + // Excludes role "pirate" + protected static final File ROLE_JUDGE_FILE = new File(COMMON_DIR, "role-judge.xml"); + protected static final String ROLE_JUDGE_OID = "12345111-1111-2222-1111-121212111111"; + protected static final String ROLE_JUDGE_TITLE = "Honorable Justice"; + protected static final String ROLE_JUDGE_DRINK = "tea"; + protected static final String ROLE_JUDGE_DESCRIPTION = "Role with role exclusions"; + protected static final String ROLE_JUDGE_POLICY_RULE_EXCLUSION_PREFIX = "criminal exclusion: "; + + protected static final File ROLE_THIEF_FILE = new File(COMMON_DIR, "role-thief.xml"); + protected static final String ROLE_THIEF_OID = "b189fcb8-1ff9-11e5-8912-001e8c717e5b"; + + protected static final File ROLE_EMPTY_FILE = new File(COMMON_DIR, "role-empty.xml"); + protected static final String ROLE_EMPTY_OID = "12345111-1111-2222-1111-121212111112"; + + protected static final File ROLE_USELESS_FILE = new File(COMMON_DIR, "role-useless.xml"); + protected static final String ROLE_USELESS_OID = "12345111-1111-2222-1111-831209543124"; + + protected static final File ROLE_SAILOR_FILE = new File(COMMON_DIR, "role-sailor.xml"); + protected static final String ROLE_SAILOR_OID = "12345111-1111-2222-1111-121212111113"; + protected static final String ROLE_SAILOR_DRINK = "grog"; + + protected static final File ROLE_RED_SAILOR_FILE = new File(COMMON_DIR, "role-red-sailor.xml"); + protected static final String ROLE_RED_SAILOR_OID = "12345111-1111-2222-1111-121212111223"; + + protected static final File ROLE_CYAN_SAILOR_FILE = new File(COMMON_DIR, "role-cyan-sailor.xml"); + protected static final String ROLE_CYAN_SAILOR_OID = "d3abd794-9c30-11e6-bb5a-af14bf2cc29b"; + + protected static final File ROLE_STRONG_SAILOR_FILE = new File(COMMON_DIR, "role-strong-sailor.xml"); + protected static final String ROLE_STRONG_SAILOR_OID = "0bf7532e-7d15-11e7-8594-7bff6e0adc6e"; + + protected static final File ROLE_DRINKER_FILE = new File(COMMON_DIR, "role-drinker.xml"); + protected static final String ROLE_DRINKER_OID = "0abbde4c-ab3f-11e6-910d-d7dabf5f09f0"; + + protected static final File ROLE_PERSONA_ADMIN_FILE = new File(COMMON_DIR, "role-persona-admin.xml"); + protected static final String ROLE_PERSONA_ADMIN_OID = "16813ae6-2c0a-11e7-91fc-8333c244329e"; + + protected static final File ROLE_AUTOMATIC_FILE = new File(COMMON_DIR, "role-automatic.xml"); + protected static final String ROLE_AUTOMATIC_OID = "8fdb56d8-e3f3-11e6-8be9-cb9862ab7c04"; + + protected static final File ROLE_AUTOCRATIC_FILE = new File(COMMON_DIR, "role-autocratic.xml"); + protected static final String ROLE_AUTOCRATIC_OID = "4a678382-e3f4-11e6-8c3d-cfd3dba8168f"; + + protected static final File ROLE_AUTODIDACTIC_FILE = new File(COMMON_DIR, "role-autodidactic.xml"); + protected static final String ROLE_AUTODIDACTIC_OID = "a4f941dc-e3f4-11e6-8eba-9fe432784017"; + + protected static final File ROLE_AUTOGRAPHIC_FILE = new File(COMMON_DIR, "role-autographic.xml"); + protected static final String ROLE_AUTOGRAPHIC_OID = "be835a70-e3f4-11e6-82cb-9b47ebe57b11"; + + protected static final File ROLE_AUTOTESTERS_FILE = new File(COMMON_DIR, "role-autotesters.xml"); + protected static final String ROLE_AUTOTESTERS_OID = "be835a70-e3f4-11e6-82cb-9b47ecb57v14"; + + protected static final File ROLE_ADMINS_FILE = new File(COMMON_DIR, "role-admins.xml"); + protected static final String ROLE_ADMINS_OID = "be835a70-e3f4-11e6-82cb-9b47ecb57v15"; + + protected static final File ROLE_END_USER_FILE = new File(COMMON_DIR, "role-end-user.xml"); + protected static final String ROLE_END_USER_OID = "00000000-0000-0000-0000-00000000aa0f"; + + public static final File USER_JACK_FILE = new File(COMMON_DIR, "user-jack.xml"); + public static final String USER_JACK_OID = "c0c010c0-d34d-b33f-f00d-111111111111"; + public static final String USER_JACK_USERNAME = "jack"; + public static final String USER_JACK_FULL_NAME = "Jack Sparrow"; + public static final String USER_JACK_GIVEN_NAME = "Jack"; + public static final String USER_JACK_FAMILY_NAME = "Sparrow"; + public static final String USER_JACK_ADDITIONAL_NAME = "Jackie"; + public static final String USER_JACK_DESCRIPTION = "Where's the rum?"; + public static final String USER_JACK_SUBTYPE = "captain"; + public static final String USER_JACK_EMPLOYEE_NUMBER = "emp1234"; + public static final String USER_JACK_LOCALITY = "Caribbean"; + public static final String USER_JACK_PASSWORD = "deadmentellnotales"; + + protected static final File USER_BARBOSSA_FILE = new File(COMMON_DIR, "user-barbossa.xml"); + protected static final String USER_BARBOSSA_OID = "c0c010c0-d34d-b33f-f00d-111111111112"; + protected static final String USER_BARBOSSA_USERNAME = "barbossa"; + protected static final String USER_BARBOSSA_FULL_NAME = "Hector Barbossa"; + + protected static final File USER_GUYBRUSH_FILE = new File (COMMON_DIR, "user-guybrush.xml"); + protected static final String USER_GUYBRUSH_OID = "c0c010c0-d34d-b33f-f00d-111111111116"; + protected static final String USER_GUYBRUSH_USERNAME = "guybrush"; + protected static final String USER_GUYBRUSH_FULL_NAME = "Guybrush Threepwood"; + protected static final String USER_GUYBRUSH_GIVEN_NAME = "Guybrush"; + protected static final String USER_GUYBRUSH_FAMILY_NAME = "Threepwood"; + protected static final String USER_GUYBRUSH_LOCALITY = "Melee Island"; + + public static final File USER_WILL_FILE = new File(COMMON_DIR, "user-will.xml"); + public static final String USER_WILL_OID = "c0c010c0-d34d-b33f-f00d-111111145118"; + + // Largo does not have a full name set, employeeType=PIRATE + protected static final File USER_LARGO_FILE = new File(COMMON_DIR, "user-largo.xml"); + protected static final String USER_LARGO_OID = "c0c010c0-d34d-b33f-f00d-111111111118"; + protected static final String USER_LARGO_USERNAME = "largo"; + + // Rapp does not have a full name set, employeeType=COOK + protected static final File USER_RAPP_FILE = new File(COMMON_DIR, "user-rapp.xml"); + protected static final String USER_RAPP_OID = "c0c010c0-d34d-b33f-f00d-11111111c008"; + protected static final String USER_RAPP_USERNAME = "rapp"; + protected static final String USER_RAPP_FULLNAME = "Rapp Scallion"; + + // Herman has a validity dates set in the activation part + protected static final File USER_HERMAN_FILE = new File(COMMON_DIR, "user-herman.xml"); + protected static final String USER_HERMAN_OID = "c0c010c0-d34d-b33f-f00d-111111111122"; + protected static final String USER_HERMAN_USERNAME = "herman"; + protected static final String USER_HERMAN_GIVEN_NAME = "Herman"; + protected static final String USER_HERMAN_FAMILY_NAME = "Toothrot"; + protected static final String USER_HERMAN_FULL_NAME = "Herman Toothrot"; + protected static final String USER_HERMAN_PASSWORD = "m0nk3y"; + protected static final Date USER_HERMAN_VALID_FROM_DATE = MiscUtil.asDate(1700, 5, 30, 11, 0, 0); + protected static final Date USER_HERMAN_VALID_TO_DATE = MiscUtil.asDate(2233, 3, 23, 18, 30, 0); + + // Has null name, doesn not have given name, no employeeType + protected static final File USER_THREE_HEADED_MONKEY_FILE = new File(COMMON_DIR, "/user-three-headed-monkey.xml"); + protected static final String USER_THREE_HEADED_MONKEY_OID = "c0c010c0-d34d-b33f-f00d-110011001133"; + protected static final String USER_THREE_HEADED_MONKEY_NAME = "monkey"; + protected static final String USER_THREE_HEADED_MONKEY_FULL_NAME = "Three-Headed Monkey"; + + // User with no OID + protected static final File USER_NOOID_FILE = new File(COMMON_DIR, "user-nooid.xml"); + protected static final String USER_NOOID_USERNAME = "nooid"; + + // Elaine has account on the dummy resources (default, red, blue) + // The accounts are also assigned + protected static final File USER_ELAINE_FILE = new File (COMMON_DIR, "user-elaine.xml"); + protected static final String USER_ELAINE_OID = "c0c010c0-d34d-b33f-f00d-11111111111e"; + protected static final String USER_ELAINE_USERNAME = "elaine"; + + // Captain Kate Capsize does not exist in the repo. This user is designed to be added. + // She has account on dummy resources (default, red, blue) + // The accounts are also assigned + static final File USER_CAPSIZE_FILE = new File(COMMON_DIR, "user-capsize.xml"); + protected static final String USER_CAPSIZE_OID = "c0c010c0-d34d-b33f-f00d-11c1c1c1c11c"; + protected static final String USER_CAPSIZE_USERNAME = "capsize"; + static final File ACCOUNT_CAPSIZE_DUMMY_DEFAULT_FILE = new File(COMMON_DIR, "account-capsize-dummy-default.xml"); + static final File ACCOUNT_CAPSIZE_DUMMY_RED_FILE = new File(COMMON_DIR, "account-capsize-dummy-red.xml"); + static final File ACCOUNT_CAPSIZE_DUMMY_BLUE_FILE = new File(COMMON_DIR, "account-capsize-dummy-blue.xml"); + + protected static final File USER_DRAKE_FILE = new File(COMMON_DIR, "user-drake.xml"); + protected static final String USER_DRAKE_OID = "c0c010c0-d34d-b33f-f00d-11d1d1d1d1d1"; + protected static final String USER_DRAKE_USERNAME = "drake"; + protected static final String USER_DRAKE_FULLNAME = "Francis Drake"; + + public static final File ACCOUNT_JACK_DUMMY_FILE = new File(COMMON_DIR, "account-jack-dummy.xml"); + public static final File ACCOUNT_JACK_DUMMY_RED_FILE = new File(COMMON_DIR, "account-jack-dummy-red.xml"); + public static final String ACCOUNT_JACK_DUMMY_USERNAME = "jack"; + public static final String ACCOUNT_JACK_DUMMY_FULLNAME = "Jack Sparrow"; + + public static final File ACCOUNT_HERMAN_DUMMY_FILE = new File(COMMON_DIR, "account-herman-dummy.xml"); + public static final String ACCOUNT_HERMAN_DUMMY_OID = "22220000-2200-0000-0000-444400004444"; + public static final String ACCOUNT_HERMAN_DUMMY_USERNAME = "ht"; + + public static final File ACCOUNT_SHADOW_GUYBRUSH_DUMMY_FILE = new File(COMMON_DIR, "account-shadow-guybrush-dummy.xml"); + public static final String ACCOUNT_SHADOW_GUYBRUSH_OID = "22226666-2200-6666-6666-444400004444"; + public static final String ACCOUNT_GUYBRUSH_DUMMY_USERNAME = "guybrush"; + public static final String ACCOUNT_GUYBRUSH_DUMMY_FULLNAME = "Guybrush Threepwood"; + public static final String ACCOUNT_GUYBRUSH_DUMMY_LOCATION = "Melee Island"; + public static final File ACCOUNT_GUYBRUSH_DUMMY_FILE = new File (COMMON_DIR, "account-guybrush-dummy.xml"); + public static final File ACCOUNT_GUYBRUSH_DUMMY_RED_FILE = new File(COMMON_DIR, "account-guybrush-dummy-red.xml"); + + public static final String ACCOUNT_SHADOW_JACK_DUMMY_FILENAME = COMMON_DIR + "/account-shadow-jack-dummy.xml"; + + public static final String ACCOUNT_DAVIEJONES_DUMMY_USERNAME = "daviejones"; + public static final String ACCOUNT_CALYPSO_DUMMY_USERNAME = "calypso"; + + public static final File ACCOUNT_SHADOW_ELAINE_DUMMY_FILE = new File(COMMON_DIR, "account-elaine-dummy.xml"); + public static final String ACCOUNT_SHADOW_ELAINE_DUMMY_OID = "c0c010c0-d34d-b33f-f00d-22220004000e"; + public static final String ACCOUNT_ELAINE_DUMMY_USERNAME = USER_ELAINE_USERNAME; + public static final String ACCOUNT_ELAINE_DUMMY_FULLNAME = "Elaine Marley"; + + public static final File ACCOUNT_SHADOW_ELAINE_DUMMY_RED_FILE = new File(COMMON_DIR, "account-elaine-dummy-red.xml"); + public static final String ACCOUNT_SHADOW_ELAINE_DUMMY_RED_OID = "c0c010c0-d34d-b33f-f00d-22220104000e"; + public static final String ACCOUNT_ELAINE_DUMMY_RED_USERNAME = USER_ELAINE_USERNAME; + + public static final File ACCOUNT_SHADOW_ELAINE_DUMMY_BLUE_FILE = new File(COMMON_DIR, "account-elaine-dummy-blue.xml"); + public static final String ACCOUNT_SHADOW_ELAINE_DUMMY_BLUE_OID = "c0c010c0-d34d-b33f-f00d-22220204000e"; + public static final String ACCOUNT_ELAINE_DUMMY_BLUE_USERNAME = USER_ELAINE_USERNAME; + + public static final File GROUP_PIRATE_DUMMY_FILE = new File(COMMON_DIR, "group-pirate-dummy.xml"); + public static final String GROUP_PIRATE_DUMMY_NAME = "pirate"; + public static final String GROUP_PIRATE_DUMMY_DESCRIPTION = "Scurvy pirates"; + + public static final File SHADOW_GROUP_DUMMY_TESTERS_FILE = new File(COMMON_DIR, "group-testers-dummy.xml"); + public static final String SHADOW_GROUP_DUMMY_TESTERS_OID = "20000000-0000-0000-3333-000000000002"; + public static final String GROUP_DUMMY_TESTERS_NAME = "testers"; + public static final String GROUP_DUMMY_TESTERS_DESCRIPTION = "To boldly go where no pirate has gone before"; + + public static final File GROUP_SHADOW_JOKER_DUMMY_UPCASE_FILE = new File(COMMON_DIR, "group-shadow-dummy-upcase-joker.xml"); + public static final String GROUP_SHADOW_JOKER_DUMMY_UPCASE_OID = "bc2a1d98-9ca4-11e4-a600-001e8c717e5b"; + public static final String GROUP_SHADOW_JOKER_DUMMY_UPCASE_NAME = "joker"; + public static final String GROUP_JOKER_DUMMY_UPCASE_NAME = "JOKER"; + + public static final String DUMMY_ORG_TOP_NAME = DummyResourceContoller.ORG_TOP_NAME; + + protected static final File PASSWORD_POLICY_GLOBAL_FILE = new File(COMMON_DIR, "password-policy-global.xml"); + protected static final String PASSWORD_POLICY_GLOBAL_OID = "12344321-0000-0000-0000-000000000003"; + + protected static final File PASSWORD_POLICY_BENEVOLENT_FILE = new File(COMMON_DIR, "password-policy-benevolent.xml"); + protected static final String PASSWORD_POLICY_BENEVOLENT_OID = "ed8026dc-569a-11e7-abdf-4fce56706755"; + + protected static final File ORG_MONKEY_ISLAND_FILE = new File(COMMON_DIR, "org-monkey-island.xml"); + protected static final String ORG_GOVERNOR_OFFICE_OID = "00000000-8888-6666-0000-100000000001"; + protected static final String ORG_SCUMM_BAR_OID = "00000000-8888-6666-0000-100000000006"; + protected static final String ORG_SCUMM_BAR_NAME = "F0006"; + protected static final String ORG_SCUMM_BAR_DISPLAY_NAME = "Scumm Bar"; + protected static final String ORG_MINISTRY_OF_OFFENSE_OID = "00000000-8888-6666-0000-100000000003"; + protected static final String ORG_MINISTRY_OF_OFFENSE_NAME = "F0003"; + protected static final String ORG_MINISTRY_OF_DEFENSE_OID = "00000000-8888-6666-0000-100000000002"; + protected static final String ORG_MINISTRY_OF_DEFENSE_NAME = "F0002"; + protected static final String ORG_MINISTRY_OF_RUM_OID = "00000000-8888-6666-0000-100000000004"; + protected static final String ORG_MINISTRY_OF_RUM_NAME = "F0004"; + protected static final String ORG_SWASHBUCKLER_SECTION_OID = "00000000-8888-6666-0000-100000000005"; + protected static final String ORG_PROJECT_ROOT_OID = "00000000-8888-6666-0000-200000000000"; + protected static final String ORG_SAVE_ELAINE_OID = "00000000-8888-6666-0000-200000000001"; + protected static final String ORG_KIDNAP_AND_MARRY_ELAINE_OID = "00000000-8888-6666-0000-200000000002"; + + protected static final String ORG_TYPE_FUNCTIONAL = "functional"; + protected static final String ORG_TYPE_PROJECT = "project"; + + protected static final File CUSTOM_LIBRARY_FILE = new File(COMMON_DIR, "custom-library.xml"); + + protected static final File SERVICE_SHIP_SEA_MONKEY_FILE = new File(COMMON_DIR, "service-ship-sea-monkey.xml"); + protected static final String SERVICE_SHIP_SEA_MONKEY_OID = "914b94be-1901-11e6-9269-972ee32cd8db"; + + protected static final String TASK_RECONCILE_DUMMY_FILENAME = COMMON_DIR + "/task-reconcile-dummy.xml"; + protected static final String TASK_RECONCILE_DUMMY_OID = "10000000-0000-0000-5656-565600000004"; + + protected static final String TASK_RECONCILE_DUMMY_BLUE_FILENAME = COMMON_DIR + "/task-reconcile-dummy-blue.xml"; + protected static final String TASK_RECONCILE_DUMMY_BLUE_OID = "10000000-0000-0000-5656-565600000204"; + + protected static final String TASK_RECONCILE_DUMMY_GREEN_FILENAME = COMMON_DIR + "/task-reconcile-dummy-green.xml"; + protected static final String TASK_RECONCILE_DUMMY_GREEN_OID = "10000000-0000-0000-5656-565600000404"; + + protected static final String TASK_LIVE_SYNC_DUMMY_FILENAME = COMMON_DIR + "/task-dumy-livesync.xml"; + protected static final String TASK_LIVE_SYNC_DUMMY_OID = "10000000-0000-0000-5555-555500000004"; + + protected static final String TASK_LIVE_SYNC_DUMMY_BLUE_FILENAME = COMMON_DIR + "/task-dumy-blue-livesync.xml"; + protected static final String TASK_LIVE_SYNC_DUMMY_BLUE_OID = "10000000-0000-0000-5555-555500000204"; + + protected static final String TASK_LIVE_SYNC_DUMMY_GREEN_FILENAME = COMMON_DIR + "/task-dumy-green-livesync.xml"; + protected static final String TASK_LIVE_SYNC_DUMMY_GREEN_OID = "10000000-0000-0000-5555-555500000404"; + + protected static final String TASK_VALIDITY_SCANNER_FILENAME = COMMON_DIR + "/task-validity-scanner.xml"; + protected static final String TASK_PARTITIONED_VALIDITY_SCANNER_FILENAME = COMMON_DIR + "/task-partitioned-validity-scanner.xml"; + protected static final String TASK_VALIDITY_SCANNER_OID = "10000000-0000-0000-5555-555505060400"; + + protected static final File TASK_TRIGGER_SCANNER_FILE = new File(COMMON_DIR, "task-trigger-scanner.xml"); + protected static final String TASK_TRIGGER_SCANNER_OID = "00000000-0000-0000-0000-000000000007"; + + protected static final File TASK_MOCK_JACK_FILE = new File(COMMON_DIR, "task-mock-jack.xml"); + protected static final String TASK_MOCK_JACK_OID = "10000000-0000-0000-5656-565674633311"; + + protected static final String TASK_DELETE_NOT_UPDATED_SHADOWS = COMMON_DIR + "/task-delete-not-updated-shadows.xml"; + protected static final String TASK_DELETE_NOT_UPDATED_SHADOWS_OID = "5b2ba49f-6d4f-4618-afdf-4d138117e40a"; + + public static final File LOOKUP_LANGUAGES_FILE = new File(COMMON_DIR, "lookup-languages.xml"); + public static final String LOOKUP_LANGUAGES_OID = "70000000-0000-0000-1111-000000000001"; + public static final String LOOKUP_LANGUAGES_NAME = "Languages"; + + protected static final File SECURITY_POLICY_FILE = new File(COMMON_DIR, "security-policy.xml"); + protected static final String SECURITY_POLICY_OID = "28bf845a-b107-11e3-85bc-001e8c717e5b"; + + protected static final File ARCHETYPE_TASK_RECONCILIATION_FILE = new File(COMMON_DIR, "archetype-task-reconciliation.xml"); + protected static final String ARCHETYPE_TASK_RECONCILIATION_OID = "00000000-0000-0000-0000-000000000501"; + + protected static final File ARCHETYPE_EMPLOYEE_FILE = new File(COMMON_DIR, "archetype-employee.xml"); + protected static final String ARCHETYPE_EMPLOYEE_OID = "7135e68c-ee53-11e8-8025-170b77da3fd6"; + protected static final String ARCHETYPE_EMPLOYEE_DISPLAY_LABEL = "Employee"; + protected static final String ARCHETYPE_EMPLOYEE_DISPLAY_PLURAL_LABEL = "Employees"; + + protected static final File ARCHETYPE_APPROVAL_CASE_FILE = new File(COMMON_DIR, "archetype-approval-case.xml"); + protected static final String ARCHETYPE_APPROVAL_CASE_OID = "00000000-0000-0000-0000-000000000342"; + + protected static final String NS_PIRACY = "http://midpoint.evolveum.com/xml/ns/samples/piracy"; + protected static final ItemName PIRACY_SHIP = new ItemName(NS_PIRACY, "ship"); + protected static final ItemName PIRACY_SHIP_BROKEN = new ItemName(NS_PIRACY, "ship-broken"); + protected static final ItemName PIRACY_TALES = new ItemName(NS_PIRACY, "tales"); + protected static final ItemName PIRACY_WEAPON = new ItemName(NS_PIRACY, "weapon"); + protected static final ItemName PIRACY_LOOT = new ItemName(NS_PIRACY, "loot"); + protected static final ItemName PIRACY_BAD_LUCK = new ItemName(NS_PIRACY, "badLuck"); + protected static final ItemName PIRACY_FUNERAL_TIMESTAMP = new ItemName(NS_PIRACY, "funeralTimestamp"); + protected static final ItemName PIRACY_SEA_QNAME = new ItemName(NS_PIRACY, "sea"); + protected static final ItemName PIRACY_COLORS = new ItemName(NS_PIRACY, "colors"); + protected static final ItemName PIRACY_MARK = new ItemName(NS_PIRACY, "mark"); + protected static final ItemName PIRACY_KEY = new ItemName(NS_PIRACY, "key"); + protected static final ItemName PIRACY_BINARY_ID = new ItemName(NS_PIRACY, "binaryId"); + protected static final ItemName PIRACY_COST_CENTER = new ItemName(NS_PIRACY, "costCenter"); + protected static final ItemName PIRACY_RISK_VECTOR = new ItemName(NS_PIRACY, "riskVector"); + protected static final ItemName PIRACY_RISK_VECTOR_RISK = new ItemName(NS_PIRACY, "risk"); + protected static final ItemName PIRACY_RISK_VECTOR_VALUE = new ItemName(NS_PIRACY, "value"); + protected static final ItemName RELATION_PIRACY_CAPTAIN = new ItemName(NS_PIRACY, "captain"); + protected static final ItemName PIRACY_LOCKER = new ItemName(NS_PIRACY, "locker"); + + protected static final ItemPath ROLE_EXTENSION_COST_CENTER_PATH = ItemPath + .create(RoleType.F_EXTENSION, new QName(NS_PIRACY, "costCenter")); + + protected static final String DUMMY_ACCOUNT_ATTRIBUTE_SEA_NAME = "sea"; + protected static final String DUMMY_ACCOUNT_ATTRIBUTE_MATE_NAME = "mate"; + protected static final String DUMMY_ACCOUNT_ATTRIBUTE_LOCKER_NAME = "locker"; + protected static final String DUMMY_ACCOUNT_ATTRIBUTE_PROOF_NAME = "proof"; + + protected static final String INTENT_TEST = "test"; + protected static final String INTENT_DUMMY_GROUP = "group"; + protected static final String INTENT_DUMMY_PRIVILEGE = "privilege"; + + // Authorizations + + protected static final String NS_TEST_AUTZ = "http://midpoint.evolveum.com/xml/ns/test/authorization"; + protected static final QName AUTZ_LOOT_QNAME = new QName(NS_TEST_AUTZ, "loot"); + protected static final String AUTZ_LOOT_URL = QNameUtil.qNameToUri(AUTZ_LOOT_QNAME); + protected static final QName AUTZ_COMMAND_QNAME = new QName(NS_TEST_AUTZ, "command"); + protected static final String AUTZ_COMMAND_URL = QNameUtil.qNameToUri(AUTZ_COMMAND_QNAME); + protected static final QName AUTZ_PUNISH_QNAME = new QName(NS_TEST_AUTZ, "punish"); + protected static final String AUTZ_PUNISH_URL = QNameUtil.qNameToUri(AUTZ_PUNISH_QNAME); + protected static final QName AUTZ_CAPSIZE_QNAME = new QName(NS_TEST_AUTZ, "capsize"); + protected static final String AUTZ_CAPSIZE_URL = QNameUtil.qNameToUri(AUTZ_CAPSIZE_QNAME); + protected static final QName AUTZ_SUPERSPECIAL_QNAME = new QName(NS_TEST_AUTZ, "superspecial"); + protected static final String AUTZ_SUPERSPECIAL_URL = QNameUtil.qNameToUri(AUTZ_SUPERSPECIAL_QNAME); + protected static final QName AUTZ_NONSENSE_QNAME = new QName(NS_TEST_AUTZ, "nonsense"); + protected static final String AUTZ_NONSENSE_URL = QNameUtil.qNameToUri(AUTZ_NONSENSE_QNAME); + protected static final QName AUTZ_SAIL_QNAME = new QName(NS_TEST_AUTZ, "sail"); + protected static final String AUTZ_SAIL_URL = QNameUtil.qNameToUri(AUTZ_SAIL_QNAME); + protected static final QName AUTZ_DRINK_QNAME = new QName(NS_TEST_AUTZ, "drink"); + protected static final String AUTZ_DRINK_URL = QNameUtil.qNameToUri(AUTZ_DRINK_QNAME); + protected static final QName AUTZ_APPARATE_QNAME = new QName(NS_TEST_AUTZ, "apparate"); + protected static final String AUTZ_APPARATE_URL = QNameUtil.qNameToUri(AUTZ_APPARATE_QNAME); + protected static final QName AUTZ_GAMBLE_QNAME = new QName(NS_TEST_AUTZ, "gamble"); + protected static final String AUTZ_GAMBLE_URL = QNameUtil.qNameToUri(AUTZ_GAMBLE_QNAME); + protected static final QName AUTZ_CROUPIER_QNAME = new QName(NS_TEST_AUTZ, "croupier"); + protected static final String AUTZ_CROUPIER_URL = QNameUtil.qNameToUri(AUTZ_CROUPIER_QNAME); + protected static final QName AUTZ_PIT_BOSS_QNAME = new QName(NS_TEST_AUTZ, "pitBoss"); + protected static final String AUTZ_PIT_BOSS_URL = QNameUtil.qNameToUri(AUTZ_PIT_BOSS_QNAME); + + protected static final String NOTIFIER_ACCOUNT_PASSWORD_NAME = "accountPasswordNotifier"; + protected static final String NOTIFIER_USER_PASSWORD_NAME = "userPasswordNotifier"; + protected static final String NOTIFIER_ACCOUNT_ACTIVATION_NAME = "accountActivationNotifier"; + + private static final Trace LOGGER = TraceManager.getTrace(AbstractConfiguredModelIntegrationTest.class); + + protected PrismObject userAdministrator; + + public AbstractConfiguredModelIntegrationTest() { + super(); + } + + @Override + public void initSystem(Task initTask, OperationResult initResult) throws Exception { + LOGGER.trace("initSystem"); + + // We want logging config from logback-test.xml and not from system config object (unless suppressed) + InternalsConfig.setAvoidLoggingChange(isAvoidLoggingChange()); + super.initSystem(initTask, initResult); + + modelService.postInit(initResult); + ManualConnectorInstance.setRandomDelayRange(0); + + // System Configuration + PrismObject configuration; + try { + File systemConfigurationFile = getSystemConfigurationFile(); + if (systemConfigurationFile != null) { + configuration = repoAddObjectFromFile(systemConfigurationFile, initResult); + } else { + configuration = addSystemConfigurationObject(initResult); + } + } catch (ObjectAlreadyExistsException e) { + throw new ObjectAlreadyExistsException("System configuration already exists in repository;" + + "looks like the previous test haven't cleaned it up", e); + } + if (configuration != null) { + relationRegistry.applyRelationsConfiguration(configuration.asObjectable()); + } + + // Users + userAdministrator = repoAddObjectFromFile(USER_ADMINISTRATOR_FILE, UserType.class, initResult); + repoAddObjectFromFile(ROLE_SUPERUSER_FILE, initResult); + login(userAdministrator); + } + + protected int getNumberOfUsers() { + return 1; // Administrator + } + + protected int getNumberOfRoles() { + return 1; // Superuser role + } + + protected File getSystemConfigurationFile() { + return SYSTEM_CONFIGURATION_FILE; + } + + // to be used in very specific cases only (it is invoked when getSystemConfigurationFile returns null). + protected PrismObject addSystemConfigurationObject(OperationResult initResult) throws IOException, CommonException, + EncryptionException { + return null; + } + + protected PrismObject getDefaultActor() { + return userAdministrator; + } + + @Override + public void run(@NotNull IHookCallBack callBack, ITestResult testResult) { + long time = System.currentTimeMillis(); + LOGGER.info("###>>> run start"); + super.run(callBack, testResult); + LOGGER.info("###>>> run end ({}ms)", new Object[]{(System.currentTimeMillis() - time)}); + } + + @AfterClass + @Override + protected void springTestContextAfterTestClass() throws Exception { + long time = System.currentTimeMillis(); + LOGGER.info("###>>> springTestContextAfterTestClass start"); + super.springTestContextAfterTestClass(); + + nullAllFields(this, getClass()); + + LOGGER.info("###>>> springTestContextAfterTestClass end ({}ms)", new Object[]{(System.currentTimeMillis() - time)}); + } + + /** + * This method null all fields which are not static, final or primitive type. + * + * All this is just to make GC work during DirtiesContext after every test class, + * because memory consumption is too big. Test class instances can't be GCed + * immediately. If they holds autowired fields like sessionFactory (for example + * through SqlRepositoryService impl), their memory footprint is getting big. + */ + public static void nullAllFields(Object object, Class forClass) throws Exception{ + if (forClass.getSuperclass() != null) { + nullAllFields(object, forClass.getSuperclass()); + } + + for (Field field : forClass.getDeclaredFields()) { + if (Modifier.isFinal(field.getModifiers()) + || Modifier.isStatic(field.getModifiers()) + || field.getType().isPrimitive()) { + continue; + } + + nullField(object, field); + } + } + + private static void nullField(Object obj, Field field) throws Exception { + LOGGER.info("Setting {} to null on {}.", new Object[]{field.getName(), obj.getClass().getSimpleName()}); + boolean accessible = field.isAccessible(); + if (!accessible) { + field.setAccessible(true); + } + field.set(obj, null); + field.setAccessible(accessible); + } + + @AfterMethod + @Override + protected void springTestContextAfterTestMethod(@NotNull Method testMethod) throws Exception { + long time = System.currentTimeMillis(); + LOGGER.info("###>>> springTestContextAfterTestMethod start"); + super.springTestContextAfterTestMethod(testMethod); + LOGGER.info("###>>> springTestContextAfterTestMethod end ({}ms)", new Object[]{(System.currentTimeMillis() - time)}); + } + + @BeforeClass + @Override + protected void springTestContextBeforeTestClass() throws Exception { + long time = System.currentTimeMillis(); + LOGGER.info("###>>> springTestContextBeforeTestClass start"); + super.springTestContextBeforeTestClass(); + LOGGER.info("###>>> springTestContextBeforeTestClass end ({}ms)", new Object[]{(System.currentTimeMillis() - time)}); + } + + @BeforeMethod + @Override + protected void springTestContextBeforeTestMethod(@NotNull Method testMethod) throws Exception { + long time = System.currentTimeMillis(); + LOGGER.info("###>>> springTestContextBeforeTestMethod start"); + super.springTestContextBeforeTestMethod(testMethod); + LOGGER.info("###>>> springTestContextBeforeTestMethod end ({}ms)", new Object[]{(System.currentTimeMillis() - time)}); + } + + @BeforeClass + @Override + protected void springTestContextPrepareTestInstance() throws Exception { + long time = System.currentTimeMillis(); + LOGGER.info("###>>> springTestContextPrepareTestInstance start"); + super.springTestContextPrepareTestInstance(); + LOGGER.info("###>>> springTestContextPrepareTestInstance end ({}ms)", new Object[]{(System.currentTimeMillis() - time)}); + } + + protected PrismSchema getPiracySchema() { + return prismContext.getSchemaRegistry().findSchemaByNamespace(NS_PIRACY); + } + + protected void assertLastScanTimestamp(String taskOid, XMLGregorianCalendar startCal, XMLGregorianCalendar endCal) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + XMLGregorianCalendar lastScanTimestamp = getLastScanTimestamp(taskOid); + assertNotNull("null lastScanTimestamp", lastScanTimestamp); + TestUtil.assertBetween("lastScanTimestamp", startCal, endCal, lastScanTimestamp); + } + + protected XMLGregorianCalendar getLastScanTimestamp(String taskOid) + throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, + ConfigurationException, ExpressionEvaluationException { + PrismObject task = getTask(taskOid); + display("Task", task); + PrismContainer taskExtension = task.getExtension(); + assertNotNull("No task extension", taskExtension); + PrismProperty lastScanTimestampProp = taskExtension.findProperty(SchemaConstants.MODEL_EXTENSION_LAST_SCAN_TIMESTAMP_PROPERTY_NAME); + assertNotNull("no lastScanTimestamp property", lastScanTimestampProp); + return lastScanTimestampProp.getRealValue(); + } + + protected void assertPasswordMetadata(PrismObject user, boolean create, XMLGregorianCalendar start, XMLGregorianCalendar end) { + assertPasswordMetadata(user, create, start, end, USER_ADMINISTRATOR_OID, SchemaConstants.CHANNEL_GUI_USER_URI); + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + protected void clearUserOrgAndRoleRefs(String userOid) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + OperationResult result = new OperationResult("clearUserOrgAndRoleRefs"); + Collection modifications = new ArrayList<>(); + ReferenceDelta parentOrgRefDelta = prismContext.deltaFactory().reference().createModificationReplace( + UserType.F_PARENT_ORG_REF, getUserDefinition(), (PrismReferenceValue)null); + modifications.add(parentOrgRefDelta); + ReferenceDelta roleMembershipRefDelta = prismContext.deltaFactory().reference().createModificationReplace( + UserType.F_ROLE_MEMBERSHIP_REF, getUserDefinition(), (PrismReferenceValue)null); + modifications.add(roleMembershipRefDelta); + repositoryService.modifyObject(UserType.class, userOid, modifications, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + PrismObject userBefore = getUser(userOid); + display("User before", userBefore); + } + + protected void assertEvaluatedRole(Collection evaluatedRoles, + String expectedRoleOid) { + for (EvaluatedAssignmentTarget evalRole: evaluatedRoles) { + if (expectedRoleOid.equals(evalRole.getTarget().getOid())) { + return; + } + } + AssertJUnit.fail("Role "+expectedRoleOid+" no present in evaluated roles "+evaluatedRoles); + } + + protected void assertSingleAccountPasswordNotification(String dummyResourceName, String username, + String password) { + assertAccountPasswordNotifications(1); + assertSingleDummyTransportMessage(NOTIFIER_ACCOUNT_PASSWORD_NAME, + getExpectedAccountPasswordNotificationBody(dummyResourceName, username, password)); + } + + protected void assertSingleUserPasswordNotification(String username, String password) { + assertUserPasswordNotifications(1); + assertSingleDummyTransportMessage(NOTIFIER_USER_PASSWORD_NAME, + getExpectedUserPasswordNotificationBody(username, password)); + } + + protected void assertAccountPasswordNotifications(int expected) { + checkDummyTransportMessages(NOTIFIER_ACCOUNT_PASSWORD_NAME, expected); + } + + protected void assertUserPasswordNotifications(int expected) { + checkDummyTransportMessages(NOTIFIER_USER_PASSWORD_NAME, expected); + } + + protected void assertNoAccountPasswordNotifications() { + checkDummyTransportMessages(NOTIFIER_ACCOUNT_PASSWORD_NAME, 0); + } + + protected void assertNoUserPasswordNotifications() { + checkDummyTransportMessages(NOTIFIER_USER_PASSWORD_NAME, 0); + } + + protected void assertHasAccountPasswordNotification(String dummyResourceName, String username, + String password) { + assertHasDummyTransportMessage(NOTIFIER_ACCOUNT_PASSWORD_NAME, + getExpectedAccountPasswordNotificationBody(dummyResourceName, username, password)); + } + + protected void assertSingleAccountPasswordNotificationGenerated(String dummyResourceName, String username) { + assertAccountPasswordNotifications(1); + String body = getDummyTransportMessageBody(NOTIFIER_ACCOUNT_PASSWORD_NAME, 0); + String expectedPrefix = getExpectedAccountPasswordNotificationBodyPrefix(dummyResourceName, username); + if (!body.startsWith(expectedPrefix)) { + fail("Expected that "+dummyResourceName+" dummy password notification message starts with prefix '"+expectedPrefix+"', but it was: "+body); + } + String suffix = body.substring(expectedPrefix.length()); + if (suffix.isEmpty()) { + fail("Empty password in "+dummyResourceName+" dummy password notification message"); + } + } + + protected String getExpectedAccountPasswordNotificationBody(String dummyResourceName, String username, + String password) { + return getExpectedAccountPasswordNotificationBodyPrefix(dummyResourceName, username) + password; + } + + protected String getExpectedAccountPasswordNotificationBodyPrefix(String dummyResourceName, String username) { + String resourceName = getDummyResourceType(dummyResourceName).getName().getOrig(); + return "Password for account "+username+" on "+resourceName+" is: "; + } + + protected String getExpectedUserPasswordNotificationBody(String username, String password) { + return getExpectedUserPasswordNotificationBodyPrefix(username) + password; + } + + protected String getExpectedUserPasswordNotificationBodyPrefix(String username) { + return "Password for user "+username+" is: "; + } + + protected void displayAccountPasswordNotifications() { + displayNotifications(NOTIFIER_ACCOUNT_PASSWORD_NAME); + } + + protected void displayUserPasswordNotifications() { + displayNotifications(NOTIFIER_USER_PASSWORD_NAME); + } + + protected Object getQuote(String description, String fullName) { + return description + " -- " + fullName; + } + + protected void loginAdministrator() throws SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + login(userAdministrator); + } +} diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/AbstractInitializedModelIntegrationTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/AbstractInitializedModelIntegrationTest.java index edb0e326ad6..b54e6769631 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/AbstractInitializedModelIntegrationTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/AbstractInitializedModelIntegrationTest.java @@ -1,432 +1,435 @@ -/* - * Copyright (c) 2010-2019 Evolveum and contributors - * - * This work is dual-licensed under the Apache License 2.0 - * and European Union Public License. See LICENSE file for details. - */ -package com.evolveum.midpoint.model.intest; - -import static org.testng.Assert.assertTrue; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNull; - -import java.io.File; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import com.evolveum.midpoint.model.impl.importer.ImportAccountsFromResourceTaskHandler; -import com.evolveum.midpoint.prism.query.OrgFilter; -import com.evolveum.midpoint.prism.xml.XmlTypeConverter; -import com.evolveum.midpoint.xml.ns._public.common.common_3.*; - -import org.springframework.beans.factory.annotation.Autowired; - -import com.evolveum.icf.dummy.resource.DummyResource; -import com.evolveum.midpoint.model.api.ProgressListener; -import com.evolveum.midpoint.model.common.mapping.MappingFactory; -import com.evolveum.midpoint.model.impl.lens.Clockwork; -import com.evolveum.midpoint.model.impl.lens.ClockworkMedic; -import com.evolveum.midpoint.model.intest.util.CheckingProgressListener; -import com.evolveum.midpoint.model.test.ProfilingModelInspectorManager; -import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.util.PrismAsserts; -import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.ResultHandler; -import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.DummyResourceContoller; -import com.evolveum.midpoint.test.IntegrationTestTools; -import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; -import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SecurityViolationException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; - -import javax.xml.datatype.XMLGregorianCalendar; - -/** - * @author semancik - * - */ -public class AbstractInitializedModelIntegrationTest extends AbstractConfiguredModelIntegrationTest { - - private static final int NUM_FUNCTIONAL_ORGS = 6; - private static final int NUM_PROJECT_ORGS = 3; - - protected static final Trace LOGGER = TraceManager.getTrace(AbstractInitializedModelIntegrationTest.class); - - private static final int NUMBER_OF_IMPORTED_USERS = 5; - private static final int NUMBER_OF_IMPORTED_ROLES = 15; - - @Autowired protected MappingFactory mappingFactory; - @Autowired protected Clockwork clockwork; - @Autowired protected ClockworkMedic clockworkMedic; - @Autowired protected ImportAccountsFromResourceTaskHandler importAccountsFromResourceTaskHandler; - - protected ProfilingModelInspectorManager profilingModelInspectorManager; - protected CheckingProgressListener checkingProgressListener; - - protected UserType userTypeJack; - protected UserType userTypeBarbossa; - protected UserType userTypeGuybrush; - protected UserType userTypeElaine; - protected UserType userTypeWill; - - protected DummyResourceContoller dummyResourceCtl; - - protected DummyResource dummyResourceCyan; - protected DummyResourceContoller dummyResourceCtlCyan; - protected ResourceType resourceDummyCyanType; - protected PrismObject resourceDummyCyan; - - protected DummyResource dummyResourceWhite; - protected DummyResourceContoller dummyResourceCtlWhite; - protected ResourceType resourceDummyWhiteType; - protected PrismObject resourceDummyWhite; - - protected static DummyResource dummyResourceEmerald; - protected static DummyResourceContoller dummyResourceCtlEmerald; - protected ResourceType resourceDummyEmeraldType; - protected PrismObject resourceDummyEmerald; - - protected DummyResource dummyResourceUpcase; - protected DummyResourceContoller dummyResourceCtlUpcase; - protected ResourceType resourceDummyUpcaseType; - protected PrismObject resourceDummyUpcase; - - protected ResourceType resourceDummySchemalessType; - protected PrismObject resourceDummySchemaless; - - public AbstractInitializedModelIntegrationTest() { - super(); - } - - @Override - public void initSystem(Task initTask, OperationResult initResult) throws Exception { - LOGGER.trace("initSystem"); - super.initSystem(initTask, initResult); - - assumeConflictResolutionAction(getDefaultConflictResolutionAction()); - - mappingFactory.setProfiling(true); - profilingModelInspectorManager = new ProfilingModelInspectorManager(); - clockworkMedic.setDiagnosticContextManager(profilingModelInspectorManager); - checkingProgressListener = new CheckingProgressListener(); - - // Resources - - dummyResourceCtl = initDummyResource(null, getResourceDummyFile(), RESOURCE_DUMMY_OID, - controller -> { - controller.extendSchemaPirate(); - controller.addAttrDef(controller.getDummyResource().getAccountObjectClass(), - DUMMY_ACCOUNT_ATTRIBUTE_SEA_NAME, String.class, false, false); - }, - initTask, initResult); - - initDummyResourcePirate(RESOURCE_DUMMY_RED_NAME, - RESOURCE_DUMMY_RED_FILE, RESOURCE_DUMMY_RED_OID, initTask, initResult); - - initDummyResourcePirate(RESOURCE_DUMMY_BLUE_NAME, - getResourceDummyBlueFile(), RESOURCE_DUMMY_BLUE_OID, initTask, initResult); - - initDummyResourcePirate(RESOURCE_DUMMY_YELLOW_NAME, - RESOURCE_DUMMY_YELLOW_FILE, RESOURCE_DUMMY_YELLOW_OID, initTask, initResult); - - initDummyResourcePirate(RESOURCE_DUMMY_GREEN_NAME, - RESOURCE_DUMMY_GREEN_FILE, RESOURCE_DUMMY_GREEN_OID, initTask, initResult); - - initDummyResourcePirate(RESOURCE_DUMMY_BLACK_NAME, - RESOURCE_DUMMY_BLACK_FILE, RESOURCE_DUMMY_BLACK_OID, initTask, initResult); - - initDummyResourcePirate(RESOURCE_DUMMY_RELATIVE_NAME, - RESOURCE_DUMMY_RELATIVE_FILE, RESOURCE_DUMMY_RELATIVE_OID, initTask, initResult); - - dummyResourceCtlCyan = DummyResourceContoller.create(RESOURCE_DUMMY_CYAN_NAME, resourceDummyCyan); - dummyResourceCtlCyan.extendSchemaPirate(); - dummyResourceCyan = dummyResourceCtlCyan.getDummyResource(); - resourceDummyCyan = importAndGetObjectFromFile(ResourceType.class, RESOURCE_DUMMY_CYAN_FILE, RESOURCE_DUMMY_CYAN_OID, initTask, initResult); - resourceDummyCyanType = resourceDummyCyan.asObjectable(); - dummyResourceCtlCyan.setResource(resourceDummyCyan); - - dummyResourceCtlWhite = DummyResourceContoller.create(RESOURCE_DUMMY_WHITE_NAME, resourceDummyWhite); - dummyResourceCtlWhite.extendSchemaPirate(); - dummyResourceWhite = dummyResourceCtlWhite.getDummyResource(); - resourceDummyWhite = importAndGetObjectFromFile(ResourceType.class, RESOURCE_DUMMY_WHITE_FILENAME, RESOURCE_DUMMY_WHITE_OID, initTask, initResult); - resourceDummyWhiteType = resourceDummyWhite.asObjectable(); - dummyResourceCtlWhite.setResource(resourceDummyWhite); - - dummyResourceCtlEmerald = DummyResourceContoller.create(RESOURCE_DUMMY_EMERALD_NAME, resourceDummyEmerald); - dummyResourceCtlEmerald.extendSchemaPirate(); - dummyResourceCtlEmerald.extendSchemaPosix(); - dummyResourceEmerald = dummyResourceCtlEmerald.getDummyResource(); - resourceDummyEmerald = importAndGetObjectFromFile(ResourceType.class, getResourceDummyEmeraldFile(), RESOURCE_DUMMY_EMERALD_OID, initTask, initResult); - resourceDummyEmeraldType = resourceDummyEmerald.asObjectable(); - dummyResourceCtlEmerald.setResource(resourceDummyEmerald); - - initDummyResource(RESOURCE_DUMMY_ORANGE_NAME, RESOURCE_DUMMY_ORANGE_FILE, RESOURCE_DUMMY_ORANGE_OID, - controller -> { - controller.extendSchemaPirate(); - controller.addAttrDef(controller.getDummyResource().getAccountObjectClass(), - DUMMY_ACCOUNT_ATTRIBUTE_MATE_NAME, String.class, false, true); - }, - initTask, initResult); - - dummyResourceCtlUpcase = DummyResourceContoller.create(RESOURCE_DUMMY_UPCASE_NAME, resourceDummyUpcase); - dummyResourceCtlUpcase.extendSchemaPirate(); - dummyResourceUpcase = dummyResourceCtlUpcase.getDummyResource(); - resourceDummyUpcase = importAndGetObjectFromFile(ResourceType.class, RESOURCE_DUMMY_UPCASE_FILE, RESOURCE_DUMMY_UPCASE_OID, initTask, initResult); - resourceDummyUpcaseType = resourceDummyUpcase.asObjectable(); - dummyResourceCtlUpcase.setResource(resourceDummyUpcase); - dummyResourceCtlUpcase.addGroup(GROUP_JOKER_DUMMY_UPCASE_NAME); - - resourceDummySchemaless = importAndGetObjectFromFile(ResourceType.class, RESOURCE_DUMMY_SCHEMALESS_FILENAME, RESOURCE_DUMMY_SCHEMALESS_OID, initTask, initResult); - resourceDummySchemalessType = resourceDummySchemaless.asObjectable(); - - - postInitDummyResouce(); - - dummyResourceCtl.addAccount(ACCOUNT_HERMAN_DUMMY_USERNAME, "Herman Toothrot", "Monkey Island"); - dummyResourceCtl.addAccount(ACCOUNT_GUYBRUSH_DUMMY_USERNAME, "Guybrush Threepwood", "Melee Island"); - dummyResourceCtl.addAccount(ACCOUNT_DAVIEJONES_DUMMY_USERNAME, "Davie Jones", "Davie Jones' Locker"); - dummyResourceCtl.addAccount(ACCOUNT_CALYPSO_DUMMY_USERNAME, "Tia Dalma", "Pantano River"); - - dummyResourceCtl.addAccount(ACCOUNT_ELAINE_DUMMY_USERNAME, "Elaine Marley", "Melee Island"); - getDummyResourceController(RESOURCE_DUMMY_RED_NAME).addAccount(ACCOUNT_ELAINE_DUMMY_USERNAME, "Elaine Marley", "Melee Island"); - getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).addAccount(ACCOUNT_ELAINE_DUMMY_USERNAME, "Elaine Marley", "Melee Island"); - - repoAddObjectFromFile(LOOKUP_LANGUAGES_FILE, initResult); - - repoAddObjectFromFile(SECURITY_POLICY_FILE, initResult); - - // User Templates - repoAddObjectFromFile(USER_TEMPLATE_FILENAME, initResult); - repoAddObjectFromFile(USER_TEMPLATE_COMPLEX_FILE, initResult); - repoAddObjectFromFile(USER_TEMPLATE_SCHEMA_CONSTRAINTS_FILE, initResult); - repoAddObjectFromFile(USER_TEMPLATE_INBOUNDS_FILENAME, initResult); - repoAddObjectFromFile(USER_TEMPLATE_COMPLEX_INCLUDE_FILENAME, initResult); - repoAddObjectFromFile(USER_TEMPLATE_ORG_ASSIGNMENT_FILENAME, initResult); - repoAddObjectFromFile(USER_TEMPLATE_CARTHESIAN_FILENAME, initResult); - - // Shadows - repoAddObjectFromFile(ACCOUNT_SHADOW_GUYBRUSH_DUMMY_FILE, initResult); - repoAddObjectFromFile(ACCOUNT_SHADOW_ELAINE_DUMMY_FILE, initResult); - repoAddObjectFromFile(ACCOUNT_SHADOW_ELAINE_DUMMY_RED_FILE, initResult); - repoAddObjectFromFile(ACCOUNT_SHADOW_ELAINE_DUMMY_BLUE_FILE, initResult); - repoAddObjectFromFile(GROUP_SHADOW_JOKER_DUMMY_UPCASE_FILE, initResult); - - // Users - userTypeJack = repoAddObjectFromFile(USER_JACK_FILE, UserType.class, true, initResult).asObjectable(); - userTypeBarbossa = repoAddObjectFromFile(USER_BARBOSSA_FILE, UserType.class, initResult).asObjectable(); - userTypeGuybrush = repoAddObjectFromFile(USER_GUYBRUSH_FILE, UserType.class, initResult).asObjectable(); - userTypeElaine = repoAddObjectFromFile(USER_ELAINE_FILE, UserType.class, initResult).asObjectable(); - userTypeWill = repoAddObjectFromFile(USER_WILL_FILE, UserType.class, true, initResult).asObjectable(); - - // Roles - repoAddObjectFromFile(ROLE_PIRATE_FILE, initResult); - repoAddObjectFromFile(ROLE_PIRATE_GREEN_FILE, initResult); - repoAddObjectFromFile(ROLE_PIRATE_RELATIVE_FILE, initResult); - repoAddObjectFromFile(ROLE_CARIBBEAN_PIRATE_FILE, initResult); - repoAddObjectFromFile(ROLE_BUCCANEER_GREEN_FILE, initResult); - repoAddObjectFromFile(ROLE_NICE_PIRATE_FILENAME, initResult); - repoAddObjectFromFile(ROLE_CAPTAIN_FILENAME, initResult); - repoAddObjectFromFile(ROLE_JUDGE_FILE, initResult); - repoAddObjectFromFile(ROLE_THIEF_FILE, initResult); - repoAddObjectFromFile(ROLE_EMPTY_FILE, initResult); - repoAddObjectFromFile(ROLE_USELESS_FILE, initResult); - repoAddObjectFromFile(ROLE_SAILOR_FILE, initResult); - repoAddObjectFromFile(ROLE_RED_SAILOR_FILE, initResult); - repoAddObjectFromFile(ROLE_CYAN_SAILOR_FILE, initResult); - repoAddObjectFromFile(ROLE_STRONG_SAILOR_FILE, initResult); - - // Orgstruct - if (doAddOrgstruct()) { - repoAddObjectsFromFile(ORG_MONKEY_ISLAND_FILE, OrgType.class, initResult); - } - - // Services - repoAddObjectFromFile(SERVICE_SHIP_SEA_MONKEY_FILE, initResult); - - // Custom function libraries - repoAddObjectFromFile(CUSTOM_LIBRARY_FILE, initResult); - - // Password policy - repoAddObjectFromFile(PASSWORD_POLICY_BENEVOLENT_FILE, initResult); - - // Archetypes - repoAddObjectFromFile(ARCHETYPE_APPROVAL_CASE_FILE, initResult); - - } - - protected ConflictResolutionActionType getDefaultConflictResolutionAction() { - return ConflictResolutionActionType.FAIL; - } - - @Override - protected int getNumberOfUsers() { - return super.getNumberOfUsers() + NUMBER_OF_IMPORTED_USERS; - } - - @Override - protected int getNumberOfRoles() { - return super.getNumberOfRoles() + NUMBER_OF_IMPORTED_ROLES; - } - - protected boolean doAddOrgstruct() { - return true; - } - - protected File getResourceDummyFile() { - return RESOURCE_DUMMY_FILE; - } - - protected File getResourceDummyBlueFile() { - return RESOURCE_DUMMY_BLUE_FILE; - } - - protected File getResourceDummyGreenFile() { - return RESOURCE_DUMMY_GREEN_FILE; - } - - protected File getResourceDummyEmeraldFile() { - return RESOURCE_DUMMY_EMERALD_FILE; - } - - protected void postInitDummyResouce() { - // Do nothing be default. Concrete tests may override this. - } - - protected void assertUserJack(PrismObject user) { - assertUserJack(user, USER_JACK_FULL_NAME, USER_JACK_GIVEN_NAME, USER_JACK_FAMILY_NAME); - } - - protected void assertUserJack(PrismObject user, String fullName) { - assertUserJack(user, fullName, USER_JACK_GIVEN_NAME, USER_JACK_FAMILY_NAME); - } - - protected void assertUserJack(PrismObject user, String fullName, String givenName, String familyName) { - assertUserJack(user, fullName, givenName, familyName, "Caribbean"); - } - - protected void assertUserJack(PrismObject user, String name, String fullName, String givenName, String familyName, String locality) { - assertUser(user, USER_JACK_OID, name, fullName, givenName, familyName, locality); - UserType userType = user.asObjectable(); - PrismAsserts.assertEqualsPolyString("Wrong jack honorificPrefix", "Cpt.", userType.getHonorificPrefix()); - PrismAsserts.assertEqualsPolyString("Wrong jack honorificSuffix", "PhD.", userType.getHonorificSuffix()); - assertEquals("Wrong jack emailAddress", "jack.sparrow@evolveum.com", userType.getEmailAddress()); - assertEquals("Wrong jack telephoneNumber", "555-1234", userType.getTelephoneNumber()); - assertEquals("Wrong jack employeeNumber", "emp1234", userType.getEmployeeNumber()); - assertEquals("Wrong jack employeeType", USER_JACK_SUBTYPE, userType.getSubtype().get(0)); - if (locality == null) { - assertNull("Locality sneaked to user jack", userType.getLocality()); - } else { - PrismAsserts.assertEqualsPolyString("Wrong jack locality", locality, userType.getLocality()); - } - } - - protected void assertUserJack(PrismObject user, String fullName, String givenName, String familyName, String locality) { - assertUserJack(user, USER_JACK_USERNAME, fullName, givenName, familyName, locality); - } - - protected void assertDummyAccountShadowRepo(PrismObject accountShadow, String oid, String username) throws SchemaException { - assertAccountShadowRepo(accountShadow, oid, username, dummyResourceCtl.getResource().asObjectable()); - } - - protected void assertDummyGroupShadowRepo(PrismObject accountShadow, String oid, String username) throws SchemaException { - assertShadowRepo(accountShadow, oid, username, dummyResourceCtl.getResourceType(), dummyResourceCtl.getGroupObjectClass()); - } - - protected void assertDummyAccountShadowModel(PrismObject accountShadow, String oid, String username) throws SchemaException { - assertShadowModel(accountShadow, oid, username, dummyResourceCtl.getResourceType(), dummyResourceCtl.getAccountObjectClass()); - } - - protected void assertDummyGroupShadowModel(PrismObject accountShadow, String oid, String username) throws SchemaException { - assertShadowModel(accountShadow, oid, username, dummyResourceCtl.getResourceType(), dummyResourceCtl.getGroupObjectClass()); - } - - protected void assertDummyAccountShadowModel(PrismObject accountShadow, String oid, String username, String fullname) throws SchemaException { - assertDummyAccountShadowModel(accountShadow, oid, username); - IntegrationTestTools.assertAttribute(accountShadow, dummyResourceCtl.getAttributeFullnameQName(), fullname); - } - - protected void assertClassType(String message, Object object, - Class type) { - assertTrue(type.isInstance(object), message); - } - - protected void setDefaultUserTemplate(String userTemplateOid) - throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { - setDefaultObjectTemplate(UserType.COMPLEX_TYPE, userTemplateOid); - } - - @Override - protected String getTopOrgOid() { - return ORG_GOVERNOR_OFFICE_OID; - } - - protected void assertMonkeyIslandOrgSanity() throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - assertMonkeyIslandOrgSanity(0); - } - - protected void assertMonkeyIslandOrgSanity(int expectedFictional) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractInitializedModelIntegrationTest.class.getName() + ".assertMonkeyIslandOrgSanity"); - OperationResult result = task.getResult(); - - PrismObject orgGovernorOffice = modelService.getObject(OrgType.class, ORG_GOVERNOR_OFFICE_OID, null, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - OrgType orgGovernorOfficeType = orgGovernorOffice.asObjectable(); - assertEquals("Wrong governor office name", PrismTestUtil.createPolyStringType("F0001"), orgGovernorOfficeType.getName()); - - List> governorSubOrgs = searchOrg(ORG_GOVERNOR_OFFICE_OID, OrgFilter.Scope.ONE_LEVEL, task, result); - if (verbose) display("governor suborgs", governorSubOrgs); - assertEquals("Unexpected number of governor suborgs", 3, governorSubOrgs.size()); - - List> functionalOrgs = searchOrg(ORG_GOVERNOR_OFFICE_OID, OrgFilter.Scope.SUBTREE, task, result); - if (verbose) display("functional orgs (null)", functionalOrgs); - assertEquals("Unexpected number of functional orgs (null)", NUM_FUNCTIONAL_ORGS - 1 + expectedFictional, functionalOrgs.size()); - - List> prootSubOrgs = searchOrg(ORG_PROJECT_ROOT_OID, OrgFilter.Scope.ONE_LEVEL, task, result); - if (verbose) display("project root suborgs", prootSubOrgs); - assertEquals("Unexpected number of governor suborgs", 2, prootSubOrgs.size()); - - List> projectOrgs = searchOrg(ORG_PROJECT_ROOT_OID, OrgFilter.Scope.SUBTREE, task, result); - if (verbose) display("project orgs (null)", projectOrgs); - assertEquals("Unexpected number of functional orgs (null)", NUM_PROJECT_ORGS - 1, projectOrgs.size()); - - PrismObject orgScummBar = modelService.getObject(OrgType.class, ORG_SCUMM_BAR_OID, null, task, result); - List scummBarInducements = orgScummBar.asObjectable().getInducement(); - assertEquals("Unexpected number of scumm bar inducements: "+scummBarInducements, 1, scummBarInducements.size()); - - ResultHandler handler = getOrgSanityCheckHandler(); - if (handler != null) { - modelService.searchObjectsIterative(OrgType.class, null, handler, null, task, result); - } - } - - protected ResultHandler getOrgSanityCheckHandler() { - return null; - } - - protected void assertShadowOperationalData(PrismObject shadow, SynchronizationSituationType expectedSituation, Long timeBeforeSync) { - ShadowType shadowType = shadow.asObjectable(); - SynchronizationSituationType actualSituation = shadowType.getSynchronizationSituation(); - assertEquals("Wrong situation in shadow "+shadow, expectedSituation, actualSituation); - XMLGregorianCalendar actualTimestampCal = shadowType.getSynchronizationTimestamp(); - assert actualTimestampCal != null : "No synchronization timestamp in shadow "+shadow; - if (timeBeforeSync != null) { - long actualTimestamp = XmlTypeConverter.toMillis(actualTimestampCal); - assert actualTimestamp >= timeBeforeSync : "Synchronization timestamp was not updated in shadow " + shadow; - } - // TODO: assert sync description - } - - protected Collection getCheckingProgressListenerCollection() { - return Collections.singleton((ProgressListener)checkingProgressListener); - } -} +/* + * Copyright (c) 2010-2019 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ +package com.evolveum.midpoint.model.intest; + +import static org.testng.Assert.assertTrue; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertNull; + +import java.io.File; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import com.evolveum.midpoint.model.impl.importer.ImportAccountsFromResourceTaskHandler; +import com.evolveum.midpoint.prism.query.OrgFilter; +import com.evolveum.midpoint.prism.xml.XmlTypeConverter; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; + +import org.springframework.beans.factory.annotation.Autowired; + +import com.evolveum.icf.dummy.resource.DummyResource; +import com.evolveum.midpoint.model.api.ProgressListener; +import com.evolveum.midpoint.model.common.mapping.MappingFactory; +import com.evolveum.midpoint.model.impl.lens.Clockwork; +import com.evolveum.midpoint.model.impl.lens.ClockworkMedic; +import com.evolveum.midpoint.model.intest.util.CheckingProgressListener; +import com.evolveum.midpoint.model.test.ProfilingModelInspectorManager; +import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.prism.util.PrismAsserts; +import com.evolveum.midpoint.prism.util.PrismTestUtil; +import com.evolveum.midpoint.schema.ResultHandler; +import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.DummyResourceContoller; +import com.evolveum.midpoint.test.IntegrationTestTools; +import com.evolveum.midpoint.test.util.TestUtil; +import com.evolveum.midpoint.util.exception.CommunicationException; +import com.evolveum.midpoint.util.exception.ConfigurationException; +import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; +import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; +import com.evolveum.midpoint.util.exception.ObjectNotFoundException; +import com.evolveum.midpoint.util.exception.SchemaException; +import com.evolveum.midpoint.util.exception.SecurityViolationException; +import com.evolveum.midpoint.util.logging.Trace; +import com.evolveum.midpoint.util.logging.TraceManager; + +import javax.xml.datatype.XMLGregorianCalendar; + +/** + * @author semancik + * + */ +public class AbstractInitializedModelIntegrationTest extends AbstractConfiguredModelIntegrationTest { + + private static final int NUM_FUNCTIONAL_ORGS = 6; + private static final int NUM_PROJECT_ORGS = 3; + + protected static final Trace LOGGER = TraceManager.getTrace(AbstractInitializedModelIntegrationTest.class); + + private static final int NUMBER_OF_IMPORTED_USERS = 5; + private static final int NUMBER_OF_IMPORTED_ROLES = 15; + + @Autowired protected MappingFactory mappingFactory; + @Autowired protected Clockwork clockwork; + @Autowired protected ClockworkMedic clockworkMedic; + @Autowired protected ImportAccountsFromResourceTaskHandler importAccountsFromResourceTaskHandler; + + protected ProfilingModelInspectorManager profilingModelInspectorManager; + protected CheckingProgressListener checkingProgressListener; + + protected UserType userTypeJack; + protected UserType userTypeBarbossa; + protected UserType userTypeGuybrush; + protected UserType userTypeElaine; + protected UserType userTypeWill; + + protected DummyResourceContoller dummyResourceCtl; + + protected DummyResource dummyResourceCyan; + protected DummyResourceContoller dummyResourceCtlCyan; + protected ResourceType resourceDummyCyanType; + protected PrismObject resourceDummyCyan; + + protected DummyResource dummyResourceWhite; + protected DummyResourceContoller dummyResourceCtlWhite; + protected ResourceType resourceDummyWhiteType; + protected PrismObject resourceDummyWhite; + + protected static DummyResource dummyResourceEmerald; + protected static DummyResourceContoller dummyResourceCtlEmerald; + protected ResourceType resourceDummyEmeraldType; + protected PrismObject resourceDummyEmerald; + + protected DummyResource dummyResourceUpcase; + protected DummyResourceContoller dummyResourceCtlUpcase; + protected ResourceType resourceDummyUpcaseType; + protected PrismObject resourceDummyUpcase; + + protected ResourceType resourceDummySchemalessType; + protected PrismObject resourceDummySchemaless; + + public AbstractInitializedModelIntegrationTest() { + super(); + } + + @Override + public void initSystem(Task initTask, OperationResult initResult) throws Exception { + LOGGER.trace("initSystem"); + super.initSystem(initTask, initResult); + + assumeConflictResolutionAction(getDefaultConflictResolutionAction()); + + mappingFactory.setProfiling(true); + profilingModelInspectorManager = new ProfilingModelInspectorManager(); + clockworkMedic.setDiagnosticContextManager(profilingModelInspectorManager); + checkingProgressListener = new CheckingProgressListener(); + + // Resources + + dummyResourceCtl = initDummyResource(null, getResourceDummyFile(), RESOURCE_DUMMY_OID, + controller -> { + controller.extendSchemaPirate(); + controller.addAttrDef(controller.getDummyResource().getAccountObjectClass(), + DUMMY_ACCOUNT_ATTRIBUTE_SEA_NAME, String.class, false, false); + }, + initTask, initResult); + + initDummyResourcePirate(RESOURCE_DUMMY_RED_NAME, + RESOURCE_DUMMY_RED_FILE, RESOURCE_DUMMY_RED_OID, initTask, initResult); + + initDummyResourcePirate(RESOURCE_DUMMY_BLUE_NAME, + getResourceDummyBlueFile(), RESOURCE_DUMMY_BLUE_OID, initTask, initResult); + + initDummyResourcePirate(RESOURCE_DUMMY_YELLOW_NAME, + RESOURCE_DUMMY_YELLOW_FILE, RESOURCE_DUMMY_YELLOW_OID, initTask, initResult); + + initDummyResourcePirate(RESOURCE_DUMMY_GREEN_NAME, + RESOURCE_DUMMY_GREEN_FILE, RESOURCE_DUMMY_GREEN_OID, initTask, initResult); + + initDummyResourcePirate(RESOURCE_DUMMY_BLACK_NAME, + RESOURCE_DUMMY_BLACK_FILE, RESOURCE_DUMMY_BLACK_OID, initTask, initResult); + + initDummyResourcePirate(RESOURCE_DUMMY_RELATIVE_NAME, + RESOURCE_DUMMY_RELATIVE_FILE, RESOURCE_DUMMY_RELATIVE_OID, initTask, initResult); + + dummyResourceCtlCyan = DummyResourceContoller.create(RESOURCE_DUMMY_CYAN_NAME, resourceDummyCyan); + dummyResourceCtlCyan.extendSchemaPirate(); + dummyResourceCyan = dummyResourceCtlCyan.getDummyResource(); + resourceDummyCyan = importAndGetObjectFromFile(ResourceType.class, RESOURCE_DUMMY_CYAN_FILE, RESOURCE_DUMMY_CYAN_OID, initTask, initResult); + resourceDummyCyanType = resourceDummyCyan.asObjectable(); + dummyResourceCtlCyan.setResource(resourceDummyCyan); + + dummyResourceCtlWhite = DummyResourceContoller.create(RESOURCE_DUMMY_WHITE_NAME, resourceDummyWhite); + dummyResourceCtlWhite.extendSchemaPirate(); + dummyResourceWhite = dummyResourceCtlWhite.getDummyResource(); + resourceDummyWhite = importAndGetObjectFromFile(ResourceType.class, RESOURCE_DUMMY_WHITE_FILENAME, RESOURCE_DUMMY_WHITE_OID, initTask, initResult); + resourceDummyWhiteType = resourceDummyWhite.asObjectable(); + dummyResourceCtlWhite.setResource(resourceDummyWhite); + + dummyResourceCtlEmerald = DummyResourceContoller.create(RESOURCE_DUMMY_EMERALD_NAME, resourceDummyEmerald); + dummyResourceCtlEmerald.extendSchemaPirate(); + dummyResourceCtlEmerald.extendSchemaPosix(); + dummyResourceEmerald = dummyResourceCtlEmerald.getDummyResource(); + resourceDummyEmerald = importAndGetObjectFromFile(ResourceType.class, getResourceDummyEmeraldFile(), RESOURCE_DUMMY_EMERALD_OID, initTask, initResult); + resourceDummyEmeraldType = resourceDummyEmerald.asObjectable(); + dummyResourceCtlEmerald.setResource(resourceDummyEmerald); + + initDummyResource(RESOURCE_DUMMY_ORANGE_NAME, RESOURCE_DUMMY_ORANGE_FILE, RESOURCE_DUMMY_ORANGE_OID, + controller -> { + controller.extendSchemaPirate(); + controller.addAttrDef(controller.getDummyResource().getAccountObjectClass(), + DUMMY_ACCOUNT_ATTRIBUTE_MATE_NAME, String.class, false, true); + }, + initTask, initResult); + + dummyResourceCtlUpcase = DummyResourceContoller.create(RESOURCE_DUMMY_UPCASE_NAME, resourceDummyUpcase); + dummyResourceCtlUpcase.extendSchemaPirate(); + dummyResourceUpcase = dummyResourceCtlUpcase.getDummyResource(); + resourceDummyUpcase = importAndGetObjectFromFile(ResourceType.class, RESOURCE_DUMMY_UPCASE_FILE, RESOURCE_DUMMY_UPCASE_OID, initTask, initResult); + resourceDummyUpcaseType = resourceDummyUpcase.asObjectable(); + dummyResourceCtlUpcase.setResource(resourceDummyUpcase); + dummyResourceCtlUpcase.addGroup(GROUP_JOKER_DUMMY_UPCASE_NAME); + + resourceDummySchemaless = importAndGetObjectFromFile(ResourceType.class, RESOURCE_DUMMY_SCHEMALESS_FILENAME, RESOURCE_DUMMY_SCHEMALESS_OID, initTask, initResult); + resourceDummySchemalessType = resourceDummySchemaless.asObjectable(); + + + postInitDummyResouce(); + + dummyResourceCtl.addAccount(ACCOUNT_HERMAN_DUMMY_USERNAME, "Herman Toothrot", "Monkey Island"); + dummyResourceCtl.addAccount(ACCOUNT_GUYBRUSH_DUMMY_USERNAME, "Guybrush Threepwood", "Melee Island"); + dummyResourceCtl.addAccount(ACCOUNT_DAVIEJONES_DUMMY_USERNAME, "Davie Jones", "Davie Jones' Locker"); + dummyResourceCtl.addAccount(ACCOUNT_CALYPSO_DUMMY_USERNAME, "Tia Dalma", "Pantano River"); + + dummyResourceCtl.addAccount(ACCOUNT_ELAINE_DUMMY_USERNAME, "Elaine Marley", "Melee Island"); + getDummyResourceController(RESOURCE_DUMMY_RED_NAME).addAccount(ACCOUNT_ELAINE_DUMMY_USERNAME, "Elaine Marley", "Melee Island"); + getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).addAccount(ACCOUNT_ELAINE_DUMMY_USERNAME, "Elaine Marley", "Melee Island"); + + repoAddObjectFromFile(LOOKUP_LANGUAGES_FILE, initResult); + + repoAddObjectFromFile(SECURITY_POLICY_FILE, initResult); + + // Archetypes + repoAddObjectFromFile(ARCHETYPE_TASK_RECONCILIATION_FILE, initResult); + + // User Templates + repoAddObjectFromFile(USER_TEMPLATE_FILENAME, initResult); + repoAddObjectFromFile(USER_TEMPLATE_COMPLEX_FILE, initResult); + repoAddObjectFromFile(USER_TEMPLATE_SCHEMA_CONSTRAINTS_FILE, initResult); + repoAddObjectFromFile(USER_TEMPLATE_INBOUNDS_FILENAME, initResult); + repoAddObjectFromFile(USER_TEMPLATE_COMPLEX_INCLUDE_FILENAME, initResult); + repoAddObjectFromFile(USER_TEMPLATE_ORG_ASSIGNMENT_FILENAME, initResult); + repoAddObjectFromFile(USER_TEMPLATE_CARTHESIAN_FILENAME, initResult); + + // Shadows + repoAddObjectFromFile(ACCOUNT_SHADOW_GUYBRUSH_DUMMY_FILE, initResult); + repoAddObjectFromFile(ACCOUNT_SHADOW_ELAINE_DUMMY_FILE, initResult); + repoAddObjectFromFile(ACCOUNT_SHADOW_ELAINE_DUMMY_RED_FILE, initResult); + repoAddObjectFromFile(ACCOUNT_SHADOW_ELAINE_DUMMY_BLUE_FILE, initResult); + repoAddObjectFromFile(GROUP_SHADOW_JOKER_DUMMY_UPCASE_FILE, initResult); + + // Users + userTypeJack = repoAddObjectFromFile(USER_JACK_FILE, UserType.class, true, initResult).asObjectable(); + userTypeBarbossa = repoAddObjectFromFile(USER_BARBOSSA_FILE, UserType.class, initResult).asObjectable(); + userTypeGuybrush = repoAddObjectFromFile(USER_GUYBRUSH_FILE, UserType.class, initResult).asObjectable(); + userTypeElaine = repoAddObjectFromFile(USER_ELAINE_FILE, UserType.class, initResult).asObjectable(); + userTypeWill = repoAddObjectFromFile(USER_WILL_FILE, UserType.class, true, initResult).asObjectable(); + + // Roles + repoAddObjectFromFile(ROLE_PIRATE_FILE, initResult); + repoAddObjectFromFile(ROLE_PIRATE_GREEN_FILE, initResult); + repoAddObjectFromFile(ROLE_PIRATE_RELATIVE_FILE, initResult); + repoAddObjectFromFile(ROLE_CARIBBEAN_PIRATE_FILE, initResult); + repoAddObjectFromFile(ROLE_BUCCANEER_GREEN_FILE, initResult); + repoAddObjectFromFile(ROLE_NICE_PIRATE_FILENAME, initResult); + repoAddObjectFromFile(ROLE_CAPTAIN_FILENAME, initResult); + repoAddObjectFromFile(ROLE_JUDGE_FILE, initResult); + repoAddObjectFromFile(ROLE_THIEF_FILE, initResult); + repoAddObjectFromFile(ROLE_EMPTY_FILE, initResult); + repoAddObjectFromFile(ROLE_USELESS_FILE, initResult); + repoAddObjectFromFile(ROLE_SAILOR_FILE, initResult); + repoAddObjectFromFile(ROLE_RED_SAILOR_FILE, initResult); + repoAddObjectFromFile(ROLE_CYAN_SAILOR_FILE, initResult); + repoAddObjectFromFile(ROLE_STRONG_SAILOR_FILE, initResult); + + // Orgstruct + if (doAddOrgstruct()) { + repoAddObjectsFromFile(ORG_MONKEY_ISLAND_FILE, OrgType.class, initResult); + } + + // Services + repoAddObjectFromFile(SERVICE_SHIP_SEA_MONKEY_FILE, initResult); + + // Custom function libraries + repoAddObjectFromFile(CUSTOM_LIBRARY_FILE, initResult); + + // Password policy + repoAddObjectFromFile(PASSWORD_POLICY_BENEVOLENT_FILE, initResult); + + // Archetypes + repoAddObjectFromFile(ARCHETYPE_APPROVAL_CASE_FILE, initResult); + + } + + protected ConflictResolutionActionType getDefaultConflictResolutionAction() { + return ConflictResolutionActionType.FAIL; + } + + @Override + protected int getNumberOfUsers() { + return super.getNumberOfUsers() + NUMBER_OF_IMPORTED_USERS; + } + + @Override + protected int getNumberOfRoles() { + return super.getNumberOfRoles() + NUMBER_OF_IMPORTED_ROLES; + } + + protected boolean doAddOrgstruct() { + return true; + } + + protected File getResourceDummyFile() { + return RESOURCE_DUMMY_FILE; + } + + protected File getResourceDummyBlueFile() { + return RESOURCE_DUMMY_BLUE_FILE; + } + + protected File getResourceDummyGreenFile() { + return RESOURCE_DUMMY_GREEN_FILE; + } + + protected File getResourceDummyEmeraldFile() { + return RESOURCE_DUMMY_EMERALD_FILE; + } + + protected void postInitDummyResouce() { + // Do nothing be default. Concrete tests may override this. + } + + protected void assertUserJack(PrismObject user) { + assertUserJack(user, USER_JACK_FULL_NAME, USER_JACK_GIVEN_NAME, USER_JACK_FAMILY_NAME); + } + + protected void assertUserJack(PrismObject user, String fullName) { + assertUserJack(user, fullName, USER_JACK_GIVEN_NAME, USER_JACK_FAMILY_NAME); + } + + protected void assertUserJack(PrismObject user, String fullName, String givenName, String familyName) { + assertUserJack(user, fullName, givenName, familyName, "Caribbean"); + } + + protected void assertUserJack(PrismObject user, String name, String fullName, String givenName, String familyName, String locality) { + assertUser(user, USER_JACK_OID, name, fullName, givenName, familyName, locality); + UserType userType = user.asObjectable(); + PrismAsserts.assertEqualsPolyString("Wrong jack honorificPrefix", "Cpt.", userType.getHonorificPrefix()); + PrismAsserts.assertEqualsPolyString("Wrong jack honorificSuffix", "PhD.", userType.getHonorificSuffix()); + assertEquals("Wrong jack emailAddress", "jack.sparrow@evolveum.com", userType.getEmailAddress()); + assertEquals("Wrong jack telephoneNumber", "555-1234", userType.getTelephoneNumber()); + assertEquals("Wrong jack employeeNumber", "emp1234", userType.getEmployeeNumber()); + assertEquals("Wrong jack employeeType", USER_JACK_SUBTYPE, userType.getSubtype().get(0)); + if (locality == null) { + assertNull("Locality sneaked to user jack", userType.getLocality()); + } else { + PrismAsserts.assertEqualsPolyString("Wrong jack locality", locality, userType.getLocality()); + } + } + + protected void assertUserJack(PrismObject user, String fullName, String givenName, String familyName, String locality) { + assertUserJack(user, USER_JACK_USERNAME, fullName, givenName, familyName, locality); + } + + protected void assertDummyAccountShadowRepo(PrismObject accountShadow, String oid, String username) throws SchemaException { + assertAccountShadowRepo(accountShadow, oid, username, dummyResourceCtl.getResource().asObjectable()); + } + + protected void assertDummyGroupShadowRepo(PrismObject accountShadow, String oid, String username) throws SchemaException { + assertShadowRepo(accountShadow, oid, username, dummyResourceCtl.getResourceType(), dummyResourceCtl.getGroupObjectClass()); + } + + protected void assertDummyAccountShadowModel(PrismObject accountShadow, String oid, String username) throws SchemaException { + assertShadowModel(accountShadow, oid, username, dummyResourceCtl.getResourceType(), dummyResourceCtl.getAccountObjectClass()); + } + + protected void assertDummyGroupShadowModel(PrismObject accountShadow, String oid, String username) throws SchemaException { + assertShadowModel(accountShadow, oid, username, dummyResourceCtl.getResourceType(), dummyResourceCtl.getGroupObjectClass()); + } + + protected void assertDummyAccountShadowModel(PrismObject accountShadow, String oid, String username, String fullname) throws SchemaException { + assertDummyAccountShadowModel(accountShadow, oid, username); + IntegrationTestTools.assertAttribute(accountShadow, dummyResourceCtl.getAttributeFullnameQName(), fullname); + } + + protected void assertClassType(String message, Object object, + Class type) { + assertTrue(type.isInstance(object), message); + } + + protected void setDefaultUserTemplate(String userTemplateOid) + throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { + setDefaultObjectTemplate(UserType.COMPLEX_TYPE, userTemplateOid); + } + + @Override + protected String getTopOrgOid() { + return ORG_GOVERNOR_OFFICE_OID; + } + + protected void assertMonkeyIslandOrgSanity() throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + assertMonkeyIslandOrgSanity(0); + } + + protected void assertMonkeyIslandOrgSanity(int expectedFictional) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = taskManager.createTaskInstance(AbstractInitializedModelIntegrationTest.class.getName() + ".assertMonkeyIslandOrgSanity"); + OperationResult result = task.getResult(); + + PrismObject orgGovernorOffice = modelService.getObject(OrgType.class, ORG_GOVERNOR_OFFICE_OID, null, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + OrgType orgGovernorOfficeType = orgGovernorOffice.asObjectable(); + assertEquals("Wrong governor office name", PrismTestUtil.createPolyStringType("F0001"), orgGovernorOfficeType.getName()); + + List> governorSubOrgs = searchOrg(ORG_GOVERNOR_OFFICE_OID, OrgFilter.Scope.ONE_LEVEL, task, result); + if (verbose) display("governor suborgs", governorSubOrgs); + assertEquals("Unexpected number of governor suborgs", 3, governorSubOrgs.size()); + + List> functionalOrgs = searchOrg(ORG_GOVERNOR_OFFICE_OID, OrgFilter.Scope.SUBTREE, task, result); + if (verbose) display("functional orgs (null)", functionalOrgs); + assertEquals("Unexpected number of functional orgs (null)", NUM_FUNCTIONAL_ORGS - 1 + expectedFictional, functionalOrgs.size()); + + List> prootSubOrgs = searchOrg(ORG_PROJECT_ROOT_OID, OrgFilter.Scope.ONE_LEVEL, task, result); + if (verbose) display("project root suborgs", prootSubOrgs); + assertEquals("Unexpected number of governor suborgs", 2, prootSubOrgs.size()); + + List> projectOrgs = searchOrg(ORG_PROJECT_ROOT_OID, OrgFilter.Scope.SUBTREE, task, result); + if (verbose) display("project orgs (null)", projectOrgs); + assertEquals("Unexpected number of functional orgs (null)", NUM_PROJECT_ORGS - 1, projectOrgs.size()); + + PrismObject orgScummBar = modelService.getObject(OrgType.class, ORG_SCUMM_BAR_OID, null, task, result); + List scummBarInducements = orgScummBar.asObjectable().getInducement(); + assertEquals("Unexpected number of scumm bar inducements: "+scummBarInducements, 1, scummBarInducements.size()); + + ResultHandler handler = getOrgSanityCheckHandler(); + if (handler != null) { + modelService.searchObjectsIterative(OrgType.class, null, handler, null, task, result); + } + } + + protected ResultHandler getOrgSanityCheckHandler() { + return null; + } + + protected void assertShadowOperationalData(PrismObject shadow, SynchronizationSituationType expectedSituation, Long timeBeforeSync) { + ShadowType shadowType = shadow.asObjectable(); + SynchronizationSituationType actualSituation = shadowType.getSynchronizationSituation(); + assertEquals("Wrong situation in shadow "+shadow, expectedSituation, actualSituation); + XMLGregorianCalendar actualTimestampCal = shadowType.getSynchronizationTimestamp(); + assert actualTimestampCal != null : "No synchronization timestamp in shadow "+shadow; + if (timeBeforeSync != null) { + long actualTimestamp = XmlTypeConverter.toMillis(actualTimestampCal); + assert actualTimestamp >= timeBeforeSync : "Synchronization timestamp was not updated in shadow " + shadow; + } + // TODO: assert sync description + } + + protected Collection getCheckingProgressListenerCollection() { + return Collections.singleton((ProgressListener)checkingProgressListener); + } +} diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestEditSchema.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestEditSchema.java index f372bdf676a..8ce9447b7ef 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestEditSchema.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestEditSchema.java @@ -1,1743 +1,1756 @@ -/* - * Copyright (c) 2010-2017 Evolveum and contributors - * - * This work is dual-licensed under the Apache License 2.0 - * and European Union Public License. See LICENSE file for details. - */ -package com.evolveum.midpoint.model.intest.gensync; - -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertTrue; - -import java.io.File; -import java.util.Collection; -import java.util.List; - -import com.evolveum.midpoint.prism.delta.DeltaFactory; -import com.evolveum.midpoint.prism.path.ItemName; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.schema.*; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.annotation.DirtiesContext.ClassMode; -import org.springframework.test.context.ContextConfiguration; -import org.testng.AssertJUnit; -import org.testng.annotations.Test; - -import com.evolveum.midpoint.model.api.ModelExecuteOptions; -import com.evolveum.midpoint.prism.Containerable; -import com.evolveum.midpoint.prism.PrismContainer; -import com.evolveum.midpoint.prism.PrismContainerDefinition; -import com.evolveum.midpoint.prism.PrismContainerValue; -import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.PrismObjectDefinition; -import com.evolveum.midpoint.prism.PrismProperty; -import com.evolveum.midpoint.prism.PrismPropertyDefinition; -import com.evolveum.midpoint.prism.PrismReferenceValue; -import com.evolveum.midpoint.prism.delta.ObjectDelta; -import com.evolveum.midpoint.prism.polystring.PolyString; -import com.evolveum.midpoint.prism.util.PrismAsserts; -import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.SchemaConstants; -import com.evolveum.midpoint.schema.processor.ResourceAttributeContainerDefinition; -import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.schema.util.MiscSchemaUtil; -import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.IntegrationTestTools; -import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.Validator; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; -import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SecurityViolationException; -import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ImportOptionsType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.AuthorizationPhaseType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.FormItemValidationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ItemRefinedDefinitionType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableRowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.RelationDefinitionType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAssociationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemObjectsType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; - -/** - * @author semancik - * - */ -@ContextConfiguration(locations = {"classpath:ctx-model-intest-test-main.xml"}) -@DirtiesContext(classMode = ClassMode.AFTER_CLASS) -public class TestEditSchema extends AbstractGenericSyncTest { - - public static final File LOOKUP_LANGUAGES_REPLACEMENT_FILE = new File(TEST_DIR, "lookup-languages-replacement.xml"); - - @Override - public void initSystem(Task initTask, OperationResult initResult) throws Exception { - super.initSystem(initTask, initResult); - - setDefaultUserTemplate(USER_TEMPLATE_COMPLEX_OID); - importObjectFromFile(ROLE_PRISONER_FILE); - importObjectFromFile(USER_OTIS_FILE); - - rememberSteadyResources(); - } - - @Test - public void test100LookupLanguagesGet() throws Exception { - final String TEST_NAME="test100LookupLanguagesGet"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - // WHEN - displayWhen(TEST_NAME); - PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, null, task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - - IntegrationTestTools.display("Languages", lookup); - - assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); - - PrismAsserts.assertEmptyAndIncomplete(lookup, LookupTableType.F_ROW); - - assertSteadyResources(); - } - - @Test - public void test102LookupLanguagesGetExclude() throws Exception { - final String TEST_NAME="test102LookupLanguagesGetExclude"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - Collection> options = schemaHelper.getOperationOptionsBuilder() - .item(LookupTableType.F_ROW).dontRetrieve() - .build(); - - // WHEN - displayWhen(TEST_NAME); - PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, options, task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - - IntegrationTestTools.display("Languages", lookup); - - assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); - - PrismAsserts.assertEmptyAndIncomplete(lookup, LookupTableType.F_ROW); - - assertSteadyResources(); - } - - @Test - public void test110LookupLanguagesGetAll() throws Exception { - final String TEST_NAME="test110LookupLanguagesGetAll"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - // WHEN - displayWhen(TEST_NAME); - PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - checkLookupResult(lookup, new String[]{"en_US", "en", "English (US)"}, - new String[]{"en_PR", "en", "English (pirate)"}, - new String[]{"sk_SK", "sk", "Slovak"}, - new String[]{"tr_TR", "tr", "Turkish"}); - } - - @Test - public void test120LookupLanguagesGetByKeyExact() throws Exception { - final String TEST_NAME="test120LookupLanguagesGetByKeyExact"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - // WHEN - displayWhen(TEST_NAME); - - GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() - .item(LookupTableType.F_ROW) - .retrieveQuery() - .item(LookupTableRowType.F_KEY) - .eq("sk_SK") - .end(); - PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - checkLookupResult(lookup, new String[] { "sk_SK", "sk", "Slovak" }); - } - - @Test - public void test121LookupLanguagesGetByKeyStartingWith() throws Exception { - final String TEST_NAME="test121LookupLanguagesGetByKeyStartingWith"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - // WHEN - displayWhen(TEST_NAME); - - GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() - .item(LookupTableType.F_ROW) - .retrieveQuery() - .item(LookupTableRowType.F_KEY) - .startsWith("e") - .end(); - PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - checkLookupResult(lookup, new String[]{"en_US", "en", "English (US)"}, - new String[]{"en_PR", "en", "English (pirate)"}); - } - - @Test - public void test122LookupLanguagesGetByKeyContaining() throws Exception { - final String TEST_NAME="test122LookupLanguagesGetByKeyContaining"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - // WHEN - displayWhen(TEST_NAME); - - GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() - .item(LookupTableType.F_ROW) - .retrieveQuery() - .item(LookupTableRowType.F_KEY) - .contains("r") - .end(); - PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - checkLookupResult(lookup, new String[]{"tr_TR", "tr", "Turkish"}); - } - - @Test - public void test123LookupLanguagesGetByKeyContainingWithPaging() throws Exception { - final String TEST_NAME="test123LookupLanguagesGetByKeyContainingWithPaging"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - // WHEN - displayWhen(TEST_NAME); - - GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() - .item(LookupTableType.F_ROW) - .retrieveQuery() - .item(LookupTableRowType.F_KEY) - .contains("_") - .offset(2) - .maxSize(1) - .asc(LookupTableRowType.F_KEY) - .end(); - PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - checkLookupResult(lookup, new String[] { "sk_SK", "sk", "Slovak" }); - } - - @Test - public void test124LookupLanguagesGetByKeyContainingReturningNothing() throws Exception { - final String TEST_NAME="test124LookupLanguagesGetByKeyContainingReturningNothing"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - // WHEN - displayWhen(TEST_NAME); - - GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() - .item(LookupTableType.F_ROW) - .retrieveQuery() - .item(LookupTableRowType.F_KEY) - .contains("xyz") - .end(); - PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - IntegrationTestTools.display("Languages", lookup); - - assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); - - PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); - assertTrue("Unexpected content in tableContainer", tableContainer == null || tableContainer.size() == 0); - - assertSteadyResources(); - } - - @Test - public void test130LookupLanguagesGetByValueExact() throws Exception { - final String TEST_NAME="test130LookupLanguagesGetByValueExact"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - // WHEN - displayWhen(TEST_NAME); - - GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() - .item(LookupTableType.F_ROW) - .retrieveQuery() - .item(LookupTableRowType.F_VALUE) - .eq("sk") - .end(); - PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - checkLookupResult(lookup, new String[] { "sk_SK", "sk", "Slovak" }); - } - - /** - * Disabled because it's not clear how to treat polystrings in searches. - * - */ - @Test - public void test131LookupLanguagesGetByLabelStartingWith() throws Exception { - final String TEST_NAME="test131LookupLanguagesGetByLabelStartingWith"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - // WHEN - displayWhen(TEST_NAME); - - String fragment = "Eng"; - GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() - .item(LookupTableType.F_ROW) - .retrieveQuery() - .item(LookupTableRowType.F_LABEL) - .startsWith(fragment) - .end(); - PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - checkLookupResult(lookup, new String[]{"en_US", "en", "English (US)"}, - new String[]{"en_PR", "en", "English (pirate)"}); - } - - @Test - public void test133LookupLanguagesGetByValueContainingWithPaging() throws Exception { - final String TEST_NAME="test123LookupLanguagesGetByKeyContainingWithPaging"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - // WHEN - displayWhen(TEST_NAME); - - GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() - .item(LookupTableType.F_ROW) - .retrieveQuery() - .item(LookupTableRowType.F_VALUE) - .contains("n") - .offset(0) - .maxSize(1) - .desc(LookupTableRowType.F_LABEL) // using sorting key other than the one used in search - .end(); - PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - checkLookupResult(lookup, new String[] { "en_US", "en", "English (US)" }); - } - - /** - * This test is disabled because id-based searching is not available yet (and it's unclear if it would be eventually necessary). - */ - @Test(enabled = false) - public void test140LookupLanguagesGetByIdExisting() throws Exception { - final String TEST_NAME="test140LookupLanguagesGetByIdExisting"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - // WHEN - displayWhen(TEST_NAME); - - Collection> options = SelectorOptions.createCollection( - prismContext.path(LookupTableType.F_ROW, 1L), - GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE)); - PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, options, task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - checkLookupResult(lookup, new String[] { "en_US", "en", "English (US)" }); - } - - - private void checkLookupResult(PrismObject lookup, String[]... tuples) { - IntegrationTestTools.display("Languages", lookup); - - assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); - - PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); - assertNotNull("Table container missing", tableContainer); - assertEquals("Unexpected table container size", tuples.length, tableContainer.size()); - - for (String[] tuple : tuples) { - assertLookupRow(tableContainer, tuple[0], tuple[1], tuple[2]); - } - assertSteadyResources(); - } - - - @Test - public void test150LookupLanguagesAddRowFull() throws Exception { - final String TEST_NAME="test150LookupLanguagesAddRow"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - LookupTableRowType row = new LookupTableRowType(); - row.setKey("gi_GI"); - row.setValue("gi"); - row.setLabel(PrismTestUtil.createPolyStringType("Gibberish")); - ObjectDelta delta = prismContext.deltaFactory().object().createModificationAddContainer(LookupTableType.class, - LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); - - // WHEN - displayWhen(TEST_NAME); - modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - - PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); - - result.computeStatus(); - TestUtil.assertSuccess(result); - - IntegrationTestTools.display("Languages", lookup); - - assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); - - PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); - assertNotNull("Table container missing", tableContainer); - assertEquals("Unexpected table container size", 5, tableContainer.size()); - - assertLookupRow(tableContainer, "en_US", "en", "English (US)"); - assertLookupRow(tableContainer, "en_PR", "en", "English (pirate)"); - assertLookupRow(tableContainer, "sk_SK", "sk", "Slovak"); - assertLookupRow(tableContainer, "tr_TR", "tr", "Turkish"); - - assertLookupRow(tableContainer, "gi_GI", "gi", "Gibberish"); - - assertSteadyResources(); - } - - @Test - public void test152LookupLanguagesAddRowKeyLabel() throws Exception { - final String TEST_NAME="test152LookupLanguagesAddRowKeyLabel"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - LookupTableRowType row = new LookupTableRowType(); - row.setKey("gi_GO"); - row.setLabel(PrismTestUtil.createPolyStringType("Gobbledygook")); - ObjectDelta delta = prismContext.deltaFactory().object().createModificationAddContainer(LookupTableType.class, - LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); - - // WHEN - displayWhen(TEST_NAME); - modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - - PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); - - result.computeStatus(); - TestUtil.assertSuccess(result); - - IntegrationTestTools.display("Languages", lookup); - - assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); - - PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); - assertNotNull("Table container missing", tableContainer); - assertEquals("Unexpected table container size", 6, tableContainer.size()); - - assertLookupRow(tableContainer, "en_US", "en", "English (US)"); - assertLookupRow(tableContainer, "en_PR", "en", "English (pirate)"); - assertLookupRow(tableContainer, "sk_SK", "sk", "Slovak"); - assertLookupRow(tableContainer, "tr_TR", "tr", "Turkish"); - assertLookupRow(tableContainer, "gi_GI", "gi", "Gibberish"); - - assertLookupRow(tableContainer, "gi_GO", null, "Gobbledygook"); - - assertSteadyResources(); - } - - @Test - public void test154LookupLanguagesAddRowKeyValue() throws Exception { - final String TEST_NAME="test154LookupLanguagesAddRowKeyValue"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - LookupTableRowType row = new LookupTableRowType(); - row.setKey("gi_HU"); - row.setValue("gi"); - ObjectDelta delta = prismContext.deltaFactory().object().createModificationAddContainer(LookupTableType.class, - LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); - - // WHEN - displayWhen(TEST_NAME); - modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - - PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); - - result.computeStatus(); - TestUtil.assertSuccess(result); - - IntegrationTestTools.display("Languages", lookup); - - assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); - - PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); - assertNotNull("Table container missing", tableContainer); - assertEquals("Unexpected table container size", 7, tableContainer.size()); - - assertLookupRow(tableContainer, "en_US", "en", "English (US)"); - assertLookupRow(tableContainer, "en_PR", "en", "English (pirate)"); - assertLookupRow(tableContainer, "sk_SK", "sk", "Slovak"); - assertLookupRow(tableContainer, "tr_TR", "tr", "Turkish"); - assertLookupRow(tableContainer, "gi_GI", "gi", "Gibberish"); - assertLookupRow(tableContainer, "gi_GO", null, "Gobbledygook"); - - assertLookupRow(tableContainer, "gi_HU", "gi", null); - - assertSteadyResources(); - } - - @Test - public void test156LookupLanguagesAddRowExistingKey() throws Exception { - final String TEST_NAME="test156LookupLanguagesAddRowExistingKey"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - LookupTableRowType row = new LookupTableRowType(); - row.setKey("gi_HU"); - row.setValue("gi"); - row.setLabel(PrismTestUtil.createPolyStringType("Humbug")); - ObjectDelta delta = prismContext.deltaFactory().object().createModificationAddContainer(LookupTableType.class, - LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); - - // WHEN - displayWhen(TEST_NAME); - boolean exception = false; - try { - modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); - } catch (ObjectAlreadyExistsException ex) { - exception = true; - } - AssertJUnit.assertFalse(exception); // as per description in https://wiki.evolveum.com/display/midPoint/Development+with+LookupTable - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - - task = createTask(TEST_NAME); - result = task.getResult(); - PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); - - result.computeStatus(); - TestUtil.assertSuccess(result); - - IntegrationTestTools.display("Languages", lookup); - - assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); - - PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); - assertNotNull("Table container missing", tableContainer); - assertEquals("Unexpected table container size", 7, tableContainer.size()); - - assertLookupRow(tableContainer, "en_US", "en", "English (US)"); - assertLookupRow(tableContainer, "en_PR", "en", "English (pirate)"); - assertLookupRow(tableContainer, "sk_SK", "sk", "Slovak"); - assertLookupRow(tableContainer, "tr_TR", "tr", "Turkish"); - assertLookupRow(tableContainer, "gi_GI", "gi", "Gibberish"); - assertLookupRow(tableContainer, "gi_GO", null, "Gobbledygook"); - - assertLookupRow(tableContainer, "gi_HU", "gi", "Humbug"); - - assertSteadyResources(); - } - - /** - * @throws Exception - */ - @Test - public void test162LookupLanguagesDeleteRowFullNoId() throws Exception { - final String TEST_NAME="test162LookupLanguagesDeleteRowFullNoId"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - LookupTableRowType row = new LookupTableRowType(); - row.setKey("sk_SK"); - row.setValue("sk"); - row.setLabel(PrismTestUtil.createPolyStringType("Slovak")); - ObjectDelta delta = prismContext.deltaFactory().object().createModificationDeleteContainer(LookupTableType.class, - LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); - - // WHEN - displayWhen(TEST_NAME); - modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - - PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); - - result.computeStatus(); - TestUtil.assertSuccess(result); - - IntegrationTestTools.display("Languages", lookup); - - assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); - - PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); - assertNotNull("Table container missing", tableContainer); - assertEquals("Unexpected table container size", 6, tableContainer.size()); - - assertLookupRow(tableContainer, "en_US", "en", "English (US)"); - assertLookupRow(tableContainer, "en_PR", "en", "English (pirate)"); - assertLookupRow(tableContainer, "tr_TR", "tr", "Turkish"); - assertLookupRow(tableContainer, "gi_GI", "gi", "Gibberish"); - assertLookupRow(tableContainer, "gi_GO", null, "Gobbledygook"); - assertLookupRow(tableContainer, "gi_HU", "gi", "Humbug"); - - assertSteadyResources(); - } - - @Test - public void test164LookupLanguagesDeleteRowFullId() throws Exception { - final String TEST_NAME="test164LookupLanguagesDeleteRowFullId"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - LookupTableRowType row = new LookupTableRowType(); - row.setKey("en_US"); - row.setValue("en"); - row.setLabel(PrismTestUtil.createPolyStringType("English (US)")); - row.setId(1L); - ObjectDelta delta = prismContext.deltaFactory().object().createModificationDeleteContainer(LookupTableType.class, - LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); - - // WHEN - displayWhen(TEST_NAME); - executeChanges(delta, null, task, result); - - // THEN - displayThen(TEST_NAME); - assertSuccess(result); - - PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); - - assertSuccess(result); - - display("Languages", lookup); - - assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); - - PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); - assertNotNull("Table container missing", tableContainer); - assertEquals("Unexpected table container size", 5, tableContainer.size()); - - assertLookupRow(tableContainer, "en_PR", "en", "English (pirate)"); - assertLookupRow(tableContainer, "tr_TR", "tr", "Turkish"); - assertLookupRow(tableContainer, "gi_GI", "gi", "Gibberish"); - assertLookupRow(tableContainer, "gi_GO", null, "Gobbledygook"); - assertLookupRow(tableContainer, "gi_HU", "gi", "Humbug"); - - assertSteadyResources(); - } - - @Test - public void test166LookupLanguagesDeleteRowIdOnly() throws Exception { - final String TEST_NAME="test166LookupLanguagesDeleteRowIdOnly"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - LookupTableRowType row = new LookupTableRowType(); - row.setId(2L); - ObjectDelta delta = prismContext.deltaFactory().object().createModificationDeleteContainer(LookupTableType.class, - LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); - - // WHEN - displayWhen(TEST_NAME); - executeChanges(delta, null, task, result); - - // THEN - displayThen(TEST_NAME); - assertSuccess(result); - - PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); - - assertSuccess(result); - - display("Languages", lookup); - - assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); - - PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); - assertNotNull("Table container missing", tableContainer); - assertEquals("Unexpected table container size", 4, tableContainer.size()); - - assertLookupRow(tableContainer, "gi_GI", "gi", "Gibberish"); - assertLookupRow(tableContainer, "gi_GO", null, "Gobbledygook"); - assertLookupRow(tableContainer, "gi_HU", "gi", "Humbug"); - assertLookupRow(tableContainer, "tr_TR", "tr", "Turkish"); - - assertSteadyResources(); - } - - @Test - public void test168LookupLanguagesDeleteRowByKey() throws Exception { - final String TEST_NAME="test168LookupLanguagesDeleteRowByKey"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - LookupTableRowType row = new LookupTableRowType(); - row.setKey("gi_GI"); - ObjectDelta delta = prismContext.deltaFactory().object().createModificationDeleteContainer(LookupTableType.class, - LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); - - // WHEN - displayWhen(TEST_NAME); - modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); - - // THEN - displayThen(TEST_NAME); - assertSuccess(result); - - PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); - - assertSuccess(result); - - IntegrationTestTools.display("Languages", lookup); - - assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); - - PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); - assertNotNull("Table container missing", tableContainer); - assertEquals("Unexpected table container size", 3, tableContainer.size()); - - assertLookupRow(tableContainer, "gi_GO", null, "Gobbledygook"); - assertLookupRow(tableContainer, "gi_HU", "gi", "Humbug"); - assertLookupRow(tableContainer, "tr_TR", "tr", "Turkish"); - - assertSteadyResources(); - } - - @Test - public void test170LookupLanguagesReplaceRows() throws Exception { - final String TEST_NAME="test170LookupLanguagesReplaceRows"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - LookupTableRowType row1 = new LookupTableRowType(); - row1.setKey("ja_JA"); - row1.setValue("ja"); - row1.setLabel(PrismTestUtil.createPolyStringType("Jabber")); - - LookupTableRowType row2 = new LookupTableRowType(); - row2.setKey("ja_MJ"); - row2.setValue("ja"); - row2.setLabel(PrismTestUtil.createPolyStringType("Mumbojumbo")); - - LookupTableRowType row3 = new LookupTableRowType(); - row3.setKey("en_PR"); // existing key - row3.setValue("en1"); - row3.setLabel(PrismTestUtil.createPolyStringType("English (pirate1)")); - - ObjectDelta delta = prismContext.deltaFactory().object().createModificationReplaceContainer(LookupTableType.class, - LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row1, row2, row3); - - // WHEN - displayWhen(TEST_NAME); - modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - - PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); - - result.computeStatus(); - TestUtil.assertSuccess(result); - - IntegrationTestTools.display("Languages", lookup); - - assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); - - PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); - assertNotNull("Table container missing", tableContainer); - assertEquals("Unexpected table container size", 3, tableContainer.size()); - - assertLookupRow(tableContainer, "ja_JA", "ja", "Jabber"); - assertLookupRow(tableContainer, "ja_MJ", "ja", "Mumbojumbo"); - assertLookupRow(tableContainer, "en_PR", "en1", "English (pirate1)"); - - assertSteadyResources(); - } - - @Test - public void test180LookupLanguagesReplaceObject() throws Exception { - final String TEST_NAME="test180LookupLanguagesReplaceObject"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - PrismObject replacement = PrismTestUtil.parseObject(LOOKUP_LANGUAGES_REPLACEMENT_FILE); - ObjectDelta delta = DeltaFactory.Object.createAddDelta(replacement); - - // WHEN - displayWhen(TEST_NAME); - ModelExecuteOptions options = ModelExecuteOptions.createOverwrite(); - options.setRaw(true); - modelService.executeChanges(MiscSchemaUtil.createCollection(delta), options, task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - - PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); - - result.computeStatus(); - TestUtil.assertSuccess(result); - - IntegrationTestTools.display("Languages", lookup); - - assertEquals("Wrong lang lookup name", "Languages Replaced", lookup.asObjectable().getName().getOrig()); - - PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); - assertNotNull("Table container missing", tableContainer); - assertEquals("Unexpected table container size", 1, tableContainer.size()); - - assertLookupRow(tableContainer, "fr_FR", "fr", "Français"); - assertSteadyResources(); - } - - @Test - public void test182LookupLanguagesReimport() throws Exception { - final String TEST_NAME="test182LookupLanguagesReimport"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - ImportOptionsType options = new ImportOptionsType(); - options.setOverwrite(true); - options.setKeepOid(true); - - // WHEN - displayWhen(TEST_NAME); - modelService.importObjectsFromFile(LOOKUP_LANGUAGES_FILE, options, task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - - PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); - - result.computeStatus(); - TestUtil.assertSuccess(result); - - IntegrationTestTools.display("Languages", lookup); - - assertEquals("Wrong lang lookup name", "Languages", lookup.asObjectable().getName().getOrig()); - - checkLookupResult(lookup, new String[]{"en_US", "en", "English (US)"}, - new String[]{"en_PR", "en", "English (pirate)"}, - new String[]{"sk_SK", "sk", "Slovak"}, - new String[]{"tr_TR", "tr", "Turkish"}); - - assertSteadyResources(); - } - - - private void assertLookupRow(PrismContainer tableContainer, String key, String value, - String label) { - for (PrismContainerValue row: tableContainer.getValues()) { - LookupTableRowType rowType = row.asContainerable(); - if (key.equals(rowType.getKey())) { - assertEquals("Wrong value for key "+key, value, rowType.getValue()); - if (label == null) { - assertNull("Unexpected label for key "+key+": "+rowType.getLabel(), rowType.getLabel()); - } else { - assertEquals("Wrong label for key "+key, PrismTestUtil.createPolyStringType(label), rowType.getLabel()); - } - return; - } - } - AssertJUnit.fail("Row with key '"+key+"' was not found in lookup table"); - } - - private PrismObject getLookupTableAll(String oid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() - .item(LookupTableType.F_ROW).retrieve(); - return modelService.getObject(LookupTableType.class, oid, optionsBuilder.build(), task, result); - } - - @Test - public void test200EditSchemaUser() throws Exception { - final String TEST_NAME="test200EditSchemaUser"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - PrismObjectDefinition userDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class); - PrismObject user = userDef.instantiate(); - - // WHEN - displayWhen(TEST_NAME); - PrismObjectDefinition editDef = getEditObjectDefinition(user); - - // THEN - displayThen(TEST_NAME); - - - PrismAsserts.assertEmphasized(editDef, UserType.F_NAME, true); - PrismAsserts.assertEmphasized(editDef, UserType.F_GIVEN_NAME, false); - PrismAsserts.assertEmphasized(editDef, UserType.F_FAMILY_NAME, true); - PrismAsserts.assertEmphasized(editDef, UserType.F_FULL_NAME, true); - PrismAsserts.assertEmphasized(editDef, UserType.F_DESCRIPTION, false); - - PrismPropertyDefinition additionalNameDef = editDef.findPropertyDefinition(UserType.F_ADDITIONAL_NAME); - assertNotNull("No definition for additionalName in user", additionalNameDef); - assertEquals("Wrong additionalName displayName", "Middle Name", additionalNameDef.getDisplayName()); - assertEquals("Wrong additionalName help", "Just a plain old middle name", additionalNameDef.getHelp()); // MID-5736 - assertTrue("additionalName not readable", additionalNameDef.canRead()); - PrismAsserts.assertEmphasized(additionalNameDef, false); - - PrismPropertyDefinition costCenterDef = editDef.findPropertyDefinition(UserType.F_COST_CENTER); - assertNotNull("No definition for costCenter in user", costCenterDef); - assertEquals("Wrong costCenter displayOrder", (Integer)123, costCenterDef.getDisplayOrder()); - assertTrue("costCenter not readable", costCenterDef.canRead()); - PrismAsserts.assertEmphasized(costCenterDef, true); - FormItemValidationType validationAnnotation = costCenterDef.getAnnotation(ItemRefinedDefinitionType.F_VALIDATION); - assertNotNull("No validation annotation in costCenter", validationAnnotation); - ExpressionType validationExpression = validationAnnotation.getServer().get(0).getExpression(); - assertNotNull("No validation expression annotation in costCenter", validationExpression); - - // This has overridden lookup def in object template - PrismPropertyDefinition preferredLanguageDef = editDef.findPropertyDefinition(UserType.F_PREFERRED_LANGUAGE); - assertNotNull("No definition for preferredLanguage in user", preferredLanguageDef); - assertEquals("Wrong preferredLanguage displayName", "Language", preferredLanguageDef.getDisplayName()); - assertTrue("preferredLanguage not readable", preferredLanguageDef.canRead()); - PrismReferenceValue valueEnumerationRef = preferredLanguageDef.getValueEnumerationRef(); - assertNotNull("No valueEnumerationRef for preferredLanguage", valueEnumerationRef); - assertEquals("Wrong valueEnumerationRef OID for preferredLanguage", LOOKUP_LANGUAGES_OID, valueEnumerationRef.getOid()); - - // This has default lookup def in schema - PrismPropertyDefinition timezoneDef = editDef.findPropertyDefinition(UserType.F_TIMEZONE); - assertNotNull("No definition for timezone in user", timezoneDef); - assertEquals("Wrong timezone displayName", "FocusType.timezone", timezoneDef.getDisplayName()); - assertTrue("timezone not readable", timezoneDef.canRead()); - valueEnumerationRef = timezoneDef.getValueEnumerationRef(); - assertNotNull("No valueEnumerationRef for timezone", valueEnumerationRef); - assertEquals("Wrong valueEnumerationRef OID for timezone", SystemObjectsType.LOOKUP_TIMEZONES.value(), valueEnumerationRef.getOid()); - - // Deprecated. But deprecation flag in overridden in object template (MID-4680) - PrismPropertyDefinition employeeTypeDef = editDef.findPropertyDefinition(UserType.F_EMPLOYEE_TYPE); - assertNotNull("No definition for employeeType in user", employeeTypeDef); - assertEquals("Wrong deprecation flag for employeeType", false, employeeTypeDef.isDeprecated()); - - PrismContainerDefinition credentialsDef = editDef.findContainerDefinition(UserType.F_CREDENTIALS); - assertNotNull("No definition for credentials in user", credentialsDef); - assertTrue("Credentials not readable", credentialsDef.canRead()); - - ItemPath passwdValPath = ItemPath.create(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE); - PrismPropertyDefinition passwdValDef = editDef.findPropertyDefinition(passwdValPath); - assertNotNull("No definition for "+passwdValPath+" in user", passwdValDef); - assertTrue("Password not readable", passwdValDef.canRead()); - - assertSteadyResources(); - } - - @Test - public void test210UserDefinition() throws Exception { - final String TEST_NAME="test210UserDefinition"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - // WHEN - displayWhen(TEST_NAME); - PrismObject user = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - - assertPropertyValues(user, UserType.F_ADDITIONAL_NAME, (propDef, name) -> { - assertNotNull("No definition for additionalName in user", propDef); - assertEquals("Wrong additionalName displayName", "Middle Name", propDef.getDisplayName()); - assertTrue("additionalName not readable", propDef.canRead()); - }, PrismTestUtil.createPolyString("Jackie")); - - - assertPropertyValues(user, UserType.F_COST_CENTER, (Validator>) (propDef, name) -> { - assertNotNull("No definition for costCenter in user", propDef); - assertEquals("Wrong costCenter displayOrder", (Integer)123, propDef.getDisplayOrder()); - assertTrue("costCenter not readable", propDef.canRead()); - }); - - assertPropertyValues(user, UserType.F_PREFERRED_LANGUAGE, - (Validator>) (propDef, name) -> { - assertNotNull("No definition for preferredLanguage in user", propDef); - assertEquals("Wrong preferredLanguage displayName", "Language", propDef.getDisplayName()); - assertTrue("preferredLanguage not readable", propDef.canRead()); - PrismReferenceValue valueEnumerationRef = propDef.getValueEnumerationRef(); - assertNotNull("No valueEnumerationRef for preferredLanguage", valueEnumerationRef); - assertEquals("Wrong valueEnumerationRef OID for preferredLanguage", LOOKUP_LANGUAGES_OID, valueEnumerationRef.getOid()); - }); - - assertContainer(user, UserType.F_CREDENTIALS, (credentialsDef, name) -> { - assertNotNull("No definition for credentials in user", credentialsDef); - assertTrue("Credentials not readable", credentialsDef.canRead()); - }, true); - - assertProperty(user, ItemPath.create(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE), - (propDef, name) -> { - assertTrue("Password not readable", propDef.canRead()); - }); - - assertSteadyResources(); - } - - /** - * Check that the user definition in schema registry was not ruined - * @throws Exception - */ - @Test - public void test211SchemaRegistryUntouched() throws Exception { - final String TEST_NAME="test211SchemaRegistryUntouched"; - displayTestTitle(TEST_NAME); - - assertUntouchedUserDefinition(); - assertSteadyResources(); - } - - /** - * Modify jack, see if the schema still applies. - */ - @Test - public void test213ModifiedUserJack() throws Exception { - final String TEST_NAME="test213ModifiedUserJack"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - modifyObjectReplaceProperty(UserType.class, USER_JACK_OID, UserType.F_PREFERRED_LANGUAGE, task, result, "en_PR"); - - // WHEN - displayWhen(TEST_NAME); - PrismObject user = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result); - - // THEN - displayThen(TEST_NAME); - assertSuccess(result); - - assertPropertyValues(user, UserType.F_ADDITIONAL_NAME, (propDef, name) -> { - assertNotNull("No definition for additionalName in user", propDef); - assertEquals("Wrong additionalName displayName", "Middle Name", propDef.getDisplayName()); - assertTrue("additionalName not readable", propDef.canRead()); - }, PrismTestUtil.createPolyString("Jackie")); - - assertPropertyValues(user, UserType.F_COST_CENTER, (propDef, name) -> { - assertNotNull("No definition for costCenter in user", propDef); - assertEquals("Wrong costCenter displayOrder", (Integer)123, propDef.getDisplayOrder()); - assertTrue("costCenter not readable", propDef.canRead()); - },"G001"); // This is set by user template - - assertPropertyValues(user, UserType.F_PREFERRED_LANGUAGE, (propDef, name) -> { - assertNotNull("No definition for preferredLanguage in user", propDef); - assertEquals("Wrong preferredLanguage displayName", "Language", propDef.getDisplayName()); - assertTrue("preferredLanguage not readable", propDef.canRead()); - PrismReferenceValue valueEnumerationRef = propDef.getValueEnumerationRef(); - assertNotNull("No valueEnumerationRef for preferredLanguage", valueEnumerationRef); - assertEquals("Wrong valueEnumerationRef OID for preferredLanguage", LOOKUP_LANGUAGES_OID, valueEnumerationRef.getOid()); - }, "en_PR"); - - - assertContainer(user, UserType.F_CREDENTIALS, new Validator>() { - @Override - public void validate(PrismContainerDefinition credentialsDef, String name) - throws Exception { - assertNotNull("No definition for credentials in user", credentialsDef); - assertTrue("Credentials not readable", credentialsDef.canRead()); - } - - }, true); - - assertProperty(user, ItemPath.create(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE), - (Validator>) (propDef, name) -> assertTrue("Password not readable", propDef.canRead())); - - assertUntouchedUserDefinition(); - assertSteadyResources(); - } - - - @Test - public void test250EditSchemaRole() throws Exception { - final String TEST_NAME="test250EditSchemaRole"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - PrismObjectDefinition roleDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(RoleType.class); - PrismObject role = roleDef.instantiate(); - - // WHEN - displayWhen(TEST_NAME); - PrismObjectDefinition editDef = getEditObjectDefinition(role); - - // THEN - displayThen(TEST_NAME); - - // TODO - PrismPropertyDefinition requestableDef = editDef.findPropertyDefinition(RoleType.F_REQUESTABLE); - assertNotNull("No definition for requestable in role", requestableDef); - assertEquals("Wrong requestable displayName", "Can request", requestableDef.getDisplayName()); - - assertSteadyResources(); - } - - @Test - public void test260EditShadowSchemaKindIntent() throws Exception { - final String TEST_NAME="test260EditShadowSchemaKindIntent"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - ResourceShadowDiscriminator discr = new ResourceShadowDiscriminator(RESOURCE_DUMMY_OID, ShadowKindType.ACCOUNT, null, null, false); - - // WHEN - displayWhen(TEST_NAME); - PrismObjectDefinition editDef = modelInteractionService.getEditShadowDefinition(discr, AuthorizationPhaseType.REQUEST, task, result); - - // THEN - displayThen(TEST_NAME); - assertSuccess(result); - - PrismPropertyDefinition nameDef = editDef.findPropertyDefinition(ShadowType.F_NAME); - assertNotNull("No definition for name in shadow", nameDef); - assertEquals("Wrong shadow name displayName", "ObjectType.name", nameDef.getDisplayName()); - assertTrue("additionalName not readable", nameDef.canRead()); - - PrismPropertyDefinition attrFullNameDef = editDef.findPropertyDefinition(dummyResourceCtl.getAttributeFullnamePath()); - assertNotNull("No definition for fullname attribute in shadow", attrFullNameDef); - assertEquals("Wrong shadow fullname attribute displayName", "Full Name", attrFullNameDef.getDisplayName()); - assertTrue("additionalName not readable", attrFullNameDef.canRead()); - - PrismContainerDefinition identifiersDef = editDef.findContainerDefinition(ItemPath.create(ShadowType.F_ASSOCIATION, - ShadowAssociationType.F_IDENTIFIERS)); - StringBuilder message = new StringBuilder(); - message.append("Wrong type for ").append(ShadowAssociationType.F_IDENTIFIERS) - .append(", expected ResourceAttributeContainerDefinition but was ") - .append(identifiersDef == null ? null : identifiersDef.getClass().getName()) - .append("; "); - assertClassType(message.toString(), identifiersDef, ResourceAttributeContainerDefinition.class); - - - assertSteadyResources(); - } - - @Test - public void test261EditShadowSchemaObjectclass() throws Exception { - final String TEST_NAME="test261EditShadowSchemaObjectclass"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - ResourceShadowDiscriminator discr = new ResourceShadowDiscriminator(RESOURCE_DUMMY_OID, dummyResourceCtl.getAccountObjectClassQName()); - IntegrationTestTools.display("Discr", discr); - - // WHEN - displayWhen(TEST_NAME); - PrismObjectDefinition editDef = modelInteractionService.getEditShadowDefinition(discr, AuthorizationPhaseType.REQUEST, task, result); - - // THEN - displayThen(TEST_NAME); - assertSuccess(result); - - PrismPropertyDefinition nameDef = editDef.findPropertyDefinition(ShadowType.F_NAME); - assertNotNull("No definition for name in shadow", nameDef); - assertEquals("Wrong shadow name displayName", "ObjectType.name", nameDef.getDisplayName()); - assertTrue("additionalName not readable", nameDef.canRead()); - - PrismPropertyDefinition attrFullNameDef = editDef.findPropertyDefinition(dummyResourceCtl.getAttributeFullnamePath()); - assertNotNull("No definition for fullname attribute in shadow", attrFullNameDef); - assertEquals("Wrong shadow fullname attribute displayName", "Full Name", attrFullNameDef.getDisplayName()); - assertTrue("additionalName not readable", attrFullNameDef.canRead()); - - assertSteadyResources(); - } - - @Test - public void test263EditShadowSchemaEmpty() throws Exception { - final String TEST_NAME="test263EditShadowSchemaEmpty"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - ResourceShadowDiscriminator discr = new ResourceShadowDiscriminator(null, null); - IntegrationTestTools.display("Discr", discr); - - // WHEN - displayWhen(TEST_NAME); - PrismObjectDefinition editDef = modelInteractionService.getEditShadowDefinition(discr, AuthorizationPhaseType.REQUEST, task, result); - - // THEN - displayThen(TEST_NAME); - assertSuccess(result); - - PrismPropertyDefinition nameDef = editDef.findPropertyDefinition(ShadowType.F_NAME); - assertNotNull("No definition for name in shadow", nameDef); - assertEquals("Wrong shadow name displayName", "ObjectType.name", nameDef.getDisplayName()); - assertTrue("additionalName not readable", nameDef.canRead()); - - PrismPropertyDefinition attrFullNameDef = editDef.findPropertyDefinition(dummyResourceCtl.getAttributeFullnamePath()); - assertNull("Unexpected definition for fullname attribute in shadow", attrFullNameDef); - - assertSteadyResources(); - } - - @Test - public void test265EditShadowSchemaNull() throws Exception { - final String TEST_NAME="test265EditShadowSchemaNull"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - // WHEN - displayWhen(TEST_NAME); - PrismObjectDefinition editDef = modelInteractionService.getEditShadowDefinition(null, AuthorizationPhaseType.REQUEST, task, result); - - // THEN - displayThen(TEST_NAME); - assertSuccess(result); - - PrismPropertyDefinition nameDef = editDef.findPropertyDefinition(ShadowType.F_NAME); - assertNotNull("No definition for name in shadow", nameDef); - assertEquals("Wrong shadow name displayName", "ObjectType.name", nameDef.getDisplayName()); - assertTrue("additionalName not readable", nameDef.canRead()); - - PrismPropertyDefinition attrFullNameDef = editDef.findPropertyDefinition(dummyResourceCtl.getAttributeFullnamePath()); - assertNull("Unexpected definition for fullname attribute in shadow", attrFullNameDef); - - assertSteadyResources(); - } - - /** - * MID-4660, MID-4491, MID-3581 - */ - @Test - public void test310CustomRelations() throws Exception { - final String TEST_NAME="test310CustomRelations"; - displayTestTitle(TEST_NAME); - - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - // WHEN - displayWhen(TEST_NAME); - List relations = modelInteractionService.getRelationDefinitions(); - - // THEN - displayThen(TEST_NAME); - display("Relations", relations); - assertRelationDef(relations, SchemaConstants.ORG_MANAGER, "RelationTypes.manager"); - assertRelationDef(relations, SchemaConstants.ORG_OWNER, "Master"); - assertRelationDef(relations, RELATION_PIRACY_CAPTAIN, "Captain"); - assertEquals("Unexpected number of relation definitions", 8, relations.size()); - } - - /** - * Login as Otis. Otis has a restricted authorizations. Check that schema is presented accordingly to - * these limitations. - */ - @Test - public void test800OtisEditSchemaUser() throws Exception { - final String TEST_NAME="test800OtisEditSchemaUser"; - displayTestTitle(TEST_NAME); - - // GIVEN - login(USER_OTIS_USERNAME); - - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - PrismObjectDefinition userDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class); - PrismObject user = userDef.instantiate(); - - // WHEN - displayWhen(TEST_NAME); - PrismObjectDefinition editDef = getEditObjectDefinition(user); - display("Otis edit schema", editDef); - - // THEN - displayThen(TEST_NAME); - - PrismPropertyDefinition nameDef = editDef.findPropertyDefinition(UserType.F_NAME); - assertNotNull("No definition for name in user", nameDef); - assertEquals("Wrong name displayName", "ObjectType.name", nameDef.getDisplayName()); - assertTrue("name not readable", nameDef.canRead()); - assertTrue("name is creatable", !nameDef.canAdd()); - assertTrue("name is modifiable", !nameDef.canModify()); - - PrismPropertyDefinition additionalNameDef = editDef.findPropertyDefinition(UserType.F_ADDITIONAL_NAME); - assertNotNull("No definition for additionalName in user", additionalNameDef); - assertEquals("Wrong additionalName displayName", "Middle Name", additionalNameDef.getDisplayName()); - assertTrue("additionalName is readable", !additionalNameDef.canRead()); - assertTrue("additionalName is creatable", !additionalNameDef.canAdd()); - assertTrue("additionalName not modifiable", additionalNameDef.canModify()); - - PrismPropertyDefinition costCenterDef = editDef.findPropertyDefinition(UserType.F_COST_CENTER); - assertNotNull("No definition for costCenter in user", costCenterDef); - assertEquals("Wrong costCenter displayOrder", (Integer)123, costCenterDef.getDisplayOrder()); - assertTrue("costCenter is readable", !costCenterDef.canRead()); - assertTrue("costCenter is creatable", !costCenterDef.canAdd()); - assertTrue("costCenter is modifiable", !costCenterDef.canModify()); - - PrismPropertyDefinition preferredLanguageDef = editDef.findPropertyDefinition(UserType.F_PREFERRED_LANGUAGE); - assertNotNull("No definition for preferredLanguage in user", preferredLanguageDef); - assertEquals("Wrong preferredLanguage displayName", "Language", preferredLanguageDef.getDisplayName()); - PrismReferenceValue valueEnumerationRef = preferredLanguageDef.getValueEnumerationRef(); - assertNotNull("No valueEnumerationRef for preferredLanguage", valueEnumerationRef); - assertEquals("Wrong valueEnumerationRef OID for preferredLanguage", LOOKUP_LANGUAGES_OID, valueEnumerationRef.getOid()); - assertTrue("preferredLanguage is readable", !preferredLanguageDef.canRead()); - assertTrue("preferredLanguage is creatable", !preferredLanguageDef.canAdd()); - assertTrue("preferredLanguage is modifiable", !preferredLanguageDef.canModify()); - - PrismContainerDefinition credentialsDef = editDef.findContainerDefinition(UserType.F_CREDENTIALS); - assertNotNull("No definition for credentials in user", credentialsDef); - assertTrue("Credentials is readable", !credentialsDef.canRead()); - assertTrue("Credentials is creatable", !credentialsDef.canAdd()); - assertTrue("Credentials is modifiable", !credentialsDef.canModify()); - - ItemPath passwdValPath = ItemPath.create(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE); - PrismPropertyDefinition passwdValDef = editDef.findPropertyDefinition(passwdValPath); - assertNotNull("No definition for "+passwdValPath+" in user", passwdValDef); - assertTrue("Password is readable", !passwdValDef.canRead()); - assertTrue("Password is creatable", !passwdValDef.canAdd()); - assertTrue("Password is modifiable", !passwdValDef.canModify()); - - assertUntouchedUserDefinition(); - assertSteadyResources(); - } - - @Test - public void test810OtisGetJack() throws Exception { - final String TEST_NAME="test810OtisGetJack"; - displayTestTitle(TEST_NAME); - - // GIVEN - login(USER_OTIS_USERNAME); - - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - // WHEN - displayWhen(TEST_NAME); - PrismObject user = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - - assertPropertyValues(user, UserType.F_NAME, new Validator>() { - @Override - public void validate(PrismPropertyDefinition propDef, String name) throws Exception { - assertNotNull("No definition for name in user", propDef); - assertEquals("Wrong name displayName", "ObjectType.name", propDef.getDisplayName()); - assertTrue(name+" not readable", propDef.canRead()); - assertTrue(name+" is creatable", !propDef.canAdd()); - assertTrue(name+" is modifiable", !propDef.canModify()); - } - }, PrismTestUtil.createPolyString("jack")); - - assertPropertyValues(user, UserType.F_DESCRIPTION, new Validator>() { - @Override - public void validate(PrismPropertyDefinition propDef, String name) throws Exception { - assertNotNull("No definition for description in user", propDef); - assertEquals("Wrong description displayName", "Comment", propDef.getDisplayName()); - assertTrue(name+" not readable", propDef.canRead()); - assertTrue(name+" is creatable", !propDef.canAdd()); - assertTrue(name+" not modifiable", propDef.canModify()); - } - }, "Where's the rum?"); - - assertPropertyValues(user, UserType.F_ADDITIONAL_NAME, new Validator>() { - @Override - public void validate(PrismPropertyDefinition propDef, String name) throws Exception { - assertNotNull("No definition for additionalName in user", propDef); - assertEquals("Wrong additionalName displayName", "Middle Name", propDef.getDisplayName()); - assertTrue(name+" is readable", !propDef.canRead()); - assertTrue(name+" is creatable", !propDef.canAdd()); - assertTrue(name+" not modifiable", propDef.canModify()); - } - }); - - assertPropertyValues(user, UserType.F_COST_CENTER, new Validator>() { - @Override - public void validate(PrismPropertyDefinition propDef, String name) throws Exception { - assertNotNull("No definition for costCenter in user", propDef); - assertEquals("Wrong costCenter displayOrder", (Integer)123, propDef.getDisplayOrder()); - assertTrue(name+" is readable", !propDef.canRead()); - assertTrue(name+" is creatable", !propDef.canAdd()); - assertTrue(name+" is modifiable", !propDef.canModify()); - } - }); - - assertPropertyValues(user, UserType.F_PREFERRED_LANGUAGE, new Validator>() { - @Override - public void validate(PrismPropertyDefinition propDef, String name) throws Exception { - assertNotNull("No definition for preferredLanguage in user", propDef); - assertEquals("Wrong preferredLanguage displayName", "Language", propDef.getDisplayName()); - PrismReferenceValue valueEnumerationRef = propDef.getValueEnumerationRef(); - assertNotNull("No valueEnumerationRef for preferredLanguage", valueEnumerationRef); - assertEquals("Wrong valueEnumerationRef OID for preferredLanguage", LOOKUP_LANGUAGES_OID, valueEnumerationRef.getOid()); - assertTrue(name+" is readable", !propDef.canRead()); - assertTrue(name+" is creatable", !propDef.canAdd()); - assertTrue(name+" is modifiable", !propDef.canModify()); - } - }); - - PrismAsserts.assertNoItem(user, UserType.F_CREDENTIALS); - - assertUntouchedUserDefinition(); - assertSteadyResources(); - } - - @Test - public void test820OtisSearchUsers() throws Exception { - final String TEST_NAME="test820OtisSearchUsers"; - displayTestTitle(TEST_NAME); - - // GIVEN - login(USER_OTIS_USERNAME); - - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - // WHEN - displayWhen(TEST_NAME); - SearchResultList> users = modelService.searchObjects(UserType.class, null, null, task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - - assertEquals("Unexepected number of users found", 7, users.size()); - - for (final PrismObject user: users) { - assertProperty(user, UserType.F_NAME, new Validator>() { - @Override - public void validate(PrismPropertyDefinition propDef, String name) throws Exception { - assertNotNull("No definition for name in user", propDef); - assertEquals("Wrong name displayName", "ObjectType.name", propDef.getDisplayName()); - assertTrue(name+" of "+user+" not readable", propDef.canRead()); - assertTrue(name+" of "+user+" is creatable", !propDef.canAdd()); - assertTrue(name+" of "+user+" is modifiable", !propDef.canModify()); - } - }); - assertProperty(user, UserType.F_ADDITIONAL_NAME, new Validator>() { - @Override - public void validate(PrismPropertyDefinition propDef, String name) throws Exception { - assertNotNull("No definition for additionalName in user", propDef); - assertEquals("Wrong additionalName displayName", "Middle Name", propDef.getDisplayName()); - assertTrue(name+" of "+user+" is readable", !propDef.canRead()); - assertTrue(name+" of "+user+" is creatable", !propDef.canAdd()); - assertTrue(name+" of "+user+" not modifiable", propDef.canModify()); - } - }); - assertProperty(user, UserType.F_COST_CENTER, new Validator>() { - @Override - public void validate(PrismPropertyDefinition propDef, String name) throws Exception { - assertNotNull("No definition for costCenter in user", propDef); - assertEquals("Wrong costCenter displayOrder", (Integer)123, propDef.getDisplayOrder()); - assertTrue(name+" of "+user+" is readable", !propDef.canRead()); - assertTrue(name+" of "+user+" is creatable", !propDef.canAdd()); - assertTrue(name+" of "+user+" is modifiable", !propDef.canModify()); - } - }); - - assertProperty(user, UserType.F_PREFERRED_LANGUAGE, new Validator>() { - @Override - public void validate(PrismPropertyDefinition propDef, String name) throws Exception { - assertNotNull("No definition for preferredLanguage in user", propDef); - assertEquals("Wrong preferredLanguage displayName", "Language", propDef.getDisplayName()); - PrismReferenceValue valueEnumerationRef = propDef.getValueEnumerationRef(); - assertNotNull("No valueEnumerationRef for preferredLanguage", valueEnumerationRef); - assertEquals("Wrong valueEnumerationRef OID for preferredLanguage", LOOKUP_LANGUAGES_OID, valueEnumerationRef.getOid()); - assertTrue(name+" of "+user+" is readable", !propDef.canRead()); - assertTrue(name+" of "+user+" is creatable", !propDef.canAdd()); - assertTrue(name+" of "+user+" is modifiable", !propDef.canModify()); - } - }); - - PrismAsserts.assertNoItem(user, UserType.F_CREDENTIALS); - - assertUntouchedUserDefinition(); - } - - } - - - private void assertProperty(PrismObject object, ItemPath path, - Validator> validator) throws Exception { - assertPropertyValues(object, path, validator, (T[])null); - } - - private void assertPropertyValues(PrismObject object, ItemPath path, - Validator> validator, T... expectedValues) throws Exception { - PrismProperty prop = object.findProperty(path); - if (expectedValues == null) { - if (prop != null) { - PrismPropertyDefinition propDef = prop.getDefinition(); - assertNotNull("No definition in property "+path, propDef); - try { - validator.validate(propDef, path.toString()+" (propDef) "); - } catch (Exception | Error e) { - IntegrationTestTools.display("Wrong definition", propDef); - throw e; - } - } - } else if (expectedValues.length == 0) { - assertNull("Unexpected property "+path+" in "+object+": "+prop, prop); - } else { - assertNotNull("No property "+path+" in "+object, prop); - PrismAsserts.assertPropertyValue(prop, expectedValues); - PrismPropertyDefinition propDef = prop.getDefinition(); - assertNotNull("No definition in property "+path, propDef); - try { - validator.validate(propDef, path.toString()+" (propDef) "); - } catch (Exception | Error e) { - IntegrationTestTools.display("Wrong definition", propDef); - throw e; - } - } - - PrismPropertyDefinition objPropDef = object.getDefinition().findPropertyDefinition(path); - assertNotNull("No definition of property "+path+" in object "+object, objPropDef); - try { - validator.validate(objPropDef, path.toString()+" (objectDef) "); - } catch (Exception | Error e) { - IntegrationTestTools.display("Wrong definition", objPropDef); - throw e; - } - - } - - private void assertContainer(PrismObject object, ItemName contName, - Validator> validator, boolean valueExpected) throws Exception { - PrismContainer container = object.findContainer(contName); - if (valueExpected) { - assertNotNull("No container "+contName+" in "+object, container); - PrismContainerDefinition contDef = container.getDefinition(); - assertNotNull("No definition in container "+contName, contDef); - validator.validate(contDef, contName.toString()); - } else { - assertNull("Unexpected container "+contName+" in "+object+": "+container, container); - } - - PrismContainerDefinition objContDef = object.getDefinition().findContainerDefinition(contName); - assertNotNull("No definition of container "+contName+" in object "+object, objContDef); - validator.validate(objContDef, contName.toString()); - } - - private void assertUntouchedUserDefinition() { - // WHEN - PrismObjectDefinition userDefinition = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class); - - - // THEN - - PrismPropertyDefinition descriptionDef = userDefinition.findPropertyDefinition(UserType.F_DESCRIPTION); - assertNotNull("No definition for description in user", descriptionDef); - assertEquals("Wrong description displayName", "ObjectType.description", descriptionDef.getDisplayName()); - assertTrue("description not readable", descriptionDef.canRead()); - assertTrue("description not creatable", descriptionDef.canAdd()); - assertTrue("description not modifiable", descriptionDef.canModify()); - - PrismPropertyDefinition additionalNameDef = userDefinition.findPropertyDefinition(UserType.F_ADDITIONAL_NAME); - assertNotNull("No definition for additionalName in user", additionalNameDef); - assertEquals("Wrong additionalName displayName", "UserType.additionalName", additionalNameDef.getDisplayName()); - assertTrue("additionalName not readable", additionalNameDef.canRead()); - assertTrue("additionalName not creatable", additionalNameDef.canAdd()); - assertTrue("additionalName not modifiable", additionalNameDef.canModify()); - - PrismPropertyDefinition costCenterDef = userDefinition.findPropertyDefinition(UserType.F_COST_CENTER); - assertNotNull("No definition for costCenter in user", costCenterDef); - assertEquals("Wrong costCenter displayOrder", (Integer)420, costCenterDef.getDisplayOrder()); - assertTrue("costCenter not readable", costCenterDef.canRead()); - assertTrue("costCenter not creatable", costCenterDef.canAdd()); - assertTrue("costCenter not modifiable", costCenterDef.canModify()); - PrismReferenceValue valueEnumerationRef = costCenterDef.getValueEnumerationRef(); - assertNull("valueEnumerationRef for costCente sneaked in", valueEnumerationRef); - - PrismPropertyDefinition preferredLanguageDef = userDefinition.findPropertyDefinition(UserType.F_PREFERRED_LANGUAGE); - assertNotNull("No definition for preferredLanguage in user", preferredLanguageDef); - assertEquals("Wrong preferredLanguage displayName", "FocusType.preferredLanguage", preferredLanguageDef.getDisplayName()); - assertTrue("preferredLanguage not readable", preferredLanguageDef.canRead()); - assertTrue("preferredLanguage not creatable", preferredLanguageDef.canAdd()); - assertTrue("preferredLanguage not modifiable", preferredLanguageDef.canModify()); - valueEnumerationRef = preferredLanguageDef.getValueEnumerationRef(); - assertNotNull("valueEnumerationRef for preferredLanguage missing", valueEnumerationRef); - assertEquals("wrong OID in valueEnumerationRef for preferredLanguage missing", - SystemObjectsType.LOOKUP_LANGUAGES.value(), valueEnumerationRef.getOid()); - - PrismContainerDefinition credentialsDef = userDefinition.findContainerDefinition(UserType.F_CREDENTIALS); - assertNotNull("No definition for credentials in user", credentialsDef); - assertTrue("Credentials not readable", credentialsDef.canRead()); - assertTrue("Credentials not creatable", credentialsDef.canAdd()); - assertTrue("Credentials not modifiable", credentialsDef.canModify()); - - ItemPath passwdValPath = ItemPath.create(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE); - PrismPropertyDefinition passwdValDef = userDefinition.findPropertyDefinition(passwdValPath); - assertNotNull("No definition for "+passwdValPath+" in user", passwdValDef); - assertTrue("Password not readable", passwdValDef.canRead()); - assertTrue("Password not creatable", passwdValDef.canAdd()); - assertTrue("Password not modifiable", passwdValDef.canModify()); - - } -} +/* + * Copyright (c) 2010-2017 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ +package com.evolveum.midpoint.model.intest.gensync; + +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertNotNull; +import static org.testng.AssertJUnit.assertNull; +import static org.testng.AssertJUnit.assertTrue; + +import java.io.File; +import java.util.Collection; +import java.util.List; + +import com.evolveum.midpoint.prism.delta.DeltaFactory; +import com.evolveum.midpoint.prism.path.ItemName; +import com.evolveum.midpoint.prism.path.ItemPath; +import com.evolveum.midpoint.schema.*; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; + +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.DirtiesContext.ClassMode; +import org.springframework.test.context.ContextConfiguration; +import org.testng.AssertJUnit; +import org.testng.annotations.Test; + +import com.evolveum.midpoint.model.api.ModelExecuteOptions; +import com.evolveum.midpoint.prism.Containerable; +import com.evolveum.midpoint.prism.PrismContainer; +import com.evolveum.midpoint.prism.PrismContainerDefinition; +import com.evolveum.midpoint.prism.PrismContainerValue; +import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.prism.PrismObjectDefinition; +import com.evolveum.midpoint.prism.PrismProperty; +import com.evolveum.midpoint.prism.PrismPropertyDefinition; +import com.evolveum.midpoint.prism.PrismReferenceValue; +import com.evolveum.midpoint.prism.delta.ObjectDelta; +import com.evolveum.midpoint.prism.polystring.PolyString; +import com.evolveum.midpoint.prism.util.PrismAsserts; +import com.evolveum.midpoint.prism.util.PrismTestUtil; +import com.evolveum.midpoint.schema.constants.SchemaConstants; +import com.evolveum.midpoint.schema.processor.ResourceAttributeContainerDefinition; +import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.schema.util.MiscSchemaUtil; +import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.IntegrationTestTools; +import com.evolveum.midpoint.test.util.TestUtil; +import com.evolveum.midpoint.util.Validator; +import com.evolveum.midpoint.util.exception.CommunicationException; +import com.evolveum.midpoint.util.exception.ConfigurationException; +import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; +import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; +import com.evolveum.midpoint.util.exception.ObjectNotFoundException; +import com.evolveum.midpoint.util.exception.SchemaException; +import com.evolveum.midpoint.util.exception.SecurityViolationException; +import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ImportOptionsType; +import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; + +/** + * @author semancik + * + */ +@ContextConfiguration(locations = {"classpath:ctx-model-intest-test-main.xml"}) +@DirtiesContext(classMode = ClassMode.AFTER_CLASS) +public class TestEditSchema extends AbstractGenericSyncTest { + + public static final File LOOKUP_LANGUAGES_REPLACEMENT_FILE = new File(TEST_DIR, "lookup-languages-replacement.xml"); + + @Override + public void initSystem(Task initTask, OperationResult initResult) throws Exception { + super.initSystem(initTask, initResult); + + setDefaultUserTemplate(USER_TEMPLATE_COMPLEX_OID); + importObjectFromFile(ROLE_PRISONER_FILE); + importObjectFromFile(USER_OTIS_FILE); + + rememberSteadyResources(); + } + + @Test + public void test100LookupLanguagesGet() throws Exception { + final String TEST_NAME="test100LookupLanguagesGet"; + displayTestTitle(TEST_NAME); + + // GIVEN + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + // WHEN + displayWhen(TEST_NAME); + PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, null, task, result); + + // THEN + displayThen(TEST_NAME); + result.computeStatus(); + TestUtil.assertSuccess(result); + + IntegrationTestTools.display("Languages", lookup); + + assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); + + PrismAsserts.assertEmptyAndIncomplete(lookup, LookupTableType.F_ROW); + + assertSteadyResources(); + } + + @Test + public void test102LookupLanguagesGetExclude() throws Exception { + final String TEST_NAME="test102LookupLanguagesGetExclude"; + displayTestTitle(TEST_NAME); + + // GIVEN + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + Collection> options = schemaHelper.getOperationOptionsBuilder() + .item(LookupTableType.F_ROW).dontRetrieve() + .build(); + + // WHEN + displayWhen(TEST_NAME); + PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, options, task, result); + + // THEN + displayThen(TEST_NAME); + result.computeStatus(); + TestUtil.assertSuccess(result); + + IntegrationTestTools.display("Languages", lookup); + + assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); + + PrismAsserts.assertEmptyAndIncomplete(lookup, LookupTableType.F_ROW); + + assertSteadyResources(); + } + + @Test + public void test110LookupLanguagesGetAll() throws Exception { + final String TEST_NAME="test110LookupLanguagesGetAll"; + displayTestTitle(TEST_NAME); + + // GIVEN + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + // WHEN + displayWhen(TEST_NAME); + PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); + + // THEN + displayThen(TEST_NAME); + result.computeStatus(); + TestUtil.assertSuccess(result); + checkLookupResult(lookup, new String[]{"en_US", "en", "English (US)"}, + new String[]{"en_PR", "en", "English (pirate)"}, + new String[]{"sk_SK", "sk", "Slovak"}, + new String[]{"tr_TR", "tr", "Turkish"}); + } + + @Test + public void test120LookupLanguagesGetByKeyExact() throws Exception { + final String TEST_NAME="test120LookupLanguagesGetByKeyExact"; + displayTestTitle(TEST_NAME); + + // GIVEN + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + // WHEN + displayWhen(TEST_NAME); + + GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() + .item(LookupTableType.F_ROW) + .retrieveQuery() + .item(LookupTableRowType.F_KEY) + .eq("sk_SK") + .end(); + PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); + + // THEN + displayThen(TEST_NAME); + result.computeStatus(); + TestUtil.assertSuccess(result); + checkLookupResult(lookup, new String[] { "sk_SK", "sk", "Slovak" }); + } + + @Test + public void test121LookupLanguagesGetByKeyStartingWith() throws Exception { + final String TEST_NAME="test121LookupLanguagesGetByKeyStartingWith"; + displayTestTitle(TEST_NAME); + + // GIVEN + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + // WHEN + displayWhen(TEST_NAME); + + GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() + .item(LookupTableType.F_ROW) + .retrieveQuery() + .item(LookupTableRowType.F_KEY) + .startsWith("e") + .end(); + PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); + + // THEN + displayThen(TEST_NAME); + result.computeStatus(); + TestUtil.assertSuccess(result); + checkLookupResult(lookup, new String[]{"en_US", "en", "English (US)"}, + new String[]{"en_PR", "en", "English (pirate)"}); + } + + @Test + public void test122LookupLanguagesGetByKeyContaining() throws Exception { + final String TEST_NAME="test122LookupLanguagesGetByKeyContaining"; + displayTestTitle(TEST_NAME); + + // GIVEN + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + // WHEN + displayWhen(TEST_NAME); + + GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() + .item(LookupTableType.F_ROW) + .retrieveQuery() + .item(LookupTableRowType.F_KEY) + .contains("r") + .end(); + PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); + + // THEN + displayThen(TEST_NAME); + result.computeStatus(); + TestUtil.assertSuccess(result); + checkLookupResult(lookup, new String[]{"tr_TR", "tr", "Turkish"}); + } + + @Test + public void test123LookupLanguagesGetByKeyContainingWithPaging() throws Exception { + final String TEST_NAME="test123LookupLanguagesGetByKeyContainingWithPaging"; + displayTestTitle(TEST_NAME); + + // GIVEN + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + // WHEN + displayWhen(TEST_NAME); + + GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() + .item(LookupTableType.F_ROW) + .retrieveQuery() + .item(LookupTableRowType.F_KEY) + .contains("_") + .offset(2) + .maxSize(1) + .asc(LookupTableRowType.F_KEY) + .end(); + PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); + + // THEN + displayThen(TEST_NAME); + result.computeStatus(); + TestUtil.assertSuccess(result); + checkLookupResult(lookup, new String[] { "sk_SK", "sk", "Slovak" }); + } + + @Test + public void test124LookupLanguagesGetByKeyContainingReturningNothing() throws Exception { + final String TEST_NAME="test124LookupLanguagesGetByKeyContainingReturningNothing"; + displayTestTitle(TEST_NAME); + + // GIVEN + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + // WHEN + displayWhen(TEST_NAME); + + GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() + .item(LookupTableType.F_ROW) + .retrieveQuery() + .item(LookupTableRowType.F_KEY) + .contains("xyz") + .end(); + PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); + + // THEN + displayThen(TEST_NAME); + result.computeStatus(); + TestUtil.assertSuccess(result); + IntegrationTestTools.display("Languages", lookup); + + assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); + + PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); + assertTrue("Unexpected content in tableContainer", tableContainer == null || tableContainer.size() == 0); + + assertSteadyResources(); + } + + @Test + public void test130LookupLanguagesGetByValueExact() throws Exception { + final String TEST_NAME="test130LookupLanguagesGetByValueExact"; + displayTestTitle(TEST_NAME); + + // GIVEN + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + // WHEN + displayWhen(TEST_NAME); + + GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() + .item(LookupTableType.F_ROW) + .retrieveQuery() + .item(LookupTableRowType.F_VALUE) + .eq("sk") + .end(); + PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); + + // THEN + displayThen(TEST_NAME); + result.computeStatus(); + TestUtil.assertSuccess(result); + checkLookupResult(lookup, new String[] { "sk_SK", "sk", "Slovak" }); + } + + /** + * Disabled because it's not clear how to treat polystrings in searches. + * + */ + @Test + public void test131LookupLanguagesGetByLabelStartingWith() throws Exception { + final String TEST_NAME="test131LookupLanguagesGetByLabelStartingWith"; + displayTestTitle(TEST_NAME); + + // GIVEN + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + // WHEN + displayWhen(TEST_NAME); + + String fragment = "Eng"; + GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() + .item(LookupTableType.F_ROW) + .retrieveQuery() + .item(LookupTableRowType.F_LABEL) + .startsWith(fragment) + .end(); + PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); + + // THEN + displayThen(TEST_NAME); + result.computeStatus(); + TestUtil.assertSuccess(result); + checkLookupResult(lookup, new String[]{"en_US", "en", "English (US)"}, + new String[]{"en_PR", "en", "English (pirate)"}); + } + + @Test + public void test133LookupLanguagesGetByValueContainingWithPaging() throws Exception { + final String TEST_NAME="test123LookupLanguagesGetByKeyContainingWithPaging"; + displayTestTitle(TEST_NAME); + + // GIVEN + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + // WHEN + displayWhen(TEST_NAME); + + GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() + .item(LookupTableType.F_ROW) + .retrieveQuery() + .item(LookupTableRowType.F_VALUE) + .contains("n") + .offset(0) + .maxSize(1) + .desc(LookupTableRowType.F_LABEL) // using sorting key other than the one used in search + .end(); + PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); + + // THEN + displayThen(TEST_NAME); + result.computeStatus(); + TestUtil.assertSuccess(result); + checkLookupResult(lookup, new String[] { "en_US", "en", "English (US)" }); + } + + /** + * This test is disabled because id-based searching is not available yet (and it's unclear if it would be eventually necessary). + */ + @Test(enabled = false) + public void test140LookupLanguagesGetByIdExisting() throws Exception { + final String TEST_NAME="test140LookupLanguagesGetByIdExisting"; + displayTestTitle(TEST_NAME); + + // GIVEN + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + // WHEN + displayWhen(TEST_NAME); + + Collection> options = SelectorOptions.createCollection( + prismContext.path(LookupTableType.F_ROW, 1L), + GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE)); + PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, options, task, result); + + // THEN + displayThen(TEST_NAME); + result.computeStatus(); + TestUtil.assertSuccess(result); + checkLookupResult(lookup, new String[] { "en_US", "en", "English (US)" }); + } + + + private void checkLookupResult(PrismObject lookup, String[]... tuples) { + IntegrationTestTools.display("Languages", lookup); + + assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); + + PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); + assertNotNull("Table container missing", tableContainer); + assertEquals("Unexpected table container size", tuples.length, tableContainer.size()); + + for (String[] tuple : tuples) { + assertLookupRow(tableContainer, tuple[0], tuple[1], tuple[2]); + } + assertSteadyResources(); + } + + + @Test + public void test150LookupLanguagesAddRowFull() throws Exception { + final String TEST_NAME="test150LookupLanguagesAddRow"; + displayTestTitle(TEST_NAME); + + // GIVEN + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + LookupTableRowType row = new LookupTableRowType(); + row.setKey("gi_GI"); + row.setValue("gi"); + row.setLabel(PrismTestUtil.createPolyStringType("Gibberish")); + ObjectDelta delta = prismContext.deltaFactory().object().createModificationAddContainer(LookupTableType.class, + LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); + + // WHEN + displayWhen(TEST_NAME); + modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); + + // THEN + displayThen(TEST_NAME); + result.computeStatus(); + TestUtil.assertSuccess(result); + + PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); + + result.computeStatus(); + TestUtil.assertSuccess(result); + + IntegrationTestTools.display("Languages", lookup); + + assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); + + PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); + assertNotNull("Table container missing", tableContainer); + assertEquals("Unexpected table container size", 5, tableContainer.size()); + + assertLookupRow(tableContainer, "en_US", "en", "English (US)"); + assertLookupRow(tableContainer, "en_PR", "en", "English (pirate)"); + assertLookupRow(tableContainer, "sk_SK", "sk", "Slovak"); + assertLookupRow(tableContainer, "tr_TR", "tr", "Turkish"); + + assertLookupRow(tableContainer, "gi_GI", "gi", "Gibberish"); + + assertSteadyResources(); + } + + @Test + public void test152LookupLanguagesAddRowKeyLabel() throws Exception { + final String TEST_NAME="test152LookupLanguagesAddRowKeyLabel"; + displayTestTitle(TEST_NAME); + + // GIVEN + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + LookupTableRowType row = new LookupTableRowType(); + row.setKey("gi_GO"); + row.setLabel(PrismTestUtil.createPolyStringType("Gobbledygook")); + ObjectDelta delta = prismContext.deltaFactory().object().createModificationAddContainer(LookupTableType.class, + LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); + + // WHEN + displayWhen(TEST_NAME); + modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); + + // THEN + displayThen(TEST_NAME); + result.computeStatus(); + TestUtil.assertSuccess(result); + + PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); + + result.computeStatus(); + TestUtil.assertSuccess(result); + + IntegrationTestTools.display("Languages", lookup); + + assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); + + PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); + assertNotNull("Table container missing", tableContainer); + assertEquals("Unexpected table container size", 6, tableContainer.size()); + + assertLookupRow(tableContainer, "en_US", "en", "English (US)"); + assertLookupRow(tableContainer, "en_PR", "en", "English (pirate)"); + assertLookupRow(tableContainer, "sk_SK", "sk", "Slovak"); + assertLookupRow(tableContainer, "tr_TR", "tr", "Turkish"); + assertLookupRow(tableContainer, "gi_GI", "gi", "Gibberish"); + + assertLookupRow(tableContainer, "gi_GO", null, "Gobbledygook"); + + assertSteadyResources(); + } + + @Test + public void test154LookupLanguagesAddRowKeyValue() throws Exception { + final String TEST_NAME="test154LookupLanguagesAddRowKeyValue"; + displayTestTitle(TEST_NAME); + + // GIVEN + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + LookupTableRowType row = new LookupTableRowType(); + row.setKey("gi_HU"); + row.setValue("gi"); + ObjectDelta delta = prismContext.deltaFactory().object().createModificationAddContainer(LookupTableType.class, + LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); + + // WHEN + displayWhen(TEST_NAME); + modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); + + // THEN + displayThen(TEST_NAME); + result.computeStatus(); + TestUtil.assertSuccess(result); + + PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); + + result.computeStatus(); + TestUtil.assertSuccess(result); + + IntegrationTestTools.display("Languages", lookup); + + assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); + + PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); + assertNotNull("Table container missing", tableContainer); + assertEquals("Unexpected table container size", 7, tableContainer.size()); + + assertLookupRow(tableContainer, "en_US", "en", "English (US)"); + assertLookupRow(tableContainer, "en_PR", "en", "English (pirate)"); + assertLookupRow(tableContainer, "sk_SK", "sk", "Slovak"); + assertLookupRow(tableContainer, "tr_TR", "tr", "Turkish"); + assertLookupRow(tableContainer, "gi_GI", "gi", "Gibberish"); + assertLookupRow(tableContainer, "gi_GO", null, "Gobbledygook"); + + assertLookupRow(tableContainer, "gi_HU", "gi", null); + + assertSteadyResources(); + } + + @Test + public void test156LookupLanguagesAddRowExistingKey() throws Exception { + final String TEST_NAME="test156LookupLanguagesAddRowExistingKey"; + displayTestTitle(TEST_NAME); + + // GIVEN + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + LookupTableRowType row = new LookupTableRowType(); + row.setKey("gi_HU"); + row.setValue("gi"); + row.setLabel(PrismTestUtil.createPolyStringType("Humbug")); + ObjectDelta delta = prismContext.deltaFactory().object().createModificationAddContainer(LookupTableType.class, + LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); + + // WHEN + displayWhen(TEST_NAME); + boolean exception = false; + try { + modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); + } catch (ObjectAlreadyExistsException ex) { + exception = true; + } + AssertJUnit.assertFalse(exception); // as per description in https://wiki.evolveum.com/display/midPoint/Development+with+LookupTable + + // THEN + displayThen(TEST_NAME); + result.computeStatus(); + TestUtil.assertSuccess(result); + + task = createTask(TEST_NAME); + result = task.getResult(); + PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); + + result.computeStatus(); + TestUtil.assertSuccess(result); + + IntegrationTestTools.display("Languages", lookup); + + assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); + + PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); + assertNotNull("Table container missing", tableContainer); + assertEquals("Unexpected table container size", 7, tableContainer.size()); + + assertLookupRow(tableContainer, "en_US", "en", "English (US)"); + assertLookupRow(tableContainer, "en_PR", "en", "English (pirate)"); + assertLookupRow(tableContainer, "sk_SK", "sk", "Slovak"); + assertLookupRow(tableContainer, "tr_TR", "tr", "Turkish"); + assertLookupRow(tableContainer, "gi_GI", "gi", "Gibberish"); + assertLookupRow(tableContainer, "gi_GO", null, "Gobbledygook"); + + assertLookupRow(tableContainer, "gi_HU", "gi", "Humbug"); + + assertSteadyResources(); + } + + /** + * @throws Exception + */ + @Test + public void test162LookupLanguagesDeleteRowFullNoId() throws Exception { + final String TEST_NAME="test162LookupLanguagesDeleteRowFullNoId"; + displayTestTitle(TEST_NAME); + + // GIVEN + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + LookupTableRowType row = new LookupTableRowType(); + row.setKey("sk_SK"); + row.setValue("sk"); + row.setLabel(PrismTestUtil.createPolyStringType("Slovak")); + ObjectDelta delta = prismContext.deltaFactory().object().createModificationDeleteContainer(LookupTableType.class, + LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); + + // WHEN + displayWhen(TEST_NAME); + modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); + + // THEN + displayThen(TEST_NAME); + result.computeStatus(); + TestUtil.assertSuccess(result); + + PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); + + result.computeStatus(); + TestUtil.assertSuccess(result); + + IntegrationTestTools.display("Languages", lookup); + + assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); + + PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); + assertNotNull("Table container missing", tableContainer); + assertEquals("Unexpected table container size", 6, tableContainer.size()); + + assertLookupRow(tableContainer, "en_US", "en", "English (US)"); + assertLookupRow(tableContainer, "en_PR", "en", "English (pirate)"); + assertLookupRow(tableContainer, "tr_TR", "tr", "Turkish"); + assertLookupRow(tableContainer, "gi_GI", "gi", "Gibberish"); + assertLookupRow(tableContainer, "gi_GO", null, "Gobbledygook"); + assertLookupRow(tableContainer, "gi_HU", "gi", "Humbug"); + + assertSteadyResources(); + } + + @Test + public void test164LookupLanguagesDeleteRowFullId() throws Exception { + final String TEST_NAME="test164LookupLanguagesDeleteRowFullId"; + displayTestTitle(TEST_NAME); + + // GIVEN + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + LookupTableRowType row = new LookupTableRowType(); + row.setKey("en_US"); + row.setValue("en"); + row.setLabel(PrismTestUtil.createPolyStringType("English (US)")); + row.setId(1L); + ObjectDelta delta = prismContext.deltaFactory().object().createModificationDeleteContainer(LookupTableType.class, + LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); + + // WHEN + displayWhen(TEST_NAME); + executeChanges(delta, null, task, result); + + // THEN + displayThen(TEST_NAME); + assertSuccess(result); + + PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); + + assertSuccess(result); + + display("Languages", lookup); + + assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); + + PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); + assertNotNull("Table container missing", tableContainer); + assertEquals("Unexpected table container size", 5, tableContainer.size()); + + assertLookupRow(tableContainer, "en_PR", "en", "English (pirate)"); + assertLookupRow(tableContainer, "tr_TR", "tr", "Turkish"); + assertLookupRow(tableContainer, "gi_GI", "gi", "Gibberish"); + assertLookupRow(tableContainer, "gi_GO", null, "Gobbledygook"); + assertLookupRow(tableContainer, "gi_HU", "gi", "Humbug"); + + assertSteadyResources(); + } + + @Test + public void test166LookupLanguagesDeleteRowIdOnly() throws Exception { + final String TEST_NAME="test166LookupLanguagesDeleteRowIdOnly"; + displayTestTitle(TEST_NAME); + + // GIVEN + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + LookupTableRowType row = new LookupTableRowType(); + row.setId(2L); + ObjectDelta delta = prismContext.deltaFactory().object().createModificationDeleteContainer(LookupTableType.class, + LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); + + // WHEN + displayWhen(TEST_NAME); + executeChanges(delta, null, task, result); + + // THEN + displayThen(TEST_NAME); + assertSuccess(result); + + PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); + + assertSuccess(result); + + display("Languages", lookup); + + assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); + + PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); + assertNotNull("Table container missing", tableContainer); + assertEquals("Unexpected table container size", 4, tableContainer.size()); + + assertLookupRow(tableContainer, "gi_GI", "gi", "Gibberish"); + assertLookupRow(tableContainer, "gi_GO", null, "Gobbledygook"); + assertLookupRow(tableContainer, "gi_HU", "gi", "Humbug"); + assertLookupRow(tableContainer, "tr_TR", "tr", "Turkish"); + + assertSteadyResources(); + } + + @Test + public void test168LookupLanguagesDeleteRowByKey() throws Exception { + final String TEST_NAME="test168LookupLanguagesDeleteRowByKey"; + displayTestTitle(TEST_NAME); + + // GIVEN + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + LookupTableRowType row = new LookupTableRowType(); + row.setKey("gi_GI"); + ObjectDelta delta = prismContext.deltaFactory().object().createModificationDeleteContainer(LookupTableType.class, + LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); + + // WHEN + displayWhen(TEST_NAME); + modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); + + // THEN + displayThen(TEST_NAME); + assertSuccess(result); + + PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); + + assertSuccess(result); + + IntegrationTestTools.display("Languages", lookup); + + assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); + + PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); + assertNotNull("Table container missing", tableContainer); + assertEquals("Unexpected table container size", 3, tableContainer.size()); + + assertLookupRow(tableContainer, "gi_GO", null, "Gobbledygook"); + assertLookupRow(tableContainer, "gi_HU", "gi", "Humbug"); + assertLookupRow(tableContainer, "tr_TR", "tr", "Turkish"); + + assertSteadyResources(); + } + + @Test + public void test170LookupLanguagesReplaceRows() throws Exception { + final String TEST_NAME="test170LookupLanguagesReplaceRows"; + displayTestTitle(TEST_NAME); + + // GIVEN + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + LookupTableRowType row1 = new LookupTableRowType(); + row1.setKey("ja_JA"); + row1.setValue("ja"); + row1.setLabel(PrismTestUtil.createPolyStringType("Jabber")); + + LookupTableRowType row2 = new LookupTableRowType(); + row2.setKey("ja_MJ"); + row2.setValue("ja"); + row2.setLabel(PrismTestUtil.createPolyStringType("Mumbojumbo")); + + LookupTableRowType row3 = new LookupTableRowType(); + row3.setKey("en_PR"); // existing key + row3.setValue("en1"); + row3.setLabel(PrismTestUtil.createPolyStringType("English (pirate1)")); + + ObjectDelta delta = prismContext.deltaFactory().object().createModificationReplaceContainer(LookupTableType.class, + LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row1, row2, row3); + + // WHEN + displayWhen(TEST_NAME); + modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); + + // THEN + displayThen(TEST_NAME); + result.computeStatus(); + TestUtil.assertSuccess(result); + + PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); + + result.computeStatus(); + TestUtil.assertSuccess(result); + + IntegrationTestTools.display("Languages", lookup); + + assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); + + PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); + assertNotNull("Table container missing", tableContainer); + assertEquals("Unexpected table container size", 3, tableContainer.size()); + + assertLookupRow(tableContainer, "ja_JA", "ja", "Jabber"); + assertLookupRow(tableContainer, "ja_MJ", "ja", "Mumbojumbo"); + assertLookupRow(tableContainer, "en_PR", "en1", "English (pirate1)"); + + assertSteadyResources(); + } + + @Test + public void test180LookupLanguagesReplaceObject() throws Exception { + final String TEST_NAME="test180LookupLanguagesReplaceObject"; + displayTestTitle(TEST_NAME); + + // GIVEN + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + PrismObject replacement = PrismTestUtil.parseObject(LOOKUP_LANGUAGES_REPLACEMENT_FILE); + ObjectDelta delta = DeltaFactory.Object.createAddDelta(replacement); + + // WHEN + displayWhen(TEST_NAME); + ModelExecuteOptions options = ModelExecuteOptions.createOverwrite(); + options.setRaw(true); + modelService.executeChanges(MiscSchemaUtil.createCollection(delta), options, task, result); + + // THEN + displayThen(TEST_NAME); + result.computeStatus(); + TestUtil.assertSuccess(result); + + PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); + + result.computeStatus(); + TestUtil.assertSuccess(result); + + IntegrationTestTools.display("Languages", lookup); + + assertEquals("Wrong lang lookup name", "Languages Replaced", lookup.asObjectable().getName().getOrig()); + + PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); + assertNotNull("Table container missing", tableContainer); + assertEquals("Unexpected table container size", 1, tableContainer.size()); + + assertLookupRow(tableContainer, "fr_FR", "fr", "Français"); + assertSteadyResources(); + } + + @Test + public void test182LookupLanguagesReimport() throws Exception { + final String TEST_NAME="test182LookupLanguagesReimport"; + displayTestTitle(TEST_NAME); + + // GIVEN + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + ImportOptionsType options = new ImportOptionsType(); + options.setOverwrite(true); + options.setKeepOid(true); + + // WHEN + displayWhen(TEST_NAME); + modelService.importObjectsFromFile(LOOKUP_LANGUAGES_FILE, options, task, result); + + // THEN + displayThen(TEST_NAME); + result.computeStatus(); + TestUtil.assertSuccess(result); + + PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); + + result.computeStatus(); + TestUtil.assertSuccess(result); + + IntegrationTestTools.display("Languages", lookup); + + assertEquals("Wrong lang lookup name", "Languages", lookup.asObjectable().getName().getOrig()); + + checkLookupResult(lookup, new String[]{"en_US", "en", "English (US)"}, + new String[]{"en_PR", "en", "English (pirate)"}, + new String[]{"sk_SK", "sk", "Slovak"}, + new String[]{"tr_TR", "tr", "Turkish"}); + + assertSteadyResources(); + } + + + private void assertLookupRow(PrismContainer tableContainer, String key, String value, + String label) { + for (PrismContainerValue row: tableContainer.getValues()) { + LookupTableRowType rowType = row.asContainerable(); + if (key.equals(rowType.getKey())) { + assertEquals("Wrong value for key "+key, value, rowType.getValue()); + if (label == null) { + assertNull("Unexpected label for key "+key+": "+rowType.getLabel(), rowType.getLabel()); + } else { + assertEquals("Wrong label for key "+key, PrismTestUtil.createPolyStringType(label), rowType.getLabel()); + } + return; + } + } + AssertJUnit.fail("Row with key '"+key+"' was not found in lookup table"); + } + + private PrismObject getLookupTableAll(String oid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() + .item(LookupTableType.F_ROW).retrieve(); + return modelService.getObject(LookupTableType.class, oid, optionsBuilder.build(), task, result); + } + + @Test + public void test200EditSchemaUser() throws Exception { + final String TEST_NAME="test200EditSchemaUser"; + displayTestTitle(TEST_NAME); + + // GIVEN + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + PrismObjectDefinition userDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class); + PrismObject user = userDef.instantiate(); + + // WHEN + displayWhen(TEST_NAME); + PrismObjectDefinition editDef = getEditObjectDefinition(user); + + // THEN + displayThen(TEST_NAME); + + + PrismAsserts.assertEmphasized(editDef, UserType.F_NAME, true); + PrismAsserts.assertEmphasized(editDef, UserType.F_GIVEN_NAME, false); + PrismAsserts.assertEmphasized(editDef, UserType.F_FAMILY_NAME, true); + PrismAsserts.assertEmphasized(editDef, UserType.F_FULL_NAME, true); + PrismAsserts.assertEmphasized(editDef, UserType.F_DESCRIPTION, false); + + PrismPropertyDefinition additionalNameDef = editDef.findPropertyDefinition(UserType.F_ADDITIONAL_NAME); + assertNotNull("No definition for additionalName in user", additionalNameDef); + assertEquals("Wrong additionalName displayName", "Middle Name", additionalNameDef.getDisplayName()); + assertEquals("Wrong additionalName help", "Just a plain old middle name", additionalNameDef.getHelp()); // MID-5736 + assertTrue("additionalName not readable", additionalNameDef.canRead()); + PrismAsserts.assertEmphasized(additionalNameDef, false); + + PrismPropertyDefinition costCenterDef = editDef.findPropertyDefinition(UserType.F_COST_CENTER); + assertNotNull("No definition for costCenter in user", costCenterDef); + assertEquals("Wrong costCenter displayOrder", (Integer)123, costCenterDef.getDisplayOrder()); + assertTrue("costCenter not readable", costCenterDef.canRead()); + PrismAsserts.assertEmphasized(costCenterDef, true); + FormItemValidationType validationAnnotation = costCenterDef.getAnnotation(ItemRefinedDefinitionType.F_VALIDATION); + assertNotNull("No validation annotation in costCenter", validationAnnotation); + ExpressionType validationExpression = validationAnnotation.getServer().get(0).getExpression(); + assertNotNull("No validation expression annotation in costCenter", validationExpression); + + // This has overridden lookup def in object template + PrismPropertyDefinition preferredLanguageDef = editDef.findPropertyDefinition(UserType.F_PREFERRED_LANGUAGE); + assertNotNull("No definition for preferredLanguage in user", preferredLanguageDef); + assertEquals("Wrong preferredLanguage displayName", "Language", preferredLanguageDef.getDisplayName()); + assertTrue("preferredLanguage not readable", preferredLanguageDef.canRead()); + PrismReferenceValue valueEnumerationRef = preferredLanguageDef.getValueEnumerationRef(); + assertNotNull("No valueEnumerationRef for preferredLanguage", valueEnumerationRef); + assertEquals("Wrong valueEnumerationRef OID for preferredLanguage", LOOKUP_LANGUAGES_OID, valueEnumerationRef.getOid()); + + // This has default lookup def in schema + PrismPropertyDefinition timezoneDef = editDef.findPropertyDefinition(UserType.F_TIMEZONE); + assertNotNull("No definition for timezone in user", timezoneDef); + assertEquals("Wrong timezone displayName", "FocusType.timezone", timezoneDef.getDisplayName()); + assertTrue("timezone not readable", timezoneDef.canRead()); + valueEnumerationRef = timezoneDef.getValueEnumerationRef(); + assertNotNull("No valueEnumerationRef for timezone", valueEnumerationRef); + assertEquals("Wrong valueEnumerationRef OID for timezone", SystemObjectsType.LOOKUP_TIMEZONES.value(), valueEnumerationRef.getOid()); + + // Deprecated. But deprecation flag in overridden in object template (MID-4680) + PrismPropertyDefinition employeeTypeDef = editDef.findPropertyDefinition(UserType.F_EMPLOYEE_TYPE); + assertNotNull("No definition for employeeType in user", employeeTypeDef); + assertEquals("Wrong deprecation flag for employeeType", false, employeeTypeDef.isDeprecated()); + + PrismContainerDefinition credentialsDef = editDef.findContainerDefinition(UserType.F_CREDENTIALS); + assertNotNull("No definition for credentials in user", credentialsDef); + assertTrue("Credentials not readable", credentialsDef.canRead()); + + ItemPath passwdValPath = ItemPath.create(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE); + PrismPropertyDefinition passwdValDef = editDef.findPropertyDefinition(passwdValPath); + assertNotNull("No definition for "+passwdValPath+" in user", passwdValDef); + assertTrue("Password not readable", passwdValDef.canRead()); + + assertSteadyResources(); + } + + @Test + public void test210UserDefinition() throws Exception { + final String TEST_NAME="test210UserDefinition"; + displayTestTitle(TEST_NAME); + + // GIVEN + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + // WHEN + displayWhen(TEST_NAME); + PrismObject user = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result); + + // THEN + displayThen(TEST_NAME); + result.computeStatus(); + TestUtil.assertSuccess(result); + + assertPropertyValues(user, UserType.F_ADDITIONAL_NAME, (propDef, name) -> { + assertNotNull("No definition for additionalName in user", propDef); + assertEquals("Wrong additionalName displayName", "Middle Name", propDef.getDisplayName()); + assertTrue("additionalName not readable", propDef.canRead()); + }, PrismTestUtil.createPolyString("Jackie")); + + + assertPropertyValues(user, UserType.F_COST_CENTER, (Validator>) (propDef, name) -> { + assertNotNull("No definition for costCenter in user", propDef); + assertEquals("Wrong costCenter displayOrder", (Integer)123, propDef.getDisplayOrder()); + assertTrue("costCenter not readable", propDef.canRead()); + }); + + assertPropertyValues(user, UserType.F_PREFERRED_LANGUAGE, + (Validator>) (propDef, name) -> { + assertNotNull("No definition for preferredLanguage in user", propDef); + assertEquals("Wrong preferredLanguage displayName", "Language", propDef.getDisplayName()); + assertTrue("preferredLanguage not readable", propDef.canRead()); + PrismReferenceValue valueEnumerationRef = propDef.getValueEnumerationRef(); + assertNotNull("No valueEnumerationRef for preferredLanguage", valueEnumerationRef); + assertEquals("Wrong valueEnumerationRef OID for preferredLanguage", LOOKUP_LANGUAGES_OID, valueEnumerationRef.getOid()); + }); + + assertContainer(user, UserType.F_CREDENTIALS, (credentialsDef, name) -> { + assertNotNull("No definition for credentials in user", credentialsDef); + assertTrue("Credentials not readable", credentialsDef.canRead()); + }, true); + + assertProperty(user, ItemPath.create(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE), + (propDef, name) -> { + assertTrue("Password not readable", propDef.canRead()); + }); + + assertSteadyResources(); + } + + /** + * Check that the user definition in schema registry was not ruined + * @throws Exception + */ + @Test + public void test211SchemaRegistryUntouched() throws Exception { + final String TEST_NAME="test211SchemaRegistryUntouched"; + displayTestTitle(TEST_NAME); + + assertUntouchedUserDefinition(); + assertSteadyResources(); + } + + /** + * Modify jack, see if the schema still applies. + */ + @Test + public void test213ModifiedUserJack() throws Exception { + final String TEST_NAME="test213ModifiedUserJack"; + displayTestTitle(TEST_NAME); + + // GIVEN + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + modifyObjectReplaceProperty(UserType.class, USER_JACK_OID, UserType.F_PREFERRED_LANGUAGE, task, result, "en_PR"); + + // WHEN + displayWhen(TEST_NAME); + PrismObject user = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result); + + // THEN + displayThen(TEST_NAME); + assertSuccess(result); + + assertPropertyValues(user, UserType.F_ADDITIONAL_NAME, (propDef, name) -> { + assertNotNull("No definition for additionalName in user", propDef); + assertEquals("Wrong additionalName displayName", "Middle Name", propDef.getDisplayName()); + assertTrue("additionalName not readable", propDef.canRead()); + }, PrismTestUtil.createPolyString("Jackie")); + + assertPropertyValues(user, UserType.F_COST_CENTER, (propDef, name) -> { + assertNotNull("No definition for costCenter in user", propDef); + assertEquals("Wrong costCenter displayOrder", (Integer)123, propDef.getDisplayOrder()); + assertTrue("costCenter not readable", propDef.canRead()); + },"G001"); // This is set by user template + + assertPropertyValues(user, UserType.F_PREFERRED_LANGUAGE, (propDef, name) -> { + assertNotNull("No definition for preferredLanguage in user", propDef); + assertEquals("Wrong preferredLanguage displayName", "Language", propDef.getDisplayName()); + assertTrue("preferredLanguage not readable", propDef.canRead()); + PrismReferenceValue valueEnumerationRef = propDef.getValueEnumerationRef(); + assertNotNull("No valueEnumerationRef for preferredLanguage", valueEnumerationRef); + assertEquals("Wrong valueEnumerationRef OID for preferredLanguage", LOOKUP_LANGUAGES_OID, valueEnumerationRef.getOid()); + }, "en_PR"); + + + assertContainer(user, UserType.F_CREDENTIALS, new Validator>() { + @Override + public void validate(PrismContainerDefinition credentialsDef, String name) + throws Exception { + assertNotNull("No definition for credentials in user", credentialsDef); + assertTrue("Credentials not readable", credentialsDef.canRead()); + } + + }, true); + + assertProperty(user, ItemPath.create(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE), + (Validator>) (propDef, name) -> assertTrue("Password not readable", propDef.canRead())); + + assertUntouchedUserDefinition(); + assertSteadyResources(); + } + + @Test + public void test240EditSchemaReconciliationTask() throws Exception { + final String TEST_NAME="test240EditSchemaReconciliationTask"; + displayTestTitle(TEST_NAME); + + // GIVEN + PrismObjectDefinition taskDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(TaskType.class); + PrismObject task = taskDef.instantiate(); + task.asObjectable() + .beginAssignment() + .targetRef(ARCHETYPE_TASK_RECONCILIATION_OID, ArchetypeType.COMPLEX_TYPE); + + display("Task before", task); + + // WHEN + displayWhen(TEST_NAME); + PrismObjectDefinition editDef = getEditObjectDefinition(task); + + // THEN + displayThen(TEST_NAME); + + assertObjectDefinition(editDef) + .container(ObjectType.F_EXTENSION) + .assertSize(2); + + assertSteadyResources(); + } + + @Test + public void test250EditSchemaRole() throws Exception { + final String TEST_NAME="test250EditSchemaRole"; + displayTestTitle(TEST_NAME); + + // GIVEN + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + PrismObjectDefinition roleDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(RoleType.class); + PrismObject role = roleDef.instantiate(); + + // WHEN + displayWhen(TEST_NAME); + PrismObjectDefinition editDef = getEditObjectDefinition(role); + + // THEN + displayThen(TEST_NAME); + + // TODO + PrismPropertyDefinition requestableDef = editDef.findPropertyDefinition(RoleType.F_REQUESTABLE); + assertNotNull("No definition for requestable in role", requestableDef); + assertEquals("Wrong requestable displayName", "Can request", requestableDef.getDisplayName()); + + assertSteadyResources(); + } + + @Test + public void test260EditShadowSchemaKindIntent() throws Exception { + final String TEST_NAME="test260EditShadowSchemaKindIntent"; + displayTestTitle(TEST_NAME); + + // GIVEN + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + ResourceShadowDiscriminator discr = new ResourceShadowDiscriminator(RESOURCE_DUMMY_OID, ShadowKindType.ACCOUNT, null, null, false); + + // WHEN + displayWhen(TEST_NAME); + PrismObjectDefinition editDef = modelInteractionService.getEditShadowDefinition(discr, AuthorizationPhaseType.REQUEST, task, result); + + // THEN + displayThen(TEST_NAME); + assertSuccess(result); + + PrismPropertyDefinition nameDef = editDef.findPropertyDefinition(ShadowType.F_NAME); + assertNotNull("No definition for name in shadow", nameDef); + assertEquals("Wrong shadow name displayName", "ObjectType.name", nameDef.getDisplayName()); + assertTrue("additionalName not readable", nameDef.canRead()); + + PrismPropertyDefinition attrFullNameDef = editDef.findPropertyDefinition(dummyResourceCtl.getAttributeFullnamePath()); + assertNotNull("No definition for fullname attribute in shadow", attrFullNameDef); + assertEquals("Wrong shadow fullname attribute displayName", "Full Name", attrFullNameDef.getDisplayName()); + assertTrue("additionalName not readable", attrFullNameDef.canRead()); + + PrismContainerDefinition identifiersDef = editDef.findContainerDefinition(ItemPath.create(ShadowType.F_ASSOCIATION, + ShadowAssociationType.F_IDENTIFIERS)); + StringBuilder message = new StringBuilder(); + message.append("Wrong type for ").append(ShadowAssociationType.F_IDENTIFIERS) + .append(", expected ResourceAttributeContainerDefinition but was ") + .append(identifiersDef == null ? null : identifiersDef.getClass().getName()) + .append("; "); + assertClassType(message.toString(), identifiersDef, ResourceAttributeContainerDefinition.class); + + + assertSteadyResources(); + } + + @Test + public void test261EditShadowSchemaObjectclass() throws Exception { + final String TEST_NAME="test261EditShadowSchemaObjectclass"; + displayTestTitle(TEST_NAME); + + // GIVEN + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + ResourceShadowDiscriminator discr = new ResourceShadowDiscriminator(RESOURCE_DUMMY_OID, dummyResourceCtl.getAccountObjectClassQName()); + IntegrationTestTools.display("Discr", discr); + + // WHEN + displayWhen(TEST_NAME); + PrismObjectDefinition editDef = modelInteractionService.getEditShadowDefinition(discr, AuthorizationPhaseType.REQUEST, task, result); + + // THEN + displayThen(TEST_NAME); + assertSuccess(result); + + PrismPropertyDefinition nameDef = editDef.findPropertyDefinition(ShadowType.F_NAME); + assertNotNull("No definition for name in shadow", nameDef); + assertEquals("Wrong shadow name displayName", "ObjectType.name", nameDef.getDisplayName()); + assertTrue("additionalName not readable", nameDef.canRead()); + + PrismPropertyDefinition attrFullNameDef = editDef.findPropertyDefinition(dummyResourceCtl.getAttributeFullnamePath()); + assertNotNull("No definition for fullname attribute in shadow", attrFullNameDef); + assertEquals("Wrong shadow fullname attribute displayName", "Full Name", attrFullNameDef.getDisplayName()); + assertTrue("additionalName not readable", attrFullNameDef.canRead()); + + assertSteadyResources(); + } + + @Test + public void test263EditShadowSchemaEmpty() throws Exception { + final String TEST_NAME="test263EditShadowSchemaEmpty"; + displayTestTitle(TEST_NAME); + + // GIVEN + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + ResourceShadowDiscriminator discr = new ResourceShadowDiscriminator(null, null); + IntegrationTestTools.display("Discr", discr); + + // WHEN + displayWhen(TEST_NAME); + PrismObjectDefinition editDef = modelInteractionService.getEditShadowDefinition(discr, AuthorizationPhaseType.REQUEST, task, result); + + // THEN + displayThen(TEST_NAME); + assertSuccess(result); + + PrismPropertyDefinition nameDef = editDef.findPropertyDefinition(ShadowType.F_NAME); + assertNotNull("No definition for name in shadow", nameDef); + assertEquals("Wrong shadow name displayName", "ObjectType.name", nameDef.getDisplayName()); + assertTrue("additionalName not readable", nameDef.canRead()); + + PrismPropertyDefinition attrFullNameDef = editDef.findPropertyDefinition(dummyResourceCtl.getAttributeFullnamePath()); + assertNull("Unexpected definition for fullname attribute in shadow", attrFullNameDef); + + assertSteadyResources(); + } + + @Test + public void test265EditShadowSchemaNull() throws Exception { + final String TEST_NAME="test265EditShadowSchemaNull"; + displayTestTitle(TEST_NAME); + + // GIVEN + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + // WHEN + displayWhen(TEST_NAME); + PrismObjectDefinition editDef = modelInteractionService.getEditShadowDefinition(null, AuthorizationPhaseType.REQUEST, task, result); + + // THEN + displayThen(TEST_NAME); + assertSuccess(result); + + PrismPropertyDefinition nameDef = editDef.findPropertyDefinition(ShadowType.F_NAME); + assertNotNull("No definition for name in shadow", nameDef); + assertEquals("Wrong shadow name displayName", "ObjectType.name", nameDef.getDisplayName()); + assertTrue("additionalName not readable", nameDef.canRead()); + + PrismPropertyDefinition attrFullNameDef = editDef.findPropertyDefinition(dummyResourceCtl.getAttributeFullnamePath()); + assertNull("Unexpected definition for fullname attribute in shadow", attrFullNameDef); + + assertSteadyResources(); + } + + /** + * MID-4660, MID-4491, MID-3581 + */ + @Test + public void test310CustomRelations() throws Exception { + final String TEST_NAME="test310CustomRelations"; + displayTestTitle(TEST_NAME); + + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + // WHEN + displayWhen(TEST_NAME); + List relations = modelInteractionService.getRelationDefinitions(); + + // THEN + displayThen(TEST_NAME); + display("Relations", relations); + assertRelationDef(relations, SchemaConstants.ORG_MANAGER, "RelationTypes.manager"); + assertRelationDef(relations, SchemaConstants.ORG_OWNER, "Master"); + assertRelationDef(relations, RELATION_PIRACY_CAPTAIN, "Captain"); + assertEquals("Unexpected number of relation definitions", 8, relations.size()); + } + + /** + * Login as Otis. Otis has a restricted authorizations. Check that schema is presented accordingly to + * these limitations. + */ + @Test + public void test800OtisEditSchemaUser() throws Exception { + final String TEST_NAME="test800OtisEditSchemaUser"; + displayTestTitle(TEST_NAME); + + // GIVEN + login(USER_OTIS_USERNAME); + + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + PrismObjectDefinition userDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class); + PrismObject user = userDef.instantiate(); + + // WHEN + displayWhen(TEST_NAME); + PrismObjectDefinition editDef = getEditObjectDefinition(user); + display("Otis edit schema", editDef); + + // THEN + displayThen(TEST_NAME); + + PrismPropertyDefinition nameDef = editDef.findPropertyDefinition(UserType.F_NAME); + assertNotNull("No definition for name in user", nameDef); + assertEquals("Wrong name displayName", "ObjectType.name", nameDef.getDisplayName()); + assertTrue("name not readable", nameDef.canRead()); + assertTrue("name is creatable", !nameDef.canAdd()); + assertTrue("name is modifiable", !nameDef.canModify()); + + PrismPropertyDefinition additionalNameDef = editDef.findPropertyDefinition(UserType.F_ADDITIONAL_NAME); + assertNotNull("No definition for additionalName in user", additionalNameDef); + assertEquals("Wrong additionalName displayName", "Middle Name", additionalNameDef.getDisplayName()); + assertTrue("additionalName is readable", !additionalNameDef.canRead()); + assertTrue("additionalName is creatable", !additionalNameDef.canAdd()); + assertTrue("additionalName not modifiable", additionalNameDef.canModify()); + + PrismPropertyDefinition costCenterDef = editDef.findPropertyDefinition(UserType.F_COST_CENTER); + assertNotNull("No definition for costCenter in user", costCenterDef); + assertEquals("Wrong costCenter displayOrder", (Integer)123, costCenterDef.getDisplayOrder()); + assertTrue("costCenter is readable", !costCenterDef.canRead()); + assertTrue("costCenter is creatable", !costCenterDef.canAdd()); + assertTrue("costCenter is modifiable", !costCenterDef.canModify()); + + PrismPropertyDefinition preferredLanguageDef = editDef.findPropertyDefinition(UserType.F_PREFERRED_LANGUAGE); + assertNotNull("No definition for preferredLanguage in user", preferredLanguageDef); + assertEquals("Wrong preferredLanguage displayName", "Language", preferredLanguageDef.getDisplayName()); + PrismReferenceValue valueEnumerationRef = preferredLanguageDef.getValueEnumerationRef(); + assertNotNull("No valueEnumerationRef for preferredLanguage", valueEnumerationRef); + assertEquals("Wrong valueEnumerationRef OID for preferredLanguage", LOOKUP_LANGUAGES_OID, valueEnumerationRef.getOid()); + assertTrue("preferredLanguage is readable", !preferredLanguageDef.canRead()); + assertTrue("preferredLanguage is creatable", !preferredLanguageDef.canAdd()); + assertTrue("preferredLanguage is modifiable", !preferredLanguageDef.canModify()); + + PrismContainerDefinition credentialsDef = editDef.findContainerDefinition(UserType.F_CREDENTIALS); + assertNotNull("No definition for credentials in user", credentialsDef); + assertTrue("Credentials is readable", !credentialsDef.canRead()); + assertTrue("Credentials is creatable", !credentialsDef.canAdd()); + assertTrue("Credentials is modifiable", !credentialsDef.canModify()); + + ItemPath passwdValPath = ItemPath.create(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE); + PrismPropertyDefinition passwdValDef = editDef.findPropertyDefinition(passwdValPath); + assertNotNull("No definition for "+passwdValPath+" in user", passwdValDef); + assertTrue("Password is readable", !passwdValDef.canRead()); + assertTrue("Password is creatable", !passwdValDef.canAdd()); + assertTrue("Password is modifiable", !passwdValDef.canModify()); + + assertUntouchedUserDefinition(); + assertSteadyResources(); + } + + @Test + public void test810OtisGetJack() throws Exception { + final String TEST_NAME="test810OtisGetJack"; + displayTestTitle(TEST_NAME); + + // GIVEN + login(USER_OTIS_USERNAME); + + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + // WHEN + displayWhen(TEST_NAME); + PrismObject user = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result); + + // THEN + displayThen(TEST_NAME); + result.computeStatus(); + TestUtil.assertSuccess(result); + + assertPropertyValues(user, UserType.F_NAME, new Validator>() { + @Override + public void validate(PrismPropertyDefinition propDef, String name) throws Exception { + assertNotNull("No definition for name in user", propDef); + assertEquals("Wrong name displayName", "ObjectType.name", propDef.getDisplayName()); + assertTrue(name+" not readable", propDef.canRead()); + assertTrue(name+" is creatable", !propDef.canAdd()); + assertTrue(name+" is modifiable", !propDef.canModify()); + } + }, PrismTestUtil.createPolyString("jack")); + + assertPropertyValues(user, UserType.F_DESCRIPTION, new Validator>() { + @Override + public void validate(PrismPropertyDefinition propDef, String name) throws Exception { + assertNotNull("No definition for description in user", propDef); + assertEquals("Wrong description displayName", "Comment", propDef.getDisplayName()); + assertTrue(name+" not readable", propDef.canRead()); + assertTrue(name+" is creatable", !propDef.canAdd()); + assertTrue(name+" not modifiable", propDef.canModify()); + } + }, "Where's the rum?"); + + assertPropertyValues(user, UserType.F_ADDITIONAL_NAME, new Validator>() { + @Override + public void validate(PrismPropertyDefinition propDef, String name) throws Exception { + assertNotNull("No definition for additionalName in user", propDef); + assertEquals("Wrong additionalName displayName", "Middle Name", propDef.getDisplayName()); + assertTrue(name+" is readable", !propDef.canRead()); + assertTrue(name+" is creatable", !propDef.canAdd()); + assertTrue(name+" not modifiable", propDef.canModify()); + } + }); + + assertPropertyValues(user, UserType.F_COST_CENTER, new Validator>() { + @Override + public void validate(PrismPropertyDefinition propDef, String name) throws Exception { + assertNotNull("No definition for costCenter in user", propDef); + assertEquals("Wrong costCenter displayOrder", (Integer)123, propDef.getDisplayOrder()); + assertTrue(name+" is readable", !propDef.canRead()); + assertTrue(name+" is creatable", !propDef.canAdd()); + assertTrue(name+" is modifiable", !propDef.canModify()); + } + }); + + assertPropertyValues(user, UserType.F_PREFERRED_LANGUAGE, new Validator>() { + @Override + public void validate(PrismPropertyDefinition propDef, String name) throws Exception { + assertNotNull("No definition for preferredLanguage in user", propDef); + assertEquals("Wrong preferredLanguage displayName", "Language", propDef.getDisplayName()); + PrismReferenceValue valueEnumerationRef = propDef.getValueEnumerationRef(); + assertNotNull("No valueEnumerationRef for preferredLanguage", valueEnumerationRef); + assertEquals("Wrong valueEnumerationRef OID for preferredLanguage", LOOKUP_LANGUAGES_OID, valueEnumerationRef.getOid()); + assertTrue(name+" is readable", !propDef.canRead()); + assertTrue(name+" is creatable", !propDef.canAdd()); + assertTrue(name+" is modifiable", !propDef.canModify()); + } + }); + + PrismAsserts.assertNoItem(user, UserType.F_CREDENTIALS); + + assertUntouchedUserDefinition(); + assertSteadyResources(); + } + + @Test + public void test820OtisSearchUsers() throws Exception { + final String TEST_NAME="test820OtisSearchUsers"; + displayTestTitle(TEST_NAME); + + // GIVEN + login(USER_OTIS_USERNAME); + + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + // WHEN + displayWhen(TEST_NAME); + SearchResultList> users = modelService.searchObjects(UserType.class, null, null, task, result); + + // THEN + displayThen(TEST_NAME); + result.computeStatus(); + TestUtil.assertSuccess(result); + + assertEquals("Unexepected number of users found", 7, users.size()); + + for (final PrismObject user: users) { + assertProperty(user, UserType.F_NAME, new Validator>() { + @Override + public void validate(PrismPropertyDefinition propDef, String name) throws Exception { + assertNotNull("No definition for name in user", propDef); + assertEquals("Wrong name displayName", "ObjectType.name", propDef.getDisplayName()); + assertTrue(name+" of "+user+" not readable", propDef.canRead()); + assertTrue(name+" of "+user+" is creatable", !propDef.canAdd()); + assertTrue(name+" of "+user+" is modifiable", !propDef.canModify()); + } + }); + assertProperty(user, UserType.F_ADDITIONAL_NAME, new Validator>() { + @Override + public void validate(PrismPropertyDefinition propDef, String name) throws Exception { + assertNotNull("No definition for additionalName in user", propDef); + assertEquals("Wrong additionalName displayName", "Middle Name", propDef.getDisplayName()); + assertTrue(name+" of "+user+" is readable", !propDef.canRead()); + assertTrue(name+" of "+user+" is creatable", !propDef.canAdd()); + assertTrue(name+" of "+user+" not modifiable", propDef.canModify()); + } + }); + assertProperty(user, UserType.F_COST_CENTER, new Validator>() { + @Override + public void validate(PrismPropertyDefinition propDef, String name) throws Exception { + assertNotNull("No definition for costCenter in user", propDef); + assertEquals("Wrong costCenter displayOrder", (Integer)123, propDef.getDisplayOrder()); + assertTrue(name+" of "+user+" is readable", !propDef.canRead()); + assertTrue(name+" of "+user+" is creatable", !propDef.canAdd()); + assertTrue(name+" of "+user+" is modifiable", !propDef.canModify()); + } + }); + + assertProperty(user, UserType.F_PREFERRED_LANGUAGE, new Validator>() { + @Override + public void validate(PrismPropertyDefinition propDef, String name) throws Exception { + assertNotNull("No definition for preferredLanguage in user", propDef); + assertEquals("Wrong preferredLanguage displayName", "Language", propDef.getDisplayName()); + PrismReferenceValue valueEnumerationRef = propDef.getValueEnumerationRef(); + assertNotNull("No valueEnumerationRef for preferredLanguage", valueEnumerationRef); + assertEquals("Wrong valueEnumerationRef OID for preferredLanguage", LOOKUP_LANGUAGES_OID, valueEnumerationRef.getOid()); + assertTrue(name+" of "+user+" is readable", !propDef.canRead()); + assertTrue(name+" of "+user+" is creatable", !propDef.canAdd()); + assertTrue(name+" of "+user+" is modifiable", !propDef.canModify()); + } + }); + + PrismAsserts.assertNoItem(user, UserType.F_CREDENTIALS); + + assertUntouchedUserDefinition(); + } + + } + + + private void assertProperty(PrismObject object, ItemPath path, + Validator> validator) throws Exception { + assertPropertyValues(object, path, validator, (T[])null); + } + + private void assertPropertyValues(PrismObject object, ItemPath path, + Validator> validator, T... expectedValues) throws Exception { + PrismProperty prop = object.findProperty(path); + if (expectedValues == null) { + if (prop != null) { + PrismPropertyDefinition propDef = prop.getDefinition(); + assertNotNull("No definition in property "+path, propDef); + try { + validator.validate(propDef, path.toString()+" (propDef) "); + } catch (Exception | Error e) { + IntegrationTestTools.display("Wrong definition", propDef); + throw e; + } + } + } else if (expectedValues.length == 0) { + assertNull("Unexpected property "+path+" in "+object+": "+prop, prop); + } else { + assertNotNull("No property "+path+" in "+object, prop); + PrismAsserts.assertPropertyValue(prop, expectedValues); + PrismPropertyDefinition propDef = prop.getDefinition(); + assertNotNull("No definition in property "+path, propDef); + try { + validator.validate(propDef, path.toString()+" (propDef) "); + } catch (Exception | Error e) { + IntegrationTestTools.display("Wrong definition", propDef); + throw e; + } + } + + PrismPropertyDefinition objPropDef = object.getDefinition().findPropertyDefinition(path); + assertNotNull("No definition of property "+path+" in object "+object, objPropDef); + try { + validator.validate(objPropDef, path.toString()+" (objectDef) "); + } catch (Exception | Error e) { + IntegrationTestTools.display("Wrong definition", objPropDef); + throw e; + } + + } + + private void assertContainer(PrismObject object, ItemName contName, + Validator> validator, boolean valueExpected) throws Exception { + PrismContainer container = object.findContainer(contName); + if (valueExpected) { + assertNotNull("No container "+contName+" in "+object, container); + PrismContainerDefinition contDef = container.getDefinition(); + assertNotNull("No definition in container "+contName, contDef); + validator.validate(contDef, contName.toString()); + } else { + assertNull("Unexpected container "+contName+" in "+object+": "+container, container); + } + + PrismContainerDefinition objContDef = object.getDefinition().findContainerDefinition(contName); + assertNotNull("No definition of container "+contName+" in object "+object, objContDef); + validator.validate(objContDef, contName.toString()); + } + + private void assertUntouchedUserDefinition() { + // WHEN + PrismObjectDefinition userDefinition = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class); + + + // THEN + + PrismPropertyDefinition descriptionDef = userDefinition.findPropertyDefinition(UserType.F_DESCRIPTION); + assertNotNull("No definition for description in user", descriptionDef); + assertEquals("Wrong description displayName", "ObjectType.description", descriptionDef.getDisplayName()); + assertTrue("description not readable", descriptionDef.canRead()); + assertTrue("description not creatable", descriptionDef.canAdd()); + assertTrue("description not modifiable", descriptionDef.canModify()); + + PrismPropertyDefinition additionalNameDef = userDefinition.findPropertyDefinition(UserType.F_ADDITIONAL_NAME); + assertNotNull("No definition for additionalName in user", additionalNameDef); + assertEquals("Wrong additionalName displayName", "UserType.additionalName", additionalNameDef.getDisplayName()); + assertTrue("additionalName not readable", additionalNameDef.canRead()); + assertTrue("additionalName not creatable", additionalNameDef.canAdd()); + assertTrue("additionalName not modifiable", additionalNameDef.canModify()); + + PrismPropertyDefinition costCenterDef = userDefinition.findPropertyDefinition(UserType.F_COST_CENTER); + assertNotNull("No definition for costCenter in user", costCenterDef); + assertEquals("Wrong costCenter displayOrder", (Integer)420, costCenterDef.getDisplayOrder()); + assertTrue("costCenter not readable", costCenterDef.canRead()); + assertTrue("costCenter not creatable", costCenterDef.canAdd()); + assertTrue("costCenter not modifiable", costCenterDef.canModify()); + PrismReferenceValue valueEnumerationRef = costCenterDef.getValueEnumerationRef(); + assertNull("valueEnumerationRef for costCente sneaked in", valueEnumerationRef); + + PrismPropertyDefinition preferredLanguageDef = userDefinition.findPropertyDefinition(UserType.F_PREFERRED_LANGUAGE); + assertNotNull("No definition for preferredLanguage in user", preferredLanguageDef); + assertEquals("Wrong preferredLanguage displayName", "FocusType.preferredLanguage", preferredLanguageDef.getDisplayName()); + assertTrue("preferredLanguage not readable", preferredLanguageDef.canRead()); + assertTrue("preferredLanguage not creatable", preferredLanguageDef.canAdd()); + assertTrue("preferredLanguage not modifiable", preferredLanguageDef.canModify()); + valueEnumerationRef = preferredLanguageDef.getValueEnumerationRef(); + assertNotNull("valueEnumerationRef for preferredLanguage missing", valueEnumerationRef); + assertEquals("wrong OID in valueEnumerationRef for preferredLanguage missing", + SystemObjectsType.LOOKUP_LANGUAGES.value(), valueEnumerationRef.getOid()); + + PrismContainerDefinition credentialsDef = userDefinition.findContainerDefinition(UserType.F_CREDENTIALS); + assertNotNull("No definition for credentials in user", credentialsDef); + assertTrue("Credentials not readable", credentialsDef.canRead()); + assertTrue("Credentials not creatable", credentialsDef.canAdd()); + assertTrue("Credentials not modifiable", credentialsDef.canModify()); + + ItemPath passwdValPath = ItemPath.create(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE); + PrismPropertyDefinition passwdValDef = userDefinition.findPropertyDefinition(passwdValPath); + assertNotNull("No definition for "+passwdValPath+" in user", passwdValDef); + assertTrue("Password not readable", passwdValDef.canRead()); + assertTrue("Password not creatable", passwdValDef.canAdd()); + assertTrue("Password not modifiable", passwdValDef.canModify()); + + } +} diff --git a/model/model-intest/src/test/resources/common/archetype-task-reconciliation.xml b/model/model-intest/src/test/resources/common/archetype-task-reconciliation.xml new file mode 100644 index 00000000000..43b3795c9ca --- /dev/null +++ b/model/model-intest/src/test/resources/common/archetype-task-reconciliation.xml @@ -0,0 +1,104 @@ + + + Reconciliation task + + + + Reconciliation tasks + + fa fa-exchange + green + + + + extension + vacant + + + extension/mext:objectclass + visible + + + extension/mext:kind + visible + + + + c:TaskType + + + + + + objectRef + + + extension/mext:objectclass + + + extension/mext:kind + + + extension/mext:intent + + + extension/mext:objectQuery + + + + + + + + extension/mext:workerThreads + + + extension/mext:finishOperationsOnly + + + extension/mext:dryRun + + + + + + + + TaskType + + + + + + weak + + http://midpoint.evolveum.com/xml/ns/public/model/synchronization/task/reconciliation/handler-3 + + + handlerUri + + + + + + + + weak + + Reconciliation + + + category + + + + + diff --git a/model/model-intest/src/test/resources/common/task-reconcile-dummy.xml b/model/model-intest/src/test/resources/common/task-reconcile-dummy.xml index 6e42899df57..aa407ed60a1 100644 --- a/model/model-intest/src/test/resources/common/task-reconcile-dummy.xml +++ b/model/model-intest/src/test/resources/common/task-reconcile-dummy.xml @@ -1,36 +1,40 @@ - - - - - - - - Reconciliation: Dummy - - - ri:AccountObjectClass - - - 10000000-0000-0000-5656-565600000004 - - runnable - - http://midpoint.evolveum.com/xml/ns/public/model/synchronization/task/reconciliation/handler-3 - - recurring - tight - - 10 - - - + + + + + + + + Reconciliation: Dummy + + + ri:AccountObjectClass + + + + + + + 10000000-0000-0000-5656-565600000004 + + runnable + + http://midpoint.evolveum.com/xml/ns/public/model/synchronization/task/reconciliation/handler-3 + + recurring + tight + + 10 + + + diff --git a/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java b/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java index 2f1035c13c1..6f40c32830a 100644 --- a/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java +++ b/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java @@ -1,6678 +1,6691 @@ -/* - * Copyright (c) 2010-2019 Evolveum and contributors - * - * This work is dual-licensed under the Apache License 2.0 - * and European Union Public License. See LICENSE file for details. - */ -package com.evolveum.midpoint.model.test; - -import static com.evolveum.midpoint.prism.PrismObject.asObjectableList; -import static com.evolveum.midpoint.schema.constants.SchemaConstants.*; -import static java.util.Collections.singleton; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertTrue; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.net.ConnectException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.concurrent.atomic.AtomicLong; -import java.util.function.Consumer; -import java.util.function.Function; -import java.util.stream.Collectors; - -import javax.xml.bind.JAXBException; -import javax.xml.datatype.XMLGregorianCalendar; -import javax.xml.namespace.QName; - -import com.evolveum.midpoint.model.api.authentication.*; -import com.evolveum.midpoint.model.test.asserter.*; -import com.evolveum.midpoint.prism.*; -import com.evolveum.midpoint.prism.delta.*; -import com.evolveum.midpoint.prism.equivalence.EquivalenceStrategy; -import com.evolveum.midpoint.prism.path.*; -import com.evolveum.midpoint.repo.api.perf.PerformanceInformation; -import com.evolveum.midpoint.schema.*; -import com.evolveum.midpoint.schema.result.OperationResultStatus; -import com.evolveum.midpoint.schema.util.*; -import com.evolveum.midpoint.schema.statistics.StatisticsUtil; -import com.evolveum.midpoint.task.api.TaskDebugUtil; -import com.evolveum.midpoint.test.*; -import com.evolveum.midpoint.test.asserter.*; -import com.evolveum.midpoint.util.*; -import com.evolveum.midpoint.xml.ns._public.common.common_3.*; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.mutable.MutableInt; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.opends.server.types.DirectoryException; -import org.opends.server.types.Entry; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.security.access.ConfigAttribute; -import org.springframework.security.access.SecurityConfig; -import org.springframework.security.authentication.AnonymousAuthenticationToken; -import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.authority.AuthorityUtils; -import org.springframework.security.core.context.SecurityContext; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.security.core.context.SecurityContextImpl; -import org.springframework.security.web.FilterInvocation; -import org.testng.AssertJUnit; -import org.testng.annotations.AfterClass; - -import com.evolveum.icf.dummy.resource.ConflictException; -import com.evolveum.icf.dummy.resource.DummyAccount; -import com.evolveum.icf.dummy.resource.DummyGroup; -import com.evolveum.icf.dummy.resource.DummyResource; -import com.evolveum.icf.dummy.resource.SchemaViolationException; -import com.evolveum.midpoint.audit.api.AuditEventRecord; -import com.evolveum.midpoint.audit.api.AuditEventStage; -import com.evolveum.midpoint.audit.api.AuditEventType; -import com.evolveum.midpoint.audit.api.AuditReferenceValue; -import com.evolveum.midpoint.common.Clock; -import com.evolveum.midpoint.common.refinery.RefinedAttributeDefinition; -import com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition; -import com.evolveum.midpoint.common.refinery.RefinedResourceSchema; -import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl; -import com.evolveum.midpoint.model.api.AssignmentCandidatesSpecification; -import com.evolveum.midpoint.model.api.ModelAuditService; -import com.evolveum.midpoint.model.api.ModelAuthorizationAction; -import com.evolveum.midpoint.model.api.ModelDiagnosticService; -import com.evolveum.midpoint.model.api.ModelExecuteOptions; -import com.evolveum.midpoint.model.api.ModelInteractionService; -import com.evolveum.midpoint.model.api.ModelService; -import com.evolveum.midpoint.model.api.RoleSelectionSpecification; -import com.evolveum.midpoint.model.api.context.EvaluatedPolicyRule; -import com.evolveum.midpoint.model.api.context.ModelContext; -import com.evolveum.midpoint.model.api.context.ModelElementContext; -import com.evolveum.midpoint.model.api.context.ModelProjectionContext; -import com.evolveum.midpoint.model.api.expr.MidpointFunctions; -import com.evolveum.midpoint.model.api.hooks.HookRegistry; -import com.evolveum.midpoint.model.api.interaction.DashboardService; -import com.evolveum.midpoint.model.common.SystemObjectCache; -import com.evolveum.midpoint.model.common.stringpolicy.FocusValuePolicyOriginResolver; -import com.evolveum.midpoint.model.common.stringpolicy.ValuePolicyProcessor; -import com.evolveum.midpoint.notifications.api.NotificationManager; -import com.evolveum.midpoint.notifications.api.transports.Message; -import com.evolveum.midpoint.prism.crypto.EncryptionException; -import com.evolveum.midpoint.prism.match.MatchingRule; -import com.evolveum.midpoint.prism.polystring.PolyString; -import com.evolveum.midpoint.prism.query.ObjectFilter; -import com.evolveum.midpoint.prism.query.ObjectQuery; -import com.evolveum.midpoint.prism.query.OrgFilter; -import com.evolveum.midpoint.prism.util.PrismAsserts; -import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.prism.xml.XmlTypeConverter; -import com.evolveum.midpoint.provisioning.api.ProvisioningService; -import com.evolveum.midpoint.repo.api.RepositoryService; -import com.evolveum.midpoint.repo.common.ObjectResolver; -import com.evolveum.midpoint.repo.common.expression.ExpressionVariables; -import com.evolveum.midpoint.schema.constants.ObjectTypes; -import com.evolveum.midpoint.schema.constants.SchemaConstants; -import com.evolveum.midpoint.schema.internals.InternalsConfig; -import com.evolveum.midpoint.schema.processor.ResourceAttribute; -import com.evolveum.midpoint.schema.processor.ResourceAttributeContainer; -import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition; -import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.security.api.Authorization; -import com.evolveum.midpoint.security.api.AuthorizationConstants; -import com.evolveum.midpoint.security.api.MidPointPrincipal; -import com.evolveum.midpoint.security.api.SecurityContextManager; -import com.evolveum.midpoint.security.enforcer.api.AuthorizationParameters; -import com.evolveum.midpoint.security.enforcer.api.ItemSecurityConstraints; -import com.evolveum.midpoint.security.enforcer.api.SecurityEnforcer; -import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.task.api.TaskExecutionStatus; -import com.evolveum.midpoint.test.util.MidPointAsserts; -import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.exception.CommonException; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; -import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.PolicyViolationException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SecurityViolationException; -import com.evolveum.midpoint.util.exception.SystemException; -import com.evolveum.midpoint.util.exception.TunnelException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ImportOptionsType; -import com.evolveum.midpoint.xml.ns._public.model.model_3.ModelPortType; -import com.evolveum.prism.xml.ns._public.types_3.ChangeTypeType; -import com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType; -import com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType; -import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; -import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; - -/** - * Abstract framework for an integration test that is placed on top of a model API. - * This provides complete environment that the test should need, e.g model service instance, repository, provisioning, - * dummy auditing, etc. It also implements lots of useful methods to make writing the tests easier. - * - * @author Radovan Semancik - * - */ -public abstract class AbstractModelIntegrationTest extends AbstractIntegrationTest { - - protected static final int DEFAULT_TASK_WAIT_TIMEOUT = 25000; - protected static final long DEFAULT_TASK_SLEEP_TIME = 200; - - protected static final String CONNECTOR_DUMMY_TYPE = "com.evolveum.icf.dummy.connector.DummyConnector"; - protected static final String CONNECTOR_DUMMY_VERSION = "2.0"; - protected static final String CONNECTOR_DUMMY_NAMESPACE = "http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/com.evolveum.icf.dummy/com.evolveum.icf.dummy.connector.DummyConnector"; - - protected static final String CONNECTOR_LDAP_TYPE = "com.evolveum.polygon.connector.ldap.LdapConnector"; - protected static final String CONNECTOR_LDAP_NAMESPACE = "http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/com.evolveum.polygon.connector-ldap/com.evolveum.polygon.connector.ldap.LdapConnector"; - - protected static final String CONNECTOR_AD_TYPE = "Org.IdentityConnectors.ActiveDirectory.ActiveDirectoryConnector"; - protected static final String CONNECTOR_AD_NAMESPACE = "http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/ActiveDirectory.Connector/Org.IdentityConnectors.ActiveDirectory.ActiveDirectoryConnector"; - - protected static final ItemPath ACTIVATION_ADMINISTRATIVE_STATUS_PATH = SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS; - protected static final ItemPath ACTIVATION_VALID_FROM_PATH = SchemaConstants.PATH_ACTIVATION_VALID_FROM; - protected static final ItemPath ACTIVATION_VALID_TO_PATH = SchemaConstants.PATH_ACTIVATION_VALID_TO; - protected static final ItemPath PASSWORD_VALUE_PATH = SchemaConstants.PATH_CREDENTIALS_PASSWORD_VALUE; - - private static final String DEFAULT_CHANNEL = SchemaConstants.CHANNEL_GUI_USER_URI; - - protected static final String LOG_PREFIX_FAIL = "SSSSS=X "; - protected static final String LOG_PREFIX_ATTEMPT = "SSSSS=> "; - protected static final String LOG_PREFIX_DENY = "SSSSS=- "; - protected static final String LOG_PREFIX_ALLOW = "SSSSS=+ "; - - @Autowired protected ModelService modelService; - @Autowired protected ModelInteractionService modelInteractionService; - @Autowired protected ModelDiagnosticService modelDiagnosticService; - @Autowired protected DashboardService dashboardService; - @Autowired protected ModelAuditService modelAuditService; - @Autowired protected ModelPortType modelWeb; - @Autowired - @Qualifier("cacheRepositoryService") - protected RepositoryService repositoryService; - @Autowired - @Qualifier("sqlRepositoryServiceImpl") - protected RepositoryService plainRepositoryService; - - @Autowired protected SystemObjectCache systemObjectCache; - @Autowired protected RelationRegistry relationRegistry; - @Autowired protected ProvisioningService provisioningService; - @Autowired protected HookRegistry hookRegistry; - @Autowired protected Clock clock; - @Autowired protected SchemaHelper schemaHelper; - @Autowired protected DummyTransport dummyTransport; - @Autowired protected SecurityEnforcer securityEnforcer; - @Autowired protected SecurityContextManager securityContextManager; - @Autowired protected MidpointFunctions libraryMidpointFunctions; - @Autowired protected ValuePolicyProcessor valuePolicyProcessor; - - @Autowired(required = false) - @Qualifier("modelObjectResolver") - protected ObjectResolver modelObjectResolver; - - @Autowired(required = false) - protected NotificationManager notificationManager; - - @Autowired(required = false) - protected GuiProfiledPrincipalManager focusProfileService; - - protected DummyResourceCollection dummyResourceCollection; - - protected DummyAuditService dummyAuditService; - - protected boolean verbose = false; - - private static final Trace LOGGER = TraceManager.getTrace(AbstractModelIntegrationTest.class); - - public AbstractModelIntegrationTest() { - super(); - } - - @Override - public void initSystem(Task initTask, OperationResult initResult) throws Exception { - LOGGER.trace("initSystem"); - dummyResourceCollection = new DummyResourceCollection(modelService); - startResources(); - dummyAuditService = DummyAuditService.getInstance(); - InternalsConfig.reset(); - InternalsConfig.setAvoidLoggingChange(isAvoidLoggingChange()); - // Make sure the checks are turned on - InternalsConfig.turnOnAllChecks(); - // By default, notifications are turned off because of performance implications. Individual tests turn them on for themselves. - if (notificationManager != null) { - notificationManager.setDisabled(true); - } - } - - protected boolean isAvoidLoggingChange() { - return true; - } - - @Override - public void postInitSystem(Task initTask, OperationResult initResult) throws Exception { - super.postInitSystem(initTask, initResult); - if (dummyResourceCollection != null) { - dummyResourceCollection.resetResources(); - } - } - - protected void startResources() throws Exception { - // Nothing to do by default - } - - @AfterClass - protected void cleanUpSecurity() { - SecurityContext securityContext = SecurityContextHolder.getContext(); - securityContext.setAuthentication(null); - } - - protected void initDummyResource(String name, DummyResourceContoller controller) { - dummyResourceCollection.initDummyResource(name, controller); - } - - protected DummyResourceContoller initDummyResource(String name, File resourceFile, String resourceOid, - FailableProcessor controllerInitLambda, - Task task, OperationResult result) throws Exception { - return dummyResourceCollection.initDummyResource(name, resourceFile, resourceOid, controllerInitLambda, task, result); - } - - protected DummyResourceContoller initDummyResource(String name, File resourceFile, String resourceOid, - Task task, OperationResult result) throws Exception { - return dummyResourceCollection.initDummyResource(name, resourceFile, resourceOid, null, task, result); - } - - protected DummyResourceContoller initDummyResourcePirate(String name, File resourceFile, String resourceOid, - Task task, OperationResult result) throws Exception { - return initDummyResource(name, resourceFile, resourceOid, controller -> controller.extendSchemaPirate(), task, result); - } - - protected DummyResourceContoller initDummyResourceAd(String name, File resourceFile, String resourceOid, - Task task, OperationResult result) throws Exception { - return initDummyResource(name, resourceFile, resourceOid, controller -> controller.extendSchemaAd(), task, result); - } - - protected DummyResourceContoller getDummyResourceController(String name) { - return dummyResourceCollection.get(name); - } - - protected DummyResourceContoller getDummyResourceController() { - return getDummyResourceController(null); - } - - protected DummyAccountAsserter assertDummyAccountByUsername(String dummyResourceName, String username) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { - return getDummyResourceController(dummyResourceName).assertAccountByUsername(username); - } - - protected DummyGroupAsserter assertDummyGroupByName(String dummyResourceName, String name) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { - return getDummyResourceController(dummyResourceName).assertGroupByName(name); - } - - protected DummyResource getDummyResource(String name) { - return dummyResourceCollection.getDummyResource(name); - } - - protected DummyResource getDummyResource() { - return getDummyResource(null); - } - - protected PrismObject getDummyResourceObject(String name) { - return dummyResourceCollection.getResourceObject(name); - } - - protected PrismObject getDummyResourceObject() { - return getDummyResourceObject(null); - } - - protected ResourceType getDummyResourceType(String name) { - return dummyResourceCollection.getResourceType(name); - } - - protected ResourceType getDummyResourceType() { - return getDummyResourceType(null); - } - - protected void importObjectFromFile(String filename) throws FileNotFoundException { - importObjectFromFile(new File(filename)); - } - - protected void importObjectFromFile(File file) throws FileNotFoundException { - OperationResult result = new OperationResult(AbstractModelIntegrationTest.class.getName() + ".importObjectFromFile"); - importObjectFromFile(file, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - } - - protected void importObjectFromFile(String filename, OperationResult result) throws FileNotFoundException { - importObjectFromFile(new File(filename), result); - } - - protected void importObjectFromFile(File file, OperationResult result) throws FileNotFoundException { - OperationResult subResult = result.createSubresult(AbstractModelIntegrationTest.class.getName()+".importObjectFromFile"); - subResult.addParam("filename", file.getPath()); - LOGGER.trace("importObjectFromFile: {}", file); - Task task = taskManager.createTaskInstance(); - importObjectFromFile(file, task, result); - subResult.computeStatus(); - if (subResult.isError()) { - LOGGER.error("Import of file "+file+" failed:\n{}", subResult.debugDump()); - Throwable cause = findCause(subResult); - throw new SystemException("Import of file "+file+" failed: "+subResult.getMessage(), cause); - } - } - - protected void importObjectFromFile(File file, Task task, OperationResult result) throws FileNotFoundException { - importObjectFromFile(file, MiscSchemaUtil.getDefaultImportOptions(), task, result); - } - - protected void importObjectFromFile(File file, ImportOptionsType options, Task task, OperationResult result) throws FileNotFoundException { - FileInputStream stream = new FileInputStream(file); - modelService.importObjectsFromStream(stream, PrismContext.LANG_XML, options, task, result); - } - - protected void importObjectsFromFileNotRaw(File file, Task task, OperationResult result) throws FileNotFoundException { - ImportOptionsType options = MiscSchemaUtil.getDefaultImportOptions(); - ModelExecuteOptionsType modelOptions = new ModelExecuteOptionsType(); - modelOptions.setRaw(false); - options.setModelExecutionOptions(modelOptions); - importObjectFromFile(file, options, task, result); - } - - protected Throwable findCause(OperationResult result) { - if (result.getCause() != null) { - return result.getCause(); - } - for (OperationResult sub: result.getSubresults()) { - Throwable cause = findCause(sub); - if (cause != null) { - return cause; - } - } - return null; - } - - protected PrismObject importAndGetObjectFromFile(Class type, String filename, String oid, Task task, OperationResult result) throws FileNotFoundException, ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - return importAndGetObjectFromFile(type, new File(filename), oid, task, result); - } - - protected PrismObject importAndGetObjectFromFile(Class type, File file, String oid, Task task, OperationResult result) throws FileNotFoundException, ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - importObjectFromFile(file, result); - OperationResult importResult = result.getLastSubresult(); - TestUtil.assertSuccess("Import of "+file+" has failed", importResult); - return modelService.getObject(type, oid, null, task, result); - } - - protected PrismObject importAndGetObjectFromFileIgnoreWarnings(Class type, File file, String oid, Task task, OperationResult result) throws FileNotFoundException, ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - importObjectFromFile(file, result); - OperationResult importResult = result.getLastSubresult(); - OperationResultStatus status = importResult.getStatus(); - if (status == OperationResultStatus.FATAL_ERROR || status == OperationResultStatus.PARTIAL_ERROR) { - fail("Import of "+file+" has failed: "+importResult.getMessage()); - } - return modelService.getObject(type, oid, null, task, result); - } - - /** - * This is not the real thing. It is just for the tests. - */ - protected void applyResourceSchema(ShadowType accountType, ResourceType resourceType) throws SchemaException { - IntegrationTestTools.applyResourceSchema(accountType, resourceType, prismContext); - } - - - protected void assertUsers(int expectedNumberOfUsers) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - assertObjects(UserType.class, expectedNumberOfUsers); - } - - protected void assertRoles(int expectedNumberOfUsers) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - assertObjects(RoleType.class, expectedNumberOfUsers); - } - - protected void assertServices(int expectedNumberOfUsers) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - assertObjects(ServiceType.class, expectedNumberOfUsers); - } - - protected void assertObjects(Class type, int expectedNumberOfUsers) throws SchemaException, - ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - assertObjects(type, null, expectedNumberOfUsers); - } - - protected void assertObjects(Class type, ObjectQuery query, int expectedNumberOfUsers) - throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, - ConfigurationException, ExpressionEvaluationException { - assertEquals("Unexpected number of "+type.getSimpleName()+"s", expectedNumberOfUsers, getObjectCount(type, query)); - } - - protected int getObjectCount(Class type) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - return getObjectCount(type, null); - } - - protected int getObjectCount(Class type, ObjectQuery query) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertObjects"); - OperationResult result = task.getResult(); - List> users = modelService.searchObjects(type, query, null, task, result); - if (verbose) display(type.getSimpleName()+"s", users); - return users.size(); - } - - protected void searchObjectsIterative(Class type, ObjectQuery query, Consumer> handler, Integer expectedNumberOfObjects) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertObjects"); - OperationResult result = task.getResult(); - final MutableInt count = new MutableInt(0); - // Cannot convert to lambda here. Java does not want to understand the generic types properly. - SearchResultMetadata searchMetadata = modelService.searchObjectsIterative(type, query, (object, oresult) -> { - count.increment(); - if (handler != null) { - handler.accept(object); - } - return true; - }, null, task, result); - if (verbose) display(type.getSimpleName()+"s", count.getValue()); - assertEquals("Unexpected number of "+type.getSimpleName()+"s", expectedNumberOfObjects, count.getValue()); - } - - protected void assertUserProperty(String userOid, QName propertyName, Object... expectedPropValues) throws ObjectNotFoundException, SchemaException { - OperationResult result = new OperationResult("getObject"); - PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); - assertUserProperty(user, propertyName, expectedPropValues); - } - - protected void assertUserNoProperty(String userOid, QName propertyName) throws ObjectNotFoundException, SchemaException { - OperationResult result = new OperationResult("getObject"); - PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); - assertUserNoProperty(user, propertyName); - } - - protected void assertUserProperty(PrismObject user, QName propertyName, Object... expectedPropValues) { - PrismProperty property = user.findProperty(ItemName.fromQName(propertyName)); - assert property != null : "No property "+propertyName+" in "+user; - PrismAsserts.assertPropertyValue(property, expectedPropValues); - } - - protected void assertUserNoProperty(PrismObject user, QName propertyName) { - PrismProperty property = user.findProperty(ItemName.fromQName(propertyName)); - assert property == null : "Property "+propertyName+" present in "+user+": "+property; - } - - protected void assertAdministrativeStatusEnabled(PrismObject user) { - assertAdministrativeStatus(user, ActivationStatusType.ENABLED); - } - - protected void assertAdministrativeStatusDisabled(PrismObject user) { - assertAdministrativeStatus(user, ActivationStatusType.DISABLED); - } - - protected void assertAdministrativeStatus(PrismObject object, ActivationStatusType expected) { - PrismProperty statusProperty = object.findProperty(ACTIVATION_ADMINISTRATIVE_STATUS_PATH); - if (expected == null && statusProperty == null) { - return; - } - assert statusProperty != null : "No status property in "+object; - ActivationStatusType status = statusProperty.getRealValue(); - if (expected == null && status == null) { - return; - } - assert status != null : "No status property is null in "+object; - assert status == expected : "status property is "+status+", expected "+expected+" in "+object; - } - - protected void assertEffectiveStatus(PrismObject focus, ActivationStatusType expected) { - ActivationType activation = focus.asObjectable().getActivation(); - assertNotNull("No activation in "+focus, activation); - assertEquals("Unexpected effective activation status in "+focus, expected, activation.getEffectiveStatus()); - } - - protected void modifyUserReplace(String userOid, ItemPath propertyPath, Task task, OperationResult result, Object... newRealValue) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, - ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - modifyUserReplace(userOid, propertyPath, null, task, result, newRealValue); - } - - protected void modifyUserReplace(String userOid, ItemPath propertyPath, ModelExecuteOptions options, Task task, OperationResult result, Object... newRealValue) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, - ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - ObjectDelta objectDelta = createModifyUserReplaceDelta(userOid, propertyPath, newRealValue); - executeChanges(objectDelta, options, task, result); - } - - protected void modifyObjectReplaceProperty(Class type, String oid, ItemPath propertyPath, Task task, OperationResult result, Object... newRealValue) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, - ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - modifyObjectReplaceProperty(type, oid, propertyPath, null, task, result, newRealValue); - } - - protected void modifyObjectReplaceProperty(Class type, String oid, ItemPath propertyPath, ModelExecuteOptions options, Task task, OperationResult result, Object... newRealValue) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, - ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - ObjectDelta objectDelta = prismContext.deltaFactory().object() - .createModificationReplaceProperty(type, oid, propertyPath, newRealValue); - Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); - modelService.executeChanges(deltas, options, task, result); - } - - protected void modifyObjectDeleteProperty(Class type, String oid, ItemPath propertyPath, Task task, OperationResult result, Object... newRealValue) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, - ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - ObjectDelta objectDelta = prismContext.deltaFactory().object() - .createModificationDeleteProperty(type, oid, propertyPath, newRealValue); - Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); - modelService.executeChanges(deltas, null, task, result); - } - - protected void modifyObjectAddProperty(Class type, String oid, ItemPath propertyPath, Task task, OperationResult result, Object... newRealValue) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, - ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - ObjectDelta objectDelta = prismContext.deltaFactory().object() - .createModificationAddProperty(type, oid, propertyPath, newRealValue); - Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); - modelService.executeChanges(deltas, null, task, result); - } - - protected void modifyObjectReplaceContainer(Class type, String oid, ItemPath propertyPath, Task task, OperationResult result, C... newRealValue) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, - ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - ObjectDelta objectDelta = prismContext.deltaFactory().object() - .createModificationReplaceContainer(type, oid, propertyPath, newRealValue); - Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); - modelService.executeChanges(deltas, null, task, result); - } - - protected void modifyObjectAddContainer(Class type, String oid, ItemPath propertyPath, Task task, OperationResult result, C... newRealValue) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, - ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - ObjectDelta objectDelta = prismContext.deltaFactory().object() - .createModificationAddContainer(type, oid, propertyPath, newRealValue); - Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); - modelService.executeChanges(deltas, null, task, result); - } - - protected void modifyObjectDeleteContainer(Class type, String oid, ItemPath propertyPath, Task task, OperationResult result, C... newRealValue) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, - ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - ObjectDelta objectDelta = prismContext.deltaFactory().object() - .createModificationDeleteContainer(type, oid, propertyPath, newRealValue); - Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); - modelService.executeChanges(deltas, null, task, result); - } - - protected void modifyObjectReplaceReference(Class type, String oid, ItemPath refPath, Task task, OperationResult result, PrismReferenceValue... refVals) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, - ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - ObjectDelta objectDelta = prismContext.deltaFactory().object() - .createModificationReplaceReference(type, oid, refPath, refVals); - Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); - modelService.executeChanges(deltas, null, task, result); - } - - protected void modifyUserAdd(String userOid, ItemPath propertyPath, Task task, OperationResult result, Object... newRealValue) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, - ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - ObjectDelta objectDelta = createModifyUserAddDelta(userOid, propertyPath, newRealValue); - Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); - modelService.executeChanges(deltas, null, task, result); - } - - protected void modifyUserDelete(String userOid, ItemPath propertyPath, Task task, OperationResult result, Object... newRealValue) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, - ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - ObjectDelta objectDelta = createModifyUserDeleteDelta(userOid, propertyPath, newRealValue); - Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); - modelService.executeChanges(deltas, null, task, result); - } - - protected void modifyAccountShadowReplace(String accountOid, ItemPath propertyPath, Task task, OperationResult result, Object... newRealValue) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, - ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - PrismObject shadow = repositoryService.getObject(ShadowType.class, accountOid, null, result); - String resourceOid = shadow.asObjectable().getResourceRef().getOid(); - PrismObject resource = provisioningService.getObject(ResourceType.class, resourceOid, null, task, result); - ObjectDelta objectDelta = createModifyAccountShadowReplaceDelta(accountOid, resource, propertyPath, newRealValue); - Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); - modelService.executeChanges(deltas, null, task, result); - } - - protected ObjectDelta createOldNewPasswordDelta(String oid, String oldPassword, String newPassword) throws SchemaException { - ProtectedStringType oldPasswordPs = new ProtectedStringType(); - oldPasswordPs.setClearValue(oldPassword); - - ProtectedStringType newPasswordPs = new ProtectedStringType(); - newPasswordPs.setClearValue(newPassword); - - return deltaFor(UserType.class) - .item(PASSWORD_VALUE_PATH) - .oldRealValue(oldPasswordPs) - .replace(newPasswordPs) - .asObjectDelta(oid); - } - - protected void modifyUserChangePassword(String userOid, String newPassword) throws CommonException { - Task task = createTask("modifyUserChangePassword"); - OperationResult result = task.getResult(); - modifyUserChangePassword(userOid, newPassword, task, result); - assertSuccess(result); - } - - protected void modifyUserChangePassword(String userOid, String newPassword, Task task, OperationResult result) throws CommonException { - modifyFocusChangePassword(UserType.class, userOid, newPassword, task, result); - } - - protected void modifyFocusChangePassword(Class type, String oid, String newPassword, Task task, OperationResult result) throws CommonException { - ProtectedStringType passwordPs = new ProtectedStringType(); - passwordPs.setClearValue(newPassword); - modifyObjectReplaceProperty(type, oid, PASSWORD_VALUE_PATH, task, result, passwordPs); - } - - protected void modifyUserSetPassword(String userOid, String newPassword, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - ProtectedStringType userPasswordPs = new ProtectedStringType(); - userPasswordPs.setClearValue(newPassword); - PasswordType passwordType = new PasswordType(); - passwordType.setValue(userPasswordPs); - ObjectDelta delta = prismContext.deltaFor(UserType.class) - .item(SchemaConstants.PATH_PASSWORD).add(passwordType) - .asObjectDelta(userOid); - executeChanges(delta, null, task, result); - } - - protected void modifyAccountChangePassword(String accountOid, String newPassword, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - ProtectedStringType userPasswordPs = new ProtectedStringType(); - userPasswordPs.setClearValue(newPassword); - modifyAccountShadowReplace(accountOid, PASSWORD_VALUE_PATH, task, result, userPasswordPs); - } - - protected void clearUserPassword(String userOid) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = createTask("clearUserPassword"); - OperationResult result = task.getResult(); - List> itemDeltas = prismContext.deltaFor(UserType.class) - .item(SchemaConstants.PATH_PASSWORD).replace() - .asItemDeltas(); - repositoryService.modifyObject(UserType.class, userOid, itemDeltas, result); - assertSuccess(result); - } - - protected void renameObject(Class type, String oid, String newName, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - modifyObjectReplaceProperty(type, oid, ObjectType.F_NAME, task, result, createPolyString(newName)); - } - - protected void recomputeUser(String userOid) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { - Task task = createTask("recomputeUser"); - OperationResult result = task.getResult(); - modelService.recompute(UserType.class, userOid, null, task, result); - assertSuccess(result); - } - - protected void recomputeUser(String userOid, Task task, OperationResult result) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { - modelService.recompute(UserType.class, userOid, null, task, result); - } - - protected void recomputeFocus(Class clazz, String userOid, Task task, OperationResult result) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { - modelService.recompute(clazz, userOid, null, task, result); - } - - protected void recomputeUser(String userOid, ModelExecuteOptions options, Task task, OperationResult result) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { - modelService.recompute(UserType.class, userOid, options, task, result); - } - - protected void assignRole(String userOid, String roleOid) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".assignRole"); - OperationResult result = task.getResult(); - assignRole(userOid, roleOid, task, result); - assertSuccess(result); - } - - protected void assignRole(String userOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - assignRole(UserType.class, userOid, roleOid, (ActivationType) null, task, result); - } - - protected void assignService(String userOid, String targetOid, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - assignService(UserType.class, userOid, targetOid, (ActivationType) null, task, result); - } - - protected void assignRole(String userOid, String roleOid, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - assignRole(UserType.class, userOid, roleOid, (ActivationType) null, task, options, result); - } - - protected void assignRole(Class focusClass, String focusOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - assignRole(focusClass, focusOid, roleOid, (ActivationType) null, task, result); - } - - protected void assignRole(String userOid, String roleOid, ActivationType activationType, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, null, task, null, activationType, true, result); - } - - protected void unassignRole(String userOid, String roleOid, ActivationType activationType, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, null, task, null, activationType, false, result); - } - - protected void unassignRole(Class focusClass, String focusOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - unassignRole(focusClass, focusOid, roleOid, (ActivationType) null, task, result); - } - - protected void unassignRole(Class focusClass, String focusOid, String roleOid, ActivationType activationType, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyAssignmentHolderAssignment(focusClass, focusOid, roleOid, RoleType.COMPLEX_TYPE, null, task, null, activationType, false, result); - } - - protected void assignRole(Class focusClass, String focusOid, String roleOid, ActivationType activationType, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyAssignmentHolderAssignment(focusClass, focusOid, roleOid, RoleType.COMPLEX_TYPE, null, task, null, activationType, true, result); - } - - protected void assignService(Class focusClass, String focusOid, String targetOid, ActivationType activationType, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyAssignmentHolderAssignment(focusClass, focusOid, targetOid, ServiceType.COMPLEX_TYPE, null, task, null, activationType, true, result); - } - - protected void assignRole(Class focusClass, String focusOid, String roleOid, ActivationType activationType, Task task, ModelExecuteOptions options, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyAssignmentHolderAssignment(focusClass, focusOid, roleOid, RoleType.COMPLEX_TYPE, null, task, null, activationType, true, options, result); - } - - protected void assignFocus(Class focusClass, String focusOid, QName targetType, String targetOid, QName relation, ActivationType activationType, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyAssignmentHolderAssignment(focusClass, focusOid, targetOid, targetType, relation, task, null, activationType, true, result); - } - - protected void assignRole(String userOid, String roleOid, QName relation, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, relation, task, null, null, true, result); - } - - protected void assignRole(String userOid, String roleOid, QName relation, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, relation, task, null, null, true, options, result); - } - - protected void assignRole(String userOid, String roleOid, QName relation) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".assignRole"); - OperationResult result = task.getResult(); - assignRole(userOid, roleOid, relation, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - } - - protected void assignRole(String userOid, String roleOid, QName relation, Consumer modificationBlock, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, relation, task, modificationBlock, true, result); - } - - protected void unassignRole(String userOid, String roleOid) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - Task task = createTask("unassignRole"); - OperationResult result = task.getResult(); - unassignRole(userOid, roleOid, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - } - - protected void unassignRoleByAssignmentValue(PrismObject focus, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - AssignmentType assignment = findAssignmentByTargetRequired(focus, roleOid); - ObjectDelta delta = prismContext.deltaFor(focus.getCompileTimeClass()) - .item(FocusType.F_ASSIGNMENT) - .delete(assignment.clone()) - .asObjectDeltaCast(focus.getOid()); - modelService.executeChanges(singleton(delta), null, task, result); - } - - protected void unassignRole(String userOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, null, task, (Consumer)null, false, result); - } - - protected void unassignService(String userOid, String serviceOid, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, serviceOid, ServiceType.COMPLEX_TYPE, null, task, (Consumer)null, false, result); - } - - protected void unassignRole(String userOid, String roleOid, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, null, task, null, false, options, result); - } - - protected void assignRole(String userOid, String roleOid, PrismContainer extension, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, null, task, extension, true, result); - } - - protected void assignRole(String userOid, String roleOid, PrismContainer extension, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyAssignmentHolderAssignment(UserType.class, userOid, roleOid, RoleType.COMPLEX_TYPE, null, task, extension, null, true, options, result); - } - - protected void unassignRole(String userOid, String roleOid, PrismContainer extension, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, null, task, extension, false, result); - } - - protected void unassignRole(String userOid, String roleOid, PrismContainer extension, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyAssignmentHolderAssignment(UserType.class, userOid, roleOid, RoleType.COMPLEX_TYPE, null, task, extension, null, false, options, result); - } - - protected void unassignRole(String userOid, String roleOid, QName relation, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, relation, task, null, null, false, result); - } - - protected void unassignRole(String userOid, String roleOid, QName relation, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, relation, task, null, null, false, options, result); - } - - protected void unassignRole(String userOid, String roleOid, QName relation, Consumer modificationBlock, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, relation, task, modificationBlock, false, result); - } - - protected void unassignAllRoles(String userOid) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - unassignAllRoles(userOid, false); - } - - protected void unassignAllRoles(String userOid, boolean useRawPlusRecompute) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - Task task = getOrCreateSimpleTask("unassignAllRoles"); - OperationResult result = task.getResult(); - PrismObject user = modelService.getObject(UserType.class, userOid, null, task, result); - Collection> modifications = new ArrayList<>(); - for (AssignmentType assignment: user.asObjectable().getAssignment()) { - ObjectReferenceType targetRef = assignment.getTargetRef(); - if (targetRef != null) { - if (targetRef.getType().equals(RoleType.COMPLEX_TYPE)) { - ContainerDelta assignmentDelta = prismContext.deltaFactory().container() - .createDelta(UserType.F_ASSIGNMENT, getUserDefinition()); - PrismContainerValue cval = prismContext.itemFactory().createContainerValue(); - cval.setId(assignment.getId()); - assignmentDelta.addValueToDelete(cval); - modifications.add(assignmentDelta); - } - } - } - if (modifications.isEmpty()) { - return; - } - ObjectDelta userDelta = prismContext.deltaFactory().object() - .createModifyDelta(userOid, modifications, UserType.class); - Collection> deltas = MiscSchemaUtil.createCollection(userDelta); - modelService.executeChanges(deltas, useRawPlusRecompute ? ModelExecuteOptions.createRaw() : null, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - - if (useRawPlusRecompute) { - recomputeUser(userOid, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - } - } - - protected void assignArchetype(String userOid, String archetypeOid, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, archetypeOid, ArchetypeType.COMPLEX_TYPE, null, task, (Consumer)null, true, result); - } - - protected void unassignArchetype(String userOid, String archetypeOid, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, archetypeOid, ArchetypeType.COMPLEX_TYPE, null, task, (Consumer)null, false, result); - } - - protected void induceRole(String focusRoleOid, String targetRoleOid, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - induceRole(RoleType.class, focusRoleOid, targetRoleOid, task, result); - } - - protected void induceRole(Class focusType, String focusOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyFocusAssignment(focusType, focusOid, AbstractRoleType.F_INDUCEMENT, roleOid, RoleType.COMPLEX_TYPE, null, task, null, true, null, result); - } - - protected void induceOrg(Class focusType, String focusOid, String orgOid, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyFocusAssignment(focusType, focusOid, AbstractRoleType.F_INDUCEMENT, orgOid, OrgType.COMPLEX_TYPE, null, task, null, true, null, result); - } - - protected void uninduceRole(Class focusType, String focusOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyFocusAssignment(focusType, focusOid, AbstractRoleType.F_INDUCEMENT, roleOid, RoleType.COMPLEX_TYPE, null, task, null, false, null, result); - } - - protected void uninduceRole(String focusRoleOid, String targetRoleOid, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - uninduceRole(RoleType.class, focusRoleOid, targetRoleOid, task, result); - } - - protected void assignOrg(String userOid, String orgOid, Task task, OperationResult result) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, - CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - assignOrg(userOid, orgOid, null, task, result); - } - - protected void assignOrg(Class focusType, String focusOid, String orgOid, Task task, OperationResult result) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, - CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - assignOrg(focusType, focusOid, orgOid, null, task, result); - } - - protected void assignOrg(String userOid, String orgOid) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - assignOrg(userOid, orgOid, prismContext.getDefaultRelation()); - } - - protected void assignOrg(String userOid, String orgOid, QName relation) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, - CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - Task task = createTask(AbstractIntegrationTest.class.getName()+".assignOrg"); - OperationResult result = task.getResult(); - assignOrg(userOid, orgOid, relation, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - } - - protected void assignOrg(String userOid, String orgOid, QName relation, Task task, OperationResult result) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, - CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, orgOid, OrgType.COMPLEX_TYPE, relation, task, (Consumer)null, true, result); - } - - protected void assignOrg(Class focusType, String focusOid, String orgOid, QName relation, Task task, OperationResult result) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, - CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyFocusAssignment(focusType, focusOid, orgOid, OrgType.COMPLEX_TYPE, relation, task, (Consumer)null, true, result); - } - - protected void unassignOrg(String userOid, String orgOid) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - unassignOrg(userOid, orgOid, prismContext.getDefaultRelation()); - } - - protected void unassignOrg(String userOid, String orgOid, Task task, OperationResult result) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, - CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - unassignOrg(userOid, orgOid, null, task, result); - } - - protected void unassignOrg(String userOid, String orgOid, QName relation) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".unassignOrg"); - OperationResult result = task.getResult(); - unassignOrg(userOid, orgOid, relation, task, result); - assertSuccess(result); - } - - protected void unassignOrg(String userOid, String orgOid, QName relation, Task task, OperationResult result) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, - CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, orgOid, OrgType.COMPLEX_TYPE, relation, task, (Consumer)null, false, result); - } - - protected void unassignOrg(Class type, String focusOid, String orgOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - unassignOrg(type, focusOid, orgOid, null, task, result); - } - - protected void unassignOrg(Class type, String focusOid, String orgOid, QName relation, Task task, OperationResult result) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, - CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyFocusAssignment(type, focusOid, orgOid, OrgType.COMPLEX_TYPE, relation, task, (Consumer)null, false, result); - } - - protected void modifyUserAssignment(String userOid, String roleOid, QName refType, QName relation, Task task, - PrismContainer extension, boolean add, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, roleOid, refType, relation, task, extension, null, add, result); - } - - protected void modifyUserAssignment(String userOid, String roleOid, QName refType, QName relation, Task task, - PrismContainer extension, ActivationType activationType, boolean add, OperationResult result) - throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, roleOid, refType, relation, task, extension, activationType, add, null, result); - } - - protected void modifyUserAssignment(String userOid, String roleOid, QName refType, QName relation, Task task, - PrismContainer extension, ActivationType activationType, boolean add, ModelExecuteOptions options, - OperationResult result) - throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - ObjectDelta userDelta = createAssignmentUserDelta(userOid, roleOid, refType, relation, extension, activationType, add); - executeChanges(userDelta, options, task, result); - } - - protected void modifyAssignmentHolderAssignment(Class focusClass, String focusOid, String roleOid, QName refType, QName relation, Task task, - PrismContainer extension, ActivationType activationType, boolean add, OperationResult result) - throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyAssignmentHolderAssignment(focusClass, focusOid, roleOid, refType, relation, task, extension, activationType, add, null, result); - } - - protected void modifyAssignmentHolderAssignment(Class focusClass, String focusOid, String roleOid, QName refType, QName relation, Task task, - PrismContainer extension, ActivationType activationType, boolean add, ModelExecuteOptions options, OperationResult result) - throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - ObjectDelta delta = createAssignmentAssignmentHolderDelta(focusClass, focusOid, roleOid, refType, relation, extension, activationType, add); - executeChanges(delta, options, task, result); - } - - protected void modifyUserAssignment(String userOid, String roleOid, QName refType, QName relation, Task task, - Consumer modificationBlock, boolean add, OperationResult result) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - modifyFocusAssignment(UserType.class, userOid, roleOid, refType, relation, task, modificationBlock, add, result); - } - - protected void modifyUserAssignment(String userOid, String roleOid, QName refType, QName relation, Task task, - Consumer modificationBlock, boolean add, ModelExecuteOptions options, OperationResult result) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - modifyFocusAssignment(UserType.class, userOid, roleOid, refType, relation, task, modificationBlock, add, options, result); - } - - protected void modifyFocusAssignment(Class focusClass, String focusOid, String roleOid, QName refType, QName relation, Task task, - Consumer modificationBlock, boolean add, OperationResult result) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - modifyFocusAssignment(focusClass, focusOid, roleOid, refType, relation, task, modificationBlock, add, null, result); - } - - protected void modifyFocusAssignment(Class focusClass, String focusOid, String roleOid, QName refType, QName relation, Task task, - Consumer modificationBlock, boolean add, ModelExecuteOptions options, OperationResult result) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - modifyFocusAssignment(focusClass, focusOid, FocusType.F_ASSIGNMENT, roleOid, refType, relation, task, modificationBlock, add, options, result); - } - - protected void modifyFocusAssignment(Class focusClass, String focusOid, QName elementName, String roleOid, QName refType, QName relation, Task task, - Consumer modificationBlock, boolean add, ModelExecuteOptions options, OperationResult result) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - ObjectDelta focusDelta = createAssignmentFocusDelta(focusClass, focusOid, elementName, roleOid, refType, relation, modificationBlock, add); - Collection> deltas = MiscSchemaUtil.createCollection(focusDelta); - executeChanges(focusDelta, options, task, result); - } - - protected void deleteFocusAssignmentEmptyDelta(PrismObject existingFocus, String targetOid, Task task, OperationResult result) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - deleteFocusAssignmentEmptyDelta(existingFocus, targetOid, null, null, task, result); - } - - protected void deleteFocusAssignmentEmptyDelta(PrismObject existingFocus, String targetOid, QName relation, Task task, OperationResult result) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - deleteFocusAssignmentEmptyDelta(existingFocus, targetOid, relation, null, task, result); - } - - protected void deleteFocusAssignmentEmptyDelta(PrismObject existingFocus, String targetOid, QName relation, - ModelExecuteOptions options, Task task, OperationResult result) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - ObjectDelta focusDelta = createAssignmentFocusEmptyDeleteDelta(existingFocus, targetOid, relation); - executeChanges(focusDelta, options, task, result); - } - - protected void unassign(Class focusClass, String focusOid, String roleId, Task task, OperationResult result) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - ObjectDelta focusDelta = createAssignmentAssignmentHolderDelta(focusClass, focusOid, roleId, null, null, null, null, false); - executeChanges(focusDelta, null, task, result); - } - - protected void unassign(Class focusClass, String focusOid, long assignmentId, Task task, OperationResult result) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - unassign(focusClass, focusOid, assignmentId, null, task, result); - } - - protected void unassign(Class focusClass, String focusOid, long assignmentId, ModelExecuteOptions options, Task task, OperationResult result) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - unassign(focusClass, focusOid, createAssignmentIdOnly(assignmentId), options, task, result); - } - - protected void unassign(Class focusClass, String focusOid, AssignmentType currentAssignment, ModelExecuteOptions options, Task task, OperationResult result) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - Collection> modifications = new ArrayList<>(); - ContainerDelta assignmentDelta = prismContext.deltaFactory().container().createDelta(UserType.F_ASSIGNMENT, getUserDefinition()); - assignmentDelta.addValuesToDelete(currentAssignment.asPrismContainerValue().clone()); - modifications.add(assignmentDelta); - ObjectDelta focusDelta = prismContext.deltaFactory().object().createModifyDelta(focusOid, modifications, focusClass - ); - executeChanges(focusDelta, options, task, result); - } - - protected void unlink(Class focusClass, String focusOid, String targetOid, Task task, OperationResult result) - throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - ObjectDelta delta = prismContext.deltaFactory().object() - .createModificationDeleteReference(focusClass, focusOid, FocusType.F_LINK_REF, - targetOid); - executeChanges(delta, null, task, result); - } - - protected void unlinkUser(String userOid, String targetOid) - throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - Task task = createTask("unlinkUser"); - OperationResult result = task.getResult(); - unlink(UserType.class, userOid, targetOid, task, result); - assertSuccess(result); - } - - /** - * Executes unassign delta by removing each assignment individually by id. - */ - protected void unassignAll(PrismObject focusBefore, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - executeChanges(createUnassignAllDelta(focusBefore), null, task, result); - } - - /** - * Creates unassign delta by removing each assignment individually by id. - */ - protected ObjectDelta createUnassignAllDelta(PrismObject focusBefore) throws SchemaException { - Collection> modifications = new ArrayList<>(); - for (AssignmentType assignmentType: focusBefore.asObjectable().getAssignment()) { - modifications.add((createAssignmentModification(assignmentType.getId(), false))); - } - return prismContext.deltaFactory().object() - .createModifyDelta(focusBefore.getOid(), modifications, focusBefore.getCompileTimeClass() - ); - } - - /** - * Executes assignment replace delta with empty values. - */ - protected void unassignAllReplace(String userOid, Task task, OperationResult result) - throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - ObjectDelta userDelta = prismContext.deltaFactory().object() - .createModificationReplaceContainer(UserType.class, userOid, - UserType.F_ASSIGNMENT, new PrismContainerValue[0]); - Collection> deltas = MiscSchemaUtil.createCollection(userDelta); - modelService.executeChanges(deltas, null, task, result); - } - - protected ContainerDelta createAssignmentModification(String roleOid, QName refType, QName relation, - PrismContainer extension, ActivationType activationType, boolean add) throws SchemaException { - return createAssignmentModification(UserType.class, FocusType.F_ASSIGNMENT, roleOid, refType, relation, extension, activationType, add); - } - - protected ContainerDelta createAssignmentModification(Class type, QName elementName, String roleOid, QName refType, QName relation, - PrismContainer extension, ActivationType activationType, boolean add) throws SchemaException { - try { - return createAssignmentModification(type, elementName, roleOid, refType, relation, - assignment -> { - if (extension != null) { - try { - assignment.asPrismContainerValue().add(extension.clone()); - } catch (SchemaException e) { - throw new TunnelException(e); - } - } - assignment.setActivation(activationType); - }, add); - } catch (TunnelException te) { - throw (SchemaException)te.getCause(); - } - } - - - protected ContainerDelta createAssignmentModification(Class type, QName elementName, String roleOid, QName refType, QName relation, - Consumer modificationBlock, boolean add) throws SchemaException { - ContainerDelta assignmentDelta = prismContext.deltaFactory().container().createDelta(ItemName.fromQName(elementName), getObjectDefinition(type)); - PrismContainerValue cval = prismContext.itemFactory().createContainerValue(); - if (add) { - assignmentDelta.addValueToAdd(cval); - } else { - assignmentDelta.addValueToDelete(cval); - } - PrismReference targetRef = cval.findOrCreateReference(AssignmentType.F_TARGET_REF); - targetRef.getValue().setOid(roleOid); - targetRef.getValue().setTargetType(refType); - targetRef.getValue().setRelation(relation); - if (modificationBlock != null) { - modificationBlock.accept(cval.asContainerable()); - } - return assignmentDelta; - } - - protected ContainerDelta createAssignmentModification(long id, boolean add) throws SchemaException { - ContainerDelta assignmentDelta = prismContext.deltaFactory().container().createDelta(UserType.F_ASSIGNMENT, getUserDefinition()); - PrismContainerValue cval = prismContext.itemFactory().createContainerValue(); - cval.setId(id); - if (add) { - assignmentDelta.addValueToAdd(cval); - } else { - assignmentDelta.addValueToDelete(cval); - } - return assignmentDelta; - } - - protected ContainerDelta createAssignmentEmptyDeleteModification(PrismObject existingFocus, String roleOid, QName relation) throws SchemaException { - AssignmentType existingAssignment = findAssignment(existingFocus, roleOid, relation); - return createAssignmentModification(existingAssignment.getId(), false); - } - - protected AssignmentType findAssignment(PrismObject existingFocus, String targetOid, QName relation) { - for (AssignmentType assignmentType : existingFocus.asObjectable().getAssignment()) { - if (assignmentMatches(assignmentType, targetOid, relation)) { - return assignmentType; - } - } - return null; - } - - protected boolean assignmentMatches(AssignmentType assignmentType, String targetOid, QName relation) { - ObjectReferenceType targetRef = assignmentType.getTargetRef(); - if (targetRef == null) { - return false; - } - return referenceMatches(targetRef, targetOid, relation); - } - - private boolean referenceMatches(ObjectReferenceType ref, String targetOid, QName relation) { - if (targetOid != null && !targetOid.equals(ref.getOid())) { - return false; - } - if (relation != null && !QNameUtil.match(relation, ref.getRelation())) { - return false; - } - return true; - } - - protected ObjectDelta createAssignmentUserDelta(String userOid, String roleOid, QName refType, QName relation, - PrismContainer extension, ActivationType activationType, boolean add) throws SchemaException { - Collection> modifications = new ArrayList<>(); - modifications.add((createAssignmentModification(roleOid, refType, relation, extension, activationType, add))); - ObjectDelta userDelta = prismContext.deltaFactory().object() - .createModifyDelta(userOid, modifications, UserType.class); - return userDelta; - } - - protected ObjectDelta createAssignmentAssignmentHolderDelta(Class focusClass, String focusOid, String roleOid, QName refType, QName relation, - PrismContainer extension, ActivationType activationType, boolean add) throws SchemaException { - Collection> modifications = new ArrayList<>(); - modifications.add((createAssignmentModification(roleOid, refType, relation, extension, activationType, add))); - return prismContext.deltaFactory().object().createModifyDelta(focusOid, modifications, focusClass); - } - - protected ObjectDelta createAssignmentUserDelta(String userOid, String roleOid, QName refType, QName relation, - Consumer modificationBlock, boolean add) throws SchemaException { - return createAssignmentFocusDelta(UserType.class, userOid, roleOid, refType, relation, modificationBlock, add); - } - - protected ObjectDelta createAssignmentFocusDelta(Class focusClass, String focusOid, String roleOid, QName refType, QName relation, - Consumer modificationBlock, boolean add) throws SchemaException { - return createAssignmentFocusDelta(focusClass, focusOid, FocusType.F_ASSIGNMENT, roleOid, refType, relation, modificationBlock, add); - } - - protected ObjectDelta createAssignmentFocusDelta(Class focusClass, String focusOid, QName elementName, String roleOid, QName refType, QName relation, - Consumer modificationBlock, boolean add) throws SchemaException { - Collection> modifications = new ArrayList<>(); - modifications.add((createAssignmentModification(focusClass, elementName, roleOid, refType, relation, modificationBlock, add))); - return prismContext.deltaFactory().object().createModifyDelta(focusOid, modifications, focusClass); - } - - protected ObjectDelta createAssignmentFocusEmptyDeleteDelta(PrismObject existingFocus, String roleOid, QName relation) throws SchemaException { - Collection> modifications = new ArrayList<>(); - modifications.add((createAssignmentEmptyDeleteModification(existingFocus, roleOid, relation))); - return prismContext.deltaFactory().object() - .createModifyDelta(existingFocus.getOid(), modifications, existingFocus.getCompileTimeClass() - ); - } - - protected ContainerDelta createAccountAssignmentModification(String resourceOid, String intent, boolean add) throws SchemaException { - return createAssignmentModification(resourceOid, ShadowKindType.ACCOUNT, intent, add); - } - - protected PropertyDelta createUserPropertyReplaceModification(QName propertyName, V... values) { - return prismContext.deltaFactory().property().createReplaceDelta(getUserDefinition(), propertyName, values); - } - - protected ContainerDelta createAssignmentModification(String resourceOid, ShadowKindType kind, - String intent, boolean add) throws SchemaException { - AssignmentType assignmentType = createConstructionAssignment(resourceOid, kind, intent); - return createAssignmentModification(assignmentType, add); - } - - protected ContainerDelta createAssignmentModification(AssignmentType assignmentType, boolean add) throws SchemaException { - ContainerDelta assignmentDelta = prismContext.deltaFactory().container().createDelta(UserType.F_ASSIGNMENT, getUserDefinition()); - - if (add) { - assignmentDelta.addValueToAdd(assignmentType.asPrismContainerValue()); - } else { - assignmentDelta.addValueToDelete(assignmentType.asPrismContainerValue()); - } - - PrismContainerDefinition assignmentDef = getUserDefinition().findContainerDefinition(UserType.F_ASSIGNMENT); - assignmentDelta.applyDefinition(assignmentDef); - - return assignmentDelta; - } - - protected AssignmentType createAccountAssignment(String resourceOid, String intent) { - return createConstructionAssignment(resourceOid, ShadowKindType.ACCOUNT, intent); - } - - protected AssignmentType createConstructionAssignment(String resourceOid, ShadowKindType kind, String intent) { - AssignmentType assignmentType = new AssignmentType(); - ConstructionType constructionType = new ConstructionType(); - constructionType.setKind(kind); - assignmentType.setConstruction(constructionType); - ObjectReferenceType resourceRef = new ObjectReferenceType(); - resourceRef.setOid(resourceOid); - resourceRef.setType(ResourceType.COMPLEX_TYPE); - constructionType.setResourceRef(resourceRef); - constructionType.setIntent(intent); - return assignmentType; - } - - protected AssignmentType createTargetAssignment(String targetOid, QName targetType) { - AssignmentType assignmentType = new AssignmentType(); - ObjectReferenceType targetRef = new ObjectReferenceType(); - targetRef.setOid(targetOid); - targetRef.setType(targetType); - assignmentType.setTargetRef(targetRef); - return assignmentType; - } - - protected ObjectDelta createParametricAssignmentDelta(String userOid, String roleOid, String orgOid, String tenantOid, boolean adding) throws SchemaException { - Collection> modifications = new ArrayList<>(); - - ContainerDelta assignmentDelta = prismContext.deltaFactory().container().createDelta(UserType.F_ASSIGNMENT, getUserDefinition()); - PrismContainerValue cval = prismContext.itemFactory().createContainerValue(); - if (adding) { - assignmentDelta.addValueToAdd(cval); - } else { - assignmentDelta.addValueToDelete(cval); - } - PrismReference targetRef = cval.findOrCreateReference(AssignmentType.F_TARGET_REF); - targetRef.getValue().setOid(roleOid); - targetRef.getValue().setTargetType(RoleType.COMPLEX_TYPE); - - if (orgOid != null) { - PrismReference orgRef = cval.findOrCreateReference(AssignmentType.F_ORG_REF); - orgRef.getValue().setOid(orgOid); - } - - if (tenantOid != null) { - PrismReference tenantRef = cval.findOrCreateReference(AssignmentType.F_TENANT_REF); - tenantRef.getValue().setOid(tenantOid); - } - - - modifications.add(assignmentDelta); - return prismContext.deltaFactory().object().createModifyDelta(userOid, modifications, UserType.class - ); - } - - protected void assignParametricRole(String userOid, String roleOid, String orgOid, String tenantOid, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - assignParametricRole(userOid, roleOid, orgOid, tenantOid, null, task, result); - } - - protected void assignParametricRole(String userOid, String roleOid, String orgOid, String tenantOid, ModelExecuteOptions options, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Collection> deltas = MiscSchemaUtil.createCollection( - createParametricAssignmentDelta(userOid, roleOid, orgOid, tenantOid, true)); - modelService.executeChanges(deltas, options, task, result); - } - - protected void unassignParametricRole(String userOid, String roleOid, String orgOid, String tenantOid, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - unassignParametricRole(userOid, roleOid, orgOid, tenantOid, null, task, result); - } - - protected void unassignParametricRole(String userOid, String roleOid, String orgOid, String tenantOid, ModelExecuteOptions options, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Collection> deltas = MiscSchemaUtil.createCollection( - createParametricAssignmentDelta(userOid, roleOid, orgOid, tenantOid, false)); - modelService.executeChanges(deltas, options, task, result); - } - - protected void assertAssignees(String targetOid, int expectedAssignees) throws SchemaException { - assertAssignees(targetOid, prismContext.getDefaultRelation(), expectedAssignees); - } - - protected void assertAssignees(String targetOid, QName relation, int expectedAssignees) throws SchemaException { - OperationResult result = new OperationResult(AbstractModelIntegrationTest.class.getName()+".assertAssignees"); - int count = countAssignees(targetOid, relation, result); - if (count != expectedAssignees) { - SearchResultList> assignees = listAssignees(targetOid, result); - AssertJUnit.fail("Unexpected number of assignees of "+targetOid+" as '"+relation+"', expected "+expectedAssignees+", but was " + count+ ": "+assignees); - } - - } - - protected int countAssignees(String targetOid, OperationResult result) throws SchemaException { - return countAssignees(targetOid, prismContext.getDefaultRelation(), result); - } - - protected int countAssignees(String targetOid, QName relation, OperationResult result) throws SchemaException { - PrismReferenceValue refVal = itemFactory().createReferenceValue(); - refVal.setOid(targetOid); - refVal.setRelation(relation); - ObjectQuery query = prismContext.queryFor(FocusType.class) - .item(FocusType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF).ref(refVal) - .build(); - return repositoryService.countObjects(FocusType.class, query, null, result); - } - - protected SearchResultList> listAssignees(String targetOid, OperationResult result) throws SchemaException { - ObjectQuery query = prismContext.queryFor(FocusType.class) - .item(FocusType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF).ref(targetOid) - .build(); - return repositoryService.searchObjects(FocusType.class, query, null, result); - } - - protected ConstructionType createAccountConstruction(String resourceOid, String intent) throws SchemaException { - ConstructionType accountConstructionType = new ConstructionType(); - ObjectReferenceType resourceRef = new ObjectReferenceType(); - resourceRef.setOid(resourceOid); - accountConstructionType.setResourceRef(resourceRef); - accountConstructionType.setIntent(intent); - return accountConstructionType; - } - - protected ObjectDelta createReplaceAccountConstructionUserDelta(String userOid, Long id, ConstructionType newValue) throws SchemaException { - PrismContainerDefinition pcd = getAssignmentDefinition().findContainerDefinition(AssignmentType.F_CONSTRUCTION); - ContainerDelta acDelta = prismContext.deltaFactory().container().create( - ItemPath.create(UserType.F_ASSIGNMENT, id, AssignmentType.F_CONSTRUCTION), pcd); - acDelta.setValueToReplace(newValue.asPrismContainerValue()); - - Collection> modifications = new ArrayList<>(); - modifications.add(acDelta); - ObjectDelta userDelta = prismContext.deltaFactory().object() - .createModifyDelta(userOid, modifications, UserType.class); - return userDelta; - } - - protected ObjectDelta createAccountAssignmentUserDelta(String focusOid, String resourceOid, String intent, boolean add) throws SchemaException { - return createAssignmentDelta(UserType.class, focusOid, resourceOid, ShadowKindType.ACCOUNT, intent, add); - } - - protected ObjectDelta createAssignmentDelta(Class type, String focusOid, - String resourceOid, ShadowKindType kind, String intent, boolean add) throws SchemaException { - Collection> modifications = new ArrayList<>(); - modifications.add(createAssignmentModification(resourceOid, kind, intent, add)); - ObjectDelta userDelta = prismContext.deltaFactory().object().createModifyDelta(focusOid, modifications, type - ); - return userDelta; - } - - protected Collection> executeChanges(ObjectDelta objectDelta, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - display("Executing delta", objectDelta); - Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); - return modelService.executeChanges(deltas, options, task, result); - } - - protected Collection> executeChanges(Collection> deltas, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - display("Executing deltas", deltas); - return modelService.executeChanges(deltas, options, task, result); - } - - protected Collection> executeChangesAssertSuccess(ObjectDelta objectDelta, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Collection> rv = executeChanges(objectDelta, options, task, result); - assertSuccess(result); - return rv; - } - - protected ModelContext previewChanges(ObjectDelta objectDelta, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - display("Preview changes for delta", objectDelta); - Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); - return modelInteractionService.previewChanges(deltas, options, task, result); - } - - protected void assignAccountToUser(String focusOid, String resourceOid, String intent) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - assignAccount(UserType.class, focusOid, resourceOid, intent); - } - - protected void assignAccount(Class type, String focusOid, String resourceOid, String intent) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".assignAccount"); - OperationResult result = task.getResult(); - assignAccount(type, focusOid, resourceOid, intent, task, result); - assertSuccess(result); - } - - protected void assignAccountToUser(String focusOid, String resourceOid, String intent, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - assignAccount(UserType.class, focusOid, resourceOid, intent, task, result); - } - - protected void assignAccount(Class type, String focusOid, String resourceOid, String intent, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - ObjectDelta userDelta = createAssignmentDelta(type, focusOid, resourceOid, ShadowKindType.ACCOUNT, intent, true); - executeChanges(userDelta, null, task, result); - } - - protected void unassignAccountFromUser(String focusOid, String resourceOid, String intent) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - unassignAccount(UserType.class, focusOid, resourceOid, intent); - } - - protected void unassignAccount(Class type, String focusOid, String resourceOid, String intent) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".assignAccount"); - OperationResult result = task.getResult(); - unassignAccount(type, focusOid, resourceOid, intent, task, result); - assertSuccess(result); - } - - protected void unassignAccountFromUser(String focusOid, String resourceOid, String intent, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - unassignAccount(UserType.class, focusOid, resourceOid, intent, task, result); - } - - protected void unassignAccount(Class type, String focusOid, String resourceOid, String intent, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - ObjectDelta userDelta = createAssignmentDelta(type, focusOid, resourceOid, ShadowKindType.ACCOUNT, intent, false); - Collection> deltas = MiscSchemaUtil.createCollection(userDelta); - modelService.executeChanges(deltas, null, task, result); - } - - protected void assignPolicyRule(Class type, String focusOid, PolicyRuleType policyRule, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - AssignmentType assignmentType = new AssignmentType(); - assignmentType.setPolicyRule(policyRule); - assign(type, focusOid, assignmentType, task, result); - } - - protected void assign(Class type, String focusOid, AssignmentType assignmentType, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Collection> modifications = new ArrayList<>(); - modifications.add(createAssignmentModification(assignmentType, true)); - ObjectDelta userDelta = prismContext.deltaFactory().object().createModifyDelta(focusOid, modifications, type - ); - executeChanges(userDelta, null, task, result); - } - - protected PrismObject getUser(String userOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".getUser"); - OperationResult result = task.getResult(); - PrismObject user = modelService.getObject(UserType.class, userOid, null, task, result); - result.computeStatus(); - TestUtil.assertSuccess("getObject(User) result not success", result); - return user; - } - - protected PrismObject getUserFromRepo(String userOid) throws ObjectNotFoundException, SchemaException { - return repositoryService.getObject(UserType.class, userOid, null, new OperationResult("dummy")); - } - - protected PrismObject findObjectByName(Class type, String name) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = getOrCreateSimpleTask("findObjectByName"); - OperationResult result = task.getResult(); - List> objects = modelService.searchObjects(type, createNameQuery(name), null, task, result); - if (objects.isEmpty()) { - return null; - } - assert objects.size() == 1 : "Too many objects found for name "+name+": "+objects; - return objects.iterator().next(); - } - - protected ObjectQuery createNameQuery(String name) throws SchemaException { - return ObjectQueryUtil.createNameQuery(PrismTestUtil.createPolyString(name), prismContext); - } - - protected PrismObject findUserByUsername(String username) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - return findObjectByName(UserType.class, username); - } - - protected PrismObject findServiceByName(String name) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - return findObjectByName(ServiceType.class, name); - } - - protected RoleType getRoleSimple(String oid) { - try { - return getRole(oid).asObjectable(); - } catch (CommonException e) { - throw new SystemException("Unexpected exception while getting role " + oid + ": " + e.getMessage(), e); - } - } - - protected PrismObject getRole(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".getRole"); - OperationResult result = task.getResult(); - PrismObject role = modelService.getObject(RoleType.class, oid, null, task, result); - result.computeStatus(); - TestUtil.assertSuccess("getObject(Role) result not success", result); - return role; - } - - protected PrismObject findAccountByUsername(String username, PrismObject resource) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".findAccountByUsername"); - OperationResult result = task.getResult(); - return findAccountByUsername(username, resource, task, result); - } - - protected PrismObject findAccountByUsername(String username, PrismObject resource, - Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - ObjectQuery query = createAccountShadowQuery(username, resource); - List> accounts = modelService.searchObjects(ShadowType.class, query, null, task, result); - if (accounts.isEmpty()) { - return null; - } - assert accounts.size() == 1 : "Too many accounts found for username "+username+" on "+resource+": "+accounts; - return accounts.iterator().next(); - } - - protected Collection> listAccounts(PrismObject resource, - Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - - RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource); - RefinedObjectClassDefinition rAccount = rSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT); - Collection identifierDefs = rAccount.getPrimaryIdentifiers(); - assert identifierDefs.size() == 1 : "Unexpected identifier set in "+resource+" refined schema: "+identifierDefs; - ResourceAttributeDefinition identifierDef = identifierDefs.iterator().next(); - ObjectQuery query = prismContext.queryFor(ShadowType.class) - .item(ShadowType.F_OBJECT_CLASS).eq(rAccount.getObjectClassDefinition().getTypeName()) - .and().item(ShadowType.F_RESOURCE_REF).ref(resource.getOid()) - .build(); - List> accounts = modelService.searchObjects(ShadowType.class, query, null, task, result); - return accounts; - } - - protected PrismObject getShadowModel(String accountOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - return getShadowModel(accountOid, null, true); - } - - protected PrismObject getShadowModelNoFetch(String accountOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - return getShadowModel(accountOid, GetOperationOptions.createNoFetch(), true); - } - - protected PrismObject getShadowModelFuture(String accountOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - return getShadowModel(accountOid, GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE), true); - } - - protected PrismObject getShadowModel(String shadowOid, GetOperationOptions rootOptions, boolean assertSuccess) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".getShadowModel"); - OperationResult result = task.getResult(); - Collection> opts = null; - if (rootOptions != null) { - opts = SelectorOptions.createCollection(rootOptions); - } - LOGGER.info("Getting model shadow {} with options {}", shadowOid, opts); - PrismObject shadow = modelService.getObject(ShadowType.class, shadowOid, opts , task, result); - LOGGER.info("Got model shadow (options {})\n{}", shadowOid, shadow.debugDumpLazily(1)); - result.computeStatus(); - if (assertSuccess) { - TestUtil.assertSuccess("getObject(shadow) result not success", result); - } - return shadow; - } - - protected void assertNoObject(Class type, String oid) throws SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = createTask(AbstractModelIntegrationTest.class.getName() + ".assertNoObject"); - assertNoObject(type, oid, task, task.getResult()); - } - - protected void assertNoObject(Class type, String oid, Task task, OperationResult result) throws SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - try { - PrismObject object = modelService.getObject(type, oid, null, task, result); - display("Unexpected object", object); - AssertJUnit.fail("Expected that "+object+" does not exist, but it does"); - } catch (ObjectNotFoundException e) { - // This is expected - return; - } - } - - protected void assertObjectByName(Class type, String name, Task task, OperationResult result) - throws SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, - ExpressionEvaluationException, ObjectNotFoundException { - SearchResultList> objects = modelService - .searchObjects(type, prismContext.queryFor(type).item(ObjectType.F_NAME).eqPoly(name).build(), null, task, - result); - if (objects.isEmpty()) { - fail("Expected that " + type + " " + name + " did exist but it did not"); - } - } - - protected void assertNoObjectByName(Class type, String name, Task task, OperationResult result) - throws SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, - ExpressionEvaluationException, ObjectNotFoundException { - SearchResultList> objects = modelService - .searchObjects(type, prismContext.queryFor(type).item(ObjectType.F_NAME).eqPoly(name).build(), null, task, - result); - if (!objects.isEmpty()) { - fail("Expected that " + type + " " + name + " did not exists but it did: " + objects); - } - } - - protected void assertNoShadow(String username, PrismObject resource, - Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException { - ObjectQuery query = createAccountShadowQuery(username, resource); - List> accounts = repositoryService.searchObjects(ShadowType.class, query, null, result); - if (accounts.isEmpty()) { - return; - } - LOGGER.error("Found shadow for "+username+" on "+resource+" while not expecting it:\n"+accounts.get(0).debugDump()); - assert false : "Found shadow for "+username+" on "+resource+" while not expecting it: "+accounts; - } - - protected void assertHasShadow(String username, PrismObject resource, - Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException { - ObjectQuery query = createAccountShadowQuery(username, resource); - List> accounts = repositoryService.searchObjects(ShadowType.class, query, null, result); - if (accounts.isEmpty()) { - AssertJUnit.fail("No shadow for "+username+" on "+resource); - } else if (accounts.size() > 1) { - AssertJUnit.fail("Too many shadows for "+username+" on "+resource+" ("+accounts.size()+"): "+accounts); - } - } - - protected ShadowAsserter assertShadow(String username, PrismObject resource) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException { - ObjectQuery query = createAccountShadowQuery(username, resource); - OperationResult result = new OperationResult("assertShadow"); - List> accounts = repositoryService.searchObjects(ShadowType.class, query, null, result); - if (accounts.isEmpty()) { - AssertJUnit.fail("No shadow for "+username+" on "+resource); - } else if (accounts.size() > 1) { - AssertJUnit.fail("Too many shadows for "+username+" on "+resource+" ("+accounts.size()+"): "+accounts); - } - ShadowAsserter asserter = ShadowAsserter.forShadow(accounts.get(0), "shadow for username "+username+" on "+resource); - initializeAsserter(asserter); - asserter.display(); - return asserter; - } - - protected ShadowAsserter assertShadowByName(ShadowKindType kind, String intent, String name, - PrismObject resource, String message, OperationResult result) - throws ConfigurationException, SchemaException, ObjectNotFoundException, CommunicationException, - SecurityViolationException { - PrismObject shadow = findShadowByName(kind, intent, name, resource, result); - assertNotNull("No shadow with name '"+name+"'", shadow); - return assertShadow(shadow, message); - } - - protected ShadowAsserter assertShadowByNameViaModel(ShadowKindType kind, String intent, String name, - PrismObject resource, String message, Task task, OperationResult result) - throws ConfigurationException, SchemaException, ObjectNotFoundException, CommunicationException, - SecurityViolationException, ExpressionEvaluationException { - PrismObject shadow = findShadowByNameViaModel(kind, intent, name, resource, task, result); - assertNotNull("No shadow with name '"+name+"'", shadow); - return assertShadow(shadow, message); - } - - protected PrismObject findShadowByNameViaModel(ShadowKindType kind, String intent, String name, - PrismObject resource, Task task, OperationResult result) - throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, - ConfigurationException, ExpressionEvaluationException { - return findShadowByNameViaModel(kind, intent, name, resource, schemaHelper.getOperationOptionsBuilder().noFetch().build(), - task, result); - } - - protected PrismObject findShadowByNameViaModel(ShadowKindType kind, String intent, String name, - PrismObject resource, Collection> options, Task task, - OperationResult result) - throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, - ConfigurationException, ExpressionEvaluationException { - RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource); - RefinedObjectClassDefinition rOcDef = rSchema.getRefinedDefinition(kind,intent); - ObjectQuery query = createShadowQuerySecondaryIdentifier(rOcDef, name, resource); - List> shadows = modelService.searchObjects(ShadowType.class, query, options, task, result); - if (shadows.isEmpty()) { - return null; - } - assert shadows.size() == 1 : "Too many shadows found for name "+name+" on "+resource+": "+shadows; - return shadows.iterator().next(); - } - - - protected ObjectQuery createAccountShadowQuery(String username, PrismObject resource) throws SchemaException { - RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource); - RefinedObjectClassDefinition rAccount = rSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT); - Collection identifierDefs = rAccount.getPrimaryIdentifiers(); - assert identifierDefs.size() == 1 : "Unexpected identifier set in "+resource+" refined schema: "+identifierDefs; - ResourceAttributeDefinition identifierDef = identifierDefs.iterator().next(); - //TODO: set matching rule instead of null - return prismContext.queryFor(ShadowType.class) - .itemWithDef(identifierDef, ShadowType.F_ATTRIBUTES, identifierDef.getItemName()).eq(username) - .and().item(ShadowType.F_OBJECT_CLASS).eq(rAccount.getObjectClassDefinition().getTypeName()) - .and().item(ShadowType.F_RESOURCE_REF).ref(resource.getOid()) - .build(); - } - - protected String getSingleLinkOid(PrismObject focus) { - PrismReferenceValue accountRefValue = getSingleLinkRef(focus); - assertNull("Unexpected object in linkRefValue", accountRefValue.getObject()); - return accountRefValue.getOid(); - } - - protected PrismReferenceValue getSingleLinkRef(PrismObject focus) { - F focusType = focus.asObjectable(); - assertEquals("Unexpected number of linkRefs", 1, focusType.getLinkRef().size()); - ObjectReferenceType linkRefType = focusType.getLinkRef().get(0); - String accountOid = linkRefType.getOid(); - assertFalse("No linkRef oid", StringUtils.isBlank(accountOid)); - PrismReferenceValue accountRefValue = linkRefType.asReferenceValue(); - assertEquals("OID mismatch in linkRefValue", accountOid, accountRefValue.getOid()); - return accountRefValue; - } - - protected String getLinkRefOid(String userOid, String resourceOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - return getLinkRefOid(getUser(userOid), resourceOid); - } - - protected String getLinkRefOid(PrismObject focus, String resourceOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - PrismReferenceValue linkRef = getLinkRef(focus, resourceOid); - if (linkRef == null) { - return null; - } - return linkRef.getOid(); - } - - protected PrismReferenceValue getLinkRef(PrismObject focus, String resourceOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - F focusType = focus.asObjectable(); - for (ObjectReferenceType linkRefType: focusType.getLinkRef()) { - String linkTargetOid = linkRefType.getOid(); - assertFalse("No linkRef oid", StringUtils.isBlank(linkTargetOid)); - PrismObject account = getShadowModel(linkTargetOid, GetOperationOptions.createNoFetch(), false); - if (resourceOid.equals(account.asObjectable().getResourceRef().getOid())) { - // This is noFetch. Therefore there is no fetchResult - return linkRefType.asReferenceValue(); - } - } - AssertJUnit.fail("Account for resource "+resourceOid+" not found in "+focus); - return null; // Never reached. But compiler complains about missing return - } - - protected String getLinkRefOid(PrismObject focus, String resourceOid, ShadowKindType kind, String intent) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - F focusType = focus.asObjectable(); - for (ObjectReferenceType linkRefType: focusType.getLinkRef()) { - String linkTargetOid = linkRefType.getOid(); - assertFalse("No linkRef oid", StringUtils.isBlank(linkTargetOid)); - PrismObject account = getShadowModel(linkTargetOid, GetOperationOptions.createNoFetch(), false); - ShadowType shadowType = account.asObjectable(); - if (kind != null && !kind.equals(shadowType.getKind())) { - continue; - } - if (!MiscUtil.equals(intent, shadowType.getIntent())) { - continue; - } - if (resourceOid.equals(shadowType.getResourceRef().getOid())) { - // This is noFetch. Therefore there is no fetchResult - return linkTargetOid; - } - } - AssertJUnit.fail("Linked shadow for resource "+resourceOid+", kind "+kind+" and intent "+intent+" not found in "+focus); - return null; // Never reached. But compiler complains about missing return - } - - protected void assertUserNoAccountRefs(PrismObject user) { - UserType userJackType = user.asObjectable(); - assertEquals("Unexpected number of accountRefs", 0, userJackType.getLinkRef().size()); - } - - protected String assertAccount(PrismObject user, String resourceOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - String accountOid = getLinkRefOid(user, resourceOid); - assertNotNull("User " + user + " has no account on resource " + resourceOid, accountOid); - return accountOid; - } - - protected void assertAccounts(String userOid, int numAccounts) throws ObjectNotFoundException, SchemaException { - OperationResult result = new OperationResult("assertAccounts"); - PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); - assertLinks(user, numAccounts); - } - - protected void assertNoShadows(Collection shadowOids) throws SchemaException { - for (String shadowOid: shadowOids) { - assertNoShadow(shadowOid); - } - } - - protected void assertNoShadow(String shadowOid) throws SchemaException { - OperationResult result = new OperationResult(AbstractModelIntegrationTest.class.getName() + ".assertNoShadow"); - // Check is shadow is gone - try { - PrismObject shadow = repositoryService.getObject(ShadowType.class, shadowOid, null, result); - display("Unexpected shadow", shadow); - AssertJUnit.fail("Shadow "+shadowOid+" still exists"); - } catch (ObjectNotFoundException e) { - // This is OK - } - } - - protected AssignmentType getUserAssignment(String userOid, String roleOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - return getAssignment(getUser(userOid), roleOid); - } - - protected AssignmentType getUserAssignment(String userOid, String roleOid, QName relation) - throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - PrismObject user = getUser(userOid); - List assignments = user.asObjectable().getAssignment(); - for (AssignmentType assignment: assignments) { - ObjectReferenceType targetRef = assignment.getTargetRef(); - if (targetRef != null && roleOid.equals(targetRef.getOid()) && prismContext.relationMatches(relation, - targetRef.getRelation())) { - return assignment; - } - } - return null; - } - - protected AssignmentType getAssignment(PrismObject focus, String roleOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - List assignments = focus.asObjectable().getAssignment(); - for (AssignmentType assignment: assignments) { - ObjectReferenceType targetRef = assignment.getTargetRef(); - if (targetRef != null && roleOid.equals(targetRef.getOid())) { - return assignment; - } - } - return null; - } - - protected ItemPath getAssignmentPath(long id) { - return ItemPath.create(FocusType.F_ASSIGNMENT, id); - } - - protected void assertNoAssignments(PrismObject user) { - MidPointAsserts.assertNoAssignments(user); - } - - protected void assertNoAssignments(String userOid, OperationResult result) throws ObjectNotFoundException, SchemaException { - PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); - assertNoAssignments(user); - } - - protected void assertNoAssignments(String userOid) throws ObjectNotFoundException, SchemaException { - OperationResult result = new OperationResult(AbstractModelIntegrationTest.class.getName() + ".assertNoShadow"); - assertNoAssignments(userOid, result); - } - - protected AssignmentType assertAssignedRole(String userOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { - PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); - return assertAssignedRole(user, roleOid); - } - - protected AssignmentType assertAssignedRole(PrismObject focus, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { - return assertAssignedRole(focus, roleOid); - } - - protected AssignmentType assertAssignedRole(PrismObject user, String roleOid) { - return MidPointAsserts.assertAssignedRole(user, roleOid); - } - - protected static void assertAssignedRoles(PrismObject user, String... roleOids) { - MidPointAsserts.assertAssignedRoles(user, roleOids); - } - - protected static void assertAssignedRoles(PrismObject user, Collection roleOids) { - MidPointAsserts.assertAssignedRoles(user, roleOids); - } - - protected AssignmentType assertInducedRole(PrismObject role, String roleOid) { - return MidPointAsserts.assertInducedRole(role, roleOid); - } - - protected void assignDeputy(String userDeputyOid, String userTargetOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - assignDeputy(userDeputyOid, userTargetOid, null, task, result); - } - - protected void assignDeputy(String userDeputyOid, String userTargetOid, Consumer modificationBlock, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userDeputyOid, userTargetOid, UserType.COMPLEX_TYPE, SchemaConstants.ORG_DEPUTY, task, modificationBlock, true, result); - } - - protected void unassignDeputy(String userDeputyOid, String userTargetOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - unassignDeputy(userDeputyOid, userTargetOid, null, task, result); - } - - protected void unassignDeputy(String userDeputyOid, String userTargetOid, Consumer modificationBlock, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userDeputyOid, userTargetOid, UserType.COMPLEX_TYPE, SchemaConstants.ORG_DEPUTY, task, modificationBlock, false, result); - } - - protected void assignDeputyLimits(String userDeputyOid, String userTargetOid, Task task, OperationResult result, ObjectReferenceType... limitTargets) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - modifyDeputyAssignmentLimits(userDeputyOid, userTargetOid, true, null, task, result, limitTargets); - } - - protected void assignDeputyLimits(String userDeputyOid, String userTargetOid, Consumer assignmentMutator, Task task, OperationResult result, ObjectReferenceType... limitTargets) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - modifyDeputyAssignmentLimits(userDeputyOid, userTargetOid, true, assignmentMutator, task, result, limitTargets); - } - - protected void unassignDeputyLimits(String userDeputyOid, String userTargetOid, Task task, OperationResult result, ObjectReferenceType... limitTargets) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - modifyDeputyAssignmentLimits(userDeputyOid, userTargetOid, false, null, task, result, limitTargets); - } - - protected void unassignDeputyLimits(String userDeputyOid, String userTargetOid, Consumer assignmentMutator, Task task, OperationResult result, ObjectReferenceType... limitTargets) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - modifyDeputyAssignmentLimits(userDeputyOid, userTargetOid, false, assignmentMutator, task, result, limitTargets); - } - - protected void modifyDeputyAssignmentLimits(String userDeputyOid, String userTargetOid, boolean add, Consumer assignmentMutator, Task task, OperationResult result, ObjectReferenceType... limitTargets) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userDeputyOid, userTargetOid, UserType.COMPLEX_TYPE, SchemaConstants.ORG_DEPUTY, task, - assignment -> { - AssignmentSelectorType limitTargetContent = new AssignmentSelectorType(); - assignment.setLimitTargetContent(limitTargetContent); - for (ObjectReferenceType limitTarget: limitTargets) { - limitTargetContent.getTargetRef().add(limitTarget); - } - if (assignmentMutator != null) { - assignmentMutator.accept(assignment); - } - }, add, result); - } - - protected void assertAssignedDeputy(PrismObject focus, String targetUserOid) { - MidPointAsserts.assertAssigned(focus, targetUserOid, UserType.COMPLEX_TYPE, SchemaConstants.ORG_DEPUTY); - } - - protected static void assertAssignedOrgs(PrismObject user, String... orgOids) { - MidPointAsserts.assertAssignedOrgs(user, orgOids); - } - - protected void assertObjectRefs(String contextDesc, Collection real, ObjectType... expected) { - assertObjectRefs(contextDesc, real, objectsToOids(expected)); - } - - protected void assertPrismRefValues(String contextDesc, Collection real, ObjectType... expected) { - assertPrismRefValues(contextDesc, real, objectsToOids(expected)); - } - - protected void assertPrismRefValues(String contextDesc, Collection real, Collection expected) { - assertPrismRefValues(contextDesc, real, objectsToOids(expected)); - } - - protected void assertObjectRefs(String contextDesc, Collection real, String... expected) { - assertObjectRefs(contextDesc, true, real, expected); - } - - protected void assertObjectRefs(String contextDesc, boolean checkNames, Collection real, String... expected) { - List refOids = new ArrayList<>(); - for (ObjectReferenceType ref: real) { - refOids.add(ref.getOid()); - assertNotNull("Missing type in "+ref.getOid()+" in "+contextDesc, ref.getType()); - if (checkNames) { - assertNotNull("Missing name in " + ref.getOid() + " in " + contextDesc, ref.getTargetName()); - } - } - PrismAsserts.assertSets("Wrong values in "+contextDesc, refOids, expected); - } - - protected void assertPrismRefValues(String contextDesc, Collection real, String... expected) { - List refOids = new ArrayList<>(); - for (PrismReferenceValue ref: real) { - refOids.add(ref.getOid()); - assertNotNull("Missing type in "+ref.getOid()+" in "+contextDesc, ref.getTargetType()); - assertNotNull("Missing name in "+ref.getOid()+" in "+contextDesc, ref.getTargetName()); - } - PrismAsserts.assertSets("Wrong values in "+contextDesc, refOids, expected); - } - - private String[] objectsToOids(ObjectType[] objects) { - return Arrays.stream(objects) - .map(o -> o.getOid()) - .toArray(String[]::new); - } - - private String[] objectsToOids(Collection objects) { - return objects.stream() - .map(o -> o.getOid()) - .toArray(String[]::new); - } - - protected void assertDelegatedRef(PrismObject focus, String... oids) { - List refOids = new ArrayList<>(); - for (ObjectReferenceType ref: focus.asObjectable().getDelegatedRef()) { - refOids.add(ref.getOid()); - assertNotNull("Missing type in delegatedRef "+ref.getOid()+" in "+focus, ref.getType()); - } - PrismAsserts.assertSets("Wrong values in delegatedRef in "+focus, refOids, oids); - } - - protected void assertNotAssignedRole(PrismObject focus, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { - MidPointAsserts.assertNotAssignedRole(focus, roleOid); - } - - protected void assertNotAssignedRole(String userOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { - PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); - MidPointAsserts.assertNotAssignedRole(user, roleOid); - } - - protected void assertNotAssignedResource(String userOid, String resourceOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { - PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); - MidPointAsserts.assertNotAssignedResource(user, resourceOid); - } - - protected void assertAssignedResource(Class type, String userOid, String resourceOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { - PrismObject focus = repositoryService.getObject(type, userOid, null, result); - MidPointAsserts.assertAssignedResource(focus, resourceOid); - } - - protected void assertNotAssignedRole(PrismObject user, String roleOid) { - MidPointAsserts.assertNotAssignedRole(user, roleOid); - } - - protected void assertNotAssignedOrg(PrismObject user, String orgOid, QName relation) { - MidPointAsserts.assertNotAssignedOrg(user, orgOid, relation); - } - - protected void assertAssignedOrg(String userOid, String orgOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { - PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); - assertAssignedOrg(user, orgOid); - } - - protected void assertAssignedOrg(PrismObject focus, String orgOid, QName relation) { - MidPointAsserts.assertAssignedOrg(focus, orgOid, relation); - } - - protected AssignmentType assertAssignedOrg(PrismObject focus, String orgOid) { - return MidPointAsserts.assertAssignedOrg(focus, orgOid); - } - - protected void assertNotAssignedOrg(PrismObject focus, String orgOid) { - MidPointAsserts.assertNotAssignedOrg(focus, orgOid); - } - - protected AssignmentType assertAssignedOrg(PrismObject user, PrismObject org) { - return MidPointAsserts.assertAssignedOrg(user, org.getOid()); - } - - protected void assertHasOrg(String userOid, String orgOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { - PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); - assertAssignedOrg(user, orgOid); - } - - protected void assertHasOrgs(PrismObject user, String... orgOids) throws Exception { - for (String orgOid: orgOids) { - assertHasOrg(user, orgOid); - } - assertHasOrgs(user, orgOids.length); - } - - protected void assertHasOrg(PrismObject focus, String orgOid) { - MidPointAsserts.assertHasOrg(focus, orgOid); - } - - protected void assertHasOrg(PrismObject user, String orgOid, QName relation) { - MidPointAsserts.assertHasOrg(user, orgOid, relation); - } - - protected void assertHasNoOrg(PrismObject user, String orgOid) { - MidPointAsserts.assertHasNoOrg(user, orgOid, null); - } - - protected void assertHasNoOrg(PrismObject user, String orgOid, QName relation) { - MidPointAsserts.assertHasNoOrg(user, orgOid, relation); - } - - protected void assertHasNoOrg(PrismObject user) { - MidPointAsserts.assertHasNoOrg(user); - } - - protected void assertHasOrgs(PrismObject user, int expectedNumber) { - MidPointAsserts.assertHasOrgs(user, expectedNumber); - } - - protected void assertHasArchetypes(PrismObject object, String... oids) { - for (String oid : oids) { - assertHasArchetype(object, oid); - } - assertHasArchetypes(object, oids.length); - } - - protected void assertHasArchetypes(PrismObject object, int expectedNumber) { - MidPointAsserts.assertHasArchetypes(object, expectedNumber); - } - - protected void assertHasArchetype(PrismObject object, String oid) { - MidPointAsserts.assertHasArchetype(object, oid); - } - - protected void assertSubOrgs(String baseOrgOid, int expected) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".assertSubOrgs"); - OperationResult result = task.getResult(); - List> subOrgs = getSubOrgs(baseOrgOid, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - assertEquals("Unexpected number of suborgs of org "+baseOrgOid+", has suborgs "+subOrgs, expected, subOrgs.size()); - } - - protected void assertSubOrgs(PrismObject baseOrg, int expected) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".assertSubOrgs"); - OperationResult result = task.getResult(); - List> subOrgs = getSubOrgs(baseOrg.getOid(), task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - assertEquals("Unexpected number of suborgs of"+baseOrg+", has suborgs "+subOrgs, expected, subOrgs.size()); - } - - protected List> getSubOrgs(String baseOrgOid, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - ObjectQuery query = prismContext.queryFor(OrgType.class) - .isDirectChildOf(baseOrgOid) - .build(); - return modelService.searchObjects(OrgType.class, query, null, task, result); - } - - protected List> getSubOrgUsers(String baseOrgOid, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - ObjectQuery query = prismContext.queryFor(UserType.class) - .isDirectChildOf(baseOrgOid) - .build(); - return modelService.searchObjects(UserType.class, query, null, task, result); - } - - protected String dumpOrgTree(String topOrgOid) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - return dumpOrgTree(topOrgOid, false); - } - - protected String dumpOrgTree(String topOrgOid, boolean dumpUsers) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".assertSubOrgs"); - OperationResult result = task.getResult(); - PrismObject topOrg = modelService.getObject(OrgType.class, topOrgOid, null, task, result); - String dump = dumpOrgTree(topOrg, dumpUsers, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - return dump; - } - - protected String dumpOrgTree(PrismObject topOrg, boolean dumpUsers, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - StringBuilder sb = new StringBuilder(); - dumpOrg(sb, topOrg, 0); - sb.append("\n"); - dumpSubOrgs(sb, topOrg.getOid(), dumpUsers, 1, task, result); - return sb.toString(); - } - - private void dumpSubOrgs(StringBuilder sb, String baseOrgOid, boolean dumpUsers, int indent, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - List> subOrgs = getSubOrgs(baseOrgOid, task, result); - for (PrismObject suborg: subOrgs) { - dumpOrg(sb, suborg, indent); - if (dumpUsers) { - dumpOrgUsers(sb, suborg.getOid(), dumpUsers, indent + 1, task, result); - } - sb.append("\n"); - dumpSubOrgs(sb, suborg.getOid(), dumpUsers, indent + 1, task, result); - } - } - - private void dumpOrgUsers(StringBuilder sb, String baseOrgOid, boolean dumpUsers, int indent, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - List> subUsers = getSubOrgUsers(baseOrgOid, task, result); - for (PrismObject subuser: subUsers) { - sb.append("\n"); - DebugUtil.indentDebugDump(sb, indent); - sb.append(subuser); - } - } - - private void dumpOrg(StringBuilder sb, PrismObject org, int indent) { - DebugUtil.indentDebugDump(sb, indent); - sb.append(org); - List linkRefs = org.asObjectable().getLinkRef(); - sb.append(": ").append(linkRefs.size()).append(" links"); - } - - protected void displayUsers() throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".displayUsers"); - OperationResult result = task.getResult(); - ResultHandler handler = (user, parentResult) -> { - display("User", user); - return true; - }; - modelService.searchObjectsIterative(UserType.class, null, handler, null, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - } - - protected void dumpFocus(String message, PrismObject focus) throws ObjectNotFoundException, SchemaException { - OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName() + ".dumpFocus"); - StringBuilder sb = new StringBuilder(); - sb.append(focus.debugDump(0)); - sb.append("\nOrgs:"); - for (ObjectReferenceType parentOrgRef: focus.asObjectable().getParentOrgRef()) { - sb.append("\n"); - DebugUtil.indentDebugDump(sb, 1); - PrismObject org = repositoryService.getObject(OrgType.class, parentOrgRef.getOid(), null, result); - sb.append(org); - PolyStringType displayName = org.asObjectable().getDisplayName(); - if (displayName != null) { - sb.append(": ").append(displayName); - } - } - sb.append("\nProjections:"); - for (ObjectReferenceType linkRef: focus.asObjectable().getLinkRef()) { - PrismObject shadow = repositoryService.getObject(ShadowType.class, linkRef.getOid(), null, result); - ObjectReferenceType resourceRef = shadow.asObjectable().getResourceRef(); - PrismObject resource = repositoryService.getObject(ResourceType.class, resourceRef.getOid(), null, result); - sb.append("\n"); - DebugUtil.indentDebugDump(sb, 1); - sb.append(resource); - sb.append("/"); - sb.append(shadow.asObjectable().getKind()); - sb.append("/"); - sb.append(shadow.asObjectable().getIntent()); - sb.append(": "); - sb.append(shadow.asObjectable().getName()); - } - sb.append("\nAssignments:"); - for (AssignmentType assignmentType: focus.asObjectable().getAssignment()) { - sb.append("\n"); - DebugUtil.indentDebugDump(sb, 1); - if (assignmentType.getConstruction() != null) { - sb.append("Constr(").append(assignmentType.getConstruction().getDescription()).append(") "); - } - if (assignmentType.getTargetRef() != null) { - sb.append("-["); - if (assignmentType.getTargetRef().getRelation() != null) { - sb.append(assignmentType.getTargetRef().getRelation().getLocalPart()); - } - sb.append("]-> "); - Class targetClass = ObjectTypes.getObjectTypeFromTypeQName(assignmentType.getTargetRef().getType()).getClassDefinition(); - PrismObject target = repositoryService.getObject(targetClass, assignmentType.getTargetRef().getOid(), null, result); - sb.append(target); - } - } - display(message, sb.toString()); - } - - protected void assertAssignments(PrismObject user, int expectedNumber) { - MidPointAsserts.assertAssignments(user, expectedNumber); - } - - protected void assertInducements(PrismObject role, int expectedNumber) { - MidPointAsserts.assertInducements(role, expectedNumber); - } - - protected void assertInducedRoles(PrismObject role, String... roleOids) { - assertInducements(role, roleOids.length); - for (String roleOid : roleOids) { - assertInducedRole(role, roleOid); - } - } - - protected void assertAssignments(PrismObject user, Class expectedType, int expectedNumber) { - MidPointAsserts.assertAssignments(user, expectedType, expectedNumber); - } - - protected void assertAssigned(PrismObject user, String targetOid, QName refType) { - MidPointAsserts.assertAssigned(user, targetOid, refType); - } - - protected void assertAssignedNoOrg(String userOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { - PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); - assertAssignedNoOrg(user); - } - - protected void assertAssignedNoOrg(PrismObject user) { - assertAssignedNo(user, OrgType.COMPLEX_TYPE); - } - - protected void assertAssignedNoRole(PrismObject focus, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { - assertAssignedNoRole(focus); - } - - protected void assertAssignedNoRole(String userOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { - PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); - assertAssignedNoRole(user); - } - - protected void assertAssignedNoRole(PrismObject user) { - assertAssignedNo(user, RoleType.COMPLEX_TYPE); - } - - protected void assertAssignedNo(PrismObject user, QName refType) { - F userType = user.asObjectable(); - for (AssignmentType assignmentType: userType.getAssignment()) { - ObjectReferenceType targetRef = assignmentType.getTargetRef(); - if (targetRef != null) { - if (refType.equals(targetRef.getType())) { - AssertJUnit.fail(user+" has role "+targetRef.getOid()+" while expected no roles"); - } - } - } - } - - protected void assertAssignedAccount(String userOid, String resourceOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { - PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); - assertAssignedAccount(user, resourceOid); - } - - protected AssignmentType assertAssignedAccount(PrismObject user, String resourceOid) throws ObjectNotFoundException, SchemaException { - UserType userType = user.asObjectable(); - for (AssignmentType assignmentType: userType.getAssignment()) { - ConstructionType construction = assignmentType.getConstruction(); - if (construction != null) { - if (construction.getKind() != null && construction.getKind() != ShadowKindType.ACCOUNT) { - continue; - } - if (resourceOid.equals(construction.getResourceRef().getOid())) { - return assignmentType; - } - } - } - AssertJUnit.fail(user.toString() + " does not have account assignment for resource " + resourceOid); - return null; // not reached - } - - protected void assertAssignedNoAccount(PrismObject user, String resourceOid) throws ObjectNotFoundException, SchemaException { - UserType userType = user.asObjectable(); - for (AssignmentType assignmentType: userType.getAssignment()) { - ConstructionType construction = assignmentType.getConstruction(); - if (construction != null) { - if (construction.getKind() != null && construction.getKind() != ShadowKindType.ACCOUNT) { - continue; - } - if (resourceOid.equals(construction.getResourceRef().getOid())) { - AssertJUnit.fail(user.toString()+" has account assignment for resource "+resourceOid+" while expecting no such assignment"); - } - } - } - } - - protected PrismObjectDefinition getRoleDefinition() { - return prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(RoleType.class); - } - - protected PrismObjectDefinition getShadowDefinition() { - return prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(ShadowType.class); - } - - protected PrismContainerDefinition getAssignmentDefinition() { - return prismContext.getSchemaRegistry().findContainerDefinitionByType(AssignmentType.COMPLEX_TYPE); - } - - protected PrismContainerDefinition getAssignmentExtensionDefinition() { - PrismContainerDefinition assignmentDefinition = getAssignmentDefinition(); - return assignmentDefinition.findContainerDefinition(AssignmentType.F_EXTENSION); - } - - protected PrismContainer getAssignmentExtensionInstance() throws SchemaException { - return getAssignmentExtensionDefinition().instantiate(); - } - - protected PrismObjectDefinition getResourceDefinition() { - return prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(ResourceType.class); - } - - protected PrismObjectDefinition getAccountShadowDefinition() { - return prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(ShadowType.class); - } - - - protected PrismObject createObject(Class type, String name) throws SchemaException { - PrismObject object = getObjectDefinition(type).instantiate(); - object.asObjectable().setName(createPolyStringType(name)); - return object; - } - - protected PrismObject createUser(String name, String fullName) throws SchemaException { - return createUser(name, fullName, null); - } - - protected PrismObject createUser(String name, String fullName, Boolean enabled) throws SchemaException { - PrismObject user = createObject(UserType.class, name); - UserType userType = user.asObjectable(); - userType.setFullName(createPolyStringType(fullName)); - if (enabled != null) { - ActivationType activation = new ActivationType(); - userType.setActivation(activation); - if (enabled) { - activation.setAdministrativeStatus(ActivationStatusType.ENABLED); - } else { - activation.setAdministrativeStatus(ActivationStatusType.DISABLED); - } - } - return user; - } - - protected PrismObject createUser(String name, String givenName, String familyName, Boolean enabled) throws SchemaException { - PrismObject user = getUserDefinition().instantiate(); - UserType userType = user.asObjectable(); - userType.setName(createPolyStringType(name)); - userType.setGivenName(createPolyStringType(givenName)); - userType.setFamilyName(createPolyStringType(familyName)); - userType.setFullName(createPolyStringType(givenName + " " + familyName)); - if (enabled != null) { - ActivationType activation = new ActivationType(); - userType.setActivation(activation); - if (enabled) { - activation.setAdministrativeStatus(ActivationStatusType.ENABLED); - } else { - activation.setAdministrativeStatus(ActivationStatusType.DISABLED); - } - } - return user; - } - - protected void fillinUser(PrismObject user, String name, String fullName) { - user.asObjectable().setName(createPolyStringType(name)); - user.asObjectable().setFullName(createPolyStringType(fullName)); - } - - protected void fillinUserAssignmentAccountConstruction(PrismObject user, String resourceOid) { - AssignmentType assignmentType = new AssignmentType(); - ConstructionType accountConstruntion = new ConstructionType(); - ObjectReferenceType resourceRef = new ObjectReferenceType(); - resourceRef.setOid(resourceOid); - resourceRef.setType(ResourceType.COMPLEX_TYPE); - accountConstruntion.setResourceRef(resourceRef); - accountConstruntion.setKind(ShadowKindType.ACCOUNT); - assignmentType.setConstruction(accountConstruntion); - user.asObjectable().getAssignment().add(assignmentType); - } - - protected PrismObject createAccount(PrismObject resource, String name, boolean enabled) throws SchemaException { - PrismObject shadow = getShadowDefinition().instantiate(); - ShadowType shadowType = shadow.asObjectable(); - ObjectReferenceType resourceRef = new ObjectReferenceType(); - resourceRef.setOid(resource.getOid()); - shadowType.setResourceRef(resourceRef); - RefinedResourceSchema refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource); - RefinedObjectClassDefinition objectClassDefinition = refinedSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT); - shadowType.setObjectClass(objectClassDefinition.getTypeName()); - shadowType.setKind(ShadowKindType.ACCOUNT); - ResourceAttributeContainer attrCont = ShadowUtil.getOrCreateAttributesContainer(shadow, objectClassDefinition); - RefinedAttributeDefinition idSecondaryDef = objectClassDefinition.getSecondaryIdentifiers().iterator().next(); - ResourceAttribute icfsNameAttr = idSecondaryDef.instantiate(); - icfsNameAttr.setRealValue(name); - attrCont.add(icfsNameAttr); - ActivationType activation = new ActivationType(); - shadowType.setActivation(activation); - if (enabled) { - activation.setAdministrativeStatus(ActivationStatusType.ENABLED); - } else { - activation.setAdministrativeStatus(ActivationStatusType.DISABLED); - } - return shadow; - } - - protected void addAttributeToShadow(PrismObject shadow, PrismObject resource, String attrName, T attrValue) throws SchemaException { - ResourceAttributeContainer attrs = ShadowUtil.getAttributesContainer(shadow); - ResourceAttributeDefinition attrSnDef = attrs.getDefinition().findAttributeDefinition( - new ItemName(ResourceTypeUtil.getResourceNamespace(resource), attrName)); - ResourceAttribute attr = attrSnDef.instantiate(); - attr.setRealValue(attrValue); - attrs.add(attr); - } - - protected void setDefaultUserTemplate(String userTemplateOid) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { - setDefaultObjectTemplate(UserType.COMPLEX_TYPE, userTemplateOid); - } - - protected void setDefaultObjectTemplate(QName objectType, String userTemplateOid) - throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { - OperationResult result = new OperationResult(AbstractModelIntegrationTest.class.getName()+".setDefaultObjectTemplate"); - setDefaultObjectTemplate(objectType, userTemplateOid, result); - result.computeStatus(); - TestUtil.assertSuccess("Applying default object template failed (result)", result); - } - - - protected void setDefaultObjectTemplate(QName objectType, String objectTemplateOid, OperationResult parentResult) - throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { - setDefaultObjectTemplate(objectType, null, objectTemplateOid, parentResult); - } - - protected void setDefaultObjectTemplate(QName objectType, String subType, String objectTemplateOid, OperationResult parentResult) - throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { - - PrismObject systemConfig = repositoryService.getObject(SystemConfigurationType.class, - SystemObjectsType.SYSTEM_CONFIGURATION.value(), null, parentResult); - - PrismContainerValue oldValue = null; - for (ObjectPolicyConfigurationType focusPolicyType: systemConfig.asObjectable().getDefaultObjectPolicyConfiguration()) { - if (QNameUtil.match(objectType, focusPolicyType.getType()) && MiscUtil.equals(subType, focusPolicyType.getSubtype())) { - oldValue = focusPolicyType.asPrismContainerValue(); - } - } - Collection modifications = new ArrayList<>(); - - if (oldValue != null) { - ObjectPolicyConfigurationType oldPolicy = oldValue.asContainerable(); - ObjectReferenceType oldObjectTemplateRef = oldPolicy.getObjectTemplateRef(); - if (oldObjectTemplateRef != null) { - if (oldObjectTemplateRef.getOid().equals(objectTemplateOid)) { - // Already set - return; - } - } - ContainerDelta deleteDelta = prismContext.deltaFactory().container().createModificationDelete(SystemConfigurationType.F_DEFAULT_OBJECT_POLICY_CONFIGURATION, - SystemConfigurationType.class, oldValue.clone()); - ((Collection)modifications).add(deleteDelta); - } - - if (objectTemplateOid != null) { - ObjectPolicyConfigurationType newFocusPolicyType; - ContainerDelta addDelta; - if (oldValue == null) { - newFocusPolicyType = new ObjectPolicyConfigurationType(); - newFocusPolicyType.setType(objectType); - newFocusPolicyType.setSubtype(subType); - addDelta = prismContext.deltaFactory().container().createModificationAdd(SystemConfigurationType.F_DEFAULT_OBJECT_POLICY_CONFIGURATION, - SystemConfigurationType.class, newFocusPolicyType); - } else { - PrismContainerValue newValue = oldValue.cloneComplex(CloneStrategy.REUSE); - addDelta = prismContext.deltaFactory().container().createModificationAdd(SystemConfigurationType.F_DEFAULT_OBJECT_POLICY_CONFIGURATION, - SystemConfigurationType.class, newValue); - newFocusPolicyType = newValue.asContainerable(); - } - ObjectReferenceType templateRef = new ObjectReferenceType(); - templateRef.setOid(objectTemplateOid); - newFocusPolicyType.setObjectTemplateRef(templateRef); - ((Collection)modifications).add(addDelta); - } - - modifySystemObjectInRepo(SystemConfigurationType.class, - SystemObjectsType.SYSTEM_CONFIGURATION.value(), modifications, parentResult); - - } - - protected void setConflictResolution(QName objectType, String subType, ConflictResolutionType conflictResolution, OperationResult parentResult) - throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { - - PrismObject systemConfig = repositoryService.getObject(SystemConfigurationType.class, - SystemObjectsType.SYSTEM_CONFIGURATION.value(), null, parentResult); - - PrismContainerValue oldValue = null; - for (ObjectPolicyConfigurationType focusPolicyType: systemConfig.asObjectable().getDefaultObjectPolicyConfiguration()) { - if (QNameUtil.match(objectType, focusPolicyType.getType()) && MiscUtil.equals(subType, focusPolicyType.getSubtype())) { - oldValue = focusPolicyType.asPrismContainerValue(); - } - } - Collection modifications = new ArrayList<>(); - - if (oldValue != null) { - ContainerDelta deleteDelta = prismContext.deltaFactory().container().createModificationDelete(SystemConfigurationType.F_DEFAULT_OBJECT_POLICY_CONFIGURATION, - SystemConfigurationType.class, oldValue.clone()); - ((Collection)modifications).add(deleteDelta); - } - - ObjectPolicyConfigurationType newFocusPolicyType = new ObjectPolicyConfigurationType(); - newFocusPolicyType.setType(objectType); - newFocusPolicyType.setSubtype(subType); - if (oldValue != null) { - ObjectReferenceType oldObjectTemplateRef = oldValue.asContainerable().getObjectTemplateRef(); - if (oldObjectTemplateRef != null) { - newFocusPolicyType.setObjectTemplateRef(oldObjectTemplateRef.clone()); - } - } - - newFocusPolicyType.setConflictResolution(conflictResolution); - - ContainerDelta addDelta = prismContext.deltaFactory().container() - .createModificationAdd(SystemConfigurationType.F_DEFAULT_OBJECT_POLICY_CONFIGURATION, - SystemConfigurationType.class, newFocusPolicyType); - - ((Collection)modifications).add(addDelta); - - modifySystemObjectInRepo(SystemConfigurationType.class, - SystemObjectsType.SYSTEM_CONFIGURATION.value(), modifications, parentResult); - - } - - protected void setConflictResolutionAction(QName objectType, String subType, ConflictResolutionActionType conflictResolutionAction, OperationResult parentResult) - throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { - ConflictResolutionType conflictResolutionType = new ConflictResolutionType(); - conflictResolutionType.action(conflictResolutionAction); - setConflictResolution(objectType, subType, conflictResolutionType, parentResult); - } - - protected void setGlobalSecurityPolicy(String securityPolicyOid, OperationResult parentResult) - throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { - - Collection modifications = new ArrayList<>(); - - ReferenceDelta refDelta = prismContext.deltaFactory().reference().createModificationReplace(SystemConfigurationType.F_GLOBAL_SECURITY_POLICY_REF, - SystemConfigurationType.class, securityPolicyOid); - modifications.add(refDelta); - - modifySystemObjectInRepo(SystemConfigurationType.class, - SystemObjectsType.SYSTEM_CONFIGURATION.value(), modifications, parentResult); - - } - - protected void modifySystemObjectInRepo(Class type, String oid, Collection modifications, OperationResult parentResult) - throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { - display("Modifications of system object "+oid, modifications); - repositoryService.modifyObject(type, oid, modifications, parentResult); - invalidateSystemObjectsCache(); - } - - @Override - protected void invalidateSystemObjectsCache() { - systemObjectCache.invalidateCaches(); - } - - protected ItemPath getIcfsNameAttributePath() { - return ItemPath.create( - ShadowType.F_ATTRIBUTES, - SchemaTestConstants.ICFS_NAME); - - } - - protected void assertResolvedResourceRefs(ModelContext context) { - for (ModelProjectionContext projectionContext: context.getProjectionContexts()) { - assertResolvedResourceRefs(projectionContext.getObjectOld(), "objectOld in "+projectionContext); - assertResolvedResourceRefs(projectionContext.getObjectNew(), "objectNew in "+projectionContext); - assertResolvedResourceRefs(projectionContext.getPrimaryDelta(), "primaryDelta in "+projectionContext); - assertResolvedResourceRefs(projectionContext.getSecondaryDelta(), "secondaryDelta in "+projectionContext); - } - } - - private void assertResolvedResourceRefs(ObjectDelta delta, String desc) { - if (delta == null) { - return; - } - if (delta.isAdd()) { - assertResolvedResourceRefs(delta.getObjectToAdd(), desc); - } else if (delta.isModify()) { - ReferenceDelta referenceDelta = delta.findReferenceModification(ShadowType.F_RESOURCE_REF); - if (referenceDelta != null) { - assertResolvedResourceRefs(referenceDelta.getValuesToAdd(), "valuesToAdd in "+desc); - assertResolvedResourceRefs(referenceDelta.getValuesToDelete(), "valuesToDelete in "+desc); - assertResolvedResourceRefs(referenceDelta.getValuesToReplace(), "valuesToReplace in "+desc); - } - } - } - - private void assertResolvedResourceRefs(PrismObject shadow, String desc) { - if (shadow == null) { - return; - } - PrismReference resourceRef = shadow.findReference(ShadowType.F_RESOURCE_REF); - if (resourceRef == null) { - AssertJUnit.fail("No resourceRef in "+desc); - } - assertResolvedResourceRefs(resourceRef.getValues(), desc); - } - - private void assertResolvedResourceRefs(Collection values, String desc) { - if (values == null) { - return; - } - for (PrismReferenceValue pval: values) { - assertNotNull("resourceRef in "+desc+" does not contain object", pval.getObject()); - } - } - - /** - * Breaks user assignment delta in the context by inserting some empty value. This may interfere with comparing the values to - * existing user values. - */ - protected void breakAssignmentDelta(Collection> deltas) throws SchemaException { - breakAssignmentDelta((ObjectDelta)deltas.iterator().next()); - } - - /** - * Breaks user assignment delta in the context by inserting some empty value. This may interfere with comparing the values to - * existing user values. - */ - protected void breakAssignmentDelta(ObjectDelta userDelta) throws SchemaException { - ContainerDelta assignmentDelta = userDelta.findContainerDelta(UserType.F_ASSIGNMENT); - PrismContainerValue assignmentDeltaValue = null; - if (assignmentDelta.getValuesToAdd() != null) { - assignmentDeltaValue = assignmentDelta.getValuesToAdd().iterator().next(); - } - if (assignmentDelta.getValuesToDelete() != null) { - assignmentDeltaValue = assignmentDelta.getValuesToDelete().iterator().next(); - } - PrismContainer activationContainer = assignmentDeltaValue.findOrCreateContainer(AssignmentType.F_ACTIVATION); - PrismContainerValue emptyValue = prismContext.itemFactory().createContainerValue(); - activationContainer.add(emptyValue); - } - - - protected void purgeResourceSchema(String resourceOid) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".purgeResourceSchema"); - OperationResult result = task.getResult(); - - ObjectDelta resourceDelta = prismContext.deltaFactory().object().createModificationReplaceContainer(ResourceType.class, - resourceOid, ResourceType.F_SCHEMA, new PrismContainerValue[0]); - Collection> deltas = MiscSchemaUtil.createCollection(resourceDelta); - - modelService.executeChanges(deltas, null, task, result); - - result.computeStatus(); - TestUtil.assertSuccess(result); - } - - protected List> searchOrg(String baseOrgOid, OrgFilter.Scope scope, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - ObjectQuery query = prismContext.queryFor(OrgType.class) - .isInScopeOf(baseOrgOid, scope) - .build(); - return modelService.searchObjects(OrgType.class, query, null, task, result); - } - - protected PrismObject searchObjectByName(Class type, String name) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".searchObjectByName"); - OperationResult result = task.getResult(); - PrismObject out = searchObjectByName(type, name, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - return out; - } - - protected PrismObject searchObjectByName(Class type, String name, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - ObjectQuery query = ObjectQueryUtil.createNameQuery(name, prismContext); - List> foundObjects = modelService.searchObjects(type, query, null, task, result); - if (foundObjects.isEmpty()) { - return null; - } - if (foundObjects.size() > 1) { - throw new IllegalStateException("More than one object found for type "+type+" and name '"+name+"'"); - } - return foundObjects.iterator().next(); - } - - protected void assertAccountShadowModel(PrismObject accountShadow, String oid, String username, ResourceType resourceType) throws SchemaException { - assertShadowModel(accountShadow, oid, username, resourceType, getAccountObjectClass(resourceType), null); - } - - protected void assertAccountShadowModel(PrismObject accountShadow, String oid, String username, ResourceType resourceType, MatchingRule matchingRule) throws SchemaException { - assertShadowModel(accountShadow, oid, username, resourceType, getAccountObjectClass(resourceType), matchingRule); - } - - protected void assertShadowModel(PrismObject accountShadow, String oid, String username, ResourceType resourceType, - QName objectClass) throws SchemaException { - assertShadowModel(accountShadow, oid, username, resourceType, objectClass, null); - } - - protected void assertShadowModel(PrismObject accountShadow, String oid, String username, ResourceType resourceType, - QName objectClass, MatchingRule nameMatchingRule) throws SchemaException { - assertShadowCommon(accountShadow, oid, username, resourceType, objectClass, nameMatchingRule, false); - IntegrationTestTools.assertProvisioningShadow(accountShadow, resourceType, RefinedAttributeDefinition.class, objectClass); - } - - protected ObjectDelta createModifyUserAddDummyAccount(String userOid, String dummyResourceName) throws SchemaException { - return createModifyUserAddAccount(userOid, getDummyResourceObject(dummyResourceName)); - } - - protected ObjectDelta createModifyUserAddAccount(String userOid, PrismObject resource) throws SchemaException { - return createModifyUserAddAccount(userOid, resource, null); - } - - protected ObjectDelta createModifyUserAddAccount(String userOid, PrismObject resource, String intent) throws SchemaException { - PrismObject account = getAccountShadowDefinition().instantiate(); - ObjectReferenceType resourceRef = new ObjectReferenceType(); - resourceRef.setOid(resource.getOid()); - account.asObjectable().setResourceRef(resourceRef); - RefinedResourceSchema refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource); - RefinedObjectClassDefinition rocd = null; - if (StringUtils.isNotBlank(intent)) { - rocd = refinedSchema.getRefinedDefinition(ShadowKindType.ACCOUNT, intent); - account.asObjectable().setIntent(intent); - } else { - rocd = refinedSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT); - } - account.asObjectable().setObjectClass(rocd.getObjectClassDefinition().getTypeName()); - account.asObjectable().setKind(ShadowKindType.ACCOUNT); - - - ObjectDelta userDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, userOid - ); - PrismReferenceValue accountRefVal = itemFactory().createReferenceValue(); - accountRefVal.setObject(account); - ReferenceDelta accountDelta = prismContext.deltaFactory().reference().createModificationAdd(UserType.F_LINK_REF, getUserDefinition(), accountRefVal); - userDelta.addModification(accountDelta); - - return userDelta; - } - - protected ObjectDelta createModifyUserDeleteDummyAccount(String userOid, String dummyResourceName) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - return createModifyUserDeleteAccount(userOid, getDummyResourceObject(dummyResourceName)); - } - - protected ObjectDelta createModifyUserDeleteAccount(String userOid, PrismObject resource) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - return createModifyUserDeleteAccount(userOid, resource.getOid()); - } - - protected ObjectDelta createModifyUserDeleteAccount(String userOid, String resourceOid) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - String accountOid = getLinkRefOid(userOid, resourceOid); - PrismObject account = getShadowModel(accountOid); - - ObjectDelta userDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, userOid - ); - PrismReferenceValue accountRefVal = itemFactory().createReferenceValue(); - accountRefVal.setObject(account); - ReferenceDelta accountDelta = prismContext.deltaFactory().reference().createModificationDelete(UserType.F_LINK_REF, getUserDefinition(), accountRefVal); - userDelta.addModification(accountDelta); - - return userDelta; - } - - protected ObjectDelta createModifyUserUnlinkAccount(String userOid, PrismObject resource) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - String accountOid = getLinkRefOid(userOid, resource.getOid()); - - ObjectDelta userDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, userOid - ); - PrismReferenceValue accountRefVal = itemFactory().createReferenceValue(); - accountRefVal.setOid(accountOid); - ReferenceDelta accountDelta = prismContext.deltaFactory().reference().createModificationDelete(UserType.F_LINK_REF, getUserDefinition(), accountRefVal); - userDelta.addModification(accountDelta); - - return userDelta; - } - - protected void deleteUserAccount(String userOid, String resourceOid, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - ObjectDelta userDelta = createModifyUserDeleteAccount(userOid, resourceOid); - executeChanges(userDelta, null, task, result); - } - - - // TASKS - - protected void waitForTaskFinish(Task task, boolean checkSubresult) throws Exception { - waitForTaskFinish(task, checkSubresult, DEFAULT_TASK_WAIT_TIMEOUT); - } - - protected void waitForTaskFinish(Task task, boolean checkSubresult, final int timeout) throws Exception { - waitForTaskFinish(task, checkSubresult, timeout, DEFAULT_TASK_SLEEP_TIME); - } - - protected void waitForTaskFinish(final Task task, final boolean checkSubresult, final int timeout, long sleepTime) throws Exception { - final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForTaskFinish"); - Checker checker = new Checker() { - @Override - public boolean check() throws CommonException { - task.refresh(waitResult); - waitResult.summarize(); -// Task freshTask = taskManager.getTaskWithResult(task.getOid(), waitResult); - OperationResult result = task.getResult(); - if (verbose) display("Check result", result); - assert !isError(result, checkSubresult) : "Error in "+task+": "+TestUtil.getErrorMessage(result); - assert !isUnknown(result, checkSubresult) : "Unknown result in "+task+": "+TestUtil.getErrorMessage(result); - return !isInProgress(result, checkSubresult); - } - @Override - public void timeout() { - try { - task.refresh(waitResult); - } catch (ObjectNotFoundException e) { - LOGGER.error("Exception during task refresh: {}", e,e); - } catch (SchemaException e) { - LOGGER.error("Exception during task refresh: {}", e,e); - } - OperationResult result = task.getResult(); - LOGGER.debug("Result of timed-out task:\n{}", result.debugDump()); - assert false : "Timeout ("+timeout+") while waiting for "+task+" to finish. Last result "+result; - } - }; - IntegrationTestTools.waitFor("Waiting for " + task + " finish", checker, timeout, sleepTime); - } - - protected void waitForTaskCloseOrSuspend(String taskOid) throws Exception { - waitForTaskCloseOrSuspend(taskOid, DEFAULT_TASK_WAIT_TIMEOUT); - } - - protected void waitForTaskCloseOrSuspend(String taskOid, final int timeout) throws Exception { - waitForTaskCloseOrSuspend(taskOid, timeout, DEFAULT_TASK_SLEEP_TIME); - } - - protected void waitForTaskCloseOrSuspend(final String taskOid, final int timeout, long sleepTime) throws Exception { - final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForTaskCloseOrSuspend"); - Checker checker = new Checker() { - @Override - public boolean check() throws CommonException { - Task task = taskManager.getTaskWithResult(taskOid, waitResult); - waitResult.summarize(); - display("Task execution status = " + task.getExecutionStatus()); - return task.getExecutionStatus() == TaskExecutionStatus.CLOSED - || task.getExecutionStatus() == TaskExecutionStatus.SUSPENDED; - } - @Override - public void timeout() { - Task task = null; - try { - task = taskManager.getTaskWithResult(taskOid, waitResult); - } catch (ObjectNotFoundException|SchemaException e) { - LOGGER.error("Exception during task refresh: {}", e,e); - } - OperationResult result = null; - if (task != null) { - result = task.getResult(); - LOGGER.debug("Result of timed-out task:\n{}", result.debugDump()); - } - assert false : "Timeout ("+timeout+") while waiting for "+taskOid+" to close or suspend. Last result "+result; - } - }; - IntegrationTestTools.waitFor("Waiting for " + taskOid + " close/suspend", checker, timeout, sleepTime); - } - - protected Task waitForTaskFinish(String taskOid, boolean checkSubresult) throws CommonException { - return waitForTaskFinish(taskOid, checkSubresult, DEFAULT_TASK_WAIT_TIMEOUT); - } - - protected Task waitForTaskFinish(String taskOid, boolean checkSubresult, Function customizer) throws CommonException { - return waitForTaskFinish(taskOid, checkSubresult, 0, DEFAULT_TASK_WAIT_TIMEOUT, false, 0, customizer); - } - - protected Task waitForTaskFinish(final String taskOid, final boolean checkSubresult, final int timeout) throws CommonException { - return waitForTaskFinish(taskOid, checkSubresult, timeout, false); - } - - protected Task waitForTaskFinish(final String taskOid, final boolean checkSubresult, final int timeout, final boolean errorOk) throws CommonException { - return waitForTaskFinish(taskOid, checkSubresult, 0, timeout, errorOk); - } - - protected Task waitForTaskFinish(final String taskOid, final boolean checkSubresult, long startTime, final int timeout, final boolean errorOk) throws CommonException { - return waitForTaskFinish(taskOid, checkSubresult, startTime, timeout, errorOk, 0, null); - } - - protected Task waitForTaskFinish(String taskOid, boolean checkSubresult, long startTime, int timeout, boolean errorOk, - int showProgressEach, Function customizer) throws CommonException { - long realStartTime = startTime != 0 ? startTime : System.currentTimeMillis(); - final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForTaskFinish"); - TaskFinishChecker.Builder builder = new TaskFinishChecker.Builder() - .taskManager(taskManager) - .taskOid(taskOid) - .waitResult(waitResult) - .checkSubresult(checkSubresult) - .errorOk(errorOk) - .timeout(timeout) - .showProgressEach(showProgressEach) - .verbose(verbose); - if (customizer != null) { - builder = customizer.apply(builder); - } - TaskFinishChecker checker = builder.build(); - IntegrationTestTools.waitFor("Waiting for task " + taskOid + " finish", checker, realStartTime, timeout, DEFAULT_TASK_SLEEP_TIME); - return checker.getLastTask(); - } - - protected void dumpTaskTree(String oid, OperationResult result) - throws ObjectNotFoundException, - SchemaException { - Collection> options = schemaHelper.getOperationOptionsBuilder() - .item(TaskType.F_SUBTASK).retrieve() - .build(); - PrismObject task = taskManager.getObject(TaskType.class, oid, options, result); - dumpTaskAndSubtasks(task.asObjectable(), 0); - } - - protected void dumpTaskAndSubtasks(TaskType task, int level) throws SchemaException { - String xml = prismContext.xmlSerializer().serialize(task.asPrismObject()); - display("Task (level " + level + ")", xml); - for (TaskType subtask : TaskTypeUtil.getResolvedSubtasks(task)) { - dumpTaskAndSubtasks(subtask, level + 1); - } - } - - protected long getRunDurationMillis(String taskReconOpendjOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - return getTaskRunDurationMillis(getTask(taskReconOpendjOid).asObjectable()); - } - - protected long getTaskRunDurationMillis(TaskType taskType) { - long duration = XmlTypeConverter.toMillis(taskType.getLastRunFinishTimestamp()) - - XmlTypeConverter.toMillis(taskType.getLastRunStartTimestamp()); - System.out.println("Duration for " + taskType.getName() + " is " + duration); - return duration; - } - - protected long getTreeRunDurationMillis(String rootTaskOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - PrismObject rootTask = getTaskTree(rootTaskOid); - return TaskTypeUtil.getAllTasksStream(rootTask.asObjectable()) - .mapToLong(this::getTaskRunDurationMillis) - .max().orElse(0); - } - - protected void displayOperationStatistics(String label, OperationStatsType statistics) { - display(label, StatisticsUtil.format(statistics)); - } - - @Nullable - protected OperationStatsType getTaskTreeOperationStatistics(String rootTaskOid) - throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, - ConfigurationException, ExpressionEvaluationException { - PrismObject rootTask = getTaskTree(rootTaskOid); - return TaskTypeUtil.getAllTasksStream(rootTask.asObjectable()) - .map(t -> t.getOperationStats()) - .reduce(StatisticsUtil::sum) - .orElse(null); - } - - protected List getSubcases(String parentCaseOid, Collection> options, - OperationResult result) throws SchemaException { - return asObjectableList( - repositoryService.searchObjects(CaseType.class, - prismContext.queryFor(CaseType.class).item(CaseType.F_PARENT_REF).ref(parentCaseOid).build(), - options, result)); - } - - protected void deleteCaseTree(String rootCaseOid, OperationResult result) throws SchemaException, ObjectNotFoundException { - List subcases = getSubcases(rootCaseOid, null, result); - for (CaseType subcase : subcases) { - deleteCaseTree(subcase.getOid(), result); - } - repositoryService.deleteObject(CaseType.class, rootCaseOid, result); - } - - protected void displayTaskWithOperationStats(String message, PrismObject task) throws SchemaException { - display(message, task); - String stats = prismContext.xmlSerializer() - .serializeRealValue(task.asObjectable().getOperationStats(), TaskType.F_OPERATION_STATS); - display(message + ": Operational stats", stats); - } - - protected void displayTaskWithOperationStats(String message, Task task) throws SchemaException { - display(message, task); - String stats = prismContext.xmlSerializer() - .serializeRealValue(task.getUpdatedOrClonedTaskObject().asObjectable().getOperationStats(), TaskType.F_OPERATION_STATS); - display(message + ": Operational stats", stats); - } - - protected void assertJpegPhoto(Class clazz, String oid, byte[] expectedValue, OperationResult result) - throws SchemaException, ObjectNotFoundException { - PrismObject object = repositoryService - .getObject(clazz, oid, schemaHelper.getOperationOptionsBuilder().retrieve().build(), result); - byte[] actualValue = object.asObjectable().getJpegPhoto(); - if (expectedValue == null) { - if (actualValue != null) { - fail("Photo present even if it should not be: " + Arrays.toString(actualValue)); - } - } else { - assertNotNull("No photo", actualValue); - if (!Arrays.equals(actualValue, expectedValue)) { - fail("Photo is different than expected.\nExpected = " + Arrays.toString(expectedValue) - + "\nActual value = " + Arrays.toString(actualValue)); - } - } - } - - protected void waitForTaskStart(String taskOid, boolean checkSubresult) throws Exception { - waitForTaskStart(taskOid, checkSubresult, DEFAULT_TASK_WAIT_TIMEOUT); - } - - protected void waitForTaskStart(final String taskOid, final boolean checkSubresult, final int timeout) throws Exception { - final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForTaskStart"); - Checker checker = new Checker() { - @Override - public boolean check() throws CommonException { - Task freshTask = taskManager.getTaskWithResult(taskOid, waitResult); - OperationResult result = freshTask.getResult(); - if (verbose) display("Check result", result); - assert !isError(result, checkSubresult) : "Error in "+freshTask+": "+TestUtil.getErrorMessage(result); - if (isUnknown(result, checkSubresult)) { - return false; - } - return freshTask.getLastRunStartTimestamp() != null; - } - @Override - public void timeout() { - try { - Task freshTask = taskManager.getTaskWithResult(taskOid, waitResult); - OperationResult result = freshTask.getResult(); - LOGGER.debug("Result of timed-out task:\n{}", result.debugDump()); - assert false : "Timeout ("+timeout+") while waiting for "+freshTask+" to start. Last result "+result; - } catch (ObjectNotFoundException | SchemaException e) { - LOGGER.error("Exception during task refresh: {}", e, e); - } - } - }; - IntegrationTestTools.waitFor("Waiting for task " + taskOid + " start", checker, timeout, DEFAULT_TASK_SLEEP_TIME); - } - - protected void waitForTaskNextStart(String taskOid, boolean checkSubresult, int timeout, boolean kickTheTask) throws Exception { - OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForTaskNextStart"); - Task origTask = taskManager.getTaskWithResult(taskOid, waitResult); - Long origLastRunStartTimestamp = origTask.getLastRunStartTimestamp(); - if (kickTheTask) { - taskManager.scheduleTaskNow(origTask, waitResult); - } - Checker checker = new Checker() { - @Override - public boolean check() throws CommonException { - Task freshTask = taskManager.getTaskWithResult(taskOid, waitResult); - OperationResult result = freshTask.getResult(); - if (verbose) display("Check result", result); - assert !isError(result, checkSubresult) : "Error in "+freshTask+": "+TestUtil.getErrorMessage(result); - return !isUnknown(result, checkSubresult) && - !java.util.Objects.equals(freshTask.getLastRunStartTimestamp(), origLastRunStartTimestamp); - } - @Override - public void timeout() { - try { - Task freshTask = taskManager.getTaskWithResult(taskOid, waitResult); - OperationResult result = freshTask.getResult(); - LOGGER.debug("Result of timed-out task:\n{}", result.debugDump()); - assert false : "Timeout ("+timeout+") while waiting for "+freshTask+" to start. Last result "+result; - } catch (ObjectNotFoundException | SchemaException e) { - LOGGER.error("Exception during task refresh: {}", e, e); - } - } - }; - IntegrationTestTools.waitFor("Waiting for task " + taskOid + " next start", checker, timeout, DEFAULT_TASK_SLEEP_TIME); - } - - protected OperationResult waitForTaskNextRunAssertSuccess(String taskOid, boolean checkSubresult) throws Exception { - return waitForTaskNextRunAssertSuccess(taskOid, checkSubresult, DEFAULT_TASK_WAIT_TIMEOUT); - } - - protected OperationResult waitForTaskNextRunAssertSuccess(Task origTask, boolean checkSubresult) throws Exception { - return waitForTaskNextRunAssertSuccess(origTask, checkSubresult, DEFAULT_TASK_WAIT_TIMEOUT); - } - - protected OperationResult waitForTaskNextRunAssertSuccess(final String taskOid, final boolean checkSubresult, final int timeout) throws Exception { - OperationResult taskResult = waitForTaskNextRun(taskOid, checkSubresult, timeout); - if (isError(taskResult, checkSubresult)) { - assert false : "Error in task "+taskOid+": "+TestUtil.getErrorMessage(taskResult)+"\n\n"+taskResult.debugDump(); - } - return taskResult; - } - - protected OperationResult waitForTaskNextRunAssertSuccess(Task origTask, final boolean checkSubresult, final int timeout) throws Exception { - OperationResult taskResult = waitForTaskNextRun(origTask, checkSubresult, timeout); - if (isError(taskResult, checkSubresult)) { - assert false : "Error in task "+origTask+": "+TestUtil.getErrorMessage(taskResult)+"\n\n"+taskResult.debugDump(); - } - return taskResult; - } - - protected OperationResult waitForTaskNextRun(final String taskOid) throws Exception { - return waitForTaskNextRun(taskOid, false, DEFAULT_TASK_WAIT_TIMEOUT, false); - } - - protected OperationResult waitForTaskNextRun(final String taskOid, final boolean checkSubresult, final int timeout) throws Exception { - return waitForTaskNextRun(taskOid, checkSubresult, timeout, false); - } - - protected OperationResult waitForTaskNextRun(final String taskOid, final boolean checkSubresult, final int timeout, boolean kickTheTask) throws Exception { - final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForTaskNextRun"); - Task origTask = taskManager.getTaskWithResult(taskOid, waitResult); - return waitForTaskNextRun(origTask, checkSubresult, timeout, waitResult, kickTheTask); - } - - protected OperationResult waitForTaskNextRun(final Task origTask, final boolean checkSubresult, final int timeout) throws Exception { - return waitForTaskNextRun(origTask, checkSubresult, timeout, false); - } - - protected OperationResult waitForTaskNextRun(final Task origTask, final boolean checkSubresult, final int timeout, boolean kickTheTask) throws Exception { - final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForTaskNextRun"); - return waitForTaskNextRun(origTask, checkSubresult, timeout, waitResult, kickTheTask); - } - - protected OperationResult waitForTaskNextRun(final Task origTask, final boolean checkSubresult, final int timeout, final OperationResult waitResult, boolean kickTheTask) throws Exception { - final Long origLastRunStartTimestamp = origTask.getLastRunStartTimestamp(); - final Long origLastRunFinishTimestamp = origTask.getLastRunFinishTimestamp(); - if (kickTheTask) { - taskManager.scheduleTaskNow(origTask, waitResult); - } - final Holder taskResultHolder = new Holder<>(); - Checker checker = new Checker() { - @Override - public boolean check() throws CommonException { - Task freshTask = taskManager.getTaskWithResult(origTask.getOid(), waitResult); - OperationResult taskResult = freshTask.getResult(); -// display("Times", longTimeToString(origLastRunStartTimestamp) + "-" + longTimeToString(origLastRunStartTimestamp) -// + " : " + longTimeToString(freshTask.getLastRunStartTimestamp()) + "-" + longTimeToString(freshTask.getLastRunFinishTimestamp())); - if (verbose) display("Check result", taskResult); - taskResultHolder.setValue(taskResult); - if (isError(taskResult, checkSubresult)) { - return true; - } - if (isUnknown(taskResult, checkSubresult)) { - return false; - } - if (freshTask.getLastRunFinishTimestamp() == null) { - return false; - } - if (freshTask.getLastRunStartTimestamp() == null) { - return false; - } - return !freshTask.getLastRunStartTimestamp().equals(origLastRunStartTimestamp) - && !freshTask.getLastRunFinishTimestamp().equals(origLastRunFinishTimestamp) - && freshTask.getLastRunStartTimestamp() < freshTask.getLastRunFinishTimestamp(); - } - @Override - public void timeout() { - try { - Task freshTask = taskManager.getTaskWithResult(origTask.getOid(), waitResult); - OperationResult result = freshTask.getResult(); - LOGGER.debug("Timed-out task:\n{}", freshTask.debugDump()); - display("Times", "origLastRunStartTimestamp="+longTimeToString(origLastRunStartTimestamp) - + ", origLastRunFinishTimestamp=" + longTimeToString(origLastRunFinishTimestamp) - + ", freshTask.getLastRunStartTimestamp()=" + longTimeToString(freshTask.getLastRunStartTimestamp()) - + ", freshTask.getLastRunFinishTimestamp()=" + longTimeToString(freshTask.getLastRunFinishTimestamp())); - assert false : "Timeout ("+timeout+") while waiting for "+freshTask+" next run. Last result "+result; - } catch (ObjectNotFoundException | SchemaException e) { - LOGGER.error("Exception during task refresh: {}", e, e); - } - } - }; - IntegrationTestTools.waitFor("Waiting for task " + origTask + " next run", checker, timeout, DEFAULT_TASK_SLEEP_TIME); - - Task freshTask = taskManager.getTaskWithResult(origTask.getOid(), waitResult); - LOGGER.debug("Final task:\n{}", freshTask.debugDump()); - display("Times", "origLastRunStartTimestamp="+longTimeToString(origLastRunStartTimestamp) - + ", origLastRunFinishTimestamp=" + longTimeToString(origLastRunFinishTimestamp) - + ", freshTask.getLastRunStartTimestamp()=" + longTimeToString(freshTask.getLastRunStartTimestamp()) - + ", freshTask.getLastRunFinishTimestamp()=" + longTimeToString(freshTask.getLastRunFinishTimestamp())); - - return taskResultHolder.getValue(); - } - - protected OperationResult waitForTaskTreeNextFinishedRun(String rootTaskOid, int timeout) throws Exception { - final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForTaskTreeNextFinishedRun"); - Task origRootTask = taskManager.getTaskWithResult(rootTaskOid, waitResult); - return waitForTaskTreeNextFinishedRun(origRootTask, timeout, waitResult); - } - - // a bit experimental - protected OperationResult waitForTaskTreeNextFinishedRun(Task origRootTask, int timeout, OperationResult waitResult) throws Exception { - Long origLastRunStartTimestamp = origRootTask.getLastRunStartTimestamp(); - Long origLastRunFinishTimestamp = origRootTask.getLastRunFinishTimestamp(); - long start = System.currentTimeMillis(); - Holder triggered = new Holder<>(false); // to avoid repeated checking for start-finish timestamps - OperationResult aggregateResult = new OperationResult("aggregate"); - Checker checker = () -> { - Task freshRootTask = taskManager.getTaskWithResult(origRootTask.getOid(), waitResult); - - String s = TaskDebugUtil.dumpTaskTree(freshRootTask, waitResult); - display("task tree", s); - - long waiting = (System.currentTimeMillis() - start) / 1000; - String description = - freshRootTask.getName().getOrig() + " [es:" + freshRootTask.getExecutionStatus() + ", rs:" + - freshRootTask.getResultStatus() + ", p:" + freshRootTask.getProgress() + ", n:" + - freshRootTask.getNode() + "] (waiting for: " + waiting + ")"; - // was the whole task tree refreshed at least once after we were called? - if (!triggered.getValue() && (freshRootTask.getLastRunStartTimestamp() == null - || freshRootTask.getLastRunStartTimestamp().equals(origLastRunStartTimestamp) - || freshRootTask.getLastRunFinishTimestamp() == null - || freshRootTask.getLastRunFinishTimestamp().equals(origLastRunFinishTimestamp) - || freshRootTask.getLastRunStartTimestamp() >= freshRootTask.getLastRunFinishTimestamp())) { - display("Root (triggering) task next run has not been completed yet: " + description); - return false; - } - triggered.setValue(true); - - aggregateResult.getSubresults().clear(); - List subtasks = freshRootTask.listSubtasksDeeply(waitResult); - for (Task subtask : subtasks) { - try { - subtask.refresh(waitResult); // quick hack to get operation results - } catch (ObjectNotFoundException e) { - LOGGER.warn("Task {} does not exist any more", subtask); - } - } - Task failedTask = null; - for (Task subtask : subtasks) { - if (subtask.getExecutionStatus() == TaskExecutionStatus.RUNNABLE) { - display("Found runnable/running subtasks during waiting => continuing waiting: " + description, subtask); - return false; - } - if (subtask.getExecutionStatus() == TaskExecutionStatus.WAITING) { - display("Found waiting subtasks during waiting => continuing waiting: " + description, subtask); - return false; - } - OperationResult subtaskResult = subtask.getResult(); - if (subtaskResult == null) { - display("No subtask operation result during waiting => continuing waiting: " + description, subtask); - return false; - } - if (subtaskResult.getStatus() == OperationResultStatus.IN_PROGRESS) { - display("Found 'in_progress' subtask operation result during waiting => continuing waiting: " + description, subtask); - return false; - } - if (subtaskResult.getStatus() == OperationResultStatus.UNKNOWN) { - display("Found 'unknown' subtask operation result during waiting => continuing waiting: " + description, subtask); - return false; - } - aggregateResult.addSubresult(subtaskResult); - if (subtaskResult.isError()) { - failedTask = subtask; - } - } - if (failedTask != null) { - display("Found 'error' subtask operation result during waiting => done waiting: " + description, failedTask); - return true; - } - if (freshRootTask.getExecutionStatus() == TaskExecutionStatus.WAITING) { - display("Found WAITING root task during wait for next finished run => continuing waiting: " + description); - return false; - } - return true; // all executive subtasks are closed - }; - IntegrationTestTools.waitFor("Waiting for task tree " + origRootTask + " next finished run", checker, timeout, DEFAULT_TASK_SLEEP_TIME); - - Task freshTask = taskManager.getTaskWithResult(origRootTask.getOid(), waitResult); - LOGGER.debug("Final root task:\n{}", freshTask.debugDump()); - aggregateResult.computeStatusIfUnknown(); - return aggregateResult; - } - - public void waitForCaseClose(CaseType aCase) throws Exception { - waitForCaseClose(aCase, 60000); - } - - public void waitForCaseClose(CaseType aCase, final int timeout) throws Exception { - final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForCaseClose"); - Checker checker = new Checker() { - @Override - public boolean check() throws CommonException { - CaseType currentCase = repositoryService.getObject(CaseType.class, aCase.getOid(), null, waitResult).asObjectable(); - if (verbose) AbstractIntegrationTest.display("Case", currentCase); - return SchemaConstants.CASE_STATE_CLOSED.equals(currentCase.getState()); - } - @Override - public void timeout() { - PrismObject currentCase; - try { - currentCase = repositoryService.getObject(CaseType.class, aCase.getOid(), null, waitResult); - } catch (ObjectNotFoundException | SchemaException e) { - throw new AssertionError("Couldn't retrieve case " + aCase, e); - } - LOGGER.debug("Timed-out case:\n{}", currentCase.debugDump()); - assert false : "Timeout ("+timeout+") while waiting for "+currentCase+" to finish"; - } - }; - IntegrationTestTools.waitFor("Waiting for "+aCase+" finish", checker, timeout, 1000); - } - - - private String longTimeToString(Long longTime) { - if (longTime == null) { - return "null"; - } - return longTime.toString(); - } - - public static boolean isError(OperationResult result, boolean checkSubresult) { - OperationResult subresult = getSubresult(result, checkSubresult); - return subresult != null && subresult.isError(); - } - - public static boolean isUnknown(OperationResult result, boolean checkSubresult) { - OperationResult subresult = getSubresult(result, checkSubresult); - return subresult != null && subresult.isUnknown(); // TODO or return true if null? - } - - public static boolean isInProgress(OperationResult result, boolean checkSubresult) { - OperationResult subresult = getSubresult(result, checkSubresult); - return subresult == null || subresult.isInProgress(); // "true" if there are no subresults - } - - private static OperationResult getSubresult(OperationResult result, boolean checkSubresult) { - if (checkSubresult) { - return result != null ? result.getLastSubresult() : null; - } - return result; - } - - protected OperationResult waitForTaskResume(final String taskOid, final boolean checkSubresult, final int timeout) throws Exception { - final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForTaskResume"); - Task origTask = taskManager.getTaskWithResult(taskOid, waitResult); - - final Long origLastRunStartTimestamp = origTask.getLastRunStartTimestamp(); - final Long origLastRunFinishTimestamp = origTask.getLastRunFinishTimestamp(); - - taskManager.resumeTask(origTask, waitResult); - - final Holder taskResultHolder = new Holder<>(); - Checker checker = new Checker() { - @Override - public boolean check() throws CommonException { - Task freshTask = taskManager.getTaskWithResult(origTask.getOid(), waitResult); - OperationResult taskResult = freshTask.getResult(); -// display("Times", longTimeToString(origLastRunStartTimestamp) + "-" + longTimeToString(origLastRunStartTimestamp) -// + " : " + longTimeToString(freshTask.getLastRunStartTimestamp()) + "-" + longTimeToString(freshTask.getLastRunFinishTimestamp())); - if (verbose) display("Check result", taskResult); - taskResultHolder.setValue(taskResult); - if (isError(taskResult, checkSubresult)) { - return true; - } - if (isUnknown(taskResult, checkSubresult)) { - return false; - } - if (freshTask.getLastRunFinishTimestamp() == null) { - return false; - } - if (freshTask.getLastRunStartTimestamp() == null) { - return false; - } - return !freshTask.getLastRunStartTimestamp().equals(origLastRunStartTimestamp) - && !freshTask.getLastRunFinishTimestamp().equals(origLastRunFinishTimestamp) - && freshTask.getLastRunStartTimestamp() < freshTask.getLastRunFinishTimestamp(); - } - @Override - public void timeout() { - try { - Task freshTask = taskManager.getTaskWithResult(origTask.getOid(), waitResult); - OperationResult result = freshTask.getResult(); - LOGGER.debug("Timed-out task:\n{}", freshTask.debugDump()); - display("Times", "origLastRunStartTimestamp="+longTimeToString(origLastRunStartTimestamp) - + ", origLastRunFinishTimestamp=" + longTimeToString(origLastRunFinishTimestamp) - + ", freshTask.getLastRunStartTimestamp()=" + longTimeToString(freshTask.getLastRunStartTimestamp()) - + ", freshTask.getLastRunFinishTimestamp()=" + longTimeToString(freshTask.getLastRunFinishTimestamp())); - assert false : "Timeout ("+timeout+") while waiting for "+freshTask+" next run. Last result "+result; - } catch (ObjectNotFoundException | SchemaException e) { - LOGGER.error("Exception during task refresh: {}", e, e); - } - } - }; - IntegrationTestTools.waitFor("Waiting for task " + origTask + " resume", checker, timeout, DEFAULT_TASK_SLEEP_TIME); - - Task freshTask = taskManager.getTaskWithResult(origTask.getOid(), waitResult); - LOGGER.debug("Final task:\n{}", freshTask.debugDump()); - display("Times", "origLastRunStartTimestamp="+longTimeToString(origLastRunStartTimestamp) - + ", origLastRunFinishTimestamp=" + longTimeToString(origLastRunFinishTimestamp) - + ", freshTask.getLastRunStartTimestamp()=" + longTimeToString(freshTask.getLastRunStartTimestamp()) - + ", freshTask.getLastRunFinishTimestamp()=" + longTimeToString(freshTask.getLastRunFinishTimestamp())); - - return taskResultHolder.getValue(); - } - - protected void restartTask(String taskOid) throws CommonException { - - // Wait at least 1ms here. We have the timestamp in the tasks with a millisecond granularity. If the tasks is started, - // executed and then resstarted and excecuted within the same millisecond then the second execution will not be - // detected and the wait for task finish will time-out. So waiting one millisecond here will make sure that the - // timestamps are different. And 1ms is not that long to significantly affect test run times. - try { - Thread.sleep(1); - } catch (InterruptedException e) { - LOGGER.warn("Sleep interrupted: {}", e.getMessage(), e); - } - - OperationResult result = createSubresult("restartTask"); - try { - Task task = taskManager.getTaskWithResult(taskOid, result); - LOGGER.info("Restarting task {}", taskOid); - if (task.getExecutionStatus() == TaskExecutionStatus.SUSPENDED) { - LOGGER.debug("Task {} is suspended, resuming it", task); - taskManager.resumeTask(task, result); - } else if (task.getExecutionStatus() == TaskExecutionStatus.CLOSED) { - LOGGER.debug("Task {} is closed, scheduling it to run now", task); - taskManager.scheduleTasksNow(singleton(taskOid), result); - } else if (task.getExecutionStatus() == TaskExecutionStatus.RUNNABLE) { - if (taskManager.getLocallyRunningTaskByIdentifier(task.getTaskIdentifier()) != null) { - // Task is really executing. Let's wait until it finishes; hopefully it won't start again (TODO) - LOGGER.debug("Task {} is running, waiting while it finishes before restarting", task); - waitForTaskFinish(taskOid, false); - } - LOGGER.debug("Task {} is finished, scheduling it to run now", task); - taskManager.scheduleTasksNow(singleton(taskOid), result); - } else { - throw new IllegalStateException( - "Task " + task + " cannot be restarted, because its state is: " + task.getExecutionStatus()); - } - } catch (Throwable t) { - result.recordFatalError(t); - throw t; - } finally { - result.computeStatusIfUnknown(); - } - } - - protected boolean suspendTask(String taskOid) throws CommonException { - return suspendTask(taskOid, 3000); - } - - protected boolean suspendTask(String taskOid, int waitTime) throws CommonException { - final OperationResult result = new OperationResult(AbstractIntegrationTest.class+".suspendTask"); - Task task = taskManager.getTaskWithResult(taskOid, result); - LOGGER.info("Suspending task {}", taskOid); - return taskManager.suspendTaskQuietly(task, waitTime, result); - } - - /** - * Restarts task and waits for finish. - */ - protected void rerunTask(String taskOid) throws CommonException { - long startTime = System.currentTimeMillis(); - restartTask(taskOid); - waitForTaskFinish(taskOid, true, startTime, DEFAULT_TASK_WAIT_TIMEOUT, false); - } - - protected void assertTaskExecutionStatus(String taskOid, TaskExecutionStatus expectedExecutionStatus) throws ObjectNotFoundException, SchemaException { - final OperationResult result = new OperationResult(AbstractIntegrationTest.class+".assertTaskExecutionStatus"); - Task task = taskManager.getTask(taskOid, result); - assertEquals("Wrong executionStatus in "+task, expectedExecutionStatus, task.getExecutionStatus()); - } - - protected void setSecurityContextUser(String userOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance("get administrator"); - PrismObject object = modelService.getObject(UserType.class, userOid, null, task, task.getResult()); - - assertNotNull("User " + userOid + " is null", object.asObjectable()); - SecurityContextHolder.getContext().setAuthentication( - new UsernamePasswordAuthenticationToken( - new MidPointPrincipal(object.asObjectable()), null)); - } - - protected String getSecurityContextUserOid() { - return ((MidPointPrincipal) (SecurityContextHolder.getContext().getAuthentication().getPrincipal())).getOid(); - } - - protected void assertSideEffectiveDeltasOnly(String desc, ObjectDelta focusDelta) { - if (focusDelta == null) { - return; - } - int expectedModifications = 0; - // There may be metadata modification, we tolerate that - for (ItemDelta modification: focusDelta.getModifications()) { - if (isSideEffectDelta(modification)) { - expectedModifications++; - } - } - if (focusDelta.findItemDelta(PATH_ACTIVATION_ENABLE_TIMESTAMP) != null) { - expectedModifications++; - } - if (focusDelta.findItemDelta(PATH_ACTIVATION_DISABLE_TIMESTAMP) != null) { - expectedModifications++; - } - if (focusDelta.findItemDelta(PATH_ACTIVATION_ARCHIVE_TIMESTAMP) != null) { - expectedModifications++; - } - PropertyDelta effectiveStatusDelta = focusDelta.findPropertyDelta(PATH_ACTIVATION_EFFECTIVE_STATUS); - if (effectiveStatusDelta != null) { - expectedModifications++; - } - if (focusDelta.findItemDelta(FocusType.F_ITERATION) != null) { - expectedModifications++; - } - if (focusDelta.findItemDelta(FocusType.F_ROLE_MEMBERSHIP_REF) != null) { - expectedModifications++; - } - if (focusDelta.findItemDelta(FocusType.F_DELEGATED_REF) != null) { - expectedModifications++; - } - if (focusDelta.findItemDelta(FocusType.F_ITERATION_TOKEN) != null) { - expectedModifications++; - } - assertEquals("Unexpected modifications in " + desc + ": " + focusDelta, expectedModifications, focusDelta.getModifications().size()); - } - - protected void assertSideEffectiveDeltasOnly(ObjectDelta focusDelta, String desc, ActivationStatusType expectedEfficientActivation) { - assertEffectualDeltas(focusDelta, desc, expectedEfficientActivation, 0); - } - - protected void assertEffectualDeltas(ObjectDelta focusDelta, String desc, ActivationStatusType expectedEfficientActivation, int expectedEffectualModifications) { - if (focusDelta == null) { - return; - } - int expectedModifications = expectedEffectualModifications; - // There may be metadata modification, we tolerate that - for (ItemDelta modification: focusDelta.getModifications()) { - if (isSideEffectDelta(modification)) { - expectedModifications++; - } - } - if (focusDelta.findItemDelta(PATH_ACTIVATION_ENABLE_TIMESTAMP) != null) { - expectedModifications++; - } - if (focusDelta.findItemDelta(PATH_ACTIVATION_DISABLE_TIMESTAMP) != null) { - expectedModifications++; - } - if (focusDelta.findItemDelta(PATH_ACTIVATION_ARCHIVE_TIMESTAMP) != null) { - expectedModifications++; - } - PropertyDelta effectiveStatusDelta = focusDelta.findPropertyDelta(PATH_ACTIVATION_EFFECTIVE_STATUS); - if (effectiveStatusDelta != null) { - expectedModifications++; - PrismAsserts.assertReplace(effectiveStatusDelta, expectedEfficientActivation); - } - if (focusDelta.findItemDelta(FocusType.F_ROLE_MEMBERSHIP_REF) != null) { - expectedModifications++; - } - if (focusDelta.findItemDelta(FocusType.F_DELEGATED_REF) != null) { - expectedModifications++; - } - if (focusDelta.findItemDelta(FocusType.F_ITERATION) != null) { - expectedModifications++; - } - if (focusDelta.findItemDelta(FocusType.F_ITERATION_TOKEN) != null) { - expectedModifications++; - } - assertEquals("Unexpected modifications in "+desc+": "+focusDelta, expectedModifications, focusDelta.getModifications().size()); - } - - private boolean isSideEffectDelta(ItemDelta modification) { - if (modification.getPath().containsNameExactly(ObjectType.F_METADATA) || - (modification.getPath().containsNameExactly(FocusType.F_ASSIGNMENT) && modification.getPath().containsNameExactly(ActivationType.F_EFFECTIVE_STATUS))) { - return true; - } else if (modification.getPath().containsNameExactly(FocusType.F_ASSIGNMENT) && modification.getPath().containsNameExactly(AssignmentType.F_ACTIVATION) && modification.isReplace() && (modification instanceof ContainerDelta)) { - Collection> valuesToReplace = ((ContainerDelta)modification).getValuesToReplace(); - if (valuesToReplace != null && valuesToReplace.size() == 1) { - PrismContainerValue cval = valuesToReplace.iterator().next(); - if (cval.size() == 1) { - Item item = cval.getItems().iterator().next(); - return ActivationType.F_EFFECTIVE_STATUS.equals(item.getElementName()); - } - } - } - return false; - } - - protected void assertValidFrom(PrismObject obj, Date expectedDate) { - assertEquals("Wrong validFrom in "+obj, XmlTypeConverter.createXMLGregorianCalendar(expectedDate), - getActivation(obj).getValidFrom()); - } - - protected void assertValidTo(PrismObject obj, Date expectedDate) { - assertEquals("Wrong validTo in "+obj, XmlTypeConverter.createXMLGregorianCalendar(expectedDate), - getActivation(obj).getValidTo()); - } - - protected ActivationType getActivation(PrismObject obj) { - ObjectType objectType = obj.asObjectable(); - ActivationType activation; - if (objectType instanceof ShadowType) { - activation = ((ShadowType)objectType).getActivation(); - } else if (objectType instanceof UserType) { - activation = ((UserType)objectType).getActivation(); - } else { - throw new IllegalArgumentException("Cannot get activation from "+obj); - } - assertNotNull("No activation in " + obj, activation); - return activation; - } - - protected PrismObject getTask(String taskOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".getTask"); - OperationResult result = task.getResult(); - PrismObject retTask = modelService.getObject(TaskType.class, taskOid, retrieveItemsNamed(TaskType.F_RESULT), task, result); - result.computeStatus(); - TestUtil.assertSuccess("getObject(Task) result not success", result); - return retTask; - } - - protected PrismObject getTaskTree(String taskOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".getTask"); - OperationResult result = task.getResult(); - PrismObject retTask = modelService.getObject(TaskType.class, taskOid, retrieveItemsNamed(TaskType.F_RESULT, TaskType.F_SUBTASK), task, result); - result.computeStatus(); - TestUtil.assertSuccess("getObject(Task) result not success", result); - return retTask; - } - - protected CaseType getCase(String oid) throws ObjectNotFoundException, SchemaException { - return repositoryService.getObject(CaseType.class, oid, null, new OperationResult("dummy")).asObjectable(); - } - - protected void assertObjectExists(Class clazz, String oid) { - OperationResult result = new OperationResult("assertObjectExists"); - try { - repositoryService.getObject(clazz, oid, null, result); - } catch (ObjectNotFoundException e) { - fail("Object of type " + clazz.getName() + " with OID " + oid + " doesn't exist: " + e.getMessage()); - } catch (SchemaException e) { - throw new SystemException("Object of type " + clazz.getName() + " with OID " + oid + " probably exists but couldn't be read: " + e.getMessage(), e); - } - } - - protected void assertObjectDoesntExist(Class clazz, String oid) { - OperationResult result = new OperationResult("assertObjectDoesntExist"); - try { - PrismObject object = repositoryService.getObject(clazz, oid, null, result); - fail("Object of type " + clazz.getName() + " with OID " + oid + " exists even if it shouldn't: " + object.debugDump()); - } catch (ObjectNotFoundException e) { - // ok - } catch (SchemaException e) { - throw new SystemException("Object of type " + clazz.getName() + " with OID " + oid + " probably exists, and moreover it couldn't be read: " + e.getMessage(), e); - } - } - - protected PrismObject getObject(Class type, String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".getObject"); - OperationResult result = task.getResult(); - PrismObject object = modelService.getObject(type, oid, null, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - return object; - } - - protected PrismObject getObjectViaRepo(Class type, String oid) throws ObjectNotFoundException, SchemaException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".getObject"); - OperationResult result = task.getResult(); - PrismObject object = repositoryService.getObject(type, oid, null, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - return object; - } - - protected void addObjects(File... files) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { - for (File file : files) { - addObject(file); - } - } - - protected void addObject(TestResource resource, Task task, OperationResult result) - throws IOException, ObjectNotFoundException, ConfigurationException, SecurityViolationException, - PolicyViolationException, ExpressionEvaluationException, ObjectAlreadyExistsException, CommunicationException, - SchemaException { - addObject(resource.file, task, result); - } - - protected PrismObject repoAddObject(TestResource resource, OperationResult result) - throws IOException, ObjectAlreadyExistsException, SchemaException, EncryptionException { - return repoAddObjectFromFile(resource.file, result); - } - - // not going through model to avoid conflicts (because the task starts execution during the clockwork operation) - protected void addTask(File file) throws SchemaException, IOException, ObjectAlreadyExistsException { - taskManager.addTask(prismContext.parseObject(file), new OperationResult("addTask")); - } - - protected void addObject(File file) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { - PrismObject object = prismContext.parseObject(file); - addObject(object); - } - - protected PrismObject addObject(File file, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { - return addObject(file, task, result, null); - } - - protected PrismObject addObject(File file, Task task, OperationResult result, Consumer> customizer) - throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, - CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { - PrismObject object = prismContext.parseObject(file); - if (customizer != null) { - customizer.accept(object); - } - addObject(object, task, result); - return object; - } - - protected String addObject(PrismObject object) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".addObject"); - OperationResult result = task.getResult(); - String oid = addObject(object, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - return oid; - } - - protected String addObject(PrismObject object, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - return addObject(object, null, task, result); - } - - protected String addObject(PrismObject object, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - ObjectDelta addDelta = object.createAddDelta(); - assertFalse("Immutable object provided?",addDelta.getObjectToAdd().isImmutable()); - Collection> executedDeltas = executeChanges(addDelta, options, task, result); - object.setOid(ObjectDeltaOperation.findAddDeltaOid(executedDeltas, object)); - return object.getOid(); - } - - protected void deleteObject(Class type, String oid, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - ObjectDelta delta = prismContext.deltaFactory().object().createDeleteDelta(type, oid); - executeChanges(delta, null, task, result); - } - - protected void deleteObjectRaw(Class type, String oid, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - ObjectDelta delta = prismContext.deltaFactory().object().createDeleteDelta(type, oid); - executeChanges(delta, ModelExecuteOptions.createRaw(), task, result); - } - - protected void deleteObject(Class type, String oid) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = createTask(AbstractModelIntegrationTest.class.getName() + ".deleteObject"); - OperationResult result = task.getResult(); - ObjectDelta delta = prismContext.deltaFactory().object().createDeleteDelta(type, oid); - executeChanges(delta, null, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - } - - protected void deleteObjectRepo(Class type, String oid) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - OperationResult result = new OperationResult(AbstractModelIntegrationTest.class.getName() + ".deleteObjectRepo"); - repositoryService.deleteObject(type, oid, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - } - - protected void forceDeleteShadow(String oid) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = createTask(AbstractModelIntegrationTest.class.getName() + ".forceDeleteShadow"); - OperationResult result = task.getResult(); - forceDeleteObject(ShadowType.class, oid, task, result); - assertSuccess(result); - } - - protected void forceDeleteShadow(String oid, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - forceDeleteObject(ShadowType.class, oid, task, result); - } - - protected void forceDeleteObject(Class type, String oid, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - ObjectDelta delta = prismContext.deltaFactory().object().createDeleteDelta(type, oid); - ModelExecuteOptions options = ModelExecuteOptions.createForce(); - executeChanges(delta, options, task, result); - } - - protected void addTrigger(String oid, XMLGregorianCalendar timestamp, String uri) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".addTrigger"); - OperationResult result = task.getResult(); - TriggerType triggerType = new TriggerType(); - triggerType.setTimestamp(timestamp); - triggerType.setHandlerUri(uri); - ObjectDelta delta = prismContext.deltaFactory().object() - .createModificationAddContainer(ObjectType.class, oid, ObjectType.F_TRIGGER, - triggerType); - executeChanges(delta, null, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - } - - protected void addTriggers(String oid, Collection timestamps, String uri, boolean makeDistinct) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".addTriggers"); - OperationResult result = task.getResult(); - Collection triggers = timestamps.stream() - .map(ts -> new TriggerType().timestamp(ts).handlerUri(uri)) - .map(ts -> makeDistinct ? addRandomValue(ts) : ts) - .collect(Collectors.toList()); - ObjectDelta delta = prismContext.deltaFor(ObjectType.class) - .item(ObjectType.F_TRIGGER).addRealValues(triggers) - .asObjectDeltaCast(oid); - executeChanges(delta, null, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - } - - private TriggerType addRandomValue(TriggerType trigger) { - //noinspection unchecked - @NotNull PrismPropertyDefinition workItemIdDef = - prismContext.getSchemaRegistry().findPropertyDefinitionByElementName(SchemaConstants.MODEL_EXTENSION_WORK_ITEM_ID); - PrismProperty workItemIdProp = workItemIdDef.instantiate(); - workItemIdProp.addRealValue((long) (Math.random() * 100000000000L)); - try { - //noinspection unchecked - trigger.asPrismContainerValue().findOrCreateContainer(TriggerType.F_EXTENSION).add(workItemIdProp); - } catch (SchemaException e) { - throw new AssertionError(e); - } - return trigger; - } - - protected void replaceTriggers(String oid, Collection timestamps, String uri) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".replaceTriggers"); - OperationResult result = task.getResult(); - Collection triggers = timestamps.stream() - .map(ts -> new TriggerType().timestamp(ts).handlerUri(uri)) - .collect(Collectors.toList()); - ObjectDelta delta = prismContext.deltaFor(ObjectType.class) - .item(ObjectType.F_TRIGGER).replaceRealValues(triggers) - .asObjectDeltaCast(oid); - executeChanges(delta, null, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - } - - protected void assertTrigger(PrismObject object, String handlerUri, XMLGregorianCalendar start, XMLGregorianCalendar end) throws ObjectNotFoundException, SchemaException { - for (TriggerType trigger: object.asObjectable().getTrigger()) { - if (handlerUri.equals(trigger.getHandlerUri()) - && MiscUtil.isBetween(trigger.getTimestamp(), start, end)) { - return; - } - } - AssertJUnit.fail("Expected that " + object + " will have a trigger but it has not"); - } - - protected void assertTrigger(PrismObject object, String handlerUri, XMLGregorianCalendar mid, long tolerance) throws ObjectNotFoundException, SchemaException { - XMLGregorianCalendar start = XmlTypeConverter.addMillis(mid, -tolerance); - XMLGregorianCalendar end = XmlTypeConverter.addMillis(mid, tolerance); - for (TriggerType trigger: object.asObjectable().getTrigger()) { - if (handlerUri.equals(trigger.getHandlerUri()) - && MiscUtil.isBetween(trigger.getTimestamp(), start, end)) { - return; - } - } - AssertJUnit.fail("Expected that "+object+" will have a trigger but it has not"); - } - - protected void assertNoTrigger(Class type, String oid) throws ObjectNotFoundException, SchemaException { - OperationResult result = new OperationResult(AbstractModelIntegrationTest.class.getName() + ".assertNoTrigger"); - PrismObject object = repositoryService.getObject(type, oid, null, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - assertNoTrigger(object); - } - - protected void assertNoTrigger(PrismObject object) throws ObjectNotFoundException, SchemaException { - List triggers = object.asObjectable().getTrigger(); - if (triggers != null && !triggers.isEmpty()) { - AssertJUnit.fail("Expected that "+object+" will have no triggers but it has "+triggers.size()+ " trigger: "+ triggers); - } - } - - protected void prepareNotifications() { - notificationManager.setDisabled(false); - dummyTransport.clearMessages(); - } - - protected void checkDummyTransportMessages(String name, int expectedCount) { - List messages = dummyTransport.getMessages("dummy:" + name); - if (expectedCount == 0) { - if (messages != null && !messages.isEmpty()) { - LOGGER.error(messages.size() + " unexpected message(s) recorded in dummy transport '" + name + "'"); - logNotifyMessages(messages); - printNotifyMessages(messages); - fail(messages.size() + " unexpected message(s) recorded in dummy transport '" + name + "'"); - } - } else { - assertNotNull("No messages recorded in dummy transport '" + name + "'", messages); - if (expectedCount != messages.size()) { - LOGGER.error("Invalid number of messages recorded in dummy transport '" + name + "', expected: "+expectedCount+", actual: "+messages.size()); - logNotifyMessages(messages); - printNotifyMessages(messages); - assertEquals("Invalid number of messages recorded in dummy transport '" + name + "'", expectedCount, messages.size()); - } - } - } - - protected void assertSingleDummyTransportMessage(String name, String expectedBody) { - List messages = dummyTransport.getMessages("dummy:" + name); - assertNotNull("No messages recorded in dummy transport '" + name + "'", messages); - if (messages.size() != 1) { - fail("Invalid number of messages recorded in dummy transport '" + name + "', expected: 1, actual: "+messages.size()); - } - Message message = messages.get(0); - assertEquals("Unexpected notifier "+name+" message body", expectedBody, message.getBody()); - } - - protected void assertSingleDummyTransportMessageContaining(String name, String expectedSubstring) { - List messages = dummyTransport.getMessages("dummy:" + name); - assertNotNull("No messages recorded in dummy transport '" + name + "'", messages); - if (messages.size() != 1) { - fail("Invalid number of messages recorded in dummy transport '" + name + "', expected: 1, actual: "+messages.size()); - } - Message message = messages.get(0); - assertTrue("Notifier "+name+" message body does not contain text: " + expectedSubstring + ", it is:\n" + message.getBody(), - message.getBody().contains(expectedSubstring)); - } - - protected String getDummyTransportMessageBody(String name, int index) { - List messages = dummyTransport.getMessages("dummy:" + name); - Message message = messages.get(index); - return message.getBody(); - } - - protected void assertHasDummyTransportMessage(String name, String expectedBody) { - List messages = dummyTransport.getMessages("dummy:" + name); - assertNotNull("No messages recorded in dummy transport '" + name + "'", messages); - for (Message message: messages) { - if (expectedBody.equals(message.getBody())) { - return; - } - } - fail("Notifier "+name+" message body " + expectedBody + " not found"); - } - - protected void displayAllNotifications() { - for (java.util.Map.Entry> entry: dummyTransport.getMessages().entrySet()) { - List messages = entry.getValue(); - if (messages != null && !messages.isEmpty()) { - display("Notification messages: "+entry.getKey(), messages); - } - } - } - - protected void displayNotifications(String name) { - List messages = dummyTransport.getMessages("dummy:" + name); - display("Notification messages: "+name, messages); - } - - private void logNotifyMessages(List messages) { - for (Message message: messages) { - LOGGER.debug("Notification message:\n{}", message.getBody()); - } - } - - private void printNotifyMessages(List messages) { - for (Message message: messages) { - System.out.println(message); - } - } - - protected void checkDummyTransportMessagesAtLeast(String name, int expectedCount) { - if (expectedCount == 0) { - return; - } - List messages = dummyTransport.getMessages("dummy:" + name); - assertNotNull("No messages recorded in dummy transport '" + name + "'", messages); - assertTrue("Number of messages recorded in dummy transport '" + name + "' (" + messages.size() + ") is not at least " + expectedCount, messages.size() >= expectedCount); - } - - protected DummyAccount getDummyAccount(String dummyInstanceName, String username) throws SchemaViolationException, ConflictException, InterruptedException { - DummyResource dummyResource = DummyResource.getInstance(dummyInstanceName); - try { - return dummyResource.getAccountByUsername(username); - } catch (ConnectException e) { - throw new IllegalStateException(e.getMessage(),e); - } catch (FileNotFoundException e) { - throw new IllegalStateException(e.getMessage(),e); - } - } - - protected DummyAccount getDummyAccountById(String dummyInstanceName, String id) throws SchemaViolationException, ConflictException, InterruptedException { - DummyResource dummyResource = DummyResource.getInstance(dummyInstanceName); - try { - return dummyResource.getAccountById(id); - } catch (ConnectException e) { - throw new IllegalStateException(e.getMessage(),e); - } catch (FileNotFoundException e) { - throw new IllegalStateException(e.getMessage(),e); - } - } - - protected DummyAccount assertDefaultDummyAccount(String username, String fullname, boolean active) throws SchemaViolationException, ConflictException, InterruptedException { - return assertDummyAccount(null, username, fullname, active); - } - - protected DummyAccount assertDummyAccount(String dummyInstanceName, String username, String fullname, Boolean active) throws SchemaViolationException, ConflictException, InterruptedException { - DummyAccount account = getDummyAccount(dummyInstanceName, username); - // display("account", account); - assertNotNull("No dummy("+dummyInstanceName+") account for username "+username, account); - assertEquals("Wrong fullname for dummy("+dummyInstanceName+") account "+username, fullname, account.getAttributeValue("fullname")); - assertEquals("Wrong activation for dummy(" + dummyInstanceName + ") account " + username, active, account.isEnabled()); - return account; - } - - protected DummyAccount assertDummyAccount(String dummyInstanceName, String username) throws SchemaViolationException, ConflictException, InterruptedException { - DummyAccount account = getDummyAccount(dummyInstanceName, username); - assertNotNull("No dummy(" + dummyInstanceName + ") account for username " + username, account); - return account; - } - - protected DummyAccountAsserter assertDummyAccountById(String dummyResourceName, String id) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { - return getDummyResourceController(dummyResourceName).assertAccountById(id); - } - - protected void assertNoDummyAccountById(String dummyInstanceName, String id) throws SchemaViolationException, ConflictException, InterruptedException { - DummyAccount account = getDummyAccountById(dummyInstanceName, id); - assertNull("Dummy(" + dummyInstanceName + ") account for id " + id + " exists while not expecting it", account); - } - - protected void assertDummyAccountActivation(String dummyInstanceName, String username, Boolean active) throws SchemaViolationException, ConflictException, InterruptedException { - DummyAccount account = getDummyAccount(dummyInstanceName, username); - assertNotNull("No dummy("+dummyInstanceName+") account for username "+username, account); - assertEquals("Wrong activation for dummy(" + dummyInstanceName + ") account " + username, active, account.isEnabled()); - } - - protected void assertNoDummyAccount(String username) throws SchemaViolationException, ConflictException, InterruptedException { - assertNoDummyAccount(null, username); - } - - protected void assertNoDummyAccount(String dummyInstanceName, String username) throws SchemaViolationException, ConflictException, InterruptedException { - DummyAccount account = getDummyAccount(dummyInstanceName, username); - assertNull("Dummy account for username " + username + " exists while not expecting it (" + dummyInstanceName + ")", account); - } - - protected void assertDefaultDummyAccountAttribute(String username, String attributeName, Object... expectedAttributeValues) throws SchemaViolationException, ConflictException, InterruptedException { - assertDummyAccountAttribute(null, username, attributeName, expectedAttributeValues); - } - - protected void assertDummyAccountAttribute(String dummyInstanceName, String username, String attributeName, Object... expectedAttributeValues) throws SchemaViolationException, ConflictException, InterruptedException { - DummyAccount account = getDummyAccount(dummyInstanceName, username); - assertNotNull("No dummy account for username "+username, account); - Set values = account.getAttributeValues(attributeName, Object.class); - if ((values == null || values.isEmpty()) && (expectedAttributeValues == null || expectedAttributeValues.length == 0)) { - return; - } - assertNotNull("No values for attribute "+attributeName+" of "+dummyInstanceName+" dummy account "+username, values); - assertEquals("Unexpected number of values for attribute " + attributeName + " of "+dummyInstanceName+" dummy account " + username + - ". Expected: " + Arrays.toString(expectedAttributeValues) + ", was: " + values, - expectedAttributeValues.length, values.size()); - for (Object expectedValue: expectedAttributeValues) { - if (!values.contains(expectedValue)) { - AssertJUnit.fail("Value '"+expectedValue+"' expected in attribute "+attributeName+" of "+dummyInstanceName+" dummy account "+username+ - " but not found. Values found: "+values); - } - } - } - - protected void assertNoDummyAccountAttribute(String dummyInstanceName, String username, String attributeName) throws SchemaViolationException, ConflictException, InterruptedException { - DummyAccount account = getDummyAccount(dummyInstanceName, username); - assertNotNull("No dummy "+dummyInstanceName+" account for username "+username, account); - Set values = account.getAttributeValues(attributeName, Object.class); - if (values == null || values.isEmpty()) { - return; - } - AssertJUnit.fail("Expected no value in attribute " + attributeName + " of "+dummyInstanceName+" dummy account " + username + - ". Values found: " + values); - } - - protected void assertDummyAccountAttributeGenerated(String dummyInstanceName, String username) throws SchemaViolationException, ConflictException, InterruptedException { - DummyAccount account = getDummyAccount(dummyInstanceName, username); - assertNotNull("No dummy account for username "+username, account); - Integer generated = account.getAttributeValue(DummyAccount.ATTR_INTERNAL_ID, Integer.class); - if (generated == null) { - AssertJUnit.fail("No value in generated attribute dir of " + dummyInstanceName + " dummy account " + username); - } - } - - protected DummyGroup getDummyGroup(String dummyInstanceName, String name) throws SchemaViolationException, ConflictException, InterruptedException { - DummyResource dummyResource = DummyResource.getInstance(dummyInstanceName); - try { - return dummyResource.getGroupByName(name); - } catch (ConnectException e) { - throw new IllegalStateException(e.getMessage(),e); - } catch (FileNotFoundException e) { - throw new IllegalStateException(e.getMessage(),e); - } - } - - protected void assertDummyGroup(String username, String description) throws SchemaViolationException, ConflictException, InterruptedException { - assertDummyGroup(null, username, description, null); - } - - protected void assertDummyGroup(String username, String description, Boolean active) throws SchemaViolationException, ConflictException, InterruptedException { - assertDummyGroup(null, username, description, active); - } - - protected void assertDummyGroup(String dummyInstanceName, String groupname, String description, Boolean active) throws SchemaViolationException, ConflictException, InterruptedException { - DummyGroup group = getDummyGroup(dummyInstanceName, groupname); - assertNotNull("No dummy("+dummyInstanceName+") group for name "+groupname, group); - assertEquals("Wrong fullname for dummy(" + dummyInstanceName + ") group " + groupname, description, - group.getAttributeValue(DummyResourceContoller.DUMMY_GROUP_ATTRIBUTE_DESCRIPTION)); - if (active != null) { - assertEquals("Wrong activation for dummy("+dummyInstanceName+") group "+groupname, active, group.isEnabled()); - } - } - - protected void assertNoDummyGroup(String groupname) throws SchemaViolationException, ConflictException, InterruptedException { - assertNoDummyGroup(null, groupname); - } - - protected void assertNoDummyGroup(String dummyInstanceName, String groupname) throws SchemaViolationException, ConflictException, InterruptedException { - DummyGroup group = getDummyGroup(dummyInstanceName, groupname); - assertNull("Dummy group '" + groupname + "' exists while not expecting it (" + dummyInstanceName + ")", group); - } - - protected void assertDummyGroupAttribute(String dummyInstanceName, String groupname, String attributeName, Object... expectedAttributeValues) throws SchemaViolationException, ConflictException, InterruptedException { - DummyGroup group = getDummyGroup(dummyInstanceName, groupname); - assertNotNull("No dummy group for groupname "+groupname, group); - Set values = group.getAttributeValues(attributeName, Object.class); - if ((values == null || values.isEmpty()) && (expectedAttributeValues == null || expectedAttributeValues.length == 0)) { - return; - } - assertNotNull("No values for attribute "+attributeName+" of "+dummyInstanceName+" dummy group "+groupname, values); - assertEquals("Unexpected number of values for attribute " + attributeName + " of dummy group " + groupname + ": " + values, expectedAttributeValues.length, values.size()); - for (Object expectedValue: expectedAttributeValues) { - if (!values.contains(expectedValue)) { - AssertJUnit.fail("Value '"+expectedValue+"' expected in attribute "+attributeName+" of dummy group "+groupname+ - " but not found. Values found: "+values); - } - } - } - - protected void assertDummyGroupMember(String dummyInstanceName, String dummyGroupName, String accountId) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { - DummyResource dummyResource = DummyResource.getInstance(dummyInstanceName); - DummyGroup group = dummyResource.getGroupByName(dummyGroupName); - assertNotNull("No dummy group "+dummyGroupName, group); - IntegrationTestTools.assertGroupMember(group, accountId); - } - - protected void assertDefaultDummyGroupMember(String dummyGroupName, String accountId) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { - assertDummyGroupMember(null, dummyGroupName, accountId); - } - - protected void assertNoDummyGroupMember(String dummyInstanceName, String dummyGroupName, String accountId) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { - DummyResource dummyResource = DummyResource.getInstance(dummyInstanceName); - DummyGroup group = dummyResource.getGroupByName(dummyGroupName); - IntegrationTestTools.assertNoGroupMember(group, accountId); - } - - protected void assertNoDefaultDummyGroupMember(String dummyGroupName, String accountId) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { - assertNoDummyGroupMember(null, dummyGroupName, accountId); - } - - protected void assertDummyAccountNoAttribute(String dummyInstanceName, String username, String attributeName) throws SchemaViolationException, ConflictException, InterruptedException { - DummyAccount account = getDummyAccount(dummyInstanceName, username); - assertNotNull("No dummy account for username "+username, account); - Set values = account.getAttributeValues(attributeName, Object.class); - assertTrue("Unexpected values for attribute " + attributeName + " of dummy account " + username + ": " + values, values == null || values.isEmpty()); - } - - protected Entry assertOpenDjAccount(String uid, String cn, Boolean active) throws DirectoryException { - Entry entry = openDJController.searchByUid(uid); - assertNotNull("OpenDJ accoun with uid "+uid+" not found", entry); - openDJController.assertAttribute(entry, "cn", cn); - if (active != null) { - openDJController.assertActive(entry, active); - } - return entry; - } - - protected void assertNoOpenDjAccount(String uid) throws DirectoryException { - Entry entry = openDJController.searchByUid(uid); - assertNull("Expected that OpenDJ account with uid " + uid + " will be gone, but it is still there", entry); - } - - protected void assertIteration(PrismObject shadow, Integer expectedIteration, String expectedIterationToken) { - PrismAsserts.assertPropertyValue(shadow, ShadowType.F_ITERATION, expectedIteration); - PrismAsserts.assertPropertyValue(shadow, ShadowType.F_ITERATION_TOKEN, expectedIterationToken); - } - - protected void assertIterationDelta(ObjectDelta shadowDelta, Integer expectedIteration, String expectedIterationToken) { - PrismAsserts.assertPropertyReplace(shadowDelta, ShadowType.F_ITERATION, expectedIteration); - PrismAsserts.assertPropertyReplace(shadowDelta, ShadowType.F_ITERATION_TOKEN, expectedIterationToken); - } - - protected void assertSituation(PrismObject shadow, SynchronizationSituationType expectedSituation) { - if (expectedSituation == null) { - PrismAsserts.assertNoItem(shadow, ShadowType.F_SYNCHRONIZATION_SITUATION); - } else { - PrismAsserts.assertPropertyValue(shadow, ShadowType.F_SYNCHRONIZATION_SITUATION, expectedSituation); - } - } - - protected void assertEnableTimestampFocus(PrismObject focus, - XMLGregorianCalendar startTime, XMLGregorianCalendar endTime) { - XMLGregorianCalendar userDisableTimestamp = focus.asObjectable().getActivation().getEnableTimestamp(); - TestUtil.assertBetween("Wrong user enableTimestamp in "+focus, - startTime, endTime, userDisableTimestamp); - } - - protected void assertDisableTimestampFocus(PrismObject focus, - XMLGregorianCalendar startTime, XMLGregorianCalendar endTime) { - XMLGregorianCalendar userDisableTimestamp = focus.asObjectable().getActivation().getDisableTimestamp(); - TestUtil.assertBetween("Wrong user disableTimestamp in "+focus, - startTime, endTime, userDisableTimestamp); - } - - protected void assertEnableTimestampShadow(PrismObject shadow, - XMLGregorianCalendar startTime, XMLGregorianCalendar endTime) { - ActivationType activationType = shadow.asObjectable().getActivation(); - assertNotNull("No activation in "+shadow, activationType); - XMLGregorianCalendar userDisableTimestamp = activationType.getEnableTimestamp(); - TestUtil.assertBetween("Wrong shadow enableTimestamp in "+shadow, - startTime, endTime, userDisableTimestamp); - } - - protected void assertDisableTimestampShadow(PrismObject shadow, - XMLGregorianCalendar startTime, XMLGregorianCalendar endTime) { - XMLGregorianCalendar userDisableTimestamp = shadow.asObjectable().getActivation().getDisableTimestamp(); - TestUtil.assertBetween("Wrong shadow disableTimestamp in "+shadow, - startTime, endTime, userDisableTimestamp); - } - - protected void assertDisableReasonShadow(PrismObject shadow, String expectedReason) { - String disableReason = shadow.asObjectable().getActivation().getDisableReason(); - assertEquals("Wrong shadow disableReason in " + shadow, expectedReason, disableReason); - } - - protected String getPassword(PrismObject user) throws EncryptionException { - CredentialsType credentialsType = user.asObjectable().getCredentials(); - assertNotNull("No credentials in "+user, credentialsType); - PasswordType passwordType = credentialsType.getPassword(); - assertNotNull("No password in "+user, passwordType); - ProtectedStringType protectedStringType = passwordType.getValue(); - assertNotNull("No password value in "+user, protectedStringType); - return protector.decryptString(protectedStringType); - } - - protected void assertPassword(PrismObject user, String expectedPassword) throws EncryptionException { - String decryptedUserPassword = getPassword(user); - assertEquals("Wrong password in "+user, expectedPassword, decryptedUserPassword); - } - - protected void assertUserLdapPassword(PrismObject user, String expectedPassword) throws EncryptionException { - CredentialsType credentialsType = user.asObjectable().getCredentials(); - assertNotNull("No credentials in "+user, credentialsType); - PasswordType passwordType = credentialsType.getPassword(); - assertNotNull("No password in "+user, passwordType); - ProtectedStringType protectedStringType = passwordType.getValue(); - assertLdapPassword(protectedStringType, expectedPassword, user); - } - - protected void assertShadowLdapPassword(PrismObject shadow, String expectedPassword) throws EncryptionException { - CredentialsType credentialsType = shadow.asObjectable().getCredentials(); - assertNotNull("No credentials in "+shadow, credentialsType); - PasswordType passwordType = credentialsType.getPassword(); - assertNotNull("No password in "+shadow, passwordType); - ProtectedStringType protectedStringType = passwordType.getValue(); - assertLdapPassword(protectedStringType, expectedPassword, shadow); - } - - protected void assertLdapPassword(ProtectedStringType protectedStringType, String expectedPassword, PrismObject source) throws EncryptionException { - assertNotNull("No password value in "+source, protectedStringType); - String decryptedUserPassword = protector.decryptString(protectedStringType); - assertNotNull("Null password in " + source, decryptedUserPassword); - if (decryptedUserPassword.startsWith("{") || decryptedUserPassword.contains("}")) { - assertTrue("Wrong password hash in "+source+": "+decryptedUserPassword+", expected "+expectedPassword, ldapShaPasswordEncoder.matches(decryptedUserPassword, expectedPassword)); - } else { - assertEquals("Wrong password in "+source, expectedPassword, decryptedUserPassword); - } - } - - protected void assertGroupMember(DummyGroup group, String accountId) { - IntegrationTestTools.assertGroupMember(group, accountId); - } - - protected void assertNoGroupMember(DummyGroup group, String accountId) { - IntegrationTestTools.assertNoGroupMember(group, accountId); - } - - protected void assertNoGroupMembers(DummyGroup group) { - IntegrationTestTools.assertNoGroupMembers(group); - } - - protected void login(String principalName) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - MidPointPrincipal principal = focusProfileService.getPrincipal(principalName, UserType.class); - login(principal); - } - - protected void login(PrismObject user) throws SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - MidPointPrincipal principal = focusProfileService.getPrincipal(user); - login(principal); - } - - protected void login(MidPointPrincipal principal) { - SecurityContext securityContext = SecurityContextHolder.getContext(); - Authentication authentication = new UsernamePasswordAuthenticationToken(principal, null, principal.getAuthorities()); - securityContext.setAuthentication(createMpAuthentication(authentication)); - } - - protected Authentication createMpAuthentication(Authentication authentication) { - MidpointAuthentication mpAuthentication = new MidpointAuthentication(SecurityPolicyUtil.createDefaultSequence()); - ModuleAuthentication moduleAuthentication = new ModuleAuthentication(NameOfModuleType.LOGIN_FORM); - moduleAuthentication.setAuthentication(authentication); - moduleAuthentication.setNameOfModule(SecurityPolicyUtil.DEFAULT_MODULE_NAME); - moduleAuthentication.setState(StateOfModule.SUCCESSFULLY); - moduleAuthentication.setPrefix(ModuleWebSecurityConfiguration.DEFAULT_PREFIX_OF_MODULE_WITH_SLASH - + ModuleWebSecurityConfiguration.DEFAULT_PREFIX_FOR_DEFAULT_MODULE + SecurityPolicyUtil.DEFAULT_MODULE_NAME + "/"); - mpAuthentication.addAuthentications(moduleAuthentication); - mpAuthentication.setPrincipal(authentication.getPrincipal()); - return mpAuthentication; - } - - protected void loginSuperUser(String principalName) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - MidPointPrincipal principal = focusProfileService.getPrincipal(principalName, UserType.class); - loginSuperUser(principal); - } - - protected void loginSuperUser(PrismObject user) throws SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - MidPointPrincipal principal = focusProfileService.getPrincipal(user); - loginSuperUser(principal); - } - - protected void loginSuperUser(MidPointPrincipal principal) throws SchemaException { - AuthorizationType superAutzType = new AuthorizationType(); - prismContext.adopt(superAutzType, RoleType.class, RoleType.F_AUTHORIZATION); - superAutzType.getAction().add(AuthorizationConstants.AUTZ_ALL_URL); - Authorization superAutz = new Authorization(superAutzType); - Collection authorities = principal.getAuthorities(); - authorities.add(superAutz); - SecurityContext securityContext = SecurityContextHolder.getContext(); - Authentication authentication = new UsernamePasswordAuthenticationToken(principal, null); - securityContext.setAuthentication(createMpAuthentication(authentication)); - } - - protected void loginAnonymous() { - Authentication authentication = new AnonymousAuthenticationToken("foo", - AuthorizationConstants.ANONYMOUS_USER_PRINCIPAL, AuthorityUtils.createAuthorityList("ROLE_ANONYMOUS")); - SecurityContextHolder.getContext().setAuthentication(createMpAuthentication(authentication)); - } - - protected void assertLoggedInUsername(String username) { - MidPointPrincipal midPointPrincipal = getSecurityContextPrincipal(); - FocusType user = midPointPrincipal.getFocus(); - if (user == null) { - if (username == null) { - return; - } else { - AssertJUnit.fail("Expected logged in user '"+username+"' but there was no user in the spring security context"); - } - } - assertEquals("Wrong logged-in user", username, user.getName().getOrig()); - } - - protected void assertLoggedInUserOid(String userOid) { - MidPointPrincipal midPointPrincipal = getSecurityContextPrincipal(); - assertPrincipalUserOid(midPointPrincipal, userOid); - } - - protected void assertPrincipalUserOid(MidPointPrincipal principal, String userOid) { - FocusType user = principal.getFocus(); - if (user == null) { - if (userOid == null) { - return; - } else { - AssertJUnit.fail("Expected user "+userOid+" in principal "+principal+" but there was none"); - } - } - assertEquals("Wrong user OID in principal", userOid, user.getOid()); - } - - protected MidPointPrincipal getSecurityContextPrincipal() { - SecurityContext securityContext = SecurityContextHolder.getContext(); - Authentication authentication = securityContext.getAuthentication(); - if (authentication == null) { - return null; - } - Object principal = authentication.getPrincipal(); - if (principal == null) { - return null; - } - if (principal instanceof MidPointPrincipal) { - return (MidPointPrincipal)principal; - } else { - AssertJUnit.fail("Unknown principal in the spring security context: "+principal); - return null; // not reached - } - } - - protected PrismObject getSecurityContextPrincipalFocus() { - SecurityContext securityContext = SecurityContextHolder.getContext(); - Authentication authentication = securityContext.getAuthentication(); - if (authentication == null) { - return null; - } - Object principal = authentication.getPrincipal(); - if (principal == null) { - return null; - } - if (principal instanceof MidPointPrincipal) { - FocusType focusType = ((MidPointPrincipal)principal).getFocus(); - if (focusType == null) { - return null; - } - return focusType.asPrismObject(); - } else { - return null; - } - } - - protected void assertAuthenticated() { - SecurityContext securityContext = SecurityContextHolder.getContext(); - Authentication authentication = securityContext.getAuthentication(); - assertTrue("Security context is not authenticated", authentication.isAuthenticated()); - } - - protected void resetAuthentication() { - SecurityContext securityContext = SecurityContextHolder.getContext(); - securityContext.setAuthentication(null); - } - - protected void assertNoAuthentication() { - SecurityContext securityContext = SecurityContextHolder.getContext(); - assertNull("Unexpected authentication", securityContext.getAuthentication()); - } - - protected void assertSecurityContextPrincipalAttorneyOid(String attotrneyOid) { - MidPointPrincipal midPointPrincipal = getSecurityContextPrincipal(); - assertPrincipalAttorneyOid(midPointPrincipal, attotrneyOid); - } - - protected void assertPrincipalAttorneyOid(MidPointPrincipal principal, String attotrneyOid) { - FocusType attorney = principal.getAttorney(); - if (attorney == null) { - if (attotrneyOid == null) { - return; - } else { - AssertJUnit.fail("Expected attorney "+attotrneyOid+" in principal "+principal+" but there was none"); - } - } - assertEquals("Wrong attroney OID in principal", attotrneyOid, attorney.getOid()); - } - - protected Collection getSecurityContextAuthorizations() { - MidPointPrincipal midPointPrincipal = getSecurityContextPrincipal(); - if (midPointPrincipal == null) { - return null; - } - return midPointPrincipal.getAuthorities(); - } - - protected void assertAuthorizationActions(String message, Collection autzs, String... expectedActions) { - Collection actualActions = autzs.stream() - .map(a -> a.getAction()) - .flatMap(List::stream) - .collect(Collectors.toList()); - PrismAsserts.assertEqualsCollectionUnordered(message, actualActions, expectedActions); - } - - protected void assertSecurityContextAuthorizationActions(String... expectedActions) { - Collection securityContextAuthorizations = getSecurityContextAuthorizations(); - assertAuthorizationActions("Wrong authorizations in security context", securityContextAuthorizations, expectedActions); - } - - protected void assertSecurityContextAuthorizationActions(ModelAuthorizationAction... expectedModelActions) { - Collection securityContextAuthorizations = getSecurityContextAuthorizations(); - String[] expectedActions = new String[expectedModelActions.length]; - for (int i=0;i securityContextAuthorizations = getSecurityContextAuthorizations(); - if (securityContextAuthorizations != null && !securityContextAuthorizations.isEmpty()) { - fail("Unexpected authorizations in security context: "+securityContextAuthorizations); - } - } - - protected void displayAllUsers() throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".displayAllUsers"); - OperationResult result = task.getResult(); - ResultHandler handler = (object, parentResult) -> { - display("User", object); - return true; - }; - modelService.searchObjectsIterative(UserType.class, null, handler, null, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - } - - /** - * Returns appropriate object synchronization settings for the class. - * Assumes single sync setting for now. - */ - protected ObjectSynchronizationType determineSynchronization(ResourceType resource, Class type, String name) { - SynchronizationType synchronization = resource.getSynchronization(); - if (synchronization == null) { - return null; - } - List objectSynchronizations = synchronization.getObjectSynchronization(); - if (objectSynchronizations.isEmpty()) { - return null; - } - for (ObjectSynchronizationType objSyncType: objectSynchronizations) { - QName focusTypeQName = objSyncType.getFocusType(); - if (focusTypeQName == null) { - if (type != UserType.class) { - continue; - } - } else { - ObjectTypes focusType = ObjectTypes.getObjectTypeFromTypeQName(focusTypeQName); - if (type != focusType.getClassDefinition()) { - continue; - } - } - if (name == null) { - // we got it - return objSyncType; - } else { - if (name.equals(objSyncType.getName())) { - return objSyncType; - } - } - } - throw new IllegalArgumentException("Synchronization setting for "+type+" and name "+name+" not found in "+resource); - } - - protected void assertShadowKindIntent(String shadowOid, ShadowKindType expectedKind, - String expectedIntent) throws ObjectNotFoundException, SchemaException { - OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName()+".assertShadowKindIntent"); - PrismObject shadow = repositoryService.getObject(ShadowType.class, shadowOid, null, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - assertShadowKindIntent(shadow, expectedKind, expectedIntent); - } - - protected void assertShadowKindIntent(PrismObject shadow, ShadowKindType expectedKind, - String expectedIntent) { - assertEquals("Wrong kind in " + shadow, expectedKind, shadow.asObjectable().getKind()); - assertEquals("Wrong intent in " + shadow, expectedIntent, shadow.asObjectable().getIntent()); - } - - protected PrismObject getDefaultActor() { - return null; - } - - protected Task createTask(String operationName) { - Task task = super.createTask(operationName); - PrismObject defaultActor = getDefaultActor(); - if (defaultActor != null) { - task.setOwner(defaultActor); - } - task.setChannel(DEFAULT_CHANNEL); - return task; - } - - protected Task createTask(String operationName, MidPointPrincipal principal) { - Task task = super.createTask(operationName); - task.setOwner(principal.getFocus().asPrismObject()); - task.setChannel(DEFAULT_CHANNEL); - return task; - } - - protected void modifyRoleAddConstruction(String roleOid, long inducementId, String resourceOid) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = createTask(AbstractModelIntegrationTest.class.getName() + ".modifyRoleAddConstruction"); - OperationResult result = task.getResult(); - ConstructionType construction = new ConstructionType(); - ObjectReferenceType resourceRedRef = new ObjectReferenceType(); - resourceRedRef.setOid(resourceOid); - construction.setResourceRef(resourceRedRef); - ObjectDelta roleDelta = prismContext.deltaFactory().object() - .createModificationAddContainer(RoleType.class, roleOid, - ItemPath.create(RoleType.F_INDUCEMENT, inducementId, AssignmentType.F_CONSTRUCTION), - construction); - modelService.executeChanges(MiscSchemaUtil.createCollection(roleDelta), null, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - } - - protected void modifyRoleAddInducementTarget(String roleOid, String targetOid, boolean reconcileAffected, - ModelExecuteOptions defaultOptions, Task task) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - if (task == null) { - task = createTask(AbstractModelIntegrationTest.class.getName() + ".modifyRoleAddInducementTarget"); - } - OperationResult result = task.getResult(); - AssignmentType inducement = new AssignmentType(); - ObjectReferenceType targetRef = new ObjectReferenceType(); - targetRef.setOid(targetOid); - inducement.setTargetRef(targetRef); - ObjectDelta roleDelta = prismContext.deltaFactory().object() - .createModificationAddContainer(RoleType.class, roleOid, - RoleType.F_INDUCEMENT, inducement); - ModelExecuteOptions options = nullToEmpty(defaultOptions); - options.setReconcileAffected(reconcileAffected); - executeChanges(roleDelta, options, task, result); - result.computeStatus(); - if (reconcileAffected) { - TestUtil.assertInProgressOrSuccess(result); - } else { - TestUtil.assertSuccess(result); - } - } - - protected void modifyRoleAddExclusion(String roleOid, String excludedRoleOid, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - modifyRoleExclusion(roleOid, excludedRoleOid, true, task, result); - } - - protected void modifyRoleDeleteExclusion(String roleOid, String excludedRoleOid, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - modifyRoleExclusion(roleOid, excludedRoleOid, false, task, result); - } - - protected void modifyRoleExclusion(String roleOid, String excludedRoleOid, boolean add, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - modifyRolePolicyRule(roleOid, createExclusionPolicyRule(excludedRoleOid), add, task, result); - } - - protected void modifyRolePolicyRule(String roleOid, PolicyRuleType exclusionPolicyRule, boolean add, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - AssignmentType assignment = new AssignmentType(); - assignment.setPolicyRule(exclusionPolicyRule); - ObjectDelta roleDelta; - if (add) { - roleDelta = prismContext.deltaFactory().object() - .createModificationAddContainer(RoleType.class, roleOid, RoleType.F_ASSIGNMENT, - assignment); - } else { - roleDelta = prismContext.deltaFactory().object() - .createModificationDeleteContainer(RoleType.class, roleOid, RoleType.F_ASSIGNMENT, - assignment); - } - executeChanges(roleDelta, null, task, result); - } - - protected void modifyRoleAddAssignment(String roleOid, AssignmentType assignment, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - ObjectDelta roleDelta = prismContext.deltaFactory().object() - .createModificationAddContainer(RoleType.class, roleOid, RoleType.F_ASSIGNMENT, - assignment); - executeChanges(roleDelta, null, task, result); - } - - protected void modifyRoleDeleteAssignment(String roleOid, AssignmentType assignment, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - ObjectDelta roleDelta = prismContext.deltaFactory().object() - .createModificationDeleteContainer(RoleType.class, roleOid, RoleType.F_ASSIGNMENT, - assignment); - executeChanges(roleDelta, null, task, result); - } - - protected PolicyRuleType createExclusionPolicyRule(String excludedRoleOid) { - PolicyRuleType policyRule = new PolicyRuleType(); - PolicyConstraintsType policyContraints = new PolicyConstraintsType(); - ExclusionPolicyConstraintType exclusionConstraint = new ExclusionPolicyConstraintType(); - ObjectReferenceType targetRef = new ObjectReferenceType(); - targetRef.setOid(excludedRoleOid); - targetRef.setType(RoleType.COMPLEX_TYPE); - exclusionConstraint.setTargetRef(targetRef); - policyContraints.getExclusion().add(exclusionConstraint); - policyRule.setPolicyConstraints(policyContraints); - return policyRule; - } - - protected PolicyRuleType createMinAssigneePolicyRule(int minAssignees) { - PolicyRuleType policyRule = new PolicyRuleType(); - PolicyConstraintsType policyContraints = new PolicyConstraintsType(); - MultiplicityPolicyConstraintType minAssigneeConstraint = new MultiplicityPolicyConstraintType(); - minAssigneeConstraint.setMultiplicity(Integer.toString(minAssignees)); - policyContraints.getMinAssignees().add(minAssigneeConstraint); - policyRule.setPolicyConstraints(policyContraints); - return policyRule; - } - - protected PolicyRuleType createMaxAssigneePolicyRule(int maxAssignees) { - PolicyRuleType policyRule = new PolicyRuleType(); - PolicyConstraintsType policyContraints = new PolicyConstraintsType(); - MultiplicityPolicyConstraintType maxAssigneeConstraint = new MultiplicityPolicyConstraintType(); - maxAssigneeConstraint.setMultiplicity(Integer.toString(maxAssignees)); - policyContraints.getMaxAssignees().add(maxAssigneeConstraint); - policyRule.setPolicyConstraints(policyContraints); - return policyRule; - } - - protected AssignmentType createAssignmentIdOnly(long id) { - AssignmentType assignment = new AssignmentType(); - assignment.asPrismContainerValue().setId(id); - return assignment; - } - - protected void modifyRoleAddPolicyException(String roleOid, PolicyExceptionType policyException, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - ObjectDelta roleDelta = prismContext.deltaFactory().object() - .createModificationAddContainer(RoleType.class, roleOid, RoleType.F_POLICY_EXCEPTION, - policyException); - executeChanges(roleDelta, null, task, result); - } - - protected void modifyRoleDeletePolicyException(String roleOid, PolicyExceptionType policyException, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - ObjectDelta roleDelta = prismContext.deltaFactory().object() - .createModificationDeleteContainer(RoleType.class, roleOid, RoleType.F_POLICY_EXCEPTION, - policyException); - executeChanges(roleDelta, null, task, result); - } - - protected void modifyRoleReplacePolicyException(String roleOid, PolicyExceptionType policyException, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - ObjectDelta roleDelta = prismContext.deltaFactory().object() - .createModificationReplaceContainer(RoleType.class, roleOid, RoleType.F_POLICY_EXCEPTION, - policyException); - executeChanges(roleDelta, null, task, result); - } - - protected PolicyExceptionType createPolicyException(String ruleName, String policySituation) { - PolicyExceptionType policyException = new PolicyExceptionType(); - policyException.setPolicySituation(policySituation); - policyException.setRuleName(ruleName); - return policyException; - } - - protected Optional findAssignmentByTarget(PrismObject focus, String targetOid) { - return focus.asObjectable().getAssignment().stream() - .filter(a -> a.getTargetRef() != null && targetOid.equals(a.getTargetRef().getOid())) - .findFirst(); - } - - protected AssignmentType findAssignmentByTargetRequired(PrismObject focus, String targetOid) { - return findAssignmentByTarget(focus, targetOid) - .orElseThrow(() -> new IllegalStateException("No assignment to " + targetOid + " in " + focus)); - } - - - protected AssignmentType findInducementByTarget(String roleOid, String targetOid) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = createTask(AbstractModelIntegrationTest.class.getName() + ".findInducementByTarget"); - OperationResult result = task.getResult(); - PrismObject role = modelService.getObject(RoleType.class, roleOid, null, task, result); - for (AssignmentType inducement: role.asObjectable().getInducement()) { - ObjectReferenceType targetRef = inducement.getTargetRef(); - if (targetRef != null && targetOid.equals(targetRef.getOid())) { - return inducement; - } - } - return null; - } - - protected void modifyRoleDeleteInducementTarget(String roleOid, String targetOid, - ModelExecuteOptions options) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = createTask(AbstractModelIntegrationTest.class.getName() + ".modifyRoleDeleteInducementTarget"); - OperationResult result = task.getResult(); - AssignmentType inducement = findInducementByTarget(roleOid, targetOid); - ObjectDelta roleDelta = prismContext.deltaFactory().object() - .createModificationDeleteContainer(RoleType.class, roleOid, RoleType.F_INDUCEMENT, - inducement.asPrismContainerValue().clone()); - modelService.executeChanges(MiscSchemaUtil.createCollection(roleDelta), options, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - } - - protected void modifyRoleDeleteInducement(String roleOid, long inducementId, boolean reconcileAffected, - ModelExecuteOptions defaultOptions, Task task) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - if (task == null) { - task = createTask(AbstractModelIntegrationTest.class.getName() + ".modifyRoleDeleteInducement"); - } - OperationResult result = task.getResult(); - - AssignmentType inducement = new AssignmentType(); - inducement.setId(inducementId); - ObjectDelta roleDelta = prismContext.deltaFactory().object() - .createModificationDeleteContainer(RoleType.class, roleOid, - RoleType.F_INDUCEMENT, inducement); - ModelExecuteOptions options = nullToEmpty(defaultOptions); - options.setReconcileAffected(reconcileAffected); - executeChanges(roleDelta, options, task, result); - result.computeStatus(); - if (reconcileAffected) { - TestUtil.assertInProgressOrSuccess(result); - } else { - TestUtil.assertSuccess(result); - } - } - - @NotNull - protected ModelExecuteOptions nullToEmpty(ModelExecuteOptions options) { - return options != null ? options : new ModelExecuteOptions(); - } - - protected void modifyUserAddAccount(String userOid, File accountFile, Task task, OperationResult result) throws SchemaException, IOException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - PrismObject account = prismContext.parseObject(accountFile); - - ObjectDelta userDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, userOid - ); - PrismReferenceValue accountRefVal = itemFactory().createReferenceValue(); - accountRefVal.setObject(account); - ReferenceDelta accountDelta = prismContext.deltaFactory().reference().createModificationAdd(UserType.F_LINK_REF, getUserDefinition(), accountRefVal); - userDelta.addModification(accountDelta); - Collection> deltas = (Collection)MiscUtil.createCollection(userDelta); - - modelService.executeChanges(deltas, null, task, result); - } - - protected void assertAuthorized(MidPointPrincipal principal, String action) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { - Task task = createTask("assertAuthorized", principal); - assertAuthorized(principal, action, null, task, task.getResult()); - assertAuthorized(principal, action, AuthorizationPhaseType.REQUEST, task, task.getResult()); - assertAuthorized(principal, action, AuthorizationPhaseType.EXECUTION, task, task.getResult()); - assertSuccess(task.getResult()); - } - - protected void assertAuthorized(MidPointPrincipal principal, String action, AuthorizationPhaseType phase) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { - Task task = createTask("assertAuthorized", principal); - assertAuthorized(principal, action, phase, task, task.getResult()); - assertSuccess(task.getResult()); - } - - protected void assertAuthorized(MidPointPrincipal principal, String action, AuthorizationPhaseType phase, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { - SecurityContext origContext = SecurityContextHolder.getContext(); - createSecurityContext(principal); - try { - assertTrue("AuthorizationEvaluator.isAuthorized: Principal "+principal+" NOT authorized for action "+action, - securityEnforcer.isAuthorized(action, phase, AuthorizationParameters.EMPTY, null, task, result)); - if (phase == null) { - List requiredActions = new ArrayList<>(1); - requiredActions.add(action); - securityEnforcer.decideAccess(getSecurityContextPrincipal(), requiredActions, task, result); - } - } finally { - SecurityContextHolder.setContext(origContext); - } - } - - protected void assertNotAuthorized(MidPointPrincipal principal, String action) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { - Task task = createTask("assertNotAuthorized", principal); - assertNotAuthorized(principal, action, null, task, task.getResult()); - assertNotAuthorized(principal, action, AuthorizationPhaseType.REQUEST, task, task.getResult()); - assertNotAuthorized(principal, action, AuthorizationPhaseType.EXECUTION, task, task.getResult()); - assertSuccess(task.getResult()); - } - - protected void assertNotAuthorized(MidPointPrincipal principal, String action, AuthorizationPhaseType phase) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { - Task task = createTask("assertNotAuthorized", principal); - assertNotAuthorized(principal, action, phase, task, task.getResult()); - assertSuccess(task.getResult()); - } - - protected void assertNotAuthorized(MidPointPrincipal principal, String action, AuthorizationPhaseType phase, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { - SecurityContext origContext = SecurityContextHolder.getContext(); - createSecurityContext(principal); - boolean isAuthorized = securityEnforcer.isAuthorized(action, phase, AuthorizationParameters.EMPTY, null, task, result); - SecurityContextHolder.setContext(origContext); - assertFalse("AuthorizationEvaluator.isAuthorized: Principal " + principal + " IS authorized for action " + action + " (" + phase + ") but he should not be", isAuthorized); - } - - protected void assertAuthorizations(PrismObject user, String... expectedAuthorizations) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - MidPointPrincipal principal = focusProfileService.getPrincipal(user); - assertNotNull("No principal for "+user, principal); - assertAuthorizations(principal, expectedAuthorizations); - } - - protected void assertAuthorizations(MidPointPrincipal principal, String... expectedAuthorizations) { - List actualAuthorizations = new ArrayList<>(); - for (Authorization authorization: principal.getAuthorities()) { - actualAuthorizations.addAll(authorization.getAction()); - } - PrismAsserts.assertSets("Wrong authorizations in "+principal, actualAuthorizations, expectedAuthorizations); - } - - - protected void assertNoAuthorizations(PrismObject user) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - MidPointPrincipal principal = focusProfileService.getPrincipal(user); - assertNotNull("No principal for "+user, principal); - assertNoAuthorizations(principal); - } - - protected void assertNoAuthorizations(MidPointPrincipal principal) { - if (principal.getAuthorities() != null && !principal.getAuthorities().isEmpty()) { - AssertJUnit.fail("Unexpected authorizations in "+principal+": "+principal.getAuthorities()); - } - } - - protected CompiledGuiProfileAsserter assertCompiledGuiProfile(MidPointPrincipal principal) { - if (!(principal instanceof GuiProfiledPrincipal)) { - fail("Expected GuiProfiledPrincipal, but got "+principal.getClass()); - } - CompiledGuiProfile compiledGuiProfile = ((GuiProfiledPrincipal)principal).getCompiledGuiProfile(); - CompiledGuiProfileAsserter asserter = new CompiledGuiProfileAsserter<>(compiledGuiProfile, null, "in principal "+principal); - initializeAsserter(asserter); - asserter.display(); - return asserter; - } - - protected CompiledGuiProfileAsserter assertCompiledGuiProfile(CompiledGuiProfile compiledGuiProfile) { - CompiledGuiProfileAsserter asserter = new CompiledGuiProfileAsserter<>(compiledGuiProfile, null, null); - initializeAsserter(asserter); - asserter.display(); - return asserter; - } - - protected EvaluatedPolicyRulesAsserter assertEvaluatedPolicyRules(Collection evaluatedPolicyRules) { - EvaluatedPolicyRulesAsserter asserter = new EvaluatedPolicyRulesAsserter<>(evaluatedPolicyRules, null, null); - initializeAsserter(asserter); - asserter.display(); - return asserter; - } - - protected EvaluatedPolicyRulesAsserter assertEvaluatedPolicyRules(Collection evaluatedPolicyRules, PrismObject sourceObject) { - EvaluatedPolicyRulesAsserter asserter = new EvaluatedPolicyRulesAsserter<>(evaluatedPolicyRules, null, sourceObject.toString()); - initializeAsserter(asserter); - asserter.display(); - return asserter; - } - - protected void createSecurityContext(MidPointPrincipal principal) { - SecurityContext context = new SecurityContextImpl(); - Authentication authentication = new UsernamePasswordAuthenticationToken(principal, null); - context.setAuthentication(authentication); - SecurityContextHolder.setContext(context); - } - - protected Object createSecureObject() { - return new FilterInvocation("/midpoint", "whateverServlet", "doSomething"); - } - - protected Collection createConfigAttributes(String action) { - Collection attrs = new ArrayList<>(); - attrs.add(new SecurityConfig(action)); - return attrs; - } - - protected PrismObjectDefinition getEditObjectDefinition(PrismObject object) throws SchemaException, ConfigurationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".getEditObjectDefinition"); - OperationResult result = task.getResult(); - PrismObjectDefinition editSchema = modelInteractionService.getEditObjectDefinition(object, null, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - return editSchema; - } - - protected RoleSelectionSpecification getAssignableRoleSpecification(PrismObject targetHolder) throws ObjectNotFoundException, SchemaException, ConfigurationException, ExpressionEvaluationException, CommunicationException, SecurityViolationException { - return getAssignableRoleSpecification(targetHolder, 0); - } - - protected RoleSelectionSpecification getAssignableRoleSpecification(PrismObject focus, int assignmentOrder) throws ObjectNotFoundException, SchemaException, ConfigurationException, ExpressionEvaluationException, CommunicationException, SecurityViolationException { - return getAssignableRoleSpecification(focus, AbstractRoleType.class, 0); - } - - protected RoleSelectionSpecification getAssignableRoleSpecification(PrismObject focus, Class targetType, int assignmentOrder) throws ObjectNotFoundException, SchemaException, ConfigurationException, ExpressionEvaluationException, CommunicationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".getAssignableRoleSpecification"); - OperationResult result = task.getResult(); - RoleSelectionSpecification spec = modelInteractionService.getAssignableRoleSpecification(focus, targetType, assignmentOrder, task, result); - assertSuccess(result); - return spec; - } - - protected RoleSelectionSpecificationAsserter assertAssignableRoleSpecification(PrismObject targetHolder) throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException { - RoleSelectionSpecification spec = getAssignableRoleSpecification(targetHolder); - RoleSelectionSpecificationAsserter asserter = new RoleSelectionSpecificationAsserter(spec, null, "for holder "+targetHolder); - initializeAsserter(asserter); - asserter.display(); - return asserter; - } - - protected RoleSelectionSpecificationAsserter assertAssignableRoleSpecification(PrismObject targetHolder, int order) throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException { - RoleSelectionSpecification spec = getAssignableRoleSpecification(targetHolder, order); - RoleSelectionSpecificationAsserter asserter = new RoleSelectionSpecificationAsserter(spec, null, "for holder "+targetHolder+", order "+order); - initializeAsserter(asserter); - asserter.display(); - return asserter; - } - - protected RoleSelectionSpecificationAsserter assertAssignableRoleSpecification(PrismObject targetHolder, Class roleType, int order) throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException { - RoleSelectionSpecification spec = getAssignableRoleSpecification(targetHolder, roleType, order); - RoleSelectionSpecificationAsserter asserter = new RoleSelectionSpecificationAsserter(spec, null, "for holder "+targetHolder+", role type "+roleType.getSimpleName()+", order "+order); - initializeAsserter(asserter); - asserter.display(); - return asserter; - } - - protected void assertAllowRequestAssignmentItems(String userOid, String targetRoleOid, ItemPath... expectedAllowedItemPaths) - throws SchemaException, SecurityViolationException, CommunicationException, ObjectNotFoundException, ConfigurationException, ExpressionEvaluationException { - Task task = createTask(AbstractModelIntegrationTest.class.getName() + ".assertAllowRequestItems"); - OperationResult result = task.getResult(); - assertAllowRequestAssignmentItems(userOid, targetRoleOid, task, result, expectedAllowedItemPaths); - assertSuccess(result); - } - - protected void assertAllowRequestAssignmentItems(String userOid, String targetRoleOid, Task task, OperationResult result, ItemPath... expectedAllowedItemPaths) - throws SchemaException, SecurityViolationException, CommunicationException, ObjectNotFoundException, ConfigurationException, ExpressionEvaluationException { - PrismObject user = getUser(userOid); - PrismObject target = getRole(targetRoleOid); - - ItemSecurityConstraints constraints = modelInteractionService.getAllowedRequestAssignmentItems(user, target, task, result); - display("Request decisions for "+target, constraints); - - for (ItemPath expectedAllowedItemPath: expectedAllowedItemPaths) { - AuthorizationDecisionType decision = constraints.findItemDecision(expectedAllowedItemPath); - assertEquals("Wrong decision for item "+expectedAllowedItemPath, AuthorizationDecisionType.ALLOW, decision); - } - } - - - protected void assertEncryptedUserPassword(String userOid, String expectedClearPassword) throws EncryptionException, ObjectNotFoundException, SchemaException { - OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName()+".assertEncryptedUserPassword"); - PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - assertEncryptedUserPassword(user, expectedClearPassword); - } - - protected void assertEncryptedUserPassword(PrismObject user, String expectedClearPassword) throws EncryptionException { - UserType userType = user.asObjectable(); - ProtectedStringType protectedActualPassword = userType.getCredentials().getPassword().getValue(); - String actualClearPassword = protector.decryptString(protectedActualPassword); - assertEquals("Wrong password for "+user, expectedClearPassword, actualClearPassword); - } - - @Deprecated - protected void assertPasswordMetadata(PrismObject user, boolean create, XMLGregorianCalendar start, XMLGregorianCalendar end, String actorOid, String channel) { - PrismContainer metadataContainer = user.findContainer(PATH_CREDENTIALS_PASSWORD_METADATA); - assertNotNull("No password metadata in "+user, metadataContainer); - MetadataType metadataType = metadataContainer.getValue().asContainerable(); - assertMetadata("password metadata in "+user, metadataType, create, false, start, end, actorOid, channel); - } - - protected void assertPasswordMetadata(PrismObject user, QName credentialType, boolean create, XMLGregorianCalendar start, XMLGregorianCalendar end, String actorOid, String channel) { - PrismContainer metadataContainer = user.findContainer(ItemPath.create(UserType.F_CREDENTIALS, credentialType, PasswordType.F_METADATA)); - assertNotNull("No password metadata in "+user, metadataContainer); - MetadataType metadataType = metadataContainer.getValue().asContainerable(); - assertMetadata("password metadata in "+user, metadataType, create, false, start, end, actorOid, channel); - } - - protected void assertCreateMetadata(PrismObject object, XMLGregorianCalendar start, XMLGregorianCalendar end) { - MetadataType metadataType = object.asObjectable().getMetadata(); - PrismObject defaultActor = getDefaultActor(); - assertMetadata(object.toString(), metadataType, true, true, start, end, - defaultActor==null?null:defaultActor.getOid(), DEFAULT_CHANNEL); - } - - protected void assertModifyMetadata(PrismObject object, XMLGregorianCalendar start, XMLGregorianCalendar end) { - MetadataType metadataType = object.asObjectable().getMetadata(); - PrismObject defaultActor = getDefaultActor(); - assertMetadata(object.toString(), metadataType, false, false, start, end, - defaultActor==null?null:defaultActor.getOid(), DEFAULT_CHANNEL); - } - - protected void assertCreateMetadata(AssignmentType assignmentType, XMLGregorianCalendar start, XMLGregorianCalendar end) { - MetadataType metadataType = assignmentType.getMetadata(); - PrismObject defaultActor = getDefaultActor(); - assertMetadata(assignmentType.toString(), metadataType, true, true, start, end, - defaultActor==null?null:defaultActor.getOid(), DEFAULT_CHANNEL); - } - - protected void assertDummyPassword(String instance, String userId, String expectedClearPassword) throws SchemaViolationException, ConflictException, InterruptedException { - DummyAccount account = getDummyAccount(instance, userId); - assertNotNull("No dummy account "+userId, account); - assertEquals("Wrong password in dummy '"+instance+"' account "+userId, expectedClearPassword, account.getPassword()); - } - - protected void assertDummyPasswordNotEmpty(String instance, String userId) throws SchemaViolationException, ConflictException, InterruptedException { - DummyAccount account = getDummyAccount(instance, userId); - assertNotNull("No dummy account "+userId, account); - String actualPassword = account.getPassword(); - if (actualPassword == null || actualPassword.isEmpty()) { - fail("Empty password in dummy '"+instance+"' account "+userId); - } - } - - protected void reconcileUser(String oid, Task task, OperationResult result) throws CommunicationException, ObjectAlreadyExistsException, ExpressionEvaluationException, PolicyViolationException, SchemaException, SecurityViolationException, ConfigurationException, ObjectNotFoundException { - reconcileUser(oid, null, task, result); - } - - protected void reconcileUser(String oid, ModelExecuteOptions options, Task task, OperationResult result) throws CommunicationException, ObjectAlreadyExistsException, ExpressionEvaluationException, PolicyViolationException, SchemaException, SecurityViolationException, ConfigurationException, ObjectNotFoundException { - ObjectDelta emptyDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, oid); - modelService.executeChanges(MiscSchemaUtil.createCollection(emptyDelta), ModelExecuteOptions.createReconcile(options), task, result); - } - - protected void reconcileOrg(String oid, Task task, OperationResult result) throws CommunicationException, ObjectAlreadyExistsException, ExpressionEvaluationException, PolicyViolationException, SchemaException, SecurityViolationException, ConfigurationException, ObjectNotFoundException { - ObjectDelta emptyDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(OrgType.class, oid); - modelService.executeChanges(MiscSchemaUtil.createCollection(emptyDelta), ModelExecuteOptions.createReconcile(), task, result); - } - - protected void assertRefEquals(String message, ObjectReferenceType expected, ObjectReferenceType actual) { - if (expected == null && actual == null) { - return; - } - if (expected == null || actual == null) { - fail(message + ": expected=" + expected + ", actual=" + actual); - } - PrismAsserts.assertRefEquivalent(message, expected.asReferenceValue(), actual.asReferenceValue()); - } - - protected void assertTaskClosed(PrismObject task) { - assertEquals("Wrong executionStatus in "+task, TaskExecutionStatusType.CLOSED, task.asObjectable().getExecutionStatus()); - } - - protected void assertTaskClosed(Task task) { - assertEquals("Wrong executionStatus in "+task, TaskExecutionStatus.CLOSED, task.getExecutionStatus()); - } - - protected List getAllAuditRecords(Task task, OperationResult result) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - Map params = new HashMap<>(); - return modelAuditService.listRecords("select * from m_audit_event as aer order by aer.timestampValue asc", params, task, result); - } - - protected List getAuditRecords(int maxRecords, Task task, OperationResult result) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - Map params = new HashMap<>(); - params.put("setMaxResults", maxRecords); - return modelAuditService.listRecords("select * from m_audit_event as aer order by aer.timestampValue asc", params, task, result); - } - - protected List getObjectAuditRecords(String oid) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - Task task = createTask("getObjectAuditRecords"); - OperationResult result = task.getResult(); - return getObjectAuditRecords(oid, task, result); - } - - protected List getObjectAuditRecords(String oid, Task task, OperationResult result) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - Map params = new HashMap<>(); - params.put("targetOid", oid); - return modelAuditService.listRecords("select * from m_audit_event as aer where (aer.targetOid = :targetOid) order by aer.timestampValue asc", - params, task, result); - } - - protected List getParamAuditRecords(String paramName, String paramValue, Task task, OperationResult result) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - Map params = new HashMap<>(); - params.put("paramName", paramName); - params.put("paramValue", paramValue); - return modelAuditService.listRecords("select * from m_audit_event as aer left join aer.propertyValues as pv where (pv.name = :paramName and pv.value = :paramValue) order by aer.timestampValue asc", - params, task, result); - } - - protected List getAuditRecordsFromTo(XMLGregorianCalendar from, XMLGregorianCalendar to) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - Task task = createTask("getAuditRecordsFromTo"); - OperationResult result = task.getResult(); - return getAuditRecordsFromTo(from, to, task, result); - } - - protected List getAuditRecordsFromTo(XMLGregorianCalendar from, XMLGregorianCalendar to, Task task, OperationResult result) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - Map params = new HashMap<>(); - params.put("from", from); - params.put("to", to); - return modelAuditService.listRecords("select * from m_audit_event as aer where (aer.timestampValue >= :from) and (aer.timestampValue <= :to) order by aer.timestampValue asc", - params, task, result); - } - - protected void checkUserApprovers(String oid, List expectedApprovers, OperationResult result) throws SchemaException, ObjectNotFoundException { - PrismObject user = repositoryService.getObject(UserType.class, oid, null, result); - checkApprovers(user, expectedApprovers, user.asObjectable().getMetadata().getModifyApproverRef(), result); - } - - protected void checkUserApproversForCreate(String oid, List expectedApprovers, OperationResult result) throws SchemaException, ObjectNotFoundException { - PrismObject user = repositoryService.getObject(UserType.class, oid, null, result); - checkApprovers(user, expectedApprovers, user.asObjectable().getMetadata().getCreateApproverRef(), result); - } - - protected void checkApproversForCreate(Class clazz, String oid, List expectedApprovers, OperationResult result) throws SchemaException, ObjectNotFoundException { - PrismObject object = repositoryService.getObject(clazz, oid, null, result); - checkApprovers(object, expectedApprovers, object.asObjectable().getMetadata().getCreateApproverRef(), result); - } - - protected void checkApprovers(PrismObject object, List expectedApprovers, List realApprovers, OperationResult result) throws SchemaException, ObjectNotFoundException { - HashSet realApproversSet = new HashSet<>(); - for (ObjectReferenceType approver : realApprovers) { - realApproversSet.add(approver.getOid()); - assertEquals("Unexpected target type in approverRef", UserType.COMPLEX_TYPE, approver.getType()); - } - assertEquals("Mismatch in approvers in metadata", new HashSet(expectedApprovers), realApproversSet); - } - - protected PrismObject findUserInRepo(String name, OperationResult result) throws SchemaException { - List> users = findUserInRepoUnchecked(name, result); - assertEquals("Didn't find exactly 1 user object with name " + name, 1, users.size()); - return users.get(0); - } - - protected List> findUserInRepoUnchecked(String name, OperationResult result) throws SchemaException { - ObjectQuery q = prismContext.queryFor(UserType.class).item(UserType.F_NAME).eqPoly(name).matchingOrig().build(); - return repositoryService.searchObjects(UserType.class, q, null, result); - } - - protected List> findRoleInRepoUnchecked(String name, OperationResult result) throws SchemaException { - ObjectQuery q = prismContext.queryFor(RoleType.class).item(RoleType.F_NAME).eqPoly(name).matchingOrig().build(); - return repositoryService.searchObjects(RoleType.class, q, null, result); - } - - protected void assertFocusModificationSanity(ModelContext context) throws JAXBException { - ModelElementContext focusContext = context.getFocusContext(); - PrismObject focusOld = focusContext.getObjectOld(); - if (focusOld == null) { - return; - } - ObjectDelta focusPrimaryDelta = focusContext.getPrimaryDelta(); - if (focusPrimaryDelta != null) { - assertEquals("No OID in old focus object", focusOld.getOid(), focusPrimaryDelta.getOid()); - assertEquals(ChangeType.MODIFY, focusPrimaryDelta.getChangeType()); - assertNull(focusPrimaryDelta.getObjectToAdd()); - for (ItemDelta itemMod : focusPrimaryDelta.getModifications()) { - if (itemMod.getValuesToDelete() != null) { - Item property = focusOld.findItem(itemMod.getPath()); - assertNotNull("Deleted item " + itemMod.getParentPath() + "/" + itemMod.getElementName() + " not found in focus", property); - for (Object valueToDelete : itemMod.getValuesToDelete()) { - if (!property.contains((PrismValue) valueToDelete, EquivalenceStrategy.REAL_VALUE)) { - display("Deleted value " + valueToDelete + " is not in focus item " + itemMod.getParentPath() + "/" + itemMod.getElementName()); - display("Deleted value", valueToDelete); - display("HASHCODE: " + valueToDelete.hashCode()); - for (Object value : property.getValues()) { - display("Existing value", value); - display("EQUALS: " + valueToDelete.equals(value)); - display("HASHCODE: " + value.hashCode()); - } - fail("Deleted value " + valueToDelete + " is not in focus item " + itemMod.getParentPath() + "/" + itemMod.getElementName()); - } - } - } - - } - } - } - - protected PrismObject getUserFromRepo(String oid, OperationResult result) throws SchemaException, ObjectNotFoundException { - return repositoryService.getObject(UserType.class, oid, null, result); - } - - protected boolean assignmentExists(List assignmentList, String targetOid) { - for (AssignmentType assignmentType : assignmentList) { - if (assignmentType.getTargetRef() != null && targetOid.equals(assignmentType.getTargetRef().getOid())) { - return true; - } - } - return false; - } - - // just guessing (good enough for testing) - protected boolean isH2() { - Task task = createTask("isH2"); - RepositoryDiag diag = modelDiagnosticService.getRepositoryDiag(task, task.getResult()); - return diag.isEmbedded() || "org.h2.Driver".equals(diag.getDriverShortName()); - } - - protected void assertNoPostponedOperation(PrismObject shadow) { - List pendingOperations = shadow.asObjectable().getPendingOperation(); - if (!pendingOperations.isEmpty()) { - AssertJUnit.fail("Expected no pending operations in "+shadow+", but found one: "+pendingOperations); - } - } - - protected String addAndRecomputeUser(File file, Task initTask, OperationResult initResult) throws Exception { - String oid = repoAddObjectFromFile(file, initResult).getOid(); - recomputeUser(oid, initTask, initResult); - display("User " + file, getUser(oid)); - return oid; - } - - protected String addAndRecompute(File file, Task task, OperationResult result) throws Exception { - PrismObject object = repoAddObjectFromFile(file, result); - modelService.recompute(object.asObjectable().getClass(), object.getOid(), null, task, result); - display("Object: " + file, getObject(object.asObjectable().getClass(), object.getOid())); - return object.getOid(); - } - - protected void assertAuditReferenceValue(List events, String refName, String oid, QName type, String name) { - if (events.size() != 1) { - display("Events", events); - assertEquals("Wrong # of events", 1, events.size()); - } - assertAuditReferenceValue(events.get(0), refName, oid, type, name); - } - - protected void assertAuditReferenceValue(AuditEventRecord event, String refName, String oid, QName type, String name) { - Set values = event.getReferenceValues(refName); - assertEquals("Wrong # of reference values of '" + refName + "'", 1, values.size()); - AuditReferenceValue value = values.iterator().next(); - assertEquals("Wrong OID", oid, value.getOid()); - assertEquals("Wrong type", type, value.getType()); - assertEquals("Wrong name", name, PolyString.getOrig(value.getTargetName())); - } - - protected void assertAuditTarget(AuditEventRecord event, String oid, QName type, String name) { - PrismReferenceValue target = event.getTarget(); - assertNotNull("No target", target); - assertEquals("Wrong OID", oid, target.getOid()); - assertEquals("Wrong type", type, target.getTargetType()); - assertEquals("Wrong name", name, PolyString.getOrig(target.getTargetName())); - } - - protected List filter(List records, AuditEventStage stage) { - return records.stream() - .filter(r -> r.getEventStage() == stage) - .collect(Collectors.toList()); - } - - protected List filter(List records, AuditEventType type, AuditEventStage stage) { - return records.stream() - .filter(r -> r.getEventType() == type && r.getEventStage() == stage) - .collect(Collectors.toList()); - } - - protected void resetTriggerTask(String taskOid, File taskFile, OperationResult result) - throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException, FileNotFoundException { - taskManager.suspendAndDeleteTasks(Collections.singletonList(taskOid), 60000L, true, result); - importObjectFromFile(taskFile, result); - taskManager.suspendTasks(Collections.singletonList(taskOid), 60000L, result); - modifySystemObjectInRepo(TaskType.class, taskOid, - prismContext.deltaFor(TaskType.class) - .item(TaskType.F_SCHEDULE).replace() - .asItemDeltas(), - result); - taskManager.resumeTasks(singleton(taskOid), result); - } - - protected void repoAddObjects(List objects, OperationResult result) - throws EncryptionException, ObjectAlreadyExistsException, SchemaException { - for (ObjectType object : objects) { - repoAddObject(object.asPrismObject(), result); - } - } - - protected void recomputeAndRefreshObjects(List objects, Task task, OperationResult result) - throws CommunicationException, ObjectNotFoundException, ObjectAlreadyExistsException, ConfigurationException, - SchemaException, SecurityViolationException, PolicyViolationException, ExpressionEvaluationException { - for (int i = 0; i < objects.size(); i++) { - ObjectType object = objects.get(i); - modelService.recompute(object.getClass(), object.getOid(), null, task, result); - objects.set(i, repositoryService.getObject(object.getClass(), object.getOid(), null, result).asObjectable()); - } - } - - protected void dumpAllUsers(OperationResult initResult) throws SchemaException { - SearchResultList> users = repositoryService - .searchObjects(UserType.class, null, null, initResult); - display("Users", users); - } - - protected PrismObject

assertLinkedPersona(PrismObject focus, Class

personaClass, String subtype) throws ObjectNotFoundException, SchemaException { - OperationResult result = new OperationResult("assertLinkedPersona"); - for (ObjectReferenceType personaRef: focus.asObjectable().getPersonaRef()) { - PrismObject

persona = repositoryService.getObject((Class

)ObjectTypes.getObjectTypeFromTypeQName(personaRef.getType()).getClassDefinition(), - personaRef.getOid(), null, result); - if (isTypeAndSubtype(persona, personaClass, subtype)) { - return persona; - } - } - fail("No persona "+personaClass.getSimpleName()+"/"+subtype+" in "+focus); - return null; // not reached - } - - protected boolean isTypeAndSubtype(PrismObject focus, Class expectedType, String subtype) { - if (!expectedType.isAssignableFrom(focus.getCompileTimeClass())) { - return false; - } - if (!FocusTypeUtil.hasSubtype(focus, subtype)) { - return false; - } - return true; - } - - protected PrismObject getOrg(String orgName) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - PrismObject org = findObjectByName(OrgType.class, orgName); - assertNotNull("The org "+orgName+" is missing!", org); - display("Org "+orgName, org); - PrismAsserts.assertPropertyValue(org, OrgType.F_NAME, createPolyString(orgName)); - return org; - } - - protected void dumpOrgTree() throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - display("Org tree", dumpOrgTree(getTopOrgOid())); - } - - protected void dumpOrgTreeAndUsers() throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - display("Org tree", dumpOrgTree(getTopOrgOid(), true)); - } - - protected String getTopOrgOid() { - return null; - } - - protected void transplantGlobalPolicyRulesAdd(File configWithGlobalRulesFile, Task task, OperationResult parentResult) throws SchemaException, IOException, ObjectNotFoundException, ObjectAlreadyExistsException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - // copy rules from the file into live system config object - PrismObject rules = prismContext.parserFor(configWithGlobalRulesFile).parse(); - ObjectDelta delta = prismContext.deltaFor(SystemConfigurationType.class) - .item(SystemConfigurationType.F_GLOBAL_POLICY_RULE).add( - rules.asObjectable().getGlobalPolicyRule().stream() - .map(r -> r.clone().asPrismContainerValue()) - .collect(Collectors.toList())) - .asObjectDeltaCast(SystemObjectsType.SYSTEM_CONFIGURATION.value()); - modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, parentResult); - } - - protected void displayProvisioningScripts() { - displayProvisioningScripts(null); - } - - protected void displayProvisioningScripts(String dummyName) { - display("Provisioning scripts "+dummyName, getDummyResource(dummyName).getScriptHistory()); - } - - protected void purgeProvisioningScriptHistory() { - purgeProvisioningScriptHistory(null); - } - - protected void purgeProvisioningScriptHistory(String dummyName) { - getDummyResource(dummyName).purgeScriptHistory(); - } - - protected void assertNoProvisioningScripts() { - if (!getDummyResource().getScriptHistory().isEmpty()) { - IntegrationTestTools.displayScripts(getDummyResource().getScriptHistory()); - AssertJUnit.fail(getDummyResource().getScriptHistory().size()+" provisioning scripts were executed while not expected any"); - } - } - - protected void assertDummyProvisioningScriptsNone() { - IntegrationTestTools.assertScripts(getDummyResource().getScriptHistory()); - } - - protected void applyPasswordPolicy(String passwordPolicyOid, String securityPolicyOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - if (passwordPolicyOid == null) { - modifyObjectReplaceReference(SecurityPolicyType.class, securityPolicyOid, PATH_CREDENTIALS_PASSWORD_VALUE_POLICY_REF, - task, result /* no value */); - } else { - PrismReferenceValue passPolicyRef = itemFactory().createReferenceValue(passwordPolicyOid, ValuePolicyType.COMPLEX_TYPE); - modifyObjectReplaceReference(SecurityPolicyType.class, securityPolicyOid, PATH_CREDENTIALS_PASSWORD_VALUE_POLICY_REF, - task, result, passPolicyRef); - } - } - - protected void assertPasswordCompliesWithPolicy(PrismObject user, String passwordPolicyOid) throws EncryptionException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { - Task task = createTask("assertPasswordCompliesWithPolicy"); - OperationResult result = task.getResult(); - assertPasswordCompliesWithPolicy(user, passwordPolicyOid, task, result); - assertSuccess(result); - } - - protected void assertPasswordCompliesWithPolicy(PrismObject user, String passwordPolicyOid, Task task, OperationResult result) throws EncryptionException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { - String password = getPassword(user); - display("Password of "+user, password); - PrismObject passwordPolicy = repositoryService.getObject(ValuePolicyType.class, passwordPolicyOid, null, result); - List messages = new ArrayList<>(); - boolean valid = valuePolicyProcessor.validateValue(password, passwordPolicy.asObjectable(), createUserOriginResolver(user), messages, "validating password of "+user, task, result); - if (!valid) { - fail("Password for "+user+" does not comply with password policy: "+messages); - } - } - - protected FocusValuePolicyOriginResolver createUserOriginResolver(PrismObject user) { - if (user != null) { - return new FocusValuePolicyOriginResolver<>(user, modelObjectResolver); - } else { - return null; - } - } - - protected List> getTasksForObject(String oid, QName type, - Collection> options, Task task, OperationResult result) - throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, - ConfigurationException, ExpressionEvaluationException { - ObjectQuery query = prismContext.queryFor(TaskType.class) - .item(TaskType.F_OBJECT_REF).ref(itemFactory().createReferenceValue(oid, type)) - .build(); - return modelService.searchObjects(TaskType.class, query, options, task, result); - } - - protected List> getCasesForObject(String oid, QName type, - Collection> options, Task task, OperationResult result) - throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, - ConfigurationException, ExpressionEvaluationException { - ObjectQuery query = prismContext.queryFor(CaseType.class) - .item(CaseType.F_OBJECT_REF).ref(itemFactory().createReferenceValue(oid, type)) - .build(); - return modelService.searchObjects(CaseType.class, query, options, task, result); - } - - protected CaseType getApprovalCase(List> cases) { - List rv = cases.stream() - .filter(o -> ObjectTypeUtil.hasArchetype(o, SystemObjectsType.ARCHETYPE_APPROVAL_CASE.value())) - .map(o -> o.asObjectable()) - .collect(Collectors.toList()); - if (rv.isEmpty()) { - throw new AssertionError("No approval case found"); - } else if (rv.size() > 1) { - throw new AssertionError("More than one approval case found: " + rv); - } else { - return rv.get(0); - } - } - - protected CaseType getRootCase(List> cases) { - List rv = cases.stream() - .map(o -> o.asObjectable()) - .filter(c -> c.getParentRef() == null) - .collect(Collectors.toList()); - if (rv.isEmpty()) { - throw new AssertionError("No root case found"); - } else if (rv.size() > 1) { - throw new AssertionError("More than one root case found: " + rv); - } else { - return rv.get(0); - } - } - - @SuppressWarnings("unused") // maybe in the future :) - protected Consumer createShowTaskTreeConsumer(long period) { - AtomicLong lastTimeShown = new AtomicLong(0); - return task -> { - try { - if (lastTimeShown.get() + period < System.currentTimeMillis()) { - dumpTaskTree(task.getOid(), getResult()); - lastTimeShown.set(System.currentTimeMillis()); - } - } catch (CommonException e) { - throw new AssertionError(e); - } - }; - } - - // highly experimental - public class TestCtx { - public final String name; - - public final Task task; - public final OperationResult result; - - TestCtx(Object testCase, String name) { - this.name = name; - TestUtil.displayTestTitle(testCase, name); - task = taskManager.createTaskInstance(testCase.getClass().getName() + "." + name); - result = task.getResult(); - dummyAuditService.clear(); - } - - public void displayWhen() { - TestUtil.displayWhen(name); - } - - public void displayThen() { - TestUtil.displayThen(name); - } - } - - protected TestCtx createContext(Object testCase, String testName) { - return new TestCtx(testCase, testName); - } - - protected T runPrivileged(Producer producer) { - return securityContextManager.runPrivileged(producer); - } - - protected void assertPendingOperationDeltas(PrismObject shadow, int expectedNumber) { - List pendingOperations = shadow.asObjectable().getPendingOperation(); - assertEquals("Wrong number of pending operations in "+shadow, expectedNumber, pendingOperations.size()); - } - - protected PendingOperationType assertSinglePendingOperation(PrismObject shadow, - XMLGregorianCalendar requestStart, XMLGregorianCalendar requestEnd) { - return assertSinglePendingOperation(shadow, requestStart, requestEnd, - OperationResultStatusType.IN_PROGRESS, null, null); - } - - protected PendingOperationType assertSinglePendingOperation(PrismObject shadow, - PendingOperationExecutionStatusType expectedExecutionStatus, OperationResultStatusType expectedResultStatus) { - assertPendingOperationDeltas(shadow, 1); - return assertPendingOperation(shadow, shadow.asObjectable().getPendingOperation().get(0), - null, null, expectedExecutionStatus, expectedResultStatus, null, null); - } - - protected PendingOperationType assertSinglePendingOperation(PrismObject shadow, - XMLGregorianCalendar requestStart, XMLGregorianCalendar requestEnd, - OperationResultStatusType expectedStatus, - XMLGregorianCalendar completionStart, XMLGregorianCalendar completionEnd) { - assertPendingOperationDeltas(shadow, 1); - return assertPendingOperation(shadow, shadow.asObjectable().getPendingOperation().get(0), - requestStart, requestEnd, expectedStatus, completionStart, completionEnd); - } - - protected PendingOperationType assertPendingOperation( - PrismObject shadow, PendingOperationType pendingOperation, - XMLGregorianCalendar requestStart, XMLGregorianCalendar requestEnd) { - return assertPendingOperation(shadow, pendingOperation, requestStart, requestEnd, - OperationResultStatusType.IN_PROGRESS, null, null); - } - - protected PendingOperationType assertPendingOperation( - PrismObject shadow, PendingOperationType pendingOperation, - PendingOperationExecutionStatusType expectedExecutionStatus, OperationResultStatusType expectedResultStatus) { - return assertPendingOperation(shadow, pendingOperation, null, null, - expectedExecutionStatus, expectedResultStatus, null, null); - } - - protected PendingOperationType assertPendingOperation( - PrismObject shadow, PendingOperationType pendingOperation) { - return assertPendingOperation(shadow, pendingOperation, null, null, - OperationResultStatusType.IN_PROGRESS, null, null); - } - - protected PendingOperationType assertPendingOperation( - PrismObject shadow, PendingOperationType pendingOperation, - XMLGregorianCalendar requestStart, XMLGregorianCalendar requestEnd, - OperationResultStatusType expectedResultStatus, - XMLGregorianCalendar completionStart, XMLGregorianCalendar completionEnd) { - PendingOperationExecutionStatusType expectedExecutionStatus; - if (expectedResultStatus == OperationResultStatusType.IN_PROGRESS) { - expectedExecutionStatus = PendingOperationExecutionStatusType.EXECUTING; - } else { - expectedExecutionStatus = PendingOperationExecutionStatusType.COMPLETED; - } - return assertPendingOperation(shadow, pendingOperation, requestStart, requestEnd, expectedExecutionStatus, expectedResultStatus, completionStart, completionEnd); - } - - protected PendingOperationType assertPendingOperation( - PrismObject shadow, PendingOperationType pendingOperation, - XMLGregorianCalendar requestStart, XMLGregorianCalendar requestEnd, - PendingOperationExecutionStatusType expectedExecutionStatus, - OperationResultStatusType expectedResultStatus, - XMLGregorianCalendar completionStart, XMLGregorianCalendar completionEnd) { - assertNotNull("No operation ", pendingOperation); - - ObjectDeltaType deltaType = pendingOperation.getDelta(); - assertNotNull("No delta in pending operation in "+shadow, deltaType); - // TODO: check content of pending operations in the shadow - - TestUtil.assertBetween("No request timestamp in pending operation in "+shadow, requestStart, requestEnd, pendingOperation.getRequestTimestamp()); - - PendingOperationExecutionStatusType executiontStatus = pendingOperation.getExecutionStatus(); - assertEquals("Wrong execution status in pending operation in "+shadow, expectedExecutionStatus, executiontStatus); - - OperationResultStatusType resultStatus = pendingOperation.getResultStatus(); - assertEquals("Wrong result status in pending operation in "+shadow, expectedResultStatus, resultStatus); - - // TODO: assert other timestamps - - if (expectedExecutionStatus == PendingOperationExecutionStatusType.COMPLETED) { - TestUtil.assertBetween("No completion timestamp in pending operation in "+shadow, completionStart, completionEnd, pendingOperation.getCompletionTimestamp()); - } - - return pendingOperation; - } - - protected PendingOperationType findPendingOperation(PrismObject shadow, - PendingOperationExecutionStatusType expectedExecutionStaus) { - return findPendingOperation(shadow, expectedExecutionStaus, null, null, null); - } - - protected PendingOperationType findPendingOperation(PrismObject shadow, - OperationResultStatusType expectedResult) { - return findPendingOperation(shadow, null, expectedResult, null, null); - } - - protected PendingOperationType findPendingOperation(PrismObject shadow, - OperationResultStatusType expectedResult, ItemPath itemPath) { - return findPendingOperation(shadow, null, expectedResult, null, itemPath); - } - - protected PendingOperationType findPendingOperation(PrismObject shadow, - PendingOperationExecutionStatusType expectedExecutionStaus, ItemPath itemPath) { - return findPendingOperation(shadow, expectedExecutionStaus, null, null, itemPath); - } - - protected PendingOperationType findPendingOperation(PrismObject shadow, - OperationResultStatusType expectedResult, ChangeTypeType expectedChangeType) { - return findPendingOperation(shadow, null, expectedResult, expectedChangeType, null); - } - - protected PendingOperationType findPendingOperation(PrismObject shadow, - PendingOperationExecutionStatusType expectedExecutionStatus, OperationResultStatusType expectedResult, - ChangeTypeType expectedChangeType, ItemPath itemPath) { - List pendingOperations = shadow.asObjectable().getPendingOperation(); - for (PendingOperationType pendingOperation: pendingOperations) { - if (expectedExecutionStatus != null && !expectedExecutionStatus.equals(pendingOperation.getExecutionStatus())) { - continue; - } - if (expectedResult != null && !expectedResult.equals(pendingOperation.getResultStatus())) { - continue; - } - ObjectDeltaType delta = pendingOperation.getDelta(); - if (expectedChangeType != null) { - if (!expectedChangeType.equals(delta.getChangeType())) { - continue; - } - } - if (itemPath == null) { - return pendingOperation; - } - assertNotNull("No delta in pending operation in "+shadow, delta); - for (ItemDeltaType itemDelta: delta.getItemDelta()) { - ItemPath deltaPath = itemDelta.getPath().getItemPath(); - if (itemPath.equivalent(deltaPath)) { - return pendingOperation; - } - } - } - return null; - } - - protected UserAsserter assertUserAfter(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - UserAsserter asserter = assertUser(oid, "after"); - asserter.assertOid(oid); - return asserter; - } - - protected UserAsserter assertUserAfterByUsername(String username) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - UserAsserter asserter = assertUserByUsername(username, "after"); - asserter.display(); - asserter.assertName(username); - return asserter; - } - - protected UserAsserter assertUserBefore(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - UserAsserter asserter = assertUser(oid, "before"); - asserter.assertOid(oid); - return asserter; - } - - protected UserAsserter assertUserBeforeByUsername(String username) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - UserAsserter asserter = assertUserByUsername(username, "before"); - asserter.display(); - asserter.assertName(username); - return asserter; - } - - protected UserAsserter assertUser(String oid, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - PrismObject user = getUser(oid); - return assertUser(user, message); - } - protected RepoOpAsserter createRepoOpAsserter(PerformanceInformation performanceInformation, String details) { - return new RepoOpAsserter(performanceInformation, details); - } - - protected RepoOpAsserter createRepoOpAsserter(String details) { - PerformanceInformation repoPerformanceInformation = repositoryService.getPerformanceMonitor().getThreadLocalPerformanceInformation(); - return new RepoOpAsserter(repoPerformanceInformation, details); - } - - protected UserAsserter assertUser(PrismObject user, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - UserAsserter asserter = UserAsserter.forUser(user, message); - initializeAsserter(asserter); - asserter.display(); - return asserter; - } - - protected UserAsserter assertUserByUsername(String username, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - PrismObject user = findUserByUsername(username); - assertNotNull("User with username '"+username+"' was not found", user); - UserAsserter asserter = UserAsserter.forUser(user, message); - initializeAsserter(asserter); - return asserter; - } - - protected OrgAsserter assertOrg(String oid, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - PrismObject org = getObject(OrgType.class, oid); - OrgAsserter asserter = assertOrg(org, message); - asserter.assertOid(oid); - return asserter; - } - - protected OrgAsserter assertOrg(PrismObject org, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - OrgAsserter asserter = OrgAsserter.forOrg(org, message); - initializeAsserter(asserter); - return asserter; - } - - protected OrgAsserter assertOrgAfter(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - OrgAsserter asserter = assertOrg(oid, "after"); - asserter.display(); - asserter.assertOid(oid); - return asserter; - } - - protected OrgAsserter assertOrgByName(String name, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - PrismObject org = findObjectByName(OrgType.class, name); - assertNotNull("No org with name '"+name+"'", org); - OrgAsserter asserter = OrgAsserter.forOrg(org, message); - initializeAsserter(asserter); - asserter.assertName(name); - return asserter; - } - - protected RoleAsserter assertRole(String oid, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - PrismObject role = getObject(RoleType.class, oid); - RoleAsserter asserter = assertRole(role, message); - asserter.assertOid(oid); - return asserter; - } - - protected RoleAsserter assertRoleByName(String name, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - PrismObject role = findObjectByName(RoleType.class, name); - assertNotNull("No role with name '"+name+"'", role); - RoleAsserter asserter = assertRole(role, message); - asserter.assertName(name); - return asserter; - } - - protected RoleAsserter assertRole(PrismObject role, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - RoleAsserter asserter = RoleAsserter.forRole(role, message); - initializeAsserter(asserter); - asserter.display(); - return asserter; - } - - protected RoleAsserter assertRoleBefore(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - RoleAsserter asserter = assertRole(oid, "before"); - return asserter; - } - - protected RoleAsserter assertRoleAfter(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - RoleAsserter asserter = assertRole(oid, "after"); - return asserter; - } - - protected RoleAsserter assertRoleAfterByName(String name) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - RoleAsserter asserter = assertRoleByName(name, "after"); - return asserter; - } - - protected FocusAsserter assertService(String oid, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - PrismObject service = getObject(ServiceType.class, oid); - // TODO: change to ServiceAsserter later - FocusAsserter asserter = FocusAsserter.forFocus(service, message); - initializeAsserter(asserter); - asserter.assertOid(oid); - return asserter; - } - - protected FocusAsserter assertServiceByName(String name, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - PrismObject service = findServiceByName(name); - // TODO: change to ServiceAsserter later - FocusAsserter asserter = FocusAsserter.forFocus(service, message); - initializeAsserter(asserter); - asserter.assertName(name); - return asserter; - } - - protected FocusAsserter assertServiceAfterByName(String name) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - return assertServiceByName(name, "after"); - } - - protected FocusAsserter assertServiceBeforeByName(String name) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - return assertServiceByName(name, "before"); - } - - protected FocusAsserter assertServiceAfter(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - return assertService(oid, "after"); - } - - protected FocusAsserter assertServiceBefore(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - return assertService(oid, "before"); - } - - protected void assertNoServiceByName(String name) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - PrismObject service = findServiceByName(name); - if (service != null) { - display("Unexpected service", service); - fail("Unexpected "+service); - } - } - - protected CaseAsserter assertCase(String oid, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - PrismObject acase = getObject(CaseType.class, oid); - CaseAsserter asserter = CaseAsserter.forCase(acase, message); - initializeAsserter(asserter); - asserter.assertOid(oid); - return asserter; - } - - protected CaseAsserter assertCaseAfter(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - CaseAsserter asserter = assertCase(oid, "after"); - asserter.display(); - asserter.assertOid(oid); - return asserter; - } - - protected ShadowAsserter assertModelShadow(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - PrismObject repoShadow = getShadowModel(oid); - ShadowAsserter asserter = ShadowAsserter.forShadow(repoShadow, "model"); - asserter - .display(); - return asserter; - } - - protected ShadowAsserter assertModelShadowNoFetch(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - PrismObject repoShadow = getShadowModelNoFetch(oid); - ShadowAsserter asserter = ShadowAsserter.forShadow(repoShadow, "model(noFetch)"); - asserter - .display(); - return asserter; - } - - protected ShadowAsserter assertModelShadowFuture(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - PrismObject repoShadow = getShadowModelFuture(oid); - ShadowAsserter asserter = ShadowAsserter.forShadow(repoShadow, "model(future)"); - asserter - .display(); - return asserter; - } - - protected ShadowAsserter assertModelShadowFutureNoFetch(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - GetOperationOptions options = GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE); - options.setNoFetch(true); - PrismObject repoShadow = getShadowModel(oid, options, true); - ShadowAsserter asserter = ShadowAsserter.forShadow(repoShadow, "model(future,noFetch)"); - asserter - .display(); - return asserter; - } - - protected void assertNoModelShadow(String oid) throws SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = createTask("assertNoModelShadow"); - OperationResult result = task.getResult(); - try { - PrismObject shadow = modelService.getObject(ShadowType.class, oid, null, task, result); - fail("Expected that shadow "+oid+" will not be in the model. But it was: "+shadow); - } catch (ObjectNotFoundException e) { - // Expected - assertFailure(result); - } - } - - protected void assertNoModelShadowFuture(String oid) throws SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = createTask("assertNoModelShadowFuture"); - OperationResult result = task.getResult(); - Collection> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); - try { - PrismObject shadow = modelService.getObject(ShadowType.class, oid, options, task, result); - fail("Expected that future shadow "+oid+" will not be in the model. But it was: "+shadow); - } catch (ObjectNotFoundException e) { - // Expected - assertFailure(result); - } - } - - protected ResourceAsserter assertResource(String oid, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - PrismObject resource = getObject(ResourceType.class, oid); - return assertResource(resource, message); - } - - protected ResourceAsserter assertResource(PrismObject user, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - ResourceAsserter asserter = ResourceAsserter.forResource(user, message); - initializeAsserter(asserter); - asserter.display(); - return asserter; - } - - protected ResourceAsserter assertResourceAfter(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - ResourceAsserter asserter = assertResource(oid, "after"); - asserter.assertOid(oid); - return asserter; - } - - protected ModelContextAsserter assertPreviewContext(ModelContext previewContext) { - ModelContextAsserter asserter = ModelContextAsserter.forContext(previewContext, "preview context"); - initializeAsserter(asserter); - asserter.display(); - return asserter; - } - - protected OperationResultAsserter assertOperationResult(OperationResult result) { - OperationResultAsserter asserter = OperationResultAsserter.forResult(result); - initializeAsserter(asserter); - asserter.display(); - return asserter; - } - - // SECURITY - - protected void assertGetDeny(Class type, String oid) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - assertGetDeny(type, oid, null); - } - - protected void assertGetDeny(Class type, String oid, Collection> options) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertGetDeny"); - OperationResult result = task.getResult(); - try { - logAttempt("get", type, oid, null); - PrismObject object = modelService.getObject(type, oid, options, task, result); - failDeny("get", type, oid, null); - } catch (SecurityViolationException e) { - // this is expected - logDeny("get", type, oid, null); - result.computeStatus(); - TestUtil.assertFailure(result); - } - } - - protected PrismObject assertGetAllow(Class type, String oid) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - return assertGetAllow(type, oid, null); - } - - protected PrismObject assertGetAllow(Class type, String oid, Collection> options) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertGetAllow"); - OperationResult result = task.getResult(); - logAttempt("get", type, oid, null); - PrismObject object = modelService.getObject(type, oid, options, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - logAllow("get", type, oid, null); - return object; - } - - protected void assertSearchFilter(Class type, ObjectFilter filter, int expectedResults) throws Exception { - assertSearch(type, prismContext.queryFactory().createQuery(filter), null, expectedResults); - } - - protected SearchResultList> assertSearch(Class type, ObjectQuery query, int expectedResults) throws Exception { - return assertSearch(type, query, null, expectedResults); - } - - protected void assertSearchRaw(Class type, ObjectQuery query, int expectedResults) throws Exception { - assertSearch(type, query, SelectorOptions.createCollection(GetOperationOptions.createRaw()), expectedResults); - } - - protected void assertSearchDeny(Class type, ObjectQuery query, - Collection> options) throws Exception { - try { - assertSearch(type, query, options, 0); - } catch (SecurityViolationException e) { - // This is expected. The search should either return zero results or throw an exception. - logDeny("search"); - } - } - - - protected SearchResultList> assertSearch(Class type, ObjectQuery query, - Collection> options, int expectedResults) throws Exception { - ObjectQuery originalQuery = query != null ? query.clone() : null; - return assertSearch(type, query, options, - new SearchAssertion() { - - @Override - public void assertObjects(String message, List> objects) throws Exception { - if (objects.size() > expectedResults) { - failDeny(message, type, originalQuery, expectedResults, objects.size()); - } else if (objects.size() < expectedResults) { - failAllow(message, type, originalQuery, expectedResults, objects.size()); - } - } - - @Override - public void assertCount(int count) throws Exception { - if (count > expectedResults) { - failDeny("count", type, originalQuery, expectedResults, count); - } else if (count < expectedResults) { - failAllow("count", type, originalQuery, expectedResults, count); - } - } - - }); - } - - protected void assertSearch(Class type, ObjectQuery query, String... expectedOids) throws Exception { - assertSearch(type, query, null, expectedOids); - } - - protected void assertSearchFilter(Class type, ObjectFilter filter, - Collection> options, String... expectedOids) throws Exception { - assertSearch(type, prismContext.queryFactory().createQuery(filter), options, expectedOids); - } - - protected void assertSearchFilter(Class type, ObjectFilter filter, String... expectedOids) throws Exception { - assertSearch(type, prismContext.queryFactory().createQuery(filter), expectedOids); - } - - protected void assertSearch(Class type, ObjectQuery query, - Collection> options, String... expectedOids) throws Exception { - assertSearch(type, query, options, - new SearchAssertion() { - - @Override - public void assertObjects(String message, List> objects) throws Exception { - if (!MiscUtil.unorderedCollectionEquals(objects, Arrays.asList(expectedOids), - (object,expectedOid) -> expectedOid.equals(object.getOid()))) { - failAllow(message, type, (query==null?"null":query.toString())+", expected "+Arrays.toString(expectedOids)+", actual "+objects, null); - } - } - - @Override - public void assertCount(int count) throws Exception { - if (count != expectedOids.length) { - failAllow("count", type, query, expectedOids.length, count); - } - } - - }); - } - - protected SearchResultList> assertSearch(Class type, ObjectQuery query, - Collection> options, SearchAssertion assertion) throws Exception { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertSearchObjects"); - OperationResult result = task.getResult(); - SearchResultList> objects; - try { - logAttempt("search", type, query); - objects = modelService.searchObjects(type, query, options, task, result); - display("Search returned", objects.toString()); - assertion.assertObjects("search", objects); - assertSuccess(result); - } catch (SecurityViolationException e) { - // this should not happen - result.computeStatus(); - TestUtil.assertFailure(result); - failAllow("search", type, query, e); - return null; // not reached - } - - task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertSearchObjectsIterative"); - result = task.getResult(); - try { - logAttempt("searchIterative", type, query); - final List> iterativeObjects = new ArrayList<>(); - ResultHandler handler = new ResultHandler() { - @Override - public boolean handle(PrismObject object, OperationResult parentResult) { - iterativeObjects.add(object); - return true; - } - }; - modelService.searchObjectsIterative(type, query, handler, options, task, result); - display("Search iterative returned", iterativeObjects.toString()); - assertion.assertObjects("searchIterative", iterativeObjects); - assertSuccess(result); - } catch (SecurityViolationException e) { - // this should not happen - result.computeStatus(); - TestUtil.assertFailure(result); - failAllow("searchIterative", type, query, e); - return null; // not reached - } - - task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertSearchObjects.count"); - result = task.getResult(); - try { - logAttempt("count", type, query); - int numObjects = modelService.countObjects(type, query, options, task, result); - display("Count returned", numObjects); - assertion.assertCount(numObjects); - assertSuccess(result); - } catch (SecurityViolationException e) { - // this should not happen - result.computeStatus(); - TestUtil.assertFailure(result); - failAllow("search", type, query, e); - return null; // not reached - } - - return objects; - } - - - protected void assertAddDeny(File file) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, IOException { - assertAddDeny(file, null); - } - - protected void assertAddDenyRaw(File file) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, IOException { - assertAddDeny(file, ModelExecuteOptions.createRaw()); - } - - protected void assertAddDeny(File file, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, IOException { - PrismObject object = PrismTestUtil.parseObject(file); - assertAddDeny(object, options); - } - - protected void assertAddDeny(PrismObject object, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, IOException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertAddDeny"); - OperationResult result = task.getResult(); - ObjectDelta addDelta = object.createAddDelta(); - try { - logAttempt("add", object.getCompileTimeClass(), object.getOid(), null); - modelService.executeChanges(MiscSchemaUtil.createCollection(addDelta), options, task, result); - failDeny("add", object.getCompileTimeClass(), object.getOid(), null); - } catch (SecurityViolationException e) { - // this is expected - logDeny("add", object.getCompileTimeClass(), object.getOid(), null); - result.computeStatus(); - TestUtil.assertFailure(result); - } - } - - protected void assertAddAllow(File file) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { - assertAddAllow(file, null); - } - - protected OperationResult assertAddAllowTracing(File file) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { - return assertAddAllowTracing(file, null); - } - - protected void assertAddAllow(File file, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { - PrismObject object = PrismTestUtil.parseObject(file); - assertAddAllow(object, options); - } - - protected OperationResult assertAddAllowTracing(File file, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { - PrismObject object = PrismTestUtil.parseObject(file); - return assertAddAllowTracing(object, options); - } - - protected OperationResult assertAddAllow(PrismObject object, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { - Task task = createAllowDenyTask(AbstractModelIntegrationTest.class.getName() + ".assertAddAllow"); - return assertAddAllow(object, options, task); - } - - protected OperationResult assertAddAllowTracing(PrismObject object, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { - Task task = createAllowDenyTask(AbstractModelIntegrationTest.class.getName() + ".assertAddAllow"); - setTracing(task, createDefaultTracingProfile()); - return assertAddAllow(object, options, task); - } - - protected OperationResult assertAddAllow(PrismObject object, ModelExecuteOptions options, Task task) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { - OperationResult result = task.getResult(); - ObjectDelta addDelta = object.createAddDelta(); - logAttempt("add", object.getCompileTimeClass(), object.getOid(), null); - try { - modelService.executeChanges(MiscSchemaUtil.createCollection(addDelta), options, task, result); - } catch (SecurityViolationException e) { - failAllow("add", object.getCompileTimeClass(), object.getOid(), null, e); - } - result.computeStatus(); - TestUtil.assertSuccess(result); - logAllow("add", object.getCompileTimeClass(), object.getOid(), null); - return result; - } - - protected void assertDeleteDeny(Class type, String oid) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - assertDeleteDeny(type, oid, null); - } - - protected void assertDeleteDeny(Class type, String oid, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertDeleteDeny"); - OperationResult result = task.getResult(); - ObjectDelta delta = prismContext.deltaFactory().object().createDeleteDelta(type, oid); - try { - logAttempt("delete", type, oid, null); - modelService.executeChanges(MiscSchemaUtil.createCollection(delta), options, task, result); - failDeny("delete", type, oid, null); - } catch (SecurityViolationException e) { - // this is expected - logDeny("delete", type, oid, null); - result.computeStatus(); - TestUtil.assertFailure(result); - } catch (ObjectNotFoundException e) { - // MID-3221 - // still consider OK ... for now - logError("delete", type, oid, null); - result.computeStatus(); - TestUtil.assertFailure(result); - } - } - - protected void assertDeleteAllow(Class type, String oid) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - assertDeleteAllow(type, oid, null); - } - - protected void assertDeleteAllow(Class type, String oid, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertDeleteAllow"); - OperationResult result = task.getResult(); - ObjectDelta delta = prismContext.deltaFactory().object().createDeleteDelta(type, oid); - logAttempt("delete", type, oid, null); - try { - modelService.executeChanges(MiscSchemaUtil.createCollection(delta), options, task, result); - } catch (SecurityViolationException e) { - failAllow("delete", type, oid, null, e); - } - result.computeStatus(); - TestUtil.assertSuccess(result); - logAllow("delete", type, oid, null); - } - - private Task createAllowDenyTask(String opname) { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertAllow."+opname); - task.setOwner(getSecurityContextPrincipalFocus()); - task.setChannel(SchemaConstants.CHANNEL_GUI_USER_URI); - return task; - } - - protected OperationResult assertAllow(String opname, Attempt attempt) throws Exception { - Task task = createAllowDenyTask(opname); - return assertAllow(opname, attempt, task); - } - - protected OperationResult assertAllowTracing(String opname, Attempt attempt) throws Exception { - Task task = createAllowDenyTask(opname); - setTracing(task, createDefaultTracingProfile()); - return assertAllow(opname, attempt, task); - } - - protected OperationResult assertAllow(String opname, Attempt attempt, Task task) throws Exception { - OperationResult result = task.getResult(); - try { - logAttempt(opname); - attempt.run(task, result); - } catch (SecurityViolationException e) { - failAllow(opname, e); - } - result.computeStatus(); - TestUtil.assertSuccess(result); - logAllow(opname); - return result; - } - - protected OperationResult assertDeny(String opname, Attempt attempt) throws Exception { - Task task = createAllowDenyTask(opname); - OperationResult result = task.getResult(); - try { - logAttempt(opname); - attempt.run(task, result); - failDeny(opname); - } catch (SecurityViolationException e) { - // this is expected - logDeny(opname); - result.computeStatus(); - TestUtil.assertFailure(result); - } - return result; - } - - protected void asAdministrator(Attempt attempt) throws Exception { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".asAdministrator"); - OperationResult result = task.getResult(); - MidPointPrincipal origPrincipal = getSecurityContextPrincipal(); - login(USER_ADMINISTRATOR_USERNAME); - task.setOwner(getSecurityContextPrincipalFocus()); - task.setChannel(SchemaConstants.CHANNEL_GUI_USER_URI); - try { - attempt.run(task, result); - } catch (Throwable e) { - login(origPrincipal); - throw e; - } - login(origPrincipal); - result.computeStatus(); - TestUtil.assertSuccess(result); - } - - protected void logAttempt(String action) { - String msg = LOG_PREFIX_ATTEMPT+"Trying "+action; - System.out.println(msg); - LOGGER.info(msg); - } - - protected void logDeny(String action, Class type, ObjectQuery query) { - logDeny(action, type, query==null?"null":query.toString()); - } - - protected void logDeny(String action, Class type, String oid, ItemPath itemPath) { - logDeny(action, type, oid+" prop "+itemPath); - } - - protected void logDeny(String action, Class type, String desc) { - String msg = LOG_PREFIX_DENY+"Denied "+action+" of "+type.getSimpleName()+":"+desc; - System.out.println(msg); - LOGGER.info(msg); - } - - protected void logDeny(String action) { - String msg = LOG_PREFIX_DENY+"Denied "+action; - System.out.println(msg); - LOGGER.info(msg); - } - - protected void logAllow(String action, Class type, ObjectQuery query) { - logAllow(action, type, query==null?"null":query.toString()); - } - - protected void logAllow(String action, Class type, String oid, ItemPath itemPath) { - logAllow(action, type, oid+" prop "+itemPath); - } - - protected void logAllow(String action, Class type, String desc) { - String msg = LOG_PREFIX_ALLOW+"Allowed "+action+" of "+type.getSimpleName()+":"+desc; - System.out.println(msg); - LOGGER.info(msg); - } - - protected void logAllow(String action) { - String msg = LOG_PREFIX_ALLOW+"Allowed "+action; - System.out.println(msg); - LOGGER.info(msg); - } - - protected void logError(String action, Class type, String oid, ItemPath itemPath, Throwable e) { - logError(action, type, oid+" prop "+itemPath, e); - } - - protected void logError(String action, Class type, String desc, Throwable e) { - String msg = LOG_PREFIX_DENY+"Error "+action+" of "+type.getSimpleName()+":"+desc + "("+e+")"; - System.out.println(msg); - LOGGER.info(msg); - } - - protected void logAttempt(String action, Class type, ObjectQuery query) { - logAttempt(action, type, query==null?"null":query.toString()); - } - - protected void logAttempt(String action, Class type, String oid, ItemPath itemPath) { - logAttempt(action, type, oid+" prop "+itemPath); - } - - protected void logAttempt(String action, Class type, String desc) { - String msg = LOG_PREFIX_ATTEMPT+"Trying "+action+" of "+type.getSimpleName()+":"+desc; - System.out.println(msg); - LOGGER.info(msg); - } - - protected void failDeny(String action, Class type, ObjectQuery query, int expected, int actual) { - failDeny(action, type, (query==null?"null":query.toString())+", expected "+expected+", actual "+actual); - } - - protected void failDeny(String action, Class type, String oid, ItemPath itemPath) { - failDeny(action, type, oid+" prop "+itemPath); - } - - protected void failDeny(String action, Class type, String desc) { - String msg = "Failed to deny "+action+" of "+type.getSimpleName()+":"+desc; - System.out.println(LOG_PREFIX_FAIL+msg); - LOGGER.error(LOG_PREFIX_FAIL+msg); - AssertJUnit.fail(msg); - } - - protected void failDeny(String action) { - String msg = "Failed to deny "+action; - System.out.println(LOG_PREFIX_FAIL+msg); - LOGGER.error(LOG_PREFIX_FAIL+msg); - AssertJUnit.fail(msg); - } - - protected void failAllow(String action, Class type, ObjectQuery query, SecurityViolationException e) throws SecurityViolationException { - failAllow(action, type, query==null?"null":query.toString(), e); - } - - protected void failAllow(String action, Class type, ObjectQuery query, int expected, int actual) throws SecurityViolationException { - failAllow(action, type, (query==null?"null":query.toString())+", expected "+expected+", actual "+actual, null); - } - - protected void failAllow(String action, Class type, String oid, ItemPath itemPath, SecurityViolationException e) throws SecurityViolationException { - failAllow(action, type, oid+" prop "+itemPath, e); - } - - protected void failAllow(String action, Class type, String desc, SecurityViolationException e) throws SecurityViolationException { - String msg = "Failed to allow "+action+" of "+type.getSimpleName()+":"+desc; - System.out.println(LOG_PREFIX_FAIL+msg); - LOGGER.error(LOG_PREFIX_FAIL+msg); - if (e != null) { - throw new SecurityViolationException(msg+": "+e.getMessage(), e); - } else { - AssertJUnit.fail(msg); - } - } - - protected void failAllow(String action, SecurityViolationException e) throws SecurityViolationException { - String msg = "Failed to allow "+action; - System.out.println(LOG_PREFIX_FAIL+msg); - LOGGER.error(LOG_PREFIX_FAIL+msg); - if (e != null) { - throw new SecurityViolationException(msg+": "+e.getMessage(), e); - } else { - AssertJUnit.fail(msg); - } - } - - protected ArchetypePolicyAsserter assertArchetypePolicy(PrismObject object) throws SchemaException, ConfigurationException { - OperationResult result = new OperationResult("assertArchetypePolicy"); - ArchetypePolicyType archetypePolicy = modelInteractionService.determineArchetypePolicy(object, result); - ArchetypePolicyAsserter asserter = new ArchetypePolicyAsserter<>(archetypePolicy, null, "for "+object); - initializeAsserter(asserter); - asserter.display(); - return asserter; - } - - protected AssignmentCandidatesSpecificationAsserter assertAssignmentTargetSpecification(PrismObject object) throws SchemaException, ConfigurationException { - OperationResult result = new OperationResult("assertAssignmentTargetSpecification"); - AssignmentCandidatesSpecification targetSpec = modelInteractionService.determineAssignmentTargetSpecification(object, result); - AssignmentCandidatesSpecificationAsserter asserter = new AssignmentCandidatesSpecificationAsserter<>(targetSpec, null, "targets for "+object); - initializeAsserter(asserter); - asserter.display(); - return asserter; - } - - protected AssignmentCandidatesSpecificationAsserter assertAssignmentHolderSpecification(PrismObject object) throws SchemaException, ConfigurationException { - OperationResult result = new OperationResult("assertAssignmentHolderSpecification"); - AssignmentCandidatesSpecification targetSpec = modelInteractionService.determineAssignmentHolderSpecification(object, result); - AssignmentCandidatesSpecificationAsserter asserter = new AssignmentCandidatesSpecificationAsserter<>(targetSpec, null, "holders for "+object); - initializeAsserter(asserter); - asserter.display(); - return asserter; - } - - protected ExpressionVariables createVariables(Object... params) { - return ExpressionVariables.create(prismContext, params); - } - -} +/* + * Copyright (c) 2010-2019 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ +package com.evolveum.midpoint.model.test; + +import static com.evolveum.midpoint.prism.PrismObject.asObjectableList; +import static com.evolveum.midpoint.schema.constants.SchemaConstants.*; +import static java.util.Collections.singleton; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertFalse; +import static org.testng.AssertJUnit.assertNotNull; +import static org.testng.AssertJUnit.assertNull; +import static org.testng.AssertJUnit.assertTrue; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.net.ConnectException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.concurrent.atomic.AtomicLong; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.stream.Collectors; + +import javax.xml.bind.JAXBException; +import javax.xml.datatype.XMLGregorianCalendar; +import javax.xml.namespace.QName; + +import com.evolveum.midpoint.model.api.authentication.*; +import com.evolveum.midpoint.model.test.asserter.*; +import com.evolveum.midpoint.prism.*; +import com.evolveum.midpoint.prism.delta.*; +import com.evolveum.midpoint.prism.equivalence.EquivalenceStrategy; +import com.evolveum.midpoint.prism.path.*; +import com.evolveum.midpoint.repo.api.perf.PerformanceInformation; +import com.evolveum.midpoint.schema.*; +import com.evolveum.midpoint.schema.result.OperationResultStatus; +import com.evolveum.midpoint.schema.util.*; +import com.evolveum.midpoint.schema.statistics.StatisticsUtil; +import com.evolveum.midpoint.task.api.TaskDebugUtil; +import com.evolveum.midpoint.test.*; +import com.evolveum.midpoint.test.asserter.*; +import com.evolveum.midpoint.test.asserter.prism.PrismContainerDefinitionAsserter; +import com.evolveum.midpoint.util.*; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.mutable.MutableInt; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.opends.server.types.DirectoryException; +import org.opends.server.types.Entry; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.security.access.ConfigAttribute; +import org.springframework.security.access.SecurityConfig; +import org.springframework.security.authentication.AnonymousAuthenticationToken; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.authority.AuthorityUtils; +import org.springframework.security.core.context.SecurityContext; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.core.context.SecurityContextImpl; +import org.springframework.security.web.FilterInvocation; +import org.testng.AssertJUnit; +import org.testng.annotations.AfterClass; + +import com.evolveum.icf.dummy.resource.ConflictException; +import com.evolveum.icf.dummy.resource.DummyAccount; +import com.evolveum.icf.dummy.resource.DummyGroup; +import com.evolveum.icf.dummy.resource.DummyResource; +import com.evolveum.icf.dummy.resource.SchemaViolationException; +import com.evolveum.midpoint.audit.api.AuditEventRecord; +import com.evolveum.midpoint.audit.api.AuditEventStage; +import com.evolveum.midpoint.audit.api.AuditEventType; +import com.evolveum.midpoint.audit.api.AuditReferenceValue; +import com.evolveum.midpoint.common.Clock; +import com.evolveum.midpoint.common.refinery.RefinedAttributeDefinition; +import com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition; +import com.evolveum.midpoint.common.refinery.RefinedResourceSchema; +import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl; +import com.evolveum.midpoint.model.api.AssignmentCandidatesSpecification; +import com.evolveum.midpoint.model.api.ModelAuditService; +import com.evolveum.midpoint.model.api.ModelAuthorizationAction; +import com.evolveum.midpoint.model.api.ModelDiagnosticService; +import com.evolveum.midpoint.model.api.ModelExecuteOptions; +import com.evolveum.midpoint.model.api.ModelInteractionService; +import com.evolveum.midpoint.model.api.ModelService; +import com.evolveum.midpoint.model.api.RoleSelectionSpecification; +import com.evolveum.midpoint.model.api.context.EvaluatedPolicyRule; +import com.evolveum.midpoint.model.api.context.ModelContext; +import com.evolveum.midpoint.model.api.context.ModelElementContext; +import com.evolveum.midpoint.model.api.context.ModelProjectionContext; +import com.evolveum.midpoint.model.api.expr.MidpointFunctions; +import com.evolveum.midpoint.model.api.hooks.HookRegistry; +import com.evolveum.midpoint.model.api.interaction.DashboardService; +import com.evolveum.midpoint.model.common.SystemObjectCache; +import com.evolveum.midpoint.model.common.stringpolicy.FocusValuePolicyOriginResolver; +import com.evolveum.midpoint.model.common.stringpolicy.ValuePolicyProcessor; +import com.evolveum.midpoint.notifications.api.NotificationManager; +import com.evolveum.midpoint.notifications.api.transports.Message; +import com.evolveum.midpoint.prism.crypto.EncryptionException; +import com.evolveum.midpoint.prism.match.MatchingRule; +import com.evolveum.midpoint.prism.polystring.PolyString; +import com.evolveum.midpoint.prism.query.ObjectFilter; +import com.evolveum.midpoint.prism.query.ObjectQuery; +import com.evolveum.midpoint.prism.query.OrgFilter; +import com.evolveum.midpoint.prism.util.PrismAsserts; +import com.evolveum.midpoint.prism.util.PrismTestUtil; +import com.evolveum.midpoint.prism.xml.XmlTypeConverter; +import com.evolveum.midpoint.provisioning.api.ProvisioningService; +import com.evolveum.midpoint.repo.api.RepositoryService; +import com.evolveum.midpoint.repo.common.ObjectResolver; +import com.evolveum.midpoint.repo.common.expression.ExpressionVariables; +import com.evolveum.midpoint.schema.constants.ObjectTypes; +import com.evolveum.midpoint.schema.constants.SchemaConstants; +import com.evolveum.midpoint.schema.internals.InternalsConfig; +import com.evolveum.midpoint.schema.processor.ResourceAttribute; +import com.evolveum.midpoint.schema.processor.ResourceAttributeContainer; +import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition; +import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.security.api.Authorization; +import com.evolveum.midpoint.security.api.AuthorizationConstants; +import com.evolveum.midpoint.security.api.MidPointPrincipal; +import com.evolveum.midpoint.security.api.SecurityContextManager; +import com.evolveum.midpoint.security.enforcer.api.AuthorizationParameters; +import com.evolveum.midpoint.security.enforcer.api.ItemSecurityConstraints; +import com.evolveum.midpoint.security.enforcer.api.SecurityEnforcer; +import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.task.api.TaskExecutionStatus; +import com.evolveum.midpoint.test.util.MidPointAsserts; +import com.evolveum.midpoint.test.util.TestUtil; +import com.evolveum.midpoint.util.exception.CommonException; +import com.evolveum.midpoint.util.exception.CommunicationException; +import com.evolveum.midpoint.util.exception.ConfigurationException; +import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; +import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; +import com.evolveum.midpoint.util.exception.ObjectNotFoundException; +import com.evolveum.midpoint.util.exception.PolicyViolationException; +import com.evolveum.midpoint.util.exception.SchemaException; +import com.evolveum.midpoint.util.exception.SecurityViolationException; +import com.evolveum.midpoint.util.exception.SystemException; +import com.evolveum.midpoint.util.exception.TunnelException; +import com.evolveum.midpoint.util.logging.Trace; +import com.evolveum.midpoint.util.logging.TraceManager; +import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ImportOptionsType; +import com.evolveum.midpoint.xml.ns._public.model.model_3.ModelPortType; +import com.evolveum.prism.xml.ns._public.types_3.ChangeTypeType; +import com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType; +import com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType; +import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; +import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; + +/** + * Abstract framework for an integration test that is placed on top of a model API. + * This provides complete environment that the test should need, e.g model service instance, repository, provisioning, + * dummy auditing, etc. It also implements lots of useful methods to make writing the tests easier. + * + * @author Radovan Semancik + * + */ +public abstract class AbstractModelIntegrationTest extends AbstractIntegrationTest { + + protected static final int DEFAULT_TASK_WAIT_TIMEOUT = 25000; + protected static final long DEFAULT_TASK_SLEEP_TIME = 200; + + protected static final String CONNECTOR_DUMMY_TYPE = "com.evolveum.icf.dummy.connector.DummyConnector"; + protected static final String CONNECTOR_DUMMY_VERSION = "2.0"; + protected static final String CONNECTOR_DUMMY_NAMESPACE = "http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/com.evolveum.icf.dummy/com.evolveum.icf.dummy.connector.DummyConnector"; + + protected static final String CONNECTOR_LDAP_TYPE = "com.evolveum.polygon.connector.ldap.LdapConnector"; + protected static final String CONNECTOR_LDAP_NAMESPACE = "http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/com.evolveum.polygon.connector-ldap/com.evolveum.polygon.connector.ldap.LdapConnector"; + + protected static final String CONNECTOR_AD_TYPE = "Org.IdentityConnectors.ActiveDirectory.ActiveDirectoryConnector"; + protected static final String CONNECTOR_AD_NAMESPACE = "http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/ActiveDirectory.Connector/Org.IdentityConnectors.ActiveDirectory.ActiveDirectoryConnector"; + + protected static final ItemPath ACTIVATION_ADMINISTRATIVE_STATUS_PATH = SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS; + protected static final ItemPath ACTIVATION_VALID_FROM_PATH = SchemaConstants.PATH_ACTIVATION_VALID_FROM; + protected static final ItemPath ACTIVATION_VALID_TO_PATH = SchemaConstants.PATH_ACTIVATION_VALID_TO; + protected static final ItemPath PASSWORD_VALUE_PATH = SchemaConstants.PATH_CREDENTIALS_PASSWORD_VALUE; + + private static final String DEFAULT_CHANNEL = SchemaConstants.CHANNEL_GUI_USER_URI; + + protected static final String LOG_PREFIX_FAIL = "SSSSS=X "; + protected static final String LOG_PREFIX_ATTEMPT = "SSSSS=> "; + protected static final String LOG_PREFIX_DENY = "SSSSS=- "; + protected static final String LOG_PREFIX_ALLOW = "SSSSS=+ "; + + @Autowired protected ModelService modelService; + @Autowired protected ModelInteractionService modelInteractionService; + @Autowired protected ModelDiagnosticService modelDiagnosticService; + @Autowired protected DashboardService dashboardService; + @Autowired protected ModelAuditService modelAuditService; + @Autowired protected ModelPortType modelWeb; + @Autowired + @Qualifier("cacheRepositoryService") + protected RepositoryService repositoryService; + @Autowired + @Qualifier("sqlRepositoryServiceImpl") + protected RepositoryService plainRepositoryService; + + @Autowired protected SystemObjectCache systemObjectCache; + @Autowired protected RelationRegistry relationRegistry; + @Autowired protected ProvisioningService provisioningService; + @Autowired protected HookRegistry hookRegistry; + @Autowired protected Clock clock; + @Autowired protected SchemaHelper schemaHelper; + @Autowired protected DummyTransport dummyTransport; + @Autowired protected SecurityEnforcer securityEnforcer; + @Autowired protected SecurityContextManager securityContextManager; + @Autowired protected MidpointFunctions libraryMidpointFunctions; + @Autowired protected ValuePolicyProcessor valuePolicyProcessor; + + @Autowired(required = false) + @Qualifier("modelObjectResolver") + protected ObjectResolver modelObjectResolver; + + @Autowired(required = false) + protected NotificationManager notificationManager; + + @Autowired(required = false) + protected GuiProfiledPrincipalManager focusProfileService; + + protected DummyResourceCollection dummyResourceCollection; + + protected DummyAuditService dummyAuditService; + + protected boolean verbose = false; + + private static final Trace LOGGER = TraceManager.getTrace(AbstractModelIntegrationTest.class); + + public AbstractModelIntegrationTest() { + super(); + } + + @Override + public void initSystem(Task initTask, OperationResult initResult) throws Exception { + LOGGER.trace("initSystem"); + dummyResourceCollection = new DummyResourceCollection(modelService); + startResources(); + dummyAuditService = DummyAuditService.getInstance(); + InternalsConfig.reset(); + InternalsConfig.setAvoidLoggingChange(isAvoidLoggingChange()); + // Make sure the checks are turned on + InternalsConfig.turnOnAllChecks(); + // By default, notifications are turned off because of performance implications. Individual tests turn them on for themselves. + if (notificationManager != null) { + notificationManager.setDisabled(true); + } + } + + protected boolean isAvoidLoggingChange() { + return true; + } + + @Override + public void postInitSystem(Task initTask, OperationResult initResult) throws Exception { + super.postInitSystem(initTask, initResult); + if (dummyResourceCollection != null) { + dummyResourceCollection.resetResources(); + } + } + + protected void startResources() throws Exception { + // Nothing to do by default + } + + @AfterClass + protected void cleanUpSecurity() { + SecurityContext securityContext = SecurityContextHolder.getContext(); + securityContext.setAuthentication(null); + } + + protected void initDummyResource(String name, DummyResourceContoller controller) { + dummyResourceCollection.initDummyResource(name, controller); + } + + protected DummyResourceContoller initDummyResource(String name, File resourceFile, String resourceOid, + FailableProcessor controllerInitLambda, + Task task, OperationResult result) throws Exception { + return dummyResourceCollection.initDummyResource(name, resourceFile, resourceOid, controllerInitLambda, task, result); + } + + protected DummyResourceContoller initDummyResource(String name, File resourceFile, String resourceOid, + Task task, OperationResult result) throws Exception { + return dummyResourceCollection.initDummyResource(name, resourceFile, resourceOid, null, task, result); + } + + protected DummyResourceContoller initDummyResourcePirate(String name, File resourceFile, String resourceOid, + Task task, OperationResult result) throws Exception { + return initDummyResource(name, resourceFile, resourceOid, controller -> controller.extendSchemaPirate(), task, result); + } + + protected DummyResourceContoller initDummyResourceAd(String name, File resourceFile, String resourceOid, + Task task, OperationResult result) throws Exception { + return initDummyResource(name, resourceFile, resourceOid, controller -> controller.extendSchemaAd(), task, result); + } + + protected DummyResourceContoller getDummyResourceController(String name) { + return dummyResourceCollection.get(name); + } + + protected DummyResourceContoller getDummyResourceController() { + return getDummyResourceController(null); + } + + protected DummyAccountAsserter assertDummyAccountByUsername(String dummyResourceName, String username) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { + return getDummyResourceController(dummyResourceName).assertAccountByUsername(username); + } + + protected DummyGroupAsserter assertDummyGroupByName(String dummyResourceName, String name) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { + return getDummyResourceController(dummyResourceName).assertGroupByName(name); + } + + protected DummyResource getDummyResource(String name) { + return dummyResourceCollection.getDummyResource(name); + } + + protected DummyResource getDummyResource() { + return getDummyResource(null); + } + + protected PrismObject getDummyResourceObject(String name) { + return dummyResourceCollection.getResourceObject(name); + } + + protected PrismObject getDummyResourceObject() { + return getDummyResourceObject(null); + } + + protected ResourceType getDummyResourceType(String name) { + return dummyResourceCollection.getResourceType(name); + } + + protected ResourceType getDummyResourceType() { + return getDummyResourceType(null); + } + + protected void importObjectFromFile(String filename) throws FileNotFoundException { + importObjectFromFile(new File(filename)); + } + + protected void importObjectFromFile(File file) throws FileNotFoundException { + OperationResult result = new OperationResult(AbstractModelIntegrationTest.class.getName() + ".importObjectFromFile"); + importObjectFromFile(file, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + } + + protected void importObjectFromFile(String filename, OperationResult result) throws FileNotFoundException { + importObjectFromFile(new File(filename), result); + } + + protected void importObjectFromFile(File file, OperationResult result) throws FileNotFoundException { + OperationResult subResult = result.createSubresult(AbstractModelIntegrationTest.class.getName()+".importObjectFromFile"); + subResult.addParam("filename", file.getPath()); + LOGGER.trace("importObjectFromFile: {}", file); + Task task = taskManager.createTaskInstance(); + importObjectFromFile(file, task, result); + subResult.computeStatus(); + if (subResult.isError()) { + LOGGER.error("Import of file "+file+" failed:\n{}", subResult.debugDump()); + Throwable cause = findCause(subResult); + throw new SystemException("Import of file "+file+" failed: "+subResult.getMessage(), cause); + } + } + + protected void importObjectFromFile(File file, Task task, OperationResult result) throws FileNotFoundException { + importObjectFromFile(file, MiscSchemaUtil.getDefaultImportOptions(), task, result); + } + + protected void importObjectFromFile(File file, ImportOptionsType options, Task task, OperationResult result) throws FileNotFoundException { + FileInputStream stream = new FileInputStream(file); + modelService.importObjectsFromStream(stream, PrismContext.LANG_XML, options, task, result); + } + + protected void importObjectsFromFileNotRaw(File file, Task task, OperationResult result) throws FileNotFoundException { + ImportOptionsType options = MiscSchemaUtil.getDefaultImportOptions(); + ModelExecuteOptionsType modelOptions = new ModelExecuteOptionsType(); + modelOptions.setRaw(false); + options.setModelExecutionOptions(modelOptions); + importObjectFromFile(file, options, task, result); + } + + protected Throwable findCause(OperationResult result) { + if (result.getCause() != null) { + return result.getCause(); + } + for (OperationResult sub: result.getSubresults()) { + Throwable cause = findCause(sub); + if (cause != null) { + return cause; + } + } + return null; + } + + protected PrismObject importAndGetObjectFromFile(Class type, String filename, String oid, Task task, OperationResult result) throws FileNotFoundException, ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + return importAndGetObjectFromFile(type, new File(filename), oid, task, result); + } + + protected PrismObject importAndGetObjectFromFile(Class type, File file, String oid, Task task, OperationResult result) throws FileNotFoundException, ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + importObjectFromFile(file, result); + OperationResult importResult = result.getLastSubresult(); + TestUtil.assertSuccess("Import of "+file+" has failed", importResult); + return modelService.getObject(type, oid, null, task, result); + } + + protected PrismObject importAndGetObjectFromFileIgnoreWarnings(Class type, File file, String oid, Task task, OperationResult result) throws FileNotFoundException, ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + importObjectFromFile(file, result); + OperationResult importResult = result.getLastSubresult(); + OperationResultStatus status = importResult.getStatus(); + if (status == OperationResultStatus.FATAL_ERROR || status == OperationResultStatus.PARTIAL_ERROR) { + fail("Import of "+file+" has failed: "+importResult.getMessage()); + } + return modelService.getObject(type, oid, null, task, result); + } + + /** + * This is not the real thing. It is just for the tests. + */ + protected void applyResourceSchema(ShadowType accountType, ResourceType resourceType) throws SchemaException { + IntegrationTestTools.applyResourceSchema(accountType, resourceType, prismContext); + } + + + protected void assertUsers(int expectedNumberOfUsers) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + assertObjects(UserType.class, expectedNumberOfUsers); + } + + protected void assertRoles(int expectedNumberOfUsers) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + assertObjects(RoleType.class, expectedNumberOfUsers); + } + + protected void assertServices(int expectedNumberOfUsers) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + assertObjects(ServiceType.class, expectedNumberOfUsers); + } + + protected void assertObjects(Class type, int expectedNumberOfUsers) throws SchemaException, + ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + assertObjects(type, null, expectedNumberOfUsers); + } + + protected void assertObjects(Class type, ObjectQuery query, int expectedNumberOfUsers) + throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, + ConfigurationException, ExpressionEvaluationException { + assertEquals("Unexpected number of "+type.getSimpleName()+"s", expectedNumberOfUsers, getObjectCount(type, query)); + } + + protected int getObjectCount(Class type) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + return getObjectCount(type, null); + } + + protected int getObjectCount(Class type, ObjectQuery query) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertObjects"); + OperationResult result = task.getResult(); + List> users = modelService.searchObjects(type, query, null, task, result); + if (verbose) display(type.getSimpleName()+"s", users); + return users.size(); + } + + protected void searchObjectsIterative(Class type, ObjectQuery query, Consumer> handler, Integer expectedNumberOfObjects) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertObjects"); + OperationResult result = task.getResult(); + final MutableInt count = new MutableInt(0); + // Cannot convert to lambda here. Java does not want to understand the generic types properly. + SearchResultMetadata searchMetadata = modelService.searchObjectsIterative(type, query, (object, oresult) -> { + count.increment(); + if (handler != null) { + handler.accept(object); + } + return true; + }, null, task, result); + if (verbose) display(type.getSimpleName()+"s", count.getValue()); + assertEquals("Unexpected number of "+type.getSimpleName()+"s", expectedNumberOfObjects, count.getValue()); + } + + protected void assertUserProperty(String userOid, QName propertyName, Object... expectedPropValues) throws ObjectNotFoundException, SchemaException { + OperationResult result = new OperationResult("getObject"); + PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); + assertUserProperty(user, propertyName, expectedPropValues); + } + + protected void assertUserNoProperty(String userOid, QName propertyName) throws ObjectNotFoundException, SchemaException { + OperationResult result = new OperationResult("getObject"); + PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); + assertUserNoProperty(user, propertyName); + } + + protected void assertUserProperty(PrismObject user, QName propertyName, Object... expectedPropValues) { + PrismProperty property = user.findProperty(ItemName.fromQName(propertyName)); + assert property != null : "No property "+propertyName+" in "+user; + PrismAsserts.assertPropertyValue(property, expectedPropValues); + } + + protected void assertUserNoProperty(PrismObject user, QName propertyName) { + PrismProperty property = user.findProperty(ItemName.fromQName(propertyName)); + assert property == null : "Property "+propertyName+" present in "+user+": "+property; + } + + protected void assertAdministrativeStatusEnabled(PrismObject user) { + assertAdministrativeStatus(user, ActivationStatusType.ENABLED); + } + + protected void assertAdministrativeStatusDisabled(PrismObject user) { + assertAdministrativeStatus(user, ActivationStatusType.DISABLED); + } + + protected void assertAdministrativeStatus(PrismObject object, ActivationStatusType expected) { + PrismProperty statusProperty = object.findProperty(ACTIVATION_ADMINISTRATIVE_STATUS_PATH); + if (expected == null && statusProperty == null) { + return; + } + assert statusProperty != null : "No status property in "+object; + ActivationStatusType status = statusProperty.getRealValue(); + if (expected == null && status == null) { + return; + } + assert status != null : "No status property is null in "+object; + assert status == expected : "status property is "+status+", expected "+expected+" in "+object; + } + + protected void assertEffectiveStatus(PrismObject focus, ActivationStatusType expected) { + ActivationType activation = focus.asObjectable().getActivation(); + assertNotNull("No activation in "+focus, activation); + assertEquals("Unexpected effective activation status in "+focus, expected, activation.getEffectiveStatus()); + } + + protected void modifyUserReplace(String userOid, ItemPath propertyPath, Task task, OperationResult result, Object... newRealValue) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, + ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + modifyUserReplace(userOid, propertyPath, null, task, result, newRealValue); + } + + protected void modifyUserReplace(String userOid, ItemPath propertyPath, ModelExecuteOptions options, Task task, OperationResult result, Object... newRealValue) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, + ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + ObjectDelta objectDelta = createModifyUserReplaceDelta(userOid, propertyPath, newRealValue); + executeChanges(objectDelta, options, task, result); + } + + protected void modifyObjectReplaceProperty(Class type, String oid, ItemPath propertyPath, Task task, OperationResult result, Object... newRealValue) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, + ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + modifyObjectReplaceProperty(type, oid, propertyPath, null, task, result, newRealValue); + } + + protected void modifyObjectReplaceProperty(Class type, String oid, ItemPath propertyPath, ModelExecuteOptions options, Task task, OperationResult result, Object... newRealValue) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, + ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + ObjectDelta objectDelta = prismContext.deltaFactory().object() + .createModificationReplaceProperty(type, oid, propertyPath, newRealValue); + Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); + modelService.executeChanges(deltas, options, task, result); + } + + protected void modifyObjectDeleteProperty(Class type, String oid, ItemPath propertyPath, Task task, OperationResult result, Object... newRealValue) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, + ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + ObjectDelta objectDelta = prismContext.deltaFactory().object() + .createModificationDeleteProperty(type, oid, propertyPath, newRealValue); + Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); + modelService.executeChanges(deltas, null, task, result); + } + + protected void modifyObjectAddProperty(Class type, String oid, ItemPath propertyPath, Task task, OperationResult result, Object... newRealValue) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, + ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + ObjectDelta objectDelta = prismContext.deltaFactory().object() + .createModificationAddProperty(type, oid, propertyPath, newRealValue); + Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); + modelService.executeChanges(deltas, null, task, result); + } + + protected void modifyObjectReplaceContainer(Class type, String oid, ItemPath propertyPath, Task task, OperationResult result, C... newRealValue) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, + ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + ObjectDelta objectDelta = prismContext.deltaFactory().object() + .createModificationReplaceContainer(type, oid, propertyPath, newRealValue); + Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); + modelService.executeChanges(deltas, null, task, result); + } + + protected void modifyObjectAddContainer(Class type, String oid, ItemPath propertyPath, Task task, OperationResult result, C... newRealValue) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, + ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + ObjectDelta objectDelta = prismContext.deltaFactory().object() + .createModificationAddContainer(type, oid, propertyPath, newRealValue); + Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); + modelService.executeChanges(deltas, null, task, result); + } + + protected void modifyObjectDeleteContainer(Class type, String oid, ItemPath propertyPath, Task task, OperationResult result, C... newRealValue) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, + ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + ObjectDelta objectDelta = prismContext.deltaFactory().object() + .createModificationDeleteContainer(type, oid, propertyPath, newRealValue); + Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); + modelService.executeChanges(deltas, null, task, result); + } + + protected void modifyObjectReplaceReference(Class type, String oid, ItemPath refPath, Task task, OperationResult result, PrismReferenceValue... refVals) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, + ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + ObjectDelta objectDelta = prismContext.deltaFactory().object() + .createModificationReplaceReference(type, oid, refPath, refVals); + Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); + modelService.executeChanges(deltas, null, task, result); + } + + protected void modifyUserAdd(String userOid, ItemPath propertyPath, Task task, OperationResult result, Object... newRealValue) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, + ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + ObjectDelta objectDelta = createModifyUserAddDelta(userOid, propertyPath, newRealValue); + Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); + modelService.executeChanges(deltas, null, task, result); + } + + protected void modifyUserDelete(String userOid, ItemPath propertyPath, Task task, OperationResult result, Object... newRealValue) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, + ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + ObjectDelta objectDelta = createModifyUserDeleteDelta(userOid, propertyPath, newRealValue); + Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); + modelService.executeChanges(deltas, null, task, result); + } + + protected void modifyAccountShadowReplace(String accountOid, ItemPath propertyPath, Task task, OperationResult result, Object... newRealValue) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, + ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + PrismObject shadow = repositoryService.getObject(ShadowType.class, accountOid, null, result); + String resourceOid = shadow.asObjectable().getResourceRef().getOid(); + PrismObject resource = provisioningService.getObject(ResourceType.class, resourceOid, null, task, result); + ObjectDelta objectDelta = createModifyAccountShadowReplaceDelta(accountOid, resource, propertyPath, newRealValue); + Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); + modelService.executeChanges(deltas, null, task, result); + } + + protected ObjectDelta createOldNewPasswordDelta(String oid, String oldPassword, String newPassword) throws SchemaException { + ProtectedStringType oldPasswordPs = new ProtectedStringType(); + oldPasswordPs.setClearValue(oldPassword); + + ProtectedStringType newPasswordPs = new ProtectedStringType(); + newPasswordPs.setClearValue(newPassword); + + return deltaFor(UserType.class) + .item(PASSWORD_VALUE_PATH) + .oldRealValue(oldPasswordPs) + .replace(newPasswordPs) + .asObjectDelta(oid); + } + + protected void modifyUserChangePassword(String userOid, String newPassword) throws CommonException { + Task task = createTask("modifyUserChangePassword"); + OperationResult result = task.getResult(); + modifyUserChangePassword(userOid, newPassword, task, result); + assertSuccess(result); + } + + protected void modifyUserChangePassword(String userOid, String newPassword, Task task, OperationResult result) throws CommonException { + modifyFocusChangePassword(UserType.class, userOid, newPassword, task, result); + } + + protected void modifyFocusChangePassword(Class type, String oid, String newPassword, Task task, OperationResult result) throws CommonException { + ProtectedStringType passwordPs = new ProtectedStringType(); + passwordPs.setClearValue(newPassword); + modifyObjectReplaceProperty(type, oid, PASSWORD_VALUE_PATH, task, result, passwordPs); + } + + protected void modifyUserSetPassword(String userOid, String newPassword, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + ProtectedStringType userPasswordPs = new ProtectedStringType(); + userPasswordPs.setClearValue(newPassword); + PasswordType passwordType = new PasswordType(); + passwordType.setValue(userPasswordPs); + ObjectDelta delta = prismContext.deltaFor(UserType.class) + .item(SchemaConstants.PATH_PASSWORD).add(passwordType) + .asObjectDelta(userOid); + executeChanges(delta, null, task, result); + } + + protected void modifyAccountChangePassword(String accountOid, String newPassword, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + ProtectedStringType userPasswordPs = new ProtectedStringType(); + userPasswordPs.setClearValue(newPassword); + modifyAccountShadowReplace(accountOid, PASSWORD_VALUE_PATH, task, result, userPasswordPs); + } + + protected void clearUserPassword(String userOid) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + Task task = createTask("clearUserPassword"); + OperationResult result = task.getResult(); + List> itemDeltas = prismContext.deltaFor(UserType.class) + .item(SchemaConstants.PATH_PASSWORD).replace() + .asItemDeltas(); + repositoryService.modifyObject(UserType.class, userOid, itemDeltas, result); + assertSuccess(result); + } + + protected void renameObject(Class type, String oid, String newName, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + modifyObjectReplaceProperty(type, oid, ObjectType.F_NAME, task, result, createPolyString(newName)); + } + + protected void recomputeUser(String userOid) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { + Task task = createTask("recomputeUser"); + OperationResult result = task.getResult(); + modelService.recompute(UserType.class, userOid, null, task, result); + assertSuccess(result); + } + + protected void recomputeUser(String userOid, Task task, OperationResult result) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { + modelService.recompute(UserType.class, userOid, null, task, result); + } + + protected void recomputeFocus(Class clazz, String userOid, Task task, OperationResult result) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { + modelService.recompute(clazz, userOid, null, task, result); + } + + protected void recomputeUser(String userOid, ModelExecuteOptions options, Task task, OperationResult result) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { + modelService.recompute(UserType.class, userOid, options, task, result); + } + + protected void assignRole(String userOid, String roleOid) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".assignRole"); + OperationResult result = task.getResult(); + assignRole(userOid, roleOid, task, result); + assertSuccess(result); + } + + protected void assignRole(String userOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + assignRole(UserType.class, userOid, roleOid, (ActivationType) null, task, result); + } + + protected void assignService(String userOid, String targetOid, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + assignService(UserType.class, userOid, targetOid, (ActivationType) null, task, result); + } + + protected void assignRole(String userOid, String roleOid, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + assignRole(UserType.class, userOid, roleOid, (ActivationType) null, task, options, result); + } + + protected void assignRole(Class focusClass, String focusOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + assignRole(focusClass, focusOid, roleOid, (ActivationType) null, task, result); + } + + protected void assignRole(String userOid, String roleOid, ActivationType activationType, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, null, task, null, activationType, true, result); + } + + protected void unassignRole(String userOid, String roleOid, ActivationType activationType, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, null, task, null, activationType, false, result); + } + + protected void unassignRole(Class focusClass, String focusOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + unassignRole(focusClass, focusOid, roleOid, (ActivationType) null, task, result); + } + + protected void unassignRole(Class focusClass, String focusOid, String roleOid, ActivationType activationType, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyAssignmentHolderAssignment(focusClass, focusOid, roleOid, RoleType.COMPLEX_TYPE, null, task, null, activationType, false, result); + } + + protected void assignRole(Class focusClass, String focusOid, String roleOid, ActivationType activationType, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyAssignmentHolderAssignment(focusClass, focusOid, roleOid, RoleType.COMPLEX_TYPE, null, task, null, activationType, true, result); + } + + protected void assignService(Class focusClass, String focusOid, String targetOid, ActivationType activationType, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyAssignmentHolderAssignment(focusClass, focusOid, targetOid, ServiceType.COMPLEX_TYPE, null, task, null, activationType, true, result); + } + + protected void assignRole(Class focusClass, String focusOid, String roleOid, ActivationType activationType, Task task, ModelExecuteOptions options, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyAssignmentHolderAssignment(focusClass, focusOid, roleOid, RoleType.COMPLEX_TYPE, null, task, null, activationType, true, options, result); + } + + protected void assignFocus(Class focusClass, String focusOid, QName targetType, String targetOid, QName relation, ActivationType activationType, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyAssignmentHolderAssignment(focusClass, focusOid, targetOid, targetType, relation, task, null, activationType, true, result); + } + + protected void assignRole(String userOid, String roleOid, QName relation, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, relation, task, null, null, true, result); + } + + protected void assignRole(String userOid, String roleOid, QName relation, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, relation, task, null, null, true, options, result); + } + + protected void assignRole(String userOid, String roleOid, QName relation) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".assignRole"); + OperationResult result = task.getResult(); + assignRole(userOid, roleOid, relation, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + } + + protected void assignRole(String userOid, String roleOid, QName relation, Consumer modificationBlock, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, relation, task, modificationBlock, true, result); + } + + protected void unassignRole(String userOid, String roleOid) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + Task task = createTask("unassignRole"); + OperationResult result = task.getResult(); + unassignRole(userOid, roleOid, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + } + + protected void unassignRoleByAssignmentValue(PrismObject focus, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + AssignmentType assignment = findAssignmentByTargetRequired(focus, roleOid); + ObjectDelta delta = prismContext.deltaFor(focus.getCompileTimeClass()) + .item(FocusType.F_ASSIGNMENT) + .delete(assignment.clone()) + .asObjectDeltaCast(focus.getOid()); + modelService.executeChanges(singleton(delta), null, task, result); + } + + protected void unassignRole(String userOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, null, task, (Consumer)null, false, result); + } + + protected void unassignService(String userOid, String serviceOid, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userOid, serviceOid, ServiceType.COMPLEX_TYPE, null, task, (Consumer)null, false, result); + } + + protected void unassignRole(String userOid, String roleOid, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, null, task, null, false, options, result); + } + + protected void assignRole(String userOid, String roleOid, PrismContainer extension, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, null, task, extension, true, result); + } + + protected void assignRole(String userOid, String roleOid, PrismContainer extension, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyAssignmentHolderAssignment(UserType.class, userOid, roleOid, RoleType.COMPLEX_TYPE, null, task, extension, null, true, options, result); + } + + protected void unassignRole(String userOid, String roleOid, PrismContainer extension, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, null, task, extension, false, result); + } + + protected void unassignRole(String userOid, String roleOid, PrismContainer extension, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyAssignmentHolderAssignment(UserType.class, userOid, roleOid, RoleType.COMPLEX_TYPE, null, task, extension, null, false, options, result); + } + + protected void unassignRole(String userOid, String roleOid, QName relation, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, relation, task, null, null, false, result); + } + + protected void unassignRole(String userOid, String roleOid, QName relation, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, relation, task, null, null, false, options, result); + } + + protected void unassignRole(String userOid, String roleOid, QName relation, Consumer modificationBlock, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, relation, task, modificationBlock, false, result); + } + + protected void unassignAllRoles(String userOid) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + unassignAllRoles(userOid, false); + } + + protected void unassignAllRoles(String userOid, boolean useRawPlusRecompute) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + Task task = getOrCreateSimpleTask("unassignAllRoles"); + OperationResult result = task.getResult(); + PrismObject user = modelService.getObject(UserType.class, userOid, null, task, result); + Collection> modifications = new ArrayList<>(); + for (AssignmentType assignment: user.asObjectable().getAssignment()) { + ObjectReferenceType targetRef = assignment.getTargetRef(); + if (targetRef != null) { + if (targetRef.getType().equals(RoleType.COMPLEX_TYPE)) { + ContainerDelta assignmentDelta = prismContext.deltaFactory().container() + .createDelta(UserType.F_ASSIGNMENT, getUserDefinition()); + PrismContainerValue cval = prismContext.itemFactory().createContainerValue(); + cval.setId(assignment.getId()); + assignmentDelta.addValueToDelete(cval); + modifications.add(assignmentDelta); + } + } + } + if (modifications.isEmpty()) { + return; + } + ObjectDelta userDelta = prismContext.deltaFactory().object() + .createModifyDelta(userOid, modifications, UserType.class); + Collection> deltas = MiscSchemaUtil.createCollection(userDelta); + modelService.executeChanges(deltas, useRawPlusRecompute ? ModelExecuteOptions.createRaw() : null, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + + if (useRawPlusRecompute) { + recomputeUser(userOid, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + } + } + + protected void assignArchetype(String userOid, String archetypeOid, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userOid, archetypeOid, ArchetypeType.COMPLEX_TYPE, null, task, (Consumer)null, true, result); + } + + protected void unassignArchetype(String userOid, String archetypeOid, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userOid, archetypeOid, ArchetypeType.COMPLEX_TYPE, null, task, (Consumer)null, false, result); + } + + protected void induceRole(String focusRoleOid, String targetRoleOid, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + induceRole(RoleType.class, focusRoleOid, targetRoleOid, task, result); + } + + protected void induceRole(Class focusType, String focusOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyFocusAssignment(focusType, focusOid, AbstractRoleType.F_INDUCEMENT, roleOid, RoleType.COMPLEX_TYPE, null, task, null, true, null, result); + } + + protected void induceOrg(Class focusType, String focusOid, String orgOid, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyFocusAssignment(focusType, focusOid, AbstractRoleType.F_INDUCEMENT, orgOid, OrgType.COMPLEX_TYPE, null, task, null, true, null, result); + } + + protected void uninduceRole(Class focusType, String focusOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyFocusAssignment(focusType, focusOid, AbstractRoleType.F_INDUCEMENT, roleOid, RoleType.COMPLEX_TYPE, null, task, null, false, null, result); + } + + protected void uninduceRole(String focusRoleOid, String targetRoleOid, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + uninduceRole(RoleType.class, focusRoleOid, targetRoleOid, task, result); + } + + protected void assignOrg(String userOid, String orgOid, Task task, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, + CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + assignOrg(userOid, orgOid, null, task, result); + } + + protected void assignOrg(Class focusType, String focusOid, String orgOid, Task task, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, + CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + assignOrg(focusType, focusOid, orgOid, null, task, result); + } + + protected void assignOrg(String userOid, String orgOid) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + assignOrg(userOid, orgOid, prismContext.getDefaultRelation()); + } + + protected void assignOrg(String userOid, String orgOid, QName relation) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, + CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + Task task = createTask(AbstractIntegrationTest.class.getName()+".assignOrg"); + OperationResult result = task.getResult(); + assignOrg(userOid, orgOid, relation, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + } + + protected void assignOrg(String userOid, String orgOid, QName relation, Task task, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, + CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userOid, orgOid, OrgType.COMPLEX_TYPE, relation, task, (Consumer)null, true, result); + } + + protected void assignOrg(Class focusType, String focusOid, String orgOid, QName relation, Task task, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, + CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyFocusAssignment(focusType, focusOid, orgOid, OrgType.COMPLEX_TYPE, relation, task, (Consumer)null, true, result); + } + + protected void unassignOrg(String userOid, String orgOid) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + unassignOrg(userOid, orgOid, prismContext.getDefaultRelation()); + } + + protected void unassignOrg(String userOid, String orgOid, Task task, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, + CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + unassignOrg(userOid, orgOid, null, task, result); + } + + protected void unassignOrg(String userOid, String orgOid, QName relation) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".unassignOrg"); + OperationResult result = task.getResult(); + unassignOrg(userOid, orgOid, relation, task, result); + assertSuccess(result); + } + + protected void unassignOrg(String userOid, String orgOid, QName relation, Task task, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, + CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userOid, orgOid, OrgType.COMPLEX_TYPE, relation, task, (Consumer)null, false, result); + } + + protected void unassignOrg(Class type, String focusOid, String orgOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + unassignOrg(type, focusOid, orgOid, null, task, result); + } + + protected void unassignOrg(Class type, String focusOid, String orgOid, QName relation, Task task, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, + CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyFocusAssignment(type, focusOid, orgOid, OrgType.COMPLEX_TYPE, relation, task, (Consumer)null, false, result); + } + + protected void modifyUserAssignment(String userOid, String roleOid, QName refType, QName relation, Task task, + PrismContainer extension, boolean add, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userOid, roleOid, refType, relation, task, extension, null, add, result); + } + + protected void modifyUserAssignment(String userOid, String roleOid, QName refType, QName relation, Task task, + PrismContainer extension, ActivationType activationType, boolean add, OperationResult result) + throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userOid, roleOid, refType, relation, task, extension, activationType, add, null, result); + } + + protected void modifyUserAssignment(String userOid, String roleOid, QName refType, QName relation, Task task, + PrismContainer extension, ActivationType activationType, boolean add, ModelExecuteOptions options, + OperationResult result) + throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + ObjectDelta userDelta = createAssignmentUserDelta(userOid, roleOid, refType, relation, extension, activationType, add); + executeChanges(userDelta, options, task, result); + } + + protected void modifyAssignmentHolderAssignment(Class focusClass, String focusOid, String roleOid, QName refType, QName relation, Task task, + PrismContainer extension, ActivationType activationType, boolean add, OperationResult result) + throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyAssignmentHolderAssignment(focusClass, focusOid, roleOid, refType, relation, task, extension, activationType, add, null, result); + } + + protected void modifyAssignmentHolderAssignment(Class focusClass, String focusOid, String roleOid, QName refType, QName relation, Task task, + PrismContainer extension, ActivationType activationType, boolean add, ModelExecuteOptions options, OperationResult result) + throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + ObjectDelta delta = createAssignmentAssignmentHolderDelta(focusClass, focusOid, roleOid, refType, relation, extension, activationType, add); + executeChanges(delta, options, task, result); + } + + protected void modifyUserAssignment(String userOid, String roleOid, QName refType, QName relation, Task task, + Consumer modificationBlock, boolean add, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + modifyFocusAssignment(UserType.class, userOid, roleOid, refType, relation, task, modificationBlock, add, result); + } + + protected void modifyUserAssignment(String userOid, String roleOid, QName refType, QName relation, Task task, + Consumer modificationBlock, boolean add, ModelExecuteOptions options, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + modifyFocusAssignment(UserType.class, userOid, roleOid, refType, relation, task, modificationBlock, add, options, result); + } + + protected void modifyFocusAssignment(Class focusClass, String focusOid, String roleOid, QName refType, QName relation, Task task, + Consumer modificationBlock, boolean add, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + modifyFocusAssignment(focusClass, focusOid, roleOid, refType, relation, task, modificationBlock, add, null, result); + } + + protected void modifyFocusAssignment(Class focusClass, String focusOid, String roleOid, QName refType, QName relation, Task task, + Consumer modificationBlock, boolean add, ModelExecuteOptions options, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + modifyFocusAssignment(focusClass, focusOid, FocusType.F_ASSIGNMENT, roleOid, refType, relation, task, modificationBlock, add, options, result); + } + + protected void modifyFocusAssignment(Class focusClass, String focusOid, QName elementName, String roleOid, QName refType, QName relation, Task task, + Consumer modificationBlock, boolean add, ModelExecuteOptions options, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + ObjectDelta focusDelta = createAssignmentFocusDelta(focusClass, focusOid, elementName, roleOid, refType, relation, modificationBlock, add); + Collection> deltas = MiscSchemaUtil.createCollection(focusDelta); + executeChanges(focusDelta, options, task, result); + } + + protected void deleteFocusAssignmentEmptyDelta(PrismObject existingFocus, String targetOid, Task task, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + deleteFocusAssignmentEmptyDelta(existingFocus, targetOid, null, null, task, result); + } + + protected void deleteFocusAssignmentEmptyDelta(PrismObject existingFocus, String targetOid, QName relation, Task task, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + deleteFocusAssignmentEmptyDelta(existingFocus, targetOid, relation, null, task, result); + } + + protected void deleteFocusAssignmentEmptyDelta(PrismObject existingFocus, String targetOid, QName relation, + ModelExecuteOptions options, Task task, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + ObjectDelta focusDelta = createAssignmentFocusEmptyDeleteDelta(existingFocus, targetOid, relation); + executeChanges(focusDelta, options, task, result); + } + + protected void unassign(Class focusClass, String focusOid, String roleId, Task task, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + ObjectDelta focusDelta = createAssignmentAssignmentHolderDelta(focusClass, focusOid, roleId, null, null, null, null, false); + executeChanges(focusDelta, null, task, result); + } + + protected void unassign(Class focusClass, String focusOid, long assignmentId, Task task, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + unassign(focusClass, focusOid, assignmentId, null, task, result); + } + + protected void unassign(Class focusClass, String focusOid, long assignmentId, ModelExecuteOptions options, Task task, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + unassign(focusClass, focusOid, createAssignmentIdOnly(assignmentId), options, task, result); + } + + protected void unassign(Class focusClass, String focusOid, AssignmentType currentAssignment, ModelExecuteOptions options, Task task, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + Collection> modifications = new ArrayList<>(); + ContainerDelta assignmentDelta = prismContext.deltaFactory().container().createDelta(UserType.F_ASSIGNMENT, getUserDefinition()); + assignmentDelta.addValuesToDelete(currentAssignment.asPrismContainerValue().clone()); + modifications.add(assignmentDelta); + ObjectDelta focusDelta = prismContext.deltaFactory().object().createModifyDelta(focusOid, modifications, focusClass + ); + executeChanges(focusDelta, options, task, result); + } + + protected void unlink(Class focusClass, String focusOid, String targetOid, Task task, OperationResult result) + throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + ObjectDelta delta = prismContext.deltaFactory().object() + .createModificationDeleteReference(focusClass, focusOid, FocusType.F_LINK_REF, + targetOid); + executeChanges(delta, null, task, result); + } + + protected void unlinkUser(String userOid, String targetOid) + throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + Task task = createTask("unlinkUser"); + OperationResult result = task.getResult(); + unlink(UserType.class, userOid, targetOid, task, result); + assertSuccess(result); + } + + /** + * Executes unassign delta by removing each assignment individually by id. + */ + protected void unassignAll(PrismObject focusBefore, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + executeChanges(createUnassignAllDelta(focusBefore), null, task, result); + } + + /** + * Creates unassign delta by removing each assignment individually by id. + */ + protected ObjectDelta createUnassignAllDelta(PrismObject focusBefore) throws SchemaException { + Collection> modifications = new ArrayList<>(); + for (AssignmentType assignmentType: focusBefore.asObjectable().getAssignment()) { + modifications.add((createAssignmentModification(assignmentType.getId(), false))); + } + return prismContext.deltaFactory().object() + .createModifyDelta(focusBefore.getOid(), modifications, focusBefore.getCompileTimeClass() + ); + } + + /** + * Executes assignment replace delta with empty values. + */ + protected void unassignAllReplace(String userOid, Task task, OperationResult result) + throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + ObjectDelta userDelta = prismContext.deltaFactory().object() + .createModificationReplaceContainer(UserType.class, userOid, + UserType.F_ASSIGNMENT, new PrismContainerValue[0]); + Collection> deltas = MiscSchemaUtil.createCollection(userDelta); + modelService.executeChanges(deltas, null, task, result); + } + + protected ContainerDelta createAssignmentModification(String roleOid, QName refType, QName relation, + PrismContainer extension, ActivationType activationType, boolean add) throws SchemaException { + return createAssignmentModification(UserType.class, FocusType.F_ASSIGNMENT, roleOid, refType, relation, extension, activationType, add); + } + + protected ContainerDelta createAssignmentModification(Class type, QName elementName, String roleOid, QName refType, QName relation, + PrismContainer extension, ActivationType activationType, boolean add) throws SchemaException { + try { + return createAssignmentModification(type, elementName, roleOid, refType, relation, + assignment -> { + if (extension != null) { + try { + assignment.asPrismContainerValue().add(extension.clone()); + } catch (SchemaException e) { + throw new TunnelException(e); + } + } + assignment.setActivation(activationType); + }, add); + } catch (TunnelException te) { + throw (SchemaException)te.getCause(); + } + } + + + protected ContainerDelta createAssignmentModification(Class type, QName elementName, String roleOid, QName refType, QName relation, + Consumer modificationBlock, boolean add) throws SchemaException { + ContainerDelta assignmentDelta = prismContext.deltaFactory().container().createDelta(ItemName.fromQName(elementName), getObjectDefinition(type)); + PrismContainerValue cval = prismContext.itemFactory().createContainerValue(); + if (add) { + assignmentDelta.addValueToAdd(cval); + } else { + assignmentDelta.addValueToDelete(cval); + } + PrismReference targetRef = cval.findOrCreateReference(AssignmentType.F_TARGET_REF); + targetRef.getValue().setOid(roleOid); + targetRef.getValue().setTargetType(refType); + targetRef.getValue().setRelation(relation); + if (modificationBlock != null) { + modificationBlock.accept(cval.asContainerable()); + } + return assignmentDelta; + } + + protected ContainerDelta createAssignmentModification(long id, boolean add) throws SchemaException { + ContainerDelta assignmentDelta = prismContext.deltaFactory().container().createDelta(UserType.F_ASSIGNMENT, getUserDefinition()); + PrismContainerValue cval = prismContext.itemFactory().createContainerValue(); + cval.setId(id); + if (add) { + assignmentDelta.addValueToAdd(cval); + } else { + assignmentDelta.addValueToDelete(cval); + } + return assignmentDelta; + } + + protected ContainerDelta createAssignmentEmptyDeleteModification(PrismObject existingFocus, String roleOid, QName relation) throws SchemaException { + AssignmentType existingAssignment = findAssignment(existingFocus, roleOid, relation); + return createAssignmentModification(existingAssignment.getId(), false); + } + + protected AssignmentType findAssignment(PrismObject existingFocus, String targetOid, QName relation) { + for (AssignmentType assignmentType : existingFocus.asObjectable().getAssignment()) { + if (assignmentMatches(assignmentType, targetOid, relation)) { + return assignmentType; + } + } + return null; + } + + protected boolean assignmentMatches(AssignmentType assignmentType, String targetOid, QName relation) { + ObjectReferenceType targetRef = assignmentType.getTargetRef(); + if (targetRef == null) { + return false; + } + return referenceMatches(targetRef, targetOid, relation); + } + + private boolean referenceMatches(ObjectReferenceType ref, String targetOid, QName relation) { + if (targetOid != null && !targetOid.equals(ref.getOid())) { + return false; + } + if (relation != null && !QNameUtil.match(relation, ref.getRelation())) { + return false; + } + return true; + } + + protected ObjectDelta createAssignmentUserDelta(String userOid, String roleOid, QName refType, QName relation, + PrismContainer extension, ActivationType activationType, boolean add) throws SchemaException { + Collection> modifications = new ArrayList<>(); + modifications.add((createAssignmentModification(roleOid, refType, relation, extension, activationType, add))); + ObjectDelta userDelta = prismContext.deltaFactory().object() + .createModifyDelta(userOid, modifications, UserType.class); + return userDelta; + } + + protected ObjectDelta createAssignmentAssignmentHolderDelta(Class focusClass, String focusOid, String roleOid, QName refType, QName relation, + PrismContainer extension, ActivationType activationType, boolean add) throws SchemaException { + Collection> modifications = new ArrayList<>(); + modifications.add((createAssignmentModification(roleOid, refType, relation, extension, activationType, add))); + return prismContext.deltaFactory().object().createModifyDelta(focusOid, modifications, focusClass); + } + + protected ObjectDelta createAssignmentUserDelta(String userOid, String roleOid, QName refType, QName relation, + Consumer modificationBlock, boolean add) throws SchemaException { + return createAssignmentFocusDelta(UserType.class, userOid, roleOid, refType, relation, modificationBlock, add); + } + + protected ObjectDelta createAssignmentFocusDelta(Class focusClass, String focusOid, String roleOid, QName refType, QName relation, + Consumer modificationBlock, boolean add) throws SchemaException { + return createAssignmentFocusDelta(focusClass, focusOid, FocusType.F_ASSIGNMENT, roleOid, refType, relation, modificationBlock, add); + } + + protected ObjectDelta createAssignmentFocusDelta(Class focusClass, String focusOid, QName elementName, String roleOid, QName refType, QName relation, + Consumer modificationBlock, boolean add) throws SchemaException { + Collection> modifications = new ArrayList<>(); + modifications.add((createAssignmentModification(focusClass, elementName, roleOid, refType, relation, modificationBlock, add))); + return prismContext.deltaFactory().object().createModifyDelta(focusOid, modifications, focusClass); + } + + protected ObjectDelta createAssignmentFocusEmptyDeleteDelta(PrismObject existingFocus, String roleOid, QName relation) throws SchemaException { + Collection> modifications = new ArrayList<>(); + modifications.add((createAssignmentEmptyDeleteModification(existingFocus, roleOid, relation))); + return prismContext.deltaFactory().object() + .createModifyDelta(existingFocus.getOid(), modifications, existingFocus.getCompileTimeClass() + ); + } + + protected ContainerDelta createAccountAssignmentModification(String resourceOid, String intent, boolean add) throws SchemaException { + return createAssignmentModification(resourceOid, ShadowKindType.ACCOUNT, intent, add); + } + + protected PropertyDelta createUserPropertyReplaceModification(QName propertyName, V... values) { + return prismContext.deltaFactory().property().createReplaceDelta(getUserDefinition(), propertyName, values); + } + + protected ContainerDelta createAssignmentModification(String resourceOid, ShadowKindType kind, + String intent, boolean add) throws SchemaException { + AssignmentType assignmentType = createConstructionAssignment(resourceOid, kind, intent); + return createAssignmentModification(assignmentType, add); + } + + protected ContainerDelta createAssignmentModification(AssignmentType assignmentType, boolean add) throws SchemaException { + ContainerDelta assignmentDelta = prismContext.deltaFactory().container().createDelta(UserType.F_ASSIGNMENT, getUserDefinition()); + + if (add) { + assignmentDelta.addValueToAdd(assignmentType.asPrismContainerValue()); + } else { + assignmentDelta.addValueToDelete(assignmentType.asPrismContainerValue()); + } + + PrismContainerDefinition assignmentDef = getUserDefinition().findContainerDefinition(UserType.F_ASSIGNMENT); + assignmentDelta.applyDefinition(assignmentDef); + + return assignmentDelta; + } + + protected AssignmentType createAccountAssignment(String resourceOid, String intent) { + return createConstructionAssignment(resourceOid, ShadowKindType.ACCOUNT, intent); + } + + protected AssignmentType createConstructionAssignment(String resourceOid, ShadowKindType kind, String intent) { + AssignmentType assignmentType = new AssignmentType(); + ConstructionType constructionType = new ConstructionType(); + constructionType.setKind(kind); + assignmentType.setConstruction(constructionType); + ObjectReferenceType resourceRef = new ObjectReferenceType(); + resourceRef.setOid(resourceOid); + resourceRef.setType(ResourceType.COMPLEX_TYPE); + constructionType.setResourceRef(resourceRef); + constructionType.setIntent(intent); + return assignmentType; + } + + protected AssignmentType createTargetAssignment(String targetOid, QName targetType) { + AssignmentType assignmentType = new AssignmentType(); + ObjectReferenceType targetRef = new ObjectReferenceType(); + targetRef.setOid(targetOid); + targetRef.setType(targetType); + assignmentType.setTargetRef(targetRef); + return assignmentType; + } + + protected ObjectDelta createParametricAssignmentDelta(String userOid, String roleOid, String orgOid, String tenantOid, boolean adding) throws SchemaException { + Collection> modifications = new ArrayList<>(); + + ContainerDelta assignmentDelta = prismContext.deltaFactory().container().createDelta(UserType.F_ASSIGNMENT, getUserDefinition()); + PrismContainerValue cval = prismContext.itemFactory().createContainerValue(); + if (adding) { + assignmentDelta.addValueToAdd(cval); + } else { + assignmentDelta.addValueToDelete(cval); + } + PrismReference targetRef = cval.findOrCreateReference(AssignmentType.F_TARGET_REF); + targetRef.getValue().setOid(roleOid); + targetRef.getValue().setTargetType(RoleType.COMPLEX_TYPE); + + if (orgOid != null) { + PrismReference orgRef = cval.findOrCreateReference(AssignmentType.F_ORG_REF); + orgRef.getValue().setOid(orgOid); + } + + if (tenantOid != null) { + PrismReference tenantRef = cval.findOrCreateReference(AssignmentType.F_TENANT_REF); + tenantRef.getValue().setOid(tenantOid); + } + + + modifications.add(assignmentDelta); + return prismContext.deltaFactory().object().createModifyDelta(userOid, modifications, UserType.class + ); + } + + protected void assignParametricRole(String userOid, String roleOid, String orgOid, String tenantOid, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + assignParametricRole(userOid, roleOid, orgOid, tenantOid, null, task, result); + } + + protected void assignParametricRole(String userOid, String roleOid, String orgOid, String tenantOid, ModelExecuteOptions options, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + Collection> deltas = MiscSchemaUtil.createCollection( + createParametricAssignmentDelta(userOid, roleOid, orgOid, tenantOid, true)); + modelService.executeChanges(deltas, options, task, result); + } + + protected void unassignParametricRole(String userOid, String roleOid, String orgOid, String tenantOid, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + unassignParametricRole(userOid, roleOid, orgOid, tenantOid, null, task, result); + } + + protected void unassignParametricRole(String userOid, String roleOid, String orgOid, String tenantOid, ModelExecuteOptions options, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + Collection> deltas = MiscSchemaUtil.createCollection( + createParametricAssignmentDelta(userOid, roleOid, orgOid, tenantOid, false)); + modelService.executeChanges(deltas, options, task, result); + } + + protected void assertAssignees(String targetOid, int expectedAssignees) throws SchemaException { + assertAssignees(targetOid, prismContext.getDefaultRelation(), expectedAssignees); + } + + protected void assertAssignees(String targetOid, QName relation, int expectedAssignees) throws SchemaException { + OperationResult result = new OperationResult(AbstractModelIntegrationTest.class.getName()+".assertAssignees"); + int count = countAssignees(targetOid, relation, result); + if (count != expectedAssignees) { + SearchResultList> assignees = listAssignees(targetOid, result); + AssertJUnit.fail("Unexpected number of assignees of "+targetOid+" as '"+relation+"', expected "+expectedAssignees+", but was " + count+ ": "+assignees); + } + + } + + protected int countAssignees(String targetOid, OperationResult result) throws SchemaException { + return countAssignees(targetOid, prismContext.getDefaultRelation(), result); + } + + protected int countAssignees(String targetOid, QName relation, OperationResult result) throws SchemaException { + PrismReferenceValue refVal = itemFactory().createReferenceValue(); + refVal.setOid(targetOid); + refVal.setRelation(relation); + ObjectQuery query = prismContext.queryFor(FocusType.class) + .item(FocusType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF).ref(refVal) + .build(); + return repositoryService.countObjects(FocusType.class, query, null, result); + } + + protected SearchResultList> listAssignees(String targetOid, OperationResult result) throws SchemaException { + ObjectQuery query = prismContext.queryFor(FocusType.class) + .item(FocusType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF).ref(targetOid) + .build(); + return repositoryService.searchObjects(FocusType.class, query, null, result); + } + + protected ConstructionType createAccountConstruction(String resourceOid, String intent) throws SchemaException { + ConstructionType accountConstructionType = new ConstructionType(); + ObjectReferenceType resourceRef = new ObjectReferenceType(); + resourceRef.setOid(resourceOid); + accountConstructionType.setResourceRef(resourceRef); + accountConstructionType.setIntent(intent); + return accountConstructionType; + } + + protected ObjectDelta createReplaceAccountConstructionUserDelta(String userOid, Long id, ConstructionType newValue) throws SchemaException { + PrismContainerDefinition pcd = getAssignmentDefinition().findContainerDefinition(AssignmentType.F_CONSTRUCTION); + ContainerDelta acDelta = prismContext.deltaFactory().container().create( + ItemPath.create(UserType.F_ASSIGNMENT, id, AssignmentType.F_CONSTRUCTION), pcd); + acDelta.setValueToReplace(newValue.asPrismContainerValue()); + + Collection> modifications = new ArrayList<>(); + modifications.add(acDelta); + ObjectDelta userDelta = prismContext.deltaFactory().object() + .createModifyDelta(userOid, modifications, UserType.class); + return userDelta; + } + + protected ObjectDelta createAccountAssignmentUserDelta(String focusOid, String resourceOid, String intent, boolean add) throws SchemaException { + return createAssignmentDelta(UserType.class, focusOid, resourceOid, ShadowKindType.ACCOUNT, intent, add); + } + + protected ObjectDelta createAssignmentDelta(Class type, String focusOid, + String resourceOid, ShadowKindType kind, String intent, boolean add) throws SchemaException { + Collection> modifications = new ArrayList<>(); + modifications.add(createAssignmentModification(resourceOid, kind, intent, add)); + ObjectDelta userDelta = prismContext.deltaFactory().object().createModifyDelta(focusOid, modifications, type + ); + return userDelta; + } + + protected Collection> executeChanges(ObjectDelta objectDelta, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + display("Executing delta", objectDelta); + Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); + return modelService.executeChanges(deltas, options, task, result); + } + + protected Collection> executeChanges(Collection> deltas, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + display("Executing deltas", deltas); + return modelService.executeChanges(deltas, options, task, result); + } + + protected Collection> executeChangesAssertSuccess(ObjectDelta objectDelta, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + Collection> rv = executeChanges(objectDelta, options, task, result); + assertSuccess(result); + return rv; + } + + protected ModelContext previewChanges(ObjectDelta objectDelta, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + display("Preview changes for delta", objectDelta); + Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); + return modelInteractionService.previewChanges(deltas, options, task, result); + } + + protected void assignAccountToUser(String focusOid, String resourceOid, String intent) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + assignAccount(UserType.class, focusOid, resourceOid, intent); + } + + protected void assignAccount(Class type, String focusOid, String resourceOid, String intent) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".assignAccount"); + OperationResult result = task.getResult(); + assignAccount(type, focusOid, resourceOid, intent, task, result); + assertSuccess(result); + } + + protected void assignAccountToUser(String focusOid, String resourceOid, String intent, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + assignAccount(UserType.class, focusOid, resourceOid, intent, task, result); + } + + protected void assignAccount(Class type, String focusOid, String resourceOid, String intent, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + ObjectDelta userDelta = createAssignmentDelta(type, focusOid, resourceOid, ShadowKindType.ACCOUNT, intent, true); + executeChanges(userDelta, null, task, result); + } + + protected void unassignAccountFromUser(String focusOid, String resourceOid, String intent) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + unassignAccount(UserType.class, focusOid, resourceOid, intent); + } + + protected void unassignAccount(Class type, String focusOid, String resourceOid, String intent) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".assignAccount"); + OperationResult result = task.getResult(); + unassignAccount(type, focusOid, resourceOid, intent, task, result); + assertSuccess(result); + } + + protected void unassignAccountFromUser(String focusOid, String resourceOid, String intent, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + unassignAccount(UserType.class, focusOid, resourceOid, intent, task, result); + } + + protected void unassignAccount(Class type, String focusOid, String resourceOid, String intent, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + ObjectDelta userDelta = createAssignmentDelta(type, focusOid, resourceOid, ShadowKindType.ACCOUNT, intent, false); + Collection> deltas = MiscSchemaUtil.createCollection(userDelta); + modelService.executeChanges(deltas, null, task, result); + } + + protected void assignPolicyRule(Class type, String focusOid, PolicyRuleType policyRule, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + AssignmentType assignmentType = new AssignmentType(); + assignmentType.setPolicyRule(policyRule); + assign(type, focusOid, assignmentType, task, result); + } + + protected void assign(Class type, String focusOid, AssignmentType assignmentType, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + Collection> modifications = new ArrayList<>(); + modifications.add(createAssignmentModification(assignmentType, true)); + ObjectDelta userDelta = prismContext.deltaFactory().object().createModifyDelta(focusOid, modifications, type + ); + executeChanges(userDelta, null, task, result); + } + + protected PrismObject getUser(String userOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".getUser"); + OperationResult result = task.getResult(); + PrismObject user = modelService.getObject(UserType.class, userOid, null, task, result); + result.computeStatus(); + TestUtil.assertSuccess("getObject(User) result not success", result); + return user; + } + + protected PrismObject getUserFromRepo(String userOid) throws ObjectNotFoundException, SchemaException { + return repositoryService.getObject(UserType.class, userOid, null, new OperationResult("dummy")); + } + + protected PrismObject findObjectByName(Class type, String name) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = getOrCreateSimpleTask("findObjectByName"); + OperationResult result = task.getResult(); + List> objects = modelService.searchObjects(type, createNameQuery(name), null, task, result); + if (objects.isEmpty()) { + return null; + } + assert objects.size() == 1 : "Too many objects found for name "+name+": "+objects; + return objects.iterator().next(); + } + + protected ObjectQuery createNameQuery(String name) throws SchemaException { + return ObjectQueryUtil.createNameQuery(PrismTestUtil.createPolyString(name), prismContext); + } + + protected PrismObject findUserByUsername(String username) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + return findObjectByName(UserType.class, username); + } + + protected PrismObject findServiceByName(String name) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + return findObjectByName(ServiceType.class, name); + } + + protected RoleType getRoleSimple(String oid) { + try { + return getRole(oid).asObjectable(); + } catch (CommonException e) { + throw new SystemException("Unexpected exception while getting role " + oid + ": " + e.getMessage(), e); + } + } + + protected PrismObject getRole(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".getRole"); + OperationResult result = task.getResult(); + PrismObject role = modelService.getObject(RoleType.class, oid, null, task, result); + result.computeStatus(); + TestUtil.assertSuccess("getObject(Role) result not success", result); + return role; + } + + protected PrismObject findAccountByUsername(String username, PrismObject resource) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".findAccountByUsername"); + OperationResult result = task.getResult(); + return findAccountByUsername(username, resource, task, result); + } + + protected PrismObject findAccountByUsername(String username, PrismObject resource, + Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + ObjectQuery query = createAccountShadowQuery(username, resource); + List> accounts = modelService.searchObjects(ShadowType.class, query, null, task, result); + if (accounts.isEmpty()) { + return null; + } + assert accounts.size() == 1 : "Too many accounts found for username "+username+" on "+resource+": "+accounts; + return accounts.iterator().next(); + } + + protected Collection> listAccounts(PrismObject resource, + Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + + RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource); + RefinedObjectClassDefinition rAccount = rSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT); + Collection identifierDefs = rAccount.getPrimaryIdentifiers(); + assert identifierDefs.size() == 1 : "Unexpected identifier set in "+resource+" refined schema: "+identifierDefs; + ResourceAttributeDefinition identifierDef = identifierDefs.iterator().next(); + ObjectQuery query = prismContext.queryFor(ShadowType.class) + .item(ShadowType.F_OBJECT_CLASS).eq(rAccount.getObjectClassDefinition().getTypeName()) + .and().item(ShadowType.F_RESOURCE_REF).ref(resource.getOid()) + .build(); + List> accounts = modelService.searchObjects(ShadowType.class, query, null, task, result); + return accounts; + } + + protected PrismObject getShadowModel(String accountOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + return getShadowModel(accountOid, null, true); + } + + protected PrismObject getShadowModelNoFetch(String accountOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + return getShadowModel(accountOid, GetOperationOptions.createNoFetch(), true); + } + + protected PrismObject getShadowModelFuture(String accountOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + return getShadowModel(accountOid, GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE), true); + } + + protected PrismObject getShadowModel(String shadowOid, GetOperationOptions rootOptions, boolean assertSuccess) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".getShadowModel"); + OperationResult result = task.getResult(); + Collection> opts = null; + if (rootOptions != null) { + opts = SelectorOptions.createCollection(rootOptions); + } + LOGGER.info("Getting model shadow {} with options {}", shadowOid, opts); + PrismObject shadow = modelService.getObject(ShadowType.class, shadowOid, opts , task, result); + LOGGER.info("Got model shadow (options {})\n{}", shadowOid, shadow.debugDumpLazily(1)); + result.computeStatus(); + if (assertSuccess) { + TestUtil.assertSuccess("getObject(shadow) result not success", result); + } + return shadow; + } + + protected void assertNoObject(Class type, String oid) throws SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = createTask(AbstractModelIntegrationTest.class.getName() + ".assertNoObject"); + assertNoObject(type, oid, task, task.getResult()); + } + + protected void assertNoObject(Class type, String oid, Task task, OperationResult result) throws SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + try { + PrismObject object = modelService.getObject(type, oid, null, task, result); + display("Unexpected object", object); + AssertJUnit.fail("Expected that "+object+" does not exist, but it does"); + } catch (ObjectNotFoundException e) { + // This is expected + return; + } + } + + protected void assertObjectByName(Class type, String name, Task task, OperationResult result) + throws SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, + ExpressionEvaluationException, ObjectNotFoundException { + SearchResultList> objects = modelService + .searchObjects(type, prismContext.queryFor(type).item(ObjectType.F_NAME).eqPoly(name).build(), null, task, + result); + if (objects.isEmpty()) { + fail("Expected that " + type + " " + name + " did exist but it did not"); + } + } + + protected void assertNoObjectByName(Class type, String name, Task task, OperationResult result) + throws SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, + ExpressionEvaluationException, ObjectNotFoundException { + SearchResultList> objects = modelService + .searchObjects(type, prismContext.queryFor(type).item(ObjectType.F_NAME).eqPoly(name).build(), null, task, + result); + if (!objects.isEmpty()) { + fail("Expected that " + type + " " + name + " did not exists but it did: " + objects); + } + } + + protected void assertNoShadow(String username, PrismObject resource, + Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException { + ObjectQuery query = createAccountShadowQuery(username, resource); + List> accounts = repositoryService.searchObjects(ShadowType.class, query, null, result); + if (accounts.isEmpty()) { + return; + } + LOGGER.error("Found shadow for "+username+" on "+resource+" while not expecting it:\n"+accounts.get(0).debugDump()); + assert false : "Found shadow for "+username+" on "+resource+" while not expecting it: "+accounts; + } + + protected void assertHasShadow(String username, PrismObject resource, + Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException { + ObjectQuery query = createAccountShadowQuery(username, resource); + List> accounts = repositoryService.searchObjects(ShadowType.class, query, null, result); + if (accounts.isEmpty()) { + AssertJUnit.fail("No shadow for "+username+" on "+resource); + } else if (accounts.size() > 1) { + AssertJUnit.fail("Too many shadows for "+username+" on "+resource+" ("+accounts.size()+"): "+accounts); + } + } + + protected ShadowAsserter assertShadow(String username, PrismObject resource) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException { + ObjectQuery query = createAccountShadowQuery(username, resource); + OperationResult result = new OperationResult("assertShadow"); + List> accounts = repositoryService.searchObjects(ShadowType.class, query, null, result); + if (accounts.isEmpty()) { + AssertJUnit.fail("No shadow for "+username+" on "+resource); + } else if (accounts.size() > 1) { + AssertJUnit.fail("Too many shadows for "+username+" on "+resource+" ("+accounts.size()+"): "+accounts); + } + ShadowAsserter asserter = ShadowAsserter.forShadow(accounts.get(0), "shadow for username "+username+" on "+resource); + initializeAsserter(asserter); + asserter.display(); + return asserter; + } + + protected ShadowAsserter assertShadowByName(ShadowKindType kind, String intent, String name, + PrismObject resource, String message, OperationResult result) + throws ConfigurationException, SchemaException, ObjectNotFoundException, CommunicationException, + SecurityViolationException { + PrismObject shadow = findShadowByName(kind, intent, name, resource, result); + assertNotNull("No shadow with name '"+name+"'", shadow); + return assertShadow(shadow, message); + } + + protected ShadowAsserter assertShadowByNameViaModel(ShadowKindType kind, String intent, String name, + PrismObject resource, String message, Task task, OperationResult result) + throws ConfigurationException, SchemaException, ObjectNotFoundException, CommunicationException, + SecurityViolationException, ExpressionEvaluationException { + PrismObject shadow = findShadowByNameViaModel(kind, intent, name, resource, task, result); + assertNotNull("No shadow with name '"+name+"'", shadow); + return assertShadow(shadow, message); + } + + protected PrismObject findShadowByNameViaModel(ShadowKindType kind, String intent, String name, + PrismObject resource, Task task, OperationResult result) + throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, + ConfigurationException, ExpressionEvaluationException { + return findShadowByNameViaModel(kind, intent, name, resource, schemaHelper.getOperationOptionsBuilder().noFetch().build(), + task, result); + } + + protected PrismObject findShadowByNameViaModel(ShadowKindType kind, String intent, String name, + PrismObject resource, Collection> options, Task task, + OperationResult result) + throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, + ConfigurationException, ExpressionEvaluationException { + RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource); + RefinedObjectClassDefinition rOcDef = rSchema.getRefinedDefinition(kind,intent); + ObjectQuery query = createShadowQuerySecondaryIdentifier(rOcDef, name, resource); + List> shadows = modelService.searchObjects(ShadowType.class, query, options, task, result); + if (shadows.isEmpty()) { + return null; + } + assert shadows.size() == 1 : "Too many shadows found for name "+name+" on "+resource+": "+shadows; + return shadows.iterator().next(); + } + + + protected ObjectQuery createAccountShadowQuery(String username, PrismObject resource) throws SchemaException { + RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource); + RefinedObjectClassDefinition rAccount = rSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT); + Collection identifierDefs = rAccount.getPrimaryIdentifiers(); + assert identifierDefs.size() == 1 : "Unexpected identifier set in "+resource+" refined schema: "+identifierDefs; + ResourceAttributeDefinition identifierDef = identifierDefs.iterator().next(); + //TODO: set matching rule instead of null + return prismContext.queryFor(ShadowType.class) + .itemWithDef(identifierDef, ShadowType.F_ATTRIBUTES, identifierDef.getItemName()).eq(username) + .and().item(ShadowType.F_OBJECT_CLASS).eq(rAccount.getObjectClassDefinition().getTypeName()) + .and().item(ShadowType.F_RESOURCE_REF).ref(resource.getOid()) + .build(); + } + + protected String getSingleLinkOid(PrismObject focus) { + PrismReferenceValue accountRefValue = getSingleLinkRef(focus); + assertNull("Unexpected object in linkRefValue", accountRefValue.getObject()); + return accountRefValue.getOid(); + } + + protected PrismReferenceValue getSingleLinkRef(PrismObject focus) { + F focusType = focus.asObjectable(); + assertEquals("Unexpected number of linkRefs", 1, focusType.getLinkRef().size()); + ObjectReferenceType linkRefType = focusType.getLinkRef().get(0); + String accountOid = linkRefType.getOid(); + assertFalse("No linkRef oid", StringUtils.isBlank(accountOid)); + PrismReferenceValue accountRefValue = linkRefType.asReferenceValue(); + assertEquals("OID mismatch in linkRefValue", accountOid, accountRefValue.getOid()); + return accountRefValue; + } + + protected String getLinkRefOid(String userOid, String resourceOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + return getLinkRefOid(getUser(userOid), resourceOid); + } + + protected String getLinkRefOid(PrismObject focus, String resourceOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + PrismReferenceValue linkRef = getLinkRef(focus, resourceOid); + if (linkRef == null) { + return null; + } + return linkRef.getOid(); + } + + protected PrismReferenceValue getLinkRef(PrismObject focus, String resourceOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + F focusType = focus.asObjectable(); + for (ObjectReferenceType linkRefType: focusType.getLinkRef()) { + String linkTargetOid = linkRefType.getOid(); + assertFalse("No linkRef oid", StringUtils.isBlank(linkTargetOid)); + PrismObject account = getShadowModel(linkTargetOid, GetOperationOptions.createNoFetch(), false); + if (resourceOid.equals(account.asObjectable().getResourceRef().getOid())) { + // This is noFetch. Therefore there is no fetchResult + return linkRefType.asReferenceValue(); + } + } + AssertJUnit.fail("Account for resource "+resourceOid+" not found in "+focus); + return null; // Never reached. But compiler complains about missing return + } + + protected String getLinkRefOid(PrismObject focus, String resourceOid, ShadowKindType kind, String intent) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + F focusType = focus.asObjectable(); + for (ObjectReferenceType linkRefType: focusType.getLinkRef()) { + String linkTargetOid = linkRefType.getOid(); + assertFalse("No linkRef oid", StringUtils.isBlank(linkTargetOid)); + PrismObject account = getShadowModel(linkTargetOid, GetOperationOptions.createNoFetch(), false); + ShadowType shadowType = account.asObjectable(); + if (kind != null && !kind.equals(shadowType.getKind())) { + continue; + } + if (!MiscUtil.equals(intent, shadowType.getIntent())) { + continue; + } + if (resourceOid.equals(shadowType.getResourceRef().getOid())) { + // This is noFetch. Therefore there is no fetchResult + return linkTargetOid; + } + } + AssertJUnit.fail("Linked shadow for resource "+resourceOid+", kind "+kind+" and intent "+intent+" not found in "+focus); + return null; // Never reached. But compiler complains about missing return + } + + protected void assertUserNoAccountRefs(PrismObject user) { + UserType userJackType = user.asObjectable(); + assertEquals("Unexpected number of accountRefs", 0, userJackType.getLinkRef().size()); + } + + protected String assertAccount(PrismObject user, String resourceOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + String accountOid = getLinkRefOid(user, resourceOid); + assertNotNull("User " + user + " has no account on resource " + resourceOid, accountOid); + return accountOid; + } + + protected void assertAccounts(String userOid, int numAccounts) throws ObjectNotFoundException, SchemaException { + OperationResult result = new OperationResult("assertAccounts"); + PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); + assertLinks(user, numAccounts); + } + + protected void assertNoShadows(Collection shadowOids) throws SchemaException { + for (String shadowOid: shadowOids) { + assertNoShadow(shadowOid); + } + } + + protected void assertNoShadow(String shadowOid) throws SchemaException { + OperationResult result = new OperationResult(AbstractModelIntegrationTest.class.getName() + ".assertNoShadow"); + // Check is shadow is gone + try { + PrismObject shadow = repositoryService.getObject(ShadowType.class, shadowOid, null, result); + display("Unexpected shadow", shadow); + AssertJUnit.fail("Shadow "+shadowOid+" still exists"); + } catch (ObjectNotFoundException e) { + // This is OK + } + } + + protected AssignmentType getUserAssignment(String userOid, String roleOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + return getAssignment(getUser(userOid), roleOid); + } + + protected AssignmentType getUserAssignment(String userOid, String roleOid, QName relation) + throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + PrismObject user = getUser(userOid); + List assignments = user.asObjectable().getAssignment(); + for (AssignmentType assignment: assignments) { + ObjectReferenceType targetRef = assignment.getTargetRef(); + if (targetRef != null && roleOid.equals(targetRef.getOid()) && prismContext.relationMatches(relation, + targetRef.getRelation())) { + return assignment; + } + } + return null; + } + + protected AssignmentType getAssignment(PrismObject focus, String roleOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + List assignments = focus.asObjectable().getAssignment(); + for (AssignmentType assignment: assignments) { + ObjectReferenceType targetRef = assignment.getTargetRef(); + if (targetRef != null && roleOid.equals(targetRef.getOid())) { + return assignment; + } + } + return null; + } + + protected ItemPath getAssignmentPath(long id) { + return ItemPath.create(FocusType.F_ASSIGNMENT, id); + } + + protected void assertNoAssignments(PrismObject user) { + MidPointAsserts.assertNoAssignments(user); + } + + protected void assertNoAssignments(String userOid, OperationResult result) throws ObjectNotFoundException, SchemaException { + PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); + assertNoAssignments(user); + } + + protected void assertNoAssignments(String userOid) throws ObjectNotFoundException, SchemaException { + OperationResult result = new OperationResult(AbstractModelIntegrationTest.class.getName() + ".assertNoShadow"); + assertNoAssignments(userOid, result); + } + + protected AssignmentType assertAssignedRole(String userOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { + PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); + return assertAssignedRole(user, roleOid); + } + + protected AssignmentType assertAssignedRole(PrismObject focus, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { + return assertAssignedRole(focus, roleOid); + } + + protected AssignmentType assertAssignedRole(PrismObject user, String roleOid) { + return MidPointAsserts.assertAssignedRole(user, roleOid); + } + + protected static void assertAssignedRoles(PrismObject user, String... roleOids) { + MidPointAsserts.assertAssignedRoles(user, roleOids); + } + + protected static void assertAssignedRoles(PrismObject user, Collection roleOids) { + MidPointAsserts.assertAssignedRoles(user, roleOids); + } + + protected AssignmentType assertInducedRole(PrismObject role, String roleOid) { + return MidPointAsserts.assertInducedRole(role, roleOid); + } + + protected void assignDeputy(String userDeputyOid, String userTargetOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + assignDeputy(userDeputyOid, userTargetOid, null, task, result); + } + + protected void assignDeputy(String userDeputyOid, String userTargetOid, Consumer modificationBlock, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userDeputyOid, userTargetOid, UserType.COMPLEX_TYPE, SchemaConstants.ORG_DEPUTY, task, modificationBlock, true, result); + } + + protected void unassignDeputy(String userDeputyOid, String userTargetOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + unassignDeputy(userDeputyOid, userTargetOid, null, task, result); + } + + protected void unassignDeputy(String userDeputyOid, String userTargetOid, Consumer modificationBlock, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userDeputyOid, userTargetOid, UserType.COMPLEX_TYPE, SchemaConstants.ORG_DEPUTY, task, modificationBlock, false, result); + } + + protected void assignDeputyLimits(String userDeputyOid, String userTargetOid, Task task, OperationResult result, ObjectReferenceType... limitTargets) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + modifyDeputyAssignmentLimits(userDeputyOid, userTargetOid, true, null, task, result, limitTargets); + } + + protected void assignDeputyLimits(String userDeputyOid, String userTargetOid, Consumer assignmentMutator, Task task, OperationResult result, ObjectReferenceType... limitTargets) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + modifyDeputyAssignmentLimits(userDeputyOid, userTargetOid, true, assignmentMutator, task, result, limitTargets); + } + + protected void unassignDeputyLimits(String userDeputyOid, String userTargetOid, Task task, OperationResult result, ObjectReferenceType... limitTargets) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + modifyDeputyAssignmentLimits(userDeputyOid, userTargetOid, false, null, task, result, limitTargets); + } + + protected void unassignDeputyLimits(String userDeputyOid, String userTargetOid, Consumer assignmentMutator, Task task, OperationResult result, ObjectReferenceType... limitTargets) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + modifyDeputyAssignmentLimits(userDeputyOid, userTargetOid, false, assignmentMutator, task, result, limitTargets); + } + + protected void modifyDeputyAssignmentLimits(String userDeputyOid, String userTargetOid, boolean add, Consumer assignmentMutator, Task task, OperationResult result, ObjectReferenceType... limitTargets) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userDeputyOid, userTargetOid, UserType.COMPLEX_TYPE, SchemaConstants.ORG_DEPUTY, task, + assignment -> { + AssignmentSelectorType limitTargetContent = new AssignmentSelectorType(); + assignment.setLimitTargetContent(limitTargetContent); + for (ObjectReferenceType limitTarget: limitTargets) { + limitTargetContent.getTargetRef().add(limitTarget); + } + if (assignmentMutator != null) { + assignmentMutator.accept(assignment); + } + }, add, result); + } + + protected void assertAssignedDeputy(PrismObject focus, String targetUserOid) { + MidPointAsserts.assertAssigned(focus, targetUserOid, UserType.COMPLEX_TYPE, SchemaConstants.ORG_DEPUTY); + } + + protected static void assertAssignedOrgs(PrismObject user, String... orgOids) { + MidPointAsserts.assertAssignedOrgs(user, orgOids); + } + + protected void assertObjectRefs(String contextDesc, Collection real, ObjectType... expected) { + assertObjectRefs(contextDesc, real, objectsToOids(expected)); + } + + protected void assertPrismRefValues(String contextDesc, Collection real, ObjectType... expected) { + assertPrismRefValues(contextDesc, real, objectsToOids(expected)); + } + + protected void assertPrismRefValues(String contextDesc, Collection real, Collection expected) { + assertPrismRefValues(contextDesc, real, objectsToOids(expected)); + } + + protected void assertObjectRefs(String contextDesc, Collection real, String... expected) { + assertObjectRefs(contextDesc, true, real, expected); + } + + protected void assertObjectRefs(String contextDesc, boolean checkNames, Collection real, String... expected) { + List refOids = new ArrayList<>(); + for (ObjectReferenceType ref: real) { + refOids.add(ref.getOid()); + assertNotNull("Missing type in "+ref.getOid()+" in "+contextDesc, ref.getType()); + if (checkNames) { + assertNotNull("Missing name in " + ref.getOid() + " in " + contextDesc, ref.getTargetName()); + } + } + PrismAsserts.assertSets("Wrong values in "+contextDesc, refOids, expected); + } + + protected void assertPrismRefValues(String contextDesc, Collection real, String... expected) { + List refOids = new ArrayList<>(); + for (PrismReferenceValue ref: real) { + refOids.add(ref.getOid()); + assertNotNull("Missing type in "+ref.getOid()+" in "+contextDesc, ref.getTargetType()); + assertNotNull("Missing name in "+ref.getOid()+" in "+contextDesc, ref.getTargetName()); + } + PrismAsserts.assertSets("Wrong values in "+contextDesc, refOids, expected); + } + + private String[] objectsToOids(ObjectType[] objects) { + return Arrays.stream(objects) + .map(o -> o.getOid()) + .toArray(String[]::new); + } + + private String[] objectsToOids(Collection objects) { + return objects.stream() + .map(o -> o.getOid()) + .toArray(String[]::new); + } + + protected void assertDelegatedRef(PrismObject focus, String... oids) { + List refOids = new ArrayList<>(); + for (ObjectReferenceType ref: focus.asObjectable().getDelegatedRef()) { + refOids.add(ref.getOid()); + assertNotNull("Missing type in delegatedRef "+ref.getOid()+" in "+focus, ref.getType()); + } + PrismAsserts.assertSets("Wrong values in delegatedRef in "+focus, refOids, oids); + } + + protected void assertNotAssignedRole(PrismObject focus, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { + MidPointAsserts.assertNotAssignedRole(focus, roleOid); + } + + protected void assertNotAssignedRole(String userOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { + PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); + MidPointAsserts.assertNotAssignedRole(user, roleOid); + } + + protected void assertNotAssignedResource(String userOid, String resourceOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { + PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); + MidPointAsserts.assertNotAssignedResource(user, resourceOid); + } + + protected void assertAssignedResource(Class type, String userOid, String resourceOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { + PrismObject focus = repositoryService.getObject(type, userOid, null, result); + MidPointAsserts.assertAssignedResource(focus, resourceOid); + } + + protected void assertNotAssignedRole(PrismObject user, String roleOid) { + MidPointAsserts.assertNotAssignedRole(user, roleOid); + } + + protected void assertNotAssignedOrg(PrismObject user, String orgOid, QName relation) { + MidPointAsserts.assertNotAssignedOrg(user, orgOid, relation); + } + + protected void assertAssignedOrg(String userOid, String orgOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { + PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); + assertAssignedOrg(user, orgOid); + } + + protected void assertAssignedOrg(PrismObject focus, String orgOid, QName relation) { + MidPointAsserts.assertAssignedOrg(focus, orgOid, relation); + } + + protected AssignmentType assertAssignedOrg(PrismObject focus, String orgOid) { + return MidPointAsserts.assertAssignedOrg(focus, orgOid); + } + + protected void assertNotAssignedOrg(PrismObject focus, String orgOid) { + MidPointAsserts.assertNotAssignedOrg(focus, orgOid); + } + + protected AssignmentType assertAssignedOrg(PrismObject user, PrismObject org) { + return MidPointAsserts.assertAssignedOrg(user, org.getOid()); + } + + protected void assertHasOrg(String userOid, String orgOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { + PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); + assertAssignedOrg(user, orgOid); + } + + protected void assertHasOrgs(PrismObject user, String... orgOids) throws Exception { + for (String orgOid: orgOids) { + assertHasOrg(user, orgOid); + } + assertHasOrgs(user, orgOids.length); + } + + protected void assertHasOrg(PrismObject focus, String orgOid) { + MidPointAsserts.assertHasOrg(focus, orgOid); + } + + protected void assertHasOrg(PrismObject user, String orgOid, QName relation) { + MidPointAsserts.assertHasOrg(user, orgOid, relation); + } + + protected void assertHasNoOrg(PrismObject user, String orgOid) { + MidPointAsserts.assertHasNoOrg(user, orgOid, null); + } + + protected void assertHasNoOrg(PrismObject user, String orgOid, QName relation) { + MidPointAsserts.assertHasNoOrg(user, orgOid, relation); + } + + protected void assertHasNoOrg(PrismObject user) { + MidPointAsserts.assertHasNoOrg(user); + } + + protected void assertHasOrgs(PrismObject user, int expectedNumber) { + MidPointAsserts.assertHasOrgs(user, expectedNumber); + } + + protected void assertHasArchetypes(PrismObject object, String... oids) { + for (String oid : oids) { + assertHasArchetype(object, oid); + } + assertHasArchetypes(object, oids.length); + } + + protected void assertHasArchetypes(PrismObject object, int expectedNumber) { + MidPointAsserts.assertHasArchetypes(object, expectedNumber); + } + + protected void assertHasArchetype(PrismObject object, String oid) { + MidPointAsserts.assertHasArchetype(object, oid); + } + + protected void assertSubOrgs(String baseOrgOid, int expected) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".assertSubOrgs"); + OperationResult result = task.getResult(); + List> subOrgs = getSubOrgs(baseOrgOid, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + assertEquals("Unexpected number of suborgs of org "+baseOrgOid+", has suborgs "+subOrgs, expected, subOrgs.size()); + } + + protected void assertSubOrgs(PrismObject baseOrg, int expected) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".assertSubOrgs"); + OperationResult result = task.getResult(); + List> subOrgs = getSubOrgs(baseOrg.getOid(), task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + assertEquals("Unexpected number of suborgs of"+baseOrg+", has suborgs "+subOrgs, expected, subOrgs.size()); + } + + protected List> getSubOrgs(String baseOrgOid, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + ObjectQuery query = prismContext.queryFor(OrgType.class) + .isDirectChildOf(baseOrgOid) + .build(); + return modelService.searchObjects(OrgType.class, query, null, task, result); + } + + protected List> getSubOrgUsers(String baseOrgOid, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + ObjectQuery query = prismContext.queryFor(UserType.class) + .isDirectChildOf(baseOrgOid) + .build(); + return modelService.searchObjects(UserType.class, query, null, task, result); + } + + protected String dumpOrgTree(String topOrgOid) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + return dumpOrgTree(topOrgOid, false); + } + + protected String dumpOrgTree(String topOrgOid, boolean dumpUsers) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".assertSubOrgs"); + OperationResult result = task.getResult(); + PrismObject topOrg = modelService.getObject(OrgType.class, topOrgOid, null, task, result); + String dump = dumpOrgTree(topOrg, dumpUsers, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + return dump; + } + + protected String dumpOrgTree(PrismObject topOrg, boolean dumpUsers, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + StringBuilder sb = new StringBuilder(); + dumpOrg(sb, topOrg, 0); + sb.append("\n"); + dumpSubOrgs(sb, topOrg.getOid(), dumpUsers, 1, task, result); + return sb.toString(); + } + + private void dumpSubOrgs(StringBuilder sb, String baseOrgOid, boolean dumpUsers, int indent, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + List> subOrgs = getSubOrgs(baseOrgOid, task, result); + for (PrismObject suborg: subOrgs) { + dumpOrg(sb, suborg, indent); + if (dumpUsers) { + dumpOrgUsers(sb, suborg.getOid(), dumpUsers, indent + 1, task, result); + } + sb.append("\n"); + dumpSubOrgs(sb, suborg.getOid(), dumpUsers, indent + 1, task, result); + } + } + + private void dumpOrgUsers(StringBuilder sb, String baseOrgOid, boolean dumpUsers, int indent, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + List> subUsers = getSubOrgUsers(baseOrgOid, task, result); + for (PrismObject subuser: subUsers) { + sb.append("\n"); + DebugUtil.indentDebugDump(sb, indent); + sb.append(subuser); + } + } + + private void dumpOrg(StringBuilder sb, PrismObject org, int indent) { + DebugUtil.indentDebugDump(sb, indent); + sb.append(org); + List linkRefs = org.asObjectable().getLinkRef(); + sb.append(": ").append(linkRefs.size()).append(" links"); + } + + protected void displayUsers() throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".displayUsers"); + OperationResult result = task.getResult(); + ResultHandler handler = (user, parentResult) -> { + display("User", user); + return true; + }; + modelService.searchObjectsIterative(UserType.class, null, handler, null, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + } + + protected void dumpFocus(String message, PrismObject focus) throws ObjectNotFoundException, SchemaException { + OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName() + ".dumpFocus"); + StringBuilder sb = new StringBuilder(); + sb.append(focus.debugDump(0)); + sb.append("\nOrgs:"); + for (ObjectReferenceType parentOrgRef: focus.asObjectable().getParentOrgRef()) { + sb.append("\n"); + DebugUtil.indentDebugDump(sb, 1); + PrismObject org = repositoryService.getObject(OrgType.class, parentOrgRef.getOid(), null, result); + sb.append(org); + PolyStringType displayName = org.asObjectable().getDisplayName(); + if (displayName != null) { + sb.append(": ").append(displayName); + } + } + sb.append("\nProjections:"); + for (ObjectReferenceType linkRef: focus.asObjectable().getLinkRef()) { + PrismObject shadow = repositoryService.getObject(ShadowType.class, linkRef.getOid(), null, result); + ObjectReferenceType resourceRef = shadow.asObjectable().getResourceRef(); + PrismObject resource = repositoryService.getObject(ResourceType.class, resourceRef.getOid(), null, result); + sb.append("\n"); + DebugUtil.indentDebugDump(sb, 1); + sb.append(resource); + sb.append("/"); + sb.append(shadow.asObjectable().getKind()); + sb.append("/"); + sb.append(shadow.asObjectable().getIntent()); + sb.append(": "); + sb.append(shadow.asObjectable().getName()); + } + sb.append("\nAssignments:"); + for (AssignmentType assignmentType: focus.asObjectable().getAssignment()) { + sb.append("\n"); + DebugUtil.indentDebugDump(sb, 1); + if (assignmentType.getConstruction() != null) { + sb.append("Constr(").append(assignmentType.getConstruction().getDescription()).append(") "); + } + if (assignmentType.getTargetRef() != null) { + sb.append("-["); + if (assignmentType.getTargetRef().getRelation() != null) { + sb.append(assignmentType.getTargetRef().getRelation().getLocalPart()); + } + sb.append("]-> "); + Class targetClass = ObjectTypes.getObjectTypeFromTypeQName(assignmentType.getTargetRef().getType()).getClassDefinition(); + PrismObject target = repositoryService.getObject(targetClass, assignmentType.getTargetRef().getOid(), null, result); + sb.append(target); + } + } + display(message, sb.toString()); + } + + protected void assertAssignments(PrismObject user, int expectedNumber) { + MidPointAsserts.assertAssignments(user, expectedNumber); + } + + protected void assertInducements(PrismObject role, int expectedNumber) { + MidPointAsserts.assertInducements(role, expectedNumber); + } + + protected void assertInducedRoles(PrismObject role, String... roleOids) { + assertInducements(role, roleOids.length); + for (String roleOid : roleOids) { + assertInducedRole(role, roleOid); + } + } + + protected void assertAssignments(PrismObject user, Class expectedType, int expectedNumber) { + MidPointAsserts.assertAssignments(user, expectedType, expectedNumber); + } + + protected void assertAssigned(PrismObject user, String targetOid, QName refType) { + MidPointAsserts.assertAssigned(user, targetOid, refType); + } + + protected void assertAssignedNoOrg(String userOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { + PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); + assertAssignedNoOrg(user); + } + + protected void assertAssignedNoOrg(PrismObject user) { + assertAssignedNo(user, OrgType.COMPLEX_TYPE); + } + + protected void assertAssignedNoRole(PrismObject focus, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { + assertAssignedNoRole(focus); + } + + protected void assertAssignedNoRole(String userOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { + PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); + assertAssignedNoRole(user); + } + + protected void assertAssignedNoRole(PrismObject user) { + assertAssignedNo(user, RoleType.COMPLEX_TYPE); + } + + protected void assertAssignedNo(PrismObject user, QName refType) { + F userType = user.asObjectable(); + for (AssignmentType assignmentType: userType.getAssignment()) { + ObjectReferenceType targetRef = assignmentType.getTargetRef(); + if (targetRef != null) { + if (refType.equals(targetRef.getType())) { + AssertJUnit.fail(user+" has role "+targetRef.getOid()+" while expected no roles"); + } + } + } + } + + protected void assertAssignedAccount(String userOid, String resourceOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { + PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); + assertAssignedAccount(user, resourceOid); + } + + protected AssignmentType assertAssignedAccount(PrismObject user, String resourceOid) throws ObjectNotFoundException, SchemaException { + UserType userType = user.asObjectable(); + for (AssignmentType assignmentType: userType.getAssignment()) { + ConstructionType construction = assignmentType.getConstruction(); + if (construction != null) { + if (construction.getKind() != null && construction.getKind() != ShadowKindType.ACCOUNT) { + continue; + } + if (resourceOid.equals(construction.getResourceRef().getOid())) { + return assignmentType; + } + } + } + AssertJUnit.fail(user.toString() + " does not have account assignment for resource " + resourceOid); + return null; // not reached + } + + protected void assertAssignedNoAccount(PrismObject user, String resourceOid) throws ObjectNotFoundException, SchemaException { + UserType userType = user.asObjectable(); + for (AssignmentType assignmentType: userType.getAssignment()) { + ConstructionType construction = assignmentType.getConstruction(); + if (construction != null) { + if (construction.getKind() != null && construction.getKind() != ShadowKindType.ACCOUNT) { + continue; + } + if (resourceOid.equals(construction.getResourceRef().getOid())) { + AssertJUnit.fail(user.toString()+" has account assignment for resource "+resourceOid+" while expecting no such assignment"); + } + } + } + } + + protected PrismObjectDefinition getRoleDefinition() { + return prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(RoleType.class); + } + + protected PrismObjectDefinition getShadowDefinition() { + return prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(ShadowType.class); + } + + protected PrismContainerDefinition getAssignmentDefinition() { + return prismContext.getSchemaRegistry().findContainerDefinitionByType(AssignmentType.COMPLEX_TYPE); + } + + protected PrismContainerDefinition getAssignmentExtensionDefinition() { + PrismContainerDefinition assignmentDefinition = getAssignmentDefinition(); + return assignmentDefinition.findContainerDefinition(AssignmentType.F_EXTENSION); + } + + protected PrismContainer getAssignmentExtensionInstance() throws SchemaException { + return getAssignmentExtensionDefinition().instantiate(); + } + + protected PrismObjectDefinition getResourceDefinition() { + return prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(ResourceType.class); + } + + protected PrismObjectDefinition getAccountShadowDefinition() { + return prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(ShadowType.class); + } + + + protected PrismObject createObject(Class type, String name) throws SchemaException { + PrismObject object = getObjectDefinition(type).instantiate(); + object.asObjectable().setName(createPolyStringType(name)); + return object; + } + + protected PrismObject createUser(String name, String fullName) throws SchemaException { + return createUser(name, fullName, null); + } + + protected PrismObject createUser(String name, String fullName, Boolean enabled) throws SchemaException { + PrismObject user = createObject(UserType.class, name); + UserType userType = user.asObjectable(); + userType.setFullName(createPolyStringType(fullName)); + if (enabled != null) { + ActivationType activation = new ActivationType(); + userType.setActivation(activation); + if (enabled) { + activation.setAdministrativeStatus(ActivationStatusType.ENABLED); + } else { + activation.setAdministrativeStatus(ActivationStatusType.DISABLED); + } + } + return user; + } + + protected PrismObject createUser(String name, String givenName, String familyName, Boolean enabled) throws SchemaException { + PrismObject user = getUserDefinition().instantiate(); + UserType userType = user.asObjectable(); + userType.setName(createPolyStringType(name)); + userType.setGivenName(createPolyStringType(givenName)); + userType.setFamilyName(createPolyStringType(familyName)); + userType.setFullName(createPolyStringType(givenName + " " + familyName)); + if (enabled != null) { + ActivationType activation = new ActivationType(); + userType.setActivation(activation); + if (enabled) { + activation.setAdministrativeStatus(ActivationStatusType.ENABLED); + } else { + activation.setAdministrativeStatus(ActivationStatusType.DISABLED); + } + } + return user; + } + + protected void fillinUser(PrismObject user, String name, String fullName) { + user.asObjectable().setName(createPolyStringType(name)); + user.asObjectable().setFullName(createPolyStringType(fullName)); + } + + protected void fillinUserAssignmentAccountConstruction(PrismObject user, String resourceOid) { + AssignmentType assignmentType = new AssignmentType(); + ConstructionType accountConstruntion = new ConstructionType(); + ObjectReferenceType resourceRef = new ObjectReferenceType(); + resourceRef.setOid(resourceOid); + resourceRef.setType(ResourceType.COMPLEX_TYPE); + accountConstruntion.setResourceRef(resourceRef); + accountConstruntion.setKind(ShadowKindType.ACCOUNT); + assignmentType.setConstruction(accountConstruntion); + user.asObjectable().getAssignment().add(assignmentType); + } + + protected PrismObject createAccount(PrismObject resource, String name, boolean enabled) throws SchemaException { + PrismObject shadow = getShadowDefinition().instantiate(); + ShadowType shadowType = shadow.asObjectable(); + ObjectReferenceType resourceRef = new ObjectReferenceType(); + resourceRef.setOid(resource.getOid()); + shadowType.setResourceRef(resourceRef); + RefinedResourceSchema refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource); + RefinedObjectClassDefinition objectClassDefinition = refinedSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT); + shadowType.setObjectClass(objectClassDefinition.getTypeName()); + shadowType.setKind(ShadowKindType.ACCOUNT); + ResourceAttributeContainer attrCont = ShadowUtil.getOrCreateAttributesContainer(shadow, objectClassDefinition); + RefinedAttributeDefinition idSecondaryDef = objectClassDefinition.getSecondaryIdentifiers().iterator().next(); + ResourceAttribute icfsNameAttr = idSecondaryDef.instantiate(); + icfsNameAttr.setRealValue(name); + attrCont.add(icfsNameAttr); + ActivationType activation = new ActivationType(); + shadowType.setActivation(activation); + if (enabled) { + activation.setAdministrativeStatus(ActivationStatusType.ENABLED); + } else { + activation.setAdministrativeStatus(ActivationStatusType.DISABLED); + } + return shadow; + } + + protected void addAttributeToShadow(PrismObject shadow, PrismObject resource, String attrName, T attrValue) throws SchemaException { + ResourceAttributeContainer attrs = ShadowUtil.getAttributesContainer(shadow); + ResourceAttributeDefinition attrSnDef = attrs.getDefinition().findAttributeDefinition( + new ItemName(ResourceTypeUtil.getResourceNamespace(resource), attrName)); + ResourceAttribute attr = attrSnDef.instantiate(); + attr.setRealValue(attrValue); + attrs.add(attr); + } + + protected void setDefaultUserTemplate(String userTemplateOid) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { + setDefaultObjectTemplate(UserType.COMPLEX_TYPE, userTemplateOid); + } + + protected void setDefaultObjectTemplate(QName objectType, String userTemplateOid) + throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { + OperationResult result = new OperationResult(AbstractModelIntegrationTest.class.getName()+".setDefaultObjectTemplate"); + setDefaultObjectTemplate(objectType, userTemplateOid, result); + result.computeStatus(); + TestUtil.assertSuccess("Applying default object template failed (result)", result); + } + + + protected void setDefaultObjectTemplate(QName objectType, String objectTemplateOid, OperationResult parentResult) + throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { + setDefaultObjectTemplate(objectType, null, objectTemplateOid, parentResult); + } + + protected void setDefaultObjectTemplate(QName objectType, String subType, String objectTemplateOid, OperationResult parentResult) + throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { + + PrismObject systemConfig = repositoryService.getObject(SystemConfigurationType.class, + SystemObjectsType.SYSTEM_CONFIGURATION.value(), null, parentResult); + + PrismContainerValue oldValue = null; + for (ObjectPolicyConfigurationType focusPolicyType: systemConfig.asObjectable().getDefaultObjectPolicyConfiguration()) { + if (QNameUtil.match(objectType, focusPolicyType.getType()) && MiscUtil.equals(subType, focusPolicyType.getSubtype())) { + oldValue = focusPolicyType.asPrismContainerValue(); + } + } + Collection modifications = new ArrayList<>(); + + if (oldValue != null) { + ObjectPolicyConfigurationType oldPolicy = oldValue.asContainerable(); + ObjectReferenceType oldObjectTemplateRef = oldPolicy.getObjectTemplateRef(); + if (oldObjectTemplateRef != null) { + if (oldObjectTemplateRef.getOid().equals(objectTemplateOid)) { + // Already set + return; + } + } + ContainerDelta deleteDelta = prismContext.deltaFactory().container().createModificationDelete(SystemConfigurationType.F_DEFAULT_OBJECT_POLICY_CONFIGURATION, + SystemConfigurationType.class, oldValue.clone()); + ((Collection)modifications).add(deleteDelta); + } + + if (objectTemplateOid != null) { + ObjectPolicyConfigurationType newFocusPolicyType; + ContainerDelta addDelta; + if (oldValue == null) { + newFocusPolicyType = new ObjectPolicyConfigurationType(); + newFocusPolicyType.setType(objectType); + newFocusPolicyType.setSubtype(subType); + addDelta = prismContext.deltaFactory().container().createModificationAdd(SystemConfigurationType.F_DEFAULT_OBJECT_POLICY_CONFIGURATION, + SystemConfigurationType.class, newFocusPolicyType); + } else { + PrismContainerValue newValue = oldValue.cloneComplex(CloneStrategy.REUSE); + addDelta = prismContext.deltaFactory().container().createModificationAdd(SystemConfigurationType.F_DEFAULT_OBJECT_POLICY_CONFIGURATION, + SystemConfigurationType.class, newValue); + newFocusPolicyType = newValue.asContainerable(); + } + ObjectReferenceType templateRef = new ObjectReferenceType(); + templateRef.setOid(objectTemplateOid); + newFocusPolicyType.setObjectTemplateRef(templateRef); + ((Collection)modifications).add(addDelta); + } + + modifySystemObjectInRepo(SystemConfigurationType.class, + SystemObjectsType.SYSTEM_CONFIGURATION.value(), modifications, parentResult); + + } + + protected void setConflictResolution(QName objectType, String subType, ConflictResolutionType conflictResolution, OperationResult parentResult) + throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { + + PrismObject systemConfig = repositoryService.getObject(SystemConfigurationType.class, + SystemObjectsType.SYSTEM_CONFIGURATION.value(), null, parentResult); + + PrismContainerValue oldValue = null; + for (ObjectPolicyConfigurationType focusPolicyType: systemConfig.asObjectable().getDefaultObjectPolicyConfiguration()) { + if (QNameUtil.match(objectType, focusPolicyType.getType()) && MiscUtil.equals(subType, focusPolicyType.getSubtype())) { + oldValue = focusPolicyType.asPrismContainerValue(); + } + } + Collection modifications = new ArrayList<>(); + + if (oldValue != null) { + ContainerDelta deleteDelta = prismContext.deltaFactory().container().createModificationDelete(SystemConfigurationType.F_DEFAULT_OBJECT_POLICY_CONFIGURATION, + SystemConfigurationType.class, oldValue.clone()); + ((Collection)modifications).add(deleteDelta); + } + + ObjectPolicyConfigurationType newFocusPolicyType = new ObjectPolicyConfigurationType(); + newFocusPolicyType.setType(objectType); + newFocusPolicyType.setSubtype(subType); + if (oldValue != null) { + ObjectReferenceType oldObjectTemplateRef = oldValue.asContainerable().getObjectTemplateRef(); + if (oldObjectTemplateRef != null) { + newFocusPolicyType.setObjectTemplateRef(oldObjectTemplateRef.clone()); + } + } + + newFocusPolicyType.setConflictResolution(conflictResolution); + + ContainerDelta addDelta = prismContext.deltaFactory().container() + .createModificationAdd(SystemConfigurationType.F_DEFAULT_OBJECT_POLICY_CONFIGURATION, + SystemConfigurationType.class, newFocusPolicyType); + + ((Collection)modifications).add(addDelta); + + modifySystemObjectInRepo(SystemConfigurationType.class, + SystemObjectsType.SYSTEM_CONFIGURATION.value(), modifications, parentResult); + + } + + protected void setConflictResolutionAction(QName objectType, String subType, ConflictResolutionActionType conflictResolutionAction, OperationResult parentResult) + throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { + ConflictResolutionType conflictResolutionType = new ConflictResolutionType(); + conflictResolutionType.action(conflictResolutionAction); + setConflictResolution(objectType, subType, conflictResolutionType, parentResult); + } + + protected void setGlobalSecurityPolicy(String securityPolicyOid, OperationResult parentResult) + throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { + + Collection modifications = new ArrayList<>(); + + ReferenceDelta refDelta = prismContext.deltaFactory().reference().createModificationReplace(SystemConfigurationType.F_GLOBAL_SECURITY_POLICY_REF, + SystemConfigurationType.class, securityPolicyOid); + modifications.add(refDelta); + + modifySystemObjectInRepo(SystemConfigurationType.class, + SystemObjectsType.SYSTEM_CONFIGURATION.value(), modifications, parentResult); + + } + + protected void modifySystemObjectInRepo(Class type, String oid, Collection modifications, OperationResult parentResult) + throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { + display("Modifications of system object "+oid, modifications); + repositoryService.modifyObject(type, oid, modifications, parentResult); + invalidateSystemObjectsCache(); + } + + @Override + protected void invalidateSystemObjectsCache() { + systemObjectCache.invalidateCaches(); + } + + protected ItemPath getIcfsNameAttributePath() { + return ItemPath.create( + ShadowType.F_ATTRIBUTES, + SchemaTestConstants.ICFS_NAME); + + } + + protected void assertResolvedResourceRefs(ModelContext context) { + for (ModelProjectionContext projectionContext: context.getProjectionContexts()) { + assertResolvedResourceRefs(projectionContext.getObjectOld(), "objectOld in "+projectionContext); + assertResolvedResourceRefs(projectionContext.getObjectNew(), "objectNew in "+projectionContext); + assertResolvedResourceRefs(projectionContext.getPrimaryDelta(), "primaryDelta in "+projectionContext); + assertResolvedResourceRefs(projectionContext.getSecondaryDelta(), "secondaryDelta in "+projectionContext); + } + } + + private void assertResolvedResourceRefs(ObjectDelta delta, String desc) { + if (delta == null) { + return; + } + if (delta.isAdd()) { + assertResolvedResourceRefs(delta.getObjectToAdd(), desc); + } else if (delta.isModify()) { + ReferenceDelta referenceDelta = delta.findReferenceModification(ShadowType.F_RESOURCE_REF); + if (referenceDelta != null) { + assertResolvedResourceRefs(referenceDelta.getValuesToAdd(), "valuesToAdd in "+desc); + assertResolvedResourceRefs(referenceDelta.getValuesToDelete(), "valuesToDelete in "+desc); + assertResolvedResourceRefs(referenceDelta.getValuesToReplace(), "valuesToReplace in "+desc); + } + } + } + + private void assertResolvedResourceRefs(PrismObject shadow, String desc) { + if (shadow == null) { + return; + } + PrismReference resourceRef = shadow.findReference(ShadowType.F_RESOURCE_REF); + if (resourceRef == null) { + AssertJUnit.fail("No resourceRef in "+desc); + } + assertResolvedResourceRefs(resourceRef.getValues(), desc); + } + + private void assertResolvedResourceRefs(Collection values, String desc) { + if (values == null) { + return; + } + for (PrismReferenceValue pval: values) { + assertNotNull("resourceRef in "+desc+" does not contain object", pval.getObject()); + } + } + + /** + * Breaks user assignment delta in the context by inserting some empty value. This may interfere with comparing the values to + * existing user values. + */ + protected void breakAssignmentDelta(Collection> deltas) throws SchemaException { + breakAssignmentDelta((ObjectDelta)deltas.iterator().next()); + } + + /** + * Breaks user assignment delta in the context by inserting some empty value. This may interfere with comparing the values to + * existing user values. + */ + protected void breakAssignmentDelta(ObjectDelta userDelta) throws SchemaException { + ContainerDelta assignmentDelta = userDelta.findContainerDelta(UserType.F_ASSIGNMENT); + PrismContainerValue assignmentDeltaValue = null; + if (assignmentDelta.getValuesToAdd() != null) { + assignmentDeltaValue = assignmentDelta.getValuesToAdd().iterator().next(); + } + if (assignmentDelta.getValuesToDelete() != null) { + assignmentDeltaValue = assignmentDelta.getValuesToDelete().iterator().next(); + } + PrismContainer activationContainer = assignmentDeltaValue.findOrCreateContainer(AssignmentType.F_ACTIVATION); + PrismContainerValue emptyValue = prismContext.itemFactory().createContainerValue(); + activationContainer.add(emptyValue); + } + + + protected void purgeResourceSchema(String resourceOid) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".purgeResourceSchema"); + OperationResult result = task.getResult(); + + ObjectDelta resourceDelta = prismContext.deltaFactory().object().createModificationReplaceContainer(ResourceType.class, + resourceOid, ResourceType.F_SCHEMA, new PrismContainerValue[0]); + Collection> deltas = MiscSchemaUtil.createCollection(resourceDelta); + + modelService.executeChanges(deltas, null, task, result); + + result.computeStatus(); + TestUtil.assertSuccess(result); + } + + protected List> searchOrg(String baseOrgOid, OrgFilter.Scope scope, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + ObjectQuery query = prismContext.queryFor(OrgType.class) + .isInScopeOf(baseOrgOid, scope) + .build(); + return modelService.searchObjects(OrgType.class, query, null, task, result); + } + + protected PrismObject searchObjectByName(Class type, String name) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".searchObjectByName"); + OperationResult result = task.getResult(); + PrismObject out = searchObjectByName(type, name, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + return out; + } + + protected PrismObject searchObjectByName(Class type, String name, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + ObjectQuery query = ObjectQueryUtil.createNameQuery(name, prismContext); + List> foundObjects = modelService.searchObjects(type, query, null, task, result); + if (foundObjects.isEmpty()) { + return null; + } + if (foundObjects.size() > 1) { + throw new IllegalStateException("More than one object found for type "+type+" and name '"+name+"'"); + } + return foundObjects.iterator().next(); + } + + protected void assertAccountShadowModel(PrismObject accountShadow, String oid, String username, ResourceType resourceType) throws SchemaException { + assertShadowModel(accountShadow, oid, username, resourceType, getAccountObjectClass(resourceType), null); + } + + protected void assertAccountShadowModel(PrismObject accountShadow, String oid, String username, ResourceType resourceType, MatchingRule matchingRule) throws SchemaException { + assertShadowModel(accountShadow, oid, username, resourceType, getAccountObjectClass(resourceType), matchingRule); + } + + protected void assertShadowModel(PrismObject accountShadow, String oid, String username, ResourceType resourceType, + QName objectClass) throws SchemaException { + assertShadowModel(accountShadow, oid, username, resourceType, objectClass, null); + } + + protected void assertShadowModel(PrismObject accountShadow, String oid, String username, ResourceType resourceType, + QName objectClass, MatchingRule nameMatchingRule) throws SchemaException { + assertShadowCommon(accountShadow, oid, username, resourceType, objectClass, nameMatchingRule, false); + IntegrationTestTools.assertProvisioningShadow(accountShadow, resourceType, RefinedAttributeDefinition.class, objectClass); + } + + protected ObjectDelta createModifyUserAddDummyAccount(String userOid, String dummyResourceName) throws SchemaException { + return createModifyUserAddAccount(userOid, getDummyResourceObject(dummyResourceName)); + } + + protected ObjectDelta createModifyUserAddAccount(String userOid, PrismObject resource) throws SchemaException { + return createModifyUserAddAccount(userOid, resource, null); + } + + protected ObjectDelta createModifyUserAddAccount(String userOid, PrismObject resource, String intent) throws SchemaException { + PrismObject account = getAccountShadowDefinition().instantiate(); + ObjectReferenceType resourceRef = new ObjectReferenceType(); + resourceRef.setOid(resource.getOid()); + account.asObjectable().setResourceRef(resourceRef); + RefinedResourceSchema refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource); + RefinedObjectClassDefinition rocd = null; + if (StringUtils.isNotBlank(intent)) { + rocd = refinedSchema.getRefinedDefinition(ShadowKindType.ACCOUNT, intent); + account.asObjectable().setIntent(intent); + } else { + rocd = refinedSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT); + } + account.asObjectable().setObjectClass(rocd.getObjectClassDefinition().getTypeName()); + account.asObjectable().setKind(ShadowKindType.ACCOUNT); + + + ObjectDelta userDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, userOid + ); + PrismReferenceValue accountRefVal = itemFactory().createReferenceValue(); + accountRefVal.setObject(account); + ReferenceDelta accountDelta = prismContext.deltaFactory().reference().createModificationAdd(UserType.F_LINK_REF, getUserDefinition(), accountRefVal); + userDelta.addModification(accountDelta); + + return userDelta; + } + + protected ObjectDelta createModifyUserDeleteDummyAccount(String userOid, String dummyResourceName) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + return createModifyUserDeleteAccount(userOid, getDummyResourceObject(dummyResourceName)); + } + + protected ObjectDelta createModifyUserDeleteAccount(String userOid, PrismObject resource) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + return createModifyUserDeleteAccount(userOid, resource.getOid()); + } + + protected ObjectDelta createModifyUserDeleteAccount(String userOid, String resourceOid) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + String accountOid = getLinkRefOid(userOid, resourceOid); + PrismObject account = getShadowModel(accountOid); + + ObjectDelta userDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, userOid + ); + PrismReferenceValue accountRefVal = itemFactory().createReferenceValue(); + accountRefVal.setObject(account); + ReferenceDelta accountDelta = prismContext.deltaFactory().reference().createModificationDelete(UserType.F_LINK_REF, getUserDefinition(), accountRefVal); + userDelta.addModification(accountDelta); + + return userDelta; + } + + protected ObjectDelta createModifyUserUnlinkAccount(String userOid, PrismObject resource) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + String accountOid = getLinkRefOid(userOid, resource.getOid()); + + ObjectDelta userDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, userOid + ); + PrismReferenceValue accountRefVal = itemFactory().createReferenceValue(); + accountRefVal.setOid(accountOid); + ReferenceDelta accountDelta = prismContext.deltaFactory().reference().createModificationDelete(UserType.F_LINK_REF, getUserDefinition(), accountRefVal); + userDelta.addModification(accountDelta); + + return userDelta; + } + + protected void deleteUserAccount(String userOid, String resourceOid, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + ObjectDelta userDelta = createModifyUserDeleteAccount(userOid, resourceOid); + executeChanges(userDelta, null, task, result); + } + + + // TASKS + + protected void waitForTaskFinish(Task task, boolean checkSubresult) throws Exception { + waitForTaskFinish(task, checkSubresult, DEFAULT_TASK_WAIT_TIMEOUT); + } + + protected void waitForTaskFinish(Task task, boolean checkSubresult, final int timeout) throws Exception { + waitForTaskFinish(task, checkSubresult, timeout, DEFAULT_TASK_SLEEP_TIME); + } + + protected void waitForTaskFinish(final Task task, final boolean checkSubresult, final int timeout, long sleepTime) throws Exception { + final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForTaskFinish"); + Checker checker = new Checker() { + @Override + public boolean check() throws CommonException { + task.refresh(waitResult); + waitResult.summarize(); +// Task freshTask = taskManager.getTaskWithResult(task.getOid(), waitResult); + OperationResult result = task.getResult(); + if (verbose) display("Check result", result); + assert !isError(result, checkSubresult) : "Error in "+task+": "+TestUtil.getErrorMessage(result); + assert !isUnknown(result, checkSubresult) : "Unknown result in "+task+": "+TestUtil.getErrorMessage(result); + return !isInProgress(result, checkSubresult); + } + @Override + public void timeout() { + try { + task.refresh(waitResult); + } catch (ObjectNotFoundException e) { + LOGGER.error("Exception during task refresh: {}", e,e); + } catch (SchemaException e) { + LOGGER.error("Exception during task refresh: {}", e,e); + } + OperationResult result = task.getResult(); + LOGGER.debug("Result of timed-out task:\n{}", result.debugDump()); + assert false : "Timeout ("+timeout+") while waiting for "+task+" to finish. Last result "+result; + } + }; + IntegrationTestTools.waitFor("Waiting for " + task + " finish", checker, timeout, sleepTime); + } + + protected void waitForTaskCloseOrSuspend(String taskOid) throws Exception { + waitForTaskCloseOrSuspend(taskOid, DEFAULT_TASK_WAIT_TIMEOUT); + } + + protected void waitForTaskCloseOrSuspend(String taskOid, final int timeout) throws Exception { + waitForTaskCloseOrSuspend(taskOid, timeout, DEFAULT_TASK_SLEEP_TIME); + } + + protected void waitForTaskCloseOrSuspend(final String taskOid, final int timeout, long sleepTime) throws Exception { + final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForTaskCloseOrSuspend"); + Checker checker = new Checker() { + @Override + public boolean check() throws CommonException { + Task task = taskManager.getTaskWithResult(taskOid, waitResult); + waitResult.summarize(); + display("Task execution status = " + task.getExecutionStatus()); + return task.getExecutionStatus() == TaskExecutionStatus.CLOSED + || task.getExecutionStatus() == TaskExecutionStatus.SUSPENDED; + } + @Override + public void timeout() { + Task task = null; + try { + task = taskManager.getTaskWithResult(taskOid, waitResult); + } catch (ObjectNotFoundException|SchemaException e) { + LOGGER.error("Exception during task refresh: {}", e,e); + } + OperationResult result = null; + if (task != null) { + result = task.getResult(); + LOGGER.debug("Result of timed-out task:\n{}", result.debugDump()); + } + assert false : "Timeout ("+timeout+") while waiting for "+taskOid+" to close or suspend. Last result "+result; + } + }; + IntegrationTestTools.waitFor("Waiting for " + taskOid + " close/suspend", checker, timeout, sleepTime); + } + + protected Task waitForTaskFinish(String taskOid, boolean checkSubresult) throws CommonException { + return waitForTaskFinish(taskOid, checkSubresult, DEFAULT_TASK_WAIT_TIMEOUT); + } + + protected Task waitForTaskFinish(String taskOid, boolean checkSubresult, Function customizer) throws CommonException { + return waitForTaskFinish(taskOid, checkSubresult, 0, DEFAULT_TASK_WAIT_TIMEOUT, false, 0, customizer); + } + + protected Task waitForTaskFinish(final String taskOid, final boolean checkSubresult, final int timeout) throws CommonException { + return waitForTaskFinish(taskOid, checkSubresult, timeout, false); + } + + protected Task waitForTaskFinish(final String taskOid, final boolean checkSubresult, final int timeout, final boolean errorOk) throws CommonException { + return waitForTaskFinish(taskOid, checkSubresult, 0, timeout, errorOk); + } + + protected Task waitForTaskFinish(final String taskOid, final boolean checkSubresult, long startTime, final int timeout, final boolean errorOk) throws CommonException { + return waitForTaskFinish(taskOid, checkSubresult, startTime, timeout, errorOk, 0, null); + } + + protected Task waitForTaskFinish(String taskOid, boolean checkSubresult, long startTime, int timeout, boolean errorOk, + int showProgressEach, Function customizer) throws CommonException { + long realStartTime = startTime != 0 ? startTime : System.currentTimeMillis(); + final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForTaskFinish"); + TaskFinishChecker.Builder builder = new TaskFinishChecker.Builder() + .taskManager(taskManager) + .taskOid(taskOid) + .waitResult(waitResult) + .checkSubresult(checkSubresult) + .errorOk(errorOk) + .timeout(timeout) + .showProgressEach(showProgressEach) + .verbose(verbose); + if (customizer != null) { + builder = customizer.apply(builder); + } + TaskFinishChecker checker = builder.build(); + IntegrationTestTools.waitFor("Waiting for task " + taskOid + " finish", checker, realStartTime, timeout, DEFAULT_TASK_SLEEP_TIME); + return checker.getLastTask(); + } + + protected void dumpTaskTree(String oid, OperationResult result) + throws ObjectNotFoundException, + SchemaException { + Collection> options = schemaHelper.getOperationOptionsBuilder() + .item(TaskType.F_SUBTASK).retrieve() + .build(); + PrismObject task = taskManager.getObject(TaskType.class, oid, options, result); + dumpTaskAndSubtasks(task.asObjectable(), 0); + } + + protected void dumpTaskAndSubtasks(TaskType task, int level) throws SchemaException { + String xml = prismContext.xmlSerializer().serialize(task.asPrismObject()); + display("Task (level " + level + ")", xml); + for (TaskType subtask : TaskTypeUtil.getResolvedSubtasks(task)) { + dumpTaskAndSubtasks(subtask, level + 1); + } + } + + protected long getRunDurationMillis(String taskReconOpendjOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + return getTaskRunDurationMillis(getTask(taskReconOpendjOid).asObjectable()); + } + + protected long getTaskRunDurationMillis(TaskType taskType) { + long duration = XmlTypeConverter.toMillis(taskType.getLastRunFinishTimestamp()) + - XmlTypeConverter.toMillis(taskType.getLastRunStartTimestamp()); + System.out.println("Duration for " + taskType.getName() + " is " + duration); + return duration; + } + + protected long getTreeRunDurationMillis(String rootTaskOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + PrismObject rootTask = getTaskTree(rootTaskOid); + return TaskTypeUtil.getAllTasksStream(rootTask.asObjectable()) + .mapToLong(this::getTaskRunDurationMillis) + .max().orElse(0); + } + + protected void displayOperationStatistics(String label, OperationStatsType statistics) { + display(label, StatisticsUtil.format(statistics)); + } + + @Nullable + protected OperationStatsType getTaskTreeOperationStatistics(String rootTaskOid) + throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, + ConfigurationException, ExpressionEvaluationException { + PrismObject rootTask = getTaskTree(rootTaskOid); + return TaskTypeUtil.getAllTasksStream(rootTask.asObjectable()) + .map(t -> t.getOperationStats()) + .reduce(StatisticsUtil::sum) + .orElse(null); + } + + protected List getSubcases(String parentCaseOid, Collection> options, + OperationResult result) throws SchemaException { + return asObjectableList( + repositoryService.searchObjects(CaseType.class, + prismContext.queryFor(CaseType.class).item(CaseType.F_PARENT_REF).ref(parentCaseOid).build(), + options, result)); + } + + protected void deleteCaseTree(String rootCaseOid, OperationResult result) throws SchemaException, ObjectNotFoundException { + List subcases = getSubcases(rootCaseOid, null, result); + for (CaseType subcase : subcases) { + deleteCaseTree(subcase.getOid(), result); + } + repositoryService.deleteObject(CaseType.class, rootCaseOid, result); + } + + protected void displayTaskWithOperationStats(String message, PrismObject task) throws SchemaException { + display(message, task); + String stats = prismContext.xmlSerializer() + .serializeRealValue(task.asObjectable().getOperationStats(), TaskType.F_OPERATION_STATS); + display(message + ": Operational stats", stats); + } + + protected void displayTaskWithOperationStats(String message, Task task) throws SchemaException { + display(message, task); + String stats = prismContext.xmlSerializer() + .serializeRealValue(task.getUpdatedOrClonedTaskObject().asObjectable().getOperationStats(), TaskType.F_OPERATION_STATS); + display(message + ": Operational stats", stats); + } + + protected void assertJpegPhoto(Class clazz, String oid, byte[] expectedValue, OperationResult result) + throws SchemaException, ObjectNotFoundException { + PrismObject object = repositoryService + .getObject(clazz, oid, schemaHelper.getOperationOptionsBuilder().retrieve().build(), result); + byte[] actualValue = object.asObjectable().getJpegPhoto(); + if (expectedValue == null) { + if (actualValue != null) { + fail("Photo present even if it should not be: " + Arrays.toString(actualValue)); + } + } else { + assertNotNull("No photo", actualValue); + if (!Arrays.equals(actualValue, expectedValue)) { + fail("Photo is different than expected.\nExpected = " + Arrays.toString(expectedValue) + + "\nActual value = " + Arrays.toString(actualValue)); + } + } + } + + protected void waitForTaskStart(String taskOid, boolean checkSubresult) throws Exception { + waitForTaskStart(taskOid, checkSubresult, DEFAULT_TASK_WAIT_TIMEOUT); + } + + protected void waitForTaskStart(final String taskOid, final boolean checkSubresult, final int timeout) throws Exception { + final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForTaskStart"); + Checker checker = new Checker() { + @Override + public boolean check() throws CommonException { + Task freshTask = taskManager.getTaskWithResult(taskOid, waitResult); + OperationResult result = freshTask.getResult(); + if (verbose) display("Check result", result); + assert !isError(result, checkSubresult) : "Error in "+freshTask+": "+TestUtil.getErrorMessage(result); + if (isUnknown(result, checkSubresult)) { + return false; + } + return freshTask.getLastRunStartTimestamp() != null; + } + @Override + public void timeout() { + try { + Task freshTask = taskManager.getTaskWithResult(taskOid, waitResult); + OperationResult result = freshTask.getResult(); + LOGGER.debug("Result of timed-out task:\n{}", result.debugDump()); + assert false : "Timeout ("+timeout+") while waiting for "+freshTask+" to start. Last result "+result; + } catch (ObjectNotFoundException | SchemaException e) { + LOGGER.error("Exception during task refresh: {}", e, e); + } + } + }; + IntegrationTestTools.waitFor("Waiting for task " + taskOid + " start", checker, timeout, DEFAULT_TASK_SLEEP_TIME); + } + + protected void waitForTaskNextStart(String taskOid, boolean checkSubresult, int timeout, boolean kickTheTask) throws Exception { + OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForTaskNextStart"); + Task origTask = taskManager.getTaskWithResult(taskOid, waitResult); + Long origLastRunStartTimestamp = origTask.getLastRunStartTimestamp(); + if (kickTheTask) { + taskManager.scheduleTaskNow(origTask, waitResult); + } + Checker checker = new Checker() { + @Override + public boolean check() throws CommonException { + Task freshTask = taskManager.getTaskWithResult(taskOid, waitResult); + OperationResult result = freshTask.getResult(); + if (verbose) display("Check result", result); + assert !isError(result, checkSubresult) : "Error in "+freshTask+": "+TestUtil.getErrorMessage(result); + return !isUnknown(result, checkSubresult) && + !java.util.Objects.equals(freshTask.getLastRunStartTimestamp(), origLastRunStartTimestamp); + } + @Override + public void timeout() { + try { + Task freshTask = taskManager.getTaskWithResult(taskOid, waitResult); + OperationResult result = freshTask.getResult(); + LOGGER.debug("Result of timed-out task:\n{}", result.debugDump()); + assert false : "Timeout ("+timeout+") while waiting for "+freshTask+" to start. Last result "+result; + } catch (ObjectNotFoundException | SchemaException e) { + LOGGER.error("Exception during task refresh: {}", e, e); + } + } + }; + IntegrationTestTools.waitFor("Waiting for task " + taskOid + " next start", checker, timeout, DEFAULT_TASK_SLEEP_TIME); + } + + protected OperationResult waitForTaskNextRunAssertSuccess(String taskOid, boolean checkSubresult) throws Exception { + return waitForTaskNextRunAssertSuccess(taskOid, checkSubresult, DEFAULT_TASK_WAIT_TIMEOUT); + } + + protected OperationResult waitForTaskNextRunAssertSuccess(Task origTask, boolean checkSubresult) throws Exception { + return waitForTaskNextRunAssertSuccess(origTask, checkSubresult, DEFAULT_TASK_WAIT_TIMEOUT); + } + + protected OperationResult waitForTaskNextRunAssertSuccess(final String taskOid, final boolean checkSubresult, final int timeout) throws Exception { + OperationResult taskResult = waitForTaskNextRun(taskOid, checkSubresult, timeout); + if (isError(taskResult, checkSubresult)) { + assert false : "Error in task "+taskOid+": "+TestUtil.getErrorMessage(taskResult)+"\n\n"+taskResult.debugDump(); + } + return taskResult; + } + + protected OperationResult waitForTaskNextRunAssertSuccess(Task origTask, final boolean checkSubresult, final int timeout) throws Exception { + OperationResult taskResult = waitForTaskNextRun(origTask, checkSubresult, timeout); + if (isError(taskResult, checkSubresult)) { + assert false : "Error in task "+origTask+": "+TestUtil.getErrorMessage(taskResult)+"\n\n"+taskResult.debugDump(); + } + return taskResult; + } + + protected OperationResult waitForTaskNextRun(final String taskOid) throws Exception { + return waitForTaskNextRun(taskOid, false, DEFAULT_TASK_WAIT_TIMEOUT, false); + } + + protected OperationResult waitForTaskNextRun(final String taskOid, final boolean checkSubresult, final int timeout) throws Exception { + return waitForTaskNextRun(taskOid, checkSubresult, timeout, false); + } + + protected OperationResult waitForTaskNextRun(final String taskOid, final boolean checkSubresult, final int timeout, boolean kickTheTask) throws Exception { + final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForTaskNextRun"); + Task origTask = taskManager.getTaskWithResult(taskOid, waitResult); + return waitForTaskNextRun(origTask, checkSubresult, timeout, waitResult, kickTheTask); + } + + protected OperationResult waitForTaskNextRun(final Task origTask, final boolean checkSubresult, final int timeout) throws Exception { + return waitForTaskNextRun(origTask, checkSubresult, timeout, false); + } + + protected OperationResult waitForTaskNextRun(final Task origTask, final boolean checkSubresult, final int timeout, boolean kickTheTask) throws Exception { + final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForTaskNextRun"); + return waitForTaskNextRun(origTask, checkSubresult, timeout, waitResult, kickTheTask); + } + + protected OperationResult waitForTaskNextRun(final Task origTask, final boolean checkSubresult, final int timeout, final OperationResult waitResult, boolean kickTheTask) throws Exception { + final Long origLastRunStartTimestamp = origTask.getLastRunStartTimestamp(); + final Long origLastRunFinishTimestamp = origTask.getLastRunFinishTimestamp(); + if (kickTheTask) { + taskManager.scheduleTaskNow(origTask, waitResult); + } + final Holder taskResultHolder = new Holder<>(); + Checker checker = new Checker() { + @Override + public boolean check() throws CommonException { + Task freshTask = taskManager.getTaskWithResult(origTask.getOid(), waitResult); + OperationResult taskResult = freshTask.getResult(); +// display("Times", longTimeToString(origLastRunStartTimestamp) + "-" + longTimeToString(origLastRunStartTimestamp) +// + " : " + longTimeToString(freshTask.getLastRunStartTimestamp()) + "-" + longTimeToString(freshTask.getLastRunFinishTimestamp())); + if (verbose) display("Check result", taskResult); + taskResultHolder.setValue(taskResult); + if (isError(taskResult, checkSubresult)) { + return true; + } + if (isUnknown(taskResult, checkSubresult)) { + return false; + } + if (freshTask.getLastRunFinishTimestamp() == null) { + return false; + } + if (freshTask.getLastRunStartTimestamp() == null) { + return false; + } + return !freshTask.getLastRunStartTimestamp().equals(origLastRunStartTimestamp) + && !freshTask.getLastRunFinishTimestamp().equals(origLastRunFinishTimestamp) + && freshTask.getLastRunStartTimestamp() < freshTask.getLastRunFinishTimestamp(); + } + @Override + public void timeout() { + try { + Task freshTask = taskManager.getTaskWithResult(origTask.getOid(), waitResult); + OperationResult result = freshTask.getResult(); + LOGGER.debug("Timed-out task:\n{}", freshTask.debugDump()); + display("Times", "origLastRunStartTimestamp="+longTimeToString(origLastRunStartTimestamp) + + ", origLastRunFinishTimestamp=" + longTimeToString(origLastRunFinishTimestamp) + + ", freshTask.getLastRunStartTimestamp()=" + longTimeToString(freshTask.getLastRunStartTimestamp()) + + ", freshTask.getLastRunFinishTimestamp()=" + longTimeToString(freshTask.getLastRunFinishTimestamp())); + assert false : "Timeout ("+timeout+") while waiting for "+freshTask+" next run. Last result "+result; + } catch (ObjectNotFoundException | SchemaException e) { + LOGGER.error("Exception during task refresh: {}", e, e); + } + } + }; + IntegrationTestTools.waitFor("Waiting for task " + origTask + " next run", checker, timeout, DEFAULT_TASK_SLEEP_TIME); + + Task freshTask = taskManager.getTaskWithResult(origTask.getOid(), waitResult); + LOGGER.debug("Final task:\n{}", freshTask.debugDump()); + display("Times", "origLastRunStartTimestamp="+longTimeToString(origLastRunStartTimestamp) + + ", origLastRunFinishTimestamp=" + longTimeToString(origLastRunFinishTimestamp) + + ", freshTask.getLastRunStartTimestamp()=" + longTimeToString(freshTask.getLastRunStartTimestamp()) + + ", freshTask.getLastRunFinishTimestamp()=" + longTimeToString(freshTask.getLastRunFinishTimestamp())); + + return taskResultHolder.getValue(); + } + + protected OperationResult waitForTaskTreeNextFinishedRun(String rootTaskOid, int timeout) throws Exception { + final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForTaskTreeNextFinishedRun"); + Task origRootTask = taskManager.getTaskWithResult(rootTaskOid, waitResult); + return waitForTaskTreeNextFinishedRun(origRootTask, timeout, waitResult); + } + + // a bit experimental + protected OperationResult waitForTaskTreeNextFinishedRun(Task origRootTask, int timeout, OperationResult waitResult) throws Exception { + Long origLastRunStartTimestamp = origRootTask.getLastRunStartTimestamp(); + Long origLastRunFinishTimestamp = origRootTask.getLastRunFinishTimestamp(); + long start = System.currentTimeMillis(); + Holder triggered = new Holder<>(false); // to avoid repeated checking for start-finish timestamps + OperationResult aggregateResult = new OperationResult("aggregate"); + Checker checker = () -> { + Task freshRootTask = taskManager.getTaskWithResult(origRootTask.getOid(), waitResult); + + String s = TaskDebugUtil.dumpTaskTree(freshRootTask, waitResult); + display("task tree", s); + + long waiting = (System.currentTimeMillis() - start) / 1000; + String description = + freshRootTask.getName().getOrig() + " [es:" + freshRootTask.getExecutionStatus() + ", rs:" + + freshRootTask.getResultStatus() + ", p:" + freshRootTask.getProgress() + ", n:" + + freshRootTask.getNode() + "] (waiting for: " + waiting + ")"; + // was the whole task tree refreshed at least once after we were called? + if (!triggered.getValue() && (freshRootTask.getLastRunStartTimestamp() == null + || freshRootTask.getLastRunStartTimestamp().equals(origLastRunStartTimestamp) + || freshRootTask.getLastRunFinishTimestamp() == null + || freshRootTask.getLastRunFinishTimestamp().equals(origLastRunFinishTimestamp) + || freshRootTask.getLastRunStartTimestamp() >= freshRootTask.getLastRunFinishTimestamp())) { + display("Root (triggering) task next run has not been completed yet: " + description); + return false; + } + triggered.setValue(true); + + aggregateResult.getSubresults().clear(); + List subtasks = freshRootTask.listSubtasksDeeply(waitResult); + for (Task subtask : subtasks) { + try { + subtask.refresh(waitResult); // quick hack to get operation results + } catch (ObjectNotFoundException e) { + LOGGER.warn("Task {} does not exist any more", subtask); + } + } + Task failedTask = null; + for (Task subtask : subtasks) { + if (subtask.getExecutionStatus() == TaskExecutionStatus.RUNNABLE) { + display("Found runnable/running subtasks during waiting => continuing waiting: " + description, subtask); + return false; + } + if (subtask.getExecutionStatus() == TaskExecutionStatus.WAITING) { + display("Found waiting subtasks during waiting => continuing waiting: " + description, subtask); + return false; + } + OperationResult subtaskResult = subtask.getResult(); + if (subtaskResult == null) { + display("No subtask operation result during waiting => continuing waiting: " + description, subtask); + return false; + } + if (subtaskResult.getStatus() == OperationResultStatus.IN_PROGRESS) { + display("Found 'in_progress' subtask operation result during waiting => continuing waiting: " + description, subtask); + return false; + } + if (subtaskResult.getStatus() == OperationResultStatus.UNKNOWN) { + display("Found 'unknown' subtask operation result during waiting => continuing waiting: " + description, subtask); + return false; + } + aggregateResult.addSubresult(subtaskResult); + if (subtaskResult.isError()) { + failedTask = subtask; + } + } + if (failedTask != null) { + display("Found 'error' subtask operation result during waiting => done waiting: " + description, failedTask); + return true; + } + if (freshRootTask.getExecutionStatus() == TaskExecutionStatus.WAITING) { + display("Found WAITING root task during wait for next finished run => continuing waiting: " + description); + return false; + } + return true; // all executive subtasks are closed + }; + IntegrationTestTools.waitFor("Waiting for task tree " + origRootTask + " next finished run", checker, timeout, DEFAULT_TASK_SLEEP_TIME); + + Task freshTask = taskManager.getTaskWithResult(origRootTask.getOid(), waitResult); + LOGGER.debug("Final root task:\n{}", freshTask.debugDump()); + aggregateResult.computeStatusIfUnknown(); + return aggregateResult; + } + + public void waitForCaseClose(CaseType aCase) throws Exception { + waitForCaseClose(aCase, 60000); + } + + public void waitForCaseClose(CaseType aCase, final int timeout) throws Exception { + final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForCaseClose"); + Checker checker = new Checker() { + @Override + public boolean check() throws CommonException { + CaseType currentCase = repositoryService.getObject(CaseType.class, aCase.getOid(), null, waitResult).asObjectable(); + if (verbose) AbstractIntegrationTest.display("Case", currentCase); + return SchemaConstants.CASE_STATE_CLOSED.equals(currentCase.getState()); + } + @Override + public void timeout() { + PrismObject currentCase; + try { + currentCase = repositoryService.getObject(CaseType.class, aCase.getOid(), null, waitResult); + } catch (ObjectNotFoundException | SchemaException e) { + throw new AssertionError("Couldn't retrieve case " + aCase, e); + } + LOGGER.debug("Timed-out case:\n{}", currentCase.debugDump()); + assert false : "Timeout ("+timeout+") while waiting for "+currentCase+" to finish"; + } + }; + IntegrationTestTools.waitFor("Waiting for "+aCase+" finish", checker, timeout, 1000); + } + + + private String longTimeToString(Long longTime) { + if (longTime == null) { + return "null"; + } + return longTime.toString(); + } + + public static boolean isError(OperationResult result, boolean checkSubresult) { + OperationResult subresult = getSubresult(result, checkSubresult); + return subresult != null && subresult.isError(); + } + + public static boolean isUnknown(OperationResult result, boolean checkSubresult) { + OperationResult subresult = getSubresult(result, checkSubresult); + return subresult != null && subresult.isUnknown(); // TODO or return true if null? + } + + public static boolean isInProgress(OperationResult result, boolean checkSubresult) { + OperationResult subresult = getSubresult(result, checkSubresult); + return subresult == null || subresult.isInProgress(); // "true" if there are no subresults + } + + private static OperationResult getSubresult(OperationResult result, boolean checkSubresult) { + if (checkSubresult) { + return result != null ? result.getLastSubresult() : null; + } + return result; + } + + protected OperationResult waitForTaskResume(final String taskOid, final boolean checkSubresult, final int timeout) throws Exception { + final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForTaskResume"); + Task origTask = taskManager.getTaskWithResult(taskOid, waitResult); + + final Long origLastRunStartTimestamp = origTask.getLastRunStartTimestamp(); + final Long origLastRunFinishTimestamp = origTask.getLastRunFinishTimestamp(); + + taskManager.resumeTask(origTask, waitResult); + + final Holder taskResultHolder = new Holder<>(); + Checker checker = new Checker() { + @Override + public boolean check() throws CommonException { + Task freshTask = taskManager.getTaskWithResult(origTask.getOid(), waitResult); + OperationResult taskResult = freshTask.getResult(); +// display("Times", longTimeToString(origLastRunStartTimestamp) + "-" + longTimeToString(origLastRunStartTimestamp) +// + " : " + longTimeToString(freshTask.getLastRunStartTimestamp()) + "-" + longTimeToString(freshTask.getLastRunFinishTimestamp())); + if (verbose) display("Check result", taskResult); + taskResultHolder.setValue(taskResult); + if (isError(taskResult, checkSubresult)) { + return true; + } + if (isUnknown(taskResult, checkSubresult)) { + return false; + } + if (freshTask.getLastRunFinishTimestamp() == null) { + return false; + } + if (freshTask.getLastRunStartTimestamp() == null) { + return false; + } + return !freshTask.getLastRunStartTimestamp().equals(origLastRunStartTimestamp) + && !freshTask.getLastRunFinishTimestamp().equals(origLastRunFinishTimestamp) + && freshTask.getLastRunStartTimestamp() < freshTask.getLastRunFinishTimestamp(); + } + @Override + public void timeout() { + try { + Task freshTask = taskManager.getTaskWithResult(origTask.getOid(), waitResult); + OperationResult result = freshTask.getResult(); + LOGGER.debug("Timed-out task:\n{}", freshTask.debugDump()); + display("Times", "origLastRunStartTimestamp="+longTimeToString(origLastRunStartTimestamp) + + ", origLastRunFinishTimestamp=" + longTimeToString(origLastRunFinishTimestamp) + + ", freshTask.getLastRunStartTimestamp()=" + longTimeToString(freshTask.getLastRunStartTimestamp()) + + ", freshTask.getLastRunFinishTimestamp()=" + longTimeToString(freshTask.getLastRunFinishTimestamp())); + assert false : "Timeout ("+timeout+") while waiting for "+freshTask+" next run. Last result "+result; + } catch (ObjectNotFoundException | SchemaException e) { + LOGGER.error("Exception during task refresh: {}", e, e); + } + } + }; + IntegrationTestTools.waitFor("Waiting for task " + origTask + " resume", checker, timeout, DEFAULT_TASK_SLEEP_TIME); + + Task freshTask = taskManager.getTaskWithResult(origTask.getOid(), waitResult); + LOGGER.debug("Final task:\n{}", freshTask.debugDump()); + display("Times", "origLastRunStartTimestamp="+longTimeToString(origLastRunStartTimestamp) + + ", origLastRunFinishTimestamp=" + longTimeToString(origLastRunFinishTimestamp) + + ", freshTask.getLastRunStartTimestamp()=" + longTimeToString(freshTask.getLastRunStartTimestamp()) + + ", freshTask.getLastRunFinishTimestamp()=" + longTimeToString(freshTask.getLastRunFinishTimestamp())); + + return taskResultHolder.getValue(); + } + + protected void restartTask(String taskOid) throws CommonException { + + // Wait at least 1ms here. We have the timestamp in the tasks with a millisecond granularity. If the tasks is started, + // executed and then resstarted and excecuted within the same millisecond then the second execution will not be + // detected and the wait for task finish will time-out. So waiting one millisecond here will make sure that the + // timestamps are different. And 1ms is not that long to significantly affect test run times. + try { + Thread.sleep(1); + } catch (InterruptedException e) { + LOGGER.warn("Sleep interrupted: {}", e.getMessage(), e); + } + + OperationResult result = createSubresult("restartTask"); + try { + Task task = taskManager.getTaskWithResult(taskOid, result); + LOGGER.info("Restarting task {}", taskOid); + if (task.getExecutionStatus() == TaskExecutionStatus.SUSPENDED) { + LOGGER.debug("Task {} is suspended, resuming it", task); + taskManager.resumeTask(task, result); + } else if (task.getExecutionStatus() == TaskExecutionStatus.CLOSED) { + LOGGER.debug("Task {} is closed, scheduling it to run now", task); + taskManager.scheduleTasksNow(singleton(taskOid), result); + } else if (task.getExecutionStatus() == TaskExecutionStatus.RUNNABLE) { + if (taskManager.getLocallyRunningTaskByIdentifier(task.getTaskIdentifier()) != null) { + // Task is really executing. Let's wait until it finishes; hopefully it won't start again (TODO) + LOGGER.debug("Task {} is running, waiting while it finishes before restarting", task); + waitForTaskFinish(taskOid, false); + } + LOGGER.debug("Task {} is finished, scheduling it to run now", task); + taskManager.scheduleTasksNow(singleton(taskOid), result); + } else { + throw new IllegalStateException( + "Task " + task + " cannot be restarted, because its state is: " + task.getExecutionStatus()); + } + } catch (Throwable t) { + result.recordFatalError(t); + throw t; + } finally { + result.computeStatusIfUnknown(); + } + } + + protected boolean suspendTask(String taskOid) throws CommonException { + return suspendTask(taskOid, 3000); + } + + protected boolean suspendTask(String taskOid, int waitTime) throws CommonException { + final OperationResult result = new OperationResult(AbstractIntegrationTest.class+".suspendTask"); + Task task = taskManager.getTaskWithResult(taskOid, result); + LOGGER.info("Suspending task {}", taskOid); + return taskManager.suspendTaskQuietly(task, waitTime, result); + } + + /** + * Restarts task and waits for finish. + */ + protected void rerunTask(String taskOid) throws CommonException { + long startTime = System.currentTimeMillis(); + restartTask(taskOid); + waitForTaskFinish(taskOid, true, startTime, DEFAULT_TASK_WAIT_TIMEOUT, false); + } + + protected void assertTaskExecutionStatus(String taskOid, TaskExecutionStatus expectedExecutionStatus) throws ObjectNotFoundException, SchemaException { + final OperationResult result = new OperationResult(AbstractIntegrationTest.class+".assertTaskExecutionStatus"); + Task task = taskManager.getTask(taskOid, result); + assertEquals("Wrong executionStatus in "+task, expectedExecutionStatus, task.getExecutionStatus()); + } + + protected void setSecurityContextUser(String userOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = taskManager.createTaskInstance("get administrator"); + PrismObject object = modelService.getObject(UserType.class, userOid, null, task, task.getResult()); + + assertNotNull("User " + userOid + " is null", object.asObjectable()); + SecurityContextHolder.getContext().setAuthentication( + new UsernamePasswordAuthenticationToken( + new MidPointPrincipal(object.asObjectable()), null)); + } + + protected String getSecurityContextUserOid() { + return ((MidPointPrincipal) (SecurityContextHolder.getContext().getAuthentication().getPrincipal())).getOid(); + } + + protected void assertSideEffectiveDeltasOnly(String desc, ObjectDelta focusDelta) { + if (focusDelta == null) { + return; + } + int expectedModifications = 0; + // There may be metadata modification, we tolerate that + for (ItemDelta modification: focusDelta.getModifications()) { + if (isSideEffectDelta(modification)) { + expectedModifications++; + } + } + if (focusDelta.findItemDelta(PATH_ACTIVATION_ENABLE_TIMESTAMP) != null) { + expectedModifications++; + } + if (focusDelta.findItemDelta(PATH_ACTIVATION_DISABLE_TIMESTAMP) != null) { + expectedModifications++; + } + if (focusDelta.findItemDelta(PATH_ACTIVATION_ARCHIVE_TIMESTAMP) != null) { + expectedModifications++; + } + PropertyDelta effectiveStatusDelta = focusDelta.findPropertyDelta(PATH_ACTIVATION_EFFECTIVE_STATUS); + if (effectiveStatusDelta != null) { + expectedModifications++; + } + if (focusDelta.findItemDelta(FocusType.F_ITERATION) != null) { + expectedModifications++; + } + if (focusDelta.findItemDelta(FocusType.F_ROLE_MEMBERSHIP_REF) != null) { + expectedModifications++; + } + if (focusDelta.findItemDelta(FocusType.F_DELEGATED_REF) != null) { + expectedModifications++; + } + if (focusDelta.findItemDelta(FocusType.F_ITERATION_TOKEN) != null) { + expectedModifications++; + } + assertEquals("Unexpected modifications in " + desc + ": " + focusDelta, expectedModifications, focusDelta.getModifications().size()); + } + + protected void assertSideEffectiveDeltasOnly(ObjectDelta focusDelta, String desc, ActivationStatusType expectedEfficientActivation) { + assertEffectualDeltas(focusDelta, desc, expectedEfficientActivation, 0); + } + + protected void assertEffectualDeltas(ObjectDelta focusDelta, String desc, ActivationStatusType expectedEfficientActivation, int expectedEffectualModifications) { + if (focusDelta == null) { + return; + } + int expectedModifications = expectedEffectualModifications; + // There may be metadata modification, we tolerate that + for (ItemDelta modification: focusDelta.getModifications()) { + if (isSideEffectDelta(modification)) { + expectedModifications++; + } + } + if (focusDelta.findItemDelta(PATH_ACTIVATION_ENABLE_TIMESTAMP) != null) { + expectedModifications++; + } + if (focusDelta.findItemDelta(PATH_ACTIVATION_DISABLE_TIMESTAMP) != null) { + expectedModifications++; + } + if (focusDelta.findItemDelta(PATH_ACTIVATION_ARCHIVE_TIMESTAMP) != null) { + expectedModifications++; + } + PropertyDelta effectiveStatusDelta = focusDelta.findPropertyDelta(PATH_ACTIVATION_EFFECTIVE_STATUS); + if (effectiveStatusDelta != null) { + expectedModifications++; + PrismAsserts.assertReplace(effectiveStatusDelta, expectedEfficientActivation); + } + if (focusDelta.findItemDelta(FocusType.F_ROLE_MEMBERSHIP_REF) != null) { + expectedModifications++; + } + if (focusDelta.findItemDelta(FocusType.F_DELEGATED_REF) != null) { + expectedModifications++; + } + if (focusDelta.findItemDelta(FocusType.F_ITERATION) != null) { + expectedModifications++; + } + if (focusDelta.findItemDelta(FocusType.F_ITERATION_TOKEN) != null) { + expectedModifications++; + } + assertEquals("Unexpected modifications in "+desc+": "+focusDelta, expectedModifications, focusDelta.getModifications().size()); + } + + private boolean isSideEffectDelta(ItemDelta modification) { + if (modification.getPath().containsNameExactly(ObjectType.F_METADATA) || + (modification.getPath().containsNameExactly(FocusType.F_ASSIGNMENT) && modification.getPath().containsNameExactly(ActivationType.F_EFFECTIVE_STATUS))) { + return true; + } else if (modification.getPath().containsNameExactly(FocusType.F_ASSIGNMENT) && modification.getPath().containsNameExactly(AssignmentType.F_ACTIVATION) && modification.isReplace() && (modification instanceof ContainerDelta)) { + Collection> valuesToReplace = ((ContainerDelta)modification).getValuesToReplace(); + if (valuesToReplace != null && valuesToReplace.size() == 1) { + PrismContainerValue cval = valuesToReplace.iterator().next(); + if (cval.size() == 1) { + Item item = cval.getItems().iterator().next(); + return ActivationType.F_EFFECTIVE_STATUS.equals(item.getElementName()); + } + } + } + return false; + } + + protected void assertValidFrom(PrismObject obj, Date expectedDate) { + assertEquals("Wrong validFrom in "+obj, XmlTypeConverter.createXMLGregorianCalendar(expectedDate), + getActivation(obj).getValidFrom()); + } + + protected void assertValidTo(PrismObject obj, Date expectedDate) { + assertEquals("Wrong validTo in "+obj, XmlTypeConverter.createXMLGregorianCalendar(expectedDate), + getActivation(obj).getValidTo()); + } + + protected ActivationType getActivation(PrismObject obj) { + ObjectType objectType = obj.asObjectable(); + ActivationType activation; + if (objectType instanceof ShadowType) { + activation = ((ShadowType)objectType).getActivation(); + } else if (objectType instanceof UserType) { + activation = ((UserType)objectType).getActivation(); + } else { + throw new IllegalArgumentException("Cannot get activation from "+obj); + } + assertNotNull("No activation in " + obj, activation); + return activation; + } + + protected PrismObject getTask(String taskOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".getTask"); + OperationResult result = task.getResult(); + PrismObject retTask = modelService.getObject(TaskType.class, taskOid, retrieveItemsNamed(TaskType.F_RESULT), task, result); + result.computeStatus(); + TestUtil.assertSuccess("getObject(Task) result not success", result); + return retTask; + } + + protected PrismObject getTaskTree(String taskOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".getTask"); + OperationResult result = task.getResult(); + PrismObject retTask = modelService.getObject(TaskType.class, taskOid, retrieveItemsNamed(TaskType.F_RESULT, TaskType.F_SUBTASK), task, result); + result.computeStatus(); + TestUtil.assertSuccess("getObject(Task) result not success", result); + return retTask; + } + + protected CaseType getCase(String oid) throws ObjectNotFoundException, SchemaException { + return repositoryService.getObject(CaseType.class, oid, null, new OperationResult("dummy")).asObjectable(); + } + + protected void assertObjectExists(Class clazz, String oid) { + OperationResult result = new OperationResult("assertObjectExists"); + try { + repositoryService.getObject(clazz, oid, null, result); + } catch (ObjectNotFoundException e) { + fail("Object of type " + clazz.getName() + " with OID " + oid + " doesn't exist: " + e.getMessage()); + } catch (SchemaException e) { + throw new SystemException("Object of type " + clazz.getName() + " with OID " + oid + " probably exists but couldn't be read: " + e.getMessage(), e); + } + } + + protected void assertObjectDoesntExist(Class clazz, String oid) { + OperationResult result = new OperationResult("assertObjectDoesntExist"); + try { + PrismObject object = repositoryService.getObject(clazz, oid, null, result); + fail("Object of type " + clazz.getName() + " with OID " + oid + " exists even if it shouldn't: " + object.debugDump()); + } catch (ObjectNotFoundException e) { + // ok + } catch (SchemaException e) { + throw new SystemException("Object of type " + clazz.getName() + " with OID " + oid + " probably exists, and moreover it couldn't be read: " + e.getMessage(), e); + } + } + + protected PrismObject getObject(Class type, String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".getObject"); + OperationResult result = task.getResult(); + PrismObject object = modelService.getObject(type, oid, null, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + return object; + } + + protected PrismObject getObjectViaRepo(Class type, String oid) throws ObjectNotFoundException, SchemaException { + Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".getObject"); + OperationResult result = task.getResult(); + PrismObject object = repositoryService.getObject(type, oid, null, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + return object; + } + + protected void addObjects(File... files) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { + for (File file : files) { + addObject(file); + } + } + + protected void addObject(TestResource resource, Task task, OperationResult result) + throws IOException, ObjectNotFoundException, ConfigurationException, SecurityViolationException, + PolicyViolationException, ExpressionEvaluationException, ObjectAlreadyExistsException, CommunicationException, + SchemaException { + addObject(resource.file, task, result); + } + + protected PrismObject repoAddObject(TestResource resource, OperationResult result) + throws IOException, ObjectAlreadyExistsException, SchemaException, EncryptionException { + return repoAddObjectFromFile(resource.file, result); + } + + // not going through model to avoid conflicts (because the task starts execution during the clockwork operation) + protected void addTask(File file) throws SchemaException, IOException, ObjectAlreadyExistsException { + taskManager.addTask(prismContext.parseObject(file), new OperationResult("addTask")); + } + + protected void addObject(File file) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { + PrismObject object = prismContext.parseObject(file); + addObject(object); + } + + protected PrismObject addObject(File file, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { + return addObject(file, task, result, null); + } + + protected PrismObject addObject(File file, Task task, OperationResult result, Consumer> customizer) + throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, + CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { + PrismObject object = prismContext.parseObject(file); + if (customizer != null) { + customizer.accept(object); + } + addObject(object, task, result); + return object; + } + + protected String addObject(PrismObject object) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".addObject"); + OperationResult result = task.getResult(); + String oid = addObject(object, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + return oid; + } + + protected String addObject(PrismObject object, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + return addObject(object, null, task, result); + } + + protected String addObject(PrismObject object, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + ObjectDelta addDelta = object.createAddDelta(); + assertFalse("Immutable object provided?",addDelta.getObjectToAdd().isImmutable()); + Collection> executedDeltas = executeChanges(addDelta, options, task, result); + object.setOid(ObjectDeltaOperation.findAddDeltaOid(executedDeltas, object)); + return object.getOid(); + } + + protected void deleteObject(Class type, String oid, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + ObjectDelta delta = prismContext.deltaFactory().object().createDeleteDelta(type, oid); + executeChanges(delta, null, task, result); + } + + protected void deleteObjectRaw(Class type, String oid, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + ObjectDelta delta = prismContext.deltaFactory().object().createDeleteDelta(type, oid); + executeChanges(delta, ModelExecuteOptions.createRaw(), task, result); + } + + protected void deleteObject(Class type, String oid) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + Task task = createTask(AbstractModelIntegrationTest.class.getName() + ".deleteObject"); + OperationResult result = task.getResult(); + ObjectDelta delta = prismContext.deltaFactory().object().createDeleteDelta(type, oid); + executeChanges(delta, null, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + } + + protected void deleteObjectRepo(Class type, String oid) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + OperationResult result = new OperationResult(AbstractModelIntegrationTest.class.getName() + ".deleteObjectRepo"); + repositoryService.deleteObject(type, oid, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + } + + protected void forceDeleteShadow(String oid) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + Task task = createTask(AbstractModelIntegrationTest.class.getName() + ".forceDeleteShadow"); + OperationResult result = task.getResult(); + forceDeleteObject(ShadowType.class, oid, task, result); + assertSuccess(result); + } + + protected void forceDeleteShadow(String oid, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + forceDeleteObject(ShadowType.class, oid, task, result); + } + + protected void forceDeleteObject(Class type, String oid, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + ObjectDelta delta = prismContext.deltaFactory().object().createDeleteDelta(type, oid); + ModelExecuteOptions options = ModelExecuteOptions.createForce(); + executeChanges(delta, options, task, result); + } + + protected void addTrigger(String oid, XMLGregorianCalendar timestamp, String uri) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".addTrigger"); + OperationResult result = task.getResult(); + TriggerType triggerType = new TriggerType(); + triggerType.setTimestamp(timestamp); + triggerType.setHandlerUri(uri); + ObjectDelta delta = prismContext.deltaFactory().object() + .createModificationAddContainer(ObjectType.class, oid, ObjectType.F_TRIGGER, + triggerType); + executeChanges(delta, null, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + } + + protected void addTriggers(String oid, Collection timestamps, String uri, boolean makeDistinct) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".addTriggers"); + OperationResult result = task.getResult(); + Collection triggers = timestamps.stream() + .map(ts -> new TriggerType().timestamp(ts).handlerUri(uri)) + .map(ts -> makeDistinct ? addRandomValue(ts) : ts) + .collect(Collectors.toList()); + ObjectDelta delta = prismContext.deltaFor(ObjectType.class) + .item(ObjectType.F_TRIGGER).addRealValues(triggers) + .asObjectDeltaCast(oid); + executeChanges(delta, null, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + } + + private TriggerType addRandomValue(TriggerType trigger) { + //noinspection unchecked + @NotNull PrismPropertyDefinition workItemIdDef = + prismContext.getSchemaRegistry().findPropertyDefinitionByElementName(SchemaConstants.MODEL_EXTENSION_WORK_ITEM_ID); + PrismProperty workItemIdProp = workItemIdDef.instantiate(); + workItemIdProp.addRealValue((long) (Math.random() * 100000000000L)); + try { + //noinspection unchecked + trigger.asPrismContainerValue().findOrCreateContainer(TriggerType.F_EXTENSION).add(workItemIdProp); + } catch (SchemaException e) { + throw new AssertionError(e); + } + return trigger; + } + + protected void replaceTriggers(String oid, Collection timestamps, String uri) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".replaceTriggers"); + OperationResult result = task.getResult(); + Collection triggers = timestamps.stream() + .map(ts -> new TriggerType().timestamp(ts).handlerUri(uri)) + .collect(Collectors.toList()); + ObjectDelta delta = prismContext.deltaFor(ObjectType.class) + .item(ObjectType.F_TRIGGER).replaceRealValues(triggers) + .asObjectDeltaCast(oid); + executeChanges(delta, null, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + } + + protected void assertTrigger(PrismObject object, String handlerUri, XMLGregorianCalendar start, XMLGregorianCalendar end) throws ObjectNotFoundException, SchemaException { + for (TriggerType trigger: object.asObjectable().getTrigger()) { + if (handlerUri.equals(trigger.getHandlerUri()) + && MiscUtil.isBetween(trigger.getTimestamp(), start, end)) { + return; + } + } + AssertJUnit.fail("Expected that " + object + " will have a trigger but it has not"); + } + + protected void assertTrigger(PrismObject object, String handlerUri, XMLGregorianCalendar mid, long tolerance) throws ObjectNotFoundException, SchemaException { + XMLGregorianCalendar start = XmlTypeConverter.addMillis(mid, -tolerance); + XMLGregorianCalendar end = XmlTypeConverter.addMillis(mid, tolerance); + for (TriggerType trigger: object.asObjectable().getTrigger()) { + if (handlerUri.equals(trigger.getHandlerUri()) + && MiscUtil.isBetween(trigger.getTimestamp(), start, end)) { + return; + } + } + AssertJUnit.fail("Expected that "+object+" will have a trigger but it has not"); + } + + protected void assertNoTrigger(Class type, String oid) throws ObjectNotFoundException, SchemaException { + OperationResult result = new OperationResult(AbstractModelIntegrationTest.class.getName() + ".assertNoTrigger"); + PrismObject object = repositoryService.getObject(type, oid, null, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + assertNoTrigger(object); + } + + protected void assertNoTrigger(PrismObject object) throws ObjectNotFoundException, SchemaException { + List triggers = object.asObjectable().getTrigger(); + if (triggers != null && !triggers.isEmpty()) { + AssertJUnit.fail("Expected that "+object+" will have no triggers but it has "+triggers.size()+ " trigger: "+ triggers); + } + } + + protected void prepareNotifications() { + notificationManager.setDisabled(false); + dummyTransport.clearMessages(); + } + + protected void checkDummyTransportMessages(String name, int expectedCount) { + List messages = dummyTransport.getMessages("dummy:" + name); + if (expectedCount == 0) { + if (messages != null && !messages.isEmpty()) { + LOGGER.error(messages.size() + " unexpected message(s) recorded in dummy transport '" + name + "'"); + logNotifyMessages(messages); + printNotifyMessages(messages); + fail(messages.size() + " unexpected message(s) recorded in dummy transport '" + name + "'"); + } + } else { + assertNotNull("No messages recorded in dummy transport '" + name + "'", messages); + if (expectedCount != messages.size()) { + LOGGER.error("Invalid number of messages recorded in dummy transport '" + name + "', expected: "+expectedCount+", actual: "+messages.size()); + logNotifyMessages(messages); + printNotifyMessages(messages); + assertEquals("Invalid number of messages recorded in dummy transport '" + name + "'", expectedCount, messages.size()); + } + } + } + + protected void assertSingleDummyTransportMessage(String name, String expectedBody) { + List messages = dummyTransport.getMessages("dummy:" + name); + assertNotNull("No messages recorded in dummy transport '" + name + "'", messages); + if (messages.size() != 1) { + fail("Invalid number of messages recorded in dummy transport '" + name + "', expected: 1, actual: "+messages.size()); + } + Message message = messages.get(0); + assertEquals("Unexpected notifier "+name+" message body", expectedBody, message.getBody()); + } + + protected void assertSingleDummyTransportMessageContaining(String name, String expectedSubstring) { + List messages = dummyTransport.getMessages("dummy:" + name); + assertNotNull("No messages recorded in dummy transport '" + name + "'", messages); + if (messages.size() != 1) { + fail("Invalid number of messages recorded in dummy transport '" + name + "', expected: 1, actual: "+messages.size()); + } + Message message = messages.get(0); + assertTrue("Notifier "+name+" message body does not contain text: " + expectedSubstring + ", it is:\n" + message.getBody(), + message.getBody().contains(expectedSubstring)); + } + + protected String getDummyTransportMessageBody(String name, int index) { + List messages = dummyTransport.getMessages("dummy:" + name); + Message message = messages.get(index); + return message.getBody(); + } + + protected void assertHasDummyTransportMessage(String name, String expectedBody) { + List messages = dummyTransport.getMessages("dummy:" + name); + assertNotNull("No messages recorded in dummy transport '" + name + "'", messages); + for (Message message: messages) { + if (expectedBody.equals(message.getBody())) { + return; + } + } + fail("Notifier "+name+" message body " + expectedBody + " not found"); + } + + protected void displayAllNotifications() { + for (java.util.Map.Entry> entry: dummyTransport.getMessages().entrySet()) { + List messages = entry.getValue(); + if (messages != null && !messages.isEmpty()) { + display("Notification messages: "+entry.getKey(), messages); + } + } + } + + protected void displayNotifications(String name) { + List messages = dummyTransport.getMessages("dummy:" + name); + display("Notification messages: "+name, messages); + } + + private void logNotifyMessages(List messages) { + for (Message message: messages) { + LOGGER.debug("Notification message:\n{}", message.getBody()); + } + } + + private void printNotifyMessages(List messages) { + for (Message message: messages) { + System.out.println(message); + } + } + + protected void checkDummyTransportMessagesAtLeast(String name, int expectedCount) { + if (expectedCount == 0) { + return; + } + List messages = dummyTransport.getMessages("dummy:" + name); + assertNotNull("No messages recorded in dummy transport '" + name + "'", messages); + assertTrue("Number of messages recorded in dummy transport '" + name + "' (" + messages.size() + ") is not at least " + expectedCount, messages.size() >= expectedCount); + } + + protected DummyAccount getDummyAccount(String dummyInstanceName, String username) throws SchemaViolationException, ConflictException, InterruptedException { + DummyResource dummyResource = DummyResource.getInstance(dummyInstanceName); + try { + return dummyResource.getAccountByUsername(username); + } catch (ConnectException e) { + throw new IllegalStateException(e.getMessage(),e); + } catch (FileNotFoundException e) { + throw new IllegalStateException(e.getMessage(),e); + } + } + + protected DummyAccount getDummyAccountById(String dummyInstanceName, String id) throws SchemaViolationException, ConflictException, InterruptedException { + DummyResource dummyResource = DummyResource.getInstance(dummyInstanceName); + try { + return dummyResource.getAccountById(id); + } catch (ConnectException e) { + throw new IllegalStateException(e.getMessage(),e); + } catch (FileNotFoundException e) { + throw new IllegalStateException(e.getMessage(),e); + } + } + + protected DummyAccount assertDefaultDummyAccount(String username, String fullname, boolean active) throws SchemaViolationException, ConflictException, InterruptedException { + return assertDummyAccount(null, username, fullname, active); + } + + protected DummyAccount assertDummyAccount(String dummyInstanceName, String username, String fullname, Boolean active) throws SchemaViolationException, ConflictException, InterruptedException { + DummyAccount account = getDummyAccount(dummyInstanceName, username); + // display("account", account); + assertNotNull("No dummy("+dummyInstanceName+") account for username "+username, account); + assertEquals("Wrong fullname for dummy("+dummyInstanceName+") account "+username, fullname, account.getAttributeValue("fullname")); + assertEquals("Wrong activation for dummy(" + dummyInstanceName + ") account " + username, active, account.isEnabled()); + return account; + } + + protected DummyAccount assertDummyAccount(String dummyInstanceName, String username) throws SchemaViolationException, ConflictException, InterruptedException { + DummyAccount account = getDummyAccount(dummyInstanceName, username); + assertNotNull("No dummy(" + dummyInstanceName + ") account for username " + username, account); + return account; + } + + protected DummyAccountAsserter assertDummyAccountById(String dummyResourceName, String id) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { + return getDummyResourceController(dummyResourceName).assertAccountById(id); + } + + protected void assertNoDummyAccountById(String dummyInstanceName, String id) throws SchemaViolationException, ConflictException, InterruptedException { + DummyAccount account = getDummyAccountById(dummyInstanceName, id); + assertNull("Dummy(" + dummyInstanceName + ") account for id " + id + " exists while not expecting it", account); + } + + protected void assertDummyAccountActivation(String dummyInstanceName, String username, Boolean active) throws SchemaViolationException, ConflictException, InterruptedException { + DummyAccount account = getDummyAccount(dummyInstanceName, username); + assertNotNull("No dummy("+dummyInstanceName+") account for username "+username, account); + assertEquals("Wrong activation for dummy(" + dummyInstanceName + ") account " + username, active, account.isEnabled()); + } + + protected void assertNoDummyAccount(String username) throws SchemaViolationException, ConflictException, InterruptedException { + assertNoDummyAccount(null, username); + } + + protected void assertNoDummyAccount(String dummyInstanceName, String username) throws SchemaViolationException, ConflictException, InterruptedException { + DummyAccount account = getDummyAccount(dummyInstanceName, username); + assertNull("Dummy account for username " + username + " exists while not expecting it (" + dummyInstanceName + ")", account); + } + + protected void assertDefaultDummyAccountAttribute(String username, String attributeName, Object... expectedAttributeValues) throws SchemaViolationException, ConflictException, InterruptedException { + assertDummyAccountAttribute(null, username, attributeName, expectedAttributeValues); + } + + protected void assertDummyAccountAttribute(String dummyInstanceName, String username, String attributeName, Object... expectedAttributeValues) throws SchemaViolationException, ConflictException, InterruptedException { + DummyAccount account = getDummyAccount(dummyInstanceName, username); + assertNotNull("No dummy account for username "+username, account); + Set values = account.getAttributeValues(attributeName, Object.class); + if ((values == null || values.isEmpty()) && (expectedAttributeValues == null || expectedAttributeValues.length == 0)) { + return; + } + assertNotNull("No values for attribute "+attributeName+" of "+dummyInstanceName+" dummy account "+username, values); + assertEquals("Unexpected number of values for attribute " + attributeName + " of "+dummyInstanceName+" dummy account " + username + + ". Expected: " + Arrays.toString(expectedAttributeValues) + ", was: " + values, + expectedAttributeValues.length, values.size()); + for (Object expectedValue: expectedAttributeValues) { + if (!values.contains(expectedValue)) { + AssertJUnit.fail("Value '"+expectedValue+"' expected in attribute "+attributeName+" of "+dummyInstanceName+" dummy account "+username+ + " but not found. Values found: "+values); + } + } + } + + protected void assertNoDummyAccountAttribute(String dummyInstanceName, String username, String attributeName) throws SchemaViolationException, ConflictException, InterruptedException { + DummyAccount account = getDummyAccount(dummyInstanceName, username); + assertNotNull("No dummy "+dummyInstanceName+" account for username "+username, account); + Set values = account.getAttributeValues(attributeName, Object.class); + if (values == null || values.isEmpty()) { + return; + } + AssertJUnit.fail("Expected no value in attribute " + attributeName + " of "+dummyInstanceName+" dummy account " + username + + ". Values found: " + values); + } + + protected void assertDummyAccountAttributeGenerated(String dummyInstanceName, String username) throws SchemaViolationException, ConflictException, InterruptedException { + DummyAccount account = getDummyAccount(dummyInstanceName, username); + assertNotNull("No dummy account for username "+username, account); + Integer generated = account.getAttributeValue(DummyAccount.ATTR_INTERNAL_ID, Integer.class); + if (generated == null) { + AssertJUnit.fail("No value in generated attribute dir of " + dummyInstanceName + " dummy account " + username); + } + } + + protected DummyGroup getDummyGroup(String dummyInstanceName, String name) throws SchemaViolationException, ConflictException, InterruptedException { + DummyResource dummyResource = DummyResource.getInstance(dummyInstanceName); + try { + return dummyResource.getGroupByName(name); + } catch (ConnectException e) { + throw new IllegalStateException(e.getMessage(),e); + } catch (FileNotFoundException e) { + throw new IllegalStateException(e.getMessage(),e); + } + } + + protected void assertDummyGroup(String username, String description) throws SchemaViolationException, ConflictException, InterruptedException { + assertDummyGroup(null, username, description, null); + } + + protected void assertDummyGroup(String username, String description, Boolean active) throws SchemaViolationException, ConflictException, InterruptedException { + assertDummyGroup(null, username, description, active); + } + + protected void assertDummyGroup(String dummyInstanceName, String groupname, String description, Boolean active) throws SchemaViolationException, ConflictException, InterruptedException { + DummyGroup group = getDummyGroup(dummyInstanceName, groupname); + assertNotNull("No dummy("+dummyInstanceName+") group for name "+groupname, group); + assertEquals("Wrong fullname for dummy(" + dummyInstanceName + ") group " + groupname, description, + group.getAttributeValue(DummyResourceContoller.DUMMY_GROUP_ATTRIBUTE_DESCRIPTION)); + if (active != null) { + assertEquals("Wrong activation for dummy("+dummyInstanceName+") group "+groupname, active, group.isEnabled()); + } + } + + protected void assertNoDummyGroup(String groupname) throws SchemaViolationException, ConflictException, InterruptedException { + assertNoDummyGroup(null, groupname); + } + + protected void assertNoDummyGroup(String dummyInstanceName, String groupname) throws SchemaViolationException, ConflictException, InterruptedException { + DummyGroup group = getDummyGroup(dummyInstanceName, groupname); + assertNull("Dummy group '" + groupname + "' exists while not expecting it (" + dummyInstanceName + ")", group); + } + + protected void assertDummyGroupAttribute(String dummyInstanceName, String groupname, String attributeName, Object... expectedAttributeValues) throws SchemaViolationException, ConflictException, InterruptedException { + DummyGroup group = getDummyGroup(dummyInstanceName, groupname); + assertNotNull("No dummy group for groupname "+groupname, group); + Set values = group.getAttributeValues(attributeName, Object.class); + if ((values == null || values.isEmpty()) && (expectedAttributeValues == null || expectedAttributeValues.length == 0)) { + return; + } + assertNotNull("No values for attribute "+attributeName+" of "+dummyInstanceName+" dummy group "+groupname, values); + assertEquals("Unexpected number of values for attribute " + attributeName + " of dummy group " + groupname + ": " + values, expectedAttributeValues.length, values.size()); + for (Object expectedValue: expectedAttributeValues) { + if (!values.contains(expectedValue)) { + AssertJUnit.fail("Value '"+expectedValue+"' expected in attribute "+attributeName+" of dummy group "+groupname+ + " but not found. Values found: "+values); + } + } + } + + protected void assertDummyGroupMember(String dummyInstanceName, String dummyGroupName, String accountId) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { + DummyResource dummyResource = DummyResource.getInstance(dummyInstanceName); + DummyGroup group = dummyResource.getGroupByName(dummyGroupName); + assertNotNull("No dummy group "+dummyGroupName, group); + IntegrationTestTools.assertGroupMember(group, accountId); + } + + protected void assertDefaultDummyGroupMember(String dummyGroupName, String accountId) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { + assertDummyGroupMember(null, dummyGroupName, accountId); + } + + protected void assertNoDummyGroupMember(String dummyInstanceName, String dummyGroupName, String accountId) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { + DummyResource dummyResource = DummyResource.getInstance(dummyInstanceName); + DummyGroup group = dummyResource.getGroupByName(dummyGroupName); + IntegrationTestTools.assertNoGroupMember(group, accountId); + } + + protected void assertNoDefaultDummyGroupMember(String dummyGroupName, String accountId) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { + assertNoDummyGroupMember(null, dummyGroupName, accountId); + } + + protected void assertDummyAccountNoAttribute(String dummyInstanceName, String username, String attributeName) throws SchemaViolationException, ConflictException, InterruptedException { + DummyAccount account = getDummyAccount(dummyInstanceName, username); + assertNotNull("No dummy account for username "+username, account); + Set values = account.getAttributeValues(attributeName, Object.class); + assertTrue("Unexpected values for attribute " + attributeName + " of dummy account " + username + ": " + values, values == null || values.isEmpty()); + } + + protected Entry assertOpenDjAccount(String uid, String cn, Boolean active) throws DirectoryException { + Entry entry = openDJController.searchByUid(uid); + assertNotNull("OpenDJ accoun with uid "+uid+" not found", entry); + openDJController.assertAttribute(entry, "cn", cn); + if (active != null) { + openDJController.assertActive(entry, active); + } + return entry; + } + + protected void assertNoOpenDjAccount(String uid) throws DirectoryException { + Entry entry = openDJController.searchByUid(uid); + assertNull("Expected that OpenDJ account with uid " + uid + " will be gone, but it is still there", entry); + } + + protected void assertIteration(PrismObject shadow, Integer expectedIteration, String expectedIterationToken) { + PrismAsserts.assertPropertyValue(shadow, ShadowType.F_ITERATION, expectedIteration); + PrismAsserts.assertPropertyValue(shadow, ShadowType.F_ITERATION_TOKEN, expectedIterationToken); + } + + protected void assertIterationDelta(ObjectDelta shadowDelta, Integer expectedIteration, String expectedIterationToken) { + PrismAsserts.assertPropertyReplace(shadowDelta, ShadowType.F_ITERATION, expectedIteration); + PrismAsserts.assertPropertyReplace(shadowDelta, ShadowType.F_ITERATION_TOKEN, expectedIterationToken); + } + + protected void assertSituation(PrismObject shadow, SynchronizationSituationType expectedSituation) { + if (expectedSituation == null) { + PrismAsserts.assertNoItem(shadow, ShadowType.F_SYNCHRONIZATION_SITUATION); + } else { + PrismAsserts.assertPropertyValue(shadow, ShadowType.F_SYNCHRONIZATION_SITUATION, expectedSituation); + } + } + + protected void assertEnableTimestampFocus(PrismObject focus, + XMLGregorianCalendar startTime, XMLGregorianCalendar endTime) { + XMLGregorianCalendar userDisableTimestamp = focus.asObjectable().getActivation().getEnableTimestamp(); + TestUtil.assertBetween("Wrong user enableTimestamp in "+focus, + startTime, endTime, userDisableTimestamp); + } + + protected void assertDisableTimestampFocus(PrismObject focus, + XMLGregorianCalendar startTime, XMLGregorianCalendar endTime) { + XMLGregorianCalendar userDisableTimestamp = focus.asObjectable().getActivation().getDisableTimestamp(); + TestUtil.assertBetween("Wrong user disableTimestamp in "+focus, + startTime, endTime, userDisableTimestamp); + } + + protected void assertEnableTimestampShadow(PrismObject shadow, + XMLGregorianCalendar startTime, XMLGregorianCalendar endTime) { + ActivationType activationType = shadow.asObjectable().getActivation(); + assertNotNull("No activation in "+shadow, activationType); + XMLGregorianCalendar userDisableTimestamp = activationType.getEnableTimestamp(); + TestUtil.assertBetween("Wrong shadow enableTimestamp in "+shadow, + startTime, endTime, userDisableTimestamp); + } + + protected void assertDisableTimestampShadow(PrismObject shadow, + XMLGregorianCalendar startTime, XMLGregorianCalendar endTime) { + XMLGregorianCalendar userDisableTimestamp = shadow.asObjectable().getActivation().getDisableTimestamp(); + TestUtil.assertBetween("Wrong shadow disableTimestamp in "+shadow, + startTime, endTime, userDisableTimestamp); + } + + protected void assertDisableReasonShadow(PrismObject shadow, String expectedReason) { + String disableReason = shadow.asObjectable().getActivation().getDisableReason(); + assertEquals("Wrong shadow disableReason in " + shadow, expectedReason, disableReason); + } + + protected String getPassword(PrismObject user) throws EncryptionException { + CredentialsType credentialsType = user.asObjectable().getCredentials(); + assertNotNull("No credentials in "+user, credentialsType); + PasswordType passwordType = credentialsType.getPassword(); + assertNotNull("No password in "+user, passwordType); + ProtectedStringType protectedStringType = passwordType.getValue(); + assertNotNull("No password value in "+user, protectedStringType); + return protector.decryptString(protectedStringType); + } + + protected void assertPassword(PrismObject user, String expectedPassword) throws EncryptionException { + String decryptedUserPassword = getPassword(user); + assertEquals("Wrong password in "+user, expectedPassword, decryptedUserPassword); + } + + protected void assertUserLdapPassword(PrismObject user, String expectedPassword) throws EncryptionException { + CredentialsType credentialsType = user.asObjectable().getCredentials(); + assertNotNull("No credentials in "+user, credentialsType); + PasswordType passwordType = credentialsType.getPassword(); + assertNotNull("No password in "+user, passwordType); + ProtectedStringType protectedStringType = passwordType.getValue(); + assertLdapPassword(protectedStringType, expectedPassword, user); + } + + protected void assertShadowLdapPassword(PrismObject shadow, String expectedPassword) throws EncryptionException { + CredentialsType credentialsType = shadow.asObjectable().getCredentials(); + assertNotNull("No credentials in "+shadow, credentialsType); + PasswordType passwordType = credentialsType.getPassword(); + assertNotNull("No password in "+shadow, passwordType); + ProtectedStringType protectedStringType = passwordType.getValue(); + assertLdapPassword(protectedStringType, expectedPassword, shadow); + } + + protected void assertLdapPassword(ProtectedStringType protectedStringType, String expectedPassword, PrismObject source) throws EncryptionException { + assertNotNull("No password value in "+source, protectedStringType); + String decryptedUserPassword = protector.decryptString(protectedStringType); + assertNotNull("Null password in " + source, decryptedUserPassword); + if (decryptedUserPassword.startsWith("{") || decryptedUserPassword.contains("}")) { + assertTrue("Wrong password hash in "+source+": "+decryptedUserPassword+", expected "+expectedPassword, ldapShaPasswordEncoder.matches(decryptedUserPassword, expectedPassword)); + } else { + assertEquals("Wrong password in "+source, expectedPassword, decryptedUserPassword); + } + } + + protected void assertGroupMember(DummyGroup group, String accountId) { + IntegrationTestTools.assertGroupMember(group, accountId); + } + + protected void assertNoGroupMember(DummyGroup group, String accountId) { + IntegrationTestTools.assertNoGroupMember(group, accountId); + } + + protected void assertNoGroupMembers(DummyGroup group) { + IntegrationTestTools.assertNoGroupMembers(group); + } + + protected void login(String principalName) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + MidPointPrincipal principal = focusProfileService.getPrincipal(principalName, UserType.class); + login(principal); + } + + protected void login(PrismObject user) throws SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + MidPointPrincipal principal = focusProfileService.getPrincipal(user); + login(principal); + } + + protected void login(MidPointPrincipal principal) { + SecurityContext securityContext = SecurityContextHolder.getContext(); + Authentication authentication = new UsernamePasswordAuthenticationToken(principal, null, principal.getAuthorities()); + securityContext.setAuthentication(createMpAuthentication(authentication)); + } + + protected Authentication createMpAuthentication(Authentication authentication) { + MidpointAuthentication mpAuthentication = new MidpointAuthentication(SecurityPolicyUtil.createDefaultSequence()); + ModuleAuthentication moduleAuthentication = new ModuleAuthentication(NameOfModuleType.LOGIN_FORM); + moduleAuthentication.setAuthentication(authentication); + moduleAuthentication.setNameOfModule(SecurityPolicyUtil.DEFAULT_MODULE_NAME); + moduleAuthentication.setState(StateOfModule.SUCCESSFULLY); + moduleAuthentication.setPrefix(ModuleWebSecurityConfiguration.DEFAULT_PREFIX_OF_MODULE_WITH_SLASH + + ModuleWebSecurityConfiguration.DEFAULT_PREFIX_FOR_DEFAULT_MODULE + SecurityPolicyUtil.DEFAULT_MODULE_NAME + "/"); + mpAuthentication.addAuthentications(moduleAuthentication); + mpAuthentication.setPrincipal(authentication.getPrincipal()); + return mpAuthentication; + } + + protected void loginSuperUser(String principalName) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + MidPointPrincipal principal = focusProfileService.getPrincipal(principalName, UserType.class); + loginSuperUser(principal); + } + + protected void loginSuperUser(PrismObject user) throws SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + MidPointPrincipal principal = focusProfileService.getPrincipal(user); + loginSuperUser(principal); + } + + protected void loginSuperUser(MidPointPrincipal principal) throws SchemaException { + AuthorizationType superAutzType = new AuthorizationType(); + prismContext.adopt(superAutzType, RoleType.class, RoleType.F_AUTHORIZATION); + superAutzType.getAction().add(AuthorizationConstants.AUTZ_ALL_URL); + Authorization superAutz = new Authorization(superAutzType); + Collection authorities = principal.getAuthorities(); + authorities.add(superAutz); + SecurityContext securityContext = SecurityContextHolder.getContext(); + Authentication authentication = new UsernamePasswordAuthenticationToken(principal, null); + securityContext.setAuthentication(createMpAuthentication(authentication)); + } + + protected void loginAnonymous() { + Authentication authentication = new AnonymousAuthenticationToken("foo", + AuthorizationConstants.ANONYMOUS_USER_PRINCIPAL, AuthorityUtils.createAuthorityList("ROLE_ANONYMOUS")); + SecurityContextHolder.getContext().setAuthentication(createMpAuthentication(authentication)); + } + + protected void assertLoggedInUsername(String username) { + MidPointPrincipal midPointPrincipal = getSecurityContextPrincipal(); + FocusType user = midPointPrincipal.getFocus(); + if (user == null) { + if (username == null) { + return; + } else { + AssertJUnit.fail("Expected logged in user '"+username+"' but there was no user in the spring security context"); + } + } + assertEquals("Wrong logged-in user", username, user.getName().getOrig()); + } + + protected void assertLoggedInUserOid(String userOid) { + MidPointPrincipal midPointPrincipal = getSecurityContextPrincipal(); + assertPrincipalUserOid(midPointPrincipal, userOid); + } + + protected void assertPrincipalUserOid(MidPointPrincipal principal, String userOid) { + FocusType user = principal.getFocus(); + if (user == null) { + if (userOid == null) { + return; + } else { + AssertJUnit.fail("Expected user "+userOid+" in principal "+principal+" but there was none"); + } + } + assertEquals("Wrong user OID in principal", userOid, user.getOid()); + } + + protected MidPointPrincipal getSecurityContextPrincipal() { + SecurityContext securityContext = SecurityContextHolder.getContext(); + Authentication authentication = securityContext.getAuthentication(); + if (authentication == null) { + return null; + } + Object principal = authentication.getPrincipal(); + if (principal == null) { + return null; + } + if (principal instanceof MidPointPrincipal) { + return (MidPointPrincipal)principal; + } else { + AssertJUnit.fail("Unknown principal in the spring security context: "+principal); + return null; // not reached + } + } + + protected PrismObject getSecurityContextPrincipalFocus() { + SecurityContext securityContext = SecurityContextHolder.getContext(); + Authentication authentication = securityContext.getAuthentication(); + if (authentication == null) { + return null; + } + Object principal = authentication.getPrincipal(); + if (principal == null) { + return null; + } + if (principal instanceof MidPointPrincipal) { + FocusType focusType = ((MidPointPrincipal)principal).getFocus(); + if (focusType == null) { + return null; + } + return focusType.asPrismObject(); + } else { + return null; + } + } + + protected void assertAuthenticated() { + SecurityContext securityContext = SecurityContextHolder.getContext(); + Authentication authentication = securityContext.getAuthentication(); + assertTrue("Security context is not authenticated", authentication.isAuthenticated()); + } + + protected void resetAuthentication() { + SecurityContext securityContext = SecurityContextHolder.getContext(); + securityContext.setAuthentication(null); + } + + protected void assertNoAuthentication() { + SecurityContext securityContext = SecurityContextHolder.getContext(); + assertNull("Unexpected authentication", securityContext.getAuthentication()); + } + + protected void assertSecurityContextPrincipalAttorneyOid(String attotrneyOid) { + MidPointPrincipal midPointPrincipal = getSecurityContextPrincipal(); + assertPrincipalAttorneyOid(midPointPrincipal, attotrneyOid); + } + + protected void assertPrincipalAttorneyOid(MidPointPrincipal principal, String attotrneyOid) { + FocusType attorney = principal.getAttorney(); + if (attorney == null) { + if (attotrneyOid == null) { + return; + } else { + AssertJUnit.fail("Expected attorney "+attotrneyOid+" in principal "+principal+" but there was none"); + } + } + assertEquals("Wrong attroney OID in principal", attotrneyOid, attorney.getOid()); + } + + protected Collection getSecurityContextAuthorizations() { + MidPointPrincipal midPointPrincipal = getSecurityContextPrincipal(); + if (midPointPrincipal == null) { + return null; + } + return midPointPrincipal.getAuthorities(); + } + + protected void assertAuthorizationActions(String message, Collection autzs, String... expectedActions) { + Collection actualActions = autzs.stream() + .map(a -> a.getAction()) + .flatMap(List::stream) + .collect(Collectors.toList()); + PrismAsserts.assertEqualsCollectionUnordered(message, actualActions, expectedActions); + } + + protected void assertSecurityContextAuthorizationActions(String... expectedActions) { + Collection securityContextAuthorizations = getSecurityContextAuthorizations(); + assertAuthorizationActions("Wrong authorizations in security context", securityContextAuthorizations, expectedActions); + } + + protected void assertSecurityContextAuthorizationActions(ModelAuthorizationAction... expectedModelActions) { + Collection securityContextAuthorizations = getSecurityContextAuthorizations(); + String[] expectedActions = new String[expectedModelActions.length]; + for (int i=0;i securityContextAuthorizations = getSecurityContextAuthorizations(); + if (securityContextAuthorizations != null && !securityContextAuthorizations.isEmpty()) { + fail("Unexpected authorizations in security context: "+securityContextAuthorizations); + } + } + + protected void displayAllUsers() throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".displayAllUsers"); + OperationResult result = task.getResult(); + ResultHandler handler = (object, parentResult) -> { + display("User", object); + return true; + }; + modelService.searchObjectsIterative(UserType.class, null, handler, null, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + } + + /** + * Returns appropriate object synchronization settings for the class. + * Assumes single sync setting for now. + */ + protected ObjectSynchronizationType determineSynchronization(ResourceType resource, Class type, String name) { + SynchronizationType synchronization = resource.getSynchronization(); + if (synchronization == null) { + return null; + } + List objectSynchronizations = synchronization.getObjectSynchronization(); + if (objectSynchronizations.isEmpty()) { + return null; + } + for (ObjectSynchronizationType objSyncType: objectSynchronizations) { + QName focusTypeQName = objSyncType.getFocusType(); + if (focusTypeQName == null) { + if (type != UserType.class) { + continue; + } + } else { + ObjectTypes focusType = ObjectTypes.getObjectTypeFromTypeQName(focusTypeQName); + if (type != focusType.getClassDefinition()) { + continue; + } + } + if (name == null) { + // we got it + return objSyncType; + } else { + if (name.equals(objSyncType.getName())) { + return objSyncType; + } + } + } + throw new IllegalArgumentException("Synchronization setting for "+type+" and name "+name+" not found in "+resource); + } + + protected void assertShadowKindIntent(String shadowOid, ShadowKindType expectedKind, + String expectedIntent) throws ObjectNotFoundException, SchemaException { + OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName()+".assertShadowKindIntent"); + PrismObject shadow = repositoryService.getObject(ShadowType.class, shadowOid, null, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + assertShadowKindIntent(shadow, expectedKind, expectedIntent); + } + + protected void assertShadowKindIntent(PrismObject shadow, ShadowKindType expectedKind, + String expectedIntent) { + assertEquals("Wrong kind in " + shadow, expectedKind, shadow.asObjectable().getKind()); + assertEquals("Wrong intent in " + shadow, expectedIntent, shadow.asObjectable().getIntent()); + } + + protected PrismObject getDefaultActor() { + return null; + } + + protected Task createTask(String operationName) { + Task task = super.createTask(operationName); + PrismObject defaultActor = getDefaultActor(); + if (defaultActor != null) { + task.setOwner(defaultActor); + } + task.setChannel(DEFAULT_CHANNEL); + return task; + } + + protected Task createTask(String operationName, MidPointPrincipal principal) { + Task task = super.createTask(operationName); + task.setOwner(principal.getFocus().asPrismObject()); + task.setChannel(DEFAULT_CHANNEL); + return task; + } + + protected void modifyRoleAddConstruction(String roleOid, long inducementId, String resourceOid) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + Task task = createTask(AbstractModelIntegrationTest.class.getName() + ".modifyRoleAddConstruction"); + OperationResult result = task.getResult(); + ConstructionType construction = new ConstructionType(); + ObjectReferenceType resourceRedRef = new ObjectReferenceType(); + resourceRedRef.setOid(resourceOid); + construction.setResourceRef(resourceRedRef); + ObjectDelta roleDelta = prismContext.deltaFactory().object() + .createModificationAddContainer(RoleType.class, roleOid, + ItemPath.create(RoleType.F_INDUCEMENT, inducementId, AssignmentType.F_CONSTRUCTION), + construction); + modelService.executeChanges(MiscSchemaUtil.createCollection(roleDelta), null, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + } + + protected void modifyRoleAddInducementTarget(String roleOid, String targetOid, boolean reconcileAffected, + ModelExecuteOptions defaultOptions, Task task) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + if (task == null) { + task = createTask(AbstractModelIntegrationTest.class.getName() + ".modifyRoleAddInducementTarget"); + } + OperationResult result = task.getResult(); + AssignmentType inducement = new AssignmentType(); + ObjectReferenceType targetRef = new ObjectReferenceType(); + targetRef.setOid(targetOid); + inducement.setTargetRef(targetRef); + ObjectDelta roleDelta = prismContext.deltaFactory().object() + .createModificationAddContainer(RoleType.class, roleOid, + RoleType.F_INDUCEMENT, inducement); + ModelExecuteOptions options = nullToEmpty(defaultOptions); + options.setReconcileAffected(reconcileAffected); + executeChanges(roleDelta, options, task, result); + result.computeStatus(); + if (reconcileAffected) { + TestUtil.assertInProgressOrSuccess(result); + } else { + TestUtil.assertSuccess(result); + } + } + + protected void modifyRoleAddExclusion(String roleOid, String excludedRoleOid, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + modifyRoleExclusion(roleOid, excludedRoleOid, true, task, result); + } + + protected void modifyRoleDeleteExclusion(String roleOid, String excludedRoleOid, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + modifyRoleExclusion(roleOid, excludedRoleOid, false, task, result); + } + + protected void modifyRoleExclusion(String roleOid, String excludedRoleOid, boolean add, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + modifyRolePolicyRule(roleOid, createExclusionPolicyRule(excludedRoleOid), add, task, result); + } + + protected void modifyRolePolicyRule(String roleOid, PolicyRuleType exclusionPolicyRule, boolean add, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + AssignmentType assignment = new AssignmentType(); + assignment.setPolicyRule(exclusionPolicyRule); + ObjectDelta roleDelta; + if (add) { + roleDelta = prismContext.deltaFactory().object() + .createModificationAddContainer(RoleType.class, roleOid, RoleType.F_ASSIGNMENT, + assignment); + } else { + roleDelta = prismContext.deltaFactory().object() + .createModificationDeleteContainer(RoleType.class, roleOid, RoleType.F_ASSIGNMENT, + assignment); + } + executeChanges(roleDelta, null, task, result); + } + + protected void modifyRoleAddAssignment(String roleOid, AssignmentType assignment, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + ObjectDelta roleDelta = prismContext.deltaFactory().object() + .createModificationAddContainer(RoleType.class, roleOid, RoleType.F_ASSIGNMENT, + assignment); + executeChanges(roleDelta, null, task, result); + } + + protected void modifyRoleDeleteAssignment(String roleOid, AssignmentType assignment, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + ObjectDelta roleDelta = prismContext.deltaFactory().object() + .createModificationDeleteContainer(RoleType.class, roleOid, RoleType.F_ASSIGNMENT, + assignment); + executeChanges(roleDelta, null, task, result); + } + + protected PolicyRuleType createExclusionPolicyRule(String excludedRoleOid) { + PolicyRuleType policyRule = new PolicyRuleType(); + PolicyConstraintsType policyContraints = new PolicyConstraintsType(); + ExclusionPolicyConstraintType exclusionConstraint = new ExclusionPolicyConstraintType(); + ObjectReferenceType targetRef = new ObjectReferenceType(); + targetRef.setOid(excludedRoleOid); + targetRef.setType(RoleType.COMPLEX_TYPE); + exclusionConstraint.setTargetRef(targetRef); + policyContraints.getExclusion().add(exclusionConstraint); + policyRule.setPolicyConstraints(policyContraints); + return policyRule; + } + + protected PolicyRuleType createMinAssigneePolicyRule(int minAssignees) { + PolicyRuleType policyRule = new PolicyRuleType(); + PolicyConstraintsType policyContraints = new PolicyConstraintsType(); + MultiplicityPolicyConstraintType minAssigneeConstraint = new MultiplicityPolicyConstraintType(); + minAssigneeConstraint.setMultiplicity(Integer.toString(minAssignees)); + policyContraints.getMinAssignees().add(minAssigneeConstraint); + policyRule.setPolicyConstraints(policyContraints); + return policyRule; + } + + protected PolicyRuleType createMaxAssigneePolicyRule(int maxAssignees) { + PolicyRuleType policyRule = new PolicyRuleType(); + PolicyConstraintsType policyContraints = new PolicyConstraintsType(); + MultiplicityPolicyConstraintType maxAssigneeConstraint = new MultiplicityPolicyConstraintType(); + maxAssigneeConstraint.setMultiplicity(Integer.toString(maxAssignees)); + policyContraints.getMaxAssignees().add(maxAssigneeConstraint); + policyRule.setPolicyConstraints(policyContraints); + return policyRule; + } + + protected AssignmentType createAssignmentIdOnly(long id) { + AssignmentType assignment = new AssignmentType(); + assignment.asPrismContainerValue().setId(id); + return assignment; + } + + protected void modifyRoleAddPolicyException(String roleOid, PolicyExceptionType policyException, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + ObjectDelta roleDelta = prismContext.deltaFactory().object() + .createModificationAddContainer(RoleType.class, roleOid, RoleType.F_POLICY_EXCEPTION, + policyException); + executeChanges(roleDelta, null, task, result); + } + + protected void modifyRoleDeletePolicyException(String roleOid, PolicyExceptionType policyException, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + ObjectDelta roleDelta = prismContext.deltaFactory().object() + .createModificationDeleteContainer(RoleType.class, roleOid, RoleType.F_POLICY_EXCEPTION, + policyException); + executeChanges(roleDelta, null, task, result); + } + + protected void modifyRoleReplacePolicyException(String roleOid, PolicyExceptionType policyException, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + ObjectDelta roleDelta = prismContext.deltaFactory().object() + .createModificationReplaceContainer(RoleType.class, roleOid, RoleType.F_POLICY_EXCEPTION, + policyException); + executeChanges(roleDelta, null, task, result); + } + + protected PolicyExceptionType createPolicyException(String ruleName, String policySituation) { + PolicyExceptionType policyException = new PolicyExceptionType(); + policyException.setPolicySituation(policySituation); + policyException.setRuleName(ruleName); + return policyException; + } + + protected Optional findAssignmentByTarget(PrismObject focus, String targetOid) { + return focus.asObjectable().getAssignment().stream() + .filter(a -> a.getTargetRef() != null && targetOid.equals(a.getTargetRef().getOid())) + .findFirst(); + } + + protected AssignmentType findAssignmentByTargetRequired(PrismObject focus, String targetOid) { + return findAssignmentByTarget(focus, targetOid) + .orElseThrow(() -> new IllegalStateException("No assignment to " + targetOid + " in " + focus)); + } + + + protected AssignmentType findInducementByTarget(String roleOid, String targetOid) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + Task task = createTask(AbstractModelIntegrationTest.class.getName() + ".findInducementByTarget"); + OperationResult result = task.getResult(); + PrismObject role = modelService.getObject(RoleType.class, roleOid, null, task, result); + for (AssignmentType inducement: role.asObjectable().getInducement()) { + ObjectReferenceType targetRef = inducement.getTargetRef(); + if (targetRef != null && targetOid.equals(targetRef.getOid())) { + return inducement; + } + } + return null; + } + + protected void modifyRoleDeleteInducementTarget(String roleOid, String targetOid, + ModelExecuteOptions options) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + Task task = createTask(AbstractModelIntegrationTest.class.getName() + ".modifyRoleDeleteInducementTarget"); + OperationResult result = task.getResult(); + AssignmentType inducement = findInducementByTarget(roleOid, targetOid); + ObjectDelta roleDelta = prismContext.deltaFactory().object() + .createModificationDeleteContainer(RoleType.class, roleOid, RoleType.F_INDUCEMENT, + inducement.asPrismContainerValue().clone()); + modelService.executeChanges(MiscSchemaUtil.createCollection(roleDelta), options, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + } + + protected void modifyRoleDeleteInducement(String roleOid, long inducementId, boolean reconcileAffected, + ModelExecuteOptions defaultOptions, Task task) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + if (task == null) { + task = createTask(AbstractModelIntegrationTest.class.getName() + ".modifyRoleDeleteInducement"); + } + OperationResult result = task.getResult(); + + AssignmentType inducement = new AssignmentType(); + inducement.setId(inducementId); + ObjectDelta roleDelta = prismContext.deltaFactory().object() + .createModificationDeleteContainer(RoleType.class, roleOid, + RoleType.F_INDUCEMENT, inducement); + ModelExecuteOptions options = nullToEmpty(defaultOptions); + options.setReconcileAffected(reconcileAffected); + executeChanges(roleDelta, options, task, result); + result.computeStatus(); + if (reconcileAffected) { + TestUtil.assertInProgressOrSuccess(result); + } else { + TestUtil.assertSuccess(result); + } + } + + @NotNull + protected ModelExecuteOptions nullToEmpty(ModelExecuteOptions options) { + return options != null ? options : new ModelExecuteOptions(); + } + + protected void modifyUserAddAccount(String userOid, File accountFile, Task task, OperationResult result) throws SchemaException, IOException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + PrismObject account = prismContext.parseObject(accountFile); + + ObjectDelta userDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, userOid + ); + PrismReferenceValue accountRefVal = itemFactory().createReferenceValue(); + accountRefVal.setObject(account); + ReferenceDelta accountDelta = prismContext.deltaFactory().reference().createModificationAdd(UserType.F_LINK_REF, getUserDefinition(), accountRefVal); + userDelta.addModification(accountDelta); + Collection> deltas = (Collection)MiscUtil.createCollection(userDelta); + + modelService.executeChanges(deltas, null, task, result); + } + + protected void assertAuthorized(MidPointPrincipal principal, String action) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { + Task task = createTask("assertAuthorized", principal); + assertAuthorized(principal, action, null, task, task.getResult()); + assertAuthorized(principal, action, AuthorizationPhaseType.REQUEST, task, task.getResult()); + assertAuthorized(principal, action, AuthorizationPhaseType.EXECUTION, task, task.getResult()); + assertSuccess(task.getResult()); + } + + protected void assertAuthorized(MidPointPrincipal principal, String action, AuthorizationPhaseType phase) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { + Task task = createTask("assertAuthorized", principal); + assertAuthorized(principal, action, phase, task, task.getResult()); + assertSuccess(task.getResult()); + } + + protected void assertAuthorized(MidPointPrincipal principal, String action, AuthorizationPhaseType phase, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { + SecurityContext origContext = SecurityContextHolder.getContext(); + createSecurityContext(principal); + try { + assertTrue("AuthorizationEvaluator.isAuthorized: Principal "+principal+" NOT authorized for action "+action, + securityEnforcer.isAuthorized(action, phase, AuthorizationParameters.EMPTY, null, task, result)); + if (phase == null) { + List requiredActions = new ArrayList<>(1); + requiredActions.add(action); + securityEnforcer.decideAccess(getSecurityContextPrincipal(), requiredActions, task, result); + } + } finally { + SecurityContextHolder.setContext(origContext); + } + } + + protected void assertNotAuthorized(MidPointPrincipal principal, String action) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { + Task task = createTask("assertNotAuthorized", principal); + assertNotAuthorized(principal, action, null, task, task.getResult()); + assertNotAuthorized(principal, action, AuthorizationPhaseType.REQUEST, task, task.getResult()); + assertNotAuthorized(principal, action, AuthorizationPhaseType.EXECUTION, task, task.getResult()); + assertSuccess(task.getResult()); + } + + protected void assertNotAuthorized(MidPointPrincipal principal, String action, AuthorizationPhaseType phase) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { + Task task = createTask("assertNotAuthorized", principal); + assertNotAuthorized(principal, action, phase, task, task.getResult()); + assertSuccess(task.getResult()); + } + + protected void assertNotAuthorized(MidPointPrincipal principal, String action, AuthorizationPhaseType phase, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { + SecurityContext origContext = SecurityContextHolder.getContext(); + createSecurityContext(principal); + boolean isAuthorized = securityEnforcer.isAuthorized(action, phase, AuthorizationParameters.EMPTY, null, task, result); + SecurityContextHolder.setContext(origContext); + assertFalse("AuthorizationEvaluator.isAuthorized: Principal " + principal + " IS authorized for action " + action + " (" + phase + ") but he should not be", isAuthorized); + } + + protected void assertAuthorizations(PrismObject user, String... expectedAuthorizations) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + MidPointPrincipal principal = focusProfileService.getPrincipal(user); + assertNotNull("No principal for "+user, principal); + assertAuthorizations(principal, expectedAuthorizations); + } + + protected void assertAuthorizations(MidPointPrincipal principal, String... expectedAuthorizations) { + List actualAuthorizations = new ArrayList<>(); + for (Authorization authorization: principal.getAuthorities()) { + actualAuthorizations.addAll(authorization.getAction()); + } + PrismAsserts.assertSets("Wrong authorizations in "+principal, actualAuthorizations, expectedAuthorizations); + } + + + protected void assertNoAuthorizations(PrismObject user) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + MidPointPrincipal principal = focusProfileService.getPrincipal(user); + assertNotNull("No principal for "+user, principal); + assertNoAuthorizations(principal); + } + + protected void assertNoAuthorizations(MidPointPrincipal principal) { + if (principal.getAuthorities() != null && !principal.getAuthorities().isEmpty()) { + AssertJUnit.fail("Unexpected authorizations in "+principal+": "+principal.getAuthorities()); + } + } + + protected CompiledGuiProfileAsserter assertCompiledGuiProfile(MidPointPrincipal principal) { + if (!(principal instanceof GuiProfiledPrincipal)) { + fail("Expected GuiProfiledPrincipal, but got "+principal.getClass()); + } + CompiledGuiProfile compiledGuiProfile = ((GuiProfiledPrincipal)principal).getCompiledGuiProfile(); + CompiledGuiProfileAsserter asserter = new CompiledGuiProfileAsserter<>(compiledGuiProfile, null, "in principal "+principal); + initializeAsserter(asserter); + asserter.display(); + return asserter; + } + + protected CompiledGuiProfileAsserter assertCompiledGuiProfile(CompiledGuiProfile compiledGuiProfile) { + CompiledGuiProfileAsserter asserter = new CompiledGuiProfileAsserter<>(compiledGuiProfile, null, null); + initializeAsserter(asserter); + asserter.display(); + return asserter; + } + + protected EvaluatedPolicyRulesAsserter assertEvaluatedPolicyRules(Collection evaluatedPolicyRules) { + EvaluatedPolicyRulesAsserter asserter = new EvaluatedPolicyRulesAsserter<>(evaluatedPolicyRules, null, null); + initializeAsserter(asserter); + asserter.display(); + return asserter; + } + + protected EvaluatedPolicyRulesAsserter assertEvaluatedPolicyRules(Collection evaluatedPolicyRules, PrismObject sourceObject) { + EvaluatedPolicyRulesAsserter asserter = new EvaluatedPolicyRulesAsserter<>(evaluatedPolicyRules, null, sourceObject.toString()); + initializeAsserter(asserter); + asserter.display(); + return asserter; + } + + protected void createSecurityContext(MidPointPrincipal principal) { + SecurityContext context = new SecurityContextImpl(); + Authentication authentication = new UsernamePasswordAuthenticationToken(principal, null); + context.setAuthentication(authentication); + SecurityContextHolder.setContext(context); + } + + protected Object createSecureObject() { + return new FilterInvocation("/midpoint", "whateverServlet", "doSomething"); + } + + protected Collection createConfigAttributes(String action) { + Collection attrs = new ArrayList<>(); + attrs.add(new SecurityConfig(action)); + return attrs; + } + + protected PrismObjectDefinition getEditObjectDefinition(PrismObject object) throws SchemaException, ConfigurationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, SecurityViolationException { + Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".getEditObjectDefinition"); + OperationResult result = task.getResult(); + PrismObjectDefinition editSchema = modelInteractionService.getEditObjectDefinition(object, null, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + return editSchema; + } + + protected RoleSelectionSpecification getAssignableRoleSpecification(PrismObject targetHolder) throws ObjectNotFoundException, SchemaException, ConfigurationException, ExpressionEvaluationException, CommunicationException, SecurityViolationException { + return getAssignableRoleSpecification(targetHolder, 0); + } + + protected RoleSelectionSpecification getAssignableRoleSpecification(PrismObject focus, int assignmentOrder) throws ObjectNotFoundException, SchemaException, ConfigurationException, ExpressionEvaluationException, CommunicationException, SecurityViolationException { + return getAssignableRoleSpecification(focus, AbstractRoleType.class, 0); + } + + protected RoleSelectionSpecification getAssignableRoleSpecification(PrismObject focus, Class targetType, int assignmentOrder) throws ObjectNotFoundException, SchemaException, ConfigurationException, ExpressionEvaluationException, CommunicationException, SecurityViolationException { + Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".getAssignableRoleSpecification"); + OperationResult result = task.getResult(); + RoleSelectionSpecification spec = modelInteractionService.getAssignableRoleSpecification(focus, targetType, assignmentOrder, task, result); + assertSuccess(result); + return spec; + } + + protected RoleSelectionSpecificationAsserter assertAssignableRoleSpecification(PrismObject targetHolder) throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException { + RoleSelectionSpecification spec = getAssignableRoleSpecification(targetHolder); + RoleSelectionSpecificationAsserter asserter = new RoleSelectionSpecificationAsserter(spec, null, "for holder "+targetHolder); + initializeAsserter(asserter); + asserter.display(); + return asserter; + } + + protected RoleSelectionSpecificationAsserter assertAssignableRoleSpecification(PrismObject targetHolder, int order) throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException { + RoleSelectionSpecification spec = getAssignableRoleSpecification(targetHolder, order); + RoleSelectionSpecificationAsserter asserter = new RoleSelectionSpecificationAsserter(spec, null, "for holder "+targetHolder+", order "+order); + initializeAsserter(asserter); + asserter.display(); + return asserter; + } + + protected RoleSelectionSpecificationAsserter assertAssignableRoleSpecification(PrismObject targetHolder, Class roleType, int order) throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException { + RoleSelectionSpecification spec = getAssignableRoleSpecification(targetHolder, roleType, order); + RoleSelectionSpecificationAsserter asserter = new RoleSelectionSpecificationAsserter(spec, null, "for holder "+targetHolder+", role type "+roleType.getSimpleName()+", order "+order); + initializeAsserter(asserter); + asserter.display(); + return asserter; + } + + protected void assertAllowRequestAssignmentItems(String userOid, String targetRoleOid, ItemPath... expectedAllowedItemPaths) + throws SchemaException, SecurityViolationException, CommunicationException, ObjectNotFoundException, ConfigurationException, ExpressionEvaluationException { + Task task = createTask(AbstractModelIntegrationTest.class.getName() + ".assertAllowRequestItems"); + OperationResult result = task.getResult(); + assertAllowRequestAssignmentItems(userOid, targetRoleOid, task, result, expectedAllowedItemPaths); + assertSuccess(result); + } + + protected void assertAllowRequestAssignmentItems(String userOid, String targetRoleOid, Task task, OperationResult result, ItemPath... expectedAllowedItemPaths) + throws SchemaException, SecurityViolationException, CommunicationException, ObjectNotFoundException, ConfigurationException, ExpressionEvaluationException { + PrismObject user = getUser(userOid); + PrismObject target = getRole(targetRoleOid); + + ItemSecurityConstraints constraints = modelInteractionService.getAllowedRequestAssignmentItems(user, target, task, result); + display("Request decisions for "+target, constraints); + + for (ItemPath expectedAllowedItemPath: expectedAllowedItemPaths) { + AuthorizationDecisionType decision = constraints.findItemDecision(expectedAllowedItemPath); + assertEquals("Wrong decision for item "+expectedAllowedItemPath, AuthorizationDecisionType.ALLOW, decision); + } + } + + + protected void assertEncryptedUserPassword(String userOid, String expectedClearPassword) throws EncryptionException, ObjectNotFoundException, SchemaException { + OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName()+".assertEncryptedUserPassword"); + PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + assertEncryptedUserPassword(user, expectedClearPassword); + } + + protected void assertEncryptedUserPassword(PrismObject user, String expectedClearPassword) throws EncryptionException { + UserType userType = user.asObjectable(); + ProtectedStringType protectedActualPassword = userType.getCredentials().getPassword().getValue(); + String actualClearPassword = protector.decryptString(protectedActualPassword); + assertEquals("Wrong password for "+user, expectedClearPassword, actualClearPassword); + } + + @Deprecated + protected void assertPasswordMetadata(PrismObject user, boolean create, XMLGregorianCalendar start, XMLGregorianCalendar end, String actorOid, String channel) { + PrismContainer metadataContainer = user.findContainer(PATH_CREDENTIALS_PASSWORD_METADATA); + assertNotNull("No password metadata in "+user, metadataContainer); + MetadataType metadataType = metadataContainer.getValue().asContainerable(); + assertMetadata("password metadata in "+user, metadataType, create, false, start, end, actorOid, channel); + } + + protected void assertPasswordMetadata(PrismObject user, QName credentialType, boolean create, XMLGregorianCalendar start, XMLGregorianCalendar end, String actorOid, String channel) { + PrismContainer metadataContainer = user.findContainer(ItemPath.create(UserType.F_CREDENTIALS, credentialType, PasswordType.F_METADATA)); + assertNotNull("No password metadata in "+user, metadataContainer); + MetadataType metadataType = metadataContainer.getValue().asContainerable(); + assertMetadata("password metadata in "+user, metadataType, create, false, start, end, actorOid, channel); + } + + protected void assertCreateMetadata(PrismObject object, XMLGregorianCalendar start, XMLGregorianCalendar end) { + MetadataType metadataType = object.asObjectable().getMetadata(); + PrismObject defaultActor = getDefaultActor(); + assertMetadata(object.toString(), metadataType, true, true, start, end, + defaultActor==null?null:defaultActor.getOid(), DEFAULT_CHANNEL); + } + + protected void assertModifyMetadata(PrismObject object, XMLGregorianCalendar start, XMLGregorianCalendar end) { + MetadataType metadataType = object.asObjectable().getMetadata(); + PrismObject defaultActor = getDefaultActor(); + assertMetadata(object.toString(), metadataType, false, false, start, end, + defaultActor==null?null:defaultActor.getOid(), DEFAULT_CHANNEL); + } + + protected void assertCreateMetadata(AssignmentType assignmentType, XMLGregorianCalendar start, XMLGregorianCalendar end) { + MetadataType metadataType = assignmentType.getMetadata(); + PrismObject defaultActor = getDefaultActor(); + assertMetadata(assignmentType.toString(), metadataType, true, true, start, end, + defaultActor==null?null:defaultActor.getOid(), DEFAULT_CHANNEL); + } + + protected void assertDummyPassword(String instance, String userId, String expectedClearPassword) throws SchemaViolationException, ConflictException, InterruptedException { + DummyAccount account = getDummyAccount(instance, userId); + assertNotNull("No dummy account "+userId, account); + assertEquals("Wrong password in dummy '"+instance+"' account "+userId, expectedClearPassword, account.getPassword()); + } + + protected void assertDummyPasswordNotEmpty(String instance, String userId) throws SchemaViolationException, ConflictException, InterruptedException { + DummyAccount account = getDummyAccount(instance, userId); + assertNotNull("No dummy account "+userId, account); + String actualPassword = account.getPassword(); + if (actualPassword == null || actualPassword.isEmpty()) { + fail("Empty password in dummy '"+instance+"' account "+userId); + } + } + + protected void reconcileUser(String oid, Task task, OperationResult result) throws CommunicationException, ObjectAlreadyExistsException, ExpressionEvaluationException, PolicyViolationException, SchemaException, SecurityViolationException, ConfigurationException, ObjectNotFoundException { + reconcileUser(oid, null, task, result); + } + + protected void reconcileUser(String oid, ModelExecuteOptions options, Task task, OperationResult result) throws CommunicationException, ObjectAlreadyExistsException, ExpressionEvaluationException, PolicyViolationException, SchemaException, SecurityViolationException, ConfigurationException, ObjectNotFoundException { + ObjectDelta emptyDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, oid); + modelService.executeChanges(MiscSchemaUtil.createCollection(emptyDelta), ModelExecuteOptions.createReconcile(options), task, result); + } + + protected void reconcileOrg(String oid, Task task, OperationResult result) throws CommunicationException, ObjectAlreadyExistsException, ExpressionEvaluationException, PolicyViolationException, SchemaException, SecurityViolationException, ConfigurationException, ObjectNotFoundException { + ObjectDelta emptyDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(OrgType.class, oid); + modelService.executeChanges(MiscSchemaUtil.createCollection(emptyDelta), ModelExecuteOptions.createReconcile(), task, result); + } + + protected void assertRefEquals(String message, ObjectReferenceType expected, ObjectReferenceType actual) { + if (expected == null && actual == null) { + return; + } + if (expected == null || actual == null) { + fail(message + ": expected=" + expected + ", actual=" + actual); + } + PrismAsserts.assertRefEquivalent(message, expected.asReferenceValue(), actual.asReferenceValue()); + } + + protected void assertTaskClosed(PrismObject task) { + assertEquals("Wrong executionStatus in "+task, TaskExecutionStatusType.CLOSED, task.asObjectable().getExecutionStatus()); + } + + protected void assertTaskClosed(Task task) { + assertEquals("Wrong executionStatus in "+task, TaskExecutionStatus.CLOSED, task.getExecutionStatus()); + } + + protected List getAllAuditRecords(Task task, OperationResult result) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { + Map params = new HashMap<>(); + return modelAuditService.listRecords("select * from m_audit_event as aer order by aer.timestampValue asc", params, task, result); + } + + protected List getAuditRecords(int maxRecords, Task task, OperationResult result) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { + Map params = new HashMap<>(); + params.put("setMaxResults", maxRecords); + return modelAuditService.listRecords("select * from m_audit_event as aer order by aer.timestampValue asc", params, task, result); + } + + protected List getObjectAuditRecords(String oid) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { + Task task = createTask("getObjectAuditRecords"); + OperationResult result = task.getResult(); + return getObjectAuditRecords(oid, task, result); + } + + protected List getObjectAuditRecords(String oid, Task task, OperationResult result) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { + Map params = new HashMap<>(); + params.put("targetOid", oid); + return modelAuditService.listRecords("select * from m_audit_event as aer where (aer.targetOid = :targetOid) order by aer.timestampValue asc", + params, task, result); + } + + protected List getParamAuditRecords(String paramName, String paramValue, Task task, OperationResult result) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { + Map params = new HashMap<>(); + params.put("paramName", paramName); + params.put("paramValue", paramValue); + return modelAuditService.listRecords("select * from m_audit_event as aer left join aer.propertyValues as pv where (pv.name = :paramName and pv.value = :paramValue) order by aer.timestampValue asc", + params, task, result); + } + + protected List getAuditRecordsFromTo(XMLGregorianCalendar from, XMLGregorianCalendar to) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { + Task task = createTask("getAuditRecordsFromTo"); + OperationResult result = task.getResult(); + return getAuditRecordsFromTo(from, to, task, result); + } + + protected List getAuditRecordsFromTo(XMLGregorianCalendar from, XMLGregorianCalendar to, Task task, OperationResult result) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { + Map params = new HashMap<>(); + params.put("from", from); + params.put("to", to); + return modelAuditService.listRecords("select * from m_audit_event as aer where (aer.timestampValue >= :from) and (aer.timestampValue <= :to) order by aer.timestampValue asc", + params, task, result); + } + + protected void checkUserApprovers(String oid, List expectedApprovers, OperationResult result) throws SchemaException, ObjectNotFoundException { + PrismObject user = repositoryService.getObject(UserType.class, oid, null, result); + checkApprovers(user, expectedApprovers, user.asObjectable().getMetadata().getModifyApproverRef(), result); + } + + protected void checkUserApproversForCreate(String oid, List expectedApprovers, OperationResult result) throws SchemaException, ObjectNotFoundException { + PrismObject user = repositoryService.getObject(UserType.class, oid, null, result); + checkApprovers(user, expectedApprovers, user.asObjectable().getMetadata().getCreateApproverRef(), result); + } + + protected void checkApproversForCreate(Class clazz, String oid, List expectedApprovers, OperationResult result) throws SchemaException, ObjectNotFoundException { + PrismObject object = repositoryService.getObject(clazz, oid, null, result); + checkApprovers(object, expectedApprovers, object.asObjectable().getMetadata().getCreateApproverRef(), result); + } + + protected void checkApprovers(PrismObject object, List expectedApprovers, List realApprovers, OperationResult result) throws SchemaException, ObjectNotFoundException { + HashSet realApproversSet = new HashSet<>(); + for (ObjectReferenceType approver : realApprovers) { + realApproversSet.add(approver.getOid()); + assertEquals("Unexpected target type in approverRef", UserType.COMPLEX_TYPE, approver.getType()); + } + assertEquals("Mismatch in approvers in metadata", new HashSet(expectedApprovers), realApproversSet); + } + + protected PrismObject findUserInRepo(String name, OperationResult result) throws SchemaException { + List> users = findUserInRepoUnchecked(name, result); + assertEquals("Didn't find exactly 1 user object with name " + name, 1, users.size()); + return users.get(0); + } + + protected List> findUserInRepoUnchecked(String name, OperationResult result) throws SchemaException { + ObjectQuery q = prismContext.queryFor(UserType.class).item(UserType.F_NAME).eqPoly(name).matchingOrig().build(); + return repositoryService.searchObjects(UserType.class, q, null, result); + } + + protected List> findRoleInRepoUnchecked(String name, OperationResult result) throws SchemaException { + ObjectQuery q = prismContext.queryFor(RoleType.class).item(RoleType.F_NAME).eqPoly(name).matchingOrig().build(); + return repositoryService.searchObjects(RoleType.class, q, null, result); + } + + protected void assertFocusModificationSanity(ModelContext context) throws JAXBException { + ModelElementContext focusContext = context.getFocusContext(); + PrismObject focusOld = focusContext.getObjectOld(); + if (focusOld == null) { + return; + } + ObjectDelta focusPrimaryDelta = focusContext.getPrimaryDelta(); + if (focusPrimaryDelta != null) { + assertEquals("No OID in old focus object", focusOld.getOid(), focusPrimaryDelta.getOid()); + assertEquals(ChangeType.MODIFY, focusPrimaryDelta.getChangeType()); + assertNull(focusPrimaryDelta.getObjectToAdd()); + for (ItemDelta itemMod : focusPrimaryDelta.getModifications()) { + if (itemMod.getValuesToDelete() != null) { + Item property = focusOld.findItem(itemMod.getPath()); + assertNotNull("Deleted item " + itemMod.getParentPath() + "/" + itemMod.getElementName() + " not found in focus", property); + for (Object valueToDelete : itemMod.getValuesToDelete()) { + if (!property.contains((PrismValue) valueToDelete, EquivalenceStrategy.REAL_VALUE)) { + display("Deleted value " + valueToDelete + " is not in focus item " + itemMod.getParentPath() + "/" + itemMod.getElementName()); + display("Deleted value", valueToDelete); + display("HASHCODE: " + valueToDelete.hashCode()); + for (Object value : property.getValues()) { + display("Existing value", value); + display("EQUALS: " + valueToDelete.equals(value)); + display("HASHCODE: " + value.hashCode()); + } + fail("Deleted value " + valueToDelete + " is not in focus item " + itemMod.getParentPath() + "/" + itemMod.getElementName()); + } + } + } + + } + } + } + + protected PrismObject getUserFromRepo(String oid, OperationResult result) throws SchemaException, ObjectNotFoundException { + return repositoryService.getObject(UserType.class, oid, null, result); + } + + protected boolean assignmentExists(List assignmentList, String targetOid) { + for (AssignmentType assignmentType : assignmentList) { + if (assignmentType.getTargetRef() != null && targetOid.equals(assignmentType.getTargetRef().getOid())) { + return true; + } + } + return false; + } + + // just guessing (good enough for testing) + protected boolean isH2() { + Task task = createTask("isH2"); + RepositoryDiag diag = modelDiagnosticService.getRepositoryDiag(task, task.getResult()); + return diag.isEmbedded() || "org.h2.Driver".equals(diag.getDriverShortName()); + } + + protected void assertNoPostponedOperation(PrismObject shadow) { + List pendingOperations = shadow.asObjectable().getPendingOperation(); + if (!pendingOperations.isEmpty()) { + AssertJUnit.fail("Expected no pending operations in "+shadow+", but found one: "+pendingOperations); + } + } + + protected String addAndRecomputeUser(File file, Task initTask, OperationResult initResult) throws Exception { + String oid = repoAddObjectFromFile(file, initResult).getOid(); + recomputeUser(oid, initTask, initResult); + display("User " + file, getUser(oid)); + return oid; + } + + protected String addAndRecompute(File file, Task task, OperationResult result) throws Exception { + PrismObject object = repoAddObjectFromFile(file, result); + modelService.recompute(object.asObjectable().getClass(), object.getOid(), null, task, result); + display("Object: " + file, getObject(object.asObjectable().getClass(), object.getOid())); + return object.getOid(); + } + + protected void assertAuditReferenceValue(List events, String refName, String oid, QName type, String name) { + if (events.size() != 1) { + display("Events", events); + assertEquals("Wrong # of events", 1, events.size()); + } + assertAuditReferenceValue(events.get(0), refName, oid, type, name); + } + + protected void assertAuditReferenceValue(AuditEventRecord event, String refName, String oid, QName type, String name) { + Set values = event.getReferenceValues(refName); + assertEquals("Wrong # of reference values of '" + refName + "'", 1, values.size()); + AuditReferenceValue value = values.iterator().next(); + assertEquals("Wrong OID", oid, value.getOid()); + assertEquals("Wrong type", type, value.getType()); + assertEquals("Wrong name", name, PolyString.getOrig(value.getTargetName())); + } + + protected void assertAuditTarget(AuditEventRecord event, String oid, QName type, String name) { + PrismReferenceValue target = event.getTarget(); + assertNotNull("No target", target); + assertEquals("Wrong OID", oid, target.getOid()); + assertEquals("Wrong type", type, target.getTargetType()); + assertEquals("Wrong name", name, PolyString.getOrig(target.getTargetName())); + } + + protected List filter(List records, AuditEventStage stage) { + return records.stream() + .filter(r -> r.getEventStage() == stage) + .collect(Collectors.toList()); + } + + protected List filter(List records, AuditEventType type, AuditEventStage stage) { + return records.stream() + .filter(r -> r.getEventType() == type && r.getEventStage() == stage) + .collect(Collectors.toList()); + } + + protected void resetTriggerTask(String taskOid, File taskFile, OperationResult result) + throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException, FileNotFoundException { + taskManager.suspendAndDeleteTasks(Collections.singletonList(taskOid), 60000L, true, result); + importObjectFromFile(taskFile, result); + taskManager.suspendTasks(Collections.singletonList(taskOid), 60000L, result); + modifySystemObjectInRepo(TaskType.class, taskOid, + prismContext.deltaFor(TaskType.class) + .item(TaskType.F_SCHEDULE).replace() + .asItemDeltas(), + result); + taskManager.resumeTasks(singleton(taskOid), result); + } + + protected void repoAddObjects(List objects, OperationResult result) + throws EncryptionException, ObjectAlreadyExistsException, SchemaException { + for (ObjectType object : objects) { + repoAddObject(object.asPrismObject(), result); + } + } + + protected void recomputeAndRefreshObjects(List objects, Task task, OperationResult result) + throws CommunicationException, ObjectNotFoundException, ObjectAlreadyExistsException, ConfigurationException, + SchemaException, SecurityViolationException, PolicyViolationException, ExpressionEvaluationException { + for (int i = 0; i < objects.size(); i++) { + ObjectType object = objects.get(i); + modelService.recompute(object.getClass(), object.getOid(), null, task, result); + objects.set(i, repositoryService.getObject(object.getClass(), object.getOid(), null, result).asObjectable()); + } + } + + protected void dumpAllUsers(OperationResult initResult) throws SchemaException { + SearchResultList> users = repositoryService + .searchObjects(UserType.class, null, null, initResult); + display("Users", users); + } + + protected PrismObject

assertLinkedPersona(PrismObject focus, Class

personaClass, String subtype) throws ObjectNotFoundException, SchemaException { + OperationResult result = new OperationResult("assertLinkedPersona"); + for (ObjectReferenceType personaRef: focus.asObjectable().getPersonaRef()) { + PrismObject

persona = repositoryService.getObject((Class

)ObjectTypes.getObjectTypeFromTypeQName(personaRef.getType()).getClassDefinition(), + personaRef.getOid(), null, result); + if (isTypeAndSubtype(persona, personaClass, subtype)) { + return persona; + } + } + fail("No persona "+personaClass.getSimpleName()+"/"+subtype+" in "+focus); + return null; // not reached + } + + protected boolean isTypeAndSubtype(PrismObject focus, Class expectedType, String subtype) { + if (!expectedType.isAssignableFrom(focus.getCompileTimeClass())) { + return false; + } + if (!FocusTypeUtil.hasSubtype(focus, subtype)) { + return false; + } + return true; + } + + protected PrismObject getOrg(String orgName) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + PrismObject org = findObjectByName(OrgType.class, orgName); + assertNotNull("The org "+orgName+" is missing!", org); + display("Org "+orgName, org); + PrismAsserts.assertPropertyValue(org, OrgType.F_NAME, createPolyString(orgName)); + return org; + } + + protected void dumpOrgTree() throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + display("Org tree", dumpOrgTree(getTopOrgOid())); + } + + protected void dumpOrgTreeAndUsers() throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + display("Org tree", dumpOrgTree(getTopOrgOid(), true)); + } + + protected String getTopOrgOid() { + return null; + } + + protected void transplantGlobalPolicyRulesAdd(File configWithGlobalRulesFile, Task task, OperationResult parentResult) throws SchemaException, IOException, ObjectNotFoundException, ObjectAlreadyExistsException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + // copy rules from the file into live system config object + PrismObject rules = prismContext.parserFor(configWithGlobalRulesFile).parse(); + ObjectDelta delta = prismContext.deltaFor(SystemConfigurationType.class) + .item(SystemConfigurationType.F_GLOBAL_POLICY_RULE).add( + rules.asObjectable().getGlobalPolicyRule().stream() + .map(r -> r.clone().asPrismContainerValue()) + .collect(Collectors.toList())) + .asObjectDeltaCast(SystemObjectsType.SYSTEM_CONFIGURATION.value()); + modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, parentResult); + } + + protected void displayProvisioningScripts() { + displayProvisioningScripts(null); + } + + protected void displayProvisioningScripts(String dummyName) { + display("Provisioning scripts "+dummyName, getDummyResource(dummyName).getScriptHistory()); + } + + protected void purgeProvisioningScriptHistory() { + purgeProvisioningScriptHistory(null); + } + + protected void purgeProvisioningScriptHistory(String dummyName) { + getDummyResource(dummyName).purgeScriptHistory(); + } + + protected void assertNoProvisioningScripts() { + if (!getDummyResource().getScriptHistory().isEmpty()) { + IntegrationTestTools.displayScripts(getDummyResource().getScriptHistory()); + AssertJUnit.fail(getDummyResource().getScriptHistory().size()+" provisioning scripts were executed while not expected any"); + } + } + + protected void assertDummyProvisioningScriptsNone() { + IntegrationTestTools.assertScripts(getDummyResource().getScriptHistory()); + } + + protected void applyPasswordPolicy(String passwordPolicyOid, String securityPolicyOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + if (passwordPolicyOid == null) { + modifyObjectReplaceReference(SecurityPolicyType.class, securityPolicyOid, PATH_CREDENTIALS_PASSWORD_VALUE_POLICY_REF, + task, result /* no value */); + } else { + PrismReferenceValue passPolicyRef = itemFactory().createReferenceValue(passwordPolicyOid, ValuePolicyType.COMPLEX_TYPE); + modifyObjectReplaceReference(SecurityPolicyType.class, securityPolicyOid, PATH_CREDENTIALS_PASSWORD_VALUE_POLICY_REF, + task, result, passPolicyRef); + } + } + + protected void assertPasswordCompliesWithPolicy(PrismObject user, String passwordPolicyOid) throws EncryptionException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { + Task task = createTask("assertPasswordCompliesWithPolicy"); + OperationResult result = task.getResult(); + assertPasswordCompliesWithPolicy(user, passwordPolicyOid, task, result); + assertSuccess(result); + } + + protected void assertPasswordCompliesWithPolicy(PrismObject user, String passwordPolicyOid, Task task, OperationResult result) throws EncryptionException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { + String password = getPassword(user); + display("Password of "+user, password); + PrismObject passwordPolicy = repositoryService.getObject(ValuePolicyType.class, passwordPolicyOid, null, result); + List messages = new ArrayList<>(); + boolean valid = valuePolicyProcessor.validateValue(password, passwordPolicy.asObjectable(), createUserOriginResolver(user), messages, "validating password of "+user, task, result); + if (!valid) { + fail("Password for "+user+" does not comply with password policy: "+messages); + } + } + + protected FocusValuePolicyOriginResolver createUserOriginResolver(PrismObject user) { + if (user != null) { + return new FocusValuePolicyOriginResolver<>(user, modelObjectResolver); + } else { + return null; + } + } + + protected List> getTasksForObject(String oid, QName type, + Collection> options, Task task, OperationResult result) + throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, + ConfigurationException, ExpressionEvaluationException { + ObjectQuery query = prismContext.queryFor(TaskType.class) + .item(TaskType.F_OBJECT_REF).ref(itemFactory().createReferenceValue(oid, type)) + .build(); + return modelService.searchObjects(TaskType.class, query, options, task, result); + } + + protected List> getCasesForObject(String oid, QName type, + Collection> options, Task task, OperationResult result) + throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, + ConfigurationException, ExpressionEvaluationException { + ObjectQuery query = prismContext.queryFor(CaseType.class) + .item(CaseType.F_OBJECT_REF).ref(itemFactory().createReferenceValue(oid, type)) + .build(); + return modelService.searchObjects(CaseType.class, query, options, task, result); + } + + protected CaseType getApprovalCase(List> cases) { + List rv = cases.stream() + .filter(o -> ObjectTypeUtil.hasArchetype(o, SystemObjectsType.ARCHETYPE_APPROVAL_CASE.value())) + .map(o -> o.asObjectable()) + .collect(Collectors.toList()); + if (rv.isEmpty()) { + throw new AssertionError("No approval case found"); + } else if (rv.size() > 1) { + throw new AssertionError("More than one approval case found: " + rv); + } else { + return rv.get(0); + } + } + + protected CaseType getRootCase(List> cases) { + List rv = cases.stream() + .map(o -> o.asObjectable()) + .filter(c -> c.getParentRef() == null) + .collect(Collectors.toList()); + if (rv.isEmpty()) { + throw new AssertionError("No root case found"); + } else if (rv.size() > 1) { + throw new AssertionError("More than one root case found: " + rv); + } else { + return rv.get(0); + } + } + + @SuppressWarnings("unused") // maybe in the future :) + protected Consumer createShowTaskTreeConsumer(long period) { + AtomicLong lastTimeShown = new AtomicLong(0); + return task -> { + try { + if (lastTimeShown.get() + period < System.currentTimeMillis()) { + dumpTaskTree(task.getOid(), getResult()); + lastTimeShown.set(System.currentTimeMillis()); + } + } catch (CommonException e) { + throw new AssertionError(e); + } + }; + } + + // highly experimental + public class TestCtx { + public final String name; + + public final Task task; + public final OperationResult result; + + TestCtx(Object testCase, String name) { + this.name = name; + TestUtil.displayTestTitle(testCase, name); + task = taskManager.createTaskInstance(testCase.getClass().getName() + "." + name); + result = task.getResult(); + dummyAuditService.clear(); + } + + public void displayWhen() { + TestUtil.displayWhen(name); + } + + public void displayThen() { + TestUtil.displayThen(name); + } + } + + protected TestCtx createContext(Object testCase, String testName) { + return new TestCtx(testCase, testName); + } + + protected T runPrivileged(Producer producer) { + return securityContextManager.runPrivileged(producer); + } + + protected void assertPendingOperationDeltas(PrismObject shadow, int expectedNumber) { + List pendingOperations = shadow.asObjectable().getPendingOperation(); + assertEquals("Wrong number of pending operations in "+shadow, expectedNumber, pendingOperations.size()); + } + + protected PendingOperationType assertSinglePendingOperation(PrismObject shadow, + XMLGregorianCalendar requestStart, XMLGregorianCalendar requestEnd) { + return assertSinglePendingOperation(shadow, requestStart, requestEnd, + OperationResultStatusType.IN_PROGRESS, null, null); + } + + protected PendingOperationType assertSinglePendingOperation(PrismObject shadow, + PendingOperationExecutionStatusType expectedExecutionStatus, OperationResultStatusType expectedResultStatus) { + assertPendingOperationDeltas(shadow, 1); + return assertPendingOperation(shadow, shadow.asObjectable().getPendingOperation().get(0), + null, null, expectedExecutionStatus, expectedResultStatus, null, null); + } + + protected PendingOperationType assertSinglePendingOperation(PrismObject shadow, + XMLGregorianCalendar requestStart, XMLGregorianCalendar requestEnd, + OperationResultStatusType expectedStatus, + XMLGregorianCalendar completionStart, XMLGregorianCalendar completionEnd) { + assertPendingOperationDeltas(shadow, 1); + return assertPendingOperation(shadow, shadow.asObjectable().getPendingOperation().get(0), + requestStart, requestEnd, expectedStatus, completionStart, completionEnd); + } + + protected PendingOperationType assertPendingOperation( + PrismObject shadow, PendingOperationType pendingOperation, + XMLGregorianCalendar requestStart, XMLGregorianCalendar requestEnd) { + return assertPendingOperation(shadow, pendingOperation, requestStart, requestEnd, + OperationResultStatusType.IN_PROGRESS, null, null); + } + + protected PendingOperationType assertPendingOperation( + PrismObject shadow, PendingOperationType pendingOperation, + PendingOperationExecutionStatusType expectedExecutionStatus, OperationResultStatusType expectedResultStatus) { + return assertPendingOperation(shadow, pendingOperation, null, null, + expectedExecutionStatus, expectedResultStatus, null, null); + } + + protected PendingOperationType assertPendingOperation( + PrismObject shadow, PendingOperationType pendingOperation) { + return assertPendingOperation(shadow, pendingOperation, null, null, + OperationResultStatusType.IN_PROGRESS, null, null); + } + + protected PendingOperationType assertPendingOperation( + PrismObject shadow, PendingOperationType pendingOperation, + XMLGregorianCalendar requestStart, XMLGregorianCalendar requestEnd, + OperationResultStatusType expectedResultStatus, + XMLGregorianCalendar completionStart, XMLGregorianCalendar completionEnd) { + PendingOperationExecutionStatusType expectedExecutionStatus; + if (expectedResultStatus == OperationResultStatusType.IN_PROGRESS) { + expectedExecutionStatus = PendingOperationExecutionStatusType.EXECUTING; + } else { + expectedExecutionStatus = PendingOperationExecutionStatusType.COMPLETED; + } + return assertPendingOperation(shadow, pendingOperation, requestStart, requestEnd, expectedExecutionStatus, expectedResultStatus, completionStart, completionEnd); + } + + protected PendingOperationType assertPendingOperation( + PrismObject shadow, PendingOperationType pendingOperation, + XMLGregorianCalendar requestStart, XMLGregorianCalendar requestEnd, + PendingOperationExecutionStatusType expectedExecutionStatus, + OperationResultStatusType expectedResultStatus, + XMLGregorianCalendar completionStart, XMLGregorianCalendar completionEnd) { + assertNotNull("No operation ", pendingOperation); + + ObjectDeltaType deltaType = pendingOperation.getDelta(); + assertNotNull("No delta in pending operation in "+shadow, deltaType); + // TODO: check content of pending operations in the shadow + + TestUtil.assertBetween("No request timestamp in pending operation in "+shadow, requestStart, requestEnd, pendingOperation.getRequestTimestamp()); + + PendingOperationExecutionStatusType executiontStatus = pendingOperation.getExecutionStatus(); + assertEquals("Wrong execution status in pending operation in "+shadow, expectedExecutionStatus, executiontStatus); + + OperationResultStatusType resultStatus = pendingOperation.getResultStatus(); + assertEquals("Wrong result status in pending operation in "+shadow, expectedResultStatus, resultStatus); + + // TODO: assert other timestamps + + if (expectedExecutionStatus == PendingOperationExecutionStatusType.COMPLETED) { + TestUtil.assertBetween("No completion timestamp in pending operation in "+shadow, completionStart, completionEnd, pendingOperation.getCompletionTimestamp()); + } + + return pendingOperation; + } + + protected PendingOperationType findPendingOperation(PrismObject shadow, + PendingOperationExecutionStatusType expectedExecutionStaus) { + return findPendingOperation(shadow, expectedExecutionStaus, null, null, null); + } + + protected PendingOperationType findPendingOperation(PrismObject shadow, + OperationResultStatusType expectedResult) { + return findPendingOperation(shadow, null, expectedResult, null, null); + } + + protected PendingOperationType findPendingOperation(PrismObject shadow, + OperationResultStatusType expectedResult, ItemPath itemPath) { + return findPendingOperation(shadow, null, expectedResult, null, itemPath); + } + + protected PendingOperationType findPendingOperation(PrismObject shadow, + PendingOperationExecutionStatusType expectedExecutionStaus, ItemPath itemPath) { + return findPendingOperation(shadow, expectedExecutionStaus, null, null, itemPath); + } + + protected PendingOperationType findPendingOperation(PrismObject shadow, + OperationResultStatusType expectedResult, ChangeTypeType expectedChangeType) { + return findPendingOperation(shadow, null, expectedResult, expectedChangeType, null); + } + + protected PendingOperationType findPendingOperation(PrismObject shadow, + PendingOperationExecutionStatusType expectedExecutionStatus, OperationResultStatusType expectedResult, + ChangeTypeType expectedChangeType, ItemPath itemPath) { + List pendingOperations = shadow.asObjectable().getPendingOperation(); + for (PendingOperationType pendingOperation: pendingOperations) { + if (expectedExecutionStatus != null && !expectedExecutionStatus.equals(pendingOperation.getExecutionStatus())) { + continue; + } + if (expectedResult != null && !expectedResult.equals(pendingOperation.getResultStatus())) { + continue; + } + ObjectDeltaType delta = pendingOperation.getDelta(); + if (expectedChangeType != null) { + if (!expectedChangeType.equals(delta.getChangeType())) { + continue; + } + } + if (itemPath == null) { + return pendingOperation; + } + assertNotNull("No delta in pending operation in "+shadow, delta); + for (ItemDeltaType itemDelta: delta.getItemDelta()) { + ItemPath deltaPath = itemDelta.getPath().getItemPath(); + if (itemPath.equivalent(deltaPath)) { + return pendingOperation; + } + } + } + return null; + } + + protected UserAsserter assertUserAfter(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + UserAsserter asserter = assertUser(oid, "after"); + asserter.assertOid(oid); + return asserter; + } + + protected UserAsserter assertUserAfterByUsername(String username) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + UserAsserter asserter = assertUserByUsername(username, "after"); + asserter.display(); + asserter.assertName(username); + return asserter; + } + + protected UserAsserter assertUserBefore(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + UserAsserter asserter = assertUser(oid, "before"); + asserter.assertOid(oid); + return asserter; + } + + protected UserAsserter assertUserBeforeByUsername(String username) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + UserAsserter asserter = assertUserByUsername(username, "before"); + asserter.display(); + asserter.assertName(username); + return asserter; + } + + protected UserAsserter assertUser(String oid, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + PrismObject user = getUser(oid); + return assertUser(user, message); + } + protected RepoOpAsserter createRepoOpAsserter(PerformanceInformation performanceInformation, String details) { + return new RepoOpAsserter(performanceInformation, details); + } + + protected RepoOpAsserter createRepoOpAsserter(String details) { + PerformanceInformation repoPerformanceInformation = repositoryService.getPerformanceMonitor().getThreadLocalPerformanceInformation(); + return new RepoOpAsserter(repoPerformanceInformation, details); + } + + protected UserAsserter assertUser(PrismObject user, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + UserAsserter asserter = UserAsserter.forUser(user, message); + initializeAsserter(asserter); + asserter.display(); + return asserter; + } + + protected UserAsserter assertUserByUsername(String username, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + PrismObject user = findUserByUsername(username); + assertNotNull("User with username '"+username+"' was not found", user); + UserAsserter asserter = UserAsserter.forUser(user, message); + initializeAsserter(asserter); + return asserter; + } + + protected OrgAsserter assertOrg(String oid, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + PrismObject org = getObject(OrgType.class, oid); + OrgAsserter asserter = assertOrg(org, message); + asserter.assertOid(oid); + return asserter; + } + + protected OrgAsserter assertOrg(PrismObject org, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + OrgAsserter asserter = OrgAsserter.forOrg(org, message); + initializeAsserter(asserter); + return asserter; + } + + protected OrgAsserter assertOrgAfter(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + OrgAsserter asserter = assertOrg(oid, "after"); + asserter.display(); + asserter.assertOid(oid); + return asserter; + } + + protected OrgAsserter assertOrgByName(String name, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + PrismObject org = findObjectByName(OrgType.class, name); + assertNotNull("No org with name '"+name+"'", org); + OrgAsserter asserter = OrgAsserter.forOrg(org, message); + initializeAsserter(asserter); + asserter.assertName(name); + return asserter; + } + + protected RoleAsserter assertRole(String oid, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + PrismObject role = getObject(RoleType.class, oid); + RoleAsserter asserter = assertRole(role, message); + asserter.assertOid(oid); + return asserter; + } + + protected RoleAsserter assertRoleByName(String name, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + PrismObject role = findObjectByName(RoleType.class, name); + assertNotNull("No role with name '"+name+"'", role); + RoleAsserter asserter = assertRole(role, message); + asserter.assertName(name); + return asserter; + } + + protected RoleAsserter assertRole(PrismObject role, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + RoleAsserter asserter = RoleAsserter.forRole(role, message); + initializeAsserter(asserter); + asserter.display(); + return asserter; + } + + protected RoleAsserter assertRoleBefore(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + RoleAsserter asserter = assertRole(oid, "before"); + return asserter; + } + + protected RoleAsserter assertRoleAfter(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + RoleAsserter asserter = assertRole(oid, "after"); + return asserter; + } + + protected RoleAsserter assertRoleAfterByName(String name) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + RoleAsserter asserter = assertRoleByName(name, "after"); + return asserter; + } + + protected FocusAsserter assertService(String oid, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + PrismObject service = getObject(ServiceType.class, oid); + // TODO: change to ServiceAsserter later + FocusAsserter asserter = FocusAsserter.forFocus(service, message); + initializeAsserter(asserter); + asserter.assertOid(oid); + return asserter; + } + + protected FocusAsserter assertServiceByName(String name, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + PrismObject service = findServiceByName(name); + // TODO: change to ServiceAsserter later + FocusAsserter asserter = FocusAsserter.forFocus(service, message); + initializeAsserter(asserter); + asserter.assertName(name); + return asserter; + } + + protected FocusAsserter assertServiceAfterByName(String name) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + return assertServiceByName(name, "after"); + } + + protected FocusAsserter assertServiceBeforeByName(String name) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + return assertServiceByName(name, "before"); + } + + protected FocusAsserter assertServiceAfter(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + return assertService(oid, "after"); + } + + protected FocusAsserter assertServiceBefore(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + return assertService(oid, "before"); + } + + protected void assertNoServiceByName(String name) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + PrismObject service = findServiceByName(name); + if (service != null) { + display("Unexpected service", service); + fail("Unexpected "+service); + } + } + + protected CaseAsserter assertCase(String oid, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + PrismObject acase = getObject(CaseType.class, oid); + CaseAsserter asserter = CaseAsserter.forCase(acase, message); + initializeAsserter(asserter); + asserter.assertOid(oid); + return asserter; + } + + protected CaseAsserter assertCaseAfter(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + CaseAsserter asserter = assertCase(oid, "after"); + asserter.display(); + asserter.assertOid(oid); + return asserter; + } + + protected ShadowAsserter assertModelShadow(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + PrismObject repoShadow = getShadowModel(oid); + ShadowAsserter asserter = ShadowAsserter.forShadow(repoShadow, "model"); + asserter + .display(); + return asserter; + } + + protected ShadowAsserter assertModelShadowNoFetch(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + PrismObject repoShadow = getShadowModelNoFetch(oid); + ShadowAsserter asserter = ShadowAsserter.forShadow(repoShadow, "model(noFetch)"); + asserter + .display(); + return asserter; + } + + protected ShadowAsserter assertModelShadowFuture(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + PrismObject repoShadow = getShadowModelFuture(oid); + ShadowAsserter asserter = ShadowAsserter.forShadow(repoShadow, "model(future)"); + asserter + .display(); + return asserter; + } + + protected ShadowAsserter assertModelShadowFutureNoFetch(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + GetOperationOptions options = GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE); + options.setNoFetch(true); + PrismObject repoShadow = getShadowModel(oid, options, true); + ShadowAsserter asserter = ShadowAsserter.forShadow(repoShadow, "model(future,noFetch)"); + asserter + .display(); + return asserter; + } + + protected void assertNoModelShadow(String oid) throws SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = createTask("assertNoModelShadow"); + OperationResult result = task.getResult(); + try { + PrismObject shadow = modelService.getObject(ShadowType.class, oid, null, task, result); + fail("Expected that shadow "+oid+" will not be in the model. But it was: "+shadow); + } catch (ObjectNotFoundException e) { + // Expected + assertFailure(result); + } + } + + protected void assertNoModelShadowFuture(String oid) throws SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = createTask("assertNoModelShadowFuture"); + OperationResult result = task.getResult(); + Collection> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); + try { + PrismObject shadow = modelService.getObject(ShadowType.class, oid, options, task, result); + fail("Expected that future shadow "+oid+" will not be in the model. But it was: "+shadow); + } catch (ObjectNotFoundException e) { + // Expected + assertFailure(result); + } + } + + protected ResourceAsserter assertResource(String oid, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + PrismObject resource = getObject(ResourceType.class, oid); + return assertResource(resource, message); + } + + protected ResourceAsserter assertResource(PrismObject user, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + ResourceAsserter asserter = ResourceAsserter.forResource(user, message); + initializeAsserter(asserter); + asserter.display(); + return asserter; + } + + protected ResourceAsserter assertResourceAfter(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + ResourceAsserter asserter = assertResource(oid, "after"); + asserter.assertOid(oid); + return asserter; + } + + // Change to PrismObjectDefinitionAsserter later + protected PrismContainerDefinitionAsserter assertObjectDefinition(PrismObjectDefinition objectDef) { + return assertContainerDefinition(objectDef); + } + + protected PrismContainerDefinitionAsserter assertContainerDefinition(PrismContainerDefinition containerDef) { + PrismContainerDefinitionAsserter asserter = PrismContainerDefinitionAsserter.forContainerDefinition(containerDef); + initializeAsserter(asserter); + asserter.display(); + return asserter; + } + + protected ModelContextAsserter assertPreviewContext(ModelContext previewContext) { + ModelContextAsserter asserter = ModelContextAsserter.forContext(previewContext, "preview context"); + initializeAsserter(asserter); + asserter.display(); + return asserter; + } + + protected OperationResultAsserter assertOperationResult(OperationResult result) { + OperationResultAsserter asserter = OperationResultAsserter.forResult(result); + initializeAsserter(asserter); + asserter.display(); + return asserter; + } + + // SECURITY + + protected void assertGetDeny(Class type, String oid) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + assertGetDeny(type, oid, null); + } + + protected void assertGetDeny(Class type, String oid, Collection> options) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertGetDeny"); + OperationResult result = task.getResult(); + try { + logAttempt("get", type, oid, null); + PrismObject object = modelService.getObject(type, oid, options, task, result); + failDeny("get", type, oid, null); + } catch (SecurityViolationException e) { + // this is expected + logDeny("get", type, oid, null); + result.computeStatus(); + TestUtil.assertFailure(result); + } + } + + protected PrismObject assertGetAllow(Class type, String oid) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + return assertGetAllow(type, oid, null); + } + + protected PrismObject assertGetAllow(Class type, String oid, Collection> options) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertGetAllow"); + OperationResult result = task.getResult(); + logAttempt("get", type, oid, null); + PrismObject object = modelService.getObject(type, oid, options, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + logAllow("get", type, oid, null); + return object; + } + + protected void assertSearchFilter(Class type, ObjectFilter filter, int expectedResults) throws Exception { + assertSearch(type, prismContext.queryFactory().createQuery(filter), null, expectedResults); + } + + protected SearchResultList> assertSearch(Class type, ObjectQuery query, int expectedResults) throws Exception { + return assertSearch(type, query, null, expectedResults); + } + + protected void assertSearchRaw(Class type, ObjectQuery query, int expectedResults) throws Exception { + assertSearch(type, query, SelectorOptions.createCollection(GetOperationOptions.createRaw()), expectedResults); + } + + protected void assertSearchDeny(Class type, ObjectQuery query, + Collection> options) throws Exception { + try { + assertSearch(type, query, options, 0); + } catch (SecurityViolationException e) { + // This is expected. The search should either return zero results or throw an exception. + logDeny("search"); + } + } + + + protected SearchResultList> assertSearch(Class type, ObjectQuery query, + Collection> options, int expectedResults) throws Exception { + ObjectQuery originalQuery = query != null ? query.clone() : null; + return assertSearch(type, query, options, + new SearchAssertion() { + + @Override + public void assertObjects(String message, List> objects) throws Exception { + if (objects.size() > expectedResults) { + failDeny(message, type, originalQuery, expectedResults, objects.size()); + } else if (objects.size() < expectedResults) { + failAllow(message, type, originalQuery, expectedResults, objects.size()); + } + } + + @Override + public void assertCount(int count) throws Exception { + if (count > expectedResults) { + failDeny("count", type, originalQuery, expectedResults, count); + } else if (count < expectedResults) { + failAllow("count", type, originalQuery, expectedResults, count); + } + } + + }); + } + + protected void assertSearch(Class type, ObjectQuery query, String... expectedOids) throws Exception { + assertSearch(type, query, null, expectedOids); + } + + protected void assertSearchFilter(Class type, ObjectFilter filter, + Collection> options, String... expectedOids) throws Exception { + assertSearch(type, prismContext.queryFactory().createQuery(filter), options, expectedOids); + } + + protected void assertSearchFilter(Class type, ObjectFilter filter, String... expectedOids) throws Exception { + assertSearch(type, prismContext.queryFactory().createQuery(filter), expectedOids); + } + + protected void assertSearch(Class type, ObjectQuery query, + Collection> options, String... expectedOids) throws Exception { + assertSearch(type, query, options, + new SearchAssertion() { + + @Override + public void assertObjects(String message, List> objects) throws Exception { + if (!MiscUtil.unorderedCollectionEquals(objects, Arrays.asList(expectedOids), + (object,expectedOid) -> expectedOid.equals(object.getOid()))) { + failAllow(message, type, (query==null?"null":query.toString())+", expected "+Arrays.toString(expectedOids)+", actual "+objects, null); + } + } + + @Override + public void assertCount(int count) throws Exception { + if (count != expectedOids.length) { + failAllow("count", type, query, expectedOids.length, count); + } + } + + }); + } + + protected SearchResultList> assertSearch(Class type, ObjectQuery query, + Collection> options, SearchAssertion assertion) throws Exception { + Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertSearchObjects"); + OperationResult result = task.getResult(); + SearchResultList> objects; + try { + logAttempt("search", type, query); + objects = modelService.searchObjects(type, query, options, task, result); + display("Search returned", objects.toString()); + assertion.assertObjects("search", objects); + assertSuccess(result); + } catch (SecurityViolationException e) { + // this should not happen + result.computeStatus(); + TestUtil.assertFailure(result); + failAllow("search", type, query, e); + return null; // not reached + } + + task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertSearchObjectsIterative"); + result = task.getResult(); + try { + logAttempt("searchIterative", type, query); + final List> iterativeObjects = new ArrayList<>(); + ResultHandler handler = new ResultHandler() { + @Override + public boolean handle(PrismObject object, OperationResult parentResult) { + iterativeObjects.add(object); + return true; + } + }; + modelService.searchObjectsIterative(type, query, handler, options, task, result); + display("Search iterative returned", iterativeObjects.toString()); + assertion.assertObjects("searchIterative", iterativeObjects); + assertSuccess(result); + } catch (SecurityViolationException e) { + // this should not happen + result.computeStatus(); + TestUtil.assertFailure(result); + failAllow("searchIterative", type, query, e); + return null; // not reached + } + + task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertSearchObjects.count"); + result = task.getResult(); + try { + logAttempt("count", type, query); + int numObjects = modelService.countObjects(type, query, options, task, result); + display("Count returned", numObjects); + assertion.assertCount(numObjects); + assertSuccess(result); + } catch (SecurityViolationException e) { + // this should not happen + result.computeStatus(); + TestUtil.assertFailure(result); + failAllow("search", type, query, e); + return null; // not reached + } + + return objects; + } + + + protected void assertAddDeny(File file) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, IOException { + assertAddDeny(file, null); + } + + protected void assertAddDenyRaw(File file) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, IOException { + assertAddDeny(file, ModelExecuteOptions.createRaw()); + } + + protected void assertAddDeny(File file, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, IOException { + PrismObject object = PrismTestUtil.parseObject(file); + assertAddDeny(object, options); + } + + protected void assertAddDeny(PrismObject object, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, IOException { + Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertAddDeny"); + OperationResult result = task.getResult(); + ObjectDelta addDelta = object.createAddDelta(); + try { + logAttempt("add", object.getCompileTimeClass(), object.getOid(), null); + modelService.executeChanges(MiscSchemaUtil.createCollection(addDelta), options, task, result); + failDeny("add", object.getCompileTimeClass(), object.getOid(), null); + } catch (SecurityViolationException e) { + // this is expected + logDeny("add", object.getCompileTimeClass(), object.getOid(), null); + result.computeStatus(); + TestUtil.assertFailure(result); + } + } + + protected void assertAddAllow(File file) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { + assertAddAllow(file, null); + } + + protected OperationResult assertAddAllowTracing(File file) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { + return assertAddAllowTracing(file, null); + } + + protected void assertAddAllow(File file, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { + PrismObject object = PrismTestUtil.parseObject(file); + assertAddAllow(object, options); + } + + protected OperationResult assertAddAllowTracing(File file, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { + PrismObject object = PrismTestUtil.parseObject(file); + return assertAddAllowTracing(object, options); + } + + protected OperationResult assertAddAllow(PrismObject object, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { + Task task = createAllowDenyTask(AbstractModelIntegrationTest.class.getName() + ".assertAddAllow"); + return assertAddAllow(object, options, task); + } + + protected OperationResult assertAddAllowTracing(PrismObject object, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { + Task task = createAllowDenyTask(AbstractModelIntegrationTest.class.getName() + ".assertAddAllow"); + setTracing(task, createDefaultTracingProfile()); + return assertAddAllow(object, options, task); + } + + protected OperationResult assertAddAllow(PrismObject object, ModelExecuteOptions options, Task task) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { + OperationResult result = task.getResult(); + ObjectDelta addDelta = object.createAddDelta(); + logAttempt("add", object.getCompileTimeClass(), object.getOid(), null); + try { + modelService.executeChanges(MiscSchemaUtil.createCollection(addDelta), options, task, result); + } catch (SecurityViolationException e) { + failAllow("add", object.getCompileTimeClass(), object.getOid(), null, e); + } + result.computeStatus(); + TestUtil.assertSuccess(result); + logAllow("add", object.getCompileTimeClass(), object.getOid(), null); + return result; + } + + protected void assertDeleteDeny(Class type, String oid) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + assertDeleteDeny(type, oid, null); + } + + protected void assertDeleteDeny(Class type, String oid, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertDeleteDeny"); + OperationResult result = task.getResult(); + ObjectDelta delta = prismContext.deltaFactory().object().createDeleteDelta(type, oid); + try { + logAttempt("delete", type, oid, null); + modelService.executeChanges(MiscSchemaUtil.createCollection(delta), options, task, result); + failDeny("delete", type, oid, null); + } catch (SecurityViolationException e) { + // this is expected + logDeny("delete", type, oid, null); + result.computeStatus(); + TestUtil.assertFailure(result); + } catch (ObjectNotFoundException e) { + // MID-3221 + // still consider OK ... for now + logError("delete", type, oid, null); + result.computeStatus(); + TestUtil.assertFailure(result); + } + } + + protected void assertDeleteAllow(Class type, String oid) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + assertDeleteAllow(type, oid, null); + } + + protected void assertDeleteAllow(Class type, String oid, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertDeleteAllow"); + OperationResult result = task.getResult(); + ObjectDelta delta = prismContext.deltaFactory().object().createDeleteDelta(type, oid); + logAttempt("delete", type, oid, null); + try { + modelService.executeChanges(MiscSchemaUtil.createCollection(delta), options, task, result); + } catch (SecurityViolationException e) { + failAllow("delete", type, oid, null, e); + } + result.computeStatus(); + TestUtil.assertSuccess(result); + logAllow("delete", type, oid, null); + } + + private Task createAllowDenyTask(String opname) { + Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertAllow."+opname); + task.setOwner(getSecurityContextPrincipalFocus()); + task.setChannel(SchemaConstants.CHANNEL_GUI_USER_URI); + return task; + } + + protected OperationResult assertAllow(String opname, Attempt attempt) throws Exception { + Task task = createAllowDenyTask(opname); + return assertAllow(opname, attempt, task); + } + + protected OperationResult assertAllowTracing(String opname, Attempt attempt) throws Exception { + Task task = createAllowDenyTask(opname); + setTracing(task, createDefaultTracingProfile()); + return assertAllow(opname, attempt, task); + } + + protected OperationResult assertAllow(String opname, Attempt attempt, Task task) throws Exception { + OperationResult result = task.getResult(); + try { + logAttempt(opname); + attempt.run(task, result); + } catch (SecurityViolationException e) { + failAllow(opname, e); + } + result.computeStatus(); + TestUtil.assertSuccess(result); + logAllow(opname); + return result; + } + + protected OperationResult assertDeny(String opname, Attempt attempt) throws Exception { + Task task = createAllowDenyTask(opname); + OperationResult result = task.getResult(); + try { + logAttempt(opname); + attempt.run(task, result); + failDeny(opname); + } catch (SecurityViolationException e) { + // this is expected + logDeny(opname); + result.computeStatus(); + TestUtil.assertFailure(result); + } + return result; + } + + protected void asAdministrator(Attempt attempt) throws Exception { + Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".asAdministrator"); + OperationResult result = task.getResult(); + MidPointPrincipal origPrincipal = getSecurityContextPrincipal(); + login(USER_ADMINISTRATOR_USERNAME); + task.setOwner(getSecurityContextPrincipalFocus()); + task.setChannel(SchemaConstants.CHANNEL_GUI_USER_URI); + try { + attempt.run(task, result); + } catch (Throwable e) { + login(origPrincipal); + throw e; + } + login(origPrincipal); + result.computeStatus(); + TestUtil.assertSuccess(result); + } + + protected void logAttempt(String action) { + String msg = LOG_PREFIX_ATTEMPT+"Trying "+action; + System.out.println(msg); + LOGGER.info(msg); + } + + protected void logDeny(String action, Class type, ObjectQuery query) { + logDeny(action, type, query==null?"null":query.toString()); + } + + protected void logDeny(String action, Class type, String oid, ItemPath itemPath) { + logDeny(action, type, oid+" prop "+itemPath); + } + + protected void logDeny(String action, Class type, String desc) { + String msg = LOG_PREFIX_DENY+"Denied "+action+" of "+type.getSimpleName()+":"+desc; + System.out.println(msg); + LOGGER.info(msg); + } + + protected void logDeny(String action) { + String msg = LOG_PREFIX_DENY+"Denied "+action; + System.out.println(msg); + LOGGER.info(msg); + } + + protected void logAllow(String action, Class type, ObjectQuery query) { + logAllow(action, type, query==null?"null":query.toString()); + } + + protected void logAllow(String action, Class type, String oid, ItemPath itemPath) { + logAllow(action, type, oid+" prop "+itemPath); + } + + protected void logAllow(String action, Class type, String desc) { + String msg = LOG_PREFIX_ALLOW+"Allowed "+action+" of "+type.getSimpleName()+":"+desc; + System.out.println(msg); + LOGGER.info(msg); + } + + protected void logAllow(String action) { + String msg = LOG_PREFIX_ALLOW+"Allowed "+action; + System.out.println(msg); + LOGGER.info(msg); + } + + protected void logError(String action, Class type, String oid, ItemPath itemPath, Throwable e) { + logError(action, type, oid+" prop "+itemPath, e); + } + + protected void logError(String action, Class type, String desc, Throwable e) { + String msg = LOG_PREFIX_DENY+"Error "+action+" of "+type.getSimpleName()+":"+desc + "("+e+")"; + System.out.println(msg); + LOGGER.info(msg); + } + + protected void logAttempt(String action, Class type, ObjectQuery query) { + logAttempt(action, type, query==null?"null":query.toString()); + } + + protected void logAttempt(String action, Class type, String oid, ItemPath itemPath) { + logAttempt(action, type, oid+" prop "+itemPath); + } + + protected void logAttempt(String action, Class type, String desc) { + String msg = LOG_PREFIX_ATTEMPT+"Trying "+action+" of "+type.getSimpleName()+":"+desc; + System.out.println(msg); + LOGGER.info(msg); + } + + protected void failDeny(String action, Class type, ObjectQuery query, int expected, int actual) { + failDeny(action, type, (query==null?"null":query.toString())+", expected "+expected+", actual "+actual); + } + + protected void failDeny(String action, Class type, String oid, ItemPath itemPath) { + failDeny(action, type, oid+" prop "+itemPath); + } + + protected void failDeny(String action, Class type, String desc) { + String msg = "Failed to deny "+action+" of "+type.getSimpleName()+":"+desc; + System.out.println(LOG_PREFIX_FAIL+msg); + LOGGER.error(LOG_PREFIX_FAIL+msg); + AssertJUnit.fail(msg); + } + + protected void failDeny(String action) { + String msg = "Failed to deny "+action; + System.out.println(LOG_PREFIX_FAIL+msg); + LOGGER.error(LOG_PREFIX_FAIL+msg); + AssertJUnit.fail(msg); + } + + protected void failAllow(String action, Class type, ObjectQuery query, SecurityViolationException e) throws SecurityViolationException { + failAllow(action, type, query==null?"null":query.toString(), e); + } + + protected void failAllow(String action, Class type, ObjectQuery query, int expected, int actual) throws SecurityViolationException { + failAllow(action, type, (query==null?"null":query.toString())+", expected "+expected+", actual "+actual, null); + } + + protected void failAllow(String action, Class type, String oid, ItemPath itemPath, SecurityViolationException e) throws SecurityViolationException { + failAllow(action, type, oid+" prop "+itemPath, e); + } + + protected void failAllow(String action, Class type, String desc, SecurityViolationException e) throws SecurityViolationException { + String msg = "Failed to allow "+action+" of "+type.getSimpleName()+":"+desc; + System.out.println(LOG_PREFIX_FAIL+msg); + LOGGER.error(LOG_PREFIX_FAIL+msg); + if (e != null) { + throw new SecurityViolationException(msg+": "+e.getMessage(), e); + } else { + AssertJUnit.fail(msg); + } + } + + protected void failAllow(String action, SecurityViolationException e) throws SecurityViolationException { + String msg = "Failed to allow "+action; + System.out.println(LOG_PREFIX_FAIL+msg); + LOGGER.error(LOG_PREFIX_FAIL+msg); + if (e != null) { + throw new SecurityViolationException(msg+": "+e.getMessage(), e); + } else { + AssertJUnit.fail(msg); + } + } + + protected ArchetypePolicyAsserter assertArchetypePolicy(PrismObject object) throws SchemaException, ConfigurationException { + OperationResult result = new OperationResult("assertArchetypePolicy"); + ArchetypePolicyType archetypePolicy = modelInteractionService.determineArchetypePolicy(object, result); + ArchetypePolicyAsserter asserter = new ArchetypePolicyAsserter<>(archetypePolicy, null, "for "+object); + initializeAsserter(asserter); + asserter.display(); + return asserter; + } + + protected AssignmentCandidatesSpecificationAsserter assertAssignmentTargetSpecification(PrismObject object) throws SchemaException, ConfigurationException { + OperationResult result = new OperationResult("assertAssignmentTargetSpecification"); + AssignmentCandidatesSpecification targetSpec = modelInteractionService.determineAssignmentTargetSpecification(object, result); + AssignmentCandidatesSpecificationAsserter asserter = new AssignmentCandidatesSpecificationAsserter<>(targetSpec, null, "targets for "+object); + initializeAsserter(asserter); + asserter.display(); + return asserter; + } + + protected AssignmentCandidatesSpecificationAsserter assertAssignmentHolderSpecification(PrismObject object) throws SchemaException, ConfigurationException { + OperationResult result = new OperationResult("assertAssignmentHolderSpecification"); + AssignmentCandidatesSpecification targetSpec = modelInteractionService.determineAssignmentHolderSpecification(object, result); + AssignmentCandidatesSpecificationAsserter asserter = new AssignmentCandidatesSpecificationAsserter<>(targetSpec, null, "holders for "+object); + initializeAsserter(asserter); + asserter.display(); + return asserter; + } + + protected ExpressionVariables createVariables(Object... params) { + return ExpressionVariables.create(prismContext, params); + } + +} diff --git a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/prism/ComplexTypeDefinitionAsserter.java b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/prism/ComplexTypeDefinitionAsserter.java index 8c24e553ca8..2481f6494d5 100644 --- a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/prism/ComplexTypeDefinitionAsserter.java +++ b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/prism/ComplexTypeDefinitionAsserter.java @@ -1,68 +1,69 @@ -/* - * Copyright (c) 2019 Evolveum and contributors - * - * This work is dual-licensed under the Apache License 2.0 - * and European Union Public License. See LICENSE file for details. - */ -package com.evolveum.midpoint.test.asserter.prism; - -import static org.testng.AssertJUnit.assertEquals; - -import javax.xml.namespace.QName; - -import com.evolveum.midpoint.prism.ComplexTypeDefinition; -import com.evolveum.midpoint.test.IntegrationTestTools; -import com.evolveum.midpoint.test.asserter.AbstractAsserter; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; - -/** - * @author semancik - * - */ -public class ComplexTypeDefinitionAsserter extends AbstractAsserter { - - private ComplexTypeDefinition complexTypeDefinition; - - public ComplexTypeDefinitionAsserter(ComplexTypeDefinition complexTypeDefinition) { - super(); - this.complexTypeDefinition = complexTypeDefinition; - } - - public ComplexTypeDefinitionAsserter(ComplexTypeDefinition complexTypeDefinition, String detail) { - super(detail); - this.complexTypeDefinition = complexTypeDefinition; - } - - public ComplexTypeDefinitionAsserter(ComplexTypeDefinition complexTypeDefinition, RA returnAsserter, String detail) { - super(returnAsserter, detail); - this.complexTypeDefinition = complexTypeDefinition; - } - - public static ComplexTypeDefinitionAsserter forComplexTypeDefinition(ComplexTypeDefinition complexTypeDefinition) { - return new ComplexTypeDefinitionAsserter<>(complexTypeDefinition); - } - - public ComplexTypeDefinition getComplexTypeDefinition() { - return complexTypeDefinition; - } - - public ComplexTypeDefinitionAsserter assertTypeQName(QName expected) { - assertEquals("Wrong type QName in "+desc(), expected, complexTypeDefinition.getTypeName()); - return this; - } - - protected String desc() { - return descWithDetails("complex type definition " + PrettyPrinter.prettyPrint(complexTypeDefinition.getTypeName())); - } - - public ComplexTypeDefinitionAsserter display() { - display(desc()); - return this; - } - - public ComplexTypeDefinitionAsserter display(String message) { - IntegrationTestTools.display(message, complexTypeDefinition); - return this; - } -} +/* + * Copyright (c) 2019 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ +package com.evolveum.midpoint.test.asserter.prism; + +import static org.testng.AssertJUnit.assertEquals; + +import javax.xml.namespace.QName; + +import com.evolveum.midpoint.prism.ComplexTypeDefinition; +import com.evolveum.midpoint.test.IntegrationTestTools; +import com.evolveum.midpoint.test.asserter.AbstractAsserter; +import com.evolveum.midpoint.util.PrettyPrinter; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; + +/** + * Related to PrismContainerDefinitionAsserter + * + * @author semancik + */ +public class ComplexTypeDefinitionAsserter extends AbstractAsserter { + + private ComplexTypeDefinition complexTypeDefinition; + + public ComplexTypeDefinitionAsserter(ComplexTypeDefinition complexTypeDefinition) { + super(); + this.complexTypeDefinition = complexTypeDefinition; + } + + public ComplexTypeDefinitionAsserter(ComplexTypeDefinition complexTypeDefinition, String detail) { + super(detail); + this.complexTypeDefinition = complexTypeDefinition; + } + + public ComplexTypeDefinitionAsserter(ComplexTypeDefinition complexTypeDefinition, RA returnAsserter, String detail) { + super(returnAsserter, detail); + this.complexTypeDefinition = complexTypeDefinition; + } + + public static ComplexTypeDefinitionAsserter forComplexTypeDefinition(ComplexTypeDefinition complexTypeDefinition) { + return new ComplexTypeDefinitionAsserter<>(complexTypeDefinition); + } + + public ComplexTypeDefinition getComplexTypeDefinition() { + return complexTypeDefinition; + } + + public ComplexTypeDefinitionAsserter assertTypeQName(QName expected) { + assertEquals("Wrong type QName in "+desc(), expected, complexTypeDefinition.getTypeName()); + return this; + } + + protected String desc() { + return descWithDetails("complex type definition " + PrettyPrinter.prettyPrint(complexTypeDefinition.getTypeName())); + } + + public ComplexTypeDefinitionAsserter display() { + display(desc()); + return this; + } + + public ComplexTypeDefinitionAsserter display(String message) { + IntegrationTestTools.display(message, complexTypeDefinition); + return this; + } +} diff --git a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/prism/PrismContainerDefinitionAsserter.java b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/prism/PrismContainerDefinitionAsserter.java new file mode 100644 index 00000000000..5e5c2f21f53 --- /dev/null +++ b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/prism/PrismContainerDefinitionAsserter.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2019 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ +package com.evolveum.midpoint.test.asserter.prism; + +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertNotNull; + +import com.evolveum.midpoint.prism.Containerable; +import com.evolveum.midpoint.prism.PrismContainerDefinition; +import com.evolveum.midpoint.prism.PrismPropertyDefinition; +import com.evolveum.midpoint.prism.path.ItemPath; +import com.evolveum.midpoint.test.IntegrationTestTools; +import com.evolveum.midpoint.util.PrettyPrinter; + + +/** + * Related to ComplexTypeDefinitionAsserter + * + * @author Radovan semancik + */ +public class PrismContainerDefinitionAsserter extends PrismDefinitionAsserter { + + public PrismContainerDefinitionAsserter(PrismContainerDefinition definition) { + super(definition); + } + + public PrismContainerDefinitionAsserter(PrismContainerDefinition definition, String detail) { + super(definition, detail); + } + + public PrismContainerDefinitionAsserter(PrismContainerDefinition definition, RA returnAsserter, String detail) { + super(definition, returnAsserter, detail); + } + + public static PrismContainerDefinitionAsserter forContainerDefinition(PrismContainerDefinition definition) { + return new PrismContainerDefinitionAsserter<>(definition); + } + + public PrismContainerDefinition getDefinition() { + return (PrismContainerDefinition) super.getDefinition(); + } + + public PrismContainerDefinitionAsserter assertSize(int expected) { + assertEquals("Wrong number of item definitions in "+desc(), expected, getDefinition() != null ? getDefinition().getDefinitions().size() : 0); + return this; + } + + public PrismContainerDefinitionAsserter> container(ItemPath subDefPath) { + PrismContainerDefinition subDefinition = getDefinition().findContainerDefinition(subDefPath); + assertNotNull("No container for path "+subDefPath+" in "+desc(), subDefinition); + PrismContainerDefinitionAsserter> subAsserter = new PrismContainerDefinitionAsserter<>(subDefinition, this, "container for "+subDefPath+" in "+desc()); + copySetupTo(subAsserter); + return subAsserter; + } + + protected String desc() { + return descWithDetails("container definition " + PrettyPrinter.prettyPrint(getDefinition().getItemName())); + } + + public PrismContainerDefinitionAsserter display() { + display(desc()); + return this; + } + + public PrismContainerDefinitionAsserter display(String message) { + IntegrationTestTools.display(message, getDefinition()); + return this; + } +} From 1b2a4f0483713c497ef5cbd3e57ec5a8469d06c8 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Fri, 28 Feb 2020 12:08:45 +0100 Subject: [PATCH 43/97] test-util: added Abstract{Unit,Spring}Test classes and UnitTestMixin This helps with test method lifecycle: - printing header/footer of the test - providing typical when/then methods and storing thread-local context It's better to use one of Abstract*Test classes instead of mixin interface directly. --- infra/test-util/pom.xml | 5 ++ .../test/util/AbstractSpringTest.java | 52 +++++++++++++ .../midpoint/test/util/AbstractUnitTest.java | 46 +++++++++++ .../evolveum/midpoint/test/util/TestUtil.java | 10 +-- .../midpoint/test/util/UnitTestMixin.java | 78 +++++++++++++++++++ 5 files changed, 186 insertions(+), 5 deletions(-) create mode 100644 infra/test-util/src/main/java/com/evolveum/midpoint/test/util/AbstractSpringTest.java create mode 100644 infra/test-util/src/main/java/com/evolveum/midpoint/test/util/AbstractUnitTest.java create mode 100644 infra/test-util/src/main/java/com/evolveum/midpoint/test/util/UnitTestMixin.java diff --git a/infra/test-util/pom.xml b/infra/test-util/pom.xml index 24007fc05a2..d982f65600e 100644 --- a/infra/test-util/pom.xml +++ b/infra/test-util/pom.xml @@ -61,6 +61,11 @@ org.springframework spring-context + + org.springframework + spring-test + + org.apache.felix diff --git a/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/AbstractSpringTest.java b/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/AbstractSpringTest.java new file mode 100644 index 00000000000..2f3de528516 --- /dev/null +++ b/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/AbstractSpringTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2010-2020 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ +package com.evolveum.midpoint.test.util; + +import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; +import org.testng.ITestResult; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; + +import com.evolveum.midpoint.util.logging.Trace; +import com.evolveum.midpoint.util.logging.TraceManager; + +/** + * Base test class for tests integrated with Spring providing {@link UnitTestMixin} implementation. + * Can be extended by any unit test class that would otherwise extend + * {@link AbstractTestNGSpringContextTests}. + */ +public abstract class AbstractSpringTest extends AbstractTestNGSpringContextTests + implements UnitTestMixin { + + private static final ThreadLocal TEST_CONTEXT_THREAD_LOCAL = new ThreadLocal<>(); + + /** + * Hides parent's logger, but that one is from commons-logging and we don't want that. + */ + protected final Trace logger = TraceManager.getTrace(getClass()); + + @BeforeMethod + public void startTestContext(ITestResult testResult) { + Class testClass = testResult.getMethod().getTestClass().getRealClass(); + String testMethodName = testResult.getMethod().getMethodName(); + TestUtil.displayTestTitle(testClass.getSimpleName() + "." + testMethodName); + + TEST_CONTEXT_THREAD_LOCAL.set(testResult); + } + + @AfterMethod + public void finishTestContext(ITestResult testResult) { + TEST_CONTEXT_THREAD_LOCAL.remove(); + + displayDefaultTestFooter(testResult); + } + + @Override + public String getTestNameShort() { + return TEST_CONTEXT_THREAD_LOCAL.get().getMethod().getMethodName(); + } +} diff --git a/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/AbstractUnitTest.java b/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/AbstractUnitTest.java new file mode 100644 index 00000000000..019b95c2b4f --- /dev/null +++ b/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/AbstractUnitTest.java @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2010-2020 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ +package com.evolveum.midpoint.test.util; + +import org.testng.ITestResult; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; + +import com.evolveum.midpoint.util.logging.Trace; +import com.evolveum.midpoint.util.logging.TraceManager; + +/** + * Base test class providing basic {@link UnitTestMixin} implementation. + * Can be extended by any unit test class that otherwise doesn't extend anything. + */ +public abstract class AbstractUnitTest implements UnitTestMixin { + + private static final ThreadLocal TEST_CONTEXT_THREAD_LOCAL = new ThreadLocal<>(); + + protected final Trace logger = TraceManager.getTrace(getClass()); + + @BeforeMethod + public void startTestContext(ITestResult testResult) { + Class testClass = testResult.getMethod().getTestClass().getRealClass(); + String testMethodName = testResult.getMethod().getMethodName(); + TestUtil.displayTestTitle(testClass.getSimpleName() + "." + testMethodName); + + TEST_CONTEXT_THREAD_LOCAL.set(testResult); + } + + @AfterMethod + public void finishTestContext(ITestResult testResult) { + TEST_CONTEXT_THREAD_LOCAL.remove(); + + displayDefaultTestFooter(testResult); + } + + @Override + public String getTestNameShort() { + return TEST_CONTEXT_THREAD_LOCAL.get().getMethod().getMethodName(); + } +} diff --git a/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/TestUtil.java b/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/TestUtil.java index b42f23215d8..e38e9e0f1d3 100644 --- a/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/TestUtil.java +++ b/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/TestUtil.java @@ -185,12 +185,12 @@ public static void displayWhen(String what) { LOGGER.info(TEST_LOG_SECTION_PREFIX + " WHEN " + what + TEST_LOG_SECTION_SUFFIX); } - public static void displayWhen(String testName, String part) { - if (part == null) { - part = ""; + public static void displayWhen(String testName, String description) { + if (description == null) { + description = ""; } - System.out.println(TEST_OUT_SECTION_PREFIX + testName + ": WHEN " + part + TEST_OUT_SECTION_SUFFIX); - LOGGER.info(TEST_LOG_SECTION_PREFIX + testName + ": WHEN " + part + TEST_LOG_SECTION_SUFFIX); + System.out.println(TEST_OUT_SECTION_PREFIX + testName + ": WHEN " + description + TEST_OUT_SECTION_SUFFIX); + LOGGER.info(TEST_LOG_SECTION_PREFIX + testName + ": WHEN " + description + TEST_LOG_SECTION_SUFFIX); } // TODO change like when diff --git a/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/UnitTestMixin.java b/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/UnitTestMixin.java new file mode 100644 index 00000000000..540ee708e5d --- /dev/null +++ b/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/UnitTestMixin.java @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2010-2020 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ +package com.evolveum.midpoint.test.util; + +import org.testng.ITestResult; + +/** + * Mixin with various utility methods - typically delegating to {@link TestUtil}. + */ +public interface UnitTestMixin { + + /** + * Returns short test name - typically just a method name (without class). + */ + String getTestNameShort(); + + /** + * Displays "when" subsection header with test name. + * Even better, use {@link #when(String)} and provide human readable description. + */ + default void when() { + when(null); + } + + /** + * Displays "when" subsection header with test name and provided description (nullable). + */ + default void when(String description) { + TestUtil.displayWhen(getTestNameShort(), description); + } + + /** + * Displays "then" subsection header with test name. + * Even better, use {@link #then(String)} and provide human readable description. + */ + default void then() { + then(null); + } + + /** + * Displays "then" subsection header with test name and provided description (nullable). + */ + default void then(String description) { + TestUtil.displayThen(getTestNameShort(), description); + } + + // TODO introduce "expect" as well? sometimes we use when/then combined section + // in such a case instead of "given - when/then" we should have "given - expect" + + // TODO inline after merge to master + default void displayWhen() { + when(); + } + + // TODO inline after merge to master + default void displayWhen(String description) { + when(description); + } + + // TODO inline after merge to master + default void displayThen() { + then(); + } + + // TODO inline after merge to master + default void displayThen(String description) { + then(description); + } + + default void displayDefaultTestFooter(ITestResult testResult) { + long testMsDuration = testResult.getEndMillis() - testResult.getStartMillis(); + TestUtil.displayFooter(testResult.getMethod().getMethodName() + " FINISHED in " + testMsDuration + " ms"); + } +} From 5ca342793621f44766769f493052abf20fa57a25 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Fri, 28 Feb 2020 12:21:56 +0100 Subject: [PATCH 44/97] Fix time assertions in TestUserTemplate --- .../model/intest/TestUserTemplate.java | 25 +++++++++++++------ .../common/user-template-complex.xml | 6 ++--- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplate.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplate.java index 07f7d112fd0..dafb855e95d 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplate.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplate.java @@ -114,7 +114,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti repoAddObjectFromFile(USER_TEMPLATE_MAROONED_FILE, initResult); repoAddObjectFromFile(USER_TEMPLATE_USELESS_FILE, initResult); repoAdd(USER_TEMPLATE_MID_5892, initResult); - + setDefaultObjectTemplate(UserType.COMPLEX_TYPE, USER_TEMPLATE_COMPLEX_OID, initResult); setDefaultObjectTemplate(UserType.COMPLEX_TYPE, SUBTYPE_MAROONED, USER_TEMPLATE_MAROONED_OID, initResult); setDefaultObjectTemplate(UserType.COMPLEX_TYPE, SUBTYPE_USELESS, USER_TEMPLATE_USELESS_OID, initResult); @@ -2453,8 +2453,6 @@ public void test302ModifyStanAccountAndReimport() throws Exception { @Test public void test800NullTimeFrom() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); importObjectFromFile(TASK_TRIGGER_SCANNER_FILE); @@ -2510,7 +2508,7 @@ public void test804PreKaboom() throws Exception { displayTestTitle(TEST_NAME); // GIVEN - clockForward("P2D"); + clockForward("P2D"); // total override is realTime + 2D // WHEN waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true); @@ -2533,7 +2531,7 @@ public void test808Kaboom() throws Exception { displayTestTitle(TEST_NAME); // GIVEN - clockForward("P1M"); + clockForward("P1M"); // total override is realTime + 2D + 1M // WHEN waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true); @@ -2546,7 +2544,8 @@ public void test808Kaboom() throws Exception { .end() .triggers() .single() - // Trigger for "tales bomb" mapping (see below) + // Trigger for "tales bomb" mapping (see below) - it was computed as funeralTimestamp + 3M + // (i.e. should be approximately equal to clock + 2M - 2D, because clock = realTime + 2D + 1M) .assertHandlerUri(RecomputeTriggerHandler.HANDLER_URI) .assertTimestampFuture("P2M", 5*24*60*60*1000L); } @@ -2563,7 +2562,7 @@ public void test810PreTalesBomb() throws Exception { displayTestTitle(TEST_NAME); // GIVEN - clockForward("P1D"); + clockForward("P1D"); // total override is realTime + 2D + 1M + 1D // WHEN waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true); @@ -2577,8 +2576,18 @@ public void test810PreTalesBomb() throws Exception { .end() .triggers() .single() + // Trigger for "tales bomb" mapping - it was computed as funeralTimestamp + 3M + // (i.e. should be approximately equal to clock + 2M - 3D, because clock = realTime + 2D + 1M + 1D) + // + // We need to set a tolerance bigger than 5 days here, because e.g. on Feb 28th 2020 the situation is as follows: + // - trigger time = 2020-05-28T00:00:00.000+01:00 (3M after funeral i.e. realTime rounded down to midnight) + // - clock = 2020-04-02T12:55:20.299+02:00 (realTime + 2D + 1M + 1D) + // - clock+2M (expected time) = 2020-06-02T12:55:20.299+02:00 + // - clock+2M - 5 days (lower tolerance interval border) = 2020-05-28T12:55:21.979+02:00 that is after funeralTimestamp! + // + // So setting the tolerance to 7 days should be good enough. .assertHandlerUri(RecomputeTriggerHandler.HANDLER_URI) - .assertTimestampFuture("P2M", 5*24*60*60*1000L); + .assertTimestampFuture("P2M", 7*24*60*60*1000L); } /** diff --git a/model/model-intest/src/test/resources/common/user-template-complex.xml b/model/model-intest/src/test/resources/common/user-template-complex.xml index 33066c780dd..3615629b79f 100644 --- a/model/model-intest/src/test/resources/common/user-template-complex.xml +++ b/model/model-intest/src/test/resources/common/user-template-complex.xml @@ -464,13 +464,13 @@ // it will not be processed. return null } - javax.xml.datatype.XMLGregorianCalendar funeralTimestamp = basic.getExtensionPropertyValue(focus,'funeralTimestamp') + javax.xml.datatype.XMLGregorianCalendar funeralTimestamp = basic.getExtensionPropertyValue(focus, 'funeralTimestamp') if (funeralTimestamp == null) { // Always process this mapping immediately return basic.longAgo() } def timestamp = basic.addDuration(funeralTimestamp, "P3M") - timetamp = basic.roundDownToMidnight(timestamp) + timestamp = basic.roundDownToMidnight(timestamp) return timestamp @@ -507,7 +507,7 @@ return basic.longAgo() } def timestamp = basic.addDuration(funeralTimestamp, "P1Y") - timetamp = basic.roundDownToMidnight(timestamp) + timestamp = basic.roundDownToMidnight(timestamp) return timestamp From c6ff0f89d7a3b09142219d59da80b4090dd11dc3 Mon Sep 17 00:00:00 2001 From: Viliam Repan Date: Fri, 28 Feb 2020 12:57:40 +0100 Subject: [PATCH 45/97] removed links from schrodinger to testing/schrodingertest project --- .../testing/schrodinger/TestBase.java | 154 +++++++++++------- .../testing/schrodinger/UserTest.java | 2 +- ...LoginPageWithAuthenticationConfigTest.java | 2 +- .../scenarios/ObjectListArchetypeTests.java | 2 +- .../scenarios/PostAuthenticationTests.java | 18 +- .../configuration/schrodinger.properties | 2 +- .../schrodinger/EnvironmentConfiguration.java | 24 +++ .../midpoint/schrodinger/MidPoint.java | 74 ++------- .../midpoint/schrodinger/WebDriver.java | 23 ++- 9 files changed, 162 insertions(+), 139 deletions(-) diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/TestBase.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/TestBase.java index 9fc0dd40352..b38963315e7 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/TestBase.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/TestBase.java @@ -7,67 +7,105 @@ package com.evolveum.midpoint.testing.schrodinger; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.Method; +import java.util.Properties; +import javax.naming.ConfigurationException; + import com.codeborne.selenide.Selenide; import com.codeborne.selenide.testng.BrowserPerClass; +import org.apache.commons.io.FileUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testng.Assert; +import org.testng.annotations.*; + import com.evolveum.midpoint.schrodinger.EnvironmentConfiguration; import com.evolveum.midpoint.schrodinger.MidPoint; +import com.evolveum.midpoint.schrodinger.WebDriver; import com.evolveum.midpoint.schrodinger.component.resource.ResourceConfigurationTab; import com.evolveum.midpoint.schrodinger.page.BasicPage; -import com.evolveum.midpoint.schrodinger.page.login.FormLoginPage; import com.evolveum.midpoint.schrodinger.page.configuration.AboutPage; import com.evolveum.midpoint.schrodinger.page.configuration.ImportObjectPage; +import com.evolveum.midpoint.schrodinger.page.login.FormLoginPage; import com.evolveum.midpoint.schrodinger.page.resource.ListResourcesPage; import com.evolveum.midpoint.schrodinger.page.resource.ViewResourcePage; -import org.apache.commons.io.FileUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.testng.Assert; -import org.testng.annotations.*; - -import javax.naming.ConfigurationException; -import java.io.File; -import java.io.IOException; -import java.lang.reflect.Method; /** * Created by Viliam Repan (lazyman). */ -@Listeners({BrowserPerClass.class}) +@Listeners({ BrowserPerClass.class }) public abstract class TestBase { public static final String PROPERTY_NAME_MIDPOINT_HOME = "-Dmidpoint.home"; public static final String PROPERTY_NAME_USER_HOME = "user.home"; public static final String PROPERTY_NAME_FILE_SEPARATOR = "file.separator"; - protected static final String CSV_RESOURCE_ATTR_UNIQUE= "Unique attribute name"; + protected static final String CSV_RESOURCE_ATTR_UNIQUE = "Unique attribute name"; + + private static final String SCHRODINGER_PROPERTIES = "./src/test/resources/configuration/schrodinger.properties"; private static final Logger LOG = LoggerFactory.getLogger(TestBase.class); + protected static File csvTargetDir; + private EnvironmentConfiguration configuration; + + private String username; + + private String password; + protected MidPoint midPoint; + protected BasicPage basicPage; + public EnvironmentConfiguration getConfiguration() { + return configuration; + } + + public String getUsername() { + return username; + } + + public String getPassword() { + return password; + } @BeforeClass public void beforeClass() throws IOException { LOG.info("Starting tests in class {}", getClass().getName()); + if (midPoint == null) { + Properties props = new Properties(); + try (InputStream is = new FileInputStream(new File(SCHRODINGER_PROPERTIES))) { + props.load(is); + } - if (midPoint !=null){ - - }else{ - - EnvironmentConfiguration config = new EnvironmentConfiguration(); - midPoint = new MidPoint(config); + configuration = buildEnvironmentConfiguration(props); + midPoint = new MidPoint(configuration); + username = props.getProperty("username"); + password = props.getProperty("password"); } FormLoginPage login = midPoint.formLogin(); + basicPage = login.loginWithReloadLoginPage(username, password); + } + + private EnvironmentConfiguration buildEnvironmentConfiguration(Properties props) throws IOException { + EnvironmentConfiguration config = new EnvironmentConfiguration(); + config.driver(WebDriver.valueOf(props.getProperty("webdriver"))); + config.driverLocation(props.getProperty("webdriverLocation")); - basicPage = login.loginWithReloadLoginPage(midPoint.getUsername(),midPoint.getPassword()); + config.headless(Boolean.parseBoolean(props.getProperty("headlessStart"))); + config.baseUrl(props.getProperty("base_url")); + return config; } @AfterClass @@ -78,13 +116,14 @@ public void afterClass() { Selenide.clearBrowserLocalStorage(); Selenide.close(); - midPoint.formLogin() - .loginWithReloadLoginPage(midPoint.getUsername(),midPoint.getPassword()); - System.out.println("After: Login name "+ midPoint.getUsername()+ " pass " +midPoint.getPassword()); + midPoint.formLogin().loginWithReloadLoginPage(username, password); + + LOG.info("After: Login name " + username + " pass " + password); + AboutPage aboutPage = basicPage.aboutPage(); - aboutPage - .clickSwitchToFactoryDefaults() - .clickYes(); + aboutPage + .clickSwitchToFactoryDefaults() + .clickYes(); } @BeforeMethod @@ -98,7 +137,6 @@ public void afterMethod(Method method) { } protected void importObject(File source, Boolean overrideExistingObject) { - ImportObjectPage importPage = basicPage.importObject(); if (overrideExistingObject) { @@ -119,9 +157,7 @@ protected void importObject(File source) { importObject(source, false); } - protected String fetchMidpointHome() throws ConfigurationException { - AboutPage aboutPage = basicPage.aboutPage(); String mpHomeDir = aboutPage.getJVMproperty(PROPERTY_NAME_MIDPOINT_HOME); @@ -133,9 +169,7 @@ protected String fetchMidpointHome() throws ConfigurationException { mpHomeDir = new StringBuilder(aboutPage.getSystemProperty(PROPERTY_NAME_USER_HOME)) .append(aboutPage.getSystemProperty(PROPERTY_NAME_FILE_SEPARATOR)).append("midpoint").toString(); - LOG.info("Midpoint home parameter is empty! Using defaults: "+ mpHomeDir); - - + LOG.info("Midpoint home parameter is empty! Using defaults: " + mpHomeDir); } return mpHomeDir; @@ -164,28 +198,28 @@ protected File initTestDirectory(String dir) throws ConfigurationException, IOEx } // TODO workaround -> factory reset during clean up seems to leave some old cached information breaking the resource until version change - public ViewResourcePage refreshResourceSchema(String resourceName){ + public ViewResourcePage refreshResourceSchema(String resourceName) { ListResourcesPage listResourcesPage = basicPage.listResources(); - ViewResourcePage resourcePage= listResourcesPage - .table() - .clickByName(resourceName) - .refreshSchema(); + ViewResourcePage resourcePage = listResourcesPage + .table() + .clickByName(resourceName) + .refreshSchema(); return resourcePage; } - public void changeResourceAttribute(String resourceName,String attributeName, String newValue){ - changeResourceAttribute(resourceName ,attributeName ,null ,newValue ,true); + public void changeResourceAttribute(String resourceName, String attributeName, String newValue) { + changeResourceAttribute(resourceName, attributeName, null, newValue, true); } - public void changeResourceAttribute(String resourceName,String attributeName, String newValue, Boolean shouldBeSuccess){ - changeResourceAttribute(resourceName ,attributeName ,null ,newValue ,shouldBeSuccess); + public void changeResourceAttribute(String resourceName, String attributeName, String newValue, Boolean shouldBeSuccess) { + changeResourceAttribute(resourceName, attributeName, null, newValue, shouldBeSuccess); } - public void changeResourceAttribute(String resourceName,String attributeName,String oldValue, String newValue, Boolean shouldBeSuccess){ + public void changeResourceAttribute(String resourceName, String attributeName, String oldValue, String newValue, Boolean shouldBeSuccess) { ListResourcesPage listResourcesPage = basicPage.listResources(); - if(shouldBeSuccess){ + if (shouldBeSuccess) { ViewResourcePage viewResourcePage = listResourcesPage .table() .search() @@ -202,30 +236,30 @@ public void changeResourceAttribute(String resourceName,String attributeName,Str Selenide.screenshot("afterMinuteSleep"); Assert.assertTrue(resourceConfigurationTab - .form() - .changeAttributeValue(attributeName,oldValue, newValue) - .and() - .and() - .clickSaveAndTestConnection() - .isTestSuccess() + .form() + .changeAttributeValue(attributeName, oldValue, newValue) + .and() + .and() + .clickSaveAndTestConnection() + .isTestSuccess() ); - }else{ + } else { Assert.assertTrue( listResourcesPage - .table() + .table() .search() - .byName() - .inputValue(resourceName) - .updateSearch() + .byName() + .inputValue(resourceName) + .updateSearch() .and() .clickByName(resourceName) - .clickEditResourceConfiguration() - .form() - .changeAttributeValue(attributeName,oldValue, newValue) - .and() + .clickEditResourceConfiguration() + .form() + .changeAttributeValue(attributeName, oldValue, newValue) + .and() .and() - .clickSaveAndTestConnection() - .isTestFailure() + .clickSaveAndTestConnection() + .isTestFailure() ); } diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/UserTest.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/UserTest.java index ff6a9d00563..9492cbe6b0c 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/UserTest.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/UserTest.java @@ -73,7 +73,7 @@ public void isLocalizedPolystringValueDisplayed(){ basicPage.loggedUser().logout(); FormLoginPage loginPage = midPoint.formLogin(); - loginPage.loginWithReloadLoginPage(midPoint.getUsername(),midPoint.getPassword(), LOCALIZATION_VALUE); + loginPage.loginWithReloadLoginPage(getUsername(), getPassword(), LOCALIZATION_VALUE); ListUsersPage usersPage = basicPage.listUsers(); Assert.assertTrue( diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/LoginPageWithAuthenticationConfigTest.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/LoginPageWithAuthenticationConfigTest.java index 2bcc7a43d85..a400fff05bd 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/LoginPageWithAuthenticationConfigTest.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/LoginPageWithAuthenticationConfigTest.java @@ -61,7 +61,7 @@ public void beforeClass() throws IOException { SystemPage systemPage = new SystemPage(); PrismForm infrastructureForm = systemPage.infrastructureTab().form(); infrastructureForm.showEmptyAttributes("Infrastructure"); - infrastructureForm.addAttributeValue("defaultHostname", midPoint.getBaseUrl()); + infrastructureForm.addAttributeValue("defaultHostname", getConfiguration().getBaseUrl()); File notificationFile = NOTIFICATION_FILE; notificationFile.createNewFile(); NotificationsTab notificationTab = systemPage.notificationsTab(); diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/ObjectListArchetypeTests.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/ObjectListArchetypeTests.java index dbdd95739bb..c40b325edc7 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/ObjectListArchetypeTests.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/ObjectListArchetypeTests.java @@ -109,7 +109,7 @@ public void configureArchetypeObjectListView(){ public void actualizeArchetypeConfiguration() { basicPage.loggedUser().logout(); midPoint.formLogin() - .loginWithReloadLoginPage(midPoint.getUsername(),midPoint.getPassword()); + .loginWithReloadLoginPage(getUsername(), getPassword()); //check archetype pluralLabel ListUsersPage collectionListPage = basicPage.listUsers(ARCHETYPE_PLURAL_LABEL); diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/PostAuthenticationTests.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/PostAuthenticationTests.java index 5b27242b05c..9b6358d9868 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/PostAuthenticationTests.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/PostAuthenticationTests.java @@ -6,18 +6,18 @@ */ package com.evolveum.midpoint.testing.schrodinger.scenarios; +import static com.codeborne.selenide.Selenide.open; +import static com.codeborne.selenide.Selenide.sleep; + +import java.io.File; + import com.codeborne.selenide.Selenide; -import com.evolveum.midpoint.schrodinger.component.AssignmentsTab; -import com.evolveum.midpoint.schrodinger.page.user.ListUsersPage; -import com.evolveum.midpoint.schrodinger.page.user.UserPage; -import com.evolveum.midpoint.testing.schrodinger.TestBase; import org.testng.Assert; import org.testng.annotations.Test; -import java.io.File; - -import static com.codeborne.selenide.Selenide.open; -import static com.codeborne.selenide.Selenide.sleep; +import com.evolveum.midpoint.schrodinger.page.user.ListUsersPage; +import com.evolveum.midpoint.schrodinger.page.user.UserPage; +import com.evolveum.midpoint.testing.schrodinger.TestBase; public class PostAuthenticationTests extends TestBase { @@ -115,7 +115,7 @@ public void flowWithPostAuthRoleAssigned(){ Selenide.refresh(); midPoint.formLogin() - .loginWithReloadLoginPage(midPoint.getUsername(),midPoint.getPassword()); + .loginWithReloadLoginPage(getUsername(), getPassword()); //todo midpoint opens the previous page before logout open("/self/dashboard"); diff --git a/testing/schrodingertest/src/test/resources/configuration/schrodinger.properties b/testing/schrodingertest/src/test/resources/configuration/schrodinger.properties index f3ff333c120..e3876f8dc54 100644 --- a/testing/schrodingertest/src/test/resources/configuration/schrodinger.properties +++ b/testing/schrodingertest/src/test/resources/configuration/schrodinger.properties @@ -1,7 +1,7 @@ username=administrator password=5ecr3t base_url=http://localhost:8180/midpoint -webdriver=webdriver.chrome.driver +webdriver=CHROME webdriverLocation=/opt/chromedriver # By default if no value is specified for headless start then the value is: false headlessStart=true diff --git a/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/EnvironmentConfiguration.java b/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/EnvironmentConfiguration.java index b1a742ed485..9c666900786 100644 --- a/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/EnvironmentConfiguration.java +++ b/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/EnvironmentConfiguration.java @@ -15,6 +15,10 @@ public class EnvironmentConfiguration { private WebDriver driver = WebDriver.CHROME; + private String driverLocation; + + private boolean headless; + private String baseUrl; public EnvironmentConfiguration driver(final WebDriver driver) { @@ -25,10 +29,22 @@ public EnvironmentConfiguration driver(final WebDriver driver) { } public EnvironmentConfiguration baseUrl(final String baseUrl) { + Validate.notNull(driver, "Base url must not be null"); + this.baseUrl = baseUrl; return this; } + public EnvironmentConfiguration driverLocation(final String driverLocation) { + this.driverLocation = driverLocation; + return this; + } + + public EnvironmentConfiguration headless(final boolean headless) { + this.headless = headless; + return this; + } + public WebDriver getDriver() { return driver; } @@ -37,6 +53,14 @@ public String getBaseUrl() { return baseUrl; } + public String getDriverLocation() { + return driverLocation; + } + + public boolean isHeadless() { + return headless; + } + public void validate() { Validate.notNull(baseUrl, "Base url must not be null"); } diff --git a/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/MidPoint.java b/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/MidPoint.java index 09c888cd468..050baee1a1f 100644 --- a/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/MidPoint.java +++ b/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/MidPoint.java @@ -6,57 +6,46 @@ */ package com.evolveum.midpoint.schrodinger; +import java.io.IOException; + import com.codeborne.selenide.Configuration; +import org.apache.commons.lang3.Validate; + import com.evolveum.midpoint.schrodinger.component.LoggedUser; import com.evolveum.midpoint.schrodinger.page.login.FormLoginPage; import com.evolveum.midpoint.schrodinger.page.login.SamlSelectPage; -import org.apache.commons.lang3.Validate; - -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Properties; /** * Created by Viliam Repan (lazyman). */ public class MidPoint { - private static EnvironmentConfiguration environment; + private static EnvironmentConfiguration configuration; public static final long TIMEOUT_DEFAULT_2_S = 2000; public static final long TIMEOUT_MEDIUM_6_S = 6000; public static final long TIMEOUT_LONG_1_M = 60000; public static final long TIMEOUT_EXTRA_LONG_1_M = 180000; - private static final String SCHRODINGER_PROPERTIES = "../../testing/schrodingertest/src/test/resources/configuration/schrodinger.properties"; - - private String username; - private String password; - private String baseUrl; - private String webDriver; - private String webdriverLocation; - private boolean headless; - public MidPoint(EnvironmentConfiguration environment) throws IOException { - Validate.notNull(environment, "Environment configuration must not be null"); + public MidPoint(EnvironmentConfiguration configuration) throws IOException { + Validate.notNull(configuration, "Environment configuration must not be null"); - MidPoint.environment = environment; + this.configuration = configuration; init(); } private void init() throws IOException { - fetchProperties(); - environment.baseUrl(baseUrl); - environment.validate(); + configuration.baseUrl(baseUrl); + configuration.validate(); - System.setProperty(webDriver, webdriverLocation); - System.setProperty("selenide.browser", environment.getDriver().name().toLowerCase()); - System.setProperty("selenide.baseUrl", environment.getBaseUrl()); + System.setProperty(configuration.getDriver().getDriver(), configuration.getDriverLocation()); + System.setProperty("selenide.browser", configuration.getDriver().name().toLowerCase()); + System.setProperty("selenide.baseUrl", configuration.getBaseUrl()); - Configuration.headless = headless; + Configuration.headless = configuration.isHeadless(); Configuration.timeout = 6000L; } @@ -73,39 +62,4 @@ public MidPoint logout() { return this; } - - private void fetchProperties() throws IOException { - - Properties schrodingerProperties = new Properties(); - InputStream input = null; - - try { - input = new FileInputStream(SCHRODINGER_PROPERTIES); - schrodingerProperties.load(input); - - webDriver = schrodingerProperties.getProperty("webdriver"); - webdriverLocation = schrodingerProperties.getProperty("webdriverLocation"); - username = schrodingerProperties.getProperty("username"); - password = schrodingerProperties.getProperty("password"); - baseUrl = schrodingerProperties.getProperty("base_url"); - - headless = Boolean.parseBoolean(schrodingerProperties.getProperty("headlessStart")); - } catch (IOException e) { - throw new IOException("An exception was thrown during Schrodinger initialization " + e.getLocalizedMessage()); - } - } - - public String getPassword() { - - return this.password; - } - - public String getUsername() { - - return this.username; - } - - public String getBaseUrl() { - return baseUrl; - } } diff --git a/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/WebDriver.java b/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/WebDriver.java index 3419fbbd76b..19b33377a39 100644 --- a/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/WebDriver.java +++ b/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/WebDriver.java @@ -11,15 +11,26 @@ */ public enum WebDriver { - CHROME, + CHROME("webdriver.chrome.driver"), - FIREFOX, + // todo + FIREFOX(null), - HTMLUNIT, + HTMLUNIT(null), - IE, + IE(null), - OPERA, + OPERA(null), - PHANTOMJS + PHANTOMJS(null); + + private String driver; + + WebDriver(String driver) { + this.driver = driver; + } + + public String getDriver() { + return driver; + } } From 920327ed6e697d7f258c6db75a14ee4b0be29bf4 Mon Sep 17 00:00:00 2001 From: Viliam Repan Date: Fri, 28 Feb 2020 13:00:01 +0100 Subject: [PATCH 46/97] removed links from schrodinger to testing/schrodingertest project --- .../evolveum/midpoint/schrodinger/MidPoint.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/MidPoint.java b/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/MidPoint.java index 050baee1a1f..40f6d5ec491 100644 --- a/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/MidPoint.java +++ b/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/MidPoint.java @@ -6,8 +6,6 @@ */ package com.evolveum.midpoint.schrodinger; -import java.io.IOException; - import com.codeborne.selenide.Configuration; import org.apache.commons.lang3.Validate; @@ -20,16 +18,17 @@ */ public class MidPoint { - private static EnvironmentConfiguration configuration; - public static final long TIMEOUT_DEFAULT_2_S = 2000; + public static final long TIMEOUT_MEDIUM_6_S = 6000; + public static final long TIMEOUT_LONG_1_M = 60000; + public static final long TIMEOUT_EXTRA_LONG_1_M = 180000; - private String baseUrl; + private static EnvironmentConfiguration configuration; - public MidPoint(EnvironmentConfiguration configuration) throws IOException { + public MidPoint(EnvironmentConfiguration configuration) { Validate.notNull(configuration, "Environment configuration must not be null"); this.configuration = configuration; @@ -37,8 +36,7 @@ public MidPoint(EnvironmentConfiguration configuration) throws IOException { init(); } - private void init() throws IOException { - configuration.baseUrl(baseUrl); + private void init() { configuration.validate(); System.setProperty(configuration.getDriver().getDriver(), configuration.getDriverLocation()); From eadaec2c65ad0fa7e184510e6b551ebe8ab43342 Mon Sep 17 00:00:00 2001 From: Viliam Repan Date: Fri, 28 Feb 2020 13:18:00 +0100 Subject: [PATCH 47/97] schrodinger initialization fix --- .../java/com/evolveum/midpoint/schrodinger/MidPoint.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/MidPoint.java b/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/MidPoint.java index 40f6d5ec491..e70ca97b413 100644 --- a/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/MidPoint.java +++ b/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/MidPoint.java @@ -7,6 +7,7 @@ package com.evolveum.midpoint.schrodinger; import com.codeborne.selenide.Configuration; +import com.codeborne.selenide.Selenide; import org.apache.commons.lang3.Validate; import com.evolveum.midpoint.schrodinger.component.LoggedUser; @@ -47,6 +48,12 @@ private void init() { Configuration.timeout = 6000L; } + public MidPoint open() { + Selenide.open(configuration.getBaseUrl()); + + return this; + } + public FormLoginPage formLogin() { return new FormLoginPage(); } From 94e740353056b182d6d259c8a991872d9dec0cc9 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Fri, 28 Feb 2020 14:42:54 +0100 Subject: [PATCH 48/97] massive test changes for new Abstract*Test super-classes and lifecycle Many fixes, removed many unnecessary title outputs (still many left), it gets all the way to model-intest now. --- .../TestIntegrationObjectWrapperFactory.java | 70 +- .../midpoint/gui/TestWrapperDelta.java | 6 - .../midpoint/web/AbstractGuiUnitTest.java | 4 - ...AbstractInitializedGuiIntegrationTest.java | 13 +- .../web/SpringApplicationContextTest.java | 13 +- .../midpoint/web/TestCleanStartup.java | 1 - .../midpoint/web/TestDescriptorLoader.java | 18 +- .../midpoint/web/TestInitialObjects.java | 6 +- .../midpoint/web/TestIntegrationSecurity.java | 22 +- .../midpoint/common/TestCryptoUtil.java | 24 +- .../midpoint/common/TestStaticValues.java | 11 +- .../common/refinery/TestRefinedSchema.java | 39 +- .../midpoint/schema/util/MiscSchemaUtil.java | 2 +- .../evolveum/midpoint/test/util/TestUtil.java | 6 +- .../test/TestAdHocCertification.java | 4 +- .../test/TestCertificationBasic.java | 60 +- .../test/TestCriticalRolesCertification.java | 42 +- .../certification/test/TestEscalation.java | 32 +- .../test/TestManualEscalation.java | 18 +- .../test/TestRoleInducementCertification.java | 42 +- .../test/TestSoDCertification.java | 16 +- .../TestPolicyDrivenRoleLifecycle.java | 18 +- .../model/common/AbstractModelCommonTest.java | 11 +- .../script/TestExpressionFunctions.java | 56 +- .../expression/script/TestScriptCaching.java | 3 - .../common/mapping/TestMappingDomain.java | 19 +- .../mapping/TestMappingDynamicSimple.java | 4 +- .../mapping/TestMappingDynamicSysVar.java | 81 +- .../impl/SpringApplicationContextTest.java | 13 +- .../model/impl/TestRefinedSchema.java | 8 +- .../impl/expr/ExpressionHandlerImplTest.java | 45 +- .../model/impl/expr/TestFilterExpression.java | 28 +- .../model/impl/expr/TestModelExpressions.java | 2 +- .../lens/TestAbstractAssignmentEvaluator.java | 56 +- .../impl/lens/TestAssignmentProcessor.java | 6 +- .../impl/lens/TestAssignmentProcessor2.java | 8 +- .../model/impl/lens/TestClockwork.java | 16 +- .../model/impl/lens/TestPasswordPolicy.java | 12 +- .../model/impl/lens/TestPolicyRules.java | 56 +- .../model/impl/lens/TestPolicyRules2.java | 92 +- .../model/impl/lens/TestProjector.java | 10 +- .../model/impl/lens/TestReconScript.java | 5 +- .../model/impl/migrator/TestMigrator.java | 12 +- .../impl/misc/ShadowIntegrityCheckerTest.java | 4 +- .../TestAbstractAuthenticationEvaluator.java | 48 +- .../TestGuiProfiledPrincipalManager.java | 2 +- .../impl/sync/ActionManagerImplTest.java | 6 +- .../impl/sync/TestSynchronizationService.java | 48 +- .../model/impl/visualizer/TestVisualizer.java | 56 +- .../midpoint/model/intest/TestActivation.java | 110 +- .../midpoint/model/intest/TestAudit.java | 56 +- .../midpoint/model/intest/TestCaseIgnore.java | 40 +- .../model/intest/TestConsistencySimple.java | 4 +- .../midpoint/model/intest/TestDeputy.java | 140 +- .../model/intest/TestEntitlements.java | 272 +-- .../midpoint/model/intest/TestInbounds.java | 28 +- .../midpoint/model/intest/TestIntent.java | 16 +- .../midpoint/model/intest/TestIteration.java | 168 +- .../model/intest/TestIterativeTasks.java | 4 +- .../midpoint/model/intest/TestLifecycle.java | 40 +- .../midpoint/model/intest/TestMerge.java | 16 +- .../intest/TestModelServiceContract.java | 60 +- .../model/intest/TestNotifications.java | 30 +- .../model/intest/TestPreviewChanges.java | 88 +- .../model/intest/TestRaceConditions.java | 2 +- .../midpoint/model/intest/TestResources.java | 72 +- .../model/intest/TestStrangeCases.java | 62 +- .../model/intest/TestTolerantAttributes.java | 8 +- .../model/intest/TestTriggerTask.java | 26 +- .../model/intest/TestUserTemplate.java | 110 +- .../intest/TestUserTemplateWithRanges.java | 36 +- .../midpoint/model/intest/TestVolatility.java | 14 +- .../intest/archetypes/TestArchetypes.java | 82 +- .../intest/archetypes/TestCollections.java | 28 +- .../async/TestAsyncUpdateTaskMechanics.java | 8 +- .../model/intest/gensync/TestEditSchema.java | 140 +- .../intest/gensync/TestRoleEntitlement.java | 22 +- .../AbstractDirectManualResourceTest.java | 136 +- .../AbstractGroupingManualResourceTest.java | 52 +- .../manual/AbstractManualResourceTest.java | 158 +- .../manual/TestDummyItsmIntegration.java | 60 +- .../model/intest/manual/TestSemiManual.java | 16 +- .../intest/manual/TestSemiManualDisable.java | 16 +- .../intest/manual/TestSemiManualGrouping.java | 12 +- .../TestSemiManualGroupingProposed.java | 8 +- .../model/intest/mapping/TestMapping.java | 188 +- .../mapping/TestMappingAutoInbound.java | 56 +- .../intest/mapping/TestMappingInbound.java | 68 +- .../model/intest/misc/TestMigration.java | 12 +- .../midpoint/model/intest/misc/TestMisc.java | 78 +- .../intest/misc/TestUuidNonUniqueName.java | 20 +- .../model/intest/multi/TestMultiAccount.java | 24 +- .../model/intest/multi/TestMultiResource.java | 240 +-- .../intest/negative/TestAssignmentErrors.java | 20 +- .../intest/negative/TestBrokenResources.java | 56 +- .../model/intest/orgstruct/TestOrgStruct.java | 36 +- .../orgstruct/TestOrgStructCaribbean.java | 24 +- .../intest/orgstruct/TestOrgStructMeta.java | 2 +- .../intest/password/AbstractPasswordTest.java | 294 +-- .../intest/password/TestPasswordDefault.java | 4 +- .../password/TestPasswordDefaultHashing.java | 12 +- .../intest/persona/AbstractPersonaTest.java | 40 +- .../intest/persona/TestPersonaPassword.java | 4 +- .../intest/rbac/TestAssignmentValidity.java | 196 +- .../midpoint/model/intest/rbac/TestRbac.java | 580 +++--- .../intest/rbac/TestSegregationOfDuties.java | 130 +- .../intest/security/TestSecurityAdvanced.java | 130 +- .../intest/security/TestSecurityBasic.java | 106 +- .../intest/security/TestSecurityMedium.java | 6 +- .../security/TestSecurityMultitenant.java | 58 +- .../security/TestSecurityPrincipal.java | 22 +- .../intest/sync/AbstractInboundSyncTest.java | 20 +- .../sync/AbstractObjTemplateSyncTest.java | 6 +- .../AbstractSynchronizationStoryTest.java | 66 +- .../model/intest/sync/TestImportRecon.java | 178 +- .../intest/sync/TestInboundLiveSyncTask.java | 4 +- .../intest/sync/TestInboundReconTask.java | 8 +- .../model/intest/sync/TestLiveSyncTask.java | 4 +- .../sync/TestLiveSyncTaskMechanics.java | 56 +- .../intest/sync/TestParallelDiscovery.java | 6 +- .../sync/TestParallelSynchronization.java | 6 +- .../model/intest/sync/TestRecomputeTask.java | 26 +- .../midpoint/model/intest/sync/TestUuid.java | 24 +- .../sync/TestValidityRecomputeTask.java | 114 +- .../test/AbstractModelIntegrationTest.java | 1674 ++++++++--------- .../notifications/impl/TestTextFormatter.java | 58 +- .../impl/TestTransportUtils.java | 16 +- .../evolveum/midpoint/report/TestReport.java | 12 +- .../midpoint/report/TestReportWebService.java | 24 +- .../AbstractTestAssignmentApproval.java | 6 +- .../assignments/TestAssignmentsAdvanced.java | 54 +- .../wf/impl/other/ManualResourceTest.java | 12 +- .../wf/impl/other/TestEscalation.java | 2 +- .../wf/impl/other/TestMiscellaneous.java | 12 +- .../wf/impl/other/TestParallelApprovals.java | 8 +- .../midpoint/wf/impl/other/TestSoD.java | 14 +- .../impl/TestConnectorDiscovery.java | 4 +- .../impl/TestConnectorManager.java | 8 +- .../impl/csv/AbstractCsvTest.java | 6 +- .../impl/dummy/AbstractBasicDummyTest.java | 12 +- .../provisioning/impl/dummy/TestDummy.java | 176 +- .../impl/dummy/TestDummyCaching.java | 10 +- .../impl/dummy/TestDummyConsistency.java | 174 +- .../impl/dummy/TestDummyExtra.java | 12 +- .../impl/dummy/TestDummyNegative.java | 8 +- .../impl/dummy/TestDummyParallelism.java | 50 +- .../TestDummyResourceAndSchemaCaching.java | 5 +- .../impl/dummy/TestDummySchemaless.java | 12 +- .../manual/AbstractManualResourceTest.java | 124 +- .../provisioning/impl/opendj/TestOpenDj.java | 208 +- .../impl/opendj/TestOpenDjDumber.java | 4 +- .../ucf/impl/connid/AbstractUcfDummyTest.java | 12 +- .../ucf/impl/connid/TestUcfOpenDj.java | 12 +- repo/audit-impl/pom.xml | 6 + .../audit/impl/TestAuditServiceImpl.java | 6 +- repo/repo-cache/pom.xml | 8 +- .../repo/cache/TestRepositoryCache.java | 39 +- .../common/commandline/TestCommandLine.java | 8 +- .../midpoint/repo/sql/BaseSQLRepoTest.java | 6 +- .../midpoint/repo/sql/ModifyTest.java | 25 +- .../midpoint/repo/sql/ModifyUser.java | 6 +- repo/repo-test-util/pom.xml | 4 - .../midpoint/test/AbstractHigherUnitTest.java | 17 +- .../test/AbstractIntegrationTest.java | 76 +- .../quartzimpl/AbstractTaskManagerTest.java | 6 +- .../midpoint/task/quartzimpl/CleanupTest.java | 49 +- .../task/quartzimpl/TestPartitioning.java | 2 +- .../TestQuartzTaskManagerContract.java | 58 +- .../quartzimpl/TestWorkBucketStrategies.java | 14 +- .../task/quartzimpl/TestWorkDistribution.java | 30 +- .../quartzimpl/TestWorkersManagement.java | 73 +- .../testing/conntest/AbstractEDirTest.java | 42 +- .../testing/conntest/TestOpenLdap.java | 6 +- .../midpoint/testing/longtest/TestLdap.java | 46 +- .../testing/longtest/TestLdapComplex.java | 20 +- .../testing/longtest/TestLdapUniversity.java | 4 +- .../midpoint/testing/longtest/TestRunAs.java | 28 +- .../testing/rest/TestAbstractRestService.java | 260 +-- .../TestRestServiceProxyAuthentication.java | 10 +- .../midpoint/testing/sanity/TestSanity.java | 24 +- .../TestConfiguredCapabilitiesActivation.java | 8 +- .../story/TestConsistencyMechanism.java | 44 +- .../testing/story/TestDelayedEnable.java | 136 +- .../midpoint/testing/story/TestDelivery.java | 10 +- .../testing/story/TestExistentialIssues.java | 28 +- .../story/TestInboundOutboundAssociation.java | 56 +- .../testing/story/TestLimitedResources.java | 36 +- .../testing/story/TestLiveSyncMadness.java | 12 +- .../midpoint/testing/story/TestMapleLeaf.java | 34 +- .../testing/story/TestMappingMadness.java | 32 +- .../story/TestMisbehavingResources.java | 24 +- .../testing/story/TestNormalizers.java | 8 +- .../testing/story/TestNullAttribute.java | 4 +- .../testing/story/TestOperationCounts.java | 6 +- .../testing/story/TestOperationPerf.java | 4 +- .../midpoint/testing/story/TestOrgSync.java | 32 +- .../story/TestPlentyOfAssignments.java | 40 +- .../testing/story/TestReconNullValue.java | 22 +- .../testing/story/TestRetirement.java | 20 +- .../midpoint/testing/story/TestScience.java | 4 +- .../testing/story/TestServiceAccounts.java | 44 +- .../story/TestServiceAccountsClassifier.java | 34 +- .../testing/story/TestShadowsPerformance.java | 18 +- .../midpoint/testing/story/TestStrings.java | 8 +- .../testing/story/TestThresholds.java | 6 +- .../story/TestThresholdsReconFull.java | 4 +- .../testing/story/TestUniversity.java | 8 +- .../midpoint/testing/story/TestUnix.java | 186 +- .../testing/story/TestUnixTolerantAux.java | 20 +- .../midpoint/testing/story/TestVillage.java | 20 +- .../midpoint/testing/story/TestWriter.java | 8 +- .../ldap/TestLdapAssociationPerformance.java | 34 +- .../testing/story/ldap/TestLdapComplex.java | 116 +- .../story/ldap/TestLdapDependency.java | 32 +- .../testing/story/ldap/TestLdapMutilated.java | 32 +- .../story/ldap/TestLdapReconPerformance.java | 18 +- .../story/ldap/TestLdapSyncMassive.java | 36 +- .../story/ldap/TestLdapVirtualGroup.java | 16 +- .../hierarchy/AbstractLdapHierarchyTest.java | 26 +- .../notorious/AbstractNotoriousTest.java | 104 +- .../testing/story/perf/TestImport.java | 2 +- .../testing/story/security/TestPrivacy.java | 4 +- .../story/security/TestRoleMembers.java | 12 +- 223 files changed, 5343 insertions(+), 5845 deletions(-) diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestIntegrationObjectWrapperFactory.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestIntegrationObjectWrapperFactory.java index 3c827bcdd24..04ae8a6ea5e 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestIntegrationObjectWrapperFactory.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestIntegrationObjectWrapperFactory.java @@ -131,13 +131,12 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100CreateWrapperUserJack() throws Exception { final String TEST_NAME = "test100CreateWrapperUserJack"; - TestUtil.displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertLoggedInUserOid(USER_ADMINISTRATOR_OID); PrismObject user = getUser(USER_JACK_OID); @@ -148,7 +147,7 @@ public void test100CreateWrapperUserJack() throws Exception { PrismObjectWrapper objectWrapper = factory.createObjectWrapper(user, ItemStatus.NOT_CHANGED, context); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); IntegrationTestTools.display("Wrapper after", objectWrapper); @@ -218,11 +217,10 @@ private void assertContainersPaths(PrismObjectWrapper objectWrapper, Collecti @Test public void test110CreateWrapperUserNewEmpty() throws Exception { final String TEST_NAME = "test110CreateWrapperUserNew"; - TestUtil.displayTestTitle(TEST_NAME); PrismObject user = getUserDefinition().instantiate(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -235,7 +233,7 @@ public void test110CreateWrapperUserNewEmpty() throws Exception { PrismObjectWrapper objectWrapper = factory.createObjectWrapper(user, ItemStatus.ADDED, context); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); IntegrationTestTools.display("Wrapper after", objectWrapper); @@ -289,11 +287,10 @@ public void test110CreateWrapperUserNewEmpty() throws Exception { @Test public void test112CreateWrapperUserNewman() throws Exception { final String TEST_NAME = "test112CreateWrapperUserNewman"; - TestUtil.displayTestTitle(TEST_NAME); PrismObject user = getUserDefinition().instantiate(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -313,7 +310,7 @@ public void test112CreateWrapperUserNewman() throws Exception { WrapperTestUtil.fillInPropertyWrapper(modelServiceLocator, mainContainerValueWrapper, extensionPath(PIRACY_SHIP), USER_NEWMAN_SHIP); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); IntegrationTestTools.display("Wrapper after", objectWrapper); @@ -367,12 +364,11 @@ public void test112CreateWrapperUserNewman() throws Exception { @Test public void test102CreateWrapperUserEmpty() throws Exception { final String TEST_NAME = "test102CreateWrapperUserEmpty"; - TestUtil.displayTestTitle(TEST_NAME); PrismObject user = getUser(USER_EMPTY_OID); PrismObject userOld = user.clone(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -384,7 +380,7 @@ public void test102CreateWrapperUserEmpty() throws Exception { PrismObjectWrapper objectWrapper = factory.createObjectWrapper(user, ItemStatus.NOT_CHANGED, context); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); IntegrationTestTools.display("Wrapper after", objectWrapper); @@ -428,14 +424,13 @@ public void test102CreateWrapperUserEmpty() throws Exception { @Test public void test150CreateWrapperShadow() throws Exception { final String TEST_NAME = "test150CreateWrapperShadow"; - TestUtil.displayTestTitle(TEST_NAME); PrismObject shadow = getShadowModel(accountJackOid); shadow.findReference(ShadowType.F_RESOURCE_REF).getValue().setObject(resourceDummy); display("Shadow", shadow); PrismObject shadowOld = shadow.clone(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -450,7 +445,7 @@ public void test150CreateWrapperShadow() throws Exception { // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Wrapper after", objectWrapper); WrapperTestUtil.assertWrapper(objectWrapper, getString("prismContainer.mainPanelDisplayName"), "shadow description", shadow, shadowOld, ItemStatus.NOT_CHANGED); @@ -512,20 +507,16 @@ private PrismObjectWrapper createObjectWrapper(Task ta @Test public void test160CreateWrapperOrgScummBar() throws Exception { - final String TEST_NAME = "test160CreateWrapperOrgScummBar"; - TestUtil.displayTestTitle(TEST_NAME); PrismObject org = getObject(OrgType.class, ORG_SCUMM_BAR_OID); PrismObject orgOld = org.clone(); // WHEN - displayWhen(TEST_NAME); - - Task task = taskManager.createTaskInstance(TEST_NAME); + when(); + Task task = getTestTask(); PrismObjectWrapper objectWrapper = createObjectWrapper(task, org, ItemStatus.NOT_CHANGED); // THEN - displayThen(TEST_NAME); - + then(); IntegrationTestTools.display("Wrapper after", objectWrapper); WrapperTestUtil.assertWrapper(objectWrapper, getString("prismContainer.mainPanelDisplayName"), "org description", org, orgOld, ItemStatus.NOT_CHANGED); @@ -605,14 +596,14 @@ public void test220AssignRoleLandluberToWally() throws Exception { assertGroupMember(dummyGroup, USER_WALLY_NAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObjectWrapper objectWrapper = createObjectWrapper(task, shadow, ItemStatus.NOT_CHANGED); assertTrue("Wrong wrapper created. Expected ShadowWrapper but was " + objectWrapper.getClass().getSimpleName(), objectWrapper instanceof ShadowWrapper); ShadowWrapper shadowWrapper = (ShadowWrapper) objectWrapper; // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Wrapper after", shadowWrapper); @@ -657,11 +648,9 @@ public void test220AssignRoleLandluberToWally() throws Exception { @Test public void test240OrgScummBarModifyTransformDescription() throws Exception { - final String TEST_NAME = "test240OrgScummBarModifyTransformDescription"; - TestUtil.displayTestTitle(TEST_NAME); PrismObject org = getObject(OrgType.class, ORG_SCUMM_BAR_OID); - Task task = taskManager.createTaskInstance(TEST_NAME); + Task task = getTestTask(); PrismObjectWrapper objectWrapper = createObjectWrapper(task, org, ItemStatus.NOT_CHANGED); IntegrationTestTools.display("Wrapper before", objectWrapper); @@ -673,11 +662,11 @@ public void test240OrgScummBarModifyTransformDescription() throws Exception { IntegrationTestTools.display("Wrapper after", objectWrapper); // WHEN - displayWhen(TEST_NAME); + when(); ObjectDelta objectDelta = objectWrapper.getObjectDelta(); // THEN - displayThen(TEST_NAME); + then(); display("Delta", objectDelta); ItemPath ahoyPath = ItemPath.create(ObjectType.F_EXTENSION, PIRACY_TRANSFORM_DESCRIPTION); PrismAsserts.assertPropertyReplace(objectDelta, ahoyPath, "Whatever"); @@ -696,7 +685,6 @@ public void test240OrgScummBarModifyTransformDescription() throws Exception { @Test public void test241OrgScummBarModifyTransformProperties() throws Exception { final String TEST_NAME = "test241OrgScummBarModifyTransformProperties"; - TestUtil.displayTestTitle(TEST_NAME); PrismObject org = getObject(OrgType.class, ORG_SCUMM_BAR_OID); Task task = taskManager.createTaskInstance(TEST_NAME); @@ -717,11 +705,11 @@ public void test241OrgScummBarModifyTransformProperties() throws Exception { IntegrationTestTools.display("Wrapper after", objectWrapper); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ObjectDelta objectDelta = objectWrapper.getObjectDelta(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Delta", objectDelta); ItemPath ahoyPath = ItemPath.create(ObjectType.F_EXTENSION, PIRACY_TRANSFORM, valueWrapperA.getNewValue().getId(), PIRACY_REPLACEMENT); PrismAsserts.assertPropertyReplace(objectDelta, ahoyPath, "Ahoy"); @@ -740,7 +728,6 @@ public void test241OrgScummBarModifyTransformProperties() throws Exception { @Test public void test242OrgScummBarAddTransform() throws Exception { final String TEST_NAME = "test242OrgScummBarAddTransform"; - TestUtil.displayTestTitle(TEST_NAME); PrismObject org = getObject(OrgType.class, ORG_SCUMM_BAR_OID); Task task = taskManager.createTaskInstance(TEST_NAME); @@ -765,11 +752,11 @@ public void test242OrgScummBarAddTransform() throws Exception { IntegrationTestTools.display("Wrapper after", objectWrapper); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ObjectDelta objectDelta = objectWrapper.getObjectDelta(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Delta", objectDelta); ItemPath transformPath = ItemPath.create(ObjectType.F_EXTENSION, PIRACY_TRANSFORM); PrismAsserts.assertModifications(objectDelta, 1); @@ -803,7 +790,6 @@ public void test242OrgScummBarAddTransform() throws Exception { @Test public void test250OrgMinistryOrRumModifyTransformDescription() throws Exception { final String TEST_NAME = "test250OrgMinistryOrRumModifyTransformDescription"; - TestUtil.displayTestTitle(TEST_NAME); PrismObject org = getObject(OrgType.class, ORG_MINISTRY_OF_RUM_OID); Task task = taskManager.createTaskInstance(TEST_NAME); @@ -818,11 +804,11 @@ public void test250OrgMinistryOrRumModifyTransformDescription() throws Exception IntegrationTestTools.display("Wrapper after", objectWrapper); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ObjectDelta objectDelta = objectWrapper.getObjectDelta(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Delta", objectDelta); PrismAsserts.assertModifications(objectDelta, 1); @@ -896,12 +882,12 @@ public void test800EditSchemaJackPropReadAllModifySomeUser() throws Exception { display("user before", user); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObjectWrapper objectWrapper = createObjectWrapper(getTestTask(), user, ItemStatus.NOT_CHANGED); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); IntegrationTestTools.display("Wrapper after", objectWrapper); assertEquals("Wrong object wrapper readOnly", Boolean.FALSE, (Boolean)objectWrapper.isReadOnly()); @@ -968,12 +954,12 @@ public void test802EditSchemaJackPropReadSomeModifySomeUser() throws Exception { display("user before", user); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObjectWrapper objectWrapper = createObjectWrapper(task, user, ItemStatus.NOT_CHANGED); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); IntegrationTestTools.display("Wrapper after", objectWrapper); assertEquals("Wrong object wrapper readOnly", Boolean.FALSE, (Boolean)objectWrapper.isReadOnly()); diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestWrapperDelta.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestWrapperDelta.java index 4cf3917b6a4..3a5ca945126 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestWrapperDelta.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestWrapperDelta.java @@ -79,7 +79,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100modifyUserFullname() throws Exception { final String TEST_NAME = "test100CreateWrapperUserJack"; - TestUtil.displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -110,7 +109,6 @@ public void test100modifyUserFullname() throws Exception { @Test public void test101modifyUserWeapon() throws Exception { final String TEST_NAME = "test101modifyUserWeapon"; - TestUtil.displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -146,7 +144,6 @@ public void test101modifyUserWeapon() throws Exception { @Test public void test110modifyUserAddAssignment() throws Exception { final String TEST_NAME = "test110modifyUserAddAssignment"; - TestUtil.displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -181,7 +178,6 @@ public void test110modifyUserAddAssignment() throws Exception { @Test public void test111modifyUserAssignemnt() throws Exception { final String TEST_NAME = "test110modifyUserAddAssignment"; - TestUtil.displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -320,7 +316,6 @@ public void test200createUser() throws Exception { @Test public void test300SaveSystemConfigWithoutChanges() throws Exception { final String TEST_NAME = "test300SaveSystemConfigWithoutChanges"; - TestUtil.displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -338,7 +333,6 @@ public void test300SaveSystemConfigWithoutChanges() throws Exception { @Test public void test301ModifyProfilingClassLoggerOfSystemConfig() throws Exception { final String TEST_NAME = "test301ModifyProfilingClassLoggerOfSystemConfig"; - TestUtil.displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/AbstractGuiUnitTest.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/AbstractGuiUnitTest.java index 0c7e7327395..c29675aa029 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/AbstractGuiUnitTest.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/AbstractGuiUnitTest.java @@ -36,16 +36,12 @@ import com.evolveum.midpoint.security.enforcer.api.SecurityEnforcer; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.AbstractHigherUnitTest; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; /** * @author lazyman */ public abstract class AbstractGuiUnitTest extends AbstractHigherUnitTest { - private static final Trace LOGGER = TraceManager.getTrace(AbstractGuiUnitTest.class); - protected ModelServiceLocator getServiceLocator() { return new ModelServiceLocator() { diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/AbstractInitializedGuiIntegrationTest.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/AbstractInitializedGuiIntegrationTest.java index 6aec3cd0ec0..02901d3f5d8 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/AbstractInitializedGuiIntegrationTest.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/AbstractInitializedGuiIntegrationTest.java @@ -26,16 +26,11 @@ /** * @author semancik - * */ public abstract class AbstractInitializedGuiIntegrationTest extends AbstractGuiIntegrationTest { private static final Trace LOGGER = TraceManager.getTrace(AbstractInitializedGuiIntegrationTest.class); -// protected final static String PIRACY_NS = "http://midpoint.evolveum.com/xml/ns/samples/piracy"; -// protected final static ItemName PIRACY_WEAPON = new ItemName(PIRACY_NS, "weapon"); - - protected DummyResource dummyResource; protected DummyResourceContoller dummyResourceCtl; protected ResourceType resourceDummyType; @@ -70,8 +65,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000PreparationAndSanity() throws Exception { - final String TEST_NAME = "test000PreparationAndSanity"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -79,11 +72,11 @@ public void test000PreparationAndSanity() throws Exception { assertNotNull("No model service", modelService); // WHEN - TestUtil.displayWhen(TEST_NAME); + when("Jack is assigned with account"); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then("One link (account) is created"); result.computeStatus(); display(result); TestUtil.assertSuccess(result); @@ -92,7 +85,5 @@ public void test000PreparationAndSanity() throws Exception { display("User after change execution", userJack); assertUserJack(userJack); accountJackOid = getSingleLinkOid(userJack); - } - } diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/SpringApplicationContextTest.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/SpringApplicationContextTest.java index be944a9953b..5377ad05c26 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/SpringApplicationContextTest.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/SpringApplicationContextTest.java @@ -7,14 +7,15 @@ package com.evolveum.midpoint.web; -import com.evolveum.midpoint.init.InitialDataImport; -import com.evolveum.midpoint.model.api.ModelService; +import static org.testng.AssertJUnit.assertNotNull; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; import org.testng.annotations.Test; -import static org.testng.AssertJUnit.assertNotNull; +import com.evolveum.midpoint.init.InitialDataImport; +import com.evolveum.midpoint.model.api.ModelService; +import com.evolveum.midpoint.test.util.AbstractSpringTest; /** * Test of spring application context initialization @@ -34,8 +35,8 @@ "classpath:ctx-security.xml", "classpath:ctx-provisioning.xml", "classpath:ctx-model.xml", - "classpath*:ctx-workflow.xml"}) -public class SpringApplicationContextTest extends AbstractTestNGSpringContextTests { + "classpath*:ctx-workflow.xml" }) +public class SpringApplicationContextTest extends AbstractSpringTest { @Autowired private ModelService modelService; diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestCleanStartup.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestCleanStartup.java index d7894f10001..c87225dd5c8 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestCleanStartup.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestCleanStartup.java @@ -45,7 +45,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti // work in progress @Test public void test001Logfiles() throws Exception { - TestUtil.displayTestTitle("test001Logfiles"); // GIVEN - system startup and initialization that has already happened LogfileTestTailer tailer = new LogfileTestTailer(LoggingConfigurationManager.AUDIT_LOGGER_NAME, false); diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestDescriptorLoader.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestDescriptorLoader.java index 7b0d5a272ed..279c90f81ae 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestDescriptorLoader.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestDescriptorLoader.java @@ -14,16 +14,12 @@ import java.util.EventListener; import java.util.Map; import java.util.Set; - import javax.servlet.*; import javax.servlet.descriptor.JspConfigDescriptor; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.web.application.DescriptorLoader; import com.evolveum.midpoint.web.security.MidPointApplication; @@ -43,15 +39,11 @@ "classpath:ctx-security.xml", "classpath:ctx-provisioning.xml", "classpath:ctx-model.xml", - "classpath*:ctx-workflow.xml"}) + "classpath*:ctx-workflow.xml" }) public class TestDescriptorLoader extends AbstractGuiUnitTest { - private static final Trace LOGGER = TraceManager.getTrace(TestDescriptorLoader.class); - - @Test(enabled=false) + @Test(enabled = false) public void testDescriptorLoader() { - final String TEST_NAME = "testDescriptorLoader"; - TestUtil.displayTestTitle(TEST_NAME); MidPointApplication midPointApplication = new MidPointApplication(); ServletContext mockServletContext = new ServletContext() { @@ -235,17 +227,17 @@ public void removeAttribute(String arg0) { @Override public void log(String msg, Throwable e) { - LOGGER.error("{}", msg, e); + logger.error("{}", msg, e); } @Override public void log(Exception e, String msg) { - LOGGER.error("{}", msg, e); + logger.error("{}", msg, e); } @Override public void log(String msg) { - LOGGER.trace("{}", msg); + logger.trace("{}", msg); } @Override diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestInitialObjects.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestInitialObjects.java index e38c70fdb8d..0ff8bc58dd6 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestInitialObjects.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestInitialObjects.java @@ -17,8 +17,6 @@ import com.evolveum.midpoint.schema.validator.ValidationItem; import com.evolveum.midpoint.schema.validator.ValidationResult; import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; /** @@ -28,8 +26,6 @@ */ public class TestInitialObjects extends AbstractGuiUnitTest { - private static final Trace LOGGER = TraceManager.getTrace(TestInitialObjects.class); - private static final File DIR_INITIAL_OBJECTS = new File("src/main/resources/initial-objects"); @Test @@ -48,7 +44,7 @@ public void testInitialObjects() throws Exception { testInitialObject(validator, errorsSb, file); } catch (Throwable e) { String msg = "Error processing file "+file.getName()+": "+e.getMessage(); - LOGGER.error(msg, e); + logger.error(msg, e); display(msg, e); throw e; } diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestIntegrationSecurity.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestIntegrationSecurity.java index ae147a9f79c..7dffcbdf538 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestIntegrationSecurity.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestIntegrationSecurity.java @@ -101,7 +101,7 @@ public void test100DecideNoRole() throws Exception { Authentication authentication = createPasswordAuthentication(USER_JACK_USERNAME, UserType.class); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertAllow(authentication, "/login"); assertAllow(authentication, "/"); @@ -112,7 +112,7 @@ public void test100DecideNoRole() throws Exception { assertDeny(authentication, "/admin/config/debugs"); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); } @Test @@ -128,7 +128,7 @@ public void test110DecideRoleUiAllowAll() throws Exception { Authentication authentication = createPasswordAuthentication(USER_JACK_USERNAME, UserType.class); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertAllow(authentication, "/login"); assertAllow(authentication, "/"); @@ -139,7 +139,7 @@ public void test110DecideRoleUiAllowAll() throws Exception { assertAllow(authentication, "/admin/config/debugs"); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); } @Test @@ -155,7 +155,7 @@ public void test120DecideRoleUiDenyAll() throws Exception { Authentication authentication = createPasswordAuthentication(USER_JACK_USERNAME, UserType.class); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertAllow(authentication, "/login"); assertAllow(authentication, "/"); @@ -166,7 +166,7 @@ public void test120DecideRoleUiDenyAll() throws Exception { assertDeny(authentication, "/admin/config/debugs"); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); } @@ -186,7 +186,7 @@ public void test200DecideRoleUiDenyAllow() throws Exception { Authentication authentication = createPasswordAuthentication(USER_JACK_USERNAME, UserType.class); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertAllow(authentication, "/login"); assertAllow(authentication, "/"); @@ -197,7 +197,7 @@ public void test200DecideRoleUiDenyAllow() throws Exception { assertDeny(authentication, "/admin/config/debugs"); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); } @@ -207,7 +207,7 @@ public void test200DecideRoleUiDenyAllow() throws Exception { @Test public void test300ConflictingAuthorizationIds() throws Exception { final String TEST_NAME = "test300ConflictingAuthorizationIds"; - displayTestTitle(TEST_NAME); + // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_AUTHORIZATION_1.oid); @@ -216,11 +216,11 @@ public void test300ConflictingAuthorizationIds() throws Exception { display("user before", user); // WHEN - displayWhen(TEST_NAME); + when("Jack logs in"); login(USER_JACK_USERNAME); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertLoggedInUsername(USER_JACK_USERNAME); } diff --git a/infra/common/src/test/java/com/evolveum/midpoint/common/TestCryptoUtil.java b/infra/common/src/test/java/com/evolveum/midpoint/common/TestCryptoUtil.java index cc26d6eecb8..7409690bf20 100644 --- a/infra/common/src/test/java/com/evolveum/midpoint/common/TestCryptoUtil.java +++ b/infra/common/src/test/java/com/evolveum/midpoint/common/TestCryptoUtil.java @@ -18,6 +18,7 @@ import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.schema.MidPointPrismContextFactory; import com.evolveum.midpoint.schema.constants.MidPointConstants; +import com.evolveum.midpoint.test.util.AbstractUnitTest; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; @@ -45,7 +46,7 @@ * @author mederly */ @Listeners({com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class}) -public class TestCryptoUtil { +public class TestCryptoUtil extends AbstractUnitTest { private static final File TEST_DIR = new File(TEST_RESOURCES_DIR, "crypto"); private static final File FILE_USER_JACK = new File(TEST_DIR, "user-jack.xml"); @@ -69,9 +70,6 @@ public void setup() throws SchemaException, SAXException, IOException { @Test public void test100CheckEncryptedUser() throws Exception { - final String TEST_NAME = "test100CheckEncryptedUser"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = getPrismContext(); PrismObject jack = prismContext.parserFor(FILE_USER_JACK).xml().parse(); @@ -82,9 +80,6 @@ public void test100CheckEncryptedUser() throws Exception { @Test public void test110EncryptUser() throws Exception { - final String TEST_NAME = "test110EncryptUser"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = getPrismContext(); PrismObject jack = prismContext.parserFor(FILE_USER_JACK).xml().parse(); @@ -99,9 +94,6 @@ public void test110EncryptUser() throws Exception { @Test public void test120EncryptBulkActionTask() throws Exception { - final String TEST_NAME = "test120EncryptBulkActionTask"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = getPrismContext(); PrismObject task = prismContext.parserFor(FILE_TASK_MODIFY_JACK_PASSWORD).xml().parse(); @@ -119,9 +111,6 @@ public void test120EncryptBulkActionTask() throws Exception { @Test public void test130EncryptUserInDelta() throws Exception { - final String TEST_NAME = "test130EncryptUserInDelta"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = getPrismContext(); PrismObject task = prismContext.parserFor(FILE_TASK_ADD_JACK).xml().parse(); @@ -140,9 +129,6 @@ public void test130EncryptUserInDelta() throws Exception { // MID-4941 @Test public void test200CheckEncryptedSystemConfiguration() throws Exception { - final String TEST_NAME = "test200CheckEncryptedSystemConfiguration"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = getPrismContext(); PrismObject config = prismContext.parserFor(FILE_SYSTEM_CONFIGURATION).xml().parse(); @@ -154,9 +140,6 @@ public void test200CheckEncryptedSystemConfiguration() throws Exception { // MID-4941 @Test public void test210EncryptSystemConfiguration() throws Exception { - final String TEST_NAME = "test210EncryptSystemConfiguration"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = getPrismContext(); PrismObject config = prismContext.parserFor(FILE_SYSTEM_CONFIGURATION).xml().parse(); @@ -173,9 +156,6 @@ public void test210EncryptSystemConfiguration() throws Exception { @SuppressWarnings("SimplifiedTestNGAssertion") @Test public void test300Reencryption() throws Exception { - final String TEST_NAME = "test300Reencryption"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = getPrismContext(); PrismObject jack = prismContext.parserFor(FILE_USER_JACK).xml().parse(); diff --git a/infra/common/src/test/java/com/evolveum/midpoint/common/TestStaticValues.java b/infra/common/src/test/java/com/evolveum/midpoint/common/TestStaticValues.java index 1b7988221c6..8b5373b9587 100644 --- a/infra/common/src/test/java/com/evolveum/midpoint/common/TestStaticValues.java +++ b/infra/common/src/test/java/com/evolveum/midpoint/common/TestStaticValues.java @@ -10,6 +10,7 @@ import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.schema.MidPointPrismContextFactory; import com.evolveum.midpoint.schema.constants.MidPointConstants; +import com.evolveum.midpoint.test.util.AbstractUnitTest; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.PrettyPrinter; @@ -33,7 +34,7 @@ /** * @author semancik */ -public class TestStaticValues { +public class TestStaticValues extends AbstractUnitTest { private static final QName PROP_NAME = new QName("http://whatever.com/", "foo"); @@ -45,10 +46,6 @@ public void setup() throws SchemaException, SAXException, IOException { @Test public void testValueElementsRoundtripString() throws Exception { - final String TEST_NAME = "testValueElementsRoundtripString"; - TestUtil.displayTestTitle(TEST_NAME); - - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); MutablePrismPropertyDefinition propDef = prismContext.definitionFactory().createPropertyDefinition(PROP_NAME, DOMUtil.XSD_STRING); propDef.setMaxOccurs(-1); @@ -61,10 +58,6 @@ public void testValueElementsRoundtripString() throws Exception { @Test public void testValueElementsRoundtripInt() throws Exception { - final String TEST_NAME = "testValueElementsRoundtripInt"; - TestUtil.displayTestTitle(TEST_NAME); - - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); MutablePrismPropertyDefinition propDef = prismContext.definitionFactory().createPropertyDefinition(PROP_NAME, DOMUtil.XSD_INT); propDef.setMaxOccurs(-1); 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 09099f0a9b5..bbe28fd82c2 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 @@ -56,6 +56,7 @@ import com.evolveum.midpoint.schema.util.ResourceTypeUtil; import com.evolveum.midpoint.schema.util.SchemaTestConstants; import com.evolveum.midpoint.schema.util.ShadowUtil; +import com.evolveum.midpoint.test.util.AbstractUnitTest; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.PrettyPrinter; @@ -71,7 +72,7 @@ * @author semancik */ @Listeners({com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class}) -public class TestRefinedSchema { +public class TestRefinedSchema extends AbstractUnitTest { public static final String TEST_DIR_NAME = "src/test/resources/refinery"; private static final File RESOURCE_COMPLEX_FILE = new File(TEST_DIR_NAME, "resource-complex.xml"); @@ -96,9 +97,6 @@ public void setup() throws SchemaException, SAXException, IOException { @Test public void test010ParseFromResourceComplex() throws Exception { - final String TEST_NAME = "test010ParseFromResourceComplex"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = createInitializedPrismContext(); @@ -106,11 +104,11 @@ public void test010ParseFromResourceComplex() throws Exception { ResourceType resourceType = resource.asObjectable(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.parse(resourceType, prismContext); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertNotNull("Refined schema is null", rSchema); System.out.println("Refined schema"); System.out.println(rSchema.debugDump()); @@ -136,9 +134,6 @@ private void assertLayerRefinedSchema(ResourceType resourceType, RefinedResource @Test public void test020ParseFromResourceSimple() throws Exception { - final String TEST_NAME = "test020ParseFromResourceSimple"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = createInitializedPrismContext(); @@ -292,9 +287,6 @@ private void assertRefinedToLayer(ResourceAttributeDefinition attrDef, LayerType @Test public void test100ParseAccount() throws Exception { - final String TEST_NAME = "test100ParseAccount"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = createInitializedPrismContext(); @@ -327,9 +319,6 @@ public void test100ParseAccount() throws Exception { @Test public void test110ApplyAttributeDefinition() throws Exception { - final String TEST_NAME = "test110ApplyAttributeDefinition"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = createInitializedPrismContext(); @@ -404,9 +393,6 @@ private ItemName getAttrQName(PrismObject resource, String localPa @Test public void test120CreateShadow() throws Exception { - final String TEST_NAME = "test120CreateShadow"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = createInitializedPrismContext(); @@ -434,9 +420,6 @@ public void test120CreateShadow() throws Exception { @Test public void test130ProtectedAccount() throws Exception { - final String TEST_NAME = "test130ProtectedAccount"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = createInitializedPrismContext(); PrismObject resource = prismContext.parseObject(RESOURCE_COMPLEX_FILE); @@ -560,9 +543,6 @@ private ResourceAttribute createStringAttribute(QName attrName, String v @Test public void test140ParseFromResourcePosix() throws Exception { - final String TEST_NAME = "test140ParseFromResourcePosix"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = createInitializedPrismContext(); @@ -570,11 +550,11 @@ public void test140ParseFromResourcePosix() throws Exception { ResourceType resourceType = resource.asObjectable(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.parse(resourceType, prismContext); // THEN - TestUtil.displayThen(TEST_NAME); + when(); assertNotNull("Refined schema is null", rSchema); System.out.println("Refined schema"); System.out.println(rSchema.debugDump()); @@ -690,9 +670,6 @@ public void test140ParseFromResourcePosix() throws Exception { // MID-5648 @Test public void test200ParseFromResourceMultithreaded() throws Exception { - final String TEST_NAME = "test200ParseFromResourceMultithreaded"; - TestUtil.displayTestTitle(TEST_NAME); - int THREADS = 50; // GIVEN @@ -702,7 +679,7 @@ public void test200ParseFromResourceMultithreaded() throws Exception { ResourceType resourceType = resource.asObjectable(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AtomicInteger errors = new AtomicInteger(0); List threads = new ArrayList<>(THREADS); @@ -721,7 +698,7 @@ public void test200ParseFromResourceMultithreaded() throws Exception { } // THEN - TestUtil.displayThen(TEST_NAME); + when(); TestUtil.waitForCompletion(threads, 20000); assertEquals("Wrong # of errors", 0, errors.get()); diff --git a/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/MiscSchemaUtil.java b/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/MiscSchemaUtil.java index a70b7ce6e58..55f2152d672 100644 --- a/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/MiscSchemaUtil.java +++ b/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/MiscSchemaUtil.java @@ -225,7 +225,7 @@ public static Collection> createCollection(Obj */ @SuppressWarnings({ "rawtypes", "unchecked" }) public static Collection> createCollection(ItemDelta... deltas) { - return (Collection)MiscUtil.createCollection(deltas); + return MiscUtil.createCollection(deltas); } public static Collection> cloneObjectDeltaCollection( diff --git a/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/TestUtil.java b/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/TestUtil.java index e38e9e0f1d3..7ef4ca5e17f 100644 --- a/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/TestUtil.java +++ b/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/TestUtil.java @@ -193,15 +193,15 @@ public static void displayWhen(String testName, String description) { LOGGER.info(TEST_LOG_SECTION_PREFIX + testName + ": WHEN " + description + TEST_LOG_SECTION_SUFFIX); } - // TODO change like when + @Deprecated // use version with separate testName and description public static void displayThen(String testName) { System.out.println(TEST_OUT_SECTION_PREFIX + " THEN " + testName + TEST_OUT_SECTION_SUFFIX); LOGGER.info(TEST_LOG_SECTION_PREFIX + " THEN " + testName + TEST_LOG_SECTION_SUFFIX); } public static void displayThen(String testName, String part) { - System.out.println(TEST_OUT_SECTION_PREFIX + " THEN " + testName + " (" + part + ")" + TEST_OUT_SECTION_SUFFIX); - LOGGER.info(TEST_LOG_SECTION_PREFIX + " THEN " + testName + " (" + part + ")" + TEST_LOG_SECTION_SUFFIX); + System.out.println(TEST_OUT_SECTION_PREFIX + testName + ": THEN " + part + TEST_OUT_SECTION_SUFFIX); + LOGGER.info(TEST_LOG_SECTION_PREFIX + testName + ": THEN " + part + TEST_LOG_SECTION_SUFFIX); } public static void displayCleanup(String testName) { diff --git a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestAdHocCertification.java b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestAdHocCertification.java index ab59b1345ae..dd99775f72a 100644 --- a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestAdHocCertification.java +++ b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestAdHocCertification.java @@ -73,7 +73,7 @@ public void test010HireIndigo() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignOrg(USER_INDIGO_OID, ORG_LABORATORY_OID, task, result); // THEN @@ -103,7 +103,7 @@ public void test020ModifyIndigo() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); @SuppressWarnings({ "unchecked", "raw" }) ObjectDelta delta = prismContext.deltaFor(UserType.class) .item(UserType.F_DESCRIPTION).replace("new description") diff --git a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestCertificationBasic.java b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestCertificationBasic.java index 8ab72408ed3..2917749a84b 100644 --- a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestCertificationBasic.java +++ b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestCertificationBasic.java @@ -86,7 +86,7 @@ public void test001CreateForeignCampaign() throws Exception { AccessCertificationDefinitionType.class, result).asObjectable(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); AccessCertificationCampaignType campaign = certificationService.createCampaign(roleInducementCertDefinition.getOid(), task, result); @@ -116,7 +116,7 @@ public void test002OpenFirstForeignStage() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); certificationService.openNextStage(roleInducementCampaignOid, task, result); // THEN @@ -137,10 +137,10 @@ public void test005CreateCampaignDenied() throws Exception { // GIVEN Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); - login(getUserFromRepo(USER_ELAINE_OID)); // elaine is a reviewer, not authorized to create campaigns + login(getUserFromRepo(USER_ELAINE_OID)); // elaine is a reviewer, not authorized to create campaigns // WHEN/THEN - TestUtil.displayWhen(TEST_NAME); + when(); try { certificationService.createCampaign(certificationDefinition.getOid(), task, result); fail("Unexpected success"); @@ -160,7 +160,7 @@ public void test006CreateCampaignDeniedBobWrongDeputy() throws Exception { login(getUserFromRepo(USER_BOB_DEPUTY_NO_ASSIGNMENTS_OID)); // this is a deputy with limitation blocking all assignments // WHEN/THEN - TestUtil.displayWhen(TEST_NAME); + when(); try { certificationService.createCampaign(certificationDefinition.getOid(), task, result); fail("Unexpected success"); @@ -180,7 +180,7 @@ public void test010CreateCampaignAllowedForDeputy() throws Exception { login(getUserFromRepo(USER_BOB_DEPUTY_FULL_OID)); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCampaignType campaign = certificationService.createCampaign(certificationDefinition.getOid(), task, result); @@ -215,7 +215,7 @@ public void test011CreateCampaignAllowed() throws Exception { login(getUserFromRepo(USER_BOB_OID)); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCampaignType campaign = certificationService.createCampaign(certificationDefinition.getOid(), task, result); @@ -259,7 +259,7 @@ private void searchWithNoCasesExpected(String TEST_NAME) throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List caseList = modelService.searchContainers( AccessCertificationCaseType.class, CertCampaignTypeUtil.createCasesForCampaignQuery(campaignOid, prismContext), null, task, result); @@ -285,7 +285,7 @@ public void test020OpenFirstStageDenied() throws Exception { login(getUserFromRepo(USER_ELAINE_OID)); // WHEN+THEN - TestUtil.displayWhen(TEST_NAME); + when(); try { certificationService.openNextStage(campaignOid, task, result); fail("Unexpected success"); @@ -308,7 +308,7 @@ public void test021OpenFirstStageAllowed() throws Exception { task.setOwner(getUserFromRepo(USER_BOB_OID)); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationService.openNextStage(campaignOid, task, result); // THEN @@ -363,7 +363,7 @@ public void test032SearchAllCasesAllowed() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List caseList = modelService.searchContainers( AccessCertificationCaseType.class, null, null, task, result); @@ -387,7 +387,7 @@ public void test034SearchAllCasesAllowedDeputy() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List caseList = modelService.searchContainers( AccessCertificationCaseType.class, null, null, task, result); @@ -411,7 +411,7 @@ public void test040SearchCasesFilteredSortedPaged() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); Collection> resolveNames = SelectorOptions.createCollection(GetOperationOptions.createResolveNames()); ObjectQuery query = prismContext.queryFor(AccessCertificationCaseType.class) @@ -452,7 +452,7 @@ public void test050SearchWorkItemsAdministrator() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List workItems = certificationService.searchOpenWorkItems( CertCampaignTypeUtil.createWorkItemsForCampaignQuery(campaignOid, prismContext), @@ -479,7 +479,7 @@ public void test052SearchWorkItemsByTenantRef() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); ObjectQuery query = prismContext.queryFor(AccessCertificationWorkItemType.class) .exists(T_PARENT) .block() @@ -512,7 +512,7 @@ public void test054SearchDecisionsByOrgRef() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); ObjectQuery query = prismContext.queryFor(AccessCertificationWorkItemType.class) .exists(T_PARENT) .block() @@ -544,7 +544,7 @@ public void test056SearchDecisionsByAdminStatus() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); ObjectQuery query = prismContext.queryFor(AccessCertificationWorkItemType.class) .exists(T_PARENT) .block() @@ -576,7 +576,7 @@ public void test060SearchOpenWorkItemsDeputyDenied() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List workItems = certificationService.searchOpenWorkItems(CertCampaignTypeUtil.createWorkItemsForCampaignQuery(campaignOid, prismContext), false, null, task, result); @@ -601,7 +601,7 @@ public void test062SearchOpenWorkItemsDeputyAllowed() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List workItems = certificationService.searchOpenWorkItems(CertCampaignTypeUtil.createWorkItemsForCampaignQuery(campaignOid, prismContext), false, null, task, result); @@ -630,7 +630,7 @@ public void test100RecordDecision() throws Exception { AccessCertificationCaseType superuserCase = findCase(caseList, USER_ADMINISTRATOR_OID, ROLE_SUPERUSER_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationWorkItemType workItem = CertCampaignTypeUtil.findWorkItem(superuserCase, 1, 1, USER_ADMINISTRATOR_OID); long id = superuserCase.asPrismContainerValue().getId(); certificationService.recordDecision(campaignOid, id, workItem.getId(), ACCEPT, "no comment", task, result); @@ -667,7 +667,7 @@ public void test105RecordAcceptJackCeo() throws Exception { AccessCertificationCaseType ceoCase = findCase(caseList, USER_JACK_OID, ROLE_CEO_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationWorkItemType workItem = CertCampaignTypeUtil.findWorkItem(ceoCase, 1, 1, USER_ADMINISTRATOR_OID); // reviewerRef will be taken from the current user long id = ceoCase.asPrismContainerValue().getId(); @@ -705,7 +705,7 @@ public void test110RecordRevokeJackCeo() throws Exception { AccessCertificationCaseType ceoCase = findCase(caseList, USER_JACK_OID, ROLE_CEO_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); // reviewerRef will be taken from the current user long id = ceoCase.asPrismContainerValue().getId(); AccessCertificationWorkItemType workItem = CertCampaignTypeUtil.findWorkItem(ceoCase, 1, 1, USER_ADMINISTRATOR_OID); @@ -763,7 +763,7 @@ public void test150CloseFirstStageDeny() throws Exception { OperationResult result = task.getResult(); // WHEN+THEN - TestUtil.displayWhen(TEST_NAME); + when(); try { certificationService.closeCurrentStage(campaignOid, task, result); fail("Unexpected success"); @@ -783,7 +783,7 @@ public void test151CloseCampaignDeny() throws Exception { OperationResult result = task.getResult(); // WHEN+THEN - TestUtil.displayWhen(TEST_NAME); + when(); try { certificationService.closeCampaign(campaignOid, task, result); fail("Unexpected success"); @@ -804,7 +804,7 @@ public void test152CloseFirstStageAllow() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationService.closeCurrentStage(campaignOid, task, result); // THEN @@ -840,7 +840,7 @@ public void test200StartRemediationDeny() throws Exception { OperationResult result = task.getResult(); // WHEN+THEN - TestUtil.displayWhen(TEST_NAME); + when(); try { certificationService.startRemediation(campaignOid, task, result); } catch (SecurityViolationException e) { @@ -860,7 +860,7 @@ public void test205StartRemediationAllow() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationService.startRemediation(campaignOid, task, result); // THEN @@ -933,7 +933,7 @@ public void test900CleanupCampaignsDeny() throws Exception { OperationResult result = task.getResult(); // WHEN+THEN - TestUtil.displayWhen(TEST_NAME); + when(); CleanupPolicyType policy = new CleanupPolicyType().maxRecords(0); certificationService.cleanupCampaigns(policy, task, result); display("result", result); @@ -954,7 +954,7 @@ public void test910CleanupCampaignsAllow() throws Exception { OperationResult result = task.getResult(); // WHEN+THEN - TestUtil.displayWhen(TEST_NAME); + when(); CleanupPolicyType policy = new CleanupPolicyType().maxRecords(0); certificationService.cleanupCampaigns(policy, task, result); result.computeStatus(); @@ -1013,7 +1013,7 @@ public void test920CleanupCampaignsByAge() throws Exception { display("campaigns", getAllCampaigns(result)); // WHEN+THEN - TestUtil.displayWhen(TEST_NAME); + when(); CleanupPolicyType policy = new CleanupPolicyType().maxAge(XmlTypeConverter.createDuration("P1D")); certificationService.cleanupCampaigns(policy, task, result); result.computeStatus(); diff --git a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestCriticalRolesCertification.java b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestCriticalRolesCertification.java index fec47a54481..570104bb9c4 100644 --- a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestCriticalRolesCertification.java +++ b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestCriticalRolesCertification.java @@ -73,7 +73,7 @@ public void test010CreateCampaign() throws Exception { dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCampaignType campaign = certificationManager.createCampaign(certificationDefinition.getOid(), task, result); @@ -123,7 +123,7 @@ public void test020OpenFirstStage() throws Exception { dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationManager.openNextStage(campaignOid, task, result); // THEN @@ -187,7 +187,7 @@ public void test100RecordDecisions1() throws Exception { List caseList = queryHelper.searchCases(campaignOid, null, null, result); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assertEquals("unexpected # of cases", 6, caseList.size()); AccessCertificationCaseType guybrushCooCase = findCase(caseList, USER_GUYBRUSH_OID, ROLE_COO_OID); @@ -230,7 +230,7 @@ public void test150CloseFirstStage() throws Exception { dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationManager.closeCurrentStage(campaignOid, task, result); // THEN @@ -272,7 +272,7 @@ public void test200OpenSecondStage() throws Exception { dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationManager.openNextStage(campaignOid, task, result); // THEN @@ -344,7 +344,7 @@ public void test220StatisticsAllStages() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCasesStatisticsType stat = certificationManager.getCampaignStatistics(campaignOid, false, task, result); @@ -375,7 +375,7 @@ public void test250RecordDecisionsSecondStage() throws Exception { List caseList = queryHelper.searchCases(campaignOid, null, null, result); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); /* Stage2: allMustAccept, default: accept, advance on: accept (target owner) @@ -460,7 +460,7 @@ public void test260Statistics() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCasesStatisticsType stat = certificationManager.getCampaignStatistics(campaignOid, true, task, result); @@ -491,7 +491,7 @@ public void test290CloseSecondStage() throws Exception { dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationManager.closeCurrentStage(campaignOid, task, result); // THEN @@ -537,7 +537,7 @@ public void test300OpenThirdStage() throws Exception { dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationManager.openNextStage(campaignOid, task, result); // THEN @@ -615,7 +615,7 @@ public void test330RecordDecisionsThirdStage() throws Exception { dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); /* Case Stage1 Stage2 Stage3 @@ -721,7 +721,7 @@ public void test390CloseThirdStage() throws Exception { dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationManager.closeCurrentStage(campaignOid, task, result); // THEN @@ -787,7 +787,7 @@ public void test400OpenFourthStage() throws Exception { dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationManager.openNextStage(campaignOid, task, result); // THEN @@ -863,7 +863,7 @@ public void test430RecordDecisionsFourthStage() throws Exception { List caseList = queryHelper.searchCases(campaignOid, null, null, result); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); /* Stage4: allMustAccept @@ -968,7 +968,7 @@ public void test490CloseFourthStage() throws Exception { dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationManager.closeCurrentStage(campaignOid, task, result); // THEN @@ -1035,7 +1035,7 @@ public void test495StartRemediation() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationManager.startRemediation(campaignOid, task, result); // THEN @@ -1087,7 +1087,7 @@ public void test497Statistics() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCasesStatisticsType stat = certificationManager.getCampaignStatistics(campaignOid, false, task, result); @@ -1145,7 +1145,7 @@ public void test500Reiterate() throws Exception { dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); //certificationManager.closeCampaign(campaignOid, true, task, result); certificationManager.reiterateCampaign(campaignOid, task, result); @@ -1237,7 +1237,7 @@ public void test510OpenNextStage() throws Exception { // next stage is dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationManager.openNextStage(campaignOid, task, result); // THEN @@ -1323,7 +1323,7 @@ Out of them, completed (for stage 2) are: elaine->CEO, guybrush->COO, administra // OperationResult result = task.getResult(); // // // WHEN -// TestUtil.displayWhen(TEST_NAME); +// when(); // certificationManager.closeCurrentStage(campaignOid, task, result); // // // THEN @@ -1361,7 +1361,7 @@ Out of them, completed (for stage 2) are: elaine->CEO, guybrush->COO, administra // OperationResult result = task.getResult(); // // // WHEN -// TestUtil.displayWhen(TEST_NAME); +// when(); // certificationManager.openNextStage(campaignOid, task, result); // // // THEN diff --git a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestEscalation.java b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestEscalation.java index 5790aae10ca..dae35133c5b 100644 --- a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestEscalation.java +++ b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestEscalation.java @@ -68,7 +68,7 @@ public void test010CreateCampaign() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCampaignType campaign = certificationService.createCampaign(certificationDefinition.getOid(), task, result); @@ -102,7 +102,7 @@ private void searchWithNoCasesExpected(String TEST_NAME) throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List caseList = modelService.searchContainers( AccessCertificationCaseType.class, CertCampaignTypeUtil.createCasesForCampaignQuery(campaignOid, prismContext), null, task, result); @@ -127,7 +127,7 @@ public void test021OpenFirstStage() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationService.openNextStage(campaignOid, task, result); // THEN @@ -165,7 +165,7 @@ public void test032SearchAllCases() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List caseList = modelService.searchContainers( AccessCertificationCaseType.class, null, null, task, result); @@ -188,7 +188,7 @@ public void test050SearchWorkItems() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List workItems = certificationService.searchOpenWorkItems( CertCampaignTypeUtil.createWorkItemsForCampaignQuery(campaignOid, prismContext), @@ -217,7 +217,7 @@ public void test100RecordDecision() throws Exception { AccessCertificationCaseType superuserCase = findCase(caseList, USER_ADMINISTRATOR_OID, ROLE_SUPERUSER_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationWorkItemType workItem = CertCampaignTypeUtil.findWorkItem(superuserCase, 1, 1, USER_ADMINISTRATOR_OID); long id = superuserCase.asPrismContainerValue().getId(); certificationService.recordDecision(campaignOid, id, workItem.getId(), ACCEPT, "no comment", task, result); @@ -253,7 +253,7 @@ public void test110Escalate() throws Exception { dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); clock.resetOverride(); clock.overrideDuration("P2D"); // first escalation is at P1D @@ -320,7 +320,7 @@ public void test120EscalateAgain() throws Exception { dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); clock.resetOverride(); clock.overrideDuration("P4D"); // second escalation is at P3D @@ -389,7 +389,7 @@ public void test130Remediation() throws Exception { dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); clock.resetOverride(); clock.overrideDuration("P15D"); // stage ends at P14D @@ -419,7 +419,7 @@ public void test140Close() throws Exception { dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); clock.resetOverride(); clock.overrideDuration("P16D"); @@ -450,7 +450,7 @@ public void test200AutomaticReiteration() throws Exception { dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); clock.resetOverride(); clock.overrideDuration("P18D"); // campaign ends at P16D, reiteration scheduled to P17D @@ -508,7 +508,7 @@ public void test300Close() throws Exception { dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); clock.resetOverride(); clock.overrideDuration("P19D"); // +1 day relative to previous test @@ -539,7 +539,7 @@ public void test310ManualReiteration() throws Exception { dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); clock.resetOverride(); clock.overrideDuration("P20D"); // +1 day relative to previous test @@ -584,7 +584,7 @@ public void test320OpenFirstStage() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationService.openNextStage(campaignOid, task, result); // THEN @@ -639,7 +639,7 @@ public void test400Close() throws Exception { dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); clock.resetOverride(); clock.overrideDuration("P21D"); // +1 day relative to previous test @@ -670,7 +670,7 @@ public void test410ManualReiterationUnavailable() throws Exception { dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); clock.resetOverride(); clock.overrideDuration("P22D"); // +1 day relative to previous test diff --git a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestManualEscalation.java b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestManualEscalation.java index 6e3e93f548f..239224c426b 100644 --- a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestManualEscalation.java +++ b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestManualEscalation.java @@ -72,7 +72,7 @@ public void test010CreateCampaign() throws Exception { login(getUserFromRepo(USER_BOB_OID)); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCampaignType campaign = certificationService.createCampaign(certificationDefinition.getOid(), task, result); @@ -102,7 +102,7 @@ public void test013SearchAllCasesAllowed() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List caseList = modelService.searchContainers( AccessCertificationCaseType.class, CertCampaignTypeUtil.createCasesForCampaignQuery(campaignOid, prismContext), null, task, result); @@ -127,7 +127,7 @@ public void test021OpenFirstStageAllowed() throws Exception { login(getUserFromRepo(USER_BOB_OID)); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationService.openNextStage(campaignOid, task, result); // THEN @@ -163,7 +163,7 @@ public void test032SearchAllCasesAllowed() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List caseList = modelService.searchContainers( AccessCertificationCaseType.class, null, null, task, result); @@ -187,7 +187,7 @@ public void test050SearchWorkItemsAsAdministrator() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List workItems = certificationService.searchOpenWorkItems( CertCampaignTypeUtil.createWorkItemsForCampaignQuery(campaignOid, prismContext), @@ -217,7 +217,7 @@ public void test100RecordDecision() throws Exception { AccessCertificationCaseType superuserCase = findCase(caseList, USER_ADMINISTRATOR_OID, ROLE_SUPERUSER_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationWorkItemType workItem = CertCampaignTypeUtil.findWorkItem(superuserCase, 1, 1, USER_ADMINISTRATOR_OID); long id = superuserCase.asPrismContainerValue().getId(); certificationService.recordDecision(campaignOid, id, workItem.getId(), ACCEPT, "no comment", task, result); @@ -250,7 +250,7 @@ public void test110Escalate() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); EscalateWorkItemActionType action = new EscalateWorkItemActionType() .approverRef(USER_JACK_OID, UserType.COMPLEX_TYPE) .delegationMethod(WorkItemDelegationMethodType.ADD_ASSIGNEES) @@ -299,7 +299,7 @@ public void test120EscalateAgain() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); EscalateWorkItemActionType action = new EscalateWorkItemActionType() .approverRef(USER_ELAINE_OID, UserType.COMPLEX_TYPE) .escalationLevelName("ESC-2"); @@ -353,7 +353,7 @@ public void test130Delegate() throws Exception { display("CEO case", ceoCase); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationWorkItemType workItem = CertCampaignTypeUtil.findWorkItem(ceoCase, 1, 1, USER_ELAINE_OID); long id = ceoCase.asPrismContainerValue().getId(); DelegateWorkItemActionType action = new DelegateWorkItemActionType() diff --git a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestRoleInducementCertification.java b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestRoleInducementCertification.java index 2f4a5b92fda..5457026ec9f 100644 --- a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestRoleInducementCertification.java +++ b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestRoleInducementCertification.java @@ -55,7 +55,7 @@ public void test010CreateCampaign() throws Exception { AccessCertificationDefinitionType.class, result).asObjectable(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCampaignType campaign = certificationManager.createCampaign(certificationDefinition.getOid(), task, result); @@ -85,7 +85,7 @@ public void test012SearchAllCases() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List caseList = queryHelper.searchCases(campaignOid, null, null, result); // THEN @@ -107,7 +107,7 @@ public void test014Statistics() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCasesStatisticsType stat = certificationManager.getCampaignStatistics(campaignOid, true, task, result); @@ -137,7 +137,7 @@ public void test020OpenFirstStage() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationManager.openNextStage(campaignOid, task, result); // THEN @@ -184,7 +184,7 @@ public void test024Statistics() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCasesStatisticsType stat = certificationManager.getCampaignStatistics(campaignOid, true, task, result); @@ -214,7 +214,7 @@ public void test030SearchAllCases() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List caseList = queryHelper.searchCases(campaignOid, null, null, result); // THEN @@ -239,7 +239,7 @@ public void test050SearchDecisionsAdministrator() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List workItems = queryHelper.searchOpenWorkItems(null, SecurityUtil.getPrincipal(), false, null, result); @@ -273,7 +273,7 @@ public void test051SearchDecisionsElaine() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List workItems = queryHelper.searchOpenWorkItems(null, SecurityUtil.getPrincipal(), false, null, result); @@ -303,7 +303,7 @@ public void test052SearchDecisionsJack() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List workItems = queryHelper.searchOpenWorkItems(null, SecurityUtil.getPrincipal(), false, null, result); @@ -342,7 +342,7 @@ public void test100RecordDecisions() throws Exception { List caseList = queryHelper.searchCases(campaignOid, null, null, result); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCaseType ceoDummyCase = findCase(caseList, ROLE_CEO_OID, RESOURCE_DUMMY_OID); AccessCertificationCaseType cooDummyCase = findCase(caseList, ROLE_COO_OID, RESOURCE_DUMMY_OID); @@ -398,7 +398,7 @@ public void test110Statistics() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCasesStatisticsType stat = certificationManager.getCampaignStatistics(campaignOid, true, task, result); @@ -429,7 +429,7 @@ public void test150CloseFirstStage() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationManager.closeCurrentStage(campaignOid, task, result); // THEN @@ -476,7 +476,7 @@ public void test160Statistics() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCasesStatisticsType stat = certificationManager.getCampaignStatistics(campaignOid, true, task, result); @@ -506,7 +506,7 @@ public void test200OpenSecondStage() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationManager.openNextStage(campaignOid, task, result); // THEN @@ -565,7 +565,7 @@ public void test210Statistics() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCasesStatisticsType stat = certificationManager.getCampaignStatistics(campaignOid, true, task, result); @@ -594,7 +594,7 @@ public void test220StatisticsAllStages() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCasesStatisticsType stat = certificationManager.getCampaignStatistics(campaignOid, false, task, result); @@ -625,7 +625,7 @@ public void test250RecordDecisionsSecondStage() throws Exception { List caseList = queryHelper.searchCases(campaignOid, null, null, result); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCaseType cooDummyBlackCase = findCase(caseList, ROLE_COO_OID, RESOURCE_DUMMY_BLACK_OID); AccessCertificationCaseType cooSuperuserCase = findCase(caseList, ROLE_COO_OID, ROLE_SUPERUSER_OID); @@ -710,7 +710,7 @@ public void test260Statistics() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCasesStatisticsType stat = certificationManager.getCampaignStatistics(campaignOid, true, task, result); @@ -740,7 +740,7 @@ public void test290CloseSecondStage() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationManager.closeCurrentStage(campaignOid, task, result); // THEN @@ -801,7 +801,7 @@ public void test300StartRemediation() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationManager.startRemediation(campaignOid, task, result); // THEN @@ -874,7 +874,7 @@ public void test310Statistics() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCasesStatisticsType stat = certificationManager.getCampaignStatistics(campaignOid, false, task, result); diff --git a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestSoDCertification.java b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestSoDCertification.java index b3c3a13c2b1..613ad7d7443 100644 --- a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestSoDCertification.java +++ b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestSoDCertification.java @@ -164,7 +164,7 @@ public void test010CreateCampaign() throws Exception { AccessCertificationDefinitionType.class, result).asObjectable(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCampaignType campaign = certificationManager.createCampaign(certificationDefinition.getOid(), task, result); @@ -193,7 +193,7 @@ public void test012SearchAllCases() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List caseList = queryHelper.searchCases(campaignOid, null, null, result); // THEN @@ -215,7 +215,7 @@ public void test014Statistics() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCasesStatisticsType stat = certificationManager.getCampaignStatistics(campaignOid, true, task, result); @@ -247,7 +247,7 @@ public void test020OpenFirstStage() throws Exception { display("jack", getUser(USER_JACK_OID)); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationManager.openNextStage(campaignOid, task, result); // THEN @@ -291,7 +291,7 @@ public void test030SearchAllCases() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List caseList = queryHelper.searchCases(campaignOid, null, null, result); // THEN @@ -318,7 +318,7 @@ public void test100RecordDecisions() throws Exception { List caseList = queryHelper.searchCases(campaignOid, null, null, result); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCaseType test2aCase = findCase(caseList, USER_JACK_OID, roleATest2aOid); AccessCertificationCaseType test2bCase = findCase(caseList, USER_JACK_OID, roleATest2bOid); @@ -374,7 +374,7 @@ public void test150CloseFirstStage() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationManager.closeCurrentStage(campaignOid, task, result); // THEN @@ -420,7 +420,7 @@ public void test200StartRemediation() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationManager.startRemediation(campaignOid, task, result); // THEN diff --git a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/complex/TestPolicyDrivenRoleLifecycle.java b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/complex/TestPolicyDrivenRoleLifecycle.java index ac8e1b27d4b..d43e3234fd3 100644 --- a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/complex/TestPolicyDrivenRoleLifecycle.java +++ b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/complex/TestPolicyDrivenRoleLifecycle.java @@ -120,7 +120,7 @@ public void test010AttemptToActivateIncompleteRoleC1345() throws Exception { OperationResult result = task.getResult(); // WHEN+THEN - TestUtil.displayWhen(TEST_NAME); + when(); TestUtil.displayThen(TEST_NAME); Holder> contextHolder = new Holder<>(); activateRoleAssertFailure(roleEmptyOid, contextHolder, result, task); @@ -155,7 +155,7 @@ public void test020AttemptToActivateIncompleteRoleC234() throws Exception { OperationResult result = task.getResult(); // WHEN+THEN - TestUtil.displayWhen(TEST_NAME); + when(); TestUtil.displayThen(TEST_NAME); Holder> contextHolder = new Holder<>(); activateRoleAssertFailure(roleHighRiskEmptyOid, contextHolder, result, task); @@ -178,7 +178,7 @@ public void test030AttemptToActivateCorrectRoleC34() throws Exception { OperationResult result = task.getResult(); // WHEN+THEN - TestUtil.displayWhen(TEST_NAME); + when(); TestUtil.displayThen(TEST_NAME); Holder> contextHolder = new Holder<>(); activateRoleAssertFailure(roleCorrectOid, contextHolder, result, task); @@ -205,7 +205,7 @@ public void test040AssignOwnerAndApproverToCorrectRole() throws Exception { OperationResult result = task.getResult(); // WHEN+THEN - TestUtil.displayWhen(TEST_NAME); + when(); TestUtil.displayThen(TEST_NAME); ModelExecuteOptions noApprovals = createPartialProcessing(new PartialProcessingOptionsType().approvals(SKIP)); assignRole(USER_ADMINISTRATOR_OID, roleCorrectOid, SchemaConstants.ORG_APPROVER, noApprovals, task, result); @@ -226,7 +226,7 @@ public void test050ActivateCorrectRole() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); Holder> contextHolder = new Holder<>(); activateRole(roleCorrectOid, contextHolder, task, result); @@ -285,7 +285,7 @@ public void test060AssignOwnerAndApproverToCorrectHighRiskRole() throws Exceptio OperationResult result = task.getResult(); // WHEN+THEN - TestUtil.displayWhen(TEST_NAME); + when(); TestUtil.displayThen(TEST_NAME); ModelExecuteOptions noApprovals = createPartialProcessing(new PartialProcessingOptionsType().approvals(SKIP)); assignRole(USER_ADMINISTRATOR_OID, roleCorrectHighRiskOid, SchemaConstants.ORG_APPROVER, noApprovals, task, result); @@ -307,7 +307,7 @@ public void test070ActivateCorrectHighRiskRole() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); Holder> contextHolder = new Holder<>(); activateRole(roleCorrectHighRiskOid, contextHolder, task, result); @@ -389,7 +389,7 @@ private void activateRole(String oid, Holder> contextHolder, Task // OperationResult result = task.getResult(); // // // WHEN -// TestUtil.displayWhen(TEST_NAME); +// when(); // assignOrg(USER_INDIGO_OID, ORG_LABORATORY_OID, task, result); // // // THEN @@ -420,7 +420,7 @@ private void activateRole(String oid, Holder> contextHolder, Task // OperationResult result = task.getResult(); // // // WHEN -// TestUtil.displayWhen(TEST_NAME); +// when(); // @SuppressWarnings({ "unchecked", "raw" }) // ObjectDelta delta = (ObjectDelta) DeltaBuilder.deltaFor(UserType.class, prismContext) // .item(UserType.F_DESCRIPTION).replace("new description") diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/AbstractModelCommonTest.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/AbstractModelCommonTest.java index ca11d7a866e..432ba8363fb 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/AbstractModelCommonTest.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/AbstractModelCommonTest.java @@ -10,13 +10,14 @@ import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.task.api.test.NullTaskImpl; +import com.evolveum.midpoint.test.util.AbstractUnitTest; import com.evolveum.midpoint.test.util.TestUtil; /** * @author semancik * */ -public class AbstractModelCommonTest { +public class AbstractModelCommonTest extends AbstractUnitTest { protected static final File COMMON_DIR = new File("src/test/resources/common"); @@ -27,14 +28,6 @@ protected void displayTestTitle(final String TEST_NAME) { TestUtil.displayTestTitle(this, TEST_NAME); } - protected void displayWhen(final String TEST_NAME) { - TestUtil.displayWhen(TEST_NAME); - } - - protected void displayThen(final String TEST_NAME) { - TestUtil.displayThen(TEST_NAME); - } - protected Task createTask() { return new NullTaskImpl(); } diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/TestExpressionFunctions.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/TestExpressionFunctions.java index 2d89123b983..5373650259c 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/TestExpressionFunctions.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/TestExpressionFunctions.java @@ -73,9 +73,6 @@ public void setup() throws SchemaException, SAXException, IOException { @Test public void testGetExtensionPropertyValue() throws Exception { - final String TEST_NAME = "testGetExtensionPropertyValue"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN BasicExpressionFunctions f = createBasicFunctions(); PrismObject userJack = PrismTestUtil.parseObject(USER_JACK_FILE); @@ -90,9 +87,6 @@ public void testGetExtensionPropertyValue() throws Exception { @Test public void testGetExtensionPropertyValueParts() throws Exception { - final String TEST_NAME = "testGetExtensionPropertyValueParts"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN BasicExpressionFunctions f = createBasicFunctions(); PrismObject userJack = PrismTestUtil.parseObject(USER_JACK_FILE); @@ -108,9 +102,6 @@ public void testGetExtensionPropertyValueParts() throws Exception { @Test public void testGetExtensionPropertyValueNotPresent() throws Exception { - final String TEST_NAME = "testGetExtensionPropertyValueNotPresent"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN BasicExpressionFunctions f = createBasicFunctions(); PrismObject userJack = PrismTestUtil.parseObject(USER_JACK_FILE); @@ -125,9 +116,6 @@ public void testGetExtensionPropertyValueNotPresent() throws Exception { @Test public void testGetExtensionPropertyValueNullObject() throws Exception { - final String TEST_NAME = "testGetExtensionPropertyValueNullObject"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN BasicExpressionFunctions f = createBasicFunctions(); @@ -141,9 +129,6 @@ public void testGetExtensionPropertyValueNullObject() throws Exception { @Test public void testGetAttributeValueParts() throws Exception { - final String TEST_NAME = "testGetAttributeValueParts"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN BasicExpressionFunctions f = createBasicFunctions(); PrismObject accountJack = PrismTestUtil.parseObject(ACCOUNT_JACK_FILE); @@ -159,9 +144,6 @@ public void testGetAttributeValueParts() throws Exception { @Test public void testGetAttributeValueDefaultRi() throws Exception { - final String TEST_NAME = "testGetAttributeValueDefaultRi"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN BasicExpressionFunctions f = createBasicFunctions(); PrismObject accountJack = PrismTestUtil.parseObject(ACCOUNT_JACK_FILE); @@ -176,9 +158,6 @@ public void testGetAttributeValueDefaultRi() throws Exception { @Test public void testGetAttributeValuesParts() throws Exception { - final String TEST_NAME = "testGetAttributeValuesParts"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN BasicExpressionFunctions f = createBasicFunctions(); PrismObject accountJack = PrismTestUtil.parseObject(ACCOUNT_JACK_FILE); @@ -194,9 +173,6 @@ public void testGetAttributeValuesParts() throws Exception { @Test public void testGetAttributeValuesDefaultRi() throws Exception { - final String TEST_NAME = "testGetAttributeValuesDefaultRi"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN BasicExpressionFunctions f = createBasicFunctions(); PrismObject accountJack = PrismTestUtil.parseObject(ACCOUNT_JACK_FILE); @@ -211,9 +187,6 @@ public void testGetAttributeValuesDefaultRi() throws Exception { @Test public void testgetResourceIcfConfigurationPropertyValueStringHost() throws Exception { - final String TEST_NAME = "testgetResourceIcfConfigurationPropertyValueStringHost"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN BasicExpressionFunctions f = createBasicFunctions(); PrismObject resource = PrismTestUtil.parseObject(RESOURCE_OPENDJ_FILE); @@ -227,9 +200,6 @@ public void testgetResourceIcfConfigurationPropertyValueStringHost() throws Exce @Test public void testgetResourceIcfConfigurationPropertyValueStringPort() throws Exception { - final String TEST_NAME = "testgetResourceIcfConfigurationPropertyValueStringPort"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN BasicExpressionFunctions f = createBasicFunctions(); PrismObject resource = PrismTestUtil.parseObject(RESOURCE_OPENDJ_FILE); @@ -243,9 +213,6 @@ public void testgetResourceIcfConfigurationPropertyValueStringPort() throws Exce @Test public void testDetermineLdapSingleAttributeValue01() throws Exception { - final String TEST_NAME = "testDetermineLdapSingleAttributeValue01"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN BasicExpressionFunctions f = createBasicFunctions(); String dn = "uid=foo, ou=People, dc=example,dc=com"; @@ -363,9 +330,6 @@ public void testFormatDateTime() throws Exception { @Test public void testParseDateTime() throws Exception { - final String TEST_NAME = "testParseDateTime"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN BasicExpressionFunctions f = createBasicFunctions(); @@ -389,8 +353,6 @@ private BasicExpressionFunctions createBasicFunctions() throws SchemaException, @Test public void testStringify() throws Exception { - final String TEST_NAME = "testStringifyString"; - TestUtil.displayTestTitle(TEST_NAME); BasicExpressionFunctions basic = createBasicFunctions(); assertEquals("foo", basic.stringify("foo")); assertEquals("foo", basic.stringify(poly("foo"))); @@ -402,8 +364,6 @@ public void testStringify() throws Exception { @Test public void testConcatName() throws Exception { - final String TEST_NAME = "testConcatName"; - TestUtil.displayTestTitle(TEST_NAME); BasicExpressionFunctions basic = createBasicFunctions(); assertEquals("foo bar", basic.concatName("foo","bar")); assertEquals("foo bar", basic.concatName(poly("foo"),"bar")); @@ -425,8 +385,6 @@ private PolyString poly(String s) { @Test public void testToAscii() throws Exception { - final String TEST_NAME = "testToAscii"; - TestUtil.displayTestTitle(TEST_NAME); BasicExpressionFunctions basic = createBasicFunctions(); assertEquals("foo", basic.toAscii("foo")); assertEquals("foo", basic.toAscii(poly("foo"))); @@ -434,14 +392,12 @@ public void testToAscii() throws Exception { assertEquals("Cortuv hrad, tam Strasa!", basic.toAscii("Čórtův hrád, tam Strašá!")); assertEquals("hrabe Teleke z Toloko", basic.toAscii(poly("hrabě Teleke z Tölökö"))); assertEquals("Vedeckotechnicka revoluce neni zadna idyla!", basic.toAscii(PrismTestUtil.createPolyStringType("Vědeckotechnická revoluce není žádná idyla!"))); - assertEquals(null, basic.toAscii(null)); + assertNull(basic.toAscii(null)); assertEquals("", basic.toAscii("")); } @Test public void testComposeDn() throws Exception { - final String TEST_NAME = "testComposeDn"; - TestUtil.displayTestTitle(TEST_NAME); BasicExpressionFunctions basic = createBasicFunctions(); assertEquals("cn=foo,o=bar", basic.composeDn("cn","foo","o","bar")); @@ -462,8 +418,6 @@ public void testComposeDn() throws Exception { @Test public void testComposeDnWithSuffix() throws Exception { - final String TEST_NAME = "testComposeDnWithSuffix"; - TestUtil.displayTestTitle(TEST_NAME); BasicExpressionFunctions basic = createBasicFunctions(); assertEquals("cn=foo,ou=baz,o=bar", basic.composeDnWithSuffix(new Rdn("cn","foo"),"ou=baz,o=bar")); @@ -490,8 +444,6 @@ public void testComposeDnWithSuffix() throws Exception { @Test public void testParseFullName() throws Exception { - final String TEST_NAME = "testParseFullName"; - TestUtil.displayTestTitle(TEST_NAME); BasicExpressionFunctions basic = createBasicFunctions(); assertEquals(null, basic.parseGivenName(null)); @@ -523,8 +475,6 @@ public void testParseFullName() throws Exception { */ @Test public void testHashLdapPasswordSsha() throws Exception { - final String TEST_NAME = "testHashLdapPasswordSsha"; - TestUtil.displayTestTitle(TEST_NAME); BasicExpressionFunctions basic = createBasicFunctions(); // WHEN @@ -544,8 +494,6 @@ public void testHashLdapPasswordSsha() throws Exception { */ @Test public void testHashLdapPasswordSshaProtectedStringClear() throws Exception { - final String TEST_NAME = "testHashLdapPasswordSshaProtectedStringClear"; - TestUtil.displayTestTitle(TEST_NAME); BasicExpressionFunctions basic = createBasicFunctions(); ProtectedStringType protectedString = new ProtectedStringType(); @@ -568,8 +516,6 @@ public void testHashLdapPasswordSshaProtectedStringClear() throws Exception { */ @Test public void testHashLdapPasswordSshaProtectedStringEncrypted() throws Exception { - final String TEST_NAME = "testHashLdapPasswordSshaProtectedStringEncrypted"; - TestUtil.displayTestTitle(TEST_NAME); BasicExpressionFunctions basic = createBasicFunctions(); ProtectedStringType protectedString = new ProtectedStringType(); diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/TestScriptCaching.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/TestScriptCaching.java index 815748b9418..da4331f5864 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/TestScriptCaching.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/TestScriptCaching.java @@ -96,9 +96,6 @@ public void setupFactory() { @Test public void testGetExtensionPropertyValue() throws Exception { - final String TEST_NAME = "testGetExtensionPropertyValue"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN InternalMonitor.reset(); diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDomain.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDomain.java index b9da769043e..ed0f93e9309 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDomain.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDomain.java @@ -26,6 +26,7 @@ import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.test.util.AbstractUnitTest; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; @@ -36,7 +37,7 @@ * MID-3692 * @author Radovan Semancik */ -public class TestMappingDomain { +public class TestMappingDomain extends AbstractUnitTest { private static final String MAPPING_DOMAIN_FILENAME = "mapping-domain.xml"; @@ -64,7 +65,7 @@ public void testControlReplaceSingleValue() throws Exception { employeeTypeOld.add("1234567890"); ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() - .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, + .createModificationReplaceProperty(UserType.class, MappingTestEvaluator.USER_OLD_OID, UserType.F_ADDITIONAL_NAME, "Jackie"); delta.addModificationReplaceProperty(UserType.F_EMPLOYEE_TYPE, "321"); @@ -107,7 +108,7 @@ public void testControlReplaceMultiValue() throws Exception { employeeTypeOld.add("003"); ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() - .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, + .createModificationReplaceProperty(UserType.class, MappingTestEvaluator.USER_OLD_OID, UserType.F_ADDITIONAL_NAME, "Jackie"); delta.addModificationReplaceProperty(UserType.F_EMPLOYEE_TYPE, "991", "992"); @@ -149,7 +150,7 @@ public void testReplaceMixedMultiValue() throws Exception { employeeTypeOld.add("004"); ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() - .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, + .createModificationReplaceProperty(UserType.class, MappingTestEvaluator.USER_OLD_OID, UserType.F_ADDITIONAL_NAME, "Jackie"); delta.addModificationReplaceProperty(UserType.F_EMPLOYEE_TYPE, "X91", "992", "Y93", "994"); @@ -160,7 +161,7 @@ public void testReplaceMixedMultiValue() throws Exception { OperationResult opResult = new OperationResult(TEST_NAME); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); mapping.evaluate(createTask(), opResult); // THEN @@ -194,7 +195,7 @@ public void testAddMixedMultiValue() throws Exception { employeeTypeOld.add("004"); ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() - .createModificationAddProperty(UserType.class, evaluator.USER_OLD_OID, + .createModificationAddProperty(UserType.class, MappingTestEvaluator.USER_OLD_OID, UserType.F_EMPLOYEE_TYPE, "X91", "992", "Y93", "994"); MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( @@ -204,7 +205,7 @@ public void testAddMixedMultiValue() throws Exception { OperationResult opResult = new OperationResult(TEST_NAME); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); mapping.evaluate(createTask(), opResult); // THEN @@ -241,7 +242,7 @@ public void testDeleteMixedMultiValue() throws Exception { employeeTypeOld.add("007"); ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() - .createModificationDeleteProperty(UserType.class, evaluator.USER_OLD_OID, + .createModificationDeleteProperty(UserType.class, MappingTestEvaluator.USER_OLD_OID, UserType.F_EMPLOYEE_TYPE, "005", "C06", "007"); MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( @@ -251,7 +252,7 @@ public void testDeleteMixedMultiValue() throws Exception { OperationResult opResult = new OperationResult(TEST_NAME); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); mapping.evaluate(createTask(), opResult); // THEN diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSimple.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSimple.java index 48803088a07..7daca0ead66 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSimple.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSimple.java @@ -1019,7 +1019,7 @@ public void testScriptTransformMultiAddDelete() throws Exception { OperationResult opResult = new OperationResult(TEST_NAME); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); mapping.evaluate(createTask(), opResult); // THEN @@ -1059,7 +1059,7 @@ public void testScriptTransformMultiReplace() throws Exception { OperationResult opResult = new OperationResult(TEST_NAME); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); mapping.evaluate(createTask(), opResult); // THEN diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSysVar.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSysVar.java index 0e5820b9caa..8b9874c2db1 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSysVar.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSysVar.java @@ -50,9 +50,6 @@ public class TestMappingDynamicSysVar extends AbstractModelCommonTest { private static final Trace LOGGER = TraceManager.getTrace(TestMappingDynamicSysVar.class); - private static final String NS_EXTENSION = "http://midpoint.evolveum.com/xml/ns/test/extension"; - private static final String PATTERN_NUMERIC = "^\\d+$"; - private MappingTestEvaluator evaluator; @BeforeClass @@ -745,9 +742,6 @@ public void testEmployeeNumberProtectedString() throws Exception { @Test public void testEmployeeTypeDeltaAreplaceB() throws Exception { - final String TEST_NAME = "testEmployeeTypeDeltaAreplaceB"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, @@ -755,13 +749,13 @@ public void testEmployeeTypeDeltaAreplaceB() throws Exception { MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-script-system-variables-employee-type.xml", - TEST_NAME, "employeeType", delta); + getTestNameShort(), "employeeType", delta); PrismObject user = (PrismObject) mapping.getSourceContext().getOldObject(); setEmployeeType(user.asObjectable(), "A"); mapping.getSourceContext().recompute(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(getTestNameShort()); // WHEN mapping.evaluate(createTask(), opResult); @@ -776,9 +770,6 @@ public void testEmployeeTypeDeltaAreplaceB() throws Exception { @Test public void testEmployeeTypeDeltaNullreplaceB() throws Exception { - final String TEST_NAME = "testEmployeeTypeDeltaNullreplaceB"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, @@ -786,13 +777,13 @@ public void testEmployeeTypeDeltaNullreplaceB() throws Exception { MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-script-system-variables-employee-type.xml", - TEST_NAME, "employeeType", delta); + getTestNameShort(), "employeeType", delta); PrismObject user = (PrismObject) mapping.getSourceContext().getOldObject(); setEmployeeType(user.asObjectable()); mapping.getSourceContext().recompute(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(getTestNameShort()); // WHEN mapping.evaluate(createTask(), opResult); @@ -807,9 +798,6 @@ public void testEmployeeTypeDeltaNullreplaceB() throws Exception { @Test public void testEmployeeTypeDeltaBreplaceB() throws Exception { - final String TEST_NAME = "testEmployeeTypeDeltaBreplaceB"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, @@ -817,13 +805,13 @@ public void testEmployeeTypeDeltaBreplaceB() throws Exception { MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-script-system-variables-employee-type.xml", - TEST_NAME, "employeeType", delta); + getTestNameShort(), "employeeType", delta); PrismObject user = (PrismObject) mapping.getSourceContext().getOldObject(); setEmployeeType(user.asObjectable(), "B"); mapping.getSourceContext().recompute(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(getTestNameShort()); // WHEN mapping.evaluate(createTask(), opResult); @@ -838,12 +826,9 @@ public void testEmployeeTypeDeltaBreplaceB() throws Exception { @Test public void testEmployeeTypeDeltaAaddB() throws Exception { - final String TEST_NAME = "testEmployeeTypeDeltaAaddB"; - TestUtil.displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = - employeeTypeDeltaABAdd(TEST_NAME, "B", "A"); + employeeTypeDeltaABAdd("B", "A"); // THEN PrismAsserts.assertTripleZero(outputTriple, "A"); @@ -853,12 +838,9 @@ public void testEmployeeTypeDeltaAaddB() throws Exception { @Test public void testEmployeeTypeDeltaABaddB() throws Exception { - final String TEST_NAME = "testEmployeeTypeDeltaABaddB"; - TestUtil.displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = - employeeTypeDeltaABAdd(TEST_NAME, "B", "A", "B"); + employeeTypeDeltaABAdd("B", "A", "B"); // THEN PrismAsserts.assertTripleZero(outputTriple, "A"); @@ -868,12 +850,9 @@ public void testEmployeeTypeDeltaABaddB() throws Exception { @Test public void testEmployeeTypeDeltaBaddB() throws Exception { - final String TEST_NAME = "testEmployeeTypeDeltaBaddB"; - TestUtil.displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = - employeeTypeDeltaABAdd(TEST_NAME, "B", "B"); + employeeTypeDeltaABAdd("B", "B"); // THEN PrismAsserts.assertTripleNoZero(outputTriple); @@ -883,12 +862,9 @@ public void testEmployeeTypeDeltaBaddB() throws Exception { @Test public void testEmployeeTypeDeltaNulladdB() throws Exception { - final String TEST_NAME = "testEmployeeTypeDeltaNulladdB"; - TestUtil.displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = - employeeTypeDeltaABAdd(TEST_NAME, "B"); + employeeTypeDeltaABAdd("B"); // THEN PrismAsserts.assertTripleNoZero(outputTriple); @@ -897,9 +873,7 @@ public void testEmployeeTypeDeltaNulladdB() throws Exception { } public PrismValueDeltaSetTriple> employeeTypeDeltaABAdd( - final String TEST_NAME, String addVal, String... oldVals) throws Exception { - TestUtil.displayTestTitle(TEST_NAME); - + String addVal, String... oldVals) throws Exception { // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, evaluator.USER_OLD_OID, @@ -907,13 +881,13 @@ public PrismValueDeltaSetTriple> employeeTypeDeltaABA MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-script-system-variables-employee-type.xml", - TEST_NAME, "employeeType", delta); + getTestNameShort(), "employeeType", delta); PrismObject user = (PrismObject) mapping.getSourceContext().getOldObject(); setEmployeeType(user.asObjectable(), oldVals); mapping.getSourceContext().recompute(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(getTestNameShort()); // WHEN mapping.evaluate(createTask(), opResult); @@ -932,12 +906,9 @@ private void setEmployeeType(UserType userType, String... vals) { @Test public void testEmployeeTypeDeltaBdeleteB() throws Exception { - final String TEST_NAME = "testEmployeeTypeDeltaBdeleteB"; - TestUtil.displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = - employeeTypeDeltaDelete(TEST_NAME, "B", "B"); + employeeTypeDeltaDelete("B", "B"); // THEN PrismAsserts.assertTripleNoZero(outputTriple); @@ -947,12 +918,9 @@ public void testEmployeeTypeDeltaBdeleteB() throws Exception { @Test public void testEmployeeTypeDeltaABdeleteB() throws Exception { - final String TEST_NAME = "testEmployeeTypeDeltaABdeleteB"; - TestUtil.displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = - employeeTypeDeltaDelete(TEST_NAME, "B", "A", "B"); + employeeTypeDeltaDelete("B", "A", "B"); // THEN PrismAsserts.assertTripleZero(outputTriple, "A"); @@ -962,12 +930,9 @@ public void testEmployeeTypeDeltaABdeleteB() throws Exception { @Test public void testEmployeeTypeDeltaAdeleteB() throws Exception { - final String TEST_NAME = "testEmployeeTypeDeltaAdeleteB"; - TestUtil.displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = - employeeTypeDeltaDelete(TEST_NAME, "B", "A"); + employeeTypeDeltaDelete("B", "A"); // THEN PrismAsserts.assertTripleZero(outputTriple, "A"); @@ -977,12 +942,9 @@ public void testEmployeeTypeDeltaAdeleteB() throws Exception { @Test public void testEmployeeTypeDeltaNulldeleteB() throws Exception { - final String TEST_NAME = "testEmployeeTypeDeltaNulldeleteB"; - TestUtil.displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = - employeeTypeDeltaDelete(TEST_NAME, "B"); + employeeTypeDeltaDelete("B"); // THEN PrismAsserts.assertTripleNoZero(outputTriple); @@ -990,9 +952,8 @@ public void testEmployeeTypeDeltaNulldeleteB() throws Exception { PrismAsserts.assertTripleMinus(outputTriple, "B"); } - public PrismValueDeltaSetTriple> employeeTypeDeltaDelete(final String TEST_NAME, String delVal, String... oldVals) throws Exception { - TestUtil.displayTestTitle(TEST_NAME); - + public PrismValueDeltaSetTriple> employeeTypeDeltaDelete( + String delVal, String... oldVals) throws Exception { // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationDeleteProperty(UserType.class, evaluator.USER_OLD_OID, @@ -1000,13 +961,13 @@ public PrismValueDeltaSetTriple> employeeTypeDeltaDel MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-script-system-variables-employee-type.xml", - TEST_NAME, "employeeType", delta); + getTestNameShort(), "employeeType", delta); PrismObject user = (PrismObject) mapping.getSourceContext().getOldObject(); setEmployeeType(user.asObjectable(), oldVals); mapping.getSourceContext().recompute(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(getTestNameShort()); // WHEN mapping.evaluate(createTask(), opResult); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/SpringApplicationContextTest.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/SpringApplicationContextTest.java index 5bb3b624b0e..0f53e75c191 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/SpringApplicationContextTest.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/SpringApplicationContextTest.java @@ -8,24 +8,23 @@ package com.evolveum.midpoint.model.impl; import static org.testng.AssertJUnit.assertNotNull; -import org.testng.annotations.Test; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; +import org.testng.annotations.Test; import com.evolveum.midpoint.repo.api.RepositoryService; +import com.evolveum.midpoint.test.util.AbstractSpringTest; /** - * * Test of spring application context initialization * * @author Igor Farinic - * */ -@ContextConfiguration(locations = {"classpath:ctx-model-test-main.xml"}) -public class SpringApplicationContextTest extends AbstractTestNGSpringContextTests { +@ContextConfiguration(locations = { "classpath:ctx-model-test-main.xml" }) +public class SpringApplicationContextTest extends AbstractSpringTest { - @Autowired(required = true) + @Autowired RepositoryService repositoryService; @Test diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/TestRefinedSchema.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/TestRefinedSchema.java index 765e019f0ba..473ea8371d3 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/TestRefinedSchema.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/TestRefinedSchema.java @@ -91,7 +91,7 @@ public void test010SanityModel() throws Exception { } @Test - public void test100EntitlementRefinedObjectClasses() throws Exception { + public void test100EntitlementRefinedObjectClasses() { final String TEST_NAME = "test100EntitlementRefinedObjectClasses"; TestUtil.displayTestTitle(this, TEST_NAME); @@ -109,7 +109,7 @@ public void test100EntitlementRefinedObjectClasses() throws Exception { } @Test - public void test101EntitlementRefinedObjectClassesModel() throws Exception { + public void test101EntitlementRefinedObjectClassesModel() { final String TEST_NAME = "test101EntitlementRefinedObjectClassesModel"; TestUtil.displayTestTitle(this, TEST_NAME); @@ -269,8 +269,8 @@ public void test124DetermineObjectClassKindIntentObjectClassModel() throws Excep ShadowKindType.ENTITLEMENT, "privilege", LayerType.MODEL); } - private void assertObjectClass(ObjectClassComplexTypeDefinition objectClass, - QName objectClassQName) { + private void assertObjectClass( + ObjectClassComplexTypeDefinition objectClass, QName objectClassQName) { assertNotNull("No object class", objectClass); assertEquals("Wrong object class QName in object class " + objectClass, objectClassQName, objectClass.getTypeName()); } diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/expr/ExpressionHandlerImplTest.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/expr/ExpressionHandlerImplTest.java index 399078f6af7..9e46d817f58 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/expr/ExpressionHandlerImplTest.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/expr/ExpressionHandlerImplTest.java @@ -11,9 +11,7 @@ import java.io.File; import java.io.IOException; - -import com.evolveum.midpoint.prism.xnode.MapXNode; -import com.evolveum.midpoint.prism.xnode.RootXNode; +import javax.xml.namespace.QName; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; @@ -21,43 +19,32 @@ import org.springframework.security.core.context.SecurityContext; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; import org.xml.sax.SAXException; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.util.PrismTestUtil; +import com.evolveum.midpoint.prism.xnode.MapXNode; +import com.evolveum.midpoint.prism.xnode.RootXNode; import com.evolveum.midpoint.schema.MidPointPrismContextFactory; import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.SchemaDebugUtil; import com.evolveum.midpoint.security.api.MidPointPrincipal; +import com.evolveum.midpoint.test.util.AbstractSpringTest; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ConditionalSearchFilterType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectSynchronizationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; - -import javax.xml.namespace.QName; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; /** - * * @author lazyman - * */ @ContextConfiguration(locations = { "classpath:ctx-model-test-no-repo.xml" }) -public class ExpressionHandlerImplTest extends AbstractTestNGSpringContextTests { +public class ExpressionHandlerImplTest extends AbstractSpringTest { private static final Trace LOGGER = TraceManager.getTrace(ExpressionHandlerImplTest.class); private static final File TEST_FOLDER = new File("./src/test/resources/expr"); @@ -81,8 +68,7 @@ public void setup() throws SchemaException, SAXException, IOException { // This test is wrong. Maybe wrong place. // But the problem is, that the account here contains raw values. It does not have // the definition applied. Therefore the equals() in groovy won't work. - @Test(enabled=false) - @SuppressWarnings("unchecked") + @Test(enabled = false) public void testConfirmUser() throws Exception { PrismObject account = PrismTestUtil.parseObject(new File( TEST_FOLDER, "account-xpath-evaluation.xml")); @@ -109,7 +95,6 @@ public void testConfirmUser() throws Exception { assertTrue("Wrong expression result (expected true)", confirmed); } - @SuppressWarnings("unchecked") @Test public void testEvaluateExpression() throws Exception { PrismObject account = PrismTestUtil.parseObject(new File(TEST_FOLDER, "account.xml")); @@ -121,14 +106,14 @@ public void testEvaluateExpression() throws Exception { accountType.setResourceRef(resourceRef); ObjectSynchronizationType synchronization = resourceType.getSynchronization().getObjectSynchronization().get(0); - for (ConditionalSearchFilterType filter : synchronization.getCorrelation()){ + for (ConditionalSearchFilterType filter : synchronization.getCorrelation()) { MapXNode clauseXNode = filter.getFilterClauseXNode(); // key = q:equal, value = map (path + expression) RootXNode expressionNode = ((MapXNode) clauseXNode.getSingleSubEntry("filter value").getValue()) .getEntryAsRoot(new QName(SchemaConstants.NS_C, "expression")); ExpressionType expression = PrismTestUtil.getPrismContext().parserFor(expressionNode).parseRealValue(ExpressionType.class); - LOGGER.debug("Expression: {}",SchemaDebugUtil.prettyPrint(expression)); + LOGGER.debug("Expression: {}", SchemaDebugUtil.prettyPrint(expression)); OperationResult result = new OperationResult("testCorrelationRule"); String name = expressionHandler.evaluateExpression(accountType, expression, "test expression", null, result); @@ -137,16 +122,4 @@ public void testEvaluateExpression() throws Exception { assertEquals("Wrong expression result", "hbarbossa", name); } } - - private Element findChildElement(Element element, String namespace, String name) { - NodeList list = element.getChildNodes(); - for (int i = 0; i < list.getLength(); i++) { - Node node = list.item(i); - if (node.getNodeType() == Node.ELEMENT_NODE && namespace.equals(node.getNamespaceURI()) - && name.equals(node.getLocalName())) { - return (Element) node; - } - } - return null; - } } diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/expr/TestFilterExpression.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/expr/TestFilterExpression.java index 4775c26f6a4..e3f7c926cab 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/expr/TestFilterExpression.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/expr/TestFilterExpression.java @@ -12,10 +12,6 @@ import java.io.File; import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -import javax.xml.namespace.QName; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.annotation.DirtiesContext; @@ -67,10 +63,10 @@ public class TestFilterExpression extends AbstractInternalModelIntegrationTest { private static final String TEST_DIR = "src/test/resources/expr"; - @Autowired(required = true) + @Autowired private ExpressionFactory expressionFactory; - @Autowired(required = true) + @Autowired private TaskManager taskManager; @BeforeSuite @@ -81,32 +77,24 @@ public void setup() throws SchemaException, SAXException, IOException { @Test public void test100EvaluateExpressionEmployeeTypeUndefinedFilter() throws Exception { - final String TEST_NAME = "testEvaluateExpressionEmployeeTypeUndefinedFilter"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestFilterExpression.class.getName() + "." + TEST_NAME); - Task task = taskManager.createTaskInstance(TEST_NAME); + Task task = getTestTask(); ObjectFilter filter = evaluateExpressionAssertFilter("expression-employeeType-undefined-filter.xml", - null, UndefinedFilter.class, task, result); + null, UndefinedFilter.class, task, task.getResult()); - executeFilter(filter, 5, task, result); + executeFilter(filter, 5, task, task.getResult()); } @Test public void test110EvaluateExpressionEmployeeTypeNoneFilter() throws Exception { - final String TEST_NAME = "testEvaluateExpressionEmployeeTypeNoneFilter"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestFilterExpression.class.getName() + "." + TEST_NAME); - Task task = taskManager.createTaskInstance(TEST_NAME); + Task task = getTestTask(); ObjectFilter filter = evaluateExpressionAssertFilter("expression-employeeType-none-filter.xml", - null, NoneFilter.class, task, result); + null, NoneFilter.class, task, task.getResult()); - executeFilter(filter, 0, task, result); + executeFilter(filter, 0, task, task.getResult()); } @Test diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/expr/TestModelExpressions.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/expr/TestModelExpressions.java index c27e780df15..e6b340cd890 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/expr/TestModelExpressions.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/expr/TestModelExpressions.java @@ -321,7 +321,7 @@ private String executeScriptExpressionString(final String TEST_NAME, ExpressionV } // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List> scriptOutputs = evaluate(scriptExpression, variables, false, TEST_NAME, null, result); // THEN diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAbstractAssignmentEvaluator.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAbstractAssignmentEvaluator.java index 51a86ade1ad..9d62fc40462 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAbstractAssignmentEvaluator.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAbstractAssignmentEvaluator.java @@ -124,12 +124,12 @@ public void test100Direct() throws Exception { ItemDeltaItem,PrismContainerDefinition> assignmentIdi = createAssignmentIdi(assignmentType); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, "testDirect", false, task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -163,12 +163,12 @@ public void test110DirectExpression() throws Exception { ItemDeltaItem,PrismContainerDefinition> assignmentIdi = createAssignmentIdi(assignmentType); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, "testDirect", false, task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -210,12 +210,12 @@ public void test120DirectExpressionReplaceDescription() throws Exception { display("Assignment IDI", assignmentIdi); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, "testDirect", false, task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertNotNull(evaluatedAssignment); @@ -271,12 +271,12 @@ public void test130DirectExpressionReplaceDescriptionFromNull() throws Exception assignmentIdi.recompute(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, "testDirect", false, task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertNotNull(evaluatedAssignment); @@ -344,12 +344,12 @@ public void test140RoleVisitor() throws Exception { ItemDeltaItem,PrismContainerDefinition> assignmentIdi = createAssignmentIdi(assignmentType); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, TEST_NAME, false, task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertNotNull(evaluatedAssignment); @@ -389,12 +389,12 @@ public void test142RoleVisitorDisabledAssignment() throws Exception { ItemDeltaItem,PrismContainerDefinition> assignmentIdi = createAssignmentIdi(assignmentType); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, TEST_NAME, false, task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -434,12 +434,12 @@ public void test150RoleEngineer() throws Exception { ItemDeltaItem,PrismContainerDefinition> assignmentIdi = createAssignmentIdi(assignmentType); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, "testRoleEngineer", false, task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertNotNull(evaluatedAssignment); @@ -485,12 +485,12 @@ public void test160AddRoleEngineer() throws Exception { ItemDeltaItem,PrismContainerDefinition> assignmentIdi = createAssignmentIdi(assignmentType); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, TEST_NAME, false, task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertNotNull(evaluatedAssignment); @@ -557,12 +557,12 @@ public void test170RoleManagerChangeCostCenter() throws Exception { ItemDeltaItem,PrismContainerDefinition> assignmentIdi = createAssignmentIdi(assignmentType); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, TEST_NAME, false, task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -620,12 +620,12 @@ public void test180RoleManagerRemoveCostCenter() throws Exception { ItemDeltaItem,PrismContainerDefinition> assignmentIdi = createAssignmentIdi(assignmentType); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, TEST_NAME, false, task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -678,12 +678,12 @@ public void test200DisableEngineerEmployeeInducement() throws Exception { ItemDeltaItem,PrismContainerDefinition> assignmentIdi = createAssignmentIdi(assignmentType); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, "testRoleEngineer", false, task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -738,12 +738,12 @@ public void test300DisableRoleEmployee() throws Exception { ItemDeltaItem,PrismContainerDefinition> assignmentIdi = createAssignmentIdi(assignmentType); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, "testRoleEngineer", false, task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -792,12 +792,12 @@ public void test310DisableRoleEngineer() throws Exception { ItemDeltaItem,PrismContainerDefinition> assignmentIdi = createAssignmentIdi(assignmentType); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, "testRoleEngineer", false, task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -853,11 +853,11 @@ public void test400UserFred() throws Exception { addFocusDeltaToContext(lensContext, descriptionDelta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); projector.project(lensContext, "test", task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); DeltaSetTriple> triple = lensContext.getEvaluatedAssignmentTriple(); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor.java index 8e31e728d46..aeb4ac5c7d7 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor.java @@ -217,7 +217,7 @@ public void test012AddAssignmentAddAccountDirectAssignmentWithAttrs() throws Exc assertFocusModificationSanity(context); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignmentProcessor.processAssignments(context, getNow(), task, result); // THEN @@ -385,11 +385,11 @@ public void test031DeleteAssignmentModifyAccount() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignmentProcessor.processAssignments(context, getNow(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Output context", context.dump(true)); display("result", result); assertSuccess(result); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor2.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor2.java index 965cc04207d..e7041d79691 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor2.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor2.java @@ -231,11 +231,11 @@ public void test020AssignMR1ToR1() throws Exception { LensContext context = createContextForAssignment(RoleType.class, ROLE_R1_OID, RoleType.class, ROLE_MR1_OID, null, null, result); // WHEN - displayWhen(); + when(); assignmentProcessor.processAssignments(context, clock.currentTimeXMLGregorianCalendar(), task, result); // THEN - displayThen(); + then(); display("Output context", context); display("Evaluated assignment triple", context.getEvaluatedAssignmentTriple()); assertSuccess(result); @@ -530,12 +530,12 @@ public void test062JackDeputyOfGuybrushDeputyOfBarbossaInLoginMode() throws Exce jackGuybrushAssignment.asPrismContainerValue().getDefinition()); // WHEN - displayWhen(); + when(); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator .evaluate(assignmentIdi, PlusMinusZero.ZERO, false, jack.asObjectable(), jack.toString(), false, task, result); // THEN - displayThen(); + then(); display("Output context", context); display("Evaluated assignment", evaluatedAssignment); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestClockwork.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestClockwork.java index 73cdf7c4f2a..a4b349e7b25 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestClockwork.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestClockwork.java @@ -100,7 +100,7 @@ public void test010SerializeAddUserBarbossa() throws Exception { fillContextWithAddUserDelta(context, bill); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); clockwork.click(context, task, result); // one round - compute projections display("Context before serialization", context); @@ -116,7 +116,7 @@ public void test010SerializeAddUserBarbossa() throws Exception { display("Context after deserialization", context); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertEquals("Secondary deltas are not preserved - their number differs", context.getFocusContext().getSecondaryDeltas().size(), context2.getFocusContext().getSecondaryDeltas().size()); for (int i = 0; i < context.getFocusContext().getSecondaryDeltas().size(); i++) { assertTrue("Secondary delta #" + i + " is not preserved correctly, " @@ -146,11 +146,11 @@ public void test020AssignAccountToJackSync() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); clockwork.run(context, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); mockClockworkHook.setRecord(false); display("Output context", context); display("Hook contexts", mockClockworkHook); @@ -223,11 +223,11 @@ public void test053ModifyUserBarbossaDisable() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); clockwork.run(context, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Output context", context); assertTrue(context.getFocusContext().getPrimaryDelta().getChangeType() == ChangeType.MODIFY); @@ -281,7 +281,7 @@ private void assignAccountToJackAsync(String testName, boolean serialize) throws rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(testName); + when(testName); while(context.getState() != ModelState.FINAL) { display("CLICK START: "+context.getState()); @@ -311,7 +311,7 @@ private void assignAccountToJackAsync(String testName, boolean serialize) throws } // THEN - displayThen(testName); + then(testName); mockClockworkHook.setRecord(false); // display("Output context", context); // display("Hook contexts", mockClockworkHook); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPasswordPolicy.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPasswordPolicy.java index 7c75465d5a7..b4cd9689080 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPasswordPolicy.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPasswordPolicy.java @@ -112,7 +112,7 @@ public void testPasswordGeneratorComplexNegative() throws Exception { pp.getStringPolicy().getLimitations().setMinUniqueChars(5); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, false, null, TEST_NAME, task, result); // THEN @@ -167,7 +167,7 @@ public void testValueGenerateRandomPin() throws Exception { ValuePolicyType pp = parsePasswordPolicy("value-policy-random-pin.xml"); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, true, null, TEST_NAME, task, result); // THEN @@ -191,7 +191,7 @@ public void testValueGenerate() throws Exception { ValuePolicyType pp = parsePasswordPolicy("value-policy-generate.xml"); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, true, null, TEST_NAME, task, result); // THEN @@ -217,7 +217,7 @@ public void testValueGenerateEmpty() throws Exception { ValuePolicyType pp = (ValuePolicyType) PrismTestUtil.parseObject(file).asObjectable(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, true, null, TEST_NAME, task, result); // THEN @@ -325,7 +325,7 @@ public void testUsername() throws Exception { ValuePolicyType pp = parsePasswordPolicy("password-policy-username.xml"); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); for (int i = 0; i < USERNAME_ATTEMPTS; i++) { Task task = getTestTask(); @@ -359,7 +359,7 @@ public void testUserProps() throws Exception { ValuePolicyType pp = parsePasswordPolicy("password-policy-props.xml"); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); for (int i = 0; i < USER_PROPS_ATTEMPTS; i++) { Task task = getTestTask(); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules.java index 7aa34e05eb6..c0df89db009 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules.java @@ -91,11 +91,11 @@ public void test005JackAttemptAssignRoleJudge() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(); + when(); projector.project(context, "test", task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -126,11 +126,11 @@ public void test007JackAttemptAssignRoleJudgeAsOwner() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(); + when(); projector.project(context, "test", task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -152,11 +152,11 @@ public void test010JackAssignRoleJudge() throws Exception { // GIVEN // WHEN - displayWhen(); + when(); assignRole(USER_JACK_OID, ROLE_JUDGE_OID, task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -185,11 +185,11 @@ public void test020JackUnassignRoleJudge() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(); + when(); projector.project(context, "test", task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -222,11 +222,11 @@ public void test100AssignRoleMutinierToJack() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(); + when(); projector.project(context, "test", task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -255,11 +255,11 @@ public void test110AssignRolePirateToJack() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(); + when(); projector.project(context, "test", task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -298,11 +298,11 @@ public void test112AssignRolePirateWithExceptionToJack() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(); + when(); projector.project(context, "test", task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -337,11 +337,11 @@ public void test120AssignRoleConstableToJack() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(); + when(); projector.project(context, "test", task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -388,11 +388,11 @@ public void test150AssignRoleThiefToJack() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(); + when(); projector.project(context, "test", task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -429,11 +429,11 @@ public void test200JackAssignRoleContractor() throws Exception { // GIVEN // WHEN - displayWhen(); + when(); assignRole(USER_JACK_OID, ROLE_CORP_CONTRACTOR_OID, task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -462,11 +462,11 @@ public void test210AssignRoleEmployeeToJack() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(); + when(); projector.project(context, "test", task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -503,11 +503,11 @@ public void test220AssignRoleEngineerToJack() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(); + when(); projector.project(context, "test", task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -560,7 +560,7 @@ public void test300DrakeChangeEmployeeType() throws Exception { // GIVEN // WHEN - displayWhen(); + when(); ObjectDelta delta = deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT) .add(ObjectTypeUtil.createAssignmentTo(ROLE_JUDGE_OID, ObjectTypes.ROLE, prismContext)) @@ -571,7 +571,7 @@ public void test300DrakeChangeEmployeeType() throws Exception { modelService.executeChanges(Collections.singletonList(delta), null, task, Collections.singleton(recordingListener), result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -604,11 +604,11 @@ public void test400AssignRoleLocalized() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(); + when(); projector.project(context, "test", task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules2.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules2.java index 1ae6bb4a0ec..32459a7fc3f 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules2.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules2.java @@ -145,11 +145,11 @@ public void test100JackAttemptAssignRoleStudent() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); projector.project(context, ACTIVITY_DESCRIPTION, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); dumpPolicyRules(context); @@ -187,11 +187,11 @@ public void test110JoeAttemptAssignRoleStudent() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); projector.project(context, ACTIVITY_DESCRIPTION, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -237,11 +237,11 @@ public void test120JackAttemptToMoveTo1900AndAssignRoleStudent() throws Exceptio assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); projector.project(context, ACTIVITY_DESCRIPTION, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -289,12 +289,12 @@ public void test130JackMoveTo1900AndAssignRoleStudent() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); clockwork.run(context, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -343,13 +343,13 @@ public void test135JackChangeValidTo() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); // cannot run the clockwork as in the secondary state the deltas are no longer considered (!) projector.project(context, ACTIVITY_DESCRIPTION, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -385,12 +385,12 @@ public void test140JackNoChange() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); projector.project(context, ACTIVITY_DESCRIPTION, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -443,12 +443,12 @@ public void test142JackNoChangeButTaskExists() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); projector.project(context, ACTIVITY_DESCRIPTION, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -492,11 +492,11 @@ public void test150FrankAttemptToAssignRoleStudentButDisabled() throws Exception assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); projector.project(context, ACTIVITY_DESCRIPTION, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -532,11 +532,11 @@ public void test160AttemptToAddPeter() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); projector.project(context, ACTIVITY_DESCRIPTION, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -571,11 +571,11 @@ public void test170AddPeter() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); clockwork.run(context, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -628,12 +628,12 @@ public void test180StudentRecompute() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); projector.project(context, ACTIVITY_DESCRIPTION, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -663,13 +663,13 @@ public void test200AddUnresolvable() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); try { clockwork.run(context, task, result); - displayThen(TEST_NAME); + then(TEST_NAME); fail("unexpected success"); } catch (ObjectNotFoundException e) { - displayThen(TEST_NAME); + then(TEST_NAME); System.out.println("Expected exception: " + e); e.printStackTrace(System.out); if (!e.getMessage().contains("No policy constraint named 'unresolvable' could be found")) { @@ -693,13 +693,13 @@ public void test210AddCyclic() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); try { clockwork.run(context, task, result); - displayThen(TEST_NAME); + then(TEST_NAME); fail("unexpected success"); } catch (SchemaException e) { - displayThen(TEST_NAME); + then(TEST_NAME); System.out.println("Expected exception: " + e); e.printStackTrace(System.out); if (!e.getMessage().contains("Trying to resolve cyclic reference to constraint")) { @@ -723,10 +723,10 @@ public void test220AddChained() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); clockwork.run(context, task, result); - displayThen(TEST_NAME); + then(TEST_NAME); display("Output context", context); Map rules = new HashMap<>(); @@ -782,13 +782,13 @@ public void test230AddAmbiguous() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); try { clockwork.run(context, task, result); - displayThen(TEST_NAME); + then(TEST_NAME); fail("unexpected success"); } catch (SchemaException e) { - displayThen(TEST_NAME); + then(TEST_NAME); System.out.println("Expected exception: " + e); e.printStackTrace(System.out); if (!e.getMessage().contains("Conflicting definitions of 'constraint-B'")) { @@ -816,13 +816,13 @@ public void test300ModifyInducement() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); try { clockwork.run(context, task, result); - displayThen(TEST_NAME); + then(TEST_NAME); fail("unexpected success"); } catch (PolicyViolationException e) { - displayThen(TEST_NAME); + then(TEST_NAME); System.out.println("Expected exception: " + e); e.printStackTrace(System.out); if (!getTranslatedMessage(e).contains("Role \"Immutable inducements\" is to be modified")) { @@ -850,9 +850,9 @@ public void test310ModifyInducementPass() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); clockwork.run(context, task, result); - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); assertSuccess("unexpected failure", result); } @@ -876,9 +876,9 @@ public void test320ModifyInducementPass2() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); clockwork.run(context, task, result); - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); assertSuccess("unexpected failure", result); } @@ -902,13 +902,13 @@ public void test330AddInducement() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); try { clockwork.run(context, task, result); - displayThen(TEST_NAME); + then(TEST_NAME); fail("unexpected success"); } catch (PolicyViolationException e) { - displayThen(TEST_NAME); + then(TEST_NAME); System.out.println("Expected exception: " + e); e.printStackTrace(System.out); if (!getTranslatedMessage(e).contains("Role \"No inducements add or delete\" is to be modified")) { @@ -936,13 +936,13 @@ public void test340AddInducementViaExpression() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); try { clockwork.run(context, task, result); - displayThen(TEST_NAME); + then(TEST_NAME); fail("unexpected success"); } catch (PolicyViolationException e) { - displayThen(TEST_NAME); + then(TEST_NAME); System.out.println("Expected exception: " + e); e.printStackTrace(System.out); if (!getTranslatedMessage(e).contains("Role \"No inducements add or delete (expression)\" is to be modified")) { diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjector.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjector.java index 3fbb62895fc..0479db55141 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjector.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjector.java @@ -199,7 +199,7 @@ public void test100AddAccountToJackDirect() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); projector.project(context, "test", task, result); // THEN @@ -574,11 +574,11 @@ public void test260ModifyAccountBarbossaDrinkReplace() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); projector.project(context, "test", task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertPartialError(result); } @@ -848,11 +848,11 @@ public void test301AssignConflictingAccountToJack() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); projector.project(context, "test", task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Output context", context); assertTrue(context.getFocusContext().getPrimaryDelta().getChangeType() == ChangeType.MODIFY); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestReconScript.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestReconScript.java index ff351529252..c5560d18190 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestReconScript.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestReconScript.java @@ -26,7 +26,6 @@ import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.asserter.ShadowAsserter; import com.evolveum.midpoint.util.QNameUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType; @@ -211,7 +210,7 @@ public void test006TestReconDelete() throws Exception{ repositoryService.modifyObject(TaskType.class, TASK_RECON_DUMMY_OID, modifications, parentResult); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); waitForTaskStart(TASK_RECON_DUMMY_OID, false); @@ -220,7 +219,7 @@ public void test006TestReconDelete() throws Exception{ waitForTaskFinish(TASK_RECON_DUMMY_OID, false); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject shadow = repositoryService.getObject(ShadowType.class, ACCOUNT_BEFORE_SCRIPT_OID, null, parentResult); ShadowAsserter.forShadow(shadow) diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/migrator/TestMigrator.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/migrator/TestMigrator.java index 534d193d787..7569c17ec87 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/migrator/TestMigrator.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/migrator/TestMigrator.java @@ -10,6 +10,7 @@ import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.test.IntegrationTestTools; +import com.evolveum.midpoint.test.util.AbstractSpringTest; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.MiscUtil; import com.evolveum.midpoint.util.exception.SchemaException; @@ -23,10 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; -import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; -import org.xml.sax.SAXException; import java.io.File; import java.io.IOException; @@ -40,7 +38,7 @@ */ @ContextConfiguration(locations = {"classpath:ctx-model-test-main.xml"}) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) -public class TestMigrator extends AbstractTestNGSpringContextTests { +public class TestMigrator extends AbstractSpringTest { @Autowired PrismContext prismContext; @Autowired Migrator migrator; @@ -49,12 +47,6 @@ public class TestMigrator extends AbstractTestNGSpringContextTests { private static final File TEST_DIR_BEFORE = new File(TEST_DIR, "before"); private static final File TEST_DIR_AFTER = new File(TEST_DIR, "after"); - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { -// PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); -// PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } - @Test public void testMigrateUserTemplate() throws Exception { TestUtil.displayTestTitle("testMigrateUserTemplate"); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/misc/ShadowIntegrityCheckerTest.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/misc/ShadowIntegrityCheckerTest.java index d32dab7ba5d..7f37e0b012b 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/misc/ShadowIntegrityCheckerTest.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/misc/ShadowIntegrityCheckerTest.java @@ -82,11 +82,11 @@ public void test100FixDuplicatesWithDifferentObjectClasses() throws Exception { repoAddObjectFromFile(TASK_SHADOW_INTEGRITY_CHECK_FILE, result); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); waitForTaskCloseOrSuspend(TASK_SHADOW_INTEGRITY_CHECK_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject taskAfter = getTask(TASK_SHADOW_INTEGRITY_CHECK_OID); display("task after", taskAfter); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/security/TestAbstractAuthenticationEvaluator.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/security/TestAbstractAuthenticationEvaluator.java index 3b67399b656..2e612e59cc8 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/security/TestAbstractAuthenticationEvaluator.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/security/TestAbstractAuthenticationEvaluator.java @@ -189,7 +189,7 @@ public void test100PasswordLoginGoodPasswordJack() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); Authentication authentication = getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_JACK_USERNAME, getGoodPasswordJack())); // THEN @@ -215,7 +215,7 @@ public void test101PasswordLoginBadPasswordJack() throws Exception { try { // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_JACK_USERNAME, getBadPasswordJack())); @@ -249,7 +249,7 @@ public void test102PasswordLoginNullPasswordJack() throws Exception { try { // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_JACK_USERNAME, null)); @@ -282,7 +282,7 @@ public void test103PasswordLoginEmptyPasswordJack() throws Exception { try { // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_JACK_USERNAME, get103EmptyPasswordJack())); @@ -314,7 +314,7 @@ public void test105PasswordLoginNullUsernameNullPassword() throws Exception { try { // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(null, null)); @@ -342,7 +342,7 @@ public void test106PasswordLoginEmptyUsernameBadPassword() throws Exception { try { // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext("", getBadPasswordJack())); @@ -370,7 +370,7 @@ public void test107PasswordLoginBadUsernameBadPassword() throws Exception { try { // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext("NoSuchUser", getBadPasswordJack())); @@ -405,7 +405,7 @@ public void test125PasswordLoginBadPasswordJackAfterLockoutFailedAttemptsDuratio try { // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_JACK_USERNAME, getBadPasswordJack())); @@ -439,7 +439,7 @@ public void test130PasswordLoginLockout() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); try { getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_JACK_USERNAME, getBadPasswordJack())); @@ -491,7 +491,7 @@ public void test132PasswordLoginLockedoutGoodPassword() throws Exception { ConnectionEnvironment connEnv = createConnectionEnvironment(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); try { getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_JACK_USERNAME, getGoodPasswordJack())); @@ -521,7 +521,7 @@ public void test133PasswordLoginLockedoutBadPassword() throws Exception { ConnectionEnvironment connEnv = createConnectionEnvironment(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); try { getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_JACK_USERNAME, getBadPasswordJack())); @@ -557,7 +557,7 @@ public void test135PasswordLoginLockedoutLockExpires() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); Authentication authentication = getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_JACK_USERNAME, getGoodPasswordJack())); // THEN @@ -582,7 +582,7 @@ public void test136PasswordLoginLockoutAgain() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); try { getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_JACK_USERNAME, getBadPasswordJack())); @@ -654,7 +654,7 @@ public void test137PasswordLoginLockedoutGoodPasswordAgain() throws Exception { ConnectionEnvironment connEnv = createConnectionEnvironment(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); try { getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_JACK_USERNAME, getGoodPasswordJack())); @@ -688,7 +688,7 @@ public void test138UnlockUserGoodPassword() throws Exception { ConnectionEnvironment connEnv = createConnectionEnvironment(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS, task, result, LockoutStatusType.NORMAL); // THEN @@ -703,7 +703,7 @@ public void test138UnlockUserGoodPassword() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); Authentication authentication = getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_JACK_USERNAME, getGoodPasswordJack())); // THEN @@ -732,7 +732,7 @@ public void test139TryToLockByModelService() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); try { modifyUserReplace(USER_JACK_OID, SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS, task, result, LockoutStatusType.LOCKED); @@ -938,7 +938,7 @@ public void test200UserGuybrushSetCredentials() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyUserCredential(task, result); // THEN @@ -964,7 +964,7 @@ public void test201UserGuybrushPasswordLoginGoodPassword() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); Authentication authentication = getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_GUYBRUSH_USERNAME, getGoodPasswordGuybrush())); // THEN @@ -990,7 +990,7 @@ public void test202UserGuybrushPasswordLoginBadPassword() throws Exception { try { // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_GUYBRUSH_USERNAME, getBadPasswordGuybrush())); @@ -1024,7 +1024,7 @@ public void test209UserGuybrushPasswordLoginGoodPasswordBeforeExpiration() throw XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); Authentication authentication = getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_GUYBRUSH_USERNAME, getGoodPasswordGuybrush())); // THEN @@ -1052,7 +1052,7 @@ public void test210UserGuybrushPasswordLoginGoodPasswordExpired() throws Excepti try { // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_GUYBRUSH_USERNAME, getGoodPasswordGuybrush())); @@ -1167,7 +1167,7 @@ private void loginJackGoodPasswordExpectSuccess(final String TEST_NAME, Task tas XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); Authentication authentication = getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_JACK_USERNAME, getGoodPasswordJack())); // THEN @@ -1187,7 +1187,7 @@ private void loginJackGoodPasswordExpectDenied(final String TEST_NAME, Task task XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); try { getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_JACK_USERNAME, getGoodPasswordJack())); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/security/TestGuiProfiledPrincipalManager.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/security/TestGuiProfiledPrincipalManager.java index edfbe85d392..7ca41d0031a 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/security/TestGuiProfiledPrincipalManager.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/security/TestGuiProfiledPrincipalManager.java @@ -94,7 +94,7 @@ private void executeDeputyLimitationsTest(String TEST_NAME, List manager; @Test(expectedExceptions = IllegalArgumentException.class) diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/sync/TestSynchronizationService.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/sync/TestSynchronizationService.java index 3926c63e98a..079fcc25b49 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/sync/TestSynchronizationService.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/sync/TestSynchronizationService.java @@ -160,11 +160,11 @@ public void test020ModifyLootAbsolute() throws Exception { change.setSourceChannel(SchemaConstants.CHANGE_CHANNEL_LIVE_SYNC_URI); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); synchronizationService.notifyChange(change, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); LensContext context = cleanDebugListener(); display("Resulting context (as seen by debug listener)", context); @@ -357,11 +357,11 @@ public void test039DeletedAccountJack() throws Exception { change.setObjectDelta(syncDelta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); synchronizationService.notifyChange(change, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); LensContext context = cleanDebugListener(); @@ -430,11 +430,11 @@ public void test050AddedAccountCalypso() throws Exception { change.setResource(getDummyResourceObject()); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); synchronizationService.notifyChange(change, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); LensContext context = cleanDebugListener(); display("Resulting context (as seen by debug listener)", context); @@ -477,11 +477,11 @@ public void test051CalypsoRecon() throws Exception { display("Change notification", change); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); synchronizationService.notifyChange(change, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); LensContext context = cleanDebugListener(); display("Resulting context (as seen by debug listener)", context); @@ -527,11 +527,11 @@ public void test100AddedAccountJack() throws Exception { change.setResource(getDummyResourceObject()); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); synchronizationService.notifyChange(change, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); LensContext context = cleanDebugListener(); @@ -590,11 +590,11 @@ public void test199DeletedAccountJackTotal() throws Exception { repositoryService.deleteObject(ShadowType.class, accountShadowJackDummyOid, result); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); synchronizationService.notifyChange(change, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result, 1); LensContext context = cleanDebugListener(); @@ -657,11 +657,11 @@ public void test200AddedAccountJackSchemaViolation() throws Exception { change.setResource(getDummyResourceObject()); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); synchronizationService.notifyChange(change, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); getDummyResource().resetBreakMode(); assertPartialError(result); @@ -720,11 +720,11 @@ public void test202UpdatedAccountJackSchemaViolation() throws Exception { change.setResource(getDummyResourceObject()); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); synchronizationService.notifyChange(change, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); getDummyResource().resetBreakMode(); assertPartialError(result); @@ -772,11 +772,11 @@ public void test210AssignJackDummy() throws Exception { getDummyResource().resetBreakMode(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccount(UserType.class, USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); LensContext context = cleanDebugListener(); @@ -820,11 +820,11 @@ public void test212AssignJackDummyLimited() throws Exception { getDummyResource().resetBreakMode(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccount(UserType.class, USER_JACK_OID, RESOURCE_DUMMY_LIMITED_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); LensContext context = cleanDebugListener(); @@ -897,11 +897,11 @@ public void test214UpdatedAccountJackLimited() throws Exception { getDummyResource().setBreakMode(BreakMode.ASSERTION_ERROR); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); synchronizationService.notifyChange(change, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); getDummyResource().resetBreakMode(); @@ -975,11 +975,11 @@ public void test300AddedGroupPirates() throws Exception { change.setResource(getDummyResourceObject()); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); synchronizationService.notifyChange(change, task, result); // THEN - displayWhen(TEST_NAME); + when(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/visualizer/TestVisualizer.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/visualizer/TestVisualizer.java index 7592dd358c0..e0321310816 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/visualizer/TestVisualizer.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/visualizer/TestVisualizer.java @@ -75,11 +75,11 @@ public void test100UserBasic() throws Exception { u.asObjectable().setFullName(new PolyStringType("User User123")); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); final Scene scene = visualizer.visualize(u, task, task.getResult()); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("scene", scene); // TODO some asserts @@ -113,11 +113,11 @@ public void test110UserWithContainers() throws Exception { ut.getAssignment().add(ass3); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); final Scene scene = visualizer.visualize(u, task, task.getResult()); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("scene", scene); // TODO some asserts @@ -133,11 +133,11 @@ public void test200UserDeltaBasic() throws Exception { .asObjectDelta(USER_ADMINISTRATOR_OID); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); final Scene scene = visualizer.visualizeDelta((ObjectDelta) delta, task, task.getResult()); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("scene", scene); // TODO some asserts @@ -163,11 +163,11 @@ public void test210UserDeltaContainers() throws Exception { .asObjectDelta(USER_ADMINISTRATOR_OID); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); final Scene scene = visualizer.visualizeDelta((ObjectDelta) delta, task, task.getResult()); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("scene", scene); // TODO some asserts @@ -184,11 +184,11 @@ public void test212UserDeltaContainerSimple() throws Exception { .asObjectDelta(USER_ADMINISTRATOR_OID); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); final List scenes = visualizer.visualizeDeltas((List) Collections.singletonList(delta), task, task.getResult()); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("scenes", scenes); // TODO some asserts @@ -215,11 +215,11 @@ public void test220UserContainerReplace() throws Exception { .asObjectDelta(USER_ADMINISTRATOR_OID); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); final Scene scene = visualizer.visualizeDelta((ObjectDelta) delta, task, task.getResult()); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("scene", scene); // TODO some asserts @@ -242,11 +242,11 @@ public void test230UserContainerDelete() throws Exception { .asObjectDelta(USER_ADMINISTRATOR_OID); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); final Scene scene = visualizer.visualizeDelta((ObjectDelta) delta, task, task.getResult()); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("scene", scene); // TODO some asserts @@ -271,7 +271,7 @@ public void test300UserAssignmentPreview() throws Exception { delta.applyDefinitionIfPresent(jack.getDefinition(), false); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ModelContext modelContext = modelInteractionService.previewChanges(Collections.>singletonList(delta), null, task, task.getResult()); List> primaryDeltas = new ArrayList<>(); List> secondaryDeltas = new ArrayList<>(); @@ -281,7 +281,7 @@ public void test300UserAssignmentPreview() throws Exception { List secondaryScenes = modelInteractionService.visualizeDeltas(secondaryDeltas, task, task.getResult()); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("primary scenes", primaryScenes); display("secondary scenes", secondaryScenes); @@ -304,13 +304,13 @@ public void test305UserAssignmentAdd() throws Exception { .asObjectDelta(USER_JACK_OID); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); final Scene scene = visualizer.visualizeDelta(delta, task, task.getResult()); modelService.executeChanges(Collections.>singletonList(delta), null, task, task.getResult()); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("scene", scene); display("jack with assignment", getUser(USER_JACK_OID)); @@ -327,7 +327,7 @@ public void test307UserDisablePreview() throws Exception { .asObjectDelta(USER_JACK_OID); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ModelContext modelContext = modelInteractionService.previewChanges(Collections.>singletonList(delta), null, task, task.getResult()); List> primaryDeltas = new ArrayList<>(); List> secondaryDeltas = new ArrayList<>(); @@ -337,7 +337,7 @@ public void test307UserDisablePreview() throws Exception { List secondaryScenes = modelInteractionService.visualizeDeltas(secondaryDeltas, task, task.getResult()); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("primary scenes", primaryScenes); display("secondary scenes", secondaryScenes); @@ -376,11 +376,11 @@ public void test310UserLinkRefDelete() throws Exception { .asObjectDelta(USER_JACK_OID); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); final Scene scene = visualizer.visualizeDelta(delta, task, task.getResult()); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("scene", scene); // TODO some asserts @@ -396,11 +396,11 @@ public void test320UserLinkRefAdd() throws Exception { .asObjectDelta(USER_JACK_OID); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); final Scene scene = visualizer.visualizeDelta(delta, task, task.getResult()); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("scene", scene); // TODO some asserts @@ -416,11 +416,11 @@ public void test330UserLinkRefReplaceNoOp() throws Exception { .asObjectDelta(USER_JACK_OID); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); final Scene scene = visualizer.visualizeDelta(delta, task, task.getResult()); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("scene", scene); // TODO some asserts @@ -436,11 +436,11 @@ public void test340UserLinkRefReplaceOp() throws Exception { .asObjectDelta(USER_JACK_OID); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); final Scene scene = visualizer.visualizeDelta(delta, task, task.getResult()); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("scene", scene); // TODO some asserts diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestActivation.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestActivation.java index a8ca5836a83..1ff5879b9c4 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestActivation.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestActivation.java @@ -772,11 +772,11 @@ public void test118ModifyJackActivationUserAndAccount() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess("executeChanges result", result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); @@ -812,11 +812,11 @@ public void test120ModifyUserJackAssignAccountDummyRed() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_RED_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess("executeChanges result", result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); @@ -870,11 +870,11 @@ public void test121ModifyJackUserAndAccountRed() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess("executeChanges result", result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); @@ -941,11 +941,11 @@ public void test138ModifyJackEnabled() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_JACK_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.ENABLED); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess("executeChanges result", result); @@ -1010,11 +1010,11 @@ public void test140ModifyUserJackAssignAccountDummyRed() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_RED_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); @@ -1059,11 +1059,11 @@ public void test147ModifyUserJackUnassignAccountDummyRedRaw() throws Exception { ObjectDelta userDelta = createAccountAssignmentUserDelta(USER_JACK_OID, RESOURCE_DUMMY_RED_OID, null, false); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(userDelta), ModelExecuteOptions.createRaw(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userJack = getUser(USER_JACK_OID); @@ -1106,11 +1106,11 @@ public void test149RecomputeJack() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); @@ -1158,11 +1158,11 @@ public void test150ModifyUserJackAssignYellowAccount() throws Exception { XMLGregorianCalendar start = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); XMLGregorianCalendar end = clock.currentTimeXMLGregorianCalendar(); assertSuccess(result); @@ -1202,11 +1202,11 @@ public void test151ReconcileJack() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1245,12 +1245,12 @@ public void test152ModifyAccountsJackDisable() throws Exception { ObjectDelta yellowDelta = createModifyAccountShadowReplaceDelta(accountYellowOid, null, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, ActivationStatusType.DISABLED); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(dummyDelta, yellowDelta), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userJack = getUser(USER_JACK_OID); @@ -1260,13 +1260,13 @@ public void test152ModifyAccountsJackDisable() throws Exception { checkAdminStatusFor15x(userJack, true, false, false); // WHEN (2) - now let's do a reconciliation on both resources - displayWhen(TEST_NAME); + when(TEST_NAME); ObjectDelta innocentDelta = createModifyUserReplaceDelta(USER_JACK_OID, UserType.F_LOCALITY, userJack.asObjectable().getLocality().toPolyString()); modelService.executeChanges(MiscSchemaUtil.createCollection(innocentDelta), ModelExecuteOptions.createReconcile(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); assertSuccess("executeChanges result (after reconciliation)", result); @@ -1361,11 +1361,11 @@ public void test160ModifyUserJackAssignAccountKhaki() throws Exception { XMLGregorianCalendar start = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_KHAKI_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); XMLGregorianCalendar end = clock.currentTimeXMLGregorianCalendar(); result.computeStatus(); TestUtil.assertSuccess("executeChanges result", result); @@ -1895,11 +1895,11 @@ public void test230JackUnassignRepoRecompute() throws Exception { assertDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, "Jack Sparrow", true); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, "Jack Sparrow", false); @@ -1917,11 +1917,11 @@ public void test231JackRecomputeReconcile() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, ModelExecuteOptions.createReconcile(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, "Jack Sparrow", false); @@ -1957,11 +1957,11 @@ public void test240AddUserRappDraft() throws Exception { display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(userBefore, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1998,11 +1998,11 @@ public void test241RecomputeRappDraft() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_RAPP_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2040,11 +2040,11 @@ public void test242RappAssignCaptain() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_RAPP_OID, ROLE_CAPTAIN_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2077,12 +2077,12 @@ public void test245ActivateRapp() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_RAPP_OID, UserType.F_LIFECYCLE_STATE, task, result, SchemaConstants.LIFECYCLE_ACTIVE); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2119,12 +2119,12 @@ public void test248DeactivateRapp() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_RAPP_OID, UserType.F_LIFECYCLE_STATE, task, result, SchemaConstants.LIFECYCLE_ARCHIVED); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2155,11 +2155,11 @@ public void test249DeleteUserRapp() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); deleteObject(UserType.class, USER_RAPP_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2187,12 +2187,12 @@ public void test300AddDummyGreenAccountMancomb() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Melee Island"); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); getDummyResource(RESOURCE_DUMMY_GREEN_NAME).addAccount(account); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject accountMancomb = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); display("Account shadow after", accountMancomb); @@ -2226,17 +2226,17 @@ public void test310ImportAccountsFromDummyGreen() throws Exception { assertNull("Unexpected user mancomb before import", userMancomb); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.importFromResource(RESOURCE_DUMMY_GREEN_OID, new QName(getDummyResourceController(RESOURCE_DUMMY_GREEN_NAME).getNamespace(), SchemaConstants.ACCOUNT_OBJECT_CLASS_LOCAL_NAME), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); waitForTaskFinish(task, true, 40000); - displayThen(TEST_NAME); + then(TEST_NAME); userMancomb = findUserByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME); assertNotNull("No user mancomb after import", userMancomb); @@ -2615,11 +2615,11 @@ public void test600AddUser1() throws Exception { ObjectDelta addDelta = user1.createAddDelta(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); Collection> executedChanges = executeChanges(addDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); user1 = getUser(ObjectDeltaOperation.findFocusDeltaOidInCollection(executedChanges)); display("User after change execution", user1); @@ -2703,11 +2703,11 @@ public void test700ModifyJackRemoveAdministrativeStatus() throws Exception { PrismAsserts.assertNoItem(userBefore, SchemaConstants.PATH_ACTIVATION_VALID_TO); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_JACK_OID, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2749,11 +2749,11 @@ public void test702ModifyJackFuneralTimestampBeforeNow() throws Exception { XMLGregorianCalendar hourAgo = XmlTypeConverter.createXMLGregorianCalendar(clock.currentTimeMillis() - 60 * 60 * 1000); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_JACK_OID, getExtensionPath(PIRACY_FUNERAL_TIMESTAMP), task, result, hourAgo); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2792,11 +2792,11 @@ public void test704ModifyJackFuneralTimestampAfterNow() throws Exception { XMLGregorianCalendar hourAhead = XmlTypeConverter.createXMLGregorianCalendar(clock.currentTimeMillis() + 60 * 60 * 1000); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_JACK_OID, getExtensionPath(PIRACY_FUNERAL_TIMESTAMP), task, result, hourAhead); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2844,11 +2844,11 @@ public void test750AddAndDeleteUserWithPrecreate() throws Exception { assertSuccess(result); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); deleteObject(UserType.class, oid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); // There's a hidden FATAL_ERROR when unlinking deleted shadow (benign ... but it prevents us from asserting success tree-wide) //assertSuccess(result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestAudit.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestAudit.java index 64c399bc357..b1b276cf692 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestAudit.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestAudit.java @@ -137,12 +137,12 @@ public void test100ModifyUserJackKid() throws Exception { initialTs = getTimeSafely(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_JACK_OID, UserType.F_TITLE, task, result, createPolyString("Kid")); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -169,12 +169,12 @@ public void test105CreateUserHerman() throws Exception { hermanInitialTs = getTimeSafely(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(userHermanBefore, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -201,12 +201,12 @@ public void test110ModifyUserJackSailor() throws Exception { ActivationStatusType.DISABLED); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -231,12 +231,12 @@ public void test115ModifyUserHermanMarooned() throws Exception { objectDelta.addModification(createAssignmentModification(RESOURCE_DUMMY_OID, ShadowKindType.ACCOUNT, null, true)); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject user = getUser(USER_HERMAN_OID); @@ -262,12 +262,12 @@ public void test120ModifyUserJackCaptain() throws Exception { ActivationStatusType.ENABLED); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); jackCaptainTs = getTimeSafely(); @@ -297,13 +297,13 @@ public void test125ModifyUserHermanHermit() throws Exception { null, null, null, true)); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject user = getUser(USER_HERMAN_OID); @@ -328,13 +328,13 @@ public void test135ModifyUserHermanCivilisedHermit() throws Exception { null, null, null, false)); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject user = getUser(USER_HERMAN_OID); @@ -358,13 +358,13 @@ public void test200ReconstructJackSailor() throws Exception { PrismAsserts.assertPropertyValue(userBefore, UserType.F_TITLE, createPolyString("Captain")); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject jackReconstructed = modelAuditService.reconstructObject(UserType.class, USER_JACK_OID, jackSailorEid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("Reconstructed jack", jackReconstructed); @@ -388,13 +388,13 @@ public void test210ReconstructJackKid() throws Exception { PrismAsserts.assertPropertyValue(userBefore, UserType.F_TITLE, createPolyString("Captain")); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject jackReconstructed = modelAuditService.reconstructObject(UserType.class, USER_JACK_OID, jackKidEid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("Reconstructed jack", jackReconstructed); @@ -423,13 +423,13 @@ public void test250ReconstructHermanCreated() throws Exception { assertAssignments(userBefore, 1); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject hermanReconstructed = modelAuditService.reconstructObject(UserType.class, USER_HERMAN_OID, hermanCreatedEid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("Reconstructed herman", hermanReconstructed); @@ -454,13 +454,13 @@ public void test252ReconstructHermanMarooned() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject hermanReconstructed = modelAuditService.reconstructObject(UserType.class, USER_HERMAN_OID, hermanMaroonedEid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("Reconstructed herman", hermanReconstructed); @@ -486,13 +486,13 @@ public void test254ReconstructHermanHermit() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject hermanReconstructed = modelAuditService.reconstructObject(UserType.class, USER_HERMAN_OID, hermanHermitEid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("Reconstructed herman", hermanReconstructed); @@ -516,7 +516,7 @@ public void test300QueryUnknown() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); AuditEventRecord record = new AuditEventRecord(AuditEventType.SYNCHRONIZATION, AuditEventStage.EXECUTION); record.setOutcome(OperationResultStatus.UNKNOWN); @@ -527,7 +527,7 @@ public void test300QueryUnknown() throws Exception { List records = modelAuditService.listRecords("select * from m_audit_event as aer where aer.outcome = :outcome", params, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("records", records); assertEquals("Wrong # of records", 1, records.size()); @@ -536,9 +536,7 @@ public void test300QueryUnknown() throws Exception { } private String assertObjectAuditRecords(String oid, int expectedNumberOfRecords) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - Task task = getTestTask(); - OperationResult result = task.getResult(); - List auditRecords = getObjectAuditRecords(oid, task, result); + List auditRecords = getObjectAuditRecords(oid); display("Object records", auditRecords); assertEquals("Wrong number of jack audit records", expectedNumberOfRecords, auditRecords.size()); return auditRecords.get(auditRecords.size() - 1).getEventIdentifier(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestCaseIgnore.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestCaseIgnore.java index 1e8a37b2670..b8c9282ed19 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestCaseIgnore.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestCaseIgnore.java @@ -118,11 +118,11 @@ public void test131ModifyUserJackAssignAccount() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(accountAssignmentUserDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); assertCounterIncrement(InternalCounters.CONNECTOR_INSTANCE_INITIALIZATION_COUNT, 0); // MID-4779 @@ -172,7 +172,7 @@ public void test133SeachAccountShadows() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); SearchResultList> foundShadows = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN @@ -264,7 +264,7 @@ public void test150JackAssignRoleX() throws Exception { assignRole(USER_JACK_OID, ROLE_X_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -307,7 +307,7 @@ public void test152GetJack() throws Exception { PrismObject userJack = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -351,7 +351,7 @@ public void test159JackUnAssignRoleX() throws Exception { unassignRole(USER_JACK_OID, ROLE_X_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -379,11 +379,11 @@ public void test160JackAssignRoleBasic() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_UPCASE_BASIC_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -427,11 +427,11 @@ public void test161JackAssignRoleJoker() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_JOKER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -479,11 +479,11 @@ public void test165JackUnAssignRoleJoker() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, ROLE_JOKER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -527,11 +527,11 @@ public void test169JackUnAssignRoleBasic() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, ROLE_UPCASE_BASIC_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -561,11 +561,11 @@ public void test170JackAssignRoleJoker() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_JOKER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); // Make sure this is repository so we do not destroy the "evidence" yet. @@ -608,11 +608,11 @@ public void test179JackUnAssignRoleJoker() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, ROLE_JOKER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); // Make sure this is repository so we do not destroy the "evidence" yet. @@ -662,11 +662,11 @@ public void test200GuybrushAssignRoleFools() throws Exception { assertShadows(4); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_GUYBRUSH_OID, ROLE_FOOL_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertShadows(6); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConsistencySimple.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConsistencySimple.java index 3973ebdcb26..984a5eb11f7 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConsistencySimple.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConsistencySimple.java @@ -198,7 +198,7 @@ private void executeTest(final String TEST_NAME, FocusOperation focusOperation, result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); switch (focusOperation) { case RECOMPUTE: recomputeUser(USER_JACK_OID, task, result); @@ -213,7 +213,7 @@ private void executeTest(final String TEST_NAME, FocusOperation focusOperation, } // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); display("Result", result); if (ASSERT_SUCCESS) { diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestDeputy.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestDeputy.java index 5a881bec058..7dfec2c6dcc 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestDeputy.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestDeputy.java @@ -79,12 +79,12 @@ public void test100AssignDeputyNoBigDeal() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -115,12 +115,12 @@ public void test109UnassignDeputyNoBigDeal() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -150,12 +150,12 @@ public void test110AssignJackPirate() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -187,12 +187,12 @@ public void test112AssignDeputyPirate() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -229,12 +229,12 @@ public void test119UnassignDeputyPirate() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -270,12 +270,12 @@ public void test120AssignbarbossaDeputyOfGuybrush() throws Exception { assertLinks(userGuybrushBefore, 1); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignDeputy(USER_BARBOSSA_OID, USER_GUYBRUSH_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -308,12 +308,12 @@ public void test122AssignGuybrushPirate() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_GUYBRUSH_OID, ROLE_PIRATE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -346,12 +346,12 @@ public void test124RecomputeBarbossa() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_BARBOSSA_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -386,12 +386,12 @@ public void test126UnassignGuybrushPirate() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_GUYBRUSH_OID, ROLE_PIRATE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -424,12 +424,12 @@ public void test128RecomputeBarbossa() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_BARBOSSA_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -456,12 +456,12 @@ public void test129UnassignBarbossaDeputyOfGuybrush() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignDeputy(USER_BARBOSSA_OID, USER_GUYBRUSH_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -507,12 +507,12 @@ public void test150AssignJackMoreRoles() throws Exception { null, null, (ActivationType) null, true))); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(userDelta), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -544,14 +544,14 @@ public void test152AssignbarbossaDeputyLimitedDeputy() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_PIRATE_OID), createOrgReference(ORG_MINISTRY_OF_RUM_OID, SchemaConstants.ORG_MANAGER)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -580,14 +580,14 @@ public void test154UnassignbarbossaDeputyLimitedDeputy() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_PIRATE_OID), createOrgReference(ORG_MINISTRY_OF_RUM_OID, SchemaConstants.ORG_MANAGER)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -613,7 +613,7 @@ public void test156AssignbarbossaDeputyLimitedDeputyRed() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_RED_SAILOR_OID), @@ -621,7 +621,7 @@ public void test156AssignbarbossaDeputyLimitedDeputyRed() throws Exception { ); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -653,7 +653,7 @@ public void test159UnassignbarbossaDeputyLimitedDeputyRed() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_RED_SAILOR_OID), @@ -661,7 +661,7 @@ public void test159UnassignbarbossaDeputyLimitedDeputyRed() throws Exception { ); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -691,14 +691,14 @@ public void test160AssignbarbossaDeputyLimitedDeputyEmpty() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_EMPTY_OID) ); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -730,14 +730,14 @@ public void test162UnassignbarbossaDeputyLimitedDeputyEmpty() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_EMPTY_OID) ); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -769,11 +769,11 @@ public void test170AddRoleDrinker() throws Exception { display("Adding role", role); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(role, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject roleAfter = getObject(RoleType.class, ROLE_DRINKER_OID); @@ -790,11 +790,11 @@ public void test172AssignJackRoleDrinker() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_DRINKER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userJackAfter = getUser(USER_JACK_OID); @@ -819,14 +819,14 @@ public void test174AssignBarbossaDeputyLimitedDeputyDrinker() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_DRINKER_OID) ); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userJackAfter = getUser(USER_JACK_OID); @@ -865,7 +865,7 @@ public void test176AssignbarGuybrushLimitedDeputyOfBarbossa() throws Exception { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignDeputyLimits(USER_GUYBRUSH_OID, USER_BARBOSSA_OID, assignment -> assignment.beginLimitTargetContent().allowTransitive(true), @@ -874,7 +874,7 @@ public void test176AssignbarGuybrushLimitedDeputyOfBarbossa() throws Exception { ); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userGuybrushAfter = getUser(USER_GUYBRUSH_OID); @@ -897,14 +897,14 @@ public void test178UnassignBarbossaDeputyLimitedDeputyDrinker() throws Exception XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_DRINKER_OID) ); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -940,7 +940,7 @@ public void test179UnassignbarGuybrushLimitedDeputyOfBarbossa() throws Exception OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignDeputyLimits(USER_GUYBRUSH_OID, USER_BARBOSSA_OID, assignment -> assignment.beginLimitTargetContent().allowTransitive(true), @@ -949,7 +949,7 @@ public void test179UnassignbarGuybrushLimitedDeputyOfBarbossa() throws Exception ); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userGuybrushAfter = getUser(USER_GUYBRUSH_OID); @@ -968,12 +968,12 @@ public void test180AssignBarbossaDeputyOfJack() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userBarbossaAfter = getUser(USER_BARBOSSA_OID); @@ -1004,14 +1004,14 @@ public void test182AssignGuybrushLimitedDeputyOfBarbossa() throws Exception { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignDeputyLimits(USER_GUYBRUSH_OID, USER_BARBOSSA_OID, task, result, createRoleReference(ROLE_DRINKER_OID) ); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userGuybrushAfter = getUser(USER_GUYBRUSH_OID); @@ -1031,14 +1031,14 @@ public void test184UnassignGuybrushLimitedDeputyOfBarbossa() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignDeputyLimits(USER_GUYBRUSH_OID, USER_BARBOSSA_OID, task, result, createRoleReference(ROLE_DRINKER_OID) ); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userGuybrushAfter = getUser(USER_GUYBRUSH_OID); @@ -1067,12 +1067,12 @@ public void test186AssignGuybrushDeputyOfBarbossa() throws Exception { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignDeputy(USER_GUYBRUSH_OID, USER_BARBOSSA_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userGuybrushAfter = getUser(USER_GUYBRUSH_OID); @@ -1092,12 +1092,12 @@ public void test188UnassignGuybrushDeputyOfBarbossa() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignDeputy(USER_GUYBRUSH_OID, USER_BARBOSSA_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userGuybrushAfter = getUser(USER_GUYBRUSH_OID); @@ -1115,12 +1115,12 @@ public void test189UnassignBarbossaDeputyOfJack() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userBarbossaAfter = getUser(USER_BARBOSSA_OID); @@ -1138,7 +1138,7 @@ public void test190AssignBarbossaDeputyLimitedDeputyEmptyDrinker() throws Except OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_EMPTY_OID), @@ -1146,7 +1146,7 @@ public void test190AssignBarbossaDeputyLimitedDeputyEmptyDrinker() throws Except ); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1178,7 +1178,7 @@ public void test192UnassignbarbossaDeputyLimitedDeputyEmptyDrinker() throws Exce XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_EMPTY_OID), @@ -1186,7 +1186,7 @@ public void test192UnassignbarbossaDeputyLimitedDeputyEmptyDrinker() throws Exce ); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -1220,14 +1220,14 @@ public void test800ImportValidityScannerTask() throws Exception { XMLGregorianCalendar startCal = clock.currentTimeXMLGregorianCalendar(); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); importObjectFromFile(TASK_VALIDITY_SCANNER_FILENAME); waitForTaskStart(TASK_VALIDITY_SCANNER_OID, false); waitForTaskFinish(TASK_VALIDITY_SCANNER_OID, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); assertLastScanTimestamp(TASK_VALIDITY_SCANNER_OID, startCal, endCal); } @@ -1255,13 +1255,13 @@ public void test802AssignBarbossaDeputyOfJack() throws Exception { activationType.setValidTo(XmlTypeConverter.addDuration(startTs, "PT2H")); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, assignment -> assignment.setActivation(activationType), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -1301,12 +1301,12 @@ public void test804BarbosaThreeHoursLater() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); waitForTaskNextRunAssertSuccess(TASK_VALIDITY_SCANNER_OID, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestEntitlements.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestEntitlements.java index d0c7ddfc54e..c2246560801 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestEntitlements.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestEntitlements.java @@ -204,11 +204,11 @@ public void test110AssociateGuybrushToSwashbucklers() throws Exception { SHADOW_GROUP_DUMMY_SWASHBUCKLERS_OID, prismContext); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(delta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertDummyGroupByName(null, GROUP_DUMMY_SWASHBUCKLERS_NAME) @@ -224,11 +224,11 @@ public void test200AssignRoleSwashbucklerToJack() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -254,11 +254,11 @@ public void test209UnAssignRoleSwashbucklerFromJack() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -321,11 +321,11 @@ public void test222AssignRoleMapmakerToWally() throws Exception { PrismObject user = findUserByUsername(USER_WALLY_NAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(user.getOid(), ROLE_MAPMAKER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertGroupMember(GROUP_DUMMY_LANDLUBERS_NAME, USER_WALLY_NAME, getDummyResource()); @@ -360,11 +360,11 @@ public void test224UnassignRoleMapmakerFromWally() throws Exception { PrismObject user = findUserByUsername(USER_WALLY_NAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(user.getOid(), ROLE_MAPMAKER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); DummyGroup dummyGroup = getDummyResource().getGroupByName(GROUP_DUMMY_MAPMAKERS_NAME); @@ -382,11 +382,11 @@ public void test300AddRoleWimp() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(ROLE_WIMP_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); DummyGroup dummyGroup = getDummyResource().getGroupByName(GROUP_DUMMY_WIMPS_NAME); @@ -414,11 +414,11 @@ public void test302AddRoleBrute() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(ROLE_BRUTE_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -441,11 +441,11 @@ public void test304AddRoleThug() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(ROLE_THUG_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -470,11 +470,11 @@ public void test310AssignRoleWimpToLargo() throws Exception { addObject(USER_LARGO_FILE); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_LARGO_OID, ROLE_WIMP_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -494,11 +494,11 @@ public void test312AssignRoleBruteToLargo() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_LARGO_OID, ROLE_BRUTE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -518,11 +518,11 @@ public void test313UnAssignRoleBruteFromLargo() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_LARGO_OID, ROLE_BRUTE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -552,11 +552,11 @@ public void test314AssignRoleThugToLargo() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_LARGO_OID, ROLE_THUG_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -576,11 +576,11 @@ public void test315UnAssignRoleThugFromLargo() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_LARGO_OID, ROLE_THUG_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -613,11 +613,11 @@ public void test317RenameLargo() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_LARGO_OID, UserType.F_NAME, task, result, PrismTestUtil.createPolyString("newLargo")); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -644,11 +644,11 @@ public void test319UnassignRoleWimpFromLargo() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_LARGO_OID, ROLE_WIMP_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -682,11 +682,11 @@ public void test320AssignRoleBruteToRapp() throws Exception { addObject(USER_RAPP_FILE); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_RAPP_OID, ROLE_BRUTE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -706,11 +706,11 @@ public void test322AssignRoleWimpToRapp() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_RAPP_OID, ROLE_WIMP_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -737,11 +737,11 @@ public void test324AssignRoleThugToRapp() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_RAPP_OID, ROLE_THUG_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -775,11 +775,11 @@ public void test327UnassignRoleWimpFromRapp() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_RAPP_OID, ROLE_WIMP_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -816,11 +816,11 @@ public void test328UnassignRoleThugFromRapp() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_RAPP_OID, ROLE_THUG_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -860,11 +860,11 @@ public void test329UnAssignRoleBruteFromRapp() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_RAPP_OID, ROLE_BRUTE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -898,12 +898,12 @@ public void test350AssignOrangeAccountToGuybrushAndRapp() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_ORANGE_OID, null, task, result); assignAccountToUser(USER_RAPP_OID, RESOURCE_DUMMY_ORANGE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); DummyAccount accountGuybrush = assertDummyAccount(RESOURCE_DUMMY_ORANGE_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); @@ -930,11 +930,11 @@ public void test351AssignRoleCrewOfGuybrushToRapp() throws Exception { assertDummyAccount(RESOURCE_DUMMY_ORANGE_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_RAPP_OID, ROLE_CREW_OF_GUYBRUSH_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userGuybrushAfter = getUser(USER_GUYBRUSH_OID); @@ -974,11 +974,11 @@ public void test358UnassignRoleCrewOfGuybrushToRapp() throws Exception { assertDummyAccount(RESOURCE_DUMMY_ORANGE_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_RAPP_OID, ROLE_CREW_OF_GUYBRUSH_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userGuybrushAfter = getUser(USER_GUYBRUSH_OID); @@ -1006,12 +1006,12 @@ public void test359UnassignOrangeAccountFromGuybrushAndRapp() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignAccountFromUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_ORANGE_OID, null, task, result); unassignAccountFromUser(USER_RAPP_OID, RESOURCE_DUMMY_ORANGE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertNoDummyAccount(RESOURCE_DUMMY_ORANGE_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); @@ -1028,11 +1028,11 @@ public void test600AssignRolePirateToJack() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject user = getUser(USER_JACK_OID); @@ -1062,11 +1062,11 @@ public void test610AssignRoleSwashbucklerToJack() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject user = getUser(USER_JACK_OID); @@ -1095,11 +1095,11 @@ public void test620UnAssignSwashbucklerFromJack() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject user = getUser(USER_JACK_OID); @@ -1142,11 +1142,11 @@ public void test630AssignRoleSwashbucklerToJackValidity() throws Exception { jackSwashbucklerAssignmentActivation.setValidTo(validTo); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, jackSwashbucklerAssignmentActivation, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1276,11 +1276,11 @@ public void test659UnassignRoleSwashbucklerFromJack() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, jackSwashbucklerAssignmentActivation.clone(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1315,11 +1315,11 @@ public void test699UnassignRolePirateFromJack() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1351,11 +1351,11 @@ public void test700ReconcileGuybrush() throws Exception { assertGroupMember(getDummyGroup(null, GROUP_DUMMY_SWASHBUCKLERS_NAME), USER_GUYBRUSH_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); dumpUserAndAccounts(getUser(USER_GUYBRUSH_OID), task, result); assertNoGroupMember(getDummyGroup(null, GROUP_DUMMY_SWASHBUCKLERS_NAME), USER_GUYBRUSH_USERNAME); @@ -1419,11 +1419,11 @@ public void test715AssociateGuybrushToThugs() throws Exception { ObjectDelta delta = ObjectDeltaCollectionsUtil.summarize(delta1, delta2); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(delta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertGroupMember(GROUP_THUG_NAME, ACCOUNT_GUYBRUSH_DUMMY_ORANGE_USERNAME, getDummyResource(RESOURCE_DUMMY_ORANGE_NAME)); @@ -1446,11 +1446,11 @@ public void test720ReconcileGuybrush() throws Exception { assertGroupMember(getDummyGroup(null, GROUP_DUMMY_LANDLUBERS_NAME), USER_GUYBRUSH_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); dumpUserAndAccounts(getUser(USER_GUYBRUSH_OID), task, result); assertGroupMember(GROUP_DUMMY_LANDLUBERS_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, getDummyResource()); @@ -1470,11 +1470,11 @@ public void test729CleanupGuybrush() throws Exception { PrismObject userBefore = dumpUserAndAccounts(USER_GUYBRUSH_OID); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignAll(userBefore, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = dumpUserAndAccounts(USER_GUYBRUSH_OID); assertAssignments(userAfter, 0); @@ -1508,11 +1508,11 @@ public void test750PrepareGuybrushFuturePerfect() throws Exception { assertLinks(userBefore, 0); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_GUYBRUSH_OID, ROLE_ORG_GROUPING_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = dumpUserAndAccounts(USER_GUYBRUSH_OID); assertAssignments(userAfter, 1); @@ -1541,11 +1541,11 @@ public void test752GuybrushFuturePerfect() throws Exception { getDummyResourceController().addGroup(orgGroupName(OU_CLUB_SCI_FI)); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = dumpUserAndAccounts(USER_GUYBRUSH_OID); assertAssignments(userAfter, 1); @@ -1566,11 +1566,11 @@ public void test759CleanupGuybrush() throws Exception { dumpUserAndAccounts(USER_GUYBRUSH_OID); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_GUYBRUSH_OID, ROLE_ORG_GROUPING_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = dumpUserAndAccounts(USER_GUYBRUSH_OID); assertAssignments(userAfter, 0); @@ -1594,11 +1594,11 @@ public void test760GuybrushOrgGroupsRepo() throws Exception { assertLinks(userBefore, 0); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_GUYBRUSH_OID, ROLE_ORG_GROUPING_REPO_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = dumpUserAndAccounts(USER_GUYBRUSH_OID); assertAssignments(userAfter, 1); @@ -1618,11 +1618,11 @@ public void test765ReconcileGuybrush() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = dumpUserAndAccounts(USER_GUYBRUSH_OID); assertAssignments(userAfter, 1); @@ -1650,11 +1650,11 @@ public void test769CleanupGuybrush() throws Exception { dumpUserAndAccounts(USER_GUYBRUSH_OID); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_GUYBRUSH_OID, ROLE_ORG_GROUPING_REPO_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = dumpUserAndAccounts(USER_GUYBRUSH_OID); assertAssignments(userAfter, 0); @@ -1674,11 +1674,11 @@ public void test780AssignGuybrushSwashbuckler() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_GUYBRUSH_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); dumpUserAndAccounts(getUser(USER_GUYBRUSH_OID), task, result); assertGroupMember(getDummyGroup(null, GROUP_DUMMY_SWASHBUCKLERS_NAME), USER_GUYBRUSH_USERNAME); @@ -1702,11 +1702,11 @@ public void test781GuybrushTheLostSwashbuckler() throws Exception { assertNoGroupMember(getDummyGroup(null, GROUP_DUMMY_SWASHBUCKLERS_NAME), USER_GUYBRUSH_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); dumpUserAndAccounts(getUser(USER_GUYBRUSH_OID), task, result); assertGroupMember(getDummyGroup(null, GROUP_DUMMY_SWASHBUCKLERS_NAME), USER_GUYBRUSH_USERNAME); @@ -1721,11 +1721,11 @@ public void test784UnassignGuybrushSwashbuckler() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_GUYBRUSH_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); dumpUserAndAccounts(getUser(USER_GUYBRUSH_OID), task, result); assertNoGroupMember(getDummyGroup(null, GROUP_DUMMY_SWASHBUCKLERS_NAME), USER_GUYBRUSH_USERNAME); @@ -1743,11 +1743,11 @@ public void test785AssignGuybrushBlueSwashbuckler() throws Exception { addObject(group, task, result); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_GUYBRUSH_OID, ROLE_SWASHBUCKLER_BLUE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); dumpUserAndAccounts(getUser(USER_GUYBRUSH_OID), task, result); assertGroupMember(getDummyGroup(RESOURCE_DUMMY_BLUE_NAME, GROUP_DUMMY_SWASHBUCKLERS_NAME), USER_GUYBRUSH_USERNAME); @@ -1771,11 +1771,11 @@ public void test786GuybrushTheLostBlueSwashbuckler() throws Exception { assertNoGroupMember(getDummyGroup(RESOURCE_DUMMY_BLUE_NAME, GROUP_DUMMY_SWASHBUCKLERS_NAME), USER_GUYBRUSH_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); dumpUserAndAccounts(getUser(USER_GUYBRUSH_OID), task, result); assertGroupMember(getDummyGroup(RESOURCE_DUMMY_BLUE_NAME, GROUP_DUMMY_SWASHBUCKLERS_NAME), USER_GUYBRUSH_USERNAME); @@ -1790,11 +1790,11 @@ public void test789UnassignGuybrushBlueSwashbuckler() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_GUYBRUSH_OID, ROLE_SWASHBUCKLER_BLUE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); dumpUserAndAccounts(getUser(USER_GUYBRUSH_OID), task, result); assertNoGroupMember(getDummyGroup(RESOURCE_DUMMY_BLUE_NAME, GROUP_DUMMY_SWASHBUCKLERS_NAME), USER_GUYBRUSH_USERNAME); @@ -1817,11 +1817,11 @@ public void test800AssignRoleSwashbucklerToJackNone() throws Exception { assertJackClean(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1847,11 +1847,11 @@ public void test805ReconcileJackNone() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1875,11 +1875,11 @@ public void test809UnAssignRoleSwashbucklerFromJackNone() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1905,11 +1905,11 @@ public void test810AssignRoleSwashbucklerToJackPositive() throws Exception { assertJackClean(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1933,11 +1933,11 @@ public void test815ReconcileJackPositive() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1961,11 +1961,11 @@ public void test817UnAssignRoleSwashbucklerFromJackPositive() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1988,11 +1988,11 @@ public void test819ReconcileJackPositive() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2023,11 +2023,11 @@ public void test820RecomputeJackFull() throws Exception { assertDefaultDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2053,11 +2053,11 @@ public void test822AssignRoleSwashbucklerToJackFull() throws Exception { assertJackClean(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2081,11 +2081,11 @@ public void test825ReconcileJackFull() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2109,11 +2109,11 @@ public void test827UnAssignRoleSwashbucklerFromJackFull() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2136,11 +2136,11 @@ public void test829ReconcileJackFull() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2167,11 +2167,11 @@ public void test830AssignJackAccountDummy() throws Exception { assertJackClean(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2197,11 +2197,11 @@ public void test840AssignRoleSwashbucklerToJackNone() throws Exception { assertJackJustAccount(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2225,11 +2225,11 @@ public void test849UnassignRoleSwashbucklerFromJackNone() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2255,11 +2255,11 @@ public void test850AssignRoleSwashbucklerToJackPositive() throws Exception { assertJackJustAccount(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2283,11 +2283,11 @@ public void test859UnassignRoleSwashbucklerToJackPositive() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2312,11 +2312,11 @@ public void test860RecomputeJackFull() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2342,11 +2342,11 @@ public void test862AssignRoleSwashbucklerToJackFull() throws Exception { assertJackJustAccount(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2370,11 +2370,11 @@ public void test869UnassignRoleSwashbucklerToJackFull() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2397,11 +2397,11 @@ public void test899UnAssignAccountJackDummy() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestInbounds.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestInbounds.java index 6fe98bcc6d6..dbb61ea263b 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestInbounds.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestInbounds.java @@ -62,11 +62,11 @@ public void test000Sanity() throws Exception { Task task = getTestTask(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); OperationResult testResult = modelService.testResource(RESOURCE_DUMMY_ORANGE_OID, task); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); TestUtil.assertSuccess("Test orange resource", testResult); DummyResource dummyResourceOrange = getDummyResource(RESOURCE_DUMMY_ORANGE_NAME); @@ -89,11 +89,11 @@ public void test101ModifyUserSubtypePirate() throws Exception { .createXMLGregorianCalendar(System.currentTimeMillis())); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(userDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); jackEmployeeNumber = assertUserAfter(USER_JACK_OID) @@ -128,11 +128,11 @@ public void test102ModifyUserSubtypeBuccaneer() throws Exception { USER_JACK_OID, UserType.F_SUBTYPE, "BUCCANEER"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(userDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -202,11 +202,11 @@ public void test200AssignAccountOrange() throws Exception { display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_ORANGE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -765,11 +765,11 @@ public void test264ModifyAccountOrangeQuoteWoodchuckRecon() throws Exception { display("Account orange before", dummyAccountBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -811,11 +811,11 @@ public void test297ModifyAccountOrangeGossipRecon() throws Exception { display("Account orange before", dummyAccountBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_GUYBRUSH_OID, ROLE_THIEF_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -849,11 +849,11 @@ public void test299UnassignAccountOrange() throws Exception { assertAssignments(userBefore, 1); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignAccountFromUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_ORANGE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIntent.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIntent.java index 772623f459e..2d8521ef034 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIntent.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIntent.java @@ -69,11 +69,11 @@ public void test131ModifyUserJackAssignAccountDefault() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); @@ -128,11 +128,11 @@ public void test132ModifyUserJackAssignAccountTest() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1); @@ -193,11 +193,11 @@ public void test135ModifyUserJackFullName() throws Exception { preTestCleanup(AssignmentPolicyEnforcementType.RELATIVE); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, PrismTestUtil.createPolyString("cpt. Jack Sparrow")); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 2); @@ -261,11 +261,11 @@ public void test147ModifyUserJackUnAssignAccountDefault() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIteration.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIteration.java index cbb80a1db49..ce2f1ccd008 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIteration.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIteration.java @@ -244,11 +244,11 @@ public void test100JackAssignAccountDummyConflicting() throws Exception { ObjectDelta accountAssignmentUserDelta = createAccountAssignmentUserDelta(USER_JACK_OID, RESOURCE_DUMMY_OID, null, true); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(accountAssignmentUserDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userJack = getUser(USER_JACK_OID); @@ -313,11 +313,11 @@ public void test200JackAssignAccountDummyPinkConflicting() throws Exception { .createModifyDelta(USER_JACK_OID, modifications, UserType.class); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(accountAssignmentUserDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userJack = getUser(USER_JACK_OID); @@ -373,11 +373,11 @@ public void test210GuybrushAssignAccountDummyPink() throws Exception { ObjectDelta accountAssignmentUserDelta = createAccountAssignmentUserDelta(USER_GUYBRUSH_OID, RESOURCE_DUMMY_PINK_OID, null, true); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(accountAssignmentUserDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userGuybrush = getUser(USER_GUYBRUSH_OID); @@ -439,11 +439,11 @@ public void test220DeWattAssignAccountDummyPinkCaseIgnore() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(accountAssignmentUserDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -501,11 +501,11 @@ public void test230ScroogeAddAccountDummyConflictingNoShadow() throws Exception userScrooge.asObjectable().getLinkRef().add(linkRef); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(DeltaFactory.Object.createAddDelta(userScrooge), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result, 2); PrismObject userScroogeAfter = findUserByUsername("scrooge"); @@ -549,14 +549,14 @@ public void test235HackerAddAccountDummyEternalConflict() throws Exception { deltas.add(DeltaFactory.Object.createAddDelta(userJoeHacker)); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); // wrong behavior is throwing "java.lang.IllegalStateException: Model operation took too many clicks (limit is 30). Is there a cycle?" // good behavior is reporting ObjectAlreadyExistsException here modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); display("Result", result); TestUtil.assertPartialError(result); @@ -594,11 +594,11 @@ public void test240LargoAssignAccountDummyConflictingNoShadow() throws Exception ObjectDelta accountAssignmentUserDelta = createAccountAssignmentUserDelta(USER_LARGO_OID, RESOURCE_DUMMY_PINK_OID, null, true); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(accountAssignmentUserDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result, 2); PrismObject userLargo = getUser(USER_LARGO_OID); @@ -661,11 +661,11 @@ public void test260JupiterConflictNoShadowSyncBack() throws Exception { PrismObject userJupiter = PrismTestUtil.parseObject(USER_JUPITER_FILE); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(DeltaFactory.Object.createAddDelta(userJupiter), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result, 2); PrismObject userJupiterAfter = findUserByUsername(USER_JUPITER_NAME); // jupiter @@ -714,11 +714,11 @@ protected void cleanUpJupiter(String TEST_NAME) throws SchemaException, ObjectAl ObjectDelta delta = createAccountAssignmentUserDelta(jupiterUserOid, RESOURCE_DUMMY_FUCHSIA_OID, "default", false); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(delta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userJupiterAfter = findUserByUsername(USER_JUPITER_NAME); // jupiter @@ -760,11 +760,11 @@ public void test264JupiterConflictNoShadowSyncBackSeparate() throws Exception { ObjectDelta delta = createAccountAssignmentUserDelta(jupiterUserOid, RESOURCE_DUMMY_FUCHSIA_OID, "default", true); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(delta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result, 2); PrismObject userJupiterAfter = findUserByUsername(USER_JUPITER_NAME); // jupiter @@ -825,11 +825,11 @@ public void test270JupiterConflictOtherNoShadowSyncBack() throws Exception { ObjectDelta delta = createAccountAssignmentUserDelta(jupiterUserOid, RESOURCE_DUMMY_FUCHSIA_OID, "default", true); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(delta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result, 2); PrismObject userJupiterAfter = findUserByUsername(USER_JUPITER_NAME); // jupiter @@ -920,11 +920,11 @@ public void test280RenameBobNoShadow() throws Exception { deltas.add(objectDelta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject userBobAfter = getUser(userBobOid); display("User after change execution", userBobAfter); assertUser(userBobAfter, userBobOid, "bobby", "Bobby Andrews", null, null, null); @@ -980,11 +980,11 @@ public void test282RenamePeterNoShadowSync() throws Exception { deltas.add(objectDelta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject userPeteAfter = getUser(userPeterOid); display("User after change execution", userPeteAfter); assertUser(userPeteAfter, userPeterOid, "pete", "Pete Crenshaw", null, null, null); @@ -1048,11 +1048,11 @@ public void test290AlfredConflictNoShadowSyncBackAdd() throws Exception { ObjectDelta delta = DeltaFactory.Object.createAddDelta(userAlfred); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(delta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result, 2); PrismObject userAlfredAfter = findUserByUsername(USER_ALFRED_NAME); // alfred @@ -1097,11 +1097,11 @@ public void test300JackAssignAccountDummyVioletConflicting() throws Exception { deltas.add(accountAssignmentUserDelta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1155,11 +1155,11 @@ public void test350GuybrushAssignAccountDummyViolet() throws Exception { deltas.add(accountAssignmentUserDelta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1214,11 +1214,11 @@ public void test360HermanAssignAccountDummyViolet() throws Exception { deltas.add(accountAssignmentUserDelta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1303,11 +1303,11 @@ public void test500JackAssignAccountDummyMagenta() throws Exception { deltas.add(accountAssignmentUserDelta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1383,11 +1383,11 @@ public void test510DrakeAssignAccountDummyMagenta() throws Exception { deltas.add(accountAssignmentUserDelta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1446,11 +1446,11 @@ public void test520DrakeModifyLocality() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_DRAKE_OID, UserType.F_LOCALITY, task, result, PrismTestUtil.createPolyString("London")); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1514,11 +1514,11 @@ public void test530GuybrushAssignAccountDummyMagenta() throws Exception { deltas.add(accountAssignmentUserDelta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1576,11 +1576,11 @@ public void test532GuybrushModifyDescription() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_DESCRIPTION, task, result, DESCRIPTION_RUM); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1639,12 +1639,12 @@ public void test600JackRename() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_JACK_OID, UserType.F_NAME, task, result, PrismTestUtil.createPolyString(USER_JACK_RENAMED_NAME)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1716,7 +1716,7 @@ public void test710DarkVioletAddLeChuck() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, LECHUCK_FULLNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); display("Adding dummy account", account.debugDump()); getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).addAccount(account); @@ -1724,7 +1724,7 @@ public void test710DarkVioletAddLeChuck() throws Exception { waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertUserNick(ACCOUNT_LECHUCK_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME); } @@ -1743,7 +1743,7 @@ public void test712DarkVioletAddCharles() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, LECHUCK_FULLNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); display("Adding dummy account", account.debugDump()); getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).addAccount(account); @@ -1751,7 +1751,7 @@ public void test712DarkVioletAddCharles() throws Exception { waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertUserNick(ACCOUNT_LECHUCK_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME); assertUserNick(ACCOUNT_CHARLES_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME+".1"); } @@ -1772,7 +1772,7 @@ public void test714DarkVioletAddShinetop() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Melee Island"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); display("Adding dummy account", account.debugDump()); getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).addAccount(account); @@ -1780,7 +1780,7 @@ public void test714DarkVioletAddShinetop() throws Exception { waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertUserNick(ACCOUNT_LECHUCK_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME); assertUserNick(ACCOUNT_CHARLES_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME+".1"); assertUserNick(ACCOUNT_SHINETOP_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME+".2", "Melee Island"); @@ -1794,14 +1794,14 @@ public void test716DarkVioletDeleteCharles() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).deleteAccountByName(ACCOUNT_CHARLES_USERNAME); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertUserNick(ACCOUNT_LECHUCK_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME); assertNoUserNick(ACCOUNT_CHARLES_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME+".1"); assertUserNick(ACCOUNT_SHINETOP_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME+".2", "Melee Island"); @@ -1817,14 +1817,14 @@ public void test720DarkVioletModifyShinetopLocation() throws Exception { DummyAccount account = getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).getAccountByUsername(ACCOUNT_SHINETOP_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); account.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Monkey Island"); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); displayAllUsers(); assertUserNick(ACCOUNT_LECHUCK_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME); assertNoUserNick(ACCOUNT_CHARLES_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME+".1"); @@ -1841,14 +1841,14 @@ public void test722DarkVioletModifyShinetopFullName() throws Exception { DummyAccount account = getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).getAccountByUsername(ACCOUNT_SHINETOP_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); account.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, CHUCKIE_FULLNAME); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); displayAllUsers(); assertUserNick(ACCOUNT_LECHUCK_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME); assertNoUserNick(ACCOUNT_CHARLES_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME+".1"); @@ -1876,7 +1876,7 @@ public void test724DarkVioletAddLe_Chuck() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Melee Island"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); display("Adding dummy account", account.debugDump()); getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).addAccount(account); @@ -1884,7 +1884,7 @@ public void test724DarkVioletAddLe_Chuck() throws Exception { waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); displayAllUsers(); assertUserNick(ACCOUNT_LECHUCK_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME); assertUserNick(ACCOUNT_LE_CHUCK_USERNAME, LE_CHUCK_FULLNAME, LE_CHUCK_FULLNAME+".1", "Melee Island"); @@ -1910,7 +1910,7 @@ public void test730DarkVioletAddBarbossa() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, USER_BARBOSSA_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); display("Adding dummy account", account.debugDump()); getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).addAccount(account); @@ -1918,7 +1918,7 @@ public void test730DarkVioletAddBarbossa() throws Exception { waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertUserNick(USER_BARBOSSA_USERNAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_USERNAME+".1"); } @@ -1942,7 +1942,7 @@ public void test732DarkVioletAddBarbossa() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, USER_BARBOSSA_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); display("Adding dummy account", account.debugDump()); getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).addAccount(account); @@ -1950,7 +1950,7 @@ public void test732DarkVioletAddBarbossa() throws Exception { waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertUserNick(USER_BARBOSSA_USERNAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_USERNAME+".1"); assertUserNick("YA" + USER_BARBOSSA_USERNAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_USERNAME+".4"); } @@ -1973,7 +1973,7 @@ public void test750DarkVioletAddMatusalem() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, RUM_FULLNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); display("Adding dummy account", account.debugDump()); getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).addAccount(account); @@ -1981,7 +1981,7 @@ public void test750DarkVioletAddMatusalem() throws Exception { waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertUserNick(ACCOUNT_MATUSALEM_USERNAME, RUM_FULLNAME, RUM_FULLNAME); } @@ -2002,7 +2002,7 @@ public void test752DarkVioletAddDiplomatico() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, RUM_FULLNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); display("Adding dummy account", account.debugDump()); getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).addAccount(account); @@ -2010,7 +2010,7 @@ public void test752DarkVioletAddDiplomatico() throws Exception { waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); displayAllUsers(); assertUserNick(ACCOUNT_MATUSALEM_USERNAME, RUM_FULLNAME, RUM_FULLNAME); @@ -2037,7 +2037,7 @@ public void test754DarkVioletAddMilionario() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Peru"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); display("Adding dummy account", account.debugDump()); getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).addAccount(account); @@ -2045,7 +2045,7 @@ public void test754DarkVioletAddMilionario() throws Exception { waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertUserNick(ACCOUNT_MATUSALEM_USERNAME, RUM_FULLNAME, RUM_FULLNAME); assertUserNick(ACCOUNT_DIPLOMATICO_USERNAME, RUM_FULLNAME, RUM_FULLNAME+iterationTokenDiplomatico); @@ -2063,14 +2063,14 @@ public void test756DarkVioletDeleteDiplomatico() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).deleteAccountByName(ACCOUNT_DIPLOMATICO_USERNAME); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertUserNick(ACCOUNT_MATUSALEM_USERNAME, RUM_FULLNAME, RUM_FULLNAME); assertNoUserNick(ACCOUNT_DIPLOMATICO_USERNAME, RUM_FULLNAME, RUM_FULLNAME+iterationTokenDiplomatico); assertUserNick(ACCOUNT_MILLONARIO_USERNAME, RUM_FULLNAME, RUM_FULLNAME+iterationTokenMillonario, "Peru"); @@ -2088,14 +2088,14 @@ public void test760DarkVioletModifyMillonarioLocation() throws Exception { DummyAccount account = getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).getAccountByUsername(ACCOUNT_MILLONARIO_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); account.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Northern Peru"); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); displayAllUsers(); assertUserNick(ACCOUNT_MATUSALEM_USERNAME, RUM_FULLNAME, RUM_FULLNAME); assertNoUserNick(ACCOUNT_DIPLOMATICO_USERNAME, RUM_FULLNAME, RUM_FULLNAME+iterationTokenDiplomatico); @@ -2117,14 +2117,14 @@ public void test762DarkVioletModifyMillonarioFullName() throws Exception { DummyAccount account = getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).getAccountByUsername(ACCOUNT_MILLONARIO_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); account.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, RON_FULLNAME); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); displayAllUsers(); assertUserNick(ACCOUNT_MATUSALEM_USERNAME, RUM_FULLNAME, RUM_FULLNAME); assertNoUserNick(ACCOUNT_DIPLOMATICO_USERNAME, RUM_FULLNAME, RUM_FULLNAME+iterationTokenDiplomatico); @@ -2147,14 +2147,14 @@ public void test764DarkVioletModifyMatusalemFullName() throws Exception { DummyAccount account = getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).getAccountByUsername(ACCOUNT_MATUSALEM_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); account.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, RON_FULLNAME); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); displayAllUsers(); assertNoUserNick(ACCOUNT_MATUSALEM_USERNAME, RUM_FULLNAME, RUM_FULLNAME); String iterationTokenMatusalem = lookupIterationTokenByAdditionalName(ACCOUNT_MATUSALEM_USERNAME); @@ -2183,11 +2183,11 @@ public void test800UniqeEmailAddUserAlfredoFettucini() throws Exception { USER_FETTUCINI_NICKNAME, true); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(user, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2220,11 +2220,11 @@ public void test802UniqeEmailAddUserBillFettucini() throws Exception { USER_BILL_FETTUCINI_FAMILY_NAME, USER_FETTUCINI_NICKNAME, true); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(user, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(user.getOid()); @@ -2267,12 +2267,12 @@ public void test820SubtypeSetByInbound() throws Exception { assertEquals("Wrong # of shadows", 2, shadows.size()); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); importAccountsFromResourceTaskHandler.importSingleShadow(shadows.get(0).getOid(), task, result); importAccountsFromResourceTaskHandler.importSingleShadow(shadows.get(1).getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); ObjectQuery userQuery = prismContext.queryFor(UserType.class) diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIterativeTasks.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIterativeTasks.java index 8aa4e32b08f..0627035f7d0 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIterativeTasks.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIterativeTasks.java @@ -75,11 +75,11 @@ public void test100RunBucketsMultithreaded() throws Exception { // GIVEN // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addTask(TASK_BUCKETS_MULTITHREADED_FILE); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForTaskFinish(TASK_BUCKETS_MULTITHREADED_OID, false); } diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestLifecycle.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestLifecycle.java index fa66933a13a..0c31c4ca91c 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestLifecycle.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestLifecycle.java @@ -93,7 +93,7 @@ public void test050SetupJack() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_HEADMASTER_OID, task, result); assignRole(USER_JACK_OID, ROLE_GAMBLER_OID, task, result); @@ -103,7 +103,7 @@ public void test050SetupJack() throws Exception { modifyUserReplace(USER_JACK_OID, UserType.F_TELEPHONE_NUMBER, task, result, USER_JACK_TELEPHONE_NUMBER); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -122,11 +122,11 @@ public void test052PrincipalJackDraft() throws Exception { // GIVEN // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); MidPointPrincipal principal = focusProfileService.getPrincipal(USER_JACK_USERNAME, UserType.class); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertNotAuthorized(principal, AUTZ_COMMAND_URL); assertNotAuthorized(principal, AUTZ_GAMBLE_URL); assertNotAuthorized(principal, AUTZ_APPARATE_URL); @@ -146,11 +146,11 @@ public void test060TransitionJackToProposed() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_JACK_OID, UserType.F_LIFECYCLE_STATE, task, result, SchemaConstants.LIFECYCLE_PROPOSED); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -171,11 +171,11 @@ public void test062PrincipalJackProposed() throws Exception { // GIVEN // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); MidPointPrincipal principal = focusProfileService.getPrincipal(USER_JACK_USERNAME, UserType.class); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertNotAuthorized(principal, AUTZ_COMMAND_URL); // Although we are in the proposed lifecycle and assignments would not be active by default // the proposed lifecycle is forcing activation to enabled. Therefore also assignments are @@ -200,11 +200,11 @@ public void test090TransitionJackToDefaultActive() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_JACK_OID, UserType.F_LIFECYCLE_STATE, task, result /* no value */); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -223,11 +223,11 @@ public void test092PrincipalJackDefaultActive() throws Exception { // GIVEN // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); MidPointPrincipal principal = focusProfileService.getPrincipal(USER_JACK_USERNAME, UserType.class); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertNotAuthorized(principal, AUTZ_COMMAND_URL); assertAuthorized(principal, AUTZ_GAMBLE_URL); assertAuthorized(principal, AUTZ_APPARATE_URL); @@ -252,12 +252,12 @@ public void test100AssignJackCaretaker() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_CARETAKER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -276,12 +276,12 @@ public void test102UnassignJackHeadmaster() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, ROLE_HEADMASTER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -304,12 +304,12 @@ public void test110UnassignJackCaretaker() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, ROLE_CARETAKER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -331,12 +331,12 @@ public void test112UnassignJackCaretaker() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_HEADMASTER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestMerge.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestMerge.java index 4c793db9b3f..fdc06b6a412 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestMerge.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestMerge.java @@ -110,7 +110,7 @@ public void test100MergeJackGuybrushPreviewDelta() throws Exception { display("Guybrush before", userGuybrushBefore); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); MergeDeltas deltas = modelInteractionService.mergeObjectsPreviewDeltas(UserType.class, USER_JACK_OID, USER_GUYBRUSH_OID, MERGE_CONFIG_DEFAULT_NAME, task, result); @@ -167,7 +167,7 @@ public void test102MergeJackGuybrushPreviewObject() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); PrismObject object = modelInteractionService.mergeObjectsPreviewObject(UserType.class, USER_JACK_OID, USER_GUYBRUSH_OID, MERGE_CONFIG_DEFAULT_NAME, task, result); @@ -224,7 +224,7 @@ public void test110MergeGuybrushJackPreviewDelta() throws Exception { display("Jack before", userJackBefore); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); MergeDeltas deltas = modelInteractionService.mergeObjectsPreviewDeltas(UserType.class, USER_GUYBRUSH_OID, USER_JACK_OID, MERGE_CONFIG_DEFAULT_NAME, task, result); @@ -278,7 +278,7 @@ public void test112MergeGuybrushJackPreviewObject() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); PrismObject object = modelInteractionService.mergeObjectsPreviewObject(UserType.class, USER_GUYBRUSH_OID, USER_JACK_OID, MERGE_CONFIG_DEFAULT_NAME, task, result); @@ -332,7 +332,7 @@ public void test200MergeJackGuybrushExpressionPreviewDelta() throws Exception { display("Guybrush before", userGuybrushBefore); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); MergeDeltas deltas = modelInteractionService.mergeObjectsPreviewDeltas(UserType.class, USER_JACK_OID, USER_GUYBRUSH_OID, MERGE_CONFIG_EXPRESSION_NAME, task, result); @@ -379,7 +379,7 @@ public void test202MergeJackGuybrushExpressionPreviewObject() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); PrismObject object = modelInteractionService.mergeObjectsPreviewObject(UserType.class, USER_JACK_OID, USER_GUYBRUSH_OID, MERGE_CONFIG_EXPRESSION_NAME, task, result); @@ -436,7 +436,7 @@ public void test300MergeJackGuybrushPreviewDeltaDefaultSpecific() throws Excepti display("Guybrush before", userGuybrushBefore); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); MergeDeltas deltas = modelInteractionService.mergeObjectsPreviewDeltas(UserType.class, USER_JACK_OID, USER_GUYBRUSH_OID, MERGE_CONFIG_DEFAULT_SPECIFIC_NAME, task, result); @@ -493,7 +493,7 @@ public void test500MergeJackGuybrush() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.mergeObjects(UserType.class, USER_JACK_OID, USER_GUYBRUSH_OID, MERGE_CONFIG_DEFAULT_NAME, task, result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelServiceContract.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelServiceContract.java index f156ecfc67b..8b5649091b5 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelServiceContract.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelServiceContract.java @@ -184,14 +184,14 @@ public void test099ModifyUserAddAccountFailing() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(deltas, null, task, result); assertNotReached(); } catch (UnsupportedOperationException e) { // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Expected exception", e); } @@ -246,11 +246,11 @@ public void test100ModifyUserAddAccount() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserAddAccount(USER_JACK_OID, ACCOUNT_JACK_DUMMY_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); @@ -737,11 +737,11 @@ public void test119ModifyUserDeleteAccount() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess("executeChanges result", result, 2); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); @@ -805,11 +805,11 @@ public void test120AddAccount() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); Collection> executeChanges = executeChanges(accountDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); @@ -1120,11 +1120,11 @@ public void test131ModifyUserJackAssignAccount() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); @@ -1288,11 +1288,11 @@ public void test135ModifyUserJackAssignAccountAgain() throws Exception { preTestCleanup(AssignmentPolicyEnforcementType.FULL); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess("executeChanges result", result); PrismObject userJack = getUser(USER_JACK_OID); @@ -1353,11 +1353,11 @@ public void test136JackRecomputeNoChange() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1576,11 +1576,11 @@ public void test148ModifyUserJackUnassignAccountPositiveEnforcement() throws Exc assertSteadyResources(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); // There is strong mapping. Complete account is fetched. assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1); @@ -2350,11 +2350,11 @@ public void test190ModifyUserJackAssignAccountAndModify() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); @@ -2476,11 +2476,11 @@ public void test191ModifyUserJackModifyAssignment() throws Exception { display("Deltas to execute execution", deltas); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess("executeChanges result", result); @@ -2537,12 +2537,12 @@ public void test192ModifyUserJack() throws Exception { preTestCleanup(AssignmentPolicyEnforcementType.FULL); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, PrismTestUtil.createPolyString("Magnificent Captain Jack Sparrow")); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); // Strong mappings assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1); @@ -2708,11 +2708,11 @@ public void test195ModifyUserJackLocationSea() throws Exception { preTestCleanup(AssignmentPolicyEnforcementType.FULL); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_JACK_OID, UserType.F_LOCALITY, task, result, createPolyString("sea")); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); // Strong mappings assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1); @@ -2982,11 +2982,11 @@ public void test210AddUserMorganWithAssignment() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(userDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); @@ -3058,11 +3058,11 @@ public void test212RenameUserMorgan() throws Exception { preTestCleanup(AssignmentPolicyEnforcementType.FULL); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_MORGAN_OID, UserType.F_NAME, task, result, PrismTestUtil.createPolyString("sirhenry")); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); // Strong mappings assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1); @@ -3234,11 +3234,11 @@ public void test300AddUserJackWithAssignmentBlue() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestNotifications.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestNotifications.java index a9f5fb4e091..46b5f7df007 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestNotifications.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestNotifications.java @@ -134,7 +134,7 @@ public void test100ModifyUserAddAccount() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyUserAddAccount(USER_JACK_OID, ACCOUNT_JACK_DUMMY_FILE, task, result); // THEN @@ -232,7 +232,7 @@ public void test119ModifyUserDeleteAccount() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN @@ -298,7 +298,7 @@ public void test131ModifyUserJackAssignAccount() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN @@ -371,7 +371,7 @@ public void test140ModifyUserJackAssignRole() throws Exception { preTestCleanup(AssignmentPolicyEnforcementType.FULL); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_SUPERUSER_OID, task, result); // THEN @@ -424,7 +424,7 @@ public void test150ModifyUserJackModifyAssignment() throws Exception { preTestCleanup(AssignmentPolicyEnforcementType.FULL); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); PrismObject jack = getUser(USER_JACK_OID); AssignmentType assignment = findAssignmentByTargetRequired(jack, ROLE_SUPERUSER_OID); Long id = assignment.getId(); @@ -486,7 +486,7 @@ public void test160ModifyUserJackDeleteAssignment() throws Exception { preTestCleanup(AssignmentPolicyEnforcementType.FULL); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); PrismObject jack = getUser(USER_JACK_OID); AssignmentType assignment = findAssignmentByTargetRequired(jack, ROLE_SUPERUSER_OID); Long id = assignment.getId(); @@ -544,7 +544,7 @@ public void test200SendSmsUsingGet() { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); Event event = new CustomEvent(lightweightIdentifierGenerator, "get", null, "hello world", EventOperationType.ADD, EventStatusType.SUCCESS, null); notificationManager.processEvent(event, task, result); @@ -569,7 +569,7 @@ public void test210SendSmsUsingPost() { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); Event event = new CustomEvent(lightweightIdentifierGenerator, "post", null, "hello world", EventOperationType.ADD, EventStatusType.SUCCESS, null); notificationManager.processEvent(event, task, result); @@ -602,7 +602,7 @@ public void test215SendSmsUsingGeneralPost() { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); Event event = new CustomEvent(lightweightIdentifierGenerator, "general-post", null, "hello world", EventOperationType.ADD, EventStatusType.SUCCESS, null); notificationManager.processEvent(event, task, result); @@ -635,7 +635,7 @@ public void test220SendSmsViaProxy() { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); Event event = new CustomEvent(lightweightIdentifierGenerator, "get-via-proxy", null, "hello world via proxy", EventOperationType.ADD, EventStatusType.SUCCESS, null); notificationManager.processEvent(event, task, result); @@ -663,7 +663,7 @@ public void test300CheckVariables() { prepareNotifications(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); Event event = new CustomEvent(lightweightIdentifierGenerator, "check-variables", null, "hello world", EventOperationType.ADD, EventStatusType.SUCCESS, null); notificationManager.processEvent(event, task, result); @@ -688,7 +688,7 @@ public void test400StringAttachment() throws Exception { preTestCleanup(AssignmentPolicyEnforcementType.FULL); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); PrismObject user = new UserType(prismContext) .name("testStringAttachmentUser") .asPrismObject(); @@ -725,7 +725,7 @@ public void test410ByteAttachment() throws Exception { preTestCleanup(AssignmentPolicyEnforcementType.FULL); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); PrismObject user = new UserType(prismContext) .name("testByteAttachmentUser") .asPrismObject(); @@ -776,7 +776,7 @@ public void test420AttachmentFromFile() throws Exception { preTestCleanup(AssignmentPolicyEnforcementType.FULL); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); PrismObject user = new UserType(prismContext) .name("testAttachmentFromFileUser") .asPrismObject(); @@ -812,7 +812,7 @@ public void test430ExpressionAttachment() throws Exception { preTestCleanup(AssignmentPolicyEnforcementType.FULL); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); PrismObject user = new UserType(prismContext) .name("testExpressionAttachmentUser") .asPrismObject(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestPreviewChanges.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestPreviewChanges.java index d94f642f7f8..10b72e71d90 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestPreviewChanges.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestPreviewChanges.java @@ -464,11 +464,11 @@ public void test200ModifyUserGuybrushDeleteAccount() throws Exception { display("Input deltas: ", deltas); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ModelContext modelContext = modelInteractionService.previewChanges(deltas, new ModelExecuteOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -507,11 +507,11 @@ public void test210GuybrushAddAccount() throws Exception { display("Input deltas: ", deltas); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ModelContext modelContext = modelInteractionService.previewChanges(deltas, new ModelExecuteOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -560,11 +560,11 @@ public void test212ModifyUserAddAccountRef() throws Exception { display("Input deltas: ", userDelta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ModelContext modelContext = modelInteractionService.previewChanges(deltas, new ModelExecuteOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -612,12 +612,12 @@ public void test220PreviewJackAssignRolePirate() throws Exception { ROLE_PIRATE_OID, RoleType.COMPLEX_TYPE, null, null, null, true); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertPreviewJackAssignRolePirate(modelContext); @@ -643,12 +643,12 @@ public void test221PreviewJackAssignRolePirateReconcile() throws Exception { ROLE_PIRATE_OID, RoleType.COMPLEX_TYPE, null, null, null, true); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), ModelExecuteOptions.createReconcile(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertPreviewJackAssignRolePirate(modelContext); @@ -744,13 +744,13 @@ public void test230GuybrushAssignAccountDummy() throws Exception { ModelExecuteOptions options = ModelExecuteOptions.createReconcile(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_GUYBRUSH_OID, ItemPath.create(UserType.F_EXTENSION, PIRACY_WEAPON), task, result, "tongue"); assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); accountGuybrushOid = assertUserAfter(USER_GUYBRUSH_OID) @@ -778,12 +778,12 @@ public void test231PreviewGuybrushModifyAccountFullName() throws Exception { accountGuybrushOid, dummyResourceCtl.getAttributeFullnamePath(), "Mighty Pirate Guybrush Threepwood"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(accountDelta), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -831,12 +831,12 @@ public void test232PreviewGuybrushModifyAccountShip() throws Exception { "The Mad Monkey"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(accountDelta), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -882,12 +882,12 @@ public void test233PreviewGuybrushAddRolePirate() throws Exception { ROLE_PIRATE_OID, RoleType.COMPLEX_TYPE, null, null, null, true); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -950,12 +950,12 @@ public void test234PreviewGuybrushAddRolePirateRecon() throws Exception { ModelExecuteOptions options = ModelExecuteOptions.createReconcile(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), options, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -1016,12 +1016,12 @@ public void test236PreviewGuybrushAddRoleSailor() throws Exception { ROLE_SAILOR_OID, RoleType.COMPLEX_TYPE, null, null, null, true); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -1069,12 +1069,12 @@ public void test238PreviewGuybrushAddRoleSailorOwner() throws Exception { ROLE_SAILOR_OID, RoleType.COMPLEX_TYPE, SchemaConstants.ORG_OWNER, null, null, true); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -1103,11 +1103,11 @@ public void test239GuybrushUnAssignAccountDummy() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignAccountFromUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1128,11 +1128,11 @@ public void test240GuybrushAssignAccountDummyRelative() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_RELATIVE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1159,12 +1159,12 @@ public void test242PreviewGuybrushAddRolePirateRelative() throws Exception { ROLE_PIRATE_RELATIVE_OID, RoleType.COMPLEX_TYPE, null, null, null, true); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -1226,12 +1226,12 @@ public void test244PreviewGuybrushAddRolePirateRelativeRecon() throws Exception ROLE_PIRATE_RELATIVE_OID, RoleType.COMPLEX_TYPE, null, null, null, true); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), ModelExecuteOptions.createReconcile(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -1287,11 +1287,11 @@ public void test249GuybrushUnAssignAccountDummyRelative() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignAccountFromUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_RELATIVE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1461,11 +1461,11 @@ ACCOUNT_SHADOW_ELAINE_DUMMY_RED_OID, getDummyResourceObject(RESOURCE_DUMMY_RED_N display("Input deltas: ", deltas); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ModelContext modelContext = modelInteractionService.previewChanges(deltas, new ModelExecuteOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Preview context", modelContext); assertPartialError(result); } @@ -1493,12 +1493,12 @@ public void test401ModifyElaineAccountDummyRedDeleteAdd() throws Exception { display("Input deltas: ", deltas); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ModelContext modelContext = modelInteractionService.previewChanges(deltas, new ModelExecuteOptions(), task, result); display("Preview context", modelContext); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertPartialError(result); } @@ -1640,11 +1640,11 @@ public void test600ModifyElaineUserDummyReplace() throws Exception { display("Input deltas: ", deltas); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ModelContext modelContext = modelInteractionService.previewChanges(deltas, new ModelExecuteOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -1743,11 +1743,11 @@ ACCOUNT_SHADOW_ELAINE_DUMMY_BLUE_OID, getDummyResourceObject(RESOURCE_DUMMY_BLUE display("Input deltas: ", deltas); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ModelContext modelContext = modelInteractionService.previewChanges(deltas, new ModelExecuteOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -2097,12 +2097,12 @@ public void test710PreviewGuybrushHavingRoleSailorOwner() throws Exception { ObjectDelta empty = prismContext.deltaFor(UserType.class).asObjectDeltaCast(USER_GUYBRUSH_OID); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ModelContext modelContext = modelInteractionService.previewChanges(singleton(empty), createEvaluateAllAssignmentRelationsOnRecompute(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestRaceConditions.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestRaceConditions.java index 51ac5ec4c90..a50f14a6cab 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestRaceConditions.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestRaceConditions.java @@ -57,7 +57,7 @@ public void test100AssignRoles() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); @SuppressWarnings({"raw"}) ObjectDelta objectDelta = deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT).add( diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestResources.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestResources.java index 46616682912..c9f4df1ee78 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestResources.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestResources.java @@ -165,11 +165,11 @@ public void test050GetResourceRaw() throws Exception { Collection> options = SelectorOptions.createCollection(GetOperationOptions.createRaw()); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, options , task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("Resource", resource); @@ -215,12 +215,12 @@ public void test052GetResourceNoFetch() throws Exception { GetOperationOptions.createNoFetch()); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, options, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("Resource", resource); @@ -266,12 +266,12 @@ public void test053GetResourceNoFetchAgain() throws Exception { GetOperationOptions.createNoFetch()); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, options, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("Resource", resource); @@ -320,12 +320,12 @@ public void test055GetResourceNoFetchReadOnly() throws Exception { Collection> options = SelectorOptions.createCollection(option); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, options, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("Resource", resource); @@ -366,11 +366,11 @@ public void test100SearchResourcesNoFetch() throws Exception { Collection> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch()); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); List> resources = modelService.searchObjects(ResourceType.class, null, options, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertNotNull("null search return", resources); assertFalse("Empty search return", resources.isEmpty()); assertEquals("Unexpected number of resources found", 2, resources.size()); @@ -416,11 +416,11 @@ public void test102SearchResourcesNoFetchReadOnly() throws Exception { Collection> options = SelectorOptions.createCollection(option); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); List> resources = modelService.searchObjects(ResourceType.class, null, options, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertNotNull("null search return", resources); assertFalse("Empty search return", resources.isEmpty()); assertEquals("Unexpected number of resources found", 2, resources.size()); @@ -472,11 +472,11 @@ public void test105SearchResourcesIterativeNoFetch() throws Exception { Collection> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch()); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.searchObjectsIterative(ResourceType.class, null, handler, options, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertFalse("Empty search return", resources.isEmpty()); @@ -525,11 +525,11 @@ public void test107SearchResourcesIterativeNoFetchReadOnly() throws Exception { Collection> options = SelectorOptions.createCollection(option); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.searchObjectsIterative(ResourceType.class, null, handler, options, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertFalse("Empty search return", resources.isEmpty()); @@ -561,11 +561,11 @@ public void test110GetResourceDummy() throws Exception { rememberCounter(InternalCounters.PRISM_OBJECT_CLONE_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null , task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertCounterIncrement(InternalCounters.PRISM_OBJECT_CLONE_COUNT, 4); @@ -606,12 +606,12 @@ public void test112GetResourceDummyReadOnly() throws Exception { GetOperationOptions.createReadOnly()); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, options , task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertCounterIncrement(InternalCounters.PRISM_OBJECT_CLONE_COUNT, 1); @@ -645,11 +645,11 @@ public void test120SearchResources() throws Exception { assertSteadyResources(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); List> resources = modelService.searchObjects(ResourceType.class, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertNotNull("null search return", resources); assertFalse("Empty search return", resources.isEmpty()); assertEquals("Unexpected number of resources found", 2, resources.size()); @@ -832,11 +832,11 @@ public void test210GetResourceDummyRed() throws Exception { rememberCounter(InternalCounters.PRISM_OBJECT_CLONE_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_RED_OID, null , task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertCounterIncrement(InternalCounters.PRISM_OBJECT_CLONE_COUNT, 1); @@ -876,11 +876,11 @@ public void test750GetResourceRaw() throws Exception { Collection> options = SelectorOptions.createCollection(GetOperationOptions.createRaw()); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, options , task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("Resource", resource); @@ -909,11 +909,11 @@ public void test752GetResourceDummy() throws Exception { rememberCounter(InternalCounters.PRISM_OBJECT_CLONE_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null , task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertCounterIncrement(InternalCounters.PRISM_OBJECT_CLONE_COUNT, 1); @@ -941,11 +941,11 @@ public void test760ModifyConfigurationString() throws Exception { "whatever wherever"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(resourceDelta), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject resourceAfter = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result); @@ -967,12 +967,12 @@ public void test761ModifyConfigurationStringRaw() throws Exception { "whatever raw wherever"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(resourceDelta), ModelExecuteOptions.createRaw(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject resourceAfter = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result); @@ -1050,11 +1050,11 @@ private void modifyConfigurationDiffExpressionRaw(final String TEST_NAME, display("Diff delta", diffDelta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(diffDelta, ModelExecuteOptions.createRaw(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertCounterIncrement(InternalCounters.CONNECTOR_INSTANCE_INITIALIZATION_COUNT, 0); @@ -1108,11 +1108,11 @@ public void test800GetResourceDummy() throws Exception { rememberCounter(InternalCounters.PRISM_OBJECT_CLONE_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null , task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertCounterIncrement(InternalCounters.PRISM_OBJECT_CLONE_COUNT, 1); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestStrangeCases.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestStrangeCases.java index 9e588e4d339..942cc27a43b 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestStrangeCases.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestStrangeCases.java @@ -380,7 +380,7 @@ public void test180DeleteHalfAssignmentFromUser() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - displayWhen(); + when(); modelService.executeChanges(deltas, null, task, getCheckingProgressListenerCollection(), result); // THEN @@ -427,11 +427,11 @@ public void test190DeleteHalfAssignedUser() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - displayWhen(); + when(); modelService.executeChanges(deltas, null, task, getCheckingProgressListenerCollection(), result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess("executeChanges result", result); @@ -473,12 +473,12 @@ public void test200ModifyUserJackBrokenAccountRefAndPolyString() throws Exceptio PolyString fullNamePolyString = new PolyString("Magnificent Captain Jack Sparrow", null); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, fullNamePolyString); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess("executeChanges result", result, 2); @@ -512,11 +512,11 @@ public void test210ModifyUserAddAccount() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); // WHEN - displayWhen(); + when(); modifyUserAddAccount(USER_JACK_OID, ACCOUNT_JACK_DUMMY_FILE, task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -542,11 +542,11 @@ public void test212ModifyUserAddAccountRed() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); // WHEN - displayWhen(); + when(); modifyUserAddAccount(USER_JACK_OID, ACCOUNT_JACK_DUMMY_RED_FILE, task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -577,12 +577,12 @@ public void test212ModifyUserJackBrokenSchemaViolationPolyString() throws Except getDummyResource().setModifyBreakMode(BreakMode.SCHEMA); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, new PolyString("Cpt. Jack Sparrow", null)); // THEN - displayThen(); + then(); result.computeStatus(); display("Result", result); TestUtil.assertPartialError(result); @@ -619,11 +619,11 @@ public void test214ModifyUserJackBrokenPassword() throws Exception { getDummyResource().setModifyBreakMode(BreakMode.SCHEMA); // WHEN - displayWhen(); + when(); modifyUserChangePassword(USER_JACK_OID, "whereStheRUM", task, result); // THEN - displayThen(); + then(); result.computeStatus(); display("Result", result); TestUtil.assertPartialError(result); @@ -661,11 +661,11 @@ public void test220ModifyUserJackBrokenConflict() throws Exception { getDummyResource().setModifyBreakMode(BreakMode.CONFLICT); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_LOCALITY, task, result, createPolyString("High seas")); // THEN - displayThen(); + then(); result.computeStatus(); display("Result", result); TestUtil.assertPartialError(result); @@ -707,14 +707,14 @@ public void test230ModifyUserJackUserTemplatePolicyViolation() throws Exception try { // WHEN - displayWhen(); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_COST_CENTER, task, result, "broke"); assertNotReached(); } catch (ExpressionEvaluationException e) { // THEN - displayThen(); + then(); display("Exception (expected)", e); assertExceptionUserFriendly(e, "We do not serve your kind here"); @@ -1169,11 +1169,11 @@ public void test400ImportJackMockTask() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(); + when(); importObjectFromFile(TASK_MOCK_JACK_FILE); // THEN - displayThen(); + then(); result.computeStatus(); assertSuccess(result); @@ -1190,11 +1190,11 @@ public void test401ListTasks() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(); + when(); List> objects = modelService.searchObjects(TaskType.class, null, null, task, result); // THEN - displayThen(); + then(); assertSuccess(result); display("Tasks", objects); @@ -1236,11 +1236,11 @@ public void test410DeleteJack() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(); + when(); deleteObject(UserType.class, USER_JACK_OID, task, result); // THEN - displayThen(); + then(); assertSuccess(result); // Make sure the user is gone @@ -1331,7 +1331,7 @@ public void test502EnumerationStoreGood() throws Exception { task, result, "bravery"); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject user = getUser(USER_GUYBRUSH_OID); @@ -1367,7 +1367,7 @@ public void test510EnumerationGetBad() throws Exception { PrismObject user = modelService.getObject(UserType.class, USER_GUYBRUSH_OID, null, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismProperty markProp = user.findProperty(ItemPath.create(UserType.F_EXTENSION, PIRACY_MARK)); @@ -1399,7 +1399,7 @@ public void test520ShipReadBadTolerateRawData() throws Exception { modelService.getObject(UserType.class, USER_GUYBRUSH_OID, SelectorOptions.createCollection(createTolerateRawData()), task, result); // THEN - displayThen(); + then(); assertSuccess(result); } @@ -1484,7 +1484,7 @@ public void test550AssignCircus() throws Exception { assertNotReached(); } catch (PolicyViolationException e) { // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertFailure(result); } @@ -1505,11 +1505,11 @@ public void test600AddUserGuybrushAssignAccount() throws Exception { deltas.add(accountAssignmentUserDelta); // WHEN - displayWhen(); + when(); modelService.executeChanges(deltas, null, task, getCheckingProgressListenerCollection(), result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1544,11 +1544,11 @@ public void test610GetAccountGuybrushRogueAttribute() throws Exception { getDummyResource().setEnforceSchema(true); // WHEN - displayWhen(); + when(); PrismObject shadow = modelService.getObject(ShadowType.class, accountGuybrushOid, null, task, result); // THEN - displayThen(); + then(); assertSuccess(result); display("Shadow after", shadow); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTolerantAttributes.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTolerantAttributes.java index bf06307c48c..f5e13c78842 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTolerantAttributes.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTolerantAttributes.java @@ -137,11 +137,11 @@ UserType.F_DESCRIPTION, getUserDefinition().findPropertyDefinition(UserType.F_DE Collection> deltas = (Collection)MiscUtil.createCollection(userDelta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(deltas, ModelExecuteOptions.createReconcile(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); // Check value in "quote attribute" @@ -326,11 +326,11 @@ public void test105ModifyAddNonTolerantAttribute() throws Exception { Collection> deltas = (Collection)MiscUtil.createCollection(userDelta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(deltas, ModelExecuteOptions.createReconcile(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertPartialError(result); } diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTriggerTask.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTriggerTask.java index afd9dbe083e..5146a7218fc 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTriggerTask.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTriggerTask.java @@ -94,7 +94,7 @@ public void test100ImportScannerTask() throws Exception { XMLGregorianCalendar startCal = clock.currentTimeXMLGregorianCalendar(); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); importObjectFromFile(TASK_TRIGGER_SCANNER_FILE); waitForTaskStart(TASK_TRIGGER_SCANNER_OID, false); @@ -126,7 +126,7 @@ public void test105NoTrigger() throws Exception { XMLGregorianCalendar startCal = clock.currentTimeXMLGregorianCalendar(); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true); // THEN @@ -157,7 +157,7 @@ public void test110TriggerCalledAgain() throws Exception { addTrigger(USER_JACK_OID, startCal, MockTriggerHandler.HANDLER_URI); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true); // THEN @@ -190,7 +190,7 @@ public void test120TwoTriggers() throws Exception { addTriggers(USER_JACK_OID, Arrays.asList(startCal, startCalPlus5ms), MockTriggerHandler.HANDLER_URI, false); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true); // THEN @@ -223,7 +223,7 @@ public void test130TwoTriggersSame() throws Exception { addTriggers(USER_JACK_OID, Arrays.asList(startCal, startCal), MockTriggerHandler.HANDLER_URI, true); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true); // THEN @@ -256,7 +256,7 @@ public void test135TwoTriggersSamePlusOne() throws Exception { addTriggers(USER_JACK_OID, Arrays.asList(startCal, startCal, startCalPlus5ms), MockTriggerHandler.HANDLER_URI, true); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true); // THEN @@ -287,7 +287,7 @@ public void test140TwoTriggersSameAggregable() throws Exception { addTriggers(USER_JACK_OID, Arrays.asList(startCal, startCal), MockMultipleTriggersHandler.HANDLER_URI, true); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true); // THEN @@ -322,7 +322,7 @@ public void test145TwoTriggersSamePlusOneAggregable() throws Exception { true); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true); // THEN @@ -358,7 +358,7 @@ public void test147TwoTriggersIdempotent() throws Exception { addTriggers(USER_JACK_OID, Arrays.asList(startCal, startCalPlus5ms), MockTriggerHandler.HANDLER_URI, false); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true); // THEN @@ -391,7 +391,7 @@ public void test150NoTriggerAgain() throws Exception { XMLGregorianCalendar startCal = clock.currentTimeXMLGregorianCalendar(); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true); // THEN @@ -426,7 +426,7 @@ public void test160TwoTriggersFirstFails() throws Exception { testTriggerHandler.setFailOnNextInvocation(true); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForTaskNextRun(TASK_TRIGGER_SCANNER_OID, true, 10000); // THEN @@ -482,7 +482,7 @@ public void test200TwoDistantTriggers() throws Exception { addTriggers(USER_JACK_OID, Arrays.asList(startCal, startCalPlus5days), MockTriggerHandler.HANDLER_URI, false); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true); // THEN @@ -528,7 +528,7 @@ public void test210InterruptedScanner() throws Exception { taskManager.resumeTasks(singleton(TASK_TRIGGER_SCANNER_OID), result); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); IntegrationTestTools.waitFor("Waiting for trigger handler invocation", () -> testTriggerHandler.getInvocationCount() > 0, 60000); suspended = taskManager.suspendTasks(singleton(TASK_TRIGGER_SCANNER_OID), 20000L, result); assertTrue("trigger scanner task was not suspended (after operation)", suspended); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplate.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplate.java index 2e6cb54c5d8..12af5910198 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplate.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplate.java @@ -131,11 +131,13 @@ public void test000Sanity() throws Exception { OperationResult result = getResult(); // WHEN - displayWhen(); - PrismObject systemConfiguration = modelService.getObject(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), + when(); + PrismObject systemConfiguration = modelService.getObject( + SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), null, task, result); // THEN + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -220,11 +222,11 @@ public void test101ModifyUserEmployeeTypePirate() throws Exception { deltas.add(userDelta); // WHEN - displayWhen(); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -979,11 +981,11 @@ public void test162ModifyUserGivenNameAgainPhantomChange() throws Exception { deltas.add(userDelta); // WHEN - displayWhen(); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userJack = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result); @@ -1058,11 +1060,11 @@ public void test170ModifyUserGuybrushEmployeeTypeThief() throws Exception { assertAssignedNoRole(userBefore); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_SUBTYPE, task, result, "THIEF"); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = modelService.getObject(UserType.class, USER_GUYBRUSH_OID, null, task, result); @@ -1086,12 +1088,12 @@ public void test172ModifyUserGuybrushHonorificPrefix() throws Exception { assertAssignedNoRole(userBefore); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_HONORIFIC_PREFIX, task, result, PrismTestUtil.createPolyString("Thf.")); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = modelService.getObject(UserType.class, USER_GUYBRUSH_OID, null, task, result); @@ -1116,11 +1118,11 @@ public void test174ModifyUserGuybrushHonorificPrefixNone() throws Exception { assertAssignedRole(userBefore, ROLE_THIEF_OID); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_HONORIFIC_PREFIX, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = modelService.getObject(UserType.class, USER_GUYBRUSH_OID, null, task, result); @@ -1146,11 +1148,11 @@ public void test180ModifyUserGuybrushEmployeeTypeMarooned() throws Exception { assertAssignedNoRole(userBefore); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_SUBTYPE, task, result, SUBTYPE_MAROONED); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = modelService.getObject(UserType.class, USER_GUYBRUSH_OID, null, task, result); @@ -1175,11 +1177,11 @@ public void test184ModifyUserGuybrushEmployeeTypeNone() throws Exception { assertAssignedNoRole(userBefore); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_SUBTYPE, task, result); // THEN - displayThen(); + then(); assertSuccess(result); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_COST_CENTER, task, result, "S321"); @@ -1207,11 +1209,11 @@ public void test185ModifyUserGuybrushSubtypeMarooned() throws Exception { assertAssignedNoRole(userBefore); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_SUBTYPE, task, result, SUBTYPE_MAROONED); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = modelService.getObject(UserType.class, USER_GUYBRUSH_OID, null, task, result); @@ -1233,11 +1235,11 @@ public void test189ModifyUserGuybrushSubtypeNone() throws Exception { assertAssignedNoRole(userBefore); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_SUBTYPE, task, result); // THEN - displayThen(); + then(); assertSuccess(result); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_COST_CENTER, task, result, "S321"); @@ -1268,11 +1270,11 @@ public void test190ModifyUserGuybrushOrganizationWhateveric() throws Exception { assertAssignments(userBefore, 1); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_ORGANIZATION, task, result, createPolyString("Whateveric")); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = modelService.getObject(UserType.class, USER_GUYBRUSH_OID, null, task, result); @@ -1298,11 +1300,11 @@ public void test191ModifyUserGuybrushOrganizationAutomatic() throws Exception { assertAssignedNoRole(userBefore); // WHEN - displayWhen(); + when(); modifyUserAdd(USER_GUYBRUSH_OID, UserType.F_ORGANIZATION, task, result, createPolyString("AUTO-matic")); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1334,7 +1336,7 @@ public void test192ModifyUserGuybrushOrganizationAddMixed() throws Exception { assertAssignments(userBefore, 2); // WHEN - displayWhen(); + when(); modifyUserAdd(USER_GUYBRUSH_OID, UserType.F_ORGANIZATION, task, result, createPolyString("DEMO-cratic"), createPolyString("AUTO-cratic"), @@ -1343,7 +1345,7 @@ public void test192ModifyUserGuybrushOrganizationAddMixed() throws Exception { ); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1382,14 +1384,14 @@ public void test193ModifyUserGuybrushOrganizationAddOutOfDomain() throws Excepti assertAssignments(userBefore, 4); // WHEN - displayWhen(); + when(); modifyUserAdd(USER_GUYBRUSH_OID, UserType.F_ORGANIZATION, task, result, createPolyString("meritocratic"), createPolyString("piratocratic") ); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1430,7 +1432,7 @@ public void test194ModifyUserGuybrushOrganizationDeleteMixed() throws Exception assertAssignments(userBefore, 4); // WHEN - displayWhen(); + when(); modifyUserDelete(USER_GUYBRUSH_OID, UserType.F_ORGANIZATION, task, result, createPolyString("AUTO-matic"), createPolyString("plutocratic"), @@ -1439,7 +1441,7 @@ public void test194ModifyUserGuybrushOrganizationDeleteMixed() throws Exception ); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1474,14 +1476,14 @@ public void test195ModifyUserGuybrushOrganizationDeleteOutOfDomain() throws Exce assertAssignments(userBefore, 2); // WHEN - displayWhen(); + when(); modifyUserDelete(USER_GUYBRUSH_OID, UserType.F_ORGANIZATION, task, result, createPolyString("piratocratic"), createPolyString("DEMO-cratic") ); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1515,11 +1517,11 @@ public void test196GuybrushAssignCaptain() throws Exception { assertAssignments(userBefore, 2); // WHEN - displayWhen(); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_CAPTAIN_OID, task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1550,11 +1552,11 @@ public void test197ModifyGuybrushEmployeeTypePirate() throws Exception { OperationResult result = getResult(); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_SUBTYPE, task, result, "PIRATE"); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1590,14 +1592,14 @@ public void test198AModifyUserGuybrushOrganizationAddInDomain() throws Exception assertAssignments(userBefore, 4); // WHEN - displayWhen(); + when(); modifyUserAdd(USER_GUYBRUSH_OID, UserType.F_ORGANIZATION, task, result, createPolyString("AUTO-graphic"), createPolyString("AUTO-matic") ); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1637,14 +1639,14 @@ public void test198BModifyUserGuybrushOrganizationDeleteMixed() throws Exception assertAssignments(userBefore, 6); // WHEN - displayWhen(); + when(); modifyUserDelete(USER_GUYBRUSH_OID, UserType.F_ORGANIZATION, task, result, createPolyString("AUTO-cratic"), createPolyString("Whateveric") ); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1680,11 +1682,11 @@ public void test199AGuyBrushModifyEmployeeTypeWannabe() throws Exception { assertAssignments(userBefore, 5); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_SUBTYPE, task, result, "wannabe"); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1719,11 +1721,11 @@ public void test199BGuyBrushUnassignCaptain() throws Exception { assertAssignments(userBefore, 4); // WHEN - displayWhen(); + when(); unassignRole(USER_GUYBRUSH_OID, ROLE_CAPTAIN_OID, task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1756,11 +1758,11 @@ public void test199CModifyUserGuybrushOrganizationCleanup() throws Exception { display("User before", userBefore); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_ORGANIZATION, task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2382,11 +2384,11 @@ public void test300ImportStanFromEmeraldResource() throws Exception { display("Shadow before", shadowBefore); // WHEN - displayWhen(); + when(); modelService.importFromResource(shadowBefore.getOid(), task, result); // THEN - displayThen(); + then(); result.computeStatus(); display(result); TestUtil.assertSuccess(result); @@ -2421,11 +2423,11 @@ public void test302ModifyStanAccountAndReimport() throws Exception { display("Shadow before", shadowBefore); // WHEN - displayWhen(); + when(); modelService.importFromResource(shadowBefore.getOid(), task, result); // THEN - displayThen(); + then(); result.computeStatus(); display(result); TestUtil.assertSuccess(result); @@ -3490,11 +3492,11 @@ public void test970ModifyUserGuybrushEmployeeTypeUseless() throws Exception { assertAssignedNoRole(userBefore); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_SUBTYPE, task, result, SUBTYPE_USELESS); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = modelService.getObject(UserType.class, USER_GUYBRUSH_OID, null, task, result); @@ -3523,14 +3525,14 @@ public void test980DeleteUserGivenName() throws Exception { repositoryService.addObject(user.asPrismObject(), null, result); // WHEN - displayWhen(); + when(); ObjectDelta delta = prismContext.deltaFor(UserType.class) .item(UserType.F_GIVEN_NAME).delete(new PolyString("jim")) .asObjectDeltaCast(user.getOid()); executeChanges(delta, null, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = modelService.getObject(UserType.class, user.getOid(), null, task, result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplateWithRanges.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplateWithRanges.java index f02cbc1b174..f277164d543 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplateWithRanges.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplateWithRanges.java @@ -364,7 +364,7 @@ public void test300GuybrushBloodyNose() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges( deltaFor(UserType.class) .item(UserType.F_TITLE).add(PolyString.fromOrig(ROLE_BLOODY_NOSE_NAME)) @@ -372,7 +372,7 @@ public void test300GuybrushBloodyNose() throws Exception { null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_GUYBRUSH_OID) @@ -395,7 +395,7 @@ public void test309GuybrushNotBloody() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges( deltaFor(UserType.class) .item(UserType.F_TITLE).delete(PolyString.fromOrig(ROLE_BLOODY_NOSE_NAME)) @@ -403,7 +403,7 @@ public void test309GuybrushNotBloody() throws Exception { null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_GUYBRUSH_OID) @@ -425,7 +425,7 @@ public void test310GuybrushBloodyNoseFuneral() throws Exception { GUYBRUSH_FUNERAL_DATE_123456_CAL); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges( deltaFor(UserType.class) .item(UserType.F_TITLE).add(PolyString.fromOrig(ROLE_BLOODY_NOSE_NAME)) @@ -433,7 +433,7 @@ public void test310GuybrushBloodyNoseFuneral() throws Exception { null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_GUYBRUSH_OID) @@ -456,7 +456,7 @@ public void test319GuybrushNoBloodyNoseFuneral() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges( deltaFor(UserType.class) .item(UserType.F_TITLE).delete(PolyString.fromOrig(ROLE_BLOODY_NOSE_NAME)) @@ -464,7 +464,7 @@ public void test319GuybrushNoBloodyNoseFuneral() throws Exception { null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_GUYBRUSH_OID) @@ -486,7 +486,7 @@ public void test320GuybrushBloodyNose() throws Exception { /* no value */); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges( deltaFor(UserType.class) .item(UserType.F_TITLE).add(PolyString.fromOrig(ROLE_BLOODY_NOSE_NAME)) @@ -494,7 +494,7 @@ public void test320GuybrushBloodyNose() throws Exception { null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_GUYBRUSH_OID) @@ -517,12 +517,12 @@ public void test322GuybrushSetFuneral() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_GUYBRUSH_OID, getExtensionPath(PIRACY_FUNERAL_TIMESTAMP), task, result, GUYBRUSH_FUNERAL_DATE_123456_CAL); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_GUYBRUSH_OID) @@ -545,12 +545,12 @@ public void test324GuybrushSetFuneral22222() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_GUYBRUSH_OID, getExtensionPath(PIRACY_FUNERAL_TIMESTAMP), task, result, GUYBRUSH_FUNERAL_DATE_22222_CAL); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_GUYBRUSH_OID) @@ -575,12 +575,12 @@ public void test326GuybrushNoFuneral() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_GUYBRUSH_OID, getExtensionPath(PIRACY_FUNERAL_TIMESTAMP), task, result /* no value */); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_GUYBRUSH_OID) @@ -602,7 +602,7 @@ public void test329GuybrushNoBloodyNose() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges( deltaFor(UserType.class) .item(UserType.F_TITLE).delete(PolyString.fromOrig(ROLE_BLOODY_NOSE_NAME)) @@ -610,7 +610,7 @@ public void test329GuybrushNoBloodyNose() throws Exception { null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_GUYBRUSH_OID) diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestVolatility.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestVolatility.java index 35b017df9ce..694125b76e9 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestVolatility.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestVolatility.java @@ -100,7 +100,7 @@ public void test100ImportLiveSyncTaskDummyHr() throws Exception { OperationResult result = task.getResult(); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); importSyncTask(); // THEN @@ -127,7 +127,7 @@ public void test110AddDummyHrAccountMancomb() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Mancomb Seepgood"); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); getDummyResource(RESOURCE_DUMMY_HR_NAME).addAccount(account); @@ -185,7 +185,7 @@ public void test120UpdateDummyHrAccountMancomb() throws Exception { OperationResult result = task.getResult(); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); DummyAccount account = getDummyResource(RESOURCE_DUMMY_HR_NAME).getAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME); account.replaceAttributeValue(DummyAccount.ATTR_FULLNAME_NAME, "Sir Mancomb Seepgood"); @@ -254,7 +254,7 @@ public void test200ModifyGuybrushAssignAccount() throws Exception { // Preconditions //assertUsers(5); - TestUtil.displayWhen(TEST_NAME); + when(); Collection> deltas = new ArrayList<>(); ObjectDelta accountAssignmentUserDelta = createAccountAssignmentUserDelta(USER_GUYBRUSH_OID, RESOURCE_DUMMY_VOLATILE_OID, null, true); @@ -308,7 +308,7 @@ public void test300AddLargo() throws Exception { // Preconditions //assertUsers(5); - TestUtil.displayWhen(TEST_NAME); + when(); PrismObject user = PrismTestUtil.parseObject(USER_LARGO_WITH_ASSIGNMENT_FILE); ObjectDelta userDelta = DeltaFactory.Object.createAddDelta(user); Collection> deltas = MiscSchemaUtil.createCollection(userDelta); @@ -370,7 +370,7 @@ public void test400AddHerman() throws Exception { display("User before", userBefore); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); addObject(userBefore, task, result); // THEN @@ -405,7 +405,7 @@ public void test402ModifyHermanMonster() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyUserAdd(USER_HERMAN_OID, UserType.F_ORGANIZATION, task, result, createPolyString(DummyResource.VALUE_MONSTER)); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestArchetypes.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestArchetypes.java index f13441a432d..03a87443c3f 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestArchetypes.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestArchetypes.java @@ -145,11 +145,11 @@ public void test050AddArchetypeTest() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(ARCHETYPE_TEST_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject archetypeTest = modelService.getObject(ArchetypeType.class, ARCHETYPE_TEST_OID, null, task, result); @@ -164,13 +164,13 @@ public void test060AddArchetypesAndRoles() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(ARCHETYPE_BUSINESS_ROLE_FILE, task, result); addObject(ROLE_BUSINESS_CAPTAIN_FILE, task, result); addObject(ROLE_BUSINESS_BOSUN_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject roleBusinessCaptainAfter = assertRoleAfter(ROLE_BUSINESS_CAPTAIN_OID) @@ -203,11 +203,11 @@ public void test070AssignGuybrushUserAdministrator() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_GUYBRUSH_OID, ROLE_USER_ADMINISTRATOR_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); // TODO: assert guybrush @@ -222,12 +222,12 @@ public void test100AssignJackArchetypeEmployee() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignArchetype(USER_JACK_OID, ARCHETYPE_EMPLOYEE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = assertUserAfter(USER_JACK_OID) @@ -269,12 +269,12 @@ public void test102SearchEmployeeArchetypeRef() throws Exception { .build(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); SearchResultList> searchResults = modelService.searchObjects(UserType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("Search results", searchResults); assertEquals("Wrong number of search results", 1, searchResults.size()); @@ -369,12 +369,12 @@ public void test109UnassignJackArchetypeEmployee() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignArchetype(USER_JACK_OID, ARCHETYPE_EMPLOYEE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = assertUserAfter(USER_JACK_OID) @@ -401,12 +401,12 @@ public void test110AssignJackRoleEmployeeBase() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_EMPLOYEE_BASE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = assertUserAfter(USER_JACK_OID) @@ -456,12 +456,12 @@ public void test115UnassignJackRoleEmployeeBase() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, ROLE_EMPLOYEE_BASE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = assertUserAfter(USER_JACK_OID) @@ -499,12 +499,12 @@ public void test120AssignJackArchetypeTest() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignArchetype(USER_JACK_OID, ARCHETYPE_TEST_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -534,12 +534,12 @@ public void test129UnassignJackArchetypeTest() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignArchetype(USER_JACK_OID, ARCHETYPE_TEST_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -565,12 +565,12 @@ public void test130AssignJackArchetypeContractor() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignArchetype(USER_JACK_OID, ARCHETYPE_CONTRACTOR_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -597,12 +597,12 @@ public void test132JackContractorRecompute() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -630,12 +630,12 @@ public void test135UnassignJackArchetypeContractor() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignArchetype(USER_JACK_OID, ARCHETYPE_CONTRACTOR_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -666,12 +666,12 @@ public void test137JackEmpnoAndRecompute() throws Exception { modifyUserReplace(USER_JACK_OID, UserType.F_EMPLOYEE_NUMBER, task, result, "Number ONE"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -700,12 +700,12 @@ public void test140AddMeathookContractor() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(USER_MEATHOOK_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_MEATHOOK_OID) @@ -734,12 +734,12 @@ public void test150AddWannabe() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(USER_WANNABE_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_WANNABE_OID) @@ -769,12 +769,12 @@ public void test160AddSelfMadeMan() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(USER_SELF_MADE_MAN_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_SELF_MADE_MAN_OID) @@ -806,7 +806,7 @@ public void test162AddFraudster() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(USER_FRAUDSTER_FILE, task, result); @@ -817,7 +817,7 @@ public void test162AddFraudster() throws Exception { } // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertFailure(result); assertNoObject(UserType.class, USER_FRAUDSTER_OID); @@ -831,13 +831,13 @@ public void test200AssignJackBarbossaArchetypeEmployee() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignArchetype(USER_JACK_OID, ARCHETYPE_EMPLOYEE_OID, task, result); assignArchetype(USER_BARBOSSA_OID, ARCHETYPE_EMPLOYEE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -892,12 +892,12 @@ public void test203DisableBarbossa() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_BARBOSSA_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.DISABLED); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -952,7 +952,7 @@ public void test300jackAssignArchetypeRaw() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); try { assignArchetype(USER_JACK_OID, ARCHETYPE_CONTRACTOR_OID, task, result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestCollections.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestCollections.java index ef8c8e23a5f..83e52c98dd2 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestCollections.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestCollections.java @@ -70,11 +70,11 @@ public void test000Sanity() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); collectionActiveUsers = modelService.getObject(ObjectCollectionType.class, COLLECTION_ACTIVE_USERS_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Collection", collectionActiveUsers); assertSuccess(result); assertNotNull("No collection", collectionActiveUsers); @@ -89,11 +89,11 @@ public void test100CompileCollectionView() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); collectionViewActiveUsers = modelInteractionService.compileObjectCollectionView(collectionActiveUsers, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Active users collection view", collectionViewActiveUsers); assertSuccess(result); assertNotNull("Null view", collectionActiveUsers); @@ -116,11 +116,11 @@ public void test102SearchCollectionUsers() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); SearchResultList> users = modelService.searchObjects(UserType.class, prismContext.queryFactory().createQuery(collectionViewActiveUsers.getFilter()), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Users in collection", users); assertSuccess(result); assertEquals("Wrong number of users in collection", getNumberOfUsers(), users.size()); @@ -135,11 +135,11 @@ public void test110CollectionStatsAllEnabled() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); CollectionStats stats = modelInteractionService.determineCollectionStats(collectionViewActiveUsers, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Collection stats", stats); assertSuccess(result); assertNotNull("Null stats", stats); @@ -158,11 +158,11 @@ public void test112EvaluateRulesAllEnabled() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); Collection evaluatedRules = modelInteractionService.evaluateCollectionPolicyRules(collectionActiveUsers, collectionViewActiveUsers, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertEvaluatedPolicyRules(evaluatedRules, collectionActiveUsers) @@ -182,11 +182,11 @@ public void test120CollectionStatsOneDisabled() throws Exception { numberOfDisabledUsers++; // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); CollectionStats stats = modelInteractionService.determineCollectionStats(collectionViewActiveUsers, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Collection stats", stats); assertSuccess(result); assertNotNull("Null stats", stats); @@ -205,11 +205,11 @@ public void test122EvaluateRulesOneDisabled() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); Collection evaluatedRules = modelInteractionService.evaluateCollectionPolicyRules(collectionActiveUsers, collectionViewActiveUsers, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertEvaluatedPolicyRules(evaluatedRules, collectionActiveUsers) diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateTaskMechanics.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateTaskMechanics.java index d7ab4d81d5b..1b73e8579a3 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateTaskMechanics.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateTaskMechanics.java @@ -94,10 +94,10 @@ public void test100SmallTaskNoWorkers() throws IOException, TimeoutException, Co prepareMessages(CHANGE_USER_ADD_FILE, "100-", 10, true); - displayWhen(); + when(); importObjectFromFile(TASK_ASYNC_UPDATE_HR_NO_WORKERS.file, result); - displayThen(); + then(); waitForTaskFinish(TASK_ASYNC_UPDATE_HR_NO_WORKERS.oid, false, 30000); PrismObject taskAfter = getTask(TASK_ASYNC_UPDATE_HR_NO_WORKERS.oid); @@ -119,10 +119,10 @@ public void test110SmallTaskOneWorker() throws IOException, TimeoutException, Co prepareMessages(CHANGE_USER_ADD_FILE, "110-", 10, true); - displayWhen(); + when(); importObjectFromFile(TASK_ASYNC_UPDATE_HR_ONE_WORKER.file, result); - displayThen(); + then(); waitForTaskFinish(TASK_ASYNC_UPDATE_HR_ONE_WORKER.oid, false, 30000); PrismObject taskAfter = getTask(TASK_ASYNC_UPDATE_HR_ONE_WORKER.oid); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestEditSchema.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestEditSchema.java index c49c370a2e5..b5e8d21e604 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestEditSchema.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestEditSchema.java @@ -103,11 +103,11 @@ public void test100LookupLanguagesGet() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -133,11 +133,11 @@ public void test102LookupLanguagesGetExclude() throws Exception { .build(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, options, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -159,11 +159,11 @@ public void test110LookupLanguagesGetAll() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); checkLookupResult(lookup, new String[]{"en_US", "en", "English (US)"}, @@ -181,7 +181,7 @@ public void test120LookupLanguagesGetByKeyExact() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() .item(LookupTableType.F_ROW) @@ -192,7 +192,7 @@ public void test120LookupLanguagesGetByKeyExact() throws Exception { PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); checkLookupResult(lookup, new String[] { "sk_SK", "sk", "Slovak" }); @@ -207,7 +207,7 @@ public void test121LookupLanguagesGetByKeyStartingWith() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() .item(LookupTableType.F_ROW) @@ -218,7 +218,7 @@ public void test121LookupLanguagesGetByKeyStartingWith() throws Exception { PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); checkLookupResult(lookup, new String[]{"en_US", "en", "English (US)"}, @@ -234,7 +234,7 @@ public void test122LookupLanguagesGetByKeyContaining() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() .item(LookupTableType.F_ROW) @@ -245,7 +245,7 @@ public void test122LookupLanguagesGetByKeyContaining() throws Exception { PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); checkLookupResult(lookup, new String[]{"tr_TR", "tr", "Turkish"}); @@ -260,7 +260,7 @@ public void test123LookupLanguagesGetByKeyContainingWithPaging() throws Exceptio OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() .item(LookupTableType.F_ROW) @@ -274,7 +274,7 @@ public void test123LookupLanguagesGetByKeyContainingWithPaging() throws Exceptio PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); checkLookupResult(lookup, new String[] { "sk_SK", "sk", "Slovak" }); @@ -289,7 +289,7 @@ public void test124LookupLanguagesGetByKeyContainingReturningNothing() throws Ex OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() .item(LookupTableType.F_ROW) @@ -300,7 +300,7 @@ public void test124LookupLanguagesGetByKeyContainingReturningNothing() throws Ex PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); IntegrationTestTools.display("Languages", lookup); @@ -322,7 +322,7 @@ public void test130LookupLanguagesGetByValueExact() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() .item(LookupTableType.F_ROW) @@ -333,7 +333,7 @@ public void test130LookupLanguagesGetByValueExact() throws Exception { PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); checkLookupResult(lookup, new String[] { "sk_SK", "sk", "Slovak" }); @@ -352,7 +352,7 @@ public void test131LookupLanguagesGetByLabelStartingWith() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); String fragment = "Eng"; GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() @@ -364,7 +364,7 @@ public void test131LookupLanguagesGetByLabelStartingWith() throws Exception { PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); checkLookupResult(lookup, new String[]{"en_US", "en", "English (US)"}, @@ -380,7 +380,7 @@ public void test133LookupLanguagesGetByValueContainingWithPaging() throws Except OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() .item(LookupTableType.F_ROW) @@ -394,7 +394,7 @@ public void test133LookupLanguagesGetByValueContainingWithPaging() throws Except PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); checkLookupResult(lookup, new String[] { "en_US", "en", "English (US)" }); @@ -412,7 +412,7 @@ public void test140LookupLanguagesGetByIdExisting() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); Collection> options = SelectorOptions.createCollection( prismContext.path(LookupTableType.F_ROW, 1L), @@ -420,7 +420,7 @@ public void test140LookupLanguagesGetByIdExisting() throws Exception { PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, options, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); checkLookupResult(lookup, new String[] { "en_US", "en", "English (US)" }); @@ -459,11 +459,11 @@ public void test150LookupLanguagesAddRowFull() throws Exception { LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -505,11 +505,11 @@ public void test152LookupLanguagesAddRowKeyLabel() throws Exception { LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -552,11 +552,11 @@ public void test154LookupLanguagesAddRowKeyValue() throws Exception { LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -601,7 +601,7 @@ public void test156LookupLanguagesAddRowExistingKey() throws Exception { LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); boolean exception = false; try { modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); @@ -611,7 +611,7 @@ public void test156LookupLanguagesAddRowExistingKey() throws Exception { AssertJUnit.assertFalse(exception); // as per description in https://wiki.evolveum.com/display/midPoint/Development+with+LookupTable // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -661,11 +661,11 @@ public void test162LookupLanguagesDeleteRowFullNoId() throws Exception { LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -709,11 +709,11 @@ public void test164LookupLanguagesDeleteRowFullId() throws Exception { LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(delta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); @@ -751,11 +751,11 @@ public void test166LookupLanguagesDeleteRowIdOnly() throws Exception { LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(delta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); @@ -792,11 +792,11 @@ public void test168LookupLanguagesDeleteRowByKey() throws Exception { LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); @@ -845,11 +845,11 @@ public void test170LookupLanguagesReplaceRows() throws Exception { LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row1, row2, row3); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -885,13 +885,13 @@ public void test180LookupLanguagesReplaceObject() throws Exception { ObjectDelta delta = DeltaFactory.Object.createAddDelta(replacement); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ModelExecuteOptions options = ModelExecuteOptions.createOverwrite(); options.setRaw(true); modelService.executeChanges(MiscSchemaUtil.createCollection(delta), options, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -925,11 +925,11 @@ public void test182LookupLanguagesReimport() throws Exception { options.setKeepOid(true); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.importObjectsFromFile(LOOKUP_LANGUAGES_FILE, options, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -986,11 +986,11 @@ public void test200EditSchemaUser() throws Exception { PrismObject user = userDef.instantiate(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObjectDefinition editDef = getEditObjectDefinition(user); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismAsserts.assertEmphasized(editDef, UserType.F_NAME, true); @@ -1060,11 +1060,11 @@ public void test210UserDefinition() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject user = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1130,11 +1130,11 @@ public void test213ModifiedUserJack() throws Exception { modifyObjectReplaceProperty(UserType.class, USER_JACK_OID, UserType.F_PREFERRED_LANGUAGE, task, result, "en_PR"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject user = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertPropertyValues(user, UserType.F_ADDITIONAL_NAME, (propDef, name) -> { @@ -1189,11 +1189,11 @@ public void test250EditSchemaRole() throws Exception { PrismObject role = roleDef.instantiate(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObjectDefinition editDef = getEditObjectDefinition(role); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); // TODO PrismPropertyDefinition requestableDef = editDef.findPropertyDefinition(RoleType.F_REQUESTABLE); @@ -1214,11 +1214,11 @@ public void test260EditShadowSchemaKindIntent() throws Exception { ResourceShadowDiscriminator discr = new ResourceShadowDiscriminator(RESOURCE_DUMMY_OID, ShadowKindType.ACCOUNT, null, null, false); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObjectDefinition editDef = modelInteractionService.getEditShadowDefinition(discr, AuthorizationPhaseType.REQUEST, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismPropertyDefinition nameDef = editDef.findPropertyDefinition(ShadowType.F_NAME); @@ -1256,11 +1256,11 @@ public void test261EditShadowSchemaObjectclass() throws Exception { IntegrationTestTools.display("Discr", discr); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObjectDefinition editDef = modelInteractionService.getEditShadowDefinition(discr, AuthorizationPhaseType.REQUEST, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismPropertyDefinition nameDef = editDef.findPropertyDefinition(ShadowType.F_NAME); @@ -1288,11 +1288,11 @@ public void test263EditShadowSchemaEmpty() throws Exception { IntegrationTestTools.display("Discr", discr); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObjectDefinition editDef = modelInteractionService.getEditShadowDefinition(discr, AuthorizationPhaseType.REQUEST, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismPropertyDefinition nameDef = editDef.findPropertyDefinition(ShadowType.F_NAME); @@ -1315,11 +1315,11 @@ public void test265EditShadowSchemaNull() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObjectDefinition editDef = modelInteractionService.getEditShadowDefinition(null, AuthorizationPhaseType.REQUEST, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismPropertyDefinition nameDef = editDef.findPropertyDefinition(ShadowType.F_NAME); @@ -1344,11 +1344,11 @@ public void test310CustomRelations() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); List relations = modelInteractionService.getRelationDefinitions(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Relations", relations); assertRelationDef(relations, SchemaConstants.ORG_MANAGER, "RelationTypes.manager"); assertRelationDef(relations, SchemaConstants.ORG_OWNER, "Master"); @@ -1374,12 +1374,12 @@ public void test800OtisEditSchemaUser() throws Exception { PrismObject user = userDef.instantiate(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObjectDefinition editDef = getEditObjectDefinition(user); display("Otis edit schema", editDef); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismPropertyDefinition nameDef = editDef.findPropertyDefinition(UserType.F_NAME); assertNotNull("No definition for name in user", nameDef); @@ -1440,11 +1440,11 @@ public void test810OtisGetJack() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject user = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1523,11 +1523,11 @@ public void test820OtisSearchUsers() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); SearchResultList> users = modelService.searchObjects(UserType.class, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestRoleEntitlement.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestRoleEntitlement.java index 528582eb342..ab0cc9f4cd2 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestRoleEntitlement.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestRoleEntitlement.java @@ -386,7 +386,7 @@ public void test119ModifyRoleDeleteEntitlement() throws Exception { prepareNotifications(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN @@ -437,11 +437,11 @@ public void test120AddEntitlement() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); Collection> executedChanges = executeChanges(groupDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); @@ -493,11 +493,11 @@ public void test121ModifyRoleLinkEntitlement() throws Exception { roleDelta.addModification(linkDelta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(roleDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject role = getRole(ROLE_PIRATE_OID); @@ -635,11 +635,11 @@ public void test131ModifyRoleAssignEntitlement() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(assignmentDelta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess("executeChanges result", result); PrismObject role = getRole(ROLE_PIRATE_OID); @@ -1153,11 +1153,11 @@ public void test200AddRoleSwashbuckler() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(roleDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); @@ -1217,11 +1217,11 @@ public void test210ModifyRoleSwashbucklerRiskLevel() throws Exception { .assertItems(PIRACY_COST_CENTER); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyObjectReplaceProperty(RoleType.class, ROLE_SWASHBUCKLER_OID, RoleType.F_RISK_LEVEL, task, result, "99"); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertRoleAfter(ROLE_SWASHBUCKLER_OID) diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractDirectManualResourceTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractDirectManualResourceTest.java index 29084ee3047..f381bcdffc4 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractDirectManualResourceTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractDirectManualResourceTest.java @@ -132,11 +132,11 @@ public void test220ModifyUserWillDisable() throws Exception { accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(userWillOid, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.DISABLED); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("result", result); willLastCaseOid = assertInProgress(result); @@ -217,11 +217,11 @@ public void test230ModifyAccountWillChangePasswordAndEnable() throws Exception { accountWillSecondReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(delta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("result", result); willSecondLastCaseOid = assertInProgress(result); @@ -299,12 +299,12 @@ public void test240CloseDisableCaseAndReadAccountWill() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject shadowModel = modelService.getObject(ShadowType.class, accountWillOid, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); accountWillCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -390,11 +390,11 @@ public void test250RecomputeWillAfter5min() throws Exception { display("Shadow before", shadowBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject shadowRepo = repositoryService.getObject(ShadowType.class, accountWillOid, null, result); @@ -474,12 +474,12 @@ public void test252UpdateBackingStoreAndGetAccountWill() throws Exception { backingStoreUpdateWill(USER_WILL_FULL_NAME_PIRATE, INTEREST_ONE, ActivationStatusType.DISABLED, USER_WILL_PASSWORD_OLD); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject shadowModel = modelService.getObject(ShadowType.class, accountWillOid, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("Model shadow", shadowModel); @@ -534,11 +534,11 @@ public void test260ClosePasswordChangeCaseAndRecomputeWill() throws Exception { accountWillSecondCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); accountWillSecondCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -639,11 +639,11 @@ public void test270RecomputeWillAfter7min() throws Exception { display("Shadow before", shadowBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject shadowRepo = assertRepoShadow(accountWillOid) @@ -734,12 +734,12 @@ public void test272UpdateBackingStoreAndGetAccountWill() throws Exception { backingStoreUpdateWill(USER_WILL_FULL_NAME_PIRATE, INTEREST_ONE, ActivationStatusType.ENABLED, USER_WILL_PASSWORD_NEW); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject shadowModel = modelService.getObject(ShadowType.class, accountWillOid, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); ShadowAsserter.forShadow(shadowModel, "model") @@ -795,11 +795,11 @@ public void test274RecomputeWillAfter22min() throws Exception { display("Shadow before", shadowBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject shadowRepo = assertRepoShadow(accountWillOid) @@ -877,11 +877,11 @@ public void test280RecomputeWillAfter27min() throws Exception { clockForward("PT5M"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject shadowRepo = assertRepoShadow(accountWillOid) @@ -950,11 +950,11 @@ public void test290RecomputeWillAfter32min() throws Exception { clockForward("PT5M"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject shadowRepo = repositoryService.getObject(ShadowType.class, accountWillOid, null, result); @@ -1014,11 +1014,11 @@ public void test300UnassignAccountWill() throws Exception { accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(userWillOid, getRoleOneOid(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("result", result); willLastCaseOid = assertInProgress(result); @@ -1086,11 +1086,11 @@ public void test302RecomputeWill() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("result", result); assertSuccess(result); @@ -1160,12 +1160,12 @@ public void test310CloseCaseAndReconcileWill() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); // We need reconcile and not recompute here. We need to fetch the updated case status. reconcileUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("result", result); assertSuccess(result); @@ -1223,11 +1223,11 @@ public void test320RecomputeWillAfter5min() throws Exception { clockForward("PT5M"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); ShadowAsserter shadowRepoAsserter = assertRepoShadow(accountWillOid) @@ -1277,14 +1277,14 @@ public void test330UpdateBackingStoreAndRecomputeWill() throws Exception { displayBackingStore(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); // Reconcile is needed here. Recompute means noFetch which means that we won't // discover that an account is missing from backing store which means that the // quantum state won't collapse. reconcileUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); ShadowAsserter shadowRepoAsserter = assertRepoShadow(accountWillOid) @@ -1339,11 +1339,11 @@ public void test340RecomputeWillAfter25min() throws Exception { clockForward("PT20M"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(userWillOid) @@ -1380,11 +1380,11 @@ public void test342RecomputeWillAfter35min() throws Exception { clockForward("PT10M"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertRepoShadow(accountWillOid); @@ -1418,11 +1418,11 @@ public void test344RecomputeWillAfter165min() throws Exception { clockForward("PT130M"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); UserAsserter userAfterAsserter = assertUserAfter(userWillOid); @@ -1483,11 +1483,11 @@ public void test510UnassignWillRoleOne() throws Exception { accountWillSecondReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(userWillOid, getRoleOneOid(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("result", result); willSecondLastCaseOid = assertInProgress(result); @@ -1551,11 +1551,11 @@ public void test512ReconcileWill() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("result", result); assertSuccess(result); @@ -1626,12 +1626,12 @@ public void test515CloseCasesAndReconcileWill() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); // We need reconcile and not recompute here. We need to fetch the updated case status. reconcileUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("result", result); assertSuccess(result); @@ -1723,11 +1723,11 @@ public void test516RecomputeWillAfter20min() throws Exception { clockForward("PT20M"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(userWillOid) @@ -1757,11 +1757,11 @@ public void test517RecomputeWillAfter50min() throws Exception { clockForward("PT15M"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertRepoShadow(accountWillOid); @@ -1793,11 +1793,11 @@ public void test518RecomputeWillAfter180min() throws Exception { clockForward("PT130M"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(userWillOid) @@ -1856,11 +1856,11 @@ public void test522AssignWillRoleTwoValidFrom() throws Exception { activationType.setValidFrom(roleTwoValidFromTimestamp); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(userWillOid, getRoleTwoOid(), activationType, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); accountWillOid = assertUserAfter(userWillOid) @@ -1890,11 +1890,11 @@ public void test524TwoHoursForRoleTwo() throws Exception { accountWillSecondReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("result", result); willSecondLastCaseOid = assertInProgress(result); @@ -1958,12 +1958,12 @@ public void test525CloseCasesAndReconcileWill() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); // We need reconcile and not recompute here. We need to fetch the updated case status. reconcileUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("result", result); assertSuccess(result); @@ -1994,12 +1994,12 @@ public void test526UnassignWillBothRoles() throws Exception { accountWillSecondReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignAll(userBefore, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("result", result); willLastCaseOid = assertInProgress(result); @@ -2053,12 +2053,12 @@ public void test528CloseCaseAndRecomputeWill() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); // We need reconcile and not recompute here. We need to fetch the updated case status. reconcileUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("result", result); assertSuccess(result); @@ -2128,11 +2128,11 @@ public void test800ImportShadowRefreshTask() throws Exception { // GIVEN // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addTask(TASK_SHADOW_REFRESH_FILE); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForTaskStart(TASK_SHADOW_REFRESH_OID, false); } @@ -2172,11 +2172,11 @@ public void test820AssignAccountJack() throws Exception { accountJackReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_JACK_OID, getResourceOid(), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("result", result); jackLastCaseOid = assertInProgress(result); @@ -2209,12 +2209,12 @@ public void test830CloseCaseWillAndWaitForRefresh() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); restartTask(TASK_SHADOW_REFRESH_OID); waitForTaskFinish(TASK_SHADOW_REFRESH_OID, false); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); accountWillCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -2234,11 +2234,11 @@ public void test840AddToBackingStoreAndGetAccountWill() throws Exception { backingStoreProvisionWill(INTEREST_ONE); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject shadowModel = modelService.getObject(ShadowType.class, accountWillOid, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); ShadowAsserter.forShadow(shadowModel, "model") diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractGroupingManualResourceTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractGroupingManualResourceTest.java index 8a36f9f1cf1..476c278df47 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractGroupingManualResourceTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractGroupingManualResourceTest.java @@ -170,11 +170,11 @@ public void test220ModifyUserWillDisable() throws Exception { accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(userWillOid, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.DISABLED); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("result", result); willLastCaseOid = assertInProgress(result); @@ -258,11 +258,11 @@ public void test230ModifyAccountWillChangePasswordAndEnable() throws Exception { accountWillSecondReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(delta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("result", result); assertInProgress(result); @@ -341,11 +341,11 @@ public void test232RunPropagationBeforeInterval() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); runPropagation(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertAccountWillAfterChangePasswordAndEnable(TEST_NAME); } @@ -366,11 +366,11 @@ public void test235RunPropagationAfterInterval() throws Exception { accountWillExecutionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); runPropagation(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); accountWillExecutionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -473,12 +473,12 @@ public void test240CloseCaseAndReadAccountWill() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject shadowModel = modelService.getObject(ShadowType.class, accountWillOid, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); accountWillCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -503,11 +503,11 @@ public void test250RecomputeWillAfter5min() throws Exception { display("Shadow before", shadowBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertAccountWillAfterChangePasswordAndEnableCaseClosed(TEST_NAME, null); @@ -530,12 +530,12 @@ public void test272UpdateBackingStoreAndGetAccountWill() throws Exception { backingStoreUpdateWill(USER_WILL_FULL_NAME_PIRATE, INTEREST_ONE, ActivationStatusType.ENABLED, USER_WILL_PASSWORD_NEW); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject shadowModel = modelService.getObject(ShadowType.class, accountWillOid, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); ShadowAsserter shadowModelAsserter = ShadowAsserter.forShadow(shadowModel, "model") @@ -585,12 +585,12 @@ public void test273GetAccountWill() throws Exception { clockForward("PT15M"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject shadowModel = modelService.getObject(ShadowType.class, accountWillOid, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); ShadowAsserter shadowModelAsserter = ShadowAsserter.forShadow(shadowModel, "model") @@ -639,11 +639,11 @@ public void test290RecomputeWillAfter15min() throws Exception { clockForward("PT15M"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject shadowRepo = repositoryService.getObject(ShadowType.class, accountWillOid, null, result); @@ -698,11 +698,11 @@ public void test300UnassignAccountWill() throws Exception { accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(userWillOid, getRoleOneOid(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("result", result); willLastCaseOid = assertInProgress(result); @@ -775,11 +775,11 @@ public void test302RunPropagationAfterInterval() throws Exception { accountWillExecutionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); runPropagation(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); accountWillExecutionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -850,12 +850,12 @@ public void test310CloseCaseAndRecomputeWill() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); // We need reconcile and not recompute here. We need to fetch the updated case status. reconcileUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("result", result); assertSuccess(result); @@ -900,11 +900,11 @@ public void test330UpdateBackingStoreAndRecomputeWill() throws Exception { displayBackingStore(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject shadowRepo = repositoryService.getObject(ShadowType.class, accountWillOid, null, result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractManualResourceTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractManualResourceTest.java index a705c75c300..98bdeda2fb2 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractManualResourceTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractManualResourceTest.java @@ -322,11 +322,11 @@ public void testConnection(final String TEST_NAME, boolean initialized) throws E } // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); OperationResult testResult = modelService.testResource(getResourceOid(), task); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Test result", testResult); TestUtil.assertSuccess("Test resource failed (result)", testResult); @@ -510,19 +510,19 @@ public void testResourceCaching(final String TEST_NAME) throws Exception { assertSteadyResources(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject resourceReadOnlyAgain = modelService.getObject( ResourceType.class, getResourceOid(), GetOperationOptions.createReadOnlyCollection(), task, result); assertSteadyResources(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject resourceAgain = modelService.getObject( ResourceType.class, getResourceOid(), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); // assertTrue("Resource instance changed", resourceBefore == resourceReadOnlyAgain); @@ -541,11 +541,11 @@ public void test020ReimportResource() throws Exception { options.setOverwrite(true); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.importObjectsFromFile(getResourceFile(), options, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); } @@ -581,11 +581,11 @@ public void test030ReimportResourceAgain() throws Exception { options.setOverwrite(true); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.importObjectsFromFile(getResourceFile(), options, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); } @@ -600,11 +600,11 @@ public void test032UseResource() throws Exception { ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(getResourceOid(), ShadowKindType.ACCOUNT, null, prismContext); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); SearchResultList> accounts = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("Found accounts", accounts); @@ -692,11 +692,11 @@ public void test101GetAccountWillFuture() throws Exception { Collection> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject shadowModel = modelService.getObject(ShadowType.class, accountWillOid, options, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("Model shadow", shadowModel); @@ -723,11 +723,11 @@ public void test102RecomputeWill() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertAccountWillAfterAssign(TEST_NAME, USER_WILL_FULL_NAME, PendingOperationExecutionStatusType.EXECUTION_PENDING); @@ -748,11 +748,11 @@ public void test103RunPropagation() throws Exception { clockForward("PT2M"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); runPropagation(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertCounterIncrement(InternalCounters.CONNECTOR_MODIFICATION_COUNT, 1); @@ -773,11 +773,11 @@ public void test104RecomputeWill() throws Exception { rememberCounter(InternalCounters.CONNECTOR_MODIFICATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertCounterIncrement(InternalCounters.CONNECTOR_MODIFICATION_COUNT, 0); @@ -798,11 +798,11 @@ public void test105RunPropagationAgain() throws Exception { rememberCounter(InternalCounters.CONNECTOR_MODIFICATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); runPropagation(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertCounterIncrement(InternalCounters.CONNECTOR_MODIFICATION_COUNT, 0); assertAccountWillAfterAssign(TEST_NAME, USER_WILL_FULL_NAME, PendingOperationExecutionStatusType.EXECUTING); @@ -825,11 +825,11 @@ public void test106AddToBackingStoreAndGetAccountWill() throws Exception { displayBackingStore(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject shadowModel = modelService.getObject(ShadowType.class, accountWillOid, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("Model shadow", shadowModel); @@ -868,11 +868,11 @@ public void test108GetAccountWillFuture() throws Exception { Collection> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject shadowModel = modelService.getObject(ShadowType.class, accountWillOid, options, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("Model shadow", shadowModel); @@ -917,12 +917,12 @@ public void test110CloseCaseAndRecomputeWill() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); // We need reconcile and not recompute here. We need to fetch the updated case status. reconcileUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); accountWillCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -944,11 +944,11 @@ public void test114RunPropagation() throws Exception { rememberCounter(InternalCounters.CONNECTOR_MODIFICATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); runPropagation(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertCounterIncrement(InternalCounters.CONNECTOR_MODIFICATION_COUNT, 0); assertWillAfterCreateCaseClosed(TEST_NAME, true); @@ -969,11 +969,11 @@ public void test120RecomputeWillAfter5min() throws Exception { clockForward("PT5M"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertRepoShadow(accountWillOid) @@ -1011,11 +1011,11 @@ public void test130RecomputeWillAfter25min() throws Exception { clockForward("PT20M"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertRepoShadow(accountWillOid) @@ -1053,11 +1053,11 @@ public void test132RecomputeWillAfter32min() throws Exception { clockForward("PT7M"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertRepoShadow(accountWillOid) @@ -1088,11 +1088,11 @@ public void test200ModifyUserWillFullname() throws Exception { accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(userWillOid, UserType.F_FULL_NAME, task, result, createPolyString(USER_WILL_FULL_NAME_PIRATE)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("result", result); willLastCaseOid = assertInProgress(result); @@ -1111,11 +1111,11 @@ public void test202RecomputeWill() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertAccountWillAfterFullNameModification(TEST_NAME, PendingOperationExecutionStatusType.EXECUTION_PENDING); @@ -1131,11 +1131,11 @@ public void test203RunPropagation() throws Exception { clockForward("PT2M"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); runPropagation(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertAccountWillAfterFullNameModification(TEST_NAME, PendingOperationExecutionStatusType.EXECUTING); @@ -1150,11 +1150,11 @@ public void test204RecomputeWill() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertAccountWillAfterFullNameModification(TEST_NAME, PendingOperationExecutionStatusType.EXECUTING); @@ -1177,11 +1177,11 @@ public void test206CloseCaseAndRecomputeWill() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); accountWillCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -1252,11 +1252,11 @@ public void test210RecomputeWillAfter5min() throws Exception { clockForward("PT5M"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject shadowRepo = repositoryService.getObject(ShadowType.class, accountWillOid, null, result); @@ -1311,12 +1311,12 @@ public void test212UpdateBackingStoreAndGetAccountWill() throws Exception { backingStoreUpdateWill(USER_WILL_FULL_NAME_PIRATE, INTEREST_ONE, ActivationStatusType.ENABLED, USER_WILL_PASSWORD_OLD); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject shadowModel = modelService.getObject(ShadowType.class, accountWillOid, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertShadowActivationAdministrativeStatus(shadowModel, ActivationStatusType.ENABLED); @@ -1372,11 +1372,11 @@ public void test400PhantomAccount() throws Exception { setupPhantom(TEST_NAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_PHANTOM_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); // This should theoretically always return IN_PROGRESS, as there is // reconciliation operation going on. But due to various "peculiarities" @@ -1388,11 +1388,11 @@ public void test400PhantomAccount() throws Exception { } // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); runPropagation(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject userAfter = getUser(USER_PHANTOM_OID); display("User after", userAfter); @@ -1445,22 +1445,22 @@ public void test410AssignPhoenixAccount() throws Exception { addObject(USER_PHOENIX_FILE); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_PHOENIX_OID, getResourceOid(), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertInProgress(result); // Make sure the operation will be picked up by propagation task clockForward("PT3M"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); runPropagation(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject userAfter = getUser(USER_PHOENIX_OID); display("User after", userAfter); @@ -1492,11 +1492,11 @@ public void test412AddPhoenixToBackingStoreAndCloseTicket() throws Exception { closeCase(phoenixLastCaseOid); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_PHOENIX_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_PHOENIX_OID); @@ -1529,11 +1529,11 @@ public void test413PhoenixLetOperationsExpire() throws Exception { clockForward("PT1H"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_PHOENIX_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_PHOENIX_OID); @@ -1564,22 +1564,22 @@ public void test414UnassignPhoenixAccount() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignAccountFromUser(USER_PHOENIX_OID, getResourceOid(), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertInProgress(result); // Make sure the operation will be picked up by propagation task clockForward("PT3M"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); runPropagation(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject userAfter = getUser(USER_PHOENIX_OID); display("User after", userAfter); @@ -1609,22 +1609,22 @@ public void test416PhoenixAccountUnassignCloseCase() throws Exception { closeCase(phoenixLastCaseOid); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_PHOENIX_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); // Make sure the operation will be picked up by propagation task clockForward("PT3M"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); runPropagation(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject userAfter = getUser(USER_PHOENIX_OID); display("User after", userAfter); @@ -1654,22 +1654,22 @@ public void test418AssignPhoenixAccountAgain() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_PHOENIX_OID, getResourceOid(), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); phoenixLastCaseOid = assertInProgress(result); // Make sure the operation will be picked up by propagation task clockForward("PT3M"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); runPropagation(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject userAfter = getUser(USER_PHOENIX_OID); display("User after", userAfter); @@ -1800,7 +1800,7 @@ public void test910ConcurrentRolesAssign() throws Exception { final long TIMEOUT = 60000L; // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ParallelTestThread[] threads = multithread(TEST_NAME, (i) -> { @@ -1812,7 +1812,7 @@ public void test910ConcurrentRolesAssign() throws Exception { }, getConcurrentTestNumberOfThreads(), getConcurrentTestRandomStartDelayRangeAssign()); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForThreads(threads, TIMEOUT); PrismObject userAfter = getUser(USER_DRAKE_OID); @@ -1878,7 +1878,7 @@ public void test919ConcurrentRoleUnassign() throws Exception { final long TIMEOUT = 60000L; // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ParallelTestThread[] threads = multithread(TEST_NAME, (i) -> { @@ -1896,7 +1896,7 @@ public void test919ConcurrentRoleUnassign() throws Exception { }, getConcurrentTestNumberOfThreads(), getConcurrentTestRandomStartDelayRangeUnassign()); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForThreads(threads, TIMEOUT); PrismObject userAfter = getUser(USER_DRAKE_OID); @@ -2069,11 +2069,11 @@ protected void assignWillRoleOne(final String TEST_NAME, String expectedFullName accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(userWillOid, getRoleOneOid(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("result", result); willLastCaseOid = assertInProgress(result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestDummyItsmIntegration.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestDummyItsmIntegration.java index 28c9f88c645..3a0ca88ecf2 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestDummyItsmIntegration.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestDummyItsmIntegration.java @@ -125,11 +125,11 @@ public void test012TestConnection() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); OperationResult testResult = modelService.testResource(RESOURCE_DUMMY_ITSM_OID, task); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Test result", testResult); TestUtil.assertSuccess("Test resource failed (result)", testResult); @@ -153,11 +153,11 @@ public void test100AssignAccountToJack() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_ITSM_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("result", result); jackLastTicketIdentifier = assertInProgress(result); @@ -184,11 +184,11 @@ public void test102CloseTicketAndRecomputeJack() throws Exception { closeDummyTicket(jackLastTicketIdentifier); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -208,11 +208,11 @@ public void test104UnassignAccountFromJack() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_ITSM_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("result", result); jackLastTicketIdentifier = assertInProgress(result); @@ -242,11 +242,11 @@ public void test108CloseTicketAndRecomputeJack() throws Exception { dumpItsm(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -276,11 +276,11 @@ public void test109LetItExpire() throws Exception { clockForward("PT3H"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -300,11 +300,11 @@ public void test110AssignItsmAccountToJackCommunicationError() throws Exception DummyItsm.getInstance().setFailureClass(CommunicationException.class); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_ITSM_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); DummyItsm.getInstance().clearFailureClass(); assertInProgress(result); @@ -341,12 +341,12 @@ public void test111ReconcileJackFixed() throws Exception { display("Repo shadow before", shadowRepoBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); // This in fact should be a call to reconcile, not refresh directly (TODO: MID-4542) provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("result", result); jackLastTicketIdentifier = assertInProgress(result); @@ -380,11 +380,11 @@ public void test112CloseTicketAndRecomputeJackCommunicationError() throws Except DummyItsm.getInstance().setFailureClass(CommunicationException.class); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); DummyItsm.getInstance().clearFailureClass(); assertPartialError(result); @@ -416,11 +416,11 @@ public void test113RecomputeJackFixed() throws Exception { DummyItsm.getInstance().clearFailureClass(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -450,11 +450,11 @@ public void test114UnassignAccountFromJackCommunicationError() throws Exception DummyItsm.getInstance().setFailureClass(CommunicationException.class); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_ITSM_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("result", result); DummyItsm.getInstance().clearFailureClass(); assertResultStatus(result, OperationResultStatus.IN_PROGRESS); @@ -507,12 +507,12 @@ public void test115ReconcileJackFixed() throws Exception { display("Repo shadow before", shadowRepoBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); // This in fact should be a call to reconcile, not refresh directly (TODO: MID-4542) provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("result", result); jackLastTicketIdentifier = assertInProgress(result); @@ -547,11 +547,11 @@ public void test117CloseTicketAndRecomputeJackCommunicationError() throws Except DummyItsm.getInstance().setFailureClass(CommunicationException.class); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); DummyItsm.getInstance().clearFailureClass(); assertPartialError(result); @@ -586,12 +586,12 @@ public void test118RecomputeJackFixed() throws Exception { display("Repo shadow before", shadowRepoBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); // This in fact should be a call to reconcile, not refresh directly (TODO: MID-4542) provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -624,11 +624,11 @@ public void test119LetItExpire() throws Exception { clockForward("PT3H"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_JACK_OID) diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManual.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManual.java index fbe7fc74894..eb098f3af39 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManual.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManual.java @@ -134,11 +134,11 @@ public void test700AssignAccountJackExisting() throws Exception { accountJackReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_JACK_OID, getResourceOid(), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("result", result); assertSuccess(result, 2); assertNull("Unexpected ticket in result", result.getAsynchronousOperationReference()); @@ -185,11 +185,11 @@ public void test710UnassignAccountJack() throws Exception { accountJackReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignAccountFromUser(USER_JACK_OID, getResourceOid(), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("result", result); jackLastCaseOid = assertInProgress(result); @@ -242,12 +242,12 @@ public void test712CloseCaseAndRecomputeJack() throws Exception { accountJackCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); // We need reconcile and not recompute here. We need to fetch the updated case status. reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("result", result); assertSuccess(result); @@ -295,12 +295,12 @@ public void test717RecomputeJackAfter130min() throws Exception { clock.overrideDuration("PT130M"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); // We need reconcile and not recompute here. We need to fetch the updated case status. reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("result", result); assertSuccess(result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualDisable.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualDisable.java index 49cf336af4b..9f7de901187 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualDisable.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualDisable.java @@ -183,22 +183,22 @@ public void test416PhoenixAccountUnassignCloseCase() throws Exception { closeCase(phoenixLastCaseOid); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_PHOENIX_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); // Make sure the operation will be picked up by propagation task clockForward("PT3M"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); runPropagation(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject userAfter = getUser(USER_PHOENIX_OID); display("User after", userAfter); @@ -226,22 +226,22 @@ public void test418AssignPhoenixAccountAgain() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_PHOENIX_OID, getResourceOid(), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); phoenixLastCaseOid = assertInProgress(result); // Make sure the operation will be picked up by propagation task clockForward("PT3M"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); runPropagation(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject userAfter = getUser(USER_PHOENIX_OID); display("User after", userAfter); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGrouping.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGrouping.java index 1df6a87b84b..8cdf9fa8d92 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGrouping.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGrouping.java @@ -130,11 +130,11 @@ public void test400PhantomAccount() throws Exception { setupPhantom(TEST_NAME); // WHEN (mid1) - displayWhen(TEST_NAME, "mid1"); + when("mid1"); recomputeUser(USER_PHANTOM_OID, task, result); // THEN (mid1) - displayThen(TEST_NAME, "mid1"); + then("mid1"); String caseOid1 = assertInProgress(result); display("Case 1", caseOid1); // No case OID yet. The case would be created after propagation is run. @@ -155,7 +155,7 @@ public void test400PhantomAccount() throws Exception { clockForward("PT3M"); // WHEN (mid2) - displayWhen(TEST_NAME, "mid2"); + when("mid2"); // Existing account is detected now. Hence partial error. runPropagation(OperationResultStatusType.PARTIAL_ERROR); @@ -164,7 +164,7 @@ public void test400PhantomAccount() throws Exception { // fixed immediately. Instead there is a pending delta to fix the problem. // THEN (mid2) - displayThen(TEST_NAME, "mid2"); + then("mid2"); String caseOid2 = assertInProgress(result); display("Case 2", caseOid2); // No case OID yet. The case will be created after propagation is run. @@ -214,11 +214,11 @@ public void test400PhantomAccount() throws Exception { clockForward("PT20M"); // WHEN (final) - displayWhen(TEST_NAME, "final"); + when("final"); runPropagation(); // THEN - displayThen(TEST_NAME, "final"); + then("final"); String liveShadowOid = assertUser(USER_PHANTOM_OID, "final") .displayWithProjections() diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGroupingProposed.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGroupingProposed.java index 41804e13ab0..67ba3cfe7c5 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGroupingProposed.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGroupingProposed.java @@ -128,11 +128,11 @@ public void test500AssignBigmouthRoleOne() throws Exception { display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(userBigmouthOid, getRoleOneOid(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("result", result); bigmouthLastCaseOid = assertInProgress(result); @@ -182,11 +182,11 @@ public void test502RunPropagation() throws Exception { clockForward("PT20M"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); runPropagation(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PendingOperationExecutionStatusType executionStage = PendingOperationExecutionStatusType.EXECUTING; diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMapping.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMapping.java index 881d6b5e7f4..3d1c0fdc198 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMapping.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMapping.java @@ -183,11 +183,11 @@ public void test100ModifyUserAssignAccountDummyBlue() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_BLUE_OID, null, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userJack = getUser(USER_JACK_OID); @@ -237,12 +237,12 @@ public void test101ModifyUserFullName() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, PrismTestUtil.createPolyString(CAPTAIN_JACK_FULL_NAME)); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userJack = getUser(USER_JACK_OID); @@ -273,14 +273,14 @@ public void test102ModifyUserFullNameRecon() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(); + when(); ObjectDelta objectDelta = createModifyUserReplaceDelta(USER_JACK_OID, UserType.F_FULL_NAME, PrismTestUtil.createPolyString(CAPTAIN_JACK_FULL_NAME)); Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); modelService.executeChanges(deltas, ModelExecuteOptions.createReconcile(), task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userJack = getUser(USER_JACK_OID); @@ -1405,11 +1405,11 @@ accountOid, getDummyResourceController(RESOURCE_DUMMY_RED_NAME).getAttributePath deltas.add(accountDelta); // WHEN - displayWhen(); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(); + then(); assertPartialError(result); userJack = getUser(USER_JACK_OID); @@ -1488,11 +1488,11 @@ accountOid, getDummyResourceController(RESOURCE_DUMMY_RED_NAME).getAttributePath deltas.add(accountDelta); // WHEN - displayWhen(); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(); + then(); assertPartialError(result); userJack = getUser(USER_JACK_OID); @@ -1781,12 +1781,12 @@ public void test183ModifyAccountLocation() throws Exception { deltas.add(accountDelta); // WHEN - displayWhen(); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(); + then(); assertPartialError(result); userJack = getUser(USER_JACK_OID); @@ -1865,11 +1865,11 @@ public void test185ModifyAccountLocationDelete() throws Exception { deltas.add(accountDelta); // WHEN - displayWhen(); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(); + then(); assertPartialError(result); userJack = getUser(USER_JACK_OID); @@ -2022,11 +2022,11 @@ public void test200ModifyUserAssignAccountDummyCrimson() throws Exception { OperationResult result = getResult(); // WHEN - displayWhen(); + when(); assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_CRIMSON_OID, null, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -2059,11 +2059,11 @@ public void test202NativeModifyDummyCrimsonThenReconcile() throws Exception { display("Dummy account before", dummyAccountBefore); // WHEN - displayWhen(); + when(); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -2097,11 +2097,11 @@ public void test204DummyCrimsonReconcile() throws Exception { display("Dummy account before", dummyAccountBefore); // WHEN - displayWhen(); + when(); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -2144,11 +2144,11 @@ public void test206DummyCrimsonReconcileIOError() throws Exception { getDummyResource(RESOURCE_DUMMY_CRIMSON_NAME).setGetBreakMode(BreakMode.IO); // WHEN - displayWhen(); + when(); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertPartialError(result); @@ -2191,11 +2191,11 @@ public void test208DummyCrimsonReconcileAgain() throws Exception { display("Dummy account before", dummyAccountBefore); // WHEN - displayWhen(); + when(); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -2234,11 +2234,11 @@ public void test210ModifyUserLocality() throws Exception { display("Dummy account before", dummyAccountBefore); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_LOCALITY, task, result, createPolyString(LOCALITY_BLOOD_ISLAND)); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -2277,7 +2277,7 @@ public void test212ModifyUserLocalityRecon() throws Exception { display("Dummy account before", dummyAccountBefore); // WHEN - displayWhen(); + when(); ObjectDelta objectDelta = createModifyUserReplaceDelta(USER_GUYBRUSH_OID, UserType.F_LOCALITY, PrismTestUtil.createPolyString(LOCALITY_SCABB_ISLAND)); Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); @@ -2285,7 +2285,7 @@ public void test212ModifyUserLocalityRecon() throws Exception { modelService.executeChanges(deltas, options, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -2328,11 +2328,11 @@ public void test214ModifyUserLocalityIOError() throws Exception { getDummyResource(RESOURCE_DUMMY_CRIMSON_NAME).setGetBreakMode(BreakMode.IO); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_LOCALITY, task, result, createPolyString(LOCALITY_BOOTY_ISLAND)); // THEN - displayThen(); + then(); assertSuccess(result, 1); // there's hidden PARTIAL_ERROR deep inside getDummyResource(RESOURCE_DUMMY_CRIMSON_NAME).resetBreakMode(); @@ -2380,11 +2380,11 @@ public void test220NativeModifyDummyCrimsonThenChangePassword() throws Exception getDummyResource(RESOURCE_DUMMY_CRIMSON_NAME).setGetBreakMode(BreakMode.IO); // WHEN - displayWhen(); + when(); modifyUserChangePassword(USER_GUYBRUSH_OID, USER_GUYBRUSH_PASSWORD_1_CLEAR, task, result); // THEN - displayThen(); + then(); assertSuccess(result, 1); // there's hidden PARTIAL_ERROR deep inside getDummyResource(RESOURCE_DUMMY_CRIMSON_NAME).resetBreakMode(); @@ -2420,11 +2420,11 @@ public void test229ModifyUserUnassignAccountDummyCrimson() throws Exception { OperationResult result = getResult(); // WHEN - displayWhen(); + when(); unassignAccountFromUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_CRIMSON_OID, null, task, result); // THEN - displayThen(); + then(); assertSuccess(result, 1); // there's hidden PARTIAL_ERROR deep inside PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -2452,11 +2452,11 @@ public void test250ModifyUserAssignAccountDummyLightCrimson() throws Exception { assertNoDummyAccount(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); // WHEN - displayWhen(); + when(); assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_LIGHT_CRIMSON_OID, null, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -2489,11 +2489,11 @@ public void test252NativeModifyDummyLightCrimsonThenReconcile() throws Exception display("Dummy account before", dummyAccountBefore); // WHEN - displayWhen(); + when(); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -2527,11 +2527,11 @@ public void test254DummyLightCrimsonReconcile() throws Exception { display("Dummy account before", dummyAccountBefore); // WHEN - displayWhen(); + when(); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -2575,11 +2575,11 @@ public void test256DummyLightCrimsonReconcileIOError() throws Exception { getDummyResource(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME).setGetBreakMode(BreakMode.IO); // WHEN - displayWhen(); + when(); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertPartialError(result); @@ -2622,11 +2622,11 @@ public void test258DummyLightCrimsonReconcileAgain() throws Exception { display("Dummy account before", dummyAccountBefore); // WHEN - displayWhen(); + when(); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -2665,11 +2665,11 @@ public void test260ModifyUserLocality() throws Exception { display("Dummy account before", dummyAccountBefore); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_LOCALITY, task, result, createPolyString(LOCALITY_BLOOD_ISLAND)); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -2708,7 +2708,7 @@ public void test262ModifyUserLocalityRecon() throws Exception { display("Dummy account before", dummyAccountBefore); // WHEN - displayWhen(); + when(); ObjectDelta objectDelta = createModifyUserReplaceDelta(USER_GUYBRUSH_OID, UserType.F_LOCALITY, PrismTestUtil.createPolyString(LOCALITY_SCABB_ISLAND)); Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); @@ -2716,7 +2716,7 @@ public void test262ModifyUserLocalityRecon() throws Exception { modelService.executeChanges(deltas, options, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -2759,11 +2759,11 @@ public void test264ModifyUserLocalityIOError() throws Exception { getDummyResource(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME).setGetBreakMode(BreakMode.IO); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_LOCALITY, task, result, createPolyString(LOCALITY_BOOTY_ISLAND)); // THEN - displayThen(); + then(); assertSuccess(result, 1); // there's hidden PARTIAL_ERROR deep inside getDummyResource(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME).resetBreakMode(); @@ -2811,11 +2811,11 @@ public void test270NativeModifyDummyLightCrimsonThenChangePassword() throws Exce getDummyResource(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME).setGetBreakMode(BreakMode.IO); // WHEN - displayWhen(); + when(); modifyUserChangePassword(USER_GUYBRUSH_OID, USER_GUYBRUSH_PASSWORD_2_CLEAR, task, result); // THEN - displayThen(); + then(); assertSuccess(result, 1); // there's hidden PARTIAL_ERROR deep inside getDummyResource(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME).resetBreakMode(); @@ -2851,11 +2851,11 @@ public void test279ModifyUserUnassignAccountDummyLightCrimson() throws Exception OperationResult result = getResult(); // WHEN - displayWhen(); + when(); unassignAccountFromUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_LIGHT_CRIMSON_OID, null, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -2881,11 +2881,11 @@ public void test300AssignGuybrushDummyYellow() throws Exception { OperationResult result = getResult(); // WHEN - displayWhen(); + when(); assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_YELLOW_OID, null, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -2915,11 +2915,11 @@ public void test302ModifyGuybrushLocality() throws Exception { OperationResult result = getResult(); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_LOCALITY, task, result, createPolyString("Forbidden dodecahedron")); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -2943,11 +2943,11 @@ public void test309UnassignGuybrushDummyYellow() throws Exception { OperationResult result = getResult(); // WHEN - displayWhen(); + when(); unassignAccountFromUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_YELLOW_OID, null, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -2968,11 +2968,11 @@ public void test400ModifyUserAssignAccountDummyCrimsonCustomFunction() throws Ex OperationResult result = getResult(); // WHEN - displayWhen(); + when(); assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_CUSTOM_FUNCTION_CRIMSON_OID, null, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -2994,11 +2994,11 @@ public void test401ModifyUserLocalityDummyCrisomCustomFunction() throws Exceptio OperationResult result = getResult(); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_LOCALITY, task, result, createPolyString(LOCALITY_SCABB_ISLAND)); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -3021,11 +3021,11 @@ public void test402ModifyDrinkDummyCustomFunctionCrimson() throws Exception { OperationResult result = getResult(); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_LOCALITY, task, result, createPolyString(LOCALITY_BLOOD_ISLAND)); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -3063,7 +3063,7 @@ public void test420AssignAntinihilistToJack() throws Exception { try { // WHEN - displayWhen(); + when(); assignRole(USER_JACK_OID, ROLE_ANTINIHILIST_OID, task, result); } catch (ExpressionEvaluationException e) { @@ -3075,7 +3075,7 @@ public void test420AssignAntinihilistToJack() throws Exception { } // THEN - displayThen(); + then(); assertFailure(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3101,11 +3101,11 @@ public void test422AssignAccountAndAntinihilistToJack() throws Exception { assertLinks(userBefore, 1); // WHEN - displayWhen(); + when(); assignRole(USER_JACK_OID, ROLE_ANTINIHILIST_OID, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3130,11 +3130,11 @@ public void test425UnassignAntinihilistFromJack() throws Exception { assertLinks(userBefore, 1); // WHEN - displayWhen(); + when(); unassignRole(USER_JACK_OID, ROLE_ANTINIHILIST_OID, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3159,11 +3159,11 @@ public void test427UnassignAccountFromJack() throws Exception { assertLinks(userBefore, 1); // WHEN - displayWhen(); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3186,11 +3186,11 @@ public void test500AssignmentsCombinationSingle() throws Exception { .end(); // WHEN - displayWhen(); + when(); addObject(jim.asPrismObject()); // THEN - displayThen(); + then(); PrismObject userAfter = getUser(jim.getOid()); display("User after", userAfter); @@ -3209,11 +3209,11 @@ public void test510AssignmentsCombinationCouple() throws Exception { PrismObject jim = findUserByUsername(USER_JIM_NAME); // WHEN - displayWhen(); + when(); assignOrg(jim.getOid(), ORG_SAVE_ELAINE_OID, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(jim.getOid()); @@ -3233,7 +3233,7 @@ public void test520DeleteUserAssignment() throws Exception { PrismObject jim = findUserByUsername(USER_JIM_NAME); // WHEN - displayWhen(); + when(); AssignmentType orgAssignment = findAssignment(jim, ORG_SAVE_ELAINE_OID, SchemaConstants.ORG_DEFAULT); assertNotNull("org assignment not found", orgAssignment); PrismContainerValue orgAssignmentPcv = prismContext.itemFactory().createContainerValue(); @@ -3244,7 +3244,7 @@ public void test520DeleteUserAssignment() throws Exception { executeChanges(delta, null, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(jim.getOid()); @@ -3263,11 +3263,11 @@ public void test600AddService() throws Exception { final String PASSWORD = "pwd1234"; // WHEN - displayWhen(); + when(); addObject(SERVICE_ROUTER, task, result); // THEN - displayThen(); + then(); assertSuccess(result); assertService(SERVICE_ROUTER.oid, "service") @@ -3296,7 +3296,7 @@ public void test610ModifyServicePassword() throws Exception { newPasswordProtected.setClearValue(NEW_PASSWORD); // WHEN - displayWhen(); + when(); ObjectDelta delta = deltaFor(ServiceType.class) .item(ServiceType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE) .replace(newPasswordProtected) @@ -3304,7 +3304,7 @@ public void test610ModifyServicePassword() throws Exception { executeChanges(delta, null, task, result); // THEN - displayThen(); + then(); assertSuccess(result); assertService(SERVICE_ROUTER.oid, "service") @@ -3336,12 +3336,12 @@ public void test650ImportFromInboundPwdCopy() throws Exception { resource.addAccount(bridge); // WHEN - displayWhen(); + when(); addObject(TASK_IMPORT_PWD_COPY, task, result); waitForTaskFinish(TASK_IMPORT_PWD_COPY.oid, true); // THEN - displayThen(); + then(); assertServiceByName(SERVICE_BRIDGE_NAME, "service") .display() .assertLinks(1) @@ -3360,11 +3360,11 @@ public void test660ImportFromInboundPwdCopyModifyPassword() throws Exception { resource.getAccountByUsername(SERVICE_BRIDGE_NAME).setPassword(NEW_PASSWORD); // WHEN - displayWhen(); + when(); rerunTask(TASK_IMPORT_PWD_COPY.oid); // THEN - displayThen(); + then(); assertServiceByName(SERVICE_BRIDGE_NAME, "service") .display() .assertLinks(1) @@ -3388,12 +3388,12 @@ public void test670ImportFromInboundPwdGenerate() throws Exception { resource.addAccount(gateway); // WHEN - displayWhen(); + when(); addObject(TASK_IMPORT_PWD_GENERATE, task, result); waitForTaskFinish(TASK_IMPORT_PWD_GENERATE.oid, true); // THEN - displayThen(); + then(); assertServiceByName(SERVICE_GATEWAY_NAME, "service") .display() .assertLinks(1) @@ -3417,11 +3417,11 @@ public void test680ImportFromInboundPwdGenerateModifyPassword() throws Exception resource.getAccountByUsername(SERVICE_GATEWAY_NAME).setPassword(NEW_PASSWORD); // WHEN - displayWhen(); + when(); rerunTask(TASK_IMPORT_PWD_GENERATE.oid); // THEN - displayThen(); + then(); assertServiceByName(SERVICE_GATEWAY_NAME, "service") .display() .assertLinks(1) @@ -3444,11 +3444,11 @@ public void test700TimedOutbound() throws Exception { .end(); // WHEN - displayWhen(); + when(); String oid = addObject(user.asPrismObject(), task, result); // THEN - displayThen(); + then(); assertUser(oid, "user after") .display() .triggers() diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingAutoInbound.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingAutoInbound.java index 66088642675..878f66eb00b 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingAutoInbound.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingAutoInbound.java @@ -78,18 +78,18 @@ public void test100ImportFromResource() throws Exception { assertUsers(getNumberOfUsers()); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.importFromResource(RESOURCE_DUMMY_AUTOGREEN_OID, new QName(MidPointConstants.NS_RI, SchemaConstants.ACCOUNT_OBJECT_CLASS_LOCAL_NAME), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); waitForTaskFinish(task, true, 40000); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(task.getResult()); SearchResultList> users = modelService.searchObjects(UserType.class, null, null, task, result); @@ -121,11 +121,11 @@ public void test110ModifyAccountTitleCraticAndReconcile() throws Exception { accountHerman.replaceAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "cratic"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(userHermanOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(userHermanOid); @@ -149,11 +149,11 @@ public void test112ModifyAccountTitleDidacticGraphicAndReconcile() throws Except accountHerman.replaceAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "didactic", "graphic"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(userHermanOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(userHermanOid); @@ -187,18 +187,18 @@ public void test200ImportFromResourceAssociations() throws Exception { dummyGroup.addMember(USER_HERMAN_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.importFromResource(RESOURCE_DUMMY_AUTOGREEN_OID, new QName(MidPointConstants.NS_RI, "AccountObjectClass"), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); waitForTaskFinish(task, true, 40000); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(task.getResult()); SearchResultList> users = modelService.searchObjects(UserType.class, null, null, task, result); @@ -226,12 +226,12 @@ public void test300ModifyAccountDirectAssign() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(userHermanOid, ROLE_ADMINS_OID); reconcileUser(userHermanOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(userHermanOid); @@ -264,18 +264,18 @@ public void test301removeUserFromAutoGroup() throws Exception { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.importFromResource(RESOURCE_DUMMY_AUTOGREEN_OID, new QName(MidPointConstants.NS_RI, "AccountObjectClass"), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); waitForTaskFinish(task, true, 70000); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(task.getResult()); PrismObject userAfter = getUser(userHermanOid); @@ -307,11 +307,11 @@ public void test402assignAutoGroupDirectly() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(userHermanOid, ROLE_AUTOCRATIC_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertDummyGroupMember(RESOURCE_DUMMY_AUTOGREEN_NAME, GROUP_DUMMY_TESTERS_NAME, USER_HERMAN_USERNAME); @@ -340,11 +340,11 @@ public void test403removeAllAssignments() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(userHermanOid, ROLE_ADMINS_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(userHermanOid); @@ -371,18 +371,18 @@ public void test404importAssociationAutotesters() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.importFromResource(RESOURCE_DUMMY_AUTOGREEN_OID, new QName(MidPointConstants.NS_RI, "AccountObjectClass"), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); waitForTaskFinish(task, true, 40000); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(task.getResult()); PrismObject userAfter = getUser(userHermanOid); @@ -401,11 +401,11 @@ public void test405assignRoleAutocraticDirectly() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(userHermanOid, ROLE_AUTOCRATIC_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(userHermanOid); @@ -429,11 +429,11 @@ public void test406unassignRoleAutocraticDirectly() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(userHermanOid, ROLE_AUTOCRATIC_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(userHermanOid); @@ -460,11 +460,11 @@ public void test407addHermanToTestersReconcile() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(userHermanOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(task.getResult()); PrismObject userAfter = getUser(userHermanOid); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingInbound.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingInbound.java index 46872bffd89..a68a563bd79 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingInbound.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingInbound.java @@ -97,11 +97,11 @@ public void test010SanitySchema() throws Exception { Task task = getTestTask(); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); OperationResult testResult = modelService.testResource(RESOURCE_DUMMY_TEA_GREEN_OID, task); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); TestUtil.assertSuccess(testResult); ResourceType resourceType = getDummyResourceType(RESOURCE_DUMMY_TEA_GREEN_NAME); @@ -125,11 +125,11 @@ public void test100ImportLiveSyncTaskDummyTeaGreen() throws Exception { OperationResult result = task.getResult(); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); importSyncTask(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForSyncTaskStart(); } @@ -153,14 +153,14 @@ public void test110AddDummyTeaGreenAccountMancomb() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, "water"); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); getDummyResource(RESOURCE_DUMMY_TEA_GREEN_NAME).addAccount(account); waitForSyncTaskNextRun(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject accountMancomb = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, getDummyResourceObject(RESOURCE_DUMMY_TEA_GREEN_NAME)); display("Account mancomb", accountMancomb); @@ -204,7 +204,7 @@ public void test120ModifyMancombPhotoSource() throws Exception { OperationResult result = task.getResult(); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); DummyAccount account = getDummyResource(RESOURCE_DUMMY_TEA_GREEN_NAME) .getAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME); @@ -215,7 +215,7 @@ public void test120ModifyMancombPhotoSource() throws Exception { waitForSyncTaskNextRun(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject accountMancomb = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, getDummyResourceObject(RESOURCE_DUMMY_TEA_GREEN_NAME)); display("Account mancomb", accountMancomb); @@ -239,7 +239,7 @@ public void test130ModifyMancombPhotoSourceAndReconcile() throws Exception { OperationResult result = task.getResult(); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); // stop the task to avoid interference with the reconciliations suspendTask(TASK_LIVE_SYNC_DUMMY_TEA_GREEN_OID); @@ -256,7 +256,7 @@ public void test130ModifyMancombPhotoSourceAndReconcile() throws Exception { reconcileUser(userMancomb.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject accountMancomb = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, getDummyResourceObject(RESOURCE_DUMMY_TEA_GREEN_NAME)); display("Account mancomb", accountMancomb); @@ -278,7 +278,7 @@ public void test140ModifyMancombPhotoInRepo() throws Exception { OperationResult result = task.getResult(); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject userMancomb = findUserByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME); assertNotNull("User mancomb has disappeared", userMancomb); @@ -289,7 +289,7 @@ public void test140ModifyMancombPhotoInRepo() throws Exception { executeChanges(delta, ModelExecuteOptions.createReconcile(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); @@ -318,7 +318,7 @@ public void test150UserReconcile() throws Exception { //assertUsers(5); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject userMancomb = findUserByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME); assertNotNull("User mancomb has disappeared", userMancomb); @@ -326,7 +326,7 @@ public void test150UserReconcile() throws Exception { reconcileUser(userMancomb.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject accountMancomb = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, getDummyResourceObject(RESOURCE_DUMMY_TEA_GREEN_NAME)); display("Account mancomb", accountMancomb); @@ -372,7 +372,7 @@ public void test300DeleteDummyTeaGreenAccountMancomb() throws Exception { OperationResult result = task.getResult(); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); getDummyResource(RESOURCE_DUMMY_TEA_GREEN_NAME).deleteAccountByName(ACCOUNT_MANCOMB_DUMMY_USERNAME); display("Dummy (tea green) resource", getDummyResource(RESOURCE_DUMMY_TEA_GREEN_NAME).debugDump()); @@ -382,7 +382,7 @@ public void test300DeleteDummyTeaGreenAccountMancomb() throws Exception { waitForSyncTaskNextRun(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertNoDummyAccount(RESOURCE_DUMMY_TEA_GREEN_NAME, ACCOUNT_MANCOMB_DUMMY_USERNAME); @@ -410,11 +410,11 @@ public void test399DeleteDummyTeaGreenAccountMancomb() throws Exception { OperationResult result = task.getResult(); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); deleteObject(TaskType.class, TASK_LIVE_SYNC_DUMMY_TEA_GREEN_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertNoObject(TaskType.class, TASK_LIVE_SYNC_DUMMY_TEA_GREEN_OID); } @@ -437,7 +437,7 @@ public void test400AddUserLeeloo() throws Exception { getDummyResource(RESOURCE_DUMMY_TEA_GREEN_NAME).addAccount(account); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.importFromResource(RESOURCE_DUMMY_TEA_GREEN_OID, new QName(MidPointConstants.NS_RI, SchemaConstants.ACCOUNT_OBJECT_CLASS_LOCAL_NAME), task, result); @@ -446,7 +446,7 @@ public void test400AddUserLeeloo() throws Exception { waitForTaskFinish(task, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); userLeelooOid = assertUserAfterByUsername(ACCOUNT_LEELOO_USERNAME) .assertFullName(ACCOUNT_LEELOO_FULL_NAME_MULTIPASS) @@ -482,12 +482,12 @@ public void test402UserLeelooRecompute() throws Exception { dummyAuditService.clear(); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(userLeelooOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertUserAfterByUsername(ACCOUNT_LEELOO_USERNAME) .assertFullName(ACCOUNT_LEELOO_FULL_NAME_MULTIPASS) @@ -515,12 +515,12 @@ public void test404UserLeelooReconcile() throws Exception { dummyAuditService.clear(); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(userLeelooOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertUserAfterByUsername(ACCOUNT_LEELOO_USERNAME) .assertFullName(ACCOUNT_LEELOO_FULL_NAME_MULTIPASS) @@ -556,12 +556,12 @@ public void test410UserLeeloominaiReconcile() throws Exception { dummyAuditService.clear(); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(userLeelooOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertUserAfterByUsername(ACCOUNT_LEELOO_USERNAME) .assertFullName(ACCOUNT_LEELOO_FULL_NAME_LEELOOMINAI) @@ -594,12 +594,12 @@ public void test412UserLeeloominaiRecompute() throws Exception { dummyAuditService.clear(); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(userLeelooOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertUserAfterByUsername(ACCOUNT_LEELOO_USERNAME) .assertFullName(ACCOUNT_LEELOO_FULL_NAME_LEELOOMINAI) @@ -627,12 +627,12 @@ public void test414UserLeeloominaiReconcile() throws Exception { dummyAuditService.clear(); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(userLeelooOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertUserAfterByUsername(ACCOUNT_LEELOO_USERNAME) .assertFullName(ACCOUNT_LEELOO_FULL_NAME_LEELOOMINAI) @@ -668,12 +668,12 @@ public void test420UserLeelooStrangeReconcile() throws Exception { dummyAuditService.clear(); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(userLeelooOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertUserAfterByUsername(ACCOUNT_LEELOO_USERNAME) .assertFullName(ACCOUNT_LEELOO_FULL_NAME_LEELOOMINAI) @@ -707,12 +707,12 @@ public void test424UserLeelooStrangeReconcile() throws Exception { dummyAuditService.clear(); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(userLeelooOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertUserAfterByUsername(ACCOUNT_LEELOO_USERNAME) .assertFullName(ACCOUNT_LEELOO_FULL_NAME_LEELOOMINAI) diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestMigration.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestMigration.java index b26a2914ed3..c52aeb6d7ad 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestMigration.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestMigration.java @@ -61,11 +61,11 @@ public void test050SanityLost1() throws Exception { final String TEST_NAME = "test050SanityLost1"; // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject shadowLost1Repo = getShadowRepo(SHADOW_ACCOUNT_DUMMY_LOST1_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertShadow(shadowLost1Repo, "Repo shadow") .assertPrimaryIdentifierValue(null); @@ -82,12 +82,12 @@ public void test100RefreshTaskDefault() throws Exception { addObject(TASK_SHADOW_REFRESH_FILE); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); waitForTaskStart(TASK_SHADOW_REFRESH_OID, false); waitForTaskFinish(TASK_SHADOW_REFRESH_OID, false); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject shadowLost1Repo = getShadowRepo(SHADOW_ACCOUNT_DUMMY_LOST1_OID); assertShadow(shadowLost1Repo, "Repo shadow") @@ -106,12 +106,12 @@ public void test110RefreshTaskExplicitDummy() throws Exception { addObject(TASK_SHADOW_REFRESH_EXPLICIT_DUMMY_FILE); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); waitForTaskStart(TASK_SHADOW_REFRESH_EXPLICIT_DUMMY_OID, false); waitForTaskFinish(TASK_SHADOW_REFRESH_EXPLICIT_DUMMY_OID, false); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject shadowLost1Repo = getShadowRepo(SHADOW_ACCOUNT_DUMMY_LOST1_OID); assertShadow(shadowLost1Repo, "Repo shadow") diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestMisc.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestMisc.java index 6e94312fd0a..09ae4a27cc4 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestMisc.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestMisc.java @@ -98,11 +98,11 @@ public void test100GetRepositoryDiag() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); RepositoryDiag diag = modelDiagnosticService.getRepositoryDiag(task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Diag", diag); assertSuccess(result); @@ -119,11 +119,11 @@ public void test110RepositorySelfTest() throws Exception { Task task = getTestTask(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); OperationResult testResult = modelDiagnosticService.repositorySelfTest(task); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Repository self-test result", testResult); TestUtil.assertSuccess("Repository self-test result", testResult); @@ -139,12 +139,12 @@ public void test200ExportUsers() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); List> users = modelService.searchObjects(UserType.class, null, SelectorOptions.createCollection(GetOperationOptions.createRaw()), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertEquals("Unexpected number of users", 6, users.size()); @@ -187,11 +187,11 @@ public void test210SearchUsersMatchingRulesPolystringNorm() throws Exception { .build(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); List> users = modelService.searchObjects(UserType.class, query,null , task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertEquals("Unexpected number of users", 1, users.size()); @@ -221,7 +221,7 @@ public void test212SearchUsersMatchingRulesPolystringIgnoreCase() throws Excepti try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); List> users = modelService.searchObjects(UserType.class, query, null, task, result); } catch (SystemException e) { @@ -249,11 +249,11 @@ public void test214SearchUsersMatchingRulesStringIgnoreCase() throws Exception { .build(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); List> users = modelService.searchObjects(UserType.class, query,null , task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertEquals("Unexpected number of users", 1, users.size()); @@ -282,11 +282,11 @@ public void test216SearchUsersMatchingRulesStringNorm() throws Exception { .build(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); List> users = modelService.searchObjects(UserType.class, query,null , task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertEquals("Unexpected number of users", 0, users.size()); @@ -305,11 +305,11 @@ public void test300RecomputeJack() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -329,11 +329,11 @@ public void test302UpdateKeyJack() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_JACK_OID, getExtensionPath(PIRACY_KEY), task, result, KEY); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -352,11 +352,11 @@ public void test310AddUserClean() throws Exception { PrismObject userBefore = createUser(USER_CLEAN_NAME, USER_CLEAN_GIVEN_NAME, USER_CLEAN_FAMILY_NAME, true); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(userBefore, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); userCleanOid = userBefore.getOid(); @@ -378,11 +378,11 @@ public void test312UpdateBinaryIdClean() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(userCleanOid, getExtensionPath(PIRACY_BINARY_ID), task, result, KEY); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(userCleanOid); @@ -401,11 +401,11 @@ public void test320DefaultRelations() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); List relations = modelInteractionService.getRelationDefinitions(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Relations", relations); assertRelationDef(relations, SchemaConstants.ORG_MANAGER, "RelationTypes.manager"); assertRelationDef(relations, SchemaConstants.ORG_OWNER, "RelationTypes.owner"); @@ -424,11 +424,11 @@ public void test400ImportRoleWithFilters() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.importObjectsFromFile(ROLE_IMPORT_FILTERS_FILE, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject roleAfter = getRole(ROLE_IMPORT_FILTERS_OID); @@ -452,11 +452,11 @@ public void test500AddHocProvisioningScriptAssignJackResourceScripty() throws Ex assertAssignments(userBefore, 0); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_JACK_OID, RESOURCE_SCRIPTY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -486,11 +486,11 @@ public void test502GetAccountJackResourceScripty() throws Exception { String accountOid = getSingleLinkOid(userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject accountShadow = modelService.getObject(ShadowType.class, accountOid, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertAttribute(accountShadow.asObjectable(), @@ -518,11 +518,11 @@ public void test504GetAccountJackResourceScriptyAgain() throws Exception { String accountOid = getSingleLinkOid(userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject accountShadow = modelService.getObject(ShadowType.class, accountOid, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertAttribute(accountShadow.asObjectable(), @@ -557,12 +557,12 @@ public void test506ModifyResourceGetAccountJackResourceScripty() throws Exceptio display("Resource version before", resourceBefore.getVersion()); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyObjectReplaceProperty(ResourceType.class, RESOURCE_SCRIPTY_OID, ResourceType.F_DESCRIPTION, null, task, result, "Whatever"); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject resourceAfter = getObject(ResourceType.class, RESOURCE_SCRIPTY_OID); @@ -595,11 +595,11 @@ public void test600jackAssignRoleShip() throws Exception { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_SHIP_OID); //THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject userAfter = getUser(USER_JACK_OID); display("User before", userAfter); assertAssignments(userAfter, 2); @@ -626,11 +626,11 @@ public void test601jackUnassignResourceAccount() throws Exception { assertAssignments(userBefore, 2); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignAccountFromUser(USER_JACK_OID, RESOURCE_SCRIPTY_OID, null); //THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject userAfter = getUser(USER_JACK_OID); display("User after", userAfter); assertAssignments(userAfter, 1); @@ -654,11 +654,11 @@ public void test602jackUnssigndRoleShip() throws Exception { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, ROLE_SHIP_OID); //THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject userAfter = getUser(USER_JACK_OID); display("User before", userAfter); assertAssignments(userAfter, 0); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestUuidNonUniqueName.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestUuidNonUniqueName.java index 3b7718a0a1e..35d5ae1f0ed 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestUuidNonUniqueName.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestUuidNonUniqueName.java @@ -72,11 +72,11 @@ public void test010TestResourceConnection() throws Exception { Task task = getTestTask(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); OperationResult result = modelService.testResource(RESOURCE_DUMMY_UUID_NONUNIQUE_NAME_OID, task); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertResourceAfter(RESOURCE_DUMMY_UUID_NONUNIQUE_NAME_OID) @@ -93,11 +93,11 @@ public void test020RefinedSchema() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_UUID_NONUNIQUE_NAME_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertResourceAfter(RESOURCE_DUMMY_UUID_NONUNIQUE_NAME_OID) @@ -127,11 +127,11 @@ public void test100AssignAccountToJackSparrow() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_UUID_NONUNIQUE_NAME_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); accountJackSparrowUid = assertUserAfter(USER_JACK_OID) @@ -163,11 +163,11 @@ public void test102GetAccountJackSparrow() throws Exception { .getOid(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject shadow = modelService.getObject(ShadowType.class, accountJackSparrowOid, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertShadow(shadow, "getObject") @@ -193,11 +193,11 @@ public void test110AssignAccountToJackSkellington() throws Exception { assertEquals(USER_SKELLINGTON_GIVEN_NAME, USER_JACK_GIVEN_NAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_SKELLINGTON_OID, RESOURCE_DUMMY_UUID_NONUNIQUE_NAME_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); accountJackSkellingtonUid = assertUserAfter(USER_SKELLINGTON_OID) diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiAccount.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiAccount.java index 17c822c2448..0f3ec3aa302 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiAccount.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiAccount.java @@ -101,11 +101,11 @@ public void test010ImportAccountsFromDummyMultiGreen() throws Exception { assertUsers(getNumberOfUsers()); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); importMultiGreenAccounts(task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); // No accounts on multigreen resource yet. No users should be created. assertUsers(getNumberOfUsers()); @@ -134,11 +134,11 @@ public void test020ImportPaulAtreides() throws Exception { assertUsers(getNumberOfUsers()); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); importMultiGreenAccounts(task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); accountPaulOid = assertUserAfterByUsername(ACCOUNT_PAUL_ATREIDES_USERNAME) .displayWithProjections() @@ -178,11 +178,11 @@ public void test100ImportMuadDib() throws Exception { assertUsers(getNumberOfUsers() + 1); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); importMultiGreenAccounts(task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); accountMuaddibOid = assertUserAfterByUsername(ACCOUNT_PAUL_ATREIDES_USERNAME) .displayWithProjections() @@ -226,11 +226,11 @@ public void test102ReconcileUserPaul() throws Exception { userPaulOid = findUserByUsername(ACCOUNT_PAUL_ATREIDES_USERNAME).getOid(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(userPaulOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); accountMuaddibOid = assertUserAfter(userPaulOid) .displayWithProjections() @@ -287,11 +287,11 @@ public void test200ImportDuke() throws Exception { assertUsers(getNumberOfUsers() + 1); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); importMultiGreenAccounts(task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); accountDukeOid = assertUserAfterByUsername(ACCOUNT_PAUL_ATREIDES_USERNAME) .displayWithProjections() @@ -355,11 +355,11 @@ public void test210ImportMahdi() throws Exception { assertUsers(getNumberOfUsers() + 1); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); importMultiGreenAccounts(task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); accountMahdiOid = assertUserAfterByUsername(ACCOUNT_PAUL_ATREIDES_USERNAME) .displayWithProjections() diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiResource.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiResource.java index 6b7c7173395..103ab7f653d 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiResource.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiResource.java @@ -375,11 +375,11 @@ public void test210JackAssignDummyBeige() throws Exception { modifyUserReplace(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_BEIGE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -412,11 +412,11 @@ public void test219JackUnAssignDummyBeige() throws Exception { modifyUserReplace(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_BEIGE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -449,11 +449,11 @@ public void test220JackAssignDummyBeigeAndDefault() throws Exception { userDelta.addModification(createAssignmentModification(RESOURCE_DUMMY_OID, ShadowKindType.ACCOUNT, null, true)); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(userDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userJack = getUser(USER_JACK_OID); @@ -480,11 +480,11 @@ public void test221JackRecompute() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userJack = getUser(USER_JACK_OID); @@ -516,11 +516,11 @@ public void test223JackKillDefaultDummyAccounAndRecompute() throws Exception { display("dummy resource before", getDummyResource()); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -554,11 +554,11 @@ public void test224JackKillBeigeAccounAndRecompute() throws Exception { display("beige dummy resource before", getDummyResource(RESOURCE_DUMMY_BEIGE_NAME)); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, ModelExecuteOptions.createReconcile(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -618,11 +618,11 @@ public void test225ForceDeleteDeadShadow() throws Exception { .getOid(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); forceDeleteObject(ShadowType.class, deadBeigeShadowOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertNoShadow(deadBeigeShadowOid); @@ -673,11 +673,11 @@ public void test226JackKillBothAccountsAndRecompute() throws Exception { display("beige dummy resource before", getDummyResource(RESOURCE_DUMMY_BEIGE_NAME)); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, ModelExecuteOptions.createReconcile(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -743,12 +743,12 @@ public void test227ModifyUserJackDefaultDummyBrokenSchemaViolation() throws Exce getDummyResource().setModifyBreakMode(BreakMode.SCHEMA); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, createPolyString("Cpt. Jack Sparrow")); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertPartialError(result); assertUserAfter(USER_JACK_OID) @@ -809,12 +809,12 @@ public void test228ModifyUserJackDefaultDummyNoError() throws Exception { getDummyResource().resetBreakMode(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, createPolyString(USER_JACK_FULL_NAME)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -874,11 +874,11 @@ public void test229JackUnassignDummyBeigeAndDefault() throws Exception { userDelta.addModification(createAssignmentModification(RESOURCE_DUMMY_OID, ShadowKindType.ACCOUNT, null, false)); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(userDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); String deadShadowOid = assertUserAfter(USER_JACK_OID) @@ -955,11 +955,11 @@ public void jackAssignRoleDummies(final String TEST_NAME) throws Exception { clearJackOrganizationalUnit(task, result); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_DUMMIES_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -1019,18 +1019,18 @@ public void jackRename(final String TEST_NAME, String toName, String toFullName, Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userJack = getUser(USER_JACK_OID); PrismAsserts.assertPropertyValue(userJack, UserType.F_NAME, PrismTestUtil.createPolyString(toName)); PrismAsserts.assertPropertyValue(userJack, UserType.F_FULL_NAME, PrismTestUtil.createPolyString(toFullName)); - assertAssignedRole(USER_JACK_OID, ROLE_DUMMIES_OID, task, result); + assertAssignedRole(USER_JACK_OID, ROLE_DUMMIES_OID, result); assertLinks(userJack, 4); assertDefaultDummyAccount(toName, toFullName, true); @@ -1069,11 +1069,11 @@ public void jackUnAssignRoleDummies(final String TEST_NAME) throws Exception { .getOids(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, ROLE_DUMMIES_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -1108,11 +1108,11 @@ public void jackAssignRoleDummiesError(final String TEST_NAME, String roleOid, S .assertLinks(0); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, roleOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); display(result); TestUtil.assertResultStatus(result, OperationResultStatus.IN_PROGRESS); @@ -1166,11 +1166,11 @@ public void jackUnassignRoleDummiesError(final String TEST_NAME, String roleOid, } // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, roleOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); display(result); // there is a failure while reading dummy account - it was not created @@ -1243,11 +1243,11 @@ public void test300AddAndAssignRelative() throws Exception { assertDefaultDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_BLUE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1281,11 +1281,11 @@ public void test310AddedAccountAndUnassignRelative() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_BLUE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1321,11 +1321,11 @@ public void test319UnassignDummyRelative() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1359,7 +1359,7 @@ public void test350AddAccountLavender() throws Exception { // WHEN try { - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(userDelta, null, task, result); AssertJUnit.fail("Unexpected success"); @@ -1369,7 +1369,7 @@ public void test350AddAccountLavender() throws Exception { } // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertFailure(result); @@ -1388,11 +1388,11 @@ public void test352AddAccountIvory() throws Exception { ObjectDelta userDelta = createModifyUserAddDummyAccount(USER_JACK_OID, RESOURCE_DUMMY_IVORY_NAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(userDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1411,11 +1411,11 @@ public void test354AddAccountBeige() throws Exception { ObjectDelta userDelta = createModifyUserAddDummyAccount(USER_JACK_OID, RESOURCE_DUMMY_BEIGE_NAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(userDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1434,11 +1434,11 @@ public void test360AddAccountDummy() throws Exception { ObjectDelta userDelta = createModifyUserAddAccount(USER_JACK_OID, getDummyResourceObject()); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(userDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1460,11 +1460,11 @@ public void test362AddAccountLavender() throws Exception { ObjectDelta userDelta = createModifyUserAddDummyAccount(USER_JACK_OID, RESOURCE_DUMMY_LAVENDER_NAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(userDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1487,7 +1487,7 @@ public void test370DeleteAccountDummy() throws Exception { // WHEN try { - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(userDelta, null, task, result); AssertJUnit.fail("Unexpected success"); @@ -1497,7 +1497,7 @@ public void test370DeleteAccountDummy() throws Exception { } // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertFailure(result); @@ -1523,7 +1523,7 @@ public void test372UnlinkAccountDummy() throws Exception { // WHEN try { - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(userDelta, null, task, result); AssertJUnit.fail("Unexpected success"); @@ -1533,7 +1533,7 @@ public void test372UnlinkAccountDummy() throws Exception { } // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertFailure(result); PrismObject user = getUser(USER_JACK_OID); @@ -1553,11 +1553,11 @@ public void test374DeleteAccountLavender() throws Exception { ObjectDelta userDelta = createModifyUserDeleteDummyAccount(USER_JACK_OID, RESOURCE_DUMMY_LAVENDER_NAME); - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(userDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject user = getUser(USER_JACK_OID); @@ -1581,11 +1581,11 @@ public void test376DeleteAccountDummy() throws Exception { ObjectDelta userDelta = createModifyUserDeleteAccount(USER_JACK_OID, getDummyResourceObject()); - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(userDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertNoDummyAccount(RESOURCE_DUMMY_LAVENDER_NAME, ACCOUNT_JACK_DUMMY_USERNAME); @@ -1606,11 +1606,11 @@ public void test378DeleteAccountBeige() throws Exception { ObjectDelta userDelta = createModifyUserDeleteDummyAccount(USER_JACK_OID, RESOURCE_DUMMY_BEIGE_NAME); - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(userDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertNoDummyAccount(RESOURCE_DUMMY_LAVENDER_NAME, ACCOUNT_JACK_DUMMY_USERNAME); @@ -1632,11 +1632,11 @@ public void test379DeleteAccountIvory() throws Exception { ObjectDelta userDelta = createModifyUserDeleteDummyAccount(USER_JACK_OID, RESOURCE_DUMMY_IVORY_NAME); - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(userDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertNoDummyAccount(RESOURCE_DUMMY_LAVENDER_NAME, ACCOUNT_JACK_DUMMY_USERNAME); @@ -1664,11 +1664,11 @@ public void test380AddAccountPeru() throws Exception { ObjectDelta userDelta = createModifyUserAddDummyAccount(USER_JACK_OID, RESOURCE_DUMMY_PERU_NAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(userDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertDummyAccount(RESOURCE_DUMMY_PERU_NAME, ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true); @@ -1686,11 +1686,11 @@ public void test382AddAccountYellow() throws Exception { ObjectDelta userDelta = createModifyUserAddDummyAccount(USER_JACK_OID, RESOURCE_DUMMY_YELLOW_NAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(userDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userJack = getUser(USER_JACK_OID); @@ -1752,11 +1752,11 @@ public void test389DeleteAccountPeru() throws Exception { ObjectDelta userDelta = createModifyUserDeleteDummyAccount(USER_JACK_OID, RESOURCE_DUMMY_PERU_NAME); - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(userDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertNoDummyAccount(RESOURCE_DUMMY_PERU_NAME, ACCOUNT_JACK_DUMMY_USERNAME); @@ -1785,11 +1785,11 @@ public void test400DavidAndGoliathAssignRole() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(userBefore.getOid(), ROLE_FIGHT_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertDavidGoliath(userBefore.getOid(), "stone", USER_WORLD_NAME, true, true, true); @@ -1867,11 +1867,11 @@ public void test401DavidAndGoliathModifyOu() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(userBefore.getOid(), UserType.F_ORGANIZATIONAL_UNIT, task, result, PrismTestUtil.createPolyString("rock")); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertDavidGoliath(userBefore.getOid(), "rock", USER_WORLD_NAME, true, true, true); @@ -1914,11 +1914,11 @@ public void test403DavidAndGoliathDisableUser() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(userBefore.getOid(), ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.DISABLED); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertDavidGoliath(userBefore.getOid(), "rock", USER_WORLD_NAME, false, false, false); @@ -1951,11 +1951,11 @@ public void test404DavidAndGoliathEnableUser() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(userBefore.getOid(), ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.ENABLED); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertDavidGoliath(userBefore.getOid(), "rock", USER_WORLD_NAME, true, true, true); @@ -1990,11 +1990,11 @@ public void test405DavidAndGoliathDisableAccountDavid() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyAccountShadowReplace(accountDavidOid, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.DISABLED); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertDavidGoliath(userBefore.getOid(), "rock", USER_WORLD_NAME, true, false, true); @@ -2028,11 +2028,11 @@ public void test406DavidAndGoliathRecompute() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertDavidGoliath(userBefore.getOid(), "rock", USER_WORLD_NAME, true, false, true); @@ -2058,11 +2058,11 @@ public void test408DavidAndGoliathEnableAccountDavid() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyAccountShadowReplace(accountDavidOid, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.ENABLED); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertDavidGoliath(userBefore.getOid(), "rock", USER_WORLD_NAME, true, true, true); @@ -2092,11 +2092,11 @@ public void test410DavidAndGoliathRename() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(userBefore.getOid(), UserType.F_NAME, task, result, PrismTestUtil.createPolyString(USER_FIELD_NAME)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertDavidGoliath(userBefore.getOid(), "rock", USER_FIELD_NAME, true, true, true); @@ -2138,11 +2138,11 @@ public void test419DavidAndGoliathUnassignRole() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(userBefore.getOid(), ROLE_FIGHT_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result, 2); assertUserAfter(userBefore.getOid()) @@ -2196,11 +2196,11 @@ public void test420DavidAndGoliathAssignRoleGoliathDown() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(userBefore.getOid(), ROLE_FIGHT_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); // explicitly recompute status here. It was computed before. // Inner errors are expected - but those should be pending on retry assertInProgress(result); @@ -2263,7 +2263,7 @@ public void test421DavidAndGoliathAssignRoleGoliathUpRecompute() throws Exceptio recomputeUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(userBefore.getOid()) @@ -2319,7 +2319,7 @@ public void test422DavidAndGoliathAssignRoleGoliathUpRecompute() throws Exceptio recomputeUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(userBefore.getOid()) @@ -2370,7 +2370,7 @@ public void test423DavidAndGoliathAssignRoleGoliathUpReconcile() throws Exceptio reconcileUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertDavidGoliath(userBefore.getOid(), "rock", USER_FIELD_NAME, true, true, true); @@ -2396,11 +2396,11 @@ public void test428DavidAndGoliathUnassignRole() throws Exception { PrismObject userBefore = findUserByUsername(USER_FIELD_NAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(userBefore.getOid(), ROLE_FIGHT_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); deadShadowOid = assertUserAfter(userBefore.getOid()) @@ -2450,11 +2450,11 @@ public void test429ExpireDeadShadow() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(userBefore.getOid()) @@ -2495,11 +2495,11 @@ public void test430DavidAndGoliathAssignRoleDavidDown() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(userBefore.getOid(), ROLE_FIGHT_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); // assertInProgress(result); assertUserAfter(userBefore.getOid()) @@ -2584,11 +2584,11 @@ public void test440DavidAndGoliathAssignRoleAndCreateUserInOneStep() throws Exce dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); // assignRole(userBefore.getOid(), ROLE_FIGHT_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertDavidGoliath(userBefore.getOid(), "stone", USER_WORLD_NAME, true, true, true); @@ -2634,11 +2634,11 @@ public void test500PrepareJack() throws Exception { assertLinks(userBefore, 1); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); deleteUserAccount(USER_JACK_OID, RESOURCE_DUMMY_YELLOW_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2666,11 +2666,11 @@ public void test501JackAssignDummyDarkYellow() throws Exception { assertLinks(userBefore, 0); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_DARK_YELLOW_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2693,11 +2693,11 @@ public void test502JackAssignDummyDarkPeru() throws Exception { display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_DARK_PERU_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2724,11 +2724,11 @@ public void test504JackUnassignDummyDarkPeru() throws Exception { display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_DARK_PERU_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2752,11 +2752,11 @@ public void test507JackUnassignDummyDarkYellow() throws Exception { display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_DARK_YELLOW_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2780,11 +2780,11 @@ public void test508JackDeleteDummyDarkYellowAccount() throws Exception { display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); deleteUserAccount(USER_JACK_OID, RESOURCE_DUMMY_DARK_YELLOW_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2808,11 +2808,11 @@ public void test509JackDeleteDummyDarkPeruAccount() throws Exception { display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); deleteUserAccount(USER_JACK_OID, RESOURCE_DUMMY_DARK_PERU_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2841,11 +2841,11 @@ public void test510JackAssignRoleDarkYellowPeru() throws Exception { assertAssignments(userBefore, 0); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_DARK_YELLOW_PERU_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2872,11 +2872,11 @@ public void test519JackUnassignDarkRoleYellowPeru() throws Exception { display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, ROLE_DARK_YELLOW_PERU_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2905,11 +2905,11 @@ public void test520JackAssignRoleDarkYellowPeru() throws Exception { assertAssignments(userBefore, 0); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_DARK_YELLOW_PERU_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2937,11 +2937,11 @@ public void test529JackUnassignRoleDarkYellowPeru() throws Exception { AssignmentType currentAssignment = findAssignmentByTargetRequired(userBefore, ROLE_DARK_YELLOW_PERU_OID); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassign(UserType.class, USER_JACK_OID, currentAssignment.getId(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestAssignmentErrors.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestAssignmentErrors.java index 5250db08b21..6582f22a4b1 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestAssignmentErrors.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestAssignmentErrors.java @@ -220,12 +220,12 @@ public void test101AddUserCharlesAssignBlankAccount() throws Exception { ObjectDelta userDelta = DeltaFactory.Object.createAddDelta(userCharles); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); //we do not expect this to throw an exception. instead the fatal error in the result is excpected Collection> executedChanges = executeChanges(userDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertFailure(result); // Even though the operation failed the addition of a user should be successful. Let's check if user was really added. @@ -267,12 +267,12 @@ public void test200UserLemonheadAssignAccountBrokenNetwork() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); // not expected that it fails, instead the error in the result is expected modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display(result); // account cannot be updated due to a network error. The operation was postponed, therefore // it is "in progress". @@ -353,14 +353,14 @@ public void test210UserSharptoothAssignAccountBrokenGeneric() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); //not expected that it fails, instead the error in the result is expected modelService.executeChanges(deltas, null, task, result); assertNotReached(); } catch (GenericConnectorException e) { // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Expected exception", e); } assertFailure(result); @@ -406,11 +406,11 @@ public void test212UserSharptoothAssignAccountRecovery() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(userSharptoothOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -479,11 +479,11 @@ public void testUserSharptoothChangePasswordError(final String TEST_NAME, BreakM dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserChangePassword(userSharptoothOid, newPassword, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertStatus(result, expectedResultStatus); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestBrokenResources.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestBrokenResources.java index ebd35b71994..017b1132a86 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestBrokenResources.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestBrokenResources.java @@ -809,11 +809,11 @@ public void test400AssignTwoResouresNotFound() throws Exception { ObjectDelta userDelta = createAssignTwoResourcesDelta(RESOURCE_CSVFILE_NOTFOUND_OID); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(userDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); display("executeChanges result", result); assertPartialError(result); @@ -841,13 +841,13 @@ public void test401AssignTwoResouresBroken() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(userDelta, null, task, result); assertNotReached(); } catch (GenericConnectorException e) { // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Expected exception", e); } @@ -886,11 +886,11 @@ public void test500AssignResourceBlack() throws Exception { assertNoDummyAccount(RESOURCE_DUMMY_BLACK_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_BLACK_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -918,11 +918,11 @@ public void test502ModifyUserEmployeeNumberNone() throws Exception { prepareTest5xx(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_EMPLOYEE_NUMBER, task, result, "none"); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -950,11 +950,11 @@ public void test509UnassignResourceBlack() throws Exception { prepareTest5xx(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignAccountFromUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_BLACK_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -989,14 +989,14 @@ public void test510AssignResourceBlackError() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_BLACK_OID, null, task, result); assertNotReached(); } catch (GenericConnectorException e) { // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Expected exception", e); } @@ -1028,11 +1028,11 @@ public void test512ReconcileUser() throws Exception { prepareTest5xx(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); // Errors deep inside the results are expected assertSuccess(result, 2); @@ -1060,14 +1060,14 @@ public void test514ModifyUserEmployeeNumberRuntime() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_EMPLOYEE_NUMBER, task, result, DummyResource.POWERFAIL_ARG_ERROR_RUNTIME); assertNotReached(); } catch (RuntimeException e) { // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Expected exception", e); assertEquals("Wrong exception message", "Booom! PowerFail script failed (runtime)", e.getMessage()); } @@ -1100,14 +1100,14 @@ public void test518UnassignResourceBlack() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignAccountFromUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_BLACK_OID, null, task, result); assertNotReached(); } catch (RuntimeException e) { // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Expected exception", e); assertEquals("Wrong exception message", "Booom! PowerFail script failed (runtime)", e.getMessage()); } @@ -1140,11 +1140,11 @@ public void test519ReconcileUser() throws Exception { prepareTest5xx(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1176,11 +1176,11 @@ public void test520AssignResourceEbonyError() throws Exception { assertNoDummyAccount(RESOURCE_DUMMY_EBONY_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_EBONY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertPartialError(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1210,11 +1210,11 @@ public void test524ModifyUserEmployeeNumberRuntime() throws Exception { prepareTest5xx(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_EMPLOYEE_NUMBER, task, result, DummyResource.POWERFAIL_ARG_ERROR_RUNTIME); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertPartialError(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1247,11 +1247,11 @@ public void test528UnassignResourceEbony() throws Exception { .assertLinks(1); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignAccountFromUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_EBONY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Result", result); assertPartialError(result); @@ -1295,7 +1295,7 @@ public void test600GuybrushAssignAccountDummyViolet() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_BROKEN_VIOLET_OID, null, task, result); assertNotReached(); @@ -1304,7 +1304,7 @@ public void test600GuybrushAssignAccountDummyViolet() throws Exception { } // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertFailure(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStruct.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStruct.java index 5e460cf2937..56c55b67d26 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStruct.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStruct.java @@ -318,11 +318,11 @@ public void test208JackUnassignAll() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignAllReplace(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userJack = getUser(USER_JACK_OID); @@ -567,11 +567,11 @@ public void test230JackRecompute() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertRefs23x(); @@ -596,11 +596,11 @@ public void test232JackDestroyRefsAndRecompute() throws Exception { rememberCounter(InternalCounters.CONNECTOR_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, ModelExecuteOptions.createReconcile(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertRefs23x(); @@ -638,11 +638,11 @@ public void test234JackDestroyRefsAndLightRecompute() throws Exception { options.setReconcileFocus(true); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.recompute(UserType.class, USER_JACK_OID, options, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertRefs23x(); @@ -692,11 +692,11 @@ public void test300JackUnassignAllOrgs() throws Exception { .createModifyDelta(USER_JACK_OID, modifications, UserType.class); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(userDelta), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject userJack = getUser(USER_JACK_OID); display("User jack after", userJack); assertAssignedNoOrg(userJack); @@ -865,13 +865,13 @@ public void test310JackConflictParentOrgRefAndAssignmentsAddOrg() throws Excepti try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(orgBefore, task, result); assertNotReached(); } catch (PolicyViolationException e) { // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Expected exception", e); assertFailure(result); } @@ -1457,11 +1457,11 @@ public void test425JackUnassignDeletedOrg() throws Exception { deleteObject(OrgType.class, ORG_TEMP_OID, task, result); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignOrg(USER_JACK_OID, ORG_TEMP_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("result", result); result.computeStatus(); TestUtil.assertSuccess(result, 1); @@ -1632,11 +1632,11 @@ public void test440JackModifyEmployeeTypeRolePirate() throws Exception { assertNoAssignments(userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_JACK_OID, UserType.F_SUBTYPE, task, result, "ROLE:Pirate"); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject userAfter = getUser(USER_JACK_OID); display("User after", userAfter); assertAssignments(userAfter, 1); @@ -1769,11 +1769,11 @@ public void test510JackEndPirate() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserChangePassword(USER_JACK_OID, "X.marks.the.SPOT", task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStructCaribbean.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStructCaribbean.java index dee2e7ed177..dd2d3f9bd9d 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStructCaribbean.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStructCaribbean.java @@ -81,7 +81,7 @@ public void test100AddOrgCaribbean() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); repoAddObjectsFromFile(ORG_CARIBBEAN_FILE, OrgType.class, result); // THEN @@ -117,7 +117,7 @@ public void test102RecomputeJamaica() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.recompute(OrgType.class, ORG_CARIBBEAN_JAMAICA_OID, null, task, result); // THEN @@ -148,7 +148,7 @@ public void test103ReconcileJamaica() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); reconcileOrg(ORG_CARIBBEAN_JAMAICA_OID, task, result); // THEN @@ -179,7 +179,7 @@ public void test104RecomputeGovernor() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.recompute(OrgType.class, ORG_GOVERNOR_OFFICE_OID, null, task, result); // THEN @@ -210,7 +210,7 @@ public void test105ReconcileGovernor() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); reconcileOrg(ORG_GOVERNOR_OFFICE_OID, task, result); // THEN @@ -244,7 +244,7 @@ public void test106RecomputeDoT() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.recompute(OrgType.class, ORG_CARIBBEAN_DEPARTMENT_OF_THINGS_OID, ModelExecuteOptions.createReconcileFocus(), task, result); @@ -281,7 +281,7 @@ public void test107ReconcileDoT() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); reconcileOrg(ORG_CARIBBEAN_DEPARTMENT_OF_THINGS_OID, task, result); // THEN @@ -321,7 +321,7 @@ public void test110RecomputeDoP() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.recompute(OrgType.class, ORG_CARIBBEAN_DEPARTMENT_OF_PEOPLE_OID, null, task, result); // THEN @@ -362,7 +362,7 @@ public void test115AssignJackToDoP() throws Exception { dumpFocus("User Jack before", userJackBefore); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignOrg(USER_JACK_OID, ORG_CARIBBEAN_DEPARTMENT_OF_PEOPLE_OID, null); // THEN @@ -410,7 +410,7 @@ public void test120AssignBarbossaDoTManager() throws Exception { assertNoDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignOrg(USER_BARBOSSA_OID, ORG_CARIBBEAN_DEPARTMENT_OF_THINGS_OID, SchemaConstants.ORG_MANAGER); // THEN @@ -448,7 +448,7 @@ public void test130AssignGibbsAsJacksDeputy() throws Exception { assertNoDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_GIBBS_USERNAME); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignDeputy(USER_GIBBS_OID, USER_JACK_OID, task, result); // THEN @@ -488,7 +488,7 @@ public void test140AssignPintelAsBarbossasDeputy() throws Exception { assertNoDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_PINTEL_USERNAME); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignDeputy(USER_PINTEL_OID, USER_BARBOSSA_OID, task, result); // THEN diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStructMeta.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStructMeta.java index 41ca1323d66..18dba2fd6dc 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStructMeta.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStructMeta.java @@ -294,7 +294,7 @@ public void test890AddFictionalOrg() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); addObject(ORG_FICTIONAL_FILE, task, result); // THEN diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/AbstractPasswordTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/AbstractPasswordTest.java index 83a2cca49e3..cc860a3a5b1 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/AbstractPasswordTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/AbstractPasswordTest.java @@ -254,11 +254,11 @@ public void test051ModifyUserJackPassword() throws Exception { XMLGregorianCalendar startCal = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserChangePassword(USER_JACK_OID, USER_PASSWORD_1_CLEAR, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -321,11 +321,11 @@ public void test070AddUserHerman() throws Exception { XMLGregorianCalendar startCal = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(USER_HERMAN_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -355,11 +355,11 @@ public void test100JackAssignAccountDummy() throws Exception { XMLGregorianCalendar startCal = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -650,11 +650,11 @@ public void test122ModifyAccountUglyJackPasswordBad() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyAccountChangePassword(accountJackUglyOid, "#badPassword!", task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertPartialError(result); assertDummyPassword(RESOURCE_DUMMY_UGLY_NAME, ACCOUNT_JACK_DUMMY_USERNAME, USER_JACK_EMPLOYEE_NUMBER); @@ -679,7 +679,7 @@ public void test125ModifyJackEmployeeNumberBad() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_JACK_OID, UserType.F_EMPLOYEE_NUMBER, task, result, USER_JACK_EMPLOYEE_NUMBER_NEW_BAD); @@ -798,11 +798,11 @@ public void test132ModifyAccountBlackJackPasswordBad() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyAccountChangePassword(accountJackBlackOid, USER_PASSWORD_A_CLEAR, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertPartialError(result); assertDummyPasswordConditional(RESOURCE_DUMMY_BLACK_NAME, ACCOUNT_JACK_DUMMY_USERNAME, USER_PASSWORD_1_CLEAR); @@ -863,11 +863,11 @@ public void test140JackAssignAccountDummyYellow() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_YELLOW_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userJack = getUser(USER_JACK_OID); @@ -912,11 +912,11 @@ public void test142ModifyUserJackPasswordAA() throws Exception { lastPasswordChangeStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserChangePassword(USER_JACK_OID, USER_PASSWORD_AA_CLEAR, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertPartialError(result); lastPasswordChangeEnd = clock.currentTimeXMLGregorianCalendar(); @@ -965,11 +965,11 @@ public void test150AssignMonkeyDummyAccount() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_THREE_HEADED_MONKEY_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -998,11 +998,11 @@ public void test152ModifyUserMonkeyPassword() throws Exception { lastPasswordChangeStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserChangePassword(USER_THREE_HEADED_MONKEY_OID, USER_PASSWORD_1_CLEAR, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); lastPasswordChangeEnd = clock.currentTimeXMLGregorianCalendar(); @@ -1027,11 +1027,11 @@ public void test154ModifyUserMonkeyPasswordA() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserChangePassword(USER_THREE_HEADED_MONKEY_OID, USER_PASSWORD_A_CLEAR, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -1050,14 +1050,14 @@ public void test200ApplyPasswordPolicyHistoryLength() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); applyPasswordPolicy(PASSWORD_POLICY_GLOBAL_OID, getSecurityPolicyOid(), task, result); modifyObjectReplaceProperty(SecurityPolicyType.class, getSecurityPolicyOid(), ItemPath.create(SecurityPolicyType.F_CREDENTIALS, CredentialsPolicyType.F_PASSWORD, PasswordCredentialsPolicyType.F_HISTORY_LENGTH), task, result, 3); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); } @@ -1086,11 +1086,11 @@ public void test204UnassignAccountRed() throws Exception { .createDeleteDelta(ShadowType.class, accountJackRedOid); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(userDelta, shadowDelta), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1516,12 +1516,12 @@ public void test310PreparePasswordStrengthTests() throws Exception { unassignOrg(USER_JACK_OID, ORG_GOVERNOR_OFFICE_OID, SchemaConstants.ORG_MANAGER, task, result); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_RED_OID, null, task, result); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_BLUE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1566,11 +1566,11 @@ public void test312ChangeUserPassword() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserChangePassword(USER_JACK_OID, USER_PASSWORD_VALID_2, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1630,7 +1630,7 @@ public void test314RemovePasswordFail() throws Exception { try { // WHEN+THEN - displayWhen(TEST_NAME); + when(TEST_NAME); try { modifyUserReplace(USER_JACK_OID, PASSWORD_VALUE_PATH, task, result /*, no value */); fail("unexpected success"); @@ -1664,11 +1664,11 @@ public void test315RemovePassword() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_JACK_OID, PASSWORD_VALUE_PATH, task, result /*, no value */); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1711,11 +1711,11 @@ public void test316UserRecompute() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1761,11 +1761,11 @@ public void test318ChangeUserPassword() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserChangePassword(USER_JACK_OID, USER_PASSWORD_VALID_3, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = assertUserAfter(USER_JACK_OID) @@ -1812,11 +1812,11 @@ public void test320ChangeEmployeeNumber() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_JACK_OID, UserType.F_EMPLOYEE_NUMBER, task, result, "emp0000"); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1845,11 +1845,11 @@ public void test330RemoveEmployeeNumber() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_JACK_OID, UserType.F_EMPLOYEE_NUMBER, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1884,7 +1884,7 @@ public void test340ModifyUserMonkeyPasswordAA() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserChangePassword(USER_THREE_HEADED_MONKEY_OID, USER_PASSWORD_AA_CLEAR, task, result); @@ -1895,7 +1895,7 @@ public void test340ModifyUserMonkeyPasswordAA() throws Exception { } // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertFailure(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -1919,11 +1919,11 @@ public void test341RecomputeMonkey() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_THREE_HEADED_MONKEY_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -1947,11 +1947,11 @@ public void test342ReconcileMonkey() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_THREE_HEADED_MONKEY_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -1980,11 +1980,11 @@ public void test343ModifyUserMonkeyDescription() throws Exception { assertDummyAccount(null, USER_THREE_HEADED_MONKEY_NAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_THREE_HEADED_MONKEY_OID, UserType.F_DESCRIPTION, task, result, "Look behind you! A three-headed MONKEY!"); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -2011,12 +2011,12 @@ public void test344ModifyUserMonkeyLocality() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_THREE_HEADED_MONKEY_OID, UserType.F_LOCALITY, task, result, createPolyString("Monkey Island")); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -2045,12 +2045,12 @@ public void test345AssignMonkeyAccountBlue() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_THREE_HEADED_MONKEY_OID, RESOURCE_DUMMY_BLUE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertPartialError(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -2075,12 +2075,12 @@ public void test346UnassignMonkeyAccountBlue() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignAccountFromUser(USER_THREE_HEADED_MONKEY_OID, RESOURCE_DUMMY_BLUE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -2108,12 +2108,12 @@ public void test347AssignMonkeyAccountYellow() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_THREE_HEADED_MONKEY_OID, RESOURCE_DUMMY_YELLOW_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertPartialError(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -2136,12 +2136,12 @@ public void test348UnassignMonkeyAccountYellow() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignAccountFromUser(USER_THREE_HEADED_MONKEY_OID, RESOURCE_DUMMY_YELLOW_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -2170,11 +2170,11 @@ public void test349AssignMonkeyPirate() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_THREE_HEADED_MONKEY_OID, ROLE_PIRATE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -2205,11 +2205,11 @@ public void test350DisableMonkey() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_THREE_HEADED_MONKEY_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.DISABLED); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -2240,11 +2240,11 @@ public void test351EnableMonkey() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_THREE_HEADED_MONKEY_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.ENABLED); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -2275,11 +2275,11 @@ public void test352UnassignMonkeyPirate() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_THREE_HEADED_MONKEY_OID, ROLE_PIRATE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -2309,11 +2309,11 @@ public void test354ModifyUserMonkeyPasswordValid1() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserChangePassword(USER_THREE_HEADED_MONKEY_OID, USER_PASSWORD_VALID_1, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -2337,11 +2337,11 @@ public void test355ModifyUserMonkeyDescriptionAgain() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_THREE_HEADED_MONKEY_OID, UserType.F_DESCRIPTION, task, result, "Look behind you! A three-headed MONKEY!"); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -2373,11 +2373,11 @@ public void test400AddUserRappWithAssignment() throws Exception { display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(userBefore, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_RAPP_OID); @@ -2414,11 +2414,11 @@ public void test401UserRappRecompute() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_RAPP_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_RAPP_OID); @@ -2458,11 +2458,11 @@ public void test402AssignRappDummyRed() throws Exception { display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_RAPP_OID, RESOURCE_DUMMY_RED_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_RAPP_OID); @@ -2522,11 +2522,11 @@ public void test403UserRappRecompute() throws Exception { display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_RAPP_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_RAPP_OID); @@ -2587,11 +2587,11 @@ public void test404InitializeRappDummyRed() throws Exception { ObjectDelta shadowDelta = createAccountInitializationDelta(accountRedOid, USER_PASSWORD_VALID_1); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(shadowDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_RAPP_OID); @@ -2649,11 +2649,11 @@ public void test405UserRappRecompute() throws Exception { display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_RAPP_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2712,11 +2712,11 @@ public void test410AssignRappDummyLifecycle() throws Exception { display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_RAPP_OID, RESOURCE_DUMMY_LIFECYCLE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2767,11 +2767,11 @@ public void test412InitializeRappDummyLifecycle() throws Exception { shadowDelta.addModificationReplaceProperty(ObjectType.F_LIFECYCLE_STATE, SchemaConstants.LIFECYCLE_ACTIVE); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(shadowDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2836,11 +2836,11 @@ public void test414UserRappRecompute() throws Exception { display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_RAPP_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_RAPP_OID); @@ -2906,11 +2906,11 @@ public void test416UserRappSubtypeWreck() throws Exception { display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_RAPP_OID, UserType.F_SUBTYPE, task, result, "WRECK"); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_RAPP_OID); @@ -2984,11 +2984,11 @@ public void test420AddUserDrakeWithAssignment() throws Exception { display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(userBefore, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); String accountOid = assertUserAfter(USER_DRAKE_OID) @@ -3035,11 +3035,11 @@ public void test500JackAssignResourceSouvenir() throws Exception { assertUserPassword(userBefore, USER_PASSWORD_VALID_3); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_SOUVENIR_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3084,11 +3084,11 @@ public void test502JackInitializeAccountSouvenir() throws Exception { ObjectDelta shadowDelta = createAccountInitializationDelta(accountJackSouvenirOid, PASSWORD_ALLIGATOR); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(shadowDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3134,11 +3134,11 @@ public void test510JackAssignResourceMaverick() throws Exception { assertUserPassword(userBefore, USER_PASSWORD_VALID_3); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_MAVERICK_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3174,11 +3174,11 @@ public void test512JackInitializeAccountMaverickAlligator() throws Exception { ObjectDelta shadowDelta = createAccountInitializationDelta(accountJackMaverickOid, PASSWORD_ALLIGATOR); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(shadowDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertPartialError(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3210,11 +3210,11 @@ public void test514JackInitializeAccountMaverickCrododile() throws Exception { ObjectDelta shadowDelta = createAccountInitializationDelta(accountJackMaverickOid, PASSWORD_CROCODILE); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(shadowDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3248,11 +3248,11 @@ public void test516JackChangePasswordResourceMaverickAlligator() throws Exceptio prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyAccountChangePassword(accountJackMaverickOid, PASSWORD_ALLIGATOR, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertPartialError(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3278,11 +3278,11 @@ public void test518JackChangePasswordResourceMaverickGiantLizard() throws Except prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyAccountChangePassword(accountJackMaverickOid, PASSWORD_GIANT_LIZARD, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3313,11 +3313,11 @@ public void test530JackUnassignResourceSouvenir() throws Exception { assertLinks(userBefore, 6); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_SOUVENIR_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3350,11 +3350,11 @@ public void test532JackChangePasswordResourceBlueAlligator() throws Exception { accountJackBlueOid = assertAccount(userBefore, RESOURCE_DUMMY_BLUE_OID); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyAccountChangePassword(accountJackBlueOid, PASSWORD_ALLIGATOR, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3383,11 +3383,11 @@ public void test535ModifyUserJackPasswordAlligator() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserChangePassword(USER_JACK_OID, PASSWORD_ALLIGATOR, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3419,11 +3419,11 @@ public void test539JackUnassignResourceMaverick() throws Exception { assertLinks(userBefore, 5); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_MAVERICK_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3483,11 +3483,11 @@ private void testJackManyPasswordChangesAttempt(String TEST_NAME, String passwor } // WHEN - displayWhen(TEST_NAME + "-" + i); + when(TEST_NAME + "-" + i); modifyUserReplace(USER_JACK_OID, PASSWORD_VALUE_PATH, task, result, userPasswordPs); // THEN - displayThen(TEST_NAME + "-" + i); + then(TEST_NAME + "-" + i); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3531,11 +3531,11 @@ public void test560ChangeJackPasswordSuperuser() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserChangePassword(USER_JACK_OID, USER_PASSWORD_VALID_4, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); login(USER_ADMINISTRATOR_USERNAME); assertSuccess(result); @@ -3600,11 +3600,11 @@ public void test562ChangeJackPasswordSelfService() throws Exception { USER_PASSWORD_VALID_4, USER_PASSWORD_VALID_5); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(objectDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); login(USER_ADMINISTRATOR_USERNAME); assertSuccess(result); @@ -3672,11 +3672,11 @@ public void test564ChangeJackPasswordAdmin() throws Exception { USER_PASSWORD_VALID_5, USER_PASSWORD_VALID_6); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(objectDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); login(USER_ADMINISTRATOR_USERNAME); assertSuccess(result); @@ -3941,7 +3941,7 @@ public void test910AddUserWithNoPasswordFail() throws Exception { try { // WHEN+THEN - displayWhen(TEST_NAME); + when(TEST_NAME); try { UserType user = new UserType(prismContext).name("passwordless"); addObject(user.asPrismObject(), task, result); @@ -4197,7 +4197,7 @@ public void test950RemoveGlobalPasswordPolicy() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); applyPasswordPolicy(null, getSecurityPolicyOid(), task, result); modifyObjectReplaceProperty(SecurityPolicyType.class, getSecurityPolicyOid(), ItemPath.create(SecurityPolicyType.F_CREDENTIALS, CredentialsPolicyType.F_PASSWORD, PasswordCredentialsPolicyType.F_HISTORY_LENGTH), @@ -4210,7 +4210,7 @@ public void test950RemoveGlobalPasswordPolicy() throws Exception { task, result /* no value */); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject securityPolicyAfter = getObject(SecurityPolicyType.class, getSecurityPolicyOid()); @@ -4249,11 +4249,11 @@ public void test952SetupOrgPolicy() throws Exception { OrgType.F_SECURITY_POLICY_REF, task, result, securityPolicyRef); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignOrg(USER_THREE_HEADED_MONKEY_OID, ORG_MINISTRY_OF_OFFENSE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject ministryPolicyAfter = getObject(OrgType.class, ORG_MINISTRY_OF_OFFENSE_OID); @@ -4284,7 +4284,7 @@ public void test954ModifyUserMonkeyPasswordAA() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserChangePassword(USER_THREE_HEADED_MONKEY_OID, USER_PASSWORD_AA_CLEAR, task, result); @@ -4295,7 +4295,7 @@ public void test954ModifyUserMonkeyPasswordAA() throws Exception { } // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertFailure(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -4318,12 +4318,12 @@ public void test956ModifyUserJackPasswordAA() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserChangePassword(USER_JACK_OID, USER_PASSWORD_AA_CLEAR, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -4347,11 +4347,11 @@ public void test961RecomputeMonkey() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_THREE_HEADED_MONKEY_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -4375,11 +4375,11 @@ public void test962ReconcileMonkey() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_THREE_HEADED_MONKEY_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -4403,12 +4403,12 @@ public void test964ModifyUserMonkeyLocality() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_THREE_HEADED_MONKEY_OID, UserType.F_LOCALITY, task, result, createPolyString("Scabb Island")); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -4437,12 +4437,12 @@ public void test965AssignMonkeyAccountBlue() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_THREE_HEADED_MONKEY_OID, RESOURCE_DUMMY_BLUE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -4471,12 +4471,12 @@ public void test966AssignMonkeyAccountYellow() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_THREE_HEADED_MONKEY_OID, RESOURCE_DUMMY_YELLOW_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertPartialError(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -4513,14 +4513,14 @@ public void test970ReapplyGlobalPasswordPolicy() throws Exception { modifyUserChangePassword(USER_JACK_OID, USER_PASSWORD_A_CLEAR); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); applyPasswordPolicy(PASSWORD_POLICY_GLOBAL_OID, getSecurityPolicyOid(), task, result); modifyObjectReplaceProperty(SecurityPolicyType.class, getSecurityPolicyOid(), ItemPath.create(SecurityPolicyType.F_CREDENTIALS, CredentialsPolicyType.F_PASSWORD, PasswordCredentialsPolicyType.F_HISTORY_LENGTH), task, result, GLOBAL_POLICY_NEW_PASSWORD_HISTORY_LENGTH); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject securityPolicyAfter = getObject(SecurityPolicyType.class, getSecurityPolicyOid()); @@ -4547,7 +4547,7 @@ public void test972ChangePasswordJack() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserChangePassword(USER_JACK_OID, USER_PASSWORD_VALID_1); modifyUserChangePassword(USER_JACK_OID, USER_PASSWORD_VALID_2); @@ -4568,7 +4568,7 @@ public void test972ChangePasswordJack() throws Exception { modifyUserChangePassword(USER_JACK_OID, USER_PASSWORD_VALID_1); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); } @@ -4589,7 +4589,7 @@ public void test974ChangePasswordJack() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserChangePassword(USER_THREE_HEADED_MONKEY_OID, USER_PASSWORD_VALID_1); modifyUserChangePassword(USER_THREE_HEADED_MONKEY_OID, USER_PASSWORD_VALID_2); @@ -4610,7 +4610,7 @@ public void test974ChangePasswordJack() throws Exception { modifyUserChangePassword(USER_THREE_HEADED_MONKEY_OID, USER_PASSWORD_VALID_2); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); } diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefault.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefault.java index 3e688e97d2d..05c126c9789 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefault.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefault.java @@ -65,11 +65,11 @@ public void test202ReconcileUserJack() throws Exception { assertLinks(userBefore, 4); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertPartialError(result); PrismObject userAfter = getUser(USER_JACK_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefaultHashing.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefaultHashing.java index 55ec6095dca..c3e82a13fa5 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefaultHashing.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefaultHashing.java @@ -152,12 +152,12 @@ public void test345AssignMonkeyAccountBlue() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_THREE_HEADED_MONKEY_OID, RESOURCE_DUMMY_BLUE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -200,12 +200,12 @@ public void test347AssignMonkeyAccountYellow() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_THREE_HEADED_MONKEY_OID, RESOURCE_DUMMY_YELLOW_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -250,12 +250,12 @@ public void test966AssignMonkeyAccountYellow() throws Exception { prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_THREE_HEADED_MONKEY_OID, RESOURCE_DUMMY_YELLOW_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/AbstractPersonaTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/AbstractPersonaTest.java index 6896cbc8772..63b4e41e6a4 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/AbstractPersonaTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/AbstractPersonaTest.java @@ -64,11 +64,11 @@ public void test100AssignRolePersonaAdminToJack() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_PERSONA_ADMIN_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -100,11 +100,11 @@ public void test102RecomputeUserJack() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserJack11x(); @@ -119,11 +119,11 @@ public void test103ReconcileUserJack() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserJack11x(); @@ -138,11 +138,11 @@ public void test104RecomputeJackAdminPersona() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(userJackAdminPersonaOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserJack11x(); @@ -157,11 +157,11 @@ public void test105ReconcileJackAdminPersona() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(userJackAdminPersonaOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserJack11x(); @@ -193,11 +193,11 @@ public void test120ModifyJackGivenName() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_JACK_OID, UserType.F_GIVEN_NAME, task, result, createPolyString(USER_JACK_GIVEN_NAME_NEW)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -232,11 +232,11 @@ public void test140ModifyUserJackPassword() throws Exception { XMLGregorianCalendar startCal = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserChangePassword(USER_JACK_OID, USER_PASSWORD_2_CLEAR, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -269,11 +269,11 @@ public void test142ModifyPersonaPassword() throws Exception { XMLGregorianCalendar startCal = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserChangePassword(personaBefore.getOid(), USER_PASSWORD_3_CLEAR, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -309,11 +309,11 @@ public void test145ModifyPersonaPasswordBack() throws Exception { XMLGregorianCalendar startCal = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserChangePassword(personaBefore.getOid(), USER_PASSWORD_2_CLEAR, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -344,11 +344,11 @@ public void test199UnassignRolePersonaAdminFromJack() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, ROLE_PERSONA_ADMIN_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/TestPersonaPassword.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/TestPersonaPassword.java index c9937298746..41cb92f31c7 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/TestPersonaPassword.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/TestPersonaPassword.java @@ -82,7 +82,7 @@ public void test145ModifyPersonaPasswordBack() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserChangePassword(personaBefore.getOid(), USER_PASSWORD_2_CLEAR, task, result); @@ -93,7 +93,7 @@ public void test145ModifyPersonaPasswordBack() throws Exception { } // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertFailure(result); XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestAssignmentValidity.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestAssignmentValidity.java index e65e83aed69..80283c31490 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestAssignmentValidity.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestAssignmentValidity.java @@ -63,11 +63,11 @@ public void test100JackAssignRolePirateValidTo() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, activationType, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -97,11 +97,11 @@ public void test102Forward15min() throws Exception { clockForward("PT15M"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -131,11 +131,11 @@ public void test104JackAssignRolePirateAgain() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -161,11 +161,11 @@ public void test106JackUnassignRolePirateValid() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -208,12 +208,12 @@ public void test110JackAssignRolePirateValidToRaw() throws Exception { ModelExecuteOptions options = ModelExecuteOptions.createRaw(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserAssignment(USER_JACK_OID, ROLE_PIRATE_OID, RoleType.COMPLEX_TYPE, null, task, null, activationType, true, options, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -241,11 +241,11 @@ public void test111RecomputeJack() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -273,11 +273,11 @@ public void test112Forward15min() throws Exception { clockForward("PT15M"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -307,11 +307,11 @@ public void test114JackAssignRolePirateAgain() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -354,11 +354,11 @@ public void test120JackAssignRoleSailorValidTo() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, activationType, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -388,11 +388,11 @@ public void test122Forward15min() throws Exception { clockForward("PT15M"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -422,11 +422,11 @@ public void test124JackAssignRoleSailorAgain() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -470,12 +470,12 @@ public void test130JackAssignRoleSailorValidToRaw() throws Exception { ModelExecuteOptions options = ModelExecuteOptions.createRaw(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserAssignment(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, RoleType.COMPLEX_TYPE, null, task, null, activationType, true, options, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -503,11 +503,11 @@ public void test131RecomputeJack() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -535,11 +535,11 @@ public void test132Forward15min() throws Exception { clockForward("PT15M"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -569,11 +569,11 @@ public void test134JackAssignRoleSailorAgain() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -617,12 +617,12 @@ public void test140JackAssignRoleSailorValidToRaw() throws Exception { ModelExecuteOptions options = ModelExecuteOptions.createRaw(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserAssignment(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, RoleType.COMPLEX_TYPE, null, task, null, activationType, true, options, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -647,12 +647,12 @@ public void test142Forward15min() throws Exception { Task task = getTestTask(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); clockForward("PT15M"); // do NOT recompute // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); @@ -681,11 +681,11 @@ public void test144JackAssignRoleSailorAgain() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -721,11 +721,11 @@ public void test150JackAssignRolePirate() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -760,11 +760,11 @@ public void test151JackAssignRoleSailorValidTo() throws Exception { activationType.setValidTo(jackPirateValidTo); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, activationType, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -796,11 +796,11 @@ public void test153Forward15min() throws Exception { clockForward("PT15M"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -830,11 +830,11 @@ public void test154JackAssignRoleSailorAgain() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -868,11 +868,11 @@ public void test160JackAssignRolePirate() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -908,12 +908,12 @@ public void test161JackAssignRoleSailorValidToRaw() throws Exception { ModelExecuteOptions options = ModelExecuteOptions.createRaw(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserAssignment(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, RoleType.COMPLEX_TYPE, null, task, null, activationType, true, options, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -951,11 +951,11 @@ public void test162RecomputeJack() throws Exception { activationType.setValidTo(jackPirateValidTo); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -987,11 +987,11 @@ public void test163Forward15min() throws Exception { clockForward("PT15M"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1021,11 +1021,11 @@ public void test164JackAssignRoleSailorAgain() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1059,11 +1059,11 @@ public void test170JackAssignRolePirate() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1097,11 +1097,11 @@ public void test171JackAssignRoleWeakSingerValidTo() throws Exception { activationType.setValidTo(jackPirateValidTo); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_WEAK_SINGER_OID, activationType, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1133,11 +1133,11 @@ public void test173Forward15min() throws Exception { clockForward("PT15M"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1168,11 +1168,11 @@ public void test174JackAssignRoleSingerAgain() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_WEAK_SINGER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1211,12 +1211,12 @@ public void test180JackAssignRoleSailorValidToRaw() throws Exception { activationType.setValidTo(jackPirateValidTo); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserAssignment(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, RoleType.COMPLEX_TYPE, null, task, null, activationType, true, ModelExecuteOptions.createRaw(), result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1243,12 +1243,12 @@ public void test182Forward15minAndAssignRaw() throws Exception { clockForward("PT15M"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserAssignment(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, RoleType.COMPLEX_TYPE, null, task, null, null, true, ModelExecuteOptions.createRaw(), result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); @@ -1272,11 +1272,11 @@ public void test184RecomputeJack() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1313,12 +1313,12 @@ public void test200JackAssignCurrentPirateFutureSailor() throws Exception { activationType.setValidFrom(getTimestamp("P1M")); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); assignRole(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, activationType, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1346,11 +1346,11 @@ public void test202RecomputeJack() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1376,11 +1376,11 @@ public void test204ReconcileJack() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1416,12 +1416,12 @@ public void test210JackAssignCurrentPirateFutureRichSailor() throws Exception { activationType.setValidFrom(getTimestamp("P1M")); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); assignRole(USER_JACK_OID, ROLE_STRONG_RICH_SAILOR_OID, activationType, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1449,11 +1449,11 @@ public void test212RecomputeJack() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1479,11 +1479,11 @@ public void test214ReconcileJack() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1519,11 +1519,11 @@ public void test220JackAssignFutureRichSailor() throws Exception { activationType.setValidFrom(getTimestamp("P1M")); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_STRONG_RICH_SAILOR_OID, activationType, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1563,14 +1563,14 @@ public void test230JackAssignRoleStrongRichSailorValidTo() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); // beware of the order: weapon is weak and is set differently by role (cutlass) and resource (from user extension: pistol, mouth) // the assert expects cutlass, so the pirate role assignment must go first assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); assignRole(USER_JACK_OID, ROLE_STRONG_RICH_SAILOR_OID, activationType, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -1600,11 +1600,11 @@ public void test232Forward15min() throws Exception { clockForward("PT15M"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1644,14 +1644,14 @@ public void test240JackAssignRoleRichSailorValidTo() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); // beware of the order: weapon is weak and is set differently by role (cutlass) and resource (from user extension: pistol, mouth) // the assert expects cutlass, so the pirate role assignment must go first assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); assignRole(USER_JACK_OID, ROLE_RICH_SAILOR_OID, activationType, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -1681,11 +1681,11 @@ public void test242Forward15min() throws Exception { clockForward("PT15M"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1722,14 +1722,14 @@ public void test250JackAssignFocusExistsResource() throws Exception { AssignmentType assignment = ObjectTypeUtil.createAssignmentTo(resourceDummyFocusExists, prismContext).activation(activation); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ObjectDelta delta = prismContext.deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT).add(assignment) .asObjectDeltaCast(USER_JACK_OID); executeChanges(delta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1754,11 +1754,11 @@ public void test252RecomputeJack() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1783,11 +1783,11 @@ public void test254ReconcileJack() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1884,11 +1884,11 @@ private void unassignAll(final String TEST_NAME) throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignAll(userBefore, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestRbac.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestRbac.java index 4a963bff043..6dc75cf4c3a 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestRbac.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestRbac.java @@ -6,25 +6,14 @@ */ package com.evolveum.midpoint.model.intest.rbac; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.*; import java.util.ArrayList; import java.util.Collection; import java.util.List; - import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; -import com.evolveum.midpoint.notifications.api.transports.Message; -import com.evolveum.midpoint.prism.*; -import com.evolveum.midpoint.prism.delta.*; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.prism.polystring.PolyString; -import com.evolveum.midpoint.util.QNameUtil; -import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; @@ -37,6 +26,16 @@ import com.evolveum.midpoint.model.api.context.EvaluatedAssignmentTarget; import com.evolveum.midpoint.model.api.context.EvaluatedConstruction; import com.evolveum.midpoint.model.api.context.ModelContext; +import com.evolveum.midpoint.notifications.api.transports.Message; +import com.evolveum.midpoint.prism.PrismContainer; +import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.prism.PrismProperty; +import com.evolveum.midpoint.prism.PrismPropertyDefinition; +import com.evolveum.midpoint.prism.delta.DeltaSetTriple; +import com.evolveum.midpoint.prism.delta.ItemDelta; +import com.evolveum.midpoint.prism.delta.ObjectDelta; +import com.evolveum.midpoint.prism.path.ItemPath; +import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.prism.schema.PrismSchema; import com.evolveum.midpoint.prism.util.PrismAsserts; @@ -49,14 +48,15 @@ import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DOMUtil; +import com.evolveum.midpoint.util.QNameUtil; import com.evolveum.midpoint.util.exception.PolicyViolationException; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.EvaluationTimeType; /** * @author semancik - * */ -@ContextConfiguration(locations = {"classpath:ctx-model-intest-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-model-intest-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public class TestRbac extends AbstractRbacTest { @@ -151,7 +151,7 @@ public void test101JackAssignRolePirate() throws Exception { assignRole(USER_JACK_OID, ROLE_PIRATE_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -159,7 +159,7 @@ public void test101JackAssignRolePirate() throws Exception { display("User jack after", userAfter); assertModifyMetadata(userAfter, startTs, endTs); - AssignmentType assignmentType = assertAssignedRole(userAfter, ROLE_PIRATE_OID, task, result); + AssignmentType assignmentType = assertAssignedRole(userAfter, ROLE_PIRATE_OID); assertCreateMetadata(assignmentType, startTs, endTs); assertEffectiveActivation(assignmentType, ActivationStatusType.ENABLED); assertRoleMembershipRef(userAfter, ROLE_PIRATE_OID); @@ -193,25 +193,25 @@ public void test102JackModifyUserLocality() throws Exception { OperationResult result = task.getResult(); // gossip is a tolerant attribute. Make sure there there is something to tolerate - DummyAccount jackDummyAccount = getDummyAccount(null, ACCOUNT_JACK_DUMMY_USERNAME); - jackDummyAccount.addAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME, - EXISTING_GOSSIP); + DummyAccount jackDummyAccount = getDummyAccount(null, ACCOUNT_JACK_DUMMY_USERNAME); + jackDummyAccount.addAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME, + EXISTING_GOSSIP); - XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); + XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN modifyUserReplace(USER_JACK_OID, UserType.F_LOCALITY, getDefaultOptions(), task, result, createPolyString(LOCALITY_TORTUGA)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - AssignmentType assignmentType = assertAssignedRole(userAfter, ROLE_PIRATE_OID, task, result); + AssignmentType assignmentType = assertAssignedRole(userAfter, ROLE_PIRATE_OID); assertRoleMembershipRef(userAfter, ROLE_PIRATE_OID); assertDelegatedRef(userAfter); assertDefaultDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true); @@ -237,7 +237,7 @@ public void test110UnAssignRolePirate() throws Exception { unassignRole(USER_JACK_OID, ROLE_PIRATE_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -270,7 +270,7 @@ public void test120JackAssignRolePirateWhileAlreadyHasAccount() throws Exception ObjectDelta delta = prismContext.deltaFactory().object() .createModificationAddReference(UserType.class, USER_JACK_OID, - UserType.F_LINK_REF, account); + UserType.F_LINK_REF, account); Collection> deltas = MiscSchemaUtil.createCollection(delta); // We need to switch off the enforcement for this operation. Otherwise we won't be able to create the account @@ -283,16 +283,16 @@ public void test120JackAssignRolePirateWhileAlreadyHasAccount() throws Exception assertDefaultDummyAccountAttribute(ACCOUNT_JACK_DUMMY_USERNAME, "weapon", "rum"); // gossip is a tolerant attribute. Make sure there there is something to tolerate - DummyAccount jackDummyAccount = getDummyAccount(null, ACCOUNT_JACK_DUMMY_USERNAME); - jackDummyAccount.addAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME, - EXISTING_GOSSIP); + DummyAccount jackDummyAccount = getDummyAccount(null, ACCOUNT_JACK_DUMMY_USERNAME); + jackDummyAccount.addAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME, + EXISTING_GOSSIP); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -313,8 +313,6 @@ public void test120JackAssignRolePirateWhileAlreadyHasAccount() throws Exception } - - @Test public void test121JackAssignAccountImplicitIntent() throws Exception { final String TEST_NAME = "test121JackAssignAccountImplicitIntent"; @@ -482,7 +480,7 @@ public void test130JackAssignRolePirateWithSeaInAssignment() throws Exception { PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_PIRATE_OID, task, result); + assertAssignedRole(userAfter, ROLE_PIRATE_OID); assertRoleMembershipRef(userAfter, ROLE_PIRATE_OID); assertDelegatedRef(userAfter); assertDefaultDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true); @@ -544,7 +542,7 @@ public void test134JackAssignRoleAdriaticPirate() throws Exception { PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_ADRIATIC_PIRATE_OID, task, result); + assertAssignedRole(userAfter, ROLE_ADRIATIC_PIRATE_OID); assertRoleMembershipRef(userAfter, ROLE_ADRIATIC_PIRATE_OID, ROLE_PIRATE_OID); assertDelegatedRef(userAfter); assertDefaultDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true); @@ -642,7 +640,7 @@ public void test137JackAssignRoleAdriaticPirateWithSeaInAssignment() throws Exce PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_ADRIATIC_PIRATE_OID, task, result); + assertAssignedRole(userAfter, ROLE_ADRIATIC_PIRATE_OID); assertRoleMembershipRef(userAfter, ROLE_ADRIATIC_PIRATE_OID, ROLE_PIRATE_OID); assertDelegatedRef(userAfter); assertDefaultDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true); @@ -700,7 +698,7 @@ public void test144JackAssignRoleBlackSeaPirate() throws Exception { PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_BLACK_SEA_PIRATE_OID, task, result); + assertAssignedRole(userAfter, ROLE_BLACK_SEA_PIRATE_OID); assertRoleMembershipRef(userAfter, ROLE_BLACK_SEA_PIRATE_OID, ROLE_PIRATE_OID); assertDelegatedRef(userAfter); @@ -760,7 +758,7 @@ public void test147JackAssignRoleBlackSeaPirateWithSeaInAssignment() throws Exce PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_BLACK_SEA_PIRATE_OID, task, result); + assertAssignedRole(userAfter, ROLE_BLACK_SEA_PIRATE_OID); assertRoleMembershipRef(userAfter, ROLE_BLACK_SEA_PIRATE_OID, ROLE_PIRATE_OID); assertDelegatedRef(userAfter); @@ -812,18 +810,18 @@ public void test154JackAssignRoleIndianOceanPirate() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_INDIAN_OCEAN_PIRATE_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); display("Result", result); TestUtil.assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_INDIAN_OCEAN_PIRATE_OID, task, result); + assertAssignedRole(userAfter, ROLE_INDIAN_OCEAN_PIRATE_OID); assertRoleMembershipRef(userAfter, ROLE_INDIAN_OCEAN_PIRATE_OID, ROLE_PIRATE_OID); assertDelegatedRef(userAfter); @@ -860,7 +858,6 @@ public void test156JackUnAssignRoleIndianOceanPirate() throws Exception { assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME); } - /** * Approver relation is not supposed to give any role privileges. * MID-3580 @@ -925,21 +922,21 @@ public void testJackAssignRolePirateRelationNoPrivs(final String TEST_NAME, QNam assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME); // WHEN (1) - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, relation, getDefaultOptions(), task, result); // THEN (1) - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertJackAssignRolePirateRelationNoPrivs(relation); // WHEN (2) - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, getDefaultOptions(), task, result); // THEN (2) - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertJackAssignRolePirateRelationNoPrivs(relation); @@ -969,7 +966,7 @@ public void testJackUnassignRolePirateRelationNoPrivs(final String TEST_NAME, QN unassignRole(USER_JACK_OID, ROLE_PIRATE_OID, relation, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -1028,7 +1025,7 @@ public void test202JackAssignRoleAllTreasure() throws Exception { PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_ALL_TREASURE_OID, task, result); + assertAssignedRole(userAfter, ROLE_ALL_TREASURE_OID); assertRoleMembershipRef(userAfter, ROLE_ALL_TREASURE_OID, ROLE_TREASURE_BRONZE_OID, ROLE_TREASURE_SILVER_OID); assertDelegatedRef(userAfter); @@ -1059,7 +1056,7 @@ public void test204AddGoldTreasureAndRecomputeJack() throws Exception { PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_ALL_TREASURE_OID, task, result); + assertAssignedRole(userAfter, ROLE_ALL_TREASURE_OID); assertRoleMembershipRef(userAfter, ROLE_ALL_TREASURE_OID, ROLE_TREASURE_BRONZE_OID, ROLE_TREASURE_SILVER_OID, ROLE_TREASURE_GOLD_OID); assertDelegatedRef(userAfter); @@ -1087,7 +1084,7 @@ public void test206JackAssignRoleAllLoot() throws Exception { PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_ALL_TREASURE_OID, task, result); + assertAssignedRole(userAfter, ROLE_ALL_TREASURE_OID); assertRoleMembershipRef(userAfter, ROLE_ALL_TREASURE_OID, ROLE_TREASURE_BRONZE_OID, ROLE_TREASURE_SILVER_OID, ROLE_TREASURE_GOLD_OID, ROLE_ALL_LOOT_OID, ROLE_LOOT_DIAMONDS_OID); @@ -1113,7 +1110,7 @@ public void test208JackUnassignRoleAllLoot() throws Exception { PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_ALL_TREASURE_OID, task, result); + assertAssignedRole(userAfter, ROLE_ALL_TREASURE_OID); assertRoleMembershipRef(userAfter, ROLE_ALL_TREASURE_OID, ROLE_TREASURE_BRONZE_OID, ROLE_TREASURE_SILVER_OID, ROLE_TREASURE_GOLD_OID); assertDelegatedRef(userAfter); @@ -1146,7 +1143,7 @@ public void test209JackUnassignRoleAllTreasure() throws Exception { /** * MID-3966 */ - @Test(enabled=false) // MID-3966 + @Test(enabled = false) // MID-3966 public void test210JackAssignRoleAllYouCanGet() throws Exception { final String TEST_NAME = "test210JackAssignRoleAllYouCanGet"; @@ -1161,7 +1158,7 @@ public void test210JackAssignRoleAllYouCanGet() throws Exception { PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_ALL_YOU_CAN_GET_OID, task, result); + assertAssignedRole(userAfter, ROLE_ALL_YOU_CAN_GET_OID); assertRoleMembershipRef(userAfter, ROLE_ALL_YOU_CAN_GET_OID, ROLE_TREASURE_BRONZE_OID, ROLE_TREASURE_SILVER_OID, ROLE_TREASURE_GOLD_OID, ROLE_LOOT_DIAMONDS_OID); @@ -1172,7 +1169,7 @@ public void test210JackAssignRoleAllYouCanGet() throws Exception { "Silver treasure", "Bronze treasure", "Golden treasure", "Diamond loot"); } - @Test(enabled=false) // MID-3966 + @Test(enabled = false) // MID-3966 public void test219JackUnassignRoleAllYouCanGet() throws Exception { final String TEST_NAME = "test219JackUnassignRoleAllYouCanGet"; @@ -1215,7 +1212,7 @@ public void test501JackAssignRolePirate() throws Exception { PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_PIRATE_OID, task, result); + assertAssignedRole(userAfter, ROLE_PIRATE_OID); assertRoleMembershipRef(userAfter, ROLE_PIRATE_OID); assertDelegatedRef(userAfter); @@ -1240,21 +1237,21 @@ public void test502JackModifyUserLocality() throws Exception { OperationResult result = task.getResult(); // gossip is a tolerant attribute. Make sure there there is something to tolerate - DummyAccount jackDummyAccount = getDummyAccount(null, ACCOUNT_JACK_DUMMY_USERNAME); - jackDummyAccount.addAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME, - EXISTING_GOSSIP); + DummyAccount jackDummyAccount = getDummyAccount(null, ACCOUNT_JACK_DUMMY_USERNAME); + jackDummyAccount.addAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME, + EXISTING_GOSSIP); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_JACK_OID, UserType.F_LOCALITY, getDefaultOptions(), task, result, createPolyString("Isla de Muerta")); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_PIRATE_OID, task, result); + assertAssignedRole(userAfter, ROLE_PIRATE_OID); assertRoleMembershipRef(userAfter, ROLE_PIRATE_OID); assertDelegatedRef(userAfter); @@ -1349,7 +1346,7 @@ public void test520JackAssignRolePirate() throws Exception { PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_PIRATE_OID, task, result); + assertAssignedRole(userAfter, ROLE_PIRATE_OID); assertRoleMembershipRef(userAfter, ROLE_PIRATE_OID); assertDelegatedRef(userAfter); @@ -1372,7 +1369,7 @@ public void test521JackUnassignRolePirateDeleteAccount() throws Exception { Task task = getTestTask(); OperationResult result = task.getResult(); - Collection> modifications = new ArrayList<>(); + Collection> modifications = new ArrayList<>(); modifications.add(createAssignmentModification(ROLE_PIRATE_OID, RoleType.COMPLEX_TYPE, null, null, null, false)); ObjectDelta userDelta = prismContext.deltaFactory().object() .createModifyDelta(USER_JACK_OID, modifications, UserType.class); @@ -1409,7 +1406,7 @@ public void test530JackAssignRoleCleric() throws Exception { assignRole(USER_JACK_OID, ROLE_CLERIC_OID, getDefaultOptions(), task, result); // THEN - assertAssignedRole(USER_JACK_OID, ROLE_CLERIC_OID, task, result); + assertAssignedRole(USER_JACK_OID, ROLE_CLERIC_OID, result); assertDefaultDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true); assertDefaultDummyAccountAttribute(ACCOUNT_JACK_DUMMY_USERNAME, "title", "Holy man"); } @@ -1430,17 +1427,17 @@ public void test532JackModifyAssignmentRoleCleric() throws Exception { UserType.class, USER_JACK_OID, itemPath, "soul"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(assignmentDelta), getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_CLERIC_OID, task, result); + assertAssignedRole(userAfter, ROLE_CLERIC_OID); assertRoleMembershipRef(userAfter, ROLE_CLERIC_OID); assertDelegatedRef(userAfter); @@ -1464,11 +1461,11 @@ public void test539JackUnAssignRoleCleric() throws Exception { UserType.class, USER_JACK_OID, UserType.F_ASSIGNMENT, assignmentType); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(assignmentDelta, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1493,16 +1490,16 @@ public void test540JackAssignRoleWannabe() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_WANNABE_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_WANNABE_OID, task, result); + assertAssignedRole(userAfter, ROLE_WANNABE_OID); assertRoleMembershipRef(userAfter); assertDelegatedRef(userAfter); @@ -1522,16 +1519,16 @@ public void test541JackRemoveHonorificSuffixWannabe() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_JACK_OID, UserType.F_HONORIFIC_SUFFIX, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_WANNABE_OID, task, result); + assertAssignedRole(userAfter, ROLE_WANNABE_OID); assertRoleMembershipRef(userAfter); assertDelegatedRef(userAfter); @@ -1550,16 +1547,16 @@ public void test542JackModifySubtypeWannabe() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_JACK_OID, UserType.F_SUBTYPE, getDefaultOptions(), task, result, "wannabe"); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_WANNABE_OID, task, result); + assertAssignedRole(userAfter, ROLE_WANNABE_OID); assertRoleMembershipRef(userAfter, ROLE_WANNABE_OID); assertDelegatedRef(userAfter); @@ -1579,16 +1576,16 @@ public void test543JackRemoveHonorificPrefixWannabe() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_JACK_OID, UserType.F_HONORIFIC_PREFIX, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_WANNABE_OID, task, result); + assertAssignedRole(userAfter, ROLE_WANNABE_OID); assertRoleMembershipRef(userAfter, ROLE_WANNABE_OID); assertDelegatedRef(userAfter); @@ -1607,17 +1604,17 @@ public void test544JackSetHonorificSuffixWannabe() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_JACK_OID, UserType.F_HONORIFIC_SUFFIX, getDefaultOptions(), task, result, PrismTestUtil.createPolyString("PhD.")); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_WANNABE_OID, task, result); + assertAssignedRole(userAfter, ROLE_WANNABE_OID); assertRoleMembershipRef(userAfter, ROLE_WANNABE_OID, ROLE_HONORABLE_WANNABE_OID); assertDelegatedRef(userAfter); @@ -1638,17 +1635,17 @@ public void test545JackRestoreHonorificPrefixWannabe() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_JACK_OID, UserType.F_HONORIFIC_PREFIX, getDefaultOptions(), task, result, PrismTestUtil.createPolyString("captain")); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_WANNABE_OID, task, result); + assertAssignedRole(userAfter, ROLE_WANNABE_OID); assertRoleMembershipRef(userAfter, ROLE_WANNABE_OID, ROLE_HONORABLE_WANNABE_OID); assertDelegatedRef(userAfter); @@ -1668,11 +1665,11 @@ public void test549JackUnassignRoleWannabe() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, ROLE_WANNABE_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1699,17 +1696,17 @@ public void test600JackAssignRoleJudge() throws Exception { assignRole(USER_JACK_OID, ROLE_JUDGE_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_JUDGE_OID, task, result); + assertAssignedRole(userAfter, ROLE_JUDGE_OID); assertRoleMembershipRef(userAfter, ROLE_JUDGE_OID); assertDelegatedRef(userAfter); - assertAssignedRole(USER_JACK_OID, ROLE_JUDGE_OID, task, result); + assertAssignedRole(USER_JACK_OID, ROLE_JUDGE_OID, result); assertDefaultDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true); assertDefaultDummyAccountAttribute(ACCOUNT_JACK_DUMMY_USERNAME, "title", "Honorable Justice"); assertDefaultDummyAccountAttribute(ACCOUNT_JACK_DUMMY_USERNAME, "weapon", "mouth", "pistol"); @@ -1740,13 +1737,13 @@ public void test602JackAssignRolePirate() throws Exception { } // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertFailure(result); PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_JUDGE_OID, task, result); + assertAssignedRole(userAfter, ROLE_JUDGE_OID); assertRoleMembershipRef(userAfter, ROLE_JUDGE_OID); assertDelegatedRef(userAfter); @@ -1767,17 +1764,17 @@ public void test605JackUnAssignRoleJudgeAssignRolePirate() throws Exception { userDelta.addModification(createAssignmentModification(ROLE_PIRATE_OID, RoleType.COMPLEX_TYPE, null, null, null, true)); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(userDelta), getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_PIRATE_OID, task, result); + assertAssignedRole(userAfter, ROLE_PIRATE_OID); assertRoleMembershipRef(userAfter, ROLE_PIRATE_OID); assertDelegatedRef(userAfter); @@ -1801,11 +1798,11 @@ public void test609JackUnAssignRolePirate() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, ROLE_PIRATE_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1829,17 +1826,17 @@ public void test610ElaineAssignRoleGovernor() throws Exception { assignRole(USER_ELAINE_OID, ROLE_GOVERNOR_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = getUser(USER_ELAINE_OID); display("User after", userAfter); - assertAssignedRole(userAfter, ROLE_GOVERNOR_OID, task, result); + assertAssignedRole(userAfter, ROLE_GOVERNOR_OID); assertRoleMembershipRef(userAfter, ROLE_GOVERNOR_OID); assertDelegatedRef(userAfter); - assertAssignedRole(USER_ELAINE_OID, ROLE_GOVERNOR_OID, task, result); + assertAssignedRole(USER_ELAINE_OID, ROLE_GOVERNOR_OID, result); assertDefaultDummyAccount(ACCOUNT_ELAINE_DUMMY_USERNAME, ACCOUNT_ELAINE_DUMMY_FULLNAME, true); assertDefaultDummyAccountAttribute(ACCOUNT_ELAINE_DUMMY_USERNAME, "title", "Her Excellency Governor"); @@ -1869,7 +1866,7 @@ public void test612JackAssignRoleGovernor() throws Exception { } // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertFailure(result); assertNoAssignments(USER_JACK_OID); @@ -1905,7 +1902,7 @@ public void test613JackAssignRoleGovernorAsApprover() throws Exception { } // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertFailure(result); assertNoAssignments(USER_JACK_OID); @@ -1933,14 +1930,14 @@ public void test620LemonheadAssignRoleCanibal() throws Exception { assertAssignees(ROLE_CANNIBAL_OID, 0); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(user.getOid(), ROLE_CANNIBAL_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); - assertAssignedRole(user.getOid(), ROLE_CANNIBAL_OID, task, result); + assertAssignedRole(user.getOid(), ROLE_CANNIBAL_OID, result); assertDefaultDummyAccount(USER_LEMONHEAD_NAME, USER_LEMONHEAD_FULLNAME, true); assertDefaultDummyAccountAttribute(USER_LEMONHEAD_NAME, "title", "Voracious Cannibal"); @@ -1963,14 +1960,14 @@ public void test622SharptoothAssignRoleCanibal() throws Exception { assertAssignees(ROLE_CANNIBAL_OID, 1); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(user.getOid(), ROLE_CANNIBAL_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); - assertAssignedRole(user.getOid(), ROLE_CANNIBAL_OID, task, result); + assertAssignedRole(user.getOid(), ROLE_CANNIBAL_OID, result); assertDefaultDummyAccount(USER_SHARPTOOTH_NAME, USER_SHARPTOOTH_FULLNAME, true); assertDefaultDummyAccountAttribute(USER_SHARPTOOTH_NAME, "title", "Voracious Cannibal"); @@ -1993,14 +1990,14 @@ public void test624RedskullAssignRoleCanibal() throws Exception { assertAssignees(ROLE_CANNIBAL_OID, 2); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(user.getOid(), ROLE_CANNIBAL_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); - assertAssignedRole(user.getOid(), ROLE_CANNIBAL_OID, task, result); + assertAssignedRole(user.getOid(), ROLE_CANNIBAL_OID, result); assertDefaultDummyAccount(USER_REDSKULL_NAME, USER_REDSKULL_FULLNAME, true); assertDefaultDummyAccountAttribute(USER_REDSKULL_NAME, "title", "Voracious Cannibal"); @@ -2024,7 +2021,7 @@ public void test625BignoseAssignRoleCanibal() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(user.getOid(), ROLE_CANNIBAL_OID, getDefaultOptions(), task, result); AssertJUnit.fail("Unexpected success"); @@ -2035,7 +2032,7 @@ public void test625BignoseAssignRoleCanibal() throws Exception { } // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertFailure(result); assertNoAssignments(user.getOid()); @@ -2055,11 +2052,11 @@ public void test627SharptoothUnassignRoleCanibal() throws Exception { assertAssignees(ROLE_CANNIBAL_OID, 3); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(userSharptoothOid, ROLE_CANNIBAL_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertNoAssignments(userSharptoothOid); @@ -2081,7 +2078,7 @@ public void test628RedskullUnassignRoleCanibal() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(userRedskullOid, ROLE_CANNIBAL_OID, getDefaultOptions(), task, result); AssertJUnit.fail("Unexpected success"); @@ -2092,10 +2089,10 @@ public void test628RedskullUnassignRoleCanibal() throws Exception { } // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertFailure(result); - assertAssignedRole(userRedskullOid, ROLE_CANNIBAL_OID, task, result); + assertAssignedRole(userRedskullOid, ROLE_CANNIBAL_OID, result); assertDefaultDummyAccount(USER_REDSKULL_NAME, USER_REDSKULL_FULLNAME, true); assertDefaultDummyAccountAttribute(USER_REDSKULL_NAME, "title", "Voracious Cannibal"); @@ -2122,7 +2119,7 @@ public void test630RappAssignRoleCannibalAsOwner() throws Exception { assignRole(USER_RAPP_OID, ROLE_CANNIBAL_OID, SchemaConstants.ORG_OWNER, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertAssignees(ROLE_CANNIBAL_OID, 2); @@ -2150,7 +2147,7 @@ public void test632RappUnassignRoleCannibalAsOwner() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); // null namespace to test no-namespace "owner" relation unassignRole(USER_RAPP_OID, ROLE_CANNIBAL_OID, QNameUtil.nullNamespace(SchemaConstants.ORG_OWNER), getDefaultOptions(), task, result); @@ -2162,7 +2159,7 @@ public void test632RappUnassignRoleCannibalAsOwner() throws Exception { } // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertFailure(result); assertAssignees(ROLE_CANNIBAL_OID, 2); @@ -2192,11 +2189,11 @@ public void test634BignoseAssignRoleCannibalAsOwner() throws Exception { assignRole(userBignoseOid, ROLE_CANNIBAL_OID, SchemaConstants.ORG_OWNER, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(userBignoseOid) - .assignments() + .assignments() .assertAssignments(1) .assertRole(ROLE_CANNIBAL_OID, SchemaConstants.ORG_OWNER); @@ -2227,11 +2224,11 @@ public void test636BignoseUnassignRoleCannibalAsOwner() throws Exception { unassignRole(userBignoseOid, ROLE_CANNIBAL_OID, SchemaConstants.ORG_OWNER, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(userBignoseOid) - .assignments() + .assignments() .assertNone(); assertAssignees(ROLE_CANNIBAL_OID, 2); @@ -2252,11 +2249,11 @@ public void test649ElaineUnassignRoleGovernor() throws Exception { assertAssignees(ROLE_GOVERNOR_OID, 1); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_ELAINE_OID, ROLE_GOVERNOR_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_ELAINE_OID); @@ -2272,22 +2269,22 @@ public void test650BignoseAssignRoleCannibalAsOwner() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); assertUserBefore(userBignoseOid) - .assignments() - .assertNone(); + .assignments() + .assertNone(); Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(userBignoseOid, ROLE_CANNIBAL_OID, SchemaConstants.ORG_OWNER, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(userBignoseOid) - .assignments() + .assignments() .assertAssignments(1) .assertRole(ROLE_CANNIBAL_OID, SchemaConstants.ORG_OWNER); } @@ -2301,15 +2298,15 @@ public void test651BignoseAssignRoleCannibalAsApprover() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(userBignoseOid, ROLE_CANNIBAL_OID, SchemaConstants.ORG_APPROVER, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(userBignoseOid) - .assignments() + .assignments() .assertAssignments(2) .assertRole(ROLE_CANNIBAL_OID, SchemaConstants.ORG_OWNER) .assertRole(ROLE_CANNIBAL_OID, SchemaConstants.ORG_APPROVER); @@ -2327,15 +2324,15 @@ public void test655BignoseAssignRoleCannibal() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(userBignoseOid, ROLE_CANNIBAL_OID, SchemaConstants.ORG_DEFAULT, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(userBignoseOid) - .assignments() + .assignments() .assertAssignments(3) .assertRole(ROLE_CANNIBAL_OID, SchemaConstants.ORG_DEFAULT) .assertRole(ROLE_CANNIBAL_OID, SchemaConstants.ORG_OWNER) @@ -2351,15 +2348,15 @@ public void test656BignoseUnassignRoleCannibal() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(userBignoseOid, ROLE_CANNIBAL_OID, SchemaConstants.ORG_DEFAULT, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(userBignoseOid) - .assignments() + .assignments() .assertAssignments(2) .assertRole(ROLE_CANNIBAL_OID, SchemaConstants.ORG_OWNER) .assertRole(ROLE_CANNIBAL_OID, SchemaConstants.ORG_APPROVER); @@ -2373,7 +2370,7 @@ public void test658BignoseUnassignRoleCannibalAsOwner() throws Exception { Task task = getTestTask(); OperationResult result = task.getResult(); - Collection> modifications = new ArrayList<>(); + Collection> modifications = new ArrayList<>(); modifications.add((createAssignmentModification(ROLE_CANNIBAL_OID, RoleType.COMPLEX_TYPE, SchemaConstants.ORG_OWNER, null, null, false))); modifications.add((createAssignmentModification(ROLE_CANNIBAL_OID, RoleType.COMPLEX_TYPE, SchemaConstants.ORG_APPROVER, null, null, false))); ObjectDelta userDelta = prismContext.deltaFactory().object() @@ -2383,11 +2380,11 @@ public void test658BignoseUnassignRoleCannibalAsOwner() throws Exception { executeChanges(userDelta, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(userBignoseOid) - .assignments() + .assignments() .assertNone(); } @@ -2403,14 +2400,14 @@ public void test700JackAssignRoleJudge() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_JUDGE_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); - assertAssignedRole(USER_JACK_OID, ROLE_JUDGE_OID, task, result); + assertAssignedRole(USER_JACK_OID, ROLE_JUDGE_OID, result); assertDefaultDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true); assertDefaultDummyAccountAttribute(ACCOUNT_JACK_DUMMY_USERNAME, "title", "Honorable Justice"); assertDefaultDummyAccountAttribute(ACCOUNT_JACK_DUMMY_USERNAME, "weapon", "mouth", "pistol"); @@ -2429,17 +2426,17 @@ public void test701JackModifyJudgeDeleteConstructionRecompute() throws Exception display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyRoleDeleteInducement(ROLE_JUDGE_OID, 1111L, true, getDefaultOptions(), task); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertInProgressOrSuccess(result); assertTrue("task is not persistent", task.isPersistent()); - assertAssignedRole(USER_JACK_OID, ROLE_JUDGE_OID, task, result); + assertAssignedRole(USER_JACK_OID, ROLE_JUDGE_OID, result); waitForTaskFinish(task.getOid(), true); @@ -2459,17 +2456,17 @@ public void test702JackModifyJudgeAddInducementHonorabilityRecompute() throws Ex display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); - modifyRoleAddInducementTarget(ROLE_JUDGE_OID, ROLE_HONORABILITY_OID, true, getDefaultOptions(), task); + when(TEST_NAME); + modifyRoleAddInducementTarget(ROLE_JUDGE_OID, ROLE_HONORABILITY_OID, true, getDefaultOptions()); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertInProgressOrSuccess(result); assertTrue("task is not persistent", task.isPersistent()); - assertAssignedRole(USER_JACK_OID, ROLE_JUDGE_OID, task, result); + assertAssignedRole(USER_JACK_OID, ROLE_JUDGE_OID, result); waitForTaskFinish(task.getOid(), true); @@ -2497,11 +2494,11 @@ public void test703JackModifyJudgeDeleteInducementHonorabilityRecompute() throws display("Role judge", roleJudge); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, ModelExecuteOptions.createReconcile(getDefaultOptions()), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2528,11 +2525,11 @@ public void test709JackUnAssignRoleJudge() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, ROLE_JUDGE_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2553,15 +2550,15 @@ public void test710JackAssignRoleEmpty() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_EMPTY_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); - assertAssignedRole(USER_JACK_OID, ROLE_EMPTY_OID, task, result); + assertAssignedRole(USER_JACK_OID, ROLE_EMPTY_OID, result); assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME); } @@ -2578,17 +2575,17 @@ public void test712JackModifyEmptyRoleAddInducementPirateRecompute() throws Exce display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); - modifyRoleAddInducementTarget(ROLE_EMPTY_OID, ROLE_PIRATE_OID, true, getDefaultOptions(), task); + when(TEST_NAME); + modifyRoleAddInducementTarget(ROLE_EMPTY_OID, ROLE_PIRATE_OID, true, getDefaultOptions()); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertInProgressOrSuccess(result); assertTrue("task is not persistent", task.isPersistent()); - assertAssignedRole(USER_JACK_OID, ROLE_EMPTY_OID, task, result); + assertAssignedRole(USER_JACK_OID, ROLE_EMPTY_OID, result); waitForTaskFinish(task.getOid(), true); @@ -2611,15 +2608,15 @@ public void test714JackModifyEmptyRoleDeleteInducementPirateRecompute() throws E modifyRoleDeleteInducementTarget(ROLE_EMPTY_OID, ROLE_PIRATE_OID, getDefaultOptions()); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); - assertAssignedRole(USER_JACK_OID, ROLE_EMPTY_OID, task, result); + assertAssignedRole(USER_JACK_OID, ROLE_EMPTY_OID, result); assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME); } @@ -2636,11 +2633,11 @@ public void test719JackUnAssignRoleEmpty() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, ROLE_EMPTY_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2663,15 +2660,15 @@ public void test720JackAssignRoleGovernorTenantRef() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignParametricRole(USER_JACK_OID, ROLE_GOVERNOR_OID, null, ORG_SCUMM_BAR_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); - assertAssignedRole(USER_JACK_OID, ROLE_GOVERNOR_OID, task, result); + assertAssignedRole(USER_JACK_OID, ROLE_GOVERNOR_OID, result); assertDefaultDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true); assertDefaultDummyAccountAttribute(ACCOUNT_JACK_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "Her Excellency Governor of Scumm Bar"); @@ -2694,11 +2691,11 @@ public void test729JackUnassignRoleGovernorTenantRef() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignParametricRole(USER_JACK_OID, ROLE_GOVERNOR_OID, null, ORG_SCUMM_BAR_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2723,17 +2720,17 @@ public void test750JackAssignRoleOmnimanager() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_PROJECT_OMNINAMAGER_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_PROJECT_OMNINAMAGER_OID, task, result); + assertAssignedRole(userAfter, ROLE_PROJECT_OMNINAMAGER_OID); assertHasOrg(userAfter, ORG_SAVE_ELAINE_OID, SchemaConstants.ORG_MANAGER); assertHasOrg(userAfter, ORG_KIDNAP_AND_MARRY_ELAINE_OID, SchemaConstants.ORG_MANAGER); @@ -2753,21 +2750,21 @@ public void test755AddProjectAndRecomputeJack() throws Exception { PrismObject userBefore = getUser(USER_JACK_OID); display("User jack before", userBefore); - assertAssignedRole(userBefore, ROLE_PROJECT_OMNINAMAGER_OID, task, result); + assertAssignedRole(userBefore, ROLE_PROJECT_OMNINAMAGER_OID); addObject(ORG_PROJECT_RECLAIM_BLACK_PEARL_FILE); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, ModelExecuteOptions.createReconcile(getDefaultOptions()), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_PROJECT_OMNINAMAGER_OID, task, result); + assertAssignedRole(userAfter, ROLE_PROJECT_OMNINAMAGER_OID); assertHasOrg(userAfter, ORG_SAVE_ELAINE_OID, SchemaConstants.ORG_MANAGER); assertHasOrg(userAfter, ORG_KIDNAP_AND_MARRY_ELAINE_OID, SchemaConstants.ORG_MANAGER); @@ -2789,11 +2786,11 @@ public void test759JackUnassignRoleOmnimanager() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, ROLE_PROJECT_OMNINAMAGER_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2826,11 +2823,11 @@ public void test760JackAssignRoleWeakGossiper() throws Exception { assertDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, false); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_WEAK_GOSSIPER_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2859,11 +2856,11 @@ public void test761JackRecompute() throws Exception { assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2892,11 +2889,11 @@ public void test762JackReconcile() throws Exception { assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_JACK_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2927,11 +2924,11 @@ public void test763PreviewChanges() throws Exception { ); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ModelContext context = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("Preview context", context); @@ -2983,11 +2980,11 @@ public void test764JackAssignRoleSailor() throws Exception { assertAssignedRole(userBefore, ROLE_WEAK_GOSSIPER_OID); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_SAILOR_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3021,11 +3018,11 @@ public void test765JackRecompute() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3059,11 +3056,11 @@ public void test766JackReconcile() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_JACK_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3099,11 +3096,11 @@ public void test767JackUnAssignRoleWeakGossiper() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, ROLE_WEAK_GOSSIPER_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3136,11 +3133,11 @@ public void test768JackRecompute() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3173,11 +3170,11 @@ public void test769JackUnAssignRoleSailor() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, ROLE_SAILOR_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3207,11 +3204,11 @@ public void test770JackAssignRoleSailor() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_SAILOR_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3246,11 +3243,11 @@ public void test772JackAssignRoleGossiper() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_WEAK_GOSSIPER_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3286,11 +3283,11 @@ public void test774JackUnAssignRoleSailor() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, ROLE_SAILOR_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3320,11 +3317,11 @@ public void test775JackUnAssignRoleGossiper() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, ROLE_WEAK_GOSSIPER_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3337,7 +3334,6 @@ public void test775JackUnAssignRoleGossiper() throws Exception { } - /** * Assign both roles together (weak and normal). * MID-2850 @@ -3354,7 +3350,6 @@ public void test778JackAssignRoleGossiperAndSailor() throws Exception { PrismObject userBefore = getUser(USER_JACK_OID); display("User jack before", userBefore); - ObjectDelta userDelta = createAssignmentUserDelta(USER_JACK_OID, ROLE_WEAK_GOSSIPER_OID, RoleType.COMPLEX_TYPE, null, null, null, true); userDelta.addModification(createAssignmentModification(ROLE_SAILOR_OID, RoleType.COMPLEX_TYPE, @@ -3362,11 +3357,11 @@ public void test778JackAssignRoleGossiperAndSailor() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(deltas, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3400,7 +3395,6 @@ public void test779JackUnassignRoleGossiperAndSailor() throws Exception { PrismObject userBefore = getUser(USER_JACK_OID); display("User jack before", userBefore); - ObjectDelta userDelta = createAssignmentUserDelta(USER_JACK_OID, ROLE_WEAK_GOSSIPER_OID, RoleType.COMPLEX_TYPE, null, null, null, false); userDelta.addModification(createAssignmentModification(ROLE_SAILOR_OID, RoleType.COMPLEX_TYPE, @@ -3408,11 +3402,11 @@ public void test779JackUnassignRoleGossiperAndSailor() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(deltas, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3444,11 +3438,11 @@ public void test780JackAssignRoleWeakSinger() throws Exception { assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_WEAK_SINGER_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3481,11 +3475,11 @@ public void test781JackAssignRoleWeakGossiper() throws Exception { assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_WEAK_GOSSIPER_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3516,11 +3510,11 @@ public void test782JackAssignRoleSailor() throws Exception { assertAssignedRole(userBefore, ROLE_WEAK_GOSSIPER_OID); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_SAILOR_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3558,11 +3552,11 @@ public void test783JackUnassignRoleSailor() throws Exception { assertAssignedRole(userBefore, ROLE_WEAK_SINGER_OID); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, ROLE_SAILOR_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3593,11 +3587,11 @@ public void test784JackUnAssignRoleWeakSinger() throws Exception { assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, ROLE_WEAK_SINGER_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3627,11 +3621,11 @@ public void test785JackUnAssignRoleGossiper() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, ROLE_WEAK_GOSSIPER_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3660,7 +3654,6 @@ public void test786JackAssignRoleGossiperAndSinger() throws Exception { PrismObject userBefore = getUser(USER_JACK_OID); display("User jack before", userBefore); - ObjectDelta userDelta = createAssignmentUserDelta(USER_JACK_OID, ROLE_WEAK_GOSSIPER_OID, RoleType.COMPLEX_TYPE, null, null, null, true); userDelta.addModification(createAssignmentModification(ROLE_WEAK_SINGER_OID, RoleType.COMPLEX_TYPE, @@ -3668,11 +3661,11 @@ public void test786JackAssignRoleGossiperAndSinger() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(deltas, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3701,7 +3694,6 @@ public void test788JackUnassignRoleGossiperAndSinger() throws Exception { PrismObject userBefore = getUser(USER_JACK_OID); display("User jack before", userBefore); - ObjectDelta userDelta = createAssignmentUserDelta(USER_JACK_OID, ROLE_WEAK_GOSSIPER_OID, RoleType.COMPLEX_TYPE, null, null, null, false); userDelta.addModification(createAssignmentModification(ROLE_WEAK_SINGER_OID, RoleType.COMPLEX_TYPE, @@ -3709,11 +3701,11 @@ public void test788JackUnassignRoleGossiperAndSinger() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(deltas, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3746,11 +3738,11 @@ public void test790JackAssignRoleWeakSinger() throws Exception { assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_WEAK_SINGER_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3790,11 +3782,11 @@ public void test791JackSwitchRolesGossiperAndSinger() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(deltas, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3825,11 +3817,11 @@ public void test792JackAssignRoleSailor() throws Exception { assertAssignedRole(userBefore, ROLE_WEAK_GOSSIPER_OID); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_SAILOR_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3874,11 +3866,11 @@ public void test793JackSwitchRolesSingerAndGossiper() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(deltas, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3920,11 +3912,11 @@ public void test794JackSwitchRolesSailorAndGossiper() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(deltas, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3960,11 +3952,11 @@ public void test795JackSwitchRolesSingerAndSailor() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(deltas, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4006,11 +3998,11 @@ public void test796JackSwitchRolesSailorAndGovernor() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(deltas, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4053,11 +4045,11 @@ public void test799JackUnassignGovernorAndWeakGossiper() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(deltas, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4079,14 +4071,14 @@ public void test800ModifyRoleImmutable() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyObjectReplaceProperty(RoleType.class, ROLE_IMMUTABLE_OID, RoleType.F_DESCRIPTION, getDefaultOptions(), task, result, "whatever"); AssertJUnit.fail("Unexpected success"); } catch (PolicyViolationException e) { // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertFailure(result); } @@ -4111,11 +4103,11 @@ public void test802AddGlobalImmutableRole() throws Exception { display("Role before", role); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(role, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4134,14 +4126,14 @@ public void test804ModifyRoleImmutableGlobalIdentifier() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyObjectReplaceProperty(RoleType.class, ROLE_IMMUTABLE_GLOBAL_OID, RoleType.F_IDENTIFIER, getDefaultOptions(), task, result, "whatever"); AssertJUnit.fail("Unexpected success"); } catch (PolicyViolationException e) { // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertFailure(result); } @@ -4161,14 +4153,14 @@ public void test805ModifyRoleImmutableGlobalDescription() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyObjectReplaceProperty(RoleType.class, ROLE_IMMUTABLE_GLOBAL_OID, RoleType.F_DESCRIPTION, getDefaultOptions(), task, result, "whatever"); AssertJUnit.fail("Unexpected success"); } catch (PolicyViolationException e) { // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertFailure(result); } @@ -4194,11 +4186,11 @@ public void test812AddGlobalImmutableDescriptionRole() throws Exception { display("Role before", role); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(role, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4219,13 +4211,13 @@ public void test814ModifyRoleImmutableDescriptionGlobalIdentifier() throws Excep OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); final String NEW_VALUE = "whatever"; modifyObjectReplaceProperty(RoleType.class, ROLE_IMMUTABLE_DESCRIPTION_GLOBAL_OID, RoleType.F_IDENTIFIER, getDefaultOptions(), task, result, NEW_VALUE); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4244,14 +4236,14 @@ public void test815ModifyRoleImmutableGlobalDescription() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyObjectReplaceProperty(RoleType.class, ROLE_IMMUTABLE_DESCRIPTION_GLOBAL_OID, RoleType.F_DESCRIPTION, getDefaultOptions(), task, result, "whatever"); AssertJUnit.fail("Unexpected success"); } catch (PolicyViolationException e) { // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertFailure(result); } @@ -4273,13 +4265,13 @@ public void test826AddNonCreateableRole() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(role, getDefaultOptions(), task, result); AssertJUnit.fail("Unexpected success"); } catch (PolicyViolationException e) { // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertFailure(result); } @@ -4299,7 +4291,7 @@ public void test826bAddCreateableRole() throws Exception { display("Role before", role); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(role, getDefaultOptions(), task, result); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4324,13 +4316,13 @@ public void test827AddImmutableAssignRole() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(role, getDefaultOptions(), task, result); AssertJUnit.fail("Unexpected success"); } catch (PolicyViolationException e) { // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertFailure(result); } @@ -4352,12 +4344,12 @@ public void test828ModifyUntouchableMetarole() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyObjectReplaceProperty(RoleType.class, ROLE_META_UNTOUCHABLE_OID, RoleType.F_DESCRIPTION, getDefaultOptions(), task, result, "Touche!"); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4374,12 +4366,12 @@ public void test830ModifyRoleJudge() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyObjectReplaceProperty(RoleType.class, ROLE_JUDGE_OID, RoleType.F_DESCRIPTION, getDefaultOptions(), task, result, "whatever"); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4401,13 +4393,13 @@ public void test840AssignRoleNonAssignable() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_NON_ASSIGNABLE_OID, getDefaultOptions(), task, result); AssertJUnit.fail("Unexpected success"); } catch (PolicyViolationException e) { // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertFailure(result); } @@ -4430,11 +4422,11 @@ public void test850JackAssignRoleBloodyFool() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_BLOODY_FOOL_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4468,11 +4460,11 @@ public void test855JackModifyFoolMetaroleDeleteInducement() throws Exception { assertInducements(roleBefore, 2); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyRoleDeleteInducement(ROLE_META_FOOL_OID, 10002L, false, getDefaultOptions(), task); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4494,11 +4486,11 @@ public void test857JackReconcile() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_JACK_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4535,11 +4527,11 @@ public void test870AssignRoleScreaming() throws Exception { display("user jack", userJackBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_SCREAMING_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userJackAfter = getUser(USER_JACK_OID); @@ -4554,7 +4546,7 @@ public void test870AssignRoleScreaming() throws Exception { /** * MID-4132: the global policy rules immutable-user-from-pluto-XXX selection is based on current object state * (not the new one) so it is _not_ selected in the primary state. - * + *

* So, this test basically confirms the behavior described in MID-4132. * If this behavior changes, so should this test. */ @@ -4575,7 +4567,7 @@ public void test880GlobalRuleOnChange() throws Exception { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChangesAssertSuccess(delta, getDefaultOptions(), task, result); } @@ -4589,12 +4581,12 @@ public void test890DeleteRoleUndeletable() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); deleteObject(RoleType.class, ROLE_UNDELETABLE_OID, task, result); AssertJUnit.fail("Unexpected success"); } catch (PolicyViolationException e) { // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertFailure(result); } @@ -4610,12 +4602,12 @@ public void test892DeleteRoleUndeletableGlobal() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); deleteObject(RoleType.class, ROLE_UNDELETABLE_GLOBAL_OID, task, result); AssertJUnit.fail("Unexpected success"); } catch (PolicyViolationException e) { // THEN - displayThen(TEST_NAME); + then(TEST_NAME); System.out.println("Got expected exception: " + e.getMessage()); result.computeStatus(); TestUtil.assertFailure(result); @@ -4635,14 +4627,14 @@ public void test900ModifyDetectingRole() throws Exception { display("Role before", roleBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ObjectDelta delta = prismContext.deltaFor(RoleType.class) .item(RoleType.F_NAME).replace(PolyString.fromOrig("modified")) .asObjectDeltaCast(ROLE_DETECTING_MODIFICATIONS_OID); executeChanges(delta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestSegregationOfDuties.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestSegregationOfDuties.java index 813b527f2c6..d6ae8a5d9e4 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestSegregationOfDuties.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestSegregationOfDuties.java @@ -549,7 +549,7 @@ public void test200GuybrushAssignRoleGold() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_PRIZE_GOLD_OID, task, result); // THEN @@ -582,7 +582,7 @@ public void test202GuybrushAssignRoleSilver() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_PRIZE_SILVER_OID, task, result); // THEN @@ -616,7 +616,7 @@ public void test204GuybrushAssignRoleSailor() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_SAILOR_OID, task, result); // THEN @@ -651,7 +651,7 @@ public void test206GuybrushAssignRoleBronze() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_PRIZE_BRONZE_OID, task, result); // THEN @@ -685,7 +685,7 @@ public void test208GuybrushUnassignRoleBronze() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); unassignRole(USER_GUYBRUSH_OID, ROLE_PRIZE_BRONZE_OID, task, result); // THEN @@ -717,7 +717,7 @@ public void test209GuybrushUnassignRoleSailor() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); unassignRole(USER_GUYBRUSH_OID, ROLE_SAILOR_OID, task, result); // THEN @@ -747,7 +747,7 @@ public void test209aGuybrushAssignRoleGoldAndSilverEnforced() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); ObjectDelta delta = prismContext.deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT).add( ObjectTypeUtil.createAssignmentTo(ROLE_PRIZE_GOLD_ENFORCED_OID, ObjectTypes.ROLE, prismContext), @@ -779,7 +779,7 @@ public void test209bGuybrushAssignRoleGoldAndSilver() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); ObjectDelta delta = prismContext.deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT).add( ObjectTypeUtil.createAssignmentTo(ROLE_PRIZE_GOLD_OID, ObjectTypes.ROLE, prismContext), @@ -811,11 +811,11 @@ public void test210GuybrushAssignRoleRed() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_GUYBRUSH_OID, ROLE_COLOR_RED_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -842,7 +842,7 @@ public void test212GuybrushAssignRoleGreen() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_COLOR_GREEN_OID, task, result); // THEN @@ -874,7 +874,7 @@ public void test214GuybrushAssignRoleColorNone() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_COLOR_NONE_OID, task, result); // THEN @@ -904,7 +904,7 @@ public void test216GuybrushAssignRoleBlue() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_COLOR_BLUE_OID, task, result); // THEN @@ -933,11 +933,11 @@ public void test219GuybrushUnassignRoleBlue() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_GUYBRUSH_OID, ROLE_COLOR_BLUE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -960,11 +960,11 @@ public void test220GuybrushAssignRoleBlue() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_GUYBRUSH_OID, ROLE_COLOR_BLUE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -999,11 +999,11 @@ public void test221GuybrushDestroyAndRecompute() throws Exception { display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_GUYBRUSH_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result, 2); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1039,11 +1039,11 @@ public void test222GuybrushDestroyAndAssignRoleRed() throws Exception { display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_GUYBRUSH_OID, ROLE_COLOR_RED_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result, 2); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1069,11 +1069,11 @@ public void test229GuybrushUnassignRoleRed() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_GUYBRUSH_OID, ROLE_COLOR_RED_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1099,7 +1099,7 @@ public void test230GuybrushAssignRoleRedAndBlueAndGreen() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); ObjectDelta delta = prismContext.deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT).add( ObjectTypeUtil.createAssignmentTo(ROLE_COLOR_RED_OID, ObjectTypes.ROLE, prismContext), @@ -1132,11 +1132,11 @@ public void test240GuybrushAssignRoleExecutiveOne() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_GUYBRUSH_OID, ROLE_EXECUTIVE_1_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1174,11 +1174,11 @@ public void test244GuybrushAssignRoleExecutiveTwo() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_GUYBRUSH_OID, ROLE_EXECUTIVE_2_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1219,11 +1219,11 @@ public void test246GuybrushUnassignRoleExecutiveOne() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_GUYBRUSH_OID, ROLE_EXECUTIVE_1_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1263,11 +1263,11 @@ public void test249GuybrushUnassignRoleExecutiveTwo() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_GUYBRUSH_OID, ROLE_EXECUTIVE_2_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1290,11 +1290,11 @@ public void test250GuybrushAssignRoleControllingOne() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_GUYBRUSH_OID, ROLE_CONTROLLING_1_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1332,11 +1332,11 @@ public void test259GuybrushUnassignRoleControllingOne() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_GUYBRUSH_OID, ROLE_CONTROLLING_1_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1356,11 +1356,11 @@ public void test800ApplyGlobalPolicyRulesExclusion() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); transplantGlobalPolicyRulesAdd(CONFIG_WITH_GLOBAL_RULES_EXCLUSION_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); List globalPolicyRules = getSystemConfiguration().getGlobalPolicyRule(); @@ -1377,11 +1377,11 @@ public void test810GuybrushAssignRoleCitizenSk() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_GUYBRUSH_OID, ROLE_CITIZEN_SK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1416,11 +1416,11 @@ public void test814GuybrushAssignRoleEmpty() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_GUYBRUSH_OID, ROLE_EMPTY_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1438,11 +1438,11 @@ public void test818GuybrushUnassignRoleCitizenSk() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_GUYBRUSH_OID, ROLE_CITIZEN_SK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1462,11 +1462,11 @@ public void test819GuybrushUnassignRoleEmpty() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_GUYBRUSH_OID, ROLE_EMPTY_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1487,11 +1487,11 @@ public void test820GuybrushAssignRoleCriminal() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_GUYBRUSH_OID, ROLE_CRIMINAL_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1512,11 +1512,11 @@ public void test822GuybrushAssignRoleMinister() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_GUYBRUSH_OID, ROLE_MINISTER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1536,11 +1536,11 @@ public void test826GuybrushUnassignRoleCriminal() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_GUYBRUSH_OID, ROLE_CRIMINAL_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1558,11 +1558,11 @@ public void test829GuybrushUnassignRoleMinister() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_GUYBRUSH_OID, ROLE_MINISTER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1580,11 +1580,11 @@ public void test900ApplyGlobalPolicyRulesSoDApproval() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); transplantGlobalPolicyRulesAdd(CONFIG_WITH_GLOBAL_RULES_SOD_APPROVAL_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); List globalPolicyRules = getSystemConfiguration().getGlobalPolicyRule(); @@ -1606,11 +1606,11 @@ public void test920GuybrushAssignRoleCriminal() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_GUYBRUSH_OID, ROLE_CRIMINAL_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1638,11 +1638,11 @@ public void test922GuybrushPreviewAssignRoleMinister() throws Exception { ROLE_MINISTER_OID, RoleType.COMPLEX_TYPE, null, null, null, true); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("Preview context", modelContext); @@ -1712,11 +1712,11 @@ public void test929GuybrushUnassignRoleCriminal() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_GUYBRUSH_OID, ROLE_CRIMINAL_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1810,7 +1810,7 @@ public void test960JimGoldByMapping() throws Exception { addObject(jim.asPrismObject()); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignRole(jim.getOid(), ROLE_PRIZE_GOLD_BY_MAPPING_OID, task, result); @@ -1831,7 +1831,7 @@ private PrismObject assignRolePolicyFailure(String TEST_NAME, String u try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(userOid, roleOid, task, result); assertNotReached(); @@ -1840,7 +1840,7 @@ private PrismObject assignRolePolicyFailure(String TEST_NAME, String u System.out.println("Got expected exception: " + e.getMessage()); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertFailure(result); } diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityAdvanced.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityAdvanced.java index 52da63f9549..933f495369f 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityAdvanced.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityAdvanced.java @@ -170,7 +170,7 @@ public void test000Sanity() throws Exception { cleanupAutzTest(USER_JACK_OID); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertSearch(UserType.class, null, NUMBER_OF_ALL_USERS); assertSearch(RoleType.class, null, getNumberOfRoles()); @@ -214,13 +214,13 @@ public void test080AutzJackEndUserPassword() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertAllow("set jack's password", (task, result) -> modifyUserSetPassword(USER_JACK_OID, "nbusr123", task, result) ); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -243,7 +243,7 @@ public void test100AutzJackPersonaManagement() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); @@ -269,7 +269,7 @@ public void test102AutzLechuckPersonaManagement() throws Exception { login(USER_LECHUCK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertGetDeny(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); @@ -299,7 +299,7 @@ public void test110AutzJackPersonaAdmin() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertAllow("assign application role 1 to jack", (task,result) -> assignRole(USER_JACK_OID, ROLE_PERSONA_ADMIN_OID, task, result)); @@ -358,7 +358,7 @@ public void test120AutzJackDelagator() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertReadAllow(NUMBER_OF_ALL_USERS); assertAddDeny(); @@ -411,7 +411,7 @@ public void test120AutzJackDelagator() throws Exception { login(USER_BARBOSSA_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); display("Logged in as Barbossa"); assertReadAllow(NUMBER_OF_ALL_USERS); @@ -421,7 +421,7 @@ public void test120AutzJackDelagator() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); display("Logged in as Jack"); assertAllow("undelegate from Barbossa", @@ -439,7 +439,7 @@ public void test120AutzJackDelagator() throws Exception { login(USER_BARBOSSA_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); display("Logged in as Barbossa"); assertReadDeny(); @@ -477,7 +477,7 @@ public void test122AutzJackDelagatorValidity() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject userJack = getUser(USER_JACK_OID); assertAssignments(userJack, 1); @@ -519,7 +519,7 @@ public void test122AutzJackDelagatorValidity() throws Exception { login(USER_BARBOSSA_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); display("Logged in as Barbossa"); // Delegation is not active yet. No access. @@ -548,7 +548,7 @@ public void test122AutzJackDelagatorValidity() throws Exception { login(USER_BARBOSSA_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); display("Logged in as Barbossa"); assertReadAllow(NUMBER_OF_ALL_USERS); @@ -563,7 +563,7 @@ public void test122AutzJackDelagatorValidity() throws Exception { login(USER_BARBOSSA_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); display("Logged in as Barbossa"); // Delegation is not active any more. No access. @@ -575,7 +575,7 @@ public void test122AutzJackDelagatorValidity() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); display("Logged in as Jack"); assertAllow("undelegate from Barbossa", @@ -594,7 +594,7 @@ public void test122AutzJackDelagatorValidity() throws Exception { login(USER_BARBOSSA_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); display("Logged in as Barbossa"); assertReadDeny(); @@ -632,7 +632,7 @@ public void test124AutzJackDelagatorPlusValidity() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject userJack = getUser(USER_JACK_OID); assertAssignments(userJack, 1); @@ -674,7 +674,7 @@ public void test124AutzJackDelagatorPlusValidity() throws Exception { login(USER_BARBOSSA_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); display("Logged in as Barbossa"); // Delegation is not active yet. No access. @@ -703,7 +703,7 @@ public void test124AutzJackDelagatorPlusValidity() throws Exception { login(USER_BARBOSSA_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); display("Logged in as Barbossa"); assertReadAllow(NUMBER_OF_ALL_USERS); @@ -732,7 +732,7 @@ public void test124AutzJackDelagatorPlusValidity() throws Exception { login(USER_BARBOSSA_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); display("Logged in as Barbossa"); // Delegation is not active any more. No access. @@ -744,7 +744,7 @@ public void test124AutzJackDelagatorPlusValidity() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); display("Logged in as Jack"); assertAllow("undelegate from Barbossa", @@ -763,7 +763,7 @@ public void test124AutzJackDelagatorPlusValidity() throws Exception { login(USER_BARBOSSA_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); display("Logged in as Barbossa"); assertReadDeny(); @@ -800,7 +800,7 @@ public void test150AutzJackApproverUnassignRoles() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertGetAllow(RoleType.class, ROLE_ORDINARY_OID); assertGetDeny(RoleType.class, ROLE_PERSONA_ADMIN_OID); // no assignment @@ -841,7 +841,7 @@ public void test151AutzJackApproverUnassignRolesAndRead() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertGetAllow(RoleType.class, ROLE_ORDINARY_OID); assertGetAllow(RoleType.class, ROLE_PERSONA_ADMIN_OID); // no assignment @@ -883,7 +883,7 @@ public void test154AutzJackApproverRead() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject roleOrdinary = assertGetAllow(RoleType.class, ROLE_ORDINARY_OID); assertNoRoleMembershipRef(roleOrdinary); @@ -948,7 +948,7 @@ public void test155AutzJackApproverSelf() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertGetDeny(RoleType.class, ROLE_ORDINARY_OID); assertGetDeny(RoleType.class, ROLE_PERSONA_ADMIN_OID); @@ -1004,7 +1004,7 @@ public void test157AutzJackReadRoleMembers() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject roleOrdinary = assertGetAllow(RoleType.class, ROLE_ORDINARY_OID); assertNoRoleMembershipRef(roleOrdinary); @@ -1056,7 +1056,7 @@ public void test158AutzJackReadRoleMembersWrong() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject roleOrdinary = assertGetAllow(RoleType.class, ROLE_ORDINARY_OID); assertNoRoleMembershipRef(roleOrdinary); @@ -1108,7 +1108,7 @@ public void test159AutzJackReadRoleMembersNone() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject roleOrdinary = assertGetAllow(RoleType.class, ROLE_ORDINARY_OID); assertNoRoleMembershipRef(roleOrdinary); @@ -1212,7 +1212,7 @@ public void test200AutzJackModifyOrgunit() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertGetAllow(UserType.class, USER_JACK_OID); assertAddDeny(); @@ -1273,7 +1273,7 @@ public void test202AutzJackModifyOrgunitAndAssignRole() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertGetAllow(UserType.class, USER_JACK_OID); assertAddDeny(); @@ -1346,7 +1346,7 @@ public void test220AutzJackRoleExpressionNoConstCenter() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertReadDeny(); assertAddDeny(); @@ -1389,7 +1389,7 @@ public void test222AutzJackRoleExpressionConstCenterBusiness() throws Exception login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertReadDeny(); assertAddDeny(); @@ -1431,7 +1431,7 @@ public void test230AttorneyCaribbeanUnlimited() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertReadAllow(); assertAddDeny(); @@ -1503,7 +1503,7 @@ public void test232ManagerAttorneyNoOrg() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertReadAllow(); assertAddDeny(); @@ -1549,7 +1549,7 @@ public void test234ManagerAttorneyRum() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertReadAllow(); assertAddDeny(); @@ -1617,7 +1617,7 @@ public void test235ManagerAttorneyRumRogersEntitled() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertReadAllow(); assertAddDeny(); @@ -1687,7 +1687,7 @@ public void test236ManagerAttorneyCaribbeanRum() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertReadAllow(); assertAddDeny(); @@ -1766,7 +1766,7 @@ public void test250AssignRequestableSelfOtherApporver() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertReadAllow(); assertAddDeny(); @@ -1859,7 +1859,7 @@ public void test252AssignRequestableSelfOtherApporverEmptyDelta() throws Excepti login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertReadAllow(); assertAddDeny(); @@ -1928,7 +1928,7 @@ public void test254AssignUnassignRequestableSelf() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertReadAllow(); assertAddDeny(); @@ -1964,7 +1964,7 @@ public void test256AssignUnassignRequestableSelfEmptyDelta() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertReadAllow(); assertAddDeny(); @@ -1998,7 +1998,7 @@ public void test260AutzJackLimitedRoleAdministrator() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_JACK_OID, SelectorOptions.createCollection(GetOperationOptions.createRaw())); @@ -2136,7 +2136,7 @@ public void test262AutzJackLimitedRoleAdministratorAndAssignApplicationRoles() t login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertReadAllow(); assertReadDenyRaw(); @@ -2261,7 +2261,7 @@ public void test264AutzJackLimitedReadRoleAdministrator() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_JACK_OID, SelectorOptions.createCollection(GetOperationOptions.createRaw())); @@ -2362,7 +2362,7 @@ public void test266AutzJackRoleAdministrator() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_JACK_OID, SelectorOptions.createCollection(GetOperationOptions.createRaw())); @@ -2421,7 +2421,7 @@ public void test270AutzJackModifyPolicyException() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertGetAllow(UserType.class, USER_JACK_OID); assertReadDenyRaw(); @@ -2478,7 +2478,7 @@ public void test272AutzJackModifyPolicyExceptionFirstRule() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertGetAllow(UserType.class, USER_JACK_OID); assertReadDenyRaw(); @@ -2581,7 +2581,7 @@ public void test280AutzJackModifyPolicyExceptionAndAssignOrg() throws Exception login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertGetAllow(UserType.class, USER_JACK_OID); assertReadDenyRaw(); @@ -2616,7 +2616,7 @@ public void test282AutzJackModifyPolicyExceptionAndAssignOrgDeny() throws Except login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertGetAllow(UserType.class, USER_JACK_OID); assertReadDenyRaw(); @@ -2649,7 +2649,7 @@ public void test283AutzJackModifyPolicyAssignOrg() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertGetAllow(UserType.class, USER_JACK_OID); assertReadDenyRaw(); @@ -2688,7 +2688,7 @@ public void test300AutzJackExceptAssignment() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject userJack = getUser(USER_JACK_OID); display("Jack", userJack); @@ -2751,7 +2751,7 @@ public void test302AutzJackExceptAdministrativeStatus() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject userJack = getUser(USER_JACK_OID); display("Jack", userJack); @@ -2820,7 +2820,7 @@ public void test304AutzJackPropExceptAssignmentReadSomeModifySomeUser() throws E login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject userJack = assertAlmostFullJackRead(2); PrismAsserts.assertPropertyValue(userJack, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, ActivationStatusType.ENABLED); @@ -2877,7 +2877,7 @@ public void test306AutzJackPropExceptAssignmentExceptAdministrativeStatus() thro login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject userJack = assertAlmostFullJackRead(2); // read of administrativeStatus is not allowed be either role @@ -2934,7 +2934,7 @@ public void test308AutzJackPropExceptAssignmentAssignApplicationRoles() throws E login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject userJack = getUser(USER_JACK_OID); display("Jack", userJack); @@ -3032,12 +3032,12 @@ public void test310AutzJackPropSubtypeDenyEscapingZoneOfControl() throws Excepti .assertSubtype(USER_JACK_SUBTYPE); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertModifyDeny(UserType.class, USER_JACK_OID, UserType.F_SUBTYPE, "escape"); // WHEN - displayThen(TEST_NAME); + then(TEST_NAME); assertUserAfter(USER_JACK_OID) .assertName(USER_JACK_USERNAME) @@ -3067,14 +3067,14 @@ public void test312AutzJackPropSubtypeAllowEscapingZoneOfControl() throws Except .assertSubtype(USER_JACK_SUBTYPE); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertModifyAllow(UserType.class, USER_JACK_OID, UserType.F_SUBTYPE, "escape"); assertModifyDeny(UserType.class, USER_JACK_OID, UserType.F_SUBTYPE, "escape again"); assertModifyDeny(UserType.class, USER_JACK_OID, UserType.F_SUBTYPE, USER_JACK_SUBTYPE); // WHEN - displayThen(TEST_NAME); + then(TEST_NAME); assertUserAfter(USER_JACK_OID) .assertName(USER_JACK_USERNAME) @@ -3099,7 +3099,7 @@ public void test320AutzJackGuybrushValutDweller() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject userBuybrush = getUser(USER_GUYBRUSH_OID); display("Guybrush(1)", userBuybrush); @@ -3150,7 +3150,7 @@ public void test330AutzJackEndUserWithPrivacy() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject userJack = assertGetAllow(UserType.class, USER_JACK_OID); display("Jack", userJack); @@ -3202,7 +3202,7 @@ public void test340AutzJackSuperUserAndExecRead() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertSearch(UserType.class, createOrgSubtreeQuery(ORG_MINISTRY_OF_OFFENSE_OID), USER_LECHUCK_OID, USER_GUYBRUSH_OID, userCobbOid, USER_ESTEVAN_OID); assertSearch(UserType.class, createOrgSubtreeAndNameQuery(ORG_MINISTRY_OF_OFFENSE_OID, USER_GUYBRUSH_USERNAME), USER_GUYBRUSH_OID); @@ -3229,7 +3229,7 @@ public void test350AutzJackResourceRead() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject resource = getObject(ResourceType.class, RESOURCE_DUMMY_VAULT_OID); @@ -3251,7 +3251,7 @@ public void test360AutzAdminResourceRead() throws Exception { login(USER_ADMINISTRATOR_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject resource = getObject(ResourceType.class, RESOURCE_DUMMY_VAULT_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityBasic.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityBasic.java index 9e47a51c047..1a18ff1be70 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityBasic.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityBasic.java @@ -100,7 +100,7 @@ public void test201AutzJackSuperuserRole() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertSuperuserAccess(NUMBER_OF_ALL_USERS); assertGlobalStateUntouched(); @@ -242,7 +242,7 @@ public void test204AutzJackSelfRole() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); @@ -295,7 +295,7 @@ public void test204aAutzJackCaseObjectSelfRole() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); @@ -348,7 +348,7 @@ public void test204bAutzJackCaseAssigneeSelfRole() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); @@ -404,7 +404,7 @@ public void test204cAutzJackCaseAssigneeSelfWithDelegatesRole() throws Exception login(USER_DEPUTY_1_NAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertGetDeny(UserType.class, USER_JACK_OID); assertGetAllow(UserType.class, USER_DEPUTY_1_OID); @@ -468,7 +468,7 @@ public void test204dAutzJackCaseAssigneeSelfWithNonWorkItemsDelegatesRole() thro login(USER_DEPUTY_2_NAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertGetDeny(UserType.class, USER_JACK_OID); assertGetAllow(UserType.class, USER_DEPUTY_2_OID); @@ -528,7 +528,7 @@ public void test205AutzJackObjectFilterModifyCaribbeanfRole() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertReadAllow(); assertReadDenyRaw(); @@ -553,7 +553,7 @@ public void test207AutzJackObjectFilterCaribbeanRole() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_JACK_OID, SelectorOptions.createCollection(GetOperationOptions.createRaw())); @@ -591,7 +591,7 @@ public void test207rAutzJackObjectFilterCaribbeanRole() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertGetAllow(UserType.class, USER_JACK_OID); assertGetAllow(UserType.class, USER_JACK_OID, SelectorOptions.createCollection(GetOperationOptions.createRaw())); @@ -644,7 +644,7 @@ public void testAutzJackReadSomeRoles(final String TEST_NAME, String roleOid) th login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertReadDeny(); assertReadDenyRaw(); @@ -701,7 +701,7 @@ public void test210AutzJackPropReadAllModifySome() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertReadAllow(); assertReadDenyRaw(); @@ -738,7 +738,7 @@ public void test211AutzJackPropReadAllModifySomeUser() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_JACK_OID, SelectorOptions.createCollection(GetOperationOptions.createRaw())); @@ -786,7 +786,7 @@ public void test212AutzJackPropReadAllModifySomeUserPartial() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_JACK_OID, SelectorOptions.createCollection(GetOperationOptions.createRaw())); @@ -883,7 +883,7 @@ public void test217AutzJackPropGetSearchSomeModifySomeUser() throws Exception { private void doReadSomeModifySomeUser(final String TEST_NAME) throws Exception { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject userJack = getUser(USER_JACK_OID); display("Jack", userJack); @@ -920,7 +920,7 @@ public void testAutzJackPropReadSomeModifySome(final String TEST_NAME, String ro login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertReadSomeModifySome(1); @@ -936,7 +936,7 @@ public void test218AutzJackPropReadSomeModifySomeExecAll() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertReadAllow(); @@ -1016,7 +1016,7 @@ public void test219AutzJackPropReadSomeModifySomeFullName() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertReadAllow(); @@ -1175,7 +1175,7 @@ public void test220AutzJackPropDenyModifySome() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertReadAllow(); @@ -1240,7 +1240,7 @@ public void test230AutzJackMasterMinistryOfRum() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertReadDeny(3); assertAddDeny(); @@ -1271,7 +1271,7 @@ public void test232AutzJackReadOrgMinistryOfRum() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertReadDeny(0); assertAddDeny(); @@ -1308,7 +1308,7 @@ public void test240AutzJackManagerFullControlNoOrg() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertReadDeny(0); assertAddDeny(); @@ -1359,7 +1359,7 @@ public void test241AutzJackManagerFullControlMemberMinistryOfRum() throws Except login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertJack24xMember(accountOid, true); @@ -1387,7 +1387,7 @@ public void test242AutzJackManagerFullControlManagerMinistryOfRum() throws Excep login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertJack24xManager(TEST_NAME, true); @@ -1418,7 +1418,7 @@ public void test243AutzJackManagerFullControlManagerMinistryOfRumAndDefense() th login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertJack24xManagerDefense(TEST_NAME, true); @@ -1444,7 +1444,7 @@ public void test245AutzJackManagerUserAdminMemberMinistryOfRum() throws Exceptio login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertJack24xMember(accountOid, false); @@ -1472,7 +1472,7 @@ public void test246AutzJackManagerUserAdminManagerMinistryOfRum() throws Excepti login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertJack24xManager(TEST_NAME, false); @@ -1501,7 +1501,7 @@ public void test247AutzJackManagerUserAdminManagerMinistryOfRumAndDefense() thro login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertJack24xManagerDefense(TEST_NAME, false); @@ -1747,7 +1747,7 @@ public void test250AutzJackSelfAccountsRead() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); @@ -1815,7 +1815,7 @@ public void test255AutzJackSelfAccountsReadWrite() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); @@ -1880,7 +1880,7 @@ public void test256AutzJackSelfAccountsPartialControl() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); @@ -1962,7 +1962,7 @@ public void test258AutzJackSelfAccountsPartialControlPassword() throws Exception login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); @@ -2025,7 +2025,7 @@ public void test259AutzJackSelfAccountsPartialControl() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); @@ -2093,7 +2093,7 @@ public void test260AutzJackObjectFilterLocationShadowRole() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_JACK_OID, SelectorOptions.createCollection(GetOperationOptions.createRaw())); @@ -2165,7 +2165,7 @@ public void test261AutzAngelicaObjectFilterLocationCreateUserShadowRole() throws assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertAllow("add user angelica", (task, result) -> addObject(USER_ANGELICA_FILE, task, result)); @@ -2196,7 +2196,7 @@ public void test270AutzJackAssignApplicationRoles() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertReadAllow(NUMBER_OF_ALL_USERS + 1); assertAddDeny(); @@ -2250,7 +2250,7 @@ public void test272AutzJackAssignAnyRoles() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertReadAllow(NUMBER_OF_ALL_USERS + 1); assertAddDeny(); @@ -2309,7 +2309,7 @@ public void test273AutzJackRedyAssignmentExceptionRules() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertReadAllow(NUMBER_OF_ALL_USERS + 1); assertAddDeny(); @@ -2362,7 +2362,7 @@ public void test274AutzJackAssignNonApplicationRoles() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertReadAllow(NUMBER_OF_ALL_USERS + 1); assertAddDeny(); @@ -2409,7 +2409,7 @@ public void test275aAutzJackAssignRequestableRoles() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertReadAllow(NUMBER_OF_ALL_USERS + 1); assertAddDeny(); @@ -2463,7 +2463,7 @@ public void test275bAutzJackAssignRequestableOrgs() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject user = getUser(USER_JACK_OID); assertAssignments(user, 1); assertAssignedRole(user, ROLE_END_USER_REQUESTABLE_ABSTRACTROLES_OID); @@ -2508,7 +2508,7 @@ public void test275cAutzJackAssignRequestableRolesAndInduceAnyRole() throws Exce login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertReadAllow(NUMBER_OF_ALL_USERS + 1); assertAddDeny(); @@ -2563,7 +2563,7 @@ public void test276AutzJackAssignRequestableRolesWithOrgRef() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertReadAllow(NUMBER_OF_ALL_USERS + 1); assertAddDeny(); @@ -2616,7 +2616,7 @@ public void test277AutzJackAssignRequestableRolesWithOrgRefSecondTime() throws E login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertReadAllow(NUMBER_OF_ALL_USERS + 1); assertAddDeny(); @@ -2698,7 +2698,7 @@ public void test278AutzJackAssignRequestableRolesWithOrgRefTweakedDelta() throws login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertReadAllow(NUMBER_OF_ALL_USERS + 1); assertAddDeny(); @@ -2766,7 +2766,7 @@ public void test279AutzJackAssignRequestableRolesWithTenantRef() throws Exceptio login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertReadAllow(NUMBER_OF_ALL_USERS + 1); assertAddDeny(); @@ -2824,7 +2824,7 @@ public void test280AutzJackEndUser() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertGetDeny(UserType.class, USER_JACK_OID, SelectorOptions.createCollection(GetOperationOptions.createRaw())); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); @@ -2907,7 +2907,7 @@ public void test281AutzJackEndUserSecondTime() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject user = getUser(USER_JACK_OID); assertAssignments(user, 1); @@ -2973,7 +2973,7 @@ public void test282AutzJackEndUserAndModify() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertReadAllow(NUMBER_OF_ALL_USERS + 1); assertAddDeny(); @@ -3014,7 +3014,7 @@ public void test283AutzJackModifyAndEndUser() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertReadAllow(NUMBER_OF_ALL_USERS + 1); assertAddDeny(); @@ -3047,7 +3047,7 @@ public void test285AutzJackEndUserAndAdd() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertReadAllow(NUMBER_OF_ALL_USERS + 1); @@ -3078,7 +3078,7 @@ public void test295AutzJackAssignOrgRelation() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ObjectFilter jackAssignableRoleFilter = assertAssignableRoleSpecification(getUser(USER_JACK_OID)) .relationDefault() @@ -3236,7 +3236,7 @@ public void test370AutzJackLimitedUserAdmin() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertGetAllow(UserType.class, USER_JACK_OID); assertGetAllow(UserType.class, USER_GUYBRUSH_OID); @@ -3263,7 +3263,7 @@ public void test380AutzJackSelfTaskOwner() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertGetDeny(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityMedium.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityMedium.java index b86c15f7bbf..919de863ea2 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityMedium.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityMedium.java @@ -58,7 +58,7 @@ public void test000Sanity() throws Exception { cleanupAutzTest(USER_JACK_OID); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertSearch(UserType.class, null, NUMBER_OF_ALL_USERS); assertSearch(RoleType.class, null, getNumberOfRoles()); @@ -84,7 +84,7 @@ public void test100AutzEmployeeManager() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertGetDeny(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); @@ -114,7 +114,7 @@ public void test102AutzEmployeeManagerAddEmployee() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertAddAllow(USER_EMPLOYEE_FRED_FILE); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityMultitenant.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityMultitenant.java index 116f3759ad7..3c9f56708a8 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityMultitenant.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityMultitenant.java @@ -216,7 +216,7 @@ public void test000Sanity() throws Exception { cleanupAutzTest(USER_JACK_OID); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertSearch(UserType.class, null, NUMBER_OF_ALL_USERS); assertSearch(RoleType.class, null, getNumberOfRoles()); @@ -246,11 +246,11 @@ public void test010ImportOrgstruct() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); importObjectsFromFileNotRaw(ORG_MULTITENANT_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); dumpOrgTree(); @@ -382,7 +382,7 @@ public void test100AutzLetoRead() throws Exception { login(USER_LETO_ATREIDES_NAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); // Matching tenant assertGetAllow(UserType.class, USER_LETO_ATREIDES_OID); @@ -406,7 +406,7 @@ public void test100AutzLetoRead() throws Exception { assertSearch(OrgType.class, null, ORG_ATREIDES_OID, ORG_CALADAN_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertGlobalStateUntouched(); } @@ -423,7 +423,7 @@ public void test102AutzLetoAdd() throws Exception { login(USER_LETO_ATREIDES_NAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); // Matching tenant assertAddAllow(USER_DUNCAN_FILE); @@ -435,7 +435,7 @@ public void test102AutzLetoAdd() throws Exception { assertAddDeny(USER_DMURR_FILE); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); login(USER_ADMINISTRATOR_USERNAME); @@ -467,7 +467,7 @@ public void test104AutzLetoModify() throws Exception { login(USER_LETO_ATREIDES_NAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); // Matching tenant assertModifyAllow(UserType.class, USER_PAUL_ATREIDES_OID, UserType.F_LOCALITY, createPolyString("Arrakis")); @@ -479,7 +479,7 @@ public void test104AutzLetoModify() throws Exception { assertModifyDeny(UserType.class, USER_EDRIC_OID, UserType.F_LOCALITY, createPolyString("Whatever")); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertGlobalStateUntouched(); } @@ -498,7 +498,7 @@ public void test106AutzLetoAddResourceTask() throws Exception { login(USER_LETO_ATREIDES_NAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); // Matching tenant assertAddDummyResourceAllow(RESOURCE_DUMMY_CASTLE_CALADAN_FILE); @@ -510,7 +510,7 @@ public void test106AutzLetoAddResourceTask() throws Exception { assertAddDummyResourceDeny(RESOURCE_DUMMY_JUNCTION_FILE); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); login(USER_ADMINISTRATOR_USERNAME); @@ -543,7 +543,7 @@ public void test109AutzLetoDelete() throws Exception { login(USER_LETO_ATREIDES_NAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); // Matching tenant assertDeleteAllow(UserType.class, USER_DUNCAN_OID); @@ -555,7 +555,7 @@ public void test109AutzLetoDelete() throws Exception { assertDeleteDeny(UserType.class, USER_DMURR_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertGlobalStateUntouched(); } @@ -572,7 +572,7 @@ public void test110AutzLetoAddOrgs() throws Exception { login(USER_LETO_ATREIDES_NAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); // Matching tenant assertAddAllow(ORG_ARRAKIS_FILE); @@ -585,7 +585,7 @@ public void test110AutzLetoAddOrgs() throws Exception { assertAddDeny(ORG_JUNCTION_FILE); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); login(USER_ADMINISTRATOR_USERNAME); @@ -626,7 +626,7 @@ public void test112AutzLetoProtectTenant() throws Exception { login(USER_LETO_ATREIDES_NAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); // Matching tenant assertAddDeny(ORG_ATREIDES_SUBTENANT_FILE); @@ -677,7 +677,7 @@ public void test112AutzLetoProtectTenant() throws Exception { assertDeleteDeny(OrgType.class, ORG_GUILD_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertGlobalStateUntouched(); } @@ -695,7 +695,7 @@ public void test114AutzLetoKeepWithinTenant() throws Exception { login(USER_LETO_ATREIDES_NAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertAddAllow(ROLE_ATREIDES_GUARD_FILE); @@ -740,7 +740,7 @@ public void test114AutzLetoKeepWithinTenant() throws Exception { (task, result) -> unassignOrg(OrgType.class, ORG_CASTLE_CALADAN_OID, ORG_CALADAN_OID, task, result)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertGlobalStateUntouched(); } @@ -757,7 +757,7 @@ public void test116AutzLetoProtectTenantAdminRole() throws Exception { login(USER_LETO_ATREIDES_NAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertAddDeny(ROLE_ATREIDES_HACKER_FILE); @@ -797,7 +797,7 @@ public void test116AutzLetoProtectTenantAdminRole() throws Exception { RoleType.F_POLICY_EXCEPTION, task, result, policyException)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertGlobalStateUntouched(); } @@ -816,7 +816,7 @@ public void test118AutzLetoBusinessRoles() throws Exception { assertAddAllow(ROLE_ATREIDES_GUARD_FILE); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertAddAllow(ROLE_ATREIDES_SWORDMASTER_FILE); @@ -835,7 +835,7 @@ public void test118AutzLetoBusinessRoles() throws Exception { assertDeleteAllow(RoleType.class, ROLE_ATREIDES_SWORDMASTER_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertGlobalStateUntouched(); } @@ -855,7 +855,7 @@ public void test120AutzPaulEndUser() throws Exception { login(USER_PAUL_ATREIDES_NAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); // Requestable role assertAllow("assign guard to paul", @@ -874,7 +874,7 @@ public void test120AutzPaulEndUser() throws Exception { (task, result) -> assignRole(USER_PAUL_ATREIDES_OID, ROLE_CORRINO_EMPEROR_OID, task, result)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertGlobalStateUntouched(); } @@ -891,7 +891,7 @@ public void test122AutzDuncanRoleManager() throws Exception { login(USER_DUNCAN_NAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertDeny("assign guard to paul", (task, result) -> assignRole(USER_PAUL_ATREIDES_OID, ROLE_ATREIDES_GUARD_OID, task, result)); @@ -915,7 +915,7 @@ public void test122AutzDuncanRoleManager() throws Exception { (task, result) -> induceOrg(RoleType.class, ROLE_ATREIDES_SWORDMASTER_OID, ORG_CALADAN_OID, task, result)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertGlobalStateUntouched(); } @@ -937,7 +937,7 @@ public void test130AutzEdricRead() throws Exception { login(USER_EDRIC_NAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); // Wrong tenant assertGetDeny(UserType.class, USER_LETO_ATREIDES_OID); @@ -955,7 +955,7 @@ public void test130AutzEdricRead() throws Exception { assertSearch(OrgType.class, null, 0); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertGlobalStateUntouched(); } diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityPrincipal.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityPrincipal.java index e6259b8fa8c..d28ef006220 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityPrincipal.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityPrincipal.java @@ -155,7 +155,7 @@ public void test061GuybrushConditionalRoleTrue() throws Exception { resetAuthentication(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); MidPointPrincipal principal = focusProfileService.getPrincipal(USER_GUYBRUSH_USERNAME, UserType.class); // THEN @@ -274,11 +274,11 @@ public void test110GuybrushRoleNicePirate() throws Exception { resetAuthentication(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); MidPointPrincipal principal = focusProfileService.getPrincipal(USER_GUYBRUSH_USERNAME, UserType.class); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Principal guybrush", principal); assertEquals("Wrong number of authorizations", 2, principal.getAuthorities().size()); @@ -298,11 +298,11 @@ public void test111GuybrushRoleCaptain() throws Exception { resetAuthentication(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); MidPointPrincipal principal = focusProfileService.getPrincipal(USER_GUYBRUSH_USERNAME, UserType.class); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Principal guybrush", principal); assertEquals("Wrong number of authorizations", 3, principal.getAuthorities().size()); @@ -323,11 +323,11 @@ public void test119GuybrushUnassignRoles() throws Exception { resetAuthentication(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); MidPointPrincipal principal = focusProfileService.getPrincipal(USER_JACK_USERNAME, UserType.class); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertEquals("Wrong number of authorizations", 0, principal.getAuthorities().size()); assertNotAuthorized(principal, AUTZ_LOOT_URL); @@ -352,11 +352,11 @@ public void test120JackRoleIndirectPirate() throws Exception { resetAuthentication(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); MidPointPrincipal principal = focusProfileService.getPrincipal(USER_JACK_USERNAME, UserType.class); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Principal guybrush", principal); assertEquals("Wrong number of authorizations", 1, principal.getAuthorities().size()); @@ -384,11 +384,11 @@ public void test122JackOrgIndirectPirate() throws Exception { resetAuthentication(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); MidPointPrincipal principal = focusProfileService.getPrincipal(USER_JACK_USERNAME, UserType.class); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Principal guybrush", principal); assertEquals("Wrong number of authorizations", 1, principal.getAuthorities().size()); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractInboundSyncTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractInboundSyncTest.java index 05007a027b4..f8545a70246 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractInboundSyncTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractInboundSyncTest.java @@ -102,7 +102,7 @@ public void test100ImportLiveSyncTaskDummyEmerald() throws Exception { OperationResult result = task.getResult(); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); importSyncTask(resourceDummyEmerald); // THEN @@ -136,7 +136,7 @@ public void test110AddDummyEmeraldAccountMancomb() throws Exception { account.addAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME, gossip); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding dummy account", account.debugDump()); @@ -188,7 +188,7 @@ public void test120ModifyDummyEmeraldAccountMancombSeepbad() throws Exception { DummyAccount account = dummyResourceEmerald.getAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); account.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Mancomb Seepbad"); @@ -244,7 +244,7 @@ public void test122ModifyDummyEmeraldAccountMancombSeepNULL() throws Exception { DummyAccount account = dummyResourceEmerald.getAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); account.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Mancomb SeepNULL"); @@ -300,7 +300,7 @@ public void test124ModifyDummyEmeraldAccountMancombSeepevil() throws Exception { DummyAccount account = dummyResourceEmerald.getAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); account.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Mancomb Seepevil"); @@ -356,7 +356,7 @@ public void test126ModifyDummyEmeraldAccountMancombTitlePirate() throws Exceptio DummyAccount account = dummyResourceEmerald.getAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); account.replaceAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "Pirate"); @@ -413,7 +413,7 @@ public void test127ModifyDummyEmeraldAccountMancombTitlePirateNull() throws Exce DummyAccount account = dummyResourceEmerald.getAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); account.replaceAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME); @@ -470,7 +470,7 @@ public void test129ModifyDummyEmeraldAccountMancombSeepgood() throws Exception { DummyAccount account = dummyResourceEmerald.getAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); account.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Mancomb Seepgood"); @@ -542,7 +542,7 @@ public void test300AddDummyEmeraldAccountPosixUser() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_POSIX_GID_NUMBER, Collections.singleton(10001)); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding dummy account", account.debugDump()); @@ -595,7 +595,7 @@ public void test310ModifyDummyEmeraldAccountPosixUserUidNumber() throws Exceptio DummyAccount account = dummyResourceEmerald.getAccountByUsername(ACCOUNT_POSIXUSER_DUMMY_USERNAME); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); account.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_POSIX_UID_NUMBER, 1002); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractObjTemplateSyncTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractObjTemplateSyncTest.java index 1225ebf6448..2a07e6e549b 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractObjTemplateSyncTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractObjTemplateSyncTest.java @@ -117,7 +117,7 @@ public void test100ImportLiveSyncTaskDummyByzantine() throws Exception { OperationResult result = task.getResult(); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); importSyncTask(resourceDummyByzantine); // THEN @@ -150,7 +150,7 @@ public void test110AddDummyByzantineAccountMancomb() throws Exception { account.addAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME, gossip); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); display("Adding dummy account", account.debugDump()); @@ -159,7 +159,7 @@ public void test110AddDummyByzantineAccountMancomb() throws Exception { waitForSyncTaskNextRun(resourceDummyByzantine); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject accountMancomb = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, resourceDummyByzantine); display("Account mancomb", accountMancomb); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractSynchronizationStoryTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractSynchronizationStoryTest.java index b345d59b4f9..c743e7f5bb8 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractSynchronizationStoryTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractSynchronizationStoryTest.java @@ -112,11 +112,11 @@ public void test100ImportLiveSyncTaskDummyGreen() throws Exception { OperationResult result = task.getResult(); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); importSyncTask(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForSyncTaskStart(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); } @@ -143,14 +143,14 @@ public void test110AddDummyGreenAccountMancomb() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Melee Island"); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); getDummyResource(RESOURCE_DUMMY_GREEN_NAME).addAccount(account); waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject accountMancomb = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); display("Account mancomb", accountMancomb); @@ -198,11 +198,11 @@ public void test200ImportLiveSyncTaskDummyBlue() throws Exception { OperationResult result = task.getResult(); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); importSyncTask(getDummyResourceObject(RESOURCE_DUMMY_BLUE_NAME)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForSyncTaskStart(getDummyResourceObject(RESOURCE_DUMMY_BLUE_NAME)); } @@ -222,14 +222,14 @@ public void test210AddDummyGreenAccountWally() throws Exception { prepareNotifications(); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); getDummyResourceController(RESOURCE_DUMMY_GREEN_NAME).addAccount(ACCOUNT_WALLY_DUMMY_USERNAME, "Wally Feed", "Scabb Island"); // Wait for sync task to pick up the change waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); dumpSyncTaskTree(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME), result); @@ -274,7 +274,7 @@ public void test220AddDummyBlueAccountWally() throws Exception { prepareNotifications(); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).addAccount(ACCOUNT_WALLY_DUMMY_USERNAME, "Wally Feed", "Scabb Island"); // Wait for sync task to pick up the change @@ -288,7 +288,7 @@ public void test220AddDummyBlueAccountWally() throws Exception { waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject(RESOURCE_DUMMY_BLUE_NAME)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); dumpSyncTaskTree(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME), result); dumpSyncTaskTree(getDummyResourceObject(RESOURCE_DUMMY_BLUE_NAME), result); @@ -338,7 +338,7 @@ public void test315AddDummyBlueAccountMancomb() throws Exception { prepareNotifications(); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).addAccount(ACCOUNT_MANCOMB_DUMMY_USERNAME, "Mancomb Seepgood", "Melee Island"); // Wait for sync task to pick up the change @@ -351,7 +351,7 @@ public void test315AddDummyBlueAccountMancomb() throws Exception { waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject(RESOURCE_DUMMY_BLUE_NAME)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); // The ckecks are simplified here because the developer has a lazy mood :-) assertDummyAccount(RESOURCE_DUMMY_BLUE_NAME, ACCOUNT_MANCOMB_DUMMY_USERNAME, "Mancomb Seepgood", true); @@ -393,11 +393,11 @@ public void test350ImportLiveSyncTaskDummyDefault() throws Exception { OperationResult result = task.getResult(); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); importSyncTask(getDummyResourceObject()); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForSyncTaskStart(getDummyResourceObject()); @@ -428,11 +428,11 @@ public void test360ModifyUserAddDummyDefaultAccount() throws Exception { Collection> deltas = (Collection)MiscUtil.createCollection(userDelta); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); dumpSyncTaskTree(getDummyResourceObject(), result); dumpSyncTaskTree(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME), result); @@ -545,7 +545,7 @@ public void test370ModifyDummyGreenAccountWally() throws Exception { DummyAccount wallyDummyAccount = getDummyResource(RESOURCE_DUMMY_GREEN_NAME).getAccountByUsername(ACCOUNT_WALLY_DUMMY_USERNAME); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); wallyDummyAccount.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Wally B. Feed"); // Wait for sync task to pick up the change @@ -560,7 +560,7 @@ public void test370ModifyDummyGreenAccountWally() throws Exception { waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject()); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); dumpSyncTaskTree(getDummyResourceObject(), result); dumpSyncTaskTree(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME), result); @@ -627,7 +627,7 @@ public void test380ModifyUserWallyFullName() throws Exception { DummyAccount wallyDummyAccount = getDummyResource(RESOURCE_DUMMY_GREEN_NAME).getAccountByUsername(ACCOUNT_WALLY_DUMMY_USERNAME); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(userWallyOid, UserType.F_FULL_NAME, task, result, PrismTestUtil.createPolyString("Bloodnose")); // Wait for sync tasks to pick up the change and have some chance to screw things @@ -643,7 +643,7 @@ public void test380ModifyUserWallyFullName() throws Exception { waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); dumpSyncTaskTree(getDummyResourceObject(), result); dumpSyncTaskTree(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME), result); @@ -697,7 +697,7 @@ public void test382ModifyUserWallyLocality() throws Exception { DummyAccount wallyDummyAccount = getDummyResource(RESOURCE_DUMMY_GREEN_NAME).getAccountByUsername(ACCOUNT_WALLY_DUMMY_USERNAME); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(userWallyOid, UserType.F_LOCALITY, task, result, PrismTestUtil.createPolyString("Plunder island")); // Wait for sync tasks to pick up the change and have some chance to screw things @@ -713,7 +713,7 @@ public void test382ModifyUserWallyLocality() throws Exception { waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); dumpSyncTaskTree(getDummyResourceObject(), result); dumpSyncTaskTree(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME), result); @@ -776,7 +776,7 @@ public void test400DeleteDummyDefaultAccount() throws Exception { prepareNotifications(); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); getDummyResource().deleteAccountByName(ACCOUNT_WALLY_DUMMY_USERNAME); display("Dummy (default) resource", getDummyResource().debugDump()); @@ -787,7 +787,7 @@ public void test400DeleteDummyDefaultAccount() throws Exception { waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); dumpSyncTaskTree(getDummyResourceObject(), result); dumpSyncTaskTree(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME), result); @@ -844,7 +844,7 @@ public void test410DeleteDummyGreenAccount() throws Exception { prepareNotifications(); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); getDummyResource(RESOURCE_DUMMY_GREEN_NAME).deleteAccountByName(ACCOUNT_WALLY_DUMMY_USERNAME); // Make sure we have steady state @@ -853,7 +853,7 @@ public void test410DeleteDummyGreenAccount() throws Exception { waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); dumpSyncTaskTree(getDummyResourceObject(), result); dumpSyncTaskTree(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME), result); @@ -901,7 +901,7 @@ public void test410DeleteDummyGreenAccount() throws Exception { waitForSyncTaskNextRun(getDummyResourceObject(RESOURCE_DUMMY_BLUE_NAME)); } - assertNoShadow(ACCOUNT_WALLY_DUMMY_USERNAME, getDummyResourceObject(RESOURCE_DUMMY_BLUE_NAME), task, result); + assertNoShadow(ACCOUNT_WALLY_DUMMY_USERNAME, getDummyResourceObject(RESOURCE_DUMMY_BLUE_NAME), result); assertUsers(7 + getNumberOfExtraDummyUsers()); @@ -941,14 +941,14 @@ public void test510AddDummyGreenAccountWallyUserTemplate() throws Exception { assumeUserTemplate(USER_TEMPLATE_SYNC_OID, getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME).asObjectable(), null, result); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); getDummyResourceController(RESOURCE_DUMMY_GREEN_NAME).addAccount(ACCOUNT_WALLY_DUMMY_USERNAME, "Wally Feed", "Scabb Island"); // Wait for sync task to pick up the change waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject accountWallyGreen = checkWallyAccount(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME), getDummyResource(RESOURCE_DUMMY_GREEN_NAME), "green", "Wally Feed"); assertShadowOperationalData(accountWallyGreen, SynchronizationSituationType.LINKED); @@ -992,14 +992,14 @@ public void test600AddDummyGreenAccountCalypso() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "The Seven Seas"); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); getDummyResource(RESOURCE_DUMMY_GREEN_NAME).addAccount(account); waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject accountShadow = findAccountByUsername(ACCOUNT_CALYPSO_DUMMY_USERNAME, getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); display("Account calypso", accountShadow); @@ -1038,14 +1038,14 @@ public void test700AddDummyGreenAccountXjojo() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Scabb Island"); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); getDummyResource(RESOURCE_DUMMY_GREEN_NAME).addAccount(account); waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject accountAfter = findAccountByUsername("Xjojo", getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); display("Account after", accountAfter); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestImportRecon.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestImportRecon.java index 7103f287906..3bad0e2f56f 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestImportRecon.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestImportRecon.java @@ -374,11 +374,11 @@ public void test100ImportStanFromResourceDummy() throws Exception { loginImportUser(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.importFromResource(ACCOUNT_STAN_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display(result); assertSuccess(result); @@ -430,11 +430,11 @@ public void test150ImportFromResourceDummy() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.importFromResource(RESOURCE_DUMMY_OID, new QName(RESOURCE_DUMMY_NAMESPACE, "AccountObjectClass"), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); @@ -443,7 +443,7 @@ public void test150ImportFromResourceDummy() throws Exception { waitForTaskFinish(task, true, 40000); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); TestUtil.assertSuccess(task.getResult()); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 6); @@ -489,11 +489,11 @@ public void test155ImportFromResourceDummyAgain() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.importFromResource(RESOURCE_DUMMY_OID, new QName(RESOURCE_DUMMY_NAMESPACE, "AccountObjectClass"), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); @@ -502,7 +502,7 @@ public void test155ImportFromResourceDummyAgain() throws Exception { waitForTaskFinish(task, true, 40000); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(task.getResult()); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 3); @@ -557,11 +557,11 @@ public void test160ImportFromResourceDummyLime() throws Exception { loginImportUser(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.importFromResource(RESOURCE_DUMMY_LIME_OID, new QName(RESOURCE_DUMMY_LIME_NAMESPACE, "AccountObjectClass"), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); @@ -570,7 +570,7 @@ public void test160ImportFromResourceDummyLime() throws Exception { waitForTaskFinish(task, true, 40000); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); TestUtil.assertSuccess(task.getResult()); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 2); @@ -635,11 +635,11 @@ public void test162ImportFromResourceDummyLimeRappOrganizationScummBar() throws rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.importFromResource(RESOURCE_DUMMY_LIME_OID, new QName(RESOURCE_DUMMY_LIME_NAMESPACE, "AccountObjectClass"), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); @@ -648,7 +648,7 @@ public void test162ImportFromResourceDummyLimeRappOrganizationScummBar() throws waitForTaskFinish(task, true, 40000); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); TestUtil.assertSuccess(task.getResult()); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 2); @@ -720,11 +720,11 @@ public void test164ImportFromResourceDummyLimeRappOrganizationNull() throws Exce rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.importFromResource(RESOURCE_DUMMY_LIME_OID, new QName(RESOURCE_DUMMY_LIME_NAMESPACE, "AccountObjectClass"), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); @@ -733,7 +733,7 @@ public void test164ImportFromResourceDummyLimeRappOrganizationNull() throws Exce waitForTaskFinish(task, true, 40000); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(task.getResult()); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 2); @@ -813,16 +813,16 @@ public void test200ReconcileDummy() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); importObjectFromFile(TASK_RECONCILE_DUMMY_SINGLE_FILE); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForTaskFinish(TASK_RECONCILE_DUMMY_OID, false); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 6); reconciliationTaskResultListener.assertResult(RESOURCE_DUMMY_OID, 0, 7, 0, 0); @@ -912,12 +912,12 @@ public void test210ReconcileDummyBroken() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); restartTask(TASK_RECONCILE_DUMMY_OID); waitForTaskFinish(TASK_RECONCILE_DUMMY_OID, false, DEFAULT_TASK_WAIT_TIMEOUT, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); List> users = modelService.searchObjects(UserType.class, null, null, task, result); display("Users after reconciliation (broken resource)", users); @@ -978,12 +978,12 @@ public void test219ReconcileDummyFixed() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); restartTask(TASK_RECONCILE_DUMMY_OID); waitForTaskFinish(TASK_RECONCILE_DUMMY_OID, false, DEFAULT_TASK_WAIT_TIMEOUT, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 6); reconciliationTaskResultListener.assertResult(RESOURCE_DUMMY_OID, 0, 7, 0, 0); @@ -1063,12 +1063,12 @@ public void test220ReconcileDummyBrokenGuybrush() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); restartTask(TASK_RECONCILE_DUMMY_OID); waitForTaskFinish(TASK_RECONCILE_DUMMY_OID, false, DEFAULT_TASK_WAIT_TIMEOUT, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); List> users = modelService.searchObjects(UserType.class, null, null, task, result); display("Users after reconciliation (broken resource account)", users); @@ -1132,12 +1132,12 @@ public void test229ReconcileDummyFixed() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); restartTask(TASK_RECONCILE_DUMMY_OID); waitForTaskFinish(TASK_RECONCILE_DUMMY_OID, false, DEFAULT_TASK_WAIT_TIMEOUT, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 6); reconciliationTaskResultListener.assertResult(RESOURCE_DUMMY_OID, 0, 7, 0, 0); @@ -1222,12 +1222,12 @@ public void test230ReconcileDummyRename() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); restartTask(TASK_RECONCILE_DUMMY_OID); waitForTaskFinish(TASK_RECONCILE_DUMMY_OID, false, DEFAULT_TASK_WAIT_TIMEOUT, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 6); reconciliationTaskResultListener.assertResult(RESOURCE_DUMMY_OID, 0, 7, 0, 1); @@ -1338,15 +1338,15 @@ public void test300ReconcileDummyAzureAddAccountOtis() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); importObjectFromFile(TASK_RECONCILE_DUMMY_AZURE_FILE); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForTaskFinish(TASK_RECONCILE_DUMMY_AZURE_OID, false); - displayThen(TEST_NAME); + then(TEST_NAME); List> users = modelService.searchObjects(UserType.class, null, null, task, result); display("Users after reconcile", users); @@ -1401,15 +1401,15 @@ public void test310ReconcileDummyAzureAgain() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); restartTask(TASK_RECONCILE_DUMMY_AZURE_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForTaskFinish(TASK_RECONCILE_DUMMY_AZURE_OID, false); - displayThen(TEST_NAME); + then(TEST_NAME); reconciliationTaskResultListener.assertResult(RESOURCE_DUMMY_AZURE_OID, 0, 1, 0, 0); List> users = modelService.searchObjects(UserType.class, null, null, task, result); @@ -1470,15 +1470,15 @@ public void test320ReconcileDummyAzureDeleteOtis() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); restartTask(TASK_RECONCILE_DUMMY_AZURE_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForTaskFinish(TASK_RECONCILE_DUMMY_AZURE_OID, false); - displayThen(TEST_NAME); + then(TEST_NAME); List> users = modelService.searchObjects(UserType.class, null, null, task, result); display("Users after reconcile", users); @@ -1544,15 +1544,15 @@ public void test330ReconcileDummyAzureAddAccountRapp() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); restartTask(TASK_RECONCILE_DUMMY_AZURE_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForTaskFinish(TASK_RECONCILE_DUMMY_AZURE_OID, false); - displayThen(TEST_NAME); + then(TEST_NAME); List> users = modelService.searchObjects(UserType.class, null, null, task, result); display("Users after reconcile", users); @@ -1651,15 +1651,15 @@ public void test332ModifyUserRappAndReconcileDummyAzure() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); restartTask(TASK_RECONCILE_DUMMY_AZURE_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForTaskFinish(TASK_RECONCILE_DUMMY_AZURE_OID, false); - displayThen(TEST_NAME); + then(TEST_NAME); List> users = modelService.searchObjects(UserType.class, null, null, task, result); display("Users after reconcile", users); @@ -1725,15 +1725,15 @@ public void test334AssignRoleCorpseToRappAndReconcileDummyAzure() throws Excepti reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); restartTask(TASK_RECONCILE_DUMMY_AZURE_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForTaskFinish(TASK_RECONCILE_DUMMY_AZURE_OID, false); - displayThen(TEST_NAME); + then(TEST_NAME); List> users = modelService.searchObjects(UserType.class, null, null, task, result); display("Users after reconcile", users); @@ -1795,15 +1795,15 @@ public void test339ReconcileDummyAzureDeleteRapp() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); restartTask(TASK_RECONCILE_DUMMY_AZURE_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForTaskFinish(TASK_RECONCILE_DUMMY_AZURE_OID, false); - displayThen(TEST_NAME); + then(TEST_NAME); List> users = modelService.searchObjects(UserType.class, null, null, task, result); display("Users after reconcile", users); @@ -1861,15 +1861,15 @@ public void test400ReconcileDummyLimeAddAccount() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); importObjectFromFile(TASK_RECONCILE_DUMMY_LIME_FILE); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForTaskFinish(TASK_RECONCILE_DUMMY_LIME_OID, false); - displayThen(TEST_NAME); + then(TEST_NAME); List> users = modelService.searchObjects(UserType.class, null, null, task, result); display("Users after reconcile", users); @@ -1916,11 +1916,11 @@ public void test401ReconcileDummyLimeKateOnlyEmpty() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1964,11 +1964,11 @@ public void test402ReconcileDummyLimeKateOnlyGrog() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2012,11 +2012,11 @@ public void test403ReconcileDummyLimeKateOnlyNoValue() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2057,11 +2057,11 @@ public void test404ReconcileDummyLimeKateOnlyRum() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2104,11 +2104,11 @@ public void test405ReconcileDummyLimeKateOnlyEmpty() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2148,11 +2148,11 @@ public void test406ReconcileDummyLimeKateOnlyEmptyAgain() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2193,11 +2193,11 @@ public void test410ReconcileDummyLimeKatePassword() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = findUserByUsername(ACCOUNT_CAPSIZE_NAME); @@ -2237,15 +2237,15 @@ public void test420ReconcileDummyLimeDeleteLinkedAccount() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); restartTask(TASK_RECONCILE_DUMMY_LIME_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForTaskFinish(TASK_RECONCILE_DUMMY_LIME_OID, false); - displayThen(TEST_NAME); + then(TEST_NAME); List> users = modelService.searchObjects(UserType.class, null, null, task, result); display("Users after reconcile", users); @@ -2294,11 +2294,11 @@ public void test500ImportTAugustusFromResourceDummy() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.importFromResource(ACCOUNT_TAUGUSTUS_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); loginAdministrator(); @@ -2363,11 +2363,11 @@ public void test502ImportAugustusFromResourceDummy() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.importFromResource(ACCOUNT_AUGUSTUS_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); loginAdministrator(); @@ -2449,11 +2449,11 @@ public void test510ImportFromResourceDummy() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.importFromResource(RESOURCE_DUMMY_OID, new QName(RESOURCE_DUMMY_NAMESPACE, "AccountObjectClass"), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); @@ -2462,7 +2462,7 @@ public void test510ImportFromResourceDummy() throws Exception { waitForTaskFinish(task, true, 40000); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); TestUtil.assertSuccess(task.getResult()); // First fetch: search in import handler @@ -2521,7 +2521,7 @@ public void test520ReconResourceDummyFilter() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); // runPrivileged is necessary for TestImportReconAuthorizations as importObjectFromFile() is using raw operations runPrivileged(() -> { try { @@ -2552,11 +2552,11 @@ public void test600SearchAllDummyAccounts() throws Exception { new QName(RESOURCE_DUMMY_NAMESPACE, "AccountObjectClass"), prismContext); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); SearchResultList> objects = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2581,11 +2581,11 @@ public void test610SearchDummyAccountsNameSubstring() throws Exception { .build(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); SearchResultList> objects = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2608,16 +2608,16 @@ public void test900DeleteDummyShadows() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); importObjectFromFile(TASK_DELETE_DUMMY_SHADOWS_FILE); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForTaskFinish(TASK_DELETE_DUMMY_SHADOWS_OID, true, 20000); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); PrismObject deleteTask = getTask(TASK_DELETE_DUMMY_SHADOWS_OID); @@ -2653,16 +2653,16 @@ public void test910DeleteDummyAccounts() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); importObjectFromFile(TASK_DELETE_DUMMY_ACCOUNTS_FILE); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForTaskFinish(TASK_DELETE_DUMMY_ACCOUNTS_OID, true, 20000); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 2); PrismObject deleteTask = getTask(TASK_DELETE_DUMMY_ACCOUNTS_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundLiveSyncTask.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundLiveSyncTask.java index 10dac92a5be..86a4e3d1cbf 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundLiveSyncTask.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundLiveSyncTask.java @@ -72,14 +72,14 @@ public void test199DeleteDummyEmeraldAccountMancomb() throws Exception { assertUsers(7); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); dummyResourceEmerald.deleteAccountByName(ACCOUNT_MANCOMB_DUMMY_USERNAME); waitForSyncTaskNextRun(resourceDummyEmerald); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject accountMancomb = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, resourceDummyEmerald); display("Account mancomb", accountMancomb); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundReconTask.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundReconTask.java index 416037f5304..50ec734dc3d 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundReconTask.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundReconTask.java @@ -78,12 +78,12 @@ public void test180NoChange() throws Exception { assertUsers(7); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); waitForSyncTaskNextRun(resourceDummyEmerald); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject accountMancomb = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, resourceDummyEmerald); display("Account mancomb", accountMancomb); @@ -120,14 +120,14 @@ public void test199DeleteDummyEmeraldAccountMancomb() throws Exception { assertUsers(7); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); dummyResourceEmerald.deleteAccountByName(ACCOUNT_MANCOMB_DUMMY_USERNAME); waitForSyncTaskNextRun(resourceDummyEmerald); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject accountMancomb = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, resourceDummyEmerald); display("Account mancomb", accountMancomb); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTask.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTask.java index f7ab748795e..980e8f3ca5f 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTask.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTask.java @@ -100,7 +100,7 @@ public void test999DeletingNotUpdatedShadowDummyGreen() throws Exception { accountJack.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "The Seven Seas"); /// WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); getDummyResource(RESOURCE_DUMMY_GREEN_NAME).addAccount(accountJack); waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); @@ -112,7 +112,7 @@ public void test999DeletingNotUpdatedShadowDummyGreen() throws Exception { rerunTask(TASK_DELETE_NOT_UPDATED_SHADOWS_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject userCarol = findUserByUsername(ACCOUNT_CAROL_DUMMY_USERNAME); display("User carol", userCarol); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTaskMechanics.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTaskMechanics.java index 205ffd9b3b1..f9c947c72e5 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTaskMechanics.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTaskMechanics.java @@ -158,13 +158,13 @@ public void test100SuspendWhileIcfSync() throws Exception { interruptedSyncResource.getDummyResource().setOperationDelayOffset(2000); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); waitForTaskNextStart(TASK_SLOW_RESOURCE_OID, false, 2000, true); // starts the task boolean suspended = suspendTask(TASK_SLOW_RESOURCE_OID, 10000); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertTrue("Task was not suspended", suspended); Task taskAfter = taskManager.getTaskWithResult(TASK_SLOW_RESOURCE_OID, result); @@ -189,13 +189,13 @@ public void test105SuspendWhileIcfSyncImprecise() throws Exception { interruptedSyncImpreciseResource.getDummyResource().setOperationDelayOffset(500); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); waitForTaskNextStart(TASK_SLOW_RESOURCE_IMPRECISE_OID, false, 2000, true); // starts the task boolean suspended = suspendTask(TASK_SLOW_RESOURCE_IMPRECISE_OID, 5000); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertTrue("Task was not suspended", suspended); Task taskAfter = taskManager.getTaskWithResult(TASK_SLOW_RESOURCE_IMPRECISE_OID, result); @@ -228,14 +228,14 @@ public void test110SuspendWhileProcessing() throws Exception { DummyInterruptedSyncResource.delay = 100; // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); waitForTaskNextStart(TASK_SLOW_MODEL_OID, false, 2000, true); // starts the task Thread.sleep(4000); boolean suspended = suspendTask(TASK_SLOW_MODEL_OID, 5000); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertTrue("Task was not suspended", suspended); Task taskAfter = taskManager.getTaskWithResult(TASK_SLOW_MODEL_OID, result); @@ -284,14 +284,14 @@ public void test115SuspendWhileProcessingImprecise() throws Exception { DummyInterruptedSyncImpreciseResource.delay = 100; // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); waitForTaskNextStart(TASK_SLOW_MODEL_IMPRECISE_OID, false, 2000, true); // starts the task Thread.sleep(4000); boolean suspended = suspendTask(TASK_SLOW_MODEL_IMPRECISE_OID, 5000); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertTrue("Task was not suspended", suspended); Task taskAfter = taskManager.getTaskWithResult(TASK_SLOW_MODEL_IMPRECISE_OID, result); @@ -329,12 +329,12 @@ public void test120Batched() throws Exception { DummyInterruptedSyncResource.errorOn = getUserName(24, true); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); waitForTaskNextRun(TASK_BATCHED_OID, false, 10000, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); Task taskAfter = taskManager.getTaskWithResult(TASK_BATCHED_OID, result); displayTaskWithOperationStats("Task after", taskAfter); @@ -344,12 +344,12 @@ public void test120Batched() throws Exception { assertObjects(UserType.class, query, 10); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); waitForTaskNextRun(TASK_BATCHED_OID, false, 10000, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); taskAfter = taskManager.getTaskWithResult(TASK_BATCHED_OID, result); displayTaskWithOperationStats("Task after", taskAfter); @@ -359,12 +359,12 @@ public void test120Batched() throws Exception { assertObjects(UserType.class, query, 20); // WHEN 3 (with error) - displayWhen(TEST_NAME); + when(TEST_NAME); waitForTaskNextRun(TASK_BATCHED_OID, false, 10000, true); // THEN 3 (with error) - displayThen(TEST_NAME); + then(TEST_NAME); taskAfter = taskManager.getTaskWithResult(TASK_BATCHED_OID, result); displayTaskWithOperationStats("Task after", taskAfter); @@ -396,7 +396,7 @@ public void test125BatchedImprecise() throws Exception { DummyInterruptedSyncImpreciseResource.delay = 0; // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); try { waitForTaskNextRun(TASK_BATCHED_IMPRECISE_OID, false, 10000, true); @@ -406,7 +406,7 @@ public void test125BatchedImprecise() throws Exception { } // THEN - displayThen(TEST_NAME); + then(TEST_NAME); Task taskAfter = taskManager.getTaskWithResult(TASK_BATCHED_IMPRECISE_OID, result); displayTaskWithOperationStats("Task after", taskAfter); @@ -444,12 +444,12 @@ public void test130Error() throws Exception { DummyInterruptedSyncResource.errorOn = getUserName(ERROR_ON, true); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); waitForTaskNextRun(TASK_ERROR_OID, false, 10000, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); Task taskAfter = taskManager.getTaskWithResult(TASK_ERROR_OID, result); displayTaskWithOperationStats("Task after", taskAfter); @@ -466,12 +466,12 @@ public void test130Error() throws Exception { // Another run - should fail the same // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); waitForTaskNextRun(TASK_ERROR_OID, false, 10000, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); taskAfter = taskManager.getTaskWithResult(TASK_ERROR_OID, result); displayTaskWithOperationStats("Task after", taskAfter); @@ -505,7 +505,7 @@ public void test135ErrorImprecise() throws Exception { DummyInterruptedSyncImpreciseResource.errorOn = getUserName(ERROR_ON, false); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); try { waitForTaskNextRun(TASK_ERROR_IMPRECISE_OID, false, 10000, true); @@ -515,7 +515,7 @@ public void test135ErrorImprecise() throws Exception { } // THEN - displayThen(TEST_NAME); + then(TEST_NAME); Task taskAfter = taskManager.getTaskWithResult(TASK_ERROR_IMPRECISE_OID, result); displayTaskWithOperationStats("Task after", taskAfter); @@ -534,12 +534,12 @@ public void test135ErrorImprecise() throws Exception { // Another run - should fail the same // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); waitForTaskNextRun(TASK_ERROR_IMPRECISE_OID, false, 10000, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); taskAfter = taskManager.getTaskWithResult(TASK_ERROR_IMPRECISE_OID, result); displayTaskWithOperationStats("Task after", taskAfter); @@ -572,12 +572,12 @@ public void test140DryRun() throws Exception { DummyInterruptedSyncResource.errorOn = null; // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); waitForTaskNextRun(TASK_DRY_RUN.oid, false, 10000, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); Task taskAfter = taskManager.getTaskWithResult(TASK_DRY_RUN.oid, result); displayTaskWithOperationStats("Task after", taskAfter); @@ -611,12 +611,12 @@ public void test150DryRunWithUpdate() throws Exception { DummyInterruptedSyncResource.errorOn = null; // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); waitForTaskNextRun(TASK_DRY_RUN_WITH_UPDATE.oid, false, 10000, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); Task taskAfter = taskManager.getTaskWithResult(TASK_DRY_RUN_WITH_UPDATE.oid, result); displayTaskWithOperationStats("Task after", taskAfter); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelDiscovery.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelDiscovery.java index bb6239b076f..c03a5a0006a 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelDiscovery.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelDiscovery.java @@ -255,11 +255,11 @@ public void test100Synchronize() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(getSyncTaskFile(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); if (DISTRIBUTION == Distribution.MULTITHREADED) { waitForTaskFinish(getSyncTaskOid(), true, 600000); @@ -268,7 +268,7 @@ public void test100Synchronize() throws Exception { } // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelSynchronization.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelSynchronization.java index 462db5b3a75..351c8e4f790 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelSynchronization.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelSynchronization.java @@ -214,11 +214,11 @@ public void test100Synchronize() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(getSyncTaskFile(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); if (DISTRIBUTION == Distribution.MULTITHREADED) { waitForTaskFinish(getSyncTaskOid(), true, 600000); @@ -227,7 +227,7 @@ public void test100Synchronize() throws Exception { } // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestRecomputeTask.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestRecomputeTask.java index 0bfb8f7cb14..582d0766293 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestRecomputeTask.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestRecomputeTask.java @@ -171,7 +171,7 @@ public void test100RecomputeAll() throws Exception { TestUtil.assertSuccess(result); // WHEN - displayWhen(); + when(); addTask(TASK_USER_RECOMPUTE_FILE); dummyAuditService.clear(); @@ -179,12 +179,12 @@ public void test100RecomputeAll() throws Exception { waitForTaskStart(TASK_USER_RECOMPUTE_OID, false); // WHEN - displayWhen(); + when(); waitForTaskFinish(TASK_USER_RECOMPUTE_OID, true, 40000); // THEN - displayThen(); + then(); List> users = modelService.searchObjects(UserType.class, null, null, task, result); display("Users after recompute", users); @@ -265,12 +265,12 @@ public void test110RecomputeSome() throws Exception { TestUtil.assertSuccess(result); // Now do something evil, remove "red" construction from judge role - modifyRoleDeleteInducement(ROLE_JUDGE_OID, 1111L, false, null, null); + modifyRoleDeleteInducement(ROLE_JUDGE_OID, 1111L, false, null, getTestTask()); displayRoles(task, result); // WHEN - displayWhen(); + when(); addTask(TASK_USER_RECOMPUTE_CAPTAIN_FILE); dummyAuditService.clear(); @@ -278,12 +278,12 @@ public void test110RecomputeSome() throws Exception { waitForTaskStart(TASK_USER_RECOMPUTE_CAPTAIN_OID, false); // WHEN - displayWhen(); + when(); waitForTaskFinish(TASK_USER_RECOMPUTE_CAPTAIN_OID, true, 40000); // THEN - displayThen(); + then(); List> users = modelService.searchObjects(UserType.class, null, null, task, result); display("Users after recompute", users); @@ -322,7 +322,7 @@ public void test120RecomputeByExpression() throws Exception { TestUtil.assertSuccess(result); // WHEN - displayWhen(); + when(); addTask(TASK_USER_RECOMPUTE_HERMAN_BY_EXPRESSION_FILE); dummyAuditService.clear(); @@ -330,12 +330,12 @@ public void test120RecomputeByExpression() throws Exception { waitForTaskStart(TASK_USER_RECOMPUTE_HERMAN_BY_EXPRESSION_OID, false); // WHEN - displayWhen(); + when(); waitForTaskFinish(TASK_USER_RECOMPUTE_HERMAN_BY_EXPRESSION_OID, true, 40000); // THEN - displayThen(); + then(); List> users = modelService.searchObjects(UserType.class, null, null, task, result); display("Users after recompute", users); @@ -401,7 +401,7 @@ public void test130RecomputeLight() throws Exception { rememberCounter(InternalCounters.CONNECTOR_OPERATION_COUNT); // WHEN - displayWhen(); + when(); addTask(TASK_USER_RECOMPUTE_LIGHT_FILE); dummyAuditService.clear(); @@ -409,12 +409,12 @@ public void test130RecomputeLight() throws Exception { waitForTaskStart(TASK_USER_RECOMPUTE_LIGHT_OID, false); // WHEN - displayWhen(); + when(); waitForTaskFinish(TASK_USER_RECOMPUTE_LIGHT_OID, true, 40000); // THEN - displayThen(); + then(); List> users = modelService.searchObjects(UserType.class, null, null, task, result); display("Users after recompute", users); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestUuid.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestUuid.java index 6393de457aa..adcd85eea7b 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestUuid.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestUuid.java @@ -136,16 +136,16 @@ public void test200ReconcileDummyUuid() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); importObjectFromFile(TASK_RECONCILE_DUMMY_UUID_FILE); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForTaskFinish(TASK_RECONCILE_DUMMY_UUID_OID, false); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); reconciliationTaskResultListener.assertResult(RESOURCE_DUMMY_UUID_OID, 0, 0, 0, 0); List> users = modelService.searchObjects(UserType.class, null, null, task, result); @@ -191,16 +191,16 @@ public void test210ReconcileDummyUuidAddAugustus() throws Exception { Task taskBefore = taskManager.getTask(TASK_RECONCILE_DUMMY_UUID_OID, result); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); restartTask(TASK_RECONCILE_DUMMY_UUID_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForTaskNextRunAssertSuccess(taskBefore, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); reconciliationTaskResultListener.assertResult(RESOURCE_DUMMY_UUID_OID, 0, 1, 0, 0); List> users = modelService.searchObjects(UserType.class, null, null, task, result); @@ -272,16 +272,16 @@ public void test220ReconcileDummyUuidDeleteAddAugustus() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); restartTask(TASK_RECONCILE_DUMMY_UUID_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForTaskNextRunAssertSuccess(taskBefore, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); reconciliationTaskResultListener.assertResult(RESOURCE_DUMMY_UUID_OID, 0, 1, 0, 1); List> users = modelService.searchObjects(UserType.class, null, null, task, result); @@ -360,16 +360,16 @@ public void test230ReconcileDummyUuidDeleteAugustusAddAugustina() throws Excepti reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); restartTask(TASK_RECONCILE_DUMMY_UUID_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForTaskNextRunAssertSuccess(taskBefore, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); reconciliationTaskResultListener.assertResult(RESOURCE_DUMMY_UUID_OID, 0, 1, 0, 2); List> users = modelService.searchObjects(UserType.class, null, null, task, result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestValidityRecomputeTask.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestValidityRecomputeTask.java index 14405e2e69c..a178675fdad 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestValidityRecomputeTask.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestValidityRecomputeTask.java @@ -100,7 +100,7 @@ public void test100ImportValidityScannerTask() throws Exception { XMLGregorianCalendar startCal = clock.currentTimeXMLGregorianCalendar(); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); importObjectFromFile(getValidityScannerTaskFileName()); waitForValidityTaskStart(); @@ -198,7 +198,7 @@ public void test115JackAssignJudgeValid() throws Exception { private void testJackAssignRoleJudgeValid(final String TEST_NAME, ActivationType activationType, Task task, OperationResult result) throws Exception { // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_BIG_JUDGE_OID, activationType, task, result); // THEN @@ -207,7 +207,7 @@ private void testJackAssignRoleJudgeValid(final String TEST_NAME, ActivationType assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForValidityNextRunAssertSuccess(); // THEN @@ -230,7 +230,7 @@ private void testJackAssignRoleJudgeValid(final String TEST_NAME, ActivationType private void testJackAssignRoleJudgeInvalid(final String TEST_NAME, ActivationType activationType, Task task, OperationResult result) throws Exception { // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_BIG_JUDGE_OID, activationType, task, result); // THEN @@ -238,7 +238,7 @@ private void testJackAssignRoleJudgeInvalid(final String TEST_NAME, ActivationTy assertNoDummyAccount(null, USER_JACK_USERNAME); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForValidityNextRunAssertSuccess(); // THEN @@ -281,7 +281,7 @@ public void test120JackDisableAssignmentJudge() throws Exception { AssignmentType judgeAssignment = getJudgeAssignment(USER_JACK_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyAssignmentAdministrativeStatus(USER_JACK_OID, judgeAssignment.getId(), ActivationStatusType.DISABLED, task, result); @@ -308,7 +308,7 @@ public void test122JackReplaceNullAdministrativeStatusAssignmentJudge() throws E AssignmentType judgeAssignment = getJudgeAssignment(USER_JACK_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyAssignmentAdministrativeStatus(USER_JACK_OID, judgeAssignment.getId(), null, task, result); @@ -332,7 +332,7 @@ public void test123JackDisableAssignmentJudge() throws Exception { AssignmentType judgeAssignment = getJudgeAssignment(USER_JACK_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyAssignmentAdministrativeStatus(USER_JACK_OID, judgeAssignment.getId(), ActivationStatusType.DISABLED, task, result); @@ -356,7 +356,7 @@ public void test124JackEnableAssignmentJudge() throws Exception { AssignmentType judgeAssignment = getJudgeAssignment(USER_JACK_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyAssignmentAdministrativeStatus(USER_JACK_OID, judgeAssignment.getId(), ActivationStatusType.ENABLED, task, result); @@ -380,7 +380,7 @@ public void test125JackDeleteAdministrativeStatusAssignmentJudge() throws Except AssignmentType judgeAssignment = getJudgeAssignment(USER_JACK_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyObjectDeleteProperty(UserType.class, USER_JACK_OID, ItemPath.create(UserType.F_ASSIGNMENT, judgeAssignment.getId(), AssignmentType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS), @@ -406,7 +406,7 @@ public void test126JackAddAdministrativeStatusAssignmentJudge() throws Exception AssignmentType judgeAssignment = getJudgeAssignment(USER_JACK_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyObjectAddProperty(UserType.class, USER_JACK_OID, ItemPath.create(UserType.F_ASSIGNMENT, judgeAssignment.getId(), AssignmentType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS), @@ -434,7 +434,7 @@ public void test127JackDeleteActivationAssignmentJudge() throws Exception { activationType.setAdministrativeStatus(ActivationStatusType.ENABLED); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyObjectDeleteContainer(UserType.class, USER_JACK_OID, ItemPath.create(UserType.F_ASSIGNMENT, judgeAssignment.getId(), AssignmentType.F_ACTIVATION), task, result, activationType); @@ -463,7 +463,7 @@ public void test128JackAssignmentJudgeValidToSetInvalid() throws Exception { activationType.setValidTo(validTo); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyObjectReplaceContainer(UserType.class, USER_JACK_OID, ItemPath.create(UserType.F_ASSIGNMENT, judgeAssignment.getId(), AssignmentType.F_ACTIVATION), task, result, activationType); @@ -490,7 +490,7 @@ public void test129JackAssignmentJudgeValidToSetValid() throws Exception { validTo.add(XmlTypeConverter.createDuration(60*60*1000)); // one hour ahead // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyObjectReplaceProperty(UserType.class, USER_JACK_OID, ItemPath.create(UserType.F_ASSIGNMENT, judgeAssignment.getId(), AssignmentType.F_ACTIVATION, ActivationType.F_VALID_TO), task, result, validTo); @@ -534,7 +534,7 @@ public void test130BarbossaAssignJudgeEnabled() throws Exception { activationType.setAdministrativeStatus(ActivationStatusType.ENABLED); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignRole(USER_BARBOSSA_OID, ROLE_JUDGE_OID, activationType, task, result); // THEN @@ -542,7 +542,7 @@ public void test130BarbossaAssignJudgeEnabled() throws Exception { assertDummyAccount(null, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForValidityNextRunAssertSuccess(); // THEN @@ -575,7 +575,7 @@ public void test131BarbossaAssignSailorEnabled() throws Exception { activationType.setAdministrativeStatus(ActivationStatusType.ENABLED); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignRole(USER_BARBOSSA_OID, ROLE_SAILOR_OID, activationType, task, result); // THEN @@ -583,7 +583,7 @@ public void test131BarbossaAssignSailorEnabled() throws Exception { assertDummyAccount(null, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForValidityNextRunAssertSuccess(); // THEN @@ -615,7 +615,7 @@ public void test132BarbossaDisableAssignmentJudge() throws Exception { AssignmentType assignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_JUDGE_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyAssignmentAdministrativeStatus(USER_BARBOSSA_OID, assignment.getId(), ActivationStatusType.DISABLED, task, result); @@ -624,7 +624,7 @@ public void test132BarbossaDisableAssignmentJudge() throws Exception { assertDummyAccount(null, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForValidityNextRunAssertSuccess(); // THEN @@ -655,7 +655,7 @@ public void test133BarbossaDisableAssignmentSailor() throws Exception { AssignmentType assignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_SAILOR_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyAssignmentAdministrativeStatus(USER_BARBOSSA_OID, assignment.getId(), ActivationStatusType.DISABLED, task, result); @@ -664,7 +664,7 @@ public void test133BarbossaDisableAssignmentSailor() throws Exception { assertNoDummyAccount(null, USER_BARBOSSA_USERNAME); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForValidityNextRunAssertSuccess(); // THEN @@ -690,7 +690,7 @@ public void test134BarbossaEnableAssignmentJudge() throws Exception { AssignmentType assignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_JUDGE_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyAssignmentAdministrativeStatus(USER_BARBOSSA_OID, assignment.getId(), ActivationStatusType.ENABLED, task, result); @@ -699,7 +699,7 @@ public void test134BarbossaEnableAssignmentJudge() throws Exception { assertDummyAccount(null, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assertDummyAccount(null, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); assertDummyAccountAttribute(null, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, @@ -727,7 +727,7 @@ public void test135BarbossaEnableAssignmentSailor() throws Exception { AssignmentType assignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_SAILOR_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyAssignmentAdministrativeStatus(USER_BARBOSSA_OID, assignment.getId(), ActivationStatusType.ENABLED, task, result); @@ -736,7 +736,7 @@ public void test135BarbossaEnableAssignmentSailor() throws Exception { assertDummyAccount(null, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assertDummyAccount(null, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); assertDummyAccountAttribute(null, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, @@ -775,7 +775,7 @@ public void test136BarbossaDisableBothAssignments() throws Exception { ActivationStatusType.DISABLED); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result); // THEN @@ -783,7 +783,7 @@ public void test136BarbossaDisableBothAssignments() throws Exception { assertNoDummyAccount(null, USER_BARBOSSA_USERNAME); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForValidityNextRunAssertSuccess(); // THEN @@ -826,7 +826,7 @@ public void test137BarbossaEnableBothAssignments() throws Exception { ActivationStatusType.ENABLED); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result); // THEN @@ -834,7 +834,7 @@ public void test137BarbossaEnableBothAssignments() throws Exception { assertDummyAccount(null, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForValidityNextRunAssertSuccess(); // THEN @@ -908,7 +908,7 @@ public void test139BarbossaDisableBothAssignmentsUnassign() throws Exception { display("Unassign delta", objectDelta); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result); // THEN @@ -916,7 +916,7 @@ public void test139BarbossaDisableBothAssignmentsUnassign() throws Exception { assertNoDummyAccount(null, USER_BARBOSSA_USERNAME); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForValidityNextRunAssertSuccess(); // THEN @@ -957,7 +957,7 @@ public void test140BarbossaAssignRedJudgeEnabled() throws Exception { activationType.setAdministrativeStatus(ActivationStatusType.ENABLED); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignRole(USER_BARBOSSA_OID, ROLE_RED_JUDGE_OID, activationType, task, result); // THEN @@ -965,7 +965,7 @@ public void test140BarbossaAssignRedJudgeEnabled() throws Exception { assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForValidityNextRunAssertSuccess(); // THEN @@ -998,7 +998,7 @@ public void test141BarbossaAssignRedSailorEnabled() throws Exception { activationType.setAdministrativeStatus(ActivationStatusType.ENABLED); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignRole(USER_BARBOSSA_OID, ROLE_RED_SAILOR_OID, activationType, task, result); // THEN @@ -1006,7 +1006,7 @@ public void test141BarbossaAssignRedSailorEnabled() throws Exception { assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForValidityNextRunAssertSuccess(); // THEN @@ -1038,7 +1038,7 @@ public void test142BarbossaDisableAssignmentRedJudge() throws Exception { AssignmentType assignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_RED_JUDGE_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyAssignmentAdministrativeStatus(USER_BARBOSSA_OID, assignment.getId(), ActivationStatusType.DISABLED, task, result); @@ -1047,7 +1047,7 @@ public void test142BarbossaDisableAssignmentRedJudge() throws Exception { assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForValidityNextRunAssertSuccess(); // THEN @@ -1078,7 +1078,7 @@ public void test143BarbossaDisableAssignmentRedSailor() throws Exception { AssignmentType assignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_RED_SAILOR_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyAssignmentAdministrativeStatus(USER_BARBOSSA_OID, assignment.getId(), ActivationStatusType.DISABLED, task, result); @@ -1087,7 +1087,7 @@ public void test143BarbossaDisableAssignmentRedSailor() throws Exception { assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, false); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForValidityNextRunAssertSuccess(); // THEN @@ -1117,7 +1117,7 @@ public void test144BarbossaEnableAssignmentRedJudge() throws Exception { AssignmentType assignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_RED_JUDGE_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyAssignmentAdministrativeStatus(USER_BARBOSSA_OID, assignment.getId(), ActivationStatusType.ENABLED, task, result); @@ -1126,7 +1126,7 @@ public void test144BarbossaEnableAssignmentRedJudge() throws Exception { assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); assertDummyAccountAttribute(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, @@ -1154,7 +1154,7 @@ public void test145BarbossaEnableAssignmentRedSailor() throws Exception { AssignmentType assignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_RED_SAILOR_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyAssignmentAdministrativeStatus(USER_BARBOSSA_OID, assignment.getId(), ActivationStatusType.ENABLED, task, result); @@ -1163,7 +1163,7 @@ public void test145BarbossaEnableAssignmentRedSailor() throws Exception { assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); assertDummyAccountAttribute(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, @@ -1208,7 +1208,7 @@ public void test146BarbossaDisableBothRedAssignments() throws Exception { ActivationStatusType.DISABLED); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result); // THEN @@ -1216,7 +1216,7 @@ public void test146BarbossaDisableBothRedAssignments() throws Exception { assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, false); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForValidityNextRunAssertSuccess(); // THEN @@ -1263,7 +1263,7 @@ public void test147BarbossaEnableBothRedAssignments() throws Exception { ActivationStatusType.ENABLED); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result); // THEN @@ -1271,7 +1271,7 @@ public void test147BarbossaEnableBothRedAssignments() throws Exception { assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForValidityNextRunAssertSuccess(); // THEN @@ -1342,7 +1342,7 @@ public void test149BarbossaDisableBothRedAssignmentsUnassign() throws Exception display("Unassign delta", objectDelta); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result); // THEN @@ -1351,7 +1351,7 @@ public void test149BarbossaDisableBothRedAssignmentsUnassign() throws Exception assertNoDummyAccount(null, USER_BARBOSSA_USERNAME); // to be on the safe side // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForValidityNextRunAssertSuccess(); // THEN @@ -1394,7 +1394,7 @@ public void test190HermanGoesInvalid() throws Exception { clock.override(validTo); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForValidityNextRunAssertSuccess(); // THEN @@ -1422,7 +1422,7 @@ public void test200ImportTriggerScannerTask() throws Exception { XMLGregorianCalendar startCal = clock.currentTimeXMLGregorianCalendar(); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); importObjectFromFile(TASK_TRIGGER_SCANNER_FILE); waitForTaskStart(TASK_TRIGGER_SCANNER_OID, false); @@ -1449,12 +1449,12 @@ public void test205AccountRedElaineDisable() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyAccountShadowReplace(ACCOUNT_SHADOW_ELAINE_DUMMY_RED_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.DISABLED); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject accountShadow = getShadowModel(ACCOUNT_SHADOW_ELAINE_DUMMY_RED_OID); @@ -1535,7 +1535,7 @@ public void test215JackDummyAccountDeleteAfterMonth() throws Exception { time.add(XmlTypeConverter.createDuration(true, 0, 1, 1, 0, 0, 0)); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); clock.override(time); waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true); @@ -1592,7 +1592,7 @@ public void test220AddDrake() throws Exception { display("Drake before", userDrake); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); addObject(userDrake); @@ -1809,7 +1809,7 @@ public void test300HermanAssignJudgeNotYetValid() throws Exception { display("Assignment validTo", judgeAssignmentValidTo); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignRole(USER_HERMAN_OID, ROLE_JUDGE_OID, activationType, task, result); // THEN diff --git a/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java b/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java index ddf12bbf018..d34a43730c1 100644 --- a/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java +++ b/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java @@ -6,56 +6,25 @@ */ package com.evolveum.midpoint.model.test; +import static java.util.Collections.singleton; +import static org.testng.AssertJUnit.*; + import static com.evolveum.midpoint.prism.PrismObject.asObjectableList; import static com.evolveum.midpoint.schema.constants.SchemaConstants.*; -import static java.util.Collections.singleton; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertTrue; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.net.ConnectException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; +import java.util.*; import java.util.concurrent.atomic.AtomicLong; import java.util.function.Consumer; import java.util.function.Function; import java.util.stream.Collectors; - -import javax.xml.bind.JAXBException; import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; -import com.evolveum.midpoint.model.api.authentication.*; -import com.evolveum.midpoint.model.test.asserter.*; -import com.evolveum.midpoint.prism.*; -import com.evolveum.midpoint.prism.delta.*; -import com.evolveum.midpoint.prism.equivalence.EquivalenceStrategy; -import com.evolveum.midpoint.prism.path.*; -import com.evolveum.midpoint.repo.api.perf.PerformanceInformation; -import com.evolveum.midpoint.schema.*; -import com.evolveum.midpoint.schema.result.OperationResultStatus; -import com.evolveum.midpoint.schema.util.*; -import com.evolveum.midpoint.schema.statistics.StatisticsUtil; -import com.evolveum.midpoint.task.api.TaskDebugUtil; -import com.evolveum.midpoint.test.*; -import com.evolveum.midpoint.test.asserter.*; -import com.evolveum.midpoint.util.*; -import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.mutable.MutableInt; import org.jetbrains.annotations.NotNull; @@ -77,11 +46,7 @@ import org.testng.AssertJUnit; import org.testng.annotations.AfterClass; -import com.evolveum.icf.dummy.resource.ConflictException; -import com.evolveum.icf.dummy.resource.DummyAccount; -import com.evolveum.icf.dummy.resource.DummyGroup; -import com.evolveum.icf.dummy.resource.DummyResource; -import com.evolveum.icf.dummy.resource.SchemaViolationException; +import com.evolveum.icf.dummy.resource.*; import com.evolveum.midpoint.audit.api.AuditEventRecord; import com.evolveum.midpoint.audit.api.AuditEventStage; import com.evolveum.midpoint.audit.api.AuditEventType; @@ -91,14 +56,8 @@ import com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition; import com.evolveum.midpoint.common.refinery.RefinedResourceSchema; import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl; -import com.evolveum.midpoint.model.api.AssignmentCandidatesSpecification; -import com.evolveum.midpoint.model.api.ModelAuditService; -import com.evolveum.midpoint.model.api.ModelAuthorizationAction; -import com.evolveum.midpoint.model.api.ModelDiagnosticService; -import com.evolveum.midpoint.model.api.ModelExecuteOptions; -import com.evolveum.midpoint.model.api.ModelInteractionService; -import com.evolveum.midpoint.model.api.ModelService; -import com.evolveum.midpoint.model.api.RoleSelectionSpecification; +import com.evolveum.midpoint.model.api.*; +import com.evolveum.midpoint.model.api.authentication.*; import com.evolveum.midpoint.model.api.context.EvaluatedPolicyRule; import com.evolveum.midpoint.model.api.context.ModelContext; import com.evolveum.midpoint.model.api.context.ModelElementContext; @@ -109,10 +68,16 @@ import com.evolveum.midpoint.model.common.SystemObjectCache; import com.evolveum.midpoint.model.common.stringpolicy.FocusValuePolicyOriginResolver; import com.evolveum.midpoint.model.common.stringpolicy.ValuePolicyProcessor; +import com.evolveum.midpoint.model.test.asserter.*; import com.evolveum.midpoint.notifications.api.NotificationManager; import com.evolveum.midpoint.notifications.api.transports.Message; +import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.crypto.EncryptionException; +import com.evolveum.midpoint.prism.delta.*; +import com.evolveum.midpoint.prism.equivalence.EquivalenceStrategy; import com.evolveum.midpoint.prism.match.MatchingRule; +import com.evolveum.midpoint.prism.path.ItemName; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.prism.query.ObjectFilter; import com.evolveum.midpoint.prism.query.ObjectQuery; @@ -122,8 +87,10 @@ import com.evolveum.midpoint.prism.xml.XmlTypeConverter; import com.evolveum.midpoint.provisioning.api.ProvisioningService; import com.evolveum.midpoint.repo.api.RepositoryService; +import com.evolveum.midpoint.repo.api.perf.PerformanceInformation; import com.evolveum.midpoint.repo.common.ObjectResolver; import com.evolveum.midpoint.repo.common.expression.ExpressionVariables; +import com.evolveum.midpoint.schema.*; import com.evolveum.midpoint.schema.constants.ObjectTypes; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.internals.InternalsConfig; @@ -131,6 +98,9 @@ import com.evolveum.midpoint.schema.processor.ResourceAttributeContainer; import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition; import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.schema.result.OperationResultStatus; +import com.evolveum.midpoint.schema.statistics.StatisticsUtil; +import com.evolveum.midpoint.schema.util.*; import com.evolveum.midpoint.security.api.Authorization; import com.evolveum.midpoint.security.api.AuthorizationConstants; import com.evolveum.midpoint.security.api.MidPointPrincipal; @@ -139,29 +109,21 @@ import com.evolveum.midpoint.security.enforcer.api.ItemSecurityConstraints; import com.evolveum.midpoint.security.enforcer.api.SecurityEnforcer; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.task.api.TaskDebugUtil; import com.evolveum.midpoint.task.api.TaskExecutionStatus; +import com.evolveum.midpoint.test.*; +import com.evolveum.midpoint.test.asserter.*; import com.evolveum.midpoint.test.util.MidPointAsserts; import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.exception.CommonException; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; +import com.evolveum.midpoint.util.*; import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.PolicyViolationException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SecurityViolationException; -import com.evolveum.midpoint.util.exception.SystemException; -import com.evolveum.midpoint.util.exception.TunnelException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; +import com.evolveum.midpoint.util.exception.*; import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ImportOptionsType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.midpoint.xml.ns._public.model.model_3.ModelPortType; -import com.evolveum.prism.xml.ns._public.types_3.ChangeTypeType; -import com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType; -import com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType; -import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; -import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; +import com.evolveum.prism.xml.ns._public.types_3.*; /** * Abstract framework for an integration test that is placed on top of a model API. @@ -169,7 +131,6 @@ * dummy auditing, etc. It also implements lots of useful methods to make writing the tests easier. * * @author Radovan Semancik - * */ public abstract class AbstractModelIntegrationTest extends AbstractIntegrationTest { @@ -239,15 +200,13 @@ public abstract class AbstractModelIntegrationTest extends AbstractIntegrationTe protected boolean verbose = false; - private static final Trace LOGGER = TraceManager.getTrace(AbstractModelIntegrationTest.class); - public AbstractModelIntegrationTest() { super(); } @Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { - LOGGER.trace("initSystem"); + logger.trace("initSystem"); dummyResourceCollection = new DummyResourceCollection(modelService); startResources(); dummyAuditService = DummyAuditService.getInstance(); @@ -259,20 +218,15 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti if (notificationManager != null) { notificationManager.setDisabled(true); } + if (dummyResourceCollection != null) { + dummyResourceCollection.resetResources(); + } } protected boolean isAvoidLoggingChange() { return true; } - @Override - public void postInitSystem(Task initTask, OperationResult initResult) throws Exception { - super.postInitSystem(initTask, initResult); - if (dummyResourceCollection != null) { - dummyResourceCollection.resetResources(); - } - } - protected void startResources() throws Exception { // Nothing to do by default } @@ -353,7 +307,7 @@ protected void importObjectFromFile(String filename) throws FileNotFoundExceptio } protected void importObjectFromFile(File file) throws FileNotFoundException { - OperationResult result = new OperationResult(AbstractModelIntegrationTest.class.getName() + ".importObjectFromFile"); + OperationResult result = new OperationResult(contextName() + ".importObjectFromFile"); importObjectFromFile(file, result); result.computeStatus(); TestUtil.assertSuccess(result); @@ -364,16 +318,16 @@ protected void importObjectFromFile(String filename, OperationResult result) thr } protected void importObjectFromFile(File file, OperationResult result) throws FileNotFoundException { - OperationResult subResult = result.createSubresult(AbstractModelIntegrationTest.class.getName()+".importObjectFromFile"); + OperationResult subResult = result.createSubresult(contextName() + ".importObjectFromFile"); subResult.addParam("filename", file.getPath()); - LOGGER.trace("importObjectFromFile: {}", file); - Task task = taskManager.createTaskInstance(); + logger.trace("importObjectFromFile: {}", file); + Task task = createTask("importObjectFromFile"); importObjectFromFile(file, task, result); subResult.computeStatus(); if (subResult.isError()) { - LOGGER.error("Import of file "+file+" failed:\n{}", subResult.debugDump()); + logger.error("Import of file " + file + " failed:\n{}", subResult.debugDump()); Throwable cause = findCause(subResult); - throw new SystemException("Import of file "+file+" failed: "+subResult.getMessage(), cause); + throw new SystemException("Import of file " + file + " failed: " + subResult.getMessage(), cause); } } @@ -398,7 +352,7 @@ protected Throwable findCause(OperationResult result) { if (result.getCause() != null) { return result.getCause(); } - for (OperationResult sub: result.getSubresults()) { + for (OperationResult sub : result.getSubresults()) { Throwable cause = findCause(sub); if (cause != null) { return cause; @@ -414,7 +368,7 @@ protected PrismObject importAndGetObjectFromFile(Class protected PrismObject importAndGetObjectFromFile(Class type, File file, String oid, Task task, OperationResult result) throws FileNotFoundException, ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { importObjectFromFile(file, result); OperationResult importResult = result.getLastSubresult(); - TestUtil.assertSuccess("Import of "+file+" has failed", importResult); + TestUtil.assertSuccess("Import of " + file + " has failed", importResult); return modelService.getObject(type, oid, null, task, result); } @@ -423,7 +377,7 @@ protected PrismObject importAndGetObjectFromFileIgnore OperationResult importResult = result.getLastSubresult(); OperationResultStatus status = importResult.getStatus(); if (status == OperationResultStatus.FATAL_ERROR || status == OperationResultStatus.PARTIAL_ERROR) { - fail("Import of "+file+" has failed: "+importResult.getMessage()); + fail("Import of " + file + " has failed: " + importResult.getMessage()); } return modelService.getObject(type, oid, null, task, result); } @@ -435,7 +389,6 @@ protected void applyResourceSchema(ShadowType accountType, ResourceType resource IntegrationTestTools.applyResourceSchema(accountType, resourceType, prismContext); } - protected void assertUsers(int expectedNumberOfUsers) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { assertObjects(UserType.class, expectedNumberOfUsers); } @@ -456,23 +409,30 @@ protected void assertObjects(Class type, int expectedN protected void assertObjects(Class type, ObjectQuery query, int expectedNumberOfUsers) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - assertEquals("Unexpected number of "+type.getSimpleName()+"s", expectedNumberOfUsers, getObjectCount(type, query)); + assertEquals("Unexpected number of " + type.getSimpleName() + "s", expectedNumberOfUsers, getObjectCount(type, query)); } - protected int getObjectCount(Class type) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + protected int getObjectCount(Class type) + throws SchemaException, ObjectNotFoundException, SecurityViolationException, + CommunicationException, ConfigurationException, ExpressionEvaluationException { return getObjectCount(type, null); } - protected int getObjectCount(Class type, ObjectQuery query) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertObjects"); + protected int getObjectCount(Class type, ObjectQuery query) + throws SchemaException, ObjectNotFoundException, SecurityViolationException, + CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = createTask("getObjectCount"); OperationResult result = task.getResult(); List> users = modelService.searchObjects(type, query, null, task, result); - if (verbose) display(type.getSimpleName()+"s", users); + if (verbose) { display(type.getSimpleName() + "s", users); } return users.size(); } - protected void searchObjectsIterative(Class type, ObjectQuery query, Consumer> handler, Integer expectedNumberOfObjects) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertObjects"); + protected void searchObjectsIterative(Class type, + ObjectQuery query, Consumer> handler, Integer expectedNumberOfObjects) + throws SchemaException, ObjectNotFoundException, SecurityViolationException, + CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = createTask("searchObjectsIterative"); OperationResult result = task.getResult(); final MutableInt count = new MutableInt(0); // Cannot convert to lambda here. Java does not want to understand the generic types properly. @@ -483,8 +443,8 @@ protected void searchObjectsIterative(Class type, Obje } return true; }, null, task, result); - if (verbose) display(type.getSimpleName()+"s", count.getValue()); - assertEquals("Unexpected number of "+type.getSimpleName()+"s", expectedNumberOfObjects, count.getValue()); + if (verbose) { display(type.getSimpleName() + "s", count.getValue()); } + assertEquals("Unexpected number of " + type.getSimpleName() + "s", expectedNumberOfObjects, count.getValue()); } protected void assertUserProperty(String userOid, QName propertyName, Object... expectedPropValues) throws ObjectNotFoundException, SchemaException { @@ -501,13 +461,13 @@ protected void assertUserNoProperty(String userOid, QName propertyName) throws O protected void assertUserProperty(PrismObject user, QName propertyName, Object... expectedPropValues) { PrismProperty property = user.findProperty(ItemName.fromQName(propertyName)); - assert property != null : "No property "+propertyName+" in "+user; + assert property != null : "No property " + propertyName + " in " + user; PrismAsserts.assertPropertyValue(property, expectedPropValues); } protected void assertUserNoProperty(PrismObject user, QName propertyName) { PrismProperty property = user.findProperty(ItemName.fromQName(propertyName)); - assert property == null : "Property "+propertyName+" present in "+user+": "+property; + assert property == null : "Property " + propertyName + " present in " + user + ": " + property; } protected void assertAdministrativeStatusEnabled(PrismObject user) { @@ -523,19 +483,19 @@ protected void assertAdministrativeStatus(PrismObject obje if (expected == null && statusProperty == null) { return; } - assert statusProperty != null : "No status property in "+object; + assert statusProperty != null : "No status property in " + object; ActivationStatusType status = statusProperty.getRealValue(); if (expected == null && status == null) { return; } - assert status != null : "No status property is null in "+object; - assert status == expected : "status property is "+status+", expected "+expected+" in "+object; + assert status != null : "No status property is null in " + object; + assert status == expected : "status property is " + status + ", expected " + expected + " in " + object; } protected void assertEffectiveStatus(PrismObject focus, ActivationStatusType expected) { ActivationType activation = focus.asObjectable().getActivation(); - assertNotNull("No activation in "+focus, activation); - assertEquals("Unexpected effective activation status in "+focus, expected, activation.getEffectiveStatus()); + assertNotNull("No activation in " + focus, activation); + assertEquals("Unexpected effective activation status in " + focus, expected, activation.getEffectiveStatus()); } protected void modifyUserReplace(String userOid, ItemPath propertyPath, Task task, OperationResult result, Object... newRealValue) @@ -655,14 +615,14 @@ protected ObjectDelta createOldNewPasswordDelta(String oid, String old newPasswordPs.setClearValue(newPassword); return deltaFor(UserType.class) - .item(PASSWORD_VALUE_PATH) + .item(PASSWORD_VALUE_PATH) .oldRealValue(oldPasswordPs) .replace(newPasswordPs) .asObjectDelta(oid); } protected void modifyUserChangePassword(String userOid, String newPassword) throws CommonException { - Task task = getTestTask(); + Task task = createTask("modifyUserChangePassword"); OperationResult result = task.getResult(); modifyUserChangePassword(userOid, newPassword, task, result); assertSuccess(result); @@ -684,8 +644,8 @@ protected void modifyUserSetPassword(String userOid, String newPassword, Task ta PasswordType passwordType = new PasswordType(); passwordType.setValue(userPasswordPs); ObjectDelta delta = prismContext.deltaFor(UserType.class) - .item(SchemaConstants.PATH_PASSWORD).add(passwordType) - .asObjectDelta(userOid); + .item(SchemaConstants.PATH_PASSWORD).add(passwordType) + .asObjectDelta(userOid); executeChanges(delta, null, task, result); } @@ -695,12 +655,12 @@ protected void modifyAccountChangePassword(String accountOid, String newPassword modifyAccountShadowReplace(accountOid, PASSWORD_VALUE_PATH, task, result, userPasswordPs); } - protected void clearUserPassword(String userOid) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = getTestTask(); + protected void clearUserPassword(String userOid) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException { + Task task = createTask("clearUserPassword"); OperationResult result = task.getResult(); - List> itemDeltas = prismContext.deltaFor(UserType.class) - .item(SchemaConstants.PATH_PASSWORD).replace() - .asItemDeltas(); + List> itemDeltas = prismContext.deltaFor(UserType.class) + .item(SchemaConstants.PATH_PASSWORD).replace() + .asItemDeltas(); repositoryService.modifyObject(UserType.class, userOid, itemDeltas, result); assertSuccess(result); } @@ -709,54 +669,58 @@ protected void renameObject(Class type, String oid, St modifyObjectReplaceProperty(type, oid, ObjectType.F_NAME, task, result, createPolyString(newName)); } - protected void recomputeUser(String userOid) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { - Task task = getTestTask(); + protected void recomputeUser(String userOid) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { + Task task = createTask("recomputeUser"); OperationResult result = task.getResult(); modelService.recompute(UserType.class, userOid, null, task, result); assertSuccess(result); } - protected void recomputeUser(String userOid, Task task, OperationResult result) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { + protected void recomputeUser(String userOid, Task task, OperationResult result) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { modelService.recompute(UserType.class, userOid, null, task, result); } - protected void recomputeFocus(Class clazz, String userOid, Task task, OperationResult result) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { + protected void recomputeFocus(Class clazz, String userOid, Task task, OperationResult result) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { modelService.recompute(clazz, userOid, null, task, result); } - protected void recomputeUser(String userOid, ModelExecuteOptions options, Task task, OperationResult result) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { + protected void recomputeUser(String userOid, ModelExecuteOptions options, Task task, OperationResult result) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { modelService.recompute(UserType.class, userOid, options, task, result); } - protected void assignRole(String userOid, String roleOid) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".assignRole"); + protected void assignRole(String userOid, String roleOid) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, + CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + Task task = createTask("assignRole"); OperationResult result = task.getResult(); assignRole(userOid, roleOid, task, result); assertSuccess(result); } - protected void assignRole(String userOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - assignRole(UserType.class, userOid, roleOid, (ActivationType) null, task, result); + protected void assignRole(String userOid, String roleOid, Task task, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, + CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + assignRole(UserType.class, userOid, roleOid, null, task, result); } protected void assignService(String userOid, String targetOid, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - assignService(UserType.class, userOid, targetOid, (ActivationType) null, task, result); + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + assignService(UserType.class, userOid, targetOid, null, task, result); } protected void assignRole(String userOid, String roleOid, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - assignRole(UserType.class, userOid, roleOid, (ActivationType) null, task, options, result); + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + assignRole(UserType.class, userOid, roleOid, null, task, options, result); } protected void assignRole(Class focusClass, String focusOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - assignRole(focusClass, focusOid, roleOid, (ActivationType) null, task, result); + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + assignRole(focusClass, focusOid, roleOid, null, task, result); } protected void assignRole(String userOid, String roleOid, ActivationType activationType, Task task, OperationResult result) throws ObjectNotFoundException, @@ -772,14 +736,14 @@ protected void unassignRole(String userOid, String roleOid, ActivationType activ } protected void unassignRole(Class focusClass, String focusOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - unassignRole(focusClass, focusOid, roleOid, (ActivationType) null, task, result); + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + unassignRole(focusClass, focusOid, roleOid, null, task, result); } protected void unassignRole(Class focusClass, String focusOid, String roleOid, ActivationType activationType, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { modifyAssignmentHolderAssignment(focusClass, focusOid, roleOid, RoleType.COMPLEX_TYPE, null, task, null, activationType, false, result); } @@ -809,7 +773,7 @@ protected void assignFocus(Class focusClass, String focusOi protected void assignRole(String userOid, String roleOid, QName relation, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { + PolicyViolationException, SecurityViolationException { modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, relation, task, null, null, true, result); } @@ -821,8 +785,8 @@ protected void assignRole(String userOid, String roleOid, QName relation, ModelE protected void assignRole(String userOid, String roleOid, QName relation) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".assignRole"); + PolicyViolationException, SecurityViolationException { + Task task = createTask("assignRole"); OperationResult result = task.getResult(); assignRole(userOid, roleOid, relation, task, result); result.computeStatus(); @@ -836,7 +800,7 @@ protected void assignRole(String userOid, String roleOid, QName relation, Consum } protected void unassignRole(String userOid, String roleOid) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - Task task = getTestTask(); + Task task = createTask("unassignRole"); OperationResult result = task.getResult(); unassignRole(userOid, roleOid, task, result); result.computeStatus(); @@ -857,13 +821,13 @@ protected void unassignRoleByAssignmentValue(PrismObject fo protected void unassignRole(String userOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, null, task, (Consumer)null, false, result); + modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, null, task, (Consumer) null, false, result); } protected void unassignService(String userOid, String serviceOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, serviceOid, ServiceType.COMPLEX_TYPE, null, task, (Consumer)null, false, result); + modifyUserAssignment(userOid, serviceOid, ServiceType.COMPLEX_TYPE, null, task, (Consumer) null, false, result); } protected void unassignRole(String userOid, String roleOid, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectNotFoundException, @@ -897,15 +861,15 @@ protected void unassignRole(String userOid, String roleOid, PrismContainer ex } protected void unassignRole(String userOid, String roleOid, QName relation, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, relation, task, null, null, false, result); + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, relation, task, null, null, false, result); } protected void unassignRole(String userOid, String roleOid, QName relation, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, relation, task, null, null, false, options, result); + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, relation, task, null, null, false, options, result); } protected void unassignRole(String userOid, String roleOid, QName relation, Consumer modificationBlock, Task task, OperationResult result) throws ObjectNotFoundException, @@ -923,11 +887,11 @@ protected void unassignAllRoles(String userOid) throws ObjectNotFoundException, protected void unassignAllRoles(String userOid, boolean useRawPlusRecompute) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - Task task = getTestTask(); + Task task = createTask("unassignAllRoles"); OperationResult result = task.getResult(); PrismObject user = modelService.getObject(UserType.class, userOid, null, task, result); - Collection> modifications = new ArrayList<>(); - for (AssignmentType assignment: user.asObjectable().getAssignment()) { + Collection> modifications = new ArrayList<>(); + for (AssignmentType assignment : user.asObjectable().getAssignment()) { ObjectReferenceType targetRef = assignment.getTargetRef(); if (targetRef != null) { if (targetRef.getType().equals(RoleType.COMPLEX_TYPE)) { @@ -960,16 +924,16 @@ protected void unassignAllRoles(String userOid, boolean useRawPlusRecompute) thr protected void assignArchetype(String userOid, String archetypeOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, archetypeOid, ArchetypeType.COMPLEX_TYPE, null, task, (Consumer)null, true, result); + modifyUserAssignment(userOid, archetypeOid, ArchetypeType.COMPLEX_TYPE, null, task, (Consumer) null, true, result); } protected void unassignArchetype(String userOid, String archetypeOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, archetypeOid, ArchetypeType.COMPLEX_TYPE, null, task, (Consumer)null, false, result); + modifyUserAssignment(userOid, archetypeOid, ArchetypeType.COMPLEX_TYPE, null, task, (Consumer) null, false, result); } - protected void induceRole(String focusRoleOid, String targetRoleOid, Task task, OperationResult result) throws ObjectNotFoundException, + protected void induceRole(String focusRoleOid, String targetRoleOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { induceRole(RoleType.class, focusRoleOid, targetRoleOid, task, result); @@ -993,7 +957,7 @@ protected void uninduceRole(Class focusType, String foc modifyFocusAssignment(focusType, focusOid, AbstractRoleType.F_INDUCEMENT, roleOid, RoleType.COMPLEX_TYPE, null, task, null, false, null, result); } - protected void uninduceRole(String focusRoleOid, String targetRoleOid, Task task, OperationResult result) throws ObjectNotFoundException, + protected void uninduceRole(String focusRoleOid, String targetRoleOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { uninduceRole(RoleType.class, focusRoleOid, targetRoleOid, task, result); @@ -1021,8 +985,7 @@ protected void assignOrg(String userOid, String orgOid, QName relation) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - AbstractIntegrationTest.class.getName(); - Task task = getTestTask(); + Task task = createTask("assignOrg"); OperationResult result = task.getResult(); assignOrg(userOid, orgOid, relation, task, result); result.computeStatus(); @@ -1033,14 +996,14 @@ protected void assignOrg(String userOid, String orgOid, QName relation, Task tas throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, orgOid, OrgType.COMPLEX_TYPE, relation, task, (Consumer)null, true, result); + modifyUserAssignment(userOid, orgOid, OrgType.COMPLEX_TYPE, relation, task, (Consumer) null, true, result); } protected void assignOrg(Class focusType, String focusOid, String orgOid, QName relation, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - modifyFocusAssignment(focusType, focusOid, orgOid, OrgType.COMPLEX_TYPE, relation, task, (Consumer)null, true, result); + modifyFocusAssignment(focusType, focusOid, orgOid, OrgType.COMPLEX_TYPE, relation, task, (Consumer) null, true, result); } protected void unassignOrg(String userOid, String orgOid) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { @@ -1055,7 +1018,7 @@ protected void unassignOrg(String userOid, String orgOid, Task task, OperationRe } protected void unassignOrg(String userOid, String orgOid, QName relation) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".unassignOrg"); + Task task = createTask("unassignOrg"); OperationResult result = task.getResult(); unassignOrg(userOid, orgOid, relation, task, result); assertSuccess(result); @@ -1065,7 +1028,7 @@ protected void unassignOrg(String userOid, String orgOid, QName relation, Task t throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, orgOid, OrgType.COMPLEX_TYPE, relation, task, (Consumer)null, false, result); + modifyUserAssignment(userOid, orgOid, OrgType.COMPLEX_TYPE, relation, task, (Consumer) null, false, result); } protected void unassignOrg(Class type, String focusOid, String orgOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { @@ -1076,7 +1039,7 @@ protected void unassignOrg(Class type, String focusOid, throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - modifyFocusAssignment(type, focusOid, orgOid, OrgType.COMPLEX_TYPE, relation, task, (Consumer)null, false, result); + modifyFocusAssignment(type, focusOid, orgOid, OrgType.COMPLEX_TYPE, relation, task, (Consumer) null, false, result); } protected void modifyUserAssignment(String userOid, String roleOid, QName refType, QName relation, Task task, @@ -1149,7 +1112,6 @@ protected void modifyFocusAssignment(Class f Consumer modificationBlock, boolean add, ModelExecuteOptions options, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { ObjectDelta focusDelta = createAssignmentFocusDelta(focusClass, focusOid, elementName, roleOid, refType, relation, modificationBlock, add); - Collection> deltas = MiscSchemaUtil.createCollection(focusDelta); executeChanges(focusDelta, options, task, result); } @@ -1188,7 +1150,7 @@ protected void unassign(Class focusClass, St protected void unassign(Class focusClass, String focusOid, AssignmentType currentAssignment, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - Collection> modifications = new ArrayList<>(); + Collection> modifications = new ArrayList<>(); ContainerDelta assignmentDelta = prismContext.deltaFactory().container().createDelta(UserType.F_ASSIGNMENT, getUserDefinition()); assignmentDelta.addValuesToDelete(currentAssignment.asPrismContainerValue().clone()); modifications.add(assignmentDelta); @@ -1211,7 +1173,7 @@ protected void unlinkUser(String userOid, String targetOid) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - Task task = getTestTask(); + Task task = createTask("unlinkUser"); OperationResult result = task.getResult(); unlink(UserType.class, userOid, targetOid, task, result); assertSuccess(result); @@ -1228,8 +1190,8 @@ protected void unassignAll(PrismObject focusBefore, Tas * Creates unassign delta by removing each assignment individually by id. */ protected ObjectDelta createUnassignAllDelta(PrismObject focusBefore) throws SchemaException { - Collection> modifications = new ArrayList<>(); - for (AssignmentType assignmentType: focusBefore.asObjectable().getAssignment()) { + Collection> modifications = new ArrayList<>(); + for (AssignmentType assignmentType : focusBefore.asObjectable().getAssignment()) { modifications.add((createAssignmentModification(assignmentType.getId(), false))); } return prismContext.deltaFactory().object() @@ -1244,9 +1206,9 @@ protected void unassignAllReplace(String userOid, Task task, OperationResult res throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - ObjectDelta userDelta = prismContext.deltaFactory().object() - .createModificationReplaceContainer(UserType.class, userOid, - UserType.F_ASSIGNMENT, new PrismContainerValue[0]); + ObjectDelta userDelta = + prismContext.deltaFactory().object().createModificationReplaceContainer( + UserType.class, userOid, UserType.F_ASSIGNMENT, new PrismContainerValue[0]); Collection> deltas = MiscSchemaUtil.createCollection(userDelta); modelService.executeChanges(deltas, null, task, result); } @@ -1271,11 +1233,10 @@ protected ContainerDelta createAssignmentM assignment.setActivation(activationType); }, add); } catch (TunnelException te) { - throw (SchemaException)te.getCause(); + throw (SchemaException) te.getCause(); } } - protected ContainerDelta createAssignmentModification(Class type, QName elementName, String roleOid, QName refType, QName relation, Consumer modificationBlock, boolean add) throws SchemaException { ContainerDelta assignmentDelta = prismContext.deltaFactory().container().createDelta(ItemName.fromQName(elementName), getObjectDefinition(type)); @@ -1295,7 +1256,7 @@ protected ContainerDelta create return assignmentDelta; } - protected ContainerDelta createAssignmentModification(long id, boolean add) throws SchemaException { + protected ContainerDelta createAssignmentModification(long id, boolean add) { ContainerDelta assignmentDelta = prismContext.deltaFactory().container().createDelta(UserType.F_ASSIGNMENT, getUserDefinition()); PrismContainerValue cval = prismContext.itemFactory().createContainerValue(); cval.setId(id); @@ -1307,12 +1268,14 @@ protected ContainerDelta createAssignmentModification(long id, b return assignmentDelta; } - protected ContainerDelta createAssignmentEmptyDeleteModification(PrismObject existingFocus, String roleOid, QName relation) throws SchemaException { + protected ContainerDelta createAssignmentEmptyDeleteModification( + PrismObject existingFocus, String roleOid, QName relation) { AssignmentType existingAssignment = findAssignment(existingFocus, roleOid, relation); return createAssignmentModification(existingAssignment.getId(), false); } - protected AssignmentType findAssignment(PrismObject existingFocus, String targetOid, QName relation) { + protected AssignmentType findAssignment( + PrismObject existingFocus, String targetOid, QName relation) { for (AssignmentType assignmentType : existingFocus.asObjectable().getAssignment()) { if (assignmentMatches(assignmentType, targetOid, relation)) { return assignmentType; @@ -1339,9 +1302,11 @@ private boolean referenceMatches(ObjectReferenceType ref, String targetOid, QNam return true; } - protected ObjectDelta createAssignmentUserDelta(String userOid, String roleOid, QName refType, QName relation, - PrismContainer extension, ActivationType activationType, boolean add) throws SchemaException { - Collection> modifications = new ArrayList<>(); + protected ObjectDelta createAssignmentUserDelta( + String userOid, String roleOid, QName refType, QName relation, + PrismContainer extension, ActivationType activationType, boolean add) + throws SchemaException { + Collection> modifications = new ArrayList<>(); modifications.add((createAssignmentModification(roleOid, refType, relation, extension, activationType, add))); ObjectDelta userDelta = prismContext.deltaFactory().object() .createModifyDelta(userOid, modifications, UserType.class); @@ -1350,7 +1315,7 @@ protected ObjectDelta createAssignmentUserDelta(String userOid, String protected ObjectDelta createAssignmentAssignmentHolderDelta(Class focusClass, String focusOid, String roleOid, QName refType, QName relation, PrismContainer extension, ActivationType activationType, boolean add) throws SchemaException { - Collection> modifications = new ArrayList<>(); + Collection> modifications = new ArrayList<>(); modifications.add((createAssignmentModification(roleOid, refType, relation, extension, activationType, add))); return prismContext.deltaFactory().object().createModifyDelta(focusOid, modifications, focusClass); } @@ -1367,20 +1332,20 @@ protected ObjectDelta createAssignmentFocusDelta(Class< protected ObjectDelta createAssignmentFocusDelta(Class focusClass, String focusOid, QName elementName, String roleOid, QName refType, QName relation, Consumer modificationBlock, boolean add) throws SchemaException { - Collection> modifications = new ArrayList<>(); + Collection> modifications = new ArrayList<>(); modifications.add((createAssignmentModification(focusClass, elementName, roleOid, refType, relation, modificationBlock, add))); return prismContext.deltaFactory().object().createModifyDelta(focusOid, modifications, focusClass); } protected ObjectDelta createAssignmentFocusEmptyDeleteDelta(PrismObject existingFocus, String roleOid, QName relation) throws SchemaException { - Collection> modifications = new ArrayList<>(); + Collection> modifications = new ArrayList<>(); modifications.add((createAssignmentEmptyDeleteModification(existingFocus, roleOid, relation))); - return prismContext.deltaFactory().object() - .createModifyDelta(existingFocus.getOid(), modifications, existingFocus.getCompileTimeClass() - ); + return prismContext.deltaFactory().object().createModifyDelta( + existingFocus.getOid(), modifications, existingFocus.getCompileTimeClass()); } - protected ContainerDelta createAccountAssignmentModification(String resourceOid, String intent, boolean add) throws SchemaException { + protected ContainerDelta createAccountAssignmentModification( + String resourceOid, String intent, boolean add) throws SchemaException { return createAssignmentModification(resourceOid, ShadowKindType.ACCOUNT, intent, add); } @@ -1426,17 +1391,10 @@ protected AssignmentType createConstructionAssignment(String resourceOid, Shadow return assignmentType; } - protected AssignmentType createTargetAssignment(String targetOid, QName targetType) { - AssignmentType assignmentType = new AssignmentType(); - ObjectReferenceType targetRef = new ObjectReferenceType(); - targetRef.setOid(targetOid); - targetRef.setType(targetType); - assignmentType.setTargetRef(targetRef); - return assignmentType; - } - - protected ObjectDelta createParametricAssignmentDelta(String userOid, String roleOid, String orgOid, String tenantOid, boolean adding) throws SchemaException { - Collection> modifications = new ArrayList<>(); + protected ObjectDelta createParametricAssignmentDelta( + String userOid, String roleOid, String orgOid, String tenantOid, boolean adding) + throws SchemaException { + Collection> modifications = new ArrayList<>(); ContainerDelta assignmentDelta = prismContext.deltaFactory().container().createDelta(UserType.F_ASSIGNMENT, getUserDefinition()); PrismContainerValue cval = prismContext.itemFactory().createContainerValue(); @@ -1459,9 +1417,8 @@ protected ObjectDelta createParametricAssignmentDelta(String userOid, tenantRef.getValue().setOid(tenantOid); } - modifications.add(assignmentDelta); - return prismContext.deltaFactory().object().createModifyDelta(userOid, modifications, UserType.class + return prismContext.deltaFactory().object().createModifyDelta(userOid, modifications, UserType.class ); } @@ -1490,19 +1447,15 @@ protected void assertAssignees(String targetOid, int expectedAssignees) throws S } protected void assertAssignees(String targetOid, QName relation, int expectedAssignees) throws SchemaException { - OperationResult result = new OperationResult(AbstractModelIntegrationTest.class.getName()+".assertAssignees"); + OperationResult result = new OperationResult(contextName() + ".assertAssignees"); int count = countAssignees(targetOid, relation, result); if (count != expectedAssignees) { SearchResultList> assignees = listAssignees(targetOid, result); - AssertJUnit.fail("Unexpected number of assignees of "+targetOid+" as '"+relation+"', expected "+expectedAssignees+", but was " + count+ ": "+assignees); + AssertJUnit.fail("Unexpected number of assignees of " + targetOid + " as '" + relation + "', expected " + expectedAssignees + ", but was " + count + ": " + assignees); } } - protected int countAssignees(String targetOid, OperationResult result) throws SchemaException { - return countAssignees(targetOid, prismContext.getDefaultRelation(), result); - } - protected int countAssignees(String targetOid, QName relation, OperationResult result) throws SchemaException { PrismReferenceValue refVal = itemFactory().createReferenceValue(); refVal.setOid(targetOid); @@ -1520,7 +1473,7 @@ protected SearchResultList> listAssignees(String targetOi return repositoryService.searchObjects(FocusType.class, query, null, result); } - protected ConstructionType createAccountConstruction(String resourceOid, String intent) throws SchemaException { + protected ConstructionType createAccountConstruction(String resourceOid, String intent) { ConstructionType accountConstructionType = new ConstructionType(); ObjectReferenceType resourceRef = new ObjectReferenceType(); resourceRef.setOid(resourceOid); @@ -1529,13 +1482,14 @@ protected ConstructionType createAccountConstruction(String resourceOid, String return accountConstructionType; } - protected ObjectDelta createReplaceAccountConstructionUserDelta(String userOid, Long id, ConstructionType newValue) throws SchemaException { + protected ObjectDelta createReplaceAccountConstructionUserDelta( + String userOid, Long id, ConstructionType newValue) { PrismContainerDefinition pcd = getAssignmentDefinition().findContainerDefinition(AssignmentType.F_CONSTRUCTION); ContainerDelta acDelta = prismContext.deltaFactory().container().create( ItemPath.create(UserType.F_ASSIGNMENT, id, AssignmentType.F_CONSTRUCTION), pcd); acDelta.setValueToReplace(newValue.asPrismContainerValue()); - Collection> modifications = new ArrayList<>(); + Collection> modifications = new ArrayList<>(); modifications.add(acDelta); ObjectDelta userDelta = prismContext.deltaFactory().object() .createModifyDelta(userOid, modifications, UserType.class); @@ -1548,25 +1502,38 @@ protected ObjectDelta createAccountAssignmentUserDelta(String focusOid protected ObjectDelta createAssignmentDelta(Class type, String focusOid, String resourceOid, ShadowKindType kind, String intent, boolean add) throws SchemaException { - Collection> modifications = new ArrayList<>(); + Collection> modifications = new ArrayList<>(); modifications.add(createAssignmentModification(resourceOid, kind, intent, add)); ObjectDelta userDelta = prismContext.deltaFactory().object().createModifyDelta(focusOid, modifications, type ); return userDelta; } - protected Collection> executeChanges(ObjectDelta objectDelta, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + protected Collection> executeChanges( + ObjectDelta objectDelta, ModelExecuteOptions options, Task task, OperationResult result) + throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, + ExpressionEvaluationException, CommunicationException, ConfigurationException, + PolicyViolationException, SecurityViolationException { display("Executing delta", objectDelta); Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); return modelService.executeChanges(deltas, options, task, result); } - protected Collection> executeChanges(Collection> deltas, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + protected Collection> executeChanges( + Collection> deltas, + ModelExecuteOptions options, Task task, OperationResult result) + throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, + ExpressionEvaluationException, CommunicationException, ConfigurationException, + PolicyViolationException, SecurityViolationException { display("Executing deltas", deltas); return modelService.executeChanges(deltas, options, task, result); } - protected Collection> executeChangesAssertSuccess(ObjectDelta objectDelta, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + protected Collection> executeChangesAssertSuccess( + ObjectDelta objectDelta, ModelExecuteOptions options, Task task, OperationResult result) + throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, + ExpressionEvaluationException, CommunicationException, ConfigurationException, + PolicyViolationException, SecurityViolationException { Collection> rv = executeChanges(objectDelta, options, task, result); assertSuccess(result); return rv; @@ -1578,18 +1545,26 @@ protected ModelContext previewChanges(ObjectDelta o return modelInteractionService.previewChanges(deltas, options, task, result); } - protected void assignAccountToUser(String focusOid, String resourceOid, String intent) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + protected void assignAccountToUser( + String focusOid, String resourceOid, String intent) + throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, + ExpressionEvaluationException, CommunicationException, ConfigurationException, + PolicyViolationException, SecurityViolationException { assignAccount(UserType.class, focusOid, resourceOid, intent); } protected void assignAccount(Class type, String focusOid, String resourceOid, String intent) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".assignAccount"); + Task task = createTask("assignAccount"); OperationResult result = task.getResult(); assignAccount(type, focusOid, resourceOid, intent, task, result); assertSuccess(result); } - protected void assignAccountToUser(String focusOid, String resourceOid, String intent, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + protected void assignAccountToUser( + String focusOid, String resourceOid, String intent, Task task, OperationResult result) + throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, + ExpressionEvaluationException, CommunicationException, ConfigurationException, + PolicyViolationException, SecurityViolationException { assignAccount(UserType.class, focusOid, resourceOid, intent, task, result); } @@ -1603,7 +1578,7 @@ protected void unassignAccountFromUser(String focusOid, String resourceOid, Stri } protected void unassignAccount(Class type, String focusOid, String resourceOid, String intent) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".assignAccount"); + Task task = createTask("unassignAccount"); OperationResult result = task.getResult(); unassignAccount(type, focusOid, resourceOid, intent, task, result); assertSuccess(result); @@ -1626,7 +1601,7 @@ protected void assignPolicyRule(Class type, String focu } protected void assign(Class type, String focusOid, AssignmentType assignmentType, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Collection> modifications = new ArrayList<>(); + Collection> modifications = new ArrayList<>(); modifications.add(createAssignmentModification(assignmentType, true)); ObjectDelta userDelta = prismContext.deltaFactory().object().createModifyDelta(focusOid, modifications, type ); @@ -1634,7 +1609,7 @@ protected void assign(Class type, String focusOid, Assi } protected PrismObject getUser(String userOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".getUser"); + Task task = createTask("getUser"); OperationResult result = task.getResult(); PrismObject user = modelService.getObject(UserType.class, userOid, null, task, result); result.computeStatus(); @@ -1646,14 +1621,16 @@ protected PrismObject getUserFromRepo(String userOid) throws ObjectNot return repositoryService.getObject(UserType.class, userOid, null, new OperationResult("dummy")); } - protected PrismObject findObjectByName(Class type, String name) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = getTestTask(); + protected PrismObject findObjectByName(Class type, String name) + throws SchemaException, ObjectNotFoundException, SecurityViolationException, + CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = createTask("findObjectByName"); OperationResult result = task.getResult(); List> objects = modelService.searchObjects(type, createNameQuery(name), null, task, result); if (objects.isEmpty()) { return null; } - assert objects.size() == 1 : "Too many objects found for name "+name+": "+objects; + assert objects.size() == 1 : "Too many objects found for name " + name + ": " + objects; return objects.iterator().next(); } @@ -1678,7 +1655,7 @@ protected RoleType getRoleSimple(String oid) { } protected PrismObject getRole(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".getRole"); + Task task = createTask("getRole"); OperationResult result = task.getResult(); PrismObject role = modelService.getObject(RoleType.class, oid, null, task, result); result.computeStatus(); @@ -1687,7 +1664,7 @@ protected PrismObject getRole(String oid) throws ObjectNotFoundExcepti } protected PrismObject findAccountByUsername(String username, PrismObject resource) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".findAccountByUsername"); + Task task = createTask("findAccountByUsername"); OperationResult result = task.getResult(); return findAccountByUsername(username, resource, task, result); } @@ -1699,24 +1676,25 @@ protected PrismObject findAccountByUsername(String username, PrismOb if (accounts.isEmpty()) { return null; } - assert accounts.size() == 1 : "Too many accounts found for username "+username+" on "+resource+": "+accounts; + assert accounts.size() == 1 : "Too many accounts found for username " + username + " on " + resource + ": " + accounts; return accounts.iterator().next(); } - protected Collection> listAccounts(PrismObject resource, - Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + protected Collection> listAccounts( + PrismObject resource, Task task, OperationResult result) + throws SchemaException, ObjectNotFoundException, SecurityViolationException, + CommunicationException, ConfigurationException, ExpressionEvaluationException { RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource); RefinedObjectClassDefinition rAccount = rSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT); Collection identifierDefs = rAccount.getPrimaryIdentifiers(); - assert identifierDefs.size() == 1 : "Unexpected identifier set in "+resource+" refined schema: "+identifierDefs; + assert identifierDefs.size() == 1 : "Unexpected identifier set in " + resource + " refined schema: " + identifierDefs; ResourceAttributeDefinition identifierDef = identifierDefs.iterator().next(); ObjectQuery query = prismContext.queryFor(ShadowType.class) .item(ShadowType.F_OBJECT_CLASS).eq(rAccount.getObjectClassDefinition().getTypeName()) .and().item(ShadowType.F_RESOURCE_REF).ref(resource.getOid()) .build(); - List> accounts = modelService.searchObjects(ShadowType.class, query, null, task, result); - return accounts; + return modelService.searchObjects(ShadowType.class, query, null, task, result); } protected PrismObject getShadowModel(String accountOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { @@ -1732,15 +1710,15 @@ protected PrismObject getShadowModelFuture(String accountOid) throws } protected PrismObject getShadowModel(String shadowOid, GetOperationOptions rootOptions, boolean assertSuccess) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".getShadowModel"); + Task task = createTask("getShadowModel"); OperationResult result = task.getResult(); Collection> opts = null; if (rootOptions != null) { opts = SelectorOptions.createCollection(rootOptions); } - LOGGER.info("Getting model shadow {} with options {}", shadowOid, opts); - PrismObject shadow = modelService.getObject(ShadowType.class, shadowOid, opts , task, result); - LOGGER.info("Got model shadow (options {})\n{}", shadowOid, shadow.debugDumpLazily(1)); + logger.info("Getting model shadow {} with options {}", shadowOid, opts); + PrismObject shadow = modelService.getObject(ShadowType.class, shadowOid, opts, task, result); + logger.info("Got model shadow (options {})\n{}", shadowOid, shadow.debugDumpLazily(1)); result.computeStatus(); if (assertSuccess) { TestUtil.assertSuccess("getObject(shadow) result not success", result); @@ -1748,20 +1726,23 @@ protected PrismObject getShadowModel(String shadowOid, GetOperationO return shadow; } - protected void assertNoObject(Class type, String oid) throws SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - AbstractModelIntegrationTest.class.getName(); - Task task = getTestTask(); + protected void assertNoObject(Class type, String oid) + throws SchemaException, SecurityViolationException, CommunicationException, + ConfigurationException, ExpressionEvaluationException { + Task task = createTask("assertNoObject"); assertNoObject(type, oid, task, task.getResult()); } - protected void assertNoObject(Class type, String oid, Task task, OperationResult result) throws SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + protected void assertNoObject( + Class type, String oid, Task task, OperationResult result) + throws SchemaException, SecurityViolationException, CommunicationException, + ConfigurationException, ExpressionEvaluationException { try { PrismObject object = modelService.getObject(type, oid, null, task, result); display("Unexpected object", object); - AssertJUnit.fail("Expected that "+object+" does not exist, but it does"); + AssertJUnit.fail("Expected that " + object + " does not exist, but it does"); } catch (ObjectNotFoundException e) { // This is expected - return; } } @@ -1787,61 +1768,35 @@ protected void assertNoObjectByName(Class type, String } } - protected void assertNoShadow(String username, PrismObject resource, - Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException { + protected void assertNoShadow( + String username, PrismObject resource, OperationResult result) + throws SchemaException { ObjectQuery query = createAccountShadowQuery(username, resource); - List> accounts = repositoryService.searchObjects(ShadowType.class, query, null, result); + List> accounts = + repositoryService.searchObjects(ShadowType.class, query, null, result); if (accounts.isEmpty()) { return; } - LOGGER.error("Found shadow for "+username+" on "+resource+" while not expecting it:\n"+accounts.get(0).debugDump()); - assert false : "Found shadow for "+username+" on "+resource+" while not expecting it: "+accounts; + logger.error("Found shadow for " + username + " on " + resource + " while not expecting it:\n" + accounts.get(0).debugDump()); + assert false : "Found shadow for " + username + " on " + resource + " while not expecting it: " + accounts; } - protected void assertHasShadow(String username, PrismObject resource, - Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException { - ObjectQuery query = createAccountShadowQuery(username, resource); - List> accounts = repositoryService.searchObjects(ShadowType.class, query, null, result); - if (accounts.isEmpty()) { - AssertJUnit.fail("No shadow for "+username+" on "+resource); - } else if (accounts.size() > 1) { - AssertJUnit.fail("Too many shadows for "+username+" on "+resource+" ("+accounts.size()+"): "+accounts); - } - } - - protected ShadowAsserter assertShadow(String username, PrismObject resource) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException { + protected ShadowAsserter assertShadow(String username, PrismObject resource) + throws SchemaException { ObjectQuery query = createAccountShadowQuery(username, resource); OperationResult result = new OperationResult("assertShadow"); List> accounts = repositoryService.searchObjects(ShadowType.class, query, null, result); if (accounts.isEmpty()) { - AssertJUnit.fail("No shadow for "+username+" on "+resource); + AssertJUnit.fail("No shadow for " + username + " on " + resource); } else if (accounts.size() > 1) { - AssertJUnit.fail("Too many shadows for "+username+" on "+resource+" ("+accounts.size()+"): "+accounts); + AssertJUnit.fail("Too many shadows for " + username + " on " + resource + " (" + accounts.size() + "): " + accounts); } - ShadowAsserter asserter = ShadowAsserter.forShadow(accounts.get(0), "shadow for username "+username+" on "+resource); + ShadowAsserter asserter = ShadowAsserter.forShadow(accounts.get(0), "shadow for username " + username + " on " + resource); initializeAsserter(asserter); asserter.display(); return asserter; } - protected ShadowAsserter assertShadowByName(ShadowKindType kind, String intent, String name, - PrismObject resource, String message, OperationResult result) - throws ConfigurationException, SchemaException, ObjectNotFoundException, CommunicationException, - SecurityViolationException { - PrismObject shadow = findShadowByName(kind, intent, name, resource, result); - assertNotNull("No shadow with name '"+name+"'", shadow); - return assertShadow(shadow, message); - } - - protected ShadowAsserter assertShadowByNameViaModel(ShadowKindType kind, String intent, String name, - PrismObject resource, String message, Task task, OperationResult result) - throws ConfigurationException, SchemaException, ObjectNotFoundException, CommunicationException, - SecurityViolationException, ExpressionEvaluationException { - PrismObject shadow = findShadowByNameViaModel(kind, intent, name, resource, task, result); - assertNotNull("No shadow with name '"+name+"'", shadow); - return assertShadow(shadow, message); - } - protected PrismObject findShadowByNameViaModel(ShadowKindType kind, String intent, String name, PrismObject resource, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, @@ -1856,22 +1811,21 @@ protected PrismObject findShadowByNameViaModel(ShadowKindType kind, throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource); - RefinedObjectClassDefinition rOcDef = rSchema.getRefinedDefinition(kind,intent); + RefinedObjectClassDefinition rOcDef = rSchema.getRefinedDefinition(kind, intent); ObjectQuery query = createShadowQuerySecondaryIdentifier(rOcDef, name, resource); List> shadows = modelService.searchObjects(ShadowType.class, query, options, task, result); if (shadows.isEmpty()) { return null; } - assert shadows.size() == 1 : "Too many shadows found for name "+name+" on "+resource+": "+shadows; + assert shadows.size() == 1 : "Too many shadows found for name " + name + " on " + resource + ": " + shadows; return shadows.iterator().next(); } - protected ObjectQuery createAccountShadowQuery(String username, PrismObject resource) throws SchemaException { RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource); RefinedObjectClassDefinition rAccount = rSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT); Collection identifierDefs = rAccount.getPrimaryIdentifiers(); - assert identifierDefs.size() == 1 : "Unexpected identifier set in "+resource+" refined schema: "+identifierDefs; + assert identifierDefs.size() == 1 : "Unexpected identifier set in " + resource + " refined schema: " + identifierDefs; ResourceAttributeDefinition identifierDef = identifierDefs.iterator().next(); //TODO: set matching rule instead of null return prismContext.queryFor(ShadowType.class) @@ -1912,7 +1866,7 @@ protected String getLinkRefOid(PrismObject focus, Strin protected PrismReferenceValue getLinkRef(PrismObject focus, String resourceOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { F focusType = focus.asObjectable(); - for (ObjectReferenceType linkRefType: focusType.getLinkRef()) { + for (ObjectReferenceType linkRefType : focusType.getLinkRef()) { String linkTargetOid = linkRefType.getOid(); assertFalse("No linkRef oid", StringUtils.isBlank(linkTargetOid)); PrismObject account = getShadowModel(linkTargetOid, GetOperationOptions.createNoFetch(), false); @@ -1921,13 +1875,13 @@ protected PrismReferenceValue getLinkRef(PrismObject fo return linkRefType.asReferenceValue(); } } - AssertJUnit.fail("Account for resource "+resourceOid+" not found in "+focus); + AssertJUnit.fail("Account for resource " + resourceOid + " not found in " + focus); return null; // Never reached. But compiler complains about missing return } protected String getLinkRefOid(PrismObject focus, String resourceOid, ShadowKindType kind, String intent) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { F focusType = focus.asObjectable(); - for (ObjectReferenceType linkRefType: focusType.getLinkRef()) { + for (ObjectReferenceType linkRefType : focusType.getLinkRef()) { String linkTargetOid = linkRefType.getOid(); assertFalse("No linkRef oid", StringUtils.isBlank(linkTargetOid)); PrismObject account = getShadowModel(linkTargetOid, GetOperationOptions.createNoFetch(), false); @@ -1943,7 +1897,7 @@ protected String getLinkRefOid(PrismObject focus, Strin return linkTargetOid; } } - AssertJUnit.fail("Linked shadow for resource "+resourceOid+", kind "+kind+" and intent "+intent+" not found in "+focus); + AssertJUnit.fail("Linked shadow for resource " + resourceOid + ", kind " + kind + " and intent " + intent + " not found in " + focus); return null; // Never reached. But compiler complains about missing return } @@ -1965,18 +1919,18 @@ protected void assertAccounts(String userOid, int numAccounts) throws ObjectNotF } protected void assertNoShadows(Collection shadowOids) throws SchemaException { - for (String shadowOid: shadowOids) { + for (String shadowOid : shadowOids) { assertNoShadow(shadowOid); } } protected void assertNoShadow(String shadowOid) throws SchemaException { - OperationResult result = new OperationResult(AbstractModelIntegrationTest.class.getName() + ".assertNoShadow"); + OperationResult result = new OperationResult(contextName() + ".assertNoShadow"); // Check is shadow is gone try { PrismObject shadow = repositoryService.getObject(ShadowType.class, shadowOid, null, result); display("Unexpected shadow", shadow); - AssertJUnit.fail("Shadow "+shadowOid+" still exists"); + AssertJUnit.fail("Shadow " + shadowOid + " still exists"); } catch (ObjectNotFoundException e) { // This is OK } @@ -1990,7 +1944,7 @@ protected AssignmentType getUserAssignment(String userOid, String roleOid, QName throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { PrismObject user = getUser(userOid); List assignments = user.asObjectable().getAssignment(); - for (AssignmentType assignment: assignments) { + for (AssignmentType assignment : assignments) { ObjectReferenceType targetRef = assignment.getTargetRef(); if (targetRef != null && roleOid.equals(targetRef.getOid()) && prismContext.relationMatches(relation, targetRef.getRelation())) { @@ -2000,9 +1954,9 @@ protected AssignmentType getUserAssignment(String userOid, String roleOid, QName return null; } - protected AssignmentType getAssignment(PrismObject focus, String roleOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + protected AssignmentType getAssignment(PrismObject focus, String roleOid) { List assignments = focus.asObjectable().getAssignment(); - for (AssignmentType assignment: assignments) { + for (AssignmentType assignment : assignments) { ObjectReferenceType targetRef = assignment.getTargetRef(); if (targetRef != null && roleOid.equals(targetRef.getOid())) { return assignment; @@ -2025,24 +1979,24 @@ protected void assertNoAssignments(String userOid, OperationResult result) throw } protected void assertNoAssignments(String userOid) throws ObjectNotFoundException, SchemaException { - OperationResult result = new OperationResult(AbstractModelIntegrationTest.class.getName() + ".assertNoShadow"); + OperationResult result = new OperationResult(contextName() + ".assertNoShadow"); assertNoAssignments(userOid, result); } - protected AssignmentType assertAssignedRole(String userOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { + protected AssignmentType assertAssignedRole( + String userOid, String roleOid, OperationResult result) + throws ObjectNotFoundException, SchemaException { PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); return assertAssignedRole(user, roleOid); } - protected AssignmentType assertAssignedRole(PrismObject focus, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { - return assertAssignedRole(focus, roleOid); - } - - protected AssignmentType assertAssignedRole(PrismObject user, String roleOid) { + protected AssignmentType assertAssignedRole( + PrismObject user, String roleOid) { return MidPointAsserts.assertAssignedRole(user, roleOid); } - protected static void assertAssignedRoles(PrismObject user, String... roleOids) { + protected static void assertAssignedRoles( + PrismObject user, String... roleOids) { MidPointAsserts.assertAssignedRoles(user, roleOids); } @@ -2091,7 +2045,7 @@ protected void modifyDeputyAssignmentLimits(String userDeputyOid, String userTar assignment -> { AssignmentSelectorType limitTargetContent = new AssignmentSelectorType(); assignment.setLimitTargetContent(limitTargetContent); - for (ObjectReferenceType limitTarget: limitTargets) { + for (ObjectReferenceType limitTarget : limitTargets) { limitTargetContent.getTargetRef().add(limitTarget); } if (assignmentMutator != null) { @@ -2126,24 +2080,24 @@ protected void assertObjectRefs(String contextDesc, Collection real, String... expected) { List refOids = new ArrayList<>(); - for (ObjectReferenceType ref: real) { + for (ObjectReferenceType ref : real) { refOids.add(ref.getOid()); - assertNotNull("Missing type in "+ref.getOid()+" in "+contextDesc, ref.getType()); + assertNotNull("Missing type in " + ref.getOid() + " in " + contextDesc, ref.getType()); if (checkNames) { assertNotNull("Missing name in " + ref.getOid() + " in " + contextDesc, ref.getTargetName()); } } - PrismAsserts.assertSets("Wrong values in "+contextDesc, refOids, expected); + PrismAsserts.assertSets("Wrong values in " + contextDesc, refOids, expected); } protected void assertPrismRefValues(String contextDesc, Collection real, String... expected) { List refOids = new ArrayList<>(); - for (PrismReferenceValue ref: real) { + for (PrismReferenceValue ref : real) { refOids.add(ref.getOid()); - assertNotNull("Missing type in "+ref.getOid()+" in "+contextDesc, ref.getTargetType()); - assertNotNull("Missing name in "+ref.getOid()+" in "+contextDesc, ref.getTargetName()); + assertNotNull("Missing type in " + ref.getOid() + " in " + contextDesc, ref.getTargetType()); + assertNotNull("Missing name in " + ref.getOid() + " in " + contextDesc, ref.getTargetName()); } - PrismAsserts.assertSets("Wrong values in "+contextDesc, refOids, expected); + PrismAsserts.assertSets("Wrong values in " + contextDesc, refOids, expected); } private String[] objectsToOids(ObjectType[] objects) { @@ -2160,11 +2114,11 @@ private String[] objectsToOids(Collection objects) { protected void assertDelegatedRef(PrismObject focus, String... oids) { List refOids = new ArrayList<>(); - for (ObjectReferenceType ref: focus.asObjectable().getDelegatedRef()) { + for (ObjectReferenceType ref : focus.asObjectable().getDelegatedRef()) { refOids.add(ref.getOid()); - assertNotNull("Missing type in delegatedRef "+ref.getOid()+" in "+focus, ref.getType()); + assertNotNull("Missing type in delegatedRef " + ref.getOid() + " in " + focus, ref.getType()); } - PrismAsserts.assertSets("Wrong values in delegatedRef in "+focus, refOids, oids); + PrismAsserts.assertSets("Wrong values in delegatedRef in " + focus, refOids, oids); } protected void assertNotAssignedRole(PrismObject focus, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { @@ -2221,7 +2175,7 @@ protected void assertHasOrg(String userOid, String orgOid, Task task, OperationR } protected void assertHasOrgs(PrismObject user, String... orgOids) throws Exception { - for (String orgOid: orgOids) { + for (String orgOid : orgOids) { assertHasOrg(user, orgOid); } assertHasOrgs(user, orgOids.length); @@ -2267,21 +2221,21 @@ protected void assertHasArchetype(PrismObject< } protected void assertSubOrgs(String baseOrgOid, int expected) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".assertSubOrgs"); + Task task = createTask("assertSubOrgs"); OperationResult result = task.getResult(); List> subOrgs = getSubOrgs(baseOrgOid, task, result); result.computeStatus(); TestUtil.assertSuccess(result); - assertEquals("Unexpected number of suborgs of org "+baseOrgOid+", has suborgs "+subOrgs, expected, subOrgs.size()); + assertEquals("Unexpected number of suborgs of org " + baseOrgOid + ", has suborgs " + subOrgs, expected, subOrgs.size()); } protected void assertSubOrgs(PrismObject baseOrg, int expected) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".assertSubOrgs"); + Task task = createTask("assertSubOrgs"); OperationResult result = task.getResult(); List> subOrgs = getSubOrgs(baseOrg.getOid(), task, result); result.computeStatus(); TestUtil.assertSuccess(result); - assertEquals("Unexpected number of suborgs of"+baseOrg+", has suborgs "+subOrgs, expected, subOrgs.size()); + assertEquals("Unexpected number of suborgs of" + baseOrg + ", has suborgs " + subOrgs, expected, subOrgs.size()); } protected List> getSubOrgs(String baseOrgOid, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { @@ -2303,7 +2257,7 @@ protected String dumpOrgTree(String topOrgOid) throws SchemaException, ObjectNot } protected String dumpOrgTree(String topOrgOid, boolean dumpUsers) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".assertSubOrgs"); + Task task = createTask("dumpOrgTree"); OperationResult result = task.getResult(); PrismObject topOrg = modelService.getObject(OrgType.class, topOrgOid, null, task, result); String dump = dumpOrgTree(topOrg, dumpUsers, task, result); @@ -2322,7 +2276,7 @@ protected String dumpOrgTree(PrismObject topOrg, boolean dumpUsers, Tas private void dumpSubOrgs(StringBuilder sb, String baseOrgOid, boolean dumpUsers, int indent, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { List> subOrgs = getSubOrgs(baseOrgOid, task, result); - for (PrismObject suborg: subOrgs) { + for (PrismObject suborg : subOrgs) { dumpOrg(sb, suborg, indent); if (dumpUsers) { dumpOrgUsers(sb, suborg.getOid(), dumpUsers, indent + 1, task, result); @@ -2334,7 +2288,7 @@ private void dumpSubOrgs(StringBuilder sb, String baseOrgOid, boolean dumpUsers, private void dumpOrgUsers(StringBuilder sb, String baseOrgOid, boolean dumpUsers, int indent, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { List> subUsers = getSubOrgUsers(baseOrgOid, task, result); - for (PrismObject subuser: subUsers) { + for (PrismObject subuser : subUsers) { sb.append("\n"); DebugUtil.indentDebugDump(sb, indent); sb.append(subuser); @@ -2349,7 +2303,7 @@ private void dumpOrg(StringBuilder sb, PrismObject org, int indent) { } protected void displayUsers() throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".displayUsers"); + Task task = createTask("displayUsers"); OperationResult result = task.getResult(); ResultHandler handler = (user, parentResult) -> { display("User", user); @@ -2365,7 +2319,7 @@ protected void dumpFocus(String message, PrismObject fo StringBuilder sb = new StringBuilder(); sb.append(focus.debugDump(0)); sb.append("\nOrgs:"); - for (ObjectReferenceType parentOrgRef: focus.asObjectable().getParentOrgRef()) { + for (ObjectReferenceType parentOrgRef : focus.asObjectable().getParentOrgRef()) { sb.append("\n"); DebugUtil.indentDebugDump(sb, 1); PrismObject org = repositoryService.getObject(OrgType.class, parentOrgRef.getOid(), null, result); @@ -2376,7 +2330,7 @@ protected void dumpFocus(String message, PrismObject fo } } sb.append("\nProjections:"); - for (ObjectReferenceType linkRef: focus.asObjectable().getLinkRef()) { + for (ObjectReferenceType linkRef : focus.asObjectable().getLinkRef()) { PrismObject shadow = repositoryService.getObject(ShadowType.class, linkRef.getOid(), null, result); ObjectReferenceType resourceRef = shadow.asObjectable().getResourceRef(); PrismObject resource = repositoryService.getObject(ResourceType.class, resourceRef.getOid(), null, result); @@ -2391,7 +2345,7 @@ protected void dumpFocus(String message, PrismObject fo sb.append(shadow.asObjectable().getName()); } sb.append("\nAssignments:"); - for (AssignmentType assignmentType: focus.asObjectable().getAssignment()) { + for (AssignmentType assignmentType : focus.asObjectable().getAssignment()) { sb.append("\n"); DebugUtil.indentDebugDump(sb, 1); if (assignmentType.getConstruction() != null) { @@ -2458,11 +2412,11 @@ protected void assertAssignedNoRole(PrismObject user) { protected void assertAssignedNo(PrismObject user, QName refType) { F userType = user.asObjectable(); - for (AssignmentType assignmentType: userType.getAssignment()) { + for (AssignmentType assignmentType : userType.getAssignment()) { ObjectReferenceType targetRef = assignmentType.getTargetRef(); if (targetRef != null) { if (refType.equals(targetRef.getType())) { - AssertJUnit.fail(user+" has role "+targetRef.getOid()+" while expected no roles"); + AssertJUnit.fail(user + " has role " + targetRef.getOid() + " while expected no roles"); } } } @@ -2475,7 +2429,7 @@ protected void assertAssignedAccount(String userOid, String resourceOid, Task ta protected AssignmentType assertAssignedAccount(PrismObject user, String resourceOid) throws ObjectNotFoundException, SchemaException { UserType userType = user.asObjectable(); - for (AssignmentType assignmentType: userType.getAssignment()) { + for (AssignmentType assignmentType : userType.getAssignment()) { ConstructionType construction = assignmentType.getConstruction(); if (construction != null) { if (construction.getKind() != null && construction.getKind() != ShadowKindType.ACCOUNT) { @@ -2492,14 +2446,14 @@ protected AssignmentType assertAssignedAccount(PrismObject user, Strin protected void assertAssignedNoAccount(PrismObject user, String resourceOid) throws ObjectNotFoundException, SchemaException { UserType userType = user.asObjectable(); - for (AssignmentType assignmentType: userType.getAssignment()) { + for (AssignmentType assignmentType : userType.getAssignment()) { ConstructionType construction = assignmentType.getConstruction(); if (construction != null) { if (construction.getKind() != null && construction.getKind() != ShadowKindType.ACCOUNT) { continue; } if (resourceOid.equals(construction.getResourceRef().getOid())) { - AssertJUnit.fail(user.toString()+" has account assignment for resource "+resourceOid+" while expecting no such assignment"); + AssertJUnit.fail(user.toString() + " has account assignment for resource " + resourceOid + " while expecting no such assignment"); } } } @@ -2534,7 +2488,6 @@ protected PrismObjectDefinition getAccountShadowDefinition() { return prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(ShadowType.class); } - protected PrismObject createObject(Class type, String name) throws SchemaException { PrismObject object = getObjectDefinition(type).instantiate(); object.asObjectable().setName(createPolyStringType(name)); @@ -2625,7 +2578,7 @@ protected PrismObject createAccount(PrismObject resour protected void addAttributeToShadow(PrismObject shadow, PrismObject resource, String attrName, T attrValue) throws SchemaException { ResourceAttributeContainer attrs = ShadowUtil.getAttributesContainer(shadow); ResourceAttributeDefinition attrSnDef = attrs.getDefinition().findAttributeDefinition( - new ItemName(ResourceTypeUtil.getResourceNamespace(resource), attrName)); + new ItemName(ResourceTypeUtil.getResourceNamespace(resource), attrName)); ResourceAttribute attr = attrSnDef.instantiate(); attr.setRealValue(attrValue); attrs.add(attr); @@ -2637,13 +2590,12 @@ protected void setDefaultUserTemplate(String userTemplateOid) throws ObjectNotFo protected void setDefaultObjectTemplate(QName objectType, String userTemplateOid) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { - OperationResult result = new OperationResult(AbstractModelIntegrationTest.class.getName()+".setDefaultObjectTemplate"); + OperationResult result = new OperationResult(contextName() + ".setDefaultObjectTemplate"); setDefaultObjectTemplate(objectType, userTemplateOid, result); result.computeStatus(); TestUtil.assertSuccess("Applying default object template failed (result)", result); } - protected void setDefaultObjectTemplate(QName objectType, String objectTemplateOid, OperationResult parentResult) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { setDefaultObjectTemplate(objectType, null, objectTemplateOid, parentResult); @@ -2656,7 +2608,7 @@ protected void setDefaultObjectTemplate(QName objectType, String subType, String SystemObjectsType.SYSTEM_CONFIGURATION.value(), null, parentResult); PrismContainerValue oldValue = null; - for (ObjectPolicyConfigurationType focusPolicyType: systemConfig.asObjectable().getDefaultObjectPolicyConfiguration()) { + for (ObjectPolicyConfigurationType focusPolicyType : systemConfig.asObjectable().getDefaultObjectPolicyConfiguration()) { if (QNameUtil.match(objectType, focusPolicyType.getType()) && MiscUtil.equals(subType, focusPolicyType.getSubtype())) { oldValue = focusPolicyType.asPrismContainerValue(); } @@ -2674,7 +2626,7 @@ protected void setDefaultObjectTemplate(QName objectType, String subType, String } ContainerDelta deleteDelta = prismContext.deltaFactory().container().createModificationDelete(SystemConfigurationType.F_DEFAULT_OBJECT_POLICY_CONFIGURATION, SystemConfigurationType.class, oldValue.clone()); - ((Collection)modifications).add(deleteDelta); + ((Collection) modifications).add(deleteDelta); } if (objectTemplateOid != null) { @@ -2695,7 +2647,7 @@ protected void setDefaultObjectTemplate(QName objectType, String subType, String ObjectReferenceType templateRef = new ObjectReferenceType(); templateRef.setOid(objectTemplateOid); newFocusPolicyType.setObjectTemplateRef(templateRef); - ((Collection)modifications).add(addDelta); + ((Collection) modifications).add(addDelta); } modifySystemObjectInRepo(SystemConfigurationType.class, @@ -2710,7 +2662,7 @@ protected void setConflictResolution(QName objectType, String subType, ConflictR SystemObjectsType.SYSTEM_CONFIGURATION.value(), null, parentResult); PrismContainerValue oldValue = null; - for (ObjectPolicyConfigurationType focusPolicyType: systemConfig.asObjectable().getDefaultObjectPolicyConfiguration()) { + for (ObjectPolicyConfigurationType focusPolicyType : systemConfig.asObjectable().getDefaultObjectPolicyConfiguration()) { if (QNameUtil.match(objectType, focusPolicyType.getType()) && MiscUtil.equals(subType, focusPolicyType.getSubtype())) { oldValue = focusPolicyType.asPrismContainerValue(); } @@ -2720,7 +2672,7 @@ protected void setConflictResolution(QName objectType, String subType, ConflictR if (oldValue != null) { ContainerDelta deleteDelta = prismContext.deltaFactory().container().createModificationDelete(SystemConfigurationType.F_DEFAULT_OBJECT_POLICY_CONFIGURATION, SystemConfigurationType.class, oldValue.clone()); - ((Collection)modifications).add(deleteDelta); + ((Collection) modifications).add(deleteDelta); } ObjectPolicyConfigurationType newFocusPolicyType = new ObjectPolicyConfigurationType(); @@ -2737,9 +2689,9 @@ protected void setConflictResolution(QName objectType, String subType, ConflictR ContainerDelta addDelta = prismContext.deltaFactory().container() .createModificationAdd(SystemConfigurationType.F_DEFAULT_OBJECT_POLICY_CONFIGURATION, - SystemConfigurationType.class, newFocusPolicyType); + SystemConfigurationType.class, newFocusPolicyType); - ((Collection)modifications).add(addDelta); + ((Collection) modifications).add(addDelta); modifySystemObjectInRepo(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), modifications, parentResult); @@ -2769,7 +2721,7 @@ protected void setGlobalSecurityPolicy(String securityPolicyOid, OperationResult protected void modifySystemObjectInRepo(Class type, String oid, Collection modifications, OperationResult parentResult) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { - display("Modifications of system object "+oid, modifications); + display("Modifications of system object " + oid, modifications); repositoryService.modifyObject(type, oid, modifications, parentResult); invalidateSystemObjectsCache(); } @@ -2787,11 +2739,11 @@ protected ItemPath getIcfsNameAttributePath() { } protected void assertResolvedResourceRefs(ModelContext context) { - for (ModelProjectionContext projectionContext: context.getProjectionContexts()) { - assertResolvedResourceRefs(projectionContext.getObjectOld(), "objectOld in "+projectionContext); - assertResolvedResourceRefs(projectionContext.getObjectNew(), "objectNew in "+projectionContext); - assertResolvedResourceRefs(projectionContext.getPrimaryDelta(), "primaryDelta in "+projectionContext); - assertResolvedResourceRefs(projectionContext.getSecondaryDelta(), "secondaryDelta in "+projectionContext); + for (ModelProjectionContext projectionContext : context.getProjectionContexts()) { + assertResolvedResourceRefs(projectionContext.getObjectOld(), "objectOld in " + projectionContext); + assertResolvedResourceRefs(projectionContext.getObjectNew(), "objectNew in " + projectionContext); + assertResolvedResourceRefs(projectionContext.getPrimaryDelta(), "primaryDelta in " + projectionContext); + assertResolvedResourceRefs(projectionContext.getSecondaryDelta(), "secondaryDelta in " + projectionContext); } } @@ -2804,9 +2756,9 @@ private void assertResolvedResourceRefs(ObjectDelta delta, String de } else if (delta.isModify()) { ReferenceDelta referenceDelta = delta.findReferenceModification(ShadowType.F_RESOURCE_REF); if (referenceDelta != null) { - assertResolvedResourceRefs(referenceDelta.getValuesToAdd(), "valuesToAdd in "+desc); - assertResolvedResourceRefs(referenceDelta.getValuesToDelete(), "valuesToDelete in "+desc); - assertResolvedResourceRefs(referenceDelta.getValuesToReplace(), "valuesToReplace in "+desc); + assertResolvedResourceRefs(referenceDelta.getValuesToAdd(), "valuesToAdd in " + desc); + assertResolvedResourceRefs(referenceDelta.getValuesToDelete(), "valuesToDelete in " + desc); + assertResolvedResourceRefs(referenceDelta.getValuesToReplace(), "valuesToReplace in " + desc); } } } @@ -2817,7 +2769,7 @@ private void assertResolvedResourceRefs(PrismObject shadow, String d } PrismReference resourceRef = shadow.findReference(ShadowType.F_RESOURCE_REF); if (resourceRef == null) { - AssertJUnit.fail("No resourceRef in "+desc); + AssertJUnit.fail("No resourceRef in " + desc); } assertResolvedResourceRefs(resourceRef.getValues(), desc); } @@ -2826,8 +2778,8 @@ private void assertResolvedResourceRefs(Collection values, if (values == null) { return; } - for (PrismReferenceValue pval: values) { - assertNotNull("resourceRef in "+desc+" does not contain object", pval.getObject()); + for (PrismReferenceValue pval : values) { + assertNotNull("resourceRef in " + desc + " does not contain object", pval.getObject()); } } @@ -2836,7 +2788,7 @@ private void assertResolvedResourceRefs(Collection values, * existing user values. */ protected void breakAssignmentDelta(Collection> deltas) throws SchemaException { - breakAssignmentDelta((ObjectDelta)deltas.iterator().next()); + breakAssignmentDelta((ObjectDelta) deltas.iterator().next()); } /** @@ -2857,9 +2809,8 @@ protected void breakAssignmentDelta(ObjectDelta userDel activationContainer.add(emptyValue); } - protected void purgeResourceSchema(String resourceOid) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".purgeResourceSchema"); + Task task = createTask("purgeResourceSchema"); OperationResult result = task.getResult(); ObjectDelta resourceDelta = prismContext.deltaFactory().object().createModificationReplaceContainer(ResourceType.class, @@ -2879,8 +2830,10 @@ protected List> searchOrg(String baseOrgOid, OrgFilter.Scop return modelService.searchObjects(OrgType.class, query, null, task, result); } - protected PrismObject searchObjectByName(Class type, String name) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".searchObjectByName"); + protected PrismObject searchObjectByName(Class type, String name) + throws SchemaException, ObjectNotFoundException, SecurityViolationException, + CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = createTask("searchObjectByName"); OperationResult result = task.getResult(); PrismObject out = searchObjectByName(type, name, task, result); result.computeStatus(); @@ -2895,7 +2848,7 @@ protected PrismObject searchObjectByName(Class type return null; } if (foundObjects.size() > 1) { - throw new IllegalStateException("More than one object found for type "+type+" and name '"+name+"'"); + throw new IllegalStateException("More than one object found for type " + type + " and name '" + name + "'"); } return foundObjects.iterator().next(); } @@ -2909,12 +2862,12 @@ protected void assertAccountShadowModel(PrismObject accountShadow, S } protected void assertShadowModel(PrismObject accountShadow, String oid, String username, ResourceType resourceType, - QName objectClass) throws SchemaException { + QName objectClass) throws SchemaException { assertShadowModel(accountShadow, oid, username, resourceType, objectClass, null); } protected void assertShadowModel(PrismObject accountShadow, String oid, String username, ResourceType resourceType, - QName objectClass, MatchingRule nameMatchingRule) throws SchemaException { + QName objectClass, MatchingRule nameMatchingRule) throws SchemaException { assertShadowCommon(accountShadow, oid, username, resourceType, objectClass, nameMatchingRule, false); IntegrationTestTools.assertProvisioningShadow(accountShadow, RefinedAttributeDefinition.class, objectClass); } @@ -2943,7 +2896,6 @@ protected ObjectDelta createModifyUserAddAccount(String userOid, Prism account.asObjectable().setObjectClass(rocd.getObjectClassDefinition().getTypeName()); account.asObjectable().setKind(ShadowKindType.ACCOUNT); - ObjectDelta userDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, userOid ); PrismReferenceValue accountRefVal = itemFactory().createReferenceValue(); @@ -2994,7 +2946,6 @@ protected void deleteUserAccount(String userOid, String resourceOid, Task task, executeChanges(userDelta, null, task, result); } - // TASKS protected void waitForTaskFinish(Task task, boolean checkSubresult) throws Exception { @@ -3006,31 +2957,31 @@ protected void waitForTaskFinish(Task task, boolean checkSubresult, final int ti } protected void waitForTaskFinish(final Task task, final boolean checkSubresult, final int timeout, long sleepTime) throws Exception { - final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForTaskFinish"); + final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class + ".waitForTaskFinish"); Checker checker = new Checker() { @Override public boolean check() throws CommonException { task.refresh(waitResult); waitResult.summarize(); -// Task freshTask = taskManager.getTaskWithResult(task.getOid(), waitResult); OperationResult result = task.getResult(); - if (verbose) display("Check result", result); - assert !isError(result, checkSubresult) : "Error in "+task+": "+TestUtil.getErrorMessage(result); - assert !isUnknown(result, checkSubresult) : "Unknown result in "+task+": "+TestUtil.getErrorMessage(result); + if (verbose) { display("Check result", result); } + assert !isError(result, checkSubresult) : "Error in " + task + ": " + TestUtil.getErrorMessage(result); + assert !isUnknown(result, checkSubresult) : "Unknown result in " + task + ": " + TestUtil.getErrorMessage(result); return !isInProgress(result, checkSubresult); } + @Override public void timeout() { try { task.refresh(waitResult); } catch (ObjectNotFoundException e) { - LOGGER.error("Exception during task refresh: {}", e,e); + logger.error("Exception during task refresh: {}", e, e); } catch (SchemaException e) { - LOGGER.error("Exception during task refresh: {}", e,e); + logger.error("Exception during task refresh: {}", e, e); } OperationResult result = task.getResult(); - LOGGER.debug("Result of timed-out task:\n{}", result.debugDump()); - assert false : "Timeout ("+timeout+") while waiting for "+task+" to finish. Last result "+result; + logger.debug("Result of timed-out task:\n{}", result.debugDump()); + assert false : "Timeout (" + timeout + ") while waiting for " + task + " to finish. Last result " + result; } }; IntegrationTestTools.waitFor("Waiting for " + task + " finish", checker, timeout, sleepTime); @@ -3045,7 +2996,7 @@ protected void waitForTaskCloseOrSuspend(String taskOid, final int timeout) thro } protected void waitForTaskCloseOrSuspend(final String taskOid, final int timeout, long sleepTime) throws Exception { - final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForTaskCloseOrSuspend"); + final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class + ".waitForTaskCloseOrSuspend"); Checker checker = new Checker() { @Override public boolean check() throws CommonException { @@ -3055,20 +3006,21 @@ public boolean check() throws CommonException { return task.getExecutionStatus() == TaskExecutionStatus.CLOSED || task.getExecutionStatus() == TaskExecutionStatus.SUSPENDED; } + @Override public void timeout() { Task task = null; try { task = taskManager.getTaskWithResult(taskOid, waitResult); - } catch (ObjectNotFoundException|SchemaException e) { - LOGGER.error("Exception during task refresh: {}", e,e); + } catch (ObjectNotFoundException | SchemaException e) { + logger.error("Exception during task refresh: {}", e, e); } OperationResult result = null; if (task != null) { result = task.getResult(); - LOGGER.debug("Result of timed-out task:\n{}", result.debugDump()); + logger.debug("Result of timed-out task:\n{}", result.debugDump()); } - assert false : "Timeout ("+timeout+") while waiting for "+taskOid+" to close or suspend. Last result "+result; + assert false : "Timeout (" + timeout + ") while waiting for " + taskOid + " to close or suspend. Last result " + result; } }; IntegrationTestTools.waitFor("Waiting for " + taskOid + " close/suspend", checker, timeout, sleepTime); @@ -3097,7 +3049,7 @@ protected Task waitForTaskFinish(final String taskOid, final boolean checkSubres protected Task waitForTaskFinish(String taskOid, boolean checkSubresult, long startTime, int timeout, boolean errorOk, int showProgressEach, Function customizer) throws CommonException { long realStartTime = startTime != 0 ? startTime : System.currentTimeMillis(); - final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForTaskFinish"); + final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class + ".waitForTaskFinish"); TaskFinishChecker.Builder builder = new TaskFinishChecker.Builder() .taskManager(taskManager) .taskOid(taskOid) @@ -3219,28 +3171,29 @@ protected void waitForTaskStart(String taskOid, boolean checkSubresult) throws E } protected void waitForTaskStart(final String taskOid, final boolean checkSubresult, final int timeout) throws Exception { - final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForTaskStart"); + final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class + ".waitForTaskStart"); Checker checker = new Checker() { @Override public boolean check() throws CommonException { Task freshTask = taskManager.getTaskWithResult(taskOid, waitResult); OperationResult result = freshTask.getResult(); - if (verbose) display("Check result", result); - assert !isError(result, checkSubresult) : "Error in "+freshTask+": "+TestUtil.getErrorMessage(result); + if (verbose) { display("Check result", result); } + assert !isError(result, checkSubresult) : "Error in " + freshTask + ": " + TestUtil.getErrorMessage(result); if (isUnknown(result, checkSubresult)) { return false; } return freshTask.getLastRunStartTimestamp() != null; } + @Override public void timeout() { try { Task freshTask = taskManager.getTaskWithResult(taskOid, waitResult); OperationResult result = freshTask.getResult(); - LOGGER.debug("Result of timed-out task:\n{}", result.debugDump()); - assert false : "Timeout ("+timeout+") while waiting for "+freshTask+" to start. Last result "+result; + logger.debug("Result of timed-out task:\n{}", result.debugDump()); + assert false : "Timeout (" + timeout + ") while waiting for " + freshTask + " to start. Last result " + result; } catch (ObjectNotFoundException | SchemaException e) { - LOGGER.error("Exception during task refresh: {}", e, e); + logger.error("Exception during task refresh: {}", e, e); } } }; @@ -3248,7 +3201,7 @@ public void timeout() { } protected void waitForTaskNextStart(String taskOid, boolean checkSubresult, int timeout, boolean kickTheTask) throws Exception { - OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForTaskNextStart"); + OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class + ".waitForTaskNextStart"); Task origTask = taskManager.getTaskWithResult(taskOid, waitResult); Long origLastRunStartTimestamp = origTask.getLastRunStartTimestamp(); if (kickTheTask) { @@ -3259,20 +3212,21 @@ protected void waitForTaskNextStart(String taskOid, boolean checkSubresult, int public boolean check() throws CommonException { Task freshTask = taskManager.getTaskWithResult(taskOid, waitResult); OperationResult result = freshTask.getResult(); - if (verbose) display("Check result", result); - assert !isError(result, checkSubresult) : "Error in "+freshTask+": "+TestUtil.getErrorMessage(result); + if (verbose) { display("Check result", result); } + assert !isError(result, checkSubresult) : "Error in " + freshTask + ": " + TestUtil.getErrorMessage(result); return !isUnknown(result, checkSubresult) && !java.util.Objects.equals(freshTask.getLastRunStartTimestamp(), origLastRunStartTimestamp); } + @Override public void timeout() { try { Task freshTask = taskManager.getTaskWithResult(taskOid, waitResult); OperationResult result = freshTask.getResult(); - LOGGER.debug("Result of timed-out task:\n{}", result.debugDump()); - assert false : "Timeout ("+timeout+") while waiting for "+freshTask+" to start. Last result "+result; + logger.debug("Result of timed-out task:\n{}", result.debugDump()); + assert false : "Timeout (" + timeout + ") while waiting for " + freshTask + " to start. Last result " + result; } catch (ObjectNotFoundException | SchemaException e) { - LOGGER.error("Exception during task refresh: {}", e, e); + logger.error("Exception during task refresh: {}", e, e); } } }; @@ -3290,7 +3244,7 @@ protected OperationResult waitForTaskNextRunAssertSuccess(Task origTask, boolean protected OperationResult waitForTaskNextRunAssertSuccess(final String taskOid, final boolean checkSubresult, final int timeout) throws Exception { OperationResult taskResult = waitForTaskNextRun(taskOid, checkSubresult, timeout); if (isError(taskResult, checkSubresult)) { - assert false : "Error in task "+taskOid+": "+TestUtil.getErrorMessage(taskResult)+"\n\n"+taskResult.debugDump(); + assert false : "Error in task " + taskOid + ": " + TestUtil.getErrorMessage(taskResult) + "\n\n" + taskResult.debugDump(); } return taskResult; } @@ -3298,7 +3252,7 @@ protected OperationResult waitForTaskNextRunAssertSuccess(final String taskOid, protected OperationResult waitForTaskNextRunAssertSuccess(Task origTask, final boolean checkSubresult, final int timeout) throws Exception { OperationResult taskResult = waitForTaskNextRun(origTask, checkSubresult, timeout); if (isError(taskResult, checkSubresult)) { - assert false : "Error in task "+origTask+": "+TestUtil.getErrorMessage(taskResult)+"\n\n"+taskResult.debugDump(); + assert false : "Error in task " + origTask + ": " + TestUtil.getErrorMessage(taskResult) + "\n\n" + taskResult.debugDump(); } return taskResult; } @@ -3312,7 +3266,7 @@ protected OperationResult waitForTaskNextRun(final String taskOid, final boolean } protected OperationResult waitForTaskNextRun(final String taskOid, final boolean checkSubresult, final int timeout, boolean kickTheTask) throws Exception { - final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForTaskNextRun"); + final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class + ".waitForTaskNextRun"); Task origTask = taskManager.getTaskWithResult(taskOid, waitResult); return waitForTaskNextRun(origTask, checkSubresult, timeout, waitResult, kickTheTask); } @@ -3322,7 +3276,7 @@ protected OperationResult waitForTaskNextRun(final Task origTask, final boolean } protected OperationResult waitForTaskNextRun(final Task origTask, final boolean checkSubresult, final int timeout, boolean kickTheTask) throws Exception { - final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForTaskNextRun"); + final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class + ".waitForTaskNextRun"); return waitForTaskNextRun(origTask, checkSubresult, timeout, waitResult, kickTheTask); } @@ -3340,7 +3294,7 @@ public boolean check() throws CommonException { OperationResult taskResult = freshTask.getResult(); // display("Times", longTimeToString(origLastRunStartTimestamp) + "-" + longTimeToString(origLastRunStartTimestamp) // + " : " + longTimeToString(freshTask.getLastRunStartTimestamp()) + "-" + longTimeToString(freshTask.getLastRunFinishTimestamp())); - if (verbose) display("Check result", taskResult); + if (verbose) { display("Check result", taskResult); } taskResultHolder.setValue(taskResult); if (isError(taskResult, checkSubresult)) { return true; @@ -3358,36 +3312,37 @@ public boolean check() throws CommonException { && !freshTask.getLastRunFinishTimestamp().equals(origLastRunFinishTimestamp) && freshTask.getLastRunStartTimestamp() < freshTask.getLastRunFinishTimestamp(); } + @Override public void timeout() { try { Task freshTask = taskManager.getTaskWithResult(origTask.getOid(), waitResult); OperationResult result = freshTask.getResult(); - LOGGER.debug("Timed-out task:\n{}", freshTask.debugDump()); - display("Times", "origLastRunStartTimestamp="+longTimeToString(origLastRunStartTimestamp) - + ", origLastRunFinishTimestamp=" + longTimeToString(origLastRunFinishTimestamp) - + ", freshTask.getLastRunStartTimestamp()=" + longTimeToString(freshTask.getLastRunStartTimestamp()) - + ", freshTask.getLastRunFinishTimestamp()=" + longTimeToString(freshTask.getLastRunFinishTimestamp())); - assert false : "Timeout ("+timeout+") while waiting for "+freshTask+" next run. Last result "+result; + logger.debug("Timed-out task:\n{}", freshTask.debugDump()); + display("Times", "origLastRunStartTimestamp=" + longTimeToString(origLastRunStartTimestamp) + + ", origLastRunFinishTimestamp=" + longTimeToString(origLastRunFinishTimestamp) + + ", freshTask.getLastRunStartTimestamp()=" + longTimeToString(freshTask.getLastRunStartTimestamp()) + + ", freshTask.getLastRunFinishTimestamp()=" + longTimeToString(freshTask.getLastRunFinishTimestamp())); + assert false : "Timeout (" + timeout + ") while waiting for " + freshTask + " next run. Last result " + result; } catch (ObjectNotFoundException | SchemaException e) { - LOGGER.error("Exception during task refresh: {}", e, e); + logger.error("Exception during task refresh: {}", e, e); } } }; IntegrationTestTools.waitFor("Waiting for task " + origTask + " next run", checker, timeout, DEFAULT_TASK_SLEEP_TIME); Task freshTask = taskManager.getTaskWithResult(origTask.getOid(), waitResult); - LOGGER.debug("Final task:\n{}", freshTask.debugDump()); - display("Times", "origLastRunStartTimestamp="+longTimeToString(origLastRunStartTimestamp) - + ", origLastRunFinishTimestamp=" + longTimeToString(origLastRunFinishTimestamp) - + ", freshTask.getLastRunStartTimestamp()=" + longTimeToString(freshTask.getLastRunStartTimestamp()) - + ", freshTask.getLastRunFinishTimestamp()=" + longTimeToString(freshTask.getLastRunFinishTimestamp())); + logger.debug("Final task:\n{}", freshTask.debugDump()); + display("Times", "origLastRunStartTimestamp=" + longTimeToString(origLastRunStartTimestamp) + + ", origLastRunFinishTimestamp=" + longTimeToString(origLastRunFinishTimestamp) + + ", freshTask.getLastRunStartTimestamp()=" + longTimeToString(freshTask.getLastRunStartTimestamp()) + + ", freshTask.getLastRunFinishTimestamp()=" + longTimeToString(freshTask.getLastRunFinishTimestamp())); return taskResultHolder.getValue(); } protected OperationResult waitForTaskTreeNextFinishedRun(String rootTaskOid, int timeout) throws Exception { - final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForTaskTreeNextFinishedRun"); + final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class + ".waitForTaskTreeNextFinishedRun"); Task origRootTask = taskManager.getTaskWithResult(rootTaskOid, waitResult); return waitForTaskTreeNextFinishedRun(origRootTask, timeout, waitResult); } @@ -3427,7 +3382,7 @@ protected OperationResult waitForTaskTreeNextFinishedRun(Task origRootTask, int try { subtask.refresh(waitResult); // quick hack to get operation results } catch (ObjectNotFoundException e) { - LOGGER.warn("Task {} does not exist any more", subtask); + logger.warn("Task {} does not exist any more", subtask); } } Task failedTask = null; @@ -3471,7 +3426,7 @@ protected OperationResult waitForTaskTreeNextFinishedRun(Task origRootTask, int IntegrationTestTools.waitFor("Waiting for task tree " + origRootTask + " next finished run", checker, timeout, DEFAULT_TASK_SLEEP_TIME); Task freshTask = taskManager.getTaskWithResult(origRootTask.getOid(), waitResult); - LOGGER.debug("Final root task:\n{}", freshTask.debugDump()); + logger.debug("Final root task:\n{}", freshTask.debugDump()); aggregateResult.computeStatusIfUnknown(); return aggregateResult; } @@ -3481,14 +3436,15 @@ public void waitForCaseClose(CaseType aCase) throws Exception { } public void waitForCaseClose(CaseType aCase, final int timeout) throws Exception { - final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForCaseClose"); + final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class + ".waitForCaseClose"); Checker checker = new Checker() { @Override public boolean check() throws CommonException { CaseType currentCase = repositoryService.getObject(CaseType.class, aCase.getOid(), null, waitResult).asObjectable(); - if (verbose) AbstractIntegrationTest.display("Case", currentCase); + if (verbose) { AbstractIntegrationTest.display("Case", currentCase); } return SchemaConstants.CASE_STATE_CLOSED.equals(currentCase.getState()); } + @Override public void timeout() { PrismObject currentCase; @@ -3497,14 +3453,13 @@ public void timeout() { } catch (ObjectNotFoundException | SchemaException e) { throw new AssertionError("Couldn't retrieve case " + aCase, e); } - LOGGER.debug("Timed-out case:\n{}", currentCase.debugDump()); - assert false : "Timeout ("+timeout+") while waiting for "+currentCase+" to finish"; + logger.debug("Timed-out case:\n{}", currentCase.debugDump()); + assert false : "Timeout (" + timeout + ") while waiting for " + currentCase + " to finish"; } }; - IntegrationTestTools.waitFor("Waiting for "+aCase+" finish", checker, timeout, 1000); + IntegrationTestTools.waitFor("Waiting for " + aCase + " finish", checker, timeout, 1000); } - private String longTimeToString(Long longTime) { if (longTime == null) { return "null"; @@ -3535,7 +3490,7 @@ private static OperationResult getSubresult(OperationResult result, boolean chec } protected OperationResult waitForTaskResume(final String taskOid, final boolean checkSubresult, final int timeout) throws Exception { - final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForTaskResume"); + final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class + ".waitForTaskResume"); Task origTask = taskManager.getTaskWithResult(taskOid, waitResult); final Long origLastRunStartTimestamp = origTask.getLastRunStartTimestamp(); @@ -3549,9 +3504,7 @@ protected OperationResult waitForTaskResume(final String taskOid, final boolean public boolean check() throws CommonException { Task freshTask = taskManager.getTaskWithResult(origTask.getOid(), waitResult); OperationResult taskResult = freshTask.getResult(); -// display("Times", longTimeToString(origLastRunStartTimestamp) + "-" + longTimeToString(origLastRunStartTimestamp) -// + " : " + longTimeToString(freshTask.getLastRunStartTimestamp()) + "-" + longTimeToString(freshTask.getLastRunFinishTimestamp())); - if (verbose) display("Check result", taskResult); + if (verbose) { display("Check result", taskResult); } taskResultHolder.setValue(taskResult); if (isError(taskResult, checkSubresult)) { return true; @@ -3569,30 +3522,31 @@ public boolean check() throws CommonException { && !freshTask.getLastRunFinishTimestamp().equals(origLastRunFinishTimestamp) && freshTask.getLastRunStartTimestamp() < freshTask.getLastRunFinishTimestamp(); } + @Override public void timeout() { try { Task freshTask = taskManager.getTaskWithResult(origTask.getOid(), waitResult); OperationResult result = freshTask.getResult(); - LOGGER.debug("Timed-out task:\n{}", freshTask.debugDump()); - display("Times", "origLastRunStartTimestamp="+longTimeToString(origLastRunStartTimestamp) - + ", origLastRunFinishTimestamp=" + longTimeToString(origLastRunFinishTimestamp) - + ", freshTask.getLastRunStartTimestamp()=" + longTimeToString(freshTask.getLastRunStartTimestamp()) - + ", freshTask.getLastRunFinishTimestamp()=" + longTimeToString(freshTask.getLastRunFinishTimestamp())); - assert false : "Timeout ("+timeout+") while waiting for "+freshTask+" next run. Last result "+result; + logger.debug("Timed-out task:\n{}", freshTask.debugDump()); + display("Times", "origLastRunStartTimestamp=" + longTimeToString(origLastRunStartTimestamp) + + ", origLastRunFinishTimestamp=" + longTimeToString(origLastRunFinishTimestamp) + + ", freshTask.getLastRunStartTimestamp()=" + longTimeToString(freshTask.getLastRunStartTimestamp()) + + ", freshTask.getLastRunFinishTimestamp()=" + longTimeToString(freshTask.getLastRunFinishTimestamp())); + assert false : "Timeout (" + timeout + ") while waiting for " + freshTask + " next run. Last result " + result; } catch (ObjectNotFoundException | SchemaException e) { - LOGGER.error("Exception during task refresh: {}", e, e); + logger.error("Exception during task refresh: {}", e, e); } } }; IntegrationTestTools.waitFor("Waiting for task " + origTask + " resume", checker, timeout, DEFAULT_TASK_SLEEP_TIME); Task freshTask = taskManager.getTaskWithResult(origTask.getOid(), waitResult); - LOGGER.debug("Final task:\n{}", freshTask.debugDump()); - display("Times", "origLastRunStartTimestamp="+longTimeToString(origLastRunStartTimestamp) - + ", origLastRunFinishTimestamp=" + longTimeToString(origLastRunFinishTimestamp) - + ", freshTask.getLastRunStartTimestamp()=" + longTimeToString(freshTask.getLastRunStartTimestamp()) - + ", freshTask.getLastRunFinishTimestamp()=" + longTimeToString(freshTask.getLastRunFinishTimestamp())); + logger.debug("Final task:\n{}", freshTask.debugDump()); + display("Times", "origLastRunStartTimestamp=" + longTimeToString(origLastRunStartTimestamp) + + ", origLastRunFinishTimestamp=" + longTimeToString(origLastRunFinishTimestamp) + + ", freshTask.getLastRunStartTimestamp()=" + longTimeToString(freshTask.getLastRunStartTimestamp()) + + ", freshTask.getLastRunFinishTimestamp()=" + longTimeToString(freshTask.getLastRunFinishTimestamp())); return taskResultHolder.getValue(); } @@ -3606,26 +3560,26 @@ protected void restartTask(String taskOid) throws CommonException { try { Thread.sleep(1); } catch (InterruptedException e) { - LOGGER.warn("Sleep interrupted: {}", e.getMessage(), e); + logger.warn("Sleep interrupted: {}", e.getMessage(), e); } OperationResult result = createSubresult("restartTask"); try { Task task = taskManager.getTaskWithResult(taskOid, result); - LOGGER.info("Restarting task {}", taskOid); + logger.info("Restarting task {}", taskOid); if (task.getExecutionStatus() == TaskExecutionStatus.SUSPENDED) { - LOGGER.debug("Task {} is suspended, resuming it", task); + logger.debug("Task {} is suspended, resuming it", task); taskManager.resumeTask(task, result); } else if (task.getExecutionStatus() == TaskExecutionStatus.CLOSED) { - LOGGER.debug("Task {} is closed, scheduling it to run now", task); + logger.debug("Task {} is closed, scheduling it to run now", task); taskManager.scheduleTasksNow(singleton(taskOid), result); } else if (task.getExecutionStatus() == TaskExecutionStatus.RUNNABLE) { if (taskManager.getLocallyRunningTaskByIdentifier(task.getTaskIdentifier()) != null) { // Task is really executing. Let's wait until it finishes; hopefully it won't start again (TODO) - LOGGER.debug("Task {} is running, waiting while it finishes before restarting", task); + logger.debug("Task {} is running, waiting while it finishes before restarting", task); waitForTaskFinish(taskOid, false); } - LOGGER.debug("Task {} is finished, scheduling it to run now", task); + logger.debug("Task {} is finished, scheduling it to run now", task); taskManager.scheduleTasksNow(singleton(taskOid), result); } else { throw new IllegalStateException( @@ -3644,9 +3598,9 @@ protected boolean suspendTask(String taskOid) throws CommonException { } protected boolean suspendTask(String taskOid, int waitTime) throws CommonException { - final OperationResult result = new OperationResult(AbstractIntegrationTest.class+".suspendTask"); + final OperationResult result = new OperationResult(AbstractIntegrationTest.class + ".suspendTask"); Task task = taskManager.getTaskWithResult(taskOid, result); - LOGGER.info("Suspending task {}", taskOid); + logger.info("Suspending task {}", taskOid); return taskManager.suspendTaskQuietly(task, waitTime, result); } @@ -3660,13 +3614,15 @@ protected void rerunTask(String taskOid) throws CommonException { } protected void assertTaskExecutionStatus(String taskOid, TaskExecutionStatus expectedExecutionStatus) throws ObjectNotFoundException, SchemaException { - final OperationResult result = new OperationResult(AbstractIntegrationTest.class+".assertTaskExecutionStatus"); - Task task = taskManager.getTask(taskOid, result); - assertEquals("Wrong executionStatus in "+task, expectedExecutionStatus, task.getExecutionStatus()); + final OperationResult result = new OperationResult(AbstractIntegrationTest.class + ".assertTaskExecutionStatus"); + Task task = taskManager.getTask(taskOid, result); + assertEquals("Wrong executionStatus in " + task, expectedExecutionStatus, task.getExecutionStatus()); } - protected void setSecurityContextUser(String userOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance("get administrator"); + protected void setSecurityContextUser(String userOid) + throws ObjectNotFoundException, SchemaException, SecurityViolationException, + CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = createTask("setSecurityContextUser"); PrismObject object = modelService.getObject(UserType.class, userOid, null, task, task.getResult()); assertNotNull("User " + userOid + " is null", object.asObjectable()); @@ -3685,7 +3641,7 @@ protected void assertSideEffectiveDeltasOnly(String desc, } int expectedModifications = 0; // There may be metadata modification, we tolerate that - for (ItemDelta modification: focusDelta.getModifications()) { + for (ItemDelta modification : focusDelta.getModifications()) { if (isSideEffectDelta(modification)) { expectedModifications++; } @@ -3728,7 +3684,7 @@ protected void assertEffectualDeltas(ObjectDelta focusD } int expectedModifications = expectedEffectualModifications; // There may be metadata modification, we tolerate that - for (ItemDelta modification: focusDelta.getModifications()) { + for (ItemDelta modification : focusDelta.getModifications()) { if (isSideEffectDelta(modification)) { expectedModifications++; } @@ -3759,7 +3715,7 @@ protected void assertEffectualDeltas(ObjectDelta focusD if (focusDelta.findItemDelta(FocusType.F_ITERATION_TOKEN) != null) { expectedModifications++; } - assertEquals("Unexpected modifications in "+desc+": "+focusDelta, expectedModifications, focusDelta.getModifications().size()); + assertEquals("Unexpected modifications in " + desc + ": " + focusDelta, expectedModifications, focusDelta.getModifications().size()); } private boolean isSideEffectDelta(ItemDelta modification) { @@ -3767,7 +3723,7 @@ private boolean isSideEffectDelta(ItemDelta modification) { (modification.getPath().containsNameExactly(FocusType.F_ASSIGNMENT) && modification.getPath().containsNameExactly(ActivationType.F_EFFECTIVE_STATUS))) { return true; } else if (modification.getPath().containsNameExactly(FocusType.F_ASSIGNMENT) && modification.getPath().containsNameExactly(AssignmentType.F_ACTIVATION) && modification.isReplace() && (modification instanceof ContainerDelta)) { - Collection> valuesToReplace = ((ContainerDelta)modification).getValuesToReplace(); + Collection> valuesToReplace = ((ContainerDelta) modification).getValuesToReplace(); if (valuesToReplace != null && valuesToReplace.size() == 1) { PrismContainerValue cval = valuesToReplace.iterator().next(); if (cval.size() == 1) { @@ -3780,12 +3736,12 @@ private boolean isSideEffectDelta(ItemDelta modification) { } protected void assertValidFrom(PrismObject obj, Date expectedDate) { - assertEquals("Wrong validFrom in "+obj, XmlTypeConverter.createXMLGregorianCalendar(expectedDate), + assertEquals("Wrong validFrom in " + obj, XmlTypeConverter.createXMLGregorianCalendar(expectedDate), getActivation(obj).getValidFrom()); } protected void assertValidTo(PrismObject obj, Date expectedDate) { - assertEquals("Wrong validTo in "+obj, XmlTypeConverter.createXMLGregorianCalendar(expectedDate), + assertEquals("Wrong validTo in " + obj, XmlTypeConverter.createXMLGregorianCalendar(expectedDate), getActivation(obj).getValidTo()); } @@ -3793,18 +3749,20 @@ protected ActivationType getActivation(PrismObject obj) { ObjectType objectType = obj.asObjectable(); ActivationType activation; if (objectType instanceof ShadowType) { - activation = ((ShadowType)objectType).getActivation(); + activation = ((ShadowType) objectType).getActivation(); } else if (objectType instanceof UserType) { - activation = ((UserType)objectType).getActivation(); + activation = ((UserType) objectType).getActivation(); } else { - throw new IllegalArgumentException("Cannot get activation from "+obj); + throw new IllegalArgumentException("Cannot get activation from " + obj); } assertNotNull("No activation in " + obj, activation); return activation; } - protected PrismObject getTask(String taskOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".getTask"); + protected PrismObject getTask(String taskOid) + throws ObjectNotFoundException, SchemaException, SecurityViolationException, + CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = createTask("getTask"); OperationResult result = task.getResult(); PrismObject retTask = modelService.getObject(TaskType.class, taskOid, retrieveItemsNamed(TaskType.F_RESULT), task, result); result.computeStatus(); @@ -3813,7 +3771,7 @@ protected PrismObject getTask(String taskOid) throws ObjectNotFoundExc } protected PrismObject getTaskTree(String taskOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".getTask"); + Task task = createTask("getTaskTree"); OperationResult result = task.getResult(); PrismObject retTask = modelService.getObject(TaskType.class, taskOid, retrieveItemsNamed(TaskType.F_RESULT, TaskType.F_SUBTASK), task, result); result.computeStatus(); @@ -3848,8 +3806,10 @@ protected void assertObjectDoesntExist(Class clazz, St } } - protected PrismObject getObject(Class type, String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".getObject"); + protected PrismObject getObject(Class type, String oid) + throws ObjectNotFoundException, SchemaException, SecurityViolationException, + CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = createTask("getObject"); OperationResult result = task.getResult(); PrismObject object = modelService.getObject(type, oid, null, task, result); result.computeStatus(); @@ -3857,8 +3817,9 @@ protected PrismObject getObject(Class type, String return object; } - protected PrismObject getObjectViaRepo(Class type, String oid) throws ObjectNotFoundException, SchemaException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".getObject"); + protected PrismObject getObjectViaRepo(Class type, String oid) + throws ObjectNotFoundException, SchemaException { + Task task = createTask("getObjectViaRepo"); OperationResult result = task.getResult(); PrismObject object = repositoryService.getObject(type, oid, null, result); result.computeStatus(); @@ -3909,8 +3870,11 @@ protected PrismObject addObject(File file, Task task, return object; } - protected String addObject(PrismObject object) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".addObject"); + protected String addObject(PrismObject object) + throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, + ExpressionEvaluationException, CommunicationException, ConfigurationException, + PolicyViolationException, SecurityViolationException { + Task task = createTask("addObject"); OperationResult result = task.getResult(); String oid = addObject(object, task, result); result.computeStatus(); @@ -3924,7 +3888,7 @@ protected String addObject(PrismObject object, Task ta protected String addObject(PrismObject object, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { ObjectDelta addDelta = object.createAddDelta(); - assertFalse("Immutable object provided?",addDelta.getObjectToAdd().isImmutable()); + assertFalse("Immutable object provided?", addDelta.getObjectToAdd().isImmutable()); Collection> executedDeltas = executeChanges(addDelta, options, task, result); object.setOid(ObjectDeltaOperation.findAddDeltaOid(executedDeltas, object)); return object.getOid(); @@ -3940,9 +3904,11 @@ protected void deleteObjectRaw(Class type, String oid, executeChanges(delta, ModelExecuteOptions.createRaw(), task, result); } - protected void deleteObject(Class type, String oid) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - AbstractModelIntegrationTest.class.getName(); - Task task = getTestTask(); + protected void deleteObject(Class type, String oid) + throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, + ExpressionEvaluationException, CommunicationException, ConfigurationException, + PolicyViolationException, SecurityViolationException { + Task task = createTask("deleteObject"); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object().createDeleteDelta(type, oid); executeChanges(delta, null, task, result); @@ -3950,33 +3916,38 @@ protected void deleteObject(Class type, String oid) th TestUtil.assertSuccess(result); } - protected void deleteObjectRepo(Class type, String oid) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - OperationResult result = new OperationResult(AbstractModelIntegrationTest.class.getName() + ".deleteObjectRepo"); + protected void deleteObjectRepo(Class type, String oid) throws ObjectNotFoundException { + OperationResult result = new OperationResult(contextName() + "deleteObjectRepo"); repositoryService.deleteObject(type, oid, result); result.computeStatus(); TestUtil.assertSuccess(result); } - protected void forceDeleteShadow(String oid) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - AbstractModelIntegrationTest.class.getName(); - Task task = getTestTask(); + protected void forceDeleteShadow(String oid) + throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, + ExpressionEvaluationException, CommunicationException, ConfigurationException, + PolicyViolationException, SecurityViolationException { + Task task = createTask("forceDeleteShadow"); OperationResult result = task.getResult(); forceDeleteObject(ShadowType.class, oid, task, result); assertSuccess(result); } - protected void forceDeleteShadow(String oid, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - forceDeleteObject(ShadowType.class, oid, task, result); - } - - protected void forceDeleteObject(Class type, String oid, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + protected void forceDeleteObject( + Class type, String oid, Task task, OperationResult result) + throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, + ExpressionEvaluationException, CommunicationException, ConfigurationException, + PolicyViolationException, SecurityViolationException { ObjectDelta delta = prismContext.deltaFactory().object().createDeleteDelta(type, oid); ModelExecuteOptions options = ModelExecuteOptions.createForce(); executeChanges(delta, options, task, result); } - protected void addTrigger(String oid, XMLGregorianCalendar timestamp, String uri) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".addTrigger"); + protected void addTrigger(String oid, XMLGregorianCalendar timestamp, String uri) + throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, + ExpressionEvaluationException, CommunicationException, ConfigurationException, + PolicyViolationException, SecurityViolationException { + Task task = createTask("addTrigger"); OperationResult result = task.getResult(); TriggerType triggerType = new TriggerType(); triggerType.setTimestamp(timestamp); @@ -3990,15 +3961,15 @@ protected void addTrigger(String oid, XMLGregorianCalendar timestamp, String uri } protected void addTriggers(String oid, Collection timestamps, String uri, boolean makeDistinct) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".addTriggers"); + Task task = createTask("addTriggers"); OperationResult result = task.getResult(); Collection triggers = timestamps.stream() .map(ts -> new TriggerType().timestamp(ts).handlerUri(uri)) .map(ts -> makeDistinct ? addRandomValue(ts) : ts) .collect(Collectors.toList()); ObjectDelta delta = prismContext.deltaFor(ObjectType.class) - .item(ObjectType.F_TRIGGER).addRealValues(triggers) - .asObjectDeltaCast(oid); + .item(ObjectType.F_TRIGGER).addRealValues(triggers) + .asObjectDeltaCast(oid); executeChanges(delta, null, task, result); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4020,21 +3991,22 @@ private TriggerType addRandomValue(TriggerType trigger) { } protected void replaceTriggers(String oid, Collection timestamps, String uri) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".replaceTriggers"); + Task task = createTask("replaceTriggers"); OperationResult result = task.getResult(); Collection triggers = timestamps.stream() .map(ts -> new TriggerType().timestamp(ts).handlerUri(uri)) .collect(Collectors.toList()); ObjectDelta delta = prismContext.deltaFor(ObjectType.class) - .item(ObjectType.F_TRIGGER).replaceRealValues(triggers) - .asObjectDeltaCast(oid); + .item(ObjectType.F_TRIGGER).replaceRealValues(triggers) + .asObjectDeltaCast(oid); executeChanges(delta, null, task, result); result.computeStatus(); TestUtil.assertSuccess(result); } - protected void assertTrigger(PrismObject object, String handlerUri, XMLGregorianCalendar start, XMLGregorianCalendar end) throws ObjectNotFoundException, SchemaException { - for (TriggerType trigger: object.asObjectable().getTrigger()) { + protected void assertTrigger(PrismObject object, + String handlerUri, XMLGregorianCalendar start, XMLGregorianCalendar end) { + for (TriggerType trigger : object.asObjectable().getTrigger()) { if (handlerUri.equals(trigger.getHandlerUri()) && MiscUtil.isBetween(trigger.getTimestamp(), start, end)) { return; @@ -4043,30 +4015,32 @@ protected void assertTrigger(PrismObject object, Strin AssertJUnit.fail("Expected that " + object + " will have a trigger but it has not"); } - protected void assertTrigger(PrismObject object, String handlerUri, XMLGregorianCalendar mid, long tolerance) throws ObjectNotFoundException, SchemaException { + protected void assertTrigger( + PrismObject object, String handlerUri, XMLGregorianCalendar mid, long tolerance) { XMLGregorianCalendar start = XmlTypeConverter.addMillis(mid, -tolerance); XMLGregorianCalendar end = XmlTypeConverter.addMillis(mid, tolerance); - for (TriggerType trigger: object.asObjectable().getTrigger()) { + for (TriggerType trigger : object.asObjectable().getTrigger()) { if (handlerUri.equals(trigger.getHandlerUri()) && MiscUtil.isBetween(trigger.getTimestamp(), start, end)) { return; } } - AssertJUnit.fail("Expected that "+object+" will have a trigger but it has not"); + AssertJUnit.fail("Expected that " + object + " will have a trigger but it has not"); } - protected void assertNoTrigger(Class type, String oid) throws ObjectNotFoundException, SchemaException { - OperationResult result = new OperationResult(AbstractModelIntegrationTest.class.getName() + ".assertNoTrigger"); + protected void assertNoTrigger(Class type, String oid) + throws ObjectNotFoundException, SchemaException { + OperationResult result = new OperationResult(contextName() + "assertNoTrigger"); PrismObject object = repositoryService.getObject(type, oid, null, result); result.computeStatus(); TestUtil.assertSuccess(result); assertNoTrigger(object); } - protected void assertNoTrigger(PrismObject object) throws ObjectNotFoundException, SchemaException { + protected void assertNoTrigger(PrismObject object) { List triggers = object.asObjectable().getTrigger(); if (triggers != null && !triggers.isEmpty()) { - AssertJUnit.fail("Expected that "+object+" will have no triggers but it has "+triggers.size()+ " trigger: "+ triggers); + AssertJUnit.fail("Expected that " + object + " will have no triggers but it has " + triggers.size() + " trigger: " + triggers); } } @@ -4079,7 +4053,7 @@ protected void checkDummyTransportMessages(String name, int expectedCount) { List messages = dummyTransport.getMessages("dummy:" + name); if (expectedCount == 0) { if (messages != null && !messages.isEmpty()) { - LOGGER.error(messages.size() + " unexpected message(s) recorded in dummy transport '" + name + "'"); + logger.error(messages.size() + " unexpected message(s) recorded in dummy transport '" + name + "'"); logNotifyMessages(messages); printNotifyMessages(messages); fail(messages.size() + " unexpected message(s) recorded in dummy transport '" + name + "'"); @@ -4087,7 +4061,7 @@ protected void checkDummyTransportMessages(String name, int expectedCount) { } else { assertNotNull("No messages recorded in dummy transport '" + name + "'", messages); if (expectedCount != messages.size()) { - LOGGER.error("Invalid number of messages recorded in dummy transport '" + name + "', expected: "+expectedCount+", actual: "+messages.size()); + logger.error("Invalid number of messages recorded in dummy transport '" + name + "', expected: " + expectedCount + ", actual: " + messages.size()); logNotifyMessages(messages); printNotifyMessages(messages); assertEquals("Invalid number of messages recorded in dummy transport '" + name + "'", expectedCount, messages.size()); @@ -4099,20 +4073,20 @@ protected void assertSingleDummyTransportMessage(String name, String expectedBod List messages = dummyTransport.getMessages("dummy:" + name); assertNotNull("No messages recorded in dummy transport '" + name + "'", messages); if (messages.size() != 1) { - fail("Invalid number of messages recorded in dummy transport '" + name + "', expected: 1, actual: "+messages.size()); + fail("Invalid number of messages recorded in dummy transport '" + name + "', expected: 1, actual: " + messages.size()); } Message message = messages.get(0); - assertEquals("Unexpected notifier "+name+" message body", expectedBody, message.getBody()); + assertEquals("Unexpected notifier " + name + " message body", expectedBody, message.getBody()); } protected void assertSingleDummyTransportMessageContaining(String name, String expectedSubstring) { List messages = dummyTransport.getMessages("dummy:" + name); assertNotNull("No messages recorded in dummy transport '" + name + "'", messages); if (messages.size() != 1) { - fail("Invalid number of messages recorded in dummy transport '" + name + "', expected: 1, actual: "+messages.size()); + fail("Invalid number of messages recorded in dummy transport '" + name + "', expected: 1, actual: " + messages.size()); } Message message = messages.get(0); - assertTrue("Notifier "+name+" message body does not contain text: " + expectedSubstring + ", it is:\n" + message.getBody(), + assertTrue("Notifier " + name + " message body does not contain text: " + expectedSubstring + ", it is:\n" + message.getBody(), message.getBody().contains(expectedSubstring)); } @@ -4125,36 +4099,36 @@ protected String getDummyTransportMessageBody(String name, int index) { protected void assertHasDummyTransportMessage(String name, String expectedBody) { List messages = dummyTransport.getMessages("dummy:" + name); assertNotNull("No messages recorded in dummy transport '" + name + "'", messages); - for (Message message: messages) { + for (Message message : messages) { if (expectedBody.equals(message.getBody())) { return; } } - fail("Notifier "+name+" message body " + expectedBody + " not found"); + fail("Notifier " + name + " message body " + expectedBody + " not found"); } protected void displayAllNotifications() { - for (java.util.Map.Entry> entry: dummyTransport.getMessages().entrySet()) { + for (java.util.Map.Entry> entry : dummyTransport.getMessages().entrySet()) { List messages = entry.getValue(); if (messages != null && !messages.isEmpty()) { - display("Notification messages: "+entry.getKey(), messages); + display("Notification messages: " + entry.getKey(), messages); } } } protected void displayNotifications(String name) { List messages = dummyTransport.getMessages("dummy:" + name); - display("Notification messages: "+name, messages); + display("Notification messages: " + name, messages); } private void logNotifyMessages(List messages) { - for (Message message: messages) { - LOGGER.debug("Notification message:\n{}", message.getBody()); + for (Message message : messages) { + logger.debug("Notification message:\n{}", message.getBody()); } } private void printNotifyMessages(List messages) { - for (Message message: messages) { + for (Message message : messages) { System.out.println(message); } } @@ -4173,9 +4147,9 @@ protected DummyAccount getDummyAccount(String dummyInstanceName, String username try { return dummyResource.getAccountByUsername(username); } catch (ConnectException e) { - throw new IllegalStateException(e.getMessage(),e); + throw new IllegalStateException(e.getMessage(), e); } catch (FileNotFoundException e) { - throw new IllegalStateException(e.getMessage(),e); + throw new IllegalStateException(e.getMessage(), e); } } @@ -4184,9 +4158,9 @@ protected DummyAccount getDummyAccountById(String dummyInstanceName, String id) try { return dummyResource.getAccountById(id); } catch (ConnectException e) { - throw new IllegalStateException(e.getMessage(),e); + throw new IllegalStateException(e.getMessage(), e); } catch (FileNotFoundException e) { - throw new IllegalStateException(e.getMessage(),e); + throw new IllegalStateException(e.getMessage(), e); } } @@ -4197,8 +4171,8 @@ protected DummyAccount assertDefaultDummyAccount(String username, String fullnam protected DummyAccount assertDummyAccount(String dummyInstanceName, String username, String fullname, Boolean active) throws SchemaViolationException, ConflictException, InterruptedException { DummyAccount account = getDummyAccount(dummyInstanceName, username); // display("account", account); - assertNotNull("No dummy("+dummyInstanceName+") account for username "+username, account); - assertEquals("Wrong fullname for dummy("+dummyInstanceName+") account "+username, fullname, account.getAttributeValue("fullname")); + assertNotNull("No dummy(" + dummyInstanceName + ") account for username " + username, account); + assertEquals("Wrong fullname for dummy(" + dummyInstanceName + ") account " + username, fullname, account.getAttributeValue("fullname")); assertEquals("Wrong activation for dummy(" + dummyInstanceName + ") account " + username, active, account.isEnabled()); return account; } @@ -4220,7 +4194,7 @@ protected void assertNoDummyAccountById(String dummyInstanceName, String id) thr protected void assertDummyAccountActivation(String dummyInstanceName, String username, Boolean active) throws SchemaViolationException, ConflictException, InterruptedException { DummyAccount account = getDummyAccount(dummyInstanceName, username); - assertNotNull("No dummy("+dummyInstanceName+") account for username "+username, account); + assertNotNull("No dummy(" + dummyInstanceName + ") account for username " + username, account); assertEquals("Wrong activation for dummy(" + dummyInstanceName + ") account " + username, active, account.isEnabled()); } @@ -4239,37 +4213,37 @@ protected void assertDefaultDummyAccountAttribute(String username, String attrib protected void assertDummyAccountAttribute(String dummyInstanceName, String username, String attributeName, Object... expectedAttributeValues) throws SchemaViolationException, ConflictException, InterruptedException { DummyAccount account = getDummyAccount(dummyInstanceName, username); - assertNotNull("No dummy account for username "+username, account); + assertNotNull("No dummy account for username " + username, account); Set values = account.getAttributeValues(attributeName, Object.class); if ((values == null || values.isEmpty()) && (expectedAttributeValues == null || expectedAttributeValues.length == 0)) { return; } - assertNotNull("No values for attribute "+attributeName+" of "+dummyInstanceName+" dummy account "+username, values); - assertEquals("Unexpected number of values for attribute " + attributeName + " of "+dummyInstanceName+" dummy account " + username + - ". Expected: " + Arrays.toString(expectedAttributeValues) + ", was: " + values, + assertNotNull("No values for attribute " + attributeName + " of " + dummyInstanceName + " dummy account " + username, values); + assertEquals("Unexpected number of values for attribute " + attributeName + " of " + dummyInstanceName + " dummy account " + username + + ". Expected: " + Arrays.toString(expectedAttributeValues) + ", was: " + values, expectedAttributeValues.length, values.size()); - for (Object expectedValue: expectedAttributeValues) { + for (Object expectedValue : expectedAttributeValues) { if (!values.contains(expectedValue)) { - AssertJUnit.fail("Value '"+expectedValue+"' expected in attribute "+attributeName+" of "+dummyInstanceName+" dummy account "+username+ - " but not found. Values found: "+values); + AssertJUnit.fail("Value '" + expectedValue + "' expected in attribute " + attributeName + " of " + dummyInstanceName + " dummy account " + username + + " but not found. Values found: " + values); } } } protected void assertNoDummyAccountAttribute(String dummyInstanceName, String username, String attributeName) throws SchemaViolationException, ConflictException, InterruptedException { DummyAccount account = getDummyAccount(dummyInstanceName, username); - assertNotNull("No dummy "+dummyInstanceName+" account for username "+username, account); + assertNotNull("No dummy " + dummyInstanceName + " account for username " + username, account); Set values = account.getAttributeValues(attributeName, Object.class); if (values == null || values.isEmpty()) { return; } - AssertJUnit.fail("Expected no value in attribute " + attributeName + " of "+dummyInstanceName+" dummy account " + username + + AssertJUnit.fail("Expected no value in attribute " + attributeName + " of " + dummyInstanceName + " dummy account " + username + ". Values found: " + values); } protected void assertDummyAccountAttributeGenerated(String dummyInstanceName, String username) throws SchemaViolationException, ConflictException, InterruptedException { DummyAccount account = getDummyAccount(dummyInstanceName, username); - assertNotNull("No dummy account for username "+username, account); + assertNotNull("No dummy account for username " + username, account); Integer generated = account.getAttributeValue(DummyAccount.ATTR_INTERNAL_ID, Integer.class); if (generated == null) { AssertJUnit.fail("No value in generated attribute dir of " + dummyInstanceName + " dummy account " + username); @@ -4281,9 +4255,9 @@ protected DummyGroup getDummyGroup(String dummyInstanceName, String name) throws try { return dummyResource.getGroupByName(name); } catch (ConnectException e) { - throw new IllegalStateException(e.getMessage(),e); + throw new IllegalStateException(e.getMessage(), e); } catch (FileNotFoundException e) { - throw new IllegalStateException(e.getMessage(),e); + throw new IllegalStateException(e.getMessage(), e); } } @@ -4297,11 +4271,11 @@ protected void assertDummyGroup(String username, String description, Boolean act protected void assertDummyGroup(String dummyInstanceName, String groupname, String description, Boolean active) throws SchemaViolationException, ConflictException, InterruptedException { DummyGroup group = getDummyGroup(dummyInstanceName, groupname); - assertNotNull("No dummy("+dummyInstanceName+") group for name "+groupname, group); + assertNotNull("No dummy(" + dummyInstanceName + ") group for name " + groupname, group); assertEquals("Wrong fullname for dummy(" + dummyInstanceName + ") group " + groupname, description, group.getAttributeValue(DummyResourceContoller.DUMMY_GROUP_ATTRIBUTE_DESCRIPTION)); if (active != null) { - assertEquals("Wrong activation for dummy("+dummyInstanceName+") group "+groupname, active, group.isEnabled()); + assertEquals("Wrong activation for dummy(" + dummyInstanceName + ") group " + groupname, active, group.isEnabled()); } } @@ -4316,17 +4290,17 @@ protected void assertNoDummyGroup(String dummyInstanceName, String groupname) th protected void assertDummyGroupAttribute(String dummyInstanceName, String groupname, String attributeName, Object... expectedAttributeValues) throws SchemaViolationException, ConflictException, InterruptedException { DummyGroup group = getDummyGroup(dummyInstanceName, groupname); - assertNotNull("No dummy group for groupname "+groupname, group); + assertNotNull("No dummy group for groupname " + groupname, group); Set values = group.getAttributeValues(attributeName, Object.class); if ((values == null || values.isEmpty()) && (expectedAttributeValues == null || expectedAttributeValues.length == 0)) { return; } - assertNotNull("No values for attribute "+attributeName+" of "+dummyInstanceName+" dummy group "+groupname, values); + assertNotNull("No values for attribute " + attributeName + " of " + dummyInstanceName + " dummy group " + groupname, values); assertEquals("Unexpected number of values for attribute " + attributeName + " of dummy group " + groupname + ": " + values, expectedAttributeValues.length, values.size()); - for (Object expectedValue: expectedAttributeValues) { + for (Object expectedValue : expectedAttributeValues) { if (!values.contains(expectedValue)) { - AssertJUnit.fail("Value '"+expectedValue+"' expected in attribute "+attributeName+" of dummy group "+groupname+ - " but not found. Values found: "+values); + AssertJUnit.fail("Value '" + expectedValue + "' expected in attribute " + attributeName + " of dummy group " + groupname + + " but not found. Values found: " + values); } } } @@ -4334,7 +4308,7 @@ protected void assertDummyGroupAttribute(String dummyInstanceName, String groupn protected void assertDummyGroupMember(String dummyInstanceName, String dummyGroupName, String accountId) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { DummyResource dummyResource = DummyResource.getInstance(dummyInstanceName); DummyGroup group = dummyResource.getGroupByName(dummyGroupName); - assertNotNull("No dummy group "+dummyGroupName, group); + assertNotNull("No dummy group " + dummyGroupName, group); IntegrationTestTools.assertGroupMember(group, accountId); } @@ -4354,14 +4328,14 @@ protected void assertNoDefaultDummyGroupMember(String dummyGroupName, String acc protected void assertDummyAccountNoAttribute(String dummyInstanceName, String username, String attributeName) throws SchemaViolationException, ConflictException, InterruptedException { DummyAccount account = getDummyAccount(dummyInstanceName, username); - assertNotNull("No dummy account for username "+username, account); + assertNotNull("No dummy account for username " + username, account); Set values = account.getAttributeValues(attributeName, Object.class); assertTrue("Unexpected values for attribute " + attributeName + " of dummy account " + username + ": " + values, values == null || values.isEmpty()); } protected Entry assertOpenDjAccount(String uid, String cn, Boolean active) throws DirectoryException { Entry entry = openDJController.searchByUid(uid); - assertNotNull("OpenDJ accoun with uid "+uid+" not found", entry); + assertNotNull("OpenDJ accoun with uid " + uid + " not found", entry); openDJController.assertAttribute(entry, "cn", cn); if (active != null) { openDJController.assertActive(entry, active); @@ -4395,30 +4369,30 @@ protected void assertSituation(PrismObject shadow, SynchronizationSi protected void assertEnableTimestampFocus(PrismObject focus, XMLGregorianCalendar startTime, XMLGregorianCalendar endTime) { XMLGregorianCalendar userDisableTimestamp = focus.asObjectable().getActivation().getEnableTimestamp(); - TestUtil.assertBetween("Wrong user enableTimestamp in "+focus, + TestUtil.assertBetween("Wrong user enableTimestamp in " + focus, startTime, endTime, userDisableTimestamp); } protected void assertDisableTimestampFocus(PrismObject focus, XMLGregorianCalendar startTime, XMLGregorianCalendar endTime) { XMLGregorianCalendar userDisableTimestamp = focus.asObjectable().getActivation().getDisableTimestamp(); - TestUtil.assertBetween("Wrong user disableTimestamp in "+focus, + TestUtil.assertBetween("Wrong user disableTimestamp in " + focus, startTime, endTime, userDisableTimestamp); } protected void assertEnableTimestampShadow(PrismObject shadow, XMLGregorianCalendar startTime, XMLGregorianCalendar endTime) { ActivationType activationType = shadow.asObjectable().getActivation(); - assertNotNull("No activation in "+shadow, activationType); + assertNotNull("No activation in " + shadow, activationType); XMLGregorianCalendar userDisableTimestamp = activationType.getEnableTimestamp(); - TestUtil.assertBetween("Wrong shadow enableTimestamp in "+shadow, + TestUtil.assertBetween("Wrong shadow enableTimestamp in " + shadow, startTime, endTime, userDisableTimestamp); } protected void assertDisableTimestampShadow(PrismObject shadow, XMLGregorianCalendar startTime, XMLGregorianCalendar endTime) { XMLGregorianCalendar userDisableTimestamp = shadow.asObjectable().getActivation().getDisableTimestamp(); - TestUtil.assertBetween("Wrong shadow disableTimestamp in "+shadow, + TestUtil.assertBetween("Wrong shadow disableTimestamp in " + shadow, startTime, endTime, userDisableTimestamp); } @@ -4429,45 +4403,45 @@ protected void assertDisableReasonShadow(PrismObject shado protected String getPassword(PrismObject user) throws EncryptionException { CredentialsType credentialsType = user.asObjectable().getCredentials(); - assertNotNull("No credentials in "+user, credentialsType); + assertNotNull("No credentials in " + user, credentialsType); PasswordType passwordType = credentialsType.getPassword(); - assertNotNull("No password in "+user, passwordType); + assertNotNull("No password in " + user, passwordType); ProtectedStringType protectedStringType = passwordType.getValue(); - assertNotNull("No password value in "+user, protectedStringType); + assertNotNull("No password value in " + user, protectedStringType); return protector.decryptString(protectedStringType); } protected void assertPassword(PrismObject user, String expectedPassword) throws EncryptionException { String decryptedUserPassword = getPassword(user); - assertEquals("Wrong password in "+user, expectedPassword, decryptedUserPassword); + assertEquals("Wrong password in " + user, expectedPassword, decryptedUserPassword); } protected void assertUserLdapPassword(PrismObject user, String expectedPassword) throws EncryptionException { CredentialsType credentialsType = user.asObjectable().getCredentials(); - assertNotNull("No credentials in "+user, credentialsType); + assertNotNull("No credentials in " + user, credentialsType); PasswordType passwordType = credentialsType.getPassword(); - assertNotNull("No password in "+user, passwordType); + assertNotNull("No password in " + user, passwordType); ProtectedStringType protectedStringType = passwordType.getValue(); assertLdapPassword(protectedStringType, expectedPassword, user); } protected void assertShadowLdapPassword(PrismObject shadow, String expectedPassword) throws EncryptionException { CredentialsType credentialsType = shadow.asObjectable().getCredentials(); - assertNotNull("No credentials in "+shadow, credentialsType); + assertNotNull("No credentials in " + shadow, credentialsType); PasswordType passwordType = credentialsType.getPassword(); - assertNotNull("No password in "+shadow, passwordType); + assertNotNull("No password in " + shadow, passwordType); ProtectedStringType protectedStringType = passwordType.getValue(); assertLdapPassword(protectedStringType, expectedPassword, shadow); } protected void assertLdapPassword(ProtectedStringType protectedStringType, String expectedPassword, PrismObject source) throws EncryptionException { - assertNotNull("No password value in "+source, protectedStringType); + assertNotNull("No password value in " + source, protectedStringType); String decryptedUserPassword = protector.decryptString(protectedStringType); assertNotNull("Null password in " + source, decryptedUserPassword); if (decryptedUserPassword.startsWith("{") || decryptedUserPassword.contains("}")) { - assertTrue("Wrong password hash in "+source+": "+decryptedUserPassword+", expected "+expectedPassword, ldapShaPasswordEncoder.matches(decryptedUserPassword, expectedPassword)); + assertTrue("Wrong password hash in " + source + ": " + decryptedUserPassword + ", expected " + expectedPassword, ldapShaPasswordEncoder.matches(decryptedUserPassword, expectedPassword)); } else { - assertEquals("Wrong password in "+source, expectedPassword, decryptedUserPassword); + assertEquals("Wrong password in " + source, expectedPassword, decryptedUserPassword); } } @@ -4547,7 +4521,7 @@ protected void assertLoggedInUsername(String username) { if (username == null) { return; } else { - AssertJUnit.fail("Expected logged in user '"+username+"' but there was no user in the spring security context"); + AssertJUnit.fail("Expected logged in user '" + username + "' but there was no user in the spring security context"); } } assertEquals("Wrong logged-in user", username, user.getName().getOrig()); @@ -4564,7 +4538,7 @@ protected void assertPrincipalUserOid(MidPointPrincipal principal, String userOi if (userOid == null) { return; } else { - AssertJUnit.fail("Expected user "+userOid+" in principal "+principal+" but there was none"); + AssertJUnit.fail("Expected user " + userOid + " in principal " + principal + " but there was none"); } } assertEquals("Wrong user OID in principal", userOid, user.getOid()); @@ -4581,9 +4555,9 @@ protected MidPointPrincipal getSecurityContextPrincipal() { return null; } if (principal instanceof MidPointPrincipal) { - return (MidPointPrincipal)principal; + return (MidPointPrincipal) principal; } else { - AssertJUnit.fail("Unknown principal in the spring security context: "+principal); + AssertJUnit.fail("Unknown principal in the spring security context: " + principal); return null; // not reached } } @@ -4599,7 +4573,7 @@ protected PrismObject getSecurityContextPrincipalFocus() { return null; } if (principal instanceof MidPointPrincipal) { - FocusType focusType = ((MidPointPrincipal)principal).getFocus(); + FocusType focusType = ((MidPointPrincipal) principal).getFocus(); return focusType.asPrismObject(); } else { return null; @@ -4633,7 +4607,7 @@ protected void assertPrincipalAttorneyOid(MidPointPrincipal principal, String at if (attotrneyOid == null) { return; } else { - AssertJUnit.fail("Expected attorney "+attotrneyOid+" in principal "+principal+" but there was none"); + AssertJUnit.fail("Expected attorney " + attotrneyOid + " in principal " + principal + " but there was none"); } } assertEquals("Wrong attroney OID in principal", attotrneyOid, attorney.getOid()); @@ -4649,9 +4623,9 @@ protected Collection getSecurityContextAuthorizations() { protected void assertAuthorizationActions(String message, Collection autzs, String... expectedActions) { Collection actualActions = autzs.stream() - .map(a -> a.getAction()) - .flatMap(List::stream) - .collect(Collectors.toList()); + .map(a -> a.getAction()) + .flatMap(List::stream) + .collect(Collectors.toList()); PrismAsserts.assertEqualsCollectionUnordered(message, actualActions, expectedActions); } @@ -4663,7 +4637,7 @@ protected void assertSecurityContextAuthorizationActions(String... expectedActio protected void assertSecurityContextAuthorizationActions(ModelAuthorizationAction... expectedModelActions) { Collection securityContextAuthorizations = getSecurityContextAuthorizations(); String[] expectedActions = new String[expectedModelActions.length]; - for (int i=0;i securityContextAuthorizations = getSecurityContextAuthorizations(); if (securityContextAuthorizations != null && !securityContextAuthorizations.isEmpty()) { - fail("Unexpected authorizations in security context: "+securityContextAuthorizations); + fail("Unexpected authorizations in security context: " + securityContextAuthorizations); } } protected void displayAllUsers() throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".displayAllUsers"); + Task task = createTask("displayAllUsers"); OperationResult result = task.getResult(); ResultHandler handler = (object, parentResult) -> { display("User", object); @@ -4701,7 +4675,7 @@ protected ObjectSynchronizationType determineSynchronization(ResourceType resour if (objectSynchronizations.isEmpty()) { return null; } - for (ObjectSynchronizationType objSyncType: objectSynchronizations) { + for (ObjectSynchronizationType objSyncType : objectSynchronizations) { QName focusTypeQName = objSyncType.getFocusType(); if (focusTypeQName == null) { if (type != UserType.class) { @@ -4722,12 +4696,12 @@ protected ObjectSynchronizationType determineSynchronization(ResourceType resour } } } - throw new IllegalArgumentException("Synchronization setting for "+type+" and name "+name+" not found in "+resource); + throw new IllegalArgumentException("Synchronization setting for " + type + " and name " + name + " not found in " + resource); } protected void assertShadowKindIntent(String shadowOid, ShadowKindType expectedKind, String expectedIntent) throws ObjectNotFoundException, SchemaException { - OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName()+".assertShadowKindIntent"); + OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName() + ".assertShadowKindIntent"); PrismObject shadow = repositoryService.getObject(ShadowType.class, shadowOid, null, result); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4753,15 +4727,14 @@ protected void customizeTask(Task task) { } protected Task createTask(String operationName, MidPointPrincipal principal) { - Task task = getTestTask(); + Task task = createTask(operationName); task.setOwner(principal.getFocus().asPrismObject()); task.setChannel(DEFAULT_CHANNEL); return task; } protected void modifyRoleAddConstruction(String roleOid, long inducementId, String resourceOid) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - AbstractModelIntegrationTest.class.getName(); - Task task = getTestTask(); + Task task = createTask("modifyRoleAddConstruction"); OperationResult result = task.getResult(); ConstructionType construction = new ConstructionType(); ObjectReferenceType resourceRedRef = new ObjectReferenceType(); @@ -4769,30 +4742,29 @@ protected void modifyRoleAddConstruction(String roleOid, long inducementId, Stri construction.setResourceRef(resourceRedRef); ObjectDelta roleDelta = prismContext.deltaFactory().object() .createModificationAddContainer(RoleType.class, roleOid, - ItemPath.create(RoleType.F_INDUCEMENT, inducementId, AssignmentType.F_CONSTRUCTION), + ItemPath.create(RoleType.F_INDUCEMENT, inducementId, AssignmentType.F_CONSTRUCTION), construction); modelService.executeChanges(MiscSchemaUtil.createCollection(roleDelta), null, task, result); result.computeStatus(); TestUtil.assertSuccess(result); } - protected void modifyRoleAddInducementTarget(String roleOid, String targetOid, boolean reconcileAffected, - ModelExecuteOptions defaultOptions, Task task) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - if (task == null) { - AbstractModelIntegrationTest.class.getName(); - task = getTestTask(); - } - OperationResult result = task.getResult(); + protected void modifyRoleAddInducementTarget( + String roleOid, String targetOid, boolean reconcileAffected, ModelExecuteOptions defaultOptions) + throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, + CommunicationException, ConfigurationException, SecurityViolationException, + ObjectAlreadyExistsException, PolicyViolationException { + OperationResult result = createSubresult("modifyRoleAddInducementTarget"); AssignmentType inducement = new AssignmentType(); ObjectReferenceType targetRef = new ObjectReferenceType(); targetRef.setOid(targetOid); inducement.setTargetRef(targetRef); ObjectDelta roleDelta = prismContext.deltaFactory().object() .createModificationAddContainer(RoleType.class, roleOid, - RoleType.F_INDUCEMENT, inducement); + RoleType.F_INDUCEMENT, inducement); ModelExecuteOptions options = nullToEmpty(defaultOptions); options.setReconcileAffected(reconcileAffected); - executeChanges(roleDelta, options, task, result); + executeChanges(roleDelta, options, getTestTask(), result); result.computeStatus(); if (reconcileAffected) { TestUtil.assertInProgressOrSuccess(result); @@ -4829,13 +4801,6 @@ protected void modifyRolePolicyRule(String roleOid, PolicyRuleType exclusionPoli executeChanges(roleDelta, null, task, result); } - protected void modifyRoleAddAssignment(String roleOid, AssignmentType assignment, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - ObjectDelta roleDelta = prismContext.deltaFactory().object() - .createModificationAddContainer(RoleType.class, roleOid, RoleType.F_ASSIGNMENT, - assignment); - executeChanges(roleDelta, null, task, result); - } - protected void modifyRoleDeleteAssignment(String roleOid, AssignmentType assignment, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { ObjectDelta roleDelta = prismContext.deltaFactory().object() .createModificationDeleteContainer(RoleType.class, roleOid, RoleType.F_ASSIGNMENT, @@ -4921,13 +4886,13 @@ protected AssignmentType findAssignmentByTargetRequired(PrismObject new IllegalStateException("No assignment to " + targetOid + " in " + focus)); } - - protected AssignmentType findInducementByTarget(String roleOid, String targetOid) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - AbstractModelIntegrationTest.class.getName(); - Task task = getTestTask(); + protected AssignmentType findInducementByTarget(String roleOid, String targetOid) + throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, + CommunicationException, ConfigurationException, SecurityViolationException { + Task task = createTask("findInducementByTarget"); OperationResult result = task.getResult(); PrismObject role = modelService.getObject(RoleType.class, roleOid, null, task, result); - for (AssignmentType inducement: role.asObjectable().getInducement()) { + for (AssignmentType inducement : role.asObjectable().getInducement()) { ObjectReferenceType targetRef = inducement.getTargetRef(); if (targetRef != null && targetOid.equals(targetRef.getOid())) { return inducement; @@ -4938,12 +4903,12 @@ protected AssignmentType findInducementByTarget(String roleOid, String targetOid protected void modifyRoleDeleteInducementTarget(String roleOid, String targetOid, ModelExecuteOptions options) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - AbstractModelIntegrationTest.class.getName(); - Task task = getTestTask(); + Task task = createTask("modifyRoleDeleteInducementTarget"); OperationResult result = task.getResult(); AssignmentType inducement = findInducementByTarget(roleOid, targetOid); - ObjectDelta roleDelta = prismContext.deltaFactory().object() - .createModificationDeleteContainer(RoleType.class, roleOid, RoleType.F_INDUCEMENT, + ObjectDelta roleDelta = + prismContext.deltaFactory().object().createModificationDeleteContainer( + RoleType.class, roleOid, RoleType.F_INDUCEMENT, inducement.asPrismContainerValue().clone()); modelService.executeChanges(MiscSchemaUtil.createCollection(roleDelta), options, task, result); result.computeStatus(); @@ -4952,17 +4917,13 @@ protected void modifyRoleDeleteInducementTarget(String roleOid, String targetOid protected void modifyRoleDeleteInducement(String roleOid, long inducementId, boolean reconcileAffected, ModelExecuteOptions defaultOptions, Task task) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - if (task == null) { - AbstractModelIntegrationTest.class.getName(); - task = getTestTask(); - } OperationResult result = task.getResult(); AssignmentType inducement = new AssignmentType(); inducement.setId(inducementId); ObjectDelta roleDelta = prismContext.deltaFactory().object() .createModificationDeleteContainer(RoleType.class, roleOid, - RoleType.F_INDUCEMENT, inducement); + RoleType.F_INDUCEMENT, inducement); ModelExecuteOptions options = nullToEmpty(defaultOptions); options.setReconcileAffected(reconcileAffected); executeChanges(roleDelta, options, task, result); @@ -4988,7 +4949,7 @@ protected void modifyUserAddAccount(String userOid, File accountFile, Task task, accountRefVal.setObject(account); ReferenceDelta accountDelta = prismContext.deltaFactory().reference().createModificationAdd(UserType.F_LINK_REF, getUserDefinition(), accountRefVal); userDelta.addModification(accountDelta); - Collection> deltas = (Collection)MiscUtil.createCollection(userDelta); + Collection> deltas = (Collection) MiscUtil.createCollection(userDelta); modelService.executeChanges(deltas, null, task, result); } @@ -5011,7 +4972,7 @@ protected void assertAuthorized(MidPointPrincipal principal, String action, Auth SecurityContext origContext = SecurityContextHolder.getContext(); createSecurityContext(principal); try { - assertTrue("AuthorizationEvaluator.isAuthorized: Principal "+principal+" NOT authorized for action "+action, + assertTrue("AuthorizationEvaluator.isAuthorized: Principal " + principal + " NOT authorized for action " + action, securityEnforcer.isAuthorized(action, phase, AuthorizationParameters.EMPTY, null, task, result)); if (phase == null) { List requiredActions = new ArrayList<>(1); @@ -5045,39 +5006,42 @@ protected void assertNotAuthorized(MidPointPrincipal principal, String action, A assertFalse("AuthorizationEvaluator.isAuthorized: Principal " + principal + " IS authorized for action " + action + " (" + phase + ") but he should not be", isAuthorized); } - protected void assertAuthorizations(PrismObject user, String... expectedAuthorizations) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + protected void assertAuthorizations(PrismObject user, String... expectedAuthorizations) + throws SchemaException, CommunicationException, ConfigurationException, + SecurityViolationException, ExpressionEvaluationException { MidPointPrincipal principal = focusProfileService.getPrincipal(user); - assertNotNull("No principal for "+user, principal); + assertNotNull("No principal for " + user, principal); assertAuthorizations(principal, expectedAuthorizations); } protected void assertAuthorizations(MidPointPrincipal principal, String... expectedAuthorizations) { List actualAuthorizations = new ArrayList<>(); - for (Authorization authorization: principal.getAuthorities()) { + for (Authorization authorization : principal.getAuthorities()) { actualAuthorizations.addAll(authorization.getAction()); } - PrismAsserts.assertSets("Wrong authorizations in "+principal, actualAuthorizations, expectedAuthorizations); + PrismAsserts.assertSets("Wrong authorizations in " + principal, actualAuthorizations, expectedAuthorizations); } - - protected void assertNoAuthorizations(PrismObject user) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + protected void assertNoAuthorizations(PrismObject user) + throws SchemaException, CommunicationException, ConfigurationException, + SecurityViolationException, ExpressionEvaluationException { MidPointPrincipal principal = focusProfileService.getPrincipal(user); - assertNotNull("No principal for "+user, principal); + assertNotNull("No principal for " + user, principal); assertNoAuthorizations(principal); } protected void assertNoAuthorizations(MidPointPrincipal principal) { if (principal.getAuthorities() != null && !principal.getAuthorities().isEmpty()) { - AssertJUnit.fail("Unexpected authorizations in "+principal+": "+principal.getAuthorities()); + AssertJUnit.fail("Unexpected authorizations in " + principal + ": " + principal.getAuthorities()); } } protected CompiledGuiProfileAsserter assertCompiledGuiProfile(MidPointPrincipal principal) { if (!(principal instanceof GuiProfiledPrincipal)) { - fail("Expected GuiProfiledPrincipal, but got "+principal.getClass()); + fail("Expected GuiProfiledPrincipal, but got " + principal.getClass()); } - CompiledGuiProfile compiledGuiProfile = ((GuiProfiledPrincipal)principal).getCompiledGuiProfile(); - CompiledGuiProfileAsserter asserter = new CompiledGuiProfileAsserter<>(compiledGuiProfile, null, "in principal "+principal); + CompiledGuiProfile compiledGuiProfile = ((GuiProfiledPrincipal) principal).getCompiledGuiProfile(); + CompiledGuiProfileAsserter asserter = new CompiledGuiProfileAsserter<>(compiledGuiProfile, null, "in principal " + principal); initializeAsserter(asserter); asserter.display(); return asserter; @@ -5090,13 +5054,6 @@ protected CompiledGuiProfileAsserter assertCompiledGuiProfile(CompiledGuiP return asserter; } - protected EvaluatedPolicyRulesAsserter assertEvaluatedPolicyRules(Collection evaluatedPolicyRules) { - EvaluatedPolicyRulesAsserter asserter = new EvaluatedPolicyRulesAsserter<>(evaluatedPolicyRules, null, null); - initializeAsserter(asserter); - asserter.display(); - return asserter; - } - protected EvaluatedPolicyRulesAsserter assertEvaluatedPolicyRules(Collection evaluatedPolicyRules, PrismObject sourceObject) { EvaluatedPolicyRulesAsserter asserter = new EvaluatedPolicyRulesAsserter<>(evaluatedPolicyRules, null, sourceObject.toString()); initializeAsserter(asserter); @@ -5122,7 +5079,7 @@ protected Collection createConfigAttributes(String action) { } protected PrismObjectDefinition getEditObjectDefinition(PrismObject object) throws SchemaException, ConfigurationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".getEditObjectDefinition"); + Task task = createTask("getEditObjectDefinition"); OperationResult result = task.getResult(); PrismObjectDefinition editSchema = modelInteractionService.getEditObjectDefinition(object, null, task, result); result.computeStatus(); @@ -5134,12 +5091,15 @@ protected RoleSelectionSpecification getAssigna return getAssignableRoleSpecification(targetHolder, 0); } - protected RoleSelectionSpecification getAssignableRoleSpecification(PrismObject focus, int assignmentOrder) throws ObjectNotFoundException, SchemaException, ConfigurationException, ExpressionEvaluationException, CommunicationException, SecurityViolationException { + protected RoleSelectionSpecification getAssignableRoleSpecification( + PrismObject focus, int assignmentOrder) + throws ObjectNotFoundException, SchemaException, ConfigurationException, + ExpressionEvaluationException, CommunicationException, SecurityViolationException { return getAssignableRoleSpecification(focus, AbstractRoleType.class, 0); } protected RoleSelectionSpecification getAssignableRoleSpecification(PrismObject focus, Class targetType, int assignmentOrder) throws ObjectNotFoundException, SchemaException, ConfigurationException, ExpressionEvaluationException, CommunicationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".getAssignableRoleSpecification"); + Task task = createTask("getAssignableRoleSpecification"); OperationResult result = task.getResult(); RoleSelectionSpecification spec = modelInteractionService.getAssignableRoleSpecification(focus, targetType, assignmentOrder, task, result); assertSuccess(result); @@ -5148,54 +5108,51 @@ protected RoleSelec protected RoleSelectionSpecificationAsserter assertAssignableRoleSpecification(PrismObject targetHolder) throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException { RoleSelectionSpecification spec = getAssignableRoleSpecification(targetHolder); - RoleSelectionSpecificationAsserter asserter = new RoleSelectionSpecificationAsserter(spec, null, "for holder "+targetHolder); + RoleSelectionSpecificationAsserter asserter = new RoleSelectionSpecificationAsserter<>(spec, null, "for holder " + targetHolder); initializeAsserter(asserter); asserter.display(); return asserter; } - protected RoleSelectionSpecificationAsserter assertAssignableRoleSpecification(PrismObject targetHolder, int order) throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException { - RoleSelectionSpecification spec = getAssignableRoleSpecification(targetHolder, order); - RoleSelectionSpecificationAsserter asserter = new RoleSelectionSpecificationAsserter(spec, null, "for holder "+targetHolder+", order "+order); - initializeAsserter(asserter); - asserter.display(); - return asserter; - } - - protected RoleSelectionSpecificationAsserter assertAssignableRoleSpecification(PrismObject targetHolder, Class roleType, int order) throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException { + protected RoleSelectionSpecificationAsserter assertAssignableRoleSpecification( + PrismObject targetHolder, Class roleType, int order) + throws CommunicationException, ObjectNotFoundException, SchemaException, + SecurityViolationException, ConfigurationException, ExpressionEvaluationException { RoleSelectionSpecification spec = getAssignableRoleSpecification(targetHolder, roleType, order); - RoleSelectionSpecificationAsserter asserter = new RoleSelectionSpecificationAsserter(spec, null, "for holder "+targetHolder+", role type "+roleType.getSimpleName()+", order "+order); + RoleSelectionSpecificationAsserter asserter = new RoleSelectionSpecificationAsserter<>(spec, null, "for holder " + targetHolder + ", role type " + roleType.getSimpleName() + ", order " + order); initializeAsserter(asserter); asserter.display(); return asserter; } - protected void assertAllowRequestAssignmentItems(String userOid, String targetRoleOid, ItemPath... expectedAllowedItemPaths) - throws SchemaException, SecurityViolationException, CommunicationException, ObjectNotFoundException, ConfigurationException, ExpressionEvaluationException { - AbstractModelIntegrationTest.class.getName(); - Task task = getTestTask(); + protected void assertAllowRequestAssignmentItems( + String userOid, String targetRoleOid, ItemPath... expectedAllowedItemPaths) + throws SchemaException, SecurityViolationException, CommunicationException, + ObjectNotFoundException, ConfigurationException, ExpressionEvaluationException { + Task task = createTask("assertAllowRequestAssignmentItems"); OperationResult result = task.getResult(); assertAllowRequestAssignmentItems(userOid, targetRoleOid, task, result, expectedAllowedItemPaths); assertSuccess(result); } - protected void assertAllowRequestAssignmentItems(String userOid, String targetRoleOid, Task task, OperationResult result, ItemPath... expectedAllowedItemPaths) - throws SchemaException, SecurityViolationException, CommunicationException, ObjectNotFoundException, ConfigurationException, ExpressionEvaluationException { + protected void assertAllowRequestAssignmentItems(String userOid, String targetRoleOid, + Task task, OperationResult result, ItemPath... expectedAllowedItemPaths) + throws SchemaException, SecurityViolationException, CommunicationException, + ObjectNotFoundException, ConfigurationException, ExpressionEvaluationException { PrismObject user = getUser(userOid); PrismObject target = getRole(targetRoleOid); ItemSecurityConstraints constraints = modelInteractionService.getAllowedRequestAssignmentItems(user, target, task, result); - display("Request decisions for "+target, constraints); + display("Request decisions for " + target, constraints); - for (ItemPath expectedAllowedItemPath: expectedAllowedItemPaths) { + for (ItemPath expectedAllowedItemPath : expectedAllowedItemPaths) { AuthorizationDecisionType decision = constraints.findItemDecision(expectedAllowedItemPath); - assertEquals("Wrong decision for item "+expectedAllowedItemPath, AuthorizationDecisionType.ALLOW, decision); + assertEquals("Wrong decision for item " + expectedAllowedItemPath, AuthorizationDecisionType.ALLOW, decision); } } - protected void assertEncryptedUserPassword(String userOid, String expectedClearPassword) throws EncryptionException, ObjectNotFoundException, SchemaException { - OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName()+".assertEncryptedUserPassword"); + OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName() + ".assertEncryptedUserPassword"); PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); result.computeStatus(); TestUtil.assertSuccess(result); @@ -5206,57 +5163,58 @@ protected void assertEncryptedUserPassword(PrismObject user, String ex UserType userType = user.asObjectable(); ProtectedStringType protectedActualPassword = userType.getCredentials().getPassword().getValue(); String actualClearPassword = protector.decryptString(protectedActualPassword); - assertEquals("Wrong password for "+user, expectedClearPassword, actualClearPassword); + assertEquals("Wrong password for " + user, expectedClearPassword, actualClearPassword); } @Deprecated protected void assertPasswordMetadata(PrismObject user, boolean create, XMLGregorianCalendar start, XMLGregorianCalendar end, String actorOid, String channel) { PrismContainer metadataContainer = user.findContainer(PATH_CREDENTIALS_PASSWORD_METADATA); - assertNotNull("No password metadata in "+user, metadataContainer); + assertNotNull("No password metadata in " + user, metadataContainer); MetadataType metadataType = metadataContainer.getValue().asContainerable(); - assertMetadata("password metadata in "+user, metadataType, create, false, start, end, actorOid, channel); + assertMetadata("password metadata in " + user, metadataType, create, false, start, end, actorOid, channel); } protected void assertPasswordMetadata(PrismObject user, QName credentialType, boolean create, XMLGregorianCalendar start, XMLGregorianCalendar end, String actorOid, String channel) { PrismContainer metadataContainer = user.findContainer(ItemPath.create(UserType.F_CREDENTIALS, credentialType, PasswordType.F_METADATA)); - assertNotNull("No password metadata in "+user, metadataContainer); + assertNotNull("No password metadata in " + user, metadataContainer); MetadataType metadataType = metadataContainer.getValue().asContainerable(); - assertMetadata("password metadata in "+user, metadataType, create, false, start, end, actorOid, channel); + assertMetadata("password metadata in " + user, metadataType, create, false, start, end, actorOid, channel); } protected void assertCreateMetadata(PrismObject object, XMLGregorianCalendar start, XMLGregorianCalendar end) { MetadataType metadataType = object.asObjectable().getMetadata(); PrismObject defaultActor = getDefaultActor(); assertMetadata(object.toString(), metadataType, true, true, start, end, - defaultActor==null?null:defaultActor.getOid(), DEFAULT_CHANNEL); + defaultActor == null ? null : defaultActor.getOid(), DEFAULT_CHANNEL); } protected void assertModifyMetadata(PrismObject object, XMLGregorianCalendar start, XMLGregorianCalendar end) { MetadataType metadataType = object.asObjectable().getMetadata(); PrismObject defaultActor = getDefaultActor(); assertMetadata(object.toString(), metadataType, false, false, start, end, - defaultActor==null?null:defaultActor.getOid(), DEFAULT_CHANNEL); + defaultActor == null ? null : defaultActor.getOid(), DEFAULT_CHANNEL); } - protected void assertCreateMetadata(AssignmentType assignmentType, XMLGregorianCalendar start, XMLGregorianCalendar end) { + protected void assertCreateMetadata( + AssignmentType assignmentType, XMLGregorianCalendar start, XMLGregorianCalendar end) { MetadataType metadataType = assignmentType.getMetadata(); PrismObject defaultActor = getDefaultActor(); assertMetadata(assignmentType.toString(), metadataType, true, true, start, end, - defaultActor==null?null:defaultActor.getOid(), DEFAULT_CHANNEL); + defaultActor == null ? null : defaultActor.getOid(), DEFAULT_CHANNEL); } protected void assertDummyPassword(String instance, String userId, String expectedClearPassword) throws SchemaViolationException, ConflictException, InterruptedException { DummyAccount account = getDummyAccount(instance, userId); - assertNotNull("No dummy account "+userId, account); - assertEquals("Wrong password in dummy '"+instance+"' account "+userId, expectedClearPassword, account.getPassword()); + assertNotNull("No dummy account " + userId, account); + assertEquals("Wrong password in dummy '" + instance + "' account " + userId, expectedClearPassword, account.getPassword()); } protected void assertDummyPasswordNotEmpty(String instance, String userId) throws SchemaViolationException, ConflictException, InterruptedException { DummyAccount account = getDummyAccount(instance, userId); - assertNotNull("No dummy account "+userId, account); + assertNotNull("No dummy account " + userId, account); String actualPassword = account.getPassword(); if (actualPassword == null || actualPassword.isEmpty()) { - fail("Empty password in dummy '"+instance+"' account "+userId); + fail("Empty password in dummy '" + instance + "' account " + userId); } } @@ -5285,53 +5243,38 @@ protected void assertRefEquals(String message, ObjectReferenceType expected, Obj } protected void assertTaskClosed(PrismObject task) { - assertEquals("Wrong executionStatus in "+task, TaskExecutionStatusType.CLOSED, task.asObjectable().getExecutionStatus()); + assertEquals("Wrong executionStatus in " + task, TaskExecutionStatusType.CLOSED, task.asObjectable().getExecutionStatus()); } protected void assertTaskClosed(Task task) { - assertEquals("Wrong executionStatus in "+task, TaskExecutionStatus.CLOSED, task.getExecutionStatus()); + assertEquals("Wrong executionStatus in " + task, TaskExecutionStatus.CLOSED, task.getExecutionStatus()); } protected List getAllAuditRecords(Task task, OperationResult result) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - Map params = new HashMap<>(); + Map params = new HashMap<>(); return modelAuditService.listRecords("select * from m_audit_event as aer order by aer.timestampValue asc", params, task, result); } protected List getAuditRecords(int maxRecords, Task task, OperationResult result) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - Map params = new HashMap<>(); + Map params = new HashMap<>(); params.put("setMaxResults", maxRecords); return modelAuditService.listRecords("select * from m_audit_event as aer order by aer.timestampValue asc", params, task, result); } - protected List getObjectAuditRecords(String oid) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - Task task = getTestTask(); + protected List getObjectAuditRecords(String oid) + throws SecurityViolationException, SchemaException, ObjectNotFoundException, + ExpressionEvaluationException, CommunicationException, ConfigurationException { + Task task = createTask("getObjectAuditRecords"); OperationResult result = task.getResult(); - return getObjectAuditRecords(oid, task, result); - } - - protected List getObjectAuditRecords(String oid, Task task, OperationResult result) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - Map params = new HashMap<>(); + Map params = new HashMap<>(); params.put("targetOid", oid); - return modelAuditService.listRecords("select * from m_audit_event as aer where (aer.targetOid = :targetOid) order by aer.timestampValue asc", - params, task, result); - } - - protected List getParamAuditRecords(String paramName, String paramValue, Task task, OperationResult result) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - Map params = new HashMap<>(); - params.put("paramName", paramName); - params.put("paramValue", paramValue); - return modelAuditService.listRecords("select * from m_audit_event as aer left join aer.propertyValues as pv where (pv.name = :paramName and pv.value = :paramValue) order by aer.timestampValue asc", + return modelAuditService.listRecords("select * from m_audit_event as aer" + + " where (aer.targetOid = :targetOid) order by aer.timestampValue asc", params, task, result); } - protected List getAuditRecordsFromTo(XMLGregorianCalendar from, XMLGregorianCalendar to) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - Task task = getTestTask(); - OperationResult result = task.getResult(); - return getAuditRecordsFromTo(from, to, task, result); - } - protected List getAuditRecordsFromTo(XMLGregorianCalendar from, XMLGregorianCalendar to, Task task, OperationResult result) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - Map params = new HashMap<>(); + Map params = new HashMap<>(); params.put("from", from); params.put("to", to); return modelAuditService.listRecords("select * from m_audit_event as aer where (aer.timestampValue >= :from) and (aer.timestampValue <= :to) order by aer.timestampValue asc", @@ -5343,29 +5286,13 @@ protected void checkUserApprovers(String oid, List expectedApprovers, Op checkApprovers(user, expectedApprovers, user.asObjectable().getMetadata().getModifyApproverRef(), result); } - protected void checkUserApproversForCreate(String oid, List expectedApprovers, OperationResult result) throws SchemaException, ObjectNotFoundException { - PrismObject user = repositoryService.getObject(UserType.class, oid, null, result); - checkApprovers(user, expectedApprovers, user.asObjectable().getMetadata().getCreateApproverRef(), result); - } - - protected void checkApproversForCreate(Class clazz, String oid, List expectedApprovers, OperationResult result) throws SchemaException, ObjectNotFoundException { - PrismObject object = repositoryService.getObject(clazz, oid, null, result); - checkApprovers(object, expectedApprovers, object.asObjectable().getMetadata().getCreateApproverRef(), result); - } - protected void checkApprovers(PrismObject object, List expectedApprovers, List realApprovers, OperationResult result) throws SchemaException, ObjectNotFoundException { HashSet realApproversSet = new HashSet<>(); for (ObjectReferenceType approver : realApprovers) { realApproversSet.add(approver.getOid()); assertEquals("Unexpected target type in approverRef", UserType.COMPLEX_TYPE, approver.getType()); } - assertEquals("Mismatch in approvers in metadata", new HashSet(expectedApprovers), realApproversSet); - } - - protected PrismObject findUserInRepo(String name, OperationResult result) throws SchemaException { - List> users = findUserInRepoUnchecked(name, result); - assertEquals("Didn't find exactly 1 user object with name " + name, 1, users.size()); - return users.get(0); + assertEquals("Mismatch in approvers in metadata", new HashSet<>(expectedApprovers), realApproversSet); } protected List> findUserInRepoUnchecked(String name, OperationResult result) throws SchemaException { @@ -5373,12 +5300,7 @@ protected List> findUserInRepoUnchecked(String name, Opera return repositoryService.searchObjects(UserType.class, q, null, result); } - protected List> findRoleInRepoUnchecked(String name, OperationResult result) throws SchemaException { - ObjectQuery q = prismContext.queryFor(RoleType.class).item(RoleType.F_NAME).eqPoly(name).matchingOrig().build(); - return repositoryService.searchObjects(RoleType.class, q, null, result); - } - - protected void assertFocusModificationSanity(ModelContext context) throws JAXBException { + protected void assertFocusModificationSanity(ModelContext context) { ModelElementContext focusContext = context.getFocusContext(); PrismObject focusOld = focusContext.getObjectOld(); if (focusOld == null) { @@ -5407,7 +5329,6 @@ protected void assertFocusModificationSanity(ModelContext< } } } - } } } @@ -5416,18 +5337,9 @@ protected PrismObject getUserFromRepo(String oid, OperationResult resu return repositoryService.getObject(UserType.class, oid, null, result); } - protected boolean assignmentExists(List assignmentList, String targetOid) { - for (AssignmentType assignmentType : assignmentList) { - if (assignmentType.getTargetRef() != null && targetOid.equals(assignmentType.getTargetRef().getOid())) { - return true; - } - } - return false; - } - // just guessing (good enough for testing) protected boolean isH2() { - Task task = getTestTask(); + Task task = createTask("isH2"); RepositoryDiag diag = modelDiagnosticService.getRepositoryDiag(task, task.getResult()); return diag.isEmbedded() || "org.h2.Driver".equals(diag.getDriverShortName()); } @@ -5435,7 +5347,7 @@ protected boolean isH2() { protected void assertNoPostponedOperation(PrismObject shadow) { List pendingOperations = shadow.asObjectable().getPendingOperation(); if (!pendingOperations.isEmpty()) { - AssertJUnit.fail("Expected no pending operations in "+shadow+", but found one: "+pendingOperations); + AssertJUnit.fail("Expected no pending operations in " + shadow + ", but found one: " + pendingOperations); } } @@ -5453,14 +5365,6 @@ protected String addAndRecompute(File file, Task task, OperationResult result) t return object.getOid(); } - protected void assertAuditReferenceValue(List events, String refName, String oid, QName type, String name) { - if (events.size() != 1) { - display("Events", events); - assertEquals("Wrong # of events", 1, events.size()); - } - assertAuditReferenceValue(events.get(0), refName, oid, type, name); - } - protected void assertAuditReferenceValue(AuditEventRecord event, String refName, String oid, QName type, String name) { Set values = event.getReferenceValues(refName); assertEquals("Wrong # of reference values of '" + refName + "'", 1, values.size()); @@ -5470,14 +5374,6 @@ protected void assertAuditReferenceValue(AuditEventRecord event, String refName, assertEquals("Wrong name", name, PolyString.getOrig(value.getTargetName())); } - protected void assertAuditTarget(AuditEventRecord event, String oid, QName type, String name) { - PrismReferenceValue target = event.getTarget(); - assertNotNull("No target", target); - assertEquals("Wrong OID", oid, target.getOid()); - assertEquals("Wrong type", type, target.getTargetType()); - assertEquals("Wrong name", name, PolyString.getOrig(target.getTargetName())); - } - protected List filter(List records, AuditEventStage stage) { return records.stream() .filter(r -> r.getEventStage() == stage) @@ -5520,22 +5416,16 @@ protected void recomputeAndRefreshObjects(List objects, Task task, O } } - protected void dumpAllUsers(OperationResult initResult) throws SchemaException { - SearchResultList> users = repositoryService - .searchObjects(UserType.class, null, null, initResult); - display("Users", users); - } - protected PrismObject

assertLinkedPersona(PrismObject focus, Class

personaClass, String subtype) throws ObjectNotFoundException, SchemaException { OperationResult result = new OperationResult("assertLinkedPersona"); - for (ObjectReferenceType personaRef: focus.asObjectable().getPersonaRef()) { - PrismObject

persona = repositoryService.getObject((Class

)ObjectTypes.getObjectTypeFromTypeQName(personaRef.getType()).getClassDefinition(), + for (ObjectReferenceType personaRef : focus.asObjectable().getPersonaRef()) { + PrismObject

persona = repositoryService.getObject((Class

) ObjectTypes.getObjectTypeFromTypeQName(personaRef.getType()).getClassDefinition(), personaRef.getOid(), null, result); if (isTypeAndSubtype(persona, personaClass, subtype)) { return persona; } } - fail("No persona "+personaClass.getSimpleName()+"/"+subtype+" in "+focus); + fail("No persona " + personaClass.getSimpleName() + "/" + subtype + " in " + focus); return null; // not reached } @@ -5551,8 +5441,8 @@ protected boolean isTypeAndSubtype(PrismObject focus, C protected PrismObject getOrg(String orgName) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { PrismObject org = findObjectByName(OrgType.class, orgName); - assertNotNull("The org "+orgName+" is missing!", org); - display("Org "+orgName, org); + assertNotNull("The org " + orgName + " is missing!", org); + display("Org " + orgName, org); PrismAsserts.assertPropertyValue(org, OrgType.F_NAME, createPolyString(orgName)); return org; } @@ -5574,9 +5464,9 @@ protected void transplantGlobalPolicyRulesAdd(File configWithGlobalRulesFile, Ta PrismObject rules = prismContext.parserFor(configWithGlobalRulesFile).parse(); ObjectDelta delta = prismContext.deltaFor(SystemConfigurationType.class) .item(SystemConfigurationType.F_GLOBAL_POLICY_RULE).add( - rules.asObjectable().getGlobalPolicyRule().stream() - .map(r -> r.clone().asPrismContainerValue()) - .collect(Collectors.toList())) + rules.asObjectable().getGlobalPolicyRule().stream() + .map(r -> r.clone().asPrismContainerValue()) + .collect(Collectors.toList())) .asObjectDeltaCast(SystemObjectsType.SYSTEM_CONFIGURATION.value()); modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, parentResult); } @@ -5586,7 +5476,7 @@ protected void displayProvisioningScripts() { } protected void displayProvisioningScripts(String dummyName) { - display("Provisioning scripts "+dummyName, getDummyResource(dummyName).getScriptHistory()); + display("Provisioning scripts " + dummyName, getDummyResource(dummyName).getScriptHistory()); } protected void purgeProvisioningScriptHistory() { @@ -5600,7 +5490,7 @@ protected void purgeProvisioningScriptHistory(String dummyName) { protected void assertNoProvisioningScripts() { if (!getDummyResource().getScriptHistory().isEmpty()) { IntegrationTestTools.displayScripts(getDummyResource().getScriptHistory()); - AssertJUnit.fail(getDummyResource().getScriptHistory().size()+" provisioning scripts were executed while not expected any"); + AssertJUnit.fail(getDummyResource().getScriptHistory().size() + " provisioning scripts were executed while not expected any"); } } @@ -5619,8 +5509,11 @@ protected void applyPasswordPolicy(String passwordPolicyOid, String securityPoli } } - protected void assertPasswordCompliesWithPolicy(PrismObject user, String passwordPolicyOid) throws EncryptionException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { - Task task = getTestTask(); + protected void assertPasswordCompliesWithPolicy( + PrismObject user, String passwordPolicyOid) + throws EncryptionException, ObjectNotFoundException, ExpressionEvaluationException, + SchemaException, CommunicationException, ConfigurationException, SecurityViolationException { + Task task = createTask("assertPasswordCompliesWithPolicy"); OperationResult result = task.getResult(); assertPasswordCompliesWithPolicy(user, passwordPolicyOid, task, result); assertSuccess(result); @@ -5628,12 +5521,12 @@ protected void assertPasswordCompliesWithPolicy(PrismObject user, Stri protected void assertPasswordCompliesWithPolicy(PrismObject user, String passwordPolicyOid, Task task, OperationResult result) throws EncryptionException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { String password = getPassword(user); - display("Password of "+user, password); + display("Password of " + user, password); PrismObject passwordPolicy = repositoryService.getObject(ValuePolicyType.class, passwordPolicyOid, null, result); List messages = new ArrayList<>(); - boolean valid = valuePolicyProcessor.validateValue(password, passwordPolicy.asObjectable(), createUserOriginResolver(user), messages, "validating password of "+user, task, result); + boolean valid = valuePolicyProcessor.validateValue(password, passwordPolicy.asObjectable(), createUserOriginResolver(user), messages, "validating password of " + user, task, result); if (!valid) { - fail("Password for "+user+" does not comply with password policy: "+messages); + fail("Password for " + user + " does not comply with password policy: " + messages); } } @@ -5645,16 +5538,6 @@ protected FocusValuePolicyOriginResolver createUserOriginResolver(Pris } } - protected List> getTasksForObject(String oid, QName type, - Collection> options, Task task, OperationResult result) - throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, - ConfigurationException, ExpressionEvaluationException { - ObjectQuery query = prismContext.queryFor(TaskType.class) - .item(TaskType.F_OBJECT_REF).ref(itemFactory().createReferenceValue(oid, type)) - .build(); - return modelService.searchObjects(TaskType.class, query, options, task, result); - } - protected List> getCasesForObject(String oid, QName type, Collection> options, Task task, OperationResult result) throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, @@ -5718,7 +5601,7 @@ public class TestCtx { TestCtx(Object testCase, String name) { this.name = name; TestUtil.displayTestTitle(testCase, name); - task = taskManager.createTaskInstance(testCase.getClass().getName() + "." + name); + task = createTask(name); result = task.getResult(); dummyAuditService.clear(); } @@ -5742,7 +5625,7 @@ protected T runPrivileged(Producer producer) { protected void assertPendingOperationDeltas(PrismObject shadow, int expectedNumber) { List pendingOperations = shadow.asObjectable().getPendingOperation(); - assertEquals("Wrong number of pending operations in "+shadow, expectedNumber, pendingOperations.size()); + assertEquals("Wrong number of pending operations in " + shadow, expectedNumber, pendingOperations.size()); } protected PendingOperationType assertSinglePendingOperation(PrismObject shadow, @@ -5781,12 +5664,6 @@ protected PendingOperationType assertPendingOperation( expectedExecutionStatus, expectedResultStatus, null, null); } - protected PendingOperationType assertPendingOperation( - PrismObject shadow, PendingOperationType pendingOperation) { - return assertPendingOperation(shadow, pendingOperation, null, null, - OperationResultStatusType.IN_PROGRESS, null, null); - } - protected PendingOperationType assertPendingOperation( PrismObject shadow, PendingOperationType pendingOperation, XMLGregorianCalendar requestStart, XMLGregorianCalendar requestEnd, @@ -5810,21 +5687,21 @@ protected PendingOperationType assertPendingOperation( assertNotNull("No operation ", pendingOperation); ObjectDeltaType deltaType = pendingOperation.getDelta(); - assertNotNull("No delta in pending operation in "+shadow, deltaType); + assertNotNull("No delta in pending operation in " + shadow, deltaType); // TODO: check content of pending operations in the shadow - TestUtil.assertBetween("No request timestamp in pending operation in "+shadow, requestStart, requestEnd, pendingOperation.getRequestTimestamp()); + TestUtil.assertBetween("No request timestamp in pending operation in " + shadow, requestStart, requestEnd, pendingOperation.getRequestTimestamp()); PendingOperationExecutionStatusType executiontStatus = pendingOperation.getExecutionStatus(); - assertEquals("Wrong execution status in pending operation in "+shadow, expectedExecutionStatus, executiontStatus); + assertEquals("Wrong execution status in pending operation in " + shadow, expectedExecutionStatus, executiontStatus); OperationResultStatusType resultStatus = pendingOperation.getResultStatus(); - assertEquals("Wrong result status in pending operation in "+shadow, expectedResultStatus, resultStatus); + assertEquals("Wrong result status in pending operation in " + shadow, expectedResultStatus, resultStatus); // TODO: assert other timestamps if (expectedExecutionStatus == PendingOperationExecutionStatusType.COMPLETED) { - TestUtil.assertBetween("No completion timestamp in pending operation in "+shadow, completionStart, completionEnd, pendingOperation.getCompletionTimestamp()); + TestUtil.assertBetween("No completion timestamp in pending operation in " + shadow, completionStart, completionEnd, pendingOperation.getCompletionTimestamp()); } return pendingOperation; @@ -5859,7 +5736,7 @@ protected PendingOperationType findPendingOperation(PrismObject shad PendingOperationExecutionStatusType expectedExecutionStatus, OperationResultStatusType expectedResult, ChangeTypeType expectedChangeType, ItemPath itemPath) { List pendingOperations = shadow.asObjectable().getPendingOperation(); - for (PendingOperationType pendingOperation: pendingOperations) { + for (PendingOperationType pendingOperation : pendingOperations) { if (expectedExecutionStatus != null && !expectedExecutionStatus.equals(pendingOperation.getExecutionStatus())) { continue; } @@ -5875,8 +5752,8 @@ protected PendingOperationType findPendingOperation(PrismObject shad if (itemPath == null) { return pendingOperation; } - assertNotNull("No delta in pending operation in "+shadow, delta); - for (ItemDeltaType itemDelta: delta.getItemDelta()) { + assertNotNull("No delta in pending operation in " + shadow, delta); + for (ItemDeltaType itemDelta : delta.getItemDelta()) { ItemPath deltaPath = itemDelta.getPath().getItemPath(); if (itemPath.equivalent(deltaPath)) { return pendingOperation; @@ -5916,16 +5793,13 @@ protected UserAsserter assertUser(String oid, String message) throws Objec PrismObject user = getUser(oid); return assertUser(user, message); } - protected RepoOpAsserter createRepoOpAsserter(PerformanceInformation performanceInformation, String details) { - return new RepoOpAsserter(performanceInformation, details); - } protected RepoOpAsserter createRepoOpAsserter(String details) { PerformanceInformation repoPerformanceInformation = repositoryService.getPerformanceMonitor().getThreadLocalPerformanceInformation(); return new RepoOpAsserter(repoPerformanceInformation, details); } - protected UserAsserter assertUser(PrismObject user, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + protected UserAsserter assertUser(PrismObject user, String message) { UserAsserter asserter = UserAsserter.forUser(user, message); initializeAsserter(asserter); asserter.display(); @@ -5934,7 +5808,7 @@ protected UserAsserter assertUser(PrismObject user, String messa protected UserAsserter assertUserByUsername(String username, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { PrismObject user = findUserByUsername(username); - assertNotNull("User with username '"+username+"' was not found", user); + assertNotNull("User with username '" + username + "' was not found", user); UserAsserter asserter = UserAsserter.forUser(user, message); initializeAsserter(asserter); return asserter; @@ -5947,7 +5821,7 @@ protected OrgAsserter assertOrg(String oid, String message) throws ObjectN return asserter; } - protected OrgAsserter assertOrg(PrismObject org, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + protected OrgAsserter assertOrg(PrismObject org, String message) { OrgAsserter asserter = OrgAsserter.forOrg(org, message); initializeAsserter(asserter); return asserter; @@ -5962,7 +5836,7 @@ protected OrgAsserter assertOrgAfter(String oid) throws ObjectNotFoundExce protected OrgAsserter assertOrgByName(String name, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { PrismObject org = findObjectByName(OrgType.class, name); - assertNotNull("No org with name '"+name+"'", org); + assertNotNull("No org with name '" + name + "'", org); OrgAsserter asserter = OrgAsserter.forOrg(org, message); initializeAsserter(asserter); asserter.assertName(name); @@ -5978,13 +5852,13 @@ protected RoleAsserter assertRole(String oid, String message) throws Objec protected RoleAsserter assertRoleByName(String name, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { PrismObject role = findObjectByName(RoleType.class, name); - assertNotNull("No role with name '"+name+"'", role); + assertNotNull("No role with name '" + name + "'", role); RoleAsserter asserter = assertRole(role, message); asserter.assertName(name); return asserter; } - protected RoleAsserter assertRole(PrismObject role, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + protected RoleAsserter assertRole(PrismObject role, String message) { RoleAsserter asserter = RoleAsserter.forRole(role, message); initializeAsserter(asserter); asserter.display(); @@ -6006,45 +5880,37 @@ protected RoleAsserter assertRoleAfterByName(String name) throws ObjectNot return asserter; } - protected FocusAsserter assertService(String oid, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + protected FocusAsserter assertService(String oid, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { PrismObject service = getObject(ServiceType.class, oid); // TODO: change to ServiceAsserter later - FocusAsserter asserter = FocusAsserter.forFocus(service, message); + FocusAsserter asserter = FocusAsserter.forFocus(service, message); initializeAsserter(asserter); asserter.assertOid(oid); return asserter; } - protected FocusAsserter assertServiceByName(String name, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + protected FocusAsserter assertServiceByName(String name, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { PrismObject service = findServiceByName(name); // TODO: change to ServiceAsserter later - FocusAsserter asserter = FocusAsserter.forFocus(service, message); + FocusAsserter asserter = FocusAsserter.forFocus(service, message); initializeAsserter(asserter); asserter.assertName(name); return asserter; } - protected FocusAsserter assertServiceAfterByName(String name) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + protected FocusAsserter assertServiceAfterByName(String name) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { return assertServiceByName(name, "after"); } - protected FocusAsserter assertServiceBeforeByName(String name) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - return assertServiceByName(name, "before"); - } - - protected FocusAsserter assertServiceAfter(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + protected FocusAsserter assertServiceAfter(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { return assertService(oid, "after"); } - protected FocusAsserter assertServiceBefore(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - return assertService(oid, "before"); - } - protected void assertNoServiceByName(String name) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { PrismObject service = findServiceByName(name); if (service != null) { display("Unexpected service", service); - fail("Unexpected "+service); + fail("Unexpected " + service); } } @@ -6067,7 +5933,7 @@ protected ShadowAsserter assertModelShadow(String oid) throws ObjectNotFou PrismObject repoShadow = getShadowModel(oid); ShadowAsserter asserter = ShadowAsserter.forShadow(repoShadow, "model"); asserter - .display(); + .display(); return asserter; } @@ -6075,7 +5941,7 @@ protected ShadowAsserter assertModelShadowNoFetch(String oid) throws Objec PrismObject repoShadow = getShadowModelNoFetch(oid); ShadowAsserter asserter = ShadowAsserter.forShadow(repoShadow, "model(noFetch)"); asserter - .display(); + .display(); return asserter; } @@ -6083,7 +5949,7 @@ protected ShadowAsserter assertModelShadowFuture(String oid) throws Object PrismObject repoShadow = getShadowModelFuture(oid); ShadowAsserter asserter = ShadowAsserter.forShadow(repoShadow, "model(future)"); asserter - .display(); + .display(); return asserter; } @@ -6093,41 +5959,16 @@ protected ShadowAsserter assertModelShadowFutureNoFetch(String oid) throws PrismObject repoShadow = getShadowModel(oid, options, true); ShadowAsserter asserter = ShadowAsserter.forShadow(repoShadow, "model(future,noFetch)"); asserter - .display(); + .display(); return asserter; } - protected void assertNoModelShadow(String oid) throws SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = getTestTask(); - OperationResult result = task.getResult(); - try { - PrismObject shadow = modelService.getObject(ShadowType.class, oid, null, task, result); - fail("Expected that shadow "+oid+" will not be in the model. But it was: "+shadow); - } catch (ObjectNotFoundException e) { - // Expected - assertFailure(result); - } - } - - protected void assertNoModelShadowFuture(String oid) throws SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = getTestTask(); - OperationResult result = task.getResult(); - Collection> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); - try { - PrismObject shadow = modelService.getObject(ShadowType.class, oid, options, task, result); - fail("Expected that future shadow "+oid+" will not be in the model. But it was: "+shadow); - } catch (ObjectNotFoundException e) { - // Expected - assertFailure(result); - } - } - protected ResourceAsserter assertResource(String oid, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { PrismObject resource = getObject(ResourceType.class, oid); return assertResource(resource, message); } - protected ResourceAsserter assertResource(PrismObject user, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + protected ResourceAsserter assertResource(PrismObject user, String message) { ResourceAsserter asserter = ResourceAsserter.forResource(user, message); initializeAsserter(asserter); asserter.display(); @@ -6140,8 +5981,8 @@ protected ResourceAsserter assertResourceAfter(String oid) throws ObjectNo return asserter; } - protected ModelContextAsserter assertPreviewContext(ModelContext previewContext) { - ModelContextAsserter asserter = ModelContextAsserter.forContext(previewContext, "preview context"); + protected ModelContextAsserter assertPreviewContext(ModelContext previewContext) { + ModelContextAsserter asserter = ModelContextAsserter.forContext(previewContext, "preview context"); initializeAsserter(asserter); asserter.display(); return asserter; @@ -6161,7 +6002,7 @@ protected void assertGetDeny(Class type, String oid) t } protected void assertGetDeny(Class type, String oid, Collection> options) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertGetDeny"); + Task task = createTask("assertGetDeny"); OperationResult result = task.getResult(); try { logAttempt("get", type, oid, null); @@ -6180,7 +6021,7 @@ protected PrismObject assertGetAllow(Class type, St } protected PrismObject assertGetAllow(Class type, String oid, Collection> options) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertGetAllow"); + Task task = createTask("assertGetAllow"); OperationResult result = task.getResult(); logAttempt("get", type, oid, null); PrismObject object = modelService.getObject(type, oid, options, task, result); @@ -6212,7 +6053,6 @@ protected void assertSearchDeny(Class type, ObjectQuer } } - protected SearchResultList> assertSearch(Class type, ObjectQuery query, Collection> options, int expectedResults) throws Exception { ObjectQuery originalQuery = query != null ? query.clone() : null; @@ -6237,18 +6077,13 @@ public void assertCount(int count) throws Exception { } } - }); + }); } protected void assertSearch(Class type, ObjectQuery query, String... expectedOids) throws Exception { assertSearch(type, query, null, expectedOids); } - protected void assertSearchFilter(Class type, ObjectFilter filter, - Collection> options, String... expectedOids) throws Exception { - assertSearch(type, prismContext.queryFactory().createQuery(filter), options, expectedOids); - } - protected void assertSearchFilter(Class type, ObjectFilter filter, String... expectedOids) throws Exception { assertSearch(type, prismContext.queryFactory().createQuery(filter), expectedOids); } @@ -6261,8 +6096,8 @@ protected void assertSearch(Class type, ObjectQuery qu @Override public void assertObjects(String message, List> objects) throws Exception { if (!MiscUtil.unorderedCollectionEquals(objects, Arrays.asList(expectedOids), - (object,expectedOid) -> expectedOid.equals(object.getOid()))) { - failAllow(message, type, (query==null?"null":query.toString())+", expected "+Arrays.toString(expectedOids)+", actual "+objects, null); + (object, expectedOid) -> expectedOid.equals(object.getOid()))) { + failAllow(message, type, (query == null ? "null" : query.toString()) + ", expected " + Arrays.toString(expectedOids) + ", actual " + objects, null); } } @@ -6273,12 +6108,12 @@ public void assertCount(int count) throws Exception { } } - }); + }); } protected SearchResultList> assertSearch(Class type, ObjectQuery query, Collection> options, SearchAssertion assertion) throws Exception { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertSearchObjects"); + Task task = createTask("assertSearchObjects"); OperationResult result = task.getResult(); SearchResultList> objects; try { @@ -6295,7 +6130,7 @@ protected SearchResultList> assertSearch(C return null; // not reached } - task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertSearchObjectsIterative"); + task = createTask("assertSearchObjectsIterative"); result = task.getResult(); try { logAttempt("searchIterative", type, query); @@ -6319,7 +6154,7 @@ public boolean handle(PrismObject object, OperationResult parentResult) { return null; // not reached } - task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertSearchObjects.count"); + task = createTask("assertSearchObjects.count"); result = task.getResult(); try { logAttempt("count", type, query); @@ -6338,7 +6173,6 @@ public boolean handle(PrismObject object, OperationResult parentResult) { return objects; } - protected void assertAddDeny(File file) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, IOException { assertAddDeny(file, null); } @@ -6352,8 +6186,8 @@ protected void assertAddDeny(File file, ModelExecuteOptio assertAddDeny(object, options); } - protected void assertAddDeny(PrismObject object, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, IOException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertAddDeny"); + protected void assertAddDeny(PrismObject object, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException { + Task task = createTask("assertAddDeny"); OperationResult result = task.getResult(); ObjectDelta addDelta = object.createAddDelta(); try { @@ -6387,17 +6221,17 @@ protected OperationResult assertAddAllowTracing(File file } protected OperationResult assertAddAllow(PrismObject object, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { - Task task = createAllowDenyTask(AbstractModelIntegrationTest.class.getName() + ".assertAddAllow"); + Task task = createAllowDenyTask("assertAddAllow"); return assertAddAllow(object, options, task); } protected OperationResult assertAddAllowTracing(PrismObject object, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { - Task task = createAllowDenyTask(AbstractModelIntegrationTest.class.getName() + ".assertAddAllow"); + Task task = createAllowDenyTask(contextName() + ".assertAddAllow"); setTracing(task, createDefaultTracingProfile()); return assertAddAllow(object, options, task); } - protected OperationResult assertAddAllow(PrismObject object, ModelExecuteOptions options, Task task) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { + protected OperationResult assertAddAllow(PrismObject object, ModelExecuteOptions options, Task task) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { OperationResult result = task.getResult(); ObjectDelta addDelta = object.createAddDelta(); logAttempt("add", object.getCompileTimeClass(), object.getOid(), null); @@ -6416,8 +6250,8 @@ protected void assertDeleteDeny(Class type, String oid assertDeleteDeny(type, oid, null); } - protected void assertDeleteDeny(Class type, String oid, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertDeleteDeny"); + protected void assertDeleteDeny(Class type, String oid, ModelExecuteOptions options) throws ObjectAlreadyExistsException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException { + Task task = createTask("assertDeleteDeny"); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object().createDeleteDelta(type, oid); try { @@ -6443,7 +6277,7 @@ protected void assertDeleteAllow(Class type, String oi } protected void assertDeleteAllow(Class type, String oid, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertDeleteAllow"); + Task task = createTask("assertDeleteAllow"); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object().createDeleteDelta(type, oid); logAttempt("delete", type, oid, null); @@ -6458,24 +6292,24 @@ protected void assertDeleteAllow(Class type, String oi } private Task createAllowDenyTask(String opname) { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertAllow."+opname); + Task task = createTracedTask("createAllowDenyTask." + opname); task.setOwner(getSecurityContextPrincipalFocus()); task.setChannel(SchemaConstants.CHANNEL_GUI_USER_URI); return task; } - protected OperationResult assertAllow(String opname, Attempt attempt) throws Exception { + protected OperationResult assertAllow(String opname, Attempt attempt) throws Exception { Task task = createAllowDenyTask(opname); return assertAllow(opname, attempt, task); } - protected OperationResult assertAllowTracing(String opname, Attempt attempt) throws Exception { + protected OperationResult assertAllowTracing(String opname, Attempt attempt) throws Exception { Task task = createAllowDenyTask(opname); setTracing(task, createDefaultTracingProfile()); return assertAllow(opname, attempt, task); } - protected OperationResult assertAllow(String opname, Attempt attempt, Task task) throws Exception { + protected OperationResult assertAllow(String opname, Attempt attempt, Task task) throws Exception { OperationResult result = task.getResult(); try { logAttempt(opname); @@ -6489,7 +6323,7 @@ protected OperationResult assertAllow(String opname, Atte return result; } - protected OperationResult assertDeny(String opname, Attempt attempt) throws Exception { + protected OperationResult assertDeny(String opname, Attempt attempt) throws Exception { Task task = createAllowDenyTask(opname); OperationResult result = task.getResult(); try { @@ -6505,8 +6339,8 @@ protected OperationResult assertDeny(String opname, Attem return result; } - protected void asAdministrator(Attempt attempt) throws Exception { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".asAdministrator"); + protected void asAdministrator(Attempt attempt) throws Exception { + Task task = createTask("asAdministrator"); OperationResult result = task.getResult(); MidPointPrincipal origPrincipal = getSecurityContextPrincipal(); login(USER_ADMINISTRATOR_USERNAME); @@ -6523,127 +6357,115 @@ protected void asAdministrator(Attempt attempt) throws Ex TestUtil.assertSuccess(result); } - protected void logAttempt(String action) { - String msg = LOG_PREFIX_ATTEMPT+"Trying "+action; + protected void logAttempt(String action) { + String msg = LOG_PREFIX_ATTEMPT + "Trying " + action; System.out.println(msg); - LOGGER.info(msg); - } - - protected void logDeny(String action, Class type, ObjectQuery query) { - logDeny(action, type, query==null?"null":query.toString()); + logger.info(msg); } protected void logDeny(String action, Class type, String oid, ItemPath itemPath) { - logDeny(action, type, oid+" prop "+itemPath); + logDeny(action, type, oid + " prop " + itemPath); } protected void logDeny(String action, Class type, String desc) { - String msg = LOG_PREFIX_DENY+"Denied "+action+" of "+type.getSimpleName()+":"+desc; + String msg = LOG_PREFIX_DENY + "Denied " + action + " of " + type.getSimpleName() + ":" + desc; System.out.println(msg); - LOGGER.info(msg); + logger.info(msg); } - protected void logDeny(String action) { - String msg = LOG_PREFIX_DENY+"Denied "+action; + protected void logDeny(String action) { + String msg = LOG_PREFIX_DENY + "Denied " + action; System.out.println(msg); - LOGGER.info(msg); - } - - protected void logAllow(String action, Class type, ObjectQuery query) { - logAllow(action, type, query==null?"null":query.toString()); + logger.info(msg); } protected void logAllow(String action, Class type, String oid, ItemPath itemPath) { - logAllow(action, type, oid+" prop "+itemPath); + logAllow(action, type, oid + " prop " + itemPath); } protected void logAllow(String action, Class type, String desc) { - String msg = LOG_PREFIX_ALLOW+"Allowed "+action+" of "+type.getSimpleName()+":"+desc; + String msg = LOG_PREFIX_ALLOW + "Allowed " + action + " of " + type.getSimpleName() + ":" + desc; System.out.println(msg); - LOGGER.info(msg); + logger.info(msg); } - protected void logAllow(String action) { - String msg = LOG_PREFIX_ALLOW+"Allowed "+action; + protected void logAllow(String action) { + String msg = LOG_PREFIX_ALLOW + "Allowed " + action; System.out.println(msg); - LOGGER.info(msg); - } - - protected void logError(String action, Class type, String oid, ItemPath itemPath, Throwable e) { - logError(action, type, oid+" prop "+itemPath, e); + logger.info(msg); } protected void logError(String action, Class type, String desc, Throwable e) { - String msg = LOG_PREFIX_DENY+"Error "+action+" of "+type.getSimpleName()+":"+desc + "("+e+")"; + String msg = LOG_PREFIX_DENY + "Error " + action + " of " + type.getSimpleName() + ":" + desc + "(" + e + ")"; System.out.println(msg); - LOGGER.info(msg); + logger.info(msg); } protected void logAttempt(String action, Class type, ObjectQuery query) { - logAttempt(action, type, query==null?"null":query.toString()); + logAttempt(action, type, query == null ? "null" : query.toString()); } protected void logAttempt(String action, Class type, String oid, ItemPath itemPath) { - logAttempt(action, type, oid+" prop "+itemPath); + logAttempt(action, type, oid + " prop " + itemPath); } protected void logAttempt(String action, Class type, String desc) { - String msg = LOG_PREFIX_ATTEMPT+"Trying "+action+" of "+type.getSimpleName()+":"+desc; + String msg = LOG_PREFIX_ATTEMPT + "Trying " + action + " of " + type.getSimpleName() + ":" + desc; System.out.println(msg); - LOGGER.info(msg); + logger.info(msg); } protected void failDeny(String action, Class type, ObjectQuery query, int expected, int actual) { - failDeny(action, type, (query==null?"null":query.toString())+", expected "+expected+", actual "+actual); + failDeny(action, type, (query == null ? "null" : query.toString()) + ", expected " + expected + ", actual " + actual); } protected void failDeny(String action, Class type, String oid, ItemPath itemPath) { - failDeny(action, type, oid+" prop "+itemPath); + failDeny(action, type, oid + " prop " + itemPath); } protected void failDeny(String action, Class type, String desc) { - String msg = "Failed to deny "+action+" of "+type.getSimpleName()+":"+desc; - System.out.println(LOG_PREFIX_FAIL+msg); - LOGGER.error(LOG_PREFIX_FAIL+msg); + String msg = "Failed to deny " + action + " of " + type.getSimpleName() + ":" + desc; + System.out.println(LOG_PREFIX_FAIL + msg); + logger.error(LOG_PREFIX_FAIL + msg); AssertJUnit.fail(msg); } - protected void failDeny(String action) { - String msg = "Failed to deny "+action; - System.out.println(LOG_PREFIX_FAIL+msg); - LOGGER.error(LOG_PREFIX_FAIL+msg); + protected void failDeny(String action) { + String msg = "Failed to deny " + action; + System.out.println(LOG_PREFIX_FAIL + msg); + logger.error(LOG_PREFIX_FAIL + msg); AssertJUnit.fail(msg); } protected void failAllow(String action, Class type, ObjectQuery query, SecurityViolationException e) throws SecurityViolationException { - failAllow(action, type, query==null?"null":query.toString(), e); + failAllow(action, type, query == null ? "null" : query.toString(), e); } protected void failAllow(String action, Class type, ObjectQuery query, int expected, int actual) throws SecurityViolationException { - failAllow(action, type, (query==null?"null":query.toString())+", expected "+expected+", actual "+actual, null); + failAllow(action, type, (query == null ? "null" : query.toString()) + ", expected " + expected + ", actual " + actual, null); } protected void failAllow(String action, Class type, String oid, ItemPath itemPath, SecurityViolationException e) throws SecurityViolationException { - failAllow(action, type, oid+" prop "+itemPath, e); + failAllow(action, type, oid + " prop " + itemPath, e); } protected void failAllow(String action, Class type, String desc, SecurityViolationException e) throws SecurityViolationException { - String msg = "Failed to allow "+action+" of "+type.getSimpleName()+":"+desc; - System.out.println(LOG_PREFIX_FAIL+msg); - LOGGER.error(LOG_PREFIX_FAIL+msg); + String msg = "Failed to allow " + action + " of " + type.getSimpleName() + ":" + desc; + System.out.println(LOG_PREFIX_FAIL + msg); + logger.error(LOG_PREFIX_FAIL + msg); if (e != null) { - throw new SecurityViolationException(msg+": "+e.getMessage(), e); + throw new SecurityViolationException(msg + ": " + e.getMessage(), e); } else { AssertJUnit.fail(msg); } } - protected void failAllow(String action, SecurityViolationException e) throws SecurityViolationException { - String msg = "Failed to allow "+action; - System.out.println(LOG_PREFIX_FAIL+msg); - LOGGER.error(LOG_PREFIX_FAIL+msg); + protected void failAllow(String action, SecurityViolationException e) throws SecurityViolationException { + String msg = "Failed to allow " + action; + System.out.println(LOG_PREFIX_FAIL + msg); + logger.error(LOG_PREFIX_FAIL + msg); if (e != null) { - throw new SecurityViolationException(msg+": "+e.getMessage(), e); + throw new SecurityViolationException(msg + ": " + e.getMessage(), e); } else { AssertJUnit.fail(msg); } @@ -6652,7 +6474,7 @@ protected void failAllow(String action, SecurityViolation protected ArchetypePolicyAsserter assertArchetypePolicy(PrismObject object) throws SchemaException, ConfigurationException { OperationResult result = new OperationResult("assertArchetypePolicy"); ArchetypePolicyType archetypePolicy = modelInteractionService.determineArchetypePolicy(object, result); - ArchetypePolicyAsserter asserter = new ArchetypePolicyAsserter<>(archetypePolicy, null, "for "+object); + ArchetypePolicyAsserter asserter = new ArchetypePolicyAsserter<>(archetypePolicy, null, "for " + object); initializeAsserter(asserter); asserter.display(); return asserter; @@ -6661,7 +6483,7 @@ protected ArchetypePolicyAsserter assertA protected AssignmentCandidatesSpecificationAsserter assertAssignmentTargetSpecification(PrismObject object) throws SchemaException, ConfigurationException { OperationResult result = new OperationResult("assertAssignmentTargetSpecification"); AssignmentCandidatesSpecification targetSpec = modelInteractionService.determineAssignmentTargetSpecification(object, result); - AssignmentCandidatesSpecificationAsserter asserter = new AssignmentCandidatesSpecificationAsserter<>(targetSpec, null, "targets for "+object); + AssignmentCandidatesSpecificationAsserter asserter = new AssignmentCandidatesSpecificationAsserter<>(targetSpec, null, "targets for " + object); initializeAsserter(asserter); asserter.display(); return asserter; @@ -6670,7 +6492,7 @@ protected AssignmentCandidatesSpecificationAsse protected AssignmentCandidatesSpecificationAsserter assertAssignmentHolderSpecification(PrismObject object) throws SchemaException, ConfigurationException { OperationResult result = new OperationResult("assertAssignmentHolderSpecification"); AssignmentCandidatesSpecification targetSpec = modelInteractionService.determineAssignmentHolderSpecification(object, result); - AssignmentCandidatesSpecificationAsserter asserter = new AssignmentCandidatesSpecificationAsserter<>(targetSpec, null, "holders for "+object); + AssignmentCandidatesSpecificationAsserter asserter = new AssignmentCandidatesSpecificationAsserter<>(targetSpec, null, "holders for " + object); initializeAsserter(asserter); asserter.display(); return asserter; diff --git a/model/notifications-impl/src/test/java/com/evolveum/midpoint/notifications/impl/TestTextFormatter.java b/model/notifications-impl/src/test/java/com/evolveum/midpoint/notifications/impl/TestTextFormatter.java index 0386350d5a7..0f335fac4e8 100644 --- a/model/notifications-impl/src/test/java/com/evolveum/midpoint/notifications/impl/TestTextFormatter.java +++ b/model/notifications-impl/src/test/java/com/evolveum/midpoint/notifications/impl/TestTextFormatter.java @@ -6,6 +6,22 @@ */ package com.evolveum.midpoint.notifications.impl; +import static org.testng.AssertJUnit.assertFalse; +import static org.testng.AssertJUnit.assertTrue; + +import java.io.File; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import java.util.Locale; +import javax.xml.bind.JAXBException; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.Test; +import org.xml.sax.SAXException; + import com.evolveum.midpoint.notifications.impl.formatters.TextFormatter; import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.PrismObject; @@ -15,6 +31,7 @@ import com.evolveum.midpoint.schema.DeltaConvertor; import com.evolveum.midpoint.schema.MidPointPrismContextFactory; import com.evolveum.midpoint.schema.constants.MidPointConstants; +import com.evolveum.midpoint.test.util.AbstractSpringTest; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType; @@ -22,24 +39,6 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import javax.xml.bind.JAXBException; - -import java.io.File; -import java.io.IOException; -import java.util.Arrays; -import java.util.List; -import java.util.Locale; - -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertTrue; - /** * @author mederly */ @@ -57,7 +56,7 @@ "classpath:ctx-model-common.xml", "classpath:ctx-notifications-test.xml", "classpath*:ctx-notifications.xml"}) -public class TestTextFormatter extends AbstractTestNGSpringContextTests { +public class TestTextFormatter extends AbstractSpringTest { public static final String OBJECTS_DIR_NAME = "src/test/resources/objects"; public static final String USER_JACK_FILE = OBJECTS_DIR_NAME + "/user-jack.xml"; @@ -258,27 +257,6 @@ public void test030FormatAccount() throws Exception { assertTrue("account password is not shown", jackFormattedHideAux.contains(PASSWORD)); assertTrue("administrative status is not shown", jackFormattedHideAux.contains(ADMINISTRATIVE_STATUS)); assertTrue("effective status is shown although it should be hidden", !jackFormattedHideAux.contains(EFFECTIVE_STATUS)); - -// AssertJUnit.assertTrue("hidden operational attribute when it should be shown ('hide none')", jackFormattedHideNone.contains("createTimestamp:")); -// AssertJUnit.assertTrue("hidden auxiliary attribute (effective status) when it should be shown ('hide none')", jackFormattedHideNone.contains("Effective Status: ENABLED")); -// AssertJUnit.assertTrue("hidden auxiliary attribute (family name) when it should be shown ('hide none')", jackFormattedHideNone.contains("Family Name: Sparrow")); -// AssertJUnit.assertTrue("hidden standard attribute when it should be shown ('hide none')", jackFormattedHideNone.contains("ship: Black Pearl")); -// -// AssertJUnit.assertTrue("shown operational attribute when it should be hidden ('hide oper')", !jackFormattedHideOper.contains("createTimestamp:")); -// AssertJUnit.assertTrue("hidden auxiliary attribute when it should be shown ('hide oper')", jackFormattedHideOper.contains("Effective Status: ENABLED")); -// AssertJUnit.assertTrue("hidden auxiliary attribute (family name) when it should be shown ('hide oper')", jackFormattedHideOper.contains("Family Name: Sparrow")); -// AssertJUnit.assertTrue("hidden standard attribute when it should be shown ('hide oper')", jackFormattedHideOper.contains("ship: Black Pearl")); -// -// AssertJUnit.assertTrue("shown auxiliary attribute (metadata) when it should be hidden ('hide aux')", !jackFormattedHideAux.contains("createTimestamp:")); -// AssertJUnit.assertTrue("shown auxiliary attribute (family name) when it should be hidden ('hide aux')", !jackFormattedHideAux.contains("Family Name: Sparrow")); -// AssertJUnit.assertTrue("shown auxiliary attribute (effective status) when it should be hidden ('hide aux')", !jackFormattedHideAux.contains("Effective Status: ENABLED")); -// AssertJUnit.assertTrue("hidden standard attribute when it should be shown ('hide aux')", jackFormattedHideAux.contains("ship: Black Pearl")); -// -// AssertJUnit.assertTrue("shown operational attribute when it should be hidden ('hide aux and oper')", !jackFormattedHideAuxAndOper.contains("createTimestamp:")); -// AssertJUnit.assertTrue("shown auxiliary attribute (effective status) when it should be hidden ('hide aux and oper')", !jackFormattedHideAuxAndOper.contains("Effective Status: ENABLED")); -// AssertJUnit.assertTrue("shown auxiliary attribute (family name) when it should be hidden ('hide aux and oper')", !jackFormattedHideAuxAndOper.contains("Family Name: Sparrow")); -// AssertJUnit.assertTrue("hidden standard attribute when it should be shown ('hide aux and oper')", jackFormattedHideAuxAndOper.contains("ship: Black Pearl")); - } diff --git a/model/notifications-impl/src/test/java/com/evolveum/midpoint/notifications/impl/TestTransportUtils.java b/model/notifications-impl/src/test/java/com/evolveum/midpoint/notifications/impl/TestTransportUtils.java index b4df5d5e126..3b26e115c42 100644 --- a/model/notifications-impl/src/test/java/com/evolveum/midpoint/notifications/impl/TestTransportUtils.java +++ b/model/notifications-impl/src/test/java/com/evolveum/midpoint/notifications/impl/TestTransportUtils.java @@ -14,6 +14,7 @@ import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.task.api.TaskManager; +import com.evolveum.midpoint.test.util.AbstractSpringTest; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; @@ -23,7 +24,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; import org.xml.sax.SAXException; @@ -51,7 +51,7 @@ "classpath:ctx-model-common.xml", "classpath:ctx-notifications-test.xml", "classpath*:ctx-notifications.xml"}) -public class TestTransportUtils extends AbstractTestNGSpringContextTests { +public class TestTransportUtils extends AbstractSpringTest { private static final Trace LOGGER = TraceManager.getTrace(TestTransportUtils.class); @@ -79,10 +79,10 @@ public void test010CheckVariablesWhiteList() { config.getWhiteList().add("majka@evodevel.*"); Task task = taskManager.createTaskInstance(); - List allowRecipient = new ArrayList(); - List forbiddenRecipient = new ArrayList(); + List allowRecipient = new ArrayList<>(); + List forbiddenRecipient = new ArrayList<>(); - List recipients = new ArrayList(); + List recipients = new ArrayList<>(); recipients.add("janko@evodevel.com"); recipients.add("janko@evolveum.com"); recipients.add("viliam@evodevel.com"); @@ -122,10 +122,10 @@ public void test020CheckVariablesBlackList() { config.getBlackList().add("majka@evodevel.*"); Task task = taskManager.createTaskInstance(); - List allowRecipient = new ArrayList(); - List forbiddenRecipient = new ArrayList(); + List allowRecipient = new ArrayList<>(); + List forbiddenRecipient = new ArrayList<>(); - List recipients = new ArrayList(); + List recipients = new ArrayList<>(); recipients.add("janko@evodevel.com"); recipients.add("janko@evolveum.com"); recipients.add("viliam@evodevel.com"); diff --git a/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReport.java b/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReport.java index af231e8aea6..88256a649f0 100644 --- a/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReport.java +++ b/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReport.java @@ -75,7 +75,7 @@ public void test100ReportUserList() throws Exception { PrismObject report = getObject(ReportType.class, REPORT_USER_LIST_OID); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reportManager.runReport(report, null, task, result); assertInProgress(result); @@ -85,7 +85,7 @@ public void test100ReportUserList() throws Exception { waitForTaskFinish(task.getOid(), true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject finishedTask = getTask(task.getOid()); display("Background task", finishedTask); @@ -139,7 +139,7 @@ public void test200ReportUserListScript() throws Exception { PrismObject report = getObject(ReportType.class, REPORT_USER_LIST_SCRIPT_OID); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reportManager.runReport(report, null, task, result); assertInProgress(result); @@ -149,7 +149,7 @@ public void test200ReportUserListScript() throws Exception { waitForTaskFinish(task.getOid(), true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject finishedTask = getTask(task.getOid()); display("Background task", finishedTask); @@ -200,7 +200,7 @@ protected PrismObject runReport(final String TEST_NAME, PrismObject runReport(final String TEST_NAME, PrismObject finishedTask = getTask(task.getOid()); display("Background task (finished)", finishedTask); diff --git a/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReportWebService.java b/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReportWebService.java index 731d5194a5a..2ea0f78ad26 100644 --- a/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReportWebService.java +++ b/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReportWebService.java @@ -74,11 +74,11 @@ public void test100ProcessReportUserList() throws Exception { RemoteReportParametersType parameters = createReportParameters(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ObjectListType userList = reportWebService.processReport(REPORT_USER_LIST_EXPRESSIONS_CSV_OID, query, parameters, null); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Returned user list ("+userList.getObject().size()+" objects)", userList); assertUserList(userList); @@ -94,14 +94,14 @@ public void test110ProcessReportUserListNoReportOid() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reportWebService.processReport(null, query, parameters, null); assertNotReached(); } catch (Fault f) { // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Expected fault", f); } } @@ -116,14 +116,14 @@ public void test112ProcessReportUserListInvalidReportOid() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reportWebService.processReport("l00n3y", query, parameters, null); assertNotReached(); } catch (Fault f) { // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Expected fault", f); } } @@ -143,14 +143,14 @@ public void test115ProcessReportUserListUnauthorizedReader() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reportWebService.processReport(REPORT_USER_LIST_EXPRESSIONS_CSV_OID, query, parameters, null); assertNotReached(); } catch (Fault f) { // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Expected fault", f); } finally { login(USER_ADMINISTRATOR_USERNAME); @@ -172,14 +172,14 @@ public void test116ProcessReportUserListUnauthorizedRunner() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reportWebService.processReport(REPORT_USER_LIST_EXPRESSIONS_CSV_OID, query, parameters, null); assertNotReached(); } catch (Fault f) { // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Expected fault", f); } finally { login(USER_ADMINISTRATOR_USERNAME); @@ -202,7 +202,7 @@ public void test119ProcessReportUserListReaderRunner() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); userList = reportWebService.processReport(REPORT_USER_LIST_EXPRESSIONS_CSV_OID, query, parameters, null); } finally { @@ -210,7 +210,7 @@ public void test119ProcessReportUserListReaderRunner() throws Exception { } // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Returned user list ("+userList.getObject().size()+" objects)", userList); assertUserList(userList); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/AbstractTestAssignmentApproval.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/AbstractTestAssignmentApproval.java index 91367ea0c0b..bd3e28e5da6 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/AbstractTestAssignmentApproval.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/AbstractTestAssignmentApproval.java @@ -384,7 +384,7 @@ protected List getExpectedWorkItems() { protected void assertDeltaExecuted(int number, boolean yes, Task opTask, OperationResult result) throws Exception { if (number == 1) { if (yes) { - assertAssignedRole(userJackOid, getRoleOid(1), opTask, result); + assertAssignedRole(userJackOid, getRoleOid(1), result); checkAuditRecords(createResultMap(getRoleOid(1), WorkflowResult.APPROVED)); checkUserApprovers(userJackOid, Collections.singletonList(realApproverOid), result); } else { @@ -527,7 +527,7 @@ protected void assertDeltaExecuted(int number, boolean yes, Task opTask, Operati case 0: if (yes) { assertUserProperty(userJackOid, UserType.F_DESCRIPTION, testName); - assertAssignedRole(userJackOid, getRoleOid(4), opTask, result); + assertAssignedRole(userJackOid, getRoleOid(4), result); } else { if (originalDescription != null) { assertUserProperty(userJackOid, UserType.F_DESCRIPTION, originalDescription); @@ -541,7 +541,7 @@ protected void assertDeltaExecuted(int number, boolean yes, Task opTask, Operati case 2: case 3: if (yes) { - assertAssignedRole(userJackOid, getRoleOid(number), opTask, result); + assertAssignedRole(userJackOid, getRoleOid(number), result); } else { assertNotAssignedRole(userJackOid, getRoleOid(number), opTask, result); } diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentsAdvanced.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentsAdvanced.java index 58593529b23..85c0c1d0d9a 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentsAdvanced.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentsAdvanced.java @@ -356,11 +356,11 @@ public void test600AssignRole29() throws Exception { OperationResult result = getResult(); // WHEN - displayWhen(); + when(); assignRole(userJackOid, roleRole29Oid, task, result); // should proceed without approvals // THEN - displayThen(); + then(); PrismObject jack = getUser(userJackOid); display("jack", jack); assertAssignedRoles(jack, roleRole29Oid); @@ -371,7 +371,7 @@ public void test610ModifyAssignmentOfRole29() throws Exception { login(userAdministrator); // WHEN - displayWhen(); + when(); PrismObject jackBefore = getUser(userJackOid); AssignmentType assignment = findAssignmentByTargetRequired(jackBefore, roleRole29Oid); ObjectDelta deltaToApprove = prismContext.deltaFor(UserType.class) @@ -465,7 +465,7 @@ protected void afterFirstClockworkRun(CaseType rootCase, List subcases }, 1, false); // THEN - displayThen(); + then(); PrismObject jackAfter = getUser(userJackOid); display("jack after", jackAfter); assertAssignedRoles(jackAfter, roleRole29Oid); @@ -487,7 +487,7 @@ public void test620ModifyAssignmentOfRole29Immediate() throws Exception { login(userAdministrator); // WHEN - displayWhen(); + when(); PrismObject jackBefore = getUser(userJackOid); AssignmentType assignment = findAssignmentByTargetRequired(jackBefore, roleRole29Oid); ObjectDelta deltaToApprove = prismContext.deltaFor(UserType.class) @@ -582,7 +582,7 @@ protected void afterFirstClockworkRun(CaseType rootCase, List subcases }, 1, true); // THEN - displayThen(); + then(); PrismObject jackAfter = getUser(userJackOid); display("jack after", jackAfter); assertAssignedRoles(jackAfter, roleRole29Oid); @@ -596,11 +596,11 @@ public void test630UnassignRole29() throws Exception { OperationResult result = getResult(); // WHEN - displayWhen(); + when(); unassignRoleByAssignmentValue(getUser(userJackOid), roleRole29Oid, task, result); // should proceed without approvals // THEN - displayThen(); + then(); PrismObject jack = getUser(userJackOid); display("jack", jack); assertNotAssignedRole(jack, roleRole29Oid); @@ -708,7 +708,7 @@ protected void afterFirstClockworkRun(CaseType rootCase, List subcases }, 1, false); // THEN - displayThen(); + then(); PrismObject jack = getUser(userJackOid); display("jack", jack); assertAssignedRoles(jack, roleRole28Oid); @@ -720,7 +720,7 @@ public void test710ModifyAssignmentOfRole28() throws Exception { login(userAdministrator); // WHEN - displayWhen(); + when(); PrismObject jackBefore = getUser(userJackOid); AssignmentType assignment = findAssignmentByTargetRequired(jackBefore, roleRole28Oid); ObjectDelta deltaToApprove = prismContext.deltaFor(UserType.class) @@ -816,7 +816,7 @@ protected void afterFirstClockworkRun(CaseType rootCase, List subcases }, 1, false); // THEN - displayThen(); + then(); PrismObject jackAfter = getUser(userJackOid); display("jack after", jackAfter); assertAssignedRoles(jackAfter, roleRole28Oid); @@ -828,7 +828,7 @@ public void test720UnassignRole28() throws Exception { login(userAdministrator); // WHEN - displayWhen(); + when(); PrismObject jackBefore = getUser(userJackOid); AssignmentType assignment = findAssignmentByTargetRequired(jackBefore, roleRole28Oid); ObjectDelta deltaToApprove = prismContext.deltaFor(UserType.class) @@ -925,7 +925,7 @@ protected void afterFirstClockworkRun(CaseType rootCase, List subcases }, 1, false); // THEN - displayThen(); + then(); PrismObject jackAfter = getUser(userJackOid); display("jack after", jackAfter); assertNotAssignedRole(jackAfter, roleRole28Oid); @@ -938,7 +938,7 @@ public void test800AssignRole27() throws Exception { OperationResult result = getResult(); // WHEN - displayWhen(); + when(); ObjectDelta delta = prismContext.deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT) .add(ObjectTypeUtil.createAssignmentTo(roleRole27Oid, ObjectTypes.ROLE, prismContext) @@ -947,7 +947,7 @@ public void test800AssignRole27() throws Exception { executeChanges(delta, null, task, result); // should proceed without approvals (only 1 of the items is present) // THEN - displayThen(); + then(); PrismObject jack = getUser(userJackOid); display("jack", jack); assertAssignedRoles(jack, roleRole27Oid); @@ -960,7 +960,7 @@ public void test810ModifyAssignmentOfRole27() throws Exception { OperationResult result = getResult(); // WHEN - displayWhen(); + when(); PrismObject jackBefore = getUser(userJackOid); AssignmentType assignmentBefore = findAssignmentByTargetRequired(jackBefore, roleRole27Oid); ObjectDelta delta = prismContext.deltaFor(UserType.class) @@ -971,7 +971,7 @@ public void test810ModifyAssignmentOfRole27() throws Exception { executeChanges(delta, null, task, result); // should proceed without approvals (only 1 of the items is present) // THEN - displayThen(); + then(); PrismObject jack = getUser(userJackOid); display("jack", jack); AssignmentType assignment = findAssignmentByTargetRequired(jack, roleRole27Oid); @@ -985,11 +985,11 @@ public void test820UnassignRole27() throws Exception { OperationResult result = getResult(); // WHEN - displayWhen(); + when(); unassignRoleByAssignmentValue(getUser(userJackOid), roleRole27Oid, task, result); // should proceed without approvals // THEN - displayThen(); + then(); PrismObject jack = getUser(userJackOid); display("jack", jack); assertNotAssignedRole(jack, roleRole27Oid); @@ -1002,7 +1002,7 @@ public void test900AssignIdempotentRole() throws Exception { OperationResult result = getResult(); // WHEN - displayWhen(); + when(); unassignAllRoles(userJackOid); ObjectDelta delta = prismContext.deltaFor(UserType.class) @@ -1017,7 +1017,7 @@ public void test900AssignIdempotentRole() throws Exception { executeChanges(delta, null, task, result); // THEN - displayThen(); + then(); PrismObject jack = getUser(userJackOid); display("jack", jack); assertNotAssignedRole(jack, ROLE_IDEMPOTENT.oid); @@ -1042,7 +1042,7 @@ public void test910AssignRoleWithIdempotentMetarole() throws Exception { OperationResult result = getResult(); // WHEN - displayWhen(); + when(); unassignAllRoles(userJackOid); ObjectDelta delta = prismContext.deltaFor(UserType.class) @@ -1057,7 +1057,7 @@ public void test910AssignRoleWithIdempotentMetarole() throws Exception { executeChanges(delta, null, task, result); // THEN - displayThen(); + then(); PrismObject jack = getUser(userJackOid); display("jack", jack); assertNotAssignedRole(jack, ROLE_WITH_IDEMPOTENT_METAROLE.oid); @@ -1174,7 +1174,7 @@ protected void assertDeltaExecuted(int number, boolean yes, Task opTask, Operati case 3: String[] oids = { roleRole21Oid, roleRole22Oid, roleRole23Oid }; if (yes) { - assertAssignedRole(userJackOid, oids[number-1], opTask, result); + assertAssignedRole(userJackOid, oids[number-1], result); } else { assertNotAssignedRole(userJackOid, oids[number-1], opTask, result); } @@ -1445,15 +1445,15 @@ protected void assertDeltaExecuted(int number, boolean yes, Task opTask, Operati assertNotAssignedRole(userJackOid, roleRole21Oid, opTask, result); assertNotAssignedRole(userJackOid, roleRole22Oid, opTask, result); } else { - assertAssignedRole(userJackOid, roleRole21Oid, opTask, result); - assertAssignedRole(userJackOid, roleRole22Oid, opTask, result); + assertAssignedRole(userJackOid, roleRole21Oid, result); + assertAssignedRole(userJackOid, roleRole22Oid, result); } break; case 1: if (yes) { assertNotAssignedRole(userJackOid, roleRole23Oid, opTask, result); } else { - assertAssignedRole(userJackOid, roleRole23Oid, opTask, result); + assertAssignedRole(userJackOid, roleRole23Oid, result); } break; default: diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/ManualResourceTest.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/ManualResourceTest.java index deb85220b55..4c6996006ca 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/ManualResourceTest.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/ManualResourceTest.java @@ -154,11 +154,11 @@ public void test012TestConnection() throws Exception { Task task = getTestTask(); // WHEN - displayWhen(); + when(); OperationResult testResult = modelService.testResource(RESOURCE_MANUAL_OID, task); // THEN - displayThen(); + then(); display("Test result", testResult); TestUtil.assertSuccess("Test resource failed (result)", testResult); } @@ -173,11 +173,11 @@ public void test100AssignWillRoleOne() throws Exception { dummyTransport.clearMessages(); // WHEN - displayWhen(); + when(); assignRole(userWillOid, ROLE_ONE_MANUAL_OID, task, result); // THEN - displayThen(); + then(); display("result", result); willLastCaseOid = assertInProgress(result); @@ -204,7 +204,7 @@ public void test110CloseCaseAndRecomputeWill() throws Exception { dummyTransport.clearMessages(); // WHEN - displayWhen(); + when(); CaseType caseBefore = getCase(willLastCaseOid); display("Case before work item completion", caseBefore); @@ -231,7 +231,7 @@ public void test110CloseCaseAndRecomputeWill() throws Exception { reconcileUser(userWillOid, task, result); // THEN - displayThen(); + then(); assertSuccess(result); CaseType caseAfter = getCase(willLastCaseOid); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestEscalation.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestEscalation.java index 69fd8d76e48..ff1b8c6eab6 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestEscalation.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestEscalation.java @@ -176,7 +176,7 @@ public void test130CompleteAfter14Days() throws Exception { display("rootTask", rootCase); waitForCaseClose(rootCase, 60000); - assertAssignedRole(userJackOid, ROLE_E1_OID, task, result); + assertAssignedRole(userJackOid, ROLE_E1_OID, result); } @Test diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestMiscellaneous.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestMiscellaneous.java index e0c5c7c1679..be9289c51c6 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestMiscellaneous.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestMiscellaneous.java @@ -155,7 +155,7 @@ public void test100RequesterComment() throws Exception { CaseType parentCase = getCase(aCase.getParentRef().getOid()); waitForCaseClose(parentCase); - AssignmentType assignment = assertAssignedRole(userJackOid, ROLE_SAILOR_OID, task, result); + AssignmentType assignment = assertAssignedRole(userJackOid, ROLE_SAILOR_OID, result); display("assignment after creation", assignment); MetadataType metadata = assignment.getMetadata(); assertNotNull("Null request timestamp in metadata", metadata.getRequestTimestamp()); @@ -222,7 +222,7 @@ public void test105RequesterCommentImmediate() throws Exception { CaseType parentCase = getCase(aCase.getParentRef().getOid()); waitForCaseClose(parentCase); - AssignmentType assignment = assertAssignedRole(userJackOid, ROLE_CAPTAIN_OID, task, result); + AssignmentType assignment = assertAssignedRole(userJackOid, ROLE_CAPTAIN_OID, result); display("assignment after creation", assignment); MetadataType metadata = assignment.getMetadata(); assertNotNull("Null request timestamp in metadata", metadata.getRequestTimestamp()); @@ -288,7 +288,7 @@ public void test200GetRoleByTemplate() throws Exception { result.computeStatus(); TestUtil.assertSuccess(result); - assertAssignedRole(userJackOid, ROLE_CAPTAIN_OID, task, result); + assertAssignedRole(userJackOid, ROLE_CAPTAIN_OID, result); } @Test @@ -312,7 +312,7 @@ public void test210GetRoleByTemplateAfterAssignments() throws Exception { result.computeStatus(); TestUtil.assertSuccess(result); - assertAssignedRole(userJackOid, ROLE_CAPTAIN_OID, task, result); + assertAssignedRole(userJackOid, ROLE_CAPTAIN_OID, result); } @Test @@ -334,7 +334,7 @@ public void test220GetRoleByFocusMappings() throws Exception { result.computeStatus(); TestUtil.assertSuccess(result); - assertAssignedRole(userJackOid, ROLE_CAPTAIN_OID, task, result); + assertAssignedRole(userJackOid, ROLE_CAPTAIN_OID, result); } @Test @@ -363,6 +363,6 @@ public void test250SkippingApprovals() throws Exception { result.computeStatus(); TestUtil.assertSuccess(result); - assertAssignedRole(userJackOid, ROLE_CAPTAIN_OID, task, result); + assertAssignedRole(userJackOid, ROLE_CAPTAIN_OID, result); } } diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestParallelApprovals.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestParallelApprovals.java index 70e39859742..a8927b11e1e 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestParallelApprovals.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestParallelApprovals.java @@ -121,7 +121,7 @@ public void test100ParallelApprovals() throws Exception { OperationResult result = getResult(); // WHEN - displayWhen(); + when(); ObjectDelta assignDelta = prismContext.deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT).add( ObjectTypeUtil.createAssignmentTo(roleRole50aOid, ObjectTypes.ROLE, prismContext), @@ -175,7 +175,7 @@ public void test110ParallelApprovalsAdd() throws Exception { taskManager.registerTaskListener(listener); // WHEN - displayWhen(); + when(); UserType alice = prismContext.createObjectable(UserType.class) .name("alice") .assignment(ObjectTypeUtil.createAssignmentTo(roleRole50aOid, ObjectTypes.ROLE, prismContext)) @@ -236,7 +236,7 @@ public void test120ParallelApprovalsInTwoOperations() throws Exception { taskManager.registerTaskListener(listener); // WHEN - displayWhen(); + when(); ObjectDelta assignDelta1 = prismContext.deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT).add( ObjectTypeUtil.createAssignmentTo(roleRole50aOid, ObjectTypes.ROLE, prismContext), @@ -304,7 +304,7 @@ public void test130ParallelApprovalsInThreeSummarizingOperations() throws Except taskManager.registerTaskListener(listener); // WHEN - displayWhen(); + when(); // three separate approval contexts, "summarizing" as the deltas are executed after all approvals assignRole(userChuckOid, roleRole51aOid, task1, result1); assignRole(userChuckOid, roleRole52aOid, task2, result2); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestSoD.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestSoD.java index d17da338e86..38630542a94 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestSoD.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestSoD.java @@ -88,7 +88,7 @@ public void test010AssignRoleJudge() throws Exception { // THEN display("jack as a Judge", getUser(userJackOid)); - assertAssignedRole(userJackOid, roleJudgeOid, task, result); + assertAssignedRole(userJackOid, roleJudgeOid, result); } /** @@ -183,7 +183,7 @@ protected void assertDeltaExecuted(int number, boolean yes, Task opTask, Operati case 1: if (yes) { - assertAssignedRole(userJackOid, rolePirateOid, opTask, result); + assertAssignedRole(userJackOid, rolePirateOid, result); } else { assertNotAssignedRole(userJackOid, rolePirateOid, opTask, result); } @@ -201,8 +201,8 @@ protected Boolean decideOnApproval(CaseWorkItemType caseWorkItem) throws Excepti // THEN display("jack as a Pirate + Judge", getUser(userJackOid)); - assertAssignedRole(userJackOid, roleJudgeOid, task, result); - assertAssignedRole(userJackOid, rolePirateOid, task, result); + assertAssignedRole(userJackOid, roleJudgeOid, result); + assertAssignedRole(userJackOid, rolePirateOid, result); } /** @@ -284,7 +284,7 @@ protected void assertDeltaExecuted(int number, boolean yes, Task opTask, Operati switch (number) { case 1: if (yes) { - assertAssignedRole(userJackOid, roleRespectableOid, opTask, result); + assertAssignedRole(userJackOid, roleRespectableOid, result); } else { assertNotAssignedRole(userJackOid, roleRespectableOid, opTask, result); } @@ -302,7 +302,7 @@ protected Boolean decideOnApproval(CaseWorkItemType caseWorkItem) throws Excepti // THEN display("jack as a Judge + Respectable", getUser(userJackOid)); - assertAssignedRole(userJackOid, roleJudgeOid, task, result); - assertAssignedRole(userJackOid, roleRespectableOid, task, result); + assertAssignedRole(userJackOid, roleJudgeOid, result); + assertAssignedRole(userJackOid, roleRespectableOid, result); } } diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorDiscovery.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorDiscovery.java index 497a3ada780..9324c59a487 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorDiscovery.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorDiscovery.java @@ -62,11 +62,11 @@ public void test001Connectors() throws Exception { OperationResult result = new OperationResult(TestConnectorDiscovery.class.getName() + "." + TEST_NAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); List> connectors = repositoryService.searchObjects(ConnectorType.class, null, null, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertFalse("No connector found",connectors.isEmpty()); display("Found "+connectors.size()+" discovered connector"); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorManager.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorManager.java index 39900f9bc19..1ecc9f9b1c9 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorManager.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorManager.java @@ -51,11 +51,11 @@ public void test100ListConnectorFactories() throws Exception { OperationResult result = new OperationResult(TestConnectorDiscovery.class.getName() + "." + TEST_NAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); Collection connectorFactories = connectorManager.getConnectorFactories(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertNotNull("Null connector factories", connectorFactories); assertFalse("No connector factories found", connectorFactories.isEmpty()); display("Found "+connectorFactories.size()+" connector factories"); @@ -81,11 +81,11 @@ public void test110SelfTest() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); connectorManager.connectorFrameworkSelfTest(result, task); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); } diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/AbstractCsvTest.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/AbstractCsvTest.java index 3e2a8ae6f96..a7772c97b4f 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/AbstractCsvTest.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/AbstractCsvTest.java @@ -318,7 +318,7 @@ public void test100AddAccountJack() throws Exception { PrismObject shadowBefore = parseObject(getAccountJackFile()); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); provisioningService.addObject(shadowBefore, null, null, task, result); // THEN @@ -335,7 +335,7 @@ public void test110GetAccountJack() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); PrismObject shadow = provisioningService.getObject(ShadowType.class, getAccountJackOid(), null, task, result); // THEN @@ -381,7 +381,7 @@ public void test120ModifyShadowPrimaryIdentifier() throws Exception { display("PropertyDelta", delta); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, getAccountJackOid(), Collections.singletonList(delta), null, null, task, result); 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 46e83e3734c..5385cba9f16 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 @@ -826,12 +826,12 @@ public void test032ResourceAndConnectorCaching() throws Exception { assertNotNull("No resource schema", resourceSchema); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject resourceAgain = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, null, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); ResourceType resourceTypeAgain = resourceAgain.asObjectable(); @@ -1158,11 +1158,11 @@ public void test100AddAccountWill() throws Exception { XMLGregorianCalendar start = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); String addedObjectOid = provisioningService.addObject(account, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); XMLGregorianCalendar end = clock.currentTimeXMLGregorianCalendar(); @@ -1414,11 +1414,11 @@ public void test106GetModifiedAccount() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, null, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummy.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummy.java index 2fc61e7f7be..7d1d8349f26 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummy.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummy.java @@ -83,8 +83,6 @@ import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.util.exception.SecurityViolationException; import com.evolveum.midpoint.util.exception.SystemException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType; import com.evolveum.midpoint.xml.ns._public.common.common_3.LockoutStatusType; @@ -174,11 +172,11 @@ public void test101AddAccountWithoutName() throws Exception { display("Adding shadow", account.asPrismObject()); // WHEN - displayWhen(TEST_NAME, "add"); + when("add"); String addedObjectOid = provisioningService.addObject(account.asPrismObject(), null, null, syncTask, result); // THEN - displayThen(TEST_NAME, "add"); + then("add"); result.computeStatus(); display("add object result", result); TestUtil.assertSuccess("addObject has failed (result)", result); @@ -191,12 +189,12 @@ public void test101AddAccountWithoutName() throws Exception { syncServiceMock.assertNotifySuccessOnly(); // WHEN - displayWhen(TEST_NAME, "get"); + when("get"); PrismObject provisioningAccount = provisioningService.getObject(ShadowType.class, ACCOUNT_MORGAN_OID, null, syncTask, result); // THEN - displayThen(TEST_NAME, "get"); + then("get"); display("account from provisioning", provisioningAccount); ShadowType provisioningAccountType = provisioningAccount.asObjectable(); PrismAsserts.assertEqualsPolyString("Account name was not generated (provisioning)", transformNameFromResource(ACCOUNT_MORGAN_NAME), @@ -263,7 +261,7 @@ public void test107AGetModifiedAccountFromCacheMax() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); try { @@ -272,7 +270,7 @@ public void test107AGetModifiedAccountFromCacheMax() throws Exception { assertNotReached(); } catch (ConfigurationException e) { // Caching is disabled, this is expected. - displayThen(TEST_NAME); + then(TEST_NAME); display("Expected exception", e); assertFailure(result); } @@ -316,12 +314,12 @@ public void test107BGetModifiedAccountFromCacheHighStaleness() throws Exception XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, options, null, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); display("getObject result", result); TestUtil.assertSuccess(result); @@ -362,11 +360,11 @@ public void test108GetAccountLowStaleness() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, options, null, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); display("getObject result", result); TestUtil.assertSuccess(result); @@ -734,11 +732,11 @@ public void test115CountAllAccounts() throws Exception { display("All shadows query", query); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); Integer count = provisioningService.countObjects(ShadowType.class, query, null, null, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("Found " + count + " shadows"); @@ -907,12 +905,12 @@ public void test120ModifyWillReplaceFullname() throws Exception { delta.checkConsistence(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); delta.checkConsistence(); @@ -940,12 +938,12 @@ public void test121ModifyObjectAddPirate() throws Exception { delta.checkConsistence(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); delta.checkConsistence(); @@ -974,12 +972,12 @@ public void test122ModifyObjectAddCaptain() throws Exception { delta.checkConsistence(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); delta.checkConsistence(); @@ -1007,12 +1005,12 @@ public void test123ModifyObjectDeletePirate() throws Exception { delta.checkConsistence(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); delta.checkConsistence(); @@ -1044,12 +1042,12 @@ public void test124ModifyAccountWillAddCaptainAgain() throws Exception { delta.checkConsistence(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); delta.checkConsistence(); @@ -1090,12 +1088,12 @@ public void test126ModifyAccountWillPassword() throws Exception { display("ObjectDelta", delta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertDummyAccount(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid) @@ -1137,12 +1135,12 @@ protected void testComparePassword(final String TEST_NAME, String tag, String sh syncServiceMock.reset(); // WHEN (match) - displayWhen(TEST_NAME); + when(TEST_NAME); ItemComparisonResult comparisonResult = provisioningService.compare(ShadowType.class, shadowOid, SchemaConstants.PATH_PASSWORD_VALUE, expectedPassword, task, result); // THEN (match) - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("Comparison result ("+tag+")", comparisonResult); @@ -1166,11 +1164,11 @@ public void test129NullAttributeValue() throws Exception { willDummyAccount.replaceAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, null); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject accountWill = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); ResourceAttributeContainer attributesContainer = ShadowUtil.getAttributesContainer(accountWill); @@ -1489,12 +1487,12 @@ public void test152ActivationStatusUndefinedAccount() throws Exception { delta.checkConsistence(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); display("modifyObject result", result); TestUtil.assertSuccess(result); @@ -1656,12 +1654,12 @@ public void test157SetValidTo() throws Exception { delta.checkConsistence(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); display("modifyObject result", result); TestUtil.assertSuccess(result); @@ -1711,12 +1709,12 @@ public void test158DeleteValidToValidFrom() throws Exception { delta.checkConsistence(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); display("modifyObject result", result); TestUtil.assertSuccess(result); @@ -1746,11 +1744,11 @@ public void test159GetLockedoutAccount() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, null, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); display("getObject result", result); TestUtil.assertSuccess(result); @@ -1832,12 +1830,12 @@ public void test162UnlockAccount() throws Exception { delta.checkConsistence(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); display("modifyObject result", result); TestUtil.assertSuccess(result); @@ -2276,7 +2274,7 @@ public boolean handle(PrismObject shadow, OperationResult parentResu // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); SearchResultMetadata searchMetadata; if (useRepo) { searchMetadata = repositoryService.searchObjectsIterative(ShadowType.class, query, handler, null, true, result); @@ -2285,7 +2283,7 @@ public boolean handle(PrismObject shadow, OperationResult parentResu } // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); display("searchObjectsIterative result", result); TestUtil.assertSuccess(result); @@ -2356,11 +2354,11 @@ public boolean handle(PrismObject shadow, OperationResult parentResu // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); SearchResultMetadata searchMetadata = provisioningService.searchObjectsIterative(ShadowType.class, query, options, handler, null, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); display("searchObjectsIterative result", result); TestUtil.assertSuccess(result); @@ -2739,12 +2737,12 @@ public void test220EntitleAccountWillPirates() throws Exception { delta.checkConsistence(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); display("modifyObject result", result); TestUtil.assertSuccess(result); @@ -3100,12 +3098,12 @@ public void test230DetitleAccountWillPirates() throws Exception { delta.checkConsistence(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); delta.checkConsistence(); assertAccountPiratesDetitled(); @@ -3132,12 +3130,12 @@ public void test232EntitleAccountWillPiratesIdentifiersName() throws Exception { delta.checkConsistence(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); delta.checkConsistence(); assertAccountPiratesEntitled(); @@ -3164,12 +3162,12 @@ public void test233DetitleAccountWillPiratesIdentifiersName() throws Exception { delta.checkConsistence(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); delta.checkConsistence(); assertAccountPiratesDetitled(); @@ -3196,12 +3194,12 @@ public void test234EntitleAccountWillPiratesIdentifiersUid() throws Exception { delta.checkConsistence(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); delta.checkConsistence(); assertAccountPiratesEntitled(); @@ -3228,12 +3226,12 @@ public void test235DetitleAccountWillPiratesIdentifiersUid() throws Exception { delta.checkConsistence(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); delta.checkConsistence(); assertAccountPiratesDetitled(); @@ -3638,12 +3636,12 @@ public void test300AccountRename() throws Exception { delta.checkConsistence(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); delta.checkConsistence(); @@ -3691,12 +3689,12 @@ public void test310ModifyMorganEnlistTimestamp() throws Exception { delta.checkConsistence(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); delta.checkConsistence(); @@ -3729,12 +3727,12 @@ public void test330ModifyAccountWillPasswordSelfService() throws Exception { ProvisioningOperationOptions options = ProvisioningOperationOptions.createRunAsAccountOid(ACCOUNT_WILL_OID); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), options, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); // Check if the account was created in the dummy resource @@ -3779,11 +3777,11 @@ public void test340ModifyWillReplaceGossipBloodAvast() throws Exception { List> mods = getGossipDelta(PlusMinusZero.ZERO, WILL_GOSSIP_BLOOD_OF_A_PIRATE, WILL_GOSSIP_AVAST); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, ACCOUNT_WILL_OID, mods, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertAccountWillGossip(WILL_GOSSIP_BLOOD_OF_A_PIRATE, WILL_GOSSIP_AVAST); @@ -3811,11 +3809,11 @@ public void test342ModifyWillAddGossipEunuch() throws Exception { List> mods = getGossipDelta(PlusMinusZero.PLUS, WILL_GOSSIP_EUNUCH); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, ACCOUNT_WILL_OID, mods, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertAccountWillGossip(WILL_GOSSIP_BLOOD_OF_A_PIRATE, WILL_GOSSIP_AVAST, WILL_GOSSIP_EUNUCH); @@ -3843,11 +3841,11 @@ public void test344ModifyWillDeleteGossipAvast() throws Exception { List> mods = getGossipDelta(PlusMinusZero.MINUS, WILL_GOSSIP_AVAST); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, ACCOUNT_WILL_OID, mods, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertAccountWillGossip(WILL_GOSSIP_BLOOD_OF_A_PIRATE, WILL_GOSSIP_EUNUCH); @@ -4013,14 +4011,14 @@ public void test509DeleteProtectedAccountShadow() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.deleteObject(ShadowType.class, ACCOUNT_DAEMON_OID, null, null, task, result); AssertJUnit.fail("Expected security exception while deleting 'daemon' account"); } catch (SecurityViolationException e) { // This is expected - displayThen(TEST_NAME); + then(TEST_NAME); display("Expected exception", e); } @@ -4130,11 +4128,11 @@ public void test520MigrationPrimaryIdentifierValueRefresh() throws Exception { repositoryService.addObject(shadowBefore, null, result); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowBefore, null, task, result); - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertRepoShadow(ACCOUNT_RELIC_OID) @@ -4166,14 +4164,14 @@ public void test600AddAccountAlreadyExist() throws Exception { display("Adding shadow", account); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); try { provisioningService.addObject(account, null, null, task, result); assertNotReached(); } catch (ObjectAlreadyExistsException e) { // This is expected - displayThen(TEST_NAME); + then(TEST_NAME); display("Expected exception", e); } @@ -4214,7 +4212,7 @@ public void test800LiveSyncInit() throws Exception { ProvisioningTestUtil.getDefaultAccountObjectClass(resourceType)); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.synchronize(coords, syncTokenTask, null, result); // THEN @@ -4254,7 +4252,7 @@ public void test801LiveSyncAddBlackbeard() throws Exception { ProvisioningTestUtil.getDefaultAccountObjectClass(resourceType)); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.synchronize(coords, syncTokenTask, null, result); // THEN @@ -4316,7 +4314,7 @@ public void test802LiveSyncModifyBlackbeard() throws Exception { ProvisioningTestUtil.getDefaultAccountObjectClass(resourceType)); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.synchronize(coords, syncTokenTask, null, result); // THEN @@ -4479,11 +4477,11 @@ public void testLiveSyncAddDrake(final String TEST_NAME, DummySyncStyle syncStyl objectClass); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.synchronize(coords, syncTokenTask, null, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); display("Synchronization result", result); TestUtil.assertSuccess("Synchronization result is not OK", result); @@ -4550,11 +4548,11 @@ public void testLiveSyncModifyDrake(final String TEST_NAME, DummySyncStyle syncS objectClass); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.synchronize(coords, syncTokenTask, null, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); display("Synchronization result", result); TestUtil.assertSuccess("Synchronization result is not OK", result); @@ -4610,11 +4608,11 @@ public void testLiveSyncAddCorsairs(final String TEST_NAME, DummySyncStyle syncS objectClass); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.synchronize(coords, syncTokenTask, null, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); display("Synchronization result", result); TestUtil.assertSuccess("Synchronization result is not OK", result); @@ -4686,11 +4684,11 @@ public void testLiveSyncDeleteCorsairs(final String TEST_NAME, DummySyncStyle sy objectClass); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.synchronize(coords, syncTokenTask, null, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); display("Synchronization result", result); TestUtil.assertSuccess("Synchronization result is not OK", result); @@ -4753,11 +4751,11 @@ public void testLiveSyncDeleteDrake(final String TEST_NAME, DummySyncStyle syncS objectClass); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.synchronize(coords, syncTokenTask, null, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); display("Synchronization result", result); TestUtil.assertSuccess("Synchronization result is not OK", result); @@ -4808,11 +4806,11 @@ public void test890LiveSyncModifyProtectedAccount() throws Exception { ProvisioningTestUtil.getDefaultAccountObjectClass(resourceType)); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.synchronize(coords, syncTokenTask, null, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Synchronization result", result); assertSuccess(result); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyCaching.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyCaching.java index 87583fa50ed..f10e971447a 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyCaching.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyCaching.java @@ -110,7 +110,7 @@ public void test107AGetModifiedAccountFromCacheMax() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); PrismObject shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, options, null, result); @@ -176,12 +176,12 @@ public void test107BGetModifiedAccountFromCacheHighStaleness() throws Exception XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, options, null, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); @@ -237,13 +237,13 @@ public void test107CSkipCachingForIncompleteAttributes() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject shadow = provisioningService .getObject(ShadowType.class, ACCOUNT_WILL_OID, null, null, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyConsistency.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyConsistency.java index 7d3b7e3332c..2e31f398d06 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyConsistency.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyConsistency.java @@ -116,11 +116,11 @@ public void test050AddAccountWill() throws Exception { display("Adding shadow", account); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); String addedObjectOid = provisioningService.addObject(account, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertEquals(ACCOUNT_WILL_OID, addedObjectOid); syncServiceMock.assertNotifySuccessOnly(); @@ -179,11 +179,11 @@ public void test100AddAccountMorganCommunicationFailure() throws Exception { lastRequestStartTs = lastAttemptStartTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); String addedObjectOid = provisioningService.addObject(account, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Result", result); assertInProgress(result); assertEquals(ACCOUNT_MORGAN_OID, addedObjectOid); @@ -211,11 +211,11 @@ public void test102GetAccountMorganRecovery() throws Exception { dummyResource.resetBreakMode(); // WHEN - displayWhen(); + when(); assertGetUncreatedShadow(ACCOUNT_MORGAN_OID); // THEN - displayThen(); + then(); syncServiceMock.assertNoNotifcations(); assertUncreatedMorgan(1); @@ -240,11 +240,11 @@ public void test104RefreshAccountMorganCommunicationFailure() throws Exception { PrismObject shadowRepoBefore = getShadowRepo(ACCOUNT_MORGAN_OID); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Result", result); assertSuccess(result); syncServiceMock.assertNoNotifcations(); @@ -272,7 +272,7 @@ public void test105GetForceRefreshAccountMorganCommunicationFailure() throws Exc try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.getObject(ShadowType.class, ACCOUNT_MORGAN_OID, options, task, result); @@ -283,7 +283,7 @@ public void test105GetForceRefreshAccountMorganCommunicationFailure() throws Exc } // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Result", result); assertFailure(result); syncServiceMock.assertNoNotifcations(); @@ -315,11 +315,11 @@ public void test106RefreshAccountMorganCommunicationFailureRetry() throws Except lastAttemptStartTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Result", result); result.computeStatus(); TestUtil.assertResultStatus(result, OperationResultStatus.HANDLED_ERROR); @@ -354,11 +354,11 @@ public void test108RefreshAccountMorganCommunicationFailureRetryAgain() throws E lastAttemptStartTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Result", result); result.computeStatus(); TestUtil.assertResultStatus(result, OperationResultStatus.HANDLED_ERROR); @@ -479,11 +479,11 @@ public void test109RefreshAccountMorganDead() throws Exception { PrismObject shadowRepoBefore = getShadowRepo(ACCOUNT_MORGAN_OID); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Result", result); assertSuccess(result); syncServiceMock.assertNoNotifcations(); @@ -514,11 +514,11 @@ public void test110AddAccountMorganAgainCommunicationFailure() throws Exception lastRequestStartTs = lastAttemptStartTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); shadowMorganOid = provisioningService.addObject(account, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Result", result); assertInProgress(result); account.checkConsistence(); @@ -549,11 +549,11 @@ public void test114RefreshAccountMorganCommunicationFailure() throws Exception { PrismObject shadowRepoBefore = getShadowRepo(shadowMorganOid); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Result", result); assertSuccess(result); syncServiceMock.assertNoNotifcations(); @@ -585,11 +585,11 @@ public void test116RefreshAccountMorganRetrySuccess() throws Exception { lastAttemptStartTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Result", result); assertSuccess(result); lastAttemptEndTs = clock.currentTimeXMLGregorianCalendar(); @@ -618,12 +618,12 @@ public void test120ModifyMorganFullNameCommunicationFailure() throws Exception { display("ObjectDelta", delta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertInProgress(result); lastRequestEndTs = lastAttemptEndTs = clock.currentTimeXMLGregorianCalendar(); syncServiceMock.assertNotifyInProgressOnly(); @@ -652,11 +652,11 @@ public void test124RefreshAccountMorganCommunicationFailure() throws Exception { PrismObject shadowRepoBefore = getShadowRepo(shadowMorganOid); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Result", result); assertSuccess(result); syncServiceMock.assertNoNotifcations(); @@ -688,11 +688,11 @@ public void test126RefreshAccountMorganCommunicationFailureRetry() throws Except lastAttemptStartTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Result", result); result.computeStatus(); TestUtil.assertResultStatus(result, OperationResultStatus.HANDLED_ERROR); @@ -727,11 +727,11 @@ public void test128RefreshAccountMorganCommunicationFailureRetryAgain() throws E lastAttemptStartTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Result", result); result.computeStatus(); TestUtil.assertResultStatus(result, OperationResultStatus.HANDLED_ERROR); @@ -761,11 +761,11 @@ public void test129RefreshAccountMorganFailed() throws Exception { PrismObject shadowRepoBefore = getShadowRepo(shadowMorganOid); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Result", result); assertSuccess(result); syncServiceMock.assertNoNotifcations(); @@ -789,12 +789,12 @@ public void test130ModifyMorganFullNameAgainCommunicationFailure() throws Except display("ObjectDelta", delta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertInProgress(result); lastRequestEndTs = lastAttemptEndTs = clock.currentTimeXMLGregorianCalendar(); syncServiceMock.assertNotifyInProgressOnly(); @@ -824,12 +824,12 @@ public void test132GetAccountMorganCommunicationFailure() throws Exception { dummyResource.setBreakMode(BreakMode.NETWORK); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.getObject(ShadowType.class, shadowMorganOid, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Result", result); assertPartialError(result); syncServiceMock.assertNoNotifcations(); @@ -860,7 +860,7 @@ public void test133GetAccountMorganStalenessZeroCommunicationFailure() throws Ex try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.getObject(ShadowType.class, shadowMorganOid, options, task, result); @@ -871,7 +871,7 @@ public void test133GetAccountMorganStalenessZeroCommunicationFailure() throws Ex } // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Result", result); assertFailure(result); syncServiceMock.assertNoNotifcations(); @@ -901,11 +901,11 @@ public void test134GetAccountMorganForceRefreshRetryCommunicationFailure() throw Collection> options = SelectorOptions.createCollection(GetOperationOptions.createForceRefresh()); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.getObject(ShadowType.class, shadowMorganOid, options, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Result", result); assertPartialError(result); lastAttemptEndTs = clock.currentTimeXMLGregorianCalendar(); @@ -938,11 +938,11 @@ public void test136RefreshAccountMorganRetrySuccess() throws Exception { lastAttemptStartTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Result", result); assertSuccess(result); lastAttemptEndTs = clock.currentTimeXMLGregorianCalendar(); @@ -971,11 +971,11 @@ public void test170DeleteMorganCommunicationFailure() throws Exception { display("ObjectDelta", delta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.deleteObject(ShadowType.class, shadowMorganOid, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertInProgress(result); lastRequestEndTs = lastAttemptEndTs = clock.currentTimeXMLGregorianCalendar(); syncServiceMock.assertNotifyInProgressOnly(); @@ -1004,11 +1004,11 @@ public void test174RefreshAccountMorganCommunicationFailure() throws Exception { PrismObject shadowRepoBefore = getShadowRepo(shadowMorganOid); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Result", result); assertSuccess(result); syncServiceMock.assertNoNotifcations(); @@ -1040,11 +1040,11 @@ public void test176RefreshAccountMorganCommunicationFailureRetry() throws Except lastAttemptStartTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Result", result); result.computeStatus(); TestUtil.assertResultStatus(result, OperationResultStatus.HANDLED_ERROR); @@ -1079,11 +1079,11 @@ public void test178RefreshAccountMorganCommunicationFailureRetryAgain() throws E lastAttemptStartTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Result", result); result.computeStatus(); TestUtil.assertResultStatus(result, OperationResultStatus.HANDLED_ERROR); @@ -1112,11 +1112,11 @@ public void test179RefreshAccountMorganFailed() throws Exception { PrismObject shadowRepoBefore = getShadowRepo(shadowMorganOid); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Result", result); assertSuccess(result); syncServiceMock.assertNoNotifcations(); @@ -1140,11 +1140,11 @@ public void test180DeleteMorganCommunicationFailureAgain() throws Exception { display("ObjectDelta", delta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject returnedShadow = provisioningService.deleteObject(ShadowType.class, shadowMorganOid, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertInProgress(result); lastRequestEndTs = lastAttemptEndTs = clock.currentTimeXMLGregorianCalendar(); syncServiceMock.assertNotifyInProgressOnly(); @@ -1179,11 +1179,11 @@ public void test186RefreshAccountMorganRetrySuccess() throws Exception { lastAttemptStartTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Result", result); assertSuccess(result); lastAttemptEndTs = clock.currentTimeXMLGregorianCalendar(); @@ -1219,11 +1219,11 @@ public void test190AccountMorganDeadExpireOperation() throws Exception { PrismObject shadowRepoBefore = getShadowRepo(ACCOUNT_MORGAN_OID); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Result", result); assertSuccess(result); syncServiceMock.assertNoNotifcations(); @@ -1304,11 +1304,11 @@ public void test192AccountMorganSecondDeadExpireOperation() throws Exception { PrismObject shadowRepoBefore = getShadowRepo(shadowMorganOid); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Result", result); assertSuccess(result); syncServiceMock.assertNoNotifcations(); @@ -1373,11 +1373,11 @@ public void test194AccountMorganDeadExpireShadow() throws Exception { PrismObject shadowRepoBefore = getShadowRepo(ACCOUNT_MORGAN_OID); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Result", result); assertSuccess(result); syncServiceMock.assertNotifySuccessOnly(); @@ -1409,11 +1409,11 @@ public void test196AccountMorganSecondDeadExpireShadow() throws Exception { PrismObject shadowRepoBefore = getShadowRepo(shadowMorganOid); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Result", result); assertSuccess(result); syncServiceMock.assertNotifySuccessOnly(); @@ -1447,12 +1447,12 @@ public void test800AddAccountMorganAlreadyExists() throws Exception { display("Adding shadow", account); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); try { provisioningService.addObject(account, null, null, task, result); assertNotReached(); } catch (ObjectAlreadyExistsException e) { - displayThen(TEST_NAME); + then(TEST_NAME); display("expected exception", e); } @@ -1526,12 +1526,12 @@ public void test802AddAccountMorganAlreadyExistsAgain() throws Exception { display("Adding shadow", account); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); try { provisioningService.addObject(account, null, null, task, result); assertNotReached(); } catch (ObjectAlreadyExistsException e) { - displayThen(TEST_NAME); + then(TEST_NAME); display("expected exception", e); } @@ -1612,11 +1612,11 @@ public void test804AddAccountElizabeth() throws Exception { display("Adding shadow", account); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.addObject(account, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); account.checkConsistence(); @@ -1647,17 +1647,17 @@ public void test806RenameAccountElizabethAlreadyExists() throws Exception { ACCOUNT_BETTY_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); try { provisioningService.modifyObject(ShadowType.class, ACCOUNT_ELIZABETH_OID, delta.getModifications(), null, null, task, result); assertNotReached(); } catch (ObjectAlreadyExistsException e) { - displayThen(TEST_NAME); + then(TEST_NAME); display("expected exception", e); } // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertFailure(result); PrismObject conflictingShadowRepo = findAccountShadowByUsername(ACCOUNT_BETTY_USERNAME, getResource(), result); @@ -1726,17 +1726,17 @@ public void test808RenameAccountElizabethAlreadyExistsAgain() throws Exception { ACCOUNT_BETTY_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); try { provisioningService.modifyObject(ShadowType.class, ACCOUNT_ELIZABETH_OID, delta.getModifications(), null, null, task, result); assertNotReached(); } catch (ObjectAlreadyExistsException e) { - displayThen(TEST_NAME); + then(TEST_NAME); display("expected exception", e); } // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertFailure(result); PrismObject conflictingShadowRepo = findAccountShadowByUsername(ACCOUNT_BETTY_USERNAME, getResource(), result); @@ -1817,11 +1817,11 @@ public void test810GetAccountMorganNotFound() throws Exception { dummyResourceCtl.deleteAccount(ACCOUNT_MORGAN_NAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject provisioningShadow = provisioningService.getObject(ShadowType.class, shadowMorganOid, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); // @formatter:off @@ -1888,12 +1888,12 @@ public void test812ModifyAccountWillNotFound() throws Exception { ACCOUNT_WILL_OID, dummyResourceCtl.getAttributeFullnamePath(), "Pirate Will Turner"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); try { provisioningService.modifyObject(ShadowType.class, ACCOUNT_WILL_OID, delta.getModifications(), null, null, task, result); assertNotReached(); } catch (ObjectNotFoundException e) { - displayThen(TEST_NAME); + then(TEST_NAME); display("expected exception", e); } @@ -1959,11 +1959,11 @@ public void test814DeleteAccountElizabethNotFound() throws Exception { dummyResourceCtl.deleteAccount(ACCOUNT_ELIZABETH_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.deleteObject(ShadowType.class, ACCOUNT_ELIZABETH_OID, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Result", result); assertHadnledError(result); @@ -2030,16 +2030,16 @@ public void test816AddAccountElizabethAfterDeathAlreadyExists() throws Exception display("Adding shadow", account); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); try { provisioningService.addObject(account, null, null, task, result); } catch (ObjectAlreadyExistsException e) { - displayThen(TEST_NAME); + then(TEST_NAME); display("expected exception", e); } // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertFailure(result); // @formatter:off @@ -2094,11 +2094,11 @@ public void test900GetAccountMurrayPending() throws Exception { repoAddObjectFromFile(ACCOUNT_SHADOW_MURRAY_PENDING_FILE, result); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject accountMurray = provisioningService.getObject(ShadowType.class, ACCOUNT_SHADOW_MURRAY_PENDING_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Result", result); assertSuccess(result); accountMurray.checkConsistence(); 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 e25844e9799..f93f189c57d 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 @@ -118,11 +118,11 @@ public void test400AddAccountElizabeth() throws Exception { XMLGregorianCalendar start = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); String addedObjectOid = provisioningService.addObject(account, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); XMLGregorianCalendar end = clock.currentTimeXMLGregorianCalendar(); @@ -167,7 +167,7 @@ public void test410AssociateCrewWillElizabeth() throws Exception { delta.checkConsistence(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); @@ -213,7 +213,7 @@ public void test419DisassociateCrewWillElizabeth() throws Exception { delta.checkConsistence(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); @@ -251,11 +251,11 @@ public void test499DeleteAccountElizabeth() throws Exception { syncServiceMock.reset(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.deleteObject(ShadowType.class, ACCOUNT_ELIZABETH_OID, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); syncServiceMock.assertNotifySuccessOnly(); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyNegative.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyNegative.java index 1ba9d31b8f4..abfca7c7cb1 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyNegative.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyNegative.java @@ -113,10 +113,10 @@ public void test190GetResource() throws Exception { syncServiceMock.reset(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject resource = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result); - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("Resource after", resource); @@ -140,7 +140,7 @@ public void test200AddAccountNullAttributes() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.addObject(account, null, null, task, result); assertNotReached(); @@ -149,7 +149,7 @@ public void test200AddAccountNullAttributes() throws Exception { display("Expected exception", e); } - displayThen(TEST_NAME); + then(TEST_NAME); syncServiceMock.assertNotifyFailureOnly(); } diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyParallelism.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyParallelism.java index 3f29e9fdd5f..104ae304e78 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyParallelism.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyParallelism.java @@ -135,12 +135,12 @@ public void test120ModifyWillReplaceFullname() throws Exception { delta.checkConsistence(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertDummyAccount(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid) @@ -169,11 +169,11 @@ public void test190DeleteWill() throws Exception { syncServiceMock.reset(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.deleteObject(ShadowType.class, ACCOUNT_WILL_OID, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); syncServiceMock.assertNotifySuccessOnly(); @@ -210,7 +210,7 @@ public void test200ParallelCreate() throws Exception { rememberDummyResourceWriteOperationCount(null); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); accountMorganOid = null; @@ -240,7 +240,7 @@ public void test200ParallelCreate() throws Exception { }, CONCURRENT_TEST_THREAD_COUNT_HIGH, CONCURRENT_TEST_MAX_START_DELAY_FAST); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForThreads(threads, WAIT_TIMEOUT); successCounter.assertCount("Wrong number of successful operations", 1); @@ -304,7 +304,7 @@ private PrismObject parallelModifyTest(final String TEST_NAME, Faila rememberDummyResourceWriteOperationCount(null); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ParallelTestThread[] threads = multithread(TEST_NAME, (i) -> { @@ -337,7 +337,7 @@ private PrismObject parallelModifyTest(final String TEST_NAME, Faila }, CONCURRENT_TEST_THREAD_COUNT, CONCURRENT_TEST_MAX_START_DELAY_FAST); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForThreads(threads, WAIT_TIMEOUT); PrismObject shadowAfter = provisioningService.getObject(ShadowType.class, accountMorganOid, null, task, result); @@ -361,7 +361,7 @@ public void test209ParallelDelete() throws Exception { rememberDummyResourceWriteOperationCount(null); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); Task task = getTestTask(); ParallelTestThread[] threads = multithread(TEST_NAME, @@ -394,7 +394,7 @@ public void test209ParallelDelete() throws Exception { }, CONCURRENT_TEST_THREAD_COUNT, CONCURRENT_TEST_MAX_START_DELAY_FAST); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForThreads(threads, WAIT_TIMEOUT); successCounter.assertCount("Wrong number of successful operations", 1); @@ -421,7 +421,7 @@ public void test210ParallelCreateSlow() throws Exception { rememberDummyResourceWriteOperationCount(null); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ParallelTestThread[] threads = multithread(TEST_NAME, (i) -> { @@ -447,7 +447,7 @@ public void test210ParallelCreateSlow() throws Exception { }, CONCURRENT_TEST_THREAD_COUNT, null); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForThreads(threads, WAIT_TIMEOUT); successCounter.assertCount("Wrong number of successful operations", 1); @@ -509,7 +509,7 @@ private PrismObject parallelModifyTestSlow(final String TEST_NAME, F rememberDummyResourceWriteOperationCount(null); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ParallelTestThread[] threads = multithread(TEST_NAME, (i) -> { @@ -542,7 +542,7 @@ private PrismObject parallelModifyTestSlow(final String TEST_NAME, F }, CONCURRENT_TEST_THREAD_COUNT, null); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForThreads(threads, WAIT_TIMEOUT); PrismObject shadowAfter = provisioningService.getObject(ShadowType.class, accountElizabethOid, null, task, result); @@ -566,7 +566,7 @@ public void test229ParallelDeleteSlow() throws Exception { rememberDummyResourceWriteOperationCount(null); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); Task task = getTestTask(); ParallelTestThread[] threads = multithread(TEST_NAME, @@ -602,7 +602,7 @@ public void test229ParallelDeleteSlow() throws Exception { }, CONCURRENT_TEST_THREAD_COUNT, null); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForThreads(threads, WAIT_TIMEOUT); successCounter.assertCount("Wrong number of successful operations", 1); @@ -669,13 +669,13 @@ public void test230ParallelGroupSearch() throws Exception { Thread.sleep(100); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); // Unblock the handlers. And here we go! dummyResource.unblockAll(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForThreads(threads, WAIT_TIMEOUT); dummyResource.setSyncSearchHandlerStart(false); @@ -739,7 +739,7 @@ public void test800ParallelReadAndModifyResource() throws Exception { } // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); long t0 = System.currentTimeMillis(); MutableBoolean readFinished = new MutableBoolean(); @@ -750,7 +750,7 @@ public void test800ParallelReadAndModifyResource() throws Exception { // roughly half the threads will try to mess with the resource if (threadIndex < CONCURRENT_TEST_THREAD_COUNT_HIGH / 2) { for (int i = 0; /* neverending */ ; i++) { - messResource(TEST_NAME, threadIndex, i); + messResource(threadIndex, i); display("T +" + (System.currentTimeMillis() - t0)); @@ -761,7 +761,7 @@ public void test800ParallelReadAndModifyResource() throws Exception { } else if (threadIndex == CONCURRENT_TEST_THREAD_COUNT_HIGH / 2) { for (int i = 0; /* neverending */ ; i++) { - Task localTask = createTask(TEST_NAME + ".test." + i); + Task localTask = createTask("test-" + i); OperationResult testResult = provisioningService.testResource(RESOURCE_DUMMY_OID, localTask); logger.debug("PAR: TESTing " + threadIndex + "." + i); @@ -784,7 +784,7 @@ public void test800ParallelReadAndModifyResource() throws Exception { try { // TODO: why is the constant MESS_RESOURCE_ITERATIONS used for operations? for (int i = 0; i < MESS_RESOURCE_ITERATIONS; i++) { - Task localTask = createTask(TEST_NAME + ".op." + i); + Task localTask = createTask("op-" + i); OperationResult localResult = localTask.getResult(); logger.debug("PAR: OPing " + threadIndex + "." + i); @@ -814,7 +814,7 @@ public void test800ParallelReadAndModifyResource() throws Exception { }, CONCURRENT_TEST_THREAD_COUNT_HIGH, CONCURRENT_TEST_MAX_START_DELAY_FAST); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForThreads(threads, WAIT_TIMEOUT); PrismObject resourceAfter = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result); @@ -851,11 +851,11 @@ private Object doResourceOperation(Task task, OperationResult result) throws Exc return null; } - private void messResource(final String TEST_NAME, int threadIndex, int i) + private void messResource(int threadIndex, int i) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, PolicyViolationException, ObjectAlreadyExistsException, ExpressionEvaluationException { - Task task = createTask(TEST_NAME + ".mess." + threadIndex + "." + i); + Task task = createTask("mess-" + threadIndex + "-" + i); OperationResult result = task.getResult(); List> deltas = deltaFor(ResourceType.class) .item(ResourceType.F_DESCRIPTION).replace("Iter " + threadIndex + "." + i) diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyResourceAndSchemaCaching.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyResourceAndSchemaCaching.java index 07b94dd1038..20726ce0d4b 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyResourceAndSchemaCaching.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyResourceAndSchemaCaching.java @@ -30,7 +30,6 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.ResourceTypeUtil; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DOMUtil; @@ -88,11 +87,11 @@ public void test010GetResource() throws Exception { rememberResourceCacheStats(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject resourceProvisioning = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, null, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Resource", resource); assertSuccess(result); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySchemaless.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySchemaless.java index fef999bffc9..719a68665e9 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySchemaless.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySchemaless.java @@ -384,12 +384,12 @@ public void resourceStatciSchemaResourceAndConnectorCaching(final String TEST_NA assertStaticSchemaSanity(resourceSchemaBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject resourceAgain = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_STATIC_SCHEMA_OID, null, null, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); ResourceType resourceTypeAgain = resourceAgain.asObjectable(); @@ -461,11 +461,11 @@ public void test040ReAddResourceStaticSchema() throws Exception { fillInConnectorRef(resourceNew, IntegrationTestTools.DUMMY_CONNECTOR_TYPE, result); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.addObject(resourceNew, null, ProvisioningOperationOptions.createOverwrite(true), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertCounterIncrement(InternalCounters.RESOURCE_SCHEMA_FETCH_COUNT, 0); @@ -700,12 +700,12 @@ public void test107Capabilities() throws Exception { OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ResourceType resourceType = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_STATIC_SCHEMA_OID, null, null, result) .asObjectable(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); // Check native capabilities diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/manual/AbstractManualResourceTest.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/manual/AbstractManualResourceTest.java index 20ffc38d28d..ffad01ef3e3 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/manual/AbstractManualResourceTest.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/manual/AbstractManualResourceTest.java @@ -367,11 +367,11 @@ public void test100AddAccountWill() throws Exception { accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); String addedObjectOid = provisioningService.addObject(account, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("result", result); willLastCaseOid = assertInProgress(result); @@ -434,11 +434,11 @@ public void test102GetAccountWillFuture() throws Exception { Collection> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject shadowProvisioning = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, options, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("Provisioning shadow", shadowProvisioning); @@ -469,11 +469,11 @@ public void test104RefreshAccountWill() throws Exception { display("Shadow before", shadowBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -523,11 +523,11 @@ public void test106AddToBackingStoreAndGetAccountWill() throws Exception { syncServiceMock.reset(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject shadowProvisioning = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("Provisioning shadow", shadowProvisioning); @@ -564,11 +564,11 @@ public void test108GetAccountWillFuture() throws Exception { Collection> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject shadowProvisioning = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, options, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("Provisioning shadow", shadowProvisioning); @@ -606,7 +606,7 @@ public void test109GetAccountWillFutureNoFetch() throws Exception { options.setNoFetch(true); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject shadowProvisioningFuture = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, SelectorOptions.createCollection(options), @@ -614,7 +614,7 @@ public void test109GetAccountWillFutureNoFetch() throws Exception { // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("Provisioning shadow (future,noFetch)", shadowProvisioningFuture); @@ -652,11 +652,11 @@ public void test110CloseCaseAndRefreshAccountWill() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); accountWillCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -712,11 +712,11 @@ public void test120RefreshAccountWillAfter5min() throws Exception { display("Shadow before", shadowBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -764,11 +764,11 @@ public void test130RefreshAccountWillAfter16min() throws Exception { display("Shadow before", shadowBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -816,11 +816,11 @@ public void test132RefreshAccountWillAfter27min() throws Exception { display("Shadow before", shadowBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -857,12 +857,12 @@ public void test200ModifyAccountWillFullname() throws Exception { accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("result", result); willLastCaseOid = assertInProgress(result); @@ -935,11 +935,11 @@ public void test202RefreshAccountWill() throws Exception { display("Shadow before", shadowBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -1019,11 +1019,11 @@ public void test204CloseCaseAndRefreshAccountWill() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); accountWillCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -1110,11 +1110,11 @@ public void test210RefreshAccountWillAfter5min() throws Exception { display("Shadow before", shadowBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -1178,11 +1178,11 @@ public void test212UpdateBackingStoreAndGetAccountWill() throws Exception { backingStoreUpdateWill(ACCOUNT_WILL_FULLNAME_PIRATE, ActivationStatusType.ENABLED, ACCOUNT_WILL_PASSWORD_OLD); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -1244,12 +1244,12 @@ public void test220ModifyAccountWillDisable() throws Exception { accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("result", result); willLastCaseOid = assertInProgress(result); @@ -1330,12 +1330,12 @@ public void test230ModifyAccountWillChangePasswordAndEnable() throws Exception { accountWillSecondReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("result", result); willSecondLastCaseOid = assertInProgress(result); @@ -1414,12 +1414,12 @@ public void test240CloseDisableCaseAndReadAccountWill() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject shadowProvisioning = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); accountWillCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -1526,11 +1526,11 @@ public void test250RefreshAccountWillAfter5min() throws Exception { display("Shadow before", shadowBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -1613,11 +1613,11 @@ public void test252UpdateBackingStoreAndGetAccountWill() throws Exception { backingStoreUpdateWill(ACCOUNT_WILL_FULLNAME_PIRATE, ActivationStatusType.DISABLED, ACCOUNT_WILL_PASSWORD_OLD); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -1682,11 +1682,11 @@ public void test260ClosePasswordChangeCaseAndRefreshAccountWill() throws Excepti accountWillSecondCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); accountWillSecondCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -1777,11 +1777,11 @@ public void test270RefreshAccountWillAfter7min() throws Exception { display("Shadow before", shadowBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -1875,11 +1875,11 @@ public void test271RefreshAccountWillAfter12min() throws Exception { display("Shadow before", shadowBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -1970,11 +1970,11 @@ public void test272UpdateBackingStoreAndGetAccountWill() throws Exception { backingStoreUpdateWill(ACCOUNT_WILL_FULLNAME_PIRATE, ActivationStatusType.ENABLED, ACCOUNT_WILL_PASSWORD_NEW); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -2034,11 +2034,11 @@ public void test280RefreshAccountWillAfter5min() throws Exception { display("Shadow before", shadowBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -2122,11 +2122,11 @@ public void test290RefreshAccountWillAfter5min() throws Exception { display("Shadow before", shadowBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -2184,11 +2184,11 @@ public void test300DeleteAccountWill() throws Exception { accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.deleteObject(ShadowType.class, ACCOUNT_WILL_OID, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("result", result); willLastCaseOid = assertInProgress(result); @@ -2250,7 +2250,7 @@ public void test302GetAccountWillFuture() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject shadowProvisioningFuture = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)), @@ -2258,7 +2258,7 @@ public void test302GetAccountWillFuture() throws Exception { // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("Provisioning shadow (future)", shadowProvisioningFuture); @@ -2278,7 +2278,7 @@ public void test303GetAccountWillFutureNoFetch() throws Exception { options.setNoFetch(true); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject shadowProvisioningFuture = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, SelectorOptions.createCollection(options), @@ -2286,7 +2286,7 @@ public void test303GetAccountWillFutureNoFetch() throws Exception { // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("Provisioning shadow (future,noFetch)", shadowProvisioningFuture); @@ -2315,11 +2315,11 @@ public void test310CloseCaseAndRefreshAccountWill() throws Exception { display("Shadow before", shadowBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); accountWillCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -2379,11 +2379,11 @@ public void test320RefreshAccountWillAfter5min() throws Exception { display("Shadow before", shadowBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDj.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDj.java index c7db08f133b..d74e11b05b3 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDj.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDj.java @@ -677,11 +677,11 @@ public void test110GetObject() throws Exception { PropertyReferenceListType resolve = new PropertyReferenceListType(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ShadowType provisioningShadow = provisioningService.getObject(ShadowType.class, ACCOUNT_JBOND_OID, null, task, result).asObjectable(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertNotNull(provisioningShadow); @@ -793,11 +793,11 @@ public void test112GetObjectNotFoundResource() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_BAD_OID, null, task, result); // THEN - displayWhen(TEST_NAME); + when(TEST_NAME); ShadowAsserter.forShadow(shadow, "provisioning") .assertTombstone(); @@ -828,11 +828,11 @@ public void test120AddAccountWill() throws Exception { display("Account before", accountBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); String addedObjectOid = provisioningService.addObject(accountBefore, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertEquals(ACCOUNT_WILL_OID, addedObjectOid); @@ -914,11 +914,11 @@ public void test130AddDeleteAccountSparrow() throws Exception { assertEquals(ACCOUNT_SPARROW_OID, addedObjectOid); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.deleteObject(ShadowType.class, ACCOUNT_SPARROW_OID, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); ShadowType objType = null; try { @@ -971,12 +971,12 @@ public void test140AddAndModifyAccountJack() throws Exception { display("Object change",delta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, objectChange.getOid(), delta.getModifications(), null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1033,12 +1033,12 @@ public void test145ModifyAccountJackJpegPhoto() throws Exception { display("Modifications",modifications); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, ACCOUNT_JACK_OID, modifications, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); Entry entry = openDJController.searchByUid("rename"); @@ -1093,12 +1093,12 @@ public void test147ModifyAccountJackGivenNameDuplicit() throws Exception { display("Modifications",modifications); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, ACCOUNT_JACK_OID, modifications, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1154,11 +1154,11 @@ public void test150ChangePassword() throws Exception { display("Object change",delta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); // Check if object was modified in LDAP Entry entryAfter = openDJController.searchAndAssertByEntryUuid(uid); @@ -1267,11 +1267,11 @@ public boolean handle(PrismObject prismObject, OperationResult paren }; // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); SearchResultMetadata searchMetadata = provisioningService.searchObjectsIterative(ShadowType.class, query, null, handler, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Count", objects.size()); assertEquals("Unexpected number of shadows", 9, objects.size()); @@ -1314,11 +1314,11 @@ public boolean handle(PrismObject prismObject, OperationResult paren }; // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); SearchResultMetadata searchMetadata = provisioningService.searchObjectsIterative(ShadowType.class, query, null, handler, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Count", objects.size()); assertEquals("Unexpected number of shadows", 3, objects.size()); @@ -1361,11 +1361,11 @@ public boolean handle(PrismObject prismObject, OperationResult paren }; // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); SearchResultMetadata searchMetadata = provisioningService.searchObjectsIterative(ShadowType.class, query, null, handler, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Count", objects.size()); assertEquals("Unexpected number of shadows", 3, objects.size()); @@ -1413,12 +1413,12 @@ public void test170DisableAccount() throws Exception{ display("Object change",delta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, objectChange.getOid(), delta.getModifications(), null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); ShadowType accountType = provisioningService.getObject(ShadowType.class, ACCOUNT_DISABLE_SIMULATED_OID, null, taskManager.createTaskInstance(), result).asObjectable(); @@ -1713,12 +1713,12 @@ public void test202SearchObjectsCompexFilter() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); List> objListType = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1746,12 +1746,12 @@ public void test203SearchObjectsByDnExists() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); List> objListType = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); for (PrismObject objType : objListType) { @@ -1787,12 +1787,12 @@ public void test205SearchObjectsByDnNotExists() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); List> objListType = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); for (PrismObject objType : objListType) { @@ -1824,12 +1824,12 @@ public void test206SearchObjectsCompexFilterStartsWith() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); List> objListType = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); for (PrismObject objType : objListType) { @@ -1861,12 +1861,12 @@ public void test230SearchObjectsPagedNoOffset() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); SearchResultList> searchResults = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("Search resutls", searchResults); @@ -1896,12 +1896,12 @@ public void test231SearchObjectsPagedOffsetZero() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); SearchResultList> searchResults = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("Search resutls", searchResults); @@ -1931,11 +1931,11 @@ public void test232SearchObjectsPagedOffset() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); SearchResultList> searchResults = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); assertSuccess(result); display("Search resutls", searchResults); @@ -1969,12 +1969,12 @@ public void test233SearchObjectsPagedNoOffsetSortSn() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); SearchResultList> searchResults = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); assertSuccess(result); display("Search resutls", searchResults); @@ -2007,12 +2007,12 @@ public void test234SearchObjectsPagedOffsetSortSn() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); List> searchResults = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); assertSuccess(result); display("Search resutls", searchResults); @@ -2051,11 +2051,11 @@ public void test250CountAccounts() throws Exception { ObjectQuery query = getQueryConverter().createObjectQuery(ShadowType.class, queryType); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); Integer count = provisioningService.countObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("All accounts count", count); @@ -2077,11 +2077,11 @@ public void test252CountLdapGroups() throws Exception { ObjectQuery query = getQueryConverter().createObjectQuery(ShadowType.class, queryType); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); Integer count = provisioningService.countObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("All LDAP groups count", count); @@ -2166,11 +2166,11 @@ public void test320AddAccountPosix() throws Exception { display("Adding account", object); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); String addedObjectOid = provisioningService.addObject(object.asPrismObject(), null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertEquals(ACCOUNT_POSIX_MCMUTTON_OID, addedObjectOid); ShadowType repoShadowType = getShadowRepo(ACCOUNT_POSIX_MCMUTTON_OID).asObjectable(); @@ -2218,12 +2218,12 @@ public void test322ModifyAccountPosix() throws Exception { display("Object change",delta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, objectChange.getOid(), delta.getModifications(), null, null, taskManager.createTaskInstance(), result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2258,11 +2258,11 @@ public void test329DeleteAccountPosix() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.deleteObject(ShadowType.class, ACCOUNT_POSIX_MCMUTTON_OID, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); try { provisioningService.getObject(ShadowType.class, ACCOUNT_POSIX_MCMUTTON_OID, null, task, result); @@ -2306,12 +2306,12 @@ public void test330SearchForPosixAccount() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); List> objListType = provisioningService.searchObjects(ShadowType.class, query, null, null, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); for (PrismObject objType : objListType) { assertNotNull("Null search result", objType); display("found object", objType); @@ -2345,11 +2345,11 @@ public void test400AddGroupSwashbucklers() throws Exception { display("Adding object", object); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); String addedObjectOid = provisioningService.addObject(object.asPrismObject(), null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertEquals(GROUP_SWASHBUCKLERS_OID, addedObjectOid); ShadowType shadowType = getShadowRepo(GROUP_SWASHBUCKLERS_OID).asObjectable(); @@ -2386,11 +2386,11 @@ public void test402AddAccountMorganWithAssociation() throws Exception { IntegrationTestTools.display("Adding object", object); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); String addedObjectOid = provisioningService.addObject(object.asPrismObject(), null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertEquals(ACCOUNT_MORGAN_OID, addedObjectOid); assertRepoShadow(ACCOUNT_MORGAN_OID) @@ -2437,7 +2437,7 @@ public void test403modifyMorganReplaceAssociation() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ObjectModificationType modification = prismContext.parserFor(FILE_MODIFY_ASSOCIATION_REPLACE).parseRealValue(ObjectModificationType.class); ObjectDelta delta = DeltaConvertor.createObjectDelta(modification, ShadowType.class, prismContext); try { @@ -2448,7 +2448,7 @@ public void test403modifyMorganReplaceAssociation() throws Exception { } // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertRepoShadow(ACCOUNT_MORGAN_OID) .assertName(ACCOUNT_MORGAN_DN); @@ -2490,12 +2490,12 @@ public void test405GetGroupSwashbucklers() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject provisioningShadow = provisioningService.getObject(ShadowType.class, GROUP_SWASHBUCKLERS_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); ShadowType provisioningShadowType = provisioningShadow.asObjectable(); assertEquals("Wrong ICF name (provisioning)", dnMatchingRule.normalize(GROUP_SWASHBUCKLERS_DN), dnMatchingRule.normalize(provisioningShadowType.getName().getOrig())); @@ -2530,11 +2530,11 @@ public void test410CreateLdapGroupAndSearchGroups() throws Exception { RESOURCE_OPENDJ_GROUP_OBJECTCLASS, prismContext); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); SearchResultList> resultList = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); assertSuccess(result); display("Search result", resultList); @@ -2564,11 +2564,11 @@ public void test412CreateLdapGroupWithMemberAndGet() throws Exception { RESOURCE_OPENDJ_GROUP_OBJECTCLASS, prismContext); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_MORGAN_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("Account shadow after", shadow); @@ -2595,11 +2595,11 @@ public void test414AddGroupCorsairsAssociateUser() throws Exception { IntegrationTestTools.display("Adding object", object); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); String addedObjectOid = provisioningService.addObject(object.asPrismObject(), null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertEquals(GROUP_CORSAIRS_OID, addedObjectOid); ShadowType shadowType = getShadowRepo(GROUP_CORSAIRS_OID).asObjectable(); @@ -2623,12 +2623,12 @@ public void test416AssociateUserToCorsairs() throws Exception { delta.checkConsistence(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); Entry groupEntry = openDJController.fetchEntry(GROUP_CORSAIRS_DN); display("LDAP group", groupEntry); @@ -2646,11 +2646,11 @@ public void test418GetMorgan() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_MORGAN_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); assertSuccess(result); display("Shadow", shadow); @@ -2716,11 +2716,11 @@ public void test450ListGroupsObjectclass() throws Exception { display("query", query); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); SearchResultList> objects = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("found objects", objects); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2742,11 +2742,11 @@ public void test452ListLdapGroupsKindIntent() throws Exception { display("query", query); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); SearchResultList> objects = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("found objects", objects); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2768,11 +2768,11 @@ public void test454ListSpecialGroupsKindIntent() throws Exception { display("query", query); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); SearchResultList> objects = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("found objects", objects); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2795,11 +2795,11 @@ public void test456AddGroupSpecialists() throws Exception { display("Adding object", object); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); String addedObjectOid = provisioningService.addObject(object.asPrismObject(), null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertEquals(GROUP_SPECIALISTS_OID, addedObjectOid); ShadowType shadowType = getShadowRepo(GROUP_SPECIALISTS_OID).asObjectable(); @@ -2837,11 +2837,11 @@ public void test457ListLdapGroupsKindIntent() throws Exception { display("query", query); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); SearchResultList> objects = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("found objects", objects); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2863,11 +2863,11 @@ public void test458ListSpecialGroupsKindIntent() throws Exception { display("query", query); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); SearchResultList> objects = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("found objects", objects); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2897,11 +2897,11 @@ public void test460ListOrganizationalUnitPeopleKindIntent() throws Exception { display("query", query); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); SearchResultList> objects = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("found objects", objects); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2928,11 +2928,11 @@ public void test470AddAccountPolyDescription() throws Exception { display("Account before", accountBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); String addedObjectOid = provisioningService.addObject(accountBefore, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); Entry entry = openDJController.fetchEntry(ACCOUNT_POLY_DN); @@ -2981,12 +2981,12 @@ public void test472ModifyAccountJackDescriptionOrig() throws Exception { display("Modifications",modifications); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, ACCOUNT_JACK_OID, modifications, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); Entry entry = openDJController.searchByUid("rename"); @@ -3032,12 +3032,12 @@ public void test474ModifyAccountJackDescriptionLangEnSk() throws Exception { display("Modifications", modifications); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, ACCOUNT_JACK_OID, modifications, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); Entry entry = openDJController.searchByUid("rename"); @@ -3084,12 +3084,12 @@ public void test476ModifyAccountJackDescriptionLangEnSkRuHr() throws Exception { display("Modifications",modifications); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, ACCOUNT_JACK_OID, modifications, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); Entry entry = openDJController.searchByUid("rename"); @@ -3136,12 +3136,12 @@ public void test478ModifyAccountJackDescriptionLangEnSkRuHr() throws Exception { display("Modifications",modifications); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, ACCOUNT_JACK_OID, modifications, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); Entry entry = openDJController.searchByUid("rename"); @@ -3187,12 +3187,12 @@ public void test478bModifyAccountJackDeleteDescription() throws Exception { display("Modifications", modifications); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, ACCOUNT_JACK_OID, modifications, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); Entry entry = openDJController.searchByUid("rename"); @@ -3239,12 +3239,12 @@ public void test479ModifyAccountJackDescriptionJack() throws Exception { display("Modifications",modifications); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.modifyObject(ShadowType.class, ACCOUNT_JACK_OID, modifications, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); Entry entry = openDJController.searchByUid("rename"); @@ -3277,11 +3277,11 @@ public void test480AddOuSuper() throws Exception { display("Adding object", object); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); String addedObjectOid = provisioningService.addObject(object.asPrismObject(), null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertEquals(OU_SUPER_OID, addedObjectOid); ShadowType shadowType = getShadowRepo(OU_SUPER_OID).asObjectable(); @@ -3323,11 +3323,11 @@ public void test489DeleteOuSuperWithSub() throws Exception { createSubOrg(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.deleteObject(ShadowType.class, OU_SUPER_OID, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertNoRepoShadow(OU_SUPER_OID); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjDumber.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjDumber.java index 6c1fc9748dc..fbfe2d48ed5 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjDumber.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjDumber.java @@ -88,7 +88,7 @@ public void test489DeleteOuSuperWithSub() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); provisioningService.deleteObject(ShadowType.class, OU_SUPER_OID, null, null, task, result); assertNotReached(); @@ -97,7 +97,7 @@ public void test489DeleteOuSuperWithSub() throws Exception { } // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertFailure(result); } diff --git a/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/AbstractUcfDummyTest.java b/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/AbstractUcfDummyTest.java index 4c289d00923..70b693ce1db 100644 --- a/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/AbstractUcfDummyTest.java +++ b/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/AbstractUcfDummyTest.java @@ -13,7 +13,6 @@ import com.evolveum.midpoint.prism.path.ItemName; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; import org.testng.annotations.BeforeClass; import com.evolveum.icf.dummy.resource.DummyResource; @@ -29,9 +28,8 @@ import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.processor.ResourceSchema; import com.evolveum.midpoint.test.DummyResourceContoller; +import com.evolveum.midpoint.test.util.AbstractSpringTest; import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; @@ -45,7 +43,7 @@ * this is a lesser evil for now (MID-392) */ @ContextConfiguration(locations = { "classpath:ctx-ucf-connid-test.xml" }) -public abstract class AbstractUcfDummyTest extends AbstractTestNGSpringContextTests { +public abstract class AbstractUcfDummyTest extends AbstractSpringTest { protected static final File RESOURCE_DUMMY_FILE = new File(UcfTestUtil.TEST_DIR, "resource-dummy.xml"); protected static final File CONNECTOR_DUMMY_FILE = new File(UcfTestUtil.TEST_DIR, "connector-dummy.xml"); @@ -60,14 +58,12 @@ public abstract class AbstractUcfDummyTest extends AbstractTestNGSpringContextTe protected static DummyResource dummyResource; protected static DummyResourceContoller dummyResourceCtl; - @Autowired(required = true) + @Autowired protected ConnectorFactory connectorFactoryIcfImpl; - @Autowired(required = true) + @Autowired protected PrismContext prismContext; - private static final Trace LOGGER = TraceManager.getTrace(AbstractUcfDummyTest.class); - @BeforeClass public void setup() throws Exception { PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); diff --git a/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/TestUcfOpenDj.java b/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/TestUcfOpenDj.java index 8621632b39f..1ba8c8c3920 100644 --- a/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/TestUcfOpenDj.java +++ b/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/TestUcfOpenDj.java @@ -29,6 +29,7 @@ import com.evolveum.midpoint.schema.util.ResourceTypeUtil; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.ldap.OpenDJController; +import com.evolveum.midpoint.test.util.AbstractSpringTest; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.PrettyPrinter; @@ -49,7 +50,6 @@ import org.opends.server.types.Entry; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; import org.testng.Assert; import org.testng.AssertJUnit; import org.testng.annotations.*; @@ -83,7 +83,7 @@ * a lesser evil for now (MID-392) */ @ContextConfiguration(locations = { "classpath:ctx-ucf-connid-test.xml" }) -public class TestUcfOpenDj extends AbstractTestNGSpringContextTests { +public class TestUcfOpenDj extends AbstractSpringTest { private static final File RESOURCE_OPENDJ_FILE = new File(UcfTestUtil.TEST_DIR, "resource-opendj.xml"); private static final File RESOURCE_OPENDJ_BAD_FILE = new File(UcfTestUtil.TEST_DIR, "resource-opendj-bad.xml"); @@ -99,11 +99,11 @@ public class TestUcfOpenDj extends AbstractTestNGSpringContextTests { private static final Trace LOGGER = TraceManager.getTrace(TestUcfOpenDj.class); - @Autowired(required = true) + @Autowired ConnectorFactory connectorFactoryIcfImpl; - @Autowired(required = true) + @Autowired Protector protector; - @Autowired(required = true) + @Autowired PrismContext prismContext; protected static OpenDJController openDJController = new OpenDJController(); @@ -123,7 +123,7 @@ public static void startLdap() throws Exception { } @AfterClass - public static void stopLdap() throws Exception { + public static void stopLdap() { openDJController.stop(); LOGGER.info("------------------------------------------------------------------------------"); LOGGER.info("STOP: OpenDjUcfTest"); diff --git a/repo/audit-impl/pom.xml b/repo/audit-impl/pom.xml index e92f46b96be..5ead1589716 100644 --- a/repo/audit-impl/pom.xml +++ b/repo/audit-impl/pom.xml @@ -99,6 +99,12 @@ 4.1-SNAPSHOT test + + com.evolveum.midpoint.infra + test-util + 4.1-SNAPSHOT + test + org.forgerock.opendj opendj diff --git a/repo/audit-impl/src/test/java/com/evolveum/midpoint/audit/impl/TestAuditServiceImpl.java b/repo/audit-impl/src/test/java/com/evolveum/midpoint/audit/impl/TestAuditServiceImpl.java index b446c824722..f6187298da6 100644 --- a/repo/audit-impl/src/test/java/com/evolveum/midpoint/audit/impl/TestAuditServiceImpl.java +++ b/repo/audit-impl/src/test/java/com/evolveum/midpoint/audit/impl/TestAuditServiceImpl.java @@ -13,7 +13,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; import org.testng.AssertJUnit; import org.testng.annotations.Test; @@ -23,6 +22,7 @@ import com.evolveum.midpoint.common.LoggingConfigurationManager; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.task.api.TaskManager; +import com.evolveum.midpoint.test.util.AbstractSpringTest; /** * @author semancik @@ -34,7 +34,7 @@ "classpath:ctx-repo-cache.xml", "classpath:ctx-repository-test.xml", "classpath:ctx-configuration-test.xml"}) -public class TestAuditServiceImpl extends AbstractTestNGSpringContextTests { +public class TestAuditServiceImpl extends AbstractSpringTest { private static final String LOG_FILENAME = "target/test.log"; @@ -45,7 +45,7 @@ public class TestAuditServiceImpl extends AbstractTestNGSpringContextTests { TaskManager taskManager; @Test - public void testAuditSimple() throws FileNotFoundException, InterruptedException { + public void testAuditSimple() throws FileNotFoundException { // GIVEN AuditEventRecord auditRecord = new AuditEventRecord(AuditEventType.ADD_OBJECT); Task task = taskManager.createTaskInstance(); diff --git a/repo/repo-cache/pom.xml b/repo/repo-cache/pom.xml index d958dfc3fbb..970068f5091 100644 --- a/repo/repo-cache/pom.xml +++ b/repo/repo-cache/pom.xml @@ -60,7 +60,7 @@ - + org.springframework spring-context @@ -99,6 +99,12 @@ 4.1-SNAPSHOT test + + com.evolveum.midpoint.infra + test-util + ${project.version} + test + org.springframework spring-test diff --git a/repo/repo-cache/src/test/java/com/evolveum/midpoint/repo/cache/TestRepositoryCache.java b/repo/repo-cache/src/test/java/com/evolveum/midpoint/repo/cache/TestRepositoryCache.java index 0e6fc3eb3c0..dc161b91145 100644 --- a/repo/repo-cache/src/test/java/com/evolveum/midpoint/repo/cache/TestRepositoryCache.java +++ b/repo/repo-cache/src/test/java/com/evolveum/midpoint/repo/cache/TestRepositoryCache.java @@ -6,6 +6,23 @@ */ package com.evolveum.midpoint.repo.cache; +import static org.testng.AssertJUnit.assertEquals; + +import static com.evolveum.midpoint.prism.util.PrismTestUtil.*; + +import java.io.IOException; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; +import javax.annotation.PostConstruct; + +import org.jetbrains.annotations.NotNull; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.Test; +import org.xml.sax.SAXException; + import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.prism.util.PrismTestUtil; @@ -16,6 +33,7 @@ import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.statistics.RepositoryPerformanceInformationUtil; +import com.evolveum.midpoint.test.util.AbstractSpringTest; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; import com.evolveum.midpoint.util.exception.ObjectNotFoundException; @@ -25,28 +43,13 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; -import org.jetbrains.annotations.NotNull; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import javax.annotation.PostConstruct; -import java.io.IOException; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -import static com.evolveum.midpoint.prism.util.PrismTestUtil.*; -import static org.testng.AssertJUnit.assertEquals; /** * */ -@SuppressWarnings("SameParameterValue") @ContextConfiguration(locations = {"classpath:ctx-repo-cache-test.xml" }) -public class TestRepositoryCache extends AbstractTestNGSpringContextTests { +@SuppressWarnings("SameParameterValue") +@ContextConfiguration(locations = { "classpath:ctx-repo-cache-test.xml" }) +public class TestRepositoryCache extends AbstractSpringTest { private static final String CLASS_DOT = TestRepositoryCache.class.getName() + "."; diff --git a/repo/repo-common/src/test/java/com/evolveum/midpoint/repo/common/commandline/TestCommandLine.java b/repo/repo-common/src/test/java/com/evolveum/midpoint/repo/common/commandline/TestCommandLine.java index 7f214b7b3fa..89d76bf2c45 100644 --- a/repo/repo-common/src/test/java/com/evolveum/midpoint/repo/common/commandline/TestCommandLine.java +++ b/repo/repo-common/src/test/java/com/evolveum/midpoint/repo/common/commandline/TestCommandLine.java @@ -68,11 +68,11 @@ public void test100PlainExecuteEcho() throws Exception { CommandLineScriptType scriptType = getScript(REPORT_PLAIN_ECHO_FILE); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); commandLineScriptExecutor.executeScript(scriptType, null, "test", task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); } @@ -95,11 +95,11 @@ public void test110RedirExecuteEcho() throws Exception { VAR_HELLOTEXT, "Hello World", PrimitiveType.STRING); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); commandLineScriptExecutor.executeScript(scriptType, variables, "test", task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); File targetFile = new File(MidPointTestConstants.TARGET_DIR_PATH, "echo-out"); diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/BaseSQLRepoTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/BaseSQLRepoTest.java index 71b8a2d4fd7..1f8cdd4b6a7 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/BaseSQLRepoTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/BaseSQLRepoTest.java @@ -32,6 +32,7 @@ import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.test.util.AbstractSpringTest; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.ObjectNotFoundException; @@ -48,7 +49,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.orm.hibernate5.LocalSessionFactoryBean; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; import org.testng.AssertJUnit; import org.testng.annotations.*; import org.xml.sax.SAXException; @@ -68,7 +68,7 @@ /** * @author lazyman */ -public class BaseSQLRepoTest extends AbstractTestNGSpringContextTests { +public class BaseSQLRepoTest extends AbstractSpringTest { private static final Trace LOGGER = TraceManager.getTrace(BaseSQLRepoTest.class); @@ -93,9 +93,11 @@ public class BaseSQLRepoTest extends AbstractTestNGSpringContextTests { static final ItemName ATTR_MANAGER = new ItemName(NS_RI, "manager"); @Autowired protected LocalSessionFactoryBean sessionFactoryBean; + @Autowired @Qualifier("sqlRepositoryServiceImpl") protected SqlRepositoryServiceImpl sqlRepositoryService; + @Autowired protected RepositoryService repositoryService; @Autowired protected BaseHelper baseHelper; @Autowired protected AuditService auditService; diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyTest.java index 726dc8b871b..47766a8b491 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyTest.java @@ -74,8 +74,6 @@ import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; import com.evolveum.midpoint.util.exception.ObjectNotFoundException; import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType; import com.evolveum.prism.xml.ns._public.query_3.SearchFilterType; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; @@ -92,8 +90,6 @@ public class ModifyTest extends BaseSQLRepoTest { private static final File ACCOUNT_FILE = new File(TEST_DIR, "account.xml"); private static final File MODIFY_USER_ADD_LINK = new File(TEST_DIR, "change-add.xml"); - private static final Trace LOGGER = TraceManager.getTrace(ModifyTest.class); - private static final QName QNAME_LOOT = new QName("http://example.com/p", "loot"); private static final QName QNAME_WEAPON = new QName("http://example.com/p", "weapon"); private static final QName QNAME_FUNERAL_DATE = new QName("http://example.com/p", "funeralDate"); @@ -198,7 +194,7 @@ public void test030ModifyUserOnNonExistingAccountTest() throws Exception { PrismObject userNew = repositoryService.getObject(UserType.class, oid, null, result); ObjectDelta delta = userOld.diff(userNew); - LOGGER.debug("Modify diff \n{}", delta.debugDump(3)); + logger.debug("Modify diff \n{}", delta.debugDump(3)); AssertJUnit.assertTrue("Modify was unsuccessful, diff size: " + delta.getModifications().size(), delta.isEmpty()); AssertJUnit.assertTrue("User is not equivalent.", userOld.equivalent(userNew)); @@ -238,7 +234,7 @@ public void test031ModifyUserOnExistingAccountTest() throws Exception { PrismObject userNew = repositoryService.getObject(UserType.class, oid, null, result); ObjectDelta delta = userOld.diff(userNew); - LOGGER.debug("Modify diff \n{}", delta.debugDump(3)); + logger.debug("Modify diff \n{}", delta.debugDump(3)); AssertJUnit.assertTrue("Modify was unsuccessful, diff size: " + delta.getModifications().size(), delta.isEmpty()); AssertJUnit.assertTrue("User is not equivalent.", userOld.equivalent(userNew)); @@ -257,8 +253,7 @@ public void test032ModifyTaskObjectRef() throws Exception { final String taskOid = "00000000-0000-0000-0000-123450000001"; AssertJUnit.assertNotNull(taskOid); System.out.println("GET"); - PrismObject getTask = null; - getTask = repositoryService.getObject(TaskType.class, taskOid, null, result); + PrismObject getTask = repositoryService.getObject(TaskType.class, taskOid, null, result); String lastVersion = getTask.getVersion(); AssertJUnit.assertTrue(task.equivalent(getTask)); TaskType taskType = null; @@ -301,7 +296,7 @@ public void test032ModifyTaskObjectRef() throws Exception { AssertJUnit.assertNotNull(taskType.getObjectRef()); objectRef = taskType.getObjectRef(); assertEquals("2", objectRef.getOid()); - LOGGER.info(PrismTestUtil.serializeObjectToString(taskType.asPrismObject())); + logger.info(PrismTestUtil.serializeObjectToString(taskType.asPrismObject())); SqlRepoTestUtil.assertVersionProgress(lastVersion, getTask.getVersion()); lastVersion = getTask.getVersion(); @@ -569,7 +564,7 @@ public void test120ModifyAccountMetadata() throws Exception { // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); PrismObject repoShadow = repositoryService.getObject(ShadowType.class, oid, null, parentResult); @@ -597,7 +592,7 @@ public void test120ModifyAccountMetadata() throws Exception { modifications.add(pdelta); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); repositoryService.modifyObject(ShadowType.class, oid, modifications, getModifyOptions(), parentResult); // THEN @@ -624,7 +619,7 @@ public void test120ModifyAccountMetadata() throws Exception { prismContext); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); repositoryService.modifyObject(ShadowType.class, oid, syncSituationDeltas, getModifyOptions(), parentResult); // AssertJUnit.assertNull(afterModify.asObjectable().getObjectChange()); @@ -986,11 +981,11 @@ public void test200ReplaceAttributes() throws Exception { Session session = open(); List shadows = session.createQuery("from RShadow").list(); - LOGGER.info("shadows:\n{}", shadows); + logger.info("shadows:\n{}", shadows); //noinspection unchecked List extStrings = session.createQuery("select e.owner.oid, e.itemId, e.value from ROExtString e").list(); for (Object[] extString : extStrings) { - LOGGER.info("-> {}", Arrays.asList(extString)); + logger.info("-> {}", Arrays.asList(extString)); } close(session); @@ -998,7 +993,7 @@ public void test200ReplaceAttributes() throws Exception { .item(ItemPath.create(ShadowType.F_ATTRIBUTES, ATTR1_QNAME), def1).eq("value1") .build(); List list1 = repositoryService.searchObjects(ShadowType.class, query1, null, result); - LOGGER.info("*** query1 result:\n{}", DebugUtil.debugDump(list1)); + logger.info("*** query1 result:\n{}", DebugUtil.debugDump(list1)); assertEquals("Wrong # of query1 results", 1, list1.size()); session = open(); diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyUser.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyUser.java index 9324f2beb9f..abc9e413cf7 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyUser.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyUser.java @@ -77,7 +77,7 @@ public void test020ModifyUser() throws Exception { delta.setOid(userOid); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); repositoryService.modifyObject(UserType.class, userOid, delta.getModifications(), result); // THEN @@ -104,7 +104,7 @@ public void test021ModifyUserNoEmpNum() throws Exception { delta.setOid(userOid); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); repositoryService.modifyObject(UserType.class, userOid, delta.getModifications(), result); // THEN @@ -131,7 +131,7 @@ public void test022ModifyUserEmptyEmpNum() throws Exception { delta.setOid(userOid); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); repositoryService.modifyObject(UserType.class, userOid, delta.getModifications(), result); // THEN diff --git a/repo/repo-test-util/pom.xml b/repo/repo-test-util/pom.xml index 01e6273de5c..436f2c0e246 100644 --- a/repo/repo-test-util/pom.xml +++ b/repo/repo-test-util/pom.xml @@ -132,10 +132,6 @@ javax.annotation javax.annotation-api - - org.springframework - spring-test - com.evolveum.midpoint.tools test-ng diff --git a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractHigherUnitTest.java b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractHigherUnitTest.java index 93287b23438..1915531dba4 100644 --- a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractHigherUnitTest.java +++ b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractHigherUnitTest.java @@ -17,7 +17,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.Random; import java.util.stream.Collectors; import javax.xml.bind.JAXBException; @@ -66,6 +65,7 @@ import com.evolveum.midpoint.schema.util.ResourceTypeUtil; import com.evolveum.midpoint.schema.util.ShadowUtil; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.util.AbstractUnitTest; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DebugDumpable; @@ -74,8 +74,6 @@ import com.evolveum.midpoint.util.exception.CommonException; import com.evolveum.midpoint.util.exception.ObjectNotFoundException; import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType; import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType; @@ -101,14 +99,11 @@ * * @author Radovan Semancik */ -public abstract class AbstractHigherUnitTest { +public abstract class AbstractHigherUnitTest extends AbstractUnitTest { public static final String COMMON_DIR_NAME = "common"; public static final File COMMON_DIR = new File(MidPointTestConstants.TEST_RESOURCES_DIR, COMMON_DIR_NAME); - private static final Trace LOGGER = TraceManager.getTrace(AbstractHigherUnitTest.class); - protected static final Random RND = new Random(); - @BeforeSuite public void setup() throws SchemaException, SAXException, IOException { PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); @@ -505,14 +500,6 @@ protected void displayTestTitle(String testName) { TestUtil.displayTestTitle(this, testName); } - protected void displayWhen(String testName) { - TestUtil.displayWhen(testName); - } - - protected void displayThen(String testName) { - TestUtil.displayThen(testName); - } - protected void displayCleanup(String testName) { TestUtil.displayCleanup(testName); } 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 1fd79152a6a..51a2f4cc14f 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 @@ -13,7 +13,6 @@ import java.io.File; import java.io.IOException; import java.io.RandomAccessFile; -import java.lang.reflect.Method; import java.security.KeyStore; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; @@ -44,7 +43,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.security.crypto.password.LdapShaPasswordEncoder; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; import org.testng.Assert; import org.testng.AssertJUnit; import org.testng.ITestResult; @@ -108,8 +106,6 @@ import com.evolveum.midpoint.tools.testng.CurrentTestResultHolder; import com.evolveum.midpoint.util.*; import com.evolveum.midpoint.util.exception.*; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; @@ -119,7 +115,7 @@ * @author Radovan Semancik */ @Listeners({ CurrentTestResultHolder.class }) -public abstract class AbstractIntegrationTest extends AbstractTestNGSpringContextTests { +public abstract class AbstractIntegrationTest extends AbstractSpringTest { protected static final String USER_ADMINISTRATOR_USERNAME = "administrator"; @@ -131,11 +127,6 @@ public abstract class AbstractIntegrationTest extends AbstractTestNGSpringContex protected static final String OPENDJ_PEOPLE_SUFFIX = "ou=people,dc=example,dc=com"; protected static final String OPENDJ_GROUPS_SUFFIX = "ou=groups,dc=example,dc=com"; - /** - * Hides parent's logger, but that one is from commons-logging and we don't want that. - */ - protected final Trace logger = TraceManager.getTrace(getClass()); - protected static final Random RND = new Random(); private static final float FLOAT_EPSILON = 0.001f; @@ -200,7 +191,7 @@ public void initSystemConditional() throws Exception { assertNotNull("Task manager is not wired properly", taskManager); PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); PrismTestUtil.setPrismContext(prismContext); - Task initTask = createTask(getClass().getName() + ".initSystem"); + Task initTask = createTask("INIT"); initTask.setChannel(SchemaConstants.CHANNEL_GUI_INIT_URI); OperationResult result = initTask.getResult(); @@ -236,6 +227,7 @@ protected void postInitSystem(Task initTask, OperationResult initResult) throws /** * Creates appropriate task and result and set it into MidpointTestMethodContext. + * This implementation fully overrides (without use) the one from {@link AbstractSpringTest}. */ @BeforeMethod public void startTestContext(ITestResult testResult) { @@ -244,7 +236,7 @@ public void startTestContext(ITestResult testResult) { TestUtil.displayTestTitle(testClass.getSimpleName() + "." + testMethodName); - Task task = createTask(testClass.getName() + "." + testMethodName); + Task task = createTask(testMethodName); customizeTask(task); // TODO do we need that subresult? :-) (Virgo's brave new world) // maybe it doesn't break tests, but changes traceability/maintenance? @@ -272,14 +264,14 @@ protected void customizeTask(Task task) { /** * Finish and destroy the test context, output duration and store the operation trace. + * This implementation fully overrides (without use) the one from {@link AbstractSpringTest}. */ @AfterMethod - public void finishTestContext(ITestResult testResult, Method testMethod) { + public void finishTestContext(ITestResult testResult) { MidpointTestMethodContext context = MidpointTestMethodContext.get(); MidpointTestMethodContext.destroy(); // let's destroy it before anything else in this method - long testMsDuration = testResult.getEndMillis() - testResult.getStartMillis(); - TestUtil.displayFooter(testMethod.getName() + " FINISHED in " + testMsDuration + " ms"); + displayDefaultTestFooter(testResult); Task task = context.getTask(); if (task != null) { @@ -333,19 +325,30 @@ protected Task getTestTask() { return MidpointTestMethodContext.get().getTask(); } - protected String getTestNameShort() { + public String getTestNameShort() { return MidpointTestMethodContext.get().getTestNameShort(); } /** - * Creates the new {@link Task}. + * Creates new {@link Task}. * For most tests this should be unnecessary and the default test-method-scoped task * that can be obtained with {@link #getTestTask()} should be enough. * Even for multi-threaded tests we may not need a new task and new subresult * (using {@link #createSubresult(String)} should suffice. + * Provided name is automatically prefixed by {@link #contextName()}. */ protected Task createTask(String operationName) { - return taskManager.createTaskInstance(operationName); + return taskManager.createTaskInstance(contextName() + "." + operationName); + } + + /** + * Context name is "class-simple-name.method" if test method context is available, + * otherwise it is just simple name of the test class. + */ + @NotNull + protected String contextName() { + MidpointTestMethodContext context = MidpointTestMethodContext.get(); + return context != null ? context.getTestName() : getClass().getSimpleName(); } /** @@ -357,6 +360,8 @@ protected OperationResult createSubresult(String subresultSuffix) { /** * Returns default {@link OperationResult} for pre-created test-method-scoped {@link Task}. + * This result can be freely used in test for some "main scope", it is not asserted in any + * after method, only displayed. */ protected OperationResult getResult() { return MidpointTestMethodContext.get().getResult(); @@ -382,14 +387,14 @@ protected PrismObject repoAdd(TestResource resource, O } protected PrismObject repoAddObjectFromFile( - File file, Class type, OperationResult parentResult) + File file, @SuppressWarnings("unused") Class type, OperationResult parentResult) throws SchemaException, ObjectAlreadyExistsException, EncryptionException, IOException { return repoAddObjectFromFile(file, false, parentResult); } protected PrismObject repoAddObjectFromFile( - File file, Class type, boolean metadata, OperationResult parentResult) + File file, @SuppressWarnings("unused") Class type, boolean metadata, OperationResult parentResult) throws SchemaException, ObjectAlreadyExistsException, EncryptionException, IOException { return repoAddObjectFromFile(file, metadata, parentResult); @@ -1759,37 +1764,6 @@ protected PrismObject parseObject(File file) throws Sc return prismContext.parseObject(file); } - /** - * Displays "when" subsection header with test name. - * Even better, use {@link #displayWhen(String)} and provide human readable description. - */ - protected void displayWhen() { - displayWhen(getTestNameShort()); - } - - /** - * Displays "when" subsection header with test name and provided description (nullable). - */ - protected void displayWhen(String description) { - TestUtil.displayWhen(getTestNameShort(), description); - } - - protected void displayWhen(String testName, String stage) { - TestUtil.displayWhen(testName + " (" + stage + ")"); - } - - protected void displayThen() { - displayThen(getTestNameShort()); - } - - protected void displayThen(String testName) { - TestUtil.displayThen(testName); - } - - protected void displayThen(String testName, String stage) { - TestUtil.displayThen(testName + " (" + stage + ")"); - } - protected void displayCleanup(String testName) { TestUtil.displayCleanup(testName); } diff --git a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/AbstractTaskManagerTest.java b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/AbstractTaskManagerTest.java index b6bc3b72346..eb527d03433 100644 --- a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/AbstractTaskManagerTest.java +++ b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/AbstractTaskManagerTest.java @@ -21,6 +21,7 @@ import com.evolveum.midpoint.task.api.TaskDebugUtil; import com.evolveum.midpoint.task.api.TaskExecutionStatus; import com.evolveum.midpoint.test.IntegrationTestTools; +import com.evolveum.midpoint.test.util.AbstractSpringTest; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.CommonException; @@ -30,7 +31,6 @@ import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; import org.testng.annotations.BeforeSuite; import org.xml.sax.SAXException; @@ -47,7 +47,7 @@ /** * @author mederly */ -public class AbstractTaskManagerTest extends AbstractTestNGSpringContextTests { +public class AbstractTaskManagerTest extends AbstractSpringTest { protected static final String CYCLE_TASK_HANDLER_URI = "http://midpoint.evolveum.com/test/cycle-task-handler"; protected static final String CYCLE_FINISHING_TASK_HANDLER_URI = "http://midpoint.evolveum.com/test/cycle-finishing-task-handler"; @@ -87,7 +87,7 @@ public class AbstractTaskManagerTest extends AbstractTestNGSpringContextTests { protected MockParallelTaskHandler parallelTaskHandler; protected MockLongTaskHandler longTaskHandler; - protected static OperationResult createResult(String test, Trace logger) { + protected static OperationResult createResult(String test) { TestUtil.displayTestTitle(test); return new OperationResult(TestQuartzTaskManagerContract.class.getName() + ".test" + test); } diff --git a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/CleanupTest.java b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/CleanupTest.java index 8c521ff929d..c605c2f01b6 100644 --- a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/CleanupTest.java +++ b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/CleanupTest.java @@ -7,45 +7,40 @@ package com.evolveum.midpoint.task.quartzimpl; -import com.evolveum.midpoint.prism.Objectable; -import com.evolveum.midpoint.prism.PrismContext; -import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.repo.api.RepositoryService; -import com.evolveum.midpoint.repo.sql.type.XMLGregorianCalendarType; -import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.common_3.CleanupPolicyType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType; +import static com.evolveum.midpoint.test.IntegrationTestTools.display; + +import java.io.File; +import java.util.Calendar; +import java.util.Date; +import java.util.List; +import java.util.TimeZone; +import javax.xml.datatype.DatatypeFactory; +import javax.xml.datatype.Duration; +import javax.xml.datatype.XMLGregorianCalendar; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; import org.testng.AssertJUnit; import org.testng.annotations.Test; -import javax.xml.datatype.DatatypeFactory; -import javax.xml.datatype.Duration; -import javax.xml.datatype.XMLGregorianCalendar; - -import java.io.File; -import java.util.Calendar; -import java.util.Date; -import java.util.List; -import java.util.TimeZone; - -import static com.evolveum.midpoint.test.IntegrationTestTools.display; +import com.evolveum.midpoint.prism.Objectable; +import com.evolveum.midpoint.prism.PrismContext; +import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.repo.api.RepositoryService; +import com.evolveum.midpoint.repo.sql.type.XMLGregorianCalendarType; +import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.test.util.AbstractSpringTest; +import com.evolveum.midpoint.xml.ns._public.common.common_3.CleanupPolicyType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType; /** * @author lazyman */ -@ContextConfiguration(locations = {"classpath:ctx-task-test.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-task-test.xml" }) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) -public class CleanupTest extends AbstractTestNGSpringContextTests { - - private static final Trace LOGGER = TraceManager.getTrace(CleanupTest.class); +public class CleanupTest extends AbstractSpringTest { public static final File FOLDER_BASIC = new File("./src/test/resources/basic"); @@ -54,7 +49,7 @@ public class CleanupTest extends AbstractTestNGSpringContextTests { @Autowired private RepositoryService repositoryService; @Autowired - private PrismContext prismContext; + private PrismContext prismContext; @Test public void testTasksCleanup() throws Exception { diff --git a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestPartitioning.java b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestPartitioning.java index e2a62db2dd5..734ac14fcd1 100644 --- a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestPartitioning.java +++ b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestPartitioning.java @@ -99,7 +99,7 @@ public void test000Integrity() { @Test public void test100DurableRecurring() throws Exception { final String TEST_NAME = "test100DurableRecurring"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); // WHEN addObjectFromFile(taskFilename(TEST_NAME, "m")); diff --git a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestQuartzTaskManagerContract.java b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestQuartzTaskManagerContract.java index 38dccd32d87..ce1d4ab6745 100644 --- a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestQuartzTaskManagerContract.java +++ b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestQuartzTaskManagerContract.java @@ -112,7 +112,7 @@ public void test000Integrity() { @Test public void test003GetProgress() throws Exception { String TEST_NAME = "test003GetProgress"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); @@ -126,7 +126,7 @@ public void test003GetProgress() throws Exception { @Test(enabled=false) // this is probably OK to fail, so do not enable it (at least for now) public void test004aTaskBigProperty() throws Exception { String TEST_NAME = "test004aTaskBigProperty"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); String string300 = "123456789-123456789-123456789-123456789-123456789-" + "123456789-123456789-123456789-123456789-123456789-" @@ -190,7 +190,7 @@ public void test004aTaskBigProperty() throws Exception { @Test public void test004bTaskBigProperty() throws Exception { String TEST_NAME = "test004aTaskBigProperty"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); String string300 = "123456789-123456789-123456789-123456789-123456789-" + "123456789-123456789-123456789-123456789-123456789-" @@ -248,7 +248,7 @@ public void test004bTaskBigProperty() throws Exception { @Test(enabled = false) public void test004cReferenceInExtension() throws Exception { // ok to fail String TEST_NAME = "test004cReferenceInExtension"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); TaskQuartzImpl task = getTask(taskOid(TEST_NAME), result); @@ -270,7 +270,7 @@ public void test004cReferenceInExtension() throws Exception { // o @Test(enabled = false) public void test004TaskProperties() throws Exception { String TEST_NAME = "test004TaskProperties"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); @@ -435,7 +435,7 @@ public void test004TaskProperties() throws Exception { @Test public void test005Single() throws Exception { final String TEST_NAME = "test005Single"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); // reset 'has run' flag on the handler singleHandler1.resetHasRun(); @@ -512,7 +512,7 @@ public void test005Single() throws Exception { @Test public void test006Cycle() throws Exception { final String TEST_NAME = "test006Cycle"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); // But before that check sanity ... a known problem with xsi:type PrismObject object = addObjectFromFile(taskFilename(TEST_NAME)); @@ -593,7 +593,7 @@ private void assertSuccessOrInProgress(Task task) { @Test public void test008MoreHandlers() throws Exception { final String TEST_NAME = "test008MoreHandlers"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); // reset 'has run' flag on handlers singleHandler1.resetHasRun(); @@ -649,7 +649,7 @@ public void test008MoreHandlers() throws Exception { @Test public void test009CycleLoose() throws Exception { final String TEST_NAME = "test009CycleLoose"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); @@ -694,7 +694,7 @@ public void test009CycleLoose() throws Exception { @Test public void test010CycleCronLoose() throws Exception { final String TEST_NAME = "test010CycleCronLoose"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); @@ -732,7 +732,7 @@ public void test010CycleCronLoose() throws Exception { @Test public void test011MoreHandlersAndSchedules() throws Exception { final String TEST_NAME = "test011MoreHandlersAndSchedules"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); // reset 'has run' flag on handlers l1Handler.resetHasRun(); @@ -800,7 +800,7 @@ public void test011MoreHandlersAndSchedules() throws Exception { @Test public void test012Suspend() throws Exception { final String TEST_NAME = "test012Suspend"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); @@ -846,7 +846,7 @@ public void test012Suspend() throws Exception { @Test public void test013ReleaseAndSuspendLooselyBound() throws Exception { final String TEST_NAME = "test013ReleaseAndSuspendLooselyBound"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); @@ -903,7 +903,7 @@ public void test013ReleaseAndSuspendLooselyBound() throws Exception { @Test public void test014SuspendLongRunning() throws Exception { final String TEST_NAME = "test014SuspendLongRunning"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); @@ -962,7 +962,7 @@ public void test014SuspendLongRunning() throws Exception { @Test public void test015DeleteTaskFromRepo() throws Exception { final String TEST_NAME = "test015DeleteTaskFromRepo"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); String oid = taskOid(TEST_NAME); @@ -998,7 +998,7 @@ public void timeout() { @Test public void test016WaitForSubtasks() throws Exception { final String TEST_NAME = "test016WaitForSubtasks"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); //taskManager.getClusterManager().startClusterManagerThread(); @@ -1080,7 +1080,7 @@ public void test016WaitForSubtasks() throws Exception { @Test public void test017WaitForSubtasksEmpty() throws Exception { final String TEST_NAME = "test017WaitForSubtasksEmpty"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); taskManager.getClusterManager().startClusterManagerThread(); @@ -1096,7 +1096,7 @@ public void test017WaitForSubtasksEmpty() throws Exception { @Test public void test018TaskResult() throws Exception { final String TEST_NAME = "test018RefreshingResult"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); Task task = taskManager.createTaskInstance(); task.setInitialExecutionStatus(TaskExecutionStatus.SUSPENDED); @@ -1123,7 +1123,7 @@ public void test018TaskResult() throws Exception { @Test public void test019FinishedHandler() throws Exception { final String TEST_NAME = "test019FinishedHandler"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); // reset 'has run' flag on handlers singleHandler1.resetHasRun(); @@ -1172,7 +1172,7 @@ public void test019FinishedHandler() throws Exception { @Test public void test020QueryByExecutionStatus() throws Exception { final String TEST_NAME = "test020QueryByExecutionStatus"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); taskManager.createTaskInstance((PrismObject) (PrismObject) addObjectFromFile(taskFilename(TEST_NAME)), result); @@ -1192,7 +1192,7 @@ public void test020QueryByExecutionStatus() throws Exception { @Test public void test021DeleteTaskTree() throws Exception { final String TEST_NAME = "test021DeleteTaskTree"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); PrismObject parentTaskPrism = addObjectFromFile(taskFilename(TEST_NAME)); PrismObject childTask1Prism = addObjectFromFile(taskFilename(TEST_NAME+"-child1")); @@ -1247,7 +1247,7 @@ public void test021DeleteTaskTree() throws Exception { @Test public void test022ExecuteRecurringOnDemand() throws Exception { final String TEST_NAME = "test022ExecuteRecurringOnDemand"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); @@ -1292,7 +1292,7 @@ public void test022ExecuteRecurringOnDemand() throws Exception { @Test public void test100LightweightSubtasks() throws Exception { final String TEST_NAME = "test100LightweightSubtasks"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); @@ -1340,7 +1340,7 @@ private void checkTaskStateRepeatedly(String taskOid, OperationResult result, in @Test public void test105LightweightSubtasksSuspension() throws Exception { final String TEST_NAME = "test105LightweightSubtasksSuspension"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); @@ -1389,7 +1389,7 @@ public void test105LightweightSubtasksSuspension() throws Exception { @Test public void test108SecondaryGroupLimit() throws Exception { final String TEST_NAME = "test108SecondaryGroupLimit"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); TaskType task1 = (TaskType) addObjectFromFile(taskFilename(TEST_NAME)).asObjectable(); waitForTaskStart(task1.getOid(), result, 10000, 500); @@ -1448,7 +1448,7 @@ protected void assertNextRetryTimeSet(TaskType task, OperationResult result) @Test public void test110GroupLimit() throws Exception { final String TEST_NAME = "test110GroupLimit"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); taskManager.getExecutionManager().setLocalExecutionLimitations((TaskExecutionLimitationsType) null); @@ -1487,7 +1487,7 @@ private TaskType getTaskType(String oid, OperationResult result) throws SchemaEx @Test public void test120NodeAllowed() throws Exception { final String TEST_NAME = "test120NodeAllowed"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); taskManager.getExecutionManager().setLocalExecutionLimitations( new TaskExecutionLimitationsType() @@ -1504,7 +1504,7 @@ public void test120NodeAllowed() throws Exception { @Test public void test130NodeNotAllowed() throws Exception { final String TEST_NAME = "test130NodeNotAllowed"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); TaskType task = (TaskType) addObjectFromFile(taskFilename(TEST_NAME)).asObjectable(); Thread.sleep(10000); @@ -1516,7 +1516,7 @@ public void test130NodeNotAllowed() throws Exception { @Test public void test999CheckingLeftovers() throws Exception { String TEST_NAME = "test999CheckingLeftovers"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); ArrayList leftovers = new ArrayList<>(); checkLeftover(leftovers, "test005", result); diff --git a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestWorkBucketStrategies.java b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestWorkBucketStrategies.java index 4996019d20d..e863887be25 100644 --- a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestWorkBucketStrategies.java +++ b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestWorkBucketStrategies.java @@ -113,7 +113,7 @@ public void test000Integrity() { @Test public void test100NumericExplicitBuckets() throws Exception { final String TEST_NAME = "test100NumericExplicitBuckets"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); TaskQuartzImpl task = taskManager.getTask(taskOid(TEST_NAME), result); @@ -194,7 +194,7 @@ public void test100NumericExplicitBuckets() throws Exception { @Test public void test110FilterExplicitBuckets() throws Exception { final String TEST_NAME = "test110FilterExplicitBuckets"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); TaskQuartzImpl task = taskManager.getTask(taskOid(TEST_NAME), result); @@ -282,7 +282,7 @@ public void test110FilterExplicitBuckets() throws Exception { @Test public void test120StringPrefixBuckets() throws Exception { final String TEST_NAME = "test120StringPrefixBuckets"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); TaskQuartzImpl task = taskManager.getTask(taskOid(TEST_NAME), result); @@ -338,7 +338,7 @@ public void test120StringPrefixBuckets() throws Exception { @Test public void test125StringExactValueBuckets() throws Exception { final String TEST_NAME = "test125StringExactValueBuckets"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); TaskQuartzImpl task = taskManager.getTask(taskOid(TEST_NAME), result); @@ -394,7 +394,7 @@ public void test125StringExactValueBuckets() throws Exception { @Test public void test130StringIntervalBuckets() throws Exception { final String TEST_NAME = "test130StringIntervalBuckets"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); TaskQuartzImpl task = taskManager.getTask(taskOid(TEST_NAME), result); @@ -444,7 +444,7 @@ public void test130StringIntervalBuckets() throws Exception { @Test public void test140OidBuckets() throws Exception { final String TEST_NAME = "test140OidBuckets"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); TaskQuartzImpl task = taskManager.getTask(taskOid(TEST_NAME), result); @@ -463,7 +463,7 @@ public void test140OidBuckets() throws Exception { @Test public void test150OidBucketsTwice() throws Exception { final String TEST_NAME = "test150OidBucketsTwice"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); TaskQuartzImpl task = taskManager.getTask(taskOid(TEST_NAME), result); diff --git a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestWorkDistribution.java b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestWorkDistribution.java index 34b33de474f..163051ece7a 100644 --- a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestWorkDistribution.java +++ b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestWorkDistribution.java @@ -117,7 +117,7 @@ public void test000Integrity() { @Test public void test100AllocateBucket() throws Exception { final String TEST_NAME = "test100AllocateBucket"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(coordinatorTaskFilename(TEST_NAME)); addObjectFromFile(workerTaskFilename(TEST_NAME)); @@ -150,7 +150,7 @@ public void test100AllocateBucket() throws Exception { @Test public void test105AllocateBucketStandalone() throws Exception { final String TEST_NAME = "test105AllocateBucketStandalone"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); TaskQuartzImpl standalone = taskManager.getTask(taskOid(TEST_NAME), result); @@ -177,7 +177,7 @@ public void test105AllocateBucketStandalone() throws Exception { @Test public void test107AllocateBucketStandaloneBatched() throws Exception { final String TEST_NAME = "test107AllocateBucketStandaloneBatched"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); TaskQuartzImpl standalone = taskManager.getTask(taskOid(TEST_NAME), result); @@ -204,7 +204,7 @@ public void test107AllocateBucketStandaloneBatched() throws Exception { public void test110AllocateTwoBucketsStandalone() throws Exception { final String TEST_NAME = "test110AllocateTwoBucketsStandalone"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); TaskQuartzImpl standalone = taskManager.getTask(taskOid(TEST_NAME), result); @@ -271,7 +271,7 @@ public void test110AllocateTwoBucketsStandalone() throws Exception { @Test public void test120UnspecifiedBuckets() throws Exception { final String TEST_NAME = "test120UnspecifiedBuckets"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); TaskQuartzImpl task = taskManager.getTask(taskOid(TEST_NAME), result); @@ -288,7 +288,7 @@ public void test120UnspecifiedBuckets() throws Exception { @Test public void test130AllocateReleaseCompleteSequence() throws Exception { final String TEST_NAME = "test130AllocateReleaseCompleteSequence"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(coordinatorTaskFilename(TEST_NAME)); addObjectFromFile(taskFilename(TEST_NAME, "1")); addObjectFromFile(taskFilename(TEST_NAME, "2")); @@ -516,7 +516,7 @@ public void test130AllocateReleaseCompleteSequence() throws Exception { @Test public void test200OneWorkerTask() throws Exception { final String TEST_NAME = "test200OneWorkerTask"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(coordinatorTaskFilename(TEST_NAME)); addObjectFromFile(workerTaskFilename(TEST_NAME)); @@ -544,7 +544,7 @@ public void test200OneWorkerTask() throws Exception { @Test public void test210ThreeWorkersTask() throws Exception { final String TEST_NAME = "test210ThreeWorkersTask"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(coordinatorTaskFilename(TEST_NAME)); addObjectFromFile(taskFilename(TEST_NAME, "1")); addObjectFromFile(taskFilename(TEST_NAME, "2")); @@ -596,7 +596,7 @@ public void test210ThreeWorkersTask() throws Exception { @Test public void test220WorkerSuspend() throws Exception { final String TEST_NAME = "test220WorkerSuspend"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(coordinatorTaskFilename(TEST_NAME)); addObjectFromFile(taskFilename(TEST_NAME, "1")); addObjectFromFile(taskFilename(TEST_NAME, "2")); @@ -623,7 +623,7 @@ public void test220WorkerSuspend() throws Exception { }); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); taskManager.resumeTask(worker1, result); taskManager.resumeTask(worker2, result); taskManager.resumeTask(worker3, result); @@ -656,7 +656,7 @@ public void test220WorkerSuspend() throws Exception { // TODO other asserts // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); workBucketsTaskHandler.setDelayProcessor(50); @@ -685,7 +685,7 @@ public void test220WorkerSuspend() throws Exception { @Test public void test230WorkerException() throws Exception { final String TEST_NAME = "test230WorkerException"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(coordinatorTaskFilename(TEST_NAME)); addObjectFromFile(taskFilename(TEST_NAME, "1")); addObjectFromFile(taskFilename(TEST_NAME, "2")); @@ -708,7 +708,7 @@ public void test230WorkerException() throws Exception { }); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); taskManager.resumeTask(worker1, result); taskManager.resumeTask(worker2, result); taskManager.resumeTask(worker3, result); @@ -741,7 +741,7 @@ public void test230WorkerException() throws Exception { // TODO other asserts // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); workBucketsTaskHandler.setDelayProcessor(50); @@ -778,7 +778,7 @@ public void test230WorkerException() throws Exception { @Test public void test300NarrowQueryOneWorkerTask() throws Exception { final String TEST_NAME = "test300NarrowQueryOneWorkerTask"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(coordinatorTaskFilename(TEST_NAME)); addObjectFromFile(workerTaskFilename(TEST_NAME)); diff --git a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestWorkersManagement.java b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestWorkersManagement.java index 7db345d6add..1b3a2913d9a 100644 --- a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestWorkersManagement.java +++ b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestWorkersManagement.java @@ -6,6 +6,22 @@ */ package com.evolveum.midpoint.task.quartzimpl; +import static java.util.Collections.singleton; +import static org.testng.AssertJUnit.*; + +import static com.evolveum.midpoint.test.IntegrationTestTools.display; + +import java.util.List; +import javax.annotation.PostConstruct; +import javax.xml.namespace.QName; + +import org.jetbrains.annotations.NotNull; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.ContextConfiguration; +import org.testng.AssertJUnit; +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.schema.cache.CacheConfigurationManager; import com.evolveum.midpoint.schema.result.OperationResult; @@ -14,27 +30,7 @@ import com.evolveum.midpoint.task.quartzimpl.work.WorkStateManager; import com.evolveum.midpoint.util.DebugUtil; import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; -import org.jetbrains.annotations.NotNull; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.testng.AssertJUnit; -import org.testng.annotations.Test; - -import javax.annotation.PostConstruct; -import javax.xml.namespace.QName; -import java.util.List; - -import static com.evolveum.midpoint.test.IntegrationTestTools.display; -import static com.evolveum.midpoint.test.util.TestUtil.displayThen; -import static com.evolveum.midpoint.test.util.TestUtil.displayWhen; -import static java.util.Collections.singleton; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; /** * Tests task handlers for workers creation and for task partitioning. @@ -42,11 +38,10 @@ * @author mederly */ -@ContextConfiguration(locations = {"classpath:ctx-task-test.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-task-test.xml" }) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) public class TestWorkersManagement extends AbstractTaskManagerTest { - private static final Trace LOGGER = TraceManager.getTrace(TestWorkersManagement.class); private static final long DEFAULT_SLEEP_INTERVAL = 250L; private static final long DEFAULT_TIMEOUT = 30000L; @@ -116,7 +111,7 @@ public void test000Integrity() { @Test public void test100CreateWorkersSingle() throws Exception { final String TEST_NAME = "test100CreateWorkersSingle"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); workBucketsTaskHandler.resetBeforeTest(); workBucketsTaskHandler.setDelayProcessor(DEFAULT_SLEEP_INTERVAL); @@ -177,19 +172,19 @@ private void displayBucketOpStatistics(String label, Task task) throws SchemaExc @Test public void test110CreateWorkersRecurring() throws Exception { final String TEST_NAME = "test110CreateWorkersRecurring"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); workBucketsTaskHandler.resetBeforeTest(); workBucketsTaskHandler.setDelayProcessor(DEFAULT_SLEEP_INTERVAL); // (1) ------------------------------------------------------------------------------------ WHEN (import task) - displayWhen(TEST_NAME, "1: import task"); + when("1: import task"); addObjectFromFile(coordinatorTaskFilename(TEST_NAME)); String coordinatorTaskOid = coordinatorTaskOid(TEST_NAME); try { // THEN (worker is created and executed) - displayThen(TEST_NAME, "1: import task"); + then("1: import task"); waitForTaskProgress(coordinatorTaskOid, result, DEFAULT_TIMEOUT, DEFAULT_SLEEP_INTERVAL, 1); TaskQuartzImpl coordinatorTask = taskManager.getTask(coordinatorTaskOid(TEST_NAME), result); @@ -207,12 +202,12 @@ public void test110CreateWorkersRecurring() throws Exception { // coordinator should run automatically in cca 15 seconds // (2) ------------------------------------------------------------------------------------ WHEN (wait for coordinator next run) - displayWhen(TEST_NAME, "2: wait for coordinator next run"); + when("2: wait for coordinator next run"); // TODO adapt this when the coordinator progress will be reported in other ways waitForTaskProgress(coordinatorTaskOid, result, 30000, DEFAULT_SLEEP_INTERVAL, 2); // THEN (worker is still present and executed) - displayThen(TEST_NAME, "2: wait for coordinator next run"); + then("2: wait for coordinator next run"); coordinatorTask = taskManager.getTask(coordinatorTaskOid(TEST_NAME), result); workers = coordinatorTask.listSubtasks(result); assertEquals("Wrong # of workers", 1, workers.size()); @@ -225,11 +220,11 @@ public void test110CreateWorkersRecurring() throws Exception { assertEquals("Wrong # of items processed", 8, workBucketsTaskHandler.getItemsProcessed()); // (3) ------------------------------------------------------------------------------------ WHEN (suspend the tree while work is done) - displayWhen(TEST_NAME, "3: suspend the tree while work is done"); + when("3: suspend the tree while work is done"); boolean stopped = taskManager.suspendTaskTree(coordinatorTaskOid, DEFAULT_TIMEOUT, result); // THEN (tasks are suspended) - displayThen(TEST_NAME, "3: suspend the tree while work is done"); + then("3: suspend the tree while work is done"); coordinatorTask = taskManager.getTask(coordinatorTaskOid(TEST_NAME), result); workers = coordinatorTask.listSubtasks(result); assertEquals("Wrong # of workers", 1, workers.size()); @@ -250,11 +245,11 @@ public void test110CreateWorkersRecurring() throws Exception { assertEquals("Wrong state-before-suspend of worker", null, worker.getStateBeforeSuspend()); // (4) ------------------------------------------------------------------------------------ WHEN (resume the tree) - displayWhen(TEST_NAME, "4: resume the tree"); + when("4: resume the tree"); taskManager.resumeTaskTree(coordinatorTaskOid, result); // THEN (tasks are resumed) - displayThen(TEST_NAME, "4: resume the tree"); + then("4: resume the tree"); coordinatorTask = taskManager.getTask(coordinatorTaskOid(TEST_NAME), result); workers = coordinatorTask.listSubtasks(result); assertEquals("Wrong # of workers", 1, workers.size()); @@ -271,12 +266,12 @@ public void test110CreateWorkersRecurring() throws Exception { assertEquals("Wrong state-before-suspend of worker", null, worker.getStateBeforeSuspend()); // (5) ------------------------------------------------------------------------------------ WHEN (suspend the tree while worker is executing) - displayWhen(TEST_NAME, "5: suspend the tree while worker is executing"); + when("5: suspend the tree while worker is executing"); waitForTaskProgress(coordinatorTaskOid, result, DEFAULT_TIMEOUT, DEFAULT_SLEEP_INTERVAL, 3); stopped = taskManager.suspendTaskTree(coordinatorTaskOid, DEFAULT_TIMEOUT, result); // THEN (tasks are suspended) - displayThen(TEST_NAME, "5: suspend the tree while worker is executing"); + then("5: suspend the tree while worker is executing"); coordinatorTask = taskManager.getTask(coordinatorTaskOid(TEST_NAME), result); workers = coordinatorTask.listSubtasks(result); assertEquals("Wrong # of workers", 1, workers.size()); @@ -297,11 +292,11 @@ public void test110CreateWorkersRecurring() throws Exception { assertTrue("tasks were not stopped", stopped); // (6) ------------------------------------------------------------------------------------ WHEN (resume after 2nd suspend) - displayWhen(TEST_NAME, "6: resume after 2nd suspend"); + when("6: resume after 2nd suspend"); taskManager.resumeTaskTree(coordinatorTaskOid, result); // THEN (tasks are suspended) - displayThen(TEST_NAME, "6: resume after 2nd suspend"); + then("6: resume after 2nd suspend"); coordinatorTask = taskManager.getTask(coordinatorTaskOid(TEST_NAME), result); workers = coordinatorTask.listSubtasks(result); assertEquals("Wrong # of workers", 1, workers.size()); @@ -327,7 +322,7 @@ public void test110CreateWorkersRecurring() throws Exception { @Test public void test200SimplePartitioning() throws Exception { final String TEST_NAME = "test200SimplePartitioning"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); partitionedWorkBucketsTaskHandler.resetBeforeTest(); partitionedWorkBucketsTaskHandler.setEnsureSingleRunner(true); @@ -377,7 +372,7 @@ public void test200SimplePartitioning() throws Exception { @Test public void test210PartitioningToWorkersSingleBucket() throws Exception { final String TEST_NAME = "test210PartitioningToWorkersSingleBucket"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); partitionedWorkBucketsTaskHandler.resetBeforeTest(); partitionedWorkBucketsTaskHandler.setEnsureSingleRunner(true); @@ -442,7 +437,7 @@ public void test210PartitioningToWorkersSingleBucket() throws Exception { @Test public void test220PartitioningToWorkersMoreBuckets() throws Exception { final String TEST_NAME = "test220PartitioningToWorkersMoreBuckets"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); partitionedWorkBucketsTaskHandler.resetBeforeTest(); partitionedWorkBucketsTaskHandler.setDelayProcessor(50L); diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractEDirTest.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractEDirTest.java index 371f8397923..d3d325dc760 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractEDirTest.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractEDirTest.java @@ -228,7 +228,7 @@ public void test100SeachJackByLdapUid() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); SearchResultList> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN @@ -269,7 +269,7 @@ public void test105SeachPiratesByCn() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); SearchResultList> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN @@ -306,7 +306,7 @@ public void test110GetJack() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); PrismObject shadow = modelService.getObject(ShadowType.class, jackAccountOid, null, task, result); // THEN @@ -346,7 +346,7 @@ public void test120JackLockout() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); SearchResultList> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN @@ -435,7 +435,7 @@ public void test200AssignAccountBarbossa() throws Exception { long tsStart = System.currentTimeMillis(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_BARBOSSA_OID, getResourceOid(), null, task, result); // THEN @@ -487,7 +487,7 @@ public void test210ModifyAccountBarbossaTitle() throws Exception { delta.addModification(attrDelta); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN @@ -516,7 +516,7 @@ public void test220ModifyUserBarbossaPassword() throws Exception { userPasswordPs.setClearValue("hereThereBeMonsters"); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, PATH_CREDENTIALS_PASSWORD_VALUE, task, result, userPasswordPs); // THEN @@ -543,7 +543,7 @@ public void test230DisableBarbossa() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, PATH_ACTIVATION_ADMINISTRATIVE_STATUS, task, result, ActivationStatusType.DISABLED); // THEN @@ -572,7 +572,7 @@ public void test239EnableBarbossa() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, PATH_ACTIVATION_ADMINISTRATIVE_STATUS, task, result, ActivationStatusType.ENABLED); // THEN @@ -612,7 +612,7 @@ public void test240ModifyAccountBarbossaPasswordAllowChangeFalse() throws Except delta.addModification(attrDelta); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN @@ -648,7 +648,7 @@ public void test250AssignGuybrushPirates() throws Exception { modifyUserReplace(USER_GUYBRUSH_OID, PATH_ACTIVATION_ADMINISTRATIVE_STATUS, task, result, ActivationStatusType.DISABLED); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_PIRATES_OID, task, result); // THEN @@ -681,7 +681,7 @@ public void test260EnableGyubrush() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_GUYBRUSH_OID, PATH_ACTIVATION_ADMINISTRATIVE_STATUS, task, result, ActivationStatusType.ENABLED); // THEN @@ -712,7 +712,7 @@ public void test300AssignBarbossaPirates() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignRole(USER_BARBOSSA_OID, ROLE_PIRATES_OID, task, result); // THEN @@ -745,7 +745,7 @@ public void test390ModifyUserBarbossaRename() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); renameObject(UserType.class, USER_BARBOSSA_OID, USER_CPTBARBOSSA_USERNAME, task, result); // THEN @@ -790,7 +790,7 @@ public void test500AddOrgMeleeIsland() throws Exception { orgType.getAssignment().add(metaroleAssignment); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); addObject(org, task, result); // THEN @@ -817,7 +817,7 @@ public void test510AssignGuybrushMeleeIsland() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignOrg(USER_GUYBRUSH_OID, orgMeleeIslandOid, task, result); // THEN @@ -847,7 +847,7 @@ public void test520RenameOrgMeleeIsland() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); renameObject(OrgType.class, orgMeleeIslandOid, GROUP_MELA_NOVA_NAME, task, result); // THEN @@ -888,7 +888,7 @@ public void test800JackLockoutExpires() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); SearchResultList> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN @@ -962,7 +962,7 @@ public void test820JackLockoutAndUnlock() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyObjectReplaceProperty(ShadowType.class, shadowLocked.getOid(), PATH_ACTIVATION_LOCKOUT_STATUS, task, result, LockoutStatusType.NORMAL); @@ -1004,7 +1004,7 @@ public void test890UnAssignBarbossaPirates() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); unassignRole(USER_BARBOSSA_OID, ROLE_PIRATES_OID, task, result); // THEN @@ -1037,7 +1037,7 @@ public void test899UnAssignAccountBarbossa() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_BARBOSSA_OID, getResourceOid(), null, task, result); // THEN diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenLdap.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenLdap.java index bfa9e3d0dae..ce6cd335672 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenLdap.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenLdap.java @@ -171,7 +171,7 @@ public void test700CheckBarbossaLockoutStatus() throws Exception { TestUtil.displayTestTitle(this, TEST_NAME); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); PrismObject shadow = getShadowModel(accountBarbossaOid); // THEN @@ -197,7 +197,7 @@ public void test702LockOutBarbossa() throws Exception { display("LDAP Entry before", entry); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); for (int i = 0; i < 10; i++) { LdapNetworkConnection conn; try { @@ -237,7 +237,7 @@ public void test705UnlockBarbossaAccount() throws Exception { SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS, LockoutStatusType.NORMAL); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); executeChanges(accountDelta, null, task, result); // THEN diff --git a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdap.java b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdap.java index 35930151dca..7b1635fa197 100644 --- a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdap.java +++ b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdap.java @@ -167,11 +167,11 @@ public void test200AssignRolePiratesToBarbossa() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_BARBOSSA_OID, ROLE_PIRATE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -208,11 +208,11 @@ public void test202AssignLdapAccountToGuybrush() throws Exception { assertTrue("Photo bytes do not match (user before)", Arrays.equals(photoIn, userJpegPhotoBefore)); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_OPENDJ_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); Entry entry = assertOpenDjAccount(USER_GUYBRUSH_USERNAME, USER_GUYBRUSH_FULL_NAME, true); @@ -258,11 +258,11 @@ public void test204AssignRolePiratesToGuybrush() throws Exception { ); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_GUYBRUSH_OID, ROLE_PIRATE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -297,12 +297,12 @@ public void test400RenameLeChuckConflicting() throws Exception { assertOpenDjAccount(ACCOUNT_CHARLES_NAME, "Charles L. Charles", true); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(userLechuckOid, UserType.F_NAME, task, result, PrismTestUtil.createPolyString(ACCOUNT_CHARLES_NAME)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertOpenDjAccount(ACCOUNT_CHARLES_NAME, "Charles L. Charles", true); assertOpenDjAccount(ACCOUNT_CHARLES_NAME + "1", "LeChuck", true); assertNoOpenDjAccount(ACCOUNT_LECHUCK_NAME); @@ -338,16 +338,16 @@ public boolean handle(PrismObject shadow, OperationResult parentResu }; // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.searchObjectsIterative(ShadowType.class, query, handler, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertEquals("Unexpected number of search results", NUM_LDAP_ENTRIES + 8, count.getValue()); @@ -369,20 +369,20 @@ public void test810BigImport() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); //task.setExtensionPropertyValue(SchemaConstants.MODEL_EXTENSION_WORKER_THREADS, 2); modelService.importFromResource(RESOURCE_OPENDJ_OID, new QName(RESOURCE_OPENDJ_NAMESPACE, "inetOrgPerson"), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); waitForTaskFinish(task, true, 20000 + NUM_LDAP_ENTRIES*2000); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); int userCount = modelService.countObjects(UserType.class, null, null, task, result); display("Users", userCount); @@ -407,19 +407,19 @@ public void test820BigReconciliation() throws Exception { ResourceType resource = modelService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, task, result).asObjectable(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconciliationTaskHandler.launch(resource, new QName(RESOURCE_OPENDJ_NAMESPACE, "inetOrgPerson"), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); // OperationResult subresult = result.getLastSubresult(); // TestUtil.assertInProgress("reconciliation launch result", subresult); waitForTaskFinish(task, true, 20000 + NUM_LDAP_ENTRIES*2000); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); int userCount = modelService.countObjects(UserType.class, null, null, task, result); display("Users", userCount); @@ -439,16 +439,16 @@ public void test900DeleteShadows() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); importObjectFromFile(TASK_DELETE_OPENDJ_SHADOWS_FILE); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForTaskFinish(TASK_DELETE_OPENDJ_SHADOWS_OID, true, 20000 + NUM_LDAP_ENTRIES*2000); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); @@ -486,16 +486,16 @@ public void test910DeleteAccounts() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); importObjectFromFile(TASK_DELETE_OPENDJ_ACCOUNTS_FILE); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForTaskFinish(TASK_DELETE_OPENDJ_ACCOUNTS_OID, true, 20000 + NUM_LDAP_ENTRIES*3000); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, (2*NUM_LDAP_ENTRIES)/100+2); diff --git a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdapComplex.java b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdapComplex.java index 2a1f982f3e3..53e78733a37 100644 --- a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdapComplex.java +++ b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdapComplex.java @@ -140,20 +140,20 @@ public void test100BigImport() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); //task.setExtensionPropertyValue(SchemaConstants.MODEL_EXTENSION_WORKER_THREADS, 2); modelService.importFromResource(RESOURCE_OPENDJ_OID, new QName(RESOURCE_OPENDJ_NAMESPACE, "inetOrgPerson"), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); waitForTaskFinish(task, true, 20000 + NUM_LDAP_ENTRIES*2000); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); int userCount = modelService.countObjects(UserType.class, null, null, task, result); display("Users", userCount); @@ -179,7 +179,7 @@ public void test120BigReconciliation() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); //task.setExtensionPropertyValue(SchemaConstants.MODEL_EXTENSION_WORKER_THREADS, 2); ResourceType resource = modelService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, task, result).asObjectable(); @@ -187,7 +187,7 @@ public void test120BigReconciliation() throws Exception { new QName(RESOURCE_OPENDJ_NAMESPACE, "AccountObjectClass"), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); // TODO // OperationResult subresult = result.getLastSubresult(); // TestUtil.assertInProgress("reconciliation launch result", subresult); @@ -195,7 +195,7 @@ public void test120BigReconciliation() throws Exception { waitForTaskFinish(task, true, 20000 + NUM_LDAP_ENTRIES*2000); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); int userCount = modelService.countObjects(UserType.class, null, null, task, result); display("Users", userCount); @@ -218,11 +218,11 @@ public void test500GuybrushAssignSecurity() throws Exception { addObject(USER_GUYBRUSH_FILE); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_OPENDJ_OID, INTENT_SECURITY, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -252,11 +252,11 @@ public void test502RuinGuybrushAccountAndReconcile() throws Exception { openDJController.assertHasNoObjectClass(entryBefore, OBJECTCLASS_USER_SECURITY_INFORMATION); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); diff --git a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdapUniversity.java b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdapUniversity.java index dd0cddb6f40..f6b97c688a6 100644 --- a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdapUniversity.java +++ b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdapUniversity.java @@ -145,7 +145,7 @@ public void test100BigImportWithLinking() throws Exception { display("e0", findUserByUsername("e0")); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); //task.setExtensionPropertyValue(SchemaConstants.MODEL_EXTENSION_WORKER_THREADS, 5); modelService.importFromResource(RESOURCE_OPENDJ_OID, new QName(RESOURCE_OPENDJ_NAMESPACE, "inetOrgPerson"), task, result); @@ -211,7 +211,7 @@ public void test120BigReconciliation() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); //task.setExtensionPropertyValue(SchemaConstants.MODEL_EXTENSION_WORKER_THREADS, 2); ResourceType resource = modelService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, task, result).asObjectable(); diff --git a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestRunAs.java b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestRunAs.java index 03c54b023bf..1dd54f64dda 100644 --- a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestRunAs.java +++ b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestRunAs.java @@ -121,11 +121,11 @@ public void test100AssignAccountDummyToBarbossa() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_BARBOSSA_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_BARBOSSA_OID); @@ -152,11 +152,11 @@ public void test109UnassignAccountDummyFromBarbossa() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignAccountFromUser(USER_BARBOSSA_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_BARBOSSA_OID); @@ -175,12 +175,12 @@ public void test200CleanupPlain() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_BARBOSSA_OID, UserType.F_ORGANIZATION, task, result /* no value */); modifyUserReplace(USER_BARBOSSA_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result /* no value */); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_BARBOSSA_OID); @@ -216,13 +216,13 @@ public void test210BarbossaSetOrganizationPlain() throws Exception { rememberCounter(InternalCounters.REPOSITORY_READ_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); long starMillis = System.currentTimeMillis(); modifyUserReplace(USER_BARBOSSA_OID, UserType.F_ORGANIZATION, task, result, createPolyString(ORG_PIRATES)); long endMillis = System.currentTimeMillis(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); long readCountIncremenet = getCounterIncrement(InternalCounters.REPOSITORY_READ_COUNT); @@ -246,12 +246,12 @@ public void test300CleanupRunAs() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_BARBOSSA_OID, UserType.F_ORGANIZATION, task, result /* no value */); modifyUserReplace(USER_BARBOSSA_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result /* no value */); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_BARBOSSA_OID); @@ -287,13 +287,13 @@ public void test310BarbossaSetOrganizationRunAs() throws Exception { rememberCounter(InternalCounters.REPOSITORY_READ_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); long starMillis = System.currentTimeMillis(); modifyUserReplace(USER_BARBOSSA_OID, UserType.F_ORGANIZATION, task, result, createPolyString(ORG_PIRATES)); long endMillis = System.currentTimeMillis(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); long readCountIncrement = getCounterIncrement(InternalCounters.REPOSITORY_READ_COUNT); @@ -328,7 +328,7 @@ private void warmUp(final String TEST_NAME) throws Exception { rememberCounter(InternalCounters.REPOSITORY_READ_COUNT); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); long firstTime = warmUpRound(0, task, result); long lastTime = 0; long sumTime = firstTime; @@ -338,7 +338,7 @@ private void warmUp(final String TEST_NAME) throws Exception { } // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); long readCountIncremenet = getCounterIncrement(InternalCounters.REPOSITORY_READ_COUNT); diff --git a/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestAbstractRestService.java b/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestAbstractRestService.java index 0b8da50ac39..bec83ffed9c 100644 --- a/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestAbstractRestService.java +++ b/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestAbstractRestService.java @@ -145,10 +145,10 @@ public void test001GetUserAdministrator() { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.get(); - displayThen(TEST_NAME); + then(TEST_NAME); assertStatus(response, 200); UserType userType = response.readEntity(UserType.class); assertNotNull("Returned entity in body must not be null.", userType); @@ -168,10 +168,10 @@ public void test002GetNonExistingUser() { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.get(); - displayThen(TEST_NAME); + then(TEST_NAME); assertStatus(response, 404); OperationResultType result = response.readEntity(OperationResultType.class); assertNotNull("Error response must contain operation result", result); @@ -192,10 +192,10 @@ public void test003GetNoAuthHeaders() { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.get(); - displayThen(TEST_NAME); + then(TEST_NAME); assertStatus(response, 401); display("Audit", getDummyAuditService()); @@ -212,10 +212,10 @@ public void test004GetAuthBadUsernameNullPassword() { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.get(); - displayThen(TEST_NAME); + then(TEST_NAME); assertStatus(response, 401); display("Audit", getDummyAuditService()); @@ -232,10 +232,10 @@ public void test005GetAuthBadUsernameEmptyPassword() { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.get(); - displayThen(TEST_NAME); + then(TEST_NAME); assertStatus(response, 401); display("Audit", getDummyAuditService()); @@ -252,10 +252,10 @@ public void test006GetAuthBadUsernameBadPassword() { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.get(); - displayThen(TEST_NAME); + then(TEST_NAME); assertStatus(response, 401); display("Audit", getDummyAuditService()); @@ -272,10 +272,10 @@ public void test007GetAuthNoPassword() { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.get(); - displayThen(TEST_NAME); + then(TEST_NAME); assertStatus(response, 401); display("Audit", getDummyAuditService()); @@ -292,10 +292,10 @@ public void test016GetAuthBadPassword() { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.get(); - displayThen(TEST_NAME); + then(TEST_NAME); assertStatus(response, 401); display("Audit", getDummyAuditService()); @@ -312,10 +312,10 @@ public void test017GetUnauthorizedUser() { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.get(); - displayThen(TEST_NAME); + then(TEST_NAME); assertStatus(response, 401); display("Audit", getDummyAuditService()); @@ -332,10 +332,10 @@ public void test018GetUserAdministratorByCyclops() { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.get(); - displayThen(TEST_NAME); + then(TEST_NAME); assertStatus(response, 403); display("Audit", getDummyAuditService()); @@ -352,10 +352,10 @@ public void test019GetUserAdministratorBySomebody() { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.get(); - displayThen(TEST_NAME); + then(TEST_NAME); assertStatus(response, 200); @@ -377,10 +377,10 @@ public void test102AddUserTemplate() throws Exception { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(getRepoFile(USER_TEMPLATE_FILE)); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); assertStatus(response, 201); @@ -400,10 +400,10 @@ public void test103AddUserBadTargetCollection() throws Exception { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(getRepoFile(USER_DARTHADDER_FILE)); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); assertStatus(response, 400); @@ -427,10 +427,10 @@ public void test104AddAccountRawResourceDoesNotExist() throws Exception { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(getRepoFile(ACCOUT_CHUCK_FILE)); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); // expecting hadnled error because resource doesn't exist.. it is OK, but let's say admin about that @@ -466,10 +466,10 @@ public void test120AddRoleAdder() throws Exception { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(getRepoFile(ROLE_ADDER_FILE)); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); assertStatus(response, 201); @@ -488,10 +488,10 @@ public void test121AddUserDarthAdder() throws Exception { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(getRepoFile(USER_DARTHADDER_FILE)); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); assertStatus(response, 201); @@ -510,10 +510,10 @@ public void test122AddRoleModifierAsDarthAdder() throws Exception { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(getRepoFile(ROLE_MODIFIER_FILE)); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); assertStatus(response, 201); @@ -532,10 +532,10 @@ public void test123DarthAdderAssignModifierHimself() throws Exception { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(MiscUtil.readFile(getRequestFile(MODIFICATION_ASSIGN_ROLE_MODIFIER))); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); assertStatus(response, 403); OperationResultType result = response.readEntity(OperationResultType.class); @@ -558,10 +558,10 @@ public void test124DarthAdderAssignModifierByAdministrator() throws Exception { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(MiscUtil.readFile(getRequestFile(MODIFICATION_ASSIGN_ROLE_MODIFIER))); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); assertStatus(response, 204); @@ -584,10 +584,10 @@ public void test130DarthAdderDisableHimself() throws Exception { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(MiscUtil.readFile(getRequestFile(MODIFICATION_DISABLE))); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); assertStatus(response, 204); @@ -610,10 +610,10 @@ public void test131GetUserAdministratorByDarthAdder() { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.get(); - displayThen(TEST_NAME); + then(TEST_NAME); assertStatus(response, 401); // assertNoEmptyResponse(response); @@ -631,10 +631,10 @@ public void test132DarthAdderEnableByAdministrator() throws Exception { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(MiscUtil.readFile(getRequestFile(MODIFICATION_ENABLE))); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); assertStatus(response, 204); @@ -657,10 +657,10 @@ public void test133GetUserAdministratorByDarthAdder() { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.get(); - displayThen(TEST_NAME); + then(TEST_NAME); assertStatus(response, 200); UserType userType = response.readEntity(UserType.class); assertNotNull("Returned entity in body must not be null.", userType); @@ -680,10 +680,10 @@ public void test135AddUserNopasswordAsDarthAdder() throws Exception { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(getRepoFile(USER_NOPASSWORD_FILE)); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); assertStatus(response, 201); @@ -702,10 +702,10 @@ public void test140GetUserAdministratorByNopassword() { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.get(); - displayThen(TEST_NAME); + then(TEST_NAME); assertStatus(response, 401); // assertNoEmptyResponse(response); @@ -723,10 +723,10 @@ public void test141GetUserAdministratorByNopasswordBadPassword() { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.get(); - displayThen(TEST_NAME); + then(TEST_NAME); assertStatus(response, 401); // assertNoEmptyResponse(response); @@ -744,10 +744,10 @@ public void test200searchAllUsers() { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(new QueryType()); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); assertStatus(response, 200); @@ -768,11 +768,11 @@ public void test401AddUserTemplateOverwrite() throws Exception { getDummyAuditService().clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(getRepoFile(USER_TEMPLATE_FILE)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); assertEquals("Expected 201 but got " + response.getStatus(), 201, response.getStatus()); @@ -802,11 +802,11 @@ public void test410AddFunctionLibraryHello() throws Exception { getDummyAuditService().clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(getRepoFile(FUNCTION_LIBRARY_HELLO_FILE)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); assertEquals("Expected 201 but got " + response.getStatus(), 201, response.getStatus()); @@ -831,10 +831,10 @@ public void test412GetFunctionLibraryHello() { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.get(); - displayThen(TEST_NAME); + then(TEST_NAME); assertStatus(response, 200); FunctionLibraryType libType = response.readEntity(FunctionLibraryType.class); assertNotNull("Returned entity in body must not be null.", libType); @@ -860,10 +860,10 @@ public void test501generateValue() throws Exception { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_GENERATE)); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); traceResponse(response); @@ -884,10 +884,10 @@ public void test502generateValueBadPath() throws Exception { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_GENERATE_BAD_PATH)); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); assertEquals("Expected 400 but got " + response.getStatus(), 400, response.getStatus()); @@ -906,10 +906,10 @@ public void test503generateValueExecute() throws Exception { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_GENERATE_EXECUTE)); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); traceResponse(response); @@ -933,10 +933,10 @@ public void test504checkGeneratedValue() throws Exception { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.get(); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); assertEquals("Expected 200 but got " + response.getStatus(), 200, response.getStatus()); @@ -954,10 +954,10 @@ public void test505generatePasswordExecute() throws Exception { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_GENERATE_PASSWORD_EXECUTE)); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); assertEquals("Expected 200 but got " + response.getStatus(), 200, response.getStatus()); @@ -980,10 +980,10 @@ public void test506generateHonorificPrefixNameExecute() throws Exception { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_GENERATE_HONORIFIC_PREFIX_EXECUTE)); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); traceResponse(response); @@ -1046,10 +1046,10 @@ public void test510validateValueExplicit() throws Exception { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_VALIDATE_EXPLICIT)); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); traceResponse(response); @@ -1070,10 +1070,10 @@ public void test511validateValueExplicitConflict() throws Exception { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_VALIDATE_EXPLICIT_CONFLICT)); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); traceResponse(response, true); @@ -1094,10 +1094,10 @@ public void test512validateValueImplicitSingle() throws Exception { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_VALIDATE_IMPLICIT_SINGLE)); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); assertEquals("Expected 200 but got " + response.getStatus(), 200, response.getStatus()); @@ -1117,10 +1117,10 @@ public void test513validateValueImplicitMulti() throws Exception { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_VALIDATE_IMPLICIT_MULTI)); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); traceResponse(response); @@ -1140,10 +1140,10 @@ public void test514validateValueImplicitMultiConflict() throws Exception { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_VALIDATE_IMPLICIT_MULTI_CONFLICT)); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); traceResponse(response); @@ -1164,10 +1164,10 @@ public void test515validatePasswordHistoryConflict() throws Exception { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_VALIDATE_PASSWORD_PASSWORD_HISTORY_CONFLICT)); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); traceResponse(response, true); @@ -1188,10 +1188,10 @@ public void test516validateValueExplicitNoValuePolicy() throws Exception { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_VALIDATE_EXPLICIT_NO_VALUE_POLICY)); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); traceResponse(response); @@ -1212,10 +1212,10 @@ public void test517generateValueExplicit() throws Exception { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_GENERATE_EXPLICIT)); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); traceResponse(response); @@ -1241,10 +1241,10 @@ public void test518validateValueImplicitPassword() throws Exception { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_VALIDATE_IMPLICIT_PASSWORD)); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); traceResponse(response); @@ -1270,10 +1270,10 @@ public void test520GeneratePasswordsUsingScripting() throws Exception { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(getRepoFile(SCRIPT_GENERATE_PASSWORDS)); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); traceResponse(response); @@ -1324,10 +1324,10 @@ public void test530ModifyValidToUsingScripting() throws Exception { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(getRepoFile(SCRIPT_MODIFY_VALID_TO)); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); traceResponse(response); @@ -1457,11 +1457,11 @@ public void test600ModifySecurityQuestionReplaceAnswerId1Existing() throws Excep getDummyAuditService().clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(getRequestFile(MODIFICATION_REPLACE_ANSWER_ID_1_VALUE)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); traceResponse(response); @@ -1501,11 +1501,11 @@ public void test602ModifySecurityQuestionReplaceTwoAnswersExisting() throws Exce getDummyAuditService().clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(getRequestFile(MODIFICATION_REPLACE_TWO_ANSWERS)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); traceResponse(response); @@ -1537,11 +1537,11 @@ public void test604ModifySecurityQuestionReplaceNoAnswer() throws Exception { getDummyAuditService().clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(getRequestFile(MODIFICATION_REPLACE_NO_ANSWER)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); traceResponse(response); @@ -1573,11 +1573,11 @@ public void test606ModifySecurityQuestionReplaceAnswer() throws Exception { getDummyAuditService().clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(getRequestFile(MODIFICATION_REPLACE_ANSWER)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); traceResponse(response); @@ -1605,10 +1605,10 @@ public void test607validateSecurityAnswerCheckExpressionFail() throws Exception getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_VALIDATE_SECURITY_ANSWER_CHECK_EXPRESSION_FAIL)); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); traceResponse(response); @@ -1629,10 +1629,10 @@ public void test608validateSecurityAnswerCheckExpression() throws Exception { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_VALIDATE_SECURITY_ANSWER_CHECK_EXPRESSION)); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); assertEquals("Expected 200 but got " + response.getStatus(), 200, response.getStatus()); @@ -1702,10 +1702,10 @@ public void test610ModifyPasswordForceChange() throws Exception { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(getRequestFile(MODIFICATION_FORCE_PASSWORD_CHANGE)); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); traceResponse(response); @@ -1717,10 +1717,10 @@ public void test610ModifyPasswordForceChange() throws Exception { getDummyAuditService().assertLoginLogout(SchemaConstants.CHANNEL_REST_URI); getDummyAuditService().assertHasDelta(1, ChangeType.MODIFY, UserType.class); - displayWhen(TEST_NAME); + when(TEST_NAME); response = client.get(); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); assertEquals("Expected 200 but got " + response.getStatus(), 200, response.getStatus()); @@ -1742,13 +1742,13 @@ public void test612ResetPassword() throws Exception { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(TEST_NAME); // ExecuteCredentialResetRequestType executeCredentialResetRequest = new ExecuteCredentialResetRequestType(); // executeCredentialResetRequest.setResetMethod("passwordReset"); // executeCredentialResetRequest.setUserEntry("123passwd456"); Response response = client.post(getRequestFile(EXECUTE_CREDENTIAL_RESET)); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); traceResponse(response); @@ -1760,11 +1760,11 @@ public void test612ResetPassword() throws Exception { getDummyAuditService().assertLoginLogout(SchemaConstants.CHANNEL_REST_URI); getDummyAuditService().assertHasDelta(1, ChangeType.MODIFY, UserType.class); - displayWhen(TEST_NAME); + when(TEST_NAME); client = prepareClient(); response = client.path("/users/" + USER_DARTHADDER_OID).get(); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); assertEquals("Expected 200 but got " + response.getStatus(), 200, response.getStatus()); @@ -1787,10 +1787,10 @@ public void test650SuspendNonExistingTask() { WebClient client = prepareClient(); client.path("/tasks/123456/suspend"); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(null); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); assertEquals("Expected 404 but got " + response.getStatus(), 404, response.getStatus()); @@ -1803,10 +1803,10 @@ public void test652SuspendWrongObject() { WebClient client = prepareClient(); client.path("/tasks/00000000-0000-0000-0000-000000000002/suspend"); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(null); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); assertEquals("Expected 400 but got " + response.getStatus(), 400, response.getStatus()); @@ -1819,10 +1819,10 @@ public void test660ResumeNonExistingTask() { WebClient client = prepareClient(); client.path("/tasks/123456/resume"); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(null); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); assertEquals("Expected 404 but got " + response.getStatus(), 404, response.getStatus()); @@ -1835,10 +1835,10 @@ public void test662ResumeWrongObject() { WebClient client = prepareClient(); client.path("/tasks/00000000-0000-0000-0000-000000000002/resume"); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(null); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); assertEquals("Expected 400 but got " + response.getStatus(), 400, response.getStatus()); @@ -1851,10 +1851,10 @@ public void test670ScheduleNonExistingTask() { WebClient client = prepareClient(); client.path("/tasks/123456/run"); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(null); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); assertEquals("Expected 404 but got " + response.getStatus(), 404, response.getStatus()); @@ -1867,10 +1867,10 @@ public void test672ScheduleWrongObject() { WebClient client = prepareClient(); client.path("/tasks/00000000-0000-0000-0000-000000000002/run"); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.post(null); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); assertEquals("Expected 400 but got " + response.getStatus(), 400, response.getStatus()); @@ -1883,10 +1883,10 @@ public void test680DeleteNonExistingTask() { WebClient client = prepareClient(); client.path("/tasks/123456"); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.delete(); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); assertEquals("Expected 404 but got " + response.getStatus(), 404, response.getStatus()); @@ -1899,10 +1899,10 @@ public void test682DeleteWrongObject() { WebClient client = prepareClient(); client.path("/tasks/00000000-0000-0000-0000-000000000002"); - displayWhen(TEST_NAME); + when(TEST_NAME); Response response = client.delete(); - displayThen(TEST_NAME); + then(TEST_NAME); displayResponse(response); assertEquals("Expected 400 but got " + response.getStatus(), 400, response.getStatus()); diff --git a/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestRestServiceProxyAuthentication.java b/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestRestServiceProxyAuthentication.java index 52a6967499d..2374012658f 100644 --- a/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestRestServiceProxyAuthentication.java +++ b/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestRestServiceProxyAuthentication.java @@ -78,7 +78,7 @@ public void test001getUserSelfBySomebody() { getDummyAuditService().clear(); - TestUtil.displayWhen(TEST_NAME); + when(); Response response = client.get(); TestUtil.displayThen(TEST_NAME); @@ -101,7 +101,7 @@ public void test002getUserSelfByEgoist() { getDummyAuditService().clear(); - TestUtil.displayWhen(TEST_NAME); + when(); Response response = client.get(); TestUtil.displayThen(TEST_NAME); @@ -128,7 +128,7 @@ public void test003getUserAdministratorByEgoist() { getDummyAuditService().clear(); - TestUtil.displayWhen(TEST_NAME); + when(); Response response = client.get(); TestUtil.displayThen(TEST_NAME); @@ -151,7 +151,7 @@ public void test004getUserSelfByHead() { getDummyAuditService().clear(); - TestUtil.displayWhen(TEST_NAME); + when(); Response response = client.get(); TestUtil.displayThen(TEST_NAME); @@ -178,7 +178,7 @@ public void test005getUserSelfByProxyHead() { getDummyAuditService().clear(); - TestUtil.displayWhen(TEST_NAME); + when(); Response response = client.get(); TestUtil.displayThen(TEST_NAME); diff --git a/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java b/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java index 02ff3f8f5a6..bb00c1d5fd1 100644 --- a/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java +++ b/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java @@ -995,11 +995,11 @@ public void test013AddOpenDjAccountToUser() throws Exception { REQUEST_USER_MODIFY_ADD_ACCOUNT_OPENDJ_FILENAME, ObjectDeltaType.class); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); OperationResultType result = modifyObjectViaModelWS(objectChange); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertNoRepoCache(); displayJaxb("modifyObject result", result, SchemaConstants.C_RESULT); TestUtil.assertSuccess("modifyObject has failed", result); @@ -1625,11 +1625,11 @@ public void test030DisableUser() throws Exception { assertNoRepoCache(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); OperationResultType result = modifyObjectViaModelWS(objectChange); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertNoRepoCache(); displayJaxb("modifyObject result:", result, SchemaConstants.C_RESULT); TestUtil.assertSuccess("modifyObject has failed", result); @@ -1686,12 +1686,12 @@ public void test030DisableUser() throws Exception { assertNoRepoCache(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelWeb.getObject(ObjectTypes.SHADOW.getTypeQName(), accountShadowOidOpendj, options, objectHolder, resultHolder); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertNoRepoCache(); displayJaxb("getObject result", resultHolder.value, SchemaConstants.C_RESULT); TestUtil.assertSuccess("getObject has failed", resultHolder.value); @@ -2859,7 +2859,7 @@ public void test301LiveSyncCreate() throws Exception { display("Sync token before", tokenBefore.toString()); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); Entry entry = openDJController.addEntryFromLdifFile(LDIF_WILL_FILENAME); display("Entry from LDIF", entry); @@ -2868,7 +2868,7 @@ public void test301LiveSyncCreate() throws Exception { basicWaitForSyncChangeDetection(syncCycle, tokenBefore, 2, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); // Search for the user that should be created now UserType user = searchUserByName(WILL_NAME); @@ -2939,7 +2939,7 @@ public void test303LiveSyncLink() throws Exception { // AssertJUnit.assertEquals(userOid, oidHolder.value); //WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); //create account for e which should be correlated final OperationResult result = new OperationResult(TestSanity.class.getName() @@ -2957,7 +2957,7 @@ public void test303LiveSyncLink() throws Exception { basicWaitForSyncChangeDetection(syncCycle, tokenBefore, 1, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); //check user and account ref userType = searchUserByName("e"); @@ -3083,11 +3083,11 @@ public void test400ImportFromResource() throws Exception { display("Entry from LDIF", addEntry); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); TaskType taskType = modelWeb.importFromResource(RESOURCE_OPENDJ_OID, RESOURCE_OPENDJ_ACCOUNT_OBJECTCLASS); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertNoRepoCache(); displayJaxb("importFromResource result", taskType.getResult(), SchemaConstants.C_RESULT); AssertJUnit.assertEquals("importFromResource has failed", OperationResultStatusType.IN_PROGRESS, taskType.getResult().getStatus()); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConfiguredCapabilitiesActivation.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConfiguredCapabilitiesActivation.java index c28cf5b22a9..79fa02276d9 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConfiguredCapabilitiesActivation.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConfiguredCapabilitiesActivation.java @@ -86,12 +86,12 @@ public void test100ImportAccount() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.importFromResource(SHADOW_SAMPLE_ACTIVATION_SIMULATED_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); /* List configuredCapabilities = resourceNoAAD.asObjectable().getCapabilities().getConfigured().getAny(); @@ -122,7 +122,7 @@ public void test110AssignJackPirate() throws Exception { //THEN - displayThen(TEST_NAME); + then(TEST_NAME); UserAsserter userAfterAsserter = assertUserAfter(USER_JACK_OID); userAfterAsserter .activation() @@ -176,7 +176,7 @@ public void test112ModifyActivationJack() throws Exception { modifyUserReplace(USER_JACK_OID, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, task, result, ActivationStatusType.DISABLED); //THEN - displayThen(TEST_NAME); + then(TEST_NAME); UserAsserter userAfterAsserter = assertUserAfter(USER_JACK_OID); userAfterAsserter diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConsistencyMechanism.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConsistencyMechanism.java index f81aec662e1..d7eafdf0969 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConsistencyMechanism.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConsistencyMechanism.java @@ -417,11 +417,11 @@ public void test100AddUser() throws Exception { OperationResult repoResult = new OperationResult("getObject"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject uObject = repositoryService.getObject(UserType.class, USER_JACK_OID, null, repoResult); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(repoResult); assertUser(uObject,"repo") @@ -616,7 +616,7 @@ public void test122AddAccountAlreadyExistUnlinked() throws Exception { Task task = taskManager.createTaskInstance(); //WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignAccount(UserType.class, USER_WILL_OID, RESOURCE_OPENDJ_OID, null, task, parentResult); // THEN @@ -754,7 +754,7 @@ public void test130DeleteObjectNotFound() throws Exception { clockForward("PT20M"); - displayThen(TEST_NAME); + then(TEST_NAME); provisioningService.refreshShadow(shadowRepo, null, task, parentResult); try { @@ -813,7 +813,7 @@ public void test140ModifyObjectNotFoundLinkedAccount() throws Exception { // requestToExecuteChanges(REQUEST_ACCOUNT_MODIFY_NOT_FOUND_DELETE_ACCOUNT_FILE, ACCOUNT_GUYBRUSH_OID, ShadowType.class, task, null, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject shadowAfter = getShadowRepo(ACCOUNT_GUYBRUSH_OID); ShadowAsserter.forShadow(shadowAfter) .assertTombstone() @@ -866,7 +866,7 @@ public void test142ModifyObjectNotFoundAssignedAccount() throws Exception { Task task = taskManager.createTaskInstance(); //WHEN - TestUtil.displayWhen(TEST_NAME); + when(); ObjectDelta delta = prismContext.deltaFor(ShadowType.class) .property(ItemPath.create(ShadowType.F_ATTRIBUTES, new ItemName(MidPointConstants.NS_RI, "roomNumber"))) .replace("cabin") @@ -976,7 +976,7 @@ public void test150RecomputeUserAccountNotFound() throws Exception { assertTrue("Oh my! Shadow is dead!", repoShadowBefore.asObjectable().isDead() != Boolean.TRUE); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); recomputeUser(USER_GUYBRUSH_OID, task, result); // THEN @@ -1165,7 +1165,7 @@ public void test212AddModifyObjectCommunicationProblem() throws Exception { .createModificationAddProperty(ShadowType.class, accountOid, createAttributePath(LDAP_ATTRIBUTE_EMPLOYEE_NUMBER), "emp4321"); delta.addModificationReplaceProperty(createAttributePath(LDAP_ATTRIBUTE_GIVENNAME), "eeeee"); - TestUtil.displayWhen(TEST_NAME); + when(); XMLGregorianCalendar lastRequestStartTs = clock.currentTimeXMLGregorianCalendar(); executeChanges(delta, null, task, parentResult); XMLGregorianCalendar lastRequestEndTs = clock.currentTimeXMLGregorianCalendar(); @@ -1232,7 +1232,7 @@ public void test214ModifyObjectCommunicationProblem() throws Exception { Task task = taskManager.createTaskInstance(); //WHEN - TestUtil.displayWhen(TEST_NAME); + when(); ObjectDelta delta = prismContext.deltaFactory() .object() .createModificationAddProperty(ShadowType.class, accountOid, createAttributePath(LDAP_ATTRIBUTE_EMPLOYEE_NUMBER), "emp4321"); @@ -1656,7 +1656,7 @@ public void test260GetDiscoveryAddCommunicationProblem() throws Exception { Task task = taskManager.createTaskInstance(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); XMLGregorianCalendar lastRequestStartTs = clock.currentTimeXMLGregorianCalendar(); assignAccount(UserType.class, USER_ANGELIKA_OID, RESOURCE_OPENDJ_OID, "internal", task, parentResult); @@ -1901,7 +1901,7 @@ public void test265ModifyUserPasswordCommunicationProblemRecon() throws Exceptio String shadowOid = getLinkRefOid(USER_ALICE_OID, RESOURCE_OPENDJ_OID); // WHEN (down) - TestUtil.displayWhen(TEST_NAME); + when(); XMLGregorianCalendar lastRequestStartTs = clock.currentTimeXMLGregorianCalendar(); modifyUserChangePassword(USER_ALICE_OID, "UNDEADmenTELLscaryTALES", task, result); XMLGregorianCalendar lastRequestEndTs = clock.currentTimeXMLGregorianCalendar(); @@ -1945,7 +1945,7 @@ public void test265ModifyUserPasswordCommunicationProblemRecon() throws Exceptio modifyResourceAvailabilityStatus(AvailabilityStatusType.UP, result); // WHEN (restore) - TestUtil.displayWhen(TEST_NAME); + when(); reconcileUser(USER_ALICE_OID, task, result); // THEN @@ -2160,11 +2160,11 @@ public void test283GetObjectNoFetchShadowAndRecompute() throws Exception { .assertNoModification(createAttributePath(LDAP_ATTRIBUTE_EMPLOYEE_TYPE)); //WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_DONALD_OID, ModelExecuteOptions.createReconcile(), task, parentResult); //THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertModelShadow(shadowOid) .attributes() .assertValue(LDAP_ATTRIBUTE_GIVENNAME, "don") @@ -2196,7 +2196,7 @@ public void test284ModifyObjectAssignToGroupCommunicationProblem() throws Except String shadowOid = getLinkRefOid(USER_DONALD_OID, RESOURCE_OPENDJ_OID); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); AssignmentType adminRoleAssignment = new AssignmentType(prismContext); adminRoleAssignment.setTargetRef(ObjectTypeUtil.createObjectRef(ROLE_LDAP_ADMINS_OID, ObjectTypes.ROLE)); @@ -2305,11 +2305,11 @@ public void test500AddUserMorganWithAssignment() throws Exception { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(USER_MORGAN_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject userMorgan = modelService.getObject(UserType.class, USER_MORGAN_OID, null, task, result); display("User morgan after", userMorgan); @@ -2354,7 +2354,7 @@ public void test501AddUserChuckWithAssignment() throws Exception { // // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); addObject(USER_CHUCK_FILE); // THEN @@ -2416,7 +2416,7 @@ public void test502AssignAccountToHerman() throws Exception { //REQUEST_USER_MODIFY_ADD_ACCOUNT_COMMUNICATION_PROBLEM //WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccount(UserType.class, USER_HERMAN_OID, RESOURCE_OPENDJ_OID, "internal", task, result); // THEN @@ -2473,7 +2473,7 @@ public void test510UnlinkAndUnassignAccountMorgan() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); ///----user's link is removed, now, remove assignment @@ -2482,7 +2482,7 @@ public void test510UnlinkAndUnassignAccountMorgan() throws Exception { user.findContainer(UserType.F_ASSIGNMENT).getValue().clone()); deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); repositoryService.deleteObject(ShadowType.class, linkRef.getOid(), result); @@ -2567,7 +2567,7 @@ public void test511AssignAccountMorgan() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelayedEnable.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelayedEnable.java index c82e14018e1..46d2e20b741 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelayedEnable.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelayedEnable.java @@ -117,12 +117,12 @@ public void test100AddUserMancomb() throws Exception { hrCreateTsStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(USER_MANCOMB_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); hrCreateTsEnd = clock.currentTimeXMLGregorianCalendar(); @@ -143,12 +143,12 @@ public void test102UserMancombTriggerScannerAgain() throws Exception { displayCurrentTime(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); runTriggerScanner(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertMancombCreated(); @@ -168,12 +168,12 @@ public void test104UserMancombRecompute() throws Exception { displayCurrentTime(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_MANCOMB_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertMancombCreated(); @@ -210,12 +210,12 @@ public void test110UserMancombRunTriggerScannerDay1() throws Exception { clockForward("P1D"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); runTriggerScanner(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertMancombEnabled(); @@ -236,12 +236,12 @@ public void test112UserMancombRecomputeDay1() throws Exception { clockForward("P1D"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_MANCOMB_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertMancombEnabled(); @@ -270,12 +270,12 @@ public void test114UserMancombRunTriggerScannerDay1Again() throws Exception { final String TEST_NAME = "test114UserMancombRunTriggerScannerDay1Again"; // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); runTriggerScanner(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertMancombEnabled(); @@ -293,12 +293,12 @@ public void test116UserMancombRecomputeDay1Again() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_MANCOMB_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertMancombEnabled(); @@ -320,12 +320,12 @@ public void test120UserMancombHrDisable() throws Exception { hrModifyTsStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_MANCOMB_OID, getExtensionPath(EXT_HR_STATUS_QNAME), task, result, EXT_HR_STATUS_DISABLED); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); hrModifyTsEnd = clock.currentTimeXMLGregorianCalendar(); @@ -359,12 +359,12 @@ public void test122UserMancombRecompute() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_MANCOMB_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertMancombHalfDisabled(); @@ -380,12 +380,12 @@ public void test124UserMancombDay1TriggerScanner() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); runTriggerScanner(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertMancombHalfDisabled(); @@ -407,12 +407,12 @@ public void test130UserMancombTriggerScannerDay2() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); runTriggerScanner(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertMancombDisabled(); @@ -445,12 +445,12 @@ public void test132UserMancombRecomputeDay2() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_MANCOMB_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertMancombDisabled(); @@ -466,12 +466,12 @@ public void test132UserMancombRecomputeDay2Again() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_MANCOMB_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertMancombDisabled(); @@ -493,12 +493,12 @@ public void test140UserMancombRecomputeDay3() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_MANCOMB_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertMancombDisabled(); @@ -516,12 +516,12 @@ public void test200HrLivesyncTask() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(TASK_DUMMY_HR_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); waitForTaskStart(TASK_DUMMY_HR_OID, true); @@ -546,12 +546,12 @@ public void test210HrAddUserGuybrush() throws Exception { hrCreateTsStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); syncWithHr(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); hrCreateTsEnd = clock.currentTimeXMLGregorianCalendar(); @@ -572,12 +572,12 @@ public void test212HrUserGuybrushSyncAgain() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); syncWithHr(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertGuybrushCreated(assertUserAfter(userGuybrushOid)); @@ -595,12 +595,12 @@ public void test214HrUserGuybrushRunTriggers() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); runTriggerScanner(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertGuybrushCreated(assertUserAfter(userGuybrushOid)); @@ -618,12 +618,12 @@ public void test216HrUserGuybrushRecompute() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(userGuybrushOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertGuybrushCreated(assertUserAfter(userGuybrushOid)); @@ -641,12 +641,12 @@ public void test218HrUserGuybrushReconcile() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(userGuybrushOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertGuybrushCreated(assertUserAfter(userGuybrushOid)); @@ -680,12 +680,12 @@ public void test220HrUserGuybrushDay1() throws Exception { clockForward("P1D"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); runTriggerScanner(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertGuybrushEnabled(); @@ -700,12 +700,12 @@ public void test222HrUserGuybrushDay1SyncAgain() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); syncWithHr(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertGuybrushEnabled(); @@ -723,12 +723,12 @@ public void test224HrUserGuybrushDay1TriggerScanAgain() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); runTriggerScanner(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertGuybrushEnabled(); @@ -744,12 +744,12 @@ public void test226HrUserGuybrushDay1Recompute() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(userGuybrushOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertGuybrushEnabled(); @@ -765,12 +765,12 @@ public void test228HrUserGuybrushDay1Reconcile() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(userGuybrushOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertGuybrushEnabled(); @@ -804,12 +804,12 @@ public void test230HrDisableGuybrush() throws Exception { hrModifyTsStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); syncWithHr(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); hrModifyTsEnd = clock.currentTimeXMLGregorianCalendar(); @@ -823,12 +823,12 @@ public void test232GuybrushHrSyncAgain() throws Exception { final String TEST_NAME = "test232GuybrushHrSyncAgain"; // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); syncWithHr(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertGuybrushHalfDisabled(); @@ -843,12 +843,12 @@ public void test234GuybrushRecompute() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(userGuybrushOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertGuybrushHalfDisabled(); @@ -864,12 +864,12 @@ public void test236GuybrushReconcile() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(userGuybrushOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertGuybrushHalfDisabled(); @@ -884,12 +884,12 @@ public void test238GuybrushrunTriggersAgain() throws Exception { clockForward("PT1H"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); runTriggerScanner(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertGuybrushHalfDisabled(); @@ -920,12 +920,12 @@ public void test240HrUserGuybrushDay2() throws Exception { clockForward("P1D"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); runTriggerScanner(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertGuybrushDisabled(); @@ -940,12 +940,12 @@ public void test242GuybrushRecompute() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(userGuybrushOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertGuybrushDisabled(); @@ -958,12 +958,12 @@ public void test244GuybrushHrSyncAgain() throws Exception { final String TEST_NAME = "test244GuybrushHrSyncAgain"; // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); syncWithHr(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertGuybrushDisabled(); @@ -978,12 +978,12 @@ public void test246GuybrushReconcile() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(userGuybrushOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertGuybrushDisabled(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelivery.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelivery.java index 0ec78ca81c6..bc3090aafcd 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelivery.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelivery.java @@ -193,7 +193,7 @@ public void test110Assign_IT_2_success() throws Exception { result.computeStatus(); assertSuccess(result); - assertAssignedRole(userBarkeeperOid, roleIt2Oid, task, result); + assertAssignedRole(userBarkeeperOid, roleIt2Oid, result); } @Test @@ -216,7 +216,7 @@ public void test120Assign_IT_1() throws Exception { task, result); waitForCaseClose(rootCase, 60000); - assertAssignedRole(userBobOid, roleIt1Oid, task, result); + assertAssignedRole(userBobOid, roleIt1Oid, result); } /** @@ -251,7 +251,7 @@ public void test130Assign_IT_3() throws Exception { task, result); waitForCaseClose(rootCase, 60000); - assertAssignedRole(userCarlaOid, roleIt3Oid, task, result); + assertAssignedRole(userCarlaOid, roleIt3Oid, result); } /** @@ -277,7 +277,7 @@ public void test140Assign_IT_4() throws Exception { task, result); waitForCaseClose(rootCase, 60000); - assertAssignedRole(userBarkeeperOid, roleIt4Oid, task, result); + assertAssignedRole(userBarkeeperOid, roleIt4Oid, result); } /** @@ -303,7 +303,7 @@ public void test150Assign_IT_5() throws Exception { task, result); waitForCaseClose(rootCase, 60000); - assertAssignedRole(userBarkeeperOid, roleIt5Oid, task, result); + assertAssignedRole(userBarkeeperOid, roleIt5Oid, result); } @NotNull diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestExistentialIssues.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestExistentialIssues.java index 3aa01fb2c32..a7dadceac97 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestExistentialIssues.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestExistentialIssues.java @@ -64,12 +64,12 @@ public void test100DisableUserDescartes() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_DESCARTES_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.DISABLED); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUserFromRepo(USER_DESCARTES_OID); @@ -92,12 +92,12 @@ public void test110DescartesAssignLazyAccount() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_DESCARTES_OID, RESOURCE_DUMMY_LAZY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUserFromRepo(USER_DESCARTES_OID); @@ -120,12 +120,12 @@ public void test112EnableDescartes() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_DESCARTES_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.ENABLED); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUserFromRepo(USER_DESCARTES_OID); @@ -148,12 +148,12 @@ public void test114DisableDescartes() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_DESCARTES_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.DISABLED); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUserFromRepo(USER_DESCARTES_OID); @@ -176,12 +176,12 @@ public void test116ReenableDescartes() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_DESCARTES_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.ENABLED); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUserFromRepo(USER_DESCARTES_OID); @@ -204,12 +204,12 @@ public void test120DescartesUnassignLazyAccount() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignAccountFromUser(USER_DESCARTES_OID, RESOURCE_DUMMY_LAZY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUserFromRepo(USER_DESCARTES_OID); @@ -232,12 +232,12 @@ public void test129DeleteDescartes() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); deleteObject(UserType.class, USER_DESCARTES_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertNoObject(UserType.class, USER_DESCARTES_OID); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInboundOutboundAssociation.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInboundOutboundAssociation.java index 831f89c6eec..dc2397998b5 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInboundOutboundAssociation.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInboundOutboundAssociation.java @@ -103,12 +103,12 @@ public void test100ImportGroupPirates() throws Exception { getDummyResourceDir().addGroup(group); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); liveSyncDir(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("dir after", getDummyResourceDir()); @@ -137,11 +137,11 @@ public void test110AssignJackDirAccount() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccount(UserType.class, USER_JACK_OID, RESOURCE_DUMMY_DIR_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("dir after", getDummyResourceDir()); @@ -165,11 +165,11 @@ public void test115Stability() throws Exception { final String TEST_NAME = "test110AssignJackDirAccount"; // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); liveSyncDir(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("dir after", getDummyResourceDir()); @@ -196,12 +196,12 @@ public void test120AddJackToGroupPirates() throws Exception { .replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, "rum"); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); liveSyncDir(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("dir after", getDummyResourceDir()); @@ -228,11 +228,11 @@ public void test130JackUnassignRolePirates() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, rolePiratesOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("dir after", getDummyResourceDir()); @@ -257,11 +257,11 @@ public void test140JackAssignRolePirates() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, rolePiratesOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("dir after", getDummyResourceDir()); @@ -294,11 +294,11 @@ public void test142JackUnAssignDirAccount() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignAccount(UserType.class, USER_JACK_OID, RESOURCE_DUMMY_DIR_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("dir after", getDummyResourceDir()); @@ -329,11 +329,11 @@ public void test149JackUnassignRolePirates() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, rolePiratesOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("dir after", getDummyResourceDir()); @@ -356,11 +356,11 @@ public void test150AssignJackDirAccount() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccount(UserType.class, USER_JACK_OID, RESOURCE_DUMMY_DIR_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("dir after", getDummyResourceDir()); @@ -384,11 +384,11 @@ public void test152JackAssignRolePirates() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, rolePiratesOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("dir after", getDummyResourceDir()); @@ -425,11 +425,11 @@ public void test153JackUnassignRolePiratesPreview() throws Exception { null, (Consumer)null, false); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ModelContext previewContext = previewChanges(focusDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertPreviewContext(previewContext) @@ -467,11 +467,11 @@ public void test154JackUnassignRolePirates() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, rolePiratesOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("dir after", getDummyResourceDir()); @@ -499,11 +499,11 @@ public void test159JackUnassignDirAccount() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignAccount(UserType.class, USER_JACK_OID, RESOURCE_DUMMY_DIR_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("dir after", getDummyResourceDir()); @@ -529,11 +529,11 @@ public void test200MancombAssignAccount() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_MANCOMB_OID, RESOURCE_DUMMY_DIR_OID, "default", task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("dir after", getDummyResourceDir()); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLimitedResources.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLimitedResources.java index 392bc586825..791da411293 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLimitedResources.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLimitedResources.java @@ -73,12 +73,12 @@ public void test000Sanity() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject resourceNoAAD = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_NO_ATTRIBUTE_ADD_DELETE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); List configuredCapabilities = resourceNoAAD.asObjectable().getCapabilities().getConfigured().getAny(); @@ -96,11 +96,11 @@ public void test100AssignJackAccountNoAttributeAddDelete() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_NO_ATTRIBUTE_ADD_DELETE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -118,12 +118,12 @@ public void test102AddJackOrganizationalUnitTreasureHunt() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserAdd(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result, createPolyString(OU_TREASURE_HUNT)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -141,12 +141,12 @@ public void test104AddJackOrganizationalUnitLootingSailing() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserAdd(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result, createPolyString(OU_LOOTING), createPolyString(OU_SAILING)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -164,12 +164,12 @@ public void test106DeleteJackOrganizationalUnitLooting() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserDelete(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result, createPolyString(OU_LOOTING)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -190,12 +190,12 @@ public void test108DeleteJackOrganizationalUnitTreasureHuntSailing() throws Exce OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserDelete(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result, createPolyString(OU_TREASURE_HUNT), createPolyString(OU_SAILING)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -213,11 +213,11 @@ public void test109UnassignJackAccountNoAttributeAddDelete() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_NO_ATTRIBUTE_ADD_DELETE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -239,11 +239,11 @@ public void test110AssignJackAccountNoCreate() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_NO_CREATE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("Result", result); assertSuccess(result, 2); @@ -262,11 +262,11 @@ public void test119UnassignJackAccountNoCreate() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_NO_CREATE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_JACK_OID) diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLiveSyncMadness.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLiveSyncMadness.java index ea41c74b141..0ddf08f3d0c 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLiveSyncMadness.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLiveSyncMadness.java @@ -122,12 +122,12 @@ public void test100AddHrAccountHerman() throws Exception { dummyResourceHr.addAccount(newAccount); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); restartTask(TASK_LIVE_SYNC_DUMMY_HR_OID); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_HR_OID, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertUserAfterByUsername(ACCOUNT_HERMAN_USERNAME) .assertFullName(ACCOUNT_HERMAN_FIST_NAME + " " + ACCOUNT_HERMAN_LAST_NAME) .assertTitle("Mr. " + ACCOUNT_HERMAN_LAST_NAME) @@ -160,12 +160,12 @@ public void test110RenameHrAccountHerman() throws Exception { account.replaceAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_HR_LAST_NAME, ACCOUNT_HT_LAST_NAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); restartTask(TASK_LIVE_SYNC_DUMMY_HR_OID); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_HR_OID, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertUserAfterByUsername(ACCOUNT_HERMAN_USERNAME) .assertFullName(ACCOUNT_HT_FIST_NAME + " " + ACCOUNT_HT_LAST_NAME) .assertTitle("Mr. " + ACCOUNT_HT_LAST_NAME) @@ -199,12 +199,12 @@ public void test112HrAccountHermanEmptyDelta() throws Exception { dummyResourceHr.recordEmptyDeltaForAccountByUsername(ACCOUNT_HERMAN_USERNAME, DummyDeltaType.MODIFY); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); restartTask(TASK_LIVE_SYNC_DUMMY_HR_OID); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_HR_OID, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertUserAfterByUsername(ACCOUNT_HERMAN_USERNAME) .assertFullName(ACCOUNT_HT_FIST_NAME + " " + ACCOUNT_HT_LAST_NAME) .assertTitle("Mr. " + ACCOUNT_HT_LAST_NAME) diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMapleLeaf.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMapleLeaf.java index 7a21ebb6649..2948e4ae570 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMapleLeaf.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMapleLeaf.java @@ -158,11 +158,11 @@ public void test001addUser() throws Exception { final String TEST_NAME = "test001addUser"; //when - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_JACK_OID, RESOURCE_OPENDJ_OID, "default"); //then - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject user = getUser(USER_JACK_OID); assertNotNull("User is null", user); @@ -189,11 +189,11 @@ public void test002assignRoleSquirrel() throws Exception { final String TEST_NAME = "test002assignRoleSquirrel"; //when - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_SQUIRREL_OID); //then - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject user = getUser(USER_JACK_OID); assertNotNull("User is null", user); @@ -220,11 +220,11 @@ public void test003unassignRoleSquirrel() throws Exception { final String TEST_NAME = "test003unassignRoleSquirrel"; //when - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, ROLE_SQUIRREL_OID); //then - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject user = getUser(USER_JACK_OID); assertNotNull("User is null", user); @@ -252,11 +252,11 @@ public void test004assignRoleMapleLeafFaculty() throws Exception { final String TEST_NAME = "test004assignRoleMapleLeafFaculty"; //when - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_MAPLE_LEAF_FACULTY_OID); //then - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject user = getUser(USER_JACK_OID); assertNotNull("User is null", user); @@ -292,11 +292,11 @@ public void test005assignRoleMapleLeafGraduate() throws Exception { final String TEST_NAME = "test005assignRoleMapleLeafGraduate"; //when - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_MAPLE_LEAF_GRADUATE_OID); //then - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject user = getUser(USER_JACK_OID); assertNotNull("User is null", user); @@ -324,11 +324,11 @@ public void test006unassignRoleMapleLeafFaculty() throws Exception { final String TEST_NAME = "test006unassignRoleMapleLeafFaculty"; //when - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, ROLE_MAPLE_LEAF_FACULTY_OID); //then - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject user = getUser(USER_JACK_OID); assertNotNull("User is null", user); @@ -374,7 +374,7 @@ public void test100changePasswordForceChange() throws Exception { AssertJUnit.assertNotNull("Unexpected value in car license: " + carLicenseBefore.getRealValue(), carLicenseBefore.getRealValue()); //when - displayWhen(TEST_NAME); + when(TEST_NAME); passwd = new ProtectedStringType(); passwd.setClearValue("somenewValue"); userDelta = createModifyUserReplaceDelta(USER_JACK_OID, SchemaConstants.PATH_PASSWORD_VALUE, passwd); @@ -384,7 +384,7 @@ public void test100changePasswordForceChange() throws Exception { //THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject userAfter = getUser(USER_JACK_OID); UserType userTypeAfter = userAfter.asObjectable(); @@ -416,7 +416,7 @@ public void test101resetPassword() throws Exception { openDJController.assertPassword("uid=jack,ou=People,dc=example,dc=com", "oldValue"); //when - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject user = getUser(USER_JACK_OID); ExecuteCredentialResetRequestType executeCredentialResetRequest = new ExecuteCredentialResetRequestType(); executeCredentialResetRequest.setResetMethod("passwordReset"); @@ -424,7 +424,7 @@ public void test101resetPassword() throws Exception { modelInteractionService.executeCredentialsReset(user, executeCredentialResetRequest, task, result); //THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject userAfter = getUser(USER_JACK_OID); UserType userTypeAfter = userAfter.asObjectable(); @@ -476,7 +476,7 @@ public void test201SetUndefinedAdministrativeStatus() throws Exception { assertNotLinked(USER_JACK_OID, accountOid); //THEN - displayThen(TEST_NAME); + then(TEST_NAME); modelService.importFromResource(accountOid, task, result); PrismObject userAfter = getUser(USER_JACK_OID); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMappingMadness.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMappingMadness.java index 0ba103f53a1..21479a6e6ed 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMappingMadness.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMappingMadness.java @@ -88,7 +88,7 @@ public void test100AssignJackDummyAccounts() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_TOLERANT_OID, null, task, result); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_TOLERANT_RANGE_OID, null, task, result); @@ -96,7 +96,7 @@ public void test100AssignJackDummyAccounts() throws Exception { assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_NONTOLERANT_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertJackPirateAccount(RESOURCE_DUMMY_TOLERANT_NAME); @@ -119,12 +119,12 @@ public void test105ModifyJackTitleCaptain() throws Exception { setAccountQuotes(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_JACK_OID, UserType.F_TITLE, task, result, createPolyString(JACK_TITLE_CAPTAIN)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertDummyAccountByUsername(RESOURCE_DUMMY_TOLERANT_NAME, USER_JACK_USERNAME) @@ -189,12 +189,12 @@ public void test110ModifyJackTitleWhatever() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_JACK_OID, UserType.F_TITLE, task, result, createPolyString(JACK_TITLE_WHATEVER_UPPER)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); // Mappings return null, which means no value. @@ -262,12 +262,12 @@ public void test112ReconcileJackWhatever() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_JACK_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertDummyAccountByUsername(RESOURCE_DUMMY_TOLERANT_NAME, USER_JACK_USERNAME) @@ -324,12 +324,12 @@ public void test120MadJack() throws Exception { setAccountMad(getDummyAccount(RESOURCE_DUMMY_SMART_RANGE_NAME, USER_JACK_USERNAME)); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_JACK_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertJackMadAccount(RESOURCE_DUMMY_TOLERANT_NAME); @@ -355,12 +355,12 @@ public void test130ModifyJackTitleWhateverLower() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_JACK_OID, UserType.F_TITLE, task, result, createPolyString(JACK_TITLE_WHATEVER_LOWER)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertJackMadAccount(RESOURCE_DUMMY_TOLERANT_NAME); @@ -385,12 +385,12 @@ public void test140ModifyJackTitleEmpty() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_JACK_OID, UserType.F_TITLE, task, result /* no value */); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertJackMadAccount(RESOURCE_DUMMY_TOLERANT_NAME); @@ -420,7 +420,7 @@ public void test199UnassignJackDummyAccount() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_TOLERANT_OID, null, task, result); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_TOLERANT_RANGE_OID, null, task, result); @@ -428,7 +428,7 @@ public void test199UnassignJackDummyAccount() throws Exception { unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_NONTOLERANT_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertNoDummyAccount(RESOURCE_DUMMY_TOLERANT_NAME, USER_JACK_USERNAME); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMisbehavingResources.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMisbehavingResources.java index e82ee85527b..be297c34378 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMisbehavingResources.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMisbehavingResources.java @@ -58,12 +58,12 @@ public void test010SanityAssignJackDummyAccount() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertDummyAccountByUsername(null, USER_JACK_USERNAME) @@ -78,12 +78,12 @@ public void test019SanityUnassignJackDummyAccount() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertNoDummyAccount(USER_JACK_USERNAME); @@ -102,12 +102,12 @@ public void test100AssignJackDummyAccountTimeout() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertInProgress(result); assertNoDummyAccount(USER_JACK_USERNAME); @@ -124,12 +124,12 @@ public void test102AssignJackDummyAccounRetry() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertDummyAccountByUsername(null, USER_JACK_USERNAME) @@ -149,12 +149,12 @@ public void test110ModifyJackDummyAccountTimeout() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, createPolyString(USER_JACK_FULL_NAME_CAPTAIN)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertInProgress(result); assertDummyAccountByUsername(null, USER_JACK_USERNAME) @@ -173,12 +173,12 @@ public void test112ModifyJackDummyAccounRetry() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertDummyAccountByUsername(null, USER_JACK_USERNAME) diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNormalizers.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNormalizers.java index 95bab2bfbc2..580aff0d27a 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNormalizers.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNormalizers.java @@ -91,12 +91,12 @@ public void test100AddUserJack() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(AbstractStoryTest.USER_JACK_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUserFromRepo(AbstractStoryTest.USER_JACK_OID); @@ -111,12 +111,12 @@ public void test110AddUserTeleke() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(USER_TELEKE_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUserFromRepo(USER_TELEKE_OID); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNullAttribute.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNullAttribute.java index 821fd823d36..efb79ced34e 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNullAttribute.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNullAttribute.java @@ -263,12 +263,12 @@ public void test030UserSmackRemoveAttribute() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(delta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getUser(USER_SMACK_OID); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationCounts.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationCounts.java index 53121d402ba..c151404e28c 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationCounts.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationCounts.java @@ -131,7 +131,7 @@ public void test100AddAlice() throws Exception { // GIVEN // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); resetThreadLocalPerformanceData(); addObject(USER_ALICE_FILE, task, result); @@ -178,7 +178,7 @@ public void test110AddBob() throws Exception { // GIVEN // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); resetThreadLocalPerformanceData(); addObject(USER_BOB_FILE, task, result); @@ -226,7 +226,7 @@ public void test120ModifyBob() throws Exception { .asObjectDeltaCast(USER_BOB_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); resetThreadLocalPerformanceData(); executeChanges(delta, null, task, result); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationPerf.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationPerf.java index a21a60538f9..4c0fabaff69 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationPerf.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationPerf.java @@ -127,12 +127,12 @@ public void testAddUser(final String TEST_NAME, File userFile, String userOid, i long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(userBefore, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); assertSuccess(result); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOrgSync.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOrgSync.java index 5d9b7e8d50c..d6ab0a71b0c 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOrgSync.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOrgSync.java @@ -481,12 +481,12 @@ public void test108RedskullGoesVegetarian() throws Exception { DummyAccount account = dummyResourceHr.getAccountByUsername(ACCOUNT_REDSKULL_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); account.removeAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_HR_RESPONSIBILITIES, RESP_CANIBALISM); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_HR_OID, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject user = findUserByUsername(ACCOUNT_REDSKULL_USERNAME); assertNotNull("No redskull user", user); display("User", user); @@ -519,12 +519,12 @@ public void test109HrDeleteRedskull() throws Exception { Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); dummyResourceHr.deleteAccountByName(ACCOUNT_REDSKULL_USERNAME); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_HR_OID, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject user = findUserByUsername(ACCOUNT_REDSKULL_USERNAME); display("User", user); assertNull("Redskull user not gone", user); @@ -1012,17 +1012,17 @@ public void test500ReconcileOpenDJDefault() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); importObjectFromFile(TASK_RECON_OPENDJ_DEFAULT_SINGLE_FILE); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForTaskFinish(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID, false, TASK_WAIT_TIMEOUT); waitForTaskCloseOrSuspend(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); reconciliationTaskResultListener.assertResult(RESOURCE_OPENDJ_OID, 0, 17, 0, 0); @@ -1052,17 +1052,17 @@ public void test502ReconcileOpenDJDefaultAgain() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); restartTask(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForTaskFinish(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID, false, TASK_WAIT_TIMEOUT); waitForTaskCloseOrSuspend(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); reconciliationTaskResultListener.assertResult(RESOURCE_OPENDJ_OID, 0, 17, 0, 0); @@ -1092,17 +1092,17 @@ public void test510ReconcileOpenDJLdapGroup() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); importObjectFromFile(TASK_RECON_OPENDJ_LDAPGROUP_SINGLE_FILE); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForTaskFinish(TASK_RECON_OPENDJ_LDAPGROUP_SINGLE_OID, false); waitForTaskCloseOrSuspend(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); reconciliationTaskResultListener.assertResult(RESOURCE_OPENDJ_OID, 0, 2, 0, 0); @@ -1143,17 +1143,17 @@ public void test550ReconcileOpenDJAfterMembershipChange() throws Exception { openDJController.assertNoUniqueMember(RESP_CANIBALISM_DN, ACCOUNT_LEMONHEAD_DN); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); restartTask(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForTaskFinish(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID, false, TASK_WAIT_TIMEOUT); waitForTaskCloseOrSuspend(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); // Task result PrismObject reconTaskAfter = getTask(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestPlentyOfAssignments.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestPlentyOfAssignments.java index 4299ac1329f..9680a9833fe 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestPlentyOfAssignments.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestPlentyOfAssignments.java @@ -185,12 +185,12 @@ public void test100AddCheese() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(cheeseBefore, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -228,12 +228,12 @@ public void test110RecomputeCheese() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_CHEESE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -272,12 +272,12 @@ public void test120CheesePreviewChanges() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -329,7 +329,7 @@ public void test200DummyGroups() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObjectDefinition shadowDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(ShadowType.class); PrismObjectDefinition roleDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(RoleType.class); @@ -382,7 +382,7 @@ public void test200DummyGroups() throws Exception { } // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); Collection dummyGroups = getDummyResource().listGroups(); @@ -412,12 +412,12 @@ public void test210AddBob() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(userBefore, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -456,12 +456,12 @@ public void test212RecomputeBob() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_BOB_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -500,12 +500,12 @@ public void test2124ReconcileBob() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_BOB_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -567,12 +567,12 @@ public void test220AddAlice() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(userBefore, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -612,12 +612,12 @@ public void test222RecomputeAlice() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_ALICE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -656,12 +656,12 @@ public void test224ReconcileAlice() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(USER_ALICE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); assertSuccess(result); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestReconNullValue.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestReconNullValue.java index 04de11fe7f2..29a2ef7be47 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestReconNullValue.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestReconNullValue.java @@ -154,7 +154,7 @@ public void test100CreateUsers() throws Exception { // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding user0", user0Before); addObject(user0Before, task, result); @@ -203,12 +203,12 @@ public void test130AddHonorificPrefix() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(delta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getObjectByName(UserType.class, USER_0_NAME); @@ -260,12 +260,12 @@ public void test140dDeleteHonorificPrefixGivenName() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(delta); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getObjectByName(UserType.class, USER_0_NAME); @@ -318,14 +318,14 @@ public void test150RemoveTitleRA() throws Exception { dumpLdap(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.recompute(UserType.class, userBefore.getOid(), null, task, result); display("LDAP after reconcile"); dumpLdap(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getObjectByName(UserType.class, USER_0_NAME); @@ -377,14 +377,14 @@ public void test160SetGivenNameAttributeAndReconcile() throws Exception { dumpLdap(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modelService.recompute(UserType.class, userBefore.getOid(), null, task, result); display("LDAP after reconcile"); dumpLdap(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getObjectByName(UserType.class, USER_0_NAME); @@ -429,14 +429,14 @@ public void test170ReplaceGivenNameEmpty() throws Exception { dumpLdap(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(userBefore.getOid(), UserType.F_GIVEN_NAME, task, result /* no value */); display("LDAP after reconcile"); dumpLdap(); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = getObjectByName(UserType.class, USER_0_NAME); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestRetirement.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestRetirement.java index 86a0c4e8b6d..8e1826d628f 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestRetirement.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestRetirement.java @@ -174,7 +174,7 @@ public void test050AddOrgRetired() throws Exception { PrismObject orgBefore = PrismTestUtil.parseObject(ORG_RETIRED_FILE); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding org", orgBefore); addObject(orgBefore, task, result); @@ -213,7 +213,7 @@ public void test100AddOrgRoyulaCarpathia() throws Exception { PrismObject orgBefore = createOrg(ORG_ROYULA_CARPATHIA_NAME, ORG_TOP_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding org", orgBefore); addObject(orgBefore, task, result); @@ -243,7 +243,7 @@ public void test110AddUserTeleke() throws Exception { USER_TELEKE_GIVEN_NAME, USER_TELEKE_FAMILY_NAME, orgRolyulaCarpathiaOid); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding user", userBefore); addObject(userBefore, task, result); @@ -273,7 +273,7 @@ public void test200AddOrgCortuvHrad() throws Exception { PrismObject orgBefore = createOrg(ORG_CORTUV_HRAD_NAME, orgRolyulaCarpathiaOid); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding org", orgBefore); addObject(orgBefore, task, result); @@ -304,7 +304,7 @@ public void test210AddUserGorc() throws Exception { USER_GORC_GIVEN_NAME, USER_GORC_FAMILY_NAME, orgCortuvHradOid); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding user", userBefore); addObject(userBefore, task, result); @@ -330,7 +330,7 @@ public void test220AddOrgVysneVlkodlaky() throws Exception { PrismObject orgBefore = createOrg(ORG_VYSNE_VLKODLAKY_NAME, orgCortuvHradOid); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding org", orgBefore); addObject(orgBefore, task, result); @@ -361,7 +361,7 @@ public void test230AddUserViljaDezi() throws Exception { USER_DEZI_GIVEN_NAME, USER_DEZI_FAMILY_NAME, orgVysneVlkodlakyOid); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding user", userBefore); addObject(userBefore, task, result); @@ -391,7 +391,7 @@ public void test300RetireUserGorc() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN @@ -414,7 +414,7 @@ public void test302ReconcileUserGorc() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); reconcileUser(userGorcOid, task, result); // THEN @@ -437,7 +437,7 @@ public void test303ReconcileUserGorcAgain() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); reconcileUser(userGorcOid, task, result); // THEN diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestScience.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestScience.java index 07498de65d2..b97552521b4 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestScience.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestScience.java @@ -178,11 +178,11 @@ public void test100JackAssignRoleStatistics() throws Exception { display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_STATISTICS_OID, task, result); // WHEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = repositoryService.getObject(UserType.class, USER_JACK_OID, null, result); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccounts.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccounts.java index dd6eea3a55f..23bdbdcd2d5 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccounts.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccounts.java @@ -89,12 +89,12 @@ public void test100StartSyncTask() throws Exception { assertServices(0); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); importObjectFromFile(TASK_LIVE_SYNC_DUMMY_FILE); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForTaskStart(TASK_LIVE_SYNC_DUMMY_OID, true); @@ -115,14 +115,14 @@ public void test101AddServiceAccountSync() throws Exception { ACCOUNT_RUM_STORAGE_DUMMY_FULLNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); getDummyResource().addAccount(account); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_OID, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertServices(1); @@ -158,7 +158,7 @@ serviceAccountShadowOid, getDummyResourceController().getAttributeFullnamePath() try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(delta, null, task, result); @@ -166,7 +166,7 @@ serviceAccountShadowOid, getDummyResourceController().getAttributeFullnamePath() } catch (UnsupportedOperationException e) { // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("expected exception", e); } @@ -205,7 +205,7 @@ public void test104DeleteServiceAccount() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(delta, null, task, result); @@ -213,7 +213,7 @@ public void test104DeleteServiceAccount() throws Exception { } catch (UnsupportedOperationException e) { // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("expected exception", e); } @@ -248,14 +248,14 @@ public void test108DeleteServiceAccountSync() throws Exception { assertServices(1); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); getDummyResource().deleteAccountByName(ACCOUNT_RUM_STORAGE_DUMMY_USERNAME); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_OID, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertNoServiceByName(ACCOUNT_RUM_STORAGE_DUMMY_USERNAME); assertServices(0); @@ -269,12 +269,12 @@ public void test109StopLivesyncTask() throws Exception { assertServices(0); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); suspendTask(TASK_LIVE_SYNC_DUMMY_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertTaskExecutionStatus(TASK_LIVE_SYNC_DUMMY_OID, TaskExecutionStatus.SUSPENDED); } @@ -286,12 +286,12 @@ public void test120StartReconTask() throws Exception { assertServices(0); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); importObjectFromFile(TASK_RECONCILE_DUMMY_FILE); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForTaskStart(TASK_RECONCILE_DUMMY_OID, true); @@ -312,14 +312,14 @@ public void test121AddServiceAccountRecon() throws Exception { ACCOUNT_MAGAZINE_DUMMY_FULLNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); getDummyResource().addAccount(account); waitForTaskNextRunAssertSuccess(TASK_RECONCILE_DUMMY_OID, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertServices(1); @@ -338,14 +338,14 @@ public void test128DeleteServiceAccountRecon() throws Exception { assertServices(1); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); getDummyResource().deleteAccountByName(ACCOUNT_MAGAZINE_DUMMY_USERNAME); waitForTaskNextRunAssertSuccess(TASK_RECONCILE_DUMMY_OID, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertNoServiceByName(ACCOUNT_MAGAZINE_DUMMY_USERNAME); assertServices(0); @@ -358,12 +358,12 @@ public void test129StopReconTask() throws Exception { assertServices(1); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); suspendTask(TASK_RECONCILE_DUMMY_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertTaskExecutionStatus(TASK_RECONCILE_DUMMY_OID, TaskExecutionStatus.SUSPENDED); } @@ -393,7 +393,7 @@ public void test140CreateServiceAccount() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(delta, null, task, result); @@ -401,7 +401,7 @@ public void test140CreateServiceAccount() throws Exception { } catch (UnsupportedOperationException e) { // THEN - displayThen(TEST_NAME); + then(TEST_NAME); display("expected exception", e); } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccountsClassifier.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccountsClassifier.java index 4bda950f28d..e9e5b580234 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccountsClassifier.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccountsClassifier.java @@ -81,7 +81,7 @@ public void test001assigneJackEmployeeRole() throws Exception { final String TEST_NAME = "test001assigneJackEmployeeRole"; //WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, ROLE_EMPLOYEE_OID); //THEN @@ -99,7 +99,7 @@ public void test100createServiceJira() throws Exception { addObject(SERVICE_JIRA_FILE); //THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject service = getObject(ServiceType.class, SERVICE_JIRA_OID); display("Service magazine after", service); assertNotNull("No magazine service", service); @@ -116,11 +116,11 @@ public void test101jiraAssignResourceNoneEnforcement() throws Exception { //GIVEN //WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccount(ServiceType.class, SERVICE_JIRA_OID, RESOURCE_DUMMY_CLASSIFIER_OID, "service"); //THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject service = getObject(ServiceType.class, SERVICE_JIRA_OID); display("Service magazine after", service); assertNotNull("No magazine service", service); @@ -137,12 +137,12 @@ public void test150StartReconTask() throws Exception { assertServices(1); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); importObjectFromFile(TASK_RECONCILE_DUMMY_CLASSIFIER_FILE); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForTaskStart(TASK_RECONCILE_DUMMY_CLASSIFIER_OID, true); @@ -161,14 +161,14 @@ public void test151LinkServiceAccountRecon() throws Exception { account.setEnabled(true); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); getDummyResource().addAccount(account); waitForTaskNextRunAssertSuccess(TASK_RECONCILE_DUMMY_CLASSIFIER_OID, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertServices(1); PrismObject serviceJirafter = getObject(ServiceType.class, SERVICE_JIRA_OID); @@ -190,14 +190,14 @@ public void test152InactivateUnmatchedAccountRecon() throws Exception { account.setEnabled(true); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); getDummyResource().addAccount(account); waitForTaskNextRunAssertSuccess(TASK_RECONCILE_DUMMY_CLASSIFIER_OID, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertServices(1); @@ -213,7 +213,7 @@ public void test200createServiceGithub() throws Exception { addObject(SERVICE_GITHUB_FILE); //THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject service = getObject(ServiceType.class, SERVICE_GITHUB_OID); display("Service github after", service); assertNotNull("No github service", service); @@ -226,11 +226,11 @@ public void test210createAccountGithub() throws Exception { final String TEST_NAME = "test210createAccountGithub"; //WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(SHADOW_GITHUB_FILE); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject shadowGithub = getShadowModel(SHADOW_GITHUB_OID); display("Shadow github after", shadowGithub); @@ -249,11 +249,11 @@ public void test215githubAssignResourceNoneEnforcement() throws Exception { //GIVEN //WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccount(ServiceType.class, SERVICE_GITHUB_OID, RESOURCE_DUMMY_CLASSIFIER_OID, "service"); //THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject service = getObject(ServiceType.class, SERVICE_GITHUB_OID); display("Service github after", service); assertNotNull("No github service", service); @@ -275,11 +275,11 @@ public void test220linkAccountGithubAndFixIntent() throws Exception { assertNoLinkedAccount(serviceGithubBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); waitForTaskNextRunAssertSuccess(TASK_RECONCILE_DUMMY_CLASSIFIER_OID, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertServices(2); PrismObject serviceGithubAfter = getObject(ServiceType.class, SERVICE_GITHUB_OID); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestShadowsPerformance.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestShadowsPerformance.java index 400df5342ca..a87c1ed2071 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestShadowsPerformance.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestShadowsPerformance.java @@ -102,11 +102,11 @@ public void test010Sanity() throws Exception { Task task = getTestTask(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); OperationResult result = modelService.testResource(RESOURCE_DUMMY_OID, task); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatusIfUnknown(); assertSuccess(result); } @@ -125,11 +125,11 @@ public void test100ImportAccounts() throws Exception { } // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addTask(TASK_IMPORT_FILE); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); Task taskAfter = waitForTaskFinish(TASK_IMPORT_OID, true, SYNC_TASK_WAIT_TIMEOUT); display("task after", prismContext.xmlSerializer().serialize(taskAfter.getUpdatedTaskObject())); @@ -155,11 +155,11 @@ public void test200DeleteAccountsAndReconcile() throws Exception { assertEquals("Wrong # of remaining accounts", 0, dummyResourceCtl.getDummyResource().listAccounts().size()); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addTask(TASK_RECONCILIATION_FILE); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); Task taskAfter = waitForTaskFinish(TASK_RECONCILIATION_OID, true, 0L, SYNC_TASK_WAIT_TIMEOUT, false, 100, null); display("task after", prismContext.xmlSerializer().serialize(taskAfter.getUpdatedTaskObject())); @@ -185,11 +185,11 @@ public void test210DeleteShadows() throws Exception { assertEquals("Wrong # of remaining accounts", 0, dummyResourceCtl.getDummyResource().listAccounts().size()); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addTask(TASK_BULK_DELETE_FILE); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); Task taskAfter = waitForTaskFinish(TASK_BULK_DELETE_OID, true, 0L, SYNC_TASK_WAIT_TIMEOUT, false, 100, null); display("task after", prismContext.xmlSerializer().serialize(taskAfter.getUpdatedTaskObject())); @@ -216,7 +216,7 @@ public void test900Summarize() { display("Summary (" + NUMBER_OF_GENERATED_USERS + " users)", sb.toString()); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); // TODO: more thresholds diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestStrings.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestStrings.java index fbbe63257ff..eb138289cec 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestStrings.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestStrings.java @@ -213,11 +213,11 @@ public void test100SimpleAssignmentStart() throws Exception { dummyTransport.clearMessages(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(userBobOid, roleATest1Oid, task, task.getResult()); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertNotAssignedRole(getUser(userBobOid), roleATest1Oid); CaseWorkItemType workItem = getWorkItem(task, result); @@ -282,7 +282,7 @@ public void test102SimpleAssignmentApproveByLechuck() throws Exception { CaseWorkItemType workItem = getWorkItem(task, result); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject lechuck = getUserFromRepo(userLechuckOid); login(lechuck); workflowService.completeWorkItem(WorkItemId.of(workItem), @@ -290,7 +290,7 @@ public void test102SimpleAssignmentApproveByLechuck() throws Exception { task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); login(userAdministrator); List workItems = getWorkItems(task, result); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholds.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholds.java index faca622cb15..1d40c2414a1 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholds.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholds.java @@ -170,7 +170,7 @@ public void test110importAccounts() throws Exception { assertUsers(getNumberOfUsers()); //WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); OperationResult reconResult = waitForTaskResume(getTaskOid(), false, TASK_IMPORT_TIMEOUT); assertFailure(reconResult); @@ -195,7 +195,7 @@ public void test111importAccountsAgain() throws Exception { assertUsers(getNumberOfUsers()+getProcessedUsers()); //WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); OperationResult reconResult = waitForTaskResume(getTaskOid(), false, TASK_IMPORT_TIMEOUT); assertFailure(reconResult); @@ -236,7 +236,7 @@ public void test520changeActivationThreeAccounts() throws Exception { openDJController.executeLdifChange(LDIF_CHANGE_ACTIVATION_FILE); //WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); OperationResult reconResult = waitForTaskResume(getTaskOid(), false, 20000); assertFailure(reconResult); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsReconFull.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsReconFull.java index 28507be8936..7242b07ed4b 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsReconFull.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsReconFull.java @@ -90,7 +90,7 @@ public void test610testFullRecon() throws Exception { OperationResult result = new OperationResult(TEST_NAME); //WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); OperationResult reconResult = waitForTaskResume(TASK_RECONCILE_OPENDJ_SIMULATE_EXECUTE_OID, true, 20000); assertSuccess(reconResult); @@ -117,7 +117,7 @@ public void test611testFullRecon() throws Exception { openDJController.delete("uid=user15,ou=People,dc=example,dc=com"); //WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); OperationResult reconResult = waitForTaskNextRun(TASK_RECONCILE_OPENDJ_SIMULATE_EXECUTE_OID, true, 20000, false); assertSuccess(reconResult); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUniversity.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUniversity.java index 98c323e630b..4b8b7869619 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUniversity.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUniversity.java @@ -347,7 +347,7 @@ public void test120MoveComputingCentre() throws Exception { // reconciliationTaskResultListener.clear(); // // // WHEN -// TestUtil.displayWhen(TEST_NAME); +// when(); // importObjectFromFile(TASK_RECON_OPENDJ_DEFAULT_SINGLE_FILE); // // // THEN @@ -386,7 +386,7 @@ public void test120MoveComputingCentre() throws Exception { // reconciliationTaskResultListener.clear(); // // // WHEN -// TestUtil.displayWhen(TEST_NAME); +// when(); // restartTask(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID); // // // THEN @@ -425,7 +425,7 @@ public void test120MoveComputingCentre() throws Exception { // reconciliationTaskResultListener.clear(); // // // WHEN -// TestUtil.displayWhen(TEST_NAME); +// when(); // importObjectFromFile(TASK_RECON_OPENDJ_LDAPGROUP_SINGLE_FILE); // // // THEN @@ -474,7 +474,7 @@ public void test120MoveComputingCentre() throws Exception { // openDJController.assertNoUniqueMember(RESP_CANIBALISM_DN, ACCOUNT_LEMONHEAD_DN); // // // WHEN -// TestUtil.displayWhen(TEST_NAME); +// when(); // restartTask(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID); // // // THEN diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnix.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnix.java index a11ff1859e6..a5ee28b4bc2 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnix.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnix.java @@ -345,11 +345,11 @@ public void test100AddUserHermanBasic() throws Exception { PrismObject user = createUser(USER_HERMAN_USERNAME, USER_HERMAN_FIST_NAME, USER_HERMAN_LAST_NAME, ROLE_BASIC_OID); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(user, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_HERMAN_USERNAME); @@ -372,11 +372,11 @@ public void test110AddUserMancombUnix() throws Exception { PrismObject user = createUser(USER_MANCOMB_USERNAME, USER_MANCOMB_FIST_NAME, USER_MANCOMB_LAST_NAME, ROLE_UNIX_OID); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(user, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_MANCOMB_USERNAME); @@ -400,11 +400,11 @@ public void test111AccountMancombEditObjectClassDefinition() throws Exception { display("shadow", shadow); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); RefinedObjectClassDefinition editObjectClassDefinition = modelInteractionService.getEditObjectClassDefinition(shadow, resourceOpenDj, AuthorizationPhaseType.REQUEST, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); display("OC def", editObjectClassDefinition); @@ -428,11 +428,11 @@ public void test119DeleteUserMancombUnix() throws Exception { PrismObject userBefore = findUserByUsername(USER_MANCOMB_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); deleteObject(UserType.class, userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_MANCOMB_USERNAME); @@ -453,11 +453,11 @@ public void test120AddUserLargo() throws Exception { PrismObject user = createUser(USER_LARGO_USERNAME, USER_LARGO_FIST_NAME, USER_LARGO_LAST_NAME, (String)null); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(user, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -476,11 +476,11 @@ public void test122AssignUserLargoBasic() throws Exception { PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(userBefore.getOid(), ROLE_BASIC_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -506,11 +506,11 @@ public void test124AssignUserLargoUnix() throws Exception { long startTs = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(userBefore.getOid(), ROLE_UNIX_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); long endTs = System.currentTimeMillis(); @@ -538,11 +538,11 @@ public void test125RecomputeUserLargo() throws Exception { PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -566,11 +566,11 @@ public void test126UnAssignUserLargoUnix() throws Exception { PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(userBefore.getOid(), ROLE_UNIX_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -594,11 +594,11 @@ public void test127RecomputeUserLargo() throws Exception { PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -622,11 +622,11 @@ public void test128UnAssignUserLargoBasic() throws Exception { PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(userBefore.getOid(), ROLE_BASIC_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -649,11 +649,11 @@ public void test129RecomputeUserLargo() throws Exception { PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -676,11 +676,11 @@ public void test130AssignUserLargoUnix() throws Exception { PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(userBefore.getOid(), ROLE_UNIX_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -706,11 +706,11 @@ public void test131ReconcileUserLargo() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -764,11 +764,11 @@ public void test132MeddleWithAccountAndReconcileUserLargo() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -815,11 +815,11 @@ public void test133ReconcileUserLargoAgain() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -850,11 +850,11 @@ public void test134AssignUserLargoBasic() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(userBefore.getOid(), ROLE_BASIC_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -886,11 +886,11 @@ public void test135UnAssignUserLargoUnix() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(userBefore.getOid(), ROLE_UNIX_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -950,11 +950,11 @@ public void test136MeddleWithAccountAndReconcileUserLargo() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -993,11 +993,11 @@ public void test137ReconcileUserLargoAgain() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -1034,11 +1034,11 @@ public void test138UnAssignUserLargoBasic() throws Exception { PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(userBefore.getOid(), ROLE_BASIC_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -1063,11 +1063,11 @@ public void test200AddLdapGroupMonkeyIsland() throws Exception { PrismObject role = createLdapGroupRole(ROLE_MONKEY_ISLAND_NAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(role, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject roleAfter = getObject(RoleType.class, role.getOid()); @@ -1091,11 +1091,11 @@ public void test202AssignUserHermanMonkeyIsland() throws Exception { PrismObject user = findUserByUsername(USER_HERMAN_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(user.getOid(), roleMonkeyIslandOid); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_HERMAN_USERNAME); @@ -1119,11 +1119,11 @@ public void test210AddUnixGroupVillains() throws Exception { PrismObject role = createUnixGroupRole(ROLE_VILLAINS_NAME, ROLE_META_UNIXGROUP_OID); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(role, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject roleAfter = getObject(RoleType.class, role.getOid()); @@ -1147,11 +1147,11 @@ public void test211AssignUserLargoUnix() throws Exception { PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(userBefore.getOid(), ROLE_UNIX_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -1175,11 +1175,11 @@ public void test212AssignUserLargoVillains() throws Exception { PrismObject user = findUserByUsername(USER_LARGO_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(user.getOid(), roleVillainsOid); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -1205,11 +1205,11 @@ public void test250AddUserRangerBasic() throws Exception { PrismObject user = createUser(USER_RANGER_USERNAME, USER_RANGER_FIST_NAME, USER_RANGER_LAST_NAME, ROLE_BASIC_OID); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(user, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_RANGER_USERNAME); @@ -1232,11 +1232,11 @@ public void test251AssignUserRangerBasic() throws Exception { PrismObject userBefore = findUserByUsername(USER_RANGER_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(userBefore.getOid(), ROLE_BASIC_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_RANGER_USERNAME); @@ -1260,11 +1260,11 @@ public void test252AddUnixGroupRangers() throws Exception { PrismObject role = createUnixGroupRole(ROLE_RANGERS_NAME, ROLE_META_UNIXGROUP2_OID); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(role, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject roleAfter = getObject(RoleType.class, role.getOid()); @@ -1288,11 +1288,11 @@ public void test253AddUnixGroupSeals() throws Exception { PrismObject role = createUnixGroupRole(ROLE_SEALS_NAME, ROLE_META_UNIXGROUP2_OID); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(role, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject roleAfter = getObject(RoleType.class, role.getOid()); @@ -1318,11 +1318,11 @@ public void test254AssignUserRangerRangers() throws Exception { PrismObject user = findUserByUsername(USER_RANGER_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(user.getOid(), roleRangersOid); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_RANGER_USERNAME); @@ -1331,7 +1331,7 @@ public void test254AssignUserRangerRangers() throws Exception { assertUser(userAfter, USER_RANGER_USERNAME, USER_RANGER_FIST_NAME, USER_RANGER_LAST_NAME); String accountOid = getSingleLinkOid(userAfter); - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject shadow = getShadowModel(accountOid); display("Shadow (model)", shadow); String accountRangerDn = assertPosixAccount(shadow, USER_RANGER_UID_NUMBER); @@ -1359,11 +1359,11 @@ public void test255AssignUserRangerSeals() throws Exception { PrismObject user = findUserByUsername(USER_RANGER_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(user.getOid(), roleSealsOid); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_RANGER_USERNAME); @@ -1392,11 +1392,11 @@ public void test256UnAssignUserRangerSealsKeepRangers() throws Exception { PrismObject userBefore = findUserByUsername(USER_RANGER_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(userBefore.getOid(), roleSealsOid); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_RANGER_USERNAME); @@ -1430,11 +1430,11 @@ public void test257RenameUserAndAccountsCheckGroupmembership() throws Exception PrismObject userBefore = findUserByUsername(USER_RANGER_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(userBefore.getOid(), UserType.F_NAME, task, result, new PolyString("usranger", "usranger")); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_RANGER_USERNAME_RENAMED); @@ -1469,11 +1469,11 @@ public void test260DeleteUserUsrangerUnix() throws Exception { PrismObject userBefore = findUserByUsername(USER_RANGER_USERNAME_RENAMED); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); deleteObject(UserType.class, userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_RANGER_USERNAME_RENAMED); @@ -1495,11 +1495,11 @@ public void test270RenameUnixGroupSeals() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); renameObject(RoleType.class, roleSealsOid, ROLE_WALRUSES_NAME, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject roleAfter = getObject(RoleType.class, roleSealsOid); @@ -1532,7 +1532,7 @@ public void test300AddUserCapsizeUnixFail() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(user, task, result); AssertJUnit.fail("Unexpected success"); @@ -1542,7 +1542,7 @@ public void test300AddUserCapsizeUnixFail() throws Exception { } // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertFailure(result); @@ -1574,11 +1574,11 @@ public void test310AddUserWallyUnix() throws Exception { PrismObject user = createUser(USER_WALLY_USERNAME, USER_WALLY_FIST_NAME, USER_WALLY_LAST_NAME, ROLE_UNIX_OID); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(user, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_WALLY_USERNAME); @@ -1624,11 +1624,11 @@ public void test312AccountWallyRemovePosixObjectclassNative() throws Exception { display("Wally LDAP account before", entryWallyBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject shadow = modelService.getObject(ShadowType.class, accountWallyOid, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1674,11 +1674,11 @@ public void test314AccountWallyAddPosixObjectclassNative() throws Exception { display("Wally LDAP account before", entryWallyBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject shadow = modelService.getObject(ShadowType.class, accountWallyOid, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1706,11 +1706,11 @@ public void test400ListAllAccountsObjectClass() throws Exception { OPENDJ_ACCOUNT_STRUCTURAL_OBJECTCLASS_NAME, prismContext); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); SearchResultList> objects = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1729,11 +1729,11 @@ public void test401ListAllAccountsKindIntent() throws Exception { display("query", query); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); SearchResultList> objects = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1752,11 +1752,11 @@ public void test402ListLdapGroupsKindIntent() throws Exception { display("query", query); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); SearchResultList> objects = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1775,11 +1775,11 @@ public void test403ListUnixGroupsKindIntent() throws Exception { display("query", query); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); SearchResultList> objects = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("found objects", objects); @@ -1796,11 +1796,11 @@ public void test500AddUserStan() throws Exception { addRoleAssignment(user, roleMonkeyIslandOid); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(user, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_STAN_USERNAME); @@ -1841,11 +1841,11 @@ public void test510StanDisablePosixAssocAndReconcile() throws Exception { repositoryService.modifyObject(UserType.class, userStan.getOid(), itemDeltas, result); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(userStan.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_STAN_USERNAME); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnixTolerantAux.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnixTolerantAux.java index a63b39df6b3..024bd61cb6d 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnixTolerantAux.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnixTolerantAux.java @@ -118,11 +118,11 @@ public void test140AssignUserLargoBasic() throws Exception { PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(userBefore.getOid(), ROLE_BASIC_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -166,11 +166,11 @@ public void test142MeddleWithAccountAndReconcileUserLargo() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); reconcileUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -198,11 +198,11 @@ public void test144AssignUserLargoUnix() throws Exception { PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(userBefore.getOid(), ROLE_UNIX_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -228,11 +228,11 @@ public void test146UnassignUserLargoUnix() throws Exception { PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(userBefore.getOid(), ROLE_UNIX_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -258,11 +258,11 @@ public void test149UnAssignUserLargoBasic() throws Exception { PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(userBefore.getOid(), ROLE_BASIC_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestVillage.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestVillage.java index e73a6ab3fe2..a884ac5eb61 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestVillage.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestVillage.java @@ -299,7 +299,7 @@ public void test020ResourceOpenDjGet() throws Exception { rememberCounter(InternalCounters.PRISM_OBJECT_CLONE_COUNT); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, task, result); // THEN @@ -340,7 +340,7 @@ public void test022ResourceOpenDjRefinedSchema() throws Exception { rememberCounter(InternalCounters.PRISM_OBJECT_CLONE_COUNT); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); long t0 = System.currentTimeMillis(); PrismObject resourceAfter = modelService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, task, result); long t1 = System.currentTimeMillis(); @@ -730,7 +730,7 @@ public void test152ModifySrcAccountHermanDeleteOrg() throws Exception { DummyAccount account = dummyResourceSrc.getAccountByUsername(ACCOUNT_HERMAN_USERNAME); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); account.replaceAttributeValues(DUMMY_ACCOUNT_ATTRIBUTE_SRC_ORG); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_SOURCE_OID, true); @@ -773,12 +773,12 @@ public void test200CreateUserAssignOrgPwdPolicy() throws Exception { ObjectDelta addUserMikeDelta = DeltaFactory.Object.createAddDelta(userMikeBefore); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); //The user's password has length 4..if the policy is not chosen correctly, it fails modelService.executeChanges(MiscUtil.createCollection(addUserMikeDelta), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertPartialError(result); //TODO: assert added user @@ -815,11 +815,11 @@ public void test300AddProjectJollyRoger() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(ORG_PROJECT_JOLLY_ROGER_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PrismObject org = getObject(OrgType.class, ORG_PROJECT_JOLLY_ROGER_OID); @@ -854,7 +854,7 @@ ShadowType.F_ATTRIBUTES, new QName(RESOURCE_OPENDJ_NAMESPACE, "cn")).eq("admins" .build(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); // TODO: search for cn=admins,ou=Jolly Roger,dc=example,dc=com SearchResultList> groupShadows = modelService.searchObjects(ShadowType.class, query, null, task, result); @@ -878,7 +878,7 @@ public void test319DeleteProjectJollyRoger() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); deleteObject(OrgType.class, ORG_PROJECT_JOLLY_ROGER_OID, task, result); // THEN @@ -905,7 +905,7 @@ public void test350AddRepoUserNoEmployeeNumberRecompute() throws Exception { repositoryService.addObject(user, null, result); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); recomputeUser(USER_MURRAY_OID, task, result); // THEN diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestWriter.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestWriter.java index 15d2efa1610..33e204882cf 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestWriter.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestWriter.java @@ -77,12 +77,12 @@ public void test100AssignJackDummyAccount() throws Exception { modifyUserReplace(USER_JACK_OID, UserType.F_LOCALITY, task, result, createPolyString(USER_JACK_LOCALITY)); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_JACK_OID, RESOURCE_WRITER_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertDummyAccountByUsername(RESOURCE_WRITER_DUMMY_NAME, USER_JACK_USERNAME) @@ -100,12 +100,12 @@ public void test110ModifyCaptainJack() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, createPolyString(USER_JACK_FULL_NAME_CAPTAIN)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertDummyAccountByUsername(RESOURCE_WRITER_DUMMY_NAME, USER_JACK_USERNAME) diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapAssociationPerformance.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapAssociationPerformance.java index cba853e5d87..3f8401ccfbb 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapAssociationPerformance.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapAssociationPerformance.java @@ -170,13 +170,13 @@ public void test010Sanity() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(ROLE_TEST_FILE, task, result); addObject(USER_TEST_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); dumpLdap(); openDJController.assertUniqueMember("cn=role-test,ou=groups,dc=example,dc=com", "uid=user-test,ou=people,dc=example,dc=com"); @@ -194,7 +194,7 @@ public void test020GenerateRoles() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); resetPerformanceCollectors(); @@ -210,7 +210,7 @@ public void test020GenerateRoles() throws Exception { IntegrationTestTools.setSilentConsole(false); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); recordDuration(TEST_NAME, (endMillis - startMillis)); @@ -242,7 +242,7 @@ public void test100AddUsers() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); resetPerformanceCollectors(); @@ -271,7 +271,7 @@ public void test100AddUsers() throws Exception { IntegrationTestTools.setSilentConsole(false); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); recordDuration(TEST_NAME, (endMillis - startMillis)); @@ -313,7 +313,7 @@ public void test110RecomputeUsers() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); getRepoPerformanceMonitor().clearGlobalPerformanceInformation(); resetGlobalCachePerformanceCollector(); @@ -323,7 +323,7 @@ public void test110RecomputeUsers() throws Exception { waitForTaskFinish(TASK_RECOMPUTE_1_OID, true, RECOMPUTE_TASK_WAIT_TIMEOUT); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); recordDuration(TEST_NAME,getRunDurationMillis(TASK_RECOMPUTE_1_OID)); @@ -357,7 +357,7 @@ public void test120RecomputeUsersNoRoleAndShadowCache() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); getRepoPerformanceMonitor().clearGlobalPerformanceInformation(); resetGlobalCachePerformanceCollector(); @@ -367,7 +367,7 @@ public void test120RecomputeUsersNoRoleAndShadowCache() throws Exception { waitForTaskFinish(TASK_RECOMPUTE_NO_CACHE_OID, true, RECOMPUTE_TASK_WAIT_TIMEOUT); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); recordDuration(TEST_NAME,getRunDurationMillis(TASK_RECOMPUTE_NO_CACHE_OID)); @@ -401,7 +401,7 @@ public void test130RecomputeUsersMultinode() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); getRepoPerformanceMonitor().clearGlobalPerformanceInformation(); resetGlobalCachePerformanceCollector(); @@ -413,7 +413,7 @@ public void test130RecomputeUsersMultinode() throws Exception { IntegrationTestTools.setSilentConsole(false); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); recordDuration(TEST_NAME, getTreeRunDurationMillis(TASK_RECOMPUTE_MULTINODE_OID)); @@ -449,7 +449,7 @@ public void test140RecomputeUsersMultinodeMultithreaded() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); getRepoPerformanceMonitor().clearGlobalPerformanceInformation(); resetGlobalCachePerformanceCollector(); @@ -461,7 +461,7 @@ public void test140RecomputeUsersMultinodeMultithreaded() throws Exception { IntegrationTestTools.setSilentConsole(false); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); recordDuration(TEST_NAME, getTreeRunDurationMillis(TASK_RECOMPUTE_MULTINODE_MULTITHREADED_OID)); @@ -498,7 +498,7 @@ public void test200RecomputeUsersNoDefaultRoleCache() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject newConfiguration = parseObject(SYSTEM_CONFIGURATION_NO_ROLE_CACHE_FILE); repositoryService.addObject(newConfiguration, RepoAddOptions.createOverwrite(), result); @@ -510,7 +510,7 @@ public void test200RecomputeUsersNoDefaultRoleCache() throws Exception { waitForTaskFinish(TASK_RECOMPUTE_4_OID, true, RECOMPUTE_TASK_WAIT_TIMEOUT); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); recordDuration(TEST_NAME,getRunDurationMillis(TASK_RECOMPUTE_4_OID)); @@ -549,7 +549,7 @@ public void test900Summarize() throws Exception { display("Summary ("+NUMBER_OF_GENERATED_USERS+" users, "+NUMBER_OF_GENERATED_ROLES+" roles)", sb.toString()); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); // TODO: more thresholds diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapComplex.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapComplex.java index b8d1fc594ba..fee50ac709c 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapComplex.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapComplex.java @@ -204,11 +204,11 @@ public void test010Shadows() throws Exception { ObjectQuery query = ObjectQueryUtil.createResourceQuery(RESOURCE_OPENDJ_OID, prismContext); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); SearchResultList> shadows = repositoryService.searchObjects(ShadowType.class, query, null, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("Found shadows", shadows); @@ -225,11 +225,11 @@ public void test050AssignAccountOpenDjSimple() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_JACK_OID, RESOURCE_OPENDJ_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); accountJackOid = assertUserAfter(USER_JACK_OID) @@ -261,11 +261,11 @@ public void test055Shadows() throws Exception { display("Query", query); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); SearchResultList> shadows = repositoryService.searchObjects(ShadowType.class, query, null, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("Found shadows", shadows); @@ -279,11 +279,11 @@ public void test059UnassignAccountOpenDjSimple() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignAccountFromUser(USER_JACK_OID, RESOURCE_OPENDJ_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -312,11 +312,11 @@ public void test100ModifyJackFullNameLang() throws Exception { newFullName.setLang(MiscUtil.paramsToMap(JACK_FULL_NAME_LANG_EN_SK)); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, newFullName); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -342,11 +342,11 @@ public void test110AssignAccountOpenDjLang() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_JACK_OID, RESOURCE_OPENDJ_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); accountJackOid = assertUserAfter(USER_JACK_OID) @@ -380,11 +380,11 @@ public void test112ModifyJackFullNameLangEnSkRuHr() throws Exception { newFullName.setLang(MiscUtil.paramsToMap(JACK_FULL_NAME_LANG_EN_SK_RU_HR)); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, newFullName); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -417,11 +417,11 @@ public void test114ModifyJackFullNameLangCzHr() throws Exception { newFullName.setLang(MiscUtil.paramsToMap(JACK_FULL_NAME_LANG_CZ_HR)); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, newFullName); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -454,11 +454,11 @@ public void test116ModifyJackFullNameLangCaptain() throws Exception { newFullName.setLang(MiscUtil.paramsToMap(JACK_FULL_NAME_LANG_CAPTAIN_EN_CZ_SK)); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, newFullName); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -489,11 +489,11 @@ public void test118ModifyJackFullNameCaptain() throws Exception { PolyString newFullName = new PolyString(USER_JACK_FULL_NAME_CAPTAIN); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, newFullName); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -519,11 +519,11 @@ public void test119UnassignAccountOpenDjLang() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignAccountFromUser(USER_JACK_OID, RESOURCE_OPENDJ_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -556,11 +556,11 @@ public void test120ModifyJackTitleMap() throws Exception { .asObjectDelta(USER_JACK_OID); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(delta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -586,11 +586,11 @@ public void test130AssignAccountOpenDjTitleMap() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_JACK_OID, RESOURCE_OPENDJ_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); accountJackOid = assertUserAfter(USER_JACK_OID) @@ -633,11 +633,11 @@ public void test132AssignAccountOpenDjTitleMapAdd() throws Exception { .asObjectDelta(USER_JACK_OID); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(delta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); accountJackOid = assertUserAfter(USER_JACK_OID) @@ -680,11 +680,11 @@ public void test134AssignAccountOpenDjTitleMapDelete() throws Exception { .asObjectDelta(USER_JACK_OID); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(delta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); accountJackOid = assertUserAfter(USER_JACK_OID) @@ -727,11 +727,11 @@ public void test138AssignAccountOpenDjTitleMapReplace() throws Exception { .asObjectDelta(USER_JACK_OID); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); executeChanges(delta, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); accountJackOid = assertUserAfter(USER_JACK_OID) @@ -763,11 +763,11 @@ public void test139UnassignAccountOpenDjTitleMap() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignAccountFromUser(USER_JACK_OID, RESOURCE_OPENDJ_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -792,11 +792,11 @@ public void test150AssignAccountOpenDj() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_JACK_OID, RESOURCE_OPENDJ_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); accountJackOid = assertUserAfter(USER_JACK_OID) @@ -853,11 +853,11 @@ public void test152JackMultivalueDescriptionGet() throws Exception { .getOid(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject shadow = modelService.getObject(ShadowType.class, accountJackOid, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); PolyString descriptionShadowAttribute = (PolyString) assertShadow(shadow, "Jack's shadow after read") @@ -892,11 +892,11 @@ public void test300Shadows() throws Exception { ObjectQuery query = ObjectQueryUtil.createResourceQuery(RESOURCE_OPENDJ_OID, prismContext); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); SearchResultList> shadows = repositoryService.searchObjects(ShadowType.class, query, null, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("Found shadows", shadows); @@ -914,7 +914,7 @@ public void test310SearchLdapAccounts() throws Exception { ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, ShadowKindType.ACCOUNT, SchemaConstants.INTENT_DEFAULT, prismContext); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); searchObjectsIterative(ShadowType.class, query, o -> display("Found object", o), 4); } @@ -932,11 +932,11 @@ public void test312Shadows() throws Exception { ObjectQuery query = ObjectQueryUtil.createResourceQuery(RESOURCE_OPENDJ_OID, prismContext); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); SearchResultList> shadows = repositoryService.searchObjects(ShadowType.class, query, null, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("Found shadows", shadows); @@ -982,7 +982,7 @@ public void test320SearchLdapAccountsBelow() throws Exception { ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, ShadowKindType.ACCOUNT, SchemaConstants.INTENT_DEFAULT, prismContext); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); searchObjectsIterative(ShadowType.class, query, o -> display("Found object", o), 4); } @@ -998,7 +998,7 @@ public void test400SearchLdapProjectGroups() throws Exception { ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, ShadowKindType.ENTITLEMENT, INTENT_LDAP_PROJECT_GROUP, prismContext); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); // Group "pirates" already exists searchObjectsIterative(ShadowType.class, query, o -> display("Found object", o), 1); @@ -1015,7 +1015,7 @@ public void test401SearchLdapOrgGroups() throws Exception { ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, ShadowKindType.ENTITLEMENT, INTENT_LDAP_ORG_GROUP, prismContext); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); searchObjectsIterative(ShadowType.class, query, o -> display("Found object", o), 0); } @@ -1033,11 +1033,11 @@ public void test410CreateProjectKeelhaul() throws Exception { .targetRef(ORG_PROJECT_TOP_OID, OrgType.COMPLEX_TYPE); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(projectKeelhaul); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject orgKeelhaul = findObjectByName(OrgType.class, PROJECT_KEELHAUL_NAME); projectKeelhaulOid = orgKeelhaul.getOid(); groupKeelhaulOid = assertOrg(orgKeelhaul, "after") @@ -1062,11 +1062,11 @@ public void test412CreateProjectWalkThePlank() throws Exception { .targetRef(ORG_PROJECT_TOP_OID, OrgType.COMPLEX_TYPE); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(projectKeelhaul); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject orgWalkThePlank = findObjectByName(OrgType.class, PROJECT_WALK_THE_PLANK_NAME); projectWalkThePlankOid = orgWalkThePlank.getOid(); groupWalkThePlankOid = assertOrg(orgWalkThePlank, "after") @@ -1094,11 +1094,11 @@ public void test415CreateOrgRumDepartment() throws Exception { .targetRef(ORG_FUNCTIONAL_TOP_OID, OrgType.COMPLEX_TYPE); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addObject(orgBefore); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); PrismObject orgAfter = findObjectByName(OrgType.class, ORG_RUM_DEPARTMENT_NAME); orgRumDepartmentOid = orgAfter.getOid(); assertNotNull("Null org oid", orgRumDepartmentOid); @@ -1133,11 +1133,11 @@ public void test420AssignJackToKeelhaul() throws Exception { .getOid(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignOrg(USER_JACK_OID, projectKeelhaulOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); openDJController.assertUniqueMembers("cn="+PROJECT_KEELHAUL_NAME+",ou=groups,dc=example,dc=com", "uid="+USER_JACK_USERNAME+",ou=people,dc=example,dc=com"); @@ -1173,11 +1173,11 @@ public void test422AssignJackToWalkThePlank() throws Exception { .getOid(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignOrg(USER_JACK_OID, projectWalkThePlankOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); openDJController.assertUniqueMembers("cn="+PROJECT_KEELHAUL_NAME+",ou=groups,dc=example,dc=com", "uid="+USER_JACK_USERNAME+",ou=people,dc=example,dc=com"); @@ -1213,11 +1213,11 @@ public void test424AssignJackToRumDepartment() throws Exception { .getOid(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignOrg(USER_JACK_OID, orgRumDepartmentOid, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); openDJController.assertUniqueMembers("cn="+PROJECT_KEELHAUL_NAME+",ou=groups,dc=example,dc=com", "uid="+USER_JACK_USERNAME+",ou=people,dc=example,dc=com"); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapDependency.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapDependency.java index b4d5b7db9a8..92dc00f4ef5 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapDependency.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapDependency.java @@ -157,12 +157,12 @@ public void test100AddOrgIT() throws Exception { PrismObject orgBefore = createOrg(ORG_IT_NAME, ORG_TOP_OID); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); display("Adding org", orgBefore); addObject(orgBefore, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); dumpOrgTree(); @@ -184,12 +184,12 @@ public void test150AssignFunctionalRoleToITOrg() throws Exception { PrismObject orgBefore = getOrg(ORG_IT_NAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); display("orgBefore: ", orgBefore); assignRoleToOrg(orgItOid, ROLE_META_ORG_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); dumpOrgTree(); @@ -213,12 +213,12 @@ public void test170UnassignFunctionalRoleFromITOrg() throws Exception { PrismObject orgBefore = getOrg(ORG_IT_NAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); display("unassigning vip role org", orgBefore); unassignRoleFromOrg(orgItOid, ROLE_META_ORG_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); dumpOrgTree(); @@ -243,12 +243,12 @@ public void test200AddOrgHR() throws Exception { PrismObject orgBefore = createOrg(ORG_HR_NAME, ORG_TOP_OID); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); display("Adding org", orgBefore); addObject(orgBefore, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); dumpOrgTree(); @@ -270,13 +270,13 @@ public void test250AssignFunctionalAndVipRoleToHROrg() throws Exception { PrismObject orgBefore = getOrg(ORG_HR_NAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); display("orgBefore: ", orgBefore); assignRoleToOrg(orgHrOid, ROLE_META_ORG_OID, task, result); assignRoleToOrg(orgHrOid, ROLE_META_ORG_VIP_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); dumpOrgTree(); @@ -302,12 +302,12 @@ public void test270UnassignVipRoleFromHROrg() throws Exception { PrismObject orgBefore = getOrg(ORG_HR_NAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); display("unassigning vip role org", orgBefore); unassignRoleFromOrg(orgHrOid, ROLE_META_ORG_VIP_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); dumpOrgTree(); @@ -334,13 +334,13 @@ public void test280AssignVipAndSuperVipRoleToHROrg() throws Exception { PrismObject orgBefore = getOrg(ORG_HR_NAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); display("orgBefore: ", orgBefore); assignRoleToOrg(orgHrOid, ROLE_META_ORG_VIP_OID, task, result); assignRoleToOrg(orgHrOid, ROLE_META_ORG_SUPERVIP_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); dumpOrgTree(); @@ -370,7 +370,7 @@ public void test290UnassignVipRoleFromHROrg() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRoleFromOrg(orgHrOid, ROLE_META_ORG_VIP_OID, task, result); assertNotReached(); @@ -380,7 +380,7 @@ public void test290UnassignVipRoleFromHROrg() throws Exception { } // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertFailure(result); dumpOrgTree(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapMutilated.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapMutilated.java index e50862689d3..a49eb893d71 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapMutilated.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapMutilated.java @@ -118,11 +118,11 @@ public void test010Shadows() throws Exception { ObjectQuery query = ObjectQueryUtil.createResourceQuery(RESOURCE_OPENDJ_OID, prismContext); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); SearchResultList> shadows = repositoryService.searchObjects(ShadowType.class, query, null, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("Found shadows", shadows); @@ -139,11 +139,11 @@ public void test100AssignAccountOpenDjSimple() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_JACK_OID, RESOURCE_OPENDJ_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); accountJackOid = assertUserAfter(USER_JACK_OID) @@ -173,11 +173,11 @@ public void test105Shadows() throws Exception { display("Query", query); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); SearchResultList> shadows = repositoryService.searchObjects(ShadowType.class, query, null, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("Found shadows", shadows); @@ -191,11 +191,11 @@ public void test109UnassignAccountOpenDjSimple() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignAccountFromUser(USER_JACK_OID, RESOURCE_OPENDJ_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -224,11 +224,11 @@ public void test300Shadows() throws Exception { ObjectQuery query = ObjectQueryUtil.createResourceQuery(RESOURCE_OPENDJ_OID, prismContext); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); SearchResultList> shadows = repositoryService.searchObjects(ShadowType.class, query, null, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("Found shadows", shadows); @@ -246,7 +246,7 @@ public void test310SearchLdapAccounts() throws Exception { ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, ShadowKindType.ACCOUNT, SchemaConstants.INTENT_DEFAULT, prismContext); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); searchObjectsIterative(ShadowType.class, query, o -> display("Found object", o), 0); } @@ -263,11 +263,11 @@ public void test312Shadows() throws Exception { ObjectQuery query = ObjectQueryUtil.createResourceQuery(RESOURCE_OPENDJ_OID, prismContext); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); SearchResultList> shadows = repositoryService.searchObjects(ShadowType.class, query, null, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); display("Found shadows", shadows); @@ -296,11 +296,11 @@ public void test320AssignAccountOpenDj() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignAccountToUser(USER_JACK_OID, RESOURCE_OPENDJ_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); accountJackOid = assertUserAfter(USER_JACK_OID) @@ -326,7 +326,7 @@ public void test322SearchLdapAccounts() throws Exception { ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, ShadowKindType.ACCOUNT, SchemaConstants.INTENT_DEFAULT, prismContext); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); searchObjectsIterative(ShadowType.class, query, o -> display("Found object", o), 1); } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapReconPerformance.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapReconPerformance.java index 2ccd3be452e..f96c9536d51 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapReconPerformance.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapReconPerformance.java @@ -112,7 +112,7 @@ public void test010GenerateUsers() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); // Add objects using model, we also want to create LDAP accounts generateObjects(UserType.class, NUMBER_OF_GENERATED_USERS, GENERATED_USER_NAME_FORMAT, GENERATED_USER_OID_FORMAT, (user,i) -> { @@ -128,7 +128,7 @@ public void test010GenerateUsers() throws Exception { result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); recordDuration(TEST_NAME, (endMillis - startMillis)); @@ -154,13 +154,13 @@ public void test100Reconcile1ThreadLdap0() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addTask(TASK_RECON_1_OPENDJ_FILE); waitForTaskFinish(TASK_RECON_1_OPENDJ_OID, true, RECON_TASK_WAIT_TIMEOUT); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); recordDuration(TEST_NAME,getRunDurationMillis(TASK_RECON_1_OPENDJ_OID)); @@ -197,13 +197,13 @@ public void test200ReconcileLdap0() throws Exception { OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); addTask(TASK_RECON_4_OPENDJ_FILE); waitForTaskFinish(TASK_RECON_4_OPENDJ_OID, true, RECON_TASK_WAIT_TIMEOUT); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); recordDuration(TEST_NAME,getRunDurationMillis(TASK_RECON_4_OPENDJ_OID)); @@ -278,13 +278,13 @@ private long testReconcileLdapRestartWhen(final String TEST_NAME, String taskOid rememberConnectorResourceCounters(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); restartTask(taskOid); waitForTaskFinish(taskOid, true, RECON_TASK_WAIT_TIMEOUT); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long duration = recordDuration(TEST_NAME, getRunDurationMillis(taskOid)); @@ -312,7 +312,7 @@ public void test900Summarize() throws Exception { display("Summary ("+NUMBER_OF_GENERATED_USERS+" users)", sb.toString()); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); if (reconDuration1ThreadBaseline < reconDuration4ThreadBaseline) { fail("Multi-thread recon SLOWER than single-thread! singlethread="+reconDuration1ThreadBaseline+"ms, multithread="+reconDuration4ThreadBaseline+"ms"); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapSyncMassive.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapSyncMassive.java index 53f4a518bf8..8e5f35e9235 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapSyncMassive.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapSyncMassive.java @@ -135,12 +135,12 @@ public void test080ImportSyncTask() throws Exception { final String TEST_NAME = "test080ImportSyncTask"; // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); importObjectFromFile(TASK_LIVE_SYNC_FILE); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_OID, true); @@ -168,12 +168,12 @@ public void test110SyncAddWill() throws Exception { display("Entry from LDIF", entry); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_OID, true); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSyncTokenIncrement(1); @@ -206,14 +206,14 @@ public void test112SyncAddGoods() throws Exception { final String TEST_NAME = "test112SyncAddGoods"; // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); for (int i = 0; i < SYNC_ADD_ATTEMPTS; i++) { syncAddAttemptGood("good", i); } // THEN - displayThen(TEST_NAME); + then(TEST_NAME); dumpLdap(); @@ -234,7 +234,7 @@ public void test150AddGoblins() throws Exception { final String TEST_NAME = "test150AddGoblins"; // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); for (int i = 0; i < NUMBER_OF_GOBLINS; i++) { String username = goblinUsername(i); @@ -247,7 +247,7 @@ public void test150AddGoblins() throws Exception { } // THEN - displayThen(TEST_NAME); + then(TEST_NAME); dumpLdap(); assertLdapConnectorInstances(1, INSTANCES_MAX); @@ -310,12 +310,12 @@ public void test210SyncAddKraken() throws Exception { display("Entry from LDIF", entry); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); OperationResult taskResult = waitForTaskNextRun(TASK_LIVE_SYNC_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertPartialError(taskResult); assertSyncTokenIncrement(0); @@ -345,14 +345,14 @@ public void test212SyncAddBads() throws Exception { final String TEST_NAME = "test212SyncAddBads"; // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); for (int i = 0; i < SYNC_ADD_ATTEMPTS; i++) { syncAddAttemptBad("bad", i); } // THEN - displayThen(TEST_NAME); + then(TEST_NAME); dumpLdap(); @@ -367,12 +367,12 @@ public void test219StopSyncTask() throws Exception { final String TEST_NAME = "test219StopSyncTask"; // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); suspendTask(TASK_LIVE_SYNC_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSyncTokenIncrement(0); assertLdapConnectorInstances(1, INSTANCES_MAX); @@ -390,14 +390,14 @@ public void test230UserRecomputeSequential() throws Exception { SearchResultList> users = modelService.searchObjects(UserType.class, null, null, task, result); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); for (PrismObject user : users) { reconcile(TEST_NAME, user); } // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertLdapConnectorInstances(1, INSTANCES_MAX); assertThreadCount(); @@ -413,7 +413,7 @@ public void test232UserRecomputeParallel() throws Exception { SearchResultList> users = modelService.searchObjects(UserType.class, null, null, task, result); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); int segmentSize = users.size() / NUMBER_OF_TEST_THREADS; ParallelTestThread[] threads = multithread(TEST_NAME, @@ -426,7 +426,7 @@ public void test232UserRecomputeParallel() throws Exception { }, NUMBER_OF_TEST_THREADS, TEST_THREADS_RANDOM_START_RANGE); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); waitForThreads(threads, PARALLEL_TEST_TIMEOUT); // When system is put under load, this means more threads. But not huge number of threads. diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapVirtualGroup.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapVirtualGroup.java index 4dbbb05433f..7253de1ae88 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapVirtualGroup.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapVirtualGroup.java @@ -212,7 +212,7 @@ public void test090AddItRoleHR() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("recompute role "+ROLE_IT_HR_NAME); modelService.recompute(RoleType.class, ROLE_IT_HR_OID, task, result); @@ -243,7 +243,7 @@ public void test100AddItDevRole() throws Exception { PrismObject roleBefore = createLdapRole(ROLE_IT_DEV_NAME); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding role", roleBefore); addObject(roleBefore, task, result); @@ -272,7 +272,7 @@ public void test110AddItOpRole() throws Exception { PrismObject roleBefore = createLdapRole(ROLE_IT_OP_NAME); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding role", roleBefore); addObject(roleBefore, task, result); @@ -304,7 +304,7 @@ public void test200CreateUsers() throws Exception { PrismObject user3Before = createUser(USER_3_NAME, "givenName3", "familyName3", true); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding user0", user0Before); addObject(user0Before, task, result); display("Adding user1", user1Before); @@ -346,7 +346,7 @@ public void test210AssignItHrRoleToUser0() throws Exception { PrismObject user0Before = getObjectByName(UserType.class, USER_0_NAME); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("user0Before: ", user0Before); assignRole(user0Before.getOid(), ROLE_IT_HR_OID); @@ -378,7 +378,7 @@ public void test220AssignItDevRoleToUser1() throws Exception { PrismObject user1Before = getObjectByName(UserType.class, USER_1_NAME); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("user1Before: ", user1Before); assignRole(user1Before.getOid(), roleItDevOid); @@ -412,7 +412,7 @@ public void test230AssignJobRoleToUser2() throws Exception { PrismObject user2Before = getObjectByName(UserType.class, USER_2_NAME); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("user2Before: ", user2Before); assignRole(user2Before.getOid(), ROLE_JOB_DEVOPS_OID); @@ -448,7 +448,7 @@ public void test240AssignJobRoleMultiJobToUser3() throws Exception { PrismObject user3Before = getObjectByName(UserType.class, USER_3_NAME); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("user3Before: ", user3Before); assignRole(user3Before.getOid(), ROLE_JOB_MULTIJOBS_OID); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/hierarchy/AbstractLdapHierarchyTest.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/hierarchy/AbstractLdapHierarchyTest.java index 691e754deb6..8de2884c922 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/hierarchy/AbstractLdapHierarchyTest.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/hierarchy/AbstractLdapHierarchyTest.java @@ -176,7 +176,7 @@ public void test100AddOrgRoyulaCarpathia() throws Exception { PrismObject orgBefore = createOrg(ORG_ROYULA_CARPATHIA_NAME, ORG_TOP_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding org", orgBefore); addObject(orgBefore, task, result); @@ -205,7 +205,7 @@ public void test110AddUserTeleke() throws Exception { USER_TELEKE_GIVEN_NAME, USER_TELEKE_FAMILY_NAME, orgRolyulaCarpathiaOid); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding user", userBefore); addObject(userBefore, task, result); @@ -234,7 +234,7 @@ public void test200AddOrgCortuvHrad() throws Exception { PrismObject orgBefore = createOrg(ORG_CORTUV_HRAD_NAME, orgRolyulaCarpathiaOid); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding org", orgBefore); addObject(orgBefore, task, result); @@ -264,7 +264,7 @@ public void test210AddUserGorc() throws Exception { USER_GORC_GIVEN_NAME, USER_GORC_FAMILY_NAME, orgCortuvHradOid); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding user", userBefore); addObject(userBefore, task, result); @@ -289,7 +289,7 @@ public void test220AddOrgVysneVlkodlaky() throws Exception { PrismObject orgBefore = createOrg(ORG_VYSNE_VLKODLAKY_NAME, orgCortuvHradOid); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding org", orgBefore); addObject(orgBefore, task, result); @@ -319,7 +319,7 @@ public void test230AddUserViljaDezi() throws Exception { USER_DEZI_GIVEN_NAME, USER_DEZI_FAMILY_NAME, orgVysneVlkodlakyOid); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding user", userBefore); addObject(userBefore, task, result); @@ -343,7 +343,7 @@ public void test300RenameOrgCortuvHrad() throws Exception { PrismObject orgBefore = createOrg(ORG_CORTUV_HRAD_NAME, orgRolyulaCarpathiaOid); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding org", orgBefore); modifyObjectReplaceProperty(OrgType.class, orgCortuvHradOid, OrgType.F_NAME, task, result, new PolyString(ORG_CORTUV_HRAD_NAME2)); @@ -376,11 +376,11 @@ public void test310RenameUserGorc() throws Exception { USER_GORC_GIVEN_NAME, USER_GORC_FAMILY_NAME, orgCortuvHradOid); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyObjectReplaceProperty(UserType.class, userGorcOid, UserType.F_NAME, task, result, new PolyString(USER_GORC_USERNAME2)); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); dumpOrgTree(); @@ -398,12 +398,12 @@ public void test320AddOrgRoyulaDiabolica() throws Exception { PrismObject orgBefore = createOrg(ORG_ROYULA_DIABOLICA_NAME, ORG_TOP_OID); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); display("Adding org", orgBefore); addObject(orgBefore, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); dumpOrgTree(); @@ -441,13 +441,13 @@ public void test322MoveOrgZblo() throws Exception { delta.addModificationAddContainer(OrgType.F_ASSIGNMENT, newAssignmentType); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); display("Modifying "+orgBefore+"with delta", delta); modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); assertSuccess(result); dumpOrgTree(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/AbstractNotoriousTest.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/AbstractNotoriousTest.java index 57bfbcede2b..a3c1e4aa325 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/AbstractNotoriousTest.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/AbstractNotoriousTest.java @@ -182,11 +182,11 @@ public void test100AssignRa0ToJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, generateRoleAOid(0), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -217,11 +217,11 @@ public void test102RecomputeJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -255,11 +255,11 @@ public void test104PreviewChangesJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -288,11 +288,11 @@ public void test109UnassignRa0FromJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, generateRoleAOid(0), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -321,11 +321,11 @@ public void test110Assign5ARolesToJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignJackARoles(5, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -353,11 +353,11 @@ public void test112RecomputeJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -385,11 +385,11 @@ public void test119Unassign5ARolesFromJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignJackARoles(5, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -418,11 +418,11 @@ public void test120AssignAllARolesToJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignJackARoles(NUMBER_OF_LEVEL_A_ROLES, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -450,11 +450,11 @@ public void test122RecomputeJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -488,11 +488,11 @@ public void test124PreviewChangesJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -521,11 +521,11 @@ public void test129UnassignAllARolesFromJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignJackARoles(NUMBER_OF_LEVEL_A_ROLES, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -555,11 +555,11 @@ public void test130AssignRb0ToJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, generateRoleBOid(0), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -597,11 +597,11 @@ public void test132AssignRa0ToJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, generateRoleAOid(0), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -632,11 +632,11 @@ public void test134RecomputeJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -667,11 +667,11 @@ public void test136UnassignRb0FromJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, generateRoleBOid(0), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -703,11 +703,11 @@ public void test138AssignRb0ToJackAgain() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assignRole(USER_JACK_OID, generateRoleBOid(0), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -738,11 +738,11 @@ public void test140RecomputeJackAgain() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -773,11 +773,11 @@ public void test142RecomputeJackAlt() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -808,11 +808,11 @@ public void test144UnassignRa0FromJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, generateRoleAOid(0), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -844,11 +844,11 @@ public void test149UnassignRb0FromJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); unassignRole(USER_JACK_OID, generateRoleBOid(0), task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -885,12 +885,12 @@ public void test150AssignNotoriousDefaultToJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyAssignmentHolderAssignment(UserType.class, USER_JACK_OID, getNotoriousOid(), getNotoriousType(), null, task, null, null, true, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -927,12 +927,12 @@ public void test152AssignNotoriousAltRelationToJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyAssignmentHolderAssignment(UserType.class, USER_JACK_OID, getNotoriousOid(), getNotoriousType(), getAltRelation(), task, null, null, true, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -970,11 +970,11 @@ public void test154RecomputeJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -1016,11 +1016,11 @@ public void test156RecomputeJackAlt() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -1058,12 +1058,12 @@ public void test158UnassignNotoriousDefaultFromJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyAssignmentHolderAssignment(UserType.class, USER_JACK_OID, getNotoriousOid(), getNotoriousType(), null, task, null, null, false, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -1099,12 +1099,12 @@ public void test159UnassignNotoriousAltRelationFromJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); modifyAssignmentHolderAssignment(UserType.class, USER_JACK_OID, getNotoriousOid(), getNotoriousType(), getAltRelation(), task, null, null, false, result); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); long endMillis = System.currentTimeMillis(); assertSuccess(result); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/perf/TestImport.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/perf/TestImport.java index 36289b0e5a6..58978bd40cb 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/perf/TestImport.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/perf/TestImport.java @@ -127,7 +127,7 @@ public void test100RunImport() throws Exception { OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); importObjectFromFile(TASK_IMPORT_FILE, result); // THEN diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestPrivacy.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestPrivacy.java index 03744d74f8c..93b6373a6d5 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestPrivacy.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestPrivacy.java @@ -79,7 +79,7 @@ public void test100AutzJackReadSearch() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertGetAllow(UserType.class, USER_GUYBRUSH_OID); assertGetAllow(UserType.class, USER_ELAINE_OID); @@ -89,7 +89,7 @@ public void test100AutzJackReadSearch() throws Exception { USER_ADMINISTRATOR_OID, USER_GUYBRUSH_OID, USER_ELAINE_OID, USER_JACK_OID); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestRoleMembers.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestRoleMembers.java index c5eac7dfc49..44f0e68ae1f 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestRoleMembers.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestRoleMembers.java @@ -88,7 +88,7 @@ public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); assertUserBefore(USER_GUYBRUSH_OID) .assertName(USER_GUYBRUSH_USERNAME) @@ -124,7 +124,7 @@ public void test000Sanity() throws Exception { assertFalse("Preview evaluated assignment triple is empty", evaluatedAssignmentTriple.isEmpty()); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); } @@ -138,7 +138,7 @@ public void test100AutzGuybrushNoMembers() throws Exception { login(USER_GUYBRUSH_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject userMancomb = assertGetAllow(UserType.class, USER_MANCOMB_OID); assertUser(userMancomb, "mancomb") @@ -170,7 +170,7 @@ public void test100AutzGuybrushNoMembers() throws Exception { assertNull("Preview evaluated assignment triple sneaked in", evaluatedAssignmentTriple); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); } @@ -198,7 +198,7 @@ public void test105AutzElaineMembers() throws Exception { login(USER_ELAINE_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(TEST_NAME); PrismObject userMancomb = assertGetAllow(UserType.class, USER_MANCOMB_OID); assertUser(userMancomb, "mancomb") @@ -218,7 +218,7 @@ public void test105AutzElaineMembers() throws Exception { .assertRoleMemberhipRefs(1); // THEN - displayThen(TEST_NAME); + then(TEST_NAME); } From 0556627144fa11dde2855435e874d73227d0a3ce Mon Sep 17 00:00:00 2001 From: Viliam Repan Date: Fri, 28 Feb 2020 14:59:24 +0100 Subject: [PATCH 49/97] schrodinger table row implementation started --- .../component/common/InlineMenu.java | 54 +++++++++++++++++ .../component/common/table/Table.java | 59 +++++++++++++++---- .../component/common/table/TableRow.java | 42 +++++++++++++ 3 files changed, 145 insertions(+), 10 deletions(-) create mode 100644 tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/component/common/InlineMenu.java create mode 100644 tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/component/common/table/TableRow.java diff --git a/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/component/common/InlineMenu.java b/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/component/common/InlineMenu.java new file mode 100644 index 00000000000..6c9f67ec569 --- /dev/null +++ b/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/component/common/InlineMenu.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2010-2020 Evolveum + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.evolveum.midpoint.schrodinger.component.common; + +import com.codeborne.selenide.SelenideElement; + +import com.evolveum.midpoint.schrodinger.component.Component; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by Viliam Repan (lazyman). + */ +public class InlineMenu extends Component { + + public InlineMenu(T parent, SelenideElement parentElement) { + super(parent, parentElement); + } + + public InlineMenu open() { + // todo implement + + return this; + } + + public List getItems() { + List items = new ArrayList<>(); + + // todo implement + + return items; + } + + public InlineMenu clickItem(String itemName) { + // todo implement + + return this; + } +} diff --git a/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/component/common/table/Table.java b/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/component/common/table/Table.java index 76180934933..cf7fb130cd1 100644 --- a/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/component/common/table/Table.java +++ b/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/component/common/table/Table.java @@ -7,19 +7,22 @@ package com.evolveum.midpoint.schrodinger.component.common.table; +import static com.codeborne.selenide.Selectors.byPartialLinkText; +import static com.codeborne.selenide.Selectors.byText; +import static com.codeborne.selenide.Selenide.$; + +import java.util.Objects; + import com.codeborne.selenide.Condition; +import com.codeborne.selenide.ElementsCollection; import com.codeborne.selenide.SelenideElement; +import org.openqa.selenium.By; + import com.evolveum.midpoint.schrodinger.MidPoint; import com.evolveum.midpoint.schrodinger.component.Component; import com.evolveum.midpoint.schrodinger.component.common.Paging; import com.evolveum.midpoint.schrodinger.component.common.Search; import com.evolveum.midpoint.schrodinger.util.Schrodinger; -import org.openqa.selenium.By; - - -import static com.codeborne.selenide.Selectors.byPartialLinkText; -import static com.codeborne.selenide.Selectors.byText; -import static com.codeborne.selenide.Selenide.$; /** * Created by Viliam Repan (lazyman). @@ -30,6 +33,42 @@ public Table(T parent, SelenideElement parentElement) { super(parent, parentElement); } + public TableRow rowByColumnLabel(String label, String rowValue) { + ElementsCollection headers = getParentElement().findAll("thead th div span[data-s-id=label]"); + int index = 1; + for (SelenideElement header : headers) { + String value = header.text(); + if (value == null) { + index++; + continue; + } + + if (Objects.equals(label, value)) { + break; + } + index++; + } + + ElementsCollection rows = getParentElement().findAll("tbody tr"); + for (SelenideElement row : rows) { + String value = row.find("td:nth-child(" + index + ")").text(); + if (value == null) { + continue; + } + value = value.trim(); + + if (Objects.equals(rowValue, value)) { + return new TableRow(this, row); + } + } + + return null; + } + + public TableRow rowByColumnResourceKey(String key, String rowValue) { + // todo implement + return null; + } public Search search() { SelenideElement searchElement = getParentElement().$(By.cssSelector(".form-inline.pull-right.search-form")); @@ -66,19 +105,19 @@ public boolean currentTableContains(String elementName, String elementValue) { } - public boolean containsText(String value){ + public boolean containsText(String value) { return $(byText(value)).is(Condition.visible); } - public boolean containsLinkTextPartially(String value){ + public boolean containsLinkTextPartially(String value) { return $(byPartialLinkText(value)).is(Condition.visible); } - public boolean buttonToolBarExists(){ + public boolean buttonToolBarExists() { return $(Schrodinger.byDataId("buttonToolbar")).exists(); } - public SelenideElement getButtonToolbar(){ + public SelenideElement getButtonToolbar() { return $(Schrodinger.byDataId("buttonToolbar")); } diff --git a/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/component/common/table/TableRow.java b/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/component/common/table/TableRow.java new file mode 100644 index 00000000000..7e45b46e466 --- /dev/null +++ b/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/component/common/table/TableRow.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2010-2020 Evolveum + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.evolveum.midpoint.schrodinger.component.common.table; + +import com.codeborne.selenide.SelenideElement; + +import com.evolveum.midpoint.schrodinger.component.Component; +import com.evolveum.midpoint.schrodinger.component.common.InlineMenu; + +/** + * Created by Viliam Repan (lazyman). + */ +public class TableRow> extends Component { + + public TableRow(T parent, SelenideElement parentElement) { + super(parent, parentElement); + } + + public TableRow clickCheckBox() { + getParentElement().find("input[type=checkbox]").click(); + // todo implement + return this; + } + + public InlineMenu getInlineMenu() { + return null; + } +} From dae6b2d83caeb1c772d2c11229be18dbe8e51943 Mon Sep 17 00:00:00 2001 From: Radovan Semancik Date: Fri, 28 Feb 2020 17:14:43 +0100 Subject: [PATCH 50/97] item constraint visibility support (MID-6043) --- .../501-archetype-task-reconciliation.xml | 216 +-- .../502-archetype-task-recomputation.xml | 200 +-- .../503-archetype-task-import.xml | 206 +-- .../504-archetype-task-live-sync.xml | 242 +-- .../505-archetype-task-async-update.xml | 146 +- .../506-archetype-task-cleanup.xml | 140 +- .../507-archetype-task-report.xml | 124 +- .../508-archetype-task-single-bulk-action.xml | 140 +- ...9-archetype-task-iterative-bulk-action.xml | 202 +-- .../midpoint/prism/path/ItemName.java | 369 ++--- .../midpoint/prism/path/UniformItemPath.java | 194 +-- .../prism}/path/UniformItemPathImpl.java | 859 ++++++----- .../midpoint/prism/impl/PrismContextImpl.java | 1356 ++++++++--------- .../prism/impl/marshaller/ItemPathHolder.java | 1124 +++++++------- .../xml/ns/public/common/common-core-3.xsd | 6 + .../impl/controller/SchemaTransformer.java | 66 +- .../model/intest/gensync/TestEditSchema.java | 9 +- .../common/archetype-task-reconciliation.xml | 20 + .../PrismContainerDefinitionAsserter.java | 9 + 19 files changed, 2946 insertions(+), 2682 deletions(-) rename infra/{prism-impl/src/main/java/com/evolveum/midpoint/prism/impl => prism-api/src/main/java/com/evolveum/midpoint/prism}/path/UniformItemPathImpl.java (96%) diff --git a/gui/admin-gui/src/main/resources/initial-objects/501-archetype-task-reconciliation.xml b/gui/admin-gui/src/main/resources/initial-objects/501-archetype-task-reconciliation.xml index a41f7378d0b..50c4a14daaa 100644 --- a/gui/admin-gui/src/main/resources/initial-objects/501-archetype-task-reconciliation.xml +++ b/gui/admin-gui/src/main/resources/initial-objects/501-archetype-task-reconciliation.xml @@ -1,92 +1,124 @@ - - - Reconciliation task - - - - Reconciliation tasks - - fa fa-exchange - green - - - - - c:TaskType - - - - - - objectRef - - - extension/mext:objectclass - - - extension/mext:kind - - - extension/mext:intent - - - extension/mext:objectQuery - - - - - - - - extension/mext:workerThreads - - - extension/mext:finishOperationsOnly - - - extension/mext:dryRun - - - - - - - - TaskType - - - - - - weak - - http://midpoint.evolveum.com/xml/ns/public/model/synchronization/task/reconciliation/handler-3 - - - handlerUri - - - - - - - - weak - - Reconciliation - - - category - - - - - + + + Reconciliation task + + + + Reconciliation tasks + + fa fa-exchange + green + + + + extension + vacant + + + extension/mext:objectclass + visible + + + extension/mext:kind + visible + + + extension/mext:intent + visible + + + extension/mext:objectQuery + visible + + + extension/mext:workerThreads + visible + + + extension/mext:finishOperationsOnly + visible + + + extension/mext:dryRun + visible + + + + c:TaskType + + + + + + objectRef + + + extension/mext:objectclass + + + extension/mext:kind + + + extension/mext:intent + + + extension/mext:objectQuery + + + + + + + + extension/mext:workerThreads + + + extension/mext:finishOperationsOnly + + + extension/mext:dryRun + + + + + + + + TaskType + + + + + + weak + + http://midpoint.evolveum.com/xml/ns/public/model/synchronization/task/reconciliation/handler-3 + + + handlerUri + + + + + + + + weak + + Reconciliation + + + category + + + + + diff --git a/gui/admin-gui/src/main/resources/initial-objects/502-archetype-task-recomputation.xml b/gui/admin-gui/src/main/resources/initial-objects/502-archetype-task-recomputation.xml index 02e510a4f7d..513c812991c 100644 --- a/gui/admin-gui/src/main/resources/initial-objects/502-archetype-task-recomputation.xml +++ b/gui/admin-gui/src/main/resources/initial-objects/502-archetype-task-recomputation.xml @@ -1,86 +1,114 @@ - - - Recomputation task - - - - Recomputation tasks - - fa fa-cogs - green - - - - - c:TaskType - - - - - - extension/mext:objectType - - - extension/mext:objectQuery - - - extension/mext:searchOptions - - - extension/mext:useRepositoryDirectly - - - - - - - - extension/mext:workerThreads - - - extension/mext:modelExecuteOptions - - - - - - - - TaskType - - - - - - weak - - http://midpoint.evolveum.com/xml/ns/public/model/synchronization/task/recompute/handler-3 - - - handlerUri - - - - - - - - weak - - Recomputation - - - category - - - - - + + + Recomputation task + + + + Recomputation tasks + + fa fa-cogs + green + + + + extension + vacant + + + extension/mext:objectType + visible + + + extension/mext:objectQuery + visible + + + extension/mext:searchOptions + visible + + + extension/mext:useRepositoryDirectly + visible + + + extension/mext:workerThreads + visible + + + extension/mext:modelExecuteOptions + visible + + + + c:TaskType + + + + + + extension/mext:objectType + + + extension/mext:objectQuery + + + extension/mext:searchOptions + + + extension/mext:useRepositoryDirectly + + + + + + + + extension/mext:workerThreads + + + extension/mext:modelExecuteOptions + + + + + + + + TaskType + + + + + + weak + + http://midpoint.evolveum.com/xml/ns/public/model/synchronization/task/recompute/handler-3 + + + handlerUri + + + + + + + + weak + + Recomputation + + + category + + + + + diff --git a/gui/admin-gui/src/main/resources/initial-objects/503-archetype-task-import.xml b/gui/admin-gui/src/main/resources/initial-objects/503-archetype-task-import.xml index 7d09626fd10..398215e8b6a 100644 --- a/gui/admin-gui/src/main/resources/initial-objects/503-archetype-task-import.xml +++ b/gui/admin-gui/src/main/resources/initial-objects/503-archetype-task-import.xml @@ -1,89 +1,117 @@ - - - Import task - - - - Import tasks - - fa fa-upload - green - - - - - TaskType - - - - - - objectRef - - - extension/mext:objectclass - - - extension/mext:kind - - - extension/mext:intent - - - extension/mext:objectQuery - - - - - - - - extension/mext:workerThreads - - - extension/mext:dryRun - - - - - - - - TaskType - - - - - - weak - - http://midpoint.evolveum.com/xml/ns/public/model/synchronization/task/import/handler-3 - - - handlerUri - - - - - - - - weak - - ImportingAccounts - - - category - - - - - + + + Import task + + + + Import tasks + + fa fa-upload + green + + + + extension + vacant + + + extension/mext:objectclass + visible + + + extension/mext:kind + visible + + + extension/mext:intent + visible + + + extension/mext:objectQuery + visible + + + extension/mext:workerThreads + visible + + + extension/mext:dryRun + visible + + + + TaskType + + + + + + objectRef + + + extension/mext:objectclass + + + extension/mext:kind + + + extension/mext:intent + + + extension/mext:objectQuery + + + + + + + + extension/mext:workerThreads + + + extension/mext:dryRun + + + + + + + + TaskType + + + + + + weak + + http://midpoint.evolveum.com/xml/ns/public/model/synchronization/task/import/handler-3 + + + handlerUri + + + + + + + + weak + + ImportingAccounts + + + category + + + + + diff --git a/gui/admin-gui/src/main/resources/initial-objects/504-archetype-task-live-sync.xml b/gui/admin-gui/src/main/resources/initial-objects/504-archetype-task-live-sync.xml index 3af293f332e..28efac11524 100644 --- a/gui/admin-gui/src/main/resources/initial-objects/504-archetype-task-live-sync.xml +++ b/gui/admin-gui/src/main/resources/initial-objects/504-archetype-task-live-sync.xml @@ -1,101 +1,141 @@ - - - Live synchronization task - - - - Live synchronization tasks - - fa fa-refresh - green - - - - - TaskType - - - - - - objectRef - - - extension/mext:objectclass - - - extension/mext:kind - - - extension/mext:intent - - - - - - - - extension/mext:workerThreads - - - extension/mext:dryRun - - - extension/mext:retryLiveSyncErrors - - - extension/mext:updateLiveSyncTokenInDryRun - - - - - - - - extension/livesync:token - - - - - - - - TaskType - - - - - - weak - - http://midpoint.evolveum.com/xml/ns/public/model/synchronization/task/live-sync/handler-3 - - - handlerUri - - - - - - - - weak - - LiveSynchronization - - - category - - - - - + + + Live synchronization task + + + + Live synchronization tasks + + fa fa-refresh + green + + + + extension + vacant + + + extension/mext:objectclass + visible + + + extension/mext:kind + visible + + + extension/mext:intent + visible + + + extension/mext:synchronizationOptions + visible + + + extension/mext:workerThreads + visible + + + extension/mext:dryRun + visible + + + extension/mext:retryLiveSyncErrors + visible + + + extension/mext:updateLiveSyncTokenInDryRun + visible + + + extension/livesync:token + visible + + + + TaskType + + + + + + objectRef + + + extension/mext:objectclass + + + extension/mext:kind + + + extension/mext:intent + + + + + + + + extension/mext:workerThreads + + + extension/mext:dryRun + + + extension/mext:retryLiveSyncErrors + + + extension/mext:updateLiveSyncTokenInDryRun + + + + + + + + extension/livesync:token + + + + + + + + TaskType + + + + + + weak + + http://midpoint.evolveum.com/xml/ns/public/model/synchronization/task/live-sync/handler-3 + + + handlerUri + + + + + + + + weak + + LiveSynchronization + + + category + + + + + diff --git a/gui/admin-gui/src/main/resources/initial-objects/505-archetype-task-async-update.xml b/gui/admin-gui/src/main/resources/initial-objects/505-archetype-task-async-update.xml index 1e3d9854b1d..4948c81997c 100644 --- a/gui/admin-gui/src/main/resources/initial-objects/505-archetype-task-async-update.xml +++ b/gui/admin-gui/src/main/resources/initial-objects/505-archetype-task-async-update.xml @@ -1,69 +1,77 @@ - - - Asynchronous update task - - - - Asynchronous update tasks - - fa fa-bolt - green - - - - - TaskType - - - - - - objectRef - - - extension/mext:workerThreads - - - - - - - - TaskType - - - - - - weak - - http://midpoint.evolveum.com/xml/ns/public/model/synchronization/task/async-update/handler-3 - - - handlerUri - - - - - - - - weak - - AsynchronousUpdate - - - category - - - - - + + + Asynchronous update task + + + + Asynchronous update tasks + + fa fa-bolt + green + + + + extension + vacant + + + extension/mext:workerThreads + visible + + + + TaskType + + + + + + objectRef + + + extension/mext:workerThreads + + + + + + + + TaskType + + + + + + weak + + http://midpoint.evolveum.com/xml/ns/public/model/synchronization/task/async-update/handler-3 + + + handlerUri + + + + + + + + weak + + AsynchronousUpdate + + + category + + + + + diff --git a/gui/admin-gui/src/main/resources/initial-objects/506-archetype-task-cleanup.xml b/gui/admin-gui/src/main/resources/initial-objects/506-archetype-task-cleanup.xml index 5f186f17ec4..7a87d788fdb 100644 --- a/gui/admin-gui/src/main/resources/initial-objects/506-archetype-task-cleanup.xml +++ b/gui/admin-gui/src/main/resources/initial-objects/506-archetype-task-cleanup.xml @@ -1,66 +1,74 @@ - - - Cleanup task - - - - Cleanup tasks - - fa fa-trash - green - - - - - TaskType - - - - - - extension/mext:cleanupPolicies - - - - - - - - TaskType - - - - - - weak - - http://midpoint.evolveum.com/xml/ns/public/model/cleanup/handler-3 - - - handlerUri - - - - - - - - weak - - Cleanup - - - category - - - - - + + + Cleanup task + + + + Cleanup tasks + + fa fa-trash + green + + + + extension + vacant + + + extension/mext:cleanupPolicies + visible + + + + TaskType + + + + + + extension/mext:cleanupPolicies + + + + + + + + TaskType + + + + + + weak + + http://midpoint.evolveum.com/xml/ns/public/model/cleanup/handler-3 + + + handlerUri + + + + + + + + weak + + Cleanup + + + category + + + + + diff --git a/gui/admin-gui/src/main/resources/initial-objects/507-archetype-task-report.xml b/gui/admin-gui/src/main/resources/initial-objects/507-archetype-task-report.xml index b9ea97d0e7b..518c67234f7 100644 --- a/gui/admin-gui/src/main/resources/initial-objects/507-archetype-task-report.xml +++ b/gui/admin-gui/src/main/resources/initial-objects/507-archetype-task-report.xml @@ -1,56 +1,68 @@ - - - Report task - - - - Report tasks - - fa fa-pie-chart - green - - - - - TaskType - - - - - - extension/rext:reportParam - - - extension/rext:reportOutputOid - - - - - - - - TaskType - - - - - - weak - - Report - - - category - - - - - + + + Report task + + + + Report tasks + + fa fa-pie-chart + green + + + + extension + vacant + + + extension/mext:reportParam + visible + + + extension/mext:reportOutputOid + visible + + + + TaskType + + + + + + extension/rext:reportParam + + + extension/rext:reportOutputOid + + + + + + + + TaskType + + + + + + weak + + Report + + + category + + + + + diff --git a/gui/admin-gui/src/main/resources/initial-objects/508-archetype-task-single-bulk-action.xml b/gui/admin-gui/src/main/resources/initial-objects/508-archetype-task-single-bulk-action.xml index 13aa31ce9d2..1aae4f05787 100644 --- a/gui/admin-gui/src/main/resources/initial-objects/508-archetype-task-single-bulk-action.xml +++ b/gui/admin-gui/src/main/resources/initial-objects/508-archetype-task-single-bulk-action.xml @@ -1,66 +1,74 @@ - - - Single bulk action task - - - - Single bulk action tasks - - fa fa-bullseye - green - - - - - TaskType - - - - - - extension/scext:executeScript - - - - - - - - TaskType - - - - - - weak - - http://midpoint.evolveum.com/xml/ns/public/model/scripting/handler-3 - - - handlerUri - - - - - - - - weak - - BulkActions - - - category - - - - - + + + Single bulk action task + + + + Single bulk action tasks + + fa fa-bullseye + green + + + + extension + vacant + + + extension/mext:executeScript + visible + + + + TaskType + + + + + + extension/scext:executeScript + + + + + + + + TaskType + + + + + + weak + + http://midpoint.evolveum.com/xml/ns/public/model/scripting/handler-3 + + + handlerUri + + + + + + + + weak + + BulkActions + + + category + + + + + diff --git a/gui/admin-gui/src/main/resources/initial-objects/509-archetype-task-iterative-bulk-action.xml b/gui/admin-gui/src/main/resources/initial-objects/509-archetype-task-iterative-bulk-action.xml index ca49a57f128..3efb36d68b2 100644 --- a/gui/admin-gui/src/main/resources/initial-objects/509-archetype-task-iterative-bulk-action.xml +++ b/gui/admin-gui/src/main/resources/initial-objects/509-archetype-task-iterative-bulk-action.xml @@ -1,87 +1,115 @@ - - - Iterative bulk action task - - - - Iterative bulk action tasks - - fa fa-bullseye - green - - - - - c:TaskType - - - - - - extension/mext:objectType - - - extension/mext:objectQuery - - - extension/mext:searchOptions - - - extension/mext:useRepositoryDirectly - - - - - - - - extension/scext:executeScript - - - extension/mext:workerThreads - - - - - - - - TaskType - - - - - - weak - - http://midpoint.evolveum.com/xml/ns/public/model/iterative-scripting/handler-3 - - - handlerUri - - - - - - - - weak - - BulkActions - - - category - - - - - + + + Iterative bulk action task + + + + Iterative bulk action tasks + + fa fa-bullseye + green + + + + extension + vacant + + + extension/mext:objectType + visible + + + extension/mext:objectQuery + visible + + + extension/mext:searchOptions + visible + + + extension/mext:useRepositoryDirectly + visible + + + extension/mext:executeScript + visible + + + extension/mext:workerThreads + visible + + + + c:TaskType + + + + + + extension/mext:objectType + + + extension/mext:objectQuery + + + extension/mext:searchOptions + + + extension/mext:useRepositoryDirectly + + + + + + + + extension/scext:executeScript + + + extension/mext:workerThreads + + + + + + + + TaskType + + + + + + weak + + http://midpoint.evolveum.com/xml/ns/public/model/iterative-scripting/handler-3 + + + handlerUri + + + + + + + + weak + + BulkActions + + + category + + + + + diff --git a/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/path/ItemName.java b/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/path/ItemName.java index 6a1fdd7836b..e5c9b78bc7e 100644 --- a/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/path/ItemName.java +++ b/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/path/ItemName.java @@ -1,184 +1,185 @@ -/* - * Copyright (c) 2010-2018 Evolveum and contributors - * - * This work is dual-licensed under the Apache License 2.0 - * and European Union Public License. See LICENSE file for details. - */ - -package com.evolveum.midpoint.prism.path; - -import com.evolveum.midpoint.util.DebugUtil; -import com.evolveum.midpoint.util.QNameUtil; - -import org.jetbrains.annotations.NotNull; - -import javax.xml.namespace.QName; -import java.util.Collections; -import java.util.List; - -/** - * - */ -public class ItemName extends QName implements ItemPath { - - public ItemName(String namespaceURI, String localPart) { - super(namespaceURI, localPart); - } - - public ItemName(String namespaceURI, String localPart, String prefix) { - super(namespaceURI, localPart, prefix); - } - - public ItemName(String localPart) { - super(localPart); - } - - public ItemName(@NotNull QName name) { - this(name.getNamespaceURI(), name.getLocalPart(), name.getPrefix()); - } - - public static ItemName fromQName(QName name) { - if (name == null) { - return null; - } else if (name instanceof ItemName) { - return (ItemName) name; - } else { - return new ItemName(name); - } - } - -// public static ItemName fromString(String name) { -// if (name == null) { -// return null; -// } else { -// return new ItemName(name); -// } -// } - - @Override - public boolean isEmpty() { - return false; - } - - @NotNull - @Override - public List getSegments() { - return Collections.singletonList(new QName(getNamespaceURI(), getLocalPart(), getPrefix())); // todo eliminate QName construction while avoiding endless recursion - } - - @Override - public Object getSegment(int i) { - if (i == 0) { - return this; - } else { - throw new IndexOutOfBoundsException("Index: " + i + ", while accessing single-item path"); - } - } - - @Override - public int size() { - return 1; - } - - @Override - public Object first() { - return this; - } - - @NotNull - @Override - public ItemPath rest() { - return ItemPath.EMPTY_PATH; - } - - @NotNull - @Override - public ItemPath rest(int n) { - if (n == 0) { - return this; - } else { - return EMPTY_PATH; - } - } - - @Override - public Long firstToIdOrNull() { - return null; - } - - @NotNull - @Override - public ItemPath namedSegmentsOnly() { - return this; - } - - @NotNull - @Override - public ItemPath removeIds() { - return this; - } - - @Override - public QName asSingleName() { - return this; - } - - @Override - public boolean isSingleName() { - return true; - } - - @Override - public ItemName lastName() { - return this; - } - - @Override - public Object last() { - return this; - } - - @Override - public ItemPath firstAsPath() { - return this; - } - - @NotNull - @Override - public ItemPath allExceptLast() { - return EMPTY_PATH; - } - - @Override - public String toString() { - if (ItemPath.isObjectReference(this)) { - return ObjectReferencePathSegment.SYMBOL; - } else if (ItemPath.isIdentifier(this)) { - return IdentifierPathSegment.SYMBOL; - } else if (ItemPath.isParent(this)) { - return ParentPathSegment.SYMBOL; - } else { - return DebugUtil.formatElementName(this); - } - } - - @Override - public void shortDump(StringBuilder sb) { - sb.append(toString()); - } - - @Override - public ItemPath subPath(int from, int to) { - if (from > 0) { - return EMPTY_PATH; - } else if (to == 0) { - return EMPTY_PATH; - } else { - return this; - } - } - - public boolean matches(ItemName other) { - return QNameUtil.match(this, other); - } -} +/* + * Copyright (c) 2010-2018 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ + +package com.evolveum.midpoint.prism.path; + +import com.evolveum.midpoint.util.DebugUtil; +import com.evolveum.midpoint.util.QNameUtil; + +import org.jetbrains.annotations.NotNull; + +import javax.xml.namespace.QName; +import java.util.Collections; +import java.util.List; + +/** + * + */ +public class ItemName extends QName implements ItemPath { + + public ItemName(String namespaceURI, String localPart) { + super(namespaceURI, localPart); + } + + public ItemName(String namespaceURI, String localPart, String prefix) { + super(namespaceURI, localPart, prefix); + } + + public ItemName(String localPart) { + super(localPart); + } + + public ItemName(@NotNull QName name) { + this(name.getNamespaceURI(), name.getLocalPart(), name.getPrefix()); + } + + public static ItemName fromQName(QName name) { + if (name == null) { + return null; + } else if (name instanceof ItemName) { + return (ItemName) name; + } else { + return new ItemName(name); + } + } + +// public static ItemName fromString(String name) { +// if (name == null) { +// return null; +// } else { +// return new ItemName(name); +// } +// } + + @Override + public boolean isEmpty() { + return false; + } + + @NotNull + @Override + public List getSegments() { + return Collections.singletonList(new QName(getNamespaceURI(), getLocalPart(), getPrefix())); // todo eliminate QName construction while avoiding endless recursion + } + + @Override + public Object getSegment(int i) { + if (i == 0) { + return this; + } else { + throw new IndexOutOfBoundsException("Index: " + i + ", while accessing single-item path"); + } + } + + @Override + public int size() { + return 1; + } + + @Override + public Object first() { + return this; + } + + @NotNull + @Override + public ItemPath rest() { + return ItemPath.EMPTY_PATH; + } + + @NotNull + @Override + public ItemPath rest(int n) { + if (n == 0) { + return this; + } else { + return EMPTY_PATH; + } + } + + @Override + public Long firstToIdOrNull() { + return null; + } + + @NotNull + @Override + public ItemPath namedSegmentsOnly() { + return this; + } + + @NotNull + @Override + public ItemPath removeIds() { + return this; + } + + @Override + public QName asSingleName() { + return this; + } + + @Override + public boolean isSingleName() { + return true; + } + + @Override + public ItemName lastName() { + return this; + } + + @Override + public Object last() { + return this; + } + + @Override + public ItemPath firstAsPath() { + return this; + } + + @NotNull + @Override + public ItemPath allExceptLast() { + return EMPTY_PATH; + } + + @Override + public String toString() { + if (ItemPath.isObjectReference(this)) { + return ObjectReferencePathSegment.SYMBOL; + } else if (ItemPath.isIdentifier(this)) { + return IdentifierPathSegment.SYMBOL; + } else if (ItemPath.isParent(this)) { + return ParentPathSegment.SYMBOL; + } else { + return DebugUtil.formatElementName(this); + } + } + + @Override + public void shortDump(StringBuilder sb) { + sb.append(toString()); + } + + @Override + public ItemPath subPath(int from, int to) { + if (from > 0) { + return EMPTY_PATH; + } else if (to == 0) { + return EMPTY_PATH; + } else { + return this; + } + } + + public boolean matches(ItemName other) { + return QNameUtil.match(this, other); + } + +} diff --git a/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/path/UniformItemPath.java b/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/path/UniformItemPath.java index e2afe0c04db..cc2776e7771 100644 --- a/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/path/UniformItemPath.java +++ b/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/path/UniformItemPath.java @@ -1,96 +1,98 @@ -/* - * Copyright (c) 2010-2018 Evolveum and contributors - * - * This work is dual-licensed under the Apache License 2.0 - * and European Union Public License. See LICENSE file for details. - */ -package com.evolveum.midpoint.prism.path; - -import com.evolveum.midpoint.util.ShortDumpable; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.io.Serializable; -import java.util.List; -import java.util.Map; - -/** - * @author semancik - * - */ -public interface UniformItemPath extends Serializable, Cloneable, ShortDumpable, ItemPath { - - @NotNull - List getSegments(); - - ItemPathSegment first(); - - @NotNull - default UniformItemPath rest() { - return rest(1); - } - - @Nullable - ItemPathSegment last(); - - /** - * Returns first segment in a form of path. - */ - UniformItemPath firstAsPath(); - - @NotNull - UniformItemPath rest(int n); - - /** - * Returns a path containing all segments except the last one. - */ - @NotNull - UniformItemPath allExceptLast(); - - /** - * Returns a path containing all segments up to (and not including) the last one. - */ - @NotNull - UniformItemPath allUpToLastName(); - - UniformItemPath allUpToIncluding(int i); - - /** - * Makes the path "normal" by inserting null Id segments where they were omitted. - */ - UniformItemPath normalize(); - - @NotNull - UniformItemPath removeIds(); - - @NotNull - UniformItemPath namedSegmentsOnly(); - - @NotNull - UniformItemPath stripVariableSegment(); - - @NotNull - UniformItemPath append(Object... components); - - UniformItemPath remainder(ItemPath prefix); - - /** - * More strict version of ItemPath comparison. Does not use any normalization - * nor approximate matching QNames via QNameUtil.match. - * - * For semantic-level comparison, please use equivalent(..) method. - */ - @Override - boolean equals(Object obj); - - UniformItemPath clone(); - - // TEMPORARY TYPED AS OBJECT (TODO FIXME) - Object asItemPathType(); - - ItemPathSegment getSegment(int i); - - void setNamespaceMap(Map namespaceMap); - - Map getNamespaceMap(); -} +/* + * Copyright (c) 2010-2018 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ +package com.evolveum.midpoint.prism.path; + +import com.evolveum.midpoint.util.ShortDumpable; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; + +/** + * @author semancik + * + */ +public interface UniformItemPath extends Serializable, Cloneable, ShortDumpable, ItemPath { + + UniformItemPath EMPTY_PATH = UniformItemPathImpl.EMPTY_PATH; + + @NotNull + List getSegments(); + + ItemPathSegment first(); + + @NotNull + default UniformItemPath rest() { + return rest(1); + } + + @Nullable + ItemPathSegment last(); + + /** + * Returns first segment in a form of path. + */ + UniformItemPath firstAsPath(); + + @NotNull + UniformItemPath rest(int n); + + /** + * Returns a path containing all segments except the last one. + */ + @NotNull + UniformItemPath allExceptLast(); + + /** + * Returns a path containing all segments up to (and not including) the last one. + */ + @NotNull + UniformItemPath allUpToLastName(); + + UniformItemPath allUpToIncluding(int i); + + /** + * Makes the path "normal" by inserting null Id segments where they were omitted. + */ + UniformItemPath normalize(); + + @NotNull + UniformItemPath removeIds(); + + @NotNull + UniformItemPath namedSegmentsOnly(); + + @NotNull + UniformItemPath stripVariableSegment(); + + @NotNull + UniformItemPath append(Object... components); + + UniformItemPath remainder(ItemPath prefix); + + /** + * More strict version of ItemPath comparison. Does not use any normalization + * nor approximate matching QNames via QNameUtil.match. + * + * For semantic-level comparison, please use equivalent(..) method. + */ + @Override + boolean equals(Object obj); + + UniformItemPath clone(); + + // TEMPORARY TYPED AS OBJECT (TODO FIXME) + Object asItemPathType(); + + ItemPathSegment getSegment(int i); + + void setNamespaceMap(Map namespaceMap); + + Map getNamespaceMap(); +} diff --git a/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/path/UniformItemPathImpl.java b/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/path/UniformItemPathImpl.java similarity index 96% rename from infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/path/UniformItemPathImpl.java rename to infra/prism-api/src/main/java/com/evolveum/midpoint/prism/path/UniformItemPathImpl.java index 4d1da8b747c..93cb90c7943 100644 --- a/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/path/UniformItemPathImpl.java +++ b/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/path/UniformItemPathImpl.java @@ -1,430 +1,429 @@ -/* - * Copyright (c) 2010-2018 Evolveum and contributors - * - * This work is dual-licensed under the Apache License 2.0 - * and European Union Public License. See LICENSE file for details. - */ -package com.evolveum.midpoint.prism.impl.path; - -import com.evolveum.midpoint.prism.path.*; -import com.evolveum.prism.xml.ns._public.types_3.ItemPathType; -import org.apache.commons.lang.Validate; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import javax.xml.namespace.QName; -import java.util.*; - -/** - * @author semancik - * - */ -public class UniformItemPathImpl implements UniformItemPath { - - public static final UniformItemPathImpl EMPTY_PATH = UniformItemPathImpl.createEmpty(); - - private static UniformItemPathImpl createEmpty() { - UniformItemPathImpl empty = new UniformItemPathImpl(); - empty.segments = Collections.emptyList(); // to ensure it won't get modified in no case - return empty; - } - - @NotNull private List segments; - private Map namespaceMap; - - @NotNull - public static UniformItemPathImpl fromItemPath(ItemPath itemPath) { - if (itemPath == null) { - return EMPTY_PATH; - } else if (itemPath instanceof UniformItemPathImpl) { - return (UniformItemPathImpl) itemPath; - } else { - return new UniformItemPathImpl(itemPath); - } - } - - public static ItemPathSegment createSegment(QName qname, boolean variable) { - if (ParentPathSegment.QNAME.equals(qname)) { - return new ParentPathSegment(); - } else if (ObjectReferencePathSegment.QNAME.equals(qname)) { - return new ObjectReferencePathSegment(); - } else if (IdentifierPathSegment.QNAME.equals(qname)) { - return new IdentifierPathSegment(); - } else if (variable) { - return new VariableItemPathSegment(qname); - } else { - return new NameItemPathSegment(qname); - } - } - - public void setNamespaceMap(Map namespaceMap) { - this.namespaceMap = namespaceMap; - } - - public Map getNamespaceMap() { - return namespaceMap; - } - - // use ItemPath.EMPTY_PATH from outside clients to avoid unnecessary instantiation - private UniformItemPathImpl() { - segments = new ArrayList<>(); // to provide room for growth - } - - public UniformItemPathImpl(QName... qnames) { - this.segments = new ArrayList<>(qnames.length); - for (QName qname : qnames) { - add(qname); - } - } - - public UniformItemPathImpl(String... names) { - this.segments = new ArrayList<>(names.length); - for (String name : names) { - add(stringToQName(name)); - } - } - - public UniformItemPathImpl(@NotNull ItemPath itemPath) { - if (itemPath instanceof UniformItemPathImpl) { - UniformItemPathImpl itemPathImpl = (UniformItemPathImpl) itemPath; - this.segments = new ArrayList<>(itemPathImpl.size()); - this.segments.addAll(itemPathImpl.segments); - } else { - List components = itemPath.getSegments(); - this.segments = new ArrayList<>(); // todo - addAll(components); - } - } - - public UniformItemPathImpl(Object... namesOrIdsOrSegments) { - this.segments = new ArrayList<>(namesOrIdsOrSegments.length); - addAll(namesOrIdsOrSegments); - } - - private QName stringToQName(String name) { - Validate.notNull(name, "name"); - switch (name) { - case ParentPathSegment.SYMBOL: - return ParentPathSegment.QNAME; - case ObjectReferencePathSegment.SYMBOL: - return ObjectReferencePathSegment.QNAME; - case IdentifierPathSegment.SYMBOL: - return IdentifierPathSegment.QNAME; - default: - return new QName(name); - } - } - - public UniformItemPathImpl(UniformItemPath parentPath, QName subName) { - this.segments = new ArrayList<>(parentPath.getSegments().size()+1); - segments.addAll(parentPath.getSegments()); - add(subName); - } - - public UniformItemPathImpl(UniformItemPath parentPath, UniformItemPath childPath) { - this.segments = new ArrayList<>(parentPath.getSegments().size()+childPath.getSegments().size()); - segments.addAll(parentPath.getSegments()); - segments.addAll(childPath.getSegments()); - } - - public UniformItemPathImpl(List segments) { - this.segments = new ArrayList<>(segments.size()); - this.segments.addAll(segments); - } - - public UniformItemPathImpl(List segments, ItemPathSegment subSegment) { - this.segments = new ArrayList<>(segments.size()+1); - this.segments.addAll(segments); - this.segments.add(subSegment); - } - - public UniformItemPathImpl(List segments, QName subName) { - this.segments = new ArrayList<>(segments.size()+1); - this.segments.addAll(segments); - add(subName); - } - - public UniformItemPathImpl(List segments, List additionalSegments) { - this.segments = new ArrayList<>(segments.size()+additionalSegments.size()); - this.segments.addAll(segments); - this.segments.addAll(additionalSegments); - } - - public UniformItemPathImpl(ItemPathSegment... segments) { - this.segments = new ArrayList<>(segments.length); - Collections.addAll(this.segments, segments); - } - - public UniformItemPathImpl(UniformItemPath parentPath, ItemPathSegment subSegment) { - this.segments = new ArrayList<>(parentPath.getSegments().size() + 1); - this.segments.addAll(parentPath.getSegments()); - this.segments.add(subSegment); - } - - @NotNull - public UniformItemPath append(Object... components) { - return new UniformItemPathImpl(segments, components); - } - - public UniformItemPath append(Long id) { - return append(new IdItemPathSegment(id)); - } - - public UniformItemPath append(ItemPathSegment subSegment) { - return new UniformItemPathImpl(segments, subSegment); - } - - public UniformItemPath append(UniformItemPath subPath) { - UniformItemPathImpl newPath = new UniformItemPathImpl(segments); - newPath.segments.addAll(subPath.getSegments()); - return newPath; - } - - private void addAll(Collection objects) { - for (Object object : objects) { - add(object); - } - } - - private void addAll(Object[] objects) { - for (Object object : objects) { - add(object); - } - } - - private void add(Object object) { - if (object instanceof UniformItemPathImpl) { - segments.addAll(((UniformItemPathImpl) object).segments); - } else if (object instanceof ItemPath) { - addAll(((ItemPath) object).getSegments()); - } else if (object instanceof ItemPathSegment) { - add((ItemPathSegment) object); - } else if (object instanceof QName) { - add((QName) object); - } else if (object instanceof String) { - add(stringToQName((String) object)); - } else if (object == null || object instanceof Long) { - this.segments.add(new IdItemPathSegment((Long) object)); - } else if (object instanceof Integer) { - this.segments.add(new IdItemPathSegment(((Integer) object).longValue())); - } else if (object instanceof Collection) { - addAll((Collection) object); - } else if (object instanceof Object[]) { // todo what about other kinds of array ? - addAll((Object[]) object); - } else { - throw new IllegalArgumentException("Invalid item path segment value: " + object); - } - } - - private void add(QName qname) { - this.segments.add(createSegment(qname, false)); - } - - private void add(ItemPathSegment segment) { - this.segments.add(segment); - } - - @NotNull - public List getSegments() { - return segments; - } - - public ItemPathSegment first() { - if (segments.isEmpty()) { - return null; - } - return segments.get(0); - } - - @NotNull - public UniformItemPath rest() { - return rest(1); - } - - @NotNull - @Override - public UniformItemPath rest(int n) { - if (n == 0) { - return this; - } else if (segments.size() < n) { - return EMPTY_PATH; - } else { - return subPath(n, size()); - } - } - - @NotNull - public UniformItemPath tail(int n) { - return rest(n); - } - - private NameItemPathSegment lastNamed() { - for (int i = segments.size()-1; i >= 0; i--) { - if (segments.get(i) instanceof NameItemPathSegment) { - return (NameItemPathSegment) segments.get(i); - } - } - return null; - } - - @Nullable - public ItemPathSegment last() { - if (segments.size() == 0) { - return null; - } - return segments.get(segments.size()-1); - } - - public UniformItemPath firstAsPath() { - return new UniformItemPathImpl(first()); - } - - @NotNull - public UniformItemPath allExceptLast() { - return subPath(0, segments.size()-1); - } - - @NotNull - public UniformItemPath allUpToLastName() { - return subPath(0, lastNameIndex()); - } - - public UniformItemPath allUpToIncluding(int i) { - return subPath(0, i+1); - } - - public int size() { - return segments.size(); - } - - public boolean isEmpty() { - return segments.isEmpty(); - } - - /** - * Makes the path "normal" by inserting null Id segments where they were omitted. - */ - public UniformItemPathImpl normalize() { - UniformItemPathImpl normalizedPath = new UniformItemPathImpl(); - ItemPathSegment lastSegment = null; - Iterator iterator = segments.iterator(); - while (iterator.hasNext()) { - ItemPathSegment origSegment = iterator.next(); - if (lastSegment != null && !(lastSegment instanceof IdItemPathSegment) && - !(origSegment instanceof IdItemPathSegment)) { - normalizedPath.segments.add(new IdItemPathSegment()); - } - normalizedPath.segments.add(origSegment); - lastSegment = origSegment; - } - if (lastSegment != null && !(lastSegment instanceof IdItemPathSegment) && - // Make sure we do not insert the Id segment as a last one. That is not correct and it would spoil comparing paths - iterator.hasNext()) { - normalizedPath.segments.add(new IdItemPathSegment()); - } - return normalizedPath; - } - - @NotNull - public UniformItemPath removeIds() { - UniformItemPathImpl rv = new UniformItemPathImpl(); - for (ItemPathSegment segment : segments) { - if (!(segment instanceof IdItemPathSegment)) { - rv.add(segment); - } - } - return rv; - } - - @NotNull - public UniformItemPath namedSegmentsOnly() { - UniformItemPathImpl rv = new UniformItemPathImpl(); - for (ItemPathSegment segment : segments) { - if (segment instanceof NameItemPathSegment) { - rv.add(((NameItemPathSegment) segment).getName()); - } - } - return rv; - } - - @NotNull - public UniformItemPath stripVariableSegment() { - return startsWithVariable() ? rest() : this; - } - - public UniformItemPath append(QName childName) { - return new UniformItemPathImpl(this, childName); - } - - public UniformItemPath remainder(ItemPath prefix) { - return new UniformItemPathImpl(ItemPathComparatorUtil.remainder(this, prefix)); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + segments.hashCode(); - return result; - } - - /** - * More strict version of ItemPath comparison. Does not use any normalization - * nor approximate matching QNames via QNameUtil.match. - * - * For semantic-level comparison, please use equivalent(..) method. - */ - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (getClass() != obj.getClass()) return false; - UniformItemPathImpl other = (UniformItemPathImpl) obj; - if (!segments.equals(other.segments)) return false; - return true; - } - - public UniformItemPath clone() { - UniformItemPathImpl clone = new UniformItemPathImpl(); - for (ItemPathSegment segment : segments) { - clone.segments.add(segment.clone()); - } - if (namespaceMap != null) { - clone.namespaceMap = new HashMap<>(namespaceMap); - } - return clone; - } - - public ItemPathType asItemPathType() { - return new ItemPathType(this); - } - - @Override - public ItemName lastName() { - NameItemPathSegment lastNamed = lastNamed(); - return lastNamed != null ? lastNamed.getName() : null; - } - - @Override - public UniformItemPathImpl subPath(int from, int to) { - int fromClipped = Math.max(0, from); - int toClipped = Math.min(to, segments.size()); - if (fromClipped >= toClipped) { - return EMPTY_PATH; - } else { - return new UniformItemPathImpl(segments.subList(fromClipped, toClipped)); - } - } - - @Override - public ItemPathSegment getSegment(int i) { - return segments.get(i); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - shortDump(sb); - return sb.toString(); - } -} +/* + * Copyright (c) 2010-2018 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ +package com.evolveum.midpoint.prism.path; + +import com.evolveum.prism.xml.ns._public.types_3.ItemPathType; +import org.apache.commons.lang.Validate; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import javax.xml.namespace.QName; +import java.util.*; + +/** + * @author semancik + * + */ +public class UniformItemPathImpl implements UniformItemPath { + + public static final UniformItemPathImpl EMPTY_PATH = UniformItemPathImpl.createEmpty(); + + private static UniformItemPathImpl createEmpty() { + UniformItemPathImpl empty = new UniformItemPathImpl(); + empty.segments = Collections.emptyList(); // to ensure it won't get modified in no case + return empty; + } + + @NotNull private List segments; + private Map namespaceMap; + + @NotNull + public static UniformItemPathImpl fromItemPath(ItemPath itemPath) { + if (itemPath == null) { + return EMPTY_PATH; + } else if (itemPath instanceof UniformItemPathImpl) { + return (UniformItemPathImpl) itemPath; + } else { + return new UniformItemPathImpl(itemPath); + } + } + + public static ItemPathSegment createSegment(QName qname, boolean variable) { + if (ParentPathSegment.QNAME.equals(qname)) { + return new ParentPathSegment(); + } else if (ObjectReferencePathSegment.QNAME.equals(qname)) { + return new ObjectReferencePathSegment(); + } else if (IdentifierPathSegment.QNAME.equals(qname)) { + return new IdentifierPathSegment(); + } else if (variable) { + return new VariableItemPathSegment(qname); + } else { + return new NameItemPathSegment(qname); + } + } + + public void setNamespaceMap(Map namespaceMap) { + this.namespaceMap = namespaceMap; + } + + public Map getNamespaceMap() { + return namespaceMap; + } + + // use ItemPath.EMPTY_PATH from outside clients to avoid unnecessary instantiation + private UniformItemPathImpl() { + segments = new ArrayList<>(); // to provide room for growth + } + + public UniformItemPathImpl(QName... qnames) { + this.segments = new ArrayList<>(qnames.length); + for (QName qname : qnames) { + add(qname); + } + } + + public UniformItemPathImpl(String... names) { + this.segments = new ArrayList<>(names.length); + for (String name : names) { + add(stringToQName(name)); + } + } + + public UniformItemPathImpl(@NotNull ItemPath itemPath) { + if (itemPath instanceof UniformItemPathImpl) { + UniformItemPathImpl itemPathImpl = (UniformItemPathImpl) itemPath; + this.segments = new ArrayList<>(itemPathImpl.size()); + this.segments.addAll(itemPathImpl.segments); + } else { + List components = itemPath.getSegments(); + this.segments = new ArrayList<>(); // todo + addAll(components); + } + } + + public UniformItemPathImpl(Object... namesOrIdsOrSegments) { + this.segments = new ArrayList<>(namesOrIdsOrSegments.length); + addAll(namesOrIdsOrSegments); + } + + private QName stringToQName(String name) { + Validate.notNull(name, "name"); + switch (name) { + case ParentPathSegment.SYMBOL: + return ParentPathSegment.QNAME; + case ObjectReferencePathSegment.SYMBOL: + return ObjectReferencePathSegment.QNAME; + case IdentifierPathSegment.SYMBOL: + return IdentifierPathSegment.QNAME; + default: + return new QName(name); + } + } + + public UniformItemPathImpl(UniformItemPath parentPath, QName subName) { + this.segments = new ArrayList<>(parentPath.getSegments().size()+1); + segments.addAll(parentPath.getSegments()); + add(subName); + } + + public UniformItemPathImpl(UniformItemPath parentPath, UniformItemPath childPath) { + this.segments = new ArrayList<>(parentPath.getSegments().size()+childPath.getSegments().size()); + segments.addAll(parentPath.getSegments()); + segments.addAll(childPath.getSegments()); + } + + public UniformItemPathImpl(List segments) { + this.segments = new ArrayList<>(segments.size()); + this.segments.addAll(segments); + } + + public UniformItemPathImpl(List segments, ItemPathSegment subSegment) { + this.segments = new ArrayList<>(segments.size()+1); + this.segments.addAll(segments); + this.segments.add(subSegment); + } + + public UniformItemPathImpl(List segments, QName subName) { + this.segments = new ArrayList<>(segments.size()+1); + this.segments.addAll(segments); + add(subName); + } + + public UniformItemPathImpl(List segments, List additionalSegments) { + this.segments = new ArrayList<>(segments.size()+additionalSegments.size()); + this.segments.addAll(segments); + this.segments.addAll(additionalSegments); + } + + public UniformItemPathImpl(ItemPathSegment... segments) { + this.segments = new ArrayList<>(segments.length); + Collections.addAll(this.segments, segments); + } + + public UniformItemPathImpl(UniformItemPath parentPath, ItemPathSegment subSegment) { + this.segments = new ArrayList<>(parentPath.getSegments().size() + 1); + this.segments.addAll(parentPath.getSegments()); + this.segments.add(subSegment); + } + + @NotNull + public UniformItemPath append(Object... components) { + return new UniformItemPathImpl(segments, components); + } + + public UniformItemPath append(Long id) { + return append(new IdItemPathSegment(id)); + } + + public UniformItemPath append(ItemPathSegment subSegment) { + return new UniformItemPathImpl(segments, subSegment); + } + + public UniformItemPath append(UniformItemPath subPath) { + UniformItemPathImpl newPath = new UniformItemPathImpl(segments); + newPath.segments.addAll(subPath.getSegments()); + return newPath; + } + + private void addAll(Collection objects) { + for (Object object : objects) { + add(object); + } + } + + private void addAll(Object[] objects) { + for (Object object : objects) { + add(object); + } + } + + private void add(Object object) { + if (object instanceof UniformItemPathImpl) { + segments.addAll(((UniformItemPathImpl) object).segments); + } else if (object instanceof ItemPath) { + addAll(((ItemPath) object).getSegments()); + } else if (object instanceof ItemPathSegment) { + add((ItemPathSegment) object); + } else if (object instanceof QName) { + add((QName) object); + } else if (object instanceof String) { + add(stringToQName((String) object)); + } else if (object == null || object instanceof Long) { + this.segments.add(new IdItemPathSegment((Long) object)); + } else if (object instanceof Integer) { + this.segments.add(new IdItemPathSegment(((Integer) object).longValue())); + } else if (object instanceof Collection) { + addAll((Collection) object); + } else if (object instanceof Object[]) { // todo what about other kinds of array ? + addAll((Object[]) object); + } else { + throw new IllegalArgumentException("Invalid item path segment value: " + object); + } + } + + private void add(QName qname) { + this.segments.add(createSegment(qname, false)); + } + + private void add(ItemPathSegment segment) { + this.segments.add(segment); + } + + @NotNull + public List getSegments() { + return segments; + } + + public ItemPathSegment first() { + if (segments.isEmpty()) { + return null; + } + return segments.get(0); + } + + @NotNull + public UniformItemPath rest() { + return rest(1); + } + + @NotNull + @Override + public UniformItemPath rest(int n) { + if (n == 0) { + return this; + } else if (segments.size() < n) { + return EMPTY_PATH; + } else { + return subPath(n, size()); + } + } + + @NotNull + public UniformItemPath tail(int n) { + return rest(n); + } + + private NameItemPathSegment lastNamed() { + for (int i = segments.size()-1; i >= 0; i--) { + if (segments.get(i) instanceof NameItemPathSegment) { + return (NameItemPathSegment) segments.get(i); + } + } + return null; + } + + @Nullable + public ItemPathSegment last() { + if (segments.size() == 0) { + return null; + } + return segments.get(segments.size()-1); + } + + public UniformItemPath firstAsPath() { + return new UniformItemPathImpl(first()); + } + + @NotNull + public UniformItemPath allExceptLast() { + return subPath(0, segments.size()-1); + } + + @NotNull + public UniformItemPath allUpToLastName() { + return subPath(0, lastNameIndex()); + } + + public UniformItemPath allUpToIncluding(int i) { + return subPath(0, i+1); + } + + public int size() { + return segments.size(); + } + + public boolean isEmpty() { + return segments.isEmpty(); + } + + /** + * Makes the path "normal" by inserting null Id segments where they were omitted. + */ + public UniformItemPathImpl normalize() { + UniformItemPathImpl normalizedPath = new UniformItemPathImpl(); + ItemPathSegment lastSegment = null; + Iterator iterator = segments.iterator(); + while (iterator.hasNext()) { + ItemPathSegment origSegment = iterator.next(); + if (lastSegment != null && !(lastSegment instanceof IdItemPathSegment) && + !(origSegment instanceof IdItemPathSegment)) { + normalizedPath.segments.add(new IdItemPathSegment()); + } + normalizedPath.segments.add(origSegment); + lastSegment = origSegment; + } + if (lastSegment != null && !(lastSegment instanceof IdItemPathSegment) && + // Make sure we do not insert the Id segment as a last one. That is not correct and it would spoil comparing paths + iterator.hasNext()) { + normalizedPath.segments.add(new IdItemPathSegment()); + } + return normalizedPath; + } + + @NotNull + public UniformItemPath removeIds() { + UniformItemPathImpl rv = new UniformItemPathImpl(); + for (ItemPathSegment segment : segments) { + if (!(segment instanceof IdItemPathSegment)) { + rv.add(segment); + } + } + return rv; + } + + @NotNull + public UniformItemPath namedSegmentsOnly() { + UniformItemPathImpl rv = new UniformItemPathImpl(); + for (ItemPathSegment segment : segments) { + if (segment instanceof NameItemPathSegment) { + rv.add(((NameItemPathSegment) segment).getName()); + } + } + return rv; + } + + @NotNull + public UniformItemPath stripVariableSegment() { + return startsWithVariable() ? rest() : this; + } + + public UniformItemPath append(QName childName) { + return new UniformItemPathImpl(this, childName); + } + + public UniformItemPath remainder(ItemPath prefix) { + return new UniformItemPathImpl(ItemPathComparatorUtil.remainder(this, prefix)); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + segments.hashCode(); + return result; + } + + /** + * More strict version of ItemPath comparison. Does not use any normalization + * nor approximate matching QNames via QNameUtil.match. + * + * For semantic-level comparison, please use equivalent(..) method. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + if (getClass() != obj.getClass()) return false; + UniformItemPathImpl other = (UniformItemPathImpl) obj; + if (!segments.equals(other.segments)) return false; + return true; + } + + public UniformItemPath clone() { + UniformItemPathImpl clone = new UniformItemPathImpl(); + for (ItemPathSegment segment : segments) { + clone.segments.add(segment.clone()); + } + if (namespaceMap != null) { + clone.namespaceMap = new HashMap<>(namespaceMap); + } + return clone; + } + + public ItemPathType asItemPathType() { + return new ItemPathType(this); + } + + @Override + public ItemName lastName() { + NameItemPathSegment lastNamed = lastNamed(); + return lastNamed != null ? lastNamed.getName() : null; + } + + @Override + public UniformItemPathImpl subPath(int from, int to) { + int fromClipped = Math.max(0, from); + int toClipped = Math.min(to, segments.size()); + if (fromClipped >= toClipped) { + return EMPTY_PATH; + } else { + return new UniformItemPathImpl(segments.subList(fromClipped, toClipped)); + } + } + + @Override + public ItemPathSegment getSegment(int i) { + return segments.get(i); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + shortDump(sb); + return sb.toString(); + } +} diff --git a/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/PrismContextImpl.java b/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/PrismContextImpl.java index ef31a3303c7..ef13edaa38f 100644 --- a/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/PrismContextImpl.java +++ b/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/PrismContextImpl.java @@ -1,678 +1,678 @@ -/* - * Copyright (c) 2010-2018 Evolveum and contributors - * - * This work is dual-licensed under the Apache License 2.0 - * and European Union Public License. See LICENSE file for details. - */ -package com.evolveum.midpoint.prism.impl; - -import com.evolveum.midpoint.prism.*; -import com.evolveum.midpoint.prism.crypto.*; -import com.evolveum.midpoint.prism.delta.DeltaFactory; -import com.evolveum.midpoint.prism.impl.delta.DeltaFactoryImpl; -import com.evolveum.midpoint.prism.delta.ObjectDelta; -import com.evolveum.midpoint.prism.impl.delta.builder.DeltaBuilder; -import com.evolveum.midpoint.prism.delta.builder.S_ItemEntry; -import com.evolveum.midpoint.prism.impl.crypto.KeyStoreBasedProtectorImpl; -import com.evolveum.midpoint.prism.impl.marshaller.*; -import com.evolveum.midpoint.prism.impl.path.CanonicalItemPathImpl; -import com.evolveum.midpoint.prism.impl.path.UniformItemPathImpl; -import com.evolveum.midpoint.prism.impl.schema.SchemaDefinitionFactory; -import com.evolveum.midpoint.prism.impl.schema.SchemaFactoryImpl; -import com.evolveum.midpoint.prism.impl.schema.SchemaRegistryImpl; -import com.evolveum.midpoint.prism.marshaller.*; -import com.evolveum.midpoint.prism.impl.lex.LexicalProcessor; -import com.evolveum.midpoint.prism.impl.lex.LexicalProcessorRegistry; -import com.evolveum.midpoint.prism.impl.lex.dom.DomLexicalProcessor; -import com.evolveum.midpoint.prism.path.*; -import com.evolveum.midpoint.prism.polystring.PolyStringNormalizer; -import com.evolveum.midpoint.prism.impl.polystring.AlphanumericPolyStringNormalizer; -import com.evolveum.midpoint.prism.impl.polystring.ConfigurableNormalizer; -import com.evolveum.midpoint.prism.query.QueryFactory; -import com.evolveum.midpoint.prism.impl.query.QueryFactoryImpl; -import com.evolveum.midpoint.prism.query.QueryConverter; -import com.evolveum.midpoint.prism.impl.query.builder.QueryBuilder; -import com.evolveum.midpoint.prism.query.builder.S_FilterEntryOrEmpty; -import com.evolveum.midpoint.prism.schema.*; -import com.evolveum.midpoint.prism.util.PrismMonitor; -import com.evolveum.midpoint.prism.util.PrismPrettyPrinter; -import com.evolveum.midpoint.prism.xnode.RootXNode; -import com.evolveum.midpoint.prism.impl.xnode.RootXNodeImpl; -import com.evolveum.midpoint.prism.xnode.XNodeFactory; -import com.evolveum.midpoint.prism.impl.xnode.XNodeFactoryImpl; -import com.evolveum.midpoint.prism.xnode.XNodeMutator; -import com.evolveum.midpoint.util.QNameUtil; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SystemException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.prism.xml.ns._public.types_3.ItemPathType; -import com.evolveum.prism.xml.ns._public.types_3.PolyStringNormalizerConfigurationType; - -import org.jetbrains.annotations.NotNull; -import org.springframework.beans.factory.annotation.Autowired; -import org.w3c.dom.Element; -import org.xml.sax.SAXException; - -import javax.xml.namespace.QName; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.util.List; - -/** - * @author semancik - * - */ -public final class PrismContextImpl implements PrismContext { - - private static final Trace LOGGER = TraceManager.getTrace(PrismContextImpl.class); - - private static boolean allowSchemalessSerialization = true; - private static boolean extraValidation = false; // TODO replace by something serious - - @NotNull private final SchemaRegistryImpl schemaRegistry; - @NotNull private final QueryConverterImpl queryConverter; - @NotNull private final LexicalProcessorRegistry lexicalProcessorRegistry; - @NotNull private PolyStringNormalizer defaultPolyStringNormalizer; - @NotNull private final PrismUnmarshaller prismUnmarshaller; - @NotNull private final PrismMarshaller prismMarshaller; - @NotNull private final BeanMarshaller beanMarshaller; - @NotNull private final BeanUnmarshaller beanUnmarshaller; - @NotNull private final HacksImpl hacks; - @NotNull private final XNodeFactory xnodeFactory; - @NotNull private final DeltaFactory deltaFactory; - @NotNull private final QueryFactory queryFactory; - @NotNull private final ItemFactory itemFactory; - @NotNull private final DefinitionFactory definitionFactory; - @NotNull private final ItemPathParser itemPathParser; - @NotNull private final SchemaFactory schemaFactory; - - private ParsingMigrator parsingMigrator; - private PrismMonitor monitor = null; - - private SchemaDefinitionFactory schemaDefinitionFactory; - - @Autowired private Protector defaultProtector; - - // We need to keep this because of deprecated methods and various hacks - @NotNull private final JaxbDomHack jaxbDomHack; - - private QName defaultRelation; - - private QName objectsElementName; - - // ugly hack - private QName defaultReferenceTypeName; - - static { - PrismPrettyPrinter.initialize(); - } - - //region Standard overhead - private PrismContextImpl(@NotNull SchemaRegistryImpl schemaRegistry) { - this.schemaRegistry = schemaRegistry; - schemaRegistry.setPrismContext(this); - this.queryConverter = new QueryConverterImpl(this); - this.lexicalProcessorRegistry = new LexicalProcessorRegistry(schemaRegistry); - PrismBeanInspector inspector = new PrismBeanInspector(this); - this.beanMarshaller = new BeanMarshaller(this, inspector); - this.beanUnmarshaller = new BeanUnmarshaller(this, inspector, beanMarshaller); - this.prismUnmarshaller = new PrismUnmarshaller(this, beanUnmarshaller, schemaRegistry); - this.prismMarshaller = new PrismMarshaller(beanMarshaller); - this.jaxbDomHack = new JaxbDomHackImpl(lexicalProcessorRegistry.domProcessor(), this); - this.hacks = new HacksImpl(this); - this.xnodeFactory = new XNodeFactoryImpl(); - this.deltaFactory = new DeltaFactoryImpl(this); - this.queryFactory = new QueryFactoryImpl(this); - this.itemFactory = new ItemFactoryImpl(this); - this.definitionFactory = new DefinitionFactoryImpl(this); - this.itemPathParser = new ItemPathParserImpl(this); - this.schemaFactory = new SchemaFactoryImpl(this); - this.defaultPolyStringNormalizer = new AlphanumericPolyStringNormalizer(); - - try { - configurePolyStringNormalizer(null); - } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { - // Should not happen - throw new SystemException(e.getMessage(), e); - } - } - - public static PrismContextImpl create(@NotNull SchemaRegistryImpl schemaRegistry) { - return new PrismContextImpl(schemaRegistry); - } - - public static PrismContextImpl createEmptyContext(@NotNull SchemaRegistryImpl schemaRegistry) { - return new PrismContextImpl(schemaRegistry); - } - - @Override - public void initialize() throws SchemaException, SAXException, IOException { - schemaRegistry.initialize(); - } - - @Override - public void configurePolyStringNormalizer(PolyStringNormalizerConfigurationType configuration) throws ClassNotFoundException, InstantiationException, IllegalAccessException { - if (configuration == null) { - defaultPolyStringNormalizer = new AlphanumericPolyStringNormalizer(); - return; - } - - String className = configuration.getClassName(); - if (className == null) { - defaultPolyStringNormalizer = new AlphanumericPolyStringNormalizer(); - } else { - String fullClassName = getNormalizerFullClassName(className); - Class normalizerClass; - try { - normalizerClass = Class.forName(fullClassName); - } catch (ClassNotFoundException e) { - throw new ClassNotFoundException("Cannot find class "+fullClassName+": "+e.getMessage(), e); - } - defaultPolyStringNormalizer = (PolyStringNormalizer) normalizerClass.newInstance(); - } - - if (defaultPolyStringNormalizer instanceof ConfigurableNormalizer) { - ((ConfigurableNormalizer)defaultPolyStringNormalizer).configure(configuration); - } - } - - private String getNormalizerFullClassName(String shortClassName) { - if (shortClassName.contains(".")) { - return shortClassName; - } - return AlphanumericPolyStringNormalizer.class.getPackage().getName() + "." + shortClassName; - } - - public static boolean isAllowSchemalessSerialization() { - return allowSchemalessSerialization; - } - - public static void setAllowSchemalessSerialization(boolean allowSchemalessSerialization) { - PrismContextImpl.allowSchemalessSerialization = allowSchemalessSerialization; - } - - public static boolean isExtraValidation() { - return extraValidation; - } - - @Override - public XmlEntityResolver getEntityResolver() { - return schemaRegistry.getEntityResolver(); - } - - @NotNull - @Override - public SchemaRegistry getSchemaRegistry() { - return schemaRegistry; - } - - /** - * WARNING! This is not really public method. It should NOT not used outside the prism implementation. - */ - public PrismUnmarshaller getPrismUnmarshaller() { - return prismUnmarshaller; - } - - @NotNull - public PrismMarshaller getPrismMarshaller() { - return prismMarshaller; - } - - /** - * WARNING! This is not really public method. It should NOT not used outside the prism implementation. - */ - public DomLexicalProcessor getParserDom() { - return lexicalProcessorRegistry.domProcessor(); - } - - /** - * WARNING! This is not really public method. It should NOT not used outside the prism implementation. - */ - @NotNull - public BeanMarshaller getBeanMarshaller() { - return beanMarshaller; - } - - @NotNull - public BeanUnmarshaller getBeanUnmarshaller() { - return beanUnmarshaller; - } - - @NotNull - @Override - public JaxbDomHack getJaxbDomHack() { - return jaxbDomHack; - } - - @NotNull - public SchemaDefinitionFactory getDefinitionFactory() { - if (schemaDefinitionFactory == null) { - schemaDefinitionFactory = new SchemaDefinitionFactory(); - } - return schemaDefinitionFactory; - } - - public void setDefinitionFactory(SchemaDefinitionFactory schemaDefinitionFactory) { - this.schemaDefinitionFactory = schemaDefinitionFactory; - } - - @NotNull - @Override - public PolyStringNormalizer getDefaultPolyStringNormalizer() { - return defaultPolyStringNormalizer; - } - - private LexicalProcessor getParser(String language) { - return lexicalProcessorRegistry.processorFor(language); - } - - private LexicalProcessor getParserNotNull(String language) { - LexicalProcessor lexicalProcessor = getParser(language); - if (lexicalProcessor == null) { - throw new SystemException("No parser for language '"+language+"'"); - } - return lexicalProcessor; - } - - @Override - public Protector getDefaultProtector() { - return defaultProtector; - } - - public void setDefaultProtector(Protector defaultProtector) { - this.defaultProtector = defaultProtector; - } - - @NotNull - @Override - public QueryConverter getQueryConverter() { - return queryConverter; - } - - @Override - public PrismMonitor getMonitor() { - return monitor; - } - - @Override - public void setMonitor(PrismMonitor monitor) { - this.monitor = monitor; - } - - @Override - public QName getDefaultRelation() { - return defaultRelation; - } - - public void setDefaultRelation(QName defaultRelation) { - this.defaultRelation = defaultRelation; - } - - @Override - public QName getObjectsElementName() { - return objectsElementName; - } - - public void setObjectsElementName(QName objectsElementName) { - this.objectsElementName = objectsElementName; - } - - @Override - public QName getDefaultReferenceTypeName() { - return defaultReferenceTypeName; - } - - public void setDefaultReferenceTypeName(QName defaultReferenceTypeName) { - this.defaultReferenceTypeName = defaultReferenceTypeName; - } - - //endregion - - //region Parsing - @NotNull - @Override - public PrismParser parserFor(@NotNull File file) { - return new PrismParserImplIO(new ParserFileSource(file), null, getDefaultParsingContext(), this, null, null, null, null); - } - - @NotNull - @Override - public PrismParser parserFor(@NotNull InputStream stream) { - return new PrismParserImplIO(new ParserInputStreamSource(stream), null, getDefaultParsingContext(), this, null, null, null, null); - } - - @NotNull - @Override - public PrismParserNoIO parserFor(@NotNull String data) { - return new PrismParserImplNoIO(new ParserStringSource(data), null, getDefaultParsingContext(), this, null, null, null, null); - } - - @NotNull - @Override - public PrismParserNoIO parserFor(@NotNull RootXNode xnode) { - return new PrismParserImplNoIO(new ParserXNodeSource((RootXNodeImpl) xnode), null, getDefaultParsingContext(), this, null, null, null, null); - } - - @NotNull - @Deprecated - @Override - public PrismParserNoIO parserFor(@NotNull Element data) { - return new PrismParserImplNoIO(new ParserElementSource(data), null, getDefaultParsingContext(), this, null, null, null, null); - } - - @NotNull - @Override - public String detectLanguage(@NotNull File file) throws IOException { - return lexicalProcessorRegistry.detectLanguage(file); - } - - @Override - public ParsingMigrator getParsingMigrator() { - return parsingMigrator; - } - - @Override - public void setParsingMigrator(ParsingMigrator parsingMigrator) { - this.parsingMigrator = parsingMigrator; - } - //endregion - - //region adopt(...) methods - /** - * Set up the specified object with prism context instance and schema definition. - */ - @Override - public void adopt(PrismContainer container, Class declaredType) throws SchemaException { - container.revive(this); - getSchemaRegistry().applyDefinition(container, declaredType, false); - } - - @Override - public void adopt(PrismContainer container) throws SchemaException { - adopt(container, container.getCompileTimeClass()); - } - - @Override - public void adopt(Objectable objectable) throws SchemaException { - adopt(objectable.asPrismObject(), objectable.getClass()); - } - - @Override - public void adopt(Containerable containerable) throws SchemaException { - containerable.asPrismContainerValue().revive(this); - } - - @Override - public void adopt(PrismContainerValue value) throws SchemaException { - value.revive(this); - } - - @Override - public void adopt(ObjectDelta delta) throws SchemaException { - delta.revive(this); - getSchemaRegistry().applyDefinition(delta, delta.getObjectTypeClass(), false); - } - - @Override - public void adopt(C containerable, Class type, ItemPath path) throws SchemaException { - PrismContainerValue prismContainerValue = containerable.asPrismContainerValue(); - adopt(prismContainerValue, type, path); - } - - @Override - public void adopt(PrismContainerValue prismContainerValue, Class type, - ItemPath path) throws SchemaException { - prismContainerValue.revive(this); - getSchemaRegistry().applyDefinition(prismContainerValue, type, path, false); - } - - @Override - public void adopt(PrismContainerValue prismContainerValue, QName typeName, - ItemPath path) throws SchemaException { - prismContainerValue.revive(this); - getSchemaRegistry().applyDefinition(prismContainerValue, typeName, path, false); - } - //endregion - - //region Serializing objects, containers, atomic values (properties) - @Override - public String serializeObjectToString(PrismObject object, String language) throws SchemaException { - return serializerFor(language).serialize(object); - } - - @NotNull - @Override - public PrismSerializer serializerFor(@NotNull String language) { - return new PrismSerializerImpl<>(new SerializerStringTarget(this, language), null, null, null, this, null); - } - - @NotNull - @Override - public PrismSerializer xmlSerializer() { - return serializerFor(LANG_XML); - } - - @NotNull - @Override - public PrismSerializer jsonSerializer() { - return serializerFor(LANG_JSON); - } - - @NotNull - @Override - public PrismSerializer yamlSerializer() { - return serializerFor(LANG_YAML); - } - - @NotNull - @Override - public PrismSerializer domSerializer() { - return new PrismSerializerImpl<>(new SerializerDomTarget(this), null, null, null, this, null); - } - - @NotNull - @Override - public PrismSerializer xnodeSerializer() { - return new PrismSerializerImpl<>(new SerializerXNodeTarget(this), null, null, null, this, null); - } - - @Override - public boolean canSerialize(Object value) { - return prismMarshaller.canSerialize(value); - } - - //endregion - - @NotNull - @Override - public PrismObject createObject(@NotNull Class clazz) throws SchemaException { - PrismObjectDefinition definition = schemaRegistry.findObjectDefinitionByCompileTimeClass(clazz); - if (definition == null) { - throw new SchemaException("Definition for prism object holding " + clazz + " couldn't be found"); - } - return definition.instantiate(); - } - - @NotNull - @Override - public T createObjectable(@NotNull Class clazz) throws SchemaException { - return createObject(clazz).asObjectable(); - } - - @NotNull - @Override - public PrismObject createKnownObject(@NotNull Class clazz) { - try { - return createObject(clazz); - } catch (SchemaException e) { - throw new SystemException("Unexpected SchemaException while instantiating " + clazz + ": " + e.getMessage(), e); - } - } - - @NotNull - @Override - public O createKnownObjectable(@NotNull Class clazz) { - return createKnownObject(clazz).asObjectable(); - } - - @NotNull - public LexicalProcessorRegistry getLexicalProcessorRegistry() { - return lexicalProcessorRegistry; - } - - @Override - public boolean isDefaultRelation(QName relation) { - return relation == null || defaultRelation != null && QNameUtil.match(relation, defaultRelation); - } - - @Override - public boolean relationsEquivalent(QName relation1, QName relation2) { - if (isDefaultRelation(relation1)) { - return isDefaultRelation(relation2); - } else { - return QNameUtil.match(relation1, relation2); - } - } - - @Override - public boolean relationMatches(QName relationQuery, QName relation) { - return QNameUtil.match(relationQuery, PrismConstants.Q_ANY) || relationsEquivalent(relationQuery, relation); - } - - @Override - public boolean relationMatches(@NotNull List relationQuery, QName relation) { - return relationQuery.stream().anyMatch(rq -> relationMatches(rq, relation)); - } - - @Override - public ParsingContext getDefaultParsingContext() { - return ParsingContextImpl.createDefault(); - } - - @Override - public ParsingContext createParsingContextForAllowMissingRefTypes() { - return ParsingContextImpl.allowMissingRefTypes(); - } - - @Override - public ParsingContext createParsingContextForCompatibilityMode() { - return ParsingContextImpl.createForCompatibilityMode(); - } - - @Override - public UniformItemPath emptyPath() { - return UniformItemPathImpl.EMPTY_PATH; - } - - @Override - public UniformItemPath path(Object... namesOrIdsOrSegments) { - return new UniformItemPathImpl(namesOrIdsOrSegments); - } - - @Override - public Hacks hacks() { - return hacks; - } - - @Override - public XNodeFactory xnodeFactory() { - return xnodeFactory; - } - - @Override - public XNodeMutator xnodeMutator() { - return hacks; - } - - @Override - public KeyStoreBasedProtector createInitializedProtector(KeyStoreBasedProtectorBuilder builder) { - KeyStoreBasedProtectorImpl protector = new KeyStoreBasedProtectorImpl(builder); - protector.init(); - return protector; - } - - @Override - public KeyStoreBasedProtector createProtector(KeyStoreBasedProtectorBuilder builder) { - return new KeyStoreBasedProtectorImpl(builder); - } - - @NotNull - @Override - public UniformItemPath toUniformPath(ItemPath path) { - return UniformItemPathImpl.fromItemPath(path); - } - - @Override - public UniformItemPath toUniformPathKeepNull(ItemPath path) { - return path != null ? UniformItemPathImpl.fromItemPath(path) : null; - } - - @Override - public UniformItemPath toUniformPath(ItemPathType path) { - return UniformItemPathImpl.fromItemPath(path.getItemPath()); - } - - @Override - public CanonicalItemPath createCanonicalItemPath(ItemPath itemPath, Class clazz) { - return new CanonicalItemPathImpl(itemPath, clazz, this); - } - - @Override - public CanonicalItemPath createCanonicalItemPath(ItemPath itemPath) { - return new CanonicalItemPathImpl(itemPath, null, null); - } - - @Override - public S_ItemEntry deltaFor(Class objectClass) throws SchemaException { - return new DeltaBuilder<>(objectClass, this); - } - - @Override - public S_FilterEntryOrEmpty queryFor(Class queryClass) { - return QueryBuilder.queryFor(queryClass, this); - } - - @Override - @NotNull - public DeltaFactory deltaFactory() { - return deltaFactory; - } - - @NotNull - @Override - public QueryFactory queryFactory() { - return queryFactory; - } - - @NotNull - @Override - public ItemFactory itemFactory() { - return itemFactory; - } - - @NotNull - @Override - public DefinitionFactory definitionFactory() { - return definitionFactory; - } - - @NotNull - @Override - public ItemPathParser itemPathParser() { - return itemPathParser; - } - - // This is instance method to allow calling it via PrismContext interface - @Override - public void setExtraValidation(boolean value) { - PrismContextImpl.extraValidation = value; - } - - @NotNull - @Override - public SchemaFactory schemaFactory() { - return schemaFactory; - } -} +/* + * Copyright (c) 2010-2018 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ +package com.evolveum.midpoint.prism.impl; + +import com.evolveum.midpoint.prism.*; +import com.evolveum.midpoint.prism.crypto.*; +import com.evolveum.midpoint.prism.delta.DeltaFactory; +import com.evolveum.midpoint.prism.impl.delta.DeltaFactoryImpl; +import com.evolveum.midpoint.prism.delta.ObjectDelta; +import com.evolveum.midpoint.prism.impl.delta.builder.DeltaBuilder; +import com.evolveum.midpoint.prism.delta.builder.S_ItemEntry; +import com.evolveum.midpoint.prism.impl.crypto.KeyStoreBasedProtectorImpl; +import com.evolveum.midpoint.prism.impl.marshaller.*; +import com.evolveum.midpoint.prism.impl.path.CanonicalItemPathImpl; +import com.evolveum.midpoint.prism.path.UniformItemPathImpl; +import com.evolveum.midpoint.prism.impl.schema.SchemaDefinitionFactory; +import com.evolveum.midpoint.prism.impl.schema.SchemaFactoryImpl; +import com.evolveum.midpoint.prism.impl.schema.SchemaRegistryImpl; +import com.evolveum.midpoint.prism.marshaller.*; +import com.evolveum.midpoint.prism.impl.lex.LexicalProcessor; +import com.evolveum.midpoint.prism.impl.lex.LexicalProcessorRegistry; +import com.evolveum.midpoint.prism.impl.lex.dom.DomLexicalProcessor; +import com.evolveum.midpoint.prism.path.*; +import com.evolveum.midpoint.prism.polystring.PolyStringNormalizer; +import com.evolveum.midpoint.prism.impl.polystring.AlphanumericPolyStringNormalizer; +import com.evolveum.midpoint.prism.impl.polystring.ConfigurableNormalizer; +import com.evolveum.midpoint.prism.query.QueryFactory; +import com.evolveum.midpoint.prism.impl.query.QueryFactoryImpl; +import com.evolveum.midpoint.prism.query.QueryConverter; +import com.evolveum.midpoint.prism.impl.query.builder.QueryBuilder; +import com.evolveum.midpoint.prism.query.builder.S_FilterEntryOrEmpty; +import com.evolveum.midpoint.prism.schema.*; +import com.evolveum.midpoint.prism.util.PrismMonitor; +import com.evolveum.midpoint.prism.util.PrismPrettyPrinter; +import com.evolveum.midpoint.prism.xnode.RootXNode; +import com.evolveum.midpoint.prism.impl.xnode.RootXNodeImpl; +import com.evolveum.midpoint.prism.xnode.XNodeFactory; +import com.evolveum.midpoint.prism.impl.xnode.XNodeFactoryImpl; +import com.evolveum.midpoint.prism.xnode.XNodeMutator; +import com.evolveum.midpoint.util.QNameUtil; +import com.evolveum.midpoint.util.exception.SchemaException; +import com.evolveum.midpoint.util.exception.SystemException; +import com.evolveum.midpoint.util.logging.Trace; +import com.evolveum.midpoint.util.logging.TraceManager; +import com.evolveum.prism.xml.ns._public.types_3.ItemPathType; +import com.evolveum.prism.xml.ns._public.types_3.PolyStringNormalizerConfigurationType; + +import org.jetbrains.annotations.NotNull; +import org.springframework.beans.factory.annotation.Autowired; +import org.w3c.dom.Element; +import org.xml.sax.SAXException; + +import javax.xml.namespace.QName; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; + +/** + * @author semancik + * + */ +public final class PrismContextImpl implements PrismContext { + + private static final Trace LOGGER = TraceManager.getTrace(PrismContextImpl.class); + + private static boolean allowSchemalessSerialization = true; + private static boolean extraValidation = false; // TODO replace by something serious + + @NotNull private final SchemaRegistryImpl schemaRegistry; + @NotNull private final QueryConverterImpl queryConverter; + @NotNull private final LexicalProcessorRegistry lexicalProcessorRegistry; + @NotNull private PolyStringNormalizer defaultPolyStringNormalizer; + @NotNull private final PrismUnmarshaller prismUnmarshaller; + @NotNull private final PrismMarshaller prismMarshaller; + @NotNull private final BeanMarshaller beanMarshaller; + @NotNull private final BeanUnmarshaller beanUnmarshaller; + @NotNull private final HacksImpl hacks; + @NotNull private final XNodeFactory xnodeFactory; + @NotNull private final DeltaFactory deltaFactory; + @NotNull private final QueryFactory queryFactory; + @NotNull private final ItemFactory itemFactory; + @NotNull private final DefinitionFactory definitionFactory; + @NotNull private final ItemPathParser itemPathParser; + @NotNull private final SchemaFactory schemaFactory; + + private ParsingMigrator parsingMigrator; + private PrismMonitor monitor = null; + + private SchemaDefinitionFactory schemaDefinitionFactory; + + @Autowired private Protector defaultProtector; + + // We need to keep this because of deprecated methods and various hacks + @NotNull private final JaxbDomHack jaxbDomHack; + + private QName defaultRelation; + + private QName objectsElementName; + + // ugly hack + private QName defaultReferenceTypeName; + + static { + PrismPrettyPrinter.initialize(); + } + + //region Standard overhead + private PrismContextImpl(@NotNull SchemaRegistryImpl schemaRegistry) { + this.schemaRegistry = schemaRegistry; + schemaRegistry.setPrismContext(this); + this.queryConverter = new QueryConverterImpl(this); + this.lexicalProcessorRegistry = new LexicalProcessorRegistry(schemaRegistry); + PrismBeanInspector inspector = new PrismBeanInspector(this); + this.beanMarshaller = new BeanMarshaller(this, inspector); + this.beanUnmarshaller = new BeanUnmarshaller(this, inspector, beanMarshaller); + this.prismUnmarshaller = new PrismUnmarshaller(this, beanUnmarshaller, schemaRegistry); + this.prismMarshaller = new PrismMarshaller(beanMarshaller); + this.jaxbDomHack = new JaxbDomHackImpl(lexicalProcessorRegistry.domProcessor(), this); + this.hacks = new HacksImpl(this); + this.xnodeFactory = new XNodeFactoryImpl(); + this.deltaFactory = new DeltaFactoryImpl(this); + this.queryFactory = new QueryFactoryImpl(this); + this.itemFactory = new ItemFactoryImpl(this); + this.definitionFactory = new DefinitionFactoryImpl(this); + this.itemPathParser = new ItemPathParserImpl(this); + this.schemaFactory = new SchemaFactoryImpl(this); + this.defaultPolyStringNormalizer = new AlphanumericPolyStringNormalizer(); + + try { + configurePolyStringNormalizer(null); + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { + // Should not happen + throw new SystemException(e.getMessage(), e); + } + } + + public static PrismContextImpl create(@NotNull SchemaRegistryImpl schemaRegistry) { + return new PrismContextImpl(schemaRegistry); + } + + public static PrismContextImpl createEmptyContext(@NotNull SchemaRegistryImpl schemaRegistry) { + return new PrismContextImpl(schemaRegistry); + } + + @Override + public void initialize() throws SchemaException, SAXException, IOException { + schemaRegistry.initialize(); + } + + @Override + public void configurePolyStringNormalizer(PolyStringNormalizerConfigurationType configuration) throws ClassNotFoundException, InstantiationException, IllegalAccessException { + if (configuration == null) { + defaultPolyStringNormalizer = new AlphanumericPolyStringNormalizer(); + return; + } + + String className = configuration.getClassName(); + if (className == null) { + defaultPolyStringNormalizer = new AlphanumericPolyStringNormalizer(); + } else { + String fullClassName = getNormalizerFullClassName(className); + Class normalizerClass; + try { + normalizerClass = Class.forName(fullClassName); + } catch (ClassNotFoundException e) { + throw new ClassNotFoundException("Cannot find class "+fullClassName+": "+e.getMessage(), e); + } + defaultPolyStringNormalizer = (PolyStringNormalizer) normalizerClass.newInstance(); + } + + if (defaultPolyStringNormalizer instanceof ConfigurableNormalizer) { + ((ConfigurableNormalizer)defaultPolyStringNormalizer).configure(configuration); + } + } + + private String getNormalizerFullClassName(String shortClassName) { + if (shortClassName.contains(".")) { + return shortClassName; + } + return AlphanumericPolyStringNormalizer.class.getPackage().getName() + "." + shortClassName; + } + + public static boolean isAllowSchemalessSerialization() { + return allowSchemalessSerialization; + } + + public static void setAllowSchemalessSerialization(boolean allowSchemalessSerialization) { + PrismContextImpl.allowSchemalessSerialization = allowSchemalessSerialization; + } + + public static boolean isExtraValidation() { + return extraValidation; + } + + @Override + public XmlEntityResolver getEntityResolver() { + return schemaRegistry.getEntityResolver(); + } + + @NotNull + @Override + public SchemaRegistry getSchemaRegistry() { + return schemaRegistry; + } + + /** + * WARNING! This is not really public method. It should NOT not used outside the prism implementation. + */ + public PrismUnmarshaller getPrismUnmarshaller() { + return prismUnmarshaller; + } + + @NotNull + public PrismMarshaller getPrismMarshaller() { + return prismMarshaller; + } + + /** + * WARNING! This is not really public method. It should NOT not used outside the prism implementation. + */ + public DomLexicalProcessor getParserDom() { + return lexicalProcessorRegistry.domProcessor(); + } + + /** + * WARNING! This is not really public method. It should NOT not used outside the prism implementation. + */ + @NotNull + public BeanMarshaller getBeanMarshaller() { + return beanMarshaller; + } + + @NotNull + public BeanUnmarshaller getBeanUnmarshaller() { + return beanUnmarshaller; + } + + @NotNull + @Override + public JaxbDomHack getJaxbDomHack() { + return jaxbDomHack; + } + + @NotNull + public SchemaDefinitionFactory getDefinitionFactory() { + if (schemaDefinitionFactory == null) { + schemaDefinitionFactory = new SchemaDefinitionFactory(); + } + return schemaDefinitionFactory; + } + + public void setDefinitionFactory(SchemaDefinitionFactory schemaDefinitionFactory) { + this.schemaDefinitionFactory = schemaDefinitionFactory; + } + + @NotNull + @Override + public PolyStringNormalizer getDefaultPolyStringNormalizer() { + return defaultPolyStringNormalizer; + } + + private LexicalProcessor getParser(String language) { + return lexicalProcessorRegistry.processorFor(language); + } + + private LexicalProcessor getParserNotNull(String language) { + LexicalProcessor lexicalProcessor = getParser(language); + if (lexicalProcessor == null) { + throw new SystemException("No parser for language '"+language+"'"); + } + return lexicalProcessor; + } + + @Override + public Protector getDefaultProtector() { + return defaultProtector; + } + + public void setDefaultProtector(Protector defaultProtector) { + this.defaultProtector = defaultProtector; + } + + @NotNull + @Override + public QueryConverter getQueryConverter() { + return queryConverter; + } + + @Override + public PrismMonitor getMonitor() { + return monitor; + } + + @Override + public void setMonitor(PrismMonitor monitor) { + this.monitor = monitor; + } + + @Override + public QName getDefaultRelation() { + return defaultRelation; + } + + public void setDefaultRelation(QName defaultRelation) { + this.defaultRelation = defaultRelation; + } + + @Override + public QName getObjectsElementName() { + return objectsElementName; + } + + public void setObjectsElementName(QName objectsElementName) { + this.objectsElementName = objectsElementName; + } + + @Override + public QName getDefaultReferenceTypeName() { + return defaultReferenceTypeName; + } + + public void setDefaultReferenceTypeName(QName defaultReferenceTypeName) { + this.defaultReferenceTypeName = defaultReferenceTypeName; + } + + //endregion + + //region Parsing + @NotNull + @Override + public PrismParser parserFor(@NotNull File file) { + return new PrismParserImplIO(new ParserFileSource(file), null, getDefaultParsingContext(), this, null, null, null, null); + } + + @NotNull + @Override + public PrismParser parserFor(@NotNull InputStream stream) { + return new PrismParserImplIO(new ParserInputStreamSource(stream), null, getDefaultParsingContext(), this, null, null, null, null); + } + + @NotNull + @Override + public PrismParserNoIO parserFor(@NotNull String data) { + return new PrismParserImplNoIO(new ParserStringSource(data), null, getDefaultParsingContext(), this, null, null, null, null); + } + + @NotNull + @Override + public PrismParserNoIO parserFor(@NotNull RootXNode xnode) { + return new PrismParserImplNoIO(new ParserXNodeSource((RootXNodeImpl) xnode), null, getDefaultParsingContext(), this, null, null, null, null); + } + + @NotNull + @Deprecated + @Override + public PrismParserNoIO parserFor(@NotNull Element data) { + return new PrismParserImplNoIO(new ParserElementSource(data), null, getDefaultParsingContext(), this, null, null, null, null); + } + + @NotNull + @Override + public String detectLanguage(@NotNull File file) throws IOException { + return lexicalProcessorRegistry.detectLanguage(file); + } + + @Override + public ParsingMigrator getParsingMigrator() { + return parsingMigrator; + } + + @Override + public void setParsingMigrator(ParsingMigrator parsingMigrator) { + this.parsingMigrator = parsingMigrator; + } + //endregion + + //region adopt(...) methods + /** + * Set up the specified object with prism context instance and schema definition. + */ + @Override + public void adopt(PrismContainer container, Class declaredType) throws SchemaException { + container.revive(this); + getSchemaRegistry().applyDefinition(container, declaredType, false); + } + + @Override + public void adopt(PrismContainer container) throws SchemaException { + adopt(container, container.getCompileTimeClass()); + } + + @Override + public void adopt(Objectable objectable) throws SchemaException { + adopt(objectable.asPrismObject(), objectable.getClass()); + } + + @Override + public void adopt(Containerable containerable) throws SchemaException { + containerable.asPrismContainerValue().revive(this); + } + + @Override + public void adopt(PrismContainerValue value) throws SchemaException { + value.revive(this); + } + + @Override + public void adopt(ObjectDelta delta) throws SchemaException { + delta.revive(this); + getSchemaRegistry().applyDefinition(delta, delta.getObjectTypeClass(), false); + } + + @Override + public void adopt(C containerable, Class type, ItemPath path) throws SchemaException { + PrismContainerValue prismContainerValue = containerable.asPrismContainerValue(); + adopt(prismContainerValue, type, path); + } + + @Override + public void adopt(PrismContainerValue prismContainerValue, Class type, + ItemPath path) throws SchemaException { + prismContainerValue.revive(this); + getSchemaRegistry().applyDefinition(prismContainerValue, type, path, false); + } + + @Override + public void adopt(PrismContainerValue prismContainerValue, QName typeName, + ItemPath path) throws SchemaException { + prismContainerValue.revive(this); + getSchemaRegistry().applyDefinition(prismContainerValue, typeName, path, false); + } + //endregion + + //region Serializing objects, containers, atomic values (properties) + @Override + public String serializeObjectToString(PrismObject object, String language) throws SchemaException { + return serializerFor(language).serialize(object); + } + + @NotNull + @Override + public PrismSerializer serializerFor(@NotNull String language) { + return new PrismSerializerImpl<>(new SerializerStringTarget(this, language), null, null, null, this, null); + } + + @NotNull + @Override + public PrismSerializer xmlSerializer() { + return serializerFor(LANG_XML); + } + + @NotNull + @Override + public PrismSerializer jsonSerializer() { + return serializerFor(LANG_JSON); + } + + @NotNull + @Override + public PrismSerializer yamlSerializer() { + return serializerFor(LANG_YAML); + } + + @NotNull + @Override + public PrismSerializer domSerializer() { + return new PrismSerializerImpl<>(new SerializerDomTarget(this), null, null, null, this, null); + } + + @NotNull + @Override + public PrismSerializer xnodeSerializer() { + return new PrismSerializerImpl<>(new SerializerXNodeTarget(this), null, null, null, this, null); + } + + @Override + public boolean canSerialize(Object value) { + return prismMarshaller.canSerialize(value); + } + + //endregion + + @NotNull + @Override + public PrismObject createObject(@NotNull Class clazz) throws SchemaException { + PrismObjectDefinition definition = schemaRegistry.findObjectDefinitionByCompileTimeClass(clazz); + if (definition == null) { + throw new SchemaException("Definition for prism object holding " + clazz + " couldn't be found"); + } + return definition.instantiate(); + } + + @NotNull + @Override + public T createObjectable(@NotNull Class clazz) throws SchemaException { + return createObject(clazz).asObjectable(); + } + + @NotNull + @Override + public PrismObject createKnownObject(@NotNull Class clazz) { + try { + return createObject(clazz); + } catch (SchemaException e) { + throw new SystemException("Unexpected SchemaException while instantiating " + clazz + ": " + e.getMessage(), e); + } + } + + @NotNull + @Override + public O createKnownObjectable(@NotNull Class clazz) { + return createKnownObject(clazz).asObjectable(); + } + + @NotNull + public LexicalProcessorRegistry getLexicalProcessorRegistry() { + return lexicalProcessorRegistry; + } + + @Override + public boolean isDefaultRelation(QName relation) { + return relation == null || defaultRelation != null && QNameUtil.match(relation, defaultRelation); + } + + @Override + public boolean relationsEquivalent(QName relation1, QName relation2) { + if (isDefaultRelation(relation1)) { + return isDefaultRelation(relation2); + } else { + return QNameUtil.match(relation1, relation2); + } + } + + @Override + public boolean relationMatches(QName relationQuery, QName relation) { + return QNameUtil.match(relationQuery, PrismConstants.Q_ANY) || relationsEquivalent(relationQuery, relation); + } + + @Override + public boolean relationMatches(@NotNull List relationQuery, QName relation) { + return relationQuery.stream().anyMatch(rq -> relationMatches(rq, relation)); + } + + @Override + public ParsingContext getDefaultParsingContext() { + return ParsingContextImpl.createDefault(); + } + + @Override + public ParsingContext createParsingContextForAllowMissingRefTypes() { + return ParsingContextImpl.allowMissingRefTypes(); + } + + @Override + public ParsingContext createParsingContextForCompatibilityMode() { + return ParsingContextImpl.createForCompatibilityMode(); + } + + @Override + public UniformItemPath emptyPath() { + return UniformItemPathImpl.EMPTY_PATH; + } + + @Override + public UniformItemPath path(Object... namesOrIdsOrSegments) { + return new UniformItemPathImpl(namesOrIdsOrSegments); + } + + @Override + public Hacks hacks() { + return hacks; + } + + @Override + public XNodeFactory xnodeFactory() { + return xnodeFactory; + } + + @Override + public XNodeMutator xnodeMutator() { + return hacks; + } + + @Override + public KeyStoreBasedProtector createInitializedProtector(KeyStoreBasedProtectorBuilder builder) { + KeyStoreBasedProtectorImpl protector = new KeyStoreBasedProtectorImpl(builder); + protector.init(); + return protector; + } + + @Override + public KeyStoreBasedProtector createProtector(KeyStoreBasedProtectorBuilder builder) { + return new KeyStoreBasedProtectorImpl(builder); + } + + @NotNull + @Override + public UniformItemPath toUniformPath(ItemPath path) { + return UniformItemPathImpl.fromItemPath(path); + } + + @Override + public UniformItemPath toUniformPathKeepNull(ItemPath path) { + return path != null ? UniformItemPathImpl.fromItemPath(path) : null; + } + + @Override + public UniformItemPath toUniformPath(ItemPathType path) { + return UniformItemPathImpl.fromItemPath(path.getItemPath()); + } + + @Override + public CanonicalItemPath createCanonicalItemPath(ItemPath itemPath, Class clazz) { + return new CanonicalItemPathImpl(itemPath, clazz, this); + } + + @Override + public CanonicalItemPath createCanonicalItemPath(ItemPath itemPath) { + return new CanonicalItemPathImpl(itemPath, null, null); + } + + @Override + public S_ItemEntry deltaFor(Class objectClass) throws SchemaException { + return new DeltaBuilder<>(objectClass, this); + } + + @Override + public S_FilterEntryOrEmpty queryFor(Class queryClass) { + return QueryBuilder.queryFor(queryClass, this); + } + + @Override + @NotNull + public DeltaFactory deltaFactory() { + return deltaFactory; + } + + @NotNull + @Override + public QueryFactory queryFactory() { + return queryFactory; + } + + @NotNull + @Override + public ItemFactory itemFactory() { + return itemFactory; + } + + @NotNull + @Override + public DefinitionFactory definitionFactory() { + return definitionFactory; + } + + @NotNull + @Override + public ItemPathParser itemPathParser() { + return itemPathParser; + } + + // This is instance method to allow calling it via PrismContext interface + @Override + public void setExtraValidation(boolean value) { + PrismContextImpl.extraValidation = value; + } + + @NotNull + @Override + public SchemaFactory schemaFactory() { + return schemaFactory; + } +} diff --git a/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/marshaller/ItemPathHolder.java b/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/marshaller/ItemPathHolder.java index c0922e00a2e..669b27fc363 100644 --- a/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/marshaller/ItemPathHolder.java +++ b/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/marshaller/ItemPathHolder.java @@ -1,562 +1,562 @@ -/* - * Copyright (c) 2010-2020 Evolveum and contributors - * - * This work is dual-licensed under the Apache License 2.0 - * and European Union Public License. See LICENSE file for details. - */ - -package com.evolveum.midpoint.prism.impl.marshaller; - -import com.evolveum.midpoint.prism.PrismConstants; -import com.evolveum.midpoint.prism.impl.path.UniformItemPathImpl; -import com.evolveum.midpoint.prism.path.*; -import com.evolveum.midpoint.prism.impl.xml.GlobalDynamicNamespacePrefixMapper; -import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.QNameUtil; -import com.evolveum.midpoint.util.exception.SystemException; -import org.apache.commons.lang.StringUtils; -import org.jetbrains.annotations.NotNull; -import org.w3c.dom.DOMException; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -import javax.xml.namespace.QName; -import java.util.*; -import java.util.Map.Entry; - -/** - * Holds internal (parsed) form of midPoint-style XPath-like expressions. - * It is able to retrieve/export these expressions from/to various forms (text, text in XML document, - * XPathSegment list, prism path specification). - * - * Assumes relative XPath, but somehow can also work with absolute XPaths. - * - * NOT to be used outside prism module (except for XPathTest in schema - but this is also to be resolved). - * - * @author semancik - * @author mederly - */ -public final class ItemPathHolder { - -// private static final Trace LOGGER = TraceManager.getTrace(ItemPathHolder.class); -// public static final String DEFAULT_PREFIX = "c"; - private boolean absolute; - private List segments; - private final Map explicitNamespaceDeclarations = new HashMap<>(); - - //region Parsing - - public static UniformItemPath parseFromString(String path) { - return new ItemPathHolder(path).toItemPath(); - } - - public static UniformItemPath parseFromString(String path, Map namespaces) { - return new ItemPathHolder(path, namespaces).toItemPath(); - } - - public static UniformItemPath parseFromElement(Element element) { - return new ItemPathHolder(element).toItemPath(); - } - - private ItemPathHolder() { - } - - private ItemPathHolder(String xpath) { - parse(xpath, null, null); - } - - private ItemPathHolder(String path, Map namespaces) { - parse(path, null, namespaces); - } - - private ItemPathHolder(Element domElement) { - String xpath = "."; - if (domElement != null) { - xpath = domElement.getTextContent(); - } - parse(xpath, domElement, null); - } - - /** - * Parses XPath-like expression (midPoint flavour), with regards to domNode from where the namespace declarations - * (embedded in XML using xmlns attributes) are taken. - * - * @param itemPath text representation of the item path - * @param domNode context (DOM node from which the expression was taken) - * @param namespaceMap externally specified namespaces - */ - private void parse(String itemPath, Node domNode, Map namespaceMap) { - - segments = new ArrayList<>(); - absolute = false; - - if (".".equals(itemPath)) { - return; - } - - // Check for explicit namespace declarations. - TrivialItemPathParser parser = TrivialItemPathParser.parse(itemPath); - explicitNamespaceDeclarations.putAll(parser.getNamespaceMap()); - - // Continue parsing with Xpath without the "preamble" - itemPath = parser.getPureItemPathString(); - - String[] segArray = itemPath.split("/"); - for (int i = 0; i < segArray.length; i++) { - if (segArray[i] == null || segArray[i].isEmpty()) { - if (i == 0) { - absolute = true; - // ignore the first empty segment of absolute path - continue; - } else { - throw new IllegalArgumentException("ItemPath " + itemPath + " has an empty segment (number " + i + ")"); - } - } - - String segmentStr = segArray[i]; - PathHolderSegment idValueFilterSegment; - - // is ID value filter attached to this segment? - int idValuePosition = segmentStr.indexOf('['); - if (idValuePosition >= 0) { - if (!segmentStr.endsWith("]")) { - throw new IllegalArgumentException("ItemPath " + itemPath + " has a ID segment not ending with ']': '" + segmentStr + "'"); - } - String value = segmentStr.substring(idValuePosition+1, segmentStr.length()-1); - segmentStr = segmentStr.substring(0, idValuePosition); - idValueFilterSegment = new PathHolderSegment(value); - } else { - idValueFilterSegment = null; - } - - // processing the rest (i.e. the first part) of the segment - - boolean variable = false; - if (segmentStr.startsWith("$")) { - // We have variable here - variable = true; - segmentStr = segmentStr.substring(1); - } - - String[] qnameArray = segmentStr.split(":"); - if (qnameArray.length > 2) { - throw new IllegalArgumentException("Unsupported format: more than one colon in XPath segment: " - + segArray[i]); - } - QName qname; - if (qnameArray.length == 1 || qnameArray[1] == null || qnameArray[1].isEmpty()) { - if (ParentPathSegment.SYMBOL.equals(qnameArray[0])) { - qname = ParentPathSegment.QNAME; - } else if (ObjectReferencePathSegment.SYMBOL.equals(qnameArray[0])) { - qname = ObjectReferencePathSegment.QNAME; - } else if (IdentifierPathSegment.SYMBOL.equals(qnameArray[0])) { - qname = IdentifierPathSegment.QNAME; - } else { - // default namespace <= empty prefix - String namespace = findNamespace(null, domNode, namespaceMap); - qname = new QName(namespace, qnameArray[0]); - } - } else { - String namespacePrefix = qnameArray[0]; - String namespace = findNamespace(namespacePrefix, domNode, namespaceMap); - if (namespace == null) { - QNameUtil.reportUndeclaredNamespacePrefix(namespacePrefix, itemPath); - namespacePrefix = QNameUtil.markPrefixAsUndeclared(namespacePrefix); - } - qname = new QName(namespace, qnameArray[1], namespacePrefix); - } - segments.add(new PathHolderSegment(qname, variable)); - if (idValueFilterSegment != null) { - segments.add(idValueFilterSegment); - } - } - } - - private String findNamespace(String prefix, Node domNode, Map namespaceMap) { - - String ns = null; - - if (explicitNamespaceDeclarations != null) { - if (prefix == null) { - ns = explicitNamespaceDeclarations.get(""); - } else { - ns = explicitNamespaceDeclarations.get(prefix); - } - if (ns != null) { - return ns; - } - } - - if (namespaceMap != null) { - if (prefix == null) { - ns = namespaceMap.get(""); - } else { - ns = namespaceMap.get(prefix); - } - if (ns != null) { - return ns; - } - } - - if (domNode != null) { - if (StringUtils.isNotEmpty(prefix)) { - ns = domNode.lookupNamespaceURI(prefix); - } else { - // we don't want the default namespace declaration (xmlns="...") to propagate into path expressions - // so here we do not try to obtain the namespace from the document - } - if (ns != null) { - return ns; - } - } - - return ns; - } - //endregion - - //region Serializing - - public static String serializeWithDeclarations(@NotNull ItemPath itemPath) { - return new ItemPathHolder(UniformItemPathImpl.fromItemPath(itemPath)).getXPathWithDeclarations(); - } - - public static String serializeWithForcedDeclarations(@NotNull ItemPath itemPath) { - return new ItemPathHolder(UniformItemPathImpl.fromItemPath(itemPath), true).getXPathWithDeclarations(); - } - - private ItemPathHolder(@NotNull UniformItemPath itemPath) { - this(itemPath, false); - } - - private ItemPathHolder(@NotNull UniformItemPath itemPath, boolean forceExplicitNamespaceDeclarations) { - if (itemPath.getNamespaceMap() != null) { - this.explicitNamespaceDeclarations.putAll(itemPath.getNamespaceMap()); - } - this.segments = new ArrayList<>(); - for (ItemPathSegment segment: itemPath.getSegments()) { - PathHolderSegment xsegment; - if (segment instanceof NameItemPathSegment) { - QName name = ((NameItemPathSegment) segment).getName(); - xsegment = new PathHolderSegment(name); - if (forceExplicitNamespaceDeclarations && StringUtils.isNotEmpty(name.getPrefix())) { - this.explicitNamespaceDeclarations.put(name.getPrefix(), name.getNamespaceURI()); - } - } else if (segment instanceof VariableItemPathSegment) { - QName name = ((VariableItemPathSegment) segment).getName(); - xsegment = new PathHolderSegment(name, true); - if (forceExplicitNamespaceDeclarations && StringUtils.isNotEmpty(name.getPrefix())) { - this.explicitNamespaceDeclarations.put(name.getPrefix(), name.getNamespaceURI()); - } - } else if (segment instanceof IdItemPathSegment) { - xsegment = new PathHolderSegment(idToString(((IdItemPathSegment) segment).getId())); - } else if (segment instanceof ObjectReferencePathSegment) { - xsegment = new PathHolderSegment(PrismConstants.T_OBJECT_REFERENCE, false); - } else if (segment instanceof ParentPathSegment) { - xsegment = new PathHolderSegment(PrismConstants.T_PARENT, false); - } else if (segment instanceof IdentifierPathSegment) { - xsegment = new PathHolderSegment(PrismConstants.T_ID, false); - } else { - throw new IllegalStateException("Unknown segment: " + segment); - } - this.segments.add(xsegment); - } - this.absolute = false; - } - - public String getXPathWithoutDeclarations() { - StringBuilder sb = new StringBuilder(); - addPureXpath(sb); - return sb.toString(); - } - - public String getXPathWithDeclarations() { - StringBuilder sb = new StringBuilder(); - addExplicitNsDeclarations(sb); - addPureXpath(sb); - return sb.toString(); - } - - private void addPureXpath(StringBuilder sb) { - if (!absolute && segments.isEmpty()) { - // Empty segment list gives a "local node" XPath - sb.append("."); - return; - } - - if (absolute) { - sb.append("/"); - } - - boolean first = true; - - for (PathHolderSegment seg : segments) { - - if (seg.isIdValueFilter()) { - - sb.append("["); - sb.append(seg.getValue()); - sb.append("]"); - - } else { - - if (!first) { - sb.append("/"); - } else { - first = false; - } - - if (seg.isVariable()) { - sb.append("$"); - } - QName qname = seg.getQName(); - - if (ObjectReferencePathSegment.QNAME.equals(qname)) { - sb.append(ObjectReferencePathSegment.SYMBOL); - } else if (ParentPathSegment.QNAME.equals(qname)) { - sb.append(ParentPathSegment.SYMBOL); - } else if (IdentifierPathSegment.QNAME.equals(qname)) { - sb.append(IdentifierPathSegment.SYMBOL); - } else if (!StringUtils.isEmpty(qname.getPrefix())) { - sb.append(qname.getPrefix()).append(':').append(qname.getLocalPart()); - } else { - if (StringUtils.isNotEmpty(qname.getNamespaceURI())) { - String prefix = GlobalDynamicNamespacePrefixMapper.getPreferredPrefix(qname.getNamespaceURI()); - seg.setQNamePrefix(prefix); // hack - we modify the path segment here (only the form, not the meaning), but nevertheless it's ugly - sb.append(seg.getQName().getPrefix()).append(':').append(seg.getQName().getLocalPart()); - } else { - // no namespace, no prefix - sb.append(qname.getLocalPart()); - } - } - } - } - } - -// public String toCanonicalPath(Class objectType, PrismContext prismContext) { -// StringBuilder sb = new StringBuilder("\\"); -// -// boolean first = true; -// -// PrismObjectDefinition objDef = null; -// if (objectType != null) { -// objDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(objectType); -// } -// ItemDefinition def = null; -// for (PathHolderSegment seg : segments) { -// -// if (seg.isIdValueFilter()) { -// //for now, we don't want to save concrete id, just the path -// continue; -// -// } else { -// -// QName qname = seg.getQName(); -// -// if (!first) { -// sb.append("\\"); -// if (StringUtils.isBlank(qname.getNamespaceURI()) && objDef != null) { -// if (def instanceof PrismContainerDefinition) { -// PrismContainerDefinition containerDef = (PrismContainerDefinition) def; -// def = containerDef.findItemDefinition(ItemName.fromQName(qname)); -// } -// -// if (def != null) { -// qname = def.getName(); -// } -// } -// } else { -// if (StringUtils.isBlank(qname.getNamespaceURI()) && objDef != null) { -// def = objDef.findItemDefinition(ItemName.fromQName(qname)); -// if (def != null) { -// qname = def.getName(); -// } -// } -// first = false; -// } -// -// -// -// sb.append(QNameUtil.qNameToUri(qname)); -// } -// } -// -// return sb.toString(); -// } - - public Map getNamespaceMap() { - Map namespaceMap = new HashMap<>(); - for (PathHolderSegment seg : segments) { - QName qname = seg.getQName(); - if (qname != null) { - if (qname.getPrefix() != null && !qname.getPrefix().isEmpty()) { - namespaceMap.put(qname.getPrefix(), qname.getNamespaceURI()); - } - } - } - return namespaceMap; - } - - public static Element serializeToElement(ItemPath path, QName elementQName, Document document) { - return new ItemPathHolder(UniformItemPathImpl.fromItemPath(path)).toElement(elementQName, document); - } - - public Element toElement(QName elementQName, Document document) { - return toElement(elementQName.getNamespaceURI(), elementQName.getLocalPart(), document); - } - - // really ugly implementation... (ignores overall context of serialization, so produces elements even if common is default namespace) TODO rework [med] - public Element toElement(String elementNamespace, String localElementName, Document document) { - Element element = document.createElementNS(elementNamespace, localElementName); - if (!StringUtils.isBlank(elementNamespace)) { - String prefix = GlobalDynamicNamespacePrefixMapper.getPreferredPrefix(elementNamespace); - if (!StringUtils.isBlank(prefix)) { - try { - element.setPrefix(prefix); - } catch (DOMException e) { - throw new SystemException("Error setting XML prefix '"+prefix+"' to element {"+elementNamespace+"}"+localElementName+": "+e.getMessage(), e); - } - } - } - element.setTextContent(getXPathWithDeclarations()); - Map namespaceMap = getNamespaceMap(); - if (namespaceMap != null) { - for (Entry entry : namespaceMap.entrySet()) { - DOMUtil.setNamespaceDeclaration(element, entry.getKey(), entry.getValue()); - } - } - return element; - } - - public List toSegments() { - // FIXME !!! - return Collections.unmodifiableList(segments); - } - - @NotNull - public UniformItemPath toItemPath() { - List xsegments = toSegments(); - List segments = new ArrayList<>(xsegments.size()); - for (PathHolderSegment segment : xsegments) { - if (segment.isIdValueFilter()) { - segments.add(new IdItemPathSegment(idToLong(segment.getValue()))); - } else { - QName qName = segment.getQName(); - boolean variable = segment.isVariable(); - segments.add(UniformItemPathImpl.createSegment(qName, variable)); - } - } - UniformItemPath path = new UniformItemPathImpl(segments); - path.setNamespaceMap(explicitNamespaceDeclarations); - return path; - } - //endregion - - //region Misc - - private void addExplicitNsDeclarations(StringBuilder sb) { - for (Entry declaration : explicitNamespaceDeclarations.entrySet()) { - sb.append("declare "); - String prefix = declaration.getKey(); - String value = declaration.getValue(); - if (prefix.equals("")) { - sb.append("default namespace '"); - sb.append(value); - sb.append("'; "); - } else { - sb.append("namespace "); - sb.append(prefix); - sb.append("='"); - sb.append(value); - sb.append("'; "); - } - } - } - - public boolean isEmpty() { - return segments.isEmpty(); - } - - @Override - public String toString() { - // TODO: more verbose toString later - return getXPathWithDeclarations(); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (absolute ? 1231 : 1237); - result = prime * result + ((segments == null) ? 0 : segments.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null) return false; - - // Special case - if (obj instanceof QName) { - if (segments.size() != 1) { - return false; - } - PathHolderSegment segment = segments.get(0); - return segment.getQName().equals(obj); - } - - if (getClass() != obj.getClass()) return false; - ItemPathHolder other = (ItemPathHolder) obj; - if (absolute != other.absolute) return false; - if (segments == null) { - if (other.segments != null) return false; - } else if (!segments.equals(other.segments)) { - return false; - } - return true; - } - - private Long idToLong(String stringVal) { - if (stringVal == null) { - return null; - } - return Long.valueOf(stringVal); - } - - private String idToString(Long longVal) { - if (longVal == null) { - return null; - } - return longVal.toString(); - } - //endregion - - //region Methods for testing - public static ItemPathHolder createForTesting(String xpath) { - return new ItemPathHolder(xpath); - } - - public static ItemPathHolder createForTesting(String xpath, Map namespaceMap) { - ItemPathHolder rv = new ItemPathHolder(); - rv.parse(xpath, null, namespaceMap); - return rv; - } - - public static ItemPathHolder createForTesting(Element element) { - return new ItemPathHolder(element); - } - - public static ItemPathHolder createForTesting(QName... segmentQNames) { - ItemPathHolder rv = new ItemPathHolder(); - rv.segments = new ArrayList<>(); - for (QName segmentQName : segmentQNames) { - PathHolderSegment segment = new PathHolderSegment(segmentQName); - rv.segments.add(segment); - } - rv.absolute = false; - return rv; - } - - //endregion -} +/* + * Copyright (c) 2010-2020 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ + +package com.evolveum.midpoint.prism.impl.marshaller; + +import com.evolveum.midpoint.prism.PrismConstants; +import com.evolveum.midpoint.prism.path.UniformItemPathImpl; +import com.evolveum.midpoint.prism.path.*; +import com.evolveum.midpoint.prism.impl.xml.GlobalDynamicNamespacePrefixMapper; +import com.evolveum.midpoint.util.DOMUtil; +import com.evolveum.midpoint.util.QNameUtil; +import com.evolveum.midpoint.util.exception.SystemException; +import org.apache.commons.lang.StringUtils; +import org.jetbrains.annotations.NotNull; +import org.w3c.dom.DOMException; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; + +import javax.xml.namespace.QName; +import java.util.*; +import java.util.Map.Entry; + +/** + * Holds internal (parsed) form of midPoint-style XPath-like expressions. + * It is able to retrieve/export these expressions from/to various forms (text, text in XML document, + * XPathSegment list, prism path specification). + * + * Assumes relative XPath, but somehow can also work with absolute XPaths. + * + * NOT to be used outside prism module (except for XPathTest in schema - but this is also to be resolved). + * + * @author semancik + * @author mederly + */ +public final class ItemPathHolder { + +// private static final Trace LOGGER = TraceManager.getTrace(ItemPathHolder.class); +// public static final String DEFAULT_PREFIX = "c"; + private boolean absolute; + private List segments; + private final Map explicitNamespaceDeclarations = new HashMap<>(); + + //region Parsing + + public static UniformItemPath parseFromString(String path) { + return new ItemPathHolder(path).toItemPath(); + } + + public static UniformItemPath parseFromString(String path, Map namespaces) { + return new ItemPathHolder(path, namespaces).toItemPath(); + } + + public static UniformItemPath parseFromElement(Element element) { + return new ItemPathHolder(element).toItemPath(); + } + + private ItemPathHolder() { + } + + private ItemPathHolder(String xpath) { + parse(xpath, null, null); + } + + private ItemPathHolder(String path, Map namespaces) { + parse(path, null, namespaces); + } + + private ItemPathHolder(Element domElement) { + String xpath = "."; + if (domElement != null) { + xpath = domElement.getTextContent(); + } + parse(xpath, domElement, null); + } + + /** + * Parses XPath-like expression (midPoint flavour), with regards to domNode from where the namespace declarations + * (embedded in XML using xmlns attributes) are taken. + * + * @param itemPath text representation of the item path + * @param domNode context (DOM node from which the expression was taken) + * @param namespaceMap externally specified namespaces + */ + private void parse(String itemPath, Node domNode, Map namespaceMap) { + + segments = new ArrayList<>(); + absolute = false; + + if (".".equals(itemPath)) { + return; + } + + // Check for explicit namespace declarations. + TrivialItemPathParser parser = TrivialItemPathParser.parse(itemPath); + explicitNamespaceDeclarations.putAll(parser.getNamespaceMap()); + + // Continue parsing with Xpath without the "preamble" + itemPath = parser.getPureItemPathString(); + + String[] segArray = itemPath.split("/"); + for (int i = 0; i < segArray.length; i++) { + if (segArray[i] == null || segArray[i].isEmpty()) { + if (i == 0) { + absolute = true; + // ignore the first empty segment of absolute path + continue; + } else { + throw new IllegalArgumentException("ItemPath " + itemPath + " has an empty segment (number " + i + ")"); + } + } + + String segmentStr = segArray[i]; + PathHolderSegment idValueFilterSegment; + + // is ID value filter attached to this segment? + int idValuePosition = segmentStr.indexOf('['); + if (idValuePosition >= 0) { + if (!segmentStr.endsWith("]")) { + throw new IllegalArgumentException("ItemPath " + itemPath + " has a ID segment not ending with ']': '" + segmentStr + "'"); + } + String value = segmentStr.substring(idValuePosition+1, segmentStr.length()-1); + segmentStr = segmentStr.substring(0, idValuePosition); + idValueFilterSegment = new PathHolderSegment(value); + } else { + idValueFilterSegment = null; + } + + // processing the rest (i.e. the first part) of the segment + + boolean variable = false; + if (segmentStr.startsWith("$")) { + // We have variable here + variable = true; + segmentStr = segmentStr.substring(1); + } + + String[] qnameArray = segmentStr.split(":"); + if (qnameArray.length > 2) { + throw new IllegalArgumentException("Unsupported format: more than one colon in XPath segment: " + + segArray[i]); + } + QName qname; + if (qnameArray.length == 1 || qnameArray[1] == null || qnameArray[1].isEmpty()) { + if (ParentPathSegment.SYMBOL.equals(qnameArray[0])) { + qname = ParentPathSegment.QNAME; + } else if (ObjectReferencePathSegment.SYMBOL.equals(qnameArray[0])) { + qname = ObjectReferencePathSegment.QNAME; + } else if (IdentifierPathSegment.SYMBOL.equals(qnameArray[0])) { + qname = IdentifierPathSegment.QNAME; + } else { + // default namespace <= empty prefix + String namespace = findNamespace(null, domNode, namespaceMap); + qname = new QName(namespace, qnameArray[0]); + } + } else { + String namespacePrefix = qnameArray[0]; + String namespace = findNamespace(namespacePrefix, domNode, namespaceMap); + if (namespace == null) { + QNameUtil.reportUndeclaredNamespacePrefix(namespacePrefix, itemPath); + namespacePrefix = QNameUtil.markPrefixAsUndeclared(namespacePrefix); + } + qname = new QName(namespace, qnameArray[1], namespacePrefix); + } + segments.add(new PathHolderSegment(qname, variable)); + if (idValueFilterSegment != null) { + segments.add(idValueFilterSegment); + } + } + } + + private String findNamespace(String prefix, Node domNode, Map namespaceMap) { + + String ns = null; + + if (explicitNamespaceDeclarations != null) { + if (prefix == null) { + ns = explicitNamespaceDeclarations.get(""); + } else { + ns = explicitNamespaceDeclarations.get(prefix); + } + if (ns != null) { + return ns; + } + } + + if (namespaceMap != null) { + if (prefix == null) { + ns = namespaceMap.get(""); + } else { + ns = namespaceMap.get(prefix); + } + if (ns != null) { + return ns; + } + } + + if (domNode != null) { + if (StringUtils.isNotEmpty(prefix)) { + ns = domNode.lookupNamespaceURI(prefix); + } else { + // we don't want the default namespace declaration (xmlns="...") to propagate into path expressions + // so here we do not try to obtain the namespace from the document + } + if (ns != null) { + return ns; + } + } + + return ns; + } + //endregion + + //region Serializing + + public static String serializeWithDeclarations(@NotNull ItemPath itemPath) { + return new ItemPathHolder(UniformItemPathImpl.fromItemPath(itemPath)).getXPathWithDeclarations(); + } + + public static String serializeWithForcedDeclarations(@NotNull ItemPath itemPath) { + return new ItemPathHolder(UniformItemPathImpl.fromItemPath(itemPath), true).getXPathWithDeclarations(); + } + + private ItemPathHolder(@NotNull UniformItemPath itemPath) { + this(itemPath, false); + } + + private ItemPathHolder(@NotNull UniformItemPath itemPath, boolean forceExplicitNamespaceDeclarations) { + if (itemPath.getNamespaceMap() != null) { + this.explicitNamespaceDeclarations.putAll(itemPath.getNamespaceMap()); + } + this.segments = new ArrayList<>(); + for (ItemPathSegment segment: itemPath.getSegments()) { + PathHolderSegment xsegment; + if (segment instanceof NameItemPathSegment) { + QName name = ((NameItemPathSegment) segment).getName(); + xsegment = new PathHolderSegment(name); + if (forceExplicitNamespaceDeclarations && StringUtils.isNotEmpty(name.getPrefix())) { + this.explicitNamespaceDeclarations.put(name.getPrefix(), name.getNamespaceURI()); + } + } else if (segment instanceof VariableItemPathSegment) { + QName name = ((VariableItemPathSegment) segment).getName(); + xsegment = new PathHolderSegment(name, true); + if (forceExplicitNamespaceDeclarations && StringUtils.isNotEmpty(name.getPrefix())) { + this.explicitNamespaceDeclarations.put(name.getPrefix(), name.getNamespaceURI()); + } + } else if (segment instanceof IdItemPathSegment) { + xsegment = new PathHolderSegment(idToString(((IdItemPathSegment) segment).getId())); + } else if (segment instanceof ObjectReferencePathSegment) { + xsegment = new PathHolderSegment(PrismConstants.T_OBJECT_REFERENCE, false); + } else if (segment instanceof ParentPathSegment) { + xsegment = new PathHolderSegment(PrismConstants.T_PARENT, false); + } else if (segment instanceof IdentifierPathSegment) { + xsegment = new PathHolderSegment(PrismConstants.T_ID, false); + } else { + throw new IllegalStateException("Unknown segment: " + segment); + } + this.segments.add(xsegment); + } + this.absolute = false; + } + + public String getXPathWithoutDeclarations() { + StringBuilder sb = new StringBuilder(); + addPureXpath(sb); + return sb.toString(); + } + + public String getXPathWithDeclarations() { + StringBuilder sb = new StringBuilder(); + addExplicitNsDeclarations(sb); + addPureXpath(sb); + return sb.toString(); + } + + private void addPureXpath(StringBuilder sb) { + if (!absolute && segments.isEmpty()) { + // Empty segment list gives a "local node" XPath + sb.append("."); + return; + } + + if (absolute) { + sb.append("/"); + } + + boolean first = true; + + for (PathHolderSegment seg : segments) { + + if (seg.isIdValueFilter()) { + + sb.append("["); + sb.append(seg.getValue()); + sb.append("]"); + + } else { + + if (!first) { + sb.append("/"); + } else { + first = false; + } + + if (seg.isVariable()) { + sb.append("$"); + } + QName qname = seg.getQName(); + + if (ObjectReferencePathSegment.QNAME.equals(qname)) { + sb.append(ObjectReferencePathSegment.SYMBOL); + } else if (ParentPathSegment.QNAME.equals(qname)) { + sb.append(ParentPathSegment.SYMBOL); + } else if (IdentifierPathSegment.QNAME.equals(qname)) { + sb.append(IdentifierPathSegment.SYMBOL); + } else if (!StringUtils.isEmpty(qname.getPrefix())) { + sb.append(qname.getPrefix()).append(':').append(qname.getLocalPart()); + } else { + if (StringUtils.isNotEmpty(qname.getNamespaceURI())) { + String prefix = GlobalDynamicNamespacePrefixMapper.getPreferredPrefix(qname.getNamespaceURI()); + seg.setQNamePrefix(prefix); // hack - we modify the path segment here (only the form, not the meaning), but nevertheless it's ugly + sb.append(seg.getQName().getPrefix()).append(':').append(seg.getQName().getLocalPart()); + } else { + // no namespace, no prefix + sb.append(qname.getLocalPart()); + } + } + } + } + } + +// public String toCanonicalPath(Class objectType, PrismContext prismContext) { +// StringBuilder sb = new StringBuilder("\\"); +// +// boolean first = true; +// +// PrismObjectDefinition objDef = null; +// if (objectType != null) { +// objDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(objectType); +// } +// ItemDefinition def = null; +// for (PathHolderSegment seg : segments) { +// +// if (seg.isIdValueFilter()) { +// //for now, we don't want to save concrete id, just the path +// continue; +// +// } else { +// +// QName qname = seg.getQName(); +// +// if (!first) { +// sb.append("\\"); +// if (StringUtils.isBlank(qname.getNamespaceURI()) && objDef != null) { +// if (def instanceof PrismContainerDefinition) { +// PrismContainerDefinition containerDef = (PrismContainerDefinition) def; +// def = containerDef.findItemDefinition(ItemName.fromQName(qname)); +// } +// +// if (def != null) { +// qname = def.getName(); +// } +// } +// } else { +// if (StringUtils.isBlank(qname.getNamespaceURI()) && objDef != null) { +// def = objDef.findItemDefinition(ItemName.fromQName(qname)); +// if (def != null) { +// qname = def.getName(); +// } +// } +// first = false; +// } +// +// +// +// sb.append(QNameUtil.qNameToUri(qname)); +// } +// } +// +// return sb.toString(); +// } + + public Map getNamespaceMap() { + Map namespaceMap = new HashMap<>(); + for (PathHolderSegment seg : segments) { + QName qname = seg.getQName(); + if (qname != null) { + if (qname.getPrefix() != null && !qname.getPrefix().isEmpty()) { + namespaceMap.put(qname.getPrefix(), qname.getNamespaceURI()); + } + } + } + return namespaceMap; + } + + public static Element serializeToElement(ItemPath path, QName elementQName, Document document) { + return new ItemPathHolder(UniformItemPathImpl.fromItemPath(path)).toElement(elementQName, document); + } + + public Element toElement(QName elementQName, Document document) { + return toElement(elementQName.getNamespaceURI(), elementQName.getLocalPart(), document); + } + + // really ugly implementation... (ignores overall context of serialization, so produces elements even if common is default namespace) TODO rework [med] + public Element toElement(String elementNamespace, String localElementName, Document document) { + Element element = document.createElementNS(elementNamespace, localElementName); + if (!StringUtils.isBlank(elementNamespace)) { + String prefix = GlobalDynamicNamespacePrefixMapper.getPreferredPrefix(elementNamespace); + if (!StringUtils.isBlank(prefix)) { + try { + element.setPrefix(prefix); + } catch (DOMException e) { + throw new SystemException("Error setting XML prefix '"+prefix+"' to element {"+elementNamespace+"}"+localElementName+": "+e.getMessage(), e); + } + } + } + element.setTextContent(getXPathWithDeclarations()); + Map namespaceMap = getNamespaceMap(); + if (namespaceMap != null) { + for (Entry entry : namespaceMap.entrySet()) { + DOMUtil.setNamespaceDeclaration(element, entry.getKey(), entry.getValue()); + } + } + return element; + } + + public List toSegments() { + // FIXME !!! + return Collections.unmodifiableList(segments); + } + + @NotNull + public UniformItemPath toItemPath() { + List xsegments = toSegments(); + List segments = new ArrayList<>(xsegments.size()); + for (PathHolderSegment segment : xsegments) { + if (segment.isIdValueFilter()) { + segments.add(new IdItemPathSegment(idToLong(segment.getValue()))); + } else { + QName qName = segment.getQName(); + boolean variable = segment.isVariable(); + segments.add(UniformItemPathImpl.createSegment(qName, variable)); + } + } + UniformItemPath path = new UniformItemPathImpl(segments); + path.setNamespaceMap(explicitNamespaceDeclarations); + return path; + } + //endregion + + //region Misc + + private void addExplicitNsDeclarations(StringBuilder sb) { + for (Entry declaration : explicitNamespaceDeclarations.entrySet()) { + sb.append("declare "); + String prefix = declaration.getKey(); + String value = declaration.getValue(); + if (prefix.equals("")) { + sb.append("default namespace '"); + sb.append(value); + sb.append("'; "); + } else { + sb.append("namespace "); + sb.append(prefix); + sb.append("='"); + sb.append(value); + sb.append("'; "); + } + } + } + + public boolean isEmpty() { + return segments.isEmpty(); + } + + @Override + public String toString() { + // TODO: more verbose toString later + return getXPathWithDeclarations(); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (absolute ? 1231 : 1237); + result = prime * result + ((segments == null) ? 0 : segments.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + // Special case + if (obj instanceof QName) { + if (segments.size() != 1) { + return false; + } + PathHolderSegment segment = segments.get(0); + return segment.getQName().equals(obj); + } + + if (getClass() != obj.getClass()) return false; + ItemPathHolder other = (ItemPathHolder) obj; + if (absolute != other.absolute) return false; + if (segments == null) { + if (other.segments != null) return false; + } else if (!segments.equals(other.segments)) { + return false; + } + return true; + } + + private Long idToLong(String stringVal) { + if (stringVal == null) { + return null; + } + return Long.valueOf(stringVal); + } + + private String idToString(Long longVal) { + if (longVal == null) { + return null; + } + return longVal.toString(); + } + //endregion + + //region Methods for testing + public static ItemPathHolder createForTesting(String xpath) { + return new ItemPathHolder(xpath); + } + + public static ItemPathHolder createForTesting(String xpath, Map namespaceMap) { + ItemPathHolder rv = new ItemPathHolder(); + rv.parse(xpath, null, namespaceMap); + return rv; + } + + public static ItemPathHolder createForTesting(Element element) { + return new ItemPathHolder(element); + } + + public static ItemPathHolder createForTesting(QName... segmentQNames) { + ItemPathHolder rv = new ItemPathHolder(); + rv.segments = new ArrayList<>(); + for (QName segmentQName : segmentQNames) { + PathHolderSegment segment = new PathHolderSegment(segmentQName); + rv.segments.add(segment); + } + rv.absolute = false; + return rv; + } + + //endregion +} diff --git a/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd b/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd index 9860e246322..253c9e8ecb2 100755 --- a/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd +++ b/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd @@ -4094,6 +4094,9 @@ Work management configuration to use for partition task. + + true + @@ -4168,6 +4171,9 @@ Work management configuration to use for partition task. Overrides the value specified in the parent element. + + true + diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/SchemaTransformer.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/SchemaTransformer.java index 910d5cf342b..0a8ec672ba2 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/SchemaTransformer.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/SchemaTransformer.java @@ -22,6 +22,7 @@ import com.evolveum.midpoint.prism.path.UniformItemPath; import com.evolveum.midpoint.prism.path.ItemName; import com.evolveum.midpoint.prism.path.ItemPath; +import com.evolveum.midpoint.prism.path.UniformItemPathImpl; import com.evolveum.midpoint.prism.xml.XsdTypeMapper; import com.evolveum.midpoint.repo.api.RepositoryService; import com.evolveum.midpoint.schema.DefinitionProcessingOption; @@ -51,6 +52,7 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; +import javax.xml.namespace.QName; import java.util.*; /** @@ -796,11 +798,21 @@ private void applyObjectTempla } } + private class VisibilityPolicyEntry { + UniformItemPath path; + UserInterfaceElementVisibilityType visibility; + + public VisibilityPolicyEntry(UniformItemPath path, UserInterfaceElementVisibilityType visibility) { + this.path = path; + this.visibility = visibility; + } + } + public void applyItemsConstraints(MutablePrismContainerDefinition objectDefinition, ArchetypePolicyType archetypePolicy, OperationResult result) throws ObjectNotFoundException, SchemaException { if (archetypePolicy == null) { return; } - Map visibilityMap = new HashMap<>(); + List visibilityPolicy = new ArrayList<>(); for (ItemConstraintType itemConstraint: archetypePolicy.getItemConstraint()) { UserInterfaceElementVisibilityType visibility = itemConstraint.getVisibility(); if (visibility == null) { @@ -810,51 +822,67 @@ public void applyItemsConstraints(MutablePrismContainerDe if (itemPathType == null) { throw new SchemaException("No 'path' in item definition in archetype policy for "+objectDefinition); } - ItemPath itemPath = prismContext.toPath(itemPathType); - visibilityMap.put(itemPath, visibility); + UniformItemPath itemPath = prismContext.toUniformPath(itemPathType); + visibilityPolicy.add(new VisibilityPolicyEntry(itemPath, visibility)); } - if (visibilityMap.isEmpty()) { + if (visibilityPolicy.isEmpty()) { return; } - reduceItems(objectDefinition, ItemPath.EMPTY_PATH, visibilityMap); + // UniformItemPath.EMPTY_PATH is null here. WHY?!? + reduceItems(objectDefinition, UniformItemPathImpl.EMPTY_PATH, visibilityPolicy); } - private UserInterfaceElementVisibilityType reduceItems(PrismContainerDefinition containerDefinition, ItemPath containerPath, Map visibilityMap) { - UserInterfaceElementVisibilityType containerVisibility = determineVisibility(visibilityMap, containerPath); + private UserInterfaceElementVisibilityType reduceItems(PrismContainerDefinition containerDefinition, UniformItemPath containerPath, List visibilityPolicy) { + UserInterfaceElementVisibilityType containerVisibility = determineVisibility(visibilityPolicy, containerPath); if (containerVisibility == UserInterfaceElementVisibilityType.HIDDEN) { containerDefinition.getDefinitions().clear(); return containerVisibility; } - Iterator iterator = containerDefinition.getDefinitions().iterator(); - while (iterator.hasNext()) { - ItemDefinition subDefinition = iterator.next(); - ItemPath itemPath = containerPath.append(subDefinition.getItemName()); + if (containerDefinition.isElaborate()) { + return containerVisibility; + } + ArrayList itemsToDelete = new ArrayList<>(); + for (ItemDefinition subDefinition : (List)containerDefinition.getDefinitions()) { + UniformItemPath itemPath = containerPath.append(subDefinition.getItemName()); if (subDefinition instanceof PrismContainerDefinition) { PrismContainerDefinition subContainerDef = (PrismContainerDefinition)subDefinition; - UserInterfaceElementVisibilityType itemVisibility = reduceItems(subContainerDef, itemPath, visibilityMap); + UserInterfaceElementVisibilityType itemVisibility = reduceItems(subContainerDef, itemPath, visibilityPolicy); if (subContainerDef.isEmpty() && itemVisibility != UserInterfaceElementVisibilityType.VISIBLE) { - subDefinition.toMutable().set - iterator.remove(); + itemsToDelete.add(subDefinition.getItemName()); } } else { - UserInterfaceElementVisibilityType itemVisibility = determineVisibility(visibilityMap, itemPath); + UserInterfaceElementVisibilityType itemVisibility = determineVisibility(visibilityPolicy, itemPath); if (itemVisibility == UserInterfaceElementVisibilityType.VACANT || itemVisibility == UserInterfaceElementVisibilityType.HIDDEN) { - iterator.remove(); + itemsToDelete.add(subDefinition.getItemName()); } } } + MutableComplexTypeDefinition mutableContainerCtDef = containerDefinition.getComplexTypeDefinition().toMutable(); + for (ItemName itemName : itemsToDelete) { + LOGGER.trace("Removing item {} due to visibility item constraint", containerPath.append(itemName)); + mutableContainerCtDef.delete(itemName); + } return containerVisibility; } - private UserInterfaceElementVisibilityType determineVisibility(Map visibilityMap, ItemPath itemPath) { + private UserInterfaceElementVisibilityType determineVisibility(List visibilityPolicy, UniformItemPath itemPath) { if (itemPath == null || itemPath.isEmpty()) { return UserInterfaceElementVisibilityType.AUTOMATIC; } - UserInterfaceElementVisibilityType visibility = visibilityMap.get(itemPath); + UserInterfaceElementVisibilityType visibility = getVisibilityPolicy(visibilityPolicy, itemPath); if (visibility != null) { return visibility; } - return determineVisibility(visibilityMap, itemPath.allExceptLast()); + return determineVisibility(visibilityPolicy, itemPath.allExceptLast()); + } + + private UserInterfaceElementVisibilityType getVisibilityPolicy(List visibilityPolicy, UniformItemPath itemPath) { + for (VisibilityPolicyEntry entry : visibilityPolicy) { + if (itemPath.equivalent(entry.path)) { + return entry.visibility; + } + } + return null; } private void validateObject(PrismObject object, GetOperationOptions options, OperationResult result) { diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestEditSchema.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestEditSchema.java index 8ce9447b7ef..3f4e6e512f9 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestEditSchema.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestEditSchema.java @@ -1212,7 +1212,14 @@ public void test240EditSchemaReconciliationTask() throws Exception { assertObjectDefinition(editDef) .container(ObjectType.F_EXTENSION) - .assertSize(2); + .assertSize(7) + .assertProperty(SchemaConstants.MODEL_EXTENSION_OBJECTCLASS) + .assertProperty(SchemaConstants.MODEL_EXTENSION_KIND) + .assertProperty(SchemaConstants.MODEL_EXTENSION_INTENT) + .assertProperty(SchemaConstants.MODEL_EXTENSION_OBJECT_QUERY) + .assertProperty(SchemaConstants.MODEL_EXTENSION_WORKER_THREADS) + .assertProperty(SchemaConstants.MODEL_EXTENSION_FINISH_OPERATIONS_ONLY) + .assertProperty(SchemaConstants.MODEL_EXTENSION_DRY_RUN); assertSteadyResources(); } diff --git a/model/model-intest/src/test/resources/common/archetype-task-reconciliation.xml b/model/model-intest/src/test/resources/common/archetype-task-reconciliation.xml index 43b3795c9ca..50c4a14daaa 100644 --- a/model/model-intest/src/test/resources/common/archetype-task-reconciliation.xml +++ b/model/model-intest/src/test/resources/common/archetype-task-reconciliation.xml @@ -30,6 +30,26 @@ extension/mext:kind visible + + extension/mext:intent + visible + + + extension/mext:objectQuery + visible + + + extension/mext:workerThreads + visible + + + extension/mext:finishOperationsOnly + visible + + + extension/mext:dryRun + visible + c:TaskType diff --git a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/prism/PrismContainerDefinitionAsserter.java b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/prism/PrismContainerDefinitionAsserter.java index 5e5c2f21f53..794b8b89751 100644 --- a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/prism/PrismContainerDefinitionAsserter.java +++ b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/prism/PrismContainerDefinitionAsserter.java @@ -12,6 +12,7 @@ import com.evolveum.midpoint.prism.Containerable; import com.evolveum.midpoint.prism.PrismContainerDefinition; import com.evolveum.midpoint.prism.PrismPropertyDefinition; +import com.evolveum.midpoint.prism.path.ItemName; import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.util.PrettyPrinter; @@ -49,6 +50,13 @@ public PrismContainerDefinitionAsserter assertSize(int expected) { return this; } + + public PrismContainerDefinitionAsserter assertProperty(ItemName itemPath) { + PrismPropertyDefinition propertyDefinition = getDefinition().findPropertyDefinition(itemPath); + assertNotNull("No property definition for path "+itemPath+" in "+desc(), propertyDefinition); + return this; + } + public PrismContainerDefinitionAsserter> container(ItemPath subDefPath) { PrismContainerDefinition subDefinition = getDefinition().findContainerDefinition(subDefPath); assertNotNull("No container for path "+subDefPath+" in "+desc(), subDefinition); @@ -70,4 +78,5 @@ public PrismContainerDefinitionAsserter display(String message) { IntegrationTestTools.display(message, getDefinition()); return this; } + } From 7a48fae07c3489a5ad6cd3555bf4cff09a78b2de Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Fri, 28 Feb 2020 18:34:08 +0100 Subject: [PATCH 51/97] AbstractIntegrationTest: createTracedTask now really creates task Previously it erroneously used task from method-scoped context. --- .../com/evolveum/midpoint/test/AbstractIntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 51a2f4cc14f..0fe657df566 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 @@ -2003,7 +2003,7 @@ protected TracingProfileType createPerformanceTracingProfile() { } protected Task createTracedTask(String operationName) { - Task task = getTestTask(); + Task task = createTask(operationName); task.addTracingRequest(TracingRootType.CLOCKWORK_RUN); task.setTracingProfile(new TracingProfileType() .collectLogEntries(true) From 6947e9f03a6fd087eb88d5340cbd8f4a302d6910 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Sat, 29 Feb 2020 10:18:21 +0100 Subject: [PATCH 52/97] AbstractIntegrationTest: customizeTask is called directly in createTask This doesn't seem to help with a few broken tests, but makes sense. --- .../test/AbstractIntegrationTest.java | 38 +++++++++++-------- 1 file changed, 23 insertions(+), 15 deletions(-) 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 0fe657df566..ac7bd1d88b1 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 @@ -117,6 +117,11 @@ @Listeners({ CurrentTestResultHolder.class }) public abstract class AbstractIntegrationTest extends AbstractSpringTest { + // TODO inttest: tests should be fixed and this should go before merge to master + // value is false, as it is used in enable= flag + @Deprecated + public static final boolean DISABLED_IN_NEW_INTEST = false; + protected static final String USER_ADMINISTRATOR_USERNAME = "administrator"; public static final String COMMON_DIR_NAME = "common"; @@ -149,9 +154,8 @@ public abstract class AbstractIntegrationTest extends AbstractSpringTest { @Autowired protected Tracer tracer; /** - * Task manager should not be used directly in subclasses, better use provided methods, - * even better just utilize prepared method-test-scoped task via {@link #getTestTask()}. - * TODO: can the goal be to make this private and only access it through behaviour (method)? + * Task manager can be used directly in subclasses but prefer various provided methods + * like {@link #getTestTask()}, {@link #createTask}, etc. */ @Autowired protected TaskManager taskManager; @@ -183,8 +187,8 @@ public abstract class AbstractIntegrationTest extends AbstractSpringTest { * Using {@code BeforeClass} is not good as the Spring wiring happens later. */ @PostConstruct - public void initSystemConditional() throws Exception { - logger.trace("initSystemConditional: initializing class {}", getClass().getName()); + public void initSystem() throws Exception { + logger.trace("initSystem: initializing class {}", getClass().getName()); // Check whether we are already initialized assertNotNull("Repository is not wired properly", repositoryService); @@ -237,8 +241,7 @@ public void startTestContext(ITestResult testResult) { TestUtil.displayTestTitle(testClass.getSimpleName() + "." + testMethodName); Task task = createTask(testMethodName); - customizeTask(task); - // TODO do we need that subresult? :-) (Virgo's brave new world) + // TODO inttest do we need that subresult? :-) (Virgo's brave new world) // maybe it doesn't break tests, but changes traceability/maintenance? // OperationResult rootResult = task.getResult(); // TracingProfileType tracingProfile = getTestMethodTracingProfile(); @@ -255,13 +258,6 @@ public void startTestContext(ITestResult testResult) { MidpointTestMethodContext.create(testClass, testMethodName, task, task.getResult()); } - /** - * Subclasses may override this if test task needs additional customization. - */ - protected void customizeTask(Task task) { - // nothing by default - } - /** * Finish and destroy the test context, output duration and store the operation trace. * This implementation fully overrides (without use) the one from {@link AbstractSpringTest}. @@ -338,9 +334,21 @@ public String getTestNameShort() { * Provided name is automatically prefixed by {@link #contextName()}. */ protected Task createTask(String operationName) { - return taskManager.createTaskInstance(contextName() + "." + operationName); + Task task = taskManager.createTaskInstance(contextName() + "." + operationName); + customizeTask(task); + return task; + } + + /** + * Subclasses may override this if test task needs additional customization. + * Each task used or created by the test is customized - this applies to default + * method-scoped task and also to any task created by {@link #createTask(String)}. + */ + protected void customizeTask(Task task) { + // nothing by default } + /** * Context name is "class-simple-name.method" if test method context is available, * otherwise it is just simple name of the test class. From bcf116a384e5b963795cf7cafa17fa2a7624c50b Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Sat, 29 Feb 2020 10:21:45 +0100 Subject: [PATCH 53/97] AbstractConfiguredModelIntegrationTest: removed older lifecycle methods They reported time to init spring context, if we really need them, they can be recreated in AbstractSpringTest later. --- model/model-intest/pom.xml | 4 - ...bstractConfiguredModelIntegrationTest.java | 77 ++----------------- 2 files changed, 8 insertions(+), 73 deletions(-) diff --git a/model/model-intest/pom.xml b/model/model-intest/pom.xml index 03662735da1..500a5f6a34d 100644 --- a/model/model-intest/pom.xml +++ b/model/model-intest/pom.xml @@ -336,10 +336,6 @@ spring-aop test - - org.jetbrains - annotations - diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/AbstractConfiguredModelIntegrationTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/AbstractConfiguredModelIntegrationTest.java index 3b121835506..08dd671feb9 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/AbstractConfiguredModelIntegrationTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/AbstractConfiguredModelIntegrationTest.java @@ -31,23 +31,13 @@ import com.evolveum.midpoint.util.MiscUtil; import com.evolveum.midpoint.util.QNameUtil; import com.evolveum.midpoint.util.exception.*; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; -import org.jetbrains.annotations.NotNull; import org.testng.AssertJUnit; -import org.testng.IHookCallBack; -import org.testng.ITestResult; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; import java.io.File; import java.io.IOException; import java.lang.reflect.Field; -import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.Collection; @@ -558,8 +548,6 @@ public class AbstractConfiguredModelIntegrationTest extends AbstractModelIntegra protected static final String NOTIFIER_USER_PASSWORD_NAME = "userPasswordNotifier"; protected static final String NOTIFIER_ACCOUNT_ACTIVATION_NAME = "accountActivationNotifier"; - private static final Trace LOGGER = TraceManager.getTrace(AbstractConfiguredModelIntegrationTest.class); - protected PrismObject userAdministrator; public AbstractConfiguredModelIntegrationTest() { @@ -568,7 +556,7 @@ public AbstractConfiguredModelIntegrationTest() { @Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { - LOGGER.trace("initSystem"); + logger.trace("initSystem"); // We want logging config from logback-test.xml and not from system config object (unless suppressed) InternalsConfig.setAvoidLoggingChange(isAvoidLoggingChange()); @@ -622,24 +610,11 @@ protected PrismObject getDefaultActor() { return userAdministrator; } - @Override - public void run(@NotNull IHookCallBack callBack, ITestResult testResult) { - long time = System.currentTimeMillis(); - LOGGER.info("###>>> run start"); - super.run(callBack, testResult); - LOGGER.info("###>>> run end ({}ms)", new Object[]{(System.currentTimeMillis() - time)}); - } - - @AfterClass - @Override - protected void springTestContextAfterTestClass() throws Exception { - long time = System.currentTimeMillis(); - LOGGER.info("###>>> springTestContextAfterTestClass start"); - super.springTestContextAfterTestClass(); - + // TODO: let's try it without this after 6 years +// @AfterClass(alwaysRun = true) + public void clearClassFields() throws Exception { + logger.trace("Clearing all fields for test class {}", getClass().getName()); nullAllFields(this, getClass()); - - LOGGER.info("###>>> springTestContextAfterTestClass end ({}ms)", new Object[]{(System.currentTimeMillis() - time)}); } /** @@ -650,7 +625,7 @@ protected void springTestContextAfterTestClass() throws Exception { * immediately. If they holds autowired fields like sessionFactory (for example * through SqlRepositoryService impl), their memory footprint is getting big. */ - public static void nullAllFields(Object object, Class forClass) throws Exception{ + public void nullAllFields(Object object, Class forClass) throws Exception { if (forClass.getSuperclass() != null) { nullAllFields(object, forClass.getSuperclass()); } @@ -666,8 +641,8 @@ public static void nullAllFields(Object object, Class forClass) throws Except } } - private static void nullField(Object obj, Field field) throws Exception { - LOGGER.info("Setting {} to null on {}.", new Object[]{field.getName(), obj.getClass().getSimpleName()}); + private void nullField(Object obj, Field field) throws Exception { + logger.info("Setting {} to null on {}.", new Object[]{field.getName(), obj.getClass().getSimpleName()}); boolean accessible = field.isAccessible(); if (!accessible) { field.setAccessible(true); @@ -676,42 +651,6 @@ private static void nullField(Object obj, Field field) throws Exception { field.setAccessible(accessible); } - @AfterMethod - @Override - protected void springTestContextAfterTestMethod(@NotNull Method testMethod) throws Exception { - long time = System.currentTimeMillis(); - LOGGER.info("###>>> springTestContextAfterTestMethod start"); - super.springTestContextAfterTestMethod(testMethod); - LOGGER.info("###>>> springTestContextAfterTestMethod end ({}ms)", new Object[]{(System.currentTimeMillis() - time)}); - } - - @BeforeClass - @Override - protected void springTestContextBeforeTestClass() throws Exception { - long time = System.currentTimeMillis(); - LOGGER.info("###>>> springTestContextBeforeTestClass start"); - super.springTestContextBeforeTestClass(); - LOGGER.info("###>>> springTestContextBeforeTestClass end ({}ms)", new Object[]{(System.currentTimeMillis() - time)}); - } - - @BeforeMethod - @Override - protected void springTestContextBeforeTestMethod(@NotNull Method testMethod) throws Exception { - long time = System.currentTimeMillis(); - LOGGER.info("###>>> springTestContextBeforeTestMethod start"); - super.springTestContextBeforeTestMethod(testMethod); - LOGGER.info("###>>> springTestContextBeforeTestMethod end ({}ms)", new Object[]{(System.currentTimeMillis() - time)}); - } - - @BeforeClass - @Override - protected void springTestContextPrepareTestInstance() throws Exception { - long time = System.currentTimeMillis(); - LOGGER.info("###>>> springTestContextPrepareTestInstance start"); - super.springTestContextPrepareTestInstance(); - LOGGER.info("###>>> springTestContextPrepareTestInstance end ({}ms)", new Object[]{(System.currentTimeMillis() - time)}); - } - protected PrismSchema getPiracySchema() { return prismContext.getSchemaRegistry().findSchemaByNamespace(NS_PIRACY); } From b6cd2ed5313fa3de4d6ed703913448be05a39e87 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Sat, 29 Feb 2020 10:22:45 +0100 Subject: [PATCH 54/97] TestParallelApprovals: fixed getTaskTest -> createTask --- .../wf/impl/other/TestParallelApprovals.java | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestParallelApprovals.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestParallelApprovals.java index a8927b11e1e..2cb2ad01d20 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestParallelApprovals.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestParallelApprovals.java @@ -220,11 +220,9 @@ public void approveAllWorkItems(Task task, OperationResult result) throws Except public void test120ParallelApprovalsInTwoOperations() throws Exception { login(userAdministrator); - String testName = getTestNameShort(); - - Task task0 = getTestTask(); - Task task1 = getTestTask(); - Task task2 = getTestTask(); + Task task0 = createTask("task0"); + Task task1 = createTask("task1"); + Task task2 = createTask("task2"); OperationResult result0 = task0.getResult(); OperationResult result1 = task1.getResult(); OperationResult result2 = task2.getResult(); @@ -286,12 +284,10 @@ public void test120ParallelApprovalsInTwoOperations() throws Exception { public void test130ParallelApprovalsInThreeSummarizingOperations() throws Exception { login(userAdministrator); - String testName = getTestNameShort(); - - Task task0 = getTestTask(); - Task task1 = getTestTask(); - Task task2 = getTestTask(); - Task task3 = getTestTask(); + Task task0 = createTask("task0"); + Task task1 = createTask("task1"); + Task task2 = createTask("task2"); + Task task3 = createTask("task3"); OperationResult result0 = task0.getResult(); OperationResult result1 = task1.getResult(); OperationResult result2 = task2.getResult(); From 1b9e4ebb066a92ede0a483a594a617ac0fed114c Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Sat, 29 Feb 2020 10:52:52 +0100 Subject: [PATCH 55/97] fixes/cleanup around TestSecurityAdvanced, but test 320 is still broken --- .../intest/security/AbstractSecurityTest.java | 3 +- .../intest/security/TestSecurityAdvanced.java | 339 +++++++----------- .../test/AbstractModelIntegrationTest.java | 19 +- 3 files changed, 141 insertions(+), 220 deletions(-) diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/AbstractSecurityTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/AbstractSecurityTest.java index 4a087fed9c8..37e1742ec02 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/AbstractSecurityTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/AbstractSecurityTest.java @@ -8,7 +8,6 @@ import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; import static org.testng.AssertJUnit.assertTrue; import static org.testng.AssertJUnit.assertFalse; @@ -1102,7 +1101,7 @@ protected void assertCanSearchRoleMembers(String roleOid, boolean expectedResult } protected void assertCanSearch(String message, Class resultType, Class objectType, String objectOid, boolean includeSpecial, ObjectQuery query, boolean expectedResult) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = getTestTask(); + Task task = createTask("assertCanSearch"); OperationResult result = task.getResult(); String opName = "canSearch("+message+")"; logAttempt(opName); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityAdvanced.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityAdvanced.java index 933f495369f..8a9fe1ac33f 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityAdvanced.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityAdvanced.java @@ -6,23 +6,26 @@ */ package com.evolveum.midpoint.model.intest.security; +import static org.testng.AssertJUnit.*; + import java.io.File; import java.io.IOException; import java.util.Collection; import java.util.List; - import javax.xml.datatype.XMLGregorianCalendar; -import com.evolveum.midpoint.prism.*; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; import com.evolveum.midpoint.model.api.ModelAuthorizationAction; +import com.evolveum.midpoint.prism.PrismContainer; +import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.prism.PrismObjectDefinition; +import com.evolveum.midpoint.prism.PrismReferenceValue; import com.evolveum.midpoint.prism.delta.ObjectDelta; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.query.ObjectFilter; import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.prism.query.TypeFilter; @@ -39,22 +42,13 @@ import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.IntegrationTestTools; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; -import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.PolicyViolationException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SecurityViolationException; - -import static org.testng.AssertJUnit.*; +import com.evolveum.midpoint.util.exception.*; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; /** * @author semancik - * */ -@ContextConfiguration(locations = {"classpath:ctx-model-intest-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-model-intest-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public class TestSecurityAdvanced extends AbstractSecurityTest { @@ -188,7 +182,7 @@ public void test000Sanity() throws Exception { * Simple end-user password change. But clear Jack's credentials before * the change. Make sure all password metadata is set correctly. * This also sets the stage for following persona tests. - * + *

* MID-4830 */ @Test @@ -217,7 +211,7 @@ public void test080AutzJackEndUserPassword() throws Exception { when(TEST_NAME); assertAllow("set jack's password", - (task, result) -> modifyUserSetPassword(USER_JACK_OID, "nbusr123", task, result) ); + (task, result) -> modifyUserSetPassword(USER_JACK_OID, "nbusr123", task, result)); // THEN then(TEST_NAME); @@ -302,7 +296,7 @@ public void test110AutzJackPersonaAdmin() throws Exception { when(TEST_NAME); assertAllow("assign application role 1 to jack", - (task,result) -> assignRole(USER_JACK_OID, ROLE_PERSONA_ADMIN_OID, task, result)); + (task, result) -> assignRole(USER_JACK_OID, ROLE_PERSONA_ADMIN_OID, task, result)); PrismObject userJack = assertGetAllow(UserType.class, USER_JACK_OID); display("User jack after persona assign", userJack); @@ -323,7 +317,7 @@ public void test110AutzJackPersonaAdmin() throws Exception { assertSearch(OrgType.class, null, 0); assertAllow("modify jack givenName", - (task,result) -> modifyUserReplace(USER_JACK_OID, UserType.F_GIVEN_NAME, task, result, + (task, result) -> modifyUserReplace(USER_JACK_OID, UserType.F_GIVEN_NAME, task, result, createPolyString(USER_JACK_GIVEN_NAME_NEW))); userJack = assertGetAllow(UserType.class, USER_JACK_OID); @@ -333,7 +327,7 @@ public void test110AutzJackPersonaAdmin() throws Exception { assertEquals("Wrong jack persona givenName after change", USER_JACK_GIVEN_NAME_NEW, personaJack.asObjectable().getGivenName().getOrig()); assertAllow("unassign application role 1 to jack", - (task,result) -> unassignRole(USER_JACK_OID, ROLE_PERSONA_ADMIN_OID, task, result)); + (task, result) -> unassignRole(USER_JACK_OID, ROLE_PERSONA_ADMIN_OID, task, result)); userJack = assertGetAllow(UserType.class, USER_JACK_OID); assertPersonaLinks(userJack, 0); @@ -373,24 +367,18 @@ public void test120AutzJackDelagator() throws Exception { assertNoAssignments(userBarbossa); assertDeny("assign business role to jack", - (task, result) -> { - assignRole(USER_JACK_OID, ROLE_BUSINESS_1_OID, task, result); - }); + (task, result) -> assignRole(USER_JACK_OID, ROLE_BUSINESS_1_OID, task, result)); userJack = getUser(USER_JACK_OID); assertAssignments(userJack, 1); // Wrong direction. It should NOT work. assertDeny("delegate from Barbossa to Jack", - (task, result) -> { - assignDeputy(USER_JACK_OID, USER_BARBOSSA_OID, task, result); - }); + (task, result) -> assignDeputy(USER_JACK_OID, USER_BARBOSSA_OID, task, result)); // Good direction assertAllow("delegate to Barbossa", - (task, result) -> { - assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result); - }); + (task, result) -> assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result)); userJack = getUser(USER_JACK_OID); display("Jack delegator", userJack); @@ -425,9 +413,7 @@ public void test120AutzJackDelagator() throws Exception { display("Logged in as Jack"); assertAllow("undelegate from Barbossa", - (task, result) -> { - unassignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result); - }); + (task, result) -> unassignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result)); userJack = getUser(USER_JACK_OID); assertAssignments(userJack, 1); @@ -448,14 +434,10 @@ public void test120AutzJackDelagator() throws Exception { assertDeleteDeny(); assertDeny("delegate to Jack", - (task, result) -> { - assignDeputy(USER_JACK_OID, USER_BARBOSSA_OID, task, result); - }); + (task, result) -> assignDeputy(USER_JACK_OID, USER_BARBOSSA_OID, task, result)); assertDeny("delegate from Jack to Barbossa", - (task, result) -> { - assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result); - }); + (task, result) -> assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result)); assertGlobalStateUntouched(); } @@ -494,10 +476,8 @@ public void test122AutzJackDelagatorValidity() throws Exception { // Good direction assertAllow("delegate to Barbossa", - (task, result) -> { - assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, - assignment -> assignment.setActivation(activationType), task, result); - }); + (task, result) -> assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, + assignment -> assignment.setActivation(activationType), task, result)); userJack = getUser(USER_JACK_OID); display("Jack delegator", userJack); @@ -572,17 +552,14 @@ public void test122AutzJackDelagatorValidity() throws Exception { assertModifyDeny(); assertDeleteDeny(); - login(USER_JACK_USERNAME); // WHEN when(TEST_NAME); display("Logged in as Jack"); assertAllow("undelegate from Barbossa", - (task, result) -> { - unassignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, - assignment -> assignment.setActivation(activationType), task, result); - }); + (task, result) -> unassignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, + assignment -> assignment.setActivation(activationType), task, result)); userJack = getUser(USER_JACK_OID); assertAssignments(userJack, 1); @@ -603,14 +580,10 @@ public void test122AutzJackDelagatorValidity() throws Exception { assertDeleteDeny(); assertDeny("delegate to Jack", - (task, result) -> { - assignDeputy(USER_JACK_OID, USER_BARBOSSA_OID, task, result); - }); + (task, result) -> assignDeputy(USER_JACK_OID, USER_BARBOSSA_OID, task, result)); assertDeny("delegate from Jack to Barbossa", - (task, result) -> { - assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result); - }); + (task, result) -> assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result)); assertGlobalStateUntouched(); } @@ -649,10 +622,8 @@ public void test124AutzJackDelagatorPlusValidity() throws Exception { // Good direction assertAllow("delegate to Barbossa", - (task, result) -> { - assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, - assignment -> assignment.setActivation(activationType), task, result); - }); + (task, result) -> assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, + assignment -> assignment.setActivation(activationType), task, result)); userJack = getUser(USER_JACK_OID); display("Jack delegator", userJack); @@ -741,17 +712,14 @@ public void test124AutzJackDelagatorPlusValidity() throws Exception { assertModifyDeny(); assertDeleteDeny(); - login(USER_JACK_USERNAME); // WHEN when(TEST_NAME); display("Logged in as Jack"); assertAllow("undelegate from Barbossa", - (task, result) -> { - unassignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, - assignment -> assignment.setActivation(activationType), task, result); - }); + (task, result) -> unassignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, + assignment -> assignment.setActivation(activationType), task, result)); userJack = getUser(USER_JACK_OID); assertAssignments(userJack, 1); @@ -772,19 +740,14 @@ public void test124AutzJackDelagatorPlusValidity() throws Exception { assertDeleteDeny(); assertDeny("delegate to Jack", - (task, result) -> { - assignDeputy(USER_JACK_OID, USER_BARBOSSA_OID, task, result); - }); + (task, result) -> assignDeputy(USER_JACK_OID, USER_BARBOSSA_OID, task, result)); assertDeny("delegate from Jack to Barbossa", - (task, result) -> { - assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result); - }); + (task, result) -> assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result)); assertGlobalStateUntouched(); } - @Test public void test150AutzJackApproverUnassignRoles() throws Exception { final String TEST_NAME = "test150AutzJackApproverUnassignRoles"; @@ -864,7 +827,6 @@ public void test151AutzJackApproverUnassignRolesAndRead() throws Exception { // The appr-read-users authorization is maySkipOnSearch and the readonly role allows read. assertSearch(UserType.class, null, NUMBER_OF_ALL_USERS); - assert15xCommon(); } @@ -913,18 +875,18 @@ public void test154AutzJackApproverRead() throws Exception { assertCanSearchRoleMembers(ROLE_UNINTERESTING_OID, false); assertDeny("unassign ordinary role from cobb", - (task,result) -> unassignRole(userCobbOid, ROLE_ORDINARY_OID, task, result)); + (task, result) -> unassignRole(userCobbOid, ROLE_ORDINARY_OID, task, result)); assertSearch(UserType.class, createMembersQuery(UserType.class, ROLE_ORDINARY_OID), 0); assertDeny("unassign uninteresting role from cobb", - (task,result) -> unassignRole(userCobbOid, ROLE_UNINTERESTING_OID, task, result)); + (task, result) -> unassignRole(userCobbOid, ROLE_UNINTERESTING_OID, task, result)); assertDeny("unassign uninteresting role from rum", - (task,result) -> unassignRole(userRumRogersOid, ROLE_UNINTERESTING_OID, task, result)); + (task, result) -> unassignRole(userRumRogersOid, ROLE_UNINTERESTING_OID, task, result)); assertDeny("unassign approver role from jack", - (task,result) -> unassignRole(USER_JACK_OID, ROLE_APPROVER_UNASSIGN_ROLES_OID, task, result)); + (task, result) -> unassignRole(USER_JACK_OID, ROLE_APPROVER_UNASSIGN_ROLES_OID, task, result)); assertDeny("unassign ordinary role from lechuck", - (task,result) -> unassignRole(USER_LECHUCK_OID, ROLE_ORDINARY_OID, task, result)); + (task, result) -> unassignRole(USER_LECHUCK_OID, ROLE_ORDINARY_OID, task, result)); assertAddDeny(); assertModifyDeny(); @@ -976,16 +938,16 @@ public void test155AutzJackApproverSelf() throws Exception { assertCanSearchRoleMembers(ROLE_UNINTERESTING_OID, false); assertDeny("unassign ordinary role from cobb", - (task,result) -> unassignRole(userCobbOid, ROLE_ORDINARY_OID, task, result)); + (task, result) -> unassignRole(userCobbOid, ROLE_ORDINARY_OID, task, result)); assertSearch(UserType.class, createMembersQuery(UserType.class, ROLE_ORDINARY_OID), 0); assertDeny("unassign uninteresting role from cobb", - (task,result) -> unassignRole(userCobbOid, ROLE_UNINTERESTING_OID, task, result)); + (task, result) -> unassignRole(userCobbOid, ROLE_UNINTERESTING_OID, task, result)); assertDeny("unassign uninteresting role from rum", - (task,result) -> unassignRole(userRumRogersOid, ROLE_UNINTERESTING_OID, task, result)); + (task, result) -> unassignRole(userRumRogersOid, ROLE_UNINTERESTING_OID, task, result)); assertDeny("unassign ordinary role from lechuck", - (task,result) -> unassignRole(USER_LECHUCK_OID, ROLE_ORDINARY_OID, task, result)); + (task, result) -> unassignRole(USER_LECHUCK_OID, ROLE_ORDINARY_OID, task, result)); assertAddDeny(); assertModifyAllow(UserType.class, USER_JACK_OID, UserType.F_HONORIFIC_PREFIX, PrismTestUtil.createPolyString("Captain")); @@ -1034,11 +996,11 @@ public void test157AutzJackReadRoleMembers() throws Exception { assertCanSearchRoleMembers(ROLE_UNINTERESTING_OID, true); assertDeny("unassign ordinary role from cobb", - (task,result) -> unassignRole(userCobbOid, ROLE_ORDINARY_OID, task, result)); + (task, result) -> unassignRole(userCobbOid, ROLE_ORDINARY_OID, task, result)); assertDeny("unassign uninteresting role from rum", - (task,result) -> unassignRole(userRumRogersOid, ROLE_UNINTERESTING_OID, task, result)); + (task, result) -> unassignRole(userRumRogersOid, ROLE_UNINTERESTING_OID, task, result)); assertDeny("unassign approver role from jack", - (task,result) -> unassignRole(USER_JACK_OID, ROLE_APPROVER_UNASSIGN_ROLES_OID, task, result)); + (task, result) -> unassignRole(USER_JACK_OID, ROLE_APPROVER_UNASSIGN_ROLES_OID, task, result)); assertAddDeny(); assertModifyDeny(); @@ -1086,11 +1048,11 @@ public void test158AutzJackReadRoleMembersWrong() throws Exception { assertCanSearchRoleMembers(ROLE_UNINTERESTING_OID, true); assertDeny("unassign ordinary role from cobb", - (task,result) -> unassignRole(userCobbOid, ROLE_ORDINARY_OID, task, result)); + (task, result) -> unassignRole(userCobbOid, ROLE_ORDINARY_OID, task, result)); assertDeny("unassign uninteresting role from rum", - (task,result) -> unassignRole(userRumRogersOid, ROLE_UNINTERESTING_OID, task, result)); + (task, result) -> unassignRole(userRumRogersOid, ROLE_UNINTERESTING_OID, task, result)); assertDeny("unassign approver role from jack", - (task,result) -> unassignRole(USER_JACK_OID, ROLE_APPROVER_UNASSIGN_ROLES_OID, task, result)); + (task, result) -> unassignRole(USER_JACK_OID, ROLE_APPROVER_UNASSIGN_ROLES_OID, task, result)); assertAddDeny(); assertModifyDeny(); @@ -1138,11 +1100,11 @@ public void test159AutzJackReadRoleMembersNone() throws Exception { assertCanSearchRoleMembers(ROLE_UNINTERESTING_OID, false); assertDeny("unassign ordinary role from cobb", - (task,result) -> unassignRole(userCobbOid, ROLE_ORDINARY_OID, task, result)); + (task, result) -> unassignRole(userCobbOid, ROLE_ORDINARY_OID, task, result)); assertDeny("unassign uninteresting role from rum", - (task,result) -> unassignRole(userRumRogersOid, ROLE_UNINTERESTING_OID, task, result)); + (task, result) -> unassignRole(userRumRogersOid, ROLE_UNINTERESTING_OID, task, result)); assertDeny("unassign approver role from jack", - (task,result) -> unassignRole(USER_JACK_OID, ROLE_APPROVER_UNASSIGN_ROLES_OID, task, result)); + (task, result) -> unassignRole(USER_JACK_OID, ROLE_APPROVER_UNASSIGN_ROLES_OID, task, result)); assertAddDeny(); assertModifyDeny(); @@ -1150,7 +1112,7 @@ public void test159AutzJackReadRoleMembersNone() throws Exception { assertGlobalStateUntouched(); } - private void assert15xCommon() throws Exception { + private void assert15xCommon() throws Exception { // list ordinary role members, this is allowed assertSearch(UserType.class, createMembersQuery(UserType.class, ROLE_ORDINARY_OID), 2); @@ -1168,25 +1130,25 @@ private void assert15xCommon() throws Exception { assertCanSearchRoleMembers(ROLE_APPROVER_UNASSIGN_ROLES_OID, false); assertAllow("unassign ordinary role from cobb", - (task,result) -> unassignRole(userCobbOid, ROLE_ORDINARY_OID, task, result)); + (task, result) -> unassignRole(userCobbOid, ROLE_ORDINARY_OID, task, result)); assertSearch(UserType.class, createMembersQuery(UserType.class, ROLE_ORDINARY_OID), 1); // Jack is not approver of uninteresting role, so this should be denied assertDeny("unassign uninteresting role from cobb", - (task,result) -> unassignRole(userCobbOid, ROLE_UNINTERESTING_OID, task, result)); + (task, result) -> unassignRole(userCobbOid, ROLE_UNINTERESTING_OID, task, result)); // Jack is not approver of uninteresting role, so this should be denied // - even though Rum Rogers is a member of a role that jack is an approver of assertDeny("unassign uninteresting role from rum", - (task,result) -> unassignRole(userRumRogersOid, ROLE_UNINTERESTING_OID, task, result)); + (task, result) -> unassignRole(userRumRogersOid, ROLE_UNINTERESTING_OID, task, result)); assertDeny("unassign approver role from jack", - (task,result) -> unassignRole(USER_JACK_OID, ROLE_APPROVER_UNASSIGN_ROLES_OID, task, result)); + (task, result) -> unassignRole(USER_JACK_OID, ROLE_APPROVER_UNASSIGN_ROLES_OID, task, result)); // Lechuck is not a member of ordinary role assertDeny("unassign ordinary role from lechuck", - (task,result) -> unassignRole(USER_LECHUCK_OID, ROLE_ORDINARY_OID, task, result)); + (task, result) -> unassignRole(USER_LECHUCK_OID, ROLE_ORDINARY_OID, task, result)); assertAddDeny(); assertModifyDeny(); @@ -1484,7 +1446,6 @@ public void test230AttorneyCaribbeanUnlimited() throws Exception { assertGlobalStateUntouched(); } - /** * Attorney for subordinate employees, but Jack has no org. * MID-4072, MID-4205 @@ -1820,25 +1781,25 @@ public void test250AssignRequestableSelfOtherApporver() throws Exception { assertAssignableRoleSpecification(userJack) .assertSize(3) .relationDefault() - .filter() - .type(RoleType.COMPLEX_TYPE) - .assertEq(RoleType.F_REQUESTABLE, true) - .end() - .end() - .end() + .filter() + .type(RoleType.COMPLEX_TYPE) + .assertEq(RoleType.F_REQUESTABLE, true) + .end() + .end() + .end() .relation(SchemaConstants.ORG_APPROVER) - .filter() - .type(RoleType.COMPLEX_TYPE) - .assertNull() - .end() - .end() - .end() + .filter() + .type(RoleType.COMPLEX_TYPE) + .assertNull() + .end() + .end() + .end() .relation(SchemaConstants.ORG_OWNER) - .filter() - .type(RoleType.COMPLEX_TYPE) - .assertNull() - .end() - .end(); + .filter() + .type(RoleType.COMPLEX_TYPE) + .assertNull() + .end() + .end(); assertGlobalStateUntouched(); } @@ -2147,7 +2108,7 @@ public void test262AutzJackLimitedRoleAdministratorAndAssignApplicationRoles() t assertAllow("assign application role to jack", (task, result) -> assignRole(USER_JACK_OID, ROLE_APPLICATION_1_OID, task, result) - ); + ); PrismObject user = getUser(USER_JACK_OID); assertAssignments(user, 3); @@ -2158,7 +2119,7 @@ public void test262AutzJackLimitedRoleAdministratorAndAssignApplicationRoles() t assertAllow("unassign application role from jack", (task, result) -> unassignRole(USER_JACK_OID, ROLE_APPLICATION_1_OID, task, result) - ); + ); // check ROLE_LIMITED_ROLE_ADMINISTRATOR_OID authorizations @@ -2410,8 +2371,6 @@ public void test266AutzJackRoleAdministrator() throws Exception { assertGlobalStateUntouched(); } - - @Test public void test270AutzJackModifyPolicyException() throws Exception { final String TEST_NAME = "test270AutzJackModifyPolicyException"; @@ -2519,7 +2478,7 @@ public void test272AutzJackModifyPolicyExceptionFirstRule() throws Exception { (task, result) -> { ObjectDelta roleDelta = prismContext.deltaFactory().object() .createModificationDeleteContainer(RoleType.class, ROLE_EMPTY_OID, - RoleType.F_POLICY_EXCEPTION, idOnlyPolicyException3); + RoleType.F_POLICY_EXCEPTION, idOnlyPolicyException3); roleDelta.addModificationReplaceProperty(RoleType.F_DESCRIPTION, "whatever"); modelService.executeChanges(MiscSchemaUtil.createCollection(roleDelta), null, task, result); }); @@ -2535,7 +2494,6 @@ public void test272AutzJackModifyPolicyExceptionFirstRule() throws Exception { @Test public void test274AutzJackModifyPolicyExceptionSituation() throws Exception { - final String TEST_NAME = "test274AutzJackModifyPolicyExceptionSituation"; // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_MODIFY_POLICY_EXCEPTION_SITUATION_OID); @@ -2564,7 +2522,6 @@ public void test274AutzJackModifyPolicyExceptionSituation() throws Exception { assertDeny("delete policyException (3)", (task, result) -> modifyRoleDeletePolicyException(ROLE_EMPTY_OID, idOnlyPolicyException3, task, result)); - assertGlobalStateUntouched(); } @@ -2669,8 +2626,13 @@ public void test283AutzJackModifyPolicyAssignOrg() throws Exception { assertGlobalStateUntouched(); } - protected void modifyRoleAddExclusionAndAssignOrg(String roleOid, String excludedRoleOid, String orgOid, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - ObjectDelta roleDelta = createAssignmentAssignmentHolderDelta(RoleType.class, roleOid, orgOid, OrgType.COMPLEX_TYPE, null, null, null, true); + protected void modifyRoleAddExclusionAndAssignOrg( + String roleOid, String excludedRoleOid, String orgOid, Task task, OperationResult result) + throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, + ExpressionEvaluationException, CommunicationException, ConfigurationException, + PolicyViolationException, SecurityViolationException { + ObjectDelta roleDelta = createAssignmentAssignmentHolderDelta( + RoleType.class, roleOid, orgOid, OrgType.COMPLEX_TYPE, null, null, null, true); PolicyRuleType exclusionPolicyRule = createExclusionPolicyRule(excludedRoleOid); AssignmentType assignment = new AssignmentType(); assignment.setPolicyRule(exclusionPolicyRule); @@ -2984,7 +2946,7 @@ public void test308AutzJackPropExceptAssignmentAssignApplicationRoles() throws E assertAllow("assign application 1 role to jack", (task, result) -> assignRole(USER_JACK_OID, ROLE_APPLICATION_1_OID, task, result) - ); + ); userJack = getUser(USER_JACK_OID); assertAssignments(userJack, 3); @@ -2995,15 +2957,15 @@ public void test308AutzJackPropExceptAssignmentAssignApplicationRoles() throws E assertAllow("unassign application 1 role from jack", (task, result) -> unassignRole(USER_JACK_OID, ROLE_APPLICATION_1_OID, task, result) - ); + ); userJack = getUser(USER_JACK_OID); assertAssignments(userJack, 2); assertAssignableRoleSpecification(getUser(USER_JACK_OID)) .relationDefault() - .filter() - .assertClass(TypeFilter.class); + .filter() + .assertClass(TypeFilter.class); assertAllowRequestAssignmentItems(USER_JACK_OID, ROLE_APPLICATION_1_OID, SchemaConstants.PATH_ASSIGNMENT_TARGET_REF, @@ -3027,9 +2989,9 @@ public void test310AutzJackPropSubtypeDenyEscapingZoneOfControl() throws Excepti login(USER_JACK_USERNAME); assertUserBefore(USER_JACK_OID) - .assertName(USER_JACK_USERNAME) - .assertFullName(USER_JACK_FULL_NAME) - .assertSubtype(USER_JACK_SUBTYPE); + .assertName(USER_JACK_USERNAME) + .assertFullName(USER_JACK_FULL_NAME) + .assertSubtype(USER_JACK_SUBTYPE); // WHEN when(TEST_NAME); @@ -3040,9 +3002,9 @@ public void test310AutzJackPropSubtypeDenyEscapingZoneOfControl() throws Excepti then(TEST_NAME); assertUserAfter(USER_JACK_OID) - .assertName(USER_JACK_USERNAME) - .assertFullName(USER_JACK_FULL_NAME) - .assertSubtype(USER_JACK_SUBTYPE); + .assertName(USER_JACK_USERNAME) + .assertFullName(USER_JACK_FULL_NAME) + .assertSubtype(USER_JACK_SUBTYPE); assertGlobalStateUntouched(); } @@ -3062,9 +3024,9 @@ public void test312AutzJackPropSubtypeAllowEscapingZoneOfControl() throws Except login(USER_JACK_USERNAME); assertUserBefore(USER_JACK_OID) - .assertName(USER_JACK_USERNAME) - .assertFullName(USER_JACK_FULL_NAME) - .assertSubtype(USER_JACK_SUBTYPE); + .assertName(USER_JACK_USERNAME) + .assertFullName(USER_JACK_FULL_NAME) + .assertSubtype(USER_JACK_SUBTYPE); // WHEN when(TEST_NAME); @@ -3077,9 +3039,9 @@ public void test312AutzJackPropSubtypeAllowEscapingZoneOfControl() throws Except then(TEST_NAME); assertUserAfter(USER_JACK_OID) - .assertName(USER_JACK_USERNAME) - .assertFullName(USER_JACK_FULL_NAME) - .assertSubtype("escape"); + .assertName(USER_JACK_USERNAME) + .assertFullName(USER_JACK_FULL_NAME) + .assertSubtype("escape"); assertGlobalStateUntouched(); } @@ -3087,9 +3049,8 @@ public void test312AutzJackPropSubtypeAllowEscapingZoneOfControl() throws Except /** * MID-4304 */ - @Test + @Test(enabled = DISABLED_IN_NEW_INTEST) public void test320AutzJackGuybrushValutDweller() throws Exception { - final String TEST_NAME = "test320AutzJackGuybrushValutDweller"; // GIVEN cleanupAutzTest(USER_JACK_OID); assertNoDummyAccount(RESOURCE_DUMMY_VAULT_NAME, USER_GUYBRUSH_USERNAME); @@ -3099,7 +3060,7 @@ public void test320AutzJackGuybrushValutDweller() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); PrismObject userBuybrush = getUser(USER_GUYBRUSH_OID); display("Guybrush(1)", userBuybrush); @@ -3109,7 +3070,7 @@ public void test320AutzJackGuybrushValutDweller() throws Exception { assertAllow("assign vault dweller role to guybrush", (task, result) -> assignRole(USER_GUYBRUSH_OID, ROLE_VAULT_DWELLER_OID, task, result) - ); + ); userBuybrush = getUser(USER_GUYBRUSH_OID); display("Guybrush(2)", userBuybrush); @@ -3124,7 +3085,7 @@ public void test320AutzJackGuybrushValutDweller() throws Exception { assertAllow("unassign vault dweller role from guybrush", (task, result) -> unassignRole(USER_GUYBRUSH_OID, ROLE_VAULT_DWELLER_OID, task, result) - ); + ); userBuybrush = getUser(USER_GUYBRUSH_OID); assertAssignments(userBuybrush, 1); @@ -3136,7 +3097,7 @@ public void test320AutzJackGuybrushValutDweller() throws Exception { /** * We can get any users, but we can search only the CAPTAINs. - * + *

* MID-4860, MID-4654, MID-4859 */ @Test @@ -3182,7 +3143,7 @@ public void test330AutzJackEndUserWithPrivacy() throws Exception { * Superuser role should allow everything. Adding another role with any (allow) * authorizations should not limit superuser. Not even if those authorizations * are completely loony. - * + *

* MID-4931 */ @Test @@ -3215,7 +3176,7 @@ public void test340AutzJackSuperUserAndExecRead() throws Exception { /** * Checks whether resource operationalState authorization works. - * + *

* MID-5168, MID-3749 */ @Test @@ -3241,7 +3202,7 @@ public void test350AutzJackResourceRead() throws Exception { /** * Just to be sure we do not throw away empty PC/PCVs when not necessary. - * + *

* MID-5168, MID-3749 */ @Test @@ -3275,14 +3236,16 @@ private ObjectQuery createOrgSubtreeAndNameQuery(String orgOid, String name) { .build(); } - private void modifyJackValidTo() throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - Task task = getTestTask(); + private void modifyJackValidTo() + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, + CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + Task task = createTask("modifyJackValidTo"); OperationResult result = task.getResult(); modifyUserReplace(USER_JACK_OID, SchemaConstants.PATH_ACTIVATION_VALID_TO, task, result, JACK_VALID_TO_LONG_AHEAD); assertSuccess(result); } - private PrismObject assertAlmostFullJackRead(int expectedTargetAssignments) throws Exception { PrismObject userJack = getUser(USER_JACK_OID); display("Jack", userJack); @@ -3291,85 +3254,37 @@ private PrismObject assertAlmostFullJackRead(int expectedTargetAssignm PrismAsserts.assertPropertyValue(userJack, UserType.F_GIVEN_NAME, createPolyString(USER_JACK_GIVEN_NAME)); PrismAsserts.assertPropertyValue(userJack, SchemaConstants.PATH_ACTIVATION_EFFECTIVE_STATUS, ActivationStatusType.ENABLED); assertAssignmentsWithTargets(userJack, expectedTargetAssignments); - -// assertJackEditSchemaReadSomeModifySome(userJack); - return userJack; } - -// @Test -// public void test302AutzJackPropExceptAssignmentReadSomeModifySomeUser() throws Exception { -// final String TEST_NAME = "test216AutzJackPropReadSomeModifySomeUser"; -// displayTestTitle(TEST_NAME); -// // GIVEN -// cleanupAutzTest(USER_JACK_OID); -// assignRole(USER_JACK_OID, ROLE_PROP_READ_SOME_MODIFY_SOME_USER_OID); -// assignRole(USER_JACK_OID, ROLE_PROP_EXCEPT_ASSIGNMENT_OID); -// login(USER_JACK_USERNAME); -// -// // WHEN -// displayWhen(TEST_NAME); -// -// PrismObject userJack = getUser(USER_JACK_OID); -// display("Jack", userJack); -// assertUserJackReadSomeModifySome(userJack, 1); -// assertJackEditSchemaReadSomeModifySome(userJack); -// -// PrismObject userGuybrush = findUserByUsername(USER_GUYBRUSH_USERNAME); -// display("Guybrush", userGuybrush); -// assertNull("Unexpected Guybrush", userGuybrush); -// -// assertAddDeny(); -// -// assertModifyAllow(UserType.class, USER_JACK_OID, UserType.F_FULL_NAME, createPolyString("Captain Jack Sparrow")); -// assertModifyAllow(UserType.class, USER_JACK_OID, SchemaConstants.PATH_ACTIVATION_VALID_FROM, -// JACK_VALID_FROM_LONG_AGO); -// assertModifyDeny(UserType.class, USER_GUYBRUSH_OID, UserType.F_DESCRIPTION, "Pirate wannabe"); -// -// assertModifyDeny(UserType.class, USER_JACK_OID, UserType.F_HONORIFIC_PREFIX, createPolyString("Captain")); -// assertModifyDeny(UserType.class, USER_GUYBRUSH_OID, UserType.F_HONORIFIC_PREFIX, createPolyString("Pirate")); -// assertModifyDeny(UserType.class, USER_BARBOSSA_OID, UserType.F_HONORIFIC_PREFIX, createPolyString("Mutinier")); -// -// assertModifyDeny(UserType.class, USER_JACK_OID, UserType.F_COST_CENTER, "V3RYC0STLY"); -// assertModifyDeny(UserType.class, USER_JACK_OID, UserType.F_ORGANIZATION, createPolyString("Brethren of the Coast")); -// -// assertDeleteDeny(); -// -// assertGlobalStateUntouched(); -// } - - private PolicyExceptionType assertPolicyException(PrismObject role, String expectedRuleName, String expectedPolicySituation) { List policyExceptions = role.asObjectable().getPolicyException(); - assertEquals("Wrong size of policyException container in "+role, 1, policyExceptions.size()); + assertEquals("Wrong size of policyException container in " + role, 1, policyExceptions.size()); PolicyExceptionType policyException = policyExceptions.get(0); - assertEquals("Wrong rule name in "+role, expectedRuleName, policyException.getRuleName()); - assertEquals("Wrong situation in "+role, expectedPolicySituation, policyException.getPolicySituation()); + assertEquals("Wrong rule name in " + role, expectedRuleName, policyException.getRuleName()); + assertEquals("Wrong situation in " + role, expectedPolicySituation, policyException.getPolicySituation()); return policyException; } - private AssignmentType assertExclusion(PrismObject roleExclusion, String excludedRoleOid) { PrismContainer assignmentContainer = roleExclusion.findContainer(RoleType.F_ASSIGNMENT); - assertNotNull("No assignment container in "+roleExclusion, assignmentContainer); - assertEquals("Wrong size of assignment container in "+roleExclusion, 1, assignmentContainer.size()); + assertNotNull("No assignment container in " + roleExclusion, assignmentContainer); + assertEquals("Wrong size of assignment container in " + roleExclusion, 1, assignmentContainer.size()); AssignmentType exclusionAssignment = assignmentContainer.getValue().asContainerable(); PolicyRuleType exclusionPolicyRule = exclusionAssignment.getPolicyRule(); - assertNotNull("No policy rule in "+roleExclusion, exclusionPolicyRule); + assertNotNull("No policy rule in " + roleExclusion, exclusionPolicyRule); PolicyConstraintsType exclusionPolicyConstraints = exclusionPolicyRule.getPolicyConstraints(); - assertNotNull("No policy rule constraints in "+roleExclusion, exclusionPolicyConstraints); + assertNotNull("No policy rule constraints in " + roleExclusion, exclusionPolicyConstraints); List exclusionExclusionPolicyConstraints = exclusionPolicyConstraints.getExclusion(); - assertEquals("Wrong size of exclusion policy constraints in "+roleExclusion, 1, exclusionExclusionPolicyConstraints.size()); + assertEquals("Wrong size of exclusion policy constraints in " + roleExclusion, 1, exclusionExclusionPolicyConstraints.size()); ExclusionPolicyConstraintType exclusionPolicyConstraint = exclusionExclusionPolicyConstraints.get(0); - assertNotNull("No exclusion policy constraint in "+roleExclusion, exclusionPolicyConstraint); + assertNotNull("No exclusion policy constraint in " + roleExclusion, exclusionPolicyConstraint); ObjectReferenceType targetRef = exclusionPolicyConstraint.getTargetRef(); - assertNotNull("No targetRef in exclusion policy constraint in "+roleExclusion, targetRef); - assertEquals("Wrong OID targetRef in exclusion policy constraint in "+roleExclusion, excludedRoleOid, targetRef.getOid()); + assertNotNull("No targetRef in exclusion policy constraint in " + roleExclusion, targetRef); + assertEquals("Wrong OID targetRef in exclusion policy constraint in " + roleExclusion, excludedRoleOid, targetRef.getOid()); return exclusionAssignment; } - @Override protected void cleanupAutzTest(String userOid, int expectedAssignments) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException, IOException { super.cleanupAutzTest(userOid, expectedAssignments); @@ -3399,19 +3314,15 @@ private void assertDeputySearchAssignmentTarget(String delegatorOid, String... e assertSearch(UserType.class, query, expectedDeputyOids); } - @Override protected void cleanupAutzTest(String userOid) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException, IOException { super.cleanupAutzTest(userOid); - Task task = taskManager.createTaskInstance(TestSecurityAdvanced.class.getName() + ".cleanupAutzTest"); + Task task = createTask("cleanupAutzTest"); OperationResult result = task.getResult(); cleanupDelete(RoleType.class, ROLE_EXCLUSION_PIRATE_OID, task, result); } - - - } diff --git a/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java b/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java index d34a43730c1..edb97e149ee 100644 --- a/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java +++ b/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java @@ -218,11 +218,20 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti if (notificationManager != null) { notificationManager.setDisabled(true); } + // TODO inttest: Previously in postInitSystem, but it should not be a problem if (dummyResourceCollection != null) { dummyResourceCollection.resetResources(); } } + // TODO left temporarily, should go away +// @Override +// public void postInitSystem(Task initTask, OperationResult initResult) throws Exception { +// if (dummyResourceCollection != null) { +// dummyResourceCollection.resetResources(); +// } +// } + protected boolean isAvoidLoggingChange() { return true; } @@ -655,7 +664,8 @@ protected void modifyAccountChangePassword(String accountOid, String newPassword modifyAccountShadowReplace(accountOid, PASSWORD_VALUE_PATH, task, result, userPasswordPs); } - protected void clearUserPassword(String userOid) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException { + protected void clearUserPassword(String userOid) + throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException { Task task = createTask("clearUserPassword"); OperationResult result = task.getResult(); List> itemDeltas = prismContext.deltaFor(UserType.class) @@ -1112,6 +1122,8 @@ protected void modifyFocusAssignment(Class f Consumer modificationBlock, boolean add, ModelExecuteOptions options, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { ObjectDelta focusDelta = createAssignmentFocusDelta(focusClass, focusOid, elementName, roleOid, refType, relation, modificationBlock, add); + // TODO inttest: seems useless and doesn't change the problem with TestSecurityAdvanced 320 + Collection> deltas = MiscSchemaUtil.createCollection(focusDelta); executeChanges(focusDelta, options, task, result); } @@ -3292,8 +3304,6 @@ protected OperationResult waitForTaskNextRun(final Task origTask, final boolean public boolean check() throws CommonException { Task freshTask = taskManager.getTaskWithResult(origTask.getOid(), waitResult); OperationResult taskResult = freshTask.getResult(); -// display("Times", longTimeToString(origLastRunStartTimestamp) + "-" + longTimeToString(origLastRunStartTimestamp) -// + " : " + longTimeToString(freshTask.getLastRunStartTimestamp()) + "-" + longTimeToString(freshTask.getLastRunFinishTimestamp())); if (verbose) { display("Check result", taskResult); } taskResultHolder.setValue(taskResult); if (isError(taskResult, checkSubresult)) { @@ -5582,7 +5592,8 @@ protected Consumer createShowTaskTreeConsumer(long period) { return task -> { try { if (lastTimeShown.get() + period < System.currentTimeMillis()) { - dumpTaskTree(task.getOid(), getResult()); + // TODO inttest: task. is missing in master, is it good? + dumpTaskTree(task.getOid(), task.getResult()); lastTimeShown.set(System.currentTimeMillis()); } } catch (CommonException e) { From 796b52ec96a4f95dbe366f3b06f5dca3724e11cd Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Sat, 29 Feb 2020 11:01:09 +0100 Subject: [PATCH 56/97] Fix namespace prefix in report task archetype --- .../resources/initial-objects/507-archetype-task-report.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gui/admin-gui/src/main/resources/initial-objects/507-archetype-task-report.xml b/gui/admin-gui/src/main/resources/initial-objects/507-archetype-task-report.xml index 518c67234f7..c86e5679b97 100644 --- a/gui/admin-gui/src/main/resources/initial-objects/507-archetype-task-report.xml +++ b/gui/admin-gui/src/main/resources/initial-objects/507-archetype-task-report.xml @@ -23,11 +23,11 @@ vacant - extension/mext:reportParam + extension/rext:reportParam visible - extension/mext:reportOutputOid + extension/rext:reportOutputOid visible From 746225c0cdc2d90fd029e47e004f9afe895d5f64 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Sat, 29 Feb 2020 12:48:14 +0100 Subject: [PATCH 57/97] fixed TestSecurityAdvanced: createAllowDenyTask was traced (wrong) Mistake on my part, perhaps hasty autocomplete. Traced task does not clean-up FATAL_ERROR results under otherwise SUCCESS results and this caused the test to fail on result assertion. --- .../midpoint/model/test/AbstractModelIntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java b/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java index 720edf95a6c..a3a2a4ab857 100644 --- a/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java +++ b/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java @@ -6315,7 +6315,7 @@ protected void assertDeleteAllow(Class type, String oi } private Task createAllowDenyTask(String opname) { - Task task = createTracedTask("createAllowDenyTask." + opname); + Task task = createTask("createAllowDenyTask." + opname); task.setOwner(getSecurityContextPrincipalFocus()); task.setChannel(SchemaConstants.CHANNEL_GUI_USER_URI); return task; From 4d7683142da36c9a8067cc0f16b225b6b73c1fb1 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Sat, 29 Feb 2020 13:31:04 +0100 Subject: [PATCH 58/97] AbstractIntegrationTest: initSystemExecuted guard, needed for gui tests --- .../midpoint/test/AbstractIntegrationTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 ac7bd1d88b1..7c4277ea8ac 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 @@ -43,6 +43,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.security.crypto.password.LdapShaPasswordEncoder; +import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; +import org.springframework.test.context.web.ServletTestExecutionListener; import org.testng.Assert; import org.testng.AssertJUnit; import org.testng.ITestResult; @@ -181,13 +183,26 @@ public abstract class AbstractIntegrationTest extends AbstractSpringTest { */ protected PredefinedTestMethodTracing predefinedTestMethodTracing; + private boolean initSystemExecuted = false; + /** * With TestNG+Spring we can use {@code PostConstruct} for class-wide initialization. * All test methods run on a single instance (unlike with JUnit). * Using {@code BeforeClass} is not good as the Spring wiring happens later. + *

+ * There is still danger that annotation processor will run this multiple times + * for web/servlet-based tests, see text context attributes + * {@link DependencyInjectionTestExecutionListener#REINJECT_DEPENDENCIES_ATTRIBUTE} + * and {@link ServletTestExecutionListener#RESET_REQUEST_CONTEXT_HOLDER_ATTRIBUTE} for more. + * That's why we start with the guard enforcing once-only initSystem execution. */ @PostConstruct public void initSystem() throws Exception { + if (initSystemExecuted) { + logger.trace("initSystem: already called for class {} - IGNORING", getClass().getName()); + return; + } + initSystemExecuted = true; logger.trace("initSystem: initializing class {}", getClass().getName()); // Check whether we are already initialized From bcbfa7cc9b79eccb328f1b9b7fa02c1955856f2f Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Sat, 29 Feb 2020 13:34:08 +0100 Subject: [PATCH 59/97] AbstractIntegrationTest: createTask separate from createPlainTask - createTask(opName) calls customizeTask, so it works like in master - createPlainTask is shortcut for taskManager.create... helping with good name of root operation, containing context (test name) --- ...bstractConfiguredModelIntegrationTest.java | 2 +- .../model/intest/gensync/TestEditSchema.java | 7 +- .../intest/security/AbstractSecurityTest.java | 2 +- .../intest/security/TestSecurityAdvanced.java | 6 +- .../test/AbstractModelIntegrationTest.java | 138 +++++++++--------- .../wf/impl/other/TestParallelApprovals.java | 14 +- .../impl/dummy/TestDummyParallelism.java | 6 +- .../test/AbstractIntegrationTest.java | 33 +++-- 8 files changed, 101 insertions(+), 107 deletions(-) diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/AbstractConfiguredModelIntegrationTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/AbstractConfiguredModelIntegrationTest.java index b03d9d8bb4a..7f8d12e1f24 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/AbstractConfiguredModelIntegrationTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/AbstractConfiguredModelIntegrationTest.java @@ -613,7 +613,7 @@ protected PrismObject getDefaultActor() { return userAdministrator; } - // TODO: let's try it without this after 6 years + // TODO inttest: let's try it without this after 6 years // @AfterClass(alwaysRun = true) public void clearClassFields() throws Exception { logger.trace("Clearing all fields for test class {}", getClass().getName()); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestEditSchema.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestEditSchema.java index d55539f3970..434df21b22e 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestEditSchema.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestEditSchema.java @@ -1164,9 +1164,6 @@ public void validate(PrismContainerDefinition credentialsDef, S @Test public void test240EditSchemaReconciliationTask() throws Exception { - final String TEST_NAME="test240EditSchemaReconciliationTask"; - displayTestTitle(TEST_NAME); - // GIVEN PrismObjectDefinition taskDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(TaskType.class); PrismObject task = taskDef.instantiate(); @@ -1177,11 +1174,11 @@ public void test240EditSchemaReconciliationTask() throws Exception { display("Task before", task); // WHEN - displayWhen(TEST_NAME); + when(); PrismObjectDefinition editDef = getEditObjectDefinition(task); // THEN - displayThen(TEST_NAME); + then(); assertObjectDefinition(editDef) .container(ObjectType.F_EXTENSION) diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/AbstractSecurityTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/AbstractSecurityTest.java index 37e1742ec02..3e9868d3c02 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/AbstractSecurityTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/AbstractSecurityTest.java @@ -1101,7 +1101,7 @@ protected void assertCanSearchRoleMembers(String roleOid, boolean expectedResult } protected void assertCanSearch(String message, Class resultType, Class objectType, String objectOid, boolean includeSpecial, ObjectQuery query, boolean expectedResult) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = createTask("assertCanSearch"); + Task task = createPlainTask("assertCanSearch"); OperationResult result = task.getResult(); String opName = "canSearch("+message+")"; logAttempt(opName); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityAdvanced.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityAdvanced.java index 8a9fe1ac33f..f211fe54dcc 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityAdvanced.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityAdvanced.java @@ -3049,7 +3049,7 @@ public void test312AutzJackPropSubtypeAllowEscapingZoneOfControl() throws Except /** * MID-4304 */ - @Test(enabled = DISABLED_IN_NEW_INTEST) + @Test public void test320AutzJackGuybrushValutDweller() throws Exception { // GIVEN cleanupAutzTest(USER_JACK_OID); @@ -3240,7 +3240,7 @@ private void modifyJackValidTo() throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - Task task = createTask("modifyJackValidTo"); + Task task = createPlainTask("modifyJackValidTo"); OperationResult result = task.getResult(); modifyUserReplace(USER_JACK_OID, SchemaConstants.PATH_ACTIVATION_VALID_TO, task, result, JACK_VALID_TO_LONG_AHEAD); assertSuccess(result); @@ -3320,7 +3320,7 @@ protected void cleanupAutzTest(String userOid) throws ObjectNotFoundException, S ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException, IOException { super.cleanupAutzTest(userOid); - Task task = createTask("cleanupAutzTest"); + Task task = createPlainTask("cleanupAutzTest"); OperationResult result = task.getResult(); cleanupDelete(RoleType.class, ROLE_EXCLUSION_PIRATE_OID, task, result); diff --git a/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java b/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java index a3a2a4ab857..c00a1c95917 100644 --- a/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java +++ b/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java @@ -113,6 +113,7 @@ import com.evolveum.midpoint.task.api.TaskExecutionStatus; import com.evolveum.midpoint.test.*; import com.evolveum.midpoint.test.asserter.*; +import com.evolveum.midpoint.test.asserter.prism.PrismContainerDefinitionAsserter; import com.evolveum.midpoint.test.util.MidPointAsserts; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.*; @@ -218,20 +219,15 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti if (notificationManager != null) { notificationManager.setDisabled(true); } - // TODO inttest: Previously in postInitSystem, but it should not be a problem + } + + @Override + public void postInitSystem(Task initTask, OperationResult initResult) throws Exception { if (dummyResourceCollection != null) { dummyResourceCollection.resetResources(); } } - // TODO left temporarily, should go away -// @Override -// public void postInitSystem(Task initTask, OperationResult initResult) throws Exception { -// if (dummyResourceCollection != null) { -// dummyResourceCollection.resetResources(); -// } -// } - protected boolean isAvoidLoggingChange() { return true; } @@ -330,7 +326,7 @@ protected void importObjectFromFile(File file, OperationResult result) throws Fi OperationResult subResult = result.createSubresult(contextName() + ".importObjectFromFile"); subResult.addParam("filename", file.getPath()); logger.trace("importObjectFromFile: {}", file); - Task task = createTask("importObjectFromFile"); + Task task = createPlainTask("importObjectFromFile"); importObjectFromFile(file, task, result); subResult.computeStatus(); if (subResult.isError()) { @@ -430,7 +426,7 @@ protected int getObjectCount(Class type) protected int getObjectCount(Class type, ObjectQuery query) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = createTask("getObjectCount"); + Task task = createPlainTask("getObjectCount"); OperationResult result = task.getResult(); List> users = modelService.searchObjects(type, query, null, task, result); if (verbose) { display(type.getSimpleName() + "s", users); } @@ -441,7 +437,7 @@ protected void searchObjectsIterative(Class type, ObjectQuery query, Consumer> handler, Integer expectedNumberOfObjects) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = createTask("searchObjectsIterative"); + Task task = createPlainTask("searchObjectsIterative"); OperationResult result = task.getResult(); final MutableInt count = new MutableInt(0); // Cannot convert to lambda here. Java does not want to understand the generic types properly. @@ -631,7 +627,7 @@ protected ObjectDelta createOldNewPasswordDelta(String oid, String old } protected void modifyUserChangePassword(String userOid, String newPassword) throws CommonException { - Task task = createTask("modifyUserChangePassword"); + Task task = createPlainTask("modifyUserChangePassword"); OperationResult result = task.getResult(); modifyUserChangePassword(userOid, newPassword, task, result); assertSuccess(result); @@ -666,7 +662,7 @@ protected void modifyAccountChangePassword(String accountOid, String newPassword protected void clearUserPassword(String userOid) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException { - Task task = createTask("clearUserPassword"); + Task task = createPlainTask("clearUserPassword"); OperationResult result = task.getResult(); List> itemDeltas = prismContext.deltaFor(UserType.class) .item(SchemaConstants.PATH_PASSWORD).replace() @@ -680,7 +676,7 @@ protected void renameObject(Class type, String oid, St } protected void recomputeUser(String userOid) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { - Task task = createTask("recomputeUser"); + Task task = createPlainTask("recomputeUser"); OperationResult result = task.getResult(); modelService.recompute(UserType.class, userOid, null, task, result); assertSuccess(result); @@ -702,7 +698,7 @@ protected void assignRole(String userOid, String roleOid) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - Task task = createTask("assignRole"); + Task task = createPlainTask("assignRole"); OperationResult result = task.getResult(); assignRole(userOid, roleOid, task, result); assertSuccess(result); @@ -796,7 +792,7 @@ protected void assignRole(String userOid, String roleOid, QName relation, ModelE protected void assignRole(String userOid, String roleOid, QName relation) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - Task task = createTask("assignRole"); + Task task = createPlainTask("assignRole"); OperationResult result = task.getResult(); assignRole(userOid, roleOid, relation, task, result); result.computeStatus(); @@ -810,7 +806,7 @@ protected void assignRole(String userOid, String roleOid, QName relation, Consum } protected void unassignRole(String userOid, String roleOid) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - Task task = createTask("unassignRole"); + Task task = createPlainTask("unassignRole"); OperationResult result = task.getResult(); unassignRole(userOid, roleOid, task, result); result.computeStatus(); @@ -897,7 +893,7 @@ protected void unassignAllRoles(String userOid) throws ObjectNotFoundException, protected void unassignAllRoles(String userOid, boolean useRawPlusRecompute) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - Task task = createTask("unassignAllRoles"); + Task task = createPlainTask("unassignAllRoles"); OperationResult result = task.getResult(); PrismObject user = modelService.getObject(UserType.class, userOid, null, task, result); Collection> modifications = new ArrayList<>(); @@ -995,7 +991,7 @@ protected void assignOrg(String userOid, String orgOid, QName relation) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - Task task = createTask("assignOrg"); + Task task = createPlainTask("assignOrg"); OperationResult result = task.getResult(); assignOrg(userOid, orgOid, relation, task, result); result.computeStatus(); @@ -1028,7 +1024,7 @@ protected void unassignOrg(String userOid, String orgOid, Task task, OperationRe } protected void unassignOrg(String userOid, String orgOid, QName relation) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - Task task = createTask("unassignOrg"); + Task task = createPlainTask("unassignOrg"); OperationResult result = task.getResult(); unassignOrg(userOid, orgOid, relation, task, result); assertSuccess(result); @@ -1185,7 +1181,7 @@ protected void unlinkUser(String userOid, String targetOid) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - Task task = createTask("unlinkUser"); + Task task = createPlainTask("unlinkUser"); OperationResult result = task.getResult(); unlink(UserType.class, userOid, targetOid, task, result); assertSuccess(result); @@ -1566,7 +1562,7 @@ protected void assignAccountToUser( } protected void assignAccount(Class type, String focusOid, String resourceOid, String intent) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = createTask("assignAccount"); + Task task = createPlainTask("assignAccount"); OperationResult result = task.getResult(); assignAccount(type, focusOid, resourceOid, intent, task, result); assertSuccess(result); @@ -1590,7 +1586,7 @@ protected void unassignAccountFromUser(String focusOid, String resourceOid, Stri } protected void unassignAccount(Class type, String focusOid, String resourceOid, String intent) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = createTask("unassignAccount"); + Task task = createPlainTask("unassignAccount"); OperationResult result = task.getResult(); unassignAccount(type, focusOid, resourceOid, intent, task, result); assertSuccess(result); @@ -1621,7 +1617,7 @@ protected void assign(Class type, String focusOid, Assi } protected PrismObject getUser(String userOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = createTask("getUser"); + Task task = createPlainTask("getUser"); OperationResult result = task.getResult(); PrismObject user = modelService.getObject(UserType.class, userOid, null, task, result); result.computeStatus(); @@ -1636,7 +1632,7 @@ protected PrismObject getUserFromRepo(String userOid) throws ObjectNot protected PrismObject findObjectByName(Class type, String name) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = createTask("findObjectByName"); + Task task = createPlainTask("findObjectByName"); OperationResult result = task.getResult(); List> objects = modelService.searchObjects(type, createNameQuery(name), null, task, result); if (objects.isEmpty()) { @@ -1667,7 +1663,7 @@ protected RoleType getRoleSimple(String oid) { } protected PrismObject getRole(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = createTask("getRole"); + Task task = createPlainTask("getRole"); OperationResult result = task.getResult(); PrismObject role = modelService.getObject(RoleType.class, oid, null, task, result); result.computeStatus(); @@ -1676,7 +1672,7 @@ protected PrismObject getRole(String oid) throws ObjectNotFoundExcepti } protected PrismObject findAccountByUsername(String username, PrismObject resource) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = createTask("findAccountByUsername"); + Task task = createPlainTask("findAccountByUsername"); OperationResult result = task.getResult(); return findAccountByUsername(username, resource, task, result); } @@ -1722,7 +1718,7 @@ protected PrismObject getShadowModelFuture(String accountOid) throws } protected PrismObject getShadowModel(String shadowOid, GetOperationOptions rootOptions, boolean assertSuccess) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = createTask("getShadowModel"); + Task task = createPlainTask("getShadowModel"); OperationResult result = task.getResult(); Collection> opts = null; if (rootOptions != null) { @@ -1741,7 +1737,7 @@ protected PrismObject getShadowModel(String shadowOid, GetOperationO protected void assertNoObject(Class type, String oid) throws SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = createTask("assertNoObject"); + Task task = createPlainTask("assertNoObject"); assertNoObject(type, oid, task, task.getResult()); } @@ -2233,7 +2229,7 @@ protected void assertHasArchetype(PrismObject< } protected void assertSubOrgs(String baseOrgOid, int expected) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = createTask("assertSubOrgs"); + Task task = createPlainTask("assertSubOrgs"); OperationResult result = task.getResult(); List> subOrgs = getSubOrgs(baseOrgOid, task, result); result.computeStatus(); @@ -2242,7 +2238,7 @@ protected void assertSubOrgs(String baseOrgOid, int expected) throws SchemaExcep } protected void assertSubOrgs(PrismObject baseOrg, int expected) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = createTask("assertSubOrgs"); + Task task = createPlainTask("assertSubOrgs"); OperationResult result = task.getResult(); List> subOrgs = getSubOrgs(baseOrg.getOid(), task, result); result.computeStatus(); @@ -2269,7 +2265,7 @@ protected String dumpOrgTree(String topOrgOid) throws SchemaException, ObjectNot } protected String dumpOrgTree(String topOrgOid, boolean dumpUsers) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = createTask("dumpOrgTree"); + Task task = createPlainTask("dumpOrgTree"); OperationResult result = task.getResult(); PrismObject topOrg = modelService.getObject(OrgType.class, topOrgOid, null, task, result); String dump = dumpOrgTree(topOrg, dumpUsers, task, result); @@ -2315,7 +2311,7 @@ private void dumpOrg(StringBuilder sb, PrismObject org, int indent) { } protected void displayUsers() throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = createTask("displayUsers"); + Task task = createPlainTask("displayUsers"); OperationResult result = task.getResult(); ResultHandler handler = (user, parentResult) -> { display("User", user); @@ -2822,7 +2818,7 @@ protected void breakAssignmentDelta(ObjectDelta userDel } protected void purgeResourceSchema(String resourceOid) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = createTask("purgeResourceSchema"); + Task task = createPlainTask("purgeResourceSchema"); OperationResult result = task.getResult(); ObjectDelta resourceDelta = prismContext.deltaFactory().object().createModificationReplaceContainer(ResourceType.class, @@ -2845,7 +2841,7 @@ protected List> searchOrg(String baseOrgOid, OrgFilter.Scop protected PrismObject searchObjectByName(Class type, String name) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = createTask("searchObjectByName"); + Task task = createPlainTask("searchObjectByName"); OperationResult result = task.getResult(); PrismObject out = searchObjectByName(type, name, task, result); result.computeStatus(); @@ -3632,7 +3628,7 @@ protected void assertTaskExecutionStatus(String taskOid, TaskExecutionStatus exp protected void setSecurityContextUser(String userOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = createTask("setSecurityContextUser"); + Task task = createPlainTask("setSecurityContextUser"); PrismObject object = modelService.getObject(UserType.class, userOid, null, task, task.getResult()); assertNotNull("User " + userOid + " is null", object.asObjectable()); @@ -3772,7 +3768,7 @@ protected ActivationType getActivation(PrismObject obj) { protected PrismObject getTask(String taskOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = createTask("getTask"); + Task task = createPlainTask("getTask"); OperationResult result = task.getResult(); PrismObject retTask = modelService.getObject(TaskType.class, taskOid, retrieveItemsNamed(TaskType.F_RESULT), task, result); result.computeStatus(); @@ -3781,7 +3777,7 @@ protected PrismObject getTask(String taskOid) } protected PrismObject getTaskTree(String taskOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = createTask("getTaskTree"); + Task task = createPlainTask("getTaskTree"); OperationResult result = task.getResult(); PrismObject retTask = modelService.getObject(TaskType.class, taskOid, retrieveItemsNamed(TaskType.F_RESULT, TaskType.F_SUBTASK), task, result); result.computeStatus(); @@ -3819,7 +3815,7 @@ protected void assertObjectDoesntExist(Class clazz, St protected PrismObject getObject(Class type, String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = createTask("getObject"); + Task task = createPlainTask("getObject"); OperationResult result = task.getResult(); PrismObject object = modelService.getObject(type, oid, null, task, result); result.computeStatus(); @@ -3829,7 +3825,7 @@ protected PrismObject getObject(Class type, String protected PrismObject getObjectViaRepo(Class type, String oid) throws ObjectNotFoundException, SchemaException { - Task task = createTask("getObjectViaRepo"); + Task task = createPlainTask("getObjectViaRepo"); OperationResult result = task.getResult(); PrismObject object = repositoryService.getObject(type, oid, null, result); result.computeStatus(); @@ -3884,7 +3880,7 @@ protected String addObject(PrismObject object) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = createTask("addObject"); + Task task = createPlainTask("addObject"); OperationResult result = task.getResult(); String oid = addObject(object, task, result); result.computeStatus(); @@ -3918,7 +3914,7 @@ protected void deleteObject(Class type, String oid) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = createTask("deleteObject"); + Task task = createPlainTask("deleteObject"); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object().createDeleteDelta(type, oid); executeChanges(delta, null, task, result); @@ -3937,7 +3933,7 @@ protected void forceDeleteShadow(String oid) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = createTask("forceDeleteShadow"); + Task task = createPlainTask("forceDeleteShadow"); OperationResult result = task.getResult(); forceDeleteObject(ShadowType.class, oid, task, result); assertSuccess(result); @@ -3957,7 +3953,7 @@ protected void addTrigger(String oid, XMLGregorianCalendar timestamp, String uri throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = createTask("addTrigger"); + Task task = createPlainTask("addTrigger"); OperationResult result = task.getResult(); TriggerType triggerType = new TriggerType(); triggerType.setTimestamp(timestamp); @@ -3971,7 +3967,7 @@ protected void addTrigger(String oid, XMLGregorianCalendar timestamp, String uri } protected void addTriggers(String oid, Collection timestamps, String uri, boolean makeDistinct) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = createTask("addTriggers"); + Task task = createPlainTask("addTriggers"); OperationResult result = task.getResult(); Collection triggers = timestamps.stream() .map(ts -> new TriggerType().timestamp(ts).handlerUri(uri)) @@ -4001,7 +3997,7 @@ private TriggerType addRandomValue(TriggerType trigger) { } protected void replaceTriggers(String oid, Collection timestamps, String uri) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = createTask("replaceTriggers"); + Task task = createPlainTask("replaceTriggers"); OperationResult result = task.getResult(); Collection triggers = timestamps.stream() .map(ts -> new TriggerType().timestamp(ts).handlerUri(uri)) @@ -4661,7 +4657,7 @@ protected void assertSecurityContextNoAuthorizationActions() { } protected void displayAllUsers() throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = createTask("displayAllUsers"); + Task task = createPlainTask("displayAllUsers"); OperationResult result = task.getResult(); ResultHandler handler = (object, parentResult) -> { display("User", object); @@ -4737,14 +4733,14 @@ protected void customizeTask(Task task) { } protected Task createTask(String operationName, MidPointPrincipal principal) { - Task task = createTask(operationName); + Task task = createPlainTask(operationName); task.setOwner(principal.getFocus().asPrismObject()); task.setChannel(DEFAULT_CHANNEL); return task; } protected void modifyRoleAddConstruction(String roleOid, long inducementId, String resourceOid) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = createTask("modifyRoleAddConstruction"); + Task task = createPlainTask("modifyRoleAddConstruction"); OperationResult result = task.getResult(); ConstructionType construction = new ConstructionType(); ObjectReferenceType resourceRedRef = new ObjectReferenceType(); @@ -4899,7 +4895,7 @@ protected AssignmentType findAssignmentByTargetRequired(PrismObject role = modelService.getObject(RoleType.class, roleOid, null, task, result); for (AssignmentType inducement : role.asObjectable().getInducement()) { @@ -4913,7 +4909,7 @@ protected AssignmentType findInducementByTarget(String roleOid, String targetOid protected void modifyRoleDeleteInducementTarget(String roleOid, String targetOid, ModelExecuteOptions options) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = createTask("modifyRoleDeleteInducementTarget"); + Task task = createPlainTask("modifyRoleDeleteInducementTarget"); OperationResult result = task.getResult(); AssignmentType inducement = findInducementByTarget(roleOid, targetOid); ObjectDelta roleDelta = @@ -5089,7 +5085,7 @@ protected Collection createConfigAttributes(String action) { } protected PrismObjectDefinition getEditObjectDefinition(PrismObject object) throws SchemaException, ConfigurationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, SecurityViolationException { - Task task = createTask("getEditObjectDefinition"); + Task task = createPlainTask("getEditObjectDefinition"); OperationResult result = task.getResult(); PrismObjectDefinition editSchema = modelInteractionService.getEditObjectDefinition(object, null, task, result); result.computeStatus(); @@ -5109,7 +5105,7 @@ protected RoleSelectionSpecification getAssigna } protected RoleSelectionSpecification getAssignableRoleSpecification(PrismObject focus, Class targetType, int assignmentOrder) throws ObjectNotFoundException, SchemaException, ConfigurationException, ExpressionEvaluationException, CommunicationException, SecurityViolationException { - Task task = createTask("getAssignableRoleSpecification"); + Task task = createPlainTask("getAssignableRoleSpecification"); OperationResult result = task.getResult(); RoleSelectionSpecification spec = modelInteractionService.getAssignableRoleSpecification(focus, targetType, assignmentOrder, task, result); assertSuccess(result); @@ -5139,7 +5135,7 @@ protected void assertAllowRequestAssignmentItems( String userOid, String targetRoleOid, ItemPath... expectedAllowedItemPaths) throws SchemaException, SecurityViolationException, CommunicationException, ObjectNotFoundException, ConfigurationException, ExpressionEvaluationException { - Task task = createTask("assertAllowRequestAssignmentItems"); + Task task = createPlainTask("assertAllowRequestAssignmentItems"); OperationResult result = task.getResult(); assertAllowRequestAssignmentItems(userOid, targetRoleOid, task, result, expectedAllowedItemPaths); assertSuccess(result); @@ -5274,7 +5270,7 @@ protected List getAuditRecords(int maxRecords, Task task, Oper protected List getObjectAuditRecords(String oid) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - Task task = createTask("getObjectAuditRecords"); + Task task = createPlainTask("getObjectAuditRecords"); OperationResult result = task.getResult(); Map params = new HashMap<>(); params.put("targetOid", oid); @@ -5349,7 +5345,7 @@ protected PrismObject getUserFromRepo(String oid, OperationResult resu // just guessing (good enough for testing) protected boolean isH2() { - Task task = createTask("isH2"); + Task task = createPlainTask("isH2"); RepositoryDiag diag = modelDiagnosticService.getRepositoryDiag(task, task.getResult()); return diag.isEmbedded() || "org.h2.Driver".equals(diag.getDriverShortName()); } @@ -5523,7 +5519,7 @@ protected void assertPasswordCompliesWithPolicy( PrismObject user, String passwordPolicyOid) throws EncryptionException, ObjectNotFoundException, ExpressionEvaluationException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException { - Task task = createTask("assertPasswordCompliesWithPolicy"); + Task task = createPlainTask("assertPasswordCompliesWithPolicy"); OperationResult result = task.getResult(); assertPasswordCompliesWithPolicy(user, passwordPolicyOid, task, result); assertSuccess(result); @@ -5612,7 +5608,7 @@ public class TestCtx { TestCtx(Object testCase, String name) { this.name = name; TestUtil.displayTestTitle(testCase, name); - task = createTask(name); + task = createPlainTask(name); result = task.getResult(); dummyAuditService.clear(); } @@ -5993,12 +5989,12 @@ protected ResourceAsserter assertResourceAfter(String oid) throws ObjectNo } // Change to PrismObjectDefinitionAsserter later - protected PrismContainerDefinitionAsserter assertObjectDefinition(PrismObjectDefinition objectDef) { + protected PrismContainerDefinitionAsserter assertObjectDefinition(PrismObjectDefinition objectDef) { return assertContainerDefinition(objectDef); } - protected PrismContainerDefinitionAsserter assertContainerDefinition(PrismContainerDefinition containerDef) { - PrismContainerDefinitionAsserter asserter = PrismContainerDefinitionAsserter.forContainerDefinition(containerDef); + protected PrismContainerDefinitionAsserter assertContainerDefinition(PrismContainerDefinition containerDef) { + PrismContainerDefinitionAsserter asserter = PrismContainerDefinitionAsserter.forContainerDefinition(containerDef); initializeAsserter(asserter); asserter.display(); return asserter; @@ -6025,7 +6021,7 @@ protected void assertGetDeny(Class type, String oid) t } protected void assertGetDeny(Class type, String oid, Collection> options) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = createTask("assertGetDeny"); + Task task = createPlainTask("assertGetDeny"); OperationResult result = task.getResult(); try { logAttempt("get", type, oid, null); @@ -6044,7 +6040,7 @@ protected PrismObject assertGetAllow(Class type, St } protected PrismObject assertGetAllow(Class type, String oid, Collection> options) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = createTask("assertGetAllow"); + Task task = createPlainTask("assertGetAllow"); OperationResult result = task.getResult(); logAttempt("get", type, oid, null); PrismObject object = modelService.getObject(type, oid, options, task, result); @@ -6136,7 +6132,7 @@ public void assertCount(int count) throws Exception { protected SearchResultList> assertSearch(Class type, ObjectQuery query, Collection> options, SearchAssertion assertion) throws Exception { - Task task = createTask("assertSearchObjects"); + Task task = createPlainTask("assertSearchObjects"); OperationResult result = task.getResult(); SearchResultList> objects; try { @@ -6153,7 +6149,7 @@ protected SearchResultList> assertSearch(C return null; // not reached } - task = createTask("assertSearchObjectsIterative"); + task = createPlainTask("assertSearchObjectsIterative"); result = task.getResult(); try { logAttempt("searchIterative", type, query); @@ -6177,7 +6173,7 @@ public boolean handle(PrismObject object, OperationResult parentResult) { return null; // not reached } - task = createTask("assertSearchObjects.count"); + task = createPlainTask("assertSearchObjects.count"); result = task.getResult(); try { logAttempt("count", type, query); @@ -6210,7 +6206,7 @@ protected void assertAddDeny(File file, ModelExecuteOptio } protected void assertAddDeny(PrismObject object, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException { - Task task = createTask("assertAddDeny"); + Task task = createPlainTask("assertAddDeny"); OperationResult result = task.getResult(); ObjectDelta addDelta = object.createAddDelta(); try { @@ -6274,7 +6270,7 @@ protected void assertDeleteDeny(Class type, String oid } protected void assertDeleteDeny(Class type, String oid, ModelExecuteOptions options) throws ObjectAlreadyExistsException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException { - Task task = createTask("assertDeleteDeny"); + Task task = createPlainTask("assertDeleteDeny"); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object().createDeleteDelta(type, oid); try { @@ -6300,7 +6296,7 @@ protected void assertDeleteAllow(Class type, String oi } protected void assertDeleteAllow(Class type, String oid, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = createTask("assertDeleteAllow"); + Task task = createPlainTask("assertDeleteAllow"); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object().createDeleteDelta(type, oid); logAttempt("delete", type, oid, null); @@ -6363,7 +6359,7 @@ protected OperationResult assertDeny(String opname, Attempt attempt) throws Exce } protected void asAdministrator(Attempt attempt) throws Exception { - Task task = createTask("asAdministrator"); + Task task = createPlainTask("asAdministrator"); OperationResult result = task.getResult(); MidPointPrincipal origPrincipal = getSecurityContextPrincipal(); login(USER_ADMINISTRATOR_USERNAME); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestParallelApprovals.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestParallelApprovals.java index 2cb2ad01d20..6f4dd217e22 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestParallelApprovals.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestParallelApprovals.java @@ -220,9 +220,9 @@ public void approveAllWorkItems(Task task, OperationResult result) throws Except public void test120ParallelApprovalsInTwoOperations() throws Exception { login(userAdministrator); - Task task0 = createTask("task0"); - Task task1 = createTask("task1"); - Task task2 = createTask("task2"); + Task task0 = createPlainTask("task0"); + Task task1 = createPlainTask("task1"); + Task task2 = createPlainTask("task2"); OperationResult result0 = task0.getResult(); OperationResult result1 = task1.getResult(); OperationResult result2 = task2.getResult(); @@ -284,10 +284,10 @@ public void test120ParallelApprovalsInTwoOperations() throws Exception { public void test130ParallelApprovalsInThreeSummarizingOperations() throws Exception { login(userAdministrator); - Task task0 = createTask("task0"); - Task task1 = createTask("task1"); - Task task2 = createTask("task2"); - Task task3 = createTask("task3"); + Task task0 = createPlainTask("task0"); + Task task1 = createPlainTask("task1"); + Task task2 = createPlainTask("task2"); + Task task3 = createPlainTask("task3"); OperationResult result0 = task0.getResult(); OperationResult result1 = task1.getResult(); OperationResult result2 = task2.getResult(); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyParallelism.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyParallelism.java index 104ae304e78..ec8a899f9d3 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyParallelism.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyParallelism.java @@ -761,7 +761,7 @@ public void test800ParallelReadAndModifyResource() throws Exception { } else if (threadIndex == CONCURRENT_TEST_THREAD_COUNT_HIGH / 2) { for (int i = 0; /* neverending */ ; i++) { - Task localTask = createTask("test-" + i); + Task localTask = createPlainTask("test-" + i); OperationResult testResult = provisioningService.testResource(RESOURCE_DUMMY_OID, localTask); logger.debug("PAR: TESTing " + threadIndex + "." + i); @@ -784,7 +784,7 @@ public void test800ParallelReadAndModifyResource() throws Exception { try { // TODO: why is the constant MESS_RESOURCE_ITERATIONS used for operations? for (int i = 0; i < MESS_RESOURCE_ITERATIONS; i++) { - Task localTask = createTask("op-" + i); + Task localTask = createPlainTask("op-" + i); OperationResult localResult = localTask.getResult(); logger.debug("PAR: OPing " + threadIndex + "." + i); @@ -855,7 +855,7 @@ private void messResource(int threadIndex, int i) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, PolicyViolationException, ObjectAlreadyExistsException, ExpressionEvaluationException { - Task task = createTask("mess-" + threadIndex + "-" + i); + Task task = createPlainTask("mess-" + threadIndex + "-" + i); OperationResult result = task.getResult(); List> deltas = deltaFor(ResourceType.class) .item(ResourceType.F_DESCRIPTION).replace("Iter " + threadIndex + "." + i) 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 7c4277ea8ac..3c3c184e6dd 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 @@ -119,11 +119,6 @@ @Listeners({ CurrentTestResultHolder.class }) public abstract class AbstractIntegrationTest extends AbstractSpringTest { - // TODO inttest: tests should be fixed and this should go before merge to master - // value is false, as it is used in enable= flag - @Deprecated - public static final boolean DISABLED_IN_NEW_INTEST = false; - protected static final String USER_ADMINISTRATOR_USERNAME = "administrator"; public static final String COMMON_DIR_NAME = "common"; @@ -157,7 +152,7 @@ public abstract class AbstractIntegrationTest extends AbstractSpringTest { /** * Task manager can be used directly in subclasses but prefer various provided methods - * like {@link #getTestTask()}, {@link #createTask}, etc. + * like {@link #getTestTask()}, {@link #createPlainTask}, etc. */ @Autowired protected TaskManager taskManager; @@ -210,7 +205,7 @@ public void initSystem() throws Exception { assertNotNull("Task manager is not wired properly", taskManager); PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); PrismTestUtil.setPrismContext(prismContext); - Task initTask = createTask("INIT"); + Task initTask = createPlainTask("INIT"); initTask.setChannel(SchemaConstants.CHANNEL_GUI_INIT_URI); OperationResult result = initTask.getResult(); @@ -239,14 +234,15 @@ protected void initSystem(Task task, OperationResult initResult) throws Exceptio * May be used to clean up initialized objects as all of the initialized objects should be * available at this time. */ - @Deprecated // let's try to use initSystem only protected void postInitSystem(Task initTask, OperationResult initResult) throws Exception { // Nothing to do by default } /** - * Creates appropriate task and result and set it into MidpointTestMethodContext. - * This implementation fully overrides (without use) the one from {@link AbstractSpringTest}. + * Creates test method context which includes customized {@link Task} + * (see {@link #createTask(String)}) and other test related info wrapped as + * {@link MidpointTestMethodContext} and stores it in thread-local variable for future access. + * This implementation fully overrides version from {@link AbstractSpringTest}. */ @BeforeMethod public void startTestContext(ITestResult testResult) { @@ -341,15 +337,21 @@ public String getTestNameShort() { } /** - * Creates new {@link Task}. + * Creates new {@link Task} with operation name prefixed with {@link #contextName()}. * For most tests this should be unnecessary and the default test-method-scoped task * that can be obtained with {@link #getTestTask()} should be enough. - * Even for multi-threaded tests we may not need a new task and new subresult - * (using {@link #createSubresult(String)} should suffice. - * Provided name is automatically prefixed by {@link #contextName()}. + * Even for multi-threaded tests we may not need the whole task - instead + * {@link #createSubresult(String)} should suffice. + */ + protected Task createPlainTask(String operationName) { + return taskManager.createTaskInstance(contextName() + "." + operationName); + } + + /** + * Just like {@link #createPlainTask} but also calls overridable {@link #customizeTask}. */ protected Task createTask(String operationName) { - Task task = taskManager.createTaskInstance(contextName() + "." + operationName); + Task task = createPlainTask(operationName); customizeTask(task); return task; } @@ -363,7 +365,6 @@ protected void customizeTask(Task task) { // nothing by default } - /** * Context name is "class-simple-name.method" if test method context is available, * otherwise it is just simple name of the test class. From 46800adeee61565b06be42bd80a38683c95b3545 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Sat, 29 Feb 2020 17:33:15 +0100 Subject: [PATCH 60/97] POMs: declared infra/test-util in parent, added to prism-impl & schema In other places version element was removed, parent will take care... --- gui/admin-gui/pom.xml | 1 - infra/common/pom.xml | 1 - infra/prism-impl/pom.xml | 5 +++++ infra/schema/pom.xml | 7 ++++++- model/certification-impl/pom.xml | 1 - model/model-common/pom.xml | 1 - model/model-impl/pom.xml | 1 - model/model-intest/pom.xml | 1 - model/model-test/pom.xml | 1 - model/notifications-impl/pom.xml | 1 - model/report-impl/pom.xml | 1 - model/workflow-impl/pom.xml | 1 - pom.xml | 5 +++++ provisioning/provisioning-impl/pom.xml | 1 - provisioning/ucf-impl-builtin/pom.xml | 1 - provisioning/ucf-impl-connid/pom.xml | 1 - repo/audit-impl/pom.xml | 1 - repo/repo-cache/pom.xml | 1 - repo/repo-common/pom.xml | 1 - repo/repo-sql-impl-test/pom.xml | 1 - repo/repo-test-util/pom.xml | 1 - repo/security-impl/pom.xml | 1 - repo/system-init/pom.xml | 1 - repo/task-quartz-impl/pom.xml | 2 -- testing/conntest/pom.xml | 1 - testing/longtest/pom.xml | 1 - testing/rest/pom.xml | 1 - testing/samples-test/pom.xml | 1 - testing/sanity/pom.xml | 1 - testing/story/pom.xml | 1 - 30 files changed, 16 insertions(+), 29 deletions(-) diff --git a/gui/admin-gui/pom.xml b/gui/admin-gui/pom.xml index bdc1af0a87c..805fd7e838c 100644 --- a/gui/admin-gui/pom.xml +++ b/gui/admin-gui/pom.xml @@ -691,7 +691,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test diff --git a/infra/common/pom.xml b/infra/common/pom.xml index cd28b157f36..c9a0371983f 100644 --- a/infra/common/pom.xml +++ b/infra/common/pom.xml @@ -139,7 +139,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test diff --git a/infra/prism-impl/pom.xml b/infra/prism-impl/pom.xml index 2250f23165e..5b971b02d26 100644 --- a/infra/prism-impl/pom.xml +++ b/infra/prism-impl/pom.xml @@ -147,6 +147,11 @@ test-ng test + + com.evolveum.midpoint.infra + test-util + test + org.assertj assertj-core diff --git a/infra/schema/pom.xml b/infra/schema/pom.xml index 0be58ba91c4..a8db16ffc5c 100644 --- a/infra/schema/pom.xml +++ b/infra/schema/pom.xml @@ -153,7 +153,12 @@ com.evolveum.midpoint.tools test-ng - 4.1-SNAPSHOT + ${project.version} + test + + + com.evolveum.midpoint.infra + test-util test diff --git a/model/certification-impl/pom.xml b/model/certification-impl/pom.xml index aa0f718526a..66cdf67cc5f 100644 --- a/model/certification-impl/pom.xml +++ b/model/certification-impl/pom.xml @@ -156,7 +156,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test diff --git a/model/model-common/pom.xml b/model/model-common/pom.xml index 3f4dd147999..2f2a73fba90 100644 --- a/model/model-common/pom.xml +++ b/model/model-common/pom.xml @@ -170,7 +170,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test diff --git a/model/model-impl/pom.xml b/model/model-impl/pom.xml index 658321c8a0d..5112a06f0ab 100644 --- a/model/model-impl/pom.xml +++ b/model/model-impl/pom.xml @@ -352,7 +352,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test diff --git a/model/model-intest/pom.xml b/model/model-intest/pom.xml index 500a5f6a34d..4aaba738eec 100644 --- a/model/model-intest/pom.xml +++ b/model/model-intest/pom.xml @@ -210,7 +210,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test diff --git a/model/model-test/pom.xml b/model/model-test/pom.xml index 956b4e839e0..2d83ff38c0c 100644 --- a/model/model-test/pom.xml +++ b/model/model-test/pom.xml @@ -28,7 +28,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT com.evolveum.midpoint.infra diff --git a/model/notifications-impl/pom.xml b/model/notifications-impl/pom.xml index e5f2d506861..30b048df08e 100644 --- a/model/notifications-impl/pom.xml +++ b/model/notifications-impl/pom.xml @@ -262,7 +262,6 @@ com.evolveum.midpoint.infra test-util - ${project.version} test diff --git a/model/report-impl/pom.xml b/model/report-impl/pom.xml index 71b1f44b91a..9d27432ea9d 100644 --- a/model/report-impl/pom.xml +++ b/model/report-impl/pom.xml @@ -251,7 +251,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test diff --git a/model/workflow-impl/pom.xml b/model/workflow-impl/pom.xml index d2baa8d0607..63993dbb824 100644 --- a/model/workflow-impl/pom.xml +++ b/model/workflow-impl/pom.xml @@ -161,7 +161,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test diff --git a/pom.xml b/pom.xml index c52c665f450..93a3dc9d889 100644 --- a/pom.xml +++ b/pom.xml @@ -1525,6 +1525,11 @@ test-ng ${project.version} + + com.evolveum.midpoint.infra + test-util + ${project.version} + diff --git a/provisioning/provisioning-impl/pom.xml b/provisioning/provisioning-impl/pom.xml index 473f404a9a2..dc51d917e10 100644 --- a/provisioning/provisioning-impl/pom.xml +++ b/provisioning/provisioning-impl/pom.xml @@ -133,7 +133,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test diff --git a/provisioning/ucf-impl-builtin/pom.xml b/provisioning/ucf-impl-builtin/pom.xml index 5fa23ce9403..c8229c2835e 100644 --- a/provisioning/ucf-impl-builtin/pom.xml +++ b/provisioning/ucf-impl-builtin/pom.xml @@ -110,7 +110,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test diff --git a/provisioning/ucf-impl-connid/pom.xml b/provisioning/ucf-impl-connid/pom.xml index 810837423b8..28aa5026ba4 100644 --- a/provisioning/ucf-impl-connid/pom.xml +++ b/provisioning/ucf-impl-connid/pom.xml @@ -105,7 +105,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test diff --git a/repo/audit-impl/pom.xml b/repo/audit-impl/pom.xml index 5ead1589716..3ebe1d9cf4d 100644 --- a/repo/audit-impl/pom.xml +++ b/repo/audit-impl/pom.xml @@ -102,7 +102,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test diff --git a/repo/repo-cache/pom.xml b/repo/repo-cache/pom.xml index 970068f5091..8e880c5616f 100644 --- a/repo/repo-cache/pom.xml +++ b/repo/repo-cache/pom.xml @@ -102,7 +102,6 @@ com.evolveum.midpoint.infra test-util - ${project.version} test diff --git a/repo/repo-common/pom.xml b/repo/repo-common/pom.xml index dfedb60a586..77532bb9728 100644 --- a/repo/repo-common/pom.xml +++ b/repo/repo-common/pom.xml @@ -176,7 +176,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test diff --git a/repo/repo-sql-impl-test/pom.xml b/repo/repo-sql-impl-test/pom.xml index 35f54a11040..cfe1d19eac7 100644 --- a/repo/repo-sql-impl-test/pom.xml +++ b/repo/repo-sql-impl-test/pom.xml @@ -188,7 +188,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test diff --git a/repo/repo-test-util/pom.xml b/repo/repo-test-util/pom.xml index 436f2c0e246..64bc9cc6b23 100644 --- a/repo/repo-test-util/pom.xml +++ b/repo/repo-test-util/pom.xml @@ -79,7 +79,6 @@ com.evolveum.midpoint.infra test-util - ${project.version} com.evolveum.midpoint.infra diff --git a/repo/security-impl/pom.xml b/repo/security-impl/pom.xml index 9d147f3e0d6..76f0cffe90d 100644 --- a/repo/security-impl/pom.xml +++ b/repo/security-impl/pom.xml @@ -115,7 +115,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test diff --git a/repo/system-init/pom.xml b/repo/system-init/pom.xml index 58a0ce9786d..5390bb8c3ef 100644 --- a/repo/system-init/pom.xml +++ b/repo/system-init/pom.xml @@ -120,7 +120,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test diff --git a/repo/task-quartz-impl/pom.xml b/repo/task-quartz-impl/pom.xml index 25a818127e7..defcac15c63 100644 --- a/repo/task-quartz-impl/pom.xml +++ b/repo/task-quartz-impl/pom.xml @@ -165,13 +165,11 @@ com.evolveum.midpoint.tools test-ng - 4.1-SNAPSHOT test com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test diff --git a/testing/conntest/pom.xml b/testing/conntest/pom.xml index c97091cf160..38c57ed1c3a 100644 --- a/testing/conntest/pom.xml +++ b/testing/conntest/pom.xml @@ -170,7 +170,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test diff --git a/testing/longtest/pom.xml b/testing/longtest/pom.xml index 8855bc6b85f..0c4580b54dd 100644 --- a/testing/longtest/pom.xml +++ b/testing/longtest/pom.xml @@ -166,7 +166,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test diff --git a/testing/rest/pom.xml b/testing/rest/pom.xml index 60a906dde26..85b17a1276f 100644 --- a/testing/rest/pom.xml +++ b/testing/rest/pom.xml @@ -193,7 +193,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test diff --git a/testing/samples-test/pom.xml b/testing/samples-test/pom.xml index e9c130e6c04..2fae7db2850 100644 --- a/testing/samples-test/pom.xml +++ b/testing/samples-test/pom.xml @@ -115,7 +115,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test diff --git a/testing/sanity/pom.xml b/testing/sanity/pom.xml index c3aeaf33f66..34815259a8d 100644 --- a/testing/sanity/pom.xml +++ b/testing/sanity/pom.xml @@ -193,7 +193,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test diff --git a/testing/story/pom.xml b/testing/story/pom.xml index 5bdb0fa3d7e..bbec43d0c7e 100644 --- a/testing/story/pom.xml +++ b/testing/story/pom.xml @@ -235,7 +235,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test From b9ead3acecff99f1a7a7fe095c8b01daa2dd0c9e Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Sun, 1 Mar 2020 01:57:27 +0100 Subject: [PATCH 61/97] POM/test: AbstractUnitTest moved to test-ng module, fixed cycle dep This probably doesn't compile, but... - AbstractUnitTest and UnitTestMixin are moved to tools/test-ng - UnitTestMixin doesn't need TestUtil for display duties anymore --- infra/prism-impl/pom.xml | 5 - infra/schema/pom.xml | 6 -- infra/test-util/pom.xml | 8 +- .../test/util/AbstractSpringTest.java | 17 ++- .../evolveum/midpoint/test/util/TestUtil.java | 53 +-------- .../midpoint/test/util/UnitTestMixin.java | 78 -------------- model/model-common/pom.xml | 5 + tools/test-ng/pom.xml | 10 +- .../tools/testng}/AbstractUnitTest.java | 26 +++-- .../midpoint/tools/testng/UnitTestMixin.java | 101 ++++++++++++++++++ 10 files changed, 158 insertions(+), 151 deletions(-) delete mode 100644 infra/test-util/src/main/java/com/evolveum/midpoint/test/util/UnitTestMixin.java rename {infra/test-util/src/main/java/com/evolveum/midpoint/test/util => tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng}/AbstractUnitTest.java (65%) create mode 100644 tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/UnitTestMixin.java diff --git a/infra/prism-impl/pom.xml b/infra/prism-impl/pom.xml index 5b971b02d26..2250f23165e 100644 --- a/infra/prism-impl/pom.xml +++ b/infra/prism-impl/pom.xml @@ -147,11 +147,6 @@ test-ng test - - com.evolveum.midpoint.infra - test-util - test - org.assertj assertj-core diff --git a/infra/schema/pom.xml b/infra/schema/pom.xml index a8db16ffc5c..ce664fbef9e 100644 --- a/infra/schema/pom.xml +++ b/infra/schema/pom.xml @@ -153,12 +153,6 @@ com.evolveum.midpoint.tools test-ng - ${project.version} - test - - - com.evolveum.midpoint.infra - test-util test diff --git a/infra/test-util/pom.xml b/infra/test-util/pom.xml index d982f65600e..2a5be4ca36d 100644 --- a/infra/test-util/pom.xml +++ b/infra/test-util/pom.xml @@ -18,7 +18,7 @@ test-util jar - midPoint Infrastructure - testing mock utils + midPoint Infrastructure - testing utils (lvl 2) @@ -105,8 +105,10 @@ com.evolveum.midpoint.tools test-ng - 4.1-SNAPSHOT - test + + + org.slf4j + slf4j-api org.apache.qpid diff --git a/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/AbstractSpringTest.java b/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/AbstractSpringTest.java index 2f3de528516..49fe1a4def1 100644 --- a/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/AbstractSpringTest.java +++ b/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/AbstractSpringTest.java @@ -6,11 +6,13 @@ */ package com.evolveum.midpoint.test.util; +import org.jetbrains.annotations.NotNull; import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; import org.testng.ITestResult; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; +import com.evolveum.midpoint.tools.testng.UnitTestMixin; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; @@ -33,7 +35,7 @@ public abstract class AbstractSpringTest extends AbstractTestNGSpringContextTest public void startTestContext(ITestResult testResult) { Class testClass = testResult.getMethod().getTestClass().getRealClass(); String testMethodName = testResult.getMethod().getMethodName(); - TestUtil.displayTestTitle(testClass.getSimpleName() + "." + testMethodName); + displayTestTitle(testClass.getSimpleName() + "." + testMethodName); TEST_CONTEXT_THREAD_LOCAL.set(testResult); } @@ -45,6 +47,19 @@ public void finishTestContext(ITestResult testResult) { displayDefaultTestFooter(testResult); } + @Override + public Trace logger() { + return logger; + } + + @NotNull + public String contextName() { + ITestResult context = TEST_CONTEXT_THREAD_LOCAL.get(); + return context != null + ? getClass().getSimpleName() + "." + context.getMethod().getMethodName() + : getClass().getSimpleName(); + } + @Override public String getTestNameShort() { return TEST_CONTEXT_THREAD_LOCAL.get().getMethod().getMethodName(); diff --git a/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/TestUtil.java b/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/TestUtil.java index 7ef4ca5e17f..e69df1ea4bc 100644 --- a/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/TestUtil.java +++ b/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/TestUtil.java @@ -44,7 +44,6 @@ import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.result.OperationResultStatus; -import com.evolveum.midpoint.schema.util.TestNameHolder; import com.evolveum.midpoint.util.JAXBUtil; import com.evolveum.midpoint.util.MiscUtil; import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; @@ -62,12 +61,6 @@ public class TestUtil { public static final int MAX_EXCEPTION_MESSAGE_LENGTH = 500; - public static final String TEST_LOG_PREFIX = "=====[ "; - public static final String TEST_LOG_SUFFIX = " ]======================================"; - public static final String TEST_OUT_PREFIX = "\n\n=====[ "; - public static final String TEST_OUT_SUFFIX = " ]======================================\n"; - public static final String TEST_OUT_FOOTER_PREFIX = "====== "; - public static final String TEST_OUT_FOOTER_SUFFIX = "\n"; public static final String TEST_OUT_SECTION_PREFIX = "\n\n----- "; public static final String TEST_OUT_SECTION_SUFFIX = " --------------------------------------\n"; public static final String TEST_LOG_SECTION_PREFIX = "----- "; @@ -161,49 +154,6 @@ public static void assertExceptionSanity(ObjectAlreadyExistsException e) { + e.getMessage().length() + " characters): " + e.getMessage(); } - public static void displayTestTitle(String testName) { - System.out.println(TEST_OUT_PREFIX + testName + TEST_OUT_SUFFIX); - LOGGER.info(TEST_LOG_PREFIX + testName + TEST_LOG_SUFFIX); - TestNameHolder.setCurrentTestName(testName); - } - - public static void displayTestTitle(Object testCase, String testName) { - String qualifiedTestName = testCase.getClass().getSimpleName() + "." + testName; - System.out.println(TEST_OUT_PREFIX + qualifiedTestName + TEST_OUT_SUFFIX); - LOGGER.info(TEST_LOG_PREFIX + qualifiedTestName + TEST_LOG_SUFFIX); - TestNameHolder.setCurrentTestName(qualifiedTestName); - } - - public static void displayFooter(String footerText) { - System.out.println(TEST_OUT_FOOTER_PREFIX + footerText + TEST_OUT_FOOTER_SUFFIX); - LOGGER.info(TEST_LOG_PREFIX + footerText + TEST_LOG_SUFFIX); - } - - @Deprecated // use version with separate testName and description - public static void displayWhen(String what) { - System.out.println(TEST_OUT_SECTION_PREFIX + " WHEN " + what + TEST_OUT_SECTION_SUFFIX); - LOGGER.info(TEST_LOG_SECTION_PREFIX + " WHEN " + what + TEST_LOG_SECTION_SUFFIX); - } - - public static void displayWhen(String testName, String description) { - if (description == null) { - description = ""; - } - System.out.println(TEST_OUT_SECTION_PREFIX + testName + ": WHEN " + description + TEST_OUT_SECTION_SUFFIX); - LOGGER.info(TEST_LOG_SECTION_PREFIX + testName + ": WHEN " + description + TEST_LOG_SECTION_SUFFIX); - } - - @Deprecated // use version with separate testName and description - public static void displayThen(String testName) { - System.out.println(TEST_OUT_SECTION_PREFIX + " THEN " + testName + TEST_OUT_SECTION_SUFFIX); - LOGGER.info(TEST_LOG_SECTION_PREFIX + " THEN " + testName + TEST_LOG_SECTION_SUFFIX); - } - - public static void displayThen(String testName, String part) { - System.out.println(TEST_OUT_SECTION_PREFIX + testName + ": THEN " + part + TEST_OUT_SECTION_SUFFIX); - LOGGER.info(TEST_LOG_SECTION_PREFIX + testName + ": THEN " + part + TEST_LOG_SECTION_SUFFIX); - } - public static void displayCleanup(String testName) { System.out.println(TEST_OUT_SECTION_PREFIX + " CLEANUP " + testName + TEST_OUT_SECTION_SUFFIX); LOGGER.info(TEST_LOG_SECTION_PREFIX + " CLEANUP " + testName + TEST_LOG_SECTION_SUFFIX); @@ -662,7 +612,8 @@ private static void assertNoPermission(File f, Set permissi assertFalse(permissions.contains(permission), f.getPath() + ": unexpected permission " + permission); } - public static ParallelTestThread[] multithread(final String TEST_NAME, MultithreadRunner lambda, int numberOfThreads, Integer randomStartDelayRange) { + public static ParallelTestThread[] multithread( + MultithreadRunner lambda, int numberOfThreads, Integer randomStartDelayRange) { ParallelTestThread[] threads = new ParallelTestThread[numberOfThreads]; System.out.println("Going to create " + numberOfThreads + " threads..."); for (int i = 0; i < numberOfThreads; i++) { diff --git a/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/UnitTestMixin.java b/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/UnitTestMixin.java deleted file mode 100644 index 540ee708e5d..00000000000 --- a/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/UnitTestMixin.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2010-2020 Evolveum and contributors - * - * This work is dual-licensed under the Apache License 2.0 - * and European Union Public License. See LICENSE file for details. - */ -package com.evolveum.midpoint.test.util; - -import org.testng.ITestResult; - -/** - * Mixin with various utility methods - typically delegating to {@link TestUtil}. - */ -public interface UnitTestMixin { - - /** - * Returns short test name - typically just a method name (without class). - */ - String getTestNameShort(); - - /** - * Displays "when" subsection header with test name. - * Even better, use {@link #when(String)} and provide human readable description. - */ - default void when() { - when(null); - } - - /** - * Displays "when" subsection header with test name and provided description (nullable). - */ - default void when(String description) { - TestUtil.displayWhen(getTestNameShort(), description); - } - - /** - * Displays "then" subsection header with test name. - * Even better, use {@link #then(String)} and provide human readable description. - */ - default void then() { - then(null); - } - - /** - * Displays "then" subsection header with test name and provided description (nullable). - */ - default void then(String description) { - TestUtil.displayThen(getTestNameShort(), description); - } - - // TODO introduce "expect" as well? sometimes we use when/then combined section - // in such a case instead of "given - when/then" we should have "given - expect" - - // TODO inline after merge to master - default void displayWhen() { - when(); - } - - // TODO inline after merge to master - default void displayWhen(String description) { - when(description); - } - - // TODO inline after merge to master - default void displayThen() { - then(); - } - - // TODO inline after merge to master - default void displayThen(String description) { - then(description); - } - - default void displayDefaultTestFooter(ITestResult testResult) { - long testMsDuration = testResult.getEndMillis() - testResult.getStartMillis(); - TestUtil.displayFooter(testResult.getMethod().getMethodName() + " FINISHED in " + testMsDuration + " ms"); - } -} diff --git a/model/model-common/pom.xml b/model/model-common/pom.xml index 2f2a73fba90..9099d5cf774 100644 --- a/model/model-common/pom.xml +++ b/model/model-common/pom.xml @@ -172,6 +172,11 @@ test-util test + + com.evolveum.midpoint.tools + test-ng + test + com.evolveum.midpoint.repo repo-test-util diff --git a/tools/test-ng/pom.xml b/tools/test-ng/pom.xml index d156cee451f..e3a842e2bae 100644 --- a/tools/test-ng/pom.xml +++ b/tools/test-ng/pom.xml @@ -18,7 +18,7 @@ test-ng jar - midPoint Infrastructure - testing support tools + midPoint Tools - testing utils (lvl 1) true @@ -29,5 +29,13 @@ org.testng testng + + org.slf4j + slf4j-api + + + org.jetbrains + annotations + diff --git a/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/AbstractUnitTest.java b/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/AbstractUnitTest.java similarity index 65% rename from infra/test-util/src/main/java/com/evolveum/midpoint/test/util/AbstractUnitTest.java rename to tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/AbstractUnitTest.java index 019b95c2b4f..3c87709dba1 100644 --- a/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/AbstractUnitTest.java +++ b/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/AbstractUnitTest.java @@ -4,15 +4,15 @@ * This work is dual-licensed under the Apache License 2.0 * and European Union Public License. See LICENSE file for details. */ -package com.evolveum.midpoint.test.util; +package com.evolveum.midpoint.tools.testng; +import org.jetbrains.annotations.NotNull; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.testng.ITestResult; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; - /** * Base test class providing basic {@link UnitTestMixin} implementation. * Can be extended by any unit test class that otherwise doesn't extend anything. @@ -21,13 +21,13 @@ public abstract class AbstractUnitTest implements UnitTestMixin { private static final ThreadLocal TEST_CONTEXT_THREAD_LOCAL = new ThreadLocal<>(); - protected final Trace logger = TraceManager.getTrace(getClass()); + protected final Logger logger = LoggerFactory.getLogger(getClass()); @BeforeMethod public void startTestContext(ITestResult testResult) { Class testClass = testResult.getMethod().getTestClass().getRealClass(); String testMethodName = testResult.getMethod().getMethodName(); - TestUtil.displayTestTitle(testClass.getSimpleName() + "." + testMethodName); + displayTestTitle(testClass.getSimpleName() + "." + testMethodName); TEST_CONTEXT_THREAD_LOCAL.set(testResult); } @@ -39,6 +39,20 @@ public void finishTestContext(ITestResult testResult) { displayDefaultTestFooter(testResult); } + @Override + public Logger logger() { + return logger; + } + + @Override + @NotNull + public String contextName() { + ITestResult context = TEST_CONTEXT_THREAD_LOCAL.get(); + return context != null + ? getClass().getSimpleName() + "." + context.getMethod().getMethodName() + : getClass().getSimpleName(); + } + @Override public String getTestNameShort() { return TEST_CONTEXT_THREAD_LOCAL.get().getMethod().getMethodName(); diff --git a/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/UnitTestMixin.java b/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/UnitTestMixin.java new file mode 100644 index 00000000000..e546a17deb2 --- /dev/null +++ b/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/UnitTestMixin.java @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2010-2020 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ +package com.evolveum.midpoint.tools.testng; + +import org.jetbrains.annotations.NotNull; +import org.slf4j.Logger; +import org.testng.ITestResult; + +/** + * Mixin with various utility methods, mostly related to test header/footer/section output/logging. + */ +public interface UnitTestMixin { + + String TEST_LOG_PREFIX = "=====[ "; + String TEST_LOG_SUFFIX = " ]======================================"; + String TEST_OUT_PREFIX = "\n\n=====[ "; + String TEST_OUT_SUFFIX = " ]======================================\n"; + String TEST_OUT_FOOTER_PREFIX = "====== "; + String TEST_OUT_FOOTER_SUFFIX = "\n"; + String TEST_OUT_SECTION_PREFIX = "\n\n----- "; + String TEST_OUT_SECTION_SUFFIX = " --------------------------------------\n"; + String TEST_LOG_SECTION_PREFIX = "----- "; + String TEST_LOG_SECTION_SUFFIX = " --------------------------------------"; + + /** + * Context name is "class-simple-name.method" if test method context is available, + * otherwise it is just simple name of the test class. + * This also works as "getTestName" including (short) class name when + * {@link #getTestNameShort()} is too short and/or class name is required. + *

+ * This is particularly useful for code that may run outside of test method. + */ + @NotNull String contextName(); + + /** + * Returns short test name - typically just a method name (without class). + * See also {@link #contextName()} if class name is required. + * This fails if test-method context is not available. + */ + String getTestNameShort(); + + /** + * Returns test class logger. + */ + Logger logger(); + + default void displayTestTitle(String testName) { + System.out.println(TEST_OUT_PREFIX + testName + TEST_OUT_SUFFIX); + logger().info(TEST_LOG_PREFIX + testName + TEST_LOG_SUFFIX); + } + + default void displayDefaultTestFooter(ITestResult testResult) { + long testMsDuration = testResult.getEndMillis() - testResult.getStartMillis(); + System.out.println(TEST_OUT_FOOTER_PREFIX + " FINISHED in " + testMsDuration + " ms" + TEST_OUT_FOOTER_SUFFIX); + logger().info(TEST_LOG_PREFIX + " FINISHED in " + testMsDuration + " ms" + TEST_LOG_SUFFIX); + } + + /** + * Displays "when" subsection header with test name. + * Even better, use {@link #when(String)} and provide human readable description. + */ + default void when() { + when(null); + } + + /** + * Displays "when" subsection header with test name and provided description (nullable). + */ + default void when(String description) { + String testName = getTestNameShort(); + if (description == null) { + description = ""; + } + System.out.println(TEST_OUT_SECTION_PREFIX + testName + ": WHEN " + description + TEST_OUT_SECTION_SUFFIX); + logger().info(TEST_LOG_SECTION_PREFIX + testName + ": WHEN " + description + TEST_LOG_SECTION_SUFFIX); + } + + /** + * Displays "then" subsection header with test name. + * Even better, use {@link #then(String)} and provide human readable description. + */ + default void then() { + then(null); + } + + /** + * Displays "then" subsection header with test name and provided description (nullable). + */ + default void then(String description) { + String testName = getTestNameShort(); + System.out.println(TEST_OUT_SECTION_PREFIX + testName + ": THEN " + description); + logger().info(TEST_LOG_SECTION_PREFIX + testName + ": THEN " + description); + } + + // TODO introduce "expect" as well? sometimes we use when/then combined section + // in such a case instead of "given - when/then" we should have "given - expect" +} From a08416de7fe22ded660555e80a653baa274ece7a Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Sun, 1 Mar 2020 01:59:04 +0100 Subject: [PATCH 62/97] TestMethodLoggerListener - unused, removed --- .../testng/TestMethodLoggerListener.java | 56 ------------------- 1 file changed, 56 deletions(-) delete mode 100644 tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/TestMethodLoggerListener.java diff --git a/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/TestMethodLoggerListener.java b/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/TestMethodLoggerListener.java deleted file mode 100644 index 7ca441f8508..00000000000 --- a/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/TestMethodLoggerListener.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2010-2014 Evolveum and contributors - * - * This work is dual-licensed under the Apache License 2.0 - * and European Union Public License. See LICENSE file for details. - */ - -package com.evolveum.midpoint.tools.testng; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; - -import org.testng.IConfigurationListener; -import org.testng.IInvokedMethod; -import org.testng.IInvokedMethodListener; -import org.testng.ITestResult; - -/** - * Created by IntelliJ IDEA. - * User: mamut - * Date: 22.11.2011 - * Time: 16:13 - * To change this template use File | Settings | File Templates. - */ -public class TestMethodLoggerListener implements IInvokedMethodListener, IConfigurationListener { - - private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); - - @Override - public void beforeInvocation(IInvokedMethod method, ITestResult testResult) { - System.out.println(DATE_FORMAT.format(new Date())); - System.out.println("----[ TestNG running method: " + method.getTestMethod().toString() + " ("+testResult+") ]----"); - } - - @Override - public void afterInvocation(IInvokedMethod method, ITestResult testResult) { - System.out.println(DATE_FORMAT.format(new Date())); - System.out.println("----[ TestNG finished method : " + method.getTestMethod().toString() + " Result: " + (testResult.isSuccess() ? "PASS" : "FAIL")+" ]----"); - } - - @Override - public void onConfigurationFailure(ITestResult res) { - System.out.println("--- TestNG configuration failure : " + res.getTestName()); - } - - @Override - public void onConfigurationSkip(ITestResult res) { - System.out.println("--- TestNG configuration skip : " + res.getTestName()); - } - - @Override - public void onConfigurationSuccess(ITestResult res) { - System.out.println("--- TestNG configuration success : " + res.getTestName()); - } -} From ba018fb5cd448e938a9075c00245add6127b3f60 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Sun, 1 Mar 2020 02:01:30 +0100 Subject: [PATCH 63/97] massive/carpet fixes of many test classes reflecting changes above --- .../midpoint/web/TestInitialObjects.java | 3 - .../midpoint/common/TestCryptoUtil.java | 3 +- .../midpoint/common/TestStaticValues.java | 3 +- .../common/refinery/TestRefinedSchema.java | 2 +- .../midpoint/prism/util/PrismTestUtil.java | 1 + .../midpoint/prism/AbstractPrismTest.java | 33 +- .../midpoint/prism/PrismInternalTestUtil.java | 9 +- .../evolveum/midpoint/prism/TestCompare.java | 45 +- .../evolveum/midpoint/prism/TestDelta.java | 432 ++++-------- .../evolveum/midpoint/prism/TestEquals.java | 20 +- .../midpoint/prism/TestPerformance.java | 3 - .../midpoint/prism/TestPolyString.java | 85 +-- .../prism/TestPrismObjectConstruction.java | 15 - .../midpoint/prism/TestPrismParsing.java | 39 +- .../midpoint/prism/TestPrismParsingXml.java | 12 - .../midpoint/prism/TestPropertyArrayList.java | 3 - .../midpoint/prism/TestUnknownItems.java | 8 - .../midpoint/prism/TestXmlSerialization.java | 5 +- .../lex/AbstractJsonLexicalProcessorTest.java | 9 - .../lex/AbstractLexicalProcessorTest.java | 40 -- .../midpoint/prism/lex/TestDomParser.java | 4 - .../prism/lex/TestProtectedString.java | 7 - .../midpoint/prism/lex/TestYamlParser.java | 5 - .../prism/query/TestQueryConverters.java | 18 +- .../midpoint/schema/TestQueryConverter.java | 142 +--- .../schema/parser/TestParseResource.java | 6 - .../test/TestAdHocCertification.java | 18 +- .../test/TestCertificationBasic.java | 277 +++----- .../test/TestCriticalRolesCertification.java | 201 ++---- .../certification/test/TestEscalation.java | 105 +-- .../test/TestManualEscalation.java | 70 +- .../test/TestRoleInducementCertification.java | 149 ++--- .../test/TestSoDCertification.java | 61 +- .../TestPolicyDrivenRoleLifecycle.java | 119 +--- .../script/ScriptExpressionFactory.java | 30 +- .../model/common/mapping/MappingImpl.java | 329 ++++----- .../model/common/AbstractModelCommonTest.java | 8 +- .../common/expression/TestExpression.java | 221 +++---- .../expression/TestExpressionProfileSafe.java | 34 +- .../common/expression/TestExpressionUtil.java | 35 +- .../expression/script/AbstractScriptTest.java | 12 +- .../common/mapping/TestMappingComplex.java | 42 +- .../common/mapping/TestMappingDomain.java | 137 ++-- .../mapping/TestMappingDynamicSimple.java | 342 ++++------ .../mapping/TestMappingDynamicSysVar.java | 393 +++++------ .../model/common/mapping/TestMappingTime.java | 19 +- .../model/impl/TestFilterResolver.java | 4 - .../model/impl/TestRefinedSchema.java | 43 +- .../model/impl/expr/TestFilterExpression.java | 65 +- .../model/impl/expr/TestModelExpressions.java | 117 ++-- .../model/impl/lens/TestAssignedMappings.java | 11 - .../impl/lens/TestAssignmentProcessor.java | 14 +- .../impl/lens/TestAssignmentProcessor2.java | 46 +- .../model/impl/lens/TestDependencies.java | 11 - .../model/impl/lens/TestPasswordPolicy.java | 111 ++-- .../lens/TestPasswordPolicyProcessor.java | 16 +- .../model/impl/lens/TestPolicyRules.java | 28 +- .../impl/lens/TestPolicyStateRecording.java | 135 ++-- .../model/impl/lens/TestProjector.java | 2 +- .../model/impl/lens/TestProjectorPersona.java | 2 - .../lens/TestProjectorRoleEntitlement.java | 4 - .../model/impl/lens/TestReconScript.java | 8 +- .../model/impl/migrator/TestMigrator.java | 2 - .../impl/misc/ShadowIntegrityCheckerTest.java | 2 - .../model/impl/misc/TestRelationRegistry.java | 4 - .../TestAbstractAuthenticationEvaluator.java | 249 ++----- .../TestGuiProfiledPrincipalManager.java | 4 +- .../midpoint/model/intest/TestActivation.java | 4 - .../midpoint/model/intest/TestCaseIgnore.java | 2 +- .../intest/TestLoggingConfiguration.java | 54 +- .../midpoint/model/intest/TestMerge.java | 25 +- .../model/intest/TestModelCrudService.java | 10 - .../intest/TestModelServiceContract.java | 14 - .../model/intest/TestModelVisualization.java | 4 - .../model/intest/TestNotifications.java | 45 +- .../intest/TestOptimizingTriggerCreator.java | 4 - .../model/intest/TestRaceConditions.java | 2 +- .../midpoint/model/intest/TestResources.java | 4 +- .../model/intest/TestSchemalessResource.java | 3 - .../model/intest/TestStrangeCases.java | 74 +-- .../model/intest/TestTolerantAttributes.java | 10 +- .../model/intest/TestTriggerTask.java | 42 +- .../model/intest/TestUserTemplate.java | 176 ++--- .../intest/TestUserTemplateWithRanges.java | 5 - .../midpoint/model/intest/TestVolatility.java | 21 +- .../async/TestAsyncUpdateGrouperJson.java | 10 - .../async/TestAsyncUpdateTaskMechanics.java | 4 +- .../intest/async/TestAsyncUpdateUcf.java | 10 - .../model/intest/async/TestNotifyChange.java | 7 - .../intest/gensync/TestRoleEntitlement.java | 2 +- .../manual/AbstractManualResourceTest.java | 23 +- .../intest/manual/TestSemiManualGrouping.java | 2 +- .../model/intest/mapping/TestMapping.java | 182 ++--- .../intest/negative/TestAssignmentErrors.java | 3 - .../intest/negative/TestBrokenResources.java | 4 - .../negative/TestModelWebServiceNegative.java | 4 - .../orgstruct/TestOrgStructCaribbean.java | 36 +- .../intest/orgstruct/TestOrgStructMeta.java | 8 +- .../intest/password/TestPasswordDefault.java | 2 - .../password/TestPasswordDefaultHashing.java | 1 - .../intest/rbac/TestSegregationOfDuties.java | 20 +- .../intest/scripting/TestScriptingBasic.java | 45 -- .../intest/security/AbstractSecurityTest.java | 2 - .../intest/security/TestSecurityBasic.java | 2 +- .../security/TestSecurityPrincipal.java | 2 +- .../intest/sync/AbstractInboundSyncTest.java | 31 +- .../sync/AbstractObjTemplateSyncTest.java | 4 +- .../AbstractSynchronizationStoryTest.java | 4 +- .../intest/sync/TestProgressReporting.java | 4 +- .../model/intest/sync/TestRecomputeTask.java | 8 +- .../sync/TestValidityRecomputeTask.java | 100 +-- .../test/AbstractModelIntegrationTest.java | 46 +- .../impl/TestTransportUtils.java | 9 +- .../AbstractTestAssignmentApproval.java | 8 +- .../TestAssignmentApprovalGlobal.java | 2 +- .../assignments/TestAssignmentsAdvanced.java | 20 +- .../impl/association/TestAddAssociation.java | 6 +- .../AbstractTestObjectLifecycleApproval.java | 2 +- .../objects/TestObjectLifecycleAdvanced.java | 10 +- .../TestObjectLifecycleApprovalGlobal.java | 2 +- .../wf/impl/other/ManualResourceTest.java | 6 +- .../wf/impl/other/TestDelegation.java | 10 +- .../wf/impl/other/TestEscalation.java | 14 +- .../midpoint/wf/impl/other/TestEvents.java | 2 +- .../wf/impl/other/TestMiscellaneous.java | 14 +- .../wf/impl/other/TestParallelApprovals.java | 4 +- .../midpoint/wf/impl/other/TestSoD.java | 6 +- .../impl/TestConnectorDiscovery.java | 41 +- .../provisioning/impl/TestDBTable.java | 28 +- .../impl/async/TestAsyncUpdate.java | 22 +- .../impl/csv/AbstractCsvTest.java | 78 +-- .../provisioning/impl/csv/TestCsvGuid.java | 4 - .../impl/csv/TestCsvUsername.java | 4 - .../impl/dummy/AbstractBasicDummyTest.java | 1 - .../provisioning/impl/dummy/TestDummy.java | 410 +++++------- .../impl/dummy/TestDummyCaching.java | 2 +- .../impl/dummy/TestDummyCaseIgnore.java | 38 +- .../impl/dummy/TestDummyExtra.java | 10 +- .../impl/dummy/TestDummyLegacy.java | 40 +- .../impl/dummy/TestDummyLimited.java | 47 +- .../impl/dummy/TestDummyNegative.java | 39 +- .../impl/dummy/TestDummyParallelism.java | 16 +- .../TestDummyPrioritiesAndReadReplace.java | 22 +- .../impl/dummy/TestDummySchemaless.java | 39 +- .../impl/dummy/TestDummySecurity.java | 53 +- .../dummy/TestDummyUuidNonUniqueName.java | 14 +- .../manual/AbstractManualResourceTest.java | 25 +- .../impl/opendj/TestOpenDjNegative.java | 7 +- .../impl/opendj/TestSynchronization.java | 44 +- .../ucf/impl/connid/AbstractUcfDummyTest.java | 4 + .../ucf/impl/connid/TestUcfDummy.java | 145 ++-- .../ucf/impl/connid/TestUcfDummyMulti.java | 26 +- .../ucf/impl/connid/TestUcfOpenDj.java | 183 ++---- .../midpoint/repo/sql/AddGetObjectTest.java | 2 +- .../midpoint/repo/sql/BaseSQLRepoTest.java | 89 ++- .../midpoint/repo/sql/CertificationTest.java | 12 +- .../repo/sql/ModifyAssignmentTest.java | 56 +- .../midpoint/repo/sql/ModifyTest.java | 163 +---- .../midpoint/repo/sql/ModifyTestReindex.java | 39 +- .../midpoint/repo/sql/ModifyUser.java | 21 +- .../midpoint/repo/sql/OrgStructTest.java | 16 +- .../midpoint/test/AbstractHigherUnitTest.java | 6 +- .../test/AbstractIntegrationTest.java | 42 +- .../midpoint/security/impl/TestEmpty.java | 3 - .../task/quartzimpl/tracing/TracerImpl.java | 1 + .../quartzimpl/AbstractTaskManagerTest.java | 1 - .../task/quartzimpl/TestWorkDistribution.java | 8 +- .../testing/conntest/Abstract389DsDnTest.java | 21 +- .../conntest/Abstract389DsNsUniqueIdTest.java | 2 +- .../testing/conntest/Abstract389DsTest.java | 2 +- .../testing/conntest/AbstractEDirTest.java | 234 ++----- .../conntest/AbstractLdapConnTest.java | 379 ++++------- .../AbstractLdapSynchronizationTest.java | 188 ++---- .../testing/conntest/AbstractLdapTest.java | 273 +++----- .../conntest/Test389DsDnLocalhost.java | 2 +- .../testing/conntest/Test389DsDnPhobos.java | 2 +- .../Test389DsNsUniqueIdLocalhost.java | 2 +- .../conntest/Test389DsNsUniqueIdPhobos.java | 2 +- .../testing/conntest/TestEDirAthena.java | 2 +- .../testing/conntest/TestEDirDeimos.java | 2 +- .../midpoint/testing/conntest/TestOpenDj.java | 2 +- .../testing/conntest/TestOpenDjDumber.java | 11 +- .../testing/conntest/TestOpenDjUnsafe.java | 9 +- .../testing/conntest/TestOpenLdap.java | 47 +- .../testing/conntest/TestOpenLdapDumber.java | 25 +- .../conntest/UserLdapConnectionConfig.java | 3 +- .../conntest/ad/AbstractAdLdapCookedTest.java | 12 +- .../AbstractAdLdapMultidomainRunAsTest.java | 10 +- .../ad/AbstractAdLdapMultidomainTest.java | 622 ++++++------------ .../conntest/ad/AbstractAdLdapRawTest.java | 10 +- .../conntest/ad/AbstractAdLdapTest.java | 323 +++------ .../midpoint/testing/conntest/ad/AdUtils.java | 88 ++- .../conntest/ad/TestAdLdapChimera.java | 2 +- .../ad/TestAdLdapChimeraNativeSchema.java | 9 +- .../conntest/ad/TestAdLdapChimeraRunAs.java | 6 +- .../conntest/ad/TestAdLdapChimeraStrange.java | 23 +- .../conntest/ad/TestAdLdapLocalhost.java | 10 +- .../testing/conntest/ad/TestAdLdapMedusa.java | 10 +- .../conntest/ad/TestAdLdapRawLocalhost.java | 10 +- .../conntest/ad/TestAdLdapRawMedusa.java | 10 +- .../longtest/TestGenericSynchronization.java | 14 +- .../testing/longtest/TestLdapUniversity.java | 18 +- .../midpoint/testing/longtest/TestRunAs.java | 3 - .../TestRestServiceProxyAuthentication.java | 13 +- .../samples/test/TestSampleImport.java | 2 +- .../midpoint/testing/sanity/TestSanity.java | 48 +- .../testing/schrodinger/TestBase.java | 12 +- .../testing/schrodinger/TestSuiteConfig.java | 42 -- .../labs/BasicProvisioningTest.java | 77 +-- .../schrodinger/page/AboutPageTest.java | 35 +- .../schrodinger/page/BulkActionsTest.java | 2 +- .../schrodinger/scenarios/AccountTests.java | 5 +- .../scenarios/AdvancedAccountTests.java | 5 +- .../scenarios/AssignmentArchetypeTest.java | 2 +- .../schrodinger/scenarios/CaseTests.java | 18 +- .../scenarios/ObjectListArchetypeTests.java | 6 +- .../scenarios/OrgMembersTests.java | 3 +- .../scenarios/OrganizationStructureTests.java | 12 +- .../scenarios/PolyStringTests.java | 2 +- .../scenarios/PostAuthenticationTests.java | 2 +- .../scenarios/ScenariosCommons.java | 2 +- .../scenarios/SynchronizationTests.java | 7 +- .../scenarios/UserAccountTests.java | 4 +- .../schrodinger/scenarios/UserPhotoTests.java | 2 +- .../testing/story/CountingInspector.java | 23 +- .../story/TestConsistencyMechanism.java | 56 +- .../midpoint/testing/story/TestDelivery.java | 12 +- .../testing/story/TestDependencyRename.java | 5 - .../testing/story/TestImportGroups.java | 7 +- .../testing/story/TestLargeGroups.java | 4 +- .../story/TestMachineIntelligence.java | 2 - .../testing/story/TestManyThreads.java | 2 +- .../testing/story/TestOperationCounts.java | 6 +- .../testing/story/TestPhotoAssignment.java | 3 - .../testing/story/TestReconNullValue.java | 4 +- .../testing/story/TestRetirement.java | 31 +- .../story/TestServiceAccountsClassifier.java | 2 +- .../testing/story/TestThresholds.java | 4 +- .../story/TestThresholdsReconFull.java | 4 +- .../testing/story/TestUniversity.java | 175 +---- .../midpoint/testing/story/TestVillage.java | 14 +- .../story/grouper/TestGrouperAsyncUpdate.java | 32 +- .../grouper/TestGrouperLargeGroupImport.java | 2 +- .../TestGrouperLargeGroupReconciliation.java | 4 +- .../testing/story/ldap/AbstractLdapTest.java | 9 +- .../story/ldap/TestLdapSyncMassive.java | 2 +- .../story/ldap/TestLdapVirtualGroup.java | 25 +- .../hierarchy/AbstractLdapHierarchyTest.java | 82 +-- .../notorious/AbstractNotoriousTest.java | 8 +- .../story/notorious/TestNotoriousOrg.java | 69 +- .../notorious/TestSupernotoriousOrg.java | 61 +- .../testing/story/perf/TestImport.java | 2 +- 252 files changed, 3578 insertions(+), 7174 deletions(-) delete mode 100644 testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/TestSuiteConfig.java diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestInitialObjects.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestInitialObjects.java index 0ff8bc58dd6..b64cf52be13 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestInitialObjects.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestInitialObjects.java @@ -30,9 +30,6 @@ public class TestInitialObjects extends AbstractGuiUnitTest { @Test public void testInitialObjects() throws Exception { - final String TEST_NAME = "testInitialObjects"; - displayTestTitle(TEST_NAME); - ObjectValidator validator = new ObjectValidator(getPrismContext()); validator.setAllWarnings(); diff --git a/infra/common/src/test/java/com/evolveum/midpoint/common/TestCryptoUtil.java b/infra/common/src/test/java/com/evolveum/midpoint/common/TestCryptoUtil.java index 7409690bf20..f4a42737afe 100644 --- a/infra/common/src/test/java/com/evolveum/midpoint/common/TestCryptoUtil.java +++ b/infra/common/src/test/java/com/evolveum/midpoint/common/TestCryptoUtil.java @@ -18,8 +18,7 @@ import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.schema.MidPointPrismContextFactory; import com.evolveum.midpoint.schema.constants.MidPointConstants; -import com.evolveum.midpoint.test.util.AbstractUnitTest; -import com.evolveum.midpoint.test.util.TestUtil; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; diff --git a/infra/common/src/test/java/com/evolveum/midpoint/common/TestStaticValues.java b/infra/common/src/test/java/com/evolveum/midpoint/common/TestStaticValues.java index 8b5373b9587..cd1b5ab8187 100644 --- a/infra/common/src/test/java/com/evolveum/midpoint/common/TestStaticValues.java +++ b/infra/common/src/test/java/com/evolveum/midpoint/common/TestStaticValues.java @@ -10,8 +10,7 @@ import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.schema.MidPointPrismContextFactory; import com.evolveum.midpoint.schema.constants.MidPointConstants; -import com.evolveum.midpoint.test.util.AbstractUnitTest; -import com.evolveum.midpoint.test.util.TestUtil; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; 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 bbe28fd82c2..547012012c8 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 @@ -56,7 +56,7 @@ import com.evolveum.midpoint.schema.util.ResourceTypeUtil; import com.evolveum.midpoint.schema.util.SchemaTestConstants; import com.evolveum.midpoint.schema.util.ShadowUtil; -import com.evolveum.midpoint.test.util.AbstractUnitTest; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.PrettyPrinter; diff --git a/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/util/PrismTestUtil.java b/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/util/PrismTestUtil.java index d735213bd6b..e3d1cf63b89 100644 --- a/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/util/PrismTestUtil.java +++ b/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/util/PrismTestUtil.java @@ -203,6 +203,7 @@ public static PolyStringType createPolyStringType(String orig, String norm) { return new PolyStringType(createPolyString(orig, norm)); } + // TODO inttest: replace with UnitTestMixin (TestUtil?) public static void displayTestTitle(String testName) { System.out.println("\n\n===[ "+testName+" ]===\n"); LOGGER.info("===[ {} ]===",testName); diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/AbstractPrismTest.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/AbstractPrismTest.java index 14eaa8edcff..f827e59b2ba 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/AbstractPrismTest.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/AbstractPrismTest.java @@ -6,9 +6,10 @@ */ package com.evolveum.midpoint.prism; -import static com.evolveum.midpoint.prism.PrismInternalTestUtil.DEFAULT_NAMESPACE_PREFIX; import static org.testng.AssertJUnit.assertEquals; +import static com.evolveum.midpoint.prism.PrismInternalTestUtil.DEFAULT_NAMESPACE_PREFIX; + import java.io.IOException; import java.util.Collection; import java.util.function.Function; @@ -24,6 +25,7 @@ import com.evolveum.midpoint.prism.foo.UserType; import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.prism.util.PrismTestUtil; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.util.DebugDumpable; import com.evolveum.midpoint.util.MiscUtil; import com.evolveum.midpoint.util.PrettyPrinter; @@ -31,9 +33,8 @@ /** * @author semancik - * */ -public class AbstractPrismTest { +public class AbstractPrismTest extends AbstractUnitTest { protected static final String USER_FOO_OID = "01234567"; @@ -43,25 +44,12 @@ public class AbstractPrismTest { protected static final String ASSIGNMENT_ABRAKADABRA_DESCRIPTION = "abra kadabra"; protected static final long ASSIGNMENT_ABRAKADABRA_ID = 222L; - @BeforeSuite public void setupDebug() throws SchemaException, SAXException, IOException { PrettyPrinter.setDefaultNamespacePrefix(DEFAULT_NAMESPACE_PREFIX); PrismTestUtil.resetPrismContext(new PrismInternalTestUtil()); } - protected void displayTestTitle(String testName) { - PrismTestUtil.displayTestTitle(testName); - } - - protected void displayWhen(String testName) { - PrismTestUtil.displayWhen(testName); - } - - protected void displayThen(String testName) { - PrismTestUtil.displayThen(testName); - } - protected void display(String title, String value) { PrismTestUtil.display(title, value); } @@ -108,7 +96,7 @@ private void assertAssignmentValueCount(ObjectDelta userDelta, int exp if (expectedValues == 0) { return; } else { - fail("No assignment delta in "+userDelta); + fail("No assignment delta in " + userDelta); } } Collection> values = lambda.apply(assignmentDelta); @@ -116,10 +104,10 @@ private void assertAssignmentValueCount(ObjectDelta userDelta, int exp if (expectedValues == 0) { return; } else { - fail("No values to delete in assignment "+type+" in "+userDelta); + fail("No values to delete in assignment " + type + " in " + userDelta); } } - assertEquals("Wrong number of assignment "+type+" values in "+userDelta, expectedValues, values.size()); + assertEquals("Wrong number of assignment " + type + " values in " + userDelta, expectedValues, values.size()); } protected void assertAssignmentDelete(ObjectDelta userDelta, Long expectedId, String expectedDescription) { @@ -137,18 +125,18 @@ protected void assertAssignmentReplace(ObjectDelta userDelta, Long exp private void assertAssignmentValue(ObjectDelta userDelta, Long expectedId, String expectedDescription, String type, Function, Collection>> lambda) { ContainerDelta assignmentDelta = userDelta.findContainerDelta(UserType.F_ASSIGNMENT); if (assignmentDelta == null) { - fail("No assignment delta in "+userDelta); + fail("No assignment delta in " + userDelta); } Collection> valuesToDelete = lambda.apply(assignmentDelta); if (valuesToDelete == null) { - fail("No values to "+type+" in assignment delta in "+userDelta); + fail("No values to " + type + " in assignment delta in " + userDelta); } for (PrismContainerValue valueToDelete : valuesToDelete) { if (assignmentMatches(valueToDelete, expectedId, expectedDescription)) { return; } } - fail("Assignment "+expectedId+":"+expectedDescription+" not found in "+userDelta); + fail("Assignment " + expectedId + ":" + expectedDescription + " not found in " + userDelta); } protected boolean assignmentMatches(PrismContainerValue assignmentValue, Long expectedId, String expectedDescription) { @@ -202,5 +190,4 @@ protected PrismObject createUserFoo() throws SchemaException { return user; } - } diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/PrismInternalTestUtil.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/PrismInternalTestUtil.java index 4ce7ee91ada..d5286a82407 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/PrismInternalTestUtil.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/PrismInternalTestUtil.java @@ -287,10 +287,6 @@ public static void assertPathVisitor(PathVisitable visitable, final ItemPath pat assertEquals("Wrong number of visits for path "+path, expectedVisits, visits.size()); } - public static void displayTestTitle(String testName) { - PrismTestUtil.displayTestTitle(testName); - } - public static void assertUserJack(PrismObject user, boolean expectRawInConstructions, boolean withIncomplete) throws SchemaException { assertUserJack(user, expectRawInConstructions, true, withIncomplete); } @@ -312,9 +308,6 @@ public static void assertUserJack(PrismObject user, boolean expectRawI assertPathVisitor(user, ItemPath.create(UserType.F_ASSIGNMENT, null), false, 2); assertPathVisitor(user, ItemPath.create(UserType.F_ACTIVATION, ActivationType.F_ENABLED), false, 1); assertPathVisitor(user, UserType.F_EXTENSION, false, 1); -// assertPathVisitor(user, ItemPath.create( -// UserType.F_EXTENSION, -// NameItemPathSegment.WILDCARD), false, 5); } public static void assertUserJackContent(PrismObject user, boolean expectRawInConstructions, @@ -462,7 +455,7 @@ private static void assertLang(Map lang, String key, String expe assertEquals("Wrong lang in polystring for key "+key, expectedValue, lang.get(key)); } - private static void assertUserJackExtension(PrismObject user, boolean withIncomplete) throws SchemaException { + private static void assertUserJackExtension(PrismObject user, boolean withIncomplete) { PrismContext prismContext = user.getPrismContext(); PrismContainer extension = user.getExtension(); assertContainerDefinition(extension, "extension", DOMUtil.XSD_ANY, 0, 1); diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestCompare.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestCompare.java index 142edbfa703..f7a04dd4294 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestCompare.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestCompare.java @@ -37,7 +37,7 @@ public abstract class TestCompare extends AbstractPrismTest { private static final QName REF_QNAME = new QName(NS_FOO, "ref"); - private static final QName REF_TYPE_QNAME = new QName(NS_FOO, "RefType");; + private static final QName REF_TYPE_QNAME = new QName(NS_FOO, "RefType"); protected abstract String getSubdirName(); @@ -56,22 +56,16 @@ protected File getFile(String baseName) { */ @Test public void testCompareJack() throws SchemaException, SAXException, IOException { - final String TEST_NAME="testCompareJack"; - displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = constructInitializedPrismContext(); -// Document document = DOMUtil.parseFile(USER_JACK_FILE_XML); -// Element userElement = DOMUtil.getFirstChildElement(document); - PrismObject user1 = prismContext.parseObject(getFile(USER_JACK_FILE_BASENAME)); PrismObject user2 = prismContext.parseObject(getFile(USER_JACK_FILE_BASENAME)); // WHEN, THEN - assertTrue("Users not the same (PrismObject)(1)", user1.equals(user2)); - assertTrue("Users not the same (PrismObject)(2)", user2.equals(user1)); + assertEquals("Users not the same (PrismObject)(1)", user2, user1); + assertEquals("Users not the same (PrismObject)(2)", user1, user2); // Following line won't work here. We don't have proper generated classes here. // It is tested in the "schema" project that has a proper code generation @@ -87,9 +81,6 @@ public void testCompareJack() throws SchemaException, SAXException, IOException */ @Test public void testDiffJack() throws Exception { - final String TEST_NAME="testDiffJack"; - displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = constructInitializedPrismContext(); @@ -144,9 +135,6 @@ public void testDiffJack() throws Exception { */ @Test public void testDiffJackLiteral() throws Exception { - final String TEST_NAME="testDiffJackLiteral"; - displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = constructInitializedPrismContext(); @@ -194,9 +182,6 @@ public void testDiffJackLiteral() throws Exception { @Test public void testDiffPatchRoundTrip() throws SchemaException, SAXException, IOException { - final String TEST_NAME="testDiffPatchRoundTrip"; - displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = constructInitializedPrismContext(); @@ -206,27 +191,18 @@ public void testDiffPatchRoundTrip() throws SchemaException, SAXException, IOExc ObjectDelta jackDelta = jackOriginal.diff(jackModified); -// System.out.println("jackOriginal:\n" + prismContext.getXnodeProcessor().serializeObject(jackOriginal).debugDump(1)); -// System.out.println("jackModified:\n" + prismContext.getXnodeProcessor().serializeObject(jackModified).debugDump(1)); -// System.out.println("jackDelta:\n" + jackDelta.debugDump()); - jackDelta.assertDefinitions(); jackDelta.checkConsistence(true, true, true); // WHEN jackDelta.applyTo(jackOriginal); -// System.out.println("jackOriginal after applying delta:\n" + prismContext.getXnodeProcessor().serializeObject(jackOriginal).debugDump(1)); - // THEN assertTrue("Roundtrip failed", jackOriginal.equivalent(jackModified)); } @Test public void testEqualsReferenceValues() throws Exception { - final String TEST_NAME="testEqualsReferenceValues"; - displayTestTitle(TEST_NAME); - PrismContext prismContext = constructInitializedPrismContext(); PrismReferenceValue val11 = new PrismReferenceValueImpl("oid1"); @@ -270,7 +246,6 @@ public void testEqualsReferenceValues() throws Exception { yetAnotherDifferentUser.setPropertyRealValue(UserType.F_FULL_NAME, "John J Random"); val35.setObject(yetAnotherDifferentUser); - assertTrue("val11 - val11", val11.equals(val11)); assertTrue("val11 - val12", val11.equals(val12)); assertTrue("val12 - val11", val12.equals(val11)); @@ -299,9 +274,6 @@ public void testEqualsReferenceValues() throws Exception { @Test public void testEqualsReferenceValuesSchema() throws Exception { - final String TEST_NAME="testEqualsReferenceValuesSchema"; - displayTestTitle(TEST_NAME); - PrismContext prismContext = constructInitializedPrismContext(); MutablePrismReferenceDefinition ref1Def = prismContext.definitionFactory().createReferenceDefinition(REF_QNAME, REF_TYPE_QNAME); @@ -389,21 +361,10 @@ public void testEqualsReferenceValuesSchema() throws Exception { assertFalse("val43 - val21", val43.equals(val21)); assertFalse("val43 - val22", val43.equals(val22)); assertTrue("val43 - val23", val43.equals(val23)); - - -// assertTrue("val11 - val11", val11.equals(val11)); -// assertTrue("val11 - val11", val11.equals(val11)); -// assertTrue("val11 - val11", val11.equals(val11)); -// assertTrue("val11 - val11", val11.equals(val11)); - - } @Test public void testDiffReferences() throws Exception { - final String TEST_NAME="testDiffReferences"; - displayTestTitle(TEST_NAME); - if (!"xml".equals(getFilenameSuffix())) { return; } diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestDelta.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestDelta.java index fcb7ead5e63..60fbcf69145 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestDelta.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestDelta.java @@ -6,15 +6,20 @@ */ package com.evolveum.midpoint.prism; -import static com.evolveum.midpoint.prism.PrismInternalTestUtil.*; import static org.testng.AssertJUnit.*; -import java.util.Collection; +import static com.evolveum.midpoint.prism.PrismInternalTestUtil.*; +import java.util.Collection; import javax.xml.datatype.XMLGregorianCalendar; -import com.evolveum.midpoint.prism.delta.*; +import org.testng.AssertJUnit; +import org.testng.annotations.Test; +import com.evolveum.midpoint.prism.delta.*; +import com.evolveum.midpoint.prism.foo.ActivationType; +import com.evolveum.midpoint.prism.foo.AssignmentType; +import com.evolveum.midpoint.prism.foo.UserType; import com.evolveum.midpoint.prism.impl.PrismPropertyValueImpl; import com.evolveum.midpoint.prism.impl.PrismReferenceDefinitionImpl; import com.evolveum.midpoint.prism.impl.PrismReferenceValueImpl; @@ -23,12 +28,6 @@ import com.evolveum.midpoint.prism.impl.delta.PropertyDeltaImpl; import com.evolveum.midpoint.prism.impl.delta.ReferenceDeltaImpl; import com.evolveum.midpoint.prism.path.ItemPath; -import org.testng.AssertJUnit; -import org.testng.annotations.Test; - -import com.evolveum.midpoint.prism.foo.ActivationType; -import com.evolveum.midpoint.prism.foo.AssignmentType; -import com.evolveum.midpoint.prism.foo.UserType; import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; @@ -43,9 +42,6 @@ public class TestDelta extends AbstractPrismTest { @Test public void testDeltaPaths() throws Exception { - final String TEST_NAME="testDeltaPaths"; - displayTestTitle(TEST_NAME); - PrismContext prismContext = getPrismContext(); PrismPropertyDefinition descDefinition = prismContext.definitionFactory().createPropertyDefinition(UserType.F_DESCRIPTION, @@ -65,8 +61,8 @@ public void testDeltaPaths() throws Exception { assignmentValue1.setPropertyRealValue(AssignmentType.F_DESCRIPTION, ASSIGNMENT_PATLAMA_DESCRIPTION, PrismTestUtil.getPrismContext()); ObjectDelta assObjDelta1 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddContainer(UserType.class, USER_FOO_OID, - UserType.F_ASSIGNMENT, assignmentValue1); - ItemDelta assDelta1 = assObjDelta1.getModifications().iterator().next(); + UserType.F_ASSIGNMENT, assignmentValue1); + ItemDelta assDelta1 = assObjDelta1.getModifications().iterator().next(); assertPath(assDelta1, UserType.F_ASSIGNMENT); PrismContainerValue assignmentValue2 = prismContext.itemFactory().createContainerValue(); @@ -74,8 +70,8 @@ public void testDeltaPaths() throws Exception { assignmentValue1.setPropertyRealValue(AssignmentType.F_DESCRIPTION, "jamalalicha patlama paprtala", PrismTestUtil.getPrismContext()); ObjectDelta assObjDelta2 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddContainer(UserType.class, USER_FOO_OID, - UserType.F_ASSIGNMENT, assignmentValue2); - ItemDelta assDelta2 = assObjDelta2.getModifications().iterator().next(); + UserType.F_ASSIGNMENT, assignmentValue2); + ItemDelta assDelta2 = assObjDelta2.getModifications().iterator().next(); assertPath(assDelta2, UserType.F_ASSIGNMENT); PrismPropertyDefinition assDescDefinition = prismContext.definitionFactory().createPropertyDefinition(AssignmentType.F_DESCRIPTION, @@ -90,18 +86,15 @@ public void testDeltaPaths() throws Exception { } - private void assertPath(ItemDelta delta, ItemPath expectedPath) { - PrismAsserts.assertPathEquivalent("Wrong path in "+delta, expectedPath, delta.getPath()); + private void assertPath(ItemDelta delta, ItemPath expectedPath) { + PrismAsserts.assertPathEquivalent("Wrong path in " + delta, expectedPath, delta.getPath()); } @Test - public void testPropertyDeltaMerge01() throws Exception { - final String TEST_NAME="testPropertyDeltaMerge01"; - displayTestTitle(TEST_NAME); - + public void testPropertyDeltaMerge01() { // GIVEN - PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory().createPropertyDefinition(UserType.F_DESCRIPTION, - DOMUtil.XSD_STRING); + PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory() + .createPropertyDefinition(UserType.F_DESCRIPTION, DOMUtil.XSD_STRING); PropertyDelta delta1 = new PropertyDeltaImpl(propertyDefinition, PrismTestUtil.getPrismContext()); delta1.addRealValuesToAdd("add1"); @@ -122,13 +115,10 @@ public void testPropertyDeltaMerge01() throws Exception { } @Test - public void testPropertyDeltaMerge02() throws Exception { - final String TEST_NAME="testPropertyDeltaMerge02"; - displayTestTitle(TEST_NAME); - + public void testPropertyDeltaMerge02() { // GIVEN - PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory().createPropertyDefinition(UserType.F_DESCRIPTION, - DOMUtil.XSD_STRING); + PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory() + .createPropertyDefinition(UserType.F_DESCRIPTION, DOMUtil.XSD_STRING); PropertyDelta delta1 = new PropertyDeltaImpl(propertyDefinition, PrismTestUtil.getPrismContext()); delta1.addRealValuesToDelete("del1"); @@ -149,13 +139,10 @@ public void testPropertyDeltaMerge02() throws Exception { } @Test - public void testPropertyDeltaMerge03() throws Exception { - final String TEST_NAME="testPropertyDeltaMerge03"; - displayTestTitle(TEST_NAME); - + public void testPropertyDeltaMerge03() { // GIVEN - PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory().createPropertyDefinition(UserType.F_DESCRIPTION, - DOMUtil.XSD_STRING); + PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory() + .createPropertyDefinition(UserType.F_DESCRIPTION, DOMUtil.XSD_STRING); PropertyDelta delta1 = new PropertyDeltaImpl(propertyDefinition, PrismTestUtil.getPrismContext()); delta1.addRealValuesToAdd("add1"); @@ -178,13 +165,10 @@ public void testPropertyDeltaMerge03() throws Exception { } @Test - public void testPropertyDeltaMerge04() throws Exception { - final String TEST_NAME="testPropertyDeltaMerge04"; - displayTestTitle(TEST_NAME); - + public void testPropertyDeltaMerge04() { // GIVEN - PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory().createPropertyDefinition(UserType.F_DESCRIPTION, - DOMUtil.XSD_STRING); + PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory() + .createPropertyDefinition(UserType.F_DESCRIPTION, DOMUtil.XSD_STRING); PropertyDelta delta1 = new PropertyDeltaImpl(propertyDefinition, PrismTestUtil.getPrismContext()); delta1.addRealValuesToAdd("add1"); @@ -207,13 +191,10 @@ public void testPropertyDeltaMerge04() throws Exception { } @Test - public void testPropertyDeltaMerge05() throws Exception { - final String TEST_NAME="testPropertyDeltaMerge05"; - displayTestTitle(TEST_NAME); - + public void testPropertyDeltaMerge05() { // GIVEN - PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory().createPropertyDefinition(UserType.F_DESCRIPTION, - DOMUtil.XSD_STRING); + PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory() + .createPropertyDefinition(UserType.F_DESCRIPTION, DOMUtil.XSD_STRING); PropertyDelta delta1 = new PropertyDeltaImpl(propertyDefinition, PrismTestUtil.getPrismContext()); delta1.addRealValuesToAdd("add1"); @@ -235,13 +216,10 @@ public void testPropertyDeltaMerge05() throws Exception { } @Test - public void testPropertyDeltaMerge06() throws Exception { - final String TEST_NAME="testPropertyDeltaMerge06"; - displayTestTitle(TEST_NAME); - + public void testPropertyDeltaMerge06() { // GIVEN - PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory().createPropertyDefinition(UserType.F_DESCRIPTION, - DOMUtil.XSD_STRING); + PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory() + .createPropertyDefinition(UserType.F_DESCRIPTION, DOMUtil.XSD_STRING); PropertyDelta delta1 = new PropertyDeltaImpl(propertyDefinition, PrismTestUtil.getPrismContext()); delta1.addRealValuesToAdd("add1"); @@ -263,13 +241,10 @@ public void testPropertyDeltaMerge06() throws Exception { } @Test - public void testPropertyDeltaMerge10() throws Exception { - final String TEST_NAME="testPropertyDeltaMerge10"; - displayTestTitle(TEST_NAME); - + public void testPropertyDeltaMerge10() { // GIVEN - PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory().createPropertyDefinition(UserType.F_DESCRIPTION, - DOMUtil.XSD_STRING); + PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory() + .createPropertyDefinition(UserType.F_DESCRIPTION, DOMUtil.XSD_STRING); PropertyDelta delta1 = new PropertyDeltaImpl(propertyDefinition, PrismTestUtil.getPrismContext()); delta1.setRealValuesToReplace("r1x", "r1y"); @@ -290,13 +265,10 @@ public void testPropertyDeltaMerge10() throws Exception { } @Test - public void testPropertyDeltaMerge11() throws Exception { - final String TEST_NAME="testPropertyDeltaMerge11"; - displayTestTitle(TEST_NAME); - + public void testPropertyDeltaMerge11() { // GIVEN - PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory().createPropertyDefinition(UserType.F_DESCRIPTION, - DOMUtil.XSD_STRING); + PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory() + .createPropertyDefinition(UserType.F_DESCRIPTION, DOMUtil.XSD_STRING); PropertyDelta delta1 = new PropertyDeltaImpl(propertyDefinition, PrismTestUtil.getPrismContext()); delta1.setRealValuesToReplace("r1x", "r1y"); @@ -318,13 +290,10 @@ public void testPropertyDeltaMerge11() throws Exception { } @Test - public void testPropertyDeltaMerge12() throws Exception { - final String TEST_NAME="testPropertyDeltaMerge12"; - displayTestTitle(TEST_NAME); - + public void testPropertyDeltaMerge12() { // GIVEN - PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory().createPropertyDefinition(UserType.F_DESCRIPTION, - DOMUtil.XSD_STRING); + PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory() + .createPropertyDefinition(UserType.F_DESCRIPTION, DOMUtil.XSD_STRING); PropertyDelta delta1 = new PropertyDeltaImpl(propertyDefinition, PrismTestUtil.getPrismContext()); delta1.setRealValuesToReplace("r1x", "r1y"); @@ -347,9 +316,6 @@ public void testPropertyDeltaMerge12() throws Exception { @Test public void testPropertyDeltaMerge13() throws Exception { - final String TEST_NAME="testPropertyDeltaMerge13"; - displayTestTitle(TEST_NAME); - // GIVEN PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory().createPropertyDefinition(UserType.F_DESCRIPTION, DOMUtil.XSD_STRING); @@ -374,9 +340,6 @@ public void testPropertyDeltaMerge13() throws Exception { @Test public void testPropertyDeltaMerge20() throws Exception { - final String TEST_NAME="testPropertyDeltaMerge20"; - displayTestTitle(TEST_NAME); - // GIVEN PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory().createPropertyDefinition(UserType.F_DESCRIPTION, DOMUtil.XSD_STRING); @@ -402,9 +365,6 @@ public void testPropertyDeltaMerge20() throws Exception { @Test public void testPropertyDeltaSwallow01() throws Exception { - final String TEST_NAME="testPropertyDeltaSwallow01"; - displayTestTitle(TEST_NAME); - // GIVEN PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory().createPropertyDefinition(UserType.F_DESCRIPTION, DOMUtil.XSD_STRING); @@ -412,7 +372,7 @@ public void testPropertyDeltaSwallow01() throws Exception { PropertyDelta delta1 = new PropertyDeltaImpl(propertyDefinition, PrismTestUtil.getPrismContext()); delta1.addRealValuesToAdd("add1"); ObjectDelta objectDelta = new ObjectDeltaImpl<>(UserType.class, ChangeType.MODIFY, - PrismTestUtil.getPrismContext()); + PrismTestUtil.getPrismContext()); objectDelta.addModification(delta1); PropertyDelta delta2 = new PropertyDeltaImpl(propertyDefinition, PrismTestUtil.getPrismContext()); @@ -434,9 +394,6 @@ public void testPropertyDeltaSwallow01() throws Exception { @Test public void testSummarize01() throws Exception { - final String TEST_NAME="testSummarize01"; - displayTestTitle(TEST_NAME); - // GIVEN PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory().createPropertyDefinition(UserType.F_DESCRIPTION, DOMUtil.XSD_STRING); @@ -444,13 +401,13 @@ public void testSummarize01() throws Exception { PropertyDelta delta1 = new PropertyDeltaImpl(propertyDefinition, PrismTestUtil.getPrismContext()); delta1.addRealValuesToAdd("add1"); ObjectDelta objectDelta1 = new ObjectDeltaImpl<>(UserType.class, ChangeType.MODIFY, - PrismTestUtil.getPrismContext()); + PrismTestUtil.getPrismContext()); objectDelta1.addModification(delta1); PropertyDelta delta2 = new PropertyDeltaImpl(propertyDefinition, PrismTestUtil.getPrismContext()); delta2.addRealValuesToAdd("add2"); ObjectDelta objectDelta2 = new ObjectDeltaImpl<>(UserType.class, ChangeType.MODIFY, - PrismTestUtil.getPrismContext()); + PrismTestUtil.getPrismContext()); objectDelta2.addModification(delta2); // WHEN @@ -469,9 +426,6 @@ public void testSummarize01() throws Exception { @Test public void testSummarize02() throws Exception { - final String TEST_NAME="testSummarize02"; - displayTestTitle(TEST_NAME); - // GIVEN PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory().createPropertyDefinition(UserType.F_DESCRIPTION, DOMUtil.XSD_STRING); @@ -479,13 +433,13 @@ public void testSummarize02() throws Exception { PropertyDelta delta1 = new PropertyDeltaImpl(propertyDefinition, PrismTestUtil.getPrismContext()); delta1.addRealValuesToDelete("del1"); ObjectDelta objectDelta1 = new ObjectDeltaImpl<>(UserType.class, ChangeType.MODIFY, - PrismTestUtil.getPrismContext()); + PrismTestUtil.getPrismContext()); objectDelta1.addModification(delta1); PropertyDelta delta2 = new PropertyDeltaImpl(propertyDefinition, PrismTestUtil.getPrismContext()); delta2.addRealValuesToDelete("del2"); ObjectDelta objectDelta2 = new ObjectDeltaImpl<>(UserType.class, ChangeType.MODIFY, - PrismTestUtil.getPrismContext()); + PrismTestUtil.getPrismContext()); objectDelta2.addModification(delta2); // WHEN @@ -504,9 +458,6 @@ public void testSummarize02() throws Exception { @Test public void testSummarize05() throws Exception { - final String TEST_NAME="testSummarize05"; - displayTestTitle(TEST_NAME); - // GIVEN PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory().createPropertyDefinition(UserType.F_DESCRIPTION, DOMUtil.XSD_STRING); @@ -515,14 +466,14 @@ public void testSummarize05() throws Exception { // Let's complicate the things a bit with origin. This should work even though origins do not match. delta1.addValueToAdd(new PrismPropertyValueImpl<>("add1", OriginType.OUTBOUND, null)); ObjectDelta objectDelta1 = new ObjectDeltaImpl<>(UserType.class, ChangeType.MODIFY, - PrismTestUtil.getPrismContext()); + PrismTestUtil.getPrismContext()); objectDelta1.addModification(delta1); PropertyDelta delta2 = new PropertyDeltaImpl(propertyDefinition, PrismTestUtil.getPrismContext()); delta2.addRealValuesToAdd("add2"); delta2.addRealValuesToDelete("add1"); ObjectDelta objectDelta2 = new ObjectDeltaImpl<>(UserType.class, ChangeType.MODIFY, - PrismTestUtil.getPrismContext()); + PrismTestUtil.getPrismContext()); objectDelta2.addModification(delta2); // WHEN @@ -541,9 +492,6 @@ public void testSummarize05() throws Exception { @Test public void testSummarize06() throws Exception { - final String TEST_NAME="testSummarize06"; - displayTestTitle(TEST_NAME); - // GIVEN PrismReferenceDefinition referenceDefinition = new PrismReferenceDefinitionImpl(UserType.F_PARENT_ORG_REF, OBJECT_REFERENCE_TYPE_QNAME, PrismTestUtil.getPrismContext()); @@ -551,13 +499,13 @@ public void testSummarize06() throws Exception { ReferenceDelta delta1 = new ReferenceDeltaImpl(referenceDefinition, PrismTestUtil.getPrismContext()); delta1.addValueToAdd(new PrismReferenceValueImpl("oid1")); ObjectDelta objectDelta1 = new ObjectDeltaImpl<>(UserType.class, ChangeType.MODIFY, - PrismTestUtil.getPrismContext()); + PrismTestUtil.getPrismContext()); objectDelta1.addModification(delta1); ReferenceDelta delta2 = new ReferenceDeltaImpl(referenceDefinition, PrismTestUtil.getPrismContext()); delta2.addValueToAdd(new PrismReferenceValueImpl("oid1")); // here we add the same value ObjectDelta objectDelta2 = new ObjectDeltaImpl<>(UserType.class, ChangeType.MODIFY, - PrismTestUtil.getPrismContext()); + PrismTestUtil.getPrismContext()); objectDelta2.addModification(delta2); // WHEN @@ -576,10 +524,7 @@ public void testSummarize06() throws Exception { @Test public void testAddPropertyMulti() throws Exception { - final String TEST_NAME="testAddPropertyMulti"; - displayTestTitle(TEST_NAME); // GIVEN - // User PrismObject user = createUserFooPatlama(); @@ -601,10 +546,7 @@ public void testAddPropertyMulti() throws Exception { @Test public void testAddAssignmentSameNullIdApplyToObject() throws Exception { - final String TEST_NAME="testAddAssignmentSameNullIdApplyToObject"; - displayTestTitle(TEST_NAME); // GIVEN - // User PrismObject user = createUserFooPatlama(); @@ -615,7 +557,7 @@ public void testAddAssignmentSameNullIdApplyToObject() throws Exception { ObjectDelta userDelta = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddContainer(UserType.class, USER_FOO_OID, - UserType.F_ASSIGNMENT, assignmentValue); + UserType.F_ASSIGNMENT, assignmentValue); // WHEN userDelta.applyTo(user); @@ -632,8 +574,6 @@ public void testAddAssignmentSameNullIdApplyToObject() throws Exception { @Test public void testAddAssignmentSameNullIdSwallow() throws Exception { - final String TEST_NAME="testAddAssignmentSameNullIdSwallow"; - displayTestTitle(TEST_NAME); // GIVEN //Delta 1 @@ -643,7 +583,7 @@ public void testAddAssignmentSameNullIdSwallow() throws Exception { ObjectDelta userDelta1 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddContainer(UserType.class, USER_FOO_OID, - UserType.F_ASSIGNMENT, assignmentValue1); + UserType.F_ASSIGNMENT, assignmentValue1); //Delta 2 PrismContainerValue assignmentValue2 = getPrismContext().itemFactory().createContainerValue(); @@ -674,8 +614,6 @@ public void testAddAssignmentSameNullIdSwallow() throws Exception { @Test public void testAddAssignmentDifferentNullIdSwallow() throws Exception { - final String TEST_NAME="testAddAssignmentDifferentNullIdSwallow"; - displayTestTitle(TEST_NAME); // GIVEN //Delta 1 @@ -685,7 +623,7 @@ public void testAddAssignmentDifferentNullIdSwallow() throws Exception { ObjectDelta userDelta1 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddContainer(UserType.class, USER_FOO_OID, - UserType.F_ASSIGNMENT, assignmentValue1); + UserType.F_ASSIGNMENT, assignmentValue1); //Delta 2 PrismContainerValue assignmentValue2 = getPrismContext().itemFactory().createContainerValue(); @@ -708,14 +646,12 @@ public void testAddAssignmentDifferentNullIdSwallow() throws Exception { PrismAsserts.assertNoReplace(containerDeltaAfter); Collection> valuesToAdd = containerDeltaAfter.getValuesToAdd(); assertEquals("Unexpected number of values to add", 2, valuesToAdd.size()); - assertTrue("Value "+assignmentValue1+" missing ", valuesToAdd.contains(assignmentValue1)); - assertTrue("Value "+assignmentValue2+" missing ", valuesToAdd.contains(assignmentValue2)); + assertTrue("Value " + assignmentValue1 + " missing ", valuesToAdd.contains(assignmentValue1)); + assertTrue("Value " + assignmentValue2 + " missing ", valuesToAdd.contains(assignmentValue2)); } @Test public void testAddAssignmentDifferentFirstIdSwallow() throws Exception { - final String TEST_NAME="testAddAssignmentDifferentFirstIdSwallow"; - displayTestTitle(TEST_NAME); // GIVEN //Delta 1 @@ -725,7 +661,7 @@ public void testAddAssignmentDifferentFirstIdSwallow() throws Exception { ObjectDelta userDelta1 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddContainer(UserType.class, USER_FOO_OID, - UserType.F_ASSIGNMENT, assignmentValue1); + UserType.F_ASSIGNMENT, assignmentValue1); //Delta 2 PrismContainerValue assignmentValue2 = getPrismContext().itemFactory().createContainerValue(); @@ -747,14 +683,12 @@ public void testAddAssignmentDifferentFirstIdSwallow() throws Exception { PrismAsserts.assertNoReplace(containerDeltaAfter); Collection> valuesToAdd = containerDeltaAfter.getValuesToAdd(); assertEquals("Unexpected number of values to add", 2, valuesToAdd.size()); - assertTrue("Value "+assignmentValue1+" missing ", valuesToAdd.contains(assignmentValue1)); - assertTrue("Value "+assignmentValue2+" missing ", valuesToAdd.contains(assignmentValue2)); + assertTrue("Value " + assignmentValue1 + " missing ", valuesToAdd.contains(assignmentValue1)); + assertTrue("Value " + assignmentValue2 + " missing ", valuesToAdd.contains(assignmentValue2)); } @Test public void testAddAssignmentDifferentSecondIdSwallow() throws Exception { - final String TEST_NAME="testAddAssignmentDifferentSecondIdSwallow"; - displayTestTitle(TEST_NAME); // GIVEN //Delta 1 @@ -764,13 +698,13 @@ public void testAddAssignmentDifferentSecondIdSwallow() throws Exception { ObjectDelta userDelta1 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddContainer(UserType.class, USER_FOO_OID, - UserType.F_ASSIGNMENT, assignmentValue1); + UserType.F_ASSIGNMENT, assignmentValue1); //Delta 2 PrismContainerValue assignmentValue2 = getPrismContext().itemFactory().createContainerValue(); assignmentValue2.setId(USER_ASSIGNMENT_2_ID); assignmentValue2.setPropertyRealValue(AssignmentType.F_DESCRIPTION, ASSIGNMENT_ABRAKADABRA_DESCRIPTION, PrismTestUtil.getPrismContext()); - ContainerDelta containerDelta2 = ContainerDeltaImpl.createDelta(UserType.F_ASSIGNMENT,getUserTypeDefinition()); + ContainerDelta containerDelta2 = ContainerDeltaImpl.createDelta(UserType.F_ASSIGNMENT, getUserTypeDefinition()); containerDelta2.addValueToAdd(assignmentValue2); // WHEN @@ -786,14 +720,12 @@ public void testAddAssignmentDifferentSecondIdSwallow() throws Exception { PrismAsserts.assertNoReplace(containerDeltaAfter); Collection> valuesToAdd = containerDeltaAfter.getValuesToAdd(); assertEquals("Unexpected number of values to add", 2, valuesToAdd.size()); - assertTrue("Value "+assignmentValue1+" missing ", valuesToAdd.contains(assignmentValue1)); - assertTrue("Value "+assignmentValue2+" missing ", valuesToAdd.contains(assignmentValue2)); + assertTrue("Value " + assignmentValue1 + " missing ", valuesToAdd.contains(assignmentValue1)); + assertTrue("Value " + assignmentValue2 + " missing ", valuesToAdd.contains(assignmentValue2)); } @Test public void testAddAssignmentDifferentTwoIdsSwallow() throws Exception { - final String TEST_NAME="testAddAssignmentDifferentTwoIdsSwallow"; - displayTestTitle(TEST_NAME); // GIVEN //Delta 1 @@ -803,13 +735,13 @@ public void testAddAssignmentDifferentTwoIdsSwallow() throws Exception { ObjectDelta userDelta1 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddContainer(UserType.class, USER_FOO_OID, - UserType.F_ASSIGNMENT, assignmentValue1); + UserType.F_ASSIGNMENT, assignmentValue1); //Delta 2 PrismContainerValue assignmentValue2 = getPrismContext().itemFactory().createContainerValue(); assignmentValue2.setId(USER_ASSIGNMENT_2_ID); assignmentValue2.setPropertyRealValue(AssignmentType.F_DESCRIPTION, ASSIGNMENT_ABRAKADABRA_DESCRIPTION, PrismTestUtil.getPrismContext()); - ContainerDelta containerDelta2 = ContainerDeltaImpl.createDelta(UserType.F_ASSIGNMENT,getUserTypeDefinition()); + ContainerDelta containerDelta2 = ContainerDeltaImpl.createDelta(UserType.F_ASSIGNMENT, getUserTypeDefinition()); containerDelta2.addValueToAdd(assignmentValue2); // WHEN @@ -825,14 +757,12 @@ public void testAddAssignmentDifferentTwoIdsSwallow() throws Exception { PrismAsserts.assertNoReplace(containerDeltaAfter); Collection> valuesToAdd = containerDeltaAfter.getValuesToAdd(); assertEquals("Unexpected number of values to add", 2, valuesToAdd.size()); - assertTrue("Value "+assignmentValue1+" missing ", valuesToAdd.contains(assignmentValue1)); - assertTrue("Value "+assignmentValue2+" missing ", valuesToAdd.contains(assignmentValue2)); + assertTrue("Value " + assignmentValue1 + " missing ", valuesToAdd.contains(assignmentValue1)); + assertTrue("Value " + assignmentValue2 + " missing ", valuesToAdd.contains(assignmentValue2)); } @Test public void testAddAssignmentDifferentIdSameSwallow() throws Exception { - final String TEST_NAME="testAddAssignmentDifferentIdSameSwallow"; - displayTestTitle(TEST_NAME); // GIVEN //Delta 1 @@ -842,13 +772,13 @@ public void testAddAssignmentDifferentIdSameSwallow() throws Exception { ObjectDelta userDelta1 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddContainer(UserType.class, USER_FOO_OID, - UserType.F_ASSIGNMENT, assignmentValue1); + UserType.F_ASSIGNMENT, assignmentValue1); //Delta 2 PrismContainerValue assignmentValue2 = getPrismContext().itemFactory().createContainerValue(); assignmentValue2.setId(USER_ASSIGNMENT_1_ID); assignmentValue2.setPropertyRealValue(AssignmentType.F_DESCRIPTION, ASSIGNMENT_PATLAMA_DESCRIPTION, PrismTestUtil.getPrismContext()); - ContainerDelta containerDelta2 = ContainerDeltaImpl.createDelta(UserType.F_ASSIGNMENT,getUserTypeDefinition()); + ContainerDelta containerDelta2 = ContainerDeltaImpl.createDelta(UserType.F_ASSIGNMENT, getUserTypeDefinition()); containerDelta2.addValueToAdd(assignmentValue2); // WHEN @@ -864,14 +794,12 @@ public void testAddAssignmentDifferentIdSameSwallow() throws Exception { PrismAsserts.assertNoReplace(containerDeltaAfter); Collection> valuesToAdd = containerDeltaAfter.getValuesToAdd(); assertEquals("Unexpected number of values to add", 1, valuesToAdd.size()); - assertTrue("Value "+assignmentValue1+" missing ", valuesToAdd.contains(assignmentValue1)); + assertTrue("Value " + assignmentValue1 + " missing ", valuesToAdd.contains(assignmentValue1)); } // MID-1296 - @Test(enabled=false) + @Test(enabled = false) public void testAddAssignmentDifferentIdConflictSwallow() throws Exception { - final String TEST_NAME="testAddAssignmentDifferentIdConflictSwallow"; - displayTestTitle(TEST_NAME); // GIVEN //Delta 1 @@ -881,7 +809,7 @@ public void testAddAssignmentDifferentIdConflictSwallow() throws Exception { ObjectDelta userDelta1 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddContainer(UserType.class, USER_FOO_OID, - UserType.F_ASSIGNMENT, assignmentValue1); + UserType.F_ASSIGNMENT, assignmentValue1); //Delta 2 PrismContainerValue assignmentValue2 = getPrismContext().itemFactory().createContainerValue(); @@ -898,8 +826,6 @@ public void testAddAssignmentDifferentIdConflictSwallow() throws Exception { @Test public void testAddDeltaAddAssignmentDifferentNoIdSwallow() throws Exception { - final String TEST_NAME="testAddDeltaAddAssignmentDifferentNoIdSwallow"; - displayTestTitle(TEST_NAME); // GIVEN //Delta 1 @@ -910,7 +836,7 @@ public void testAddDeltaAddAssignmentDifferentNoIdSwallow() throws Exception { PrismContainerValue assignmentValue2 = getPrismContext().itemFactory().createContainerValue(); // null container ID assignmentValue2.setPropertyRealValue(AssignmentType.F_DESCRIPTION, ASSIGNMENT_ABRAKADABRA_DESCRIPTION, PrismTestUtil.getPrismContext()); - ContainerDelta containerDelta2 = ContainerDeltaImpl.createDelta(UserType.F_ASSIGNMENT,getUserTypeDefinition()); + ContainerDelta containerDelta2 = ContainerDeltaImpl.createDelta(UserType.F_ASSIGNMENT, getUserTypeDefinition()); containerDelta2.addValueToAdd(assignmentValue2); // WHEN @@ -927,16 +853,14 @@ public void testAddDeltaAddAssignmentDifferentNoIdSwallow() throws Exception { Collection> valuesToAdd = containerDeltaAfter.getValuesToAdd(); assertEquals("Unexpected number of values to add", 2, valuesToAdd.size()); PrismContainer user1AssignmentCont = user.findContainer(UserType.F_ASSIGNMENT); - for (PrismContainerValue cval: user1AssignmentCont.getValues()) { - assertTrue("Value "+cval+" missing ", valuesToAdd.contains(cval)); + for (PrismContainerValue cval : user1AssignmentCont.getValues()) { + assertTrue("Value " + cval + " missing ", valuesToAdd.contains(cval)); } - assertTrue("Value "+assignmentValue2+" missing ", valuesToAdd.contains(assignmentValue2)); + assertTrue("Value " + assignmentValue2 + " missing ", valuesToAdd.contains(assignmentValue2)); } @Test public void testAddDeltaNoAssignmentAddAssignmentDifferentNoIdSwallow() throws Exception { - final String TEST_NAME="testAddDeltaNoAssignmentAddAssignmentDifferentNoIdSwallow"; - displayTestTitle(TEST_NAME); // GIVEN //Delta 1 @@ -947,7 +871,7 @@ public void testAddDeltaNoAssignmentAddAssignmentDifferentNoIdSwallow() throws E PrismContainerValue assignmentValue2 = getPrismContext().itemFactory().createContainerValue(); // null container ID assignmentValue2.setPropertyRealValue(AssignmentType.F_DESCRIPTION, ASSIGNMENT_ABRAKADABRA_DESCRIPTION, PrismTestUtil.getPrismContext()); - ContainerDelta containerDelta2 = ContainerDeltaImpl.createDelta(UserType.F_ASSIGNMENT,getUserTypeDefinition()); + ContainerDelta containerDelta2 = ContainerDeltaImpl.createDelta(UserType.F_ASSIGNMENT, getUserTypeDefinition()); containerDelta2.addValueToAdd(assignmentValue2); // WHEN @@ -963,13 +887,11 @@ public void testAddDeltaNoAssignmentAddAssignmentDifferentNoIdSwallow() throws E PrismAsserts.assertNoReplace(containerDeltaAfter); Collection> valuesToAdd = containerDeltaAfter.getValuesToAdd(); assertEquals("Unexpected number of values to add", 1, valuesToAdd.size()); - assertTrue("Value "+assignmentValue2+" missing ", valuesToAdd.contains(assignmentValue2)); + assertTrue("Value " + assignmentValue2 + " missing ", valuesToAdd.contains(assignmentValue2)); } @Test public void testAddDeltaNoAssignmentAddAssignmentDifferentIdSwallow() throws Exception { - final String TEST_NAME="testAddDeltaNoAssignmentAddAssignmentDifferentIdSwallow"; - displayTestTitle(TEST_NAME); // GIVEN //Delta 1 @@ -980,7 +902,7 @@ public void testAddDeltaNoAssignmentAddAssignmentDifferentIdSwallow() throws Exc PrismContainerValue assignmentValue2 = getPrismContext().itemFactory().createContainerValue(); assignmentValue2.setId(USER_ASSIGNMENT_2_ID); assignmentValue2.setPropertyRealValue(AssignmentType.F_DESCRIPTION, ASSIGNMENT_ABRAKADABRA_DESCRIPTION, PrismTestUtil.getPrismContext()); - ContainerDelta containerDelta2 = ContainerDeltaImpl.createDelta(UserType.F_ASSIGNMENT,getUserTypeDefinition()); + ContainerDelta containerDelta2 = ContainerDeltaImpl.createDelta(UserType.F_ASSIGNMENT, getUserTypeDefinition()); containerDelta2.addValueToAdd(assignmentValue2); // WHEN @@ -996,13 +918,11 @@ public void testAddDeltaNoAssignmentAddAssignmentDifferentIdSwallow() throws Exc PrismAsserts.assertNoReplace(containerDeltaAfter); Collection> valuesToAdd = containerDeltaAfter.getValuesToAdd(); assertEquals("Unexpected number of values to add", 1, valuesToAdd.size()); - assertTrue("Value "+assignmentValue2+" missing ", valuesToAdd.contains(assignmentValue2)); + assertTrue("Value " + assignmentValue2 + " missing ", valuesToAdd.contains(assignmentValue2)); } @Test public void testAddAssignmentActivationDifferentNullIdApplyToObject() throws Exception { - final String TEST_NAME="testAddAssignmentActivationDifferentNullIdApplyToObject"; - displayTestTitle(TEST_NAME); // GIVEN // User @@ -1015,10 +935,10 @@ public void testAddAssignmentActivationDifferentNullIdApplyToObject() throws Exc ObjectDelta userDelta = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddContainer(UserType.class, USER_FOO_OID, - ItemPath.create(UserType.F_ASSIGNMENT, - // We really need ID here. Otherwise it would not be clear to which assignment to add - 123L, - AssignmentType.F_ACTIVATION), + ItemPath.create(UserType.F_ASSIGNMENT, + // We really need ID here. Otherwise it would not be clear to which assignment to add + 123L, + AssignmentType.F_ACTIVATION), activationValue); // WHEN @@ -1038,14 +958,12 @@ public void testAddAssignmentActivationDifferentNullIdApplyToObject() throws Exc @Test public void testObjectDeltaApplyToAdd() throws Exception { - final String TEST_NAME="testObjectDeltaApplyToAdd"; - displayTestTitle(TEST_NAME); // GIVEN PrismObject user = PrismTestUtil.parseObject(USER_JACK_FILE_XML); //Delta ObjectDelta userDelta = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, USER_FOO_OID, - UserType.F_LOCALITY, "Caribbean"); + UserType.F_LOCALITY, "Caribbean"); // WHEN userDelta.applyTo(user); @@ -1058,14 +976,12 @@ public void testObjectDeltaApplyToAdd() throws Exception { @Test public void testObjectDeltaApplyToDelete() throws Exception { - final String TEST_NAME="testObjectDeltaApplyToDelete"; - displayTestTitle(TEST_NAME); // GIVEN PrismObject user = PrismTestUtil.parseObject(USER_JACK_FILE_XML); //Delta ObjectDelta userDelta = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationDeleteProperty(UserType.class, USER_FOO_OID, - UserType.F_ADDITIONAL_NAMES, "Jackie"); + UserType.F_ADDITIONAL_NAMES, "Jackie"); // WHEN userDelta.applyTo(user); @@ -1078,14 +994,12 @@ public void testObjectDeltaApplyToDelete() throws Exception { @Test public void testObjectDeltaApplyToReplace() throws Exception { - final String TEST_NAME="testObjectDeltaApplyToReplace"; - displayTestTitle(TEST_NAME); // GIVEN PrismObject user = PrismTestUtil.parseObject(USER_JACK_FILE_XML); //Delta ObjectDelta userDelta = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, USER_FOO_OID, - UserType.F_ADDITIONAL_NAMES, "Cpt"); + UserType.F_ADDITIONAL_NAMES, "Cpt"); // WHEN userDelta.applyTo(user); @@ -1098,14 +1012,12 @@ public void testObjectDeltaApplyToReplace() throws Exception { @Test public void testObjectDeltaApplyToReplaceEmpty() throws Exception { - final String TEST_NAME="testObjectDeltaApplyToReplaceEmpty"; - displayTestTitle(TEST_NAME); // GIVEN PrismObject user = PrismTestUtil.parseObject(USER_JACK_FILE_XML); //Delta ObjectDelta userDelta = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, USER_FOO_OID, - UserType.F_ADDITIONAL_NAMES); + UserType.F_ADDITIONAL_NAMES); // WHEN userDelta.applyTo(user); @@ -1118,8 +1030,6 @@ public void testObjectDeltaApplyToReplaceEmpty() throws Exception { @Test public void testObjectDeltaFindItemDeltaModifyProperty() throws Exception { - final String TEST_NAME="testObjectDeltaFindItemDeltaModifyProperty"; - displayTestTitle(TEST_NAME); // GIVEN ObjectDelta userDelta = createDeltaForFindItem(false); @@ -1131,17 +1041,15 @@ public void testObjectDeltaFindItemDeltaModifyProperty() throws Exception { // THEN PrismAsserts.assertInstanceOf(PropertyDelta.class, itemDelta); PrismAsserts.assertPathEquivalent("paths are different", itemDeltaPath, itemDelta.getPath()); - PrismAsserts.assertPropertyValues("Wrong replace values in "+itemDelta, - ((PropertyDelta)itemDelta).getValuesToReplace(), "Guybrush"); + PrismAsserts.assertPropertyValues("Wrong replace values in " + itemDelta, + ((PropertyDelta) itemDelta).getValuesToReplace(), "Guybrush"); } @Test public void testObjectDeltaFindItemDeltaModifyPropertyInAddedContainer() throws Exception { - final String TEST_NAME="testObjectDeltaFindItemDeltaModifyPropertyInAddedContainer"; - displayTestTitle(TEST_NAME); // GIVEN ObjectDelta userDelta = createDeltaForFindItem(false); - System.out.println("Object delta:\n"+userDelta.debugDump()); + System.out.println("Object delta:\n" + userDelta.debugDump()); ItemPath itemDeltaPath = ItemPath.create(UserType.F_ACTIVATION, ActivationType.F_ENABLED); @@ -1149,20 +1057,18 @@ public void testObjectDeltaFindItemDeltaModifyPropertyInAddedContainer() throws ItemDelta itemDelta = userDelta.findItemDelta(itemDeltaPath); // THEN - System.out.println("Item delta:\n"+(itemDelta==null?"null":itemDelta.debugDump())); + System.out.println("Item delta:\n" + (itemDelta == null ? "null" : itemDelta.debugDump())); PrismAsserts.assertInstanceOf(PropertyDelta.class, itemDelta); assertEquals(itemDeltaPath, itemDelta.getPath()); - PrismAsserts.assertPropertyValues("Wrong add values in "+itemDelta, - ((PropertyDelta)itemDelta).getValuesToAdd(), Boolean.TRUE); + PrismAsserts.assertPropertyValues("Wrong add values in " + itemDelta, + ((PropertyDelta) itemDelta).getValuesToAdd(), Boolean.TRUE); } @Test public void testObjectDeltaFindItemDeltaModifyNonExistentPropertyInAddedContainer() throws Exception { - final String TEST_NAME="testObjectDeltaFindItemDeltaModifyNonExistentPropertyInAddedContainer"; - displayTestTitle(TEST_NAME); // GIVEN ObjectDelta userDelta = createDeltaForFindItem(false); - System.out.println("Object delta:\n"+userDelta.debugDump()); + System.out.println("Object delta:\n" + userDelta.debugDump()); ItemPath itemDeltaPath = ItemPath.create(UserType.F_ACTIVATION, ActivationType.F_VALID_TO); // not present in the delta @@ -1170,17 +1076,15 @@ public void testObjectDeltaFindItemDeltaModifyNonExistentPropertyInAddedContaine ItemDelta itemDelta = userDelta.findItemDelta(itemDeltaPath); // THEN - System.out.println("Item delta:\n"+(itemDelta==null?"null":itemDelta.debugDump())); + System.out.println("Item delta:\n" + (itemDelta == null ? "null" : itemDelta.debugDump())); assertNull("Found delta even if it shouldn't", itemDelta); } @Test public void testObjectDeltaFindItemDeltaModifyPropertyInReplacedContainer() throws Exception { - final String TEST_NAME="testObjectDeltaFindItemDeltaModifyPropertyInReplacedContainer"; - displayTestTitle(TEST_NAME); // GIVEN ObjectDelta userDelta = createDeltaForFindItem(true); - System.out.println("Object delta:\n"+userDelta.debugDump()); + System.out.println("Object delta:\n" + userDelta.debugDump()); ItemPath itemDeltaPath = ItemPath.create(UserType.F_ACTIVATION, ActivationType.F_ENABLED); @@ -1188,7 +1092,7 @@ public void testObjectDeltaFindItemDeltaModifyPropertyInReplacedContainer() thro ItemDelta itemDelta = userDelta.findItemDelta(itemDeltaPath); // THEN - System.out.println("Item delta:\n"+(itemDelta==null?"null":itemDelta.debugDump())); + System.out.println("Item delta:\n" + (itemDelta == null ? "null" : itemDelta.debugDump())); PrismAsserts.assertInstanceOf(PropertyDelta.class, itemDelta); assertEquals(itemDeltaPath, itemDelta.getPath()); // TODO @@ -1204,11 +1108,9 @@ public void testObjectDeltaFindItemDeltaModifyPropertyInReplacedContainer() thro @Test // MID-4689 public void testObjectDeltaFindItemDeltaModifyNonExistentPropertyInReplacedContainer() throws Exception { - final String TEST_NAME="testObjectDeltaFindItemDeltaModifyNonExistentPropertyInReplacedContainer"; - displayTestTitle(TEST_NAME); // GIVEN ObjectDelta userDelta = createDeltaForFindItem(true); - System.out.println("Object delta:\n"+userDelta.debugDump()); + System.out.println("Object delta:\n" + userDelta.debugDump()); ItemPath itemDeltaPath = ItemPath.create(UserType.F_ACTIVATION, ActivationType.F_VALID_TO); // not present in the delta @@ -1216,14 +1118,14 @@ public void testObjectDeltaFindItemDeltaModifyNonExistentPropertyInReplacedConta ItemDelta itemDelta = userDelta.findItemDelta(itemDeltaPath); // THEN - System.out.println("Item delta:\n"+(itemDelta==null?"null":itemDelta.debugDump())); + System.out.println("Item delta:\n" + (itemDelta == null ? "null" : itemDelta.debugDump())); assertNull("Found delta even if it shouldn't", itemDelta); } private ObjectDelta createDeltaForFindItem(boolean containerReplace) throws SchemaException { ObjectDelta userDelta = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, USER_FOO_OID, - UserType.F_LOCALITY, "Caribbean"); + UserType.F_LOCALITY, "Caribbean"); userDelta.addModificationReplaceProperty(UserType.F_GIVEN_NAME, "Guybrush"); ContainerDelta activationDelta = userDelta.createContainerModification(UserType.F_ACTIVATION); @@ -1250,17 +1152,15 @@ private ObjectDelta createDeltaForFindItem(boolean containerReplace) t */ @Test public void testObjectDeltaUnion01Simple() throws Exception { - final String TEST_NAME="testObjectDeltaUnion01Simple"; - displayTestTitle(TEST_NAME); // GIVEN //Delta ObjectDelta userDelta1 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, USER_FOO_OID, - UserType.F_FULL_NAME, PrismTestUtil.createPolyString("baz")); + UserType.F_FULL_NAME, PrismTestUtil.createPolyString("baz")); ObjectDelta userDelta2 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, USER_FOO_OID, - UserType.F_FULL_NAME, PrismTestUtil.createPolyString("baz")); + UserType.F_FULL_NAME, PrismTestUtil.createPolyString("baz")); // WHEN ObjectDelta userDeltaUnion = ObjectDeltaCollectionsUtil.union(userDelta1, userDelta2); @@ -1274,14 +1174,11 @@ public void testObjectDeltaUnion01Simple() throws Exception { */ @Test public void testObjectDeltaUnion01Metadata() throws Exception { - final String TEST_NAME="testObjectDeltaUnion01Metadata"; - displayTestTitle(TEST_NAME); // GIVEN ObjectDelta userDelta1 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, USER_FOO_OID, - UserType.F_FULL_NAME, PrismTestUtil.createPolyString("baz")); - + UserType.F_FULL_NAME, PrismTestUtil.createPolyString("baz")); PropertyDelta fullNameDelta2 = getPrismContext().deltaFactory().property().createDelta(UserType.F_FULL_NAME, UserType.class); PrismPropertyValue fullNameValue2 = new PrismPropertyValueImpl<>(PrismTestUtil.createPolyString("baz")); @@ -1314,17 +1211,15 @@ private void assertUnion01Delta(ObjectDelta userDeltaUnion) { */ @Test public void testObjectDeltaUnion02() throws Exception { - final String TEST_NAME="testObjectDeltaUnion02"; - displayTestTitle(TEST_NAME); // GIVEN //Delta ObjectDelta userDelta1 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, USER_FOO_OID, - UserType.F_FULL_NAME); + UserType.F_FULL_NAME); ObjectDelta userDelta2 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, USER_FOO_OID, - UserType.F_FULL_NAME, PrismTestUtil.createPolyString("baz")); + UserType.F_FULL_NAME, PrismTestUtil.createPolyString("baz")); // WHEN ObjectDelta userDeltaUnion = ObjectDeltaCollectionsUtil.union(userDelta1, userDelta2); @@ -1344,17 +1239,15 @@ public void testObjectDeltaUnion02() throws Exception { */ @Test public void testObjectDeltaUnion03() throws Exception { - final String TEST_NAME="testObjectDeltaUnion03"; - displayTestTitle(TEST_NAME); // GIVEN //Delta ObjectDelta userDelta1 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, USER_FOO_OID, - UserType.F_FULL_NAME); + UserType.F_FULL_NAME); ObjectDelta userDelta2 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, USER_FOO_OID, - UserType.F_FULL_NAME, PrismTestUtil.createPolyString("baz")); + UserType.F_FULL_NAME, PrismTestUtil.createPolyString("baz")); // WHEN ObjectDelta userDeltaUnion = ObjectDeltaCollectionsUtil.union(userDelta1, userDelta2); @@ -1381,16 +1274,14 @@ private PropertyDelta getCheckedPropertyDeltaFromUnion(ObjectDelta userDelta1 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, USER_FOO_OID, - UserType.F_ADDITIONAL_NAMES, PrismTestUtil.createPolyString("foo")); + UserType.F_ADDITIONAL_NAMES, PrismTestUtil.createPolyString("foo")); ObjectDelta userDelta2 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, USER_FOO_OID, - UserType.F_ADDITIONAL_NAMES, PrismTestUtil.createPolyString("bar")); + UserType.F_ADDITIONAL_NAMES, PrismTestUtil.createPolyString("bar")); // WHEN ObjectDelta userDeltaSum = ObjectDeltaCollectionsUtil.summarize(userDelta1, userDelta2); @@ -1406,16 +1297,14 @@ public void testObjectDeltaSummarizeModifyAdd() throws Exception { @Test public void testObjectDeltaSummarizeModifyReplace() throws Exception { - final String TEST_NAME="testObjectDeltaSummarizeModifyReplace"; - displayTestTitle(TEST_NAME); // GIVEN ObjectDelta userDelta1 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, USER_FOO_OID, - UserType.F_FULL_NAME, PrismTestUtil.createPolyString("foo")); + UserType.F_FULL_NAME, PrismTestUtil.createPolyString("foo")); ObjectDelta userDelta2 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, USER_FOO_OID, - UserType.F_FULL_NAME, PrismTestUtil.createPolyString("bar")); + UserType.F_FULL_NAME, PrismTestUtil.createPolyString("bar")); // WHEN ObjectDelta userDeltaSum = ObjectDeltaCollectionsUtil.summarize(userDelta1, userDelta2); @@ -1431,19 +1320,17 @@ public void testObjectDeltaSummarizeModifyReplace() throws Exception { @Test public void testObjectDeltaSummarizeModifyMix() throws Exception { - final String TEST_NAME="testObjectDeltaSummarizeModifyMix"; - displayTestTitle(TEST_NAME); // GIVEN ObjectDelta userDelta1 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, USER_FOO_OID, - UserType.F_ADDITIONAL_NAMES, PrismTestUtil.createPolyString("baz")); + UserType.F_ADDITIONAL_NAMES, PrismTestUtil.createPolyString("baz")); ObjectDelta userDelta2 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, USER_FOO_OID, - UserType.F_ADDITIONAL_NAMES, PrismTestUtil.createPolyString("foo")); + UserType.F_ADDITIONAL_NAMES, PrismTestUtil.createPolyString("foo")); ObjectDelta userDelta3 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, USER_FOO_OID, - UserType.F_ADDITIONAL_NAMES, PrismTestUtil.createPolyString("bar")); + UserType.F_ADDITIONAL_NAMES, PrismTestUtil.createPolyString("bar")); // WHEN ObjectDelta userDeltaSum = ObjectDeltaCollectionsUtil.summarize(userDelta1, userDelta2, userDelta3); @@ -1459,21 +1346,19 @@ public void testObjectDeltaSummarizeModifyMix() throws Exception { @Test public void testObjectDeltaSummarizeAddModifyMix() throws Exception { - final String TEST_NAME="testObjectDeltaSummarizeAddModifyMix"; - displayTestTitle(TEST_NAME); // GIVEN PrismObject user = createUserFooPatlama(); ObjectDelta userDelta0 = DeltaFactory.Object.createAddDelta(user); ObjectDelta userDelta1 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, USER_FOO_OID, - UserType.F_ADDITIONAL_NAMES, PrismTestUtil.createPolyString("baz")); + UserType.F_ADDITIONAL_NAMES, PrismTestUtil.createPolyString("baz")); ObjectDelta userDelta2 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, USER_FOO_OID, - UserType.F_ADDITIONAL_NAMES, PrismTestUtil.createPolyString("foo")); + UserType.F_ADDITIONAL_NAMES, PrismTestUtil.createPolyString("foo")); ObjectDelta userDelta3 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, USER_FOO_OID, - UserType.F_ADDITIONAL_NAMES, PrismTestUtil.createPolyString("bar")); + UserType.F_ADDITIONAL_NAMES, PrismTestUtil.createPolyString("bar")); // WHEN ObjectDelta userDeltaSum = ObjectDeltaCollectionsUtil.summarize(userDelta0, userDelta1, userDelta2, userDelta3); @@ -1485,13 +1370,10 @@ public void testObjectDeltaSummarizeAddModifyMix() throws Exception { assert user != userSum : "User was not cloned"; PrismAsserts.assertPropertyValue(userSum, UserType.F_ADDITIONAL_NAMES, PrismTestUtil.createPolyString("foo"), PrismTestUtil.createPolyString("bar")); - // TODO } @Test public void testObjectDeltaSummarizeAddModifySameRefValues() throws Exception { - final String TEST_NAME="testObjectDeltaSummarizeAddModifySameRefValues"; - displayTestTitle(TEST_NAME); // GIVEN PrismObjectDefinition userDef = getUserTypeDefinition(); @@ -1505,7 +1387,7 @@ public void testObjectDeltaSummarizeAddModifySameRefValues() throws Exception { ObjectDelta userDelta0 = DeltaFactory.Object.createAddDelta(user); ObjectDelta userDelta1 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddReference(UserType.class, USER_FOO_OID, - UserType.F_PARENT_ORG_REF, + UserType.F_PARENT_ORG_REF, "oid1"); System.out.println("userDelta0 = " + userDelta0.debugDump()); @@ -1523,17 +1405,16 @@ public void testObjectDeltaSummarizeAddModifySameRefValues() throws Exception { assert user != userSum : "User was not cloned"; PrismAsserts.assertReferenceValues(userSum.findOrCreateReference(UserType.F_PARENT_ORG_REF), "oid1"); } + @Test public void testDeltaComplex() throws Exception { - final String TEST_NAME="testDeltaComplex"; - displayTestTitle(TEST_NAME); // GIVEN PrismContext prismContext = getPrismContext(); ObjectDelta delta = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, USER_FOO_OID, - UserType.F_FULL_NAME, PrismTestUtil.createPolyString("Foo Bar")); + UserType.F_FULL_NAME, PrismTestUtil.createPolyString("Foo Bar")); PrismObjectDefinition userTypeDefinition = getUserTypeDefinition(); @@ -1581,12 +1462,8 @@ public void testDeltaComplex() throws Exception { PrismInternalTestUtil.assertPathVisitor(delta, ItemPath.create(UserType.F_ASSIGNMENT, null), false, 2); } - @Test public void testPropertyDeltaNarrow01() throws Exception { - final String TEST_NAME="testPropertyDeltaNarrow01"; - displayTestTitle(TEST_NAME); - // GIVEN PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory().createPropertyDefinition(UserType.F_DESCRIPTION, DOMUtil.XSD_STRING); @@ -1611,9 +1488,6 @@ public void testPropertyDeltaNarrow01() throws Exception { @Test public void testPropertyDeltaNarrow02() throws Exception { - final String TEST_NAME="testPropertyDeltaNarrow02"; - displayTestTitle(TEST_NAME); - // GIVEN PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory().createPropertyDefinition(UserType.F_DESCRIPTION, DOMUtil.XSD_STRING); @@ -1639,9 +1513,6 @@ public void testPropertyDeltaNarrow02() throws Exception { @Test public void testPropertyDeltaNarrow03() throws Exception { - final String TEST_NAME="testPropertyDeltaNarrow03"; - displayTestTitle(TEST_NAME); - // GIVEN PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory().createPropertyDefinition(UserType.F_DESCRIPTION, DOMUtil.XSD_STRING); @@ -1667,25 +1538,22 @@ public void testPropertyDeltaNarrow03() throws Exception { @Test public void testObjectDeltaNarrow01() throws Exception { - final String TEST_NAME="testObjectDeltaNarrow01"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta userDelta = getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, USER_FOO_OID, - UserType.F_ADDITIONAL_NAMES, "blabla", "bubu"); + UserType.F_ADDITIONAL_NAMES, "blabla", "bubu"); display("userDelta", userDelta); PrismObject user = createUserFoo(); display("user", user); // WHEN - displayWhen(TEST_NAME); + when(); ObjectDelta narrowedDelta = userDelta.narrow(user, false); // THEN - displayThen(TEST_NAME); + then(); display("Narrowed delta", narrowedDelta); PrismAsserts.assertIsModify(narrowedDelta); @@ -1699,14 +1567,11 @@ public void testObjectDeltaNarrow01() throws Exception { @Test public void testObjectDeltaNarrow02() throws Exception { - final String TEST_NAME="testObjectDeltaNarrow02"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta userDelta = getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, USER_FOO_OID, - UserType.F_ADDITIONAL_NAMES, "blabla", "bubu"); + UserType.F_ADDITIONAL_NAMES, "blabla", "bubu"); display("userDelta", userDelta); PrismObject user = createUserFoo(); @@ -1714,11 +1579,11 @@ public void testObjectDeltaNarrow02() throws Exception { display("user", user); // WHEN - displayWhen(TEST_NAME); + when(); ObjectDelta narrowedDelta = userDelta.narrow(user, false); // THEN - displayThen(TEST_NAME); + then(); display("Narrowed delta", narrowedDelta); PrismAsserts.assertIsModify(narrowedDelta); @@ -1732,14 +1597,11 @@ public void testObjectDeltaNarrow02() throws Exception { @Test public void testObjectDeltaNarrow03() throws Exception { - final String TEST_NAME="testObjectDeltaNarrow03"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta userDelta = getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, USER_FOO_OID, - UserType.F_ADDITIONAL_NAMES, "blabla", "bubu"); + UserType.F_ADDITIONAL_NAMES, "blabla", "bubu"); display("userDelta", userDelta); PrismObject user = createUserFoo(); @@ -1747,11 +1609,11 @@ public void testObjectDeltaNarrow03() throws Exception { display("user", user); // WHEN - displayWhen(TEST_NAME); + when(); ObjectDelta narrowedDelta = userDelta.narrow(user, false); // THEN - displayThen(TEST_NAME); + then(); display("Narrowed delta", narrowedDelta); PrismAsserts.assertIsModify(narrowedDelta); @@ -1760,14 +1622,11 @@ public void testObjectDeltaNarrow03() throws Exception { @Test public void testObjectDeltaNarrowAssignmen01() throws Exception { - final String TEST_NAME="testObjectDeltaNarrowAssignmen01"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta userDelta = getPrismContext().deltaFactory().object() .createModificationDeleteContainer(UserType.class, USER_FOO_OID, - UserType.F_ASSIGNMENT, + UserType.F_ASSIGNMENT, createAssignmentValue(null, ASSIGNMENT_PATLAMA_DESCRIPTION)); display("userDelta", userDelta); @@ -1776,11 +1635,11 @@ public void testObjectDeltaNarrowAssignmen01() throws Exception { display("user", user); // WHEN - displayWhen(TEST_NAME); + when(); ObjectDelta narrowedDelta = userDelta.narrow(user, false); // THEN - displayThen(TEST_NAME); + then(); display("Narrowed delta", narrowedDelta); PrismAsserts.assertIsModify(narrowedDelta); @@ -1789,14 +1648,11 @@ public void testObjectDeltaNarrowAssignmen01() throws Exception { @Test public void testObjectDeltaNarrowAssignmen02() throws Exception { - final String TEST_NAME="testObjectDeltaNarrowAssignmen02"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta userDelta = getPrismContext().deltaFactory().object() .createModificationDeleteContainer(UserType.class, USER_FOO_OID, - UserType.F_ASSIGNMENT, + UserType.F_ASSIGNMENT, createAssignmentValue(ASSIGNMENT_PATLAMA_ID, null)); display("userDelta", userDelta); @@ -1805,11 +1661,11 @@ public void testObjectDeltaNarrowAssignmen02() throws Exception { display("user", user); // WHEN - displayWhen(TEST_NAME); + when(); ObjectDelta narrowedDelta = userDelta.narrow(user, false); // THEN - displayThen(TEST_NAME); + then(); display("Narrowed delta", narrowedDelta); PrismAsserts.assertIsModify(narrowedDelta); @@ -1818,14 +1674,11 @@ public void testObjectDeltaNarrowAssignmen02() throws Exception { @Test public void testObjectDeltaNarrowAssignmen11() throws Exception { - final String TEST_NAME="testObjectDeltaNarrowAssignmen11"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta userDelta = getPrismContext().deltaFactory().object() .createModificationDeleteContainer(UserType.class, USER_FOO_OID, - UserType.F_ASSIGNMENT, + UserType.F_ASSIGNMENT, createAssignmentValue(null, ASSIGNMENT_PATLAMA_DESCRIPTION)); display("userDelta", userDelta); @@ -1835,11 +1688,11 @@ public void testObjectDeltaNarrowAssignmen11() throws Exception { display("user", user); // WHEN - displayWhen(TEST_NAME); + when(); ObjectDelta narrowedDelta = userDelta.narrow(user, false); // THEN - displayThen(TEST_NAME); + then(); display("Narrowed delta", narrowedDelta); PrismAsserts.assertIsModify(narrowedDelta); @@ -1852,14 +1705,11 @@ public void testObjectDeltaNarrowAssignmen11() throws Exception { @Test public void testObjectDeltaNarrowAssignmen12() throws Exception { - final String TEST_NAME="testObjectDeltaNarrowAssignmen12"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta userDelta = getPrismContext().deltaFactory().object() .createModificationDeleteContainer(UserType.class, USER_FOO_OID, - UserType.F_ASSIGNMENT, + UserType.F_ASSIGNMENT, createAssignmentValue(ASSIGNMENT_PATLAMA_ID, null)); display("userDelta", userDelta); @@ -1869,11 +1719,11 @@ public void testObjectDeltaNarrowAssignmen12() throws Exception { display("user", user); // WHEN - displayWhen(TEST_NAME); + when(); ObjectDelta narrowedDelta = userDelta.narrow(user, false); // THEN - displayThen(TEST_NAME); + then(); display("Narrowed delta", narrowedDelta); PrismAsserts.assertIsModify(narrowedDelta); diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestEquals.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestEquals.java index 039bac32526..99e836894bb 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestEquals.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestEquals.java @@ -6,9 +6,7 @@ */ package com.evolveum.midpoint.prism; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.*; import org.testng.annotations.Test; @@ -17,21 +15,18 @@ import com.evolveum.midpoint.prism.foo.UserType; /** - * @see TestCompare * @author semancik + * @see TestCompare */ public class TestEquals extends AbstractPrismTest { @Test public void testContainsEquivalentValue01() throws Exception { - final String TEST_NAME="testContainsEquivalentValue01"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta userDelta = getPrismContext().deltaFactory().object() .createModificationDeleteContainer(UserType.class, USER_FOO_OID, - UserType.F_ASSIGNMENT, + UserType.F_ASSIGNMENT, createAssignmentValue(ASSIGNMENT_PATLAMA_ID, null)); display("userDelta", userDelta); @@ -43,18 +38,15 @@ public void testContainsEquivalentValue01() throws Exception { PrismContainer assignmentContainer = user.findContainer(UserType.F_ASSIGNMENT); // WHEN, THEN - displayWhen(TEST_NAME); - assertTrue(ASSIGNMENT_PATLAMA_ID+":null", assignmentContainer.containsEquivalentValue(createAssignmentValue(ASSIGNMENT_PATLAMA_ID, null))); - assertTrue("null:"+ASSIGNMENT_PATLAMA_DESCRIPTION, assignmentContainer.containsEquivalentValue(createAssignmentValue(null, ASSIGNMENT_PATLAMA_DESCRIPTION))); + when(); + assertTrue(ASSIGNMENT_PATLAMA_ID + ":null", assignmentContainer.containsEquivalentValue(createAssignmentValue(ASSIGNMENT_PATLAMA_ID, null))); + assertTrue("null:" + ASSIGNMENT_PATLAMA_DESCRIPTION, assignmentContainer.containsEquivalentValue(createAssignmentValue(null, ASSIGNMENT_PATLAMA_DESCRIPTION))); assertFalse("364576:null", assignmentContainer.containsEquivalentValue(createAssignmentValue(364576L, null))); assertFalse("null:never ever never", assignmentContainer.containsEquivalentValue(createAssignmentValue(null, "never ever never"))); } @Test(enabled = false) // normalization no longer removes empty values public void testEqualsBrokenAssignmentActivation() throws Exception { - final String TEST_NAME="testEqualsBrokenAssignmentActivation"; - displayTestTitle(TEST_NAME); - // GIVEN PrismObjectDefinition userDef = PrismInternalTestUtil.getUserTypeDefinition(); PrismContainerDefinition assignmentDef = userDef.findContainerDefinition(UserType.F_ASSIGNMENT); diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPerformance.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPerformance.java index 4c649b8941d..b67c46a0e4c 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPerformance.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPerformance.java @@ -39,9 +39,6 @@ public void setupDebug() { */ @Test public void testPerfContainerNewValue() throws Exception { - final String TEST_NAME = "testPerfContainerNewValue"; - PrismInternalTestUtil.displayTestTitle(TEST_NAME); - // GIVEN PrismContext ctx = constructInitializedPrismContext(); PrismObjectDefinition userDefinition = getFooSchema(ctx).findObjectDefinitionByElementName(new QName(NS_FOO, "user")); diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPolyString.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPolyString.java index 9712f6276bf..d9ac4711680 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPolyString.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPolyString.java @@ -36,9 +36,6 @@ public class TestPolyString extends AbstractPrismTest { @Test public void testSimpleAlphaNormalization() { - final String TEST_NAME = "testSimpleAlphaNormalization"; - displayTestTitle(TEST_NAME); - AlphanumericPolyStringNormalizer normalizer = new AlphanumericPolyStringNormalizer(); testNormalization(normalizer, @@ -60,9 +57,6 @@ public void testSimpleAlphaNormalization() { @Test public void testAlphaNormalizationNoNfkd() { - final String TEST_NAME = "testAlphaNormalizationNoNfkd"; - displayTestTitle(TEST_NAME); - AlphanumericPolyStringNormalizer normalizer = new AlphanumericPolyStringNormalizer(); PolyStringNormalizerConfigurationType configuration = new PolyStringNormalizerConfigurationType(); configuration.setNfkd(false); @@ -87,9 +81,6 @@ public void testAlphaNormalizationNoNfkd() { @Test public void testSimpleAsciiNormalization() { - final String TEST_NAME = "testSimpleAlphaNormalization"; - displayTestTitle(TEST_NAME); - Ascii7PolyStringNormalizer normalizer = new Ascii7PolyStringNormalizer(); testNormalization(normalizer, @@ -111,9 +102,6 @@ public void testSimpleAsciiNormalization() { @Test public void testAsciiNormalizationNoNfkd() { - final String TEST_NAME = "testAsciiNormalizationNoNfkd"; - displayTestTitle(TEST_NAME); - Ascii7PolyStringNormalizer normalizer = new Ascii7PolyStringNormalizer(); PolyStringNormalizerConfigurationType configuration = new PolyStringNormalizerConfigurationType(); configuration.setNfkd(false); @@ -138,9 +126,6 @@ public void testAsciiNormalizationNoNfkd() { @Test public void testSimplePassThroughNormalization() { - final String TEST_NAME = "testSimplePassThroughNormalization"; - displayTestTitle(TEST_NAME); - PassThroughPolyStringNormalizer normalizer = new PassThroughPolyStringNormalizer(); testNormalization(normalizer, @@ -165,9 +150,6 @@ public void testSimplePassThroughNormalization() { @Test public void testPassThroughNormalizationNoNfkd() { - final String TEST_NAME = "testPassThroughNormalizationNoNfkd"; - displayTestTitle(TEST_NAME); - PassThroughPolyStringNormalizer normalizer = new PassThroughPolyStringNormalizer(); PolyStringNormalizerConfigurationType configuration = new PolyStringNormalizerConfigurationType(); configuration.setNfkd(false); @@ -192,9 +174,6 @@ public void testPassThroughNormalizationNoNfkd() { @Test public void testPassThroughNormalizationAllOff() { - final String TEST_NAME = "testPassThroughNormalizationAllOff"; - displayTestTitle(TEST_NAME); - PassThroughPolyStringNormalizer normalizer = new PassThroughPolyStringNormalizer(); PolyStringNormalizerConfigurationType configuration = new PolyStringNormalizerConfigurationType(); configuration.setTrim(false); @@ -232,9 +211,6 @@ private void testNormalization(PolyStringNormalizer normalizer, String orig, Str @Test public void testRecompute() throws Exception { - final String TEST_NAME = "testRecompute"; - displayTestTitle(TEST_NAME); - // GIVEN PrismContext ctx = constructInitializedPrismContext(); PrismObjectDefinition userDefinition = getFooSchema(ctx).findObjectDefinitionByElementName(new QName(NS_FOO,"user")); @@ -246,28 +222,25 @@ public void testRecompute() throws Exception { PrismProperty polyNameProperty = user.findOrCreateProperty(USER_POLYNAME_QNAME); // WHEN - displayWhen(TEST_NAME); + when(); polyNameProperty.setRealValue(polyName); // THEN - displayThen(TEST_NAME); + then(); assertEquals("Changed orig", orig, polyName.getOrig()); assertEquals("Wrong norm", "lala ho papluha", polyName.getNorm()); } @Test - public void testCompareTo() throws Exception { - final String TEST_NAME = "testCompareTo"; - displayTestTitle(TEST_NAME); - + public void testCompareTo() { // GIVEN String orig = "Ľala ho papľuha"; PolyString polyName = new PolyString(orig); // WHEN, THEN - assertTrue(polyName.compareTo("Ľala ho papľuha") == 0); - assertTrue(polyName.compareTo(new PolyString("Ľala ho papľuha")) == 0); + assertEquals(polyName.compareTo("Ľala ho papľuha"), 0); + assertEquals(polyName.compareTo(new PolyString("Ľala ho papľuha")), 0); assertTrue(polyName.compareTo("something different") != 0); assertTrue(polyName.compareTo(new PolyString("something different")) != 0); assertTrue(polyName.compareTo("") != 0); @@ -276,38 +249,29 @@ public void testCompareTo() throws Exception { } @Test - public void testConversion() throws Exception { - final String TEST_NAME = "testConversion"; - displayTestTitle(TEST_NAME); - + public void testConversion() { PolyString polyString = new PolyString("Ľala ho papľuha"); - executeConversionTest(TEST_NAME, polyString); + executeConversionTest(polyString); } @Test - public void testConversionWithEmptyLang() throws Exception { - final String TEST_NAME = "testConversion"; - displayTestTitle(TEST_NAME); - + public void testConversionWithEmptyLang() { PolyString polyString = new PolyString("Ľala ho papľuha"); polyString.setLang(new HashMap<>()); - executeConversionTest(TEST_NAME, polyString); + executeConversionTest(polyString); } @Test - public void testConversionWithOneLang() throws Exception { - final String TEST_NAME = "testConversion"; - displayTestTitle(TEST_NAME); - + public void testConversionWithOneLang() { PolyString polyString = new PolyString("Ľala ho papľuha"); polyString.setLang(new HashMap<>()); polyString.getLang().put("sk", "Lalala"); - executeConversionTest(TEST_NAME, polyString); + executeConversionTest(polyString); } - private void executeConversionTest(String TEST_NAME, PolyString polyString) { + private void executeConversionTest(PolyString polyString) { // WHEN - displayWhen(TEST_NAME); + when(); PolyStringType polyStringType = PolyString.toPolyStringType(polyString); PolyString polyString2 = PolyString.toPolyString(polyStringType); PolyStringType polyStringType2 = PolyString.toPolyStringType(polyString2); @@ -318,7 +282,7 @@ private void executeConversionTest(String TEST_NAME, PolyString polyString) { System.out.println("polyStringType2 = " + polyStringType2); // THEN - displayThen(TEST_NAME); + then(); assertEquals("PolyString differs", polyString, polyString2); assertEquals("PolyStringType differs", polyStringType, polyStringType2); assertEquals("PolyString.hashCode differs", polyString.hashCode(), polyString2.hashCode()); @@ -327,23 +291,17 @@ private void executeConversionTest(String TEST_NAME, PolyString polyString) { @Test public void testSerialization() throws Exception { - final String TEST_NAME = "testConversion"; - displayTestTitle(TEST_NAME); - // GIVEN PrismContext ctx = constructInitializedPrismContext(); PrismObjectDefinition userDefinition = getFooSchema(ctx).findObjectDefinitionByElementName(new QName(NS_FOO,"user")); PrismObject user = userDefinition.instantiate(); PolyString polyString = new PolyString("Ľala ho papľuha"); - executeSerializationTest(TEST_NAME, ctx, user, polyString); + executeSerializationTest(ctx, user, polyString); } @Test public void testSerializationWithEmptyLang() throws Exception { - final String TEST_NAME = "testConversion"; - displayTestTitle(TEST_NAME); - // GIVEN PrismContext ctx = constructInitializedPrismContext(); PrismObjectDefinition userDefinition = getFooSchema(ctx).findObjectDefinitionByElementName(new QName(NS_FOO,"user")); @@ -351,14 +309,11 @@ public void testSerializationWithEmptyLang() throws Exception { PolyString polyString = new PolyString("Ľala ho papľuha"); polyString.setLang(new HashMap<>()); - executeSerializationTest(TEST_NAME, ctx, user, polyString); + executeSerializationTest(ctx, user, polyString); } @Test public void testSerializationWithOneLang() throws Exception { - final String TEST_NAME = "testConversion"; - displayTestTitle(TEST_NAME); - // GIVEN PrismContext ctx = constructInitializedPrismContext(); PrismObjectDefinition userDefinition = getFooSchema(ctx).findObjectDefinitionByElementName(new QName(NS_FOO,"user")); @@ -367,16 +322,16 @@ public void testSerializationWithOneLang() throws Exception { PolyString polyString = new PolyString("Ľala ho papľuha"); polyString.setLang(new HashMap<>()); polyString.getLang().put("sk", "Lalala"); - executeSerializationTest(TEST_NAME, ctx, user, polyString); + executeSerializationTest(ctx, user, polyString); } - private void executeSerializationTest(String TEST_NAME, PrismContext ctx, PrismObject user, PolyString polyString) + private void executeSerializationTest(PrismContext ctx, PrismObject user, PolyString polyString) throws com.evolveum.midpoint.util.exception.SchemaException { PrismProperty polyNameProperty = user.findOrCreateProperty(USER_POLYNAME_QNAME); polyNameProperty.setRealValue(polyString); // WHEN - displayWhen(TEST_NAME); + when(); String xml = ctx.xmlSerializer().serialize(user); System.out.println(xml); PrismObject parsed = ctx.parserFor(xml).parse(); @@ -384,7 +339,7 @@ private void executeSerializationTest(String TEST_NAME, PrismContext ctx, PrismO PrismObject parsed2 = ctx.parserFor(xml2).parse(); // THEN - displayThen(TEST_NAME); + then(); assertEquals("original and parsed are different", user, parsed); assertEquals("parsed and parsed2 are different", parsed, parsed2); } diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismObjectConstruction.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismObjectConstruction.java index 529060b677a..f681b3c29c8 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismObjectConstruction.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismObjectConstruction.java @@ -57,9 +57,6 @@ public void setupDebug() { */ @Test public void testConstructionWithSchema() throws Exception { - final String TEST_NAME = "testConstructionWithSchema"; - PrismInternalTestUtil.displayTestTitle(TEST_NAME); - // GIVEN PrismContext ctx = constructInitializedPrismContext(); PrismObjectDefinition userDefinition = getFooSchema(ctx).findObjectDefinitionByElementName(new QName(NS_FOO,"user")); @@ -82,9 +79,6 @@ public void testConstructionWithSchema() throws Exception { */ @Test(enabled = false) // definition-less containers are no longer supported public void testDefinitionlessConstruction() throws Exception { - final String TEST_NAME = "testDefinitionlessConstruction"; - PrismInternalTestUtil.displayTestTitle(TEST_NAME); - // GIVEN // No context needed @@ -107,9 +101,6 @@ public void testDefinitionlessConstruction() throws Exception { */ // @Test public void testDefinitionlessConstructionAndSchemaApplication() throws Exception { - final String TEST_NAME = "testDefinitionlessConstructionAndSchemaApplication"; - PrismInternalTestUtil.displayTestTitle(TEST_NAME); - // GIVEN // No context needed (yet) PrismObject user = new PrismObjectImpl<>(USER_QNAME, UserType.class); @@ -137,9 +128,6 @@ public void testDefinitionlessConstructionAndSchemaApplication() throws Exceptio @Test public void testClone() throws Exception { - final String TEST_NAME = "testClone"; - PrismInternalTestUtil.displayTestTitle(TEST_NAME); - // GIVEN PrismContext ctx = constructInitializedPrismContext(); PrismObjectDefinition userDefinition = getFooSchema(ctx).findObjectDefinitionByElementName(new QName(NS_FOO,"user")); @@ -160,9 +148,6 @@ public void testClone() throws Exception { @Test public void testCloneEquals() throws Exception { - final String TEST_NAME = "testCloneEquals"; - PrismInternalTestUtil.displayTestTitle(TEST_NAME); - // GIVEN PrismContext ctx = constructInitializedPrismContext(); PrismObjectDefinition userDefinition = getFooSchema(ctx).findObjectDefinitionByElementName(new QName(NS_FOO,"user")); diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismParsing.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismParsing.java index 1698cc28d4f..a1abf46fbec 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismParsing.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismParsing.java @@ -69,8 +69,6 @@ public void setupDebug() { @Test public void test100PrismParseFile() throws Exception { - final String TEST_NAME = "test100PrismParseFile"; - displayTestTitle(TEST_NAME); // GIVEN PrismContext prismContext = constructInitializedPrismContext(); @@ -87,8 +85,6 @@ public void test100PrismParseFile() throws Exception { @Test public void test110PrismParseFileNoNs() throws Exception { - final String TEST_NAME = "test110PrismParseFileNoNs"; - displayTestTitle(TEST_NAME); // GIVEN PrismContext prismContext = constructInitializedPrismContext(); @@ -105,9 +101,6 @@ public void test110PrismParseFileNoNs() throws Exception { @Test public void test120PrismParseFileObject() throws Exception { - final String TEST_NAME = "test120PrismParseFileObject"; - displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = constructInitializedPrismContext(); @@ -124,9 +117,6 @@ public void test120PrismParseFileObject() throws Exception { @Test public void test130PrismParseFileAdhoc() throws Exception { - final String TEST_NAME = "test130PrismParseFileAdhoc"; - displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = constructInitializedPrismContext(); @@ -143,25 +133,16 @@ public void test130PrismParseFileAdhoc() throws Exception { @Test public void test200RoundTrip() throws Exception { - final String TEST_NAME = "test200RoundTrip"; - displayTestTitle(TEST_NAME); - roundTrip(getFile(USER_JACK_FILE_BASENAME), true, true); } @Test public void test210RoundTripNoNs() throws Exception { - final String TEST_NAME = "test210RoundTripNoNs"; - displayTestTitle(TEST_NAME); - roundTrip(getFile(USER_JACK_NO_NS_BASENAME), true, false); } @Test public void test220RoundTripObject() throws Exception { - final String TEST_NAME = "test220RoundTripObject"; - displayTestTitle(TEST_NAME); - roundTrip(getFile(USER_JACK_OBJECT_BASENAME), false, false); } @@ -209,9 +190,6 @@ private void roundTrip(File file, boolean expectFullPolyName, boolean withIncomp @Test public void test230RoundTripAdhoc() throws Exception { - final String TEST_NAME = "test230RoundTripAdhoc"; - displayTestTitle(TEST_NAME); - roundTripAdhoc(getFile(USER_JACK_ADHOC_BASENAME)); } @@ -252,9 +230,6 @@ private void roundTripAdhoc(File file) throws SchemaException, SAXException, IOE @Test public void test300MeleeContext() throws Exception { - final String TEST_NAME = "test300MeleeContext"; - displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = constructInitializedPrismContext(); @@ -313,9 +288,6 @@ public void test300MeleeContext() throws Exception { @Test public void test400UserWill() throws Exception { - final String TEST_NAME = "test400UserWill"; - displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = constructInitializedPrismContext(); @@ -332,9 +304,6 @@ public void test400UserWill() throws Exception { @Test public void test410UserWillRoundTrip() throws Exception { - final String TEST_NAME = "test410UserWillRoundTrip"; - displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = constructInitializedPrismContext(); @@ -370,9 +339,6 @@ public void test410UserWillRoundTrip() throws Exception { @Test public void test500UserElisabethRoundTrip() throws Exception { - final String TEST_NAME = "test500UserElisabethRoundTrip"; - displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = constructInitializedPrismContext(); @@ -409,9 +375,6 @@ public void test500UserElisabethRoundTrip() throws Exception { // MID-5326 @Test public void test600AccountBarbossa() throws Exception { - final String TEST_NAME = "test600AccountBarbossa"; - displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = constructInitializedPrismContext(); @@ -602,6 +565,6 @@ protected void validateXml(String xmlString, PrismContext prismContext) throws S } protected void displayTestTitle(final String TEST_NAME) { - PrismInternalTestUtil.displayTestTitle(TEST_NAME+"("+getSubdirName()+")"); + getSubdirName(); } } diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismParsingXml.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismParsingXml.java index 103ea497747..c37bc01a3c4 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismParsingXml.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismParsingXml.java @@ -41,9 +41,6 @@ protected String getOutputFormat() { @Test public void testPrismParseDom() throws Exception { - final String TEST_NAME = "testPrismParseDom"; - PrismInternalTestUtil.displayTestTitle(TEST_NAME); - // GIVEN Document document = DOMUtil.parseFile(getFile(USER_JACK_FILE_BASENAME)); Element userElement = DOMUtil.getFirstChildElement(document); @@ -63,9 +60,6 @@ public void testPrismParseDom() throws Exception { @Test public void testPrismParseDomAdhoc() throws Exception { - final String TEST_NAME = "testPrismParseDomAdhoc"; - PrismInternalTestUtil.displayTestTitle(TEST_NAME); - // GIVEN Document document = DOMUtil.parseFile(getFile(USER_JACK_ADHOC_BASENAME)); Element userElement = DOMUtil.getFirstChildElement(document); @@ -85,9 +79,6 @@ public void testPrismParseDomAdhoc() throws Exception { @Test public void testPrismParseXxe() throws Exception { - final String TEST_NAME = "testPrismParseXxe"; - PrismInternalTestUtil.displayTestTitle(TEST_NAME); - PrismContext prismContext = constructInitializedPrismContext(); try { @@ -105,9 +96,6 @@ public void testPrismParseXxe() throws Exception { @Test public void testPrismParseDomXxe() throws Exception { - final String TEST_NAME = "testPrismParseDomXxe"; - PrismInternalTestUtil.displayTestTitle(TEST_NAME); - try { // WHEN DOMUtil.parseFile(getFile(USER_JACK_XXE_BASENAME)); diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPropertyArrayList.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPropertyArrayList.java index 295bde68028..58a6f9ba185 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPropertyArrayList.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPropertyArrayList.java @@ -43,9 +43,6 @@ private File getFile(String baseName) { @Test public void testPrismParseDom() throws Exception { - final String TEST_NAME = "testPrismParseDom"; - PrismInternalTestUtil.displayTestTitle(TEST_NAME); - // GIVEN Document document = DOMUtil.parseFile(getFile(USER_JACK_FILE_BASENAME)); Element userElement = DOMUtil.getFirstChildElement(document); diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestUnknownItems.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestUnknownItems.java index 5a16a28d565..6669fbc0d1e 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestUnknownItems.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestUnknownItems.java @@ -37,8 +37,6 @@ public void setupDebug() { @Test(expectedExceptions = SchemaException.class) public void test010ParseWrongItemStrict() throws Exception { - final String TEST_NAME = "testParseWrongItemStrict"; - PrismInternalTestUtil.displayTestTitle(TEST_NAME); // GIVEN PrismContext prismContext = constructInitializedPrismContext(); @@ -53,8 +51,6 @@ public void test010ParseWrongItemStrict() throws Exception { @Test public void test020ParseWrongItemCompat() throws Exception { - final String TEST_NAME = "testParseWrongItemCompat"; - PrismInternalTestUtil.displayTestTitle(TEST_NAME); // GIVEN PrismContext prismContext = constructInitializedPrismContext(); @@ -73,8 +69,6 @@ public void test020ParseWrongItemCompat() throws Exception { // TODO discuss this @Test(enabled = false, expectedExceptions = SchemaException.class) public void test110ParseWrongNamespaceStrict() throws Exception { - final String TEST_NAME = "test110ParseWrongNamespaceStrict"; - PrismInternalTestUtil.displayTestTitle(TEST_NAME); // GIVEN PrismContext prismContext = constructInitializedPrismContext(); @@ -87,8 +81,6 @@ public void test110ParseWrongNamespaceStrict() throws Exception { @Test public void test120ParseWrongNamespaceCompat() throws Exception { - final String TEST_NAME = "test120ParseWrongNamespaceCompat"; - PrismInternalTestUtil.displayTestTitle(TEST_NAME); // GIVEN PrismContext prismContext = constructInitializedPrismContext(); diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestXmlSerialization.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestXmlSerialization.java index fb734af717e..785f7d94158 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestXmlSerialization.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestXmlSerialization.java @@ -21,7 +21,7 @@ import java.io.IOException; import static com.evolveum.midpoint.prism.PrismInternalTestUtil.DEFAULT_NAMESPACE_PREFIX; -import static com.evolveum.midpoint.prism.PrismInternalTestUtil.displayTestTitle; + import static org.testng.Assert.assertTrue; import static org.testng.AssertJUnit.assertEquals; @@ -39,9 +39,6 @@ public void setupDebug() throws SchemaException, SAXException, IOException { @Test public void testHandlingInvalidChars() throws Exception { - final String TEST_NAME = "testHandlingInvalidChars"; - displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/AbstractJsonLexicalProcessorTest.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/AbstractJsonLexicalProcessorTest.java index 329a635cc19..94e19f8820a 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/AbstractJsonLexicalProcessorTest.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/AbstractJsonLexicalProcessorTest.java @@ -17,7 +17,6 @@ import java.util.ArrayList; import java.util.List; -import static com.evolveum.midpoint.prism.PrismInternalTestUtil.displayTestTitle; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertFalse; import static org.testng.AssertJUnit.fail; @@ -35,10 +34,6 @@ public abstract class AbstractJsonLexicalProcessorTest extends AbstractLexicalPr @Test public void testParseObjectsIteratively_2_Wrong() throws Exception { - final String TEST_NAME = "testParseObjectsIteratively_2_Wrong"; - - displayTestTitle(TEST_NAME); - // GIVEN LexicalProcessor lexicalProcessor = createParser(); @@ -78,10 +73,6 @@ public void testParseObjectsIteratively_2_Wrong() throws Exception { @Test public void testParseObjectsIteratively_2_Wrong_2() throws Exception { - final String TEST_NAME = "testParseObjectsIteratively_2_Wrong_2"; - - displayTestTitle(TEST_NAME); - // GIVEN LexicalProcessor lexicalProcessor = createParser(); diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/AbstractLexicalProcessorTest.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/AbstractLexicalProcessorTest.java index 1ac3af2b40a..d322a9b3e56 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/AbstractLexicalProcessorTest.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/AbstractLexicalProcessorTest.java @@ -85,9 +85,6 @@ protected File getFile(String baseName) { @Test public void testParseUserToPrism() throws Exception { - final String TEST_NAME = "testParseUserToPrism"; - displayTestTitle(TEST_NAME); - // GIVEN LexicalProcessor lexicalProcessor = createParser(); PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -116,9 +113,6 @@ ParserSource getFileSource(String basename) { @Test public void testParseUserRoundTrip() throws Exception { - final String TEST_NAME = "testParseUserRoundTrip"; - displayTestTitle(TEST_NAME); - // GIVEN LexicalProcessor lexicalProcessor = createParser(); PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -187,9 +181,6 @@ public void testParseUserRoundTrip() throws Exception { @Test public void testParseResourceRumToPrism() throws Exception { - final String TEST_NAME = "testParseResourceRumToPrism"; - displayTestTitle(TEST_NAME); - // GIVEN LexicalProcessor lexicalProcessor = createParser(); PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -212,9 +203,6 @@ public void testParseResourceRumToPrism() throws Exception { @Test public void testParseResourceRoundTrip() throws Exception { - final String TEST_NAME = "testParseResourceRoundTrip"; - displayTestTitle(TEST_NAME); - // GIVEN LexicalProcessor lexicalProcessor = createParser(); PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -342,9 +330,6 @@ protected void validateResourceSchema(String dataString, PrismContext prismConte // Enable it if that changes. @Test(enabled = false) public void testParseEventHandler() throws Exception { - final String TEST_NAME = "testParseEventHandler"; - displayTestTitle(TEST_NAME); - // GIVEN LexicalProcessor lexicalProcessor = createParser(); PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -383,7 +368,6 @@ public void testParseObjectsIteratively_1() throws Exception { } protected List standardTest(String TEST_NAME, String fileName, int expectedCount) throws SchemaException, IOException { - displayTestTitle(TEST_NAME); // GIVEN LexicalProcessor lexicalProcessor = createParser(); @@ -414,10 +398,6 @@ protected List standardTest(String TEST_NAME, String fileName, in @Test public void testParseObjectsIteratively_1_FirstTwo() throws Exception { - final String TEST_NAME = "testParseObjectsIteratively_1_FirstTwo"; - - displayTestTitle(TEST_NAME); - // GIVEN LexicalProcessor lexicalProcessor = createParser(); @@ -448,10 +428,6 @@ String getFirstElementNS(List nodes, int index) { @Test public void testParseObjectsIteratively_3_NS() throws Exception { - final String TEST_NAME = "testParseObjectsIteratively_3_NS"; - - displayTestTitle(TEST_NAME); - // GIVEN LexicalProcessor lexicalProcessor = createParser(); @@ -486,10 +462,6 @@ public void testParseObjectsIteratively_3_NS() throws Exception { @Test public void testParseObjectsIteratively_4_noRootNs() throws Exception { - final String TEST_NAME = "testParseObjectsIteratively_4_noRootNs"; - - displayTestTitle(TEST_NAME); - // GIVEN LexicalProcessor lexicalProcessor = createParser(); @@ -524,10 +496,6 @@ public void testParseObjectsIteratively_4_noRootNs() throws Exception { @Test public void testParseObjectsIteratively_5_error() throws Exception { - final String TEST_NAME = "testParseObjectsIteratively_5_error"; - - displayTestTitle(TEST_NAME); - // GIVEN LexicalProcessor lexicalProcessor = createParser(); @@ -558,10 +526,6 @@ public void testParseObjectsIteratively_5_error() throws Exception { @Test public void testParseObjectsIteratively_6_single() throws Exception { - final String TEST_NAME = "testParseObjectsIteratively_6_single"; - - displayTestTitle(TEST_NAME); - // GIVEN LexicalProcessor lexicalProcessor = createParser(); @@ -594,10 +558,6 @@ public void testParseObjectsIteratively_6_single() throws Exception { @Test public void testParseObjectsIteratively_7_single() throws Exception { - final String TEST_NAME = "testParseObjectsIteratively_7_single"; - - displayTestTitle(TEST_NAME); - // GIVEN LexicalProcessor lexicalProcessor = createParser(); diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/TestDomParser.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/TestDomParser.java index 0d2e787a537..fdce12b558c 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/TestDomParser.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/TestDomParser.java @@ -7,7 +7,6 @@ package com.evolveum.midpoint.prism.lex; import static com.evolveum.midpoint.prism.PrismInternalTestUtil.USER_JACK_FILE_BASENAME; -import static com.evolveum.midpoint.prism.PrismInternalTestUtil.displayTestTitle; import static com.evolveum.midpoint.prism.util.PrismTestUtil.createDefaultParsingContext; import static org.testng.AssertJUnit.assertEquals; @@ -49,9 +48,6 @@ protected DomLexicalProcessor createParser() { @Test public void testParseUserToXNode() throws Exception { - final String TEST_NAME = "testParseUserToXNode"; - displayTestTitle(TEST_NAME); - // GIVEN DomLexicalProcessor parser = createParser(); diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/TestProtectedString.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/TestProtectedString.java index 1603ec8466d..949d09e696d 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/TestProtectedString.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/TestProtectedString.java @@ -23,7 +23,6 @@ import java.io.IOException; import static com.evolveum.midpoint.prism.PrismInternalTestUtil.DEFAULT_NAMESPACE_PREFIX; -import static com.evolveum.midpoint.prism.PrismInternalTestUtil.displayTestTitle; import static com.evolveum.midpoint.prism.util.PrismTestUtil.createDefaultParsingContext; import static org.testng.AssertJUnit.assertEquals; @@ -41,9 +40,6 @@ public void setupDebug() throws SchemaException, SAXException, IOException { @Test public void testParseProtectedStringEncrypted() throws Exception { - final String TEST_NAME = "testParseProtectedStringEncrypted"; - displayTestTitle(TEST_NAME); - // GIVEN Protector protector = PrismInternalTestUtil.createProtector(Protector.XMLSEC_ENCRYPTION_ALGORITHM_AES256_CBC); ProtectedStringType protectedStringType = protector.encryptString("salalala"); @@ -64,9 +60,6 @@ public void testParseProtectedStringEncrypted() throws Exception { @Test public void testParseProtectedStringHashed() throws Exception { - final String TEST_NAME = "testParseProtectedStringHashed"; - displayTestTitle(TEST_NAME); - // GIVEN ProtectedStringType protectedStringType = new ProtectedStringType(); protectedStringType.setClearValue("blabla"); diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/TestYamlParser.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/TestYamlParser.java index 132f66ae651..39fac145d7c 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/TestYamlParser.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/TestYamlParser.java @@ -17,7 +17,6 @@ import java.util.Iterator; import java.util.List; -import static com.evolveum.midpoint.prism.PrismInternalTestUtil.displayTestTitle; import static com.evolveum.midpoint.prism.util.PrismTestUtil.createDefaultParsingContext; import static org.testng.AssertJUnit.assertEquals; @@ -47,10 +46,6 @@ protected String getWhenItemSerialized() { @Test public void testParseObjectsIteratively_8_multiDocument() throws Exception { - final String TEST_NAME = "testParseObjectsIteratively_8_multiDocument"; - - displayTestTitle(TEST_NAME); - // GIVEN LexicalProcessor lexicalProcessor = createParser(); diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/query/TestQueryConverters.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/query/TestQueryConverters.java index 16aa93d1522..b703d1e6d22 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/query/TestQueryConverters.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/query/TestQueryConverters.java @@ -10,7 +10,6 @@ import static com.evolveum.midpoint.prism.PrismInternalTestUtil.DEFAULT_NAMESPACE_PREFIX; import static com.evolveum.midpoint.prism.util.PrismTestUtil.createPolyString; import static com.evolveum.midpoint.prism.util.PrismTestUtil.displayQuery; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.displayTestTitle; import static com.evolveum.midpoint.prism.util.PrismTestUtil.getFilterCondition; import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; import static org.testng.AssertJUnit.assertEquals; @@ -36,6 +35,7 @@ import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.prism.impl.xnode.ListXNodeImpl; import com.evolveum.midpoint.prism.impl.xnode.MapXNodeImpl; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.DomAsserts; import com.evolveum.midpoint.util.PrettyPrinter; @@ -46,7 +46,7 @@ import com.evolveum.prism.xml.ns._public.query_3.SearchFilterType; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; -public class TestQueryConverters { +public class TestQueryConverters extends AbstractUnitTest { private static final Trace LOGGER = TraceManager.getTrace(TestQueryConverters.class); @@ -66,8 +66,6 @@ public void setupDebug() throws SchemaException, SAXException, IOException { @Test public void testFilterUserNameJaxb() throws Exception { - displayTestTitle("testFilterUserNameJaxb"); - SearchFilterType filterType = PrismTestUtil.parseAnyValue(FILTER_USER_NAME_FILE); ObjectQuery query = toObjectQuery(UserType.class, filterType); displayQuery(query); @@ -99,8 +97,6 @@ public void testFilterUserNameJaxb() throws Exception { @Test public void testFilterUserAndJaxb() throws Exception { - displayTestTitle("testFilterUserAndJaxb"); - SearchFilterType filterType = PrismTestUtil.parseAnyValue(FILTER_USER_AND_FILE); ObjectQuery query = toObjectQuery(UserType.class, filterType); displayQuery(query); @@ -154,9 +150,6 @@ public void testFilterUserAndJaxb() throws Exception { @Test public void testFilterTypeUserNone() throws Exception { - displayTestTitle("testFilterTypeUserNone"); - - SearchFilterType filterType = PrismTestUtil.parseAnyValue(FILTER_TYPE_USER_NONE); ObjectQuery query = toObjectQuery(UserType.class, filterType); @@ -184,15 +177,10 @@ public void testFilterTypeUserNone() throws Exception { LOGGER.info(filterAsString); DomAsserts.assertElementQName(filterClauseElement, new QName(PrismConstants.NS_QUERY, "type")); - - - } @Test public void testFilterNotInOid() throws Exception { - displayTestTitle("testFilterNotInOid"); - SearchFilterType filterType = PrismTestUtil.parseAnyValue(FILTER_NOT_IN_OID); ObjectQuery query = toObjectQuery(UserType.class, filterType); @@ -225,8 +213,6 @@ public void testFilterNotInOid() throws Exception { @Test public void testFilterNotFullText() throws Exception { - displayTestTitle("testFilterNotFullText"); - SearchFilterType filterType = PrismTestUtil.parseAnyValue(FILTER_NOT_FULL_TEXT); ObjectQuery query = toObjectQuery(UserType.class, filterType); diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestQueryConverter.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestQueryConverter.java index f098567f29b..cb1f54cbe0a 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestQueryConverter.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestQueryConverter.java @@ -19,6 +19,7 @@ import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.constants.ObjectTypes; import com.evolveum.midpoint.schema.util.ObjectTypeUtil; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.DomAsserts; import com.evolveum.midpoint.util.PrettyPrinter; @@ -41,13 +42,14 @@ import javax.xml.namespace.QName; import java.io.File; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.List; import static com.evolveum.midpoint.prism.util.PrismTestUtil.*; import static com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType.F_OWNER_REF; import static org.testng.AssertJUnit.*; -public class TestQueryConverter { +public class TestQueryConverter extends AbstractUnitTest { private static final Trace LOGGER = TraceManager.getTrace(TestQueryConverter.class); @@ -62,8 +64,6 @@ public class TestQueryConverter { private static final QName fooBlaDefinition = new QName(NS_BLA, "foo"); private static final QName ICF_NAME = new QName(NS_ICFS, "name"); - private static final QName TAG_QNAME = new QName(SchemaConstantsGenerated.NS_COMMON, "tag"); - private static final File FILTER_AND_GENERIC_FILE = new File(TEST_DIR, "filter-and-generic.xml"); private static final File FILTER_ACCOUNT_FILE = new File(TEST_DIR, "filter-account.xml"); private static final File FILTER_ACCOUNT_ATTRIBUTES_RESOURCE_REF_FILE = new File(TEST_DIR, @@ -82,8 +82,6 @@ public void setup() throws SchemaException, SAXException, IOException { @Test public void testAccountFilter() throws Exception { - displayTestTitle("testAccountFilter"); - SearchFilterType filterType = unmarshalFilter(FILTER_ACCOUNT_FILE); ObjectQuery query = toObjectQuery(ShadowType.class, filterType); displayQuery(query); @@ -135,8 +133,6 @@ public void testAccountFilter() throws Exception { @Test public void testAccountQueryAttributesAndResource() throws Exception { - displayTestTitle("testAccountQueryAttributesAndResource"); - SearchFilterType filterType = unmarshalFilter(FILTER_ACCOUNT_ATTRIBUTES_RESOURCE_REF_FILE); ObjectQuery query = toObjectQuery(ShadowType.class, filterType); displayQuery(query); @@ -157,14 +153,10 @@ public void testAccountQueryAttributesAndResource() throws Exception { QueryType convertedQueryType = toQueryType(query); LOGGER.info(DOMUtil.serializeDOMToString(convertedQueryType.getFilter().getFilterClauseAsElement(getPrismContext()))); - - // TODO: add some asserts } @Test public void testAccountQueryAttributesAndResourceNoNs() throws Exception { - displayTestTitle("testAccountQueryAttributesAndResourceNoNs"); - SearchFilterType filterType = unmarshalFilter(FILTER_ACCOUNT_ATTRIBUTES_RESOURCE_REF_NO_NS_FILE); ObjectQuery query = toObjectQuery(ShadowType.class, filterType); displayQuery(query); @@ -185,8 +177,6 @@ public void testAccountQueryAttributesAndResourceNoNs() throws Exception { QueryType convertedQueryType = toQueryType(query); System.out.println(DOMUtil.serializeDOMToString(convertedQueryType.getFilter().getFilterClauseAsElement(getPrismContext()))); - - // TODO: add some asserts } @Test @@ -223,8 +213,6 @@ public void testAccountQueryCompositeOr() throws Exception { QueryType convertedQueryType = toQueryType(query); LOGGER.info(DOMUtil.serializeDOMToString(convertedQueryType.getFilter().getFilterClauseAsElement(getPrismContext()))); - - // TODO: add some asserts } @Test @@ -257,7 +245,6 @@ private PrismObjectDefinition getUserDefinition(){ @Test public void testTypeFilterQuery() throws Exception { - displayTestTitle("testConnectorQuery"); SearchFilterType filterType = PrismTestUtil.parseAtomicValue(FILTER_BY_TYPE_FILE, SearchFilterType.COMPLEX_TYPE); ObjectQuery query; try { @@ -275,9 +262,6 @@ public void testTypeFilterQuery() throws Exception { PrismPropertyDefinition ppd = getUserDefinition().findPropertyDefinition(namePath); PrismAsserts.assertEqualsFilter(typeFilter.getFilter(), ppd.getItemName(), ppd.getTypeName(), namePath); PrismAsserts.assertEqualsFilterValue((EqualFilter) typeFilter.getFilter(), PrismTestUtil.createPolyString("some name identificator")); -// PrismAsserts.assertEqualsFilter(query.getFilter(), ConnectorType.F_CONNECTOR_TYPE, DOMUtil.XSD_STRING, -// prismContext.path(ConnectorType.F_CONNECTOR_TYPE)); -// PrismAsserts.assertEqualsFilterValue((EqualsFilter) filter, "org.identityconnectors.ldap.LdapConnector"); QueryType convertedQueryType = toQueryType(query); displayQueryType(convertedQueryType); @@ -290,7 +274,6 @@ public void testTypeFilterQuery() throws Exception { @Test public void testShadowKindTypeQuery() throws Exception { - displayTestTitle("testShadowKindTypeQuery"); SearchFilterType filterType = PrismTestUtil.parseAtomicValue(FILTER_BY_TYPE_FILE, SearchFilterType.COMPLEX_TYPE); ObjectQuery query; try { @@ -324,8 +307,6 @@ private void assertRefFilterValue(RefFilter filter, String oid) { PrismReferenceValue val = (PrismReferenceValue) values.get(0); assertEquals(oid, val.getOid()); - // TODO: maybe some more asserts for type, relation and other reference - // values } private ObjectQuery toObjectQuery(Class type, QueryType queryType) throws Exception { @@ -360,8 +341,6 @@ private String toXml(QueryType q1jaxb) throws SchemaException { @Test public void testGenericQuery() throws Exception { - displayTestTitle("testGenericQuery"); - SearchFilterType queryType = unmarshalFilter(FILTER_AND_GENERIC_FILE); ObjectQuery query = toObjectQuery(GenericObjectType.class, queryType); @@ -390,8 +369,6 @@ public void testGenericQuery() throws Exception { @Test public void testUserQuery() throws Exception { - displayTestTitle("testUserQuery"); - File[] userQueriesToTest = new File[] { new File(TEST_DIR, "filter-user-by-fullName.xml"), new File(TEST_DIR, "filter-user-by-name.xml"), new File(TEST_DIR, "filter-user-substring-fullName.xml"), @@ -467,100 +444,81 @@ private void checkQueryRoundtrip(Class objectClass, Obj checkQuery(objectClass, q2object, q1xml); } - private void checkQueryRoundtripFile(Class objectClass, ObjectQuery query, String testName) throws Exception { - String fileName = TEST_DIR + "/" + testName + ".xml"; - checkQueryRoundtrip(objectClass, query, FileUtils.readFileToString(new File(fileName))); + private void checkQueryRoundtripFile(Class objectClass, ObjectQuery query) throws Exception { + String fileName = TEST_DIR + "/" + getTestNameShort() + ".xml"; + checkQueryRoundtrip(objectClass, query, + FileUtils.readFileToString(new File(fileName), StandardCharsets.UTF_8)); } @Test public void test100All() throws Exception { - final String TEST_NAME = "test100All"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class).all().build(); - checkQueryRoundtripFile(UserType.class, q, TEST_NAME); + checkQueryRoundtripFile(UserType.class, q); } @Test public void test110None() throws Exception { - final String TEST_NAME = "test110None"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class).none().build(); - checkQueryRoundtripFile(UserType.class, q, TEST_NAME); + checkQueryRoundtripFile(UserType.class, q); } @Test public void test120Undefined() throws Exception { - final String TEST_NAME = "test120Undefined"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class).undefined().build(); - checkQueryRoundtripFile(UserType.class, q, TEST_NAME); + checkQueryRoundtripFile(UserType.class, q); } @Test public void test200Equal() throws Exception { - final String TEST_NAME = "test200Equal"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class) .item(UserType.F_NAME).eqPoly("some-name", "somename").matchingOrig() .build(); - checkQueryRoundtripFile(UserType.class, q, TEST_NAME); + checkQueryRoundtripFile(UserType.class, q); } @Test public void test210EqualMultiple() throws Exception { - final String TEST_NAME = "test210EqualMultiple"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class) .item(UserType.F_EMPLOYEE_TYPE).eq("STD", "TEMP") .build(); - checkQueryRoundtripFile(UserType.class, q, TEST_NAME); + checkQueryRoundtripFile(UserType.class, q); } @Test public void test220EqualRightHandItem() throws Exception { - final String TEST_NAME = "test220EqualRightHandItem"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class) .item(UserType.F_EMPLOYEE_NUMBER).eq().item(UserType.F_COST_CENTER) .build(); - checkQueryRoundtripFile(UserType.class, q, TEST_NAME); + checkQueryRoundtripFile(UserType.class, q); } @Test public void test300Greater() throws Exception { - final String TEST_NAME = "test300Greater"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class) .item(UserType.F_COST_CENTER).gt("100000") .build(); - checkQueryRoundtripFile(UserType.class, q, TEST_NAME); + checkQueryRoundtripFile(UserType.class, q); } @Test public void test305GreaterLesserMatchingNorm() throws Exception { - final String TEST_NAME = "test305GreaterLesserMatchingNorm"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class) .item(UserType.F_NAME).ge(new PolyString("00", "00")).matchingNorm() .and().item(UserType.F_NAME).lt(new PolyString("0a", "0a")).matchingNorm() .build(); - checkQueryRoundtripFile(UserType.class, q, TEST_NAME); + checkQueryRoundtripFile(UserType.class, q); } @Test public void test305GreaterOrEqual() throws Exception { - final String TEST_NAME = "test305GreaterOrEqual"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class) .item(UserType.F_COST_CENTER).ge("100000") .build(); - checkQueryRoundtripFile(UserType.class, q, TEST_NAME); + checkQueryRoundtripFile(UserType.class, q); } @Test public void test310AllComparisons() throws Exception { - final String TEST_NAME = "test310AllComparisons"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class) .item(UserType.F_COST_CENTER).gt("100000") .and().item(UserType.F_COST_CENTER).lt("999999") @@ -568,27 +526,22 @@ public void test310AllComparisons() throws Exception { .item(UserType.F_COST_CENTER).ge("X100") .and().item(UserType.F_COST_CENTER).le("X999") .build(); - checkQueryRoundtripFile(UserType.class, q, TEST_NAME); + checkQueryRoundtripFile(UserType.class, q); } @Test public void test350Substring() throws Exception { - final String TEST_NAME = "test350Substring"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class) .item(UserType.F_EMPLOYEE_TYPE).contains("A") .or().item(UserType.F_EMPLOYEE_TYPE).startsWith("B") .or().item(UserType.F_EMPLOYEE_TYPE).endsWith("C") .or().item(UserType.F_NAME).startsWithPoly("john", "john").matchingOrig() .build(); - checkQueryRoundtripFile(UserType.class, q, TEST_NAME); + checkQueryRoundtripFile(UserType.class, q); } @Test public void test360Ref() throws Exception { - final String TEST_NAME = "test360Ref"; - displayTestTitle(TEST_NAME); - // we test only parsing here, as there are more serialized forms used here ObjectQuery q1object = getPrismContext().queryFor(ShadowType.class) .item(ShadowType.F_RESOURCE_REF).ref("oid1") @@ -598,7 +551,9 @@ public void test360Ref() throws Exception { .build(); q1object.getFilter().checkConsistence(true); - String q2xml = FileUtils.readFileToString(new File(TEST_DIR + "/" + TEST_NAME + ".xml")); + String q2xml = FileUtils.readFileToString( + new File(TEST_DIR + "/" + getTestNameShort() + ".xml"), + StandardCharsets.UTF_8); displayQueryXml(q2xml); QueryType q2jaxb = toQueryType(q2xml); displayQueryType(q2jaxb); @@ -616,8 +571,6 @@ public void test360Ref() throws Exception { @Test public void test365RefTwoWay() throws Exception { - final String TEST_NAME = "test365RefTwoWay"; - displayTestTitle(TEST_NAME); PrismReferenceValue reference3 = getPrismContext().itemFactory().createReferenceValue("oid3", ResourceType.COMPLEX_TYPE).relation(new QName("test")); PrismReferenceValue reference4 = getPrismContext().itemFactory().createReferenceValue("oid4", ResourceType.COMPLEX_TYPE).relation(new QName("test")); ObjectQuery q = getPrismContext().queryFor(ShadowType.class) @@ -625,38 +578,29 @@ public void test365RefTwoWay() throws Exception { .or().item(ShadowType.F_RESOURCE_REF).ref("oid2", ResourceType.COMPLEX_TYPE) .or().item(ShadowType.F_RESOURCE_REF).ref(reference3, reference4) .build(); - checkQueryRoundtripFile(ShadowType.class, q, TEST_NAME); + checkQueryRoundtripFile(ShadowType.class, q); } @Test public void test400OrgFilterRoot() throws Exception { - final String TEST_NAME = "test400OrgFilterRoot"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(OrgType.class).isRoot().build(); - checkQueryRoundtripFile(OrgType.class, q, TEST_NAME); + checkQueryRoundtripFile(OrgType.class, q); } @Test public void test410OrgFilterSubtree() throws Exception { - final String TEST_NAME = "test410OrgFilterSubtree"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(OrgType.class).isChildOf("111").build(); - checkQueryRoundtripFile(OrgType.class, q, TEST_NAME); + checkQueryRoundtripFile(OrgType.class, q); } @Test public void test420OrgFilterDirect() throws Exception { - final String TEST_NAME = "test420OrgFilterDirect"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(OrgType.class).isDirectChildOf("222").build(); - checkQueryRoundtripFile(OrgType.class, q, TEST_NAME); + checkQueryRoundtripFile(OrgType.class, q); } @Test public void test430OrgFilterDefaultScope() throws Exception { - final String TEST_NAME = "test430OrgFilterDefaultScope"; - displayTestTitle(TEST_NAME); - // default scope is SUBTREE String queryXml = "\n" + " \n" + @@ -672,44 +616,36 @@ public void test430OrgFilterDefaultScope() throws Exception { assertEquals("Parsed query is wrong", expectedQuery.toString(), query.toString()); // primitive way of comparing queries // now reserialize the parsed query and compare with XML - the XML contains explicit scope=SUBTREE (as this is set when parsing original queryXml) - checkQueryRoundtripFile(OrgType.class, query, TEST_NAME); + checkQueryRoundtripFile(OrgType.class, query); } @Test public void test500InOid() throws Exception { - final String TEST_NAME = "test500InOid"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class) .id("oid1", "oid2", "oid3") .build(); - checkQueryRoundtripFile(UserType.class, q, TEST_NAME); + checkQueryRoundtripFile(UserType.class, q); } @Test public void test505InOidEmpty() throws Exception { - final String TEST_NAME = "test505InOidEmpty"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class) .id(new String[0]) .build(); - checkQueryRoundtripFile(UserType.class, q, TEST_NAME); + checkQueryRoundtripFile(UserType.class, q); } @Test public void test510InOidContainer() throws Exception { - final String TEST_NAME = "test510InOidContainer"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class) .id(1, 2, 3) .and().ownerId("oid4") .build(); - checkQueryRoundtripFile(UserType.class, q, TEST_NAME); + checkQueryRoundtripFile(UserType.class, q); } @Test public void test590Logicals() throws Exception { - final String TEST_NAME = "test590Logicals"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class) .block() .all() @@ -724,13 +660,11 @@ public void test590Logicals() throws Exception { .and().undefined() .endBlock() .build(); - checkQueryRoundtripFile(UserType.class, q, TEST_NAME); + checkQueryRoundtripFile(UserType.class, q); } @Test public void test595Logicals2() throws Exception { - final String TEST_NAME = "test595Logicals2"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class) .item(UserType.F_DESCRIPTION).eq("A") .and().item(UserType.F_DESCRIPTION).eq("B") @@ -744,24 +678,20 @@ public void test595Logicals2() throws Exception { .endBlock() .build(); - checkQueryRoundtripFile(UserType.class, q, TEST_NAME); + checkQueryRoundtripFile(UserType.class, q); } @Test public void test600Type() throws Exception { - final String TEST_NAME = "test600Type"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(ObjectType.class) .type(UserType.class) .item(UserType.F_NAME).eqPoly("somename", "somename") .build(); - checkQueryRoundtripFile(ObjectType.class, q, TEST_NAME); + checkQueryRoundtripFile(ObjectType.class, q); } @Test public void test700Exists() throws Exception { - final String TEST_NAME = "test700Exists"; - displayTestTitle(TEST_NAME); PrismReferenceValue ownerRef = ObjectTypeUtil.createObjectRef("1234567890", ObjectTypes.USER).asReferenceValue(); ObjectQuery q = getPrismContext().queryFor(AccessCertificationCaseType.class) .exists(new ParentPathSegment()) // if using T_PARENT then toString representation of paths is different @@ -772,7 +702,7 @@ public void test700Exists() throws Exception { .and().exists(AccessCertificationCaseType.F_WORK_ITEM) .item(AccessCertificationWorkItemType.F_STAGE_NUMBER).eq(3) .build(); - checkQueryRoundtripFile(AccessCertificationCaseType.class, q, TEST_NAME); + checkQueryRoundtripFile(AccessCertificationCaseType.class, q); } @Test @@ -780,7 +710,7 @@ public void test900TypeWrong() throws Exception { final String TEST_NAME = "test900TypeWrong"; String fileName = TEST_DIR + "/" + TEST_NAME + ".xml"; try { - toQueryType(FileUtils.readFileToString(new File(fileName))); + toQueryType(FileUtils.readFileToString(new File(fileName), StandardCharsets.UTF_8)); fail("Unexpected success!"); } catch (SchemaException e) { System.out.println("Got expected exception: " + e.getMessage()); @@ -791,7 +721,8 @@ public void test900TypeWrong() throws Exception { public void test910TypeWrongCompat() throws Exception { final String TEST_NAME = "test900TypeWrong"; String fileName = TEST_DIR + "/" + TEST_NAME + ".xml"; - QueryType jaxb = toQueryTypeCompat(FileUtils.readFileToString(new File(fileName))); + QueryType jaxb = toQueryTypeCompat( + FileUtils.readFileToString(new File(fileName), StandardCharsets.UTF_8)); displayQueryType(jaxb); try { ObjectQuery query = toObjectQuery(ObjectType.class, jaxb); @@ -806,7 +737,6 @@ public void test910TypeWrongCompat() throws Exception { @Test public void test920QueryTypeEquals() throws Exception { - final String TEST_NAME = "test920QueryTypeEquals"; ObjectQuery query1 = getPrismContext().queryFor(ShadowType.class) .id("8657eccf-c60d-4b5c-bbd4-4c73ecfd6436") .and().item(ShadowType.F_RESOURCE_REF).ref("aeff994e-381a-4fb3-af3b-f0f5dcdc9653") diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/parser/TestParseResource.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/parser/TestParseResource.java index ef83789c563..87ee870b134 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/parser/TestParseResource.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/parser/TestParseResource.java @@ -212,9 +212,6 @@ public void testSchemaRoundtrip() throws Exception { @Test public void testParseResourceFileExpression() throws Exception { - final String TEST_NAME = "testParseResourceFileExpression"; - displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = getPrismContext(); @@ -637,9 +634,6 @@ public void testParseResourceDom() throws Exception { if (!"xml".equals(language)) { return; } - final String TEST_NAME = "testParseResourceDom"; - displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = getPrismContext(); diff --git a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestAdHocCertification.java b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestAdHocCertification.java index dd99775f72a..ceb14258121 100644 --- a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestAdHocCertification.java +++ b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestAdHocCertification.java @@ -64,20 +64,17 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test010HireIndigo() throws Exception { - final String TEST_NAME = "test010HireIndigo"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestAdHocCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignOrg(USER_INDIGO_OID, ORG_LABORATORY_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -94,16 +91,13 @@ public void test010HireIndigo() throws Exception { @Test public void test020ModifyIndigo() throws Exception { - final String TEST_NAME = "test020ModifyIndigo"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestAdHocCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); @SuppressWarnings({ "unchecked", "raw" }) ObjectDelta delta = prismContext.deltaFor(UserType.class) .item(UserType.F_DESCRIPTION).replace("new description") @@ -112,7 +106,7 @@ public void test020ModifyIndigo() throws Exception { executeChanges(delta, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestCertificationBasic.java b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestCertificationBasic.java index 2917749a84b..a3c2fd7bba4 100644 --- a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestCertificationBasic.java +++ b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestCertificationBasic.java @@ -7,6 +7,26 @@ package com.evolveum.midpoint.certification.test; +import static java.util.Collections.singleton; +import static org.testng.AssertJUnit.*; + +import static com.evolveum.midpoint.prism.PrismConstants.T_PARENT; +import static com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignStateType.CLOSED; +import static com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignStateType.IN_REMEDIATION; +import static com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType.F_ACTIVATION; +import static com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationResponseType.*; +import static com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType.ENABLED; +import static com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType.F_ADMINISTRATIVE_STATUS; + +import java.io.File; +import java.util.Collection; +import java.util.Date; +import java.util.List; + +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.ContextConfiguration; +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.PrismConstants; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.query.ObjectQuery; @@ -21,24 +41,6 @@ import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.SecurityViolationException; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.testng.annotations.Test; - -import java.io.File; -import java.util.Collection; -import java.util.Date; -import java.util.List; - -import static com.evolveum.midpoint.prism.PrismConstants.T_PARENT; -import static com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignStateType.CLOSED; -import static com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignStateType.IN_REMEDIATION; -import static com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType.F_ACTIVATION; -import static com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationResponseType.*; -import static com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType.ENABLED; -import static com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType.F_ADMINISTRATIVE_STATUS; -import static java.util.Collections.singleton; -import static org.testng.AssertJUnit.*; /** * Very simple certification test. @@ -46,7 +48,7 @@ * * @author mederly */ -@ContextConfiguration(locations = {"classpath:ctx-certification-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-certification-test-main.xml" }) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) public class TestCertificationBasic extends AbstractCertificationTest { @@ -75,23 +77,20 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti */ @Test public void test001CreateForeignCampaign() throws Exception { - final String TEST_NAME = "test001CreateForeignCampaign"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); roleInducementCertDefinition = repoAddObjectFromFile(ROLE_INDUCEMENT_CERT_DEF_FILE, AccessCertificationDefinitionType.class, result).asObjectable(); // WHEN - when(TEST_NAME); + when(); AccessCertificationCampaignType campaign = certificationService.createCampaign(roleInducementCertDefinition.getOid(), task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -107,20 +106,17 @@ public void test001CreateForeignCampaign() throws Exception { @Test public void test002OpenFirstForeignStage() throws Exception { - final String TEST_NAME = "test002OpenFirstForeignStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); certificationService.openNextStage(roleInducementCampaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -131,11 +127,8 @@ public void test002OpenFirstForeignStage() throws Exception { @Test public void test005CreateCampaignDenied() throws Exception { - final String TEST_NAME = "test005CreateCampaignDenied"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); login(getUserFromRepo(USER_ELAINE_OID)); // elaine is a reviewer, not authorized to create campaigns @@ -151,11 +144,8 @@ public void test005CreateCampaignDenied() throws Exception { @Test public void test006CreateCampaignDeniedBobWrongDeputy() throws Exception { - final String TEST_NAME = "test006CreateCampaignDeniedBobWrongDeputy"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); login(getUserFromRepo(USER_BOB_DEPUTY_NO_ASSIGNMENTS_OID)); // this is a deputy with limitation blocking all assignments @@ -171,11 +161,8 @@ public void test006CreateCampaignDeniedBobWrongDeputy() throws Exception { @Test public void test010CreateCampaignAllowedForDeputy() throws Exception { - final String TEST_NAME = "test010CreateCampaignAllowedForDeputy"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); login(getUserFromRepo(USER_BOB_DEPUTY_FULL_OID)); @@ -185,7 +172,7 @@ public void test010CreateCampaignAllowedForDeputy() throws Exception { certificationService.createCampaign(certificationDefinition.getOid(), task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -206,11 +193,8 @@ public void test010CreateCampaignAllowedForDeputy() throws Exception { @Test public void test011CreateCampaignAllowed() throws Exception { - final String TEST_NAME = "test010CreateCampaignAllowed"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); login(getUserFromRepo(USER_BOB_OID)); @@ -220,7 +204,7 @@ public void test011CreateCampaignAllowed() throws Exception { certificationService.createCampaign(certificationDefinition.getOid(), task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -237,25 +221,21 @@ public void test011CreateCampaignAllowed() throws Exception { @Test public void test012SearchAllCasesDenied() throws Exception { - final String TEST_NAME = "test012SearchAllCasesDenied"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ELAINE_OID)); - searchWithNoCasesExpected(TEST_NAME); + searchWithNoCasesExpected(); } @Test public void test013SearchAllCasesAllowed() throws Exception { - final String TEST_NAME = "test013SearchAllCasesAllowed"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_BOB_OID)); - searchWithNoCasesExpected(TEST_NAME); + searchWithNoCasesExpected(); } - private void searchWithNoCasesExpected(String TEST_NAME) throws Exception { + private void searchWithNoCasesExpected() throws Exception { // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -265,7 +245,7 @@ private void searchWithNoCasesExpected(String TEST_NAME) throws Exception { null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -273,14 +253,10 @@ private void searchWithNoCasesExpected(String TEST_NAME) throws Exception { assertEquals("Unexpected cases in caseList", 0, caseList.size()); } - @Test public void test020OpenFirstStageDenied() throws Exception { - final String TEST_NAME = "test020OpenFirstStageDenied"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); login(getUserFromRepo(USER_ELAINE_OID)); @@ -298,11 +274,8 @@ public void test020OpenFirstStageDenied() throws Exception { @Test public void test021OpenFirstStageAllowed() throws Exception { - final String TEST_NAME = "test021OpenFirstStageAllowed"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); login(getUserFromRepo(USER_BOB_OID)); task.setOwner(getUserFromRepo(USER_BOB_OID)); @@ -312,7 +285,7 @@ public void test021OpenFirstStageAllowed() throws Exception { certificationService.openNextStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -320,7 +293,7 @@ public void test021OpenFirstStageAllowed() throws Exception { display("campaign in stage 1", campaign); assertSanityAfterCampaignStart(campaign, certificationDefinition, 7); - checkAllCasesSanity(campaign.getCase(), campaignOid); + checkAllCasesSanity(campaign.getCase()); List caseList = campaign.getCase(); // no responses -> NO_RESPONSE in all cases assertCaseOutcome(caseList, USER_ADMINISTRATOR_OID, ROLE_SUPERUSER_OID, NO_RESPONSE, NO_RESPONSE, null); @@ -336,30 +309,24 @@ public void test021OpenFirstStageAllowed() throws Exception { @Test public void test030SearchAllCasesDenied() throws Exception { - final String TEST_NAME = "test030SearchCasesDenied"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ELAINE_OID)); - searchWithNoCasesExpected(TEST_NAME); + searchWithNoCasesExpected(); } @Test public void test031SearchAllCasesDeniedLimitedDeputy() throws Exception { - final String TEST_NAME = "test031SearchAllCasesDeniedLimitedDeputy"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_BOB_DEPUTY_NO_ASSIGNMENTS_OID)); - searchWithNoCasesExpected(TEST_NAME); + searchWithNoCasesExpected(); } @Test public void test032SearchAllCasesAllowed() throws Exception { - final String TEST_NAME = "test032SearchAllCasesAllowed"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_BOB_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -368,22 +335,20 @@ public void test032SearchAllCasesAllowed() throws Exception { AccessCertificationCaseType.class, null, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); display("caseList", caseList); - checkAllCasesSanity(caseList, campaignOid); + checkAllCasesSanity(caseList); } @Test(enabled = false) public void test034SearchAllCasesAllowedDeputy() throws Exception { - final String TEST_NAME = "test034SearchAllCasesAllowedDeputy"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_BOB_DEPUTY_FULL_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -392,22 +357,20 @@ public void test034SearchAllCasesAllowedDeputy() throws Exception { AccessCertificationCaseType.class, null, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); display("caseList", caseList); - checkAllCasesSanity(caseList, campaignOid); + checkAllCasesSanity(caseList); } @Test public void test040SearchCasesFilteredSortedPaged() throws Exception { - final String TEST_NAME = "test040SearchCasesFilteredSortedPaged"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_BOB_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -429,7 +392,7 @@ public void test040SearchCasesFilteredSortedPaged() throws Exception { // - COO // - CEO // so paging (2, 2) should return the last two - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -443,12 +406,10 @@ public void test040SearchCasesFilteredSortedPaged() throws Exception { @Test public void test050SearchWorkItemsAdministrator() throws Exception { - final String TEST_NAME = "test050SearchWorkItemsAdministrator"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -459,7 +420,7 @@ public void test050SearchWorkItemsAdministrator() throws Exception { false, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -470,12 +431,10 @@ public void test050SearchWorkItemsAdministrator() throws Exception { @Test public void test052SearchWorkItemsByTenantRef() throws Exception { - final String TEST_NAME = "test052SearchWorkItemsByTenantRef"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -483,8 +442,8 @@ public void test052SearchWorkItemsByTenantRef() throws Exception { ObjectQuery query = prismContext.queryFor(AccessCertificationWorkItemType.class) .exists(T_PARENT) .block() - .item(AccessCertificationCaseType.F_TENANT_REF).ref(ORG_GOVERNOR_OFFICE_OID) - .and().ownerId(campaignOid) + .item(AccessCertificationCaseType.F_TENANT_REF).ref(ORG_GOVERNOR_OFFICE_OID) + .and().ownerId(campaignOid) .endBlock() .build(); List workItems = @@ -492,7 +451,7 @@ public void test052SearchWorkItemsByTenantRef() throws Exception { query, false, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -503,12 +462,10 @@ public void test052SearchWorkItemsByTenantRef() throws Exception { @Test public void test054SearchDecisionsByOrgRef() throws Exception { - final String TEST_NAME = "test054SearchDecisionsByOrgRef"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -516,15 +473,15 @@ public void test054SearchDecisionsByOrgRef() throws Exception { ObjectQuery query = prismContext.queryFor(AccessCertificationWorkItemType.class) .exists(T_PARENT) .block() - .item(AccessCertificationCaseType.F_ORG_REF).ref(ORG_SCUMM_BAR_OID) - .and().ownerId(campaignOid) + .item(AccessCertificationCaseType.F_ORG_REF).ref(ORG_SCUMM_BAR_OID) + .and().ownerId(campaignOid) .endBlock() .build(); List workItems = certificationService.searchOpenWorkItems(query, false, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -535,12 +492,10 @@ public void test054SearchDecisionsByOrgRef() throws Exception { @Test public void test056SearchDecisionsByAdminStatus() throws Exception { - final String TEST_NAME = "test056SearchDecisionsByAdminStatus"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -548,15 +503,15 @@ public void test056SearchDecisionsByAdminStatus() throws Exception { ObjectQuery query = prismContext.queryFor(AccessCertificationWorkItemType.class) .exists(T_PARENT) .block() - .item(F_ACTIVATION, F_ADMINISTRATIVE_STATUS).eq(ENABLED) - .and().ownerId(campaignOid) + .item(F_ACTIVATION, F_ADMINISTRATIVE_STATUS).eq(ENABLED) + .and().ownerId(campaignOid) .endBlock() .build(); List workItems = certificationService.searchOpenWorkItems(query, false, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -567,12 +522,10 @@ public void test056SearchDecisionsByAdminStatus() throws Exception { @Test public void test060SearchOpenWorkItemsDeputyDenied() throws Exception { - final String TEST_NAME = "test060SearchOpenWorkItemsDeputyDenied"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_DEPUTY_NONE_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -582,7 +535,7 @@ public void test060SearchOpenWorkItemsDeputyDenied() throws Exception { false, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -592,12 +545,10 @@ public void test060SearchOpenWorkItemsDeputyDenied() throws Exception { @Test public void test062SearchOpenWorkItemsDeputyAllowed() throws Exception { - final String TEST_NAME = "test062SearchOpenWorkItemsDeputyAllowed"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_DEPUTY_NO_ASSIGNMENTS_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -607,7 +558,7 @@ public void test062SearchOpenWorkItemsDeputyAllowed() throws Exception { false, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -618,12 +569,10 @@ public void test062SearchOpenWorkItemsDeputyAllowed() throws Exception { @Test public void test100RecordDecision() throws Exception { - final String TEST_NAME = "test100RecordDecision"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); List caseList = queryHelper.searchCases(campaignOid, null, null, result); @@ -636,31 +585,29 @@ public void test100RecordDecision() throws Exception { certificationService.recordDecision(campaignOid, id, workItem.getId(), ACCEPT, "no comment", task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); caseList = queryHelper.searchCases(campaignOid, null, null, result); display("caseList", caseList); - checkAllCasesSanity(caseList, campaignOid); + checkAllCasesSanity(caseList); superuserCase = findCase(caseList, USER_ADMINISTRATOR_OID, ROLE_SUPERUSER_OID); assertEquals("changed case ID", Long.valueOf(id), superuserCase.asPrismContainerValue().getId()); assertSingleDecision(superuserCase, ACCEPT, "no comment", 1, 1, USER_ADMINISTRATOR_OID, ACCEPT, false); AccessCertificationCampaignType campaign = getCampaignWithCases(campaignOid); - assertPercentCompleteAll(campaign, Math.round(100.0f/7.0f), Math.round(100.0f/7.0f), Math.round(100.0f/7.0f)); // 1 reviewer per case (always administrator) - assertPercentCompleteCurrent(campaign, Math.round(100.0f/7.0f), Math.round(100.0f/7.0f), Math.round(100.0f/7.0f)); // 1 reviewer per case (always administrator) + assertPercentCompleteAll(campaign, Math.round(100.0f / 7.0f), Math.round(100.0f / 7.0f), Math.round(100.0f / 7.0f)); // 1 reviewer per case (always administrator) + assertPercentCompleteCurrent(campaign, Math.round(100.0f / 7.0f), Math.round(100.0f / 7.0f), Math.round(100.0f / 7.0f)); // 1 reviewer per case (always administrator) } @Test public void test105RecordAcceptJackCeo() throws Exception { - final String TEST_NAME = "test105RecordAcceptJackCeo"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); List caseList = queryHelper.searchCases(campaignOid, null, null, result); @@ -674,31 +621,29 @@ public void test105RecordAcceptJackCeo() throws Exception { certificationService.recordDecision(campaignOid, id, workItem.getId(), ACCEPT, "ok", task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); caseList = queryHelper.searchCases(campaignOid, null, null, result); display("caseList", caseList); - checkAllCasesSanity(caseList, campaignOid); + checkAllCasesSanity(caseList); ceoCase = findCase(caseList, USER_JACK_OID, ROLE_CEO_OID); assertEquals("changed case ID", Long.valueOf(id), ceoCase.asPrismContainerValue().getId()); assertSingleDecision(ceoCase, ACCEPT, "ok", 1, 1, USER_ADMINISTRATOR_OID, ACCEPT, false); AccessCertificationCampaignType campaign = getCampaignWithCases(campaignOid); - assertPercentCompleteAll(campaign, Math.round(200.0f/7.0f), Math.round(200.0f/7.0f), Math.round(200.0f/7.0f)); // 1 reviewer per case (always administrator) - assertPercentCompleteCurrent(campaign, Math.round(200.0f/7.0f), Math.round(200.0f/7.0f), Math.round(200.0f/7.0f)); // 1 reviewer per case (always administrator) + assertPercentCompleteAll(campaign, Math.round(200.0f / 7.0f), Math.round(200.0f / 7.0f), Math.round(200.0f / 7.0f)); // 1 reviewer per case (always administrator) + assertPercentCompleteCurrent(campaign, Math.round(200.0f / 7.0f), Math.round(200.0f / 7.0f), Math.round(200.0f / 7.0f)); // 1 reviewer per case (always administrator) } @Test public void test110RecordRevokeJackCeo() throws Exception { - final String TEST_NAME = "test110RecordRevokeJackCeo"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); List caseList = queryHelper.searchCases(campaignOid, null, null, result); @@ -712,13 +657,13 @@ public void test110RecordRevokeJackCeo() throws Exception { certificationService.recordDecision(campaignOid, id, workItem.getId(), REVOKE, "no way", task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); caseList = queryHelper.searchCases(campaignOid, null, null, result); display("caseList", caseList); - checkAllCasesSanity(caseList, campaignOid); + checkAllCasesSanity(caseList); ceoCase = findCase(caseList, USER_JACK_OID, ROLE_CEO_OID); display("CEO case", ceoCase.asPrismContainerValue()); @@ -726,12 +671,12 @@ public void test110RecordRevokeJackCeo() throws Exception { assertSingleDecision(ceoCase, REVOKE, "no way", 1, 1, USER_ADMINISTRATOR_OID, REVOKE, false); AccessCertificationCampaignType campaign = getCampaignWithCases(campaignOid); - assertPercentCompleteAll(campaign, Math.round(200.0f/7.0f), Math.round(200.0f/7.0f), Math.round(200.0f/7.0f)); // 1 reviewer per case (always administrator) - assertPercentCompleteCurrent(campaign, Math.round(200.0f/7.0f), Math.round(200.0f/7.0f), Math.round(200.0f/7.0f)); // 1 reviewer per case (always administrator) + assertPercentCompleteAll(campaign, Math.round(200.0f / 7.0f), Math.round(200.0f / 7.0f), Math.round(200.0f / 7.0f)); // 1 reviewer per case (always administrator) + assertPercentCompleteCurrent(campaign, Math.round(200.0f / 7.0f), Math.round(200.0f / 7.0f), Math.round(200.0f / 7.0f)); // 1 reviewer per case (always administrator) } @SuppressWarnings("Duplicates") - private void checkAllCasesSanity(Collection caseList, String campaignOid) { + private void checkAllCasesSanity(Collection caseList) { assertEquals("Wrong number of certification cases", 7, caseList.size()); checkCaseSanity(caseList, USER_ADMINISTRATOR_OID, ROLE_SUPERUSER_OID, userAdministrator); checkCaseSanity(caseList, USER_ADMINISTRATOR_OID, ROLE_COO_OID, userAdministrator); @@ -754,12 +699,10 @@ private void checkAllWorkItemsSanity(Collection @Test public void test150CloseFirstStageDeny() throws Exception { - final String TEST_NAME = "test150CloseFirstStageDeny"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ELAINE_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN+THEN @@ -774,12 +717,10 @@ public void test150CloseFirstStageDeny() throws Exception { @Test public void test151CloseCampaignDeny() throws Exception { - final String TEST_NAME = "test151CloseCampaignDeny"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ELAINE_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN+THEN @@ -794,12 +735,10 @@ public void test151CloseCampaignDeny() throws Exception { @Test public void test152CloseFirstStageAllow() throws Exception { - final String TEST_NAME = "test152CloseFirstStageAllow"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_BOB_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(getUserFromRepo(USER_BOB_OID)); OperationResult result = task.getResult(); @@ -808,7 +747,7 @@ public void test152CloseFirstStageAllow() throws Exception { certificationService.closeCurrentStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -816,7 +755,7 @@ public void test152CloseFirstStageAllow() throws Exception { display("campaign in stage 1", campaign); assertSanityAfterStageClose(campaign, certificationDefinition, 1); List caseList = campaign.getCase(); - checkAllCasesSanity(caseList, campaignOid); + checkAllCasesSanity(caseList); assertCaseOutcome(caseList, USER_ADMINISTRATOR_OID, ROLE_SUPERUSER_OID, ACCEPT, ACCEPT, 1); assertCaseOutcome(caseList, USER_ADMINISTRATOR_OID, ROLE_COO_OID, NO_RESPONSE, NO_RESPONSE, 1); assertCaseOutcome(caseList, USER_ADMINISTRATOR_OID, ROLE_CEO_OID, NO_RESPONSE, NO_RESPONSE, 1); @@ -824,18 +763,16 @@ public void test152CloseFirstStageAllow() throws Exception { assertCaseOutcome(caseList, USER_JACK_OID, ROLE_CEO_OID, REVOKE, REVOKE, 1); assertCaseOutcome(caseList, USER_JACK_OID, ORG_EROOT_OID, NO_RESPONSE, NO_RESPONSE, 1); - assertPercentCompleteAll(campaign, Math.round(200.0f/7.0f), Math.round(200.0f/7.0f), Math.round(200.0f/7.0f)); // 1 reviewer per case (always administrator) - assertPercentCompleteCurrent(campaign, Math.round(200.0f/7.0f), Math.round(200.0f/7.0f), Math.round(200.0f/7.0f)); // 1 reviewer per case (always administrator) + assertPercentCompleteAll(campaign, Math.round(200.0f / 7.0f), Math.round(200.0f / 7.0f), Math.round(200.0f / 7.0f)); // 1 reviewer per case (always administrator) + assertPercentCompleteCurrent(campaign, Math.round(200.0f / 7.0f), Math.round(200.0f / 7.0f), Math.round(200.0f / 7.0f)); // 1 reviewer per case (always administrator) } @Test public void test200StartRemediationDeny() throws Exception { - final String TEST_NAME = "test200StartRemediationDeny"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ELAINE_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); @@ -850,12 +787,10 @@ public void test200StartRemediationDeny() throws Exception { @Test public void test205StartRemediationAllow() throws Exception { - final String TEST_NAME = "test205StartRemediationAllow"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_BOB_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); @@ -864,7 +799,7 @@ public void test205StartRemediationAllow() throws Exception { certificationService.startRemediation(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertInProgressOrSuccess(result); @@ -896,18 +831,16 @@ public void test205StartRemediationAllow() throws Exception { assertEquals("wrong # of jack's assignments", 4, userJack.getAssignment().size()); assertEquals("wrong target OID", ORG_EROOT_OID, userJack.getAssignment().get(0).getTargetRef().getOid()); - assertPercentCompleteAll(campaign, Math.round(200.0f/7.0f), Math.round(200.0f/7.0f), Math.round(200.0f/7.0f)); // 1 reviewer per case (always administrator) - assertPercentCompleteCurrent(campaign, Math.round(200.0f/7.0f), Math.round(200.0f/7.0f), Math.round(200.0f/7.0f)); // 1 reviewer per case (always administrator) + assertPercentCompleteAll(campaign, Math.round(200.0f / 7.0f), Math.round(200.0f / 7.0f), Math.round(200.0f / 7.0f)); // 1 reviewer per case (always administrator) + assertPercentCompleteCurrent(campaign, Math.round(200.0f / 7.0f), Math.round(200.0f / 7.0f), Math.round(200.0f / 7.0f)); // 1 reviewer per case (always administrator) } @Test public void test210CheckAfterClose() throws Exception { - final String TEST_NAME = "test210CheckAfterClose"; - TestUtil.displayTestTitle(this, TEST_NAME); login(userAdministrator.asPrismObject()); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); @@ -923,12 +856,10 @@ public void test210CheckAfterClose() throws Exception { @Test public void test900CleanupCampaignsDeny() throws Exception { - final String TEST_NAME = "test900CleanupCampaignsDeny"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ELAINE_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); @@ -944,12 +875,10 @@ public void test900CleanupCampaignsDeny() throws Exception { @Test public void test910CleanupCampaignsAllow() throws Exception { - final String TEST_NAME = "test910CleanupCampaignsAllow"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); @@ -980,12 +909,10 @@ public void test910CleanupCampaignsAllow() throws Exception { @Test public void test920CleanupCampaignsByAge() throws Exception { - final String TEST_NAME = "test920CleanupCampaignsByAge"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); diff --git a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestCriticalRolesCertification.java b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestCriticalRolesCertification.java index 570104bb9c4..c847c47e963 100644 --- a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestCriticalRolesCertification.java +++ b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestCriticalRolesCertification.java @@ -61,11 +61,8 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test010CreateCampaign() throws Exception { - final String TEST_NAME = "test010CreateCampaign"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); certificationDefinition = repoAddObjectFromFile(CERT_DEF_FILE, @@ -78,7 +75,7 @@ public void test010CreateCampaign() throws Exception { certificationManager.createCampaign(certificationDefinition.getOid(), task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -113,11 +110,8 @@ public void test010CreateCampaign() throws Exception { @Test public void test020OpenFirstStage() throws Exception { - final String TEST_NAME = "test020OpenFirstStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); dummyTransport.clearMessages(); @@ -127,7 +121,7 @@ public void test020OpenFirstStage() throws Exception { certificationManager.openNextStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -177,11 +171,8 @@ public void test020OpenFirstStage() throws Exception { @Test public void test100RecordDecisions1() throws Exception { - final String TEST_NAME = "test100RecordDecisions1"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); List caseList = queryHelper.searchCases(campaignOid, null, null, result); @@ -195,7 +186,7 @@ public void test100RecordDecisions1() throws Exception { recordDecision(campaignOid, guybrushCooCase, ACCEPT, null, USER_CHEESE_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -220,11 +211,8 @@ public void test100RecordDecisions1() throws Exception { @Test public void test150CloseFirstStage() throws Exception { - final String TEST_NAME = "test150CloseFirstStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); dummyTransport.clearMessages(); @@ -234,7 +222,7 @@ public void test150CloseFirstStage() throws Exception { certificationManager.closeCurrentStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -262,11 +250,8 @@ public void test150CloseFirstStage() throws Exception { @Test public void test200OpenSecondStage() throws Exception { - final String TEST_NAME = "test200OpenSecondStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); dummyTransport.clearMessages(); @@ -276,7 +261,7 @@ public void test200OpenSecondStage() throws Exception { certificationManager.openNextStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -336,11 +321,8 @@ public void test200OpenSecondStage() throws Exception { @Test public void test220StatisticsAllStages() throws Exception { - final String TEST_NAME = "test220StatisticsAllStages"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -349,7 +331,7 @@ public void test220StatisticsAllStages() throws Exception { certificationManager.getCampaignStatistics(campaignOid, false, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -365,11 +347,8 @@ public void test220StatisticsAllStages() throws Exception { @Test public void test250RecordDecisionsSecondStage() throws Exception { - final String TEST_NAME = "test250RecordDecisionsSecondStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); List caseList = queryHelper.searchCases(campaignOid, null, null, result); @@ -408,7 +387,7 @@ public void test250RecordDecisionsSecondStage() throws Exception { // jackCto: no reviewers // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -452,11 +431,8 @@ public void test250RecordDecisionsSecondStage() throws Exception { @Test public void test260Statistics() throws Exception { - final String TEST_NAME = "test260Statistics"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -465,7 +441,7 @@ public void test260Statistics() throws Exception { certificationManager.getCampaignStatistics(campaignOid, true, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -481,11 +457,8 @@ public void test260Statistics() throws Exception { @Test public void test290CloseSecondStage() throws Exception { - final String TEST_NAME = "test290CloseSecondStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); dummyTransport.clearMessages(); @@ -495,7 +468,7 @@ public void test290CloseSecondStage() throws Exception { certificationManager.closeCurrentStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -527,11 +500,8 @@ public void test290CloseSecondStage() throws Exception { @Test public void test300OpenThirdStage() throws Exception { - final String TEST_NAME = "test300OpenThirdStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); dummyTransport.clearMessages(); @@ -541,7 +511,7 @@ public void test300OpenThirdStage() throws Exception { certificationManager.openNextStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -604,11 +574,8 @@ public void test300OpenThirdStage() throws Exception { @Test public void test330RecordDecisionsThirdStage() throws Exception { - final String TEST_NAME = "test330RecordDecisionsThirdStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); List caseList = queryHelper.searchCases(campaignOid, null, null, result); @@ -643,7 +610,7 @@ public void test330RecordDecisionsThirdStage() throws Exception { // no response for jackCto // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -711,11 +678,8 @@ public void test330RecordDecisionsThirdStage() throws Exception { @Test public void test390CloseThirdStage() throws Exception { - final String TEST_NAME = "test390CloseThirdStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); dummyTransport.clearMessages(); @@ -725,7 +689,7 @@ public void test390CloseThirdStage() throws Exception { certificationManager.closeCurrentStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -777,11 +741,8 @@ public void test390CloseThirdStage() throws Exception { @Test public void test400OpenFourthStage() throws Exception { - final String TEST_NAME = "test400OpenFourthStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); dummyTransport.clearMessages(); @@ -791,7 +752,7 @@ public void test400OpenFourthStage() throws Exception { certificationManager.openNextStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -853,11 +814,8 @@ public void test400OpenFourthStage() throws Exception { @Test public void test430RecordDecisionsFourthStage() throws Exception { - final String TEST_NAME = "test430RecordDecisionsFourthStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); List caseList = queryHelper.searchCases(campaignOid, null, null, result); @@ -892,7 +850,7 @@ public void test430RecordDecisionsFourthStage() throws Exception { recordDecision(campaignOid, administratorCeoCase, ACCEPT, null, USER_CHEESE_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -958,11 +916,8 @@ public void test430RecordDecisionsFourthStage() throws Exception { @Test public void test490CloseFourthStage() throws Exception { - final String TEST_NAME = "test490CloseFourthStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); dummyTransport.clearMessages(); @@ -972,7 +927,7 @@ public void test490CloseFourthStage() throws Exception { certificationManager.closeCurrentStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1026,11 +981,8 @@ public void test490CloseFourthStage() throws Exception { @Test public void test495StartRemediation() throws Exception { - final String TEST_NAME = "test900StartRemediation"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); @@ -1039,7 +991,7 @@ public void test495StartRemediation() throws Exception { certificationManager.startRemediation(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertInProgressOrSuccess(result); @@ -1079,11 +1031,8 @@ public void test495StartRemediation() throws Exception { @Test public void test497Statistics() throws Exception { - final String TEST_NAME = "test910Statistics"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1092,7 +1041,7 @@ public void test497Statistics() throws Exception { certificationManager.getCampaignStatistics(campaignOid, false, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1111,12 +1060,10 @@ public void test497Statistics() throws Exception { @Test public void test499CheckAfterClose() throws Exception { - final String TEST_NAME = "test920CheckAfterClose"; - TestUtil.displayTestTitle(this, TEST_NAME); login(userAdministrator.asPrismObject()); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); @@ -1133,12 +1080,10 @@ public void test499CheckAfterClose() throws Exception { @Test public void test500Reiterate() throws Exception { - final String TEST_NAME = "test500Reiterate"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); @@ -1151,7 +1096,7 @@ public void test500Reiterate() throws Exception { certificationManager.reiterateCampaign(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1227,11 +1172,8 @@ public void test500Reiterate() throws Exception { @Test public void test510OpenNextStage() throws Exception { // next stage is 2 (because the first one has no work items) - final String TEST_NAME = "test510OpenNextStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); dummyTransport.clearMessages(); @@ -1241,7 +1183,7 @@ public void test510OpenNextStage() throws Exception { // next stage is certificationManager.openNextStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1311,69 +1253,4 @@ Out of them, completed (for stage 2) are: elaine->CEO, guybrush->COO, administra assertCasesCount(campaignOid, 6); display("dummy transport", dummyTransport); } - -// @Test -// public void test520CloseFirstStage() throws Exception { -// final String TEST_NAME = "test520CloseFirstStage"; -// TestUtil.displayTestTitle(this, TEST_NAME); -// -// // GIVEN -// Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); -// task.setOwner(userAdministrator.asPrismObject()); -// OperationResult result = task.getResult(); -// -// // WHEN -// when(); -// certificationManager.closeCurrentStage(campaignOid, task, result); -// -// // THEN -// TestUtil.displayThen(TEST_NAME); -// result.computeStatus(); -// TestUtil.assertSuccess(result); -// -// AccessCertificationCampaignType campaign = getCampaignWithCases(campaignOid); -// display("campaign in stage 1", campaign); -// -// assertSanityAfterStageClose(campaign, certificationDefinition, 1); -// -// List caseList = queryHelper.searchCases(campaignOid, null, null, result); -// assertEquals("unexpected # of cases", 6, caseList.size()); -// -// assertCaseOutcome(caseList, USER_ELAINE_OID, ROLE_CEO_OID, ACCEPT, ACCEPT, 1); -// assertCaseOutcome(caseList, USER_GUYBRUSH_OID, ROLE_COO_OID, ACCEPT, ACCEPT, 1); -// assertCaseOutcome(caseList, USER_ADMINISTRATOR_OID, ROLE_COO_OID, ACCEPT, ACCEPT, 1); -// assertCaseOutcome(caseList, USER_ADMINISTRATOR_OID, ROLE_CEO_OID, ACCEPT, ACCEPT, 1); -// assertCaseOutcome(caseList, USER_JACK_OID, ROLE_CEO_OID, ACCEPT, ACCEPT, 1); -// assertCaseOutcome(caseList, USER_JACK_OID, ROLE_CTO_OID, ACCEPT, ACCEPT, 1); -// -// assertPercentComplete(campaignOid, 100, 100, 100); -// assertCasesCount(campaignOid, 6); -// } - -// @Test -// public void test530OpenSecondStage() throws Exception { -// final String TEST_NAME = "test530OpenSecondStage"; -// TestUtil.displayTestTitle(this, TEST_NAME); -// -// // GIVEN -// Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); -// task.setOwner(userAdministrator.asPrismObject()); -// OperationResult result = task.getResult(); -// -// // WHEN -// when(); -// certificationManager.openNextStage(campaignOid, task, result); -// -// // THEN -// TestUtil.displayThen(TEST_NAME); -// result.computeStatus(); -// TestUtil.assertSuccess(result); -// -// AccessCertificationCampaignType campaign = getCampaignWithCases(campaignOid); -// display("campaign in stage 2", campaign); -// assertSanityAfterStageOpen(campaign, certificationDefinition, 2, 2, 6); -// -// List caseList = queryHelper.searchCases(campaignOid, null, null, result); -// } - } diff --git a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestEscalation.java b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestEscalation.java index dae35133c5b..d4d68489ca6 100644 --- a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestEscalation.java +++ b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestEscalation.java @@ -60,11 +60,8 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test010CreateCampaign() throws Exception { - final String TEST_NAME = "test010CreateCampaign"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -73,7 +70,7 @@ public void test010CreateCampaign() throws Exception { certificationService.createCampaign(certificationDefinition.getOid(), task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -89,16 +86,13 @@ public void test010CreateCampaign() throws Exception { @Test public void test013SearchAllCases() throws Exception { - final String TEST_NAME = "test013SearchAllCases"; - TestUtil.displayTestTitle(this, TEST_NAME); - - searchWithNoCasesExpected(TEST_NAME); + searchWithNoCasesExpected(); } @SuppressWarnings("SameParameterValue") - private void searchWithNoCasesExpected(String TEST_NAME) throws Exception { + private void searchWithNoCasesExpected() throws Exception { // GIVEN - Task task = taskManager.createTaskInstance(TestEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -108,7 +102,7 @@ private void searchWithNoCasesExpected(String TEST_NAME) throws Exception { null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -118,11 +112,8 @@ private void searchWithNoCasesExpected(String TEST_NAME) throws Exception { @Test public void test021OpenFirstStage() throws Exception { - final String TEST_NAME = "test021OpenFirstStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); @@ -131,7 +122,7 @@ public void test021OpenFirstStage() throws Exception { certificationService.openNextStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -157,11 +148,8 @@ public void test021OpenFirstStage() throws Exception { @Test public void test032SearchAllCases() throws Exception { - final String TEST_NAME = "test032SearchAllCases"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -170,7 +158,7 @@ public void test032SearchAllCases() throws Exception { AccessCertificationCaseType.class, null, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -180,11 +168,8 @@ public void test032SearchAllCases() throws Exception { @Test public void test050SearchWorkItems() throws Exception { - final String TEST_NAME = "test050SearchWorkItems"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -195,7 +180,7 @@ public void test050SearchWorkItems() throws Exception { false, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -206,11 +191,8 @@ public void test050SearchWorkItems() throws Exception { @Test public void test100RecordDecision() throws Exception { - final String TEST_NAME = "test100RecordDecision"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); List caseList = queryHelper.searchCases(campaignOid, null, null, result); @@ -223,7 +205,7 @@ public void test100RecordDecision() throws Exception { certificationService.recordDecision(campaignOid, id, workItem.getId(), ACCEPT, "no comment", task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -242,12 +224,10 @@ public void test100RecordDecision() throws Exception { @Test public void test110Escalate() throws Exception { - final String TEST_NAME = "test110Escalate"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyTransport.clearMessages(); @@ -260,7 +240,7 @@ public void test110Escalate() throws Exception { waitForTaskNextRun(TASK_TRIGGER_SCANNER_OID, true, 20000, true); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -309,12 +289,10 @@ public void test110Escalate() throws Exception { @Test public void test120EscalateAgain() throws Exception { - final String TEST_NAME = "test120EscalateAgain"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyTransport.clearMessages(); @@ -327,7 +305,7 @@ public void test120EscalateAgain() throws Exception { waitForTaskNextRun(TASK_TRIGGER_SCANNER_OID, true, 20000, true); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -378,12 +356,10 @@ public void test120EscalateAgain() throws Exception { @Test public void test130Remediation() throws Exception { - final String TEST_NAME = "test130Remediation"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyTransport.clearMessages(); @@ -396,7 +372,7 @@ public void test130Remediation() throws Exception { waitForTaskNextRun(TASK_TRIGGER_SCANNER_OID, true, 20000, true); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -407,12 +383,10 @@ public void test130Remediation() throws Exception { @Test public void test140Close() throws Exception { - final String TEST_NAME = "test140Close"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); @@ -426,7 +400,7 @@ public void test140Close() throws Exception { certificationManager.closeCampaign(campaignOid, true, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -438,12 +412,10 @@ public void test140Close() throws Exception { @Test public void test200AutomaticReiteration() throws Exception { - final String TEST_NAME = "test200AutomaticReiteration"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); @@ -457,7 +429,7 @@ public void test200AutomaticReiteration() throws Exception { waitForTaskNextRun(TASK_TRIGGER_SCANNER_OID, true, 20000, true); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -496,12 +468,10 @@ public void test200AutomaticReiteration() throws Exception { @Test public void test300Close() throws Exception { - final String TEST_NAME = "test300Close"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); @@ -515,7 +485,7 @@ public void test300Close() throws Exception { certificationManager.closeCampaign(campaignOid, true, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -527,12 +497,10 @@ public void test300Close() throws Exception { @Test public void test310ManualReiteration() throws Exception { - final String TEST_NAME = "test310ManualReiteration"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); @@ -546,7 +514,7 @@ public void test310ManualReiteration() throws Exception { certificationManager.reiterateCampaign(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -575,11 +543,8 @@ public void test310ManualReiteration() throws Exception { @Test public void test320OpenFirstStage() throws Exception { - final String TEST_NAME = "test320OpenFirstStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); @@ -588,7 +553,7 @@ public void test320OpenFirstStage() throws Exception { certificationService.openNextStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -627,12 +592,10 @@ public void test320OpenFirstStage() throws Exception { @Test public void test400Close() throws Exception { - final String TEST_NAME = "test300Close"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); @@ -646,7 +609,7 @@ public void test400Close() throws Exception { certificationManager.closeCampaign(campaignOid, true, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -658,12 +621,10 @@ public void test400Close() throws Exception { @Test public void test410ManualReiterationUnavailable() throws Exception { - final String TEST_NAME = "test410ManualReiterationUnavailable"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); diff --git a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestManualEscalation.java b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestManualEscalation.java index 239224c426b..db718359252 100644 --- a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestManualEscalation.java +++ b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestManualEscalation.java @@ -63,11 +63,8 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test010CreateCampaign() throws Exception { - final String TEST_NAME = "test010CreateCampaign"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestManualEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); login(getUserFromRepo(USER_BOB_OID)); @@ -77,7 +74,7 @@ public void test010CreateCampaign() throws Exception { certificationService.createCampaign(certificationDefinition.getOid(), task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -93,12 +90,10 @@ public void test010CreateCampaign() throws Exception { @Test public void test013SearchAllCasesAllowed() throws Exception { - final String TEST_NAME = "test013SearchAllCasesAllowed"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_BOB_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestManualEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -108,7 +103,7 @@ public void test013SearchAllCasesAllowed() throws Exception { null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -118,11 +113,8 @@ public void test013SearchAllCasesAllowed() throws Exception { @Test public void test021OpenFirstStageAllowed() throws Exception { - final String TEST_NAME = "test021OpenFirstStageAllowed"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestManualEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); login(getUserFromRepo(USER_BOB_OID)); @@ -131,7 +123,7 @@ public void test021OpenFirstStageAllowed() throws Exception { certificationService.openNextStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -139,7 +131,7 @@ public void test021OpenFirstStageAllowed() throws Exception { display("campaign in stage 1", campaign); assertSanityAfterCampaignStart(campaign, certificationDefinition, 7); - checkAllCases(campaign.getCase(), campaignOid); + checkAllCases(campaign.getCase()); List caseList = campaign.getCase(); // no responses -> NO_RESPONSE in all cases assertCaseOutcome(caseList, USER_ADMINISTRATOR_OID, ROLE_SUPERUSER_OID, NO_RESPONSE, NO_RESPONSE, null); @@ -154,12 +146,10 @@ public void test021OpenFirstStageAllowed() throws Exception { @Test public void test032SearchAllCasesAllowed() throws Exception { - final String TEST_NAME = "test032SearchAllCasesAllowed"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_BOB_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestManualEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -168,22 +158,20 @@ public void test032SearchAllCasesAllowed() throws Exception { AccessCertificationCaseType.class, null, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); display("caseList", caseList); - checkAllCases(caseList, campaignOid); + checkAllCases(caseList); } @Test public void test050SearchWorkItemsAsAdministrator() throws Exception { - final String TEST_NAME = "test050SearchWorkItemsAsAdministrator"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestManualEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -194,7 +182,7 @@ public void test050SearchWorkItemsAsAdministrator() throws Exception { false, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -205,12 +193,10 @@ public void test050SearchWorkItemsAsAdministrator() throws Exception { @Test public void test100RecordDecision() throws Exception { - final String TEST_NAME = "test100RecordDecision"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestManualEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); List caseList = queryHelper.searchCases(campaignOid, null, null, result); @@ -223,13 +209,13 @@ public void test100RecordDecision() throws Exception { certificationService.recordDecision(campaignOid, id, workItem.getId(), ACCEPT, "no comment", task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); caseList = queryHelper.searchCases(campaignOid, null, null, result); display("caseList", caseList); - checkAllCases(caseList, campaignOid); + checkAllCases(caseList); superuserCase = findCase(caseList, USER_ADMINISTRATOR_OID, ROLE_SUPERUSER_OID); assertEquals("changed case ID", Long.valueOf(id), superuserCase.asPrismContainerValue().getId()); @@ -241,12 +227,10 @@ public void test100RecordDecision() throws Exception { @Test public void test110Escalate() throws Exception { - final String TEST_NAME = "test110Escalate"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestManualEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -258,13 +242,13 @@ public void test110Escalate() throws Exception { operationsHelper.escalateCampaign(campaignOid, action, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); List caseList = queryHelper.searchCases(campaignOid, null, null, result); display("caseList", caseList); - checkAllCases(caseList, campaignOid); + checkAllCases(caseList); AccessCertificationCaseType ceoCase = findCase(caseList, USER_JACK_OID, ROLE_CEO_OID); display("CEO case after escalation", ceoCase); @@ -290,12 +274,10 @@ public void test110Escalate() throws Exception { @Test public void test120EscalateAgain() throws Exception { - final String TEST_NAME = "test120EscalateAgain"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestManualEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -306,13 +288,13 @@ public void test120EscalateAgain() throws Exception { operationsHelper.escalateCampaign(campaignOid, action, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); List caseList = queryHelper.searchCases(campaignOid, null, null, result); display("caseList", caseList); - checkAllCases(caseList, campaignOid); + checkAllCases(caseList); AccessCertificationCaseType ceoCase = findCase(caseList, USER_JACK_OID, ROLE_CEO_OID); display("CEO case after escalation", ceoCase); @@ -340,12 +322,10 @@ public void test120EscalateAgain() throws Exception { @Test public void test130Delegate() throws Exception { - final String TEST_NAME = "test130Delegate"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestManualEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); List caseList = queryHelper.searchCases(campaignOid, null, null, result); @@ -362,13 +342,13 @@ public void test130Delegate() throws Exception { certificationManager.delegateWorkItems(campaignOid, Collections.singletonList(workItem), action, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); caseList = queryHelper.searchCases(campaignOid, null, null, result); display("caseList", caseList); - checkAllCases(caseList, campaignOid); + checkAllCases(caseList); ceoCase = findCase(caseList, USER_JACK_OID, ROLE_CEO_OID); display("CEO case after escalation", ceoCase); @@ -394,7 +374,7 @@ public void test130Delegate() throws Exception { assertPercentCompleteAll(campaign, Math.round(100.0f / 7.0f), Math.round(100.0f / 7.0f), Math.round(100.0f / 7.0f)); } - protected void checkAllCases(Collection caseList, String campaignOid) { + protected void checkAllCases(Collection caseList) { assertEquals("Wrong number of certification cases", 7, caseList.size()); checkCaseSanity(caseList, USER_ADMINISTRATOR_OID, ROLE_SUPERUSER_OID, userAdministrator); checkCaseSanity(caseList, USER_ADMINISTRATOR_OID, ROLE_COO_OID, userAdministrator); diff --git a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestRoleInducementCertification.java b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestRoleInducementCertification.java index 5457026ec9f..40e383a3634 100644 --- a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestRoleInducementCertification.java +++ b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestRoleInducementCertification.java @@ -44,11 +44,8 @@ public class TestRoleInducementCertification extends AbstractCertificationTest { @Test public void test010CreateCampaign() throws Exception { - final String TEST_NAME = "test010CreateCampaign"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); certificationDefinition = repoAddObjectFromFile(ROLE_INDUCEMENT_CERT_DEF_FILE, @@ -60,7 +57,7 @@ public void test010CreateCampaign() throws Exception { certificationManager.createCampaign(certificationDefinition.getOid(), task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -77,11 +74,8 @@ public void test010CreateCampaign() throws Exception { @Test public void test012SearchAllCases() throws Exception { - final String TEST_NAME = "test012SearchAllCases"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -89,7 +83,7 @@ public void test012SearchAllCases() throws Exception { List caseList = queryHelper.searchCases(campaignOid, null, null, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -99,11 +93,8 @@ public void test012SearchAllCases() throws Exception { @Test public void test014Statistics() throws Exception { - final String TEST_NAME = "test014Statistics"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -112,7 +103,7 @@ public void test014Statistics() throws Exception { certificationManager.getCampaignStatistics(campaignOid, true, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -128,11 +119,8 @@ public void test014Statistics() throws Exception { @Test public void test020OpenFirstStage() throws Exception { - final String TEST_NAME = "test020OpenFirstStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); @@ -141,7 +129,7 @@ public void test020OpenFirstStage() throws Exception { certificationManager.openNextStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -176,11 +164,8 @@ protected void checkAllCasesSanity(Collection caseL @Test public void test024Statistics() throws Exception { - final String TEST_NAME = "test024Statistics"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -189,7 +174,7 @@ public void test024Statistics() throws Exception { certificationManager.getCampaignStatistics(campaignOid, true, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -206,11 +191,8 @@ public void test024Statistics() throws Exception { @Test public void test030SearchAllCases() throws Exception { - final String TEST_NAME = "test030SearchCases"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -218,7 +200,7 @@ public void test030SearchAllCases() throws Exception { List caseList = queryHelper.searchCases(campaignOid, null, null, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -230,12 +212,9 @@ public void test030SearchAllCases() throws Exception { @Test public void test050SearchDecisionsAdministrator() throws Exception { - final String TEST_NAME = "test050SearchDecisionsAdministrator"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN login(userAdministrator.asPrismObject()); - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -251,7 +230,7 @@ public void test050SearchDecisionsAdministrator() throws Exception { */ // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -264,12 +243,9 @@ public void test050SearchDecisionsAdministrator() throws Exception { @Test public void test051SearchDecisionsElaine() throws Exception { - final String TEST_NAME = "test051SearchDecisionsElaine"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN login(userElaine.asPrismObject()); - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -283,7 +259,7 @@ public void test051SearchDecisionsElaine() throws Exception { */ // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -294,12 +270,9 @@ public void test051SearchDecisionsElaine() throws Exception { @Test public void test052SearchDecisionsJack() throws Exception { - final String TEST_NAME = "test052SearchDecisionsJack"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN login(userJack.asPrismObject()); - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -310,7 +283,7 @@ public void test052SearchDecisionsJack() throws Exception { /* Expected cases - phase 1: NONE */ // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -331,12 +304,9 @@ public void test052SearchDecisionsJack() throws Exception { @Test public void test100RecordDecisions() throws Exception { - final String TEST_NAME = "test100RecordDecisions"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN login(userAdministrator.asPrismObject()); - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); List caseList = queryHelper.searchCases(campaignOid, null, null, result); @@ -355,7 +325,7 @@ public void test100RecordDecisions() throws Exception { recordDecision(campaignOid, cooSuperuserCase, NOT_DECIDED, "I'm so procrastinative...", null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -390,11 +360,8 @@ public void test100RecordDecisions() throws Exception { @Test public void test110Statistics() throws Exception { - final String TEST_NAME = "test110Statistics"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -403,7 +370,7 @@ public void test110Statistics() throws Exception { certificationManager.getCampaignStatistics(campaignOid, true, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -420,11 +387,8 @@ public void test110Statistics() throws Exception { @Test public void test150CloseFirstStage() throws Exception { - final String TEST_NAME = "test150CloseFirstStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); @@ -433,7 +397,7 @@ public void test150CloseFirstStage() throws Exception { certificationManager.closeCurrentStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -468,11 +432,8 @@ public void test150CloseFirstStage() throws Exception { @Test public void test160Statistics() throws Exception { - final String TEST_NAME = "test160Statistics"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -481,7 +442,7 @@ public void test160Statistics() throws Exception { certificationManager.getCampaignStatistics(campaignOid, true, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -497,11 +458,8 @@ public void test160Statistics() throws Exception { @Test public void test200OpenSecondStage() throws Exception { - final String TEST_NAME = "test200OpenSecondStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); @@ -510,7 +468,7 @@ public void test200OpenSecondStage() throws Exception { certificationManager.openNextStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -557,11 +515,8 @@ public void test200OpenSecondStage() throws Exception { @Test public void test210Statistics() throws Exception { - final String TEST_NAME = "test210Statistics"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -570,7 +525,7 @@ public void test210Statistics() throws Exception { certificationManager.getCampaignStatistics(campaignOid, true, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -586,11 +541,8 @@ public void test210Statistics() throws Exception { @Test public void test220StatisticsAllStages() throws Exception { - final String TEST_NAME = "test220StatisticsAllStages"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -599,7 +551,7 @@ public void test220StatisticsAllStages() throws Exception { certificationManager.getCampaignStatistics(campaignOid, false, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -615,11 +567,8 @@ public void test220StatisticsAllStages() throws Exception { @Test public void test250RecordDecisionsSecondStage() throws Exception { - final String TEST_NAME = "test250RecordDecisionsSecondStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); List caseList = queryHelper.searchCases(campaignOid, null, null, result); @@ -637,7 +586,7 @@ public void test250RecordDecisionsSecondStage() throws Exception { recordDecision(campaignOid, superuserDummyCase, ACCEPT, null, USER_JACK_OID, task, result); // decision of administrator is missing here // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -702,11 +651,8 @@ public void test250RecordDecisionsSecondStage() throws Exception { @Test public void test260Statistics() throws Exception { - final String TEST_NAME = "test260Statistics"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -715,7 +661,7 @@ public void test260Statistics() throws Exception { certificationManager.getCampaignStatistics(campaignOid, true, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -731,11 +677,8 @@ public void test260Statistics() throws Exception { @Test public void test290CloseSecondStage() throws Exception { - final String TEST_NAME = "test290CloseSecondStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); @@ -744,7 +687,7 @@ public void test290CloseSecondStage() throws Exception { certificationManager.closeCurrentStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -792,11 +735,8 @@ public void test290CloseSecondStage() throws Exception { @Test public void test300StartRemediation() throws Exception { - final String TEST_NAME = "test300StartRemediation"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); @@ -805,7 +745,7 @@ public void test300StartRemediation() throws Exception { certificationManager.startRemediation(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertInProgressOrSuccess(result); @@ -866,11 +806,8 @@ public void test300StartRemediation() throws Exception { @Test public void test310Statistics() throws Exception { - final String TEST_NAME = "test310Statistics"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -879,7 +816,7 @@ public void test310Statistics() throws Exception { certificationManager.getCampaignStatistics(campaignOid, false, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -895,8 +832,6 @@ public void test310Statistics() throws Exception { @Test public void test320CheckAfterClose() throws Exception { - final String TEST_NAME = "test320CheckAfterClose"; - TestUtil.displayTestTitle(this, TEST_NAME); login(userAdministrator.asPrismObject()); // GIVEN diff --git a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestSoDCertification.java b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestSoDCertification.java index 613ad7d7443..861dd83d113 100644 --- a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestSoDCertification.java +++ b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestSoDCertification.java @@ -94,9 +94,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test001Triggers() throws Exception { - final String TEST_NAME = "test001Triggers"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN, WHEN PrismObject jack = getUser(USER_JACK_OID); display("jack", jack); @@ -153,11 +150,8 @@ private void assertTriggers(AssignmentType assignment, int exclusionExpected, in @Test public void test010CreateCampaign() throws Exception { - final String TEST_NAME = "test010CreateCampaign"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestSoDCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); certificationDefinition = repoAddObjectFromFile(SOD_CERTIFICATION_DEF_FILE, @@ -169,7 +163,7 @@ public void test010CreateCampaign() throws Exception { certificationManager.createCampaign(certificationDefinition.getOid(), task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -185,11 +179,8 @@ public void test010CreateCampaign() throws Exception { @Test public void test012SearchAllCases() throws Exception { - final String TEST_NAME = "test012SearchAllCases"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestSoDCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -197,7 +188,7 @@ public void test012SearchAllCases() throws Exception { List caseList = queryHelper.searchCases(campaignOid, null, null, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -207,11 +198,8 @@ public void test012SearchAllCases() throws Exception { @Test public void test014Statistics() throws Exception { - final String TEST_NAME = "test014Statistics"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestSoDCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -220,7 +208,7 @@ public void test014Statistics() throws Exception { certificationManager.getCampaignStatistics(campaignOid, true, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -236,11 +224,8 @@ public void test014Statistics() throws Exception { @Test public void test020OpenFirstStage() throws Exception { - final String TEST_NAME = "test020OpenFirstStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestSoDCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); @@ -251,7 +236,7 @@ public void test020OpenFirstStage() throws Exception { certificationManager.openNextStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -283,11 +268,8 @@ protected void checkAllCases(Collection caseList) @Test public void test030SearchAllCases() throws Exception { - final String TEST_NAME = "test030SearchCases"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestSoDCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -295,7 +277,7 @@ public void test030SearchAllCases() throws Exception { List caseList = queryHelper.searchCases(campaignOid, null, null, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -308,11 +290,8 @@ public void test030SearchAllCases() throws Exception { @Test public void test100RecordDecisions() throws Exception { - final String TEST_NAME = "test100RecordDecisions"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestSoDCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); List caseList = queryHelper.searchCases(campaignOid, null, null, result); @@ -333,7 +312,7 @@ public void test100RecordDecisions() throws Exception { recordDecision(campaignOid, test3bCase, NOT_DECIDED, "dunno", USER_JACK_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -365,11 +344,8 @@ public void test100RecordDecisions() throws Exception { @Test public void test150CloseFirstStage() throws Exception { - final String TEST_NAME = "test150CloseFirstStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestSoDCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); @@ -378,7 +354,7 @@ public void test150CloseFirstStage() throws Exception { certificationManager.closeCurrentStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -411,11 +387,8 @@ public void test150CloseFirstStage() throws Exception { @Test public void test200StartRemediation() throws Exception { - final String TEST_NAME = "test200StartRemediation"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestSoDCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); @@ -424,7 +397,7 @@ public void test200StartRemediation() throws Exception { certificationManager.startRemediation(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertInProgressOrSuccess(result); @@ -464,8 +437,6 @@ public void test200StartRemediation() throws Exception { @Test public void test210CheckAfterClose() throws Exception { - final String TEST_NAME = "test210CheckAfterClose"; - TestUtil.displayTestTitle(this, TEST_NAME); login(userAdministrator.asPrismObject()); // GIVEN diff --git a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/complex/TestPolicyDrivenRoleLifecycle.java b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/complex/TestPolicyDrivenRoleLifecycle.java index d43e3234fd3..f5ed0c18e3e 100644 --- a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/complex/TestPolicyDrivenRoleLifecycle.java +++ b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/complex/TestPolicyDrivenRoleLifecycle.java @@ -21,7 +21,6 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.WorkItemId; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DebugUtil; import com.evolveum.midpoint.util.Holder; import com.evolveum.midpoint.util.exception.*; @@ -111,17 +110,14 @@ protected File getSystemConfigurationFile() { @Test public void test010AttemptToActivateIncompleteRoleC1345() throws Exception { - final String TEST_NAME = "test010AttemptToActivateIncompleteRoleC1345"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestPolicyDrivenRoleLifecycle.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); // WHEN+THEN when(); - TestUtil.displayThen(TEST_NAME); + then(); Holder> contextHolder = new Holder<>(); activateRoleAssertFailure(roleEmptyOid, contextHolder, result, task); @@ -146,17 +142,14 @@ private void activateRoleAssertFailure(String roleOid, Holder> co @Test public void test020AttemptToActivateIncompleteRoleC234() throws Exception { - final String TEST_NAME = "test020AttemptToActivateIncompleteRoleC234"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestPolicyDrivenRoleLifecycle.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); // WHEN+THEN when(); - TestUtil.displayThen(TEST_NAME); + then(); Holder> contextHolder = new Holder<>(); activateRoleAssertFailure(roleHighRiskEmptyOid, contextHolder, result, task); @@ -169,17 +162,14 @@ public void test020AttemptToActivateIncompleteRoleC234() throws Exception { @Test public void test030AttemptToActivateCorrectRoleC34() throws Exception { - final String TEST_NAME = "test030AttemptToActivateCorrectRoleC34"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestPolicyDrivenRoleLifecycle.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); // WHEN+THEN when(); - TestUtil.displayThen(TEST_NAME); + then(); Holder> contextHolder = new Holder<>(); activateRoleAssertFailure(roleCorrectOid, contextHolder, result, task); @@ -196,17 +186,14 @@ private void dumpRules(Holder> contextHolder) { @Test public void test040AssignOwnerAndApproverToCorrectRole() throws Exception { - final String TEST_NAME = "test040AssignOwnerAndApproverToCorrectRole"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestPolicyDrivenRoleLifecycle.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); // WHEN+THEN when(); - TestUtil.displayThen(TEST_NAME); + then(); ModelExecuteOptions noApprovals = createPartialProcessing(new PartialProcessingOptionsType().approvals(SKIP)); assignRole(USER_ADMINISTRATOR_OID, roleCorrectOid, SchemaConstants.ORG_APPROVER, noApprovals, task, result); assignRole(USER_ADMINISTRATOR_OID, roleCorrectOid, SchemaConstants.ORG_OWNER, noApprovals, task, result); @@ -217,11 +204,8 @@ public void test040AssignOwnerAndApproverToCorrectRole() throws Exception { @Test public void test050ActivateCorrectRole() throws Exception { - final String TEST_NAME = "test050ActivateCorrectRole"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestPolicyDrivenRoleLifecycle.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); @@ -231,7 +215,7 @@ public void test050ActivateCorrectRole() throws Exception { activateRole(roleCorrectOid, contextHolder, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject roleAfter = getRole(roleCorrectOid); display("role after", roleAfter); @@ -276,17 +260,14 @@ public void test050ActivateCorrectRole() throws Exception { @Test public void test060AssignOwnerAndApproverToCorrectHighRiskRole() throws Exception { - final String TEST_NAME = "test060AssignOwnerAndApproverToCorrectHighRiskRole"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestPolicyDrivenRoleLifecycle.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); // WHEN+THEN when(); - TestUtil.displayThen(TEST_NAME); + then(); ModelExecuteOptions noApprovals = createPartialProcessing(new PartialProcessingOptionsType().approvals(SKIP)); assignRole(USER_ADMINISTRATOR_OID, roleCorrectHighRiskOid, SchemaConstants.ORG_APPROVER, noApprovals, task, result); assignRole(userJackOid, roleCorrectHighRiskOid, SchemaConstants.ORG_APPROVER, noApprovals, task, result); @@ -298,11 +279,8 @@ public void test060AssignOwnerAndApproverToCorrectHighRiskRole() throws Exceptio @Test public void test070ActivateCorrectHighRiskRole() throws Exception { - final String TEST_NAME = "test070ActivateCorrectHighRiskRole"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestPolicyDrivenRoleLifecycle.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); @@ -312,7 +290,7 @@ public void test070ActivateCorrectHighRiskRole() throws Exception { activateRole(roleCorrectHighRiskOid, contextHolder, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject roleAfter = getRole(roleCorrectHighRiskOid); display("role after", roleAfter); @@ -377,73 +355,4 @@ private void activateRole(String oid, Holder> contextHolder, Task } } } - -// @Test -// public void test010HireIndigo() throws Exception { -// final String TEST_NAME = "test010HireIndigo"; -// TestUtil.displayTestTitle(this, TEST_NAME); -// -// // GIVEN -// Task task = taskManager.createTaskInstance(TestPolicyDrivenRoleLifecycle.class.getName() + "." + TEST_NAME); -// task.setOwner(userAdministrator.asPrismObject()); -// OperationResult result = task.getResult(); -// -// // WHEN -// when(); -// assignOrg(USER_INDIGO_OID, ORG_LABORATORY_OID, task, result); -// -// // THEN -// TestUtil.displayThen(TEST_NAME); -// result.computeStatus(); -// TestUtil.assertSuccess(result); -// -// SearchResultList> campaigns = repositoryService -// .searchObjects(AccessCertificationCampaignType.class, null, null, result); -// assertEquals("Wrong # of campaigns", 1, campaigns.size()); -// AccessCertificationCampaignType campaign = campaigns.get(0).asObjectable(); -// -// campaign = getCampaignWithCases(campaign.getOid()); -// display("campaign", campaign); -// assertSanityAfterCampaignStart(campaign, assignmentCertificationDefinition, 1); // beware, maybe not all details would match (in the future) - then adapt this test -// assertPercentComplete(campaign, 0, 0, 0); // no cases, no problems -// assertCasesCount(campaign.getOid(), 1); -// } -// -// @Test -// public void test020ModifyIndigo() throws Exception { -// final String TEST_NAME = "test020ModifyIndigo"; -// TestUtil.displayTestTitle(this, TEST_NAME); -// -// // GIVEN -// Task task = taskManager.createTaskInstance(TestPolicyDrivenRoleLifecycle.class.getName() + "." + TEST_NAME); -// task.setOwner(userAdministrator.asPrismObject()); -// OperationResult result = task.getResult(); -// -// // WHEN -// when(); -// @SuppressWarnings({ "unchecked", "raw" }) -// ObjectDelta delta = (ObjectDelta) 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> 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); -// assertSanityAfterCampaignStart(campaign, modificationCertificationDefinition, 1); // beware, maybe not all details would match (in the future) - then adapt this test -// assertPercentComplete(campaign, 0, 0, 0); // no cases, no problems -// } } diff --git a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/script/ScriptExpressionFactory.java b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/script/ScriptExpressionFactory.java index 93f493b96cc..27fb55044ed 100644 --- a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/script/ScriptExpressionFactory.java +++ b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/script/ScriptExpressionFactory.java @@ -7,19 +7,20 @@ package com.evolveum.midpoint.model.common.expression.script; import java.util.*; - import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; +import org.jetbrains.annotations.NotNull; + import com.evolveum.midpoint.CacheInvalidationContext; import com.evolveum.midpoint.model.common.expression.functions.CustomFunctions; import com.evolveum.midpoint.model.common.expression.functions.FunctionLibrary; import com.evolveum.midpoint.prism.ItemDefinition; import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.crypto.Protector; +import com.evolveum.midpoint.repo.api.Cacheable; import com.evolveum.midpoint.repo.api.RepositoryService; import com.evolveum.midpoint.repo.cache.CacheRegistry; -import com.evolveum.midpoint.repo.api.Cacheable; import com.evolveum.midpoint.repo.common.ObjectResolver; import com.evolveum.midpoint.repo.common.expression.ExpressionFactory; import com.evolveum.midpoint.repo.common.expression.ExpressionSyntaxException; @@ -41,12 +42,9 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.FunctionLibraryType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ScriptExpressionEvaluatorType; import com.evolveum.midpoint.xml.ns._public.common.common_3.SingleCacheStateInformationType; -import org.jetbrains.annotations.NotNull; /** - * * @author Radovan Semancik - * */ public class ScriptExpressionFactory implements Cacheable { @@ -54,7 +52,7 @@ public class ScriptExpressionFactory implements Cacheable { public static final String DEFAULT_LANGUAGE = "http://midpoint.evolveum.com/xml/ns/public/expression/language#Groovy"; - private Map evaluatorMap = new HashMap<>(); + private Map evaluatorMap = new HashMap<>(); private ObjectResolver objectResolver; private final PrismContext prismContext; private Collection functions; @@ -90,7 +88,7 @@ public void setObjectResolver(ObjectResolver objectResolver) { } public void setEvaluators(Collection evaluators) { - for (ScriptEvaluator evaluator: evaluators) { + for (ScriptEvaluator evaluator : evaluators) { registerEvaluator(evaluator.getLanguageUrl(), evaluator); } } @@ -115,9 +113,11 @@ public void setCacheRegistry(CacheRegistry registry) { this.cacheRegistry = registry; } - public ScriptExpression createScriptExpression(ScriptExpressionEvaluatorType expressionType, ItemDefinition outputDefinition, - ExpressionProfile expressionProfile, ExpressionFactory expressionFactory, String shortDesc, Task task, OperationResult result) - throws ExpressionSyntaxException, SecurityViolationException { + public ScriptExpression createScriptExpression( + ScriptExpressionEvaluatorType expressionType, ItemDefinition outputDefinition, + ExpressionProfile expressionProfile, ExpressionFactory expressionFactory, + String shortDesc, Task task, OperationResult result) + throws ExpressionSyntaxException, SecurityViolationException { initializeCustomFunctionsLibraryCache(expressionFactory, task, result); //cache cleanup method @@ -152,7 +152,7 @@ private ScriptExpressionProfile processScriptExpressionProfile(ExpressionProfile return null; } else { throw new SecurityViolationException("Access to script expression evaluator " + - " not allowed (expression profile: "+expressionProfile.getIdentifier()+") in "+shortDesc); + " not allowed (expression profile: " + expressionProfile.getIdentifier() + ") in " + shortDesc); } } ScriptExpressionProfile scriptProfile = evaluatorProfile.getScriptExpressionProfile(language); @@ -161,7 +161,7 @@ private ScriptExpressionProfile processScriptExpressionProfile(ExpressionProfile return null; } else { throw new SecurityViolationException("Access to script language " + language + - " not allowed (expression profile: "+expressionProfile.getIdentifier()+") in "+shortDesc); + " not allowed (expression profile: " + expressionProfile.getIdentifier() + ") in " + shortDesc); } } return scriptProfile; @@ -205,15 +205,15 @@ private synchronized void initializeCustomFunctionsLibraryCache(ExpressionFactor public void registerEvaluator(String language, ScriptEvaluator evaluator) { if (evaluatorMap.containsKey(language)) { - throw new IllegalArgumentException("Evaluator for language "+language+" already registered"); + throw new IllegalArgumentException("Evaluator for language " + language + " already registered"); } - evaluatorMap.put(language,evaluator); + evaluatorMap.put(language, evaluator); } private ScriptEvaluator getEvaluator(String language, String shortDesc) throws ExpressionSyntaxException { ScriptEvaluator evaluator = evaluatorMap.get(language); if (evaluator == null) { - throw new ExpressionSyntaxException("Unsupported language "+language+" used in script in "+shortDesc); + throw new ExpressionSyntaxException("Unsupported language " + language + " used in script in " + shortDesc); } return evaluator; } diff --git a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/mapping/MappingImpl.java b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/mapping/MappingImpl.java index 96f92eb4f56..db701349071 100644 --- a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/mapping/MappingImpl.java +++ b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/mapping/MappingImpl.java @@ -6,6 +6,14 @@ */ package com.evolveum.midpoint.model.common.mapping; +import java.util.*; +import javax.xml.datatype.DatatypeConstants; +import javax.xml.datatype.Duration; +import javax.xml.datatype.XMLGregorianCalendar; +import javax.xml.namespace.QName; + +import org.jetbrains.annotations.NotNull; + import com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition; import com.evolveum.midpoint.model.api.context.Mapping; import com.evolveum.midpoint.prism.*; @@ -35,25 +43,17 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.DeltaSetTripleType; import com.evolveum.prism.xml.ns._public.types_3.ItemPathType; -import org.jetbrains.annotations.NotNull; - -import javax.xml.datatype.DatatypeConstants; -import javax.xml.datatype.Duration; -import javax.xml.datatype.XMLGregorianCalendar; -import javax.xml.namespace.QName; -import java.util.*; /** - * * Mapping is non-recyclable single-use object. Once evaluated it should not be evaluated again. It will retain its original * inputs and outputs that can be read again and again. But these should not be changed after evaluation. - * + *

* Configuration properties are unmodifiable. They are to be set via Mapping.Builder. * * @author Radovan Semancik - * */ -public class MappingImpl implements Mapping, DebugDumpable, PrismValueDeltaSetTripleProducer { +public class MappingImpl + implements Mapping, DebugDumpable, PrismValueDeltaSetTripleProducer { private static final String OP_EVALUATE_PREPARED = MappingImpl.class.getName() + ".evaluatePrepared"; private static final String OP_EVALUATE = MappingImpl.class.getName() + ".evaluate"; @@ -67,8 +67,8 @@ public class MappingImpl implemen private final ObjectDeltaObject sourceContext; private TypedValue> typedSourceContext; // cached - private final Collection> sources; - private final Source defaultSource; + private final Collection> sources; + private final Source defaultSource; private final PrismObjectDefinition targetContext; private final ItemPath defaultTargetPath; @@ -89,7 +89,7 @@ public class MappingImpl implemen private final String contextDescription; private final QName mappingQName; // This is sometimes used to identify the element that mapping produces - // if it is different from itemName. E.g. this happens with associations. + // if it is different from itemName. E.g. this happens with associations. private final RefinedObjectClassDefinition refinedObjectClassDefinition; // working and output properties @@ -121,15 +121,15 @@ public class MappingImpl implemen // This is single-use only. Once evaluated it is not used any more // it is remembered only for tracing purposes. - private Expression expression; + private Expression expression; // Mapping state properties that are exposed to the expressions. They can be used by the expressions to "communicate". // E.g. one expression seting the property and other expression checking the property. - private Map stateProperties; + private Map stateProperties; private static final Trace LOGGER = TraceManager.getTrace(MappingImpl.class); - private MappingImpl(Builder builder) { + private MappingImpl(Builder builder) { prismContext = builder.prismContext; expressionFactory = builder.expressionFactory; variables = builder.variables; @@ -179,7 +179,7 @@ public ObjectType getOriginObject() { return originObject; } - public Source getDefaultSource() { + public Source getDefaultSource() { return defaultSource; } @@ -223,7 +223,7 @@ public String getMappingContextDescription() { } sb.append("in "); sb.append(contextDescription); - mappingContextDescription = sb.toString(); + mappingContextDescription = sb.toString(); } return mappingContextDescription; } @@ -316,7 +316,7 @@ public boolean isApplicableToChannel(String channelUri) { public static boolean isApplicableToChannel(MappingType mappingType, String channelUri) { List exceptChannel = mappingType.getExceptChannel(); - if (exceptChannel != null && !exceptChannel.isEmpty()){ + if (exceptChannel != null && !exceptChannel.isEmpty()) { return !exceptChannel.contains(channelUri); } List applicableChannels = mappingType.getChannel(); @@ -387,7 +387,7 @@ public T setStateProperty(String propertyName, T value) { stateProperties = new HashMap<>(); } //noinspection unchecked - return (T)stateProperties.put(propertyName, value); + return (T) stateProperties.put(propertyName, value); } // TODO: rename to evaluateAll @@ -446,7 +446,7 @@ public void prepare(Task task, OperationResult parentResult) parseTarget(); if (outputPath != null && outputDefinition == null) { - throw new IllegalArgumentException("No output definition, cannot evaluate "+getMappingContextDescription()); + throw new IllegalArgumentException("No output definition, cannot evaluate " + getMappingContextDescription()); } } catch (ExpressionEvaluationException | ObjectNotFoundException | RuntimeException | SchemaException | @@ -510,10 +510,10 @@ private void evaluateBody(Task task, OperationResult parentResult) throws Expres evaluateCondition(task, result); - boolean conditionOutputOld = computeConditionResult(conditionOutputTriple==null ? null : conditionOutputTriple.getNonPositiveValues()); + boolean conditionOutputOld = computeConditionResult(conditionOutputTriple == null ? null : conditionOutputTriple.getNonPositiveValues()); boolean conditionResultOld = conditionOutputOld && conditionMaskOld; - boolean conditionOutputNew = computeConditionResult(conditionOutputTriple==null ? null : conditionOutputTriple.getNonNegativeValues()); + boolean conditionOutputNew = computeConditionResult(conditionOutputTriple == null ? null : conditionOutputTriple.getNonNegativeValues()); boolean conditionResultNew = conditionOutputNew && conditionMaskNew; if (trace != null) { @@ -594,7 +594,7 @@ private void checkRangeTarget(Task task, OperationResult result) throw new IllegalStateException("Couldn't check range for mapping in " + contextDescription + ", as original target values are not known."); } ValueSetDefinitionType rangetSetDefType = mappingType.getTarget().getSet(); - ValueSetDefinition setDef = new ValueSetDefinition<>(rangetSetDefType, outputDefinition, expressionProfile, name, "range of "+name+" in "+getMappingContextDescription(), task, result); + ValueSetDefinition setDef = new ValueSetDefinition<>(rangetSetDefType, outputDefinition, expressionProfile, name, "range of " + name + " in " + getMappingContextDescription(), task, result); setDef.init(expressionFactory); setDef.setAdditionalVariables(variables); for (V originalValue : originalTargetValues) { @@ -615,7 +615,7 @@ private void addToMinusIfNecessary(V originalValue) { outputTriple = getPrismContext().deltaFactory().createPrismValueDeltaSetTriple(); } LOGGER.trace("Original value is in the mapping range (while not in mapping result), adding it to minus set: {}", originalValue); - outputTriple.addToMinusSet((V)originalValue.clone()); + outputTriple.addToMinusSet((V) originalValue.clone()); } @SuppressWarnings("unused") // todo is this externally used? @@ -764,7 +764,7 @@ private void appendTraceHeader(StringBuilder sb) { if (!isAuthoritative()) { sb.append("\nNot authoritative"); } - for (Source source: sources) { + for (Source source : sources) { sb.append("\n"); source.mediumDump(sb); } @@ -858,7 +858,7 @@ private XMLGregorianCalendar parseTime(MappingTimeDeclarationType timeType, Task if (referenceTimeType == null) { if (defaultReferenceTime == null) { if (expressionType == null) { - throw new SchemaException("No reference time specified, there is also no default and no expression; in time specification in "+getMappingContextDescription()); + throw new SchemaException("No reference time specified, there is also no default and no expression; in time specification in " + getMappingContextDescription()); } else { referenceTime = null; } @@ -885,7 +885,7 @@ private XMLGregorianCalendar parseTime(MappingTimeDeclarationType timeType, Task timeVariables.addVariableDefinitions(variables); timeVariables.addVariableDefinition(ExpressionConstants.VAR_REFERENCE_TIME, referenceTime, timeDefinition); - PrismPropertyValue timePropVal = ExpressionUtil.evaluateExpression(sources, timeVariables, timeDefinition, expressionType, expressionProfile, expressionFactory, "time expression in "+contextDescription, task, result); + PrismPropertyValue timePropVal = ExpressionUtil.evaluateExpression(sources, timeVariables, timeDefinition, expressionType, expressionProfile, expressionFactory, "time expression in " + contextDescription, task, result); if (timePropVal == null) { return null; @@ -905,19 +905,19 @@ private XMLGregorianCalendar parseTimeSource(VariableBindingDefinitionType sourc SecurityViolationException, ExpressionEvaluationException { ItemPath path = getSourcePath(source); - Object sourceObject = ExpressionUtil.resolvePathGetValue(path, variables, false, getTypedSourceContext(), objectResolver, getPrismContext(), "reference time definition in "+getMappingContextDescription(), task, result); + Object sourceObject = ExpressionUtil.resolvePathGetValue(path, variables, false, getTypedSourceContext(), objectResolver, getPrismContext(), "reference time definition in " + getMappingContextDescription(), task, result); if (sourceObject == null) { return null; } PrismProperty timeProperty; - if (sourceObject instanceof ItemDeltaItem) { + if (sourceObject instanceof ItemDeltaItem) { //noinspection unchecked - timeProperty = (PrismProperty) ((ItemDeltaItem)sourceObject).getItemNew(); - } else if (sourceObject instanceof Item) { + timeProperty = (PrismProperty) ((ItemDeltaItem) sourceObject).getItemNew(); + } else if (sourceObject instanceof Item) { //noinspection unchecked timeProperty = (PrismProperty) sourceObject; } else { - throw new IllegalStateException("Unknown resolve result "+sourceObject); + throw new IllegalStateException("Unknown resolve result " + sourceObject); } return timeProperty != null ? timeProperty.getRealValue() : null; } @@ -932,8 +932,8 @@ private void parseSources(Task task, OperationResult result) defaultSource.recompute(); } if (sourceDefinitions != null) { - for (VariableBindingDefinitionType sourceDefinition: sourceDefinitions) { - Source source = parseSource(sourceDefinition, task, result); + for (VariableBindingDefinitionType sourceDefinition : sourceDefinitions) { + Source source = parseSource(sourceDefinition, task, result); source.recompute(); // Override existing sources (e.g. default source) @@ -943,7 +943,7 @@ private void parseSources(Task task, OperationResult result) } } - private Source parseSource(VariableBindingDefinitionType sourceDefinition, + private Source parseSource(VariableBindingDefinitionType sourceDefinition, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { @@ -953,48 +953,48 @@ private Source parseSo TypedValue typedSourceObject = ExpressionUtil.resolvePathGetTypedValue(path, variables, true, getTypedSourceContext(), objectResolver, getPrismContext(), - "source definition in "+getMappingContextDescription(), task, result); + "source definition in " + getMappingContextDescription(), task, result); Object sourceObject = typedSourceObject != null ? typedSourceObject.getValue() : null; - Item itemOld = null; - ItemDelta delta = null; - Item itemNew = null; + Item itemOld = null; + ItemDelta delta = null; + Item itemNew = null; ItemPath resolvePath = path; ItemPath residualPath = null; - Collection> subItemDeltas = null; + Collection> subItemDeltas = null; if (sourceObject != null) { - if (sourceObject instanceof ItemDeltaItem) { + if (sourceObject instanceof ItemDeltaItem) { //noinspection unchecked - itemOld = ((ItemDeltaItem)sourceObject).getItemOld(); + itemOld = ((ItemDeltaItem) sourceObject).getItemOld(); //noinspection unchecked - delta = ((ItemDeltaItem)sourceObject).getDelta(); + delta = ((ItemDeltaItem) sourceObject).getDelta(); //noinspection unchecked - itemNew = ((ItemDeltaItem)sourceObject).getItemNew(); + itemNew = ((ItemDeltaItem) sourceObject).getItemNew(); //noinspection unchecked - residualPath = ((ItemDeltaItem)sourceObject).getResidualPath(); + residualPath = ((ItemDeltaItem) sourceObject).getResidualPath(); //noinspection unchecked - resolvePath = ((ItemDeltaItem)sourceObject).getResolvePath(); + resolvePath = ((ItemDeltaItem) sourceObject).getResolvePath(); //noinspection unchecked - subItemDeltas = ((ItemDeltaItem)sourceObject).getSubItemDeltas(); - } else if (sourceObject instanceof Item) { + subItemDeltas = ((ItemDeltaItem) sourceObject).getSubItemDeltas(); + } else if (sourceObject instanceof Item) { //noinspection unchecked - itemOld = (Item) sourceObject; + itemOld = (Item) sourceObject; //noinspection unchecked - itemNew = (Item) sourceObject; + itemNew = (Item) sourceObject; } else { - throw new IllegalStateException("Unknown resolve result "+sourceObject); + throw new IllegalStateException("Unknown resolve result " + sourceObject); } } // TODO what if typedSourceObject is null? //noinspection unchecked - ID sourceItemDefinition = (ID)typedSourceObject.getDefinition(); + ID sourceItemDefinition = (ID) typedSourceObject.getDefinition(); // apply domain ValueSetDefinitionType domainSetType = sourceDefinition.getSet(); if (domainSetType != null) { - ValueSetDefinition setDef = new ValueSetDefinition<>(domainSetType, sourceItemDefinition, expressionProfile, variableName, "domain of "+variableName+" in "+getMappingContextDescription(), task, result); + ValueSetDefinition setDef = new ValueSetDefinition<>(domainSetType, sourceItemDefinition, expressionProfile, variableName, "domain of " + variableName + " in " + getMappingContextDescription(), task, result); setDef.init(expressionFactory); setDef.setAdditionalVariables(variables); try { @@ -1034,7 +1034,7 @@ private Source parseSo } } - Source source = new Source<>(itemOld, delta, itemNew, sourceQName, sourceItemDefinition); + Source source = new Source<>(itemOld, delta, itemNew, sourceQName, sourceItemDefinition); source.setResidualPath(residualPath); source.setResolvePath(resolvePath); source.setSubItemDeltas(subItemDeltas); @@ -1055,7 +1055,7 @@ private ItemPath getSourcePath(VariableBindingDefinitionType sourceType) throws } private boolean sourcesChanged() { - for (Source source: sources) { + for (Source source : sources) { if (source.getDelta() != null) { return true; } @@ -1075,9 +1075,9 @@ private void parseTarget() throws SchemaException { outputPath = defaultTargetPath; } else { ItemPath path = itemPathType.getItemPath(); - outputDefinition = ExpressionUtil.resolveDefinitionPath(path, variables, targetContext, "target definition in "+getMappingContextDescription()); + outputDefinition = ExpressionUtil.resolveDefinitionPath(path, variables, targetContext, "target definition in " + getMappingContextDescription()); if (outputDefinition == null) { - throw new SchemaException("No target item that would conform to the path "+path+" in "+getMappingContextDescription()); + throw new SchemaException("No target item that would conform to the path " + path + " in " + getMappingContextDescription()); } outputPath = path.stripVariableSegment(); } @@ -1120,7 +1120,7 @@ private void recomputeValues() { } Visitor visitor = visitable -> { if (visitable instanceof PrismValue) { - ((PrismValue)visitable).recompute(getPrismContext()); + ((PrismValue) visitable).recompute(getPrismContext()); } }; outputTriple.accept(visitor); @@ -1146,11 +1146,11 @@ private void evaluateCondition(Task task, OperationResult result) throws SchemaE conditionOutputTriple.addToZeroSet(getPrismContext().itemFactory().createPropertyValue(Boolean.TRUE)); return; } - Expression,PrismPropertyDefinition> expression = + Expression, PrismPropertyDefinition> expression = ExpressionUtil.createCondition(conditionExpressionType, expressionProfile, expressionFactory, - "condition in "+getMappingContextDescription(), task, result); + "condition in " + getMappingContextDescription(), task, result); ExpressionEvaluationContext context = new ExpressionEvaluationContext(sources, variables, - "condition in "+getMappingContextDescription(), task); + "condition in " + getMappingContextDescription(), task); context.setValuePolicyResolver(stringPolicyResolver); context.setExpressionFactory(expressionFactory); context.setDefaultSource(defaultSource); @@ -1161,16 +1161,15 @@ private void evaluateCondition(Task task, OperationResult result) throws SchemaE conditionOutputTriple = expression.evaluate(context, result); } - private void evaluateExpression(Task task, OperationResult result, boolean conditionResultOld, boolean conditionResultNew) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException { ExpressionType expressionType = null; if (mappingType != null) { expressionType = mappingType.getExpression(); } expression = expressionFactory.makeExpression(expressionType, outputDefinition, expressionProfile, - "expression in "+getMappingContextDescription(), task, result); + "expression in " + getMappingContextDescription(), task, result); ExpressionEvaluationContext context = new ExpressionEvaluationContext(sources, variables, - "expression in "+getMappingContextDescription(), task); + "expression in " + getMappingContextDescription(), task); context.setDefaultSource(defaultSource); context.setSkipEvaluationMinus(!conditionResultOld); context.setSkipEvaluationPlus(!conditionResultNew); @@ -1231,17 +1230,17 @@ public PrismValueDeltaSetTriple getOutputTriple() { return outputTriple; } - public Item getOutput() throws SchemaException { + public Item getOutput() throws SchemaException { if (outputTriple == null) { return null; } //noinspection unchecked - Item output = outputDefinition.instantiate(); + Item output = outputDefinition.instantiate(); output.addAll(PrismValueCollectionsUtil.cloneCollection(outputTriple.getNonNegativeValues())); return output; } - public ItemDelta createEmptyDelta(ItemPath path) { + public ItemDelta createEmptyDelta(ItemPath path) { //noinspection unchecked return outputDefinition.createEmptyDelta(path); } @@ -1252,7 +1251,7 @@ private void transitionState(MappingEvaluationState newState) { private void assertState(MappingEvaluationState expectedState) { if (state != expectedState) { - throw new IllegalArgumentException("Expected mapping state "+expectedState+", but was "+state); + throw new IllegalArgumentException("Expected mapping state " + expectedState + ", but was " + state); } } @@ -1319,94 +1318,58 @@ public int hashCode() { @SuppressWarnings("RedundantIfStatement") @Override public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; + if (this == obj) { return true; } + if (obj == null) { return false; } + if (getClass() != obj.getClass()) { return false; } MappingImpl other = (MappingImpl) obj; - if (conditionMaskNew != other.conditionMaskNew) - return false; - if (conditionMaskOld != other.conditionMaskOld) - return false; + if (conditionMaskNew != other.conditionMaskNew) { return false; } + if (conditionMaskOld != other.conditionMaskOld) { return false; } if (conditionOutputTriple == null) { - if (other.conditionOutputTriple != null) - return false; - } else if (!conditionOutputTriple.equals(other.conditionOutputTriple)) - return false; + if (other.conditionOutputTriple != null) { return false; } + } else if (!conditionOutputTriple.equals(other.conditionOutputTriple)) { return false; } if (defaultSource == null) { - if (other.defaultSource != null) - return false; - } else if (!defaultSource.equals(other.defaultSource)) - return false; + if (other.defaultSource != null) { return false; } + } else if (!defaultSource.equals(other.defaultSource)) { return false; } if (defaultTargetDefinition == null) { - if (other.defaultTargetDefinition != null) - return false; - } else if (!defaultTargetDefinition.equals(other.defaultTargetDefinition)) - return false; + if (other.defaultTargetDefinition != null) { return false; } + } else if (!defaultTargetDefinition.equals(other.defaultTargetDefinition)) { return false; } if (expressionProfile == null) { - if (other.expressionProfile != null) - return false; - } else if (!expressionProfile.equals(other.expressionProfile)) - return false; + if (other.expressionProfile != null) { return false; } + } else if (!expressionProfile.equals(other.expressionProfile)) { return false; } if (expressionFactory == null) { - if (other.expressionFactory != null) - return false; - } else if (!expressionFactory.equals(other.expressionFactory)) - return false; + if (other.expressionFactory != null) { return false; } + } else if (!expressionFactory.equals(other.expressionFactory)) { return false; } if (mappingType == null) { - if (other.mappingType != null) - return false; - } else if (!mappingType.equals(other.mappingType)) - return false; + if (other.mappingType != null) { return false; } + } else if (!mappingType.equals(other.mappingType)) { return false; } if (objectResolver == null) { - if (other.objectResolver != null) - return false; - } else if (!objectResolver.equals(other.objectResolver)) - return false; + if (other.objectResolver != null) { return false; } + } else if (!objectResolver.equals(other.objectResolver)) { return false; } if (originObject == null) { - if (other.originObject != null) - return false; - } else if (!originObject.equals(other.originObject)) - return false; - if (originType != other.originType) - return false; + if (other.originObject != null) { return false; } + } else if (!originObject.equals(other.originObject)) { return false; } + if (originType != other.originType) { return false; } if (outputDefinition == null) { - if (other.outputDefinition != null) - return false; - } else if (!outputDefinition.equals(other.outputDefinition)) - return false; + if (other.outputDefinition != null) { return false; } + } else if (!outputDefinition.equals(other.outputDefinition)) { return false; } if (outputTriple == null) { - if (other.outputTriple != null) - return false; - } else if (!outputTriple.equals(other.outputTriple)) - return false; + if (other.outputTriple != null) { return false; } + } else if (!outputTriple.equals(other.outputTriple)) { return false; } if (contextDescription == null) { - if (other.contextDescription != null) - return false; - } else if (!contextDescription.equals(other.contextDescription)) - return false; + if (other.contextDescription != null) { return false; } + } else if (!contextDescription.equals(other.contextDescription)) { return false; } if (sourceContext == null) { - if (other.sourceContext != null) - return false; - } else if (!sourceContext.equals(other.sourceContext)) - return false; + if (other.sourceContext != null) { return false; } + } else if (!sourceContext.equals(other.sourceContext)) { return false; } if (sources == null) { - if (other.sources != null) - return false; - } else if (!sources.equals(other.sources)) - return false; + if (other.sources != null) { return false; } + } else if (!sources.equals(other.sources)) { return false; } if (targetContext == null) { - if (other.targetContext != null) - return false; - } else if (!targetContext.equals(other.targetContext)) - return false; + if (other.targetContext != null) { return false; } + } else if (!targetContext.equals(other.targetContext)) { return false; } if (variables == null) { - if (other.variables != null) - return false; - } else if (!variables.equals(other.variables)) - return false; + if (other.variables != null) { return false; } + } else if (!variables.equals(other.variables)) { return false; } return true; } @@ -1421,7 +1384,7 @@ public String debugDump(int indent) { @Override public String toString() { if (mappingType != null && mappingType.getName() != null) { - return "M(" + mappingType.getName()+ ": "+ getMappingDisplayName() + " = " + outputTriple + toStringStrength() + ")"; + return "M(" + mappingType.getName() + ": " + getMappingDisplayName() + " = " + outputTriple + toStringStrength() + ")"; } else { return "M(" + getMappingDisplayName() + " = " + outputTriple + toStringStrength() + ")"; } @@ -1439,9 +1402,12 @@ private String getMappingDisplayName() { private String toStringStrength() { switch (getStrength()) { - case NORMAL: return ""; - case WEAK: return ", weak"; - case STRONG: return ", strong"; + case NORMAL: + return ""; + case WEAK: + return ", weak"; + case STRONG: + return ", strong"; } return null; } @@ -1467,16 +1433,14 @@ public String toHumanReadableDescription() { return sb.toString(); } - - /** * Builder is used to construct a configuration of Mapping object, which - after building - becomes * immutable. - * + *

* In order to provide backward-compatibility with existing use of Mapping object, the builder has * also traditional setter methods. Both setters and "builder-style" methods MODIFY existing Builder * object (i.e. they do not create a new one). - * + *

* TODO decide on which style of setters to keep (setters vs builder-style). */ @SuppressWarnings({ "unused", "BooleanMethodIsAlwaysInverted", "UnusedReturnValue" }) @@ -1486,14 +1450,14 @@ public static final class Builder defaultSource; + private Source defaultSource; private D defaultTargetDefinition; private ExpressionProfile expressionProfile; private ItemPath defaultTargetPath; private Collection originalTargetValues; private ObjectDeltaObject sourceContext; private PrismObjectDefinition targetContext; - private Collection> sources = new ArrayList<>(); + private Collection> sources = new ArrayList<>(); private OriginType originType; private ObjectType originObject; private ValuePolicyResolver valuePolicyResolver; @@ -1509,58 +1473,57 @@ public static final class Builder expressionFactory(ExpressionFactory val) { + public Builder expressionFactory(ExpressionFactory val) { expressionFactory = val; return this; } - public Builder variables(ExpressionVariables val) { + public Builder variables(ExpressionVariables val) { variables = val; return this; } - public Builder mappingType(MappingType val) { + public Builder mappingType(MappingType val) { mappingType = val; return this; } - public Builder objectResolver(ObjectResolver val) { + public Builder objectResolver(ObjectResolver val) { objectResolver = val; return this; } - public Builder securityContextManager(SecurityContextManager val) { + public Builder securityContextManager(SecurityContextManager val) { securityContextManager = val; return this; } - public Builder defaultSource(Source val) { + public Builder defaultSource(Source val) { defaultSource = val; return this; } - public Builder defaultTargetDefinition(D val) { + public Builder defaultTargetDefinition(D val) { defaultTargetDefinition = val; return this; } - public Builder expressionProfile(ExpressionProfile val) { + public Builder expressionProfile(ExpressionProfile val) { expressionProfile = val; return this; } - public Builder defaultTargetPath(ItemPath val) { + public Builder defaultTargetPath(ItemPath val) { defaultTargetPath = val; return this; } - public Builder originalTargetValues(Collection values) { + public Builder originalTargetValues(Collection values) { originalTargetValues = values; return this; } - public Builder sourceContext(ObjectDeltaObject val) { + public Builder sourceContext(ObjectDeltaObject val) { if (val.getDefinition() == null) { throw new IllegalArgumentException("Attempt to set mapping source context without a definition"); } @@ -1568,87 +1531,87 @@ public Builder sourceContext(ObjectDeltaObject val) { return this; } - public Builder targetContext(PrismObjectDefinition val) { + public Builder targetContext(PrismObjectDefinition val) { targetContext = val; return this; } - public Builder sources(Collection> val) { + public Builder sources(Collection> val) { sources = val; return this; } - public Builder originType(OriginType val) { + public Builder originType(OriginType val) { originType = val; return this; } - public Builder originObject(ObjectType val) { + public Builder originObject(ObjectType val) { originObject = val; return this; } - public Builder valuePolicyResolver(ValuePolicyResolver val) { + public Builder valuePolicyResolver(ValuePolicyResolver val) { valuePolicyResolver = val; return this; } - public Builder variableResolver(VariableProducer variableProducer) { + public Builder variableResolver(VariableProducer variableProducer) { this.variableProducer = variableProducer; return this; } - public Builder mappingPreExpression(MappingPreExpression mappingPreExpression) { + public Builder mappingPreExpression(MappingPreExpression mappingPreExpression) { this.mappingPreExpression = mappingPreExpression; return this; } - public Builder conditionMaskOld(boolean val) { + public Builder conditionMaskOld(boolean val) { conditionMaskOld = val; return this; } - public Builder conditionMaskNew(boolean val) { + public Builder conditionMaskNew(boolean val) { conditionMaskNew = val; return this; } - public Builder now(XMLGregorianCalendar val) { + public Builder now(XMLGregorianCalendar val) { now = val; return this; } - public Builder defaultReferenceTime(XMLGregorianCalendar val) { + public Builder defaultReferenceTime(XMLGregorianCalendar val) { defaultReferenceTime = val; return this; } - public Builder profiling(boolean val) { + public Builder profiling(boolean val) { profiling = val; return this; } - public Builder contextDescription(String val) { + public Builder contextDescription(String val) { contextDescription = val; return this; } - public Builder mappingQName(QName val) { + public Builder mappingQName(QName val) { mappingQName = val; return this; } - public Builder refinedObjectClassDefinition(RefinedObjectClassDefinition val) { + public Builder refinedObjectClassDefinition(RefinedObjectClassDefinition val) { refinedObjectClassDefinition = val; return this; } - public Builder prismContext(PrismContext val) { + public Builder prismContext(PrismContext val) { prismContext = val; return this; } - public MappingImpl build() { + public MappingImpl build() { return new MappingImpl<>(this); } @@ -1830,7 +1793,7 @@ public Builder addVariableDefinition(String name, PrismValue value) { public Builder addVariableDefinition(String name, ObjectDeltaObject value) { PrismObjectDefinition definition = value.getDefinition(); if (definition == null) { - throw new IllegalArgumentException("Attempt to set variable '"+name+"' as ODO without a definition: "+value); + throw new IllegalArgumentException("Attempt to set variable '" + name + "' as ODO without a definition: " + value); } return addVariableDefinition(name, value, definition); } @@ -1863,7 +1826,7 @@ public boolean isApplicableToChannel(String channel) { return MappingImpl.isApplicableToChannel(mappingType, channel); } - public Builder addSource(Source source) { + public Builder addSource(Source source) { sources.add(source); return this; } diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/AbstractModelCommonTest.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/AbstractModelCommonTest.java index 432ba8363fb..a7a13e48e83 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/AbstractModelCommonTest.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/AbstractModelCommonTest.java @@ -10,12 +10,10 @@ import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.task.api.test.NullTaskImpl; -import com.evolveum.midpoint.test.util.AbstractUnitTest; -import com.evolveum.midpoint.test.util.TestUtil; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; /** * @author semancik - * */ public class AbstractModelCommonTest extends AbstractUnitTest { @@ -24,10 +22,6 @@ public class AbstractModelCommonTest extends AbstractUnitTest { protected static final File SYSTEM_CONFIGURATION_FILE = new File(COMMON_DIR, "system-configuration.xml"); protected static final String EXPRESSION_PROFILE_SAFE_NAME = "safe"; - protected void displayTestTitle(final String TEST_NAME) { - TestUtil.displayTestTitle(this, TEST_NAME); - } - protected Task createTask() { return new NullTaskImpl(); } diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/TestExpression.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/TestExpression.java index 5c4094aad8b..1cf8bba5cdb 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/TestExpression.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/TestExpression.java @@ -6,15 +6,12 @@ */ package com.evolveum.midpoint.model.common.expression; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.*; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; - import javax.xml.namespace.QName; import org.testng.AssertJUnit; @@ -25,27 +22,13 @@ import com.evolveum.midpoint.common.Clock; import com.evolveum.midpoint.model.common.AbstractModelCommonTest; import com.evolveum.midpoint.model.common.ConstantsManager; -import com.evolveum.midpoint.prism.Containerable; -import com.evolveum.midpoint.prism.ItemDefinition; -import com.evolveum.midpoint.prism.PrimitiveType; -import com.evolveum.midpoint.prism.PrismContainerDefinition; -import com.evolveum.midpoint.prism.PrismContext; -import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.PrismObjectDefinition; -import com.evolveum.midpoint.prism.PrismProperty; -import com.evolveum.midpoint.prism.PrismPropertyDefinition; -import com.evolveum.midpoint.prism.PrismPropertyValue; -import com.evolveum.midpoint.prism.PrismValue; +import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.crypto.Protector; import com.evolveum.midpoint.prism.delta.PrismValueDeltaSetTriple; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.repo.common.DirectoryFileObjectResolver; import com.evolveum.midpoint.repo.common.ObjectResolver; -import com.evolveum.midpoint.repo.common.expression.Expression; -import com.evolveum.midpoint.repo.common.expression.ExpressionEvaluationContext; -import com.evolveum.midpoint.repo.common.expression.ExpressionFactory; -import com.evolveum.midpoint.repo.common.expression.ExpressionVariables; -import com.evolveum.midpoint.repo.common.expression.Source; +import com.evolveum.midpoint.repo.common.expression.*; import com.evolveum.midpoint.schema.MidPointPrismContextFactory; import com.evolveum.midpoint.schema.constants.ExpressionConstants; import com.evolveum.midpoint.schema.constants.MidPointConstants; @@ -59,19 +42,10 @@ import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SecurityViolationException; +import com.evolveum.midpoint.util.exception.*; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationExpressionsType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; /** * @author Radovan Semancik @@ -109,8 +83,6 @@ public class TestExpression extends AbstractModelCommonTest { private static final Trace LOGGER = TraceManager.getTrace(TestExpression.class); - - protected PrismContext prismContext; protected ExpressionFactory expressionFactory; protected ConstantsManager constantsManager; @@ -140,27 +112,24 @@ public void setup() throws SchemaException, SAXException, IOException { @Test public void test100AsIs() throws Exception { - final String TEST_NAME = "test100AsIs"; - displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestExpression.class.getName()+"."+TEST_NAME); + OperationResult result = new OperationResult(contextName()); rememberScriptExecutionCount(); ExpressionType expressionType = parseExpression(EXPRESSION_ASIS_FILE); - Collection> sources = prepareStringSources(INPUT_VALUE); + Collection> sources = prepareStringSources(); ExpressionVariables variables = prepareBasicVariables(); - ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources , variables, TEST_NAME, null); + ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources, variables, getTestNameShort(), null); // WHEN PrismValueDeltaSetTriple> outputTriple = evaluatePropertyExpression(expressionType, PrimitiveType.STRING, expressionContext, result); // THEN assertOutputTriple(outputTriple) - .assertEmptyMinus() - .assertEmptyPlus() - .zeroSet() + .assertEmptyMinus() + .assertEmptyPlus() + .zeroSet() .assertSinglePropertyValue(INPUT_VALUE); assertScriptExecutionIncrement(0); @@ -168,18 +137,15 @@ public void test100AsIs() throws Exception { @Test public void test110Path() throws Exception { - final String TEST_NAME = "test110Path"; - displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestExpression.class.getName()+"."+TEST_NAME); + OperationResult result = new OperationResult(contextName()); rememberScriptExecutionCount(); ExpressionType expressionType = parseExpression(EXPRESSION_PATH_FILE); - Collection> sources = prepareStringSources(INPUT_VALUE); + Collection> sources = prepareStringSources(); ExpressionVariables variables = prepareBasicVariables(); - ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources , variables, TEST_NAME, null); + ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources, variables, getTestNameShort(), null); // WHEN PrismValueDeltaSetTriple> outputTriple = evaluatePropertyExpression(expressionType, PrimitiveType.STRING, expressionContext, @@ -187,9 +153,9 @@ public void test110Path() throws Exception { // THEN assertOutputTriple(outputTriple) - .assertEmptyMinus() - .assertEmptyPlus() - .zeroSet() + .assertEmptyMinus() + .assertEmptyPlus() + .zeroSet() .assertSinglePropertyValue(USER_JACK_NAME); assertScriptExecutionIncrement(0); @@ -197,18 +163,15 @@ public void test110Path() throws Exception { @Test public void test120Value() throws Exception { - final String TEST_NAME = "test120Value"; - displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestExpression.class.getName()+"."+TEST_NAME); + OperationResult result = new OperationResult(contextName()); rememberScriptExecutionCount(); ExpressionType expressionType = parseExpression(EXPRESSION_VALUE_FILE); - Collection> sources = prepareStringSources(INPUT_VALUE); + Collection> sources = prepareStringSources(); ExpressionVariables variables = prepareBasicVariables(); - ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources , variables, TEST_NAME, null); + ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources, variables, getTestNameShort(), null); // WHEN PrismValueDeltaSetTriple> outputTriple = @@ -216,9 +179,9 @@ public void test120Value() throws Exception { // THEN assertOutputTriple(outputTriple) - .assertEmptyMinus() - .assertEmptyPlus() - .zeroSet() + .assertEmptyMinus() + .assertEmptyPlus() + .zeroSet() .assertSinglePropertyValue(EXPRESSION_VALUE_OUTPUT); assertScriptExecutionIncrement(0); @@ -226,18 +189,15 @@ public void test120Value() throws Exception { @Test public void test130Const() throws Exception { - final String TEST_NAME = "test130Const"; - displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestExpression.class.getName()+"."+TEST_NAME); + OperationResult result = new OperationResult(contextName()); rememberScriptExecutionCount(); ExpressionType expressionType = parseExpression(EXPRESSION_CONST_FILE); - Collection> sources = prepareStringSources(INPUT_VALUE); + Collection> sources = prepareStringSources(); ExpressionVariables variables = prepareBasicVariables(); - ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources , variables, TEST_NAME, null); + ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources, variables, getTestNameShort(), null); // WHEN PrismValueDeltaSetTriple> outputTriple = @@ -245,9 +205,9 @@ public void test130Const() throws Exception { // THEN assertOutputTriple(outputTriple) - .assertEmptyMinus() - .assertEmptyPlus() - .zeroSet() + .assertEmptyMinus() + .assertEmptyPlus() + .zeroSet() .assertSinglePropertyValue(ExpressionTestUtil.CONST_FOO_VALUE); assertScriptExecutionIncrement(0); @@ -255,18 +215,15 @@ public void test130Const() throws Exception { @Test public void test150ScriptGroovySimple() throws Exception { - final String TEST_NAME = "test150ScriptGroovySimple"; - displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestExpression.class.getName()+"."+TEST_NAME); + OperationResult result = new OperationResult(contextName()); rememberScriptExecutionCount(); ExpressionType expressionType = parseExpression(EXPRESSION_SCRIPT_GROOVY_SIMPLE_FILE); - Collection> sources = prepareStringSources(INPUT_VALUE); + Collection> sources = prepareStringSources(); ExpressionVariables variables = prepareBasicVariables(); - ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources , variables, TEST_NAME, null); + ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources, variables, getTestNameShort(), null); // WHEN PrismValueDeltaSetTriple> outputTriple = @@ -274,9 +231,9 @@ public void test150ScriptGroovySimple() throws Exception { // THEN assertOutputTriple(outputTriple) - .assertEmptyMinus() - .assertEmptyPlus() - .zeroSet() + .assertEmptyMinus() + .assertEmptyPlus() + .zeroSet() .assertSinglePropertyValue(VAR_FOO_VALUE + VAR_BAR_VALUE); assertScriptExecutionIncrement(1); @@ -284,18 +241,15 @@ public void test150ScriptGroovySimple() throws Exception { @Test public void test152ScriptGroovySystemAllow() throws Exception { - final String TEST_NAME = "test152ScriptGroovySystemAllow"; - displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestExpression.class.getName()+"."+TEST_NAME); + OperationResult result = new OperationResult(contextName()); rememberScriptExecutionCount(); ExpressionType expressionType = parseExpression(EXPRESSION_SCRIPT_GROOVY_SYSTEM_ALLOW_FILE); - Collection> sources = prepareStringSources(INPUT_VALUE); + Collection> sources = prepareStringSources(); ExpressionVariables variables = prepareBasicVariables(); - ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources , variables, TEST_NAME, null); + ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources, variables, getTestNameShort(), null); // WHEN PrismValueDeltaSetTriple> outputTriple = @@ -303,9 +257,9 @@ public void test152ScriptGroovySystemAllow() throws Exception { // THEN assertOutputTriple(outputTriple) - .assertEmptyMinus() - .assertEmptyPlus() - .zeroSet() + .assertEmptyMinus() + .assertEmptyPlus() + .zeroSet() .assertSinglePropertyValue(GROOVY_SCRIPT_OUTPUT_SUCCESS); assertScriptExecutionIncrement(1); @@ -313,18 +267,15 @@ public void test152ScriptGroovySystemAllow() throws Exception { @Test public void test154ScriptGroovySystemDeny() throws Exception { - final String TEST_NAME = "test154ScriptGroovySystemDeny"; - displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestExpression.class.getName()+"."+TEST_NAME); + OperationResult result = new OperationResult(contextName()); rememberScriptExecutionCount(); ExpressionType expressionType = parseExpression(EXPRESSION_SCRIPT_GROOVY_SYSTEM_DENY_FILE); - Collection> sources = prepareStringSources(INPUT_VALUE); + Collection> sources = prepareStringSources(); ExpressionVariables variables = prepareBasicVariables(); - ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources , variables, TEST_NAME, null); + ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources, variables, getTestNameShort(), null); // WHEN PrismValueDeltaSetTriple> outputTriple = @@ -332,9 +283,9 @@ public void test154ScriptGroovySystemDeny() throws Exception { // THEN assertOutputTriple(outputTriple) - .assertEmptyMinus() - .assertEmptyPlus() - .zeroSet() + .assertEmptyMinus() + .assertEmptyPlus() + .zeroSet() .assertSinglePropertyValue(GROOVY_SCRIPT_OUTPUT_SUCCESS); assertScriptExecutionIncrement(1); @@ -342,18 +293,15 @@ public void test154ScriptGroovySystemDeny() throws Exception { @Test public void test160ScriptJavaScript() throws Exception { - final String TEST_NAME = "test160ScriptJavaScript"; - displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestExpression.class.getName()+"."+TEST_NAME); + OperationResult result = new OperationResult(contextName()); rememberScriptExecutionCount(); ExpressionType expressionType = parseExpression(EXPRESSION_SCRIPT_JAVASCRIPT_FILE); - Collection> sources = prepareStringSources(INPUT_VALUE); + Collection> sources = prepareStringSources(); ExpressionVariables variables = prepareBasicVariables(); - ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources , variables, TEST_NAME, null); + ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources, variables, getTestNameShort(), null); // WHEN PrismValueDeltaSetTriple> outputTriple = @@ -361,9 +309,9 @@ public void test160ScriptJavaScript() throws Exception { // THEN assertOutputTriple(outputTriple) - .assertEmptyMinus() - .assertEmptyPlus() - .zeroSet() + .assertEmptyMinus() + .assertEmptyPlus() + .zeroSet() .assertSinglePropertyValue(VAR_FOO_VALUE + VAR_BAR_VALUE); assertScriptExecutionIncrement(1); @@ -371,11 +319,8 @@ public void test160ScriptJavaScript() throws Exception { @Test public void test200IterationCondition() throws Exception { - final String TEST_NAME = "test200IterationCondition"; - displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestExpression.class.getName()+"."+TEST_NAME); + OperationResult result = new OperationResult(contextName()); rememberScriptExecutionCount(); @@ -397,7 +342,7 @@ public void test200IterationCondition() throws Exception { variables.put(ExpressionConstants.VAR_ITERATION_TOKEN, "001", TestUtil.createPrimitivePropertyDefinition(prismContext, ExpressionConstants.VAR_ITERATION_TOKEN, PrimitiveType.STRING)); - ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(null , variables, TEST_NAME, createTask()); + ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(null, variables, getTestNameShort(), createTask()); // WHEN PrismValueDeltaSetTriple> outputTriple = @@ -405,9 +350,9 @@ public void test200IterationCondition() throws Exception { // THEN assertOutputTriple(outputTriple) - .assertEmptyMinus() - .assertEmptyPlus() - .zeroSet() + .assertEmptyMinus() + .assertEmptyPlus() + .zeroSet() .assertSinglePropertyValue(Boolean.TRUE); // Make sure that the script is executed only once. There is no delta in the variables, no need to do it twice. @@ -418,7 +363,7 @@ protected ExpressionType parseExpression(File file) throws SchemaException, IOEx return PrismTestUtil.parseAtomicValue(file, ExpressionType.COMPLEX_TYPE); } - protected Source,PrismPropertyDefinition> prepareStringSource(String value) throws SchemaException { + protected Source, PrismPropertyDefinition> prepareStringSource() throws SchemaException { PrismPropertyDefinition propDef = prismContext.definitionFactory().createPropertyDefinition(ExpressionConstants.VAR_INPUT_QNAME, PrimitiveType.STRING.getQname()); PrismProperty inputProp = prismContext.itemFactory().createProperty(ExpressionConstants.VAR_INPUT_QNAME, propDef); PrismPropertyValue pval = prismContext.itemFactory().createPropertyValue(INPUT_VALUE); @@ -426,9 +371,9 @@ protected Source,PrismPropertyDefinition> pre return new Source<>(inputProp, null, inputProp, ExpressionConstants.VAR_INPUT_QNAME, propDef); } - protected Collection> prepareStringSources(String value) throws SchemaException { + protected Collection> prepareStringSources() throws SchemaException { Collection> sources = new ArrayList<>(); - sources.add(prepareStringSource(value)); + sources.add(prepareStringSource()); return sources; } @@ -444,8 +389,8 @@ protected ExpressionVariables prepareBasicVariables() throws SchemaException, IO protected PrismValueDeltaSetTriple evaluateExpression( ExpressionType expressionType, D outputDefinition, ExpressionEvaluationContext expressionContext, OperationResult result) - throws SchemaException, ObjectNotFoundException, SecurityViolationException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - Expression expression = expressionFactory.makeExpression(expressionType, outputDefinition, getExpressionProfile(), + throws SchemaException, ObjectNotFoundException, SecurityViolationException, ExpressionEvaluationException, CommunicationException, ConfigurationException { + Expression expression = expressionFactory.makeExpression(expressionType, outputDefinition, getExpressionProfile(), expressionContext.getContextDescription(), expressionContext.getTask(), result); LOGGER.debug("Starting evaluation of expression: {}", expression); return expression.evaluate(expressionContext, result); @@ -453,7 +398,7 @@ protected PrismValueDeltaSetTri protected PrismValueDeltaSetTriple> evaluatePropertyExpression( ExpressionType expressionType, QName outputType, ExpressionEvaluationContext expressionContext, OperationResult result) - throws SchemaException, ObjectNotFoundException, SecurityViolationException, ExpressionEvaluationException, CommunicationException, ConfigurationException { + throws SchemaException, ObjectNotFoundException, SecurityViolationException, ExpressionEvaluationException, CommunicationException, ConfigurationException { PrismPropertyDefinition outputDefinition = prismContext.definitionFactory().createPropertyDefinition( ExpressionConstants.OUTPUT_ELEMENT_NAME, outputType); return evaluateExpression(expressionType, outputDefinition, expressionContext, result); @@ -462,19 +407,19 @@ protected PrismValueDeltaSetTriple> evaluatePropertyEx protected PrismValueDeltaSetTriple> evaluatePropertyExpression( ExpressionType expressionType, PrimitiveType outputType, ExpressionEvaluationContext expressionContext, OperationResult result) - throws SchemaException, ObjectNotFoundException, SecurityViolationException, ExpressionEvaluationException, CommunicationException, ConfigurationException { + throws SchemaException, ObjectNotFoundException, SecurityViolationException, ExpressionEvaluationException, CommunicationException, ConfigurationException { return evaluatePropertyExpression(expressionType, outputType.getQname(), expressionContext, result); } protected void evaluateExpressionRestricted( - ExpressionType expressionType, D outputDefinition, ExpressionEvaluationContext expressionContext, - OperationResult result) - throws SchemaException, ObjectNotFoundException, SecurityViolationException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - Expression expression; + ExpressionType expressionType, D outputDefinition, + ExpressionEvaluationContext expressionContext, OperationResult result) + throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { + Expression expression; try { - expression = expressionFactory.makeExpression(expressionType, outputDefinition , getExpressionProfile(), - expressionContext.getContextDescription(), expressionContext.getTask(), result); + expression = expressionFactory.makeExpression(expressionType, outputDefinition, getExpressionProfile(), + expressionContext.getContextDescription(), expressionContext.getTask(), result); } catch (SecurityViolationException e) { // Exception may happen here, or it may happen later. @@ -496,22 +441,24 @@ protected void evaluateExpressi LOGGER.debug("Expected exception", e); assertTrue("Wrong exception message: " + e.getMessage(), e.getMessage().contains("Access to expression evaluator") - || e.getMessage().contains("Access to Groovy method")); + || e.getMessage().contains("Access to Groovy method")); } } - protected void evaluatePropertyExpressionRestricted( - ExpressionType expressionType, QName outputType, ExpressionEvaluationContext expressionContext, OperationResult result) - throws SchemaException, ObjectNotFoundException, SecurityViolationException, ExpressionEvaluationException, CommunicationException, ConfigurationException { + protected void evaluatePropertyExpressionRestricted(ExpressionType expressionType, + QName outputType, ExpressionEvaluationContext expressionContext, OperationResult result) + throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, + CommunicationException, ConfigurationException { PrismPropertyDefinition outputDefinition = prismContext.definitionFactory().createPropertyDefinition( ExpressionConstants.OUTPUT_ELEMENT_NAME, outputType); evaluateExpressionRestricted(expressionType, outputDefinition, expressionContext, result); } protected void evaluatePropertyExpressionRestricted( - ExpressionType expressionType, PrimitiveType outputType, ExpressionEvaluationContext expressionContext, - OperationResult result) - throws SchemaException, ObjectNotFoundException, SecurityViolationException, ExpressionEvaluationException, CommunicationException, ConfigurationException { + ExpressionType expressionType, PrimitiveType outputType, + ExpressionEvaluationContext expressionContext, OperationResult result) + throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, + CommunicationException, ConfigurationException { evaluatePropertyExpressionRestricted(expressionType, outputType.getQname(), expressionContext, result); } @@ -522,7 +469,7 @@ protected void rememberScriptExecutionCount() { protected void assertScriptExecutionIncrement(int expectedIncrement) { long currentScriptExecutionCount = InternalMonitor.getCount(InternalCounters.SCRIPT_EXECUTION_COUNT); long actualIncrement = currentScriptExecutionCount - lastScriptExecutionCount; - assertEquals("Unexpected increment in script execution count", (long)expectedIncrement, actualIncrement); + assertEquals("Unexpected increment in script execution count", (long) expectedIncrement, actualIncrement); lastScriptExecutionCount = currentScriptExecutionCount; } @@ -548,7 +495,7 @@ protected ExpressionProfile compileExpressionProfile(String profileName) throws ExpressionProfiles profiles = compiler.compile(expressions); ExpressionProfile profile = profiles.getProfile(profileName); if (profile == null) { - throw new SchemaException("Profile '"+profile+"' not found in system config"); + throw new SchemaException("Profile '" + profile + "' not found in system config"); } return profile; } @@ -557,10 +504,10 @@ protected File getSystemConfigurationFile() { return SYSTEM_CONFIGURATION_FILE; } - protected PrismValueDeltaSetTripleAsserter assertOutputTriple(PrismValueDeltaSetTriple triple) { + protected PrismValueDeltaSetTripleAsserter assertOutputTriple(PrismValueDeltaSetTriple triple) { assertNotNull(triple); triple.checkConsistence(); - PrismValueDeltaSetTripleAsserter asserter = new PrismValueDeltaSetTripleAsserter<>(triple, "expression output triple"); + PrismValueDeltaSetTripleAsserter asserter = new PrismValueDeltaSetTripleAsserter<>(triple, "expression output triple"); asserter.setPrismContext(prismContext); asserter.display(); return asserter; diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/TestExpressionProfileSafe.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/TestExpressionProfileSafe.java index 4abafcfd88a..faa8c7ed01f 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/TestExpressionProfileSafe.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/TestExpressionProfileSafe.java @@ -8,13 +8,12 @@ import java.util.Collection; +import org.testng.annotations.Test; + +import com.evolveum.midpoint.prism.PrimitiveType; import com.evolveum.midpoint.repo.common.expression.ExpressionEvaluationContext; import com.evolveum.midpoint.repo.common.expression.ExpressionVariables; import com.evolveum.midpoint.repo.common.expression.Source; -import com.evolveum.midpoint.prism.*; - -import org.testng.annotations.Test; - import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType; @@ -31,18 +30,15 @@ protected String getExpressionProfileName() { @Test @Override public void test130Const() throws Exception { - final String TEST_NAME = "test130Const"; - displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestExpression.class.getName()+"."+TEST_NAME); + OperationResult result = new OperationResult(contextName()); rememberScriptExecutionCount(); ExpressionType expressionType = parseExpression(EXPRESSION_CONST_FILE); - Collection> sources = prepareStringSources(INPUT_VALUE); + Collection> sources = prepareStringSources(); ExpressionVariables variables = prepareBasicVariables(); - ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources, variables, TEST_NAME, null); + ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources, variables, getTestNameShort(), null); // WHEN evaluatePropertyExpressionRestricted(expressionType, PrimitiveType.STRING, expressionContext, result); @@ -55,18 +51,15 @@ public void test130Const() throws Exception { @Test @Override public void test154ScriptGroovySystemDeny() throws Exception { - final String TEST_NAME = "test154ScriptGroovySystemDeny"; - displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestExpression.class.getName()+"."+TEST_NAME); + OperationResult result = new OperationResult(contextName()); rememberScriptExecutionCount(); ExpressionType expressionType = parseExpression(EXPRESSION_SCRIPT_GROOVY_SYSTEM_DENY_FILE); - Collection> sources = prepareStringSources(INPUT_VALUE); + Collection> sources = prepareStringSources(); ExpressionVariables variables = prepareBasicVariables(); - ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources , variables, TEST_NAME, null); + ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources, variables, getTestNameShort(), null); // WHEN evaluatePropertyExpressionRestricted(expressionType, PrimitiveType.STRING, expressionContext, result); @@ -79,18 +72,15 @@ public void test154ScriptGroovySystemDeny() throws Exception { @Test @Override public void test160ScriptJavaScript() throws Exception { - final String TEST_NAME = "test160ScriptJavaScript"; - displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestExpression.class.getName()+"."+TEST_NAME); + OperationResult result = new OperationResult(contextName()); rememberScriptExecutionCount(); ExpressionType expressionType = parseExpression(EXPRESSION_SCRIPT_JAVASCRIPT_FILE); - Collection> sources = prepareStringSources(INPUT_VALUE); + Collection> sources = prepareStringSources(); ExpressionVariables variables = prepareBasicVariables(); - ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources , variables, TEST_NAME, null); + ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources, variables, getTestNameShort(), null); // WHEN evaluatePropertyExpressionRestricted(expressionType, PrimitiveType.STRING, expressionContext, result); diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/TestExpressionUtil.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/TestExpressionUtil.java index 39012203f3f..36b89d383f5 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/TestExpressionUtil.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/TestExpressionUtil.java @@ -73,13 +73,10 @@ public void setup() throws SchemaException, SAXException, IOException { @Test public void testResolvePathStringProperty() throws Exception { - final String TEST_NAME = "testResolvePathStringProperty"; - displayTestTitle(TEST_NAME); - // GIVEN // WHEN - PrismProperty resolvedProperty = resolvePath("$user/description", TEST_NAME); + PrismProperty resolvedProperty = resolvePath("$user/description", getTestNameShort()); // THEN assertEquals("Wrong resolved property value", "jack", resolvedProperty.getRealValue()); @@ -87,13 +84,10 @@ public void testResolvePathStringProperty() throws Exception { @Test public void testResolvePathPolyStringProperty() throws Exception { - final String TEST_NAME = "testResolvePathPolyStringProperty"; - displayTestTitle(TEST_NAME); - // GIVEN // WHEN - PrismProperty resolvedProperty = resolvePath("$user/fullName", TEST_NAME); + PrismProperty resolvedProperty = resolvePath("$user/fullName", getTestNameShort()); // THEN assertEquals("Wrong resolved property value", PrismTestUtil.createPolyString("Jack Sparrow"), @@ -102,13 +96,10 @@ public void testResolvePathPolyStringProperty() throws Exception { @Test public void testResolvePathPolyStringOrig() throws Exception { - final String TEST_NAME = "testResolvePathPolyStringOrig"; - displayTestTitle(TEST_NAME); - // GIVEN // WHEN - String resolved = resolvePath("$user/fullName/t:orig", TEST_NAME); + String resolved = resolvePath("$user/fullName/t:orig", getTestNameShort()); // THEN assertEquals("Wrong resolved property value", "Jack Sparrow", resolved); @@ -116,13 +107,10 @@ public void testResolvePathPolyStringOrig() throws Exception { @Test public void testResolvePathPolyStringNorm() throws Exception { - final String TEST_NAME = "testResolvePathPolyStringNorm"; - displayTestTitle(TEST_NAME); - // GIVEN // WHEN - String resolved = resolvePath("$user/fullName/t:norm", TEST_NAME); + String resolved = resolvePath("$user/fullName/t:norm", getTestNameShort()); // THEN assertEquals("Wrong resolved property value", "jack sparrow", resolved); @@ -130,13 +118,10 @@ public void testResolvePathPolyStringNorm() throws Exception { @Test public void testResolvePathPolyStringOdo() throws Exception { - final String TEST_NAME = "testResolvePathPolyStringOdo"; - displayTestTitle(TEST_NAME); - // GIVEN // WHEN - ItemDeltaItem,PrismPropertyDefinition> idi = resolvePathOdo("$user/fullName", TEST_NAME); + ItemDeltaItem,PrismPropertyDefinition> idi = resolvePathOdo("$user/fullName", getTestNameShort()); // THEN assertEquals("Wrong resolved idi old value", PrismTestUtil.createPolyString("Jack Sparrow"), @@ -151,13 +136,10 @@ public void testResolvePathPolyStringOdo() throws Exception { @Test public void testResolvePathPolyStringOdoOrig() throws Exception { - final String TEST_NAME = "testResolvePathPolyStringOdoOrig"; - displayTestTitle(TEST_NAME); - // GIVEN // WHEN - ItemDeltaItem,PrismPropertyDefinition> idi = resolvePathOdo("$user/fullName/t:orig", TEST_NAME); + ItemDeltaItem,PrismPropertyDefinition> idi = resolvePathOdo("$user/fullName/t:orig", getTestNameShort()); // THEN assertEquals("Wrong resolved idi old value", PrismTestUtil.createPolyString("Jack Sparrow"), @@ -170,13 +152,10 @@ public void testResolvePathPolyStringOdoOrig() throws Exception { @Test public void testResolvePathPolyStringOdoNorm() throws Exception { - final String TEST_NAME = "testResolvePathPolyStringOdoNorm"; - displayTestTitle(TEST_NAME); - // GIVEN // WHEN - ItemDeltaItem,PrismPropertyDefinition> idi = resolvePathOdo("$user/fullName/t:norm", TEST_NAME); + ItemDeltaItem,PrismPropertyDefinition> idi = resolvePathOdo("$user/fullName/t:norm", getTestNameShort()); // THEN assertEquals("Wrong resolved idi old value", PrismTestUtil.createPolyString("Jack Sparrow"), diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/AbstractScriptTest.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/AbstractScriptTest.java index b417127b496..691e9b72752 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/AbstractScriptTest.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/AbstractScriptTest.java @@ -145,7 +145,7 @@ public void testExpressionStringVariablesParallel() throws Exception { // WHEN - ParallelTestThread[] threads = TestUtil.multithread(TEST_NAME, + ParallelTestThread[] threads = TestUtil.multithread( (threadIndex) -> { String foo = "FOO"+threadIndex; @@ -399,7 +399,6 @@ protected void evaluateAndAssertBooleanScalarExpresssion(String fileName, String } private List> evaluateStringExpresssion(String fileName, String testName, ExpressionVariables variables, boolean scalar) throws SchemaException, IOException, JAXBException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException { - displayTestTitle(testName); ScriptExpressionEvaluatorType scriptType = parseScriptType(fileName); OperationResult opResult = new OperationResult(testName); @@ -407,22 +406,13 @@ private List> evaluateStringExpresssion(String fileNa } private List> evaluateBooleanExpresssion(String fileName, String testName, ExpressionVariables variables, boolean scalar) throws SchemaException, IOException, JAXBException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException { - displayTestTitle(testName); ScriptExpressionEvaluatorType scriptType = parseScriptType(fileName); OperationResult opResult = new OperationResult(testName); - return evaluateExpression(scriptType, DOMUtil.XSD_BOOLEAN, true, variables, testName, opResult); } - - private void displayTestTitle(String testName) { - System.out.println("===[ "+evaluator.getLanguageName()+": "+testName+" ]==========================="); - LOGGER.info("===[ "+evaluator.getLanguageName()+": "+testName+" ]==========================="); - } - protected ExpressionVariables createVariables(Object... params) { return ExpressionVariables.create(prismContext, params); } - } diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingComplex.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingComplex.java index 6ca0b3af3aa..9e0c05a5932 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingComplex.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingComplex.java @@ -44,9 +44,6 @@ public void setupFactory() throws SAXException, IOException, SchemaException { @Test public void testModifyObjectSetAdditionalName() throws Exception { - final String TEST_NAME = "testModifyObjectSetAdditionalName"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, @@ -55,9 +52,9 @@ public void testModifyObjectSetAdditionalName() throws Exception { MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( MAPPING_COMPLEX_FILENAME, - TEST_NAME, "title", delta); + getTestNameShort(), "title", delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(contextName()); // WHEN mapping.evaluate(createTask(), opResult); @@ -72,9 +69,6 @@ public void testModifyObjectSetAdditionalName() throws Exception { @Test public void testModifyObjectSetAdditionalNameFalse() throws Exception { - final String TEST_NAME = "testModifyObjectSetAdditionalNameFalse"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, @@ -86,9 +80,9 @@ public void testModifyObjectSetAdditionalNameFalse() throws Exception { userOld.asObjectable().getEmployeeType().add("WHATEVER"); MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( MAPPING_COMPLEX_FILENAME, - TEST_NAME, "title", delta, userOld); + getTestNameShort(), "title", delta, userOld); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(contextName()); // WHEN mapping.evaluate(createTask(), opResult); @@ -103,9 +97,6 @@ public void testModifyObjectSetAdditionalNameFalse() throws Exception { */ @Test public void testModifyObjectUnrelated() throws Exception { - final String TEST_NAME = "testModifyObjectUnrelated"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, @@ -113,9 +104,9 @@ public void testModifyObjectUnrelated() throws Exception { MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( MAPPING_COMPLEX_FILENAME, - TEST_NAME, "title", delta); + getTestNameShort(), "title", delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(contextName()); // WHEN mapping.evaluate(createTask(), opResult); @@ -130,9 +121,6 @@ public void testModifyObjectUnrelated() throws Exception { @Test public void testModifyObjectUnrelatedFalse() throws Exception { - final String TEST_NAME = "testModifyObjectUnrelatedFalse"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, @@ -143,9 +131,9 @@ public void testModifyObjectUnrelatedFalse() throws Exception { userOld.asObjectable().getEmployeeType().add("WHATEVER"); MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( MAPPING_COMPLEX_FILENAME, - TEST_NAME, "title", delta, userOld); + getTestNameShort(), "title", delta, userOld); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(contextName()); // WHEN mapping.evaluate(createTask(), opResult); @@ -157,9 +145,6 @@ public void testModifyObjectUnrelatedFalse() throws Exception { @Test public void testAddObjectUnrelatedFalse() throws Exception { - final String TEST_NAME = "testAddObjectUnrelatedFalse"; - displayTestTitle(TEST_NAME); - // GIVEN PrismObject user = evaluator.getUserOld(); user.asObjectable().getEmployeeType().clear(); @@ -168,9 +153,9 @@ public void testAddObjectUnrelatedFalse() throws Exception { MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( MAPPING_COMPLEX_FILENAME, - TEST_NAME, "title", delta); + getTestNameShort(), "title", delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(contextName()); // WHEN mapping.evaluate(createTask(), opResult); @@ -182,9 +167,6 @@ public void testAddObjectUnrelatedFalse() throws Exception { @Test public void testAddObjectUnrelatedEmptyFalse() throws Exception { - final String TEST_NAME = "testAddObjectUnrelatedEmptyFalse"; - displayTestTitle(TEST_NAME); - // GIVEN PrismObject user = evaluator.getUserOld(); user.asObjectable().getEmployeeType().clear(); @@ -192,9 +174,9 @@ public void testAddObjectUnrelatedEmptyFalse() throws Exception { MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( MAPPING_COMPLEX_FILENAME, - TEST_NAME, "title", delta); + getTestNameShort(), "title", delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(contextName()); // WHEN mapping.evaluate(createTask(), opResult); diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDomain.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDomain.java index ed0f93e9309..fc6445e5912 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDomain.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDomain.java @@ -11,8 +11,6 @@ import java.io.IOException; import java.util.List; -import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.task.api.test.NullTaskImpl; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import org.xml.sax.SAXException; @@ -26,15 +24,17 @@ import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.test.util.AbstractUnitTest; -import com.evolveum.midpoint.test.util.TestUtil; +import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.task.api.test.NullTaskImpl; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; /** * Tests for mapping domain. Those are multival input and multival output. - * + *

* MID-3692 + * * @author Radovan Semancik */ public class TestMappingDomain extends AbstractUnitTest { @@ -54,9 +54,6 @@ public void setupFactory() throws SchemaException, SAXException, IOException { */ @Test public void testControlReplaceSingleValue() throws Exception { - final String TEST_NAME = "testControlReplaceSingleValue"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN PrismObject userOld = evaluator.getUserOld(); @@ -66,14 +63,13 @@ public void testControlReplaceSingleValue() throws Exception { ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, MappingTestEvaluator.USER_OLD_OID, - UserType.F_ADDITIONAL_NAME, "Jackie"); + UserType.F_ADDITIONAL_NAME, "Jackie"); delta.addModificationReplaceProperty(UserType.F_EMPLOYEE_TYPE, "321"); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( - MAPPING_DOMAIN_FILENAME, - TEST_NAME, "organization", delta, userOld); + MappingImpl, PrismPropertyDefinition> mapping = + evaluator.createMapping(MAPPING_DOMAIN_FILENAME, getTestNameShort(), "organization", delta, userOld); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(getTestNameShort()); // WHEN mapping.evaluate(createTask(), opResult); @@ -82,8 +78,8 @@ public void testControlReplaceSingleValue() throws Exception { PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); outputTriple.checkConsistence(); PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("Pirate Jackie (321)")); - PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("Pirate null (1234567890)")); + PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("Pirate Jackie (321)")); + PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("Pirate null (1234567890)")); } private Task createTask() { @@ -95,11 +91,7 @@ private Task createTask() { */ @Test public void testControlReplaceMultiValue() throws Exception { - final String TEST_NAME = "testControlReplaceMultiValue"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - PrismObject userOld = evaluator.getUserOld(); List employeeTypeOld = userOld.asObjectable().getEmployeeType(); employeeTypeOld.clear(); @@ -109,36 +101,31 @@ public void testControlReplaceMultiValue() throws Exception { ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, MappingTestEvaluator.USER_OLD_OID, - UserType.F_ADDITIONAL_NAME, "Jackie"); + UserType.F_ADDITIONAL_NAME, "Jackie"); delta.addModificationReplaceProperty(UserType.F_EMPLOYEE_TYPE, "991", "992"); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( - MAPPING_DOMAIN_FILENAME, - TEST_NAME, "organization", delta, userOld); - - OperationResult opResult = new OperationResult(TEST_NAME); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = + evaluator.createMapping(MAPPING_DOMAIN_FILENAME, shortTestName, "organization", delta, userOld); // WHEN - mapping.evaluate(createTask(), opResult); + mapping.evaluate(createTask(), new OperationResult(shortTestName)); // THEN PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); outputTriple.checkConsistence(); PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTriplePlus(outputTriple, - PrismTestUtil.createPolyString("Pirate Jackie (991)"), - PrismTestUtil.createPolyString("Pirate Jackie (992)")); - PrismAsserts.assertTripleMinus(outputTriple, - PrismTestUtil.createPolyString("Pirate null (001)"), - PrismTestUtil.createPolyString("Pirate null (002)"), - PrismTestUtil.createPolyString("Pirate null (003)")); + PrismAsserts.assertTriplePlus(outputTriple, + PrismTestUtil.createPolyString("Pirate Jackie (991)"), + PrismTestUtil.createPolyString("Pirate Jackie (992)")); + PrismAsserts.assertTripleMinus(outputTriple, + PrismTestUtil.createPolyString("Pirate null (001)"), + PrismTestUtil.createPolyString("Pirate null (002)"), + PrismTestUtil.createPolyString("Pirate null (003)")); } @Test public void testReplaceMixedMultiValue() throws Exception { - final String TEST_NAME = "testReplaceMixedMultiValue"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN PrismObject userOld = evaluator.getUserOld(); @@ -151,38 +138,36 @@ public void testReplaceMixedMultiValue() throws Exception { ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, MappingTestEvaluator.USER_OLD_OID, - UserType.F_ADDITIONAL_NAME, "Jackie"); + UserType.F_ADDITIONAL_NAME, "Jackie"); delta.addModificationReplaceProperty(UserType.F_EMPLOYEE_TYPE, "X91", "992", "Y93", "994"); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( - MAPPING_DOMAIN_FILENAME, - TEST_NAME, "organization", delta, userOld); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = + evaluator.createMapping( + MAPPING_DOMAIN_FILENAME, shortTestName, "organization", delta, userOld); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN when(); mapping.evaluate(createTask(), opResult); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); display("Output triple", outputTriple); outputTriple.checkConsistence(); PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTriplePlus(outputTriple, - PrismTestUtil.createPolyString("Pirate Jackie (992)"), - PrismTestUtil.createPolyString("Pirate Jackie (994)")); - PrismAsserts.assertTripleMinus(outputTriple, - PrismTestUtil.createPolyString("Pirate null (001)"), - PrismTestUtil.createPolyString("Pirate null (004)")); + PrismAsserts.assertTriplePlus(outputTriple, + PrismTestUtil.createPolyString("Pirate Jackie (992)"), + PrismTestUtil.createPolyString("Pirate Jackie (994)")); + PrismAsserts.assertTripleMinus(outputTriple, + PrismTestUtil.createPolyString("Pirate null (001)"), + PrismTestUtil.createPolyString("Pirate null (004)")); } @Test public void testAddMixedMultiValue() throws Exception { - final String TEST_NAME = "testAddMixedMultiValue"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN PrismObject userOld = evaluator.getUserOld(); @@ -196,37 +181,35 @@ public void testAddMixedMultiValue() throws Exception { ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, MappingTestEvaluator.USER_OLD_OID, - UserType.F_EMPLOYEE_TYPE, "X91", "992", "Y93", "994"); + UserType.F_EMPLOYEE_TYPE, "X91", "992", "Y93", "994"); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( - MAPPING_DOMAIN_FILENAME, - TEST_NAME, "organization", delta, userOld); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = + evaluator.createMapping( + MAPPING_DOMAIN_FILENAME, shortTestName, "organization", delta, userOld); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN when(); mapping.evaluate(createTask(), opResult); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); display("Output triple", outputTriple); outputTriple.checkConsistence(); PrismAsserts.assertTripleZero(outputTriple, - PrismTestUtil.createPolyString("Pirate Jackie (001)"), - PrismTestUtil.createPolyString("Pirate Jackie (004)")); - PrismAsserts.assertTriplePlus(outputTriple, - PrismTestUtil.createPolyString("Pirate Jackie (992)"), - PrismTestUtil.createPolyString("Pirate Jackie (994)")); - PrismAsserts.assertTripleNoMinus(outputTriple); + PrismTestUtil.createPolyString("Pirate Jackie (001)"), + PrismTestUtil.createPolyString("Pirate Jackie (004)")); + PrismAsserts.assertTriplePlus(outputTriple, + PrismTestUtil.createPolyString("Pirate Jackie (992)"), + PrismTestUtil.createPolyString("Pirate Jackie (994)")); + PrismAsserts.assertTripleNoMinus(outputTriple); } @Test public void testDeleteMixedMultiValue() throws Exception { - final String TEST_NAME = "testDeleteMixedMultiValue"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN PrismObject userOld = evaluator.getUserOld(); @@ -243,30 +226,30 @@ public void testDeleteMixedMultiValue() throws Exception { ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationDeleteProperty(UserType.class, MappingTestEvaluator.USER_OLD_OID, - UserType.F_EMPLOYEE_TYPE, "005", "C06", "007"); + UserType.F_EMPLOYEE_TYPE, "005", "C06", "007"); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( - MAPPING_DOMAIN_FILENAME, - TEST_NAME, "organization", delta, userOld); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping( + MAPPING_DOMAIN_FILENAME, shortTestName, "organization", delta, userOld); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN when(); mapping.evaluate(createTask(), opResult); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); display("Output triple", outputTriple); outputTriple.checkConsistence(); PrismAsserts.assertTripleZero(outputTriple, - PrismTestUtil.createPolyString("Pirate Jackie (001)"), - PrismTestUtil.createPolyString("Pirate Jackie (004)")); + PrismTestUtil.createPolyString("Pirate Jackie (001)"), + PrismTestUtil.createPolyString("Pirate Jackie (004)")); PrismAsserts.assertTripleNoPlus(outputTriple); - PrismAsserts.assertTripleMinus(outputTriple, - PrismTestUtil.createPolyString("Pirate Jackie (005)"), - PrismTestUtil.createPolyString("Pirate Jackie (007)")); + PrismAsserts.assertTripleMinus(outputTriple, + PrismTestUtil.createPolyString("Pirate Jackie (005)"), + PrismTestUtil.createPolyString("Pirate Jackie (007)")); } } diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSimple.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSimple.java index 7daca0ead66..b9abafbe4b9 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSimple.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSimple.java @@ -6,28 +6,17 @@ */ package com.evolveum.midpoint.model.common.mapping; -import static com.evolveum.midpoint.schema.constants.SchemaConstants.*; -import static com.evolveum.midpoint.test.IntegrationTestTools.display; +import static org.testng.AssertJUnit.*; + import static com.evolveum.midpoint.prism.util.PrismAsserts.assertTripleNoMinus; import static com.evolveum.midpoint.prism.util.PrismAsserts.assertTripleZero; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertTrue; +import static com.evolveum.midpoint.schema.constants.SchemaConstants.*; +import static com.evolveum.midpoint.test.IntegrationTestTools.display; import java.io.File; import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.*; -import com.evolveum.midpoint.prism.delta.*; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; - import org.testng.AssertJUnit; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -35,6 +24,9 @@ import com.evolveum.midpoint.model.common.AbstractModelCommonTest; import com.evolveum.midpoint.model.common.expression.evaluator.GenerateExpressionEvaluator; +import com.evolveum.midpoint.prism.*; +import com.evolveum.midpoint.prism.delta.*; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; @@ -47,15 +39,10 @@ import com.evolveum.midpoint.schema.util.SchemaTestConstants; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.util.MidPointTestConstants; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; 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.ObjectReferenceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.StringPolicyType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; +import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; /** * @author Radovan Semancik @@ -75,9 +62,6 @@ public void setupFactory() throws SAXException, IOException, SchemaException { @Test public void testValueSingleDeep() throws Exception { - final String TEST_NAME = "testValueSingleDeep"; - displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMappingDynamicAdd( "mapping-value-single-deep.xml", @@ -95,9 +79,6 @@ public void testValueSingleDeep() throws Exception { @Test public void testValueSingleShallow() throws Exception { - final String TEST_NAME = "testValueSingleShallow"; - displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMappingDynamicAdd( "mapping-value-single-shallow.xml", @@ -115,9 +96,6 @@ public void testValueSingleShallow() throws Exception { @Test public void testValueMultiDeep() throws Exception { - final String TEST_NAME = "testValueMultiDeep"; - displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMappingDynamicAdd( "mapping-value-multi-deep.xml", @@ -135,9 +113,6 @@ public void testValueMultiDeep() throws Exception { @Test public void testValueMultiShallow() throws Exception { - final String TEST_NAME = "testValueMultiShallow"; - displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMappingDynamicAdd( "mapping-value-multi-shallow.xml", @@ -155,9 +130,6 @@ public void testValueMultiShallow() throws Exception { @Test public void testValueSingleEnum() throws Exception { - final String TEST_NAME = "testValueSingleEnum"; - displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMappingDynamicAdd( "mapping-value-single-enum.xml", @@ -175,9 +147,6 @@ public void testValueSingleEnum() throws Exception { @Test public void testAsIsAdd() throws Exception { - final String TEST_NAME = "testAsIsAdd"; - displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMappingDynamicAdd( "mapping-asis.xml", @@ -195,9 +164,6 @@ public void testAsIsAdd() throws Exception { @Test public void testAsIsDelete() throws Exception { - final String TEST_NAME = "testAsIsDelete"; - displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMappingDynamicDelete( "mapping-asis.xml", @@ -213,12 +179,8 @@ public void testAsIsDelete() throws Exception { PrismAsserts.assertTripleMinus(outputTriple, "PIRATE"); } - @Test public void testAsIsStringToPolyString() throws Exception { - final String TEST_NAME = "testAsIsStringToPolyString"; - displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMapping( "mapping-asis.xml", @@ -234,9 +196,6 @@ public void testAsIsStringToPolyString() throws Exception { @Test public void testAsIsStringToProtectedString() throws Exception { - final String TEST_NAME = "testAsIsStringToProtectedString"; - displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMapping( "mapping-asis.xml", @@ -252,9 +211,6 @@ public void testAsIsStringToProtectedString() throws Exception { @Test public void testAsIsProtectedStringToProtectedString() throws Exception { - final String TEST_NAME = "testAsIsProtectedStringToProtectedString"; - displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMapping( "mapping-asis-password.xml", @@ -270,9 +226,6 @@ public void testAsIsProtectedStringToProtectedString() throws Exception { @Test public void testAsIsProtectedStringToString() throws Exception { - final String TEST_NAME = "testAsIsProtectedStringToString"; - displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMapping( "mapping-asis-password.xml", @@ -288,9 +241,6 @@ public void testAsIsProtectedStringToString() throws Exception { @Test public void testAsIsProtectedStringToPolyString() throws Exception { - final String TEST_NAME = "testAsIsProtectedStringToPolyString"; - displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMapping( "mapping-asis-password.xml", @@ -304,12 +254,8 @@ public void testAsIsProtectedStringToPolyString() throws Exception { PrismAsserts.assertTripleNoMinus(outputTriple); } - @Test public void testPathVariables() throws Exception { - final String TEST_NAME = "testPathVariables"; - displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMappingDynamicAdd( "mapping-path-system-variables.xml", @@ -327,9 +273,6 @@ public void testPathVariables() throws Exception { @Test public void testPathExtensionProperty() throws Exception { - final String TEST_NAME = "testPathExtensionProperty"; - displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMapping( "mapping-path-extension-variable.xml", @@ -359,7 +302,6 @@ public void testPathVariablesNamespace() throws Exception { PrismAsserts.assertTripleNoMinus(outputTriple); } - @Test public void testPathVariablesPolyStringShort() throws Exception { // WHEN @@ -554,7 +496,7 @@ public void testScriptVariablesPolyStringGroovyNormReplaceNull() throws Exceptio "testScriptVariablesPolyStringGroovy", "description", // target "fullName" // changed property - ); // changed values + ); // changed values // THEN outputTriple.checkConsistence(); @@ -597,23 +539,22 @@ public void testAsIsVariablesPolyStringOrig() throws Exception { PrismAsserts.assertTripleNoMinus(outputTriple); } - @Test public void testScriptExtraVariablesRef() throws Exception { // GIVEN - MappingImpl.Builder,PrismPropertyDefinition> builder = evaluator.createMappingBuilder("mapping-script-extra-variables.xml", + MappingImpl.Builder, PrismPropertyDefinition> builder = evaluator.createMappingBuilder("mapping-script-extra-variables.xml", "testScriptExtraVariablesRef", "employeeType", null); VariablesMap vars = new VariablesMap(); ObjectReferenceType ref = MiscSchemaUtil.createObjectReference( - "c0c010c0-d34d-b33f-f00d-111111111112", - UserType.COMPLEX_TYPE); + "c0c010c0-d34d-b33f-f00d-111111111112", + UserType.COMPLEX_TYPE); vars.put("sailor", ref, PrismTestUtil.getPrismContext().definitionFactory().createReferenceDefinition( new QName(SchemaConstants.NS_C, "sailor"), UserType.COMPLEX_TYPE)); builder.addVariableDefinitions(vars); - MappingImpl,PrismPropertyDefinition> mapping = builder.build(); + MappingImpl, PrismPropertyDefinition> mapping = builder.build(); OperationResult opResult = new OperationResult("testScriptExtraVariablesRef"); @@ -630,21 +571,20 @@ public void testScriptExtraVariablesRef() throws Exception { @Test public void testScriptExtraVariablesJaxb() throws Exception { - final String TEST_NAME = "testScriptExtraVariablesJaxb"; - displayTestTitle(TEST_NAME); - // GIVEN - MappingImpl.Builder,PrismPropertyDefinition> builder = evaluator.createMappingBuilder("mapping-script-extra-variables.xml", - TEST_NAME, "employeeType", null); + String shortTestName = getTestNameShort(); + MappingImpl.Builder, PrismPropertyDefinition> builder = + evaluator.createMappingBuilder( + "mapping-script-extra-variables.xml", shortTestName, "employeeType", null); VariablesMap vars = new VariablesMap(); UserType userType = (UserType) PrismTestUtil.parseObject( new File(MidPointTestConstants.OBJECTS_DIR, "c0c010c0-d34d-b33f-f00d-111111111112.xml")).asObjectable(); vars.put("sailor", userType, userType.asPrismObject().getDefinition()); builder.addVariableDefinitions(vars); - MappingImpl,PrismPropertyDefinition> mapping = builder.build(); + MappingImpl, PrismPropertyDefinition> mapping = builder.build(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); @@ -665,7 +605,6 @@ public void testScriptFullNameNoChange() throws Exception { "testScriptVariablesPolyStringGroovy", "fullName"); // target - // THEN outputTriple.checkConsistence(); PrismAsserts.assertTripleZero(outputTriple, PrismTestUtil.createPolyString("Jack Sparrow")); @@ -675,15 +614,14 @@ public void testScriptFullNameNoChange() throws Exception { @Test public void testScriptFullNameReplaceGivenName() throws Exception { - final String TEST_NAME = "testScriptFullNameReplaceGivenName"; - displayTestTitle(TEST_NAME); // WHEN + String shortTestName = getTestNameShort(); PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMappingDynamicReplace( "mapping-script-fullname.xml", - TEST_NAME, - "fullName", // target - "givenName", // changed property - PrismTestUtil.createPolyString("Jackie")); // changed values + shortTestName, + "fullName", // target + "givenName", // changed property + PrismTestUtil.createPolyString("Jackie")); // changed values // THEN outputTriple.checkConsistence(); @@ -694,21 +632,21 @@ public void testScriptFullNameReplaceGivenName() throws Exception { @Test public void testScriptFullNameDeleteGivenName() throws Exception { - final String TEST_NAME = "testScriptFullNameDeleteGivenName"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() - .createModificationDeleteProperty(UserType.class, evaluator.USER_OLD_OID, - UserType.F_GIVEN_NAME, PrismTestUtil.createPolyString("Jack")); + .createModificationDeleteProperty( + UserType.class, MappingTestEvaluator.USER_OLD_OID, + UserType.F_GIVEN_NAME, PrismTestUtil.createPolyString("Jack")); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( - "mapping-script-fullname.xml", - TEST_NAME, - "fullName", // target - delta); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = + evaluator.createMapping( + "mapping-script-fullname.xml", + shortTestName, + "fullName", // target + delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); @@ -723,24 +661,22 @@ public void testScriptFullNameDeleteGivenName() throws Exception { @Test public void testScriptFullNameDeleteGivenNameFromNull() throws Exception { - final String TEST_NAME = "testScriptFullNameDeleteGivenNameFromNull"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() - .createModificationDeleteProperty(UserType.class, evaluator.USER_OLD_OID, - UserType.F_GIVEN_NAME, PrismTestUtil.createPolyString("Jack")); + .createModificationDeleteProperty(UserType.class, MappingTestEvaluator.USER_OLD_OID, + UserType.F_GIVEN_NAME, PrismTestUtil.createPolyString("Jack")); PrismObject userOld = evaluator.getUserOld(); userOld.asObjectable().setGivenName(null); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-script-fullname.xml", - TEST_NAME, + shortTestName, "fullName", // target delta, userOld); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); @@ -755,22 +691,20 @@ public void testScriptFullNameDeleteGivenNameFromNull() throws Exception { @Test public void testScriptFullNameDeleteGivenNameFamilyName() throws Exception { - final String TEST_NAME = "testScriptFullNameDeleteGivenNameFamilyName"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() - .createModificationDeleteProperty(UserType.class, evaluator.USER_OLD_OID, - UserType.F_GIVEN_NAME, PrismTestUtil.createPolyString("Jack")); + .createModificationDeleteProperty(UserType.class, MappingTestEvaluator.USER_OLD_OID, + UserType.F_GIVEN_NAME, PrismTestUtil.createPolyString("Jack")); delta.addModificationDeleteProperty(UserType.F_FAMILY_NAME, PrismTestUtil.createPolyString("Sparrow")); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-script-fullname.xml", - TEST_NAME, + shortTestName, "fullName", // target delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); @@ -806,22 +740,22 @@ public void testScriptFullNameReplaceEmployeeNumber() throws Exception { /** * Return type is a date, script returns string. */ - @Test - public void testScriptDateGroovy() throws Exception { - // WHEN - PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMappingDynamicReplace( - "mapping-script-date-groovy.xml", - "testScriptDateGroovy", - PATH_ACTIVATION_VALID_FROM, // target - "employeeNumber", // changed property - "1975-05-30"); // changed values - - // THEN - outputTriple.checkConsistence(); - PrismAsserts.assertTripleZero(outputTriple); - PrismAsserts.assertTriplePlus(outputTriple, XmlTypeConverter.createXMLGregorianCalendar(1975, 5, 30, 21, 30, 0)); - PrismAsserts.assertTripleNoMinus(outputTriple); - } + @Test + public void testScriptDateGroovy() throws Exception { + // WHEN + PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMappingDynamicReplace( + "mapping-script-date-groovy.xml", + "testScriptDateGroovy", + PATH_ACTIVATION_VALID_FROM, // target + "employeeNumber", // changed property + "1975-05-30"); // changed values + + // THEN + outputTriple.checkConsistence(); + PrismAsserts.assertTripleZero(outputTriple); + PrismAsserts.assertTriplePlus(outputTriple, XmlTypeConverter.createXMLGregorianCalendar(1975, 5, 30, 21, 30, 0)); + PrismAsserts.assertTripleNoMinus(outputTriple); + } @Test public void testScriptCustomEnum() throws Exception { @@ -864,7 +798,6 @@ public void testScriptListAbsoluteGroovy() throws Exception { testScriptListAbsolute("mapping-script-list-absolute-groovy.xml"); } - public void testScriptListAbsolute(String fileName) throws Exception { // WHEN PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMappingDynamicAdd( @@ -897,8 +830,8 @@ public void testValueConditionTrue() throws Exception { // THEN outputTriple.checkConsistence(); PrismAsserts.assertTripleZero(outputTriple, "foobar"); - PrismAsserts.assertTripleNoPlus(outputTriple); - PrismAsserts.assertTripleNoMinus(outputTriple); + PrismAsserts.assertTripleNoPlus(outputTriple); + PrismAsserts.assertTripleNoMinus(outputTriple); } @Test @@ -918,19 +851,17 @@ public void testValueConditionFalse() throws Exception { @Test public void testConditionNonEmptyCaptain() throws Exception { // GIVEN - final String TEST_NAME = "testConditionNonEmptyCaptain"; - displayTestTitle(TEST_NAME); - PrismObject user = evaluator.getUserOld(); user.asObjectable().getEmployeeType().clear(); user.asObjectable().getEmployeeType().add("CAPTAIN"); ObjectDelta delta = DeltaFactory.Object.createAddDelta(user); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-condition-nonempty.xml", - TEST_NAME, "title", delta); + shortTestName, "title", delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); @@ -939,26 +870,24 @@ public void testConditionNonEmptyCaptain() throws Exception { PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); outputTriple.checkConsistence(); PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("The CAPTAIN")); - PrismAsserts.assertTripleNoMinus(outputTriple); + PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("The CAPTAIN")); + PrismAsserts.assertTripleNoMinus(outputTriple); } @Test public void testConditionNonEmptyEmpty() throws Exception { // GIVEN - final String TEST_NAME = "testConditionNonEmptyEmpty"; - displayTestTitle(TEST_NAME); - PrismObject user = evaluator.getUserOld(); user.asObjectable().getEmployeeType().clear(); user.asObjectable().getEmployeeType().add(""); ObjectDelta delta = DeltaFactory.Object.createAddDelta(user); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-condition-nonempty.xml", - TEST_NAME, "title", delta); + shortTestName, "title", delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); @@ -971,18 +900,16 @@ public void testConditionNonEmptyEmpty() throws Exception { @Test public void testConditionNonEmptyNoValue() throws Exception { // GIVEN - final String TEST_NAME = "testConditionNonEmptyNoValue"; - displayTestTitle(TEST_NAME); - PrismObject user = evaluator.getUserOld(); user.asObjectable().getEmployeeType().clear(); ObjectDelta delta = DeltaFactory.Object.createAddDelta(user); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-condition-nonempty.xml", - TEST_NAME, "title", delta); + shortTestName, "title", delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); @@ -994,21 +921,18 @@ public void testConditionNonEmptyNoValue() throws Exception { @Test public void testScriptTransformMultiAddDelete() throws Exception { - final String TEST_NAME = "testScriptTransformMultiAddDelete"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() - .createEmptyModifyDelta(UserType.class, evaluator.USER_OLD_OID + .createEmptyModifyDelta(UserType.class, MappingTestEvaluator.USER_OLD_OID ); PropertyDelta propDelta = delta.createPropertyModification(evaluator.toPath("employeeType")); propDelta.addRealValuesToAdd("CAPTAIN"); propDelta.addRealValuesToDelete("LANDLUBER"); delta.addModification(propDelta); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( - "mapping-script-transform.xml", - TEST_NAME, "organizationalUnit", delta); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping( + "mapping-script-transform.xml", shortTestName, "organizationalUnit", delta); PrismObject user = (PrismObject) mapping.getSourceContext().getOldObject(); user.asObjectable().getEmployeeType().add("LANDLUBER"); @@ -1016,19 +940,19 @@ public void testScriptTransformMultiAddDelete() throws Exception { display("user before", user); display("delta", delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN when(); mapping.evaluate(createTask(), opResult); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); outputTriple.checkConsistence(); PrismAsserts.assertTripleZero(outputTriple, PrismTestUtil.createPolyString("The pirate deck")); - PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("The captain deck")); - PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("The landluber deck")); + PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("The captain deck")); + PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("The landluber deck")); } /** @@ -1036,47 +960,41 @@ public void testScriptTransformMultiAddDelete() throws Exception { */ @Test public void testScriptTransformMultiReplace() throws Exception { - final String TEST_NAME = "testScriptTransformMultiReplace"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() - .createEmptyModifyDelta(UserType.class, evaluator.USER_OLD_OID + .createEmptyModifyDelta(UserType.class, MappingTestEvaluator.USER_OLD_OID ); PropertyDelta propDelta = delta.createPropertyModification(evaluator.toPath("employeeType")); propDelta.setRealValuesToReplace("CAPTAIN"); delta.addModification(propDelta); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( - "mapping-script-transform.xml", - TEST_NAME, "organizationalUnit", delta); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping( + "mapping-script-transform.xml", shortTestName, "organizationalUnit", delta); PrismObject user = (PrismObject) mapping.getSourceContext().getOldObject(); display("user before", user); display("delta", delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN when(); mapping.evaluate(createTask(), opResult); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); display("output triple", outputTriple); outputTriple.checkConsistence(); PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("The captain deck")); - PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("The pirate deck")); + PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("The captain deck")); + PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("The pirate deck")); } @Test - public void testInboundMapping() throws Exception{ - final String TEST_NAME = "testInboundMapping"; - displayTestTitle(TEST_NAME); - + public void testInboundMapping() throws Exception { PrismContext prismContext = evaluator.getPrismContext(); PrismObject account = PrismTestUtil.parseObject(new File(MappingTestEvaluator.TEST_DIR, "account-inbound-mapping.xml")); @@ -1090,15 +1008,21 @@ public void testInboundMapping() throws Exception{ IntegrationTestTools.display("Account", account); Item oldItem = account.findItem(ItemPath.create(ShadowType.F_ATTRIBUTES, SchemaTestConstants.ICFS_NAME)); - ItemDelta delta = prismContext.deltaFactory().property().createModificationAddProperty(SchemaTestConstants.ICFS_NAME_PATH_PARTS, (PrismPropertyDefinition) oldItem.getDefinition(), ((PrismPropertyValue) oldItem.getAnyValue()).getValue()); + ItemDelta delta = prismContext.deltaFactory().property().createModificationAddProperty( + SchemaTestConstants.ICFS_NAME_PATH_PARTS, + (PrismPropertyDefinition) oldItem.getDefinition(), + ((PrismPropertyValue) oldItem.getAnyValue()).getValue()); PrismObject user = evaluator.getUserDefinition().instantiate(); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createInboudMapping("mapping-inbound.xml", TEST_NAME, delta, user.asObjectable(), account.asObjectable(), null, null); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = + evaluator.createInboudMapping( + "mapping-inbound.xml", shortTestName, delta, user.asObjectable(), account.asObjectable(), null, null); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); - displayWhen(TEST_NAME); + when(); mapping.evaluate(createTask(), opResult); PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); @@ -1110,15 +1034,14 @@ public void testInboundMapping() throws Exception{ @Test public void testGenerateDefault() throws Exception { - final String TEST_NAME = "testGenerateDefault"; - displayTestTitle(TEST_NAME); - final ValuePolicyType stringPolicy = evaluator.getValuePolicy(); // GIVEN - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping("mapping-generate.xml", - TEST_NAME, stringPolicy, "employeeNumber", null); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = + evaluator.createMapping("mapping-generate.xml", + shortTestName, stringPolicy, "employeeNumber", null); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN (1) mapping.evaluate(createTask(), opResult); @@ -1132,7 +1055,7 @@ public void testGenerateDefault() throws Exception { System.out.println("Generated value (1): " + value1); assertGeneratedValue(value1, stringPolicy, null, false, false); - mapping = evaluator.createMapping("mapping-generate.xml", TEST_NAME, stringPolicy, "employeeNumber", null); + mapping = evaluator.createMapping("mapping-generate.xml", shortTestName, stringPolicy, "employeeNumber", null); // WHEN (2) mapping.evaluate(createTask(), opResult); @@ -1181,17 +1104,16 @@ public void testGeneratePolicyNumericString() throws Exception { private void generatePolicy(final String TEST_NAME, String mappingFileName, String policyFileName, String pattern, boolean ignoreMax) throws Exception { - displayTestTitle(TEST_NAME); // This is just for validation. The expression has to resolve reference of its own PrismObject valuePolicy = PrismTestUtil.parseObject( new File(MidPointTestConstants.OBJECTS_DIR, policyFileName)); final ValuePolicyType stringPolicy = valuePolicy.asObjectable(); // GIVEN - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping(mappingFileName, + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping(mappingFileName, TEST_NAME, stringPolicy, "employeeNumber", null); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(contextName()); // WHEN (1) mapping.evaluate(createTask(), opResult); @@ -1232,15 +1154,15 @@ private void assertGeneratedValue(String value, ValuePolicyType valuePolicy, Str assertEquals("Unexpected generated value length", GenerateExpressionEvaluator.DEFAULT_LENGTH, value.length()); } else { if (!ignoreMin) { - assertTrue("Value '"+value+"' too short, minLength="+stringPolicy.getLimitations().getMinLength()+", length="+value.length(), value.length() >= stringPolicy.getLimitations().getMinLength()); + assertTrue("Value '" + value + "' too short, minLength=" + stringPolicy.getLimitations().getMinLength() + ", length=" + value.length(), value.length() >= stringPolicy.getLimitations().getMinLength()); } if (!ignoreMax) { - assertTrue("Value '"+value+"' too long, maxLength="+stringPolicy.getLimitations().getMaxLength()+", length="+value.length(), value.length() <= stringPolicy.getLimitations().getMaxLength()); + assertTrue("Value '" + value + "' too long, maxLength=" + stringPolicy.getLimitations().getMaxLength() + ", length=" + value.length(), value.length() <= stringPolicy.getLimitations().getMaxLength()); } // TODO: better validation } if (pattern != null) { - assertTrue("Value '"+value+"' does not match pattern '"+pattern+"'", value.matches(pattern)); + assertTrue("Value '" + value + "' does not match pattern '" + pattern + "'", value.matches(pattern)); } } @@ -1248,26 +1170,26 @@ private void assertGeneratedValue(String value, ValuePolicyType valuePolicy, Str public void testGeneratePolicyNumericInt() throws Exception { final String TEST_NAME = "testGeneratePolicyNumericInt"; generatePolicyNumeric(TEST_NAME, "mapping-generate-policy-numeric.xml", - "c0c010c0-d34d-b33f-f00d-999888111112.xml", "intType", Integer.class); + "c0c010c0-d34d-b33f-f00d-999888111112.xml", "intType"); } @Test public void testGeneratePolicyNumericInteger() throws Exception { final String TEST_NAME = "testGeneratePolicyNumericInt"; generatePolicyNumeric(TEST_NAME, "mapping-generate-policy-numeric.xml", - "c0c010c0-d34d-b33f-f00d-999888111112.xml", "integerType", Integer.class); + "c0c010c0-d34d-b33f-f00d-999888111112.xml", "integerType"); } @Test public void testGeneratePolicyNumericLong() throws Exception { final String TEST_NAME = "testGeneratePolicyNumericInt"; generatePolicyNumeric(TEST_NAME, "mapping-generate-policy-numeric.xml", - "c0c010c0-d34d-b33f-f00d-999888111112.xml", "longType", Long.class); + "c0c010c0-d34d-b33f-f00d-999888111112.xml", "longType"); } - private void generatePolicyNumeric(final String TEST_NAME, String mappingFileName, - String policyFileName, String extensionPropName, Class clazz) throws Exception { - displayTestTitle(TEST_NAME); + private void generatePolicyNumeric(final String TEST_NAME, + String mappingFileName, String policyFileName, String extensionPropName) + throws Exception { // This is just for validation. The expression has to resolve reference of its own PrismObject valuePolicy = PrismTestUtil.parseObject( @@ -1275,13 +1197,13 @@ private void generatePolicyNumeric(final String TEST_NAME, String mappingFil final ValuePolicyType valuePolicyType = valuePolicy.asObjectable(); // GIVEN PrismContext prismContext = evaluator.getPrismContext(); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMappingBuilder(mappingFileName, + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMappingBuilder(mappingFileName, TEST_NAME, valuePolicyType, ItemPath.create( UserType.F_EXTENSION, new QName(NS_EXTENSION, extensionPropName)), null) .build(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(contextName()); // WHEN (1) mapping.evaluate(createTask(), opResult); @@ -1324,12 +1246,12 @@ private void generatePolicyNumeric(final String TEST_NAME, String mappingFil @Test public void testGenerateProtectedString() throws Exception { - final String TEST_NAME = "testGenerateProtectedString"; - displayTestTitle(TEST_NAME); // GIVEN - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping("mapping-generate.xml", - TEST_NAME, SchemaConstants.PATH_PASSWORD_VALUE, null); - OperationResult opResult = new OperationResult(TEST_NAME); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = + evaluator.createMapping("mapping-generate.xml", + shortTestName, SchemaConstants.PATH_PASSWORD_VALUE, null); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); @@ -1341,7 +1263,7 @@ public void testGenerateProtectedString() throws Exception { PrismAsserts.assertTripleNoPlus(outputTriple); PrismAsserts.assertTripleNoMinus(outputTriple); - System.out.println("Generated excrypted value: "+value1); + System.out.println("Generated excrypted value: " + value1); assertNotNull(value1); assertNotNull(value1.getEncryptedDataType()); } diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSysVar.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSysVar.java index 8b9874c2db1..0d2d1ca8caf 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSysVar.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSysVar.java @@ -13,10 +13,6 @@ import java.math.BigDecimal; import java.math.BigInteger; -import com.evolveum.midpoint.prism.delta.DeltaFactory; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; - import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import org.xml.sax.SAXException; @@ -26,15 +22,16 @@ import com.evolveum.midpoint.prism.PrismProperty; import com.evolveum.midpoint.prism.PrismPropertyDefinition; import com.evolveum.midpoint.prism.PrismPropertyValue; +import com.evolveum.midpoint.prism.delta.DeltaFactory; import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.delta.PrismValueDeltaSetTriple; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.SchemaTestConstants; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; @@ -42,6 +39,7 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType; import com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; +import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; /** * @author Radovan Semancik @@ -70,19 +68,16 @@ public void testScriptSystemVariablesConditionAddObjectTrueSourcecontextGroovy() public void testScriptSystemVariablesConditionAddObjectTrue(String filename) throws Exception { // GIVEN - final String TEST_NAME = "testScriptSystemVariablesConditionAddObjectTrue"; - displayTestTitle(TEST_NAME); - PrismObject user = evaluator.getUserOld(); user.asObjectable().getEmployeeType().clear(); user.asObjectable().getEmployeeType().add("CAPTAIN"); ObjectDelta delta = DeltaFactory.Object.createAddDelta(user); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( - filename, - TEST_NAME, "title", delta); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping( + filename, shortTestName, "title", delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); @@ -90,8 +85,8 @@ public void testScriptSystemVariablesConditionAddObjectTrue(String filename) thr // THEN PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("Captain jack")); - PrismAsserts.assertTripleNoMinus(outputTriple); + PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("Captain jack")); + PrismAsserts.assertTripleNoMinus(outputTriple); } /** @@ -99,26 +94,24 @@ public void testScriptSystemVariablesConditionAddObjectTrue(String filename) thr */ @Test public void testScriptSystemVariablesConditionModifyObjectTrueGroovyUnrelated() throws Exception { - final String TEST_NAME = "testScriptSystemVariablesConditionAddObjectTrueGroovyUnrelated"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, - evaluator.toPath("employeeNumber"), "666"); + evaluator.toPath("employeeNumber"), "666"); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-script-system-variables-condition-groovy.xml", - TEST_NAME, "title", delta); + shortTestName, "title", delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); // THEN PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); - assertNull("Unexpected value in outputTriple: "+outputTriple, outputTriple); + assertNull("Unexpected value in outputTriple: " + outputTriple, outputTriple); } @Test @@ -133,26 +126,23 @@ public void testScriptSystemVariablesConditionAddObjectFalseSourcecontextGroovy( public void testScriptSystemVariablesConditionAddObjectFalse(String filename) throws Exception { // GIVEN - final String TEST_NAME = "testScriptSystemVariablesConditionAddObjectFalse"; - displayTestTitle(TEST_NAME); - PrismObject user = evaluator.getUserOld(); user.asObjectable().getEmployeeType().clear(); user.asObjectable().getEmployeeType().add("SAILOR"); ObjectDelta delta = DeltaFactory.Object.createAddDelta(user); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( - filename, - TEST_NAME, "title", delta); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = + evaluator.createMapping(filename, shortTestName, "title", delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); // THEN PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); - assertNull("Unexpected output triple: "+outputTriple, outputTriple); + assertNull("Unexpected output triple: " + outputTriple, outputTriple); } @Test @@ -167,26 +157,23 @@ public void testScriptSystemVariablesConditionAddObjectFalseNoValSourcecontextGr public void testScriptSystemVariablesConditionAddObjectFalseNoVal(String filename) throws Exception { // GIVEN - final String TEST_NAME = "testScriptSystemVariablesConditionAddObjectFalseNoVal"; - displayTestTitle(TEST_NAME); - PrismObject user = evaluator.getUserOld(); PrismProperty employeeTypeProperty = user.findProperty(UserType.F_EMPLOYEE_TYPE); employeeTypeProperty.clear(); ObjectDelta delta = DeltaFactory.Object.createAddDelta(user); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( - filename, - TEST_NAME, "title", delta); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = + evaluator.createMapping(filename, shortTestName, "title", delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); // THEN PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); - assertNull("Unexpected output triple: "+outputTriple, outputTriple); + assertNull("Unexpected output triple: " + outputTriple, outputTriple); } @Test @@ -201,29 +188,24 @@ public void testScriptSystemVariablesConditionAddObjectFalseNoPropertySourcecont public void testScriptSystemVariablesConditionAddObjectFalseNoProperty(String filename) throws Exception { // GIVEN - final String TEST_NAME = "testScriptSystemVariablesConditionAddObjectFalseNoProperty"; - displayTestTitle(TEST_NAME); - - PrismObject user = evaluator.getUserOld(); user.removeProperty(UserType.F_EMPLOYEE_TYPE); ObjectDelta delta = DeltaFactory.Object.createAddDelta(user); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( - filename, - TEST_NAME, "title", delta); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = + evaluator.createMapping(filename, shortTestName, "title", delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); // THEN PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); - assertNull("Unexpected output triple: "+outputTriple, outputTriple); + assertNull("Unexpected output triple: " + outputTriple, outputTriple); } - @Test public void testScriptSystemVariablesConditionTrueToTrueGroovy() throws Exception { testScriptSystemVariablesConditionTrueToTrue("mapping-script-system-variables-condition-groovy.xml"); @@ -231,22 +213,19 @@ public void testScriptSystemVariablesConditionTrueToTrueGroovy() throws Exceptio public void testScriptSystemVariablesConditionTrueToTrue(String filename) throws Exception { // GIVEN - final String TEST_NAME = "testScriptSystemVariablesConditionTrueToTrue"; - displayTestTitle(TEST_NAME); - ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, - evaluator.toPath("name"), PrismTestUtil.createPolyString("Jack")); + evaluator.toPath("name"), PrismTestUtil.createPolyString("Jack")); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( - filename, - TEST_NAME, "title", delta); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = + evaluator.createMapping(filename, shortTestName, "title", delta); PrismObject user = (PrismObject) mapping.getSourceContext().getOldObject(); user.asObjectable().getEmployeeType().add("CAPTAIN"); mapping.getSourceContext().recompute(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); @@ -254,8 +233,8 @@ public void testScriptSystemVariablesConditionTrueToTrue(String filename) throws // THEN PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("Captain Jack")); - PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("Captain jack")); + PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("Captain Jack")); + PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("Captain jack")); } @Test @@ -265,25 +244,22 @@ public void testScriptSystemVariablesConditionFalseToFalseGroovy() throws Except public void testScriptSystemVariablesConditionFalseToFalse(String filename) throws Exception { // GIVEN - final String TEST_NAME = "testScriptSystemVariablesConditionFalseToFalse"; - displayTestTitle(TEST_NAME); - ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, - evaluator.toPath("name"), PrismTestUtil.createPolyString("Jack")); + evaluator.toPath("name"), PrismTestUtil.createPolyString("Jack")); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( - filename, - TEST_NAME, "title", delta); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = + evaluator.createMapping(filename, shortTestName, "title", delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); // THEN PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); - assertNull("Unexpected value in outputTriple: "+outputTriple, outputTriple); + assertNull("Unexpected value in outputTriple: " + outputTriple, outputTriple); } @Test @@ -293,18 +269,16 @@ public void testScriptSystemVariablesConditionFalseToTrueGroovy() throws Excepti public void testScriptSystemVariablesConditionFalseToTrue(String filename) throws Exception { // GIVEN - final String TEST_NAME = "testScriptSystemVariablesConditionFalseToTrue"; - displayTestTitle(TEST_NAME); - ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, - evaluator.toPath("name"), PrismTestUtil.createPolyString("Jack")); + evaluator.toPath("name"), PrismTestUtil.createPolyString("Jack")); delta.addModificationAddProperty(evaluator.toPath("employeeType"), "CAPTAIN"); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( - filename, TEST_NAME, "title", delta); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = + evaluator.createMapping(filename, shortTestName, "title", delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); @@ -312,8 +286,8 @@ public void testScriptSystemVariablesConditionFalseToTrue(String filename) throw // THEN PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("Captain Jack")); - PrismAsserts.assertTripleNoMinus(outputTriple); + PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("Captain Jack")); + PrismAsserts.assertTripleNoMinus(outputTriple); } @Test @@ -323,22 +297,20 @@ public void testScriptSystemVariablesConditionTrueToFalseGroovy() throws Excepti public void testScriptSystemVariablesConditionTrueToFalse(String filename) throws Exception { // GIVEN - final String TEST_NAME = "testScriptSystemVariablesConditionTrueToFalse"; - displayTestTitle(TEST_NAME); - ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, - evaluator.toPath("name"), "Jack"); + evaluator.toPath("name"), "Jack"); delta.addModificationDeleteProperty(evaluator.toPath("employeeType"), "CAPTAIN"); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( - filename, TEST_NAME, "title", delta); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = + evaluator.createMapping(filename, shortTestName, "title", delta); PrismObject user = (PrismObject) mapping.getSourceContext().getOldObject(); user.asObjectable().getEmployeeType().add("CAPTAIN"); mapping.getSourceContext().recompute(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); @@ -346,52 +318,51 @@ public void testScriptSystemVariablesConditionTrueToFalse(String filename) throw // THEN PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTripleNoPlus(outputTriple); - PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("Captain jack")); + PrismAsserts.assertTripleNoPlus(outputTriple); + PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("Captain jack")); } @Test public void testScriptSystemVariablesConditionEmptyTrue() throws Exception { - final String TEST_NAME = "testScriptSystemVariablesConditionEmptyTrue"; - testScriptSystemVariablesConditionEmptyTrue(TEST_NAME, "mapping-script-system-variables-condition-empty.xml"); + final String shortTestName = "testScriptSystemVariablesConditionEmptyTrue"; + testScriptSystemVariablesConditionEmptyTrue(shortTestName, "mapping-script-system-variables-condition-empty.xml"); } @Test public void testScriptSystemVariablesConditionEmptyTrueFunction() throws Exception { - final String TEST_NAME = "testScriptSystemVariablesConditionEmptyTrueFunction"; - testScriptSystemVariablesConditionEmptyTrue(TEST_NAME, "mapping-script-system-variables-condition-empty-function.xml"); + final String shortTestName = "testScriptSystemVariablesConditionEmptyTrueFunction"; + testScriptSystemVariablesConditionEmptyTrue(shortTestName, "mapping-script-system-variables-condition-empty-function.xml"); } @Test public void testScriptSystemVariablesConditionEmptySingleTrue() throws Exception { - final String TEST_NAME = "testScriptSystemVariablesConditionEmptySingleTrue"; - testScriptSystemVariablesConditionEmptyTrue(TEST_NAME, "mapping-script-system-variables-condition-empty-single.xml"); + final String shortTestName = "testScriptSystemVariablesConditionEmptySingleTrue"; + testScriptSystemVariablesConditionEmptyTrue(shortTestName, "mapping-script-system-variables-condition-empty-single.xml"); } @Test public void testScriptSystemVariablesConditionEmptySingleTrueFunction() throws Exception { - final String TEST_NAME = "testScriptSystemVariablesConditionEmptySingleTrueFunction"; - testScriptSystemVariablesConditionEmptyTrue(TEST_NAME, "mapping-script-system-variables-condition-empty-single-function.xml"); + final String shortTestName = "testScriptSystemVariablesConditionEmptySingleTrueFunction"; + testScriptSystemVariablesConditionEmptyTrue(shortTestName, "mapping-script-system-variables-condition-empty-single-function.xml"); } - public void testScriptSystemVariablesConditionEmptyTrue(final String TEST_NAME, String filename) throws Exception { - displayTestTitle(TEST_NAME); + public void testScriptSystemVariablesConditionEmptyTrue(final String shortTestName, String filename) throws Exception { // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, - evaluator.toPath("name"), PrismTestUtil.createPolyString("Jack")); + evaluator.toPath("name"), PrismTestUtil.createPolyString("Jack")); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping( filename, - TEST_NAME, "title", delta); + shortTestName, "title", delta); PrismObject user = (PrismObject) mapping.getSourceContext().getOldObject(); user.asObjectable().getEmployeeType().clear(); user.asObjectable().setEmployeeNumber(null); mapping.getSourceContext().recompute(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); @@ -399,39 +370,38 @@ public void testScriptSystemVariablesConditionEmptyTrue(final String TEST_NAME, // THEN PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("Landlubber Jack")); - PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("Landlubber jack")); + PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("Landlubber Jack")); + PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("Landlubber jack")); } @Test public void testScriptSystemVariablesConditionEmptySingleFalseToTrue() throws Exception { - final String TEST_NAME = "testScriptSystemVariablesConditionEmptySingleFalseToTrue"; - testScriptSystemVariablesConditionEmptyFalseToTrue(TEST_NAME, "mapping-script-system-variables-condition-empty-single.xml"); + final String shortTestName = "testScriptSystemVariablesConditionEmptySingleFalseToTrue"; + testScriptSystemVariablesConditionEmptyFalseToTrue(shortTestName, "mapping-script-system-variables-condition-empty-single.xml"); } @Test public void testScriptSystemVariablesConditionEmptySingleFalseToTrueFunction() throws Exception { - final String TEST_NAME = "testScriptSystemVariablesConditionEmptySingleFalseToTrueFunction"; - testScriptSystemVariablesConditionEmptyFalseToTrue(TEST_NAME, "mapping-script-system-variables-condition-empty-single-function.xml"); + final String shortTestName = "testScriptSystemVariablesConditionEmptySingleFalseToTrueFunction"; + testScriptSystemVariablesConditionEmptyFalseToTrue(shortTestName, "mapping-script-system-variables-condition-empty-single-function.xml"); } - public void testScriptSystemVariablesConditionEmptyFalseToTrue(final String TEST_NAME, String filename) throws Exception { - displayTestTitle(TEST_NAME); + public void testScriptSystemVariablesConditionEmptyFalseToTrue(final String shortTestName, String filename) throws Exception { // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, - evaluator.toPath("employeeNumber")); + evaluator.toPath("employeeNumber")); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping( filename, - TEST_NAME, "title", delta); + shortTestName, "title", delta); PrismObject user = (PrismObject) mapping.getSourceContext().getOldObject(); user.asObjectable().setEmployeeNumber("666"); mapping.getSourceContext().recompute(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); @@ -439,90 +409,88 @@ public void testScriptSystemVariablesConditionEmptyFalseToTrue(final String TEST // THEN PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("Landlubber jack")); - PrismAsserts.assertTripleNoMinus(outputTriple); + PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("Landlubber jack")); + PrismAsserts.assertTripleNoMinus(outputTriple); } @Test public void testScriptSystemVariablesConditionEmptyFalse() throws Exception { - final String TEST_NAME = "testScriptSystemVariablesConditionEmptyFalse"; - testScriptSystemVariablesConditionEmptyFalse(TEST_NAME, "mapping-script-system-variables-condition-empty.xml"); + final String shortTestName = "testScriptSystemVariablesConditionEmptyFalse"; + testScriptSystemVariablesConditionEmptyFalse(shortTestName, "mapping-script-system-variables-condition-empty.xml"); } @Test public void testScriptSystemVariablesConditionEmptyFalseFunction() throws Exception { - final String TEST_NAME = "testScriptSystemVariablesConditionEmptyFalse"; - testScriptSystemVariablesConditionEmptyFalse(TEST_NAME, "mapping-script-system-variables-condition-empty-function.xml"); + final String shortTestName = "testScriptSystemVariablesConditionEmptyFalse"; + testScriptSystemVariablesConditionEmptyFalse(shortTestName, "mapping-script-system-variables-condition-empty-function.xml"); } @Test public void testScriptSystemVariablesConditionEmptySingleFalse() throws Exception { - final String TEST_NAME = "testScriptSystemVariablesConditionEmptySingleFalse"; - testScriptSystemVariablesConditionEmptyFalse(TEST_NAME, "mapping-script-system-variables-condition-empty-single.xml"); + final String shortTestName = "testScriptSystemVariablesConditionEmptySingleFalse"; + testScriptSystemVariablesConditionEmptyFalse(shortTestName, "mapping-script-system-variables-condition-empty-single.xml"); } @Test public void testScriptSystemVariablesConditionEmptySingleFalseFunction() throws Exception { - final String TEST_NAME = "testScriptSystemVariablesConditionEmptySingleFalseFunction"; - testScriptSystemVariablesConditionEmptyFalse(TEST_NAME, "mapping-script-system-variables-condition-empty-single-function.xml"); + final String shortTestName = "testScriptSystemVariablesConditionEmptySingleFalseFunction"; + testScriptSystemVariablesConditionEmptyFalse(shortTestName, "mapping-script-system-variables-condition-empty-single-function.xml"); } - public void testScriptSystemVariablesConditionEmptyFalse(final String TEST_NAME, String filename) throws Exception { - displayTestTitle(TEST_NAME); + public void testScriptSystemVariablesConditionEmptyFalse(final String shortTestName, String filename) throws Exception { // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, - evaluator.toPath("name"), PrismTestUtil.createPolyString("Jack")); + evaluator.toPath("name"), PrismTestUtil.createPolyString("Jack")); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping( filename, - TEST_NAME, "title", delta); + shortTestName, "title", delta); PrismObject user = (PrismObject) mapping.getSourceContext().getOldObject(); user.asObjectable().getEmployeeType().add("SAILOR"); user.asObjectable().setEmployeeNumber("666"); mapping.getSourceContext().recompute(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); // THEN PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); - assertNull("Unexpected value in outputTriple: "+outputTriple, outputTriple); + assertNull("Unexpected value in outputTriple: " + outputTriple, outputTriple); } @Test public void testScriptSystemVariablesConditionEmptySingleTrueToFalse() throws Exception { - final String TEST_NAME = "testScriptSystemVariablesConditionEmptySingleTrueToFalse"; - testScriptSystemVariablesConditionEmptyTrueToFalse(TEST_NAME, "mapping-script-system-variables-condition-empty-single.xml"); + final String shortTestName = "testScriptSystemVariablesConditionEmptySingleTrueToFalse"; + testScriptSystemVariablesConditionEmptyTrueToFalse(shortTestName, "mapping-script-system-variables-condition-empty-single.xml"); } @Test public void testScriptSystemVariablesConditionEmptySingleTrueToFalseFunction() throws Exception { - final String TEST_NAME = "testScriptSystemVariablesConditionEmptySingleTrueToFalseFunction"; - testScriptSystemVariablesConditionEmptyTrueToFalse(TEST_NAME, "mapping-script-system-variables-condition-empty-single-function.xml"); + final String shortTestName = "testScriptSystemVariablesConditionEmptySingleTrueToFalseFunction"; + testScriptSystemVariablesConditionEmptyTrueToFalse(shortTestName, "mapping-script-system-variables-condition-empty-single-function.xml"); } - public void testScriptSystemVariablesConditionEmptyTrueToFalse(final String TEST_NAME, String filename) throws Exception { - displayTestTitle(TEST_NAME); + public void testScriptSystemVariablesConditionEmptyTrueToFalse(final String shortTestName, String filename) throws Exception { // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, - evaluator.toPath("employeeNumber"), "666"); + evaluator.toPath("employeeNumber"), "666"); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping( filename, - TEST_NAME, "title", delta); + shortTestName, "title", delta); PrismObject user = (PrismObject) mapping.getSourceContext().getOldObject(); user.asObjectable().setEmployeeNumber(null); mapping.getSourceContext().recompute(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); @@ -530,25 +498,22 @@ public void testScriptSystemVariablesConditionEmptyTrueToFalse(final String TEST // THEN PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTripleNoPlus(outputTriple); - PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("Landlubber jack")); + PrismAsserts.assertTripleNoPlus(outputTriple); + PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("Landlubber jack")); } @Test public void testNpeFalseToTrue() throws Exception { - final String TEST_NAME = "testNpeFalseToTrue"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, - UserType.F_ADDITIONAL_NAME, "Captain Sparrow"); + UserType.F_ADDITIONAL_NAME, "Captain Sparrow"); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( - "mapping-npe.xml", - TEST_NAME, "title", delta); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = + evaluator.createMapping("mapping-npe.xml", shortTestName, "title", delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); @@ -556,29 +521,26 @@ public void testNpeFalseToTrue() throws Exception { // THEN PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("15")); - PrismAsserts.assertTripleNoMinus(outputTriple); + PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("15")); + PrismAsserts.assertTripleNoMinus(outputTriple); } @Test public void testNpeTrueToFalse() throws Exception { - final String TEST_NAME = "testNpeTrueToFalse"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, - UserType.F_ADDITIONAL_NAME); + UserType.F_ADDITIONAL_NAME); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( - "mapping-npe.xml", - TEST_NAME, "title", delta); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = + evaluator.createMapping("mapping-npe.xml", shortTestName, "title", delta); PrismObject user = (PrismObject) mapping.getSourceContext().getOldObject(); user.asObjectable().setAdditionalName(PrismTestUtil.createPolyStringType("Sultan of the Caribbean")); mapping.getSourceContext().recompute(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); @@ -586,25 +548,22 @@ public void testNpeTrueToFalse() throws Exception { // THEN PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTripleNoPlus(outputTriple); - PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("23")); + PrismAsserts.assertTripleNoPlus(outputTriple); + PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("23")); } @Test public void testPathEnum() throws Exception { - final String TEST_NAME = "testPathEnum"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, - SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, ActivationStatusType.DISABLED); + SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, ActivationStatusType.DISABLED); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( - "mapping-path-enum.xml", - TEST_NAME, "costCenter", delta); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = + evaluator.createMapping("mapping-path-enum.xml", shortTestName, "costCenter", delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN System.out.println("WHEN"); @@ -616,8 +575,8 @@ public void testPathEnum() throws Exception { System.out.println("\nOutput triple"); System.out.println(outputTriple.debugDump(1)); PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTriplePlus(outputTriple, ActivationStatusType.DISABLED.value()); - PrismAsserts.assertTripleMinus(outputTriple, ActivationStatusType.ENABLED.value()); + PrismAsserts.assertTriplePlus(outputTriple, ActivationStatusType.DISABLED.value()); + PrismAsserts.assertTripleMinus(outputTriple, ActivationStatusType.ENABLED.value()); } @Test @@ -638,15 +597,15 @@ public void testEmployeeNumberString() throws Exception { @Test public void testEmployeeNumberPolyString() throws Exception { - final String TEST_NAME = "testEmployeeNumberPolyString"; - displayTestTitle(TEST_NAME); // WHEN - PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMappingDynamicReplace( - "mapping-script-system-variables-employee-number.xml", - TEST_NAME, - "additionalName", // target - "employeeNumber", // changed property - "666"); // changed values + String shortTestName = getTestNameShort(); + PrismValueDeltaSetTriple> outputTriple = + evaluator.evaluateMappingDynamicReplace( + "mapping-script-system-variables-employee-number.xml", + shortTestName, + "additionalName", // target + "employeeNumber", // changed property + "666"); // changed values // THEN PrismAsserts.assertTripleNoZero(outputTriple); @@ -655,7 +614,7 @@ public void testEmployeeNumberPolyString() throws Exception { // Make sure it is recomputed PolyString plusval = outputTriple.getPlusSet().iterator().next().getValue(); - System.out.println("Plus polystring\n"+ plusval.debugDump()); + System.out.println("Plus polystring\n" + plusval.debugDump()); assertEquals("Wrong norm value", "666", plusval.getNorm()); } @@ -744,10 +703,10 @@ public void testEmployeeNumberProtectedString() throws Exception { public void testEmployeeTypeDeltaAreplaceB() throws Exception { // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() - .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, - UserType.F_EMPLOYEE_TYPE, "B"); + .createModificationReplaceProperty( + UserType.class, evaluator.USER_OLD_OID, UserType.F_EMPLOYEE_TYPE, "B"); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-script-system-variables-employee-type.xml", getTestNameShort(), "employeeType", delta); @@ -764,18 +723,18 @@ public void testEmployeeTypeDeltaAreplaceB() throws Exception { evaluator.assertResult(opResult); PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTriplePlus(outputTriple, "B"); - PrismAsserts.assertTripleMinus(outputTriple, "A"); + PrismAsserts.assertTriplePlus(outputTriple, "B"); + PrismAsserts.assertTripleMinus(outputTriple, "A"); } @Test public void testEmployeeTypeDeltaNullreplaceB() throws Exception { // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() - .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, - UserType.F_EMPLOYEE_TYPE, "B"); + .createModificationReplaceProperty( + UserType.class, evaluator.USER_OLD_OID, UserType.F_EMPLOYEE_TYPE, "B"); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-script-system-variables-employee-type.xml", getTestNameShort(), "employeeType", delta); @@ -792,18 +751,18 @@ public void testEmployeeTypeDeltaNullreplaceB() throws Exception { evaluator.assertResult(opResult); PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTriplePlus(outputTriple, "B"); - PrismAsserts.assertTripleNoMinus(outputTriple); + PrismAsserts.assertTriplePlus(outputTriple, "B"); + PrismAsserts.assertTripleNoMinus(outputTriple); } @Test public void testEmployeeTypeDeltaBreplaceB() throws Exception { // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() - .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, - UserType.F_EMPLOYEE_TYPE, "B"); + .createModificationReplaceProperty( + UserType.class, evaluator.USER_OLD_OID, UserType.F_EMPLOYEE_TYPE, "B"); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-script-system-variables-employee-type.xml", getTestNameShort(), "employeeType", delta); @@ -820,8 +779,8 @@ public void testEmployeeTypeDeltaBreplaceB() throws Exception { evaluator.assertResult(opResult); PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTriplePlus(outputTriple, "B"); - PrismAsserts.assertTripleNoMinus(outputTriple); + PrismAsserts.assertTriplePlus(outputTriple, "B"); + PrismAsserts.assertTripleNoMinus(outputTriple); } @Test @@ -832,8 +791,8 @@ public void testEmployeeTypeDeltaAaddB() throws Exception { // THEN PrismAsserts.assertTripleZero(outputTriple, "A"); - PrismAsserts.assertTriplePlus(outputTriple, "B"); - PrismAsserts.assertTripleNoMinus(outputTriple); + PrismAsserts.assertTriplePlus(outputTriple, "B"); + PrismAsserts.assertTripleNoMinus(outputTriple); } @Test @@ -844,8 +803,8 @@ public void testEmployeeTypeDeltaABaddB() throws Exception { // THEN PrismAsserts.assertTripleZero(outputTriple, "A"); - PrismAsserts.assertTriplePlus(outputTriple, "B"); - PrismAsserts.assertTripleNoMinus(outputTriple); + PrismAsserts.assertTriplePlus(outputTriple, "B"); + PrismAsserts.assertTripleNoMinus(outputTriple); } @Test @@ -856,8 +815,8 @@ public void testEmployeeTypeDeltaBaddB() throws Exception { // THEN PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTriplePlus(outputTriple, "B"); - PrismAsserts.assertTripleNoMinus(outputTriple); + PrismAsserts.assertTriplePlus(outputTriple, "B"); + PrismAsserts.assertTripleNoMinus(outputTriple); } @Test @@ -868,18 +827,18 @@ public void testEmployeeTypeDeltaNulladdB() throws Exception { // THEN PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTriplePlus(outputTriple, "B"); - PrismAsserts.assertTripleNoMinus(outputTriple); + PrismAsserts.assertTriplePlus(outputTriple, "B"); + PrismAsserts.assertTripleNoMinus(outputTriple); } public PrismValueDeltaSetTriple> employeeTypeDeltaABAdd( String addVal, String... oldVals) throws Exception { // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() - .createModificationAddProperty(UserType.class, evaluator.USER_OLD_OID, - UserType.F_EMPLOYEE_TYPE, addVal); + .createModificationAddProperty( + UserType.class, evaluator.USER_OLD_OID, UserType.F_EMPLOYEE_TYPE, addVal); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-script-system-variables-employee-type.xml", getTestNameShort(), "employeeType", delta); @@ -899,7 +858,7 @@ public PrismValueDeltaSetTriple> employeeTypeDeltaABA private void setEmployeeType(UserType userType, String... vals) { userType.getEmployeeType().clear(); - for (String val: vals) { + for (String val : vals) { userType.getEmployeeType().add(val); } } @@ -912,8 +871,8 @@ public void testEmployeeTypeDeltaBdeleteB() throws Exception { // THEN PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTripleNoPlus(outputTriple); - PrismAsserts.assertTripleMinus(outputTriple, "B"); + PrismAsserts.assertTripleNoPlus(outputTriple); + PrismAsserts.assertTripleMinus(outputTriple, "B"); } @Test @@ -924,8 +883,8 @@ public void testEmployeeTypeDeltaABdeleteB() throws Exception { // THEN PrismAsserts.assertTripleZero(outputTriple, "A"); - PrismAsserts.assertTripleNoPlus(outputTriple); - PrismAsserts.assertTripleMinus(outputTriple, "B"); + PrismAsserts.assertTripleNoPlus(outputTriple); + PrismAsserts.assertTripleMinus(outputTriple, "B"); } @Test @@ -936,8 +895,8 @@ public void testEmployeeTypeDeltaAdeleteB() throws Exception { // THEN PrismAsserts.assertTripleZero(outputTriple, "A"); - PrismAsserts.assertTripleNoPlus(outputTriple); - PrismAsserts.assertTripleMinus(outputTriple, "B"); + PrismAsserts.assertTripleNoPlus(outputTriple); + PrismAsserts.assertTripleMinus(outputTriple, "B"); } @Test @@ -948,18 +907,18 @@ public void testEmployeeTypeDeltaNulldeleteB() throws Exception { // THEN PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTripleNoPlus(outputTriple); - PrismAsserts.assertTripleMinus(outputTriple, "B"); + PrismAsserts.assertTripleNoPlus(outputTriple); + PrismAsserts.assertTripleMinus(outputTriple, "B"); } public PrismValueDeltaSetTriple> employeeTypeDeltaDelete( String delVal, String... oldVals) throws Exception { // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() - .createModificationDeleteProperty(UserType.class, evaluator.USER_OLD_OID, - UserType.F_EMPLOYEE_TYPE, delVal); + .createModificationDeleteProperty( + UserType.class, evaluator.USER_OLD_OID, UserType.F_EMPLOYEE_TYPE, delVal); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-script-system-variables-employee-type.xml", getTestNameShort(), "employeeType", delta); diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingTime.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingTime.java index 4232dc62dd9..5028dbed3c7 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingTime.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingTime.java @@ -31,6 +31,7 @@ import com.evolveum.midpoint.prism.xml.XmlTypeConverter; import com.evolveum.midpoint.schema.constants.ExpressionConstants; import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType; @@ -39,7 +40,7 @@ /** * @author Radovan Semancik */ -public class TestMappingTime { +public class TestMappingTime extends AbstractUnitTest { private static final String MAPPING_TIME_FROM_TO_FILENAME = "mapping-time-from-to.xml"; private static final String MAPPING_TIME_ACTIVATION = "mapping-time-deferred-delete.xml"; @@ -75,7 +76,7 @@ public void testBeforeTimeFrom() throws Exception { MappingImpl,PrismPropertyDefinition> mapping = builder.build(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(contextName()); // WHEN mapping.evaluate(createTask(), opResult); @@ -107,7 +108,7 @@ public void testBetweenTimes() throws Exception { MappingImpl,PrismPropertyDefinition> mapping = builder.build(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(contextName()); // WHEN mapping.evaluate(createTask(), opResult); @@ -138,7 +139,7 @@ public void testAfterTimeTo() throws Exception { MappingImpl,PrismPropertyDefinition> mapping = builder.build(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(contextName()); // WHEN mapping.evaluate(createTask(), opResult); @@ -168,7 +169,7 @@ public void testExistenceBefore() throws Exception { MappingImpl,PrismPropertyDefinition> mapping = builder.build(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(contextName()); // WHEN mapping.evaluate(createTask(), opResult); @@ -198,7 +199,7 @@ public void testExistenceAfter() throws Exception { MappingImpl,PrismPropertyDefinition> mapping = builder.build(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(contextName()); // WHEN mapping.evaluate(createTask(), opResult); @@ -234,7 +235,7 @@ public void testNoReferenceTime() throws Exception { MappingImpl,PrismPropertyDefinition> mapping = builder.build(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(contextName()); // WHEN mapping.evaluate(createTask(), opResult); @@ -274,7 +275,7 @@ public void testSetReferenceTimeBefore() throws Exception { MappingImpl,PrismPropertyDefinition> mapping = builder.build(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(contextName()); // WHEN mapping.evaluate(createTask(), opResult); @@ -313,7 +314,7 @@ public void testSetReferenceTimeAfter() throws Exception { MappingImpl,PrismPropertyDefinition> mapping = builder.build(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(contextName()); // WHEN mapping.evaluate(createTask(), opResult); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/TestFilterResolver.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/TestFilterResolver.java index 9ed8689f1c7..275cf01a12f 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/TestFilterResolver.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/TestFilterResolver.java @@ -21,7 +21,6 @@ import com.evolveum.midpoint.prism.PrismContainer; import com.evolveum.midpoint.prism.PrismContainerValue; import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDefinitionType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDependencyType; @@ -39,9 +38,6 @@ public class TestFilterResolver extends AbstractInternalModelIntegrationTest { @Test public void test001resolveDependencyFilter() throws Exception { - final String TEST_NAME = "test001resolveDependencyFilter"; - TestUtil.displayTestTitle(this, TEST_NAME); - // WHEN importObjectFromFile(RESOURCE_DUMMY_DEPENDENCY_FILTER_FILE); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/TestRefinedSchema.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/TestRefinedSchema.java index 473ea8371d3..2c491503749 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/TestRefinedSchema.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/TestRefinedSchema.java @@ -24,7 +24,6 @@ import com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.LayerType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType; @@ -61,9 +60,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; - TestUtil.displayTestTitle(this, TEST_NAME); - // WHEN refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(getDummyResourceType(), prismContext); @@ -75,9 +71,6 @@ public void test000Sanity() throws Exception { @Test public void test010SanityModel() throws Exception { - final String TEST_NAME = "test010SanityModel"; - TestUtil.displayTestTitle(this, TEST_NAME); - // WHEN refinedSchemaModel = RefinedResourceSchemaImpl.getRefinedSchema(getDummyResourceType(), LayerType.MODEL, prismContext); @@ -92,9 +85,6 @@ public void test010SanityModel() throws Exception { @Test public void test100EntitlementRefinedObjectClasses() { - final String TEST_NAME = "test100EntitlementRefinedObjectClasses"; - TestUtil.displayTestTitle(this, TEST_NAME); - // WHEN Collection entitlementROcDefs = refinedSchema.getRefinedDefinitions(ShadowKindType.ENTITLEMENT); @@ -110,9 +100,6 @@ public void test100EntitlementRefinedObjectClasses() { @Test public void test101EntitlementRefinedObjectClassesModel() { - final String TEST_NAME = "test101EntitlementRefinedObjectClassesModel"; - TestUtil.displayTestTitle(this, TEST_NAME); - // WHEN Collection entitlementROcDefs = refinedSchemaModel.getRefinedDefinitions(ShadowKindType.ENTITLEMENT); @@ -128,10 +115,7 @@ public void test101EntitlementRefinedObjectClassesModel() { @Test public void test110DetermineObjectClassObjectClass() throws Exception { - final String TEST_NAME = "test110DetermineObjectClassObjectClass"; - TestUtil.displayTestTitle(this, TEST_NAME); - - OperationResult result = new OperationResult(TestRefinedSchema.class.getName() + "." + TEST_NAME); + OperationResult result = new OperationResult(getTestNameShort()); importObjectFromFile(TASK_RECONCILE_DUMMY_OBJECTCLASS_FILE); @@ -151,10 +135,7 @@ public void test110DetermineObjectClassObjectClass() throws Exception { @Test public void test112DetermineObjectClassKindIntent() throws Exception { - final String TEST_NAME = "test112DetermineObjectClassKindIntent"; - TestUtil.displayTestTitle(this, TEST_NAME); - - OperationResult result = new OperationResult(TestRefinedSchema.class.getName() + "." + TEST_NAME); + OperationResult result = new OperationResult(getTestNameShort()); importObjectFromFile(TASK_RECONCILE_DUMMY_KIND_INTENT_FILE); @@ -174,10 +155,7 @@ public void test112DetermineObjectClassKindIntent() throws Exception { @Test public void test114DetermineObjectClassKindIntentObjectClass() throws Exception { - final String TEST_NAME = "test114DetermineObjectClassKindIntentObjectClass"; - TestUtil.displayTestTitle(this, TEST_NAME); - - OperationResult result = new OperationResult(TestRefinedSchema.class.getName() + "." + TEST_NAME); + OperationResult result = new OperationResult(getTestNameShort()); importObjectFromFile(TASK_RECONCILE_DUMMY_KIND_INTENT_OBJECTCLASS_FILE); @@ -197,10 +175,7 @@ public void test114DetermineObjectClassKindIntentObjectClass() throws Exception @Test public void test120DetermineObjectClassObjectClassModel() throws Exception { - final String TEST_NAME = "test120DetermineObjectClassObjectClassModel"; - TestUtil.displayTestTitle(this, TEST_NAME); - - OperationResult result = new OperationResult(TestRefinedSchema.class.getName() + "." + TEST_NAME); + OperationResult result = new OperationResult(getTestNameShort()); importObjectFromFile(TASK_RECONCILE_DUMMY_OBJECTCLASS_FILE); @@ -221,10 +196,7 @@ public void test120DetermineObjectClassObjectClassModel() throws Exception { @Test public void test122DetermineObjectClassKindIntentModel() throws Exception { - final String TEST_NAME = "test122DetermineObjectClassKindIntentModel"; - TestUtil.displayTestTitle(this, TEST_NAME); - - OperationResult result = new OperationResult(TestRefinedSchema.class.getName() + "." + TEST_NAME); + OperationResult result = new OperationResult(getTestNameShort()); importObjectFromFile(TASK_RECONCILE_DUMMY_KIND_INTENT_FILE); @@ -246,10 +218,7 @@ public void test122DetermineObjectClassKindIntentModel() throws Exception { @Test public void test124DetermineObjectClassKindIntentObjectClassModel() throws Exception { - final String TEST_NAME = "test124DetermineObjectClassKindIntentObjectClassModel"; - TestUtil.displayTestTitle(this, TEST_NAME); - - OperationResult result = new OperationResult(TestRefinedSchema.class.getName() + "." + TEST_NAME); + OperationResult result = new OperationResult(getTestNameShort()); importObjectFromFile(TASK_RECONCILE_DUMMY_KIND_INTENT_OBJECTCLASS_FILE); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/expr/TestFilterExpression.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/expr/TestFilterExpression.java index e3f7c926cab..ca2822ae06c 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/expr/TestFilterExpression.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/expr/TestFilterExpression.java @@ -46,7 +46,6 @@ import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.task.api.TaskManager; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.CommunicationException; import com.evolveum.midpoint.util.exception.ConfigurationException; @@ -99,12 +98,9 @@ public void test110EvaluateExpressionEmployeeTypeNoneFilter() throws Exception { @Test public void test120EvaluateExpressionEmployeeTypeAllFilter() throws Exception { - final String TEST_NAME = "testEvaluateExpressionEmployeeTypeAllFilter"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestFilterExpression.class.getName() + "." + TEST_NAME); - Task task = taskManager.createTaskInstance(TEST_NAME); + Task task = getTestTask(); + OperationResult result = task.getResult(); ObjectFilter filter = evaluateExpressionAssertFilter("expression-employeeType-all-filter.xml", null, AllFilter.class, task, result); @@ -114,12 +110,9 @@ public void test120EvaluateExpressionEmployeeTypeAllFilter() throws Exception { @Test public void test130EvaluateExpressionEmployeeTypeError() throws Exception { - final String TEST_NAME = "testEvaluateExpressionEmployeeTypeError"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestFilterExpression.class.getName() + "." + TEST_NAME); - Task task = taskManager.createTaskInstance(TEST_NAME); + Task task = getTestTask(); + OperationResult result = task.getResult(); try { evaluateExpressionAssertFilter("expression-employeeType-error.xml", @@ -134,12 +127,9 @@ public void test130EvaluateExpressionEmployeeTypeError() throws Exception { @Test public void test140EvaluateExpressionEmployeeTypeEmptyFilter() throws Exception { - final String TEST_NAME = "testEvaluateExpressionEmployeeTypeEmptyFilter"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestFilterExpression.class.getName() + "." + TEST_NAME); - Task task = taskManager.createTaskInstance(TEST_NAME); + Task task = getTestTask(); + OperationResult result = task.getResult(); ObjectFilter filter = evaluateExpressionAssertFilter("expression-employeeType-empty-filter.xml", null, EqualFilter.class, task, result); @@ -152,13 +142,9 @@ public void test140EvaluateExpressionEmployeeTypeEmptyFilter() throws Exception @Test public void test150EvaluateExpressionEmployeeTypeDefaultsNull() throws Exception { - final String TEST_NAME = "test150EvaluateExpressionEmployeeTypeDefaultsNull"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestFilterExpression.class.getName() + "." + TEST_NAME); - Task task = taskManager.createTaskInstance(TEST_NAME); - + Task task = getTestTask(); + OperationResult result = task.getResult(); ObjectFilter filter = evaluateExpressionAssertFilter("expression-employeeType-filter-defaults.xml", null, EqualFilter.class, task, result); @@ -171,12 +157,9 @@ public void test150EvaluateExpressionEmployeeTypeDefaultsNull() throws Exception @Test public void test152EvaluateExpressionEmployeeTypeDefaultsCaptain() throws Exception { - final String TEST_NAME = "test152EvaluateExpressionEmployeeTypeDefaultsCaptain"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestFilterExpression.class.getName() + "." + TEST_NAME); - Task task = taskManager.createTaskInstance(TEST_NAME); + Task task = getTestTask(); + OperationResult result = task.getResult(); ObjectFilter filter = evaluateExpressionAssertFilter("expression-employeeType-filter-defaults.xml", "CAPTAIN", EqualFilter.class, task, result); @@ -190,12 +173,9 @@ public void test152EvaluateExpressionEmployeeTypeDefaultsCaptain() throws Except @Test public void test200EvaluateExpressionLinkRefDefaultsNull() throws Exception { - final String TEST_NAME = "test200EvaluateExpressionLinkRefDefaultsNull"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestFilterExpression.class.getName() + "." + TEST_NAME); - Task task = taskManager.createTaskInstance(TEST_NAME); + Task task = getTestTask(); + OperationResult result = task.getResult(); ObjectFilter filter = evaluateExpressionAssertFilter("expression-linkref-filter-defaults.xml", null, RefFilter.class, task, result); @@ -208,12 +188,9 @@ public void test200EvaluateExpressionLinkRefDefaultsNull() throws Exception { @Test public void test202EvaluateExpressionLinkRefObjectReferenceTypeDefaultsNull() throws Exception { - final String TEST_NAME = "test202EvaluateExpressionLinkRefObjectReferenceTypeDefaultsNull"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestFilterExpression.class.getName() + "." + TEST_NAME); - Task task = taskManager.createTaskInstance(TEST_NAME); + Task task = getTestTask(); + OperationResult result = task.getResult(); ObjectFilter filter = evaluateExpressionAssertFilter("expression-linkref-object-reference-type-filter-defaults.xml", null, RefFilter.class, task, result); @@ -226,12 +203,9 @@ public void test202EvaluateExpressionLinkRefObjectReferenceTypeDefaultsNull() th @Test public void test210EvaluateExpressionLinkRefDefaultsVal() throws Exception { - final String TEST_NAME = "test210EvaluateExpressionLinkRefDefaultsVal"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestFilterExpression.class.getName() + "." + TEST_NAME); - Task task = taskManager.createTaskInstance(TEST_NAME); + Task task = getTestTask(); + OperationResult result = task.getResult(); ObjectFilter filter = evaluateExpressionAssertFilter("expression-linkref-filter-defaults.xml", ACCOUNT_SHADOW_GUYBRUSH_OID, RefFilter.class, task, result); @@ -244,12 +218,9 @@ public void test210EvaluateExpressionLinkRefDefaultsVal() throws Exception { @Test public void test212EvaluateExpressionLinkRefObjectReferenceTypeDefaultsVal() throws Exception { - final String TEST_NAME = "test212EvaluateExpressionLinkRefObjectReferenceTypeDefaultsVal"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestFilterExpression.class.getName() + "." + TEST_NAME); - Task task = taskManager.createTaskInstance(TEST_NAME); + Task task = getTestTask(); + OperationResult result = task.getResult(); ObjectFilter filter = evaluateExpressionAssertFilter("expression-linkref-object-reference-type-filter-defaults.xml", ACCOUNT_SHADOW_GUYBRUSH_OID, RefFilter.class, task, result); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/expr/TestModelExpressions.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/expr/TestModelExpressions.java index e6b340cd890..1d0a16d37e9 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/expr/TestModelExpressions.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/expr/TestModelExpressions.java @@ -6,17 +6,16 @@ */ package com.evolveum.midpoint.model.impl.expr; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; import static org.testng.AssertJUnit.assertEquals; +import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; + import java.io.File; import java.io.IOException; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; - -import javax.xml.bind.JAXBException; import javax.xml.namespace.QName; import org.springframework.beans.factory.annotation.Autowired; @@ -48,23 +47,14 @@ import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SecurityViolationException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; +import com.evolveum.midpoint.util.exception.*; import com.evolveum.midpoint.xml.ns._public.common.common_3.ScriptExpressionEvaluatorType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; /** - * * @author lazyman * @author mederly * @author semancik - * */ @ContextConfiguration(locations = { "classpath:ctx-model-test-main.xml" }) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) @@ -74,8 +64,6 @@ public class TestModelExpressions extends AbstractInternalModelIntegrationTest { private static final QName PROPERTY_NAME = new QName(SchemaConstants.NS_C, "foo"); - private static final Trace LOGGER = TraceManager.getTrace(TestModelExpressions.class); - private static final String CHEF_OID = "00000003-0000-0000-0000-000000000000"; private static final String CHEESE_OID = "00000002-0000-0000-0000-000000000000"; private static final String CHEESE_JR_OID = "00000002-0000-0000-0000-000000000001"; @@ -83,11 +71,11 @@ public class TestModelExpressions extends AbstractInternalModelIntegrationTest { private static final String LECHUCK_OID = "00000007-0000-0000-0000-000000000000"; private static final String F0006_OID = "00000000-8888-6666-0000-100000000006"; - @Autowired(required=true) + @Autowired private ScriptExpressionFactory scriptExpressionFactory; @Autowired private ExpressionFactory expressionFactory; - @Autowired(required = true) + @Autowired private TaskManager taskManager; private static final File TEST_EXPRESSIONS_OBJECTS_FILE = new File(TEST_DIR, "orgstruct.xml"); @@ -107,13 +95,10 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void testHello() throws Exception { - final String TEST_NAME = "testHello"; - TestUtil.displayTestTitle(this, TEST_NAME); - - assertExecuteScriptExpressionString(TEST_NAME, null, "Hello swashbuckler"); + assertExecuteScriptExpressionString(null, "Hello swashbuckler"); } - private ScriptExpressionEvaluatorType parseScriptType(String fileName) throws SchemaException, IOException, JAXBException { + private ScriptExpressionEvaluatorType parseScriptType(String fileName) throws SchemaException, IOException { ScriptExpressionEvaluatorType expressionType = PrismTestUtil.parseAtomicValue( new File(TEST_DIR, fileName), ScriptExpressionEvaluatorType.COMPLEX_TYPE); return expressionType; @@ -122,7 +107,6 @@ private ScriptExpressionEvaluatorType parseScriptType(String fileName) throws Sc @Test public void testGetUserByOid() throws Exception { final String TEST_NAME = "testGetUserByOid"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestModelExpressions.class.getName() + "." + TEST_NAME); @@ -131,28 +115,31 @@ public void testGetUserByOid() throws Exception { ExpressionVariables variables = createVariables(ExpressionConstants.VAR_USER, chef, chef.getDefinition()); // WHEN, THEN - assertExecuteScriptExpressionString(TEST_NAME, variables, chef.asObjectable().getName().getOrig()); + assertExecuteScriptExpressionString(variables, chef.asObjectable().getName().getOrig()); } @Test public void testGetManagersOids() throws Exception { - final String TEST_NAME = "testGetManagersOids"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TEST_NAME); - OperationResult result = new OperationResult(TestModelExpressions.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); + OperationResult result = createResult(); + String shortTestName = getTestNameShort(); PrismObject chef = repositoryService.getObject(UserType.class, CHEF_OID, null, result); - ScriptExpressionEvaluatorType scriptType = parseScriptType("expression-" + TEST_NAME + ".xml"); - PrismPropertyDefinition outputDefinition = getPrismContext().definitionFactory().createPropertyDefinition(PROPERTY_NAME, DOMUtil.XSD_STRING); - ScriptExpression scriptExpression = scriptExpressionFactory.createScriptExpression(scriptType, outputDefinition, - MiscSchemaUtil.getExpressionProfile(), expressionFactory, TEST_NAME, task, result); - ExpressionVariables variables = createVariables(ExpressionConstants.VAR_USER, chef, chef.getDefinition()); + ScriptExpressionEvaluatorType scriptType = parseScriptType("expression-" + shortTestName + ".xml"); + PrismPropertyDefinition outputDefinition = + getPrismContext().definitionFactory().createPropertyDefinition( + PROPERTY_NAME, DOMUtil.XSD_STRING); + ScriptExpression scriptExpression = scriptExpressionFactory.createScriptExpression( + scriptType, outputDefinition, MiscSchemaUtil.getExpressionProfile(), + expressionFactory, shortTestName, task, result); + ExpressionVariables variables = + createVariables(ExpressionConstants.VAR_USER, chef, chef.getDefinition()); // WHEN - List> scriptOutputs = evaluate(scriptExpression, variables, false, TEST_NAME, null, result); + List> scriptOutputs = + evaluate(scriptExpression, variables, false, shortTestName, null, result); // THEN display("Script output", scriptOutputs); @@ -161,7 +148,7 @@ public void testGetManagersOids() throws Exception { oids.add(scriptOutputs.get(0).getValue()); oids.add(scriptOutputs.get(1).getValue()); oids.add(scriptOutputs.get(2).getValue()); - Set expectedOids = new HashSet<>(Arrays.asList(new String[]{CHEESE_OID, CHEESE_JR_OID, LECHUCK_OID})); + Set expectedOids = new HashSet<>(Arrays.asList(new String[] { CHEESE_OID, CHEESE_JR_OID, LECHUCK_OID })); assertEquals("Unexpected script output", expectedOids, oids); } @@ -171,7 +158,6 @@ public void testGetManagersOids() throws Exception { @Test public void testIsUniquePropertyValue() throws Exception { final String TEST_NAME = "testIsUniquePropertyValue"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TEST_NAME); @@ -201,14 +187,12 @@ public void testIsUniquePropertyValue() throws Exception { @Test public void testGetOrgByName() throws Exception { final String TEST_NAME = "testGetOrgByName"; - TestUtil.displayTestTitle(this, TEST_NAME); - assertExecuteScriptExpressionString(TEST_NAME, null, F0006_OID); + assertExecuteScriptExpressionString(null, F0006_OID); } @Test public void testGetLinkedShadowName() throws Exception { final String TEST_NAME = "testGetLinkedShadowName"; - TestUtil.displayTestTitle(this, TEST_NAME); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); @@ -216,7 +200,7 @@ public void testGetLinkedShadowName() throws Exception { ExpressionVariables variables = createVariables( ExpressionConstants.VAR_USER, user, user.getDefinition()); - assertExecuteScriptExpressionString(TEST_NAME, variables, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); + assertExecuteScriptExpressionString(variables, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1); } @@ -224,7 +208,6 @@ public void testGetLinkedShadowName() throws Exception { @Test public void testGetLinkedShadowKindIntentUsername() throws Exception { final String TEST_NAME = "testGetLinkedShadowKindIntentUsername"; - TestUtil.displayTestTitle(this, TEST_NAME); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); @@ -232,7 +215,7 @@ public void testGetLinkedShadowKindIntentUsername() throws Exception { ExpressionVariables variables = createVariables( ExpressionConstants.VAR_USER, user, user.getDefinition()); - assertExecuteScriptExpressionString(TEST_NAME, variables, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); + assertExecuteScriptExpressionString(variables, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1); } @@ -240,7 +223,6 @@ public void testGetLinkedShadowKindIntentUsername() throws Exception { @Test public void testGetLinkedShadowKindIntentFullname() throws Exception { final String TEST_NAME = "testGetLinkedShadowKindIntentFullname"; - TestUtil.displayTestTitle(this, TEST_NAME); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); @@ -248,7 +230,7 @@ public void testGetLinkedShadowKindIntentFullname() throws Exception { ExpressionVariables variables = createVariables( ExpressionConstants.VAR_USER, user, user.getDefinition()); - assertExecuteScriptExpressionString(TEST_NAME, variables, ACCOUNT_GUYBRUSH_DUMMY_FULLNAME); + assertExecuteScriptExpressionString(variables, ACCOUNT_GUYBRUSH_DUMMY_FULLNAME); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1); } @@ -256,7 +238,6 @@ public void testGetLinkedShadowKindIntentFullname() throws Exception { @Test public void testGetLinkedShadowNameRepo() throws Exception { final String TEST_NAME = "testGetLinkedShadowNameRepo"; - TestUtil.displayTestTitle(this, TEST_NAME); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); @@ -264,7 +245,7 @@ public void testGetLinkedShadowNameRepo() throws Exception { ExpressionVariables variables = createVariables( ExpressionConstants.VAR_USER, user, user.getDefinition()); - assertExecuteScriptExpressionString(TEST_NAME, variables, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); + assertExecuteScriptExpressionString(variables, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); } @@ -272,7 +253,6 @@ public void testGetLinkedShadowNameRepo() throws Exception { @Test public void testGetLinkedShadowKindIntentUsernameRepo() throws Exception { final String TEST_NAME = "testGetLinkedShadowKindIntentUsernameRepo"; - TestUtil.displayTestTitle(this, TEST_NAME); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); @@ -280,7 +260,7 @@ public void testGetLinkedShadowKindIntentUsernameRepo() throws Exception { ExpressionVariables variables = createVariables( ExpressionConstants.VAR_USER, user, user.getDefinition()); - assertExecuteScriptExpressionString(TEST_NAME, variables, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); + assertExecuteScriptExpressionString(variables, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); } @@ -288,7 +268,6 @@ public void testGetLinkedShadowKindIntentUsernameRepo() throws Exception { @Test public void testGetLinkedShadowKindIntentFullnameRepo() throws Exception { final String TEST_NAME = "testGetLinkedShadowKindIntentFullnameRepo"; - TestUtil.displayTestTitle(this, TEST_NAME); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); @@ -296,36 +275,44 @@ public void testGetLinkedShadowKindIntentFullnameRepo() throws Exception { ExpressionVariables variables = createVariables( ExpressionConstants.VAR_USER, user, user.getDefinition()); - assertExecuteScriptExpressionString(TEST_NAME, variables, null); + assertExecuteScriptExpressionString(variables, null); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); } - - private void assertExecuteScriptExpressionString(final String TEST_NAME, ExpressionVariables variables, String expectedOutput) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, IOException, JAXBException, CommunicationException, ConfigurationException, SecurityViolationException { - String output = executeScriptExpressionString(TEST_NAME, variables); + private void assertExecuteScriptExpressionString( + ExpressionVariables variables, String expectedOutput) + throws ConfigurationException, ExpressionEvaluationException, ObjectNotFoundException, + IOException, CommunicationException, SchemaException, SecurityViolationException { + String output = executeScriptExpressionString(variables); assertEquals("Unexpected script output", expectedOutput, output); } - private String executeScriptExpressionString(final String TEST_NAME, ExpressionVariables variables) throws SchemaException, IOException, JAXBException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException { + private String executeScriptExpressionString(ExpressionVariables variables) + throws SecurityViolationException, ExpressionEvaluationException, SchemaException, + ObjectNotFoundException, CommunicationException, ConfigurationException, IOException { // GIVEN - Task task = taskManager.createTaskInstance(TEST_NAME); - OperationResult result = new OperationResult(TestModelExpressions.class.getName() + "." + TEST_NAME); - - ScriptExpressionEvaluatorType scriptType = parseScriptType("expression-" + TEST_NAME + ".xml"); - ItemDefinition outputDefinition = getPrismContext().definitionFactory().createPropertyDefinition(PROPERTY_NAME, DOMUtil.XSD_STRING); - ScriptExpression scriptExpression = scriptExpressionFactory.createScriptExpression(scriptType, outputDefinition, - MiscSchemaUtil.getExpressionProfile(), expressionFactory, TEST_NAME, task, result); + Task task = createPlainTask("executeScriptExpressionString"); + OperationResult result = createResult(); + String shortTestName = getTestNameShort(); + + ScriptExpressionEvaluatorType scriptType = parseScriptType("expression-" + shortTestName + ".xml"); + ItemDefinition outputDefinition = + getPrismContext().definitionFactory().createPropertyDefinition( + PROPERTY_NAME, DOMUtil.XSD_STRING); + ScriptExpression scriptExpression = scriptExpressionFactory.createScriptExpression( + scriptType, outputDefinition, MiscSchemaUtil.getExpressionProfile(), + expressionFactory, shortTestName, task, result); if (variables == null) { variables = new ExpressionVariables(); } // WHEN when(); - List> scriptOutputs = evaluate(scriptExpression, variables, false, TEST_NAME, null, result); + List> scriptOutputs = evaluate(scriptExpression, variables, false, shortTestName, null, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("Script output", scriptOutputs); result.computeStatus(); TestUtil.assertSuccess(result); @@ -344,7 +331,7 @@ private String executeScriptExpressionString(final String TEST_NAME, ExpressionV } private List> evaluate(ScriptExpression scriptExpression, ExpressionVariables variables, boolean useNew, - String contextDescription, Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException { + String contextDescription, Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException { if (task == null) { task = taskManager.createTaskInstance(); } diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignedMappings.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignedMappings.java index c39fc150e5a..b4fbc6ba597 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignedMappings.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignedMappings.java @@ -16,7 +16,6 @@ import com.evolveum.midpoint.test.TestResource; import com.evolveum.midpoint.test.asserter.UserAsserter; import com.evolveum.midpoint.test.util.MidPointTestConstants; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.ItemPathType; import org.springframework.beans.factory.annotation.Autowired; @@ -142,7 +141,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100AssignSimpleToJim() throws Exception { final String TEST_NAME = "test100AssignSimpleToJim"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN TestAssignedMappings.class.getName(); @@ -190,7 +188,6 @@ public void test100AssignSimpleToJim() throws Exception { @Test public void test110AssignRingToFrodo() throws Exception { final String TEST_NAME = "test110AssignRingToFrodo"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN TestAssignedMappings.class.getName(); @@ -241,7 +238,6 @@ public void test110AssignRingToFrodo() throws Exception { @Test public void test120AssignStingToFrodo() throws Exception { final String TEST_NAME = "test120AssignStingToFrodo"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN TestAssignedMappings.class.getName(); @@ -291,7 +287,6 @@ public void test120AssignStingToFrodo() throws Exception { @Test public void test130UnassignRingFromFrodo() throws Exception { final String TEST_NAME = "test130UnassignRingFromFrodo"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN TestAssignedMappings.class.getName(); @@ -348,7 +343,6 @@ public void test130UnassignRingFromFrodo() throws Exception { @Test public void test200AssignRolesToAdam() throws Exception { final String TEST_NAME = "test200AssignRolesToAdam"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN TestAssignedMappings.class.getName(); @@ -407,7 +401,6 @@ public void test200AssignRolesToAdam() throws Exception { @Test public void test210AssignRolesToBenjamin() throws Exception { final String TEST_NAME = "test210AssignRolesToBenjamin"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN TestAssignedMappings.class.getName(); @@ -493,7 +486,6 @@ public void test210AssignRolesToBenjamin() throws Exception { @Test public void test220AdamConditionFalseToTrue() throws Exception { final String TEST_NAME = "test220AdamConditionFalseToTrue"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN TestAssignedMappings.class.getName(); @@ -573,7 +565,6 @@ public void test220AdamConditionFalseToTrue() throws Exception { @Test public void test230BenjaminConditionTrueToFalse() throws Exception { final String TEST_NAME = "test230BenjaminConditionTrueToFalse"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN TestAssignedMappings.class.getName(); @@ -608,7 +599,6 @@ public void test230BenjaminConditionTrueToFalse() throws Exception { @Test public void test280UnassignRolesFromAdam() throws Exception { final String TEST_NAME = "test280UnassignRolesFromAdam"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN TestAssignedMappings.class.getName(); @@ -639,7 +629,6 @@ public void test280UnassignRolesFromAdam() throws Exception { @Test public void test290UnassignRolesFromBenjamin() throws Exception { final String TEST_NAME = "test290UnassignRolesFromBenjamin"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN TestAssignedMappings.class.getName(); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor.java index aeb4ac5c7d7..2f95b98a7a4 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor.java @@ -71,7 +71,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test001OutboundEmpty() throws Exception { final String TEST_NAME = "test001OutboundEmpty"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentProcessor.class.getName() + "." + TEST_NAME); @@ -96,7 +95,6 @@ public void test001OutboundEmpty() throws Exception { @Test public void test002ModifyUser() throws Exception { final String TEST_NAME = "test002ModifyUser"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentProcessor.class.getName() + "." + TEST_NAME); @@ -159,7 +157,6 @@ public void test002ModifyUser() throws Exception { @Test public void test011AddAssignmentAddAccountDirect() throws Exception { final String TEST_NAME = "test011AddAssignmentAddAccountDirect"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentProcessor.class.getName() + "." + TEST_NAME); @@ -201,7 +198,6 @@ public void test011AddAssignmentAddAccountDirect() throws Exception { @Test public void test012AddAssignmentAddAccountDirectAssignmentWithAttrs() throws Exception { final String TEST_NAME = "test012AddAssignmentAddAccountDirectAssignmentWithAttrs"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentProcessor.class.getName() + "." + TEST_NAME); @@ -221,7 +217,7 @@ public void test012AddAssignmentAddAccountDirectAssignmentWithAttrs() throws Exc assignmentProcessor.processAssignments(context, getNow(), task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("Output context", context); display("outbound processor result", result); // assertSuccess("Outbound processor failed (result)", result); @@ -272,7 +268,6 @@ public void test012AddAssignmentAddAccountDirectAssignmentWithAttrs() throws Exc @Test public void test021AddAssignmentModifyAccountAssignment() throws Exception { final String TEST_NAME = "test021AddAssignmentModifyAccountAssignment"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentProcessor.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -451,9 +446,8 @@ public void test031DeleteAssignmentModifyAccount() throws Exception { @Test public void test032ModifyUserLegalizeAccount() throws Exception { final String TEST_NAME = "test032ModifyUserLegalizeAccount"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN + // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentProcessor.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -500,7 +494,6 @@ public void test032ModifyUserLegalizeAccount() throws Exception { @Test public void test100AddAssignmentWithConditionalMetarole() throws Exception { final String TEST_NAME = "test100AddAssignmentWithConditionalMetarole"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentProcessor.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -565,7 +558,6 @@ public void test100AddAssignmentWithConditionalMetarole() throws Exception { @Test public void test102EnableConditionalMetarole() throws Exception { final String TEST_NAME = "test102EnableConditionalMetarole"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentProcessor.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -649,7 +641,6 @@ public void test102EnableConditionalMetarole() throws Exception { @Test public void test200AssignVisitor() throws Exception { final String TEST_NAME = "test200AssignVisitor"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentProcessor.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -704,7 +695,6 @@ public void test200AssignVisitor() throws Exception { @Test public void test210AssignEngineer() throws Exception { final String TEST_NAME = "test210AssignEngineer"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentProcessor.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor2.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor2.java index e7041d79691..3998139e471 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor2.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor2.java @@ -168,7 +168,7 @@ public void test000Sanity() throws Exception { public void test010AssignR1ToJack() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); LensContext context = createContextForRoleAssignment(USER_JACK_OID, ROLE_R1_OID, null, null, result); @@ -226,7 +226,7 @@ private void processAssignments(LensContext context, OperationResult r public void test020AssignMR1ToR1() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); LensContext context = createContextForAssignment(RoleType.class, ROLE_R1_OID, RoleType.class, ROLE_MR1_OID, null, null, result); @@ -272,7 +272,7 @@ public void test020AssignMR1ToR1() throws Exception { public void test030AssignR1ToJackProjectorDisabled() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); LensContext context = createContextForRoleAssignment(USER_JACK_OID, ROLE_R1_OID, null, a -> a.setActivation(ActivationUtil.createDisabled()), result); @@ -301,7 +301,7 @@ public void test030AssignR1ToJackProjectorDisabled() throws Exception { public void test040AssignR1ToJackAsApprover() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); LensContext context = createContextForRoleAssignment(USER_JACK_OID, ROLE_R1_OID, SchemaConstants.ORG_APPROVER, null, result); @@ -355,7 +355,7 @@ public void test040AssignR1ToJackAsApprover() throws Exception { public void test050JackDeputyOfBarbossa() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); AssignmentType policyRuleAssignment = new AssignmentType(prismContext); PolicyRuleType rule = new PolicyRuleType(prismContext); @@ -434,7 +434,7 @@ public void test050JackDeputyOfBarbossa() throws Exception { public void test060JackDeputyOfGuybrushDeputyOfBarbossa() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); AssignmentType deputyOfBarbossaAssignment = ObjectTypeUtil.createAssignmentTo(USER_BARBOSSA_OID, ObjectTypes.USER, prismContext); deputyOfBarbossaAssignment.getTargetRef().setRelation(SchemaConstants.ORG_DEPUTY); @@ -498,7 +498,7 @@ public void test060JackDeputyOfGuybrushDeputyOfBarbossa() throws Exception { public void test062JackDeputyOfGuybrushDeputyOfBarbossaInLoginMode() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject jack = getUser(USER_JACK_OID); AssignmentType jackGuybrushAssignment = new AssignmentType(prismContext) @@ -585,7 +585,7 @@ public void test062JackDeputyOfGuybrushDeputyOfBarbossaInLoginMode() throws Exce public void test070JackDeputyOfBarbossaApproverOfR1() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); unassignAllRoles(USER_JACK_OID); unassignAllRoles(USER_GUYBRUSH_OID); @@ -662,7 +662,7 @@ public void test070JackDeputyOfBarbossaApproverOfR1() throws Exception { public void test100DisableSomeRoles() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN createObjectsInFirstPart(true, task, result, () -> disableRoles("MMR1 R2 MR3 R4")); @@ -676,7 +676,7 @@ public void test100DisableSomeRoles() throws Exception { public void test110AssignR1ToJack() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); LensContext context = createContextForRoleAssignment(USER_JACK_OID, ROLE_R1_OID, null, null, result); @@ -734,7 +734,7 @@ public void test110AssignR1ToJack() throws Exception { public void test150DisableSomeAssignments() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN createObjectsInFirstPart(true, task, result, () -> disableAssignments("MR4-R6 MR1-MR3 R1-R2")); @@ -746,7 +746,7 @@ public void test150DisableSomeAssignments() throws Exception { public void test160AssignR1ToJack() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); LensContext context = createContextForRoleAssignment(USER_JACK_OID, ROLE_R1_OID, null, null, result); @@ -804,7 +804,7 @@ public void test160AssignR1ToJack() throws Exception { public void test200AddConditions() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN createObjectsInFirstPart(true, task, result, () -> { @@ -822,7 +822,7 @@ public void test200AddConditions() throws Exception { public void test210AssignR1ToJack() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); LensContext context = createContextForRoleAssignment(USER_JACK_OID, ROLE_R1_OID, null, null, result); context.getFocusContext().swallowToPrimaryDelta( @@ -885,7 +885,7 @@ public void test210AssignR1ToJack() throws Exception { public void test300AssignR7ToJack() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); createObjectsInSecondPart(false, task, result, null); @@ -1025,7 +1025,7 @@ public void test300AssignR7ToJack() throws Exception { public void test400AssignJackPirate() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); createObjectsInThirdPart(false, task, result, () -> { @@ -1488,7 +1488,7 @@ public static void finishCallback(String desc) { public void test500AssignJackOrg11() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); createObjectsInFourthPart(false, task, result, null); @@ -1546,7 +1546,7 @@ public void test500AssignJackOrg11() throws Exception { public void test505AssignJackOrg11AsManager() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); LensContext context = createContextForAssignment(UserType.class, USER_JACK_OID, OrgType.class, ORG11_OID, SchemaConstants.ORG_MANAGER, null, result); @@ -1601,7 +1601,7 @@ public void test505AssignJackOrg11AsManager() throws Exception { public void test507AssignJackOrg11AsApprover() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); LensContext context = createContextForAssignment(UserType.class, USER_JACK_OID, OrgType.class, ORG11_OID, SchemaConstants.ORG_APPROVER, null, result); @@ -1655,7 +1655,7 @@ public void test507AssignJackOrg11AsApprover() throws Exception { public void test510AssignJackOrg21() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); LensContext context = createContextForAssignment(UserType.class, USER_JACK_OID, OrgType.class, ORG21_OID, null, null, result); // intentionally unqualified @@ -1708,7 +1708,7 @@ public void test510AssignJackOrg21() throws Exception { public void test515AssignJackOrg21AsManager() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); LensContext context = createContextForAssignment(UserType.class, USER_JACK_OID, OrgType.class, ORG21_OID, new QName("manager"), null, result); // intentionally unqualified @@ -1775,7 +1775,7 @@ public void test515AssignJackOrg21AsManager() throws Exception { public void test520AssignJackOrg41AsApprover() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); LensContext context = createContextForAssignment(UserType.class, USER_JACK_OID, OrgType.class, ORG41_OID, new QName("approver"), null, result); // intentionally unqualified @@ -1839,7 +1839,7 @@ public void test520AssignJackOrg41AsApprover() throws Exception { public void test600AssignA1ToJack() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); createObjectsInFifthPart(false, task, result, null); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestDependencies.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestDependencies.java index e075240e2f0..fe3f57430f6 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestDependencies.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestDependencies.java @@ -33,7 +33,6 @@ import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.task.api.TaskManager; import com.evolveum.midpoint.test.DummyResourceContoller; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.CommunicationException; import com.evolveum.midpoint.util.exception.ConfigurationException; import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; @@ -109,7 +108,6 @@ private String getDummuAccountOid(String dummyName, String accountName) { @Test public void test100SortToWavesIdependent() throws Exception { final String TEST_NAME = "test100SortToWavesIdependent"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDependencies.class.getName() + "." + TEST_NAME); @@ -138,7 +136,6 @@ public void test100SortToWavesIdependent() throws Exception { @Test public void test101SortToWavesAB() throws Exception { final String TEST_NAME = "test101SortToWavesAB"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDependencies.class.getName() + "." + TEST_NAME); @@ -169,7 +166,6 @@ public void test101SortToWavesAB() throws Exception { @Test public void test102SortToWavesABCD() throws Exception { final String TEST_NAME = "test102SortToWavesABCD"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDependencies.class.getName() + "." + TEST_NAME); @@ -204,7 +200,6 @@ public void test102SortToWavesABCD() throws Exception { @Test public void test120SortToWavesBCUnsatisfied() throws Exception { final String TEST_NAME = "test120SortToWavesBCUnsatisfied"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDependencies.class.getName() + "." + TEST_NAME); @@ -235,7 +230,6 @@ public void test120SortToWavesBCUnsatisfied() throws Exception { @Test public void test151SortToWavesPR() throws Exception { final String TEST_NAME = "test151SortToWavesPR"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDependencies.class.getName() + "." + TEST_NAME); @@ -269,7 +263,6 @@ public void test151SortToWavesPR() throws Exception { @Test public void test152SortToWavesRP() throws Exception { final String TEST_NAME = "test152SortToWavesRP"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDependencies.class.getName() + "." + TEST_NAME); @@ -299,7 +292,6 @@ public void test152SortToWavesRP() throws Exception { @Test public void test200SortToWavesIdependentDeprovision() throws Exception { final String TEST_NAME = "test200SortToWavesIdependentDeprovision"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDependencies.class.getName() + "." + TEST_NAME); @@ -329,7 +321,6 @@ public void test200SortToWavesIdependentDeprovision() throws Exception { @Test public void test201SortToWavesABDeprovision() throws Exception { final String TEST_NAME = "test201SortToWavesABDeprovision"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDependencies.class.getName() + "." + TEST_NAME); @@ -361,7 +352,6 @@ public void test201SortToWavesABDeprovision() throws Exception { @Test public void test202SortToWavesABCDDeprovision() throws Exception { final String TEST_NAME = "test202SortToWavesABCDDeprovision"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDependencies.class.getName() + "." + TEST_NAME); @@ -403,7 +393,6 @@ private void setDelete(LensProjectionContext accountContext) { @Test public void test300SortToWavesXYZCircular() throws Exception { final String TEST_NAME = "test300SortToWavesXYZCircular"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDependencies.class.getName() + "." + TEST_NAME); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPasswordPolicy.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPasswordPolicy.java index b4cd9689080..402fdb0f9a6 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPasswordPolicy.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPasswordPolicy.java @@ -13,8 +13,6 @@ import java.io.File; import java.io.IOException; -import javax.xml.bind.JAXBException; - import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.annotation.DirtiesContext; @@ -32,25 +30,19 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SecurityViolationException; +import com.evolveum.midpoint.util.exception.*; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; import com.evolveum.midpoint.xml.ns._public.common.common_3.StringLimitType; import com.evolveum.midpoint.xml.ns._public.common.common_3.StringPolicyType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType; -@ContextConfiguration(locations = {"classpath:ctx-model-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-model-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public class TestPasswordPolicy extends AbstractInternalModelIntegrationTest { - public static final File TEST_DIR = new File("src/test/resources/lens/ppolicy/"); + public static final File TEST_DIR = new File("src/test/resources/lens/ppolicy/"); private static final Trace LOGGER = TraceManager.getTrace(TestPasswordPolicy.class); @@ -62,11 +54,11 @@ public class TestPasswordPolicy extends AbstractInternalModelIntegrationTest { private static final int USERNAME_ATTEMPTS = 200; private static final int USER_PROPS_ATTEMPTS = 5000; - @Autowired(required = true) + @Autowired private ValuePolicyProcessor valuePolicyProcessor; @Test - public void stringPolicyUtilsMinimalTest() throws JAXBException, SchemaException, IOException { + public void stringPolicyUtilsMinimalTest() throws SchemaException, IOException { File file = new File(TEST_DIR, "password-policy-minimal.xml"); ValuePolicyType pp = (ValuePolicyType) PrismTestUtil.parseObject(file).asObjectable(); StringPolicyType sp = pp.getStringPolicy(); @@ -81,9 +73,6 @@ public void stringPolicyUtilsMinimalTest() throws JAXBException, SchemaException @Test public void stringPolicyUtilsComplexTest() { - final String TEST_NAME = "stringPolicyUtilsComplexTest"; - TestUtil.displayTestTitle(TEST_NAME); - File file = new File(TEST_DIR, "password-policy-complex.xml"); ValuePolicyType pp = null; try { @@ -98,9 +87,6 @@ public void stringPolicyUtilsComplexTest() { @Test public void testPasswordGeneratorComplexNegative() throws Exception { - final String TEST_NAME = "testPasswordGeneratorComplexNegative"; - TestUtil.displayTestTitle(TEST_NAME); - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -113,10 +99,10 @@ public void testPasswordGeneratorComplexNegative() throws Exception { // WHEN when(); - String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, false, null, TEST_NAME, task, result); + String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, false, null, getTestNameShort(), task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("Generated password", psswd); result.computeStatus(); AssertJUnit.assertTrue(result.isAcceptable()); @@ -128,7 +114,7 @@ public void testPasswordGeneratorComplexNegative() throws Exception { } LOGGER.info("Negative testing: passwordGeneratorComplexTest"); try { - valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, false, null, TEST_NAME, task, result); + valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, false, null, getTestNameShort(), task, result); assertNotReached(); } catch (ExpressionEvaluationException e) { result.computeStatus(); @@ -138,29 +124,26 @@ public void testPasswordGeneratorComplexNegative() throws Exception { @Test public void testPasswordGeneratorComplex() throws Exception { - passwordGeneratorTest("testPasswordGeneratorComplex", "password-policy-complex.xml"); + passwordGeneratorTest("password-policy-complex.xml"); } @Test public void testPasswordGeneratorLong() throws Exception { - passwordGeneratorTest("testPasswordGeneratorLong", "password-policy-long.xml"); + passwordGeneratorTest("password-policy-long.xml"); } @Test public void testPasswordGeneratorNumeric() throws Exception { - passwordGeneratorTest("testPasswordGeneratorNumeric", "password-policy-numeric.xml"); + passwordGeneratorTest("password-policy-numeric.xml"); } @Test public void testValueGeneratorMustBeFirst() throws Exception { - passwordGeneratorTest("testValueGeneratorMustBeFirst", "value-policy-must-be-first.xml"); + passwordGeneratorTest("value-policy-must-be-first.xml"); } @Test public void testValueGenerateRandomPin() throws Exception { - final String TEST_NAME = "testValueGenerateRandomPin"; - TestUtil.displayTestTitle(TEST_NAME); - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -168,10 +151,10 @@ public void testValueGenerateRandomPin() throws Exception { // WHEN when(); - String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, true, null, TEST_NAME, task, result); + String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, true, null, getTestNameShort(), task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("Generated password", psswd); result.computeStatus(); TestUtil.assertSuccess(result); @@ -182,9 +165,6 @@ public void testValueGenerateRandomPin() throws Exception { @Test public void testValueGenerate() throws Exception { - final String TEST_NAME = "testValueGenerate"; - TestUtil.displayTestTitle(TEST_NAME); - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -192,10 +172,10 @@ public void testValueGenerate() throws Exception { // WHEN when(); - String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, true, null, TEST_NAME, task, result); + String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, true, null, getTestNameShort(), task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("Generated password", psswd); result.computeStatus(); TestUtil.assertSuccess(result); @@ -206,9 +186,6 @@ public void testValueGenerate() throws Exception { @Test public void testValueGenerateEmpty() throws Exception { - final String TEST_NAME = "testValueGenerateEmpty"; - TestUtil.displayTestTitle(TEST_NAME); - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -218,10 +195,10 @@ public void testValueGenerateEmpty() throws Exception { // WHEN when(); - String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, true, null, TEST_NAME, task, result); + String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, true, null, getTestNameShort(), task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("Generated password", psswd); result.computeStatus(); TestUtil.assertSuccess(result); @@ -229,25 +206,25 @@ public void testValueGenerateEmpty() throws Exception { assertPassword(psswd, pp); } - public void passwordGeneratorTest(final String TEST_NAME, String policyFilename) throws JAXBException, SchemaException, IOException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException { - TestUtil.displayTestTitle(TEST_NAME); - + public void passwordGeneratorTest(String policyFilename) + throws SchemaException, IOException, ExpressionEvaluationException, ObjectNotFoundException, + CommunicationException, ConfigurationException, SecurityViolationException { Task task = getTestTask(); OperationResult result = task.getResult(); File file = new File(TEST_DIR, policyFilename); - LOGGER.info("Positive testing {}: {}", TEST_NAME, policyFilename); + LOGGER.info("Positive testing {}: {}", getTestNameShort(), policyFilename); ValuePolicyType pp = (ValuePolicyType) PrismTestUtil.parseObject(file).asObjectable(); String psswd; // generate minimal size passwd for (int i = 0; i < 100; i++) { - psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, true, null, TEST_NAME, task, result); + psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, true, null, getTestNameShort(), task, result); LOGGER.info("Generated password:" + psswd); result.computeStatus(); if (!result.isSuccess()) { LOGGER.info("Result:" + result.debugDump()); - AssertJUnit.fail("Password generator failed:\n"+result.debugDump()); + AssertJUnit.fail("Password generator failed:\n" + result.debugDump()); } assertNotNull(psswd); assertPassword(psswd, pp); @@ -256,7 +233,7 @@ public void passwordGeneratorTest(final String TEST_NAME, String policyFilename) LOGGER.info("-------------------------"); // Generate up to possible for (int i = 0; i < 100; i++) { - psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, false, null, TEST_NAME, task, result); + psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, false, null, getTestNameShort(), task, result); LOGGER.info("Generated password:" + psswd); result.computeStatus(); if (!result.isSuccess()) { @@ -268,11 +245,15 @@ public void passwordGeneratorTest(final String TEST_NAME, String policyFilename) } } - private void assertPassword(String passwd, ValuePolicyType pp) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { + private void assertPassword(String passwd, ValuePolicyType pp) + throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, + CommunicationException, ConfigurationException, SecurityViolationException { assertPassword(passwd, pp, null); } - private void assertPassword(String passwd, ValuePolicyType pp, PrismObject object) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { + private void assertPassword(String passwd, ValuePolicyType pp, PrismObject object) + throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, + CommunicationException, ConfigurationException, SecurityViolationException { Task task = getTestTask(); OperationResult result = task.getResult(); boolean isValid = valuePolicyProcessor.validateValue(passwd, pp, createUserOriginResolver(object), "assertPassword", task, result); @@ -285,9 +266,6 @@ private void assertPassword(String passwd, ValuePolicyTyp @Test public void passwordValidationTestComplex() throws Exception { - final String TEST_NAME = "passwordValidationTestComplex"; - TestUtil.displayTestTitle(TEST_NAME); - ValuePolicyType pp = parsePasswordPolicy("password-policy-complex.xml"); // WHEN, THEN @@ -299,9 +277,6 @@ public void passwordValidationTestComplex() throws Exception { @Test public void passwordValidationTestTri() throws Exception { - final String TEST_NAME = "passwordValidationTestTri"; - TestUtil.displayTestTitle(TEST_NAME); - ValuePolicyType pp = parsePasswordPolicy("password-policy-tri.xml"); // WHEN, THEN @@ -318,9 +293,6 @@ public void passwordValidationTestTri() throws Exception { */ @Test public void testUsername() throws Exception { - final String TEST_NAME = "testUsername"; - TestUtil.displayTestTitle(TEST_NAME); - PrismObject user = createUserAb(); ValuePolicyType pp = parsePasswordPolicy("password-policy-username.xml"); @@ -331,19 +303,19 @@ public void testUsername() throws Exception { Task task = getTestTask(); OperationResult result = task.getResult(); - String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, true, createUserOriginResolver(user), TEST_NAME, task, result); - display("Generated password ("+i+")", psswd); + String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, true, createUserOriginResolver(user), getTestNameShort(), task, result); + display("Generated password (" + i + ")", psswd); result.computeStatus(); TestUtil.assertSuccess(result); assertNotNull(psswd); assertPassword(psswd, pp, user); - assertFalse("Generated password that matches the username: "+psswd, psswd.equals(USER_AB_USERNAME)); + assertFalse("Generated password that matches the username: " + psswd, psswd.equals(USER_AB_USERNAME)); } // THEN - TestUtil.displayThen(TEST_NAME); + then(); } /** @@ -351,9 +323,6 @@ public void testUsername() throws Exception { */ @Test public void testUserProps() throws Exception { - final String TEST_NAME = "testUserProps"; - TestUtil.displayTestTitle(TEST_NAME); - PrismObject user = createUserAb(); display("User", user); ValuePolicyType pp = parsePasswordPolicy("password-policy-props.xml"); @@ -365,8 +334,8 @@ public void testUserProps() throws Exception { Task task = getTestTask(); OperationResult result = task.getResult(); - String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, true, createUserOriginResolver(user), TEST_NAME, task, result); - display("Generated password ("+i+")", psswd); + String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, true, createUserOriginResolver(user), getTestNameShort(), task, result); + display("Generated password (" + i + ")", psswd); result.computeStatus(); TestUtil.assertSuccess(result); @@ -379,7 +348,7 @@ public void testUserProps() throws Exception { } // THEN - TestUtil.displayThen(TEST_NAME); + then(); } private PrismObject createUserAb() throws SchemaException { @@ -389,7 +358,7 @@ private PrismObject createUserAb() throws SchemaException { } private void assertNotContains(String psswd, String val) { - assertFalse("Generated password "+psswd+" contains value "+val, StringUtils.containsIgnoreCase(psswd, val)); + assertFalse("Generated password " + psswd + " contains value " + val, StringUtils.containsIgnoreCase(psswd, val)); } private ValuePolicyType parsePasswordPolicy(String filename) throws SchemaException, IOException { @@ -402,7 +371,7 @@ private boolean pwdValidHelper(String password, ValuePolicyType pp) throws Schem OperationResult result = task.getResult(); valuePolicyProcessor.validateValue(password, pp, null, "pwdValidHelper", task, result); result.computeStatus(); - String msg = "-> Policy "+pp.getName()+", password '"+password+"': "+result.getStatus(); + String msg = "-> Policy " + pp.getName() + ", password '" + password + "': " + result.getStatus(); System.out.println(msg); LOGGER.info(msg); LOGGER.trace(result.debugDump()); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPasswordPolicyProcessor.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPasswordPolicyProcessor.java index 5e371fdf8e6..d518ad75bfa 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPasswordPolicyProcessor.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPasswordPolicyProcessor.java @@ -68,7 +68,7 @@ public void test000initPasswordPolicyForHistory() throws Exception { @Test public void test100CreateFocusWithPassword() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN addObject(getTestResource(), task, result); @@ -88,7 +88,7 @@ private PrismObject getFocus() throws Exception { @Test public void test110ModifyPassword() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN modifyFocusChangePassword(getType(), getOid(), PASSWORD1, task, result); @@ -111,7 +111,7 @@ public void test110ModifyPassword() throws Exception { @Test public void test120ModifyPasswordSecondTime() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN modifyFocusChangePassword(getType(), getOid(), PASSWORD2, task, result); @@ -134,7 +134,7 @@ public void test120ModifyPasswordSecondTime() throws Exception { @Test public void test130ModifyPasswordThirdTime() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN modifyFocusChangePassword(getType(), getOid(), PASSWORD3, task, result); @@ -171,7 +171,7 @@ public void test160ModifyPasswordSamePassword3() throws Exception { private void doTestModifyPasswordExpectFailure(String password) throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); try { // WHEN @@ -207,7 +207,7 @@ public void test201deleteFocus() throws Exception { @Test public void test210CreateFocusNoPasswordHistory() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN addObject(getTestResource(), task, result); @@ -238,7 +238,7 @@ public void test230ModifySamePasswordNoPasswordHistory() throws Exception { private void modifyPasswordNoHistory() throws Exception{ Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN ProtectedStringType newValue = new ProtectedStringType(); @@ -269,7 +269,7 @@ private void assertPasswords(String password, ProtectedStringType passwordAfterC private void setPasswordHistoryLength(int historyLength) throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); modifyObjectReplaceProperty(SecurityPolicyType.class, SECURITY_POLICY_OID, SchemaConstants.PATH_CREDENTIALS_PASSWORD_HISTORY_LENGTH, task, result, historyLength); } diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules.java index c0df89db009..8afd81626eb 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules.java @@ -77,7 +77,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test005JackAttemptAssignRoleJudge() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // GIVEN @@ -110,7 +110,7 @@ public void test005JackAttemptAssignRoleJudge() throws Exception { @Test(enabled = false) public void test007JackAttemptAssignRoleJudgeAsOwner() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // GIVEN @@ -147,7 +147,7 @@ public void test007JackAttemptAssignRoleJudgeAsOwner() throws Exception { @Test public void test010JackAssignRoleJudge() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // GIVEN @@ -171,7 +171,7 @@ public void test010JackAssignRoleJudge() throws Exception { @Test public void test020JackUnassignRoleJudge() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // GIVEN @@ -208,7 +208,7 @@ public void test020JackUnassignRoleJudge() throws Exception { @Test public void test100AssignRoleMutinierToJack() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // GIVEN @@ -241,7 +241,7 @@ public void test100AssignRoleMutinierToJack() throws Exception { @Test(enabled = false) // after MID-4797 the projector.project now raises PolicyViolationException on conflicting roles public void test110AssignRolePirateToJack() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // GIVEN @@ -279,7 +279,7 @@ public void test110AssignRolePirateToJack() throws Exception { @Test public void test112AssignRolePirateWithExceptionToJack() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // GIVEN @@ -323,7 +323,7 @@ public void test112AssignRolePirateWithExceptionToJack() throws Exception { @Test public void test120AssignRoleConstableToJack() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // GIVEN @@ -374,7 +374,7 @@ public void test120AssignRoleConstableToJack() throws Exception { @Test public void test150AssignRoleThiefToJack() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // GIVEN @@ -424,7 +424,7 @@ public void test150AssignRoleThiefToJack() throws Exception { @Test public void test200JackAssignRoleContractor() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // GIVEN @@ -448,7 +448,7 @@ public void test200JackAssignRoleContractor() throws Exception { @Test public void test210AssignRoleEmployeeToJack() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // GIVEN @@ -489,7 +489,7 @@ public void test210AssignRoleEmployeeToJack() throws Exception { @Test public void test220AssignRoleEngineerToJack() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // GIVEN @@ -555,7 +555,7 @@ public void test220AssignRoleEngineerToJack() throws Exception { @Test public void test300DrakeChangeEmployeeType() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // GIVEN @@ -591,7 +591,7 @@ public void test300DrakeChangeEmployeeType() throws Exception { @Test public void test400AssignRoleLocalized() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // GIVEN diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyStateRecording.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyStateRecording.java index 7a752c8c2e2..fe81d19ff76 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyStateRecording.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyStateRecording.java @@ -38,8 +38,6 @@ @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public class TestPolicyStateRecording extends AbstractLensTest { - private static final String ROLE_JUDGE_POLICY_RULE_EXCLUSION_NAME = "criminal exclusion"; - protected static final File TEST_DIR = new File(AbstractLensTest.TEST_DIR, "policy/state"); private static final File USER_BOB_FILE = new File(TEST_DIR, "user-bob.xml"); @@ -96,19 +94,18 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100JackAssignRoleJudge() throws Exception { - TestCtx t = createContext(this, "test100JackAssignRoleJudge"); - // GIVEN + Task task = createPlainTask(); // WHEN - t.displayWhen(); - assignRole(USER_JACK_OID, ROLE_JUDGE_OID, t.task, t.result); + when(); + assignRole(USER_JACK_OID, ROLE_JUDGE_OID, task, task.getResult()); // THEN - t.displayThen(); + then(); UserType jack = getUser(USER_JACK_OID).asObjectable(); display("jack", jack); - assertSuccess(t.result); + assertSuccess(task.getResult()); assertAssignedRole(jack.asPrismObject(), ROLE_JUDGE_OID); assertEquals("Wrong # of assignments", 1, jack.getAssignment().size()); @@ -122,17 +119,15 @@ public void test100JackAssignRoleJudge() throws Exception { @Test public void test110JackAssignRolePirate() throws Exception { - TestCtx t = createContext(this, "test110JackAssignRolePirate"); - // WHEN - t.displayWhen(); - assignRole(USER_JACK_OID, ROLE_PIRATE_OID, t.task, t.result); + when(); + assignRole(USER_JACK_OID, ROLE_PIRATE_OID, getTestTask(), getTestResult()); // THEN - t.displayThen(); + then(); UserType jack = getUser(USER_JACK_OID).asObjectable(); display("jack", jack); - assertSuccess(t.result); + assertSuccess(getTestResult()); assertAssignedRole(jack.asPrismObject(), ROLE_PIRATE_OID); assertEquals("Wrong # of assignments", 2, jack.getAssignment().size()); @@ -147,21 +142,19 @@ public void test110JackAssignRolePirate() throws Exception { // should keep the situation for both assignments @Test public void test120RecomputeJack() throws Exception { - TestCtx t = createContext(this, "test120RecomputeJack"); - // GIVEN dummyAuditService.clear(); // WHEN - t.displayWhen(); - executeChanges(prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, USER_JACK_OID), createReconcile(), t.task, t.result); - //recomputeUser(USER_JACK_OID, t.task, t.result); + when(); + executeChanges(prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, USER_JACK_OID), createReconcile(), getTestTask(), getTestResult()); + //recomputeUser(USER_JACK_OID, getTestTask(), getTestResult()); // THEN - t.displayThen(); + then(); UserType jack = getUser(USER_JACK_OID).asObjectable(); display("jack", jack); - assertSuccess(t.result); + assertSuccess(getTestResult()); // TODO test that assignment IDs are filled in correctly (currently they are not) assertEquals("Wrong # of assignments", 2, jack.getAssignment().size()); @@ -178,25 +171,23 @@ public void test120RecomputeJack() throws Exception { @Test public void test130JackUnassignRolePirate() throws Exception { - TestCtx t = createContext(this, "test130JackUnassignRolePirate"); - // GIVEN UserType jack = getUser(USER_JACK_OID).asObjectable(); AssignmentType pirateAssignment = findAssignmentByTargetRequired(jack.asPrismObject(), ROLE_PIRATE_OID); // WHEN - t.displayWhen(); + when(); ObjectDelta delta = prismContext.deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT) .delete(pirateAssignment.clone()) .asObjectDeltaCast(USER_JACK_OID); - executeChangesAssertSuccess(delta, null, t.task, t.result); + executeChangesAssertSuccess(delta, null, getTestTask(), getTestResult()); // THEN - t.displayThen(); + then(); jack = getUser(USER_JACK_OID).asObjectable(); display("jack", jack); - assertSuccess(t.result); + assertSuccess(getTestResult()); assertNotAssignedRole(jack.asPrismObject(), ROLE_PIRATE_OID); assertEquals("Wrong # of assignments", 1, jack.getAssignment().size()); @@ -210,24 +201,22 @@ public void test130JackUnassignRolePirate() throws Exception { @Test public void test200BobAssign2a3a() throws Exception { - TestCtx t = createContext(this, "test200BobAssign2a3a"); - // GIVEN // WHEN - t.displayWhen(); + when(); ObjectDelta delta = prismContext.deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT) .add(createAssignmentTo(roleATest2aOid, ObjectTypes.ROLE, prismContext), createAssignmentTo(roleATest3aOid, ObjectTypes.ROLE, prismContext)) .asObjectDeltaCast(userBobOid); - executeChangesAssertSuccess(delta, null, t.task, t.result); + executeChangesAssertSuccess(delta, null, getTestTask(), getTestResult()); // THEN - t.displayThen(); + then(); UserType bob = getUser(userBobOid).asObjectable(); display("bob", bob); - assertSuccess(t.result); + assertSuccess(getTestResult()); assertAssignedRole(bob.asPrismObject(), roleATest2aOid); assertAssignedRole(bob.asPrismObject(), roleATest3aOid); @@ -245,24 +234,22 @@ public void test200BobAssign2a3a() throws Exception { @Test public void test210BobAssign2b3b() throws Exception { - TestCtx t = createContext(this, "test210BobAssign2b3b"); - // GIVEN // WHEN - t.displayWhen(); + when(); ObjectDelta delta = prismContext.deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT) .add(createAssignmentTo(roleATest2bOid, ObjectTypes.ROLE, prismContext), createAssignmentTo(roleATest3bOid, ObjectTypes.ROLE, prismContext)) .asObjectDeltaCast(userBobOid); - executeChangesAssertSuccess(delta, null, t.task, t.result); + executeChangesAssertSuccess(delta, null, getTestTask(), getTestResult()); // THEN - t.displayThen(); + then(); UserType bob = getUser(userBobOid).asObjectable(); display("bob", bob); - assertSuccess(t.result); + assertSuccess(getTestResult()); assertAssignedRole(bob.asPrismObject(), roleATest2aOid); assertAssignedRole(bob.asPrismObject(), roleATest2bOid); @@ -291,8 +278,6 @@ private void assertExclusionViolationState(AssignmentType assignment) { // new user, new assignments (no IDs) @Test public void test220AliceAssign2a2b() throws Exception { - TestCtx t = createContext(this, "test220AliceAssign2a2b"); - // GIVEN UserType alice = prismContext.createObjectable(UserType.class) .name("alice") @@ -300,14 +285,14 @@ public void test220AliceAssign2a2b() throws Exception { .assignment(createAssignmentTo(roleATest2bOid, ObjectTypes.ROLE, prismContext)); // WHEN - t.displayWhen(); - addObject(alice.asPrismObject(), t.task, t.result); + when(); + addObject(alice.asPrismObject(), getTestTask(), getTestResult()); // THEN - t.displayThen(); + then(); alice = getUser(alice.getOid()).asObjectable(); display("alice", alice); - assertSuccess(t.result); + assertSuccess(getTestResult()); assertAssignedRole(alice.asPrismObject(), roleATest2aOid); assertAssignedRole(alice.asPrismObject(), roleATest2bOid); @@ -324,8 +309,6 @@ public void test220AliceAssign2a2b() throws Exception { // new user, new assignments (explicit IDs) @Test public void test230ChuckAssign2a2b() throws Exception { - TestCtx t = createContext(this, "test230ChuckAssign2a2b"); - // GIVEN AssignmentType assignment2a = createAssignmentTo(roleATest2aOid, ObjectTypes.ROLE, prismContext); assignment2a.setId(100L); @@ -337,14 +320,14 @@ public void test230ChuckAssign2a2b() throws Exception { .assignment(assignment2b); // WHEN - t.displayWhen(); - addObject(chuck.asPrismObject(), t.task, t.result); + when(); + addObject(chuck.asPrismObject(), getTestTask(), getTestResult()); // THEN - t.displayThen(); + then(); chuck = getUser(chuck.getOid()).asObjectable(); display("chuck", chuck); - assertSuccess(t.result); + assertSuccess(getTestResult()); assertAssignedRole(chuck.asPrismObject(), roleATest2aOid); assertAssignedRole(chuck.asPrismObject(), roleATest2bOid); @@ -361,8 +344,6 @@ public void test230ChuckAssign2a2b() throws Exception { // new user, new assignments (explicit IDs, explicit OID) @Test public void test240DanAssign2a2b() throws Exception { - TestCtx t = createContext(this, "test240DanAssign2a2b"); - // GIVEN AssignmentType assignment2a = createAssignmentTo(roleATest2aOid, ObjectTypes.ROLE, prismContext); assignment2a.setId(100L); @@ -375,14 +356,14 @@ public void test240DanAssign2a2b() throws Exception { .assignment(assignment2b); // WHEN - t.displayWhen(); - addObject(dan.asPrismObject(), t.task, t.result); + when(); + addObject(dan.asPrismObject(), getTestTask(), getTestResult()); // THEN - t.displayThen(); + then(); dan = getUser(dan.getOid()).asObjectable(); display("dan", dan); - assertSuccess(t.result); + assertSuccess(getTestResult()); assertAssignedRole(dan.asPrismObject(), roleATest2aOid); assertAssignedRole(dan.asPrismObject(), roleATest2bOid); @@ -399,23 +380,21 @@ public void test240DanAssign2a2b() throws Exception { // modified user, new assignment (with ID) @Test public void test250EveAssign2b() throws Exception { - TestCtx t = createContext(this, "test220AliceAssign2a2b"); - // WHEN - t.displayWhen(); + when(); AssignmentType assignment2b = createAssignmentTo(roleATest2bOid, ObjectTypes.ROLE, prismContext); assignment2b.setId(200L); ObjectDelta delta = prismContext.deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT) .add(assignment2b) .asObjectDeltaCast(userEveOid); - executeChangesAssertSuccess(delta, null, t.task, t.result); + executeChangesAssertSuccess(delta, null, getTestTask(), getTestResult()); // THEN - t.displayThen(); + then(); UserType eve = getUser(userEveOid).asObjectable(); display("alice", eve); - assertSuccess(t.result); + assertSuccess(getTestResult()); assertAssignedRole(eve.asPrismObject(), roleATest2aOid); assertAssignedRole(eve.asPrismObject(), roleATest2bOid); @@ -431,22 +410,20 @@ public void test250EveAssign2b() throws Exception { @Test public void test300MakeRoleWrong() throws Exception { - TestCtx t = createContext(this, "test300MakeRoleWrong"); - // GIVEN // WHEN - t.displayWhen(); + when(); ObjectDelta delta = prismContext.deltaFor(RoleType.class) .item(RoleType.F_DESCRIPTION).replace("wrong") .asObjectDeltaCast(roleATestWrongOid); - executeChangesAssertSuccess(delta, null, t.task, t.result); + executeChangesAssertSuccess(delta, null, getTestTask(), getTestResult()); // THEN - t.displayThen(); + then(); RoleType wrong = getRole(roleATestWrongOid).asObjectable(); display("role 'wrong'", wrong); - assertSuccess(t.result); + assertSuccess(getTestResult()); assertEquals("Wrong policy situations for role", Collections.singletonList(WRONG_URI), wrong.getPolicySituation()); @@ -456,8 +433,6 @@ public void test300MakeRoleWrong() throws Exception { @Test public void test310CreateWrongRole() throws Exception { - TestCtx t = createContext(this, "test310CreateWrongRole"); - // GIVEN RoleType wrong2 = prismContext.createObjectable(RoleType.class) .name("wrong-2") @@ -465,14 +440,14 @@ public void test310CreateWrongRole() throws Exception { .assignment(createAssignmentTo(metaroleCommonRulesOid, ObjectTypes.ROLE, prismContext)); // WHEN - t.displayWhen(); - addObject(wrong2.asPrismObject(), t.task, t.result); + when(); + addObject(wrong2.asPrismObject(), getTestTask(), getTestResult()); // THEN - t.displayThen(); + then(); wrong2 = getRole(wrong2.getOid()).asObjectable(); display("role 'wrong-2'", wrong2); - assertSuccess(t.result); + assertSuccess(getTestResult()); assertEquals("Wrong policy situations for role", Collections.singletonList(WRONG_URI), wrong2.getPolicySituation()); @@ -482,8 +457,6 @@ public void test310CreateWrongRole() throws Exception { @Test public void test320CreateWrongRoleKnownOid() throws Exception { - TestCtx t = createContext(this, "test320CreateWrongRoleKnownOid"); - // GIVEN AssignmentType assignmentCommon = createAssignmentTo(metaroleCommonRulesOid, ObjectTypes.ROLE, prismContext); assignmentCommon.setId(300L); @@ -494,14 +467,14 @@ public void test320CreateWrongRoleKnownOid() throws Exception { .assignment(assignmentCommon); // WHEN - t.displayWhen(); - addObject(wrong3.asPrismObject(), t.task, t.result); + when(); + addObject(wrong3.asPrismObject(), getTestTask(), getTestResult()); // THEN - t.displayThen(); + then(); wrong3 = getRole(wrong3.getOid()).asObjectable(); display("role 'wrong-3'", wrong3); - assertSuccess(t.result); + assertSuccess(getTestResult()); assertEquals("Wrong policy situations for role", Collections.singletonList(WRONG_URI), wrong3.getPolicySituation()); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjector.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjector.java index 0479db55141..00b3ca9ddf7 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjector.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjector.java @@ -203,7 +203,7 @@ public void test100AddAccountToJackDirect() throws Exception { projector.project(context, "test", task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("Output context", context); // Not loading anything. The account is already loaded in the context assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjectorPersona.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjectorPersona.java index 0c6ae89ca3a..10cc9f65ced 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjectorPersona.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjectorPersona.java @@ -24,7 +24,6 @@ import com.evolveum.midpoint.schema.internals.InternalMonitor; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.QNameUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType; @@ -52,7 +51,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100AssignRolePersonaAdminToJack() throws Exception { final String TEST_NAME = "test100AssignRolePersonaAdminToJack"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestProjectorPersona.class.getName() + "." + TEST_NAME); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjectorRoleEntitlement.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjectorRoleEntitlement.java index 5f2e0bb81f9..d4001d796ec 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjectorRoleEntitlement.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjectorRoleEntitlement.java @@ -34,7 +34,6 @@ import com.evolveum.midpoint.task.api.TaskManager; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.IntegrationTestTools; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; /** @@ -71,7 +70,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100AddEntitlementToPirateDirect() throws Exception { final String TEST_NAME = "test100AddEntitlementToPirateDirect"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestProjectorRoleEntitlement.class.getName() + "." + TEST_NAME); @@ -134,7 +132,6 @@ public void test100AddEntitlementToPirateDirect() throws Exception { @Test public void test110AssignEntitlementToPirate() throws Exception { final String TEST_NAME = "test110AssignEntitlementToPirate"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestProjectorRoleEntitlement.class.getName() + "." + TEST_NAME); @@ -164,7 +161,6 @@ public void test110AssignEntitlementToPirate() throws Exception { @Test public void test111AssignEntitlementToPirateBroken() throws Exception { final String TEST_NAME = "test110AssignEntitlementToPirate"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestProjectorRoleEntitlement.class.getName() + "." + TEST_NAME); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestReconScript.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestReconScript.java index c5560d18190..1fbea682b71 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestReconScript.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestReconScript.java @@ -51,7 +51,7 @@ public void text001testReconcileScriptsWhenProvisioning() throws Exception{ final String TEST_NAME = "text001testReconcileScriptsWhenProvisioning"; Task task = taskManager.createTaskInstance(TEST_NAME); - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createResult(); ObjectDelta delta = createModifyUserAddAccount(USER_JACK_OID, getDummyResourceObject()); Collection> deltas = new ArrayList<>(); @@ -124,7 +124,7 @@ public void test003testReconcileScriptsAddUserAction() throws Exception{ final String TEST_NAME = "test003testReconcileScriptsAddUserAction"; Task task = taskManager.createTaskInstance(TEST_NAME); - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createResult(); ShadowType shadow = parseObjectType(new File(ACCOUNT_BEFORE_SCRIPT_FILENAME), ShadowType.class); @@ -169,7 +169,7 @@ public void test005TestDryRunDelete() throws Exception{ final String TEST_NAME = "test005TestDryRunDelete"; PrismObject task = getTask(TASK_RECON_DUMMY_OID); - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createResult(); PropertyDelta dryRunDelta = prismContext.deltaFactory().property().createModificationReplaceProperty(PATH_MODEL_EXTENSION_DRY_RUN, task.getDefinition(), true); Collection modifications = new ArrayList<>(); @@ -200,7 +200,7 @@ public void test006TestReconDelete() throws Exception{ final String TEST_NAME = "test006TestReconDelete"; PrismObject task = getTask(TASK_RECON_DUMMY_OID); - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createResult(); PropertyDelta dryRunDelta = prismContext.deltaFactory().property().createModificationReplaceProperty( PATH_MODEL_EXTENSION_DRY_RUN, task.getDefinition(), false); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/migrator/TestMigrator.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/migrator/TestMigrator.java index 7569c17ec87..facdb4b6c49 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/migrator/TestMigrator.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/migrator/TestMigrator.java @@ -49,8 +49,6 @@ public class TestMigrator extends AbstractSpringTest { @Test public void testMigrateUserTemplate() throws Exception { - TestUtil.displayTestTitle("testMigrateUserTemplate"); - for (File beforeFile: TEST_DIR_BEFORE.listFiles()) { String beforeName = beforeFile.getName(); if (!beforeName.endsWith(".xml")) { diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/misc/ShadowIntegrityCheckerTest.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/misc/ShadowIntegrityCheckerTest.java index 7f37e0b012b..2cf2e2b294b 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/misc/ShadowIntegrityCheckerTest.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/misc/ShadowIntegrityCheckerTest.java @@ -12,7 +12,6 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.util.MidPointTestConstants; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType; import org.springframework.test.annotation.DirtiesContext; @@ -66,7 +65,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100FixDuplicatesWithDifferentObjectClasses() throws Exception { final String TEST_NAME = "test100FixDuplicatesWithDifferentObjectClasses"; - TestUtil.displayTestTitle(this, TEST_NAME); login(userAdministrator); Task task = getTestTask(); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/misc/TestRelationRegistry.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/misc/TestRelationRegistry.java index 5a282dfaf40..ff07b129b94 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/misc/TestRelationRegistry.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/misc/TestRelationRegistry.java @@ -12,7 +12,6 @@ import com.evolveum.midpoint.schema.constants.RelationTypes; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.test.util.MidPointTestConstants; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.RelationDefinitionType; import com.evolveum.midpoint.xml.ns._public.common.common_3.RelationKindType; @@ -55,7 +54,6 @@ public class TestRelationRegistry extends AbstractInternalModelIntegrationTest { @Test public void test100DefaultRelations() { final String TEST_NAME = "test100DefaultRelations"; - TestUtil.displayTestTitle(this, TEST_NAME); assertEquals("Wrong # of default relations", RelationTypes.values().length, relationRegistry.getRelationDefinitions().size()); @@ -137,7 +135,6 @@ public void test100DefaultRelations() { @Test public void test110AddedCustomRelations() throws SchemaException, IOException { final String TEST_NAME = "test110AddedCustomRelations"; - TestUtil.displayTestTitle(this, TEST_NAME); PrismObject sysconfigObject = prismContext.parseObject(SYSCONFIG_ADDED_CUSTOM_RELATIONS_FILE); relationRegistry.applyRelationsConfiguration(sysconfigObject.asObjectable()); @@ -259,7 +256,6 @@ public void test110AddedCustomRelations() throws SchemaException, IOException { @Test public void test120ReplacedAllRelations() throws SchemaException, IOException { final String TEST_NAME = "test120ReplacedAllRelations"; - TestUtil.displayTestTitle(this, TEST_NAME); PrismObject sysconfigObject = prismContext.parseObject(SYSCONFIG_REPLACED_ALL_RELATIONS_FILE); relationRegistry.applyRelationsConfiguration(sysconfigObject.asObjectable()); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/security/TestAbstractAuthenticationEvaluator.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/security/TestAbstractAuthenticationEvaluator.java index 2e612e59cc8..75719d77874 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/security/TestAbstractAuthenticationEvaluator.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/security/TestAbstractAuthenticationEvaluator.java @@ -26,7 +26,6 @@ import com.evolveum.midpoint.xml.ns._public.common.api_types_3.UserSessionManagementType; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.support.MessageSourceAccessor; -import org.springframework.security.access.AccessDeniedException; import org.springframework.security.authentication.BadCredentialsException; import org.springframework.security.authentication.CredentialsExpiredException; import org.springframework.security.authentication.DisabledException; @@ -61,8 +60,6 @@ import com.evolveum.midpoint.util.exception.PolicyViolationException; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.util.exception.SecurityViolationException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractCredentialType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.AuthorizationType; @@ -82,8 +79,6 @@ public abstract class TestAbstractAuthenticationEvaluator userAfter = getUser(USER_JACK_OID); @@ -273,9 +256,6 @@ public void test102PasswordLoginNullPasswordJack() throws Exception { @Test public void test103PasswordLoginEmptyPasswordJack() throws Exception { - final String TEST_NAME = "test103PasswordLoginEmptyPasswordJack"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN ConnectionEnvironment connEnv = createConnectionEnvironment(); @@ -292,9 +272,9 @@ public void test103PasswordLoginEmptyPasswordJack() throws Exception { // This is expected // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("expected exception", e); - assertPasswordEncodingException(e, USER_JACK_USERNAME); + assertPasswordEncodingException(e); } PrismObject userAfter = getUser(USER_JACK_OID); @@ -304,10 +284,7 @@ public void test103PasswordLoginEmptyPasswordJack() throws Exception { } @Test - public void test105PasswordLoginNullUsernameNullPassword() throws Exception { - final String TEST_NAME = "test105PasswordLoginNullUsernameNullPassword"; - TestUtil.displayTestTitle(TEST_NAME); - + public void test105PasswordLoginNullUsernameNullPassword() { // GIVEN ConnectionEnvironment connEnv = createConnectionEnvironment(); @@ -324,18 +301,15 @@ public void test105PasswordLoginNullUsernameNullPassword() throws Exception { // This is expected // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("expected exception", e); - assertPasswordEncodingException(e, null); + assertPasswordEncodingException(e); } } @Test - public void test106PasswordLoginEmptyUsernameBadPassword() throws Exception { - final String TEST_NAME = "test106PasswordLoginEmptyUsernameBadPassword"; - TestUtil.displayTestTitle(TEST_NAME); - + public void test106PasswordLoginEmptyUsernameBadPassword() { // GIVEN ConnectionEnvironment connEnv = createConnectionEnvironment(); @@ -352,18 +326,15 @@ public void test106PasswordLoginEmptyUsernameBadPassword() throws Exception { // This is expected // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("expected exception", e); - assertNoUserException(e, null); + assertNoUserException(e); } } @Test - public void test107PasswordLoginBadUsernameBadPassword() throws Exception { - final String TEST_NAME = "test107PasswordLoginBadUsernameBadPassword"; - TestUtil.displayTestTitle(TEST_NAME); - + public void test107PasswordLoginBadUsernameBadPassword() { // GIVEN ConnectionEnvironment connEnv = createConnectionEnvironment(); @@ -380,9 +351,9 @@ public void test107PasswordLoginBadUsernameBadPassword() throws Exception { // This is expected // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("expected exception", e); - assertNoUserException(e, null); + assertNoUserException(e); } } @@ -393,9 +364,6 @@ public void test107PasswordLoginBadUsernameBadPassword() throws Exception { */ @Test public void test125PasswordLoginBadPasswordJackAfterLockoutFailedAttemptsDuration() throws Exception { - final String TEST_NAME = "test125PasswordLoginBadPasswordJackAfterLockoutFailedAttemptsDuration"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN clock.overrideDuration("PT5M"); @@ -415,9 +383,9 @@ public void test125PasswordLoginBadPasswordJackAfterLockoutFailedAttemptsDuratio // This is expected // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("expected exception", e); - assertBadPasswordException(e, USER_JACK_USERNAME); + assertBadPasswordException(e); } XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -431,9 +399,6 @@ public void test125PasswordLoginBadPasswordJackAfterLockoutFailedAttemptsDuratio @Test public void test130PasswordLoginLockout() throws Exception { - final String TEST_NAME = "test130PasswordLoginLockout"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN ConnectionEnvironment connEnv = createConnectionEnvironment(); XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); @@ -449,7 +414,7 @@ public void test130PasswordLoginLockout() throws Exception { // This is expected display("expected exception", e); - assertBadPasswordException(e, USER_JACK_USERNAME); + assertBadPasswordException(e); } PrismObject userBetween = getUser(USER_JACK_OID); @@ -466,14 +431,14 @@ public void test130PasswordLoginLockout() throws Exception { // This is expected display("expected exception", e); - assertBadPasswordException(e, USER_JACK_USERNAME); + assertBadPasswordException(e); } XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject userAfter = getUser(USER_JACK_OID); display("user after", userAfter); @@ -484,9 +449,6 @@ public void test130PasswordLoginLockout() throws Exception { @Test public void test132PasswordLoginLockedoutGoodPassword() throws Exception { - final String TEST_NAME = "test132PasswordLoginLockedoutGoodPassword"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN ConnectionEnvironment connEnv = createConnectionEnvironment(); @@ -501,9 +463,9 @@ public void test132PasswordLoginLockedoutGoodPassword() throws Exception { // This is expected // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("expected exception", e); - assertLockedException(e, USER_JACK_USERNAME); + assertLockedException(e); } PrismObject userAfter = getUser(USER_JACK_OID); @@ -514,9 +476,6 @@ public void test132PasswordLoginLockedoutGoodPassword() throws Exception { @Test public void test133PasswordLoginLockedoutBadPassword() throws Exception { - final String TEST_NAME = "test133PasswordLoginLockedoutBadPassword"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN ConnectionEnvironment connEnv = createConnectionEnvironment(); @@ -531,12 +490,12 @@ public void test133PasswordLoginLockedoutBadPassword() throws Exception { // This is expected // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("expected exception", e); // this is important. The exception should give no indication whether the password is // good or bad - assertLockedException(e, USER_JACK_USERNAME); + assertLockedException(e); } PrismObject userAfter = getUser(USER_JACK_OID); @@ -547,9 +506,6 @@ public void test133PasswordLoginLockedoutBadPassword() throws Exception { @Test public void test135PasswordLoginLockedoutLockExpires() throws Exception { - final String TEST_NAME = "test135PasswordLoginLockedoutLockExpires"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN clock.overrideDuration("PT30M"); @@ -561,7 +517,7 @@ public void test135PasswordLoginLockedoutLockExpires() throws Exception { Authentication authentication = getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_JACK_USERNAME, getGoodPasswordJack())); // THEN - TestUtil.displayThen(TEST_NAME); + then(); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); assertGoodPasswordAuthentication(authentication, USER_JACK_USERNAME); @@ -574,9 +530,6 @@ public void test135PasswordLoginLockedoutLockExpires() throws Exception { @Test public void test136PasswordLoginLockoutAgain() throws Exception { - final String TEST_NAME = "test136PasswordLoginLockoutAgain"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN ConnectionEnvironment connEnv = createConnectionEnvironment(); XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); @@ -592,9 +545,9 @@ public void test136PasswordLoginLockoutAgain() throws Exception { // This is expected // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("expected exception", e); - assertBadPasswordException(e, USER_JACK_USERNAME); + assertBadPasswordException(e); } PrismObject userBetween = getUser(USER_JACK_OID); @@ -611,9 +564,9 @@ public void test136PasswordLoginLockoutAgain() throws Exception { // This is expected // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("expected exception", e); - assertBadPasswordException(e, USER_JACK_USERNAME); + assertBadPasswordException(e); } userBetween = getUser(USER_JACK_OID); @@ -630,9 +583,9 @@ public void test136PasswordLoginLockoutAgain() throws Exception { // This is expected // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("expected exception", e); - assertBadPasswordException(e, USER_JACK_USERNAME); + assertBadPasswordException(e); } @@ -647,9 +600,6 @@ public void test136PasswordLoginLockoutAgain() throws Exception { @Test public void test137PasswordLoginLockedoutGoodPasswordAgain() throws Exception { - final String TEST_NAME = "test137PasswordLoginLockedoutGoodPasswordAgain"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN ConnectionEnvironment connEnv = createConnectionEnvironment(); @@ -664,9 +614,9 @@ public void test137PasswordLoginLockedoutGoodPasswordAgain() throws Exception { // This is expected // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("expected exception", e); - assertLockedException(e, USER_JACK_USERNAME); + assertLockedException(e); } PrismObject userAfter = getUser(USER_JACK_OID); @@ -677,9 +627,6 @@ public void test137PasswordLoginLockedoutGoodPasswordAgain() throws Exception { @Test public void test138UnlockUserGoodPassword() throws Exception { - final String TEST_NAME = "test138UnlockUserGoodPassword"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN TestAbstractAuthenticationEvaluator.class.getName(); Task task = getTestTask(); @@ -692,7 +639,7 @@ public void test138UnlockUserGoodPassword() throws Exception { modifyUserReplace(USER_JACK_OID, SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS, task, result, LockoutStatusType.NORMAL); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject userBetween = getUser(USER_JACK_OID); display("user after", userBetween); @@ -707,7 +654,7 @@ public void test138UnlockUserGoodPassword() throws Exception { Authentication authentication = getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_JACK_USERNAME, getGoodPasswordJack())); // THEN - TestUtil.displayThen(TEST_NAME); + then(); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); assertGoodPasswordAuthentication(authentication, USER_JACK_USERNAME); @@ -723,9 +670,6 @@ public void test138UnlockUserGoodPassword() throws Exception { */ @Test public void test139TryToLockByModelService() throws Exception { - final String TEST_NAME = "test139TryToLockByModelService"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN TestAbstractAuthenticationEvaluator.class.getName(); Task task = getTestTask(); @@ -742,7 +686,7 @@ public void test139TryToLockByModelService() throws Exception { // This is expected // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("expected exception", e); } @@ -755,37 +699,28 @@ public void test139TryToLockByModelService() throws Exception { @Test public void test150PasswordLoginDisabledGoodPassword() throws Exception { - final String TEST_NAME = "test150PasswordLoginDisabledGoodPassword"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN TestAbstractAuthenticationEvaluator.class.getName(); Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_JACK_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.DISABLED); - loginJackGoodPasswordExpectDenied(TEST_NAME, task, result); + loginJackGoodPasswordExpectDenied(); } @Test public void test152PasswordLoginEnabledGoodPassword() throws Exception { - final String TEST_NAME = "test152PasswordLoginEnabledGoodPassword"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN TestAbstractAuthenticationEvaluator.class.getName(); Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_JACK_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.ENABLED); - loginJackGoodPasswordExpectSuccess(TEST_NAME, task, result); + loginJackGoodPasswordExpectSuccess(); } @Test public void test154PasswordLoginNotValidYetGoodPassword() throws Exception { - final String TEST_NAME = "test154PasswordLoginNotValidYetGoodPassword"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN TestAbstractAuthenticationEvaluator.class.getName(); Task task = getTestTask(); @@ -798,58 +733,42 @@ public void test154PasswordLoginNotValidYetGoodPassword() throws Exception { modifyUserReplace(USER_JACK_OID, ACTIVATION_VALID_FROM_PATH, task, result, validFrom); modifyUserReplace(USER_JACK_OID, ACTIVATION_VALID_TO_PATH, task, result, validTo); - loginJackGoodPasswordExpectDenied(TEST_NAME, task, result); + loginJackGoodPasswordExpectDenied(); } @Test public void test155PasswordLoginValidGoodPassword() throws Exception { - final String TEST_NAME = "test155PasswordLoginValidGoodPassword"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN clock.overrideDuration("PT2H"); TestAbstractAuthenticationEvaluator.class.getName(); - Task task = getTestTask(); - OperationResult result = task.getResult(); - loginJackGoodPasswordExpectSuccess(TEST_NAME, task, result); + loginJackGoodPasswordExpectSuccess(); } @Test public void test156PasswordLoginNotValidAnyLongerGoodPassword() throws Exception { - final String TEST_NAME = "test156PasswordLoginNotValidAnyLongerGoodPassword"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN clock.overrideDuration("P2D"); TestAbstractAuthenticationEvaluator.class.getName(); - Task task = getTestTask(); - OperationResult result = task.getResult(); - loginJackGoodPasswordExpectDenied(TEST_NAME, task, result); + loginJackGoodPasswordExpectDenied(); } @Test public void test159PasswordLoginNoLongerValidEnabledGoodPassword() throws Exception { - final String TEST_NAME = "test159PasswordLoginNoLongerValidEnabledGoodPassword"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN TestAbstractAuthenticationEvaluator.class.getName(); Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_JACK_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.ENABLED); - loginJackGoodPasswordExpectSuccess(TEST_NAME, task, result); + loginJackGoodPasswordExpectSuccess(); } @Test public void test160PasswordLoginLifecycleActiveGoodPassword() throws Exception { - final String TEST_NAME = "test160PasswordLoginLifecycleActiveGoodPassword"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN TestAbstractAuthenticationEvaluator.class.getName(); Task task = getTestTask(); @@ -858,14 +777,11 @@ public void test160PasswordLoginLifecycleActiveGoodPassword() throws Exception { modifyUserReplace(USER_JACK_OID, UserType.F_LIFECYCLE_STATE, task, result, SchemaConstants.LIFECYCLE_ACTIVE); - loginJackGoodPasswordExpectSuccess(TEST_NAME, task, result); + loginJackGoodPasswordExpectSuccess(); } @Test public void test162PasswordLoginLifecycleDraftGoodPassword() throws Exception { - final String TEST_NAME = "test162PasswordLoginLifecycleDraftGoodPassword"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN TestAbstractAuthenticationEvaluator.class.getName(); Task task = getTestTask(); @@ -874,14 +790,11 @@ public void test162PasswordLoginLifecycleDraftGoodPassword() throws Exception { modifyUserReplace(USER_JACK_OID, UserType.F_LIFECYCLE_STATE, task, result, SchemaConstants.LIFECYCLE_DRAFT); - loginJackGoodPasswordExpectDenied(TEST_NAME, task, result); + loginJackGoodPasswordExpectDenied(); } @Test public void test164PasswordLoginLifecycleDeprecatedGoodPassword() throws Exception { - final String TEST_NAME = "test164PasswordLoginLifecycleDeprecatedGoodPassword"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN TestAbstractAuthenticationEvaluator.class.getName(); Task task = getTestTask(); @@ -890,14 +803,11 @@ public void test164PasswordLoginLifecycleDeprecatedGoodPassword() throws Excepti modifyUserReplace(USER_JACK_OID, UserType.F_LIFECYCLE_STATE, task, result, SchemaConstants.LIFECYCLE_DEPRECATED); - loginJackGoodPasswordExpectSuccess(TEST_NAME, task, result); + loginJackGoodPasswordExpectSuccess(); } @Test public void test166PasswordLoginLifecycleProposedGoodPassword() throws Exception { - final String TEST_NAME = "test166PasswordLoginLifecycleProposedGoodPassword"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN TestAbstractAuthenticationEvaluator.class.getName(); Task task = getTestTask(); @@ -906,14 +816,11 @@ public void test166PasswordLoginLifecycleProposedGoodPassword() throws Exception modifyUserReplace(USER_JACK_OID, UserType.F_LIFECYCLE_STATE, task, result, SchemaConstants.LIFECYCLE_PROPOSED); - loginJackGoodPasswordExpectDenied(TEST_NAME, task, result); + loginJackGoodPasswordExpectDenied(); } @Test public void test168PasswordLoginLifecycleArchivedGoodPassword() throws Exception { - final String TEST_NAME = "test168PasswordLoginLifecycleArchivedGoodPassword"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN TestAbstractAuthenticationEvaluator.class.getName(); Task task = getTestTask(); @@ -922,14 +829,11 @@ public void test168PasswordLoginLifecycleArchivedGoodPassword() throws Exception modifyUserReplace(USER_JACK_OID, UserType.F_LIFECYCLE_STATE, task, result, SchemaConstants.LIFECYCLE_ARCHIVED); - loginJackGoodPasswordExpectDenied(TEST_NAME, task, result); + loginJackGoodPasswordExpectDenied(); } @Test public void test200UserGuybrushSetCredentials() throws Exception { - final String TEST_NAME = "test200UserGuybrushSetPassword"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN TestAbstractAuthenticationEvaluator.class.getName(); Task task = getTestTask(); @@ -942,7 +846,7 @@ public void test200UserGuybrushSetCredentials() throws Exception { modifyUserCredential(task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -956,9 +860,6 @@ public void test200UserGuybrushSetCredentials() throws Exception { @Test public void test201UserGuybrushPasswordLoginGoodPassword() throws Exception { - final String TEST_NAME = "test201UserGuybrushPasswordLoginGoodPassword"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN ConnectionEnvironment connEnv = createConnectionEnvironment(); XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); @@ -968,7 +869,7 @@ public void test201UserGuybrushPasswordLoginGoodPassword() throws Exception { Authentication authentication = getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_GUYBRUSH_USERNAME, getGoodPasswordGuybrush())); // THEN - TestUtil.displayThen(TEST_NAME); + then(); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); assertGoodPasswordAuthentication(authentication, USER_GUYBRUSH_USERNAME); @@ -980,9 +881,6 @@ public void test201UserGuybrushPasswordLoginGoodPassword() throws Exception { @Test public void test202UserGuybrushPasswordLoginBadPassword() throws Exception { - final String TEST_NAME = "test202UserGuybrushPasswordLoginBadPassword"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN ConnectionEnvironment connEnv = createConnectionEnvironment(); XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); @@ -1000,9 +898,9 @@ public void test202UserGuybrushPasswordLoginBadPassword() throws Exception { // This is expected // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("expected exception", e); - assertBadPasswordException(e, USER_GUYBRUSH_USERNAME); + assertBadPasswordException(e); } XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -1014,9 +912,6 @@ public void test202UserGuybrushPasswordLoginBadPassword() throws Exception { @Test public void test209UserGuybrushPasswordLoginGoodPasswordBeforeExpiration() throws Exception { - final String TEST_NAME = "test209UserGuybrushPasswordLoginGoodPasswordBeforeExpiration"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN clock.overrideDuration("P29D"); @@ -1028,7 +923,7 @@ public void test209UserGuybrushPasswordLoginGoodPasswordBeforeExpiration() throw Authentication authentication = getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_GUYBRUSH_USERNAME, getGoodPasswordGuybrush())); // THEN - TestUtil.displayThen(TEST_NAME); + then(); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); assertGoodPasswordAuthentication(authentication, USER_GUYBRUSH_USERNAME); @@ -1040,14 +935,10 @@ public void test209UserGuybrushPasswordLoginGoodPasswordBeforeExpiration() throw @Test public void test210UserGuybrushPasswordLoginGoodPasswordExpired() throws Exception { - final String TEST_NAME = "test210UserGuybrushPasswordLoginGoodPasswordExpired"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN clock.overrideDuration("P2D"); ConnectionEnvironment connEnv = createConnectionEnvironment(); - XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); try { @@ -1062,11 +953,10 @@ public void test210UserGuybrushPasswordLoginGoodPasswordExpired() throws Excepti // This is expected // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("expected exception", e); - assertExpiredException(e, USER_GUYBRUSH_USERNAME); + assertExpiredException(e); } - XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); display("user after", userAfter); @@ -1080,7 +970,7 @@ private void assertGoodPasswordAuthentication(Authentication authentication, Str assertEquals("authentication: principal mismatch", expectedUsername, ((MidPointPrincipal)authentication.getPrincipal()).getUsername()); } - private void assertBadPasswordException(BadCredentialsException e, String username) { + private void assertBadPasswordException(BadCredentialsException e) { assertEquals("Wrong exception meessage (key)", messages.getMessage("web.security.provider.invalid"), getTranslatedMessage(e)); } @@ -1088,27 +978,23 @@ private String getTranslatedMessage(Throwable t) { return localizationService.translate(t.getMessage(), new Object[0], Locale.getDefault()); } - private void assertPasswordEncodingException(BadCredentialsException e, String principal) { + private void assertPasswordEncodingException(BadCredentialsException e) { assertEquals("Wrong exception meessage (key)", messages.getMessage("web.security.provider.password.encoding"), getTranslatedMessage(e)); } - private void assertDeniedException(AccessDeniedException e, String principal) { - assertEquals("Wrong exception meessage (key)", messages.getMessage("web.security.provider.access.denied"), getTranslatedMessage(e)); - } - - private void assertLockedException(LockedException e, String principal) { + private void assertLockedException(LockedException e) { assertEquals("Wrong exception meessage (key)", messages.getMessage("web.security.provider.locked"), getTranslatedMessage(e)); } - private void assertDisabledException(DisabledException e, String principal) { + private void assertDisabledException(DisabledException e) { assertEquals("Wrong exception meessage (key)", messages.getMessage("web.security.provider.disabled"), getTranslatedMessage(e)); } - private void assertExpiredException(CredentialsExpiredException e, String principal) { + private void assertExpiredException(CredentialsExpiredException e) { assertEquals("Wrong exception meessage (key)", messages.getMessage("web.security.provider.credential.expired"), getTranslatedMessage(e)); } - private void assertNoUserException(UsernameNotFoundException e, String principal) { + private void assertNoUserException(UsernameNotFoundException e) { assertEquals("Wrong exception meessage (key)", messages.getMessage("web.security.provider.invalid"), getTranslatedMessage(e)); } @@ -1161,7 +1047,9 @@ private void assertPrincipalJack(MidPointPrincipal principal) { assertEquals("Bad name in user in principal", USER_JACK_USERNAME, user.getName().getOrig()); } - private void loginJackGoodPasswordExpectSuccess(final String TEST_NAME, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + private void loginJackGoodPasswordExpectSuccess() + throws ObjectNotFoundException, SchemaException, SecurityViolationException, + CommunicationException, ConfigurationException, ExpressionEvaluationException { display("now", clock.currentTimeXMLGregorianCalendar()); ConnectionEnvironment connEnv = createConnectionEnvironment(); XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); @@ -1171,7 +1059,7 @@ private void loginJackGoodPasswordExpectSuccess(final String TEST_NAME, Task tas Authentication authentication = getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_JACK_USERNAME, getGoodPasswordJack())); // THEN - TestUtil.displayThen(TEST_NAME); + then(); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); assertGoodPasswordAuthentication(authentication, USER_JACK_USERNAME); @@ -1181,10 +1069,9 @@ private void loginJackGoodPasswordExpectSuccess(final String TEST_NAME, Task tas assertLastSuccessfulLogin(userAfter, startTs, endTs); } - private void loginJackGoodPasswordExpectDenied(final String TEST_NAME, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + private void loginJackGoodPasswordExpectDenied() throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { display("now", clock.currentTimeXMLGregorianCalendar()); ConnectionEnvironment connEnv = createConnectionEnvironment(); - XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN when(); @@ -1197,12 +1084,12 @@ private void loginJackGoodPasswordExpectDenied(final String TEST_NAME, Task task // This is expected // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("expected exception", e); // this is important. The exception should give no indication whether the password is // good or bad - assertDisabledException(e, USER_JACK_USERNAME); + assertDisabledException(e); } PrismObject userAfter = getUser(USER_JACK_OID); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/security/TestGuiProfiledPrincipalManager.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/security/TestGuiProfiledPrincipalManager.java index 7ca41d0031a..a33e76abd0a 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/security/TestGuiProfiledPrincipalManager.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/security/TestGuiProfiledPrincipalManager.java @@ -11,7 +11,6 @@ import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.security.api.DelegatorWithOtherPrivilegesLimitations; import com.evolveum.midpoint.security.api.MidPointPrincipal; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DebugUtil; import com.evolveum.midpoint.util.exception.CommonException; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; @@ -79,7 +78,6 @@ public void test140DeputyBlockOtherPrivileges() throws Exception { private void executeDeputyLimitationsTest(String TEST_NAME, List expectedLimitations, Consumer assignmentModifier) throws CommonException { - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN AssignmentType assignment = new AssignmentType() @@ -99,7 +97,7 @@ private void executeDeputyLimitationsTest(String TEST_NAME, List delegators = principal.getDelegatorWithOtherPrivilegesLimitationsCollection(); display("delegators with other privileges limitations", delegators); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestActivation.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestActivation.java index 1ff5879b9c4..d3859cedadb 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestActivation.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestActivation.java @@ -574,8 +574,6 @@ public void test101ModifyUserJackDisable() throws Exception { @Test public void test102ModifyUserJackEnable() throws Exception { - TestUtil.displayTestTitle(this, "test102ModifyUserJackEnable"); - // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + ".test052ModifyUserJackEnable"); OperationResult result = task.getResult(); @@ -605,7 +603,6 @@ public void test102ModifyUserJackEnable() throws Exception { */ @Test public void test111ModifyAccountJackDisable() throws Exception { - TestUtil.displayTestTitle(this, "test111ModifyAccountJackDisable"); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + ".test111ModifyAccountJackDisable"); @@ -899,7 +896,6 @@ public void test121ModifyJackUserAndAccountRed() throws Exception { @Test public void test130ModifyAccountDefaultAndRed() throws Exception { - TestUtil.displayTestTitle(this, "test130ModifyAccountDefaultAndRed"); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + ".test121ModifyJackPasswordUserAndAccountRed"); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestCaseIgnore.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestCaseIgnore.java index b8c9282ed19..b633cd98702 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestCaseIgnore.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestCaseIgnore.java @@ -176,7 +176,7 @@ public void test133SeachAccountShadows() throws Exception { SearchResultList> foundShadows = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestLoggingConfiguration.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestLoggingConfiguration.java index 2e35fe6d0a9..e8479b0b67a 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestLoggingConfiguration.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestLoggingConfiguration.java @@ -65,14 +65,11 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test001CreateSystemConfiguration() throws Exception { - final String TEST_NAME = "test001CreateSystemConfiguration"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN LogfileTestTailer tailer = new LogfileTestTailer(LoggingConfigurationManager.AUDIT_LOGGER_NAME); PrismObject systemConfiguration = PrismTestUtil.parseObject(SYSTEM_CONFIGURATION_FILE); - Task task = taskManager.createTaskInstance(TestLoggingConfiguration.class.getName() + "." + TEST_NAME); + Task task = createPlainTask(); OperationResult result = task.getResult(); ObjectDelta systemConfigurationAddDelta = DeltaFactory.Object.createAddDelta(systemConfiguration); Collection> deltas = MiscSchemaUtil.createCollection(systemConfigurationAddDelta); @@ -92,13 +89,10 @@ public void test001CreateSystemConfiguration() throws Exception { @Test public void test002InitialConfiguration() throws Exception { - final String TEST_NAME = "test002InitialConfiguration"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN LogfileTestTailer tailer = new LogfileTestTailer(LoggingConfigurationManager.AUDIT_LOGGER_NAME); - Task task = taskManager.createTaskInstance(TestLoggingConfiguration.class.getName() + "." + TEST_NAME); + Task task = createPlainTask(); OperationResult result = task.getResult(); PrismObject systemConfiguration = PrismTestUtil.parseObject(SYSTEM_CONFIGURATION_FILE); @@ -146,13 +140,10 @@ public void test002InitialConfiguration() throws Exception { */ @Test public void test004OverwriteInitialConfiguration() throws Exception { - final String TEST_NAME = "test004OverwriteInitialConfiguration"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN LogfileTestTailer tailer = new LogfileTestTailer(LoggingConfigurationManager.AUDIT_LOGGER_NAME); - Task task = taskManager.createTaskInstance(TestLoggingConfiguration.class.getName() + "." + TEST_NAME); + Task task = createPlainTask(); OperationResult result = task.getResult(); PrismObject systemConfiguration = getObject(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value()); @@ -191,13 +182,10 @@ public void test004OverwriteInitialConfiguration() throws Exception { @Test public void test010AddModelSubsystemLogger() throws Exception { - final String TEST_NAME = "test010AddModelSubsystemLogger"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN LogfileTestTailer tailer = new LogfileTestTailer(LoggingConfigurationManager.AUDIT_LOGGER_NAME); - Task task = taskManager.createTaskInstance(TestLoggingConfiguration.class.getName() + "." + TEST_NAME); + Task task = createPlainTask(); OperationResult result = task.getResult(); // Precondition @@ -253,9 +241,6 @@ public void test010AddModelSubsystemLogger() throws Exception { @Test public void test020JulLoggingDisabled() throws Exception { - final String TEST_NAME = "test020JulLoggingDisabled"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN LogfileTestTailer tailer = new LogfileTestTailer(LoggingConfigurationManager.AUDIT_LOGGER_NAME); @@ -284,15 +269,12 @@ public void test020JulLoggingDisabled() throws Exception { @Test public void test021JulLoggingEnabled() throws Exception { - final String TEST_NAME = "test021JulLoggingEnabled"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN LogfileTestTailer tailer = new LogfileTestTailer(LoggingConfigurationManager.AUDIT_LOGGER_NAME); java.util.logging.Logger julLogger = java.util.logging.Logger.getLogger(JUL_LOGGER_NAME); - Task task = taskManager.createTaskInstance(TestLoggingConfiguration.class.getName() + "." + TEST_NAME); + Task task = createPlainTask(); OperationResult result = task.getResult(); // Setup @@ -341,15 +323,12 @@ public void test021JulLoggingEnabled() throws Exception { */ @Test public void test030ConnectorLogging() throws Exception { - final String TEST_NAME = "test030ConnectorLogging"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN LogfileTestTailer tailer = new LogfileTestTailer(LoggingConfigurationManager.AUDIT_LOGGER_NAME); // ICF logging is prefixing the messages; tailer.setAllowPrefix(true); - Task task = taskManager.createTaskInstance(TestLoggingConfiguration.class.getName() + "." + TEST_NAME); + Task task = createPlainTask(); OperationResult result = task.getResult(); importObjectFromFile(RESOURCE_DUMMY_FILE, result); @@ -361,10 +340,10 @@ public void test030ConnectorLogging() throws Exception { applyTestLoggingConfig(logging); - ClassLoggerConfigurationType classLogerCongif = new ClassLoggerConfigurationType(); - classLogerCongif.setPackage(DummyConnector.class.getPackage().getName()); - classLogerCongif.setLevel(LoggingLevelType.ALL); - logging.getClassLogger().add(classLogerCongif); + ClassLoggerConfigurationType classLoggerConfig = new ClassLoggerConfigurationType(); + classLoggerConfig.setPackage(DummyConnector.class.getPackage().getName()); + classLoggerConfig.setLevel(LoggingLevelType.ALL); + logging.getClassLogger().add(classLoggerConfig); ObjectDelta systemConfigDelta = prismContext.deltaFactory().object().createModificationReplaceContainer(SystemConfigurationType.class, AbstractInitializedModelIntegrationTest.SYSTEM_CONFIGURATION_OID, SystemConfigurationType.F_LOGGING, @@ -375,9 +354,10 @@ public void test030ConnectorLogging() throws Exception { // INFO part - java.util.logging.Logger dummyConnctorJulLogger = java.util.logging.Logger.getLogger(DummyConnector.class.getName()); + java.util.logging.Logger dummyConnectorJulLogger = + java.util.logging.Logger.getLogger(DummyConnector.class.getName()); LOGGER.info("Dummy connector JUL logger as seen by the test: {}; classloader {}", - dummyConnctorJulLogger, dummyConnctorJulLogger.getClass().getClassLoader()); + dummyConnectorJulLogger, dummyConnectorJulLogger.getClass().getClassLoader()); // WHEN modelService.testResource(RESOURCE_DUMMY_OID, task); @@ -403,8 +383,6 @@ public void test030ConnectorLogging() throws Exception { @Test public void test101EnableBasicAudit() throws Exception { - TestUtil.displayTestTitle("test101EnableBasicAudit"); - // GIVEN LogfileTestTailer tailer = new LogfileTestTailer(LoggingConfigurationManager.AUDIT_LOGGER_NAME); @@ -417,7 +395,7 @@ public void test101EnableBasicAudit() throws Exception { // Setup PrismObject systemConfiguration = - PrismTestUtil.parseObject(AbstractInitializedModelIntegrationTest.SYSTEM_CONFIGURATION_FILE); + PrismTestUtil.parseObject(AbstractInitializedModelIntegrationTest.SYSTEM_CONFIGURATION_FILE); LoggingConfigurationType logging = systemConfiguration.asObjectable().getLogging(); applyTestLoggingConfig(logging); @@ -468,15 +446,13 @@ public void test101EnableBasicAudit() throws Exception { // MID-5674 @Test public void test110SetMaxHistory() throws Exception { - TestUtil.displayTestTitle("test110SetMaxHistory"); - // GIVEN Task task = taskManager.createTaskInstance(TestLoggingConfiguration.class.getName() + ".test101EnableBasicAudit"); OperationResult result = task.getResult(); // Setup PrismObject systemConfiguration = - PrismTestUtil.parseObject(AbstractInitializedModelIntegrationTest.SYSTEM_CONFIGURATION_FILE); + PrismTestUtil.parseObject(AbstractInitializedModelIntegrationTest.SYSTEM_CONFIGURATION_FILE); LoggingConfigurationType logging = systemConfiguration.asObjectable().getLogging(); applyTestLoggingConfig(logging); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestMerge.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestMerge.java index fdc06b6a412..233651495f0 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestMerge.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestMerge.java @@ -70,7 +70,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - TestUtil.displayTestTitle(this, TEST_NAME); PrismObject userJackBefore = getUser(USER_JACK_OID); display("Jack before", userJackBefore); @@ -98,7 +97,6 @@ public void test000Sanity() throws Exception { @Test public void test100MergeJackGuybrushPreviewDelta() throws Exception { final String TEST_NAME = "test100MergeJackGuybrushPreviewDelta"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestMerge.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -116,7 +114,7 @@ public void test100MergeJackGuybrushPreviewDelta() throws Exception { USER_JACK_OID, USER_GUYBRUSH_OID, MERGE_CONFIG_DEFAULT_NAME, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -161,7 +159,6 @@ public void test100MergeJackGuybrushPreviewDelta() throws Exception { @Test public void test102MergeJackGuybrushPreviewObject() throws Exception { final String TEST_NAME = "test102MergeJackGuybrushPreviewObject"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestMerge.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -173,7 +170,7 @@ public void test102MergeJackGuybrushPreviewObject() throws Exception { USER_JACK_OID, USER_GUYBRUSH_OID, MERGE_CONFIG_DEFAULT_NAME, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -212,7 +209,6 @@ public void test102MergeJackGuybrushPreviewObject() throws Exception { @Test public void test110MergeGuybrushJackPreviewDelta() throws Exception { final String TEST_NAME = "test110MergeGuybrushJackPreviewDelta"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestMerge.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -230,7 +226,7 @@ public void test110MergeGuybrushJackPreviewDelta() throws Exception { USER_GUYBRUSH_OID, USER_JACK_OID, MERGE_CONFIG_DEFAULT_NAME, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -272,7 +268,6 @@ public void test110MergeGuybrushJackPreviewDelta() throws Exception { @Test public void test112MergeGuybrushJackPreviewObject() throws Exception { final String TEST_NAME = "test112MergeGuybrushJackPreviewObject"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestMerge.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -284,7 +279,7 @@ public void test112MergeGuybrushJackPreviewObject() throws Exception { USER_GUYBRUSH_OID, USER_JACK_OID, MERGE_CONFIG_DEFAULT_NAME, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -320,7 +315,6 @@ public void test112MergeGuybrushJackPreviewObject() throws Exception { @Test public void test200MergeJackGuybrushExpressionPreviewDelta() throws Exception { final String TEST_NAME = "test200MergeJackGuybrushExpressionPreviewDelta"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestMerge.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -338,7 +332,7 @@ public void test200MergeJackGuybrushExpressionPreviewDelta() throws Exception { USER_JACK_OID, USER_GUYBRUSH_OID, MERGE_CONFIG_EXPRESSION_NAME, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -373,7 +367,6 @@ public void test200MergeJackGuybrushExpressionPreviewDelta() throws Exception { @Test public void test202MergeJackGuybrushExpressionPreviewObject() throws Exception { final String TEST_NAME = "test202MergeJackGuybrushExpressionPreviewObject"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestMerge.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -385,7 +378,7 @@ public void test202MergeJackGuybrushExpressionPreviewObject() throws Exception { USER_JACK_OID, USER_GUYBRUSH_OID, MERGE_CONFIG_EXPRESSION_NAME, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -424,7 +417,6 @@ public void test202MergeJackGuybrushExpressionPreviewObject() throws Exception { @Test public void test300MergeJackGuybrushPreviewDeltaDefaultSpecific() throws Exception { final String TEST_NAME = "test300MergeJackGuybrushPreviewDeltaDefaultSpecific"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestMerge.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -442,7 +434,7 @@ public void test300MergeJackGuybrushPreviewDeltaDefaultSpecific() throws Excepti USER_JACK_OID, USER_GUYBRUSH_OID, MERGE_CONFIG_DEFAULT_SPECIFIC_NAME, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -487,7 +479,6 @@ public void test300MergeJackGuybrushPreviewDeltaDefaultSpecific() throws Excepti @Test public void test500MergeJackGuybrush() throws Exception { final String TEST_NAME = "test500MergeJackGuybrush"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestMerge.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -498,7 +489,7 @@ public void test500MergeJackGuybrush() throws Exception { USER_JACK_OID, USER_GUYBRUSH_OID, MERGE_CONFIG_DEFAULT_NAME, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelCrudService.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelCrudService.java index c7be4d86f60..42d5fbf3cb2 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelCrudService.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelCrudService.java @@ -60,7 +60,6 @@ public class TestModelCrudService extends AbstractInitializedModelIntegrationTes @Test public void test050AddResource() throws Exception { final String TEST_NAME = "test050AddResource"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestModelCrudService.class.getName() + "." + TEST_NAME); @@ -87,7 +86,6 @@ public void test050AddResource() throws Exception { @Test public void test100ModifyUserAddAccount() throws Exception { final String TEST_NAME = "test100ModifyUserAddAccount"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestModelCrudService.class.getName() + "." + TEST_NAME); @@ -133,7 +131,6 @@ public void test100ModifyUserAddAccount() throws Exception { @Test public void test119ModifyUserDeleteAccount() throws Exception { - TestUtil.displayTestTitle(this, "test119ModifyUserDeleteAccount"); // GIVEN Task task = taskManager.createTaskInstance(TestModelCrudService.class.getName() + ".test119ModifyUserDeleteAccount"); @@ -173,7 +170,6 @@ public void test119ModifyUserDeleteAccount() throws Exception { @Test public void test120AddAccount() throws Exception { - TestUtil.displayTestTitle(this, "test120AddAccount"); // GIVEN Task task = taskManager.createTaskInstance(TestModelCrudService.class.getName() + ".test120AddAccount"); @@ -206,7 +202,6 @@ public void test120AddAccount() throws Exception { @Test public void test121ModifyUserAddAccountRef() throws Exception { - TestUtil.displayTestTitle(this, "test121ModifyUserAddAccountRef"); // GIVEN Task task = taskManager.createTaskInstance(TestModelCrudService.class.getName() + ".test121ModifyUserAddAccountRef"); @@ -242,7 +237,6 @@ public void test121ModifyUserAddAccountRef() throws Exception { @Test public void test128ModifyUserDeleteAccountRef() throws Exception { - TestUtil.displayTestTitle(this, "test128ModifyUserDeleteAccountRef"); // GIVEN Task task = taskManager.createTaskInstance(TestModelCrudService.class.getName() + ".test128ModifyUserDeleteAccountRef"); @@ -280,7 +274,6 @@ public void test128ModifyUserDeleteAccountRef() throws Exception { @Test public void test129DeleteAccount() throws Exception { - TestUtil.displayTestTitle(this, "test129DeleteAccount"); // GIVEN Task task = taskManager.createTaskInstance(TestModelCrudService.class.getName() + ".test129DeleteAccount"); @@ -305,7 +298,6 @@ public void test129DeleteAccount() throws Exception { @Test public void test150AddUserBlackbeardWithAccount() throws Exception { - TestUtil.displayTestTitle(this, "test150AddUserBlackbeardWithAccount"); // GIVEN Task task = taskManager.createTaskInstance(TestModelCrudService.class.getName() + ".test150AddUserBlackbeardWithAccount"); @@ -342,7 +334,6 @@ public void test150AddUserBlackbeardWithAccount() throws Exception { @Test public void test210AddUserMorganWithAssignment() throws Exception { - TestUtil.displayTestTitle(this, "test210AddUserMorganWithAssignment"); // GIVEN Task task = taskManager.createTaskInstance(TestModelCrudService.class.getName() + ".test210AddUserMorganWithAssignment"); @@ -377,7 +368,6 @@ public void test210AddUserMorganWithAssignment() throws Exception { @Test public void test220DeleteUserMorgan() throws Exception { - TestUtil.displayTestTitle(this, "test220DeleteUserMorgan"); // GIVEN Task task = taskManager.createTaskInstance(TestModelCrudService.class.getName() + ".test220DeleteUserMorgan"); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelServiceContract.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelServiceContract.java index 8b5649091b5..716a1b09af2 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelServiceContract.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelServiceContract.java @@ -386,7 +386,6 @@ public void test101GetAccount() throws Exception { @Test public void test102GetAccountNoFetch() throws Exception { - TestUtil.displayTestTitle(this, "test102GetAccountNoFetch"); // GIVEN Task task = taskManager.createTaskInstance(TestModelServiceContract.class.getName() + ".test102GetAccountNoFetch"); @@ -413,7 +412,6 @@ public void test102GetAccountNoFetch() throws Exception { @Test public void test103GetAccountRaw() throws Exception { - TestUtil.displayTestTitle(this, "test103GetAccountRaw"); // GIVEN Task task = taskManager.createTaskInstance(TestModelServiceContract.class.getName() + ".test103GetAccountRaw"); @@ -440,7 +438,6 @@ public void test103GetAccountRaw() throws Exception { @Test public void test105SearchAccount() throws Exception { - TestUtil.displayTestTitle(this, "test105SearchAccount"); // GIVEN Task task = taskManager.createTaskInstance(TestModelServiceContract.class.getName() + ".test105SearchAccount"); @@ -472,7 +469,6 @@ public void test105SearchAccount() throws Exception { @Test public void test106SearchAccountWithoutResourceSchema() throws Exception { - TestUtil.displayTestTitle(this, "test106SearchAccountWithoutResourceSchema"); // GIVEN Task task = taskManager.createTaskInstance(TestModelServiceContract.class.getName() + ".test106SearchAccountWithoutResourceSchema"); @@ -499,7 +495,6 @@ public void test106SearchAccountWithoutResourceSchema() throws Exception { @Test public void test108ModifyUserAddAccountAgain() throws Exception { - TestUtil.displayTestTitle(this, "test108ModifyUserAddAccountAgain"); // GIVEN Task task = taskManager.createTaskInstance(TestModelServiceContract.class.getName() + ".test108ModifyUserAddAccountAgain"); @@ -933,7 +928,6 @@ public void test121ModifyUserAddAccountRef() throws Exception { @Test public void test128ModifyUserDeleteAccountRef() throws Exception { - TestUtil.displayTestTitle(this, "test128ModifyUserDeleteAccountRef"); // GIVEN Task task = taskManager.createTaskInstance(TestModelServiceContract.class.getName() + ".test128ModifyUserDeleteAccountRef"); @@ -1001,7 +995,6 @@ public void test128ModifyUserDeleteAccountRef() throws Exception { @Test public void test129DeleteAccount() throws Exception { - TestUtil.displayTestTitle(this, "test129DeleteAccount"); // GIVEN Task task = taskManager.createTaskInstance(TestModelServiceContract.class.getName() + ".test129DeleteAccount"); @@ -1060,7 +1053,6 @@ public void test129DeleteAccount() throws Exception { @Test public void test130PreviewModifyUserJackAssignAccount() throws Exception { - TestUtil.displayTestTitle(this, "test130PreviewModifyUserJackAssignAccount"); // GIVEN try{ @@ -2272,7 +2264,6 @@ public void test182ModifyUserAddAndAssignAccountPositiveEnforcement() throws Exc */ @Test public void test189ModifyUserJackUnassignAndDeleteAccount() throws Exception { - TestUtil.displayTestTitle(this, "test189ModifyUserJackUnassignAndDeleteAccount"); // GIVEN Task task = taskManager.createTaskInstance(TestModelServiceContract.class.getName() + ".test149ModifyUserJackUnassignAccount"); @@ -2767,7 +2758,6 @@ public void test195ModifyUserJackLocationSea() throws Exception { @Test public void test198ModifyUserJackRaw() throws Exception { - TestUtil.displayTestTitle(this, "test198ModifyUserJackRaw"); // GIVEN Task task = taskManager.createTaskInstance(TestModelServiceContract.class.getName() + ".test196ModifyUserJackRaw"); @@ -2821,7 +2811,6 @@ public void test198ModifyUserJackRaw() throws Exception { @Test public void test199DeleteUserJack() throws Exception { - TestUtil.displayTestTitle(this, "test199DeleteUserJack"); // GIVEN Task task = taskManager.createTaskInstance(TestModelServiceContract.class.getName() + ".test199DeleteUserJack"); @@ -3354,9 +3343,6 @@ accountJackBlueOid, getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).getAttr @Test // MID-5516 public void test400RemoveExtensionProtectedStringValue() throws Exception { - final String TEST_NAME = "test400RemoveExtensionProtectedStringValue"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelVisualization.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelVisualization.java index 16935396520..17efd1c8c83 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelVisualization.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelVisualization.java @@ -38,8 +38,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti public void test100VisualizeOneResource() throws Exception { final String TEST_NAME = "test100VisualizeOneResource"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN Task task = taskManager.createTaskInstance(TestModelVisualization.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -58,8 +56,6 @@ public void test100VisualizeOneResource() throws Exception { public void test110VisualizeTwoResources() throws Exception { final String TEST_NAME = "test110VisualizeTwoResources"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN Task task = taskManager.createTaskInstance(TestModelVisualization.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestNotifications.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestNotifications.java index 46b5f7df007..90d38b2af3e 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestNotifications.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestNotifications.java @@ -123,7 +123,6 @@ private int findFreePort() throws IOException { @Test public void test100ModifyUserAddAccount() throws Exception { final String TEST_NAME = "test100ModifyUserAddAccount"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestNotifications.class.getName() + ".test100ModifyUserAddAccount"); @@ -138,7 +137,7 @@ public void test100ModifyUserAddAccount() throws Exception { modifyUserAddAccount(USER_JACK_OID, ACCOUNT_JACK_DUMMY_FILE, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); @@ -214,7 +213,6 @@ public void test100ModifyUserAddAccount() throws Exception { @Test public void test119ModifyUserDeleteAccount() throws Exception { final String TEST_NAME = "test119ModifyUserDeleteAccount"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestNotifications.class.getName() + "." + TEST_NAME); @@ -236,7 +234,7 @@ public void test119ModifyUserDeleteAccount() throws Exception { modelService.executeChanges(deltas, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("executeChanges result", result, 2); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); @@ -288,7 +286,6 @@ public void test119ModifyUserDeleteAccount() throws Exception { @Test public void test131ModifyUserJackAssignAccount() throws Exception { final String TEST_NAME = "test131ModifyUserJackAssignAccount"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestNotifications.class.getName() + "." + TEST_NAME); @@ -302,7 +299,7 @@ public void test131ModifyUserJackAssignAccount() throws Exception { assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("executeChanges result", result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); @@ -363,7 +360,6 @@ public void test131ModifyUserJackAssignAccount() throws Exception { @Test public void test140ModifyUserJackAssignRole() throws Exception { final String TEST_NAME = "test135ModifyUserJackAssignRole"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestNotifications.class.getName() + "." + TEST_NAME); @@ -375,7 +371,7 @@ public void test140ModifyUserJackAssignRole() throws Exception { assignRole(USER_JACK_OID, ROLE_SUPERUSER_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("executeChanges result", result); @@ -416,7 +412,6 @@ public void test140ModifyUserJackAssignRole() throws Exception { @Test public void test150ModifyUserJackModifyAssignment() throws Exception { final String TEST_NAME = "test150ModifyUserJackModifyAssignment"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestNotifications.class.getName() + "." + TEST_NAME); @@ -435,7 +430,7 @@ public void test150ModifyUserJackModifyAssignment() throws Exception { .asObjectDeltaCast(jack.getOid()), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("executeChanges result", result); @@ -478,7 +473,6 @@ public void test150ModifyUserJackModifyAssignment() throws Exception { @Test public void test160ModifyUserJackDeleteAssignment() throws Exception { final String TEST_NAME = "test160ModifyUserJackDeleteAssignment"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestNotifications.class.getName() + "." + TEST_NAME); @@ -497,7 +491,7 @@ public void test160ModifyUserJackDeleteAssignment() throws Exception { .asObjectDeltaCast(jack.getOid()), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("executeChanges result", result); @@ -537,7 +531,6 @@ public void test160ModifyUserJackDeleteAssignment() throws Exception { @Test public void test200SendSmsUsingGet() { final String TEST_NAME = "test200SendSmsUsingGet"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestNotifications.class.getName() + "." + TEST_NAME); @@ -550,7 +543,7 @@ public void test200SendSmsUsingGet() { notificationManager.processEvent(event, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("processEvent result", result); @@ -562,7 +555,6 @@ public void test200SendSmsUsingGet() { @Test public void test210SendSmsUsingPost() { final String TEST_NAME = "test210SendSmsUsingPost"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestNotifications.class.getName() + "." + TEST_NAME); @@ -575,7 +567,7 @@ public void test210SendSmsUsingPost() { notificationManager.processEvent(event, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("processEvent result", result); @@ -595,7 +587,6 @@ public void test210SendSmsUsingPost() { @Test public void test215SendSmsUsingGeneralPost() { final String TEST_NAME = "test215SendSmsUsingGeneralPost"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestNotifications.class.getName() + "." + TEST_NAME); @@ -608,7 +599,7 @@ public void test215SendSmsUsingGeneralPost() { notificationManager.processEvent(event, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("processEvent result", result); @@ -628,7 +619,6 @@ public void test215SendSmsUsingGeneralPost() { @Test public void test220SendSmsViaProxy() { final String TEST_NAME = "test220SendSmsViaProxy"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestNotifications.class.getName() + "." + TEST_NAME); @@ -641,7 +631,7 @@ public void test220SendSmsViaProxy() { notificationManager.processEvent(event, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("processEvent result", result); @@ -654,7 +644,6 @@ public void test220SendSmsViaProxy() { @Test public void test300CheckVariables() { final String TEST_NAME = "test300CheckVariables"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestNotifications.class.getName() + "." + TEST_NAME); @@ -669,7 +658,7 @@ public void test300CheckVariables() { notificationManager.processEvent(event, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("processEvent result", result); @@ -680,7 +669,6 @@ public void test300CheckVariables() { @Test public void test400StringAttachment() throws Exception { final String TEST_NAME = "test400StringAttachment"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestNotifications.class.getName() + "." + TEST_NAME); @@ -695,7 +683,7 @@ public void test400StringAttachment() throws Exception { addObject(user); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("addObject result", result); @@ -717,7 +705,6 @@ public void test400StringAttachment() throws Exception { @Test public void test410ByteAttachment() throws Exception { final String TEST_NAME = "test410ByteAttachment"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestNotifications.class.getName() + "." + TEST_NAME); @@ -732,7 +719,7 @@ public void test410ByteAttachment() throws Exception { addObject(user); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("addObject result", result); @@ -768,7 +755,6 @@ public void test410ByteAttachment() throws Exception { @Test public void test420AttachmentFromFile() throws Exception { final String TEST_NAME = "test420AttachmentFromFile"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestNotifications.class.getName() + "." + TEST_NAME); @@ -783,7 +769,7 @@ public void test420AttachmentFromFile() throws Exception { addObject(user); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("addObject result", result); @@ -804,7 +790,6 @@ public void test420AttachmentFromFile() throws Exception { @Test public void test430ExpressionAttachment() throws Exception { final String TEST_NAME = "test430ExpressionAttachment"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestNotifications.class.getName() + "." + TEST_NAME); @@ -819,7 +804,7 @@ public void test430ExpressionAttachment() throws Exception { addObject(user); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("addObject result", result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestOptimizingTriggerCreator.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestOptimizingTriggerCreator.java index 345a3d2b6cb..e51648774c6 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestOptimizingTriggerCreator.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestOptimizingTriggerCreator.java @@ -9,7 +9,6 @@ import com.evolveum.midpoint.model.api.expr.OptimizingTriggerCreator; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; @@ -34,7 +33,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100CreateThreeTriggers() throws Exception { final String TEST_NAME = "test100CreateThreeTriggers"; - TestUtil.displayTestTitle(this, TEST_NAME); OptimizingTriggerCreator creator = libraryMidpointFunctions.getOptimizingTriggerCreator(60000, 2000); boolean first = creator.createForNamedUser(USER_JACK_USERNAME); @@ -51,7 +49,6 @@ public void test100CreateThreeTriggers() throws Exception { @Test public void test110CreateTriggersWithUserDeletion() throws Exception { final String TEST_NAME = "test110CreateTriggersWithUserDeletion"; - TestUtil.displayTestTitle(this, TEST_NAME); TestTriggerTask.class.getName(); Task task = getTestTask(); @@ -84,7 +81,6 @@ public void test110CreateTriggersWithUserDeletion() throws Exception { @Test public void test200CreateThreeTriggersByOid() throws Exception { final String TEST_NAME = "test200CreateThreeTriggersByOid"; - TestUtil.displayTestTitle(this, TEST_NAME); OptimizingTriggerCreator creator = libraryMidpointFunctions.getOptimizingTriggerCreator(60000, 2000); boolean first = creator.createForObject(UserType.class, USER_BARBOSSA_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestRaceConditions.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestRaceConditions.java index a50f14a6cab..b8156f99141 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestRaceConditions.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestRaceConditions.java @@ -67,7 +67,7 @@ public void test100AssignRoles() throws Exception { executeChangesAssertSuccess(objectDelta, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject userJack = getUser(USER_JACK_OID); display("User after change execution", userJack); assertUserJack(userJack); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestResources.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestResources.java index c9f4df1ee78..fd9f931a728 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestResources.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestResources.java @@ -1141,9 +1141,7 @@ public void test820SingleDescriptionModify() throws Exception { // @Test // public void test835ModifySchemaHandling() throws Exception { -// final String TEST_NAME = "test835ModifySchemaHandling"; -// displayTestTitle(TEST_NAME); -// +// // // Task task = createTask(TEST_NAME); // OperationResult result = task.getResult(); // CarefulAnt ant = ants.get(1); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestSchemalessResource.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestSchemalessResource.java index 1e5d18ce9f6..1724860ba06 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestSchemalessResource.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestSchemalessResource.java @@ -19,7 +19,6 @@ import com.evolveum.midpoint.schema.constants.ConnectorTestOperation; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; /** @@ -44,7 +43,6 @@ public TestSchemalessResource() throws JAXBException { @Test public void test001GetObject() throws Exception { final String TEST_NAME = "test001GetObject"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = getTestTask(); OperationResult result = task.getResult(); @@ -59,7 +57,6 @@ public void test001GetObject() throws Exception { @Test public void test002TestConnection() throws Exception { final String TEST_NAME = "test002TestConnection"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = getTestTask(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestStrangeCases.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestStrangeCases.java index 942cc27a43b..b3d1d4209ef 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestStrangeCases.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestStrangeCases.java @@ -199,7 +199,7 @@ public void test010SanityAdministrator() throws Exception { public void test050AddRoleRecursionAssignment() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -232,7 +232,7 @@ public void test050AddRoleRecursionAssignment() throws Exception { public void test060AddRoleStupidAssignment() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -255,7 +255,7 @@ public void test060AddRoleStupidAssignment() throws Exception { public void test100ModifyUserGuybrushAddAccountDummyRedNoAttributesConflict() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -358,7 +358,7 @@ public void test100ModifyUserGuybrushAddAccountDummyRedNoAttributesConflict() th public void test180DeleteHalfAssignmentFromUser() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -409,7 +409,7 @@ public void test180DeleteHalfAssignmentFromUser() throws Exception { public void test190DeleteHalfAssignedUser() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -463,7 +463,7 @@ public void test190DeleteHalfAssignedUser() throws Exception { public void test200ModifyUserJackBrokenAccountRefAndPolyString() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -507,7 +507,7 @@ public void test200ModifyUserJackBrokenAccountRefAndPolyString() throws Exceptio public void test210ModifyUserAddAccount() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -537,7 +537,7 @@ public void test210ModifyUserAddAccount() throws Exception { public void test212ModifyUserAddAccountRed() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -570,7 +570,7 @@ public void test212ModifyUserAddAccountRed() throws Exception { public void test212ModifyUserJackBrokenSchemaViolationPolyString() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); @@ -612,7 +612,7 @@ public void test212ModifyUserJackBrokenSchemaViolationPolyString() throws Except public void test214ModifyUserJackBrokenPassword() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); @@ -654,7 +654,7 @@ public void test214ModifyUserJackBrokenPassword() throws Exception { public void test220ModifyUserJackBrokenConflict() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); @@ -700,7 +700,7 @@ public void test220ModifyUserJackBrokenConflict() throws Exception { public void test230ModifyUserJackUserTemplatePolicyViolation() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); getDummyResource().setModifyBreakMode(BreakMode.NONE); dummyAuditService.clear(); @@ -753,7 +753,7 @@ public void test300ExtensionSanity() { public void test301AddUserDeGhoulash() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -829,7 +829,7 @@ public void test317SearchDeGhoulashByFuneralTimestamp() throws Exception { private void searchDeGhoulash(QName propName, T propValue) throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -881,7 +881,7 @@ private void assertBasicDeGhoulashExtension(PrismObject userDeGhoulash public void test330AssignDeGhoulashIdiot() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -907,7 +907,7 @@ public void test330AssignDeGhoulashIdiot() throws Exception { public void test332AssignDeGhoulashRecursion() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -943,7 +943,7 @@ public void test332AssignDeGhoulashRecursion() throws Exception { public void test334AssignDeGhoulashStupidAssignment() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -972,7 +972,7 @@ public void test334AssignDeGhoulashStupidAssignment() throws Exception { public void test336UnassignDeGhoulashStupidAssignment() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -993,7 +993,7 @@ public void test336UnassignDeGhoulashStupidAssignment() throws Exception { public void test340AssignDeGhoulashConstructionNonExistentResource() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -1018,7 +1018,7 @@ public void test340AssignDeGhoulashConstructionNonExistentResource() throws Exce public void test349UnAssignDeGhoulashConstructionNonExistentResource() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -1042,7 +1042,7 @@ public void test349UnAssignDeGhoulashConstructionNonExistentResource() throws Ex public void test350AssignDeGhoulashRoleBadConstructionResourceRef() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -1069,7 +1069,7 @@ public void test350AssignDeGhoulashRoleBadConstructionResourceRef() throws Excep public void test351UnAssignDeGhoulashRoleBadConstructionResourceRef() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -1096,7 +1096,7 @@ public void test351UnAssignDeGhoulashRoleBadConstructionResourceRef() throws Exc public void test355AssignDeGhoulashRoleBadConstructionResourceRefLax() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -1119,7 +1119,7 @@ public void test355AssignDeGhoulashRoleBadConstructionResourceRefLax() throws Ex public void test356UnAssignDeGhoulashRoleBadConstructionResourceRefLax() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -1142,7 +1142,7 @@ public void test356UnAssignDeGhoulashRoleBadConstructionResourceRefLax() throws public void test360AddRoleTargetBadConstructionResourceRef() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -1163,7 +1163,7 @@ public void test360AddRoleTargetBadConstructionResourceRef() throws Exception { @Test public void test400ImportJackMockTask() throws Exception { // GIVEN - OperationResult result = getResult(); + OperationResult result = getTestResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -1184,7 +1184,7 @@ public void test400ImportJackMockTask() throws Exception { public void test401ListTasks() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -1230,7 +1230,7 @@ public void test401ListTasks() throws Exception { public void test410DeleteJack() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -1283,7 +1283,7 @@ public void test410DeleteJack() throws Exception { public void test450AddApprovalCase() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); @@ -1319,7 +1319,7 @@ public void test500EnumerationExtension() { public void test502EnumerationStoreGood() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObjectDefinition userDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class); userDef.findPropertyDefinition(ItemPath.create(UserType.F_EXTENSION, PIRACY_MARK)); @@ -1359,7 +1359,7 @@ public void test510EnumerationGetBad() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); @@ -1385,7 +1385,7 @@ public void test510EnumerationGetBad() throws Exception { public void test520ShipReadBadTolerateRawData() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); @@ -1425,7 +1425,7 @@ private void changeDefinition(QName piracyShip, ItemName piracyShipBroken) { public void test522ShipReadBadRaw() { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); @@ -1448,7 +1448,7 @@ public void test522ShipReadBadRaw() { public void test524ShipReadBadPlain() { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); @@ -1475,7 +1475,7 @@ public void test529FixSchema() { public void test550AssignCircus() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); try { // WHEN @@ -1495,7 +1495,7 @@ public void test550AssignCircus() throws Exception { public void test600AddUserGuybrushAssignAccount() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1536,7 +1536,7 @@ public void test600AddUserGuybrushAssignAccount() throws Exception { public void test610GetAccountGuybrushRogueAttribute() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); getDummyResource().setEnforceSchema(false); DummyAccount dummyAccount = getDummyAccount(null, USER_GUYBRUSH_USERNAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTolerantAttributes.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTolerantAttributes.java index f5e13c78842..ed0398bfe67 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTolerantAttributes.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTolerantAttributes.java @@ -55,7 +55,6 @@ public class TestTolerantAttributes extends AbstractInitializedModelIntegrationT @Test public void test100ModifyUserAddAccount() throws Exception { - TestUtil.displayTestTitle(this, "test100ModifyUserAddAccount"); // GIVEN Task task = taskManager.createTaskInstance(TestTolerantAttributes.class.getName() + ".test100ModifyUserAddAccount"); @@ -167,9 +166,8 @@ UserType.F_DESCRIPTION, getUserDefinition().findPropertyDefinition(UserType.F_DE @Test public void test102modifyAddAttributeTolerantPattern() throws Exception{ - TestUtil.displayTestTitle(this, "test102modifyAddAttributeTolerantPattern"); - // GIVEN + // GIVEN Task task = taskManager.createTaskInstance(TestTolerantAttributes.class.getName() + ".test102modifyAddAttributeTolerantPattern"); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -214,9 +212,8 @@ public void test102modifyAddAttributeTolerantPattern() throws Exception{ @Test public void test103modifyReplaceAttributeIntolerant() throws Exception{ - TestUtil.displayTestTitle(this, "test103modifyReplaceAttributeIntolerant"); - // GIVEN + // GIVEN Task task = taskManager.createTaskInstance(TestTolerantAttributes.class.getName() + ".test103modifyReplaceAttributeIntolerant"); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -261,9 +258,8 @@ public void test103modifyReplaceAttributeIntolerant() throws Exception{ @Test public void test104modifyReplaceAttributeTolerantPattern() throws Exception{ - TestUtil.displayTestTitle(this, "test104modifyReplaceAttributeTolerantPattern"); - // GIVEN + // GIVEN Task task = taskManager.createTaskInstance(TestTolerantAttributes.class.getName() + ".test104modifyReplaceAttributeTolerantPattern"); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTriggerTask.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTriggerTask.java index 5146a7218fc..a7c271e6a52 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTriggerTask.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTriggerTask.java @@ -31,7 +31,6 @@ import com.evolveum.midpoint.prism.xml.XmlTypeConverter; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; import java.util.Arrays; @@ -80,7 +79,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100ImportScannerTask() throws Exception { final String TEST_NAME = "test100ImportScannerTask"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN TestTriggerTask.class.getName(); @@ -101,7 +99,7 @@ public void test100ImportScannerTask() throws Exception { waitForTaskFinish(TASK_TRIGGER_SCANNER_OID, true); // THEN - TestUtil.displayThen(TEST_NAME); + then(); XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); assertLastScanTimestamp(TASK_TRIGGER_SCANNER_OID, startCal, endCal); @@ -115,7 +113,6 @@ public void test100ImportScannerTask() throws Exception { @Test public void test105NoTrigger() throws Exception { final String TEST_NAME = "test105NoTrigger"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN TestTriggerTask.class.getName(); @@ -130,7 +127,7 @@ public void test105NoTrigger() throws Exception { waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true); // THEN - TestUtil.displayThen(TEST_NAME); + then(); // THEN XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -144,7 +141,6 @@ public void test105NoTrigger() throws Exception { @Test public void test110TriggerCalledAgain() throws Exception { final String TEST_NAME = "test110TriggerCalledAgain"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN TestTriggerTask.class.getName(); @@ -161,7 +157,7 @@ public void test110TriggerCalledAgain() throws Exception { waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true); // THEN - TestUtil.displayThen(TEST_NAME); + then(); // THEN XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -176,7 +172,6 @@ public void test110TriggerCalledAgain() throws Exception { @Test public void test120TwoTriggers() throws Exception { final String TEST_NAME = "test120TwoTriggers"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN TestTriggerTask.class.getName(); @@ -194,7 +189,7 @@ public void test120TwoTriggers() throws Exception { waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true); // THEN - TestUtil.displayThen(TEST_NAME); + then(); // THEN XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -211,7 +206,6 @@ public void test120TwoTriggers() throws Exception { @Test public void test130TwoTriggersSame() throws Exception { final String TEST_NAME = "test130TwoTriggersSame"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN TestTriggerTask.class.getName(); @@ -227,7 +221,7 @@ public void test130TwoTriggersSame() throws Exception { waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true); // THEN - TestUtil.displayThen(TEST_NAME); + then(); // THEN XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -242,7 +236,6 @@ public void test130TwoTriggersSame() throws Exception { @Test public void test135TwoTriggersSamePlusOne() throws Exception { final String TEST_NAME = "test135TwoTriggersSamePlusOne"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN TestTriggerTask.class.getName(); @@ -260,7 +253,7 @@ public void test135TwoTriggersSamePlusOne() throws Exception { waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true); // THEN - TestUtil.displayThen(TEST_NAME); + then(); // THEN XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -275,7 +268,6 @@ public void test135TwoTriggersSamePlusOne() throws Exception { @Test public void test140TwoTriggersSameAggregable() throws Exception { final String TEST_NAME = "test140TwoTriggersSameAggregable"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN TestTriggerTask.class.getName(); @@ -291,7 +283,7 @@ public void test140TwoTriggersSameAggregable() throws Exception { waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true); // THEN - TestUtil.displayThen(TEST_NAME); + then(); // THEN XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -307,7 +299,6 @@ public void test140TwoTriggersSameAggregable() throws Exception { @Test public void test145TwoTriggersSamePlusOneAggregable() throws Exception { final String TEST_NAME = "test145TwoTriggersSamePlusOneAggregable"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN TestTriggerTask.class.getName(); @@ -326,7 +317,7 @@ public void test145TwoTriggersSamePlusOneAggregable() throws Exception { waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true); // THEN - TestUtil.displayThen(TEST_NAME); + then(); // THEN XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -342,7 +333,6 @@ public void test145TwoTriggersSamePlusOneAggregable() throws Exception { @Test public void test147TwoTriggersIdempotent() throws Exception { final String TEST_NAME = "test147TwoTriggersIdempotent"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN TestTriggerTask.class.getName(); @@ -362,7 +352,7 @@ public void test147TwoTriggersIdempotent() throws Exception { waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true); // THEN - TestUtil.displayThen(TEST_NAME); + then(); // THEN XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -380,7 +370,6 @@ public void test147TwoTriggersIdempotent() throws Exception { @Test public void test150NoTriggerAgain() throws Exception { final String TEST_NAME = "test115NoTriggerAgain"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN TestTriggerTask.class.getName(); @@ -395,7 +384,7 @@ public void test150NoTriggerAgain() throws Exception { waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true); // THEN - TestUtil.displayThen(TEST_NAME); + then(); // THEN XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -410,7 +399,6 @@ public void test150NoTriggerAgain() throws Exception { @Test public void test160TwoTriggersFirstFails() throws Exception { final String TEST_NAME = "test160TwoTriggersFirstFails"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN TestTriggerTask.class.getName(); @@ -430,7 +418,7 @@ public void test160TwoTriggersFirstFails() throws Exception { waitForTaskNextRun(TASK_TRIGGER_SCANNER_OID, true, 10000); // THEN - TestUtil.displayThen(TEST_NAME); + then(); XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -455,7 +443,7 @@ public void test160TwoTriggersFirstFails() throws Exception { waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true); // THEN - TestUtil.displayThen(TEST_NAME); + then(); endCal = clock.currentTimeXMLGregorianCalendar(); @@ -468,7 +456,6 @@ public void test160TwoTriggersFirstFails() throws Exception { @Test public void test200TwoDistantTriggers() throws Exception { final String TEST_NAME = "test200TwoDistantTriggers"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN TestTriggerTask.class.getName(); @@ -486,7 +473,7 @@ public void test200TwoDistantTriggers() throws Exception { waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true); // THEN - TestUtil.displayThen(TEST_NAME); + then(); // THEN XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -502,7 +489,6 @@ public void test200TwoDistantTriggers() throws Exception { @Test public void test210InterruptedScanner() throws Exception { final String TEST_NAME = "test210InterruptedScanner"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN TestTriggerTask.class.getName(); @@ -534,7 +520,7 @@ public void test210InterruptedScanner() throws Exception { assertTrue("trigger scanner task was not suspended (after operation)", suspended); // THEN - TestUtil.displayThen(TEST_NAME); + then(); // THEN assertNotNull("Trigger was not called", testTriggerHandler.getLastObject()); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplate.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplate.java index 8f2651e9248..3ca89f54c5f 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplate.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplate.java @@ -128,7 +128,7 @@ protected int getNumberOfRoles() { @Test public void test000Sanity() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN when(); @@ -170,7 +170,7 @@ private void assertObjectTemplate(List defaultObj public void test100ModifyUserGivenName() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); Collection> deltas = new ArrayList<>(); ObjectDelta userDelta = prismContext.deltaFactory().object().createModificationReplaceProperty(UserType.class, @@ -212,7 +212,7 @@ public void test100ModifyUserGivenName() throws Exception { public void test101ModifyUserEmployeeTypePirate() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); Collection> deltas = new ArrayList<>(); ObjectDelta userDelta = prismContext.deltaFactory().object().createModificationReplaceProperty(UserType.class, @@ -260,7 +260,7 @@ public void test101ModifyUserEmployeeTypePirate() throws Exception { public void test102ModifyUserEmployeeTypeBuccaneer() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); Collection> deltas = new ArrayList<>(); ObjectDelta userDelta = prismContext.deltaFactory().object().createModificationReplaceProperty(UserType.class, @@ -298,7 +298,7 @@ public void test102ModifyUserEmployeeTypeBuccaneer() throws Exception { public void test103ModifyUserEmployeeTypeBartender() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); Collection> deltas = new ArrayList<>(); ObjectDelta userDelta = prismContext.deltaFactory().object().createModificationReplaceProperty(UserType.class, @@ -338,7 +338,7 @@ public void test103ModifyUserEmployeeTypeBartender() throws Exception { public void test104ModifyUserCostCenter() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); Collection> deltas = new ArrayList<>(); ObjectDelta userDelta = prismContext.deltaFactory().object().createModificationReplaceProperty(UserType.class, @@ -374,7 +374,7 @@ public void test104ModifyUserCostCenter() throws Exception { public void test105ModifyUserTelephoneNumber() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); Collection> deltas = new ArrayList<>(); ObjectDelta userDelta = prismContext.deltaFactory().object().createModificationReplaceProperty(UserType.class, @@ -412,7 +412,7 @@ public void test105ModifyUserTelephoneNumber() throws Exception { public void test106ModifyUserRemoveTelephoneNumber() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); Collection> deltas = new ArrayList<>(); ObjectDelta userDelta = prismContext.deltaFactory().object().createModificationReplaceProperty(UserType.class, @@ -450,7 +450,7 @@ public void test106ModifyUserRemoveTelephoneNumber() throws Exception { public void test107ModifyUserSetTelephoneNumber() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN modifyUserReplace(USER_JACK_OID, UserType.F_TELEPHONE_NUMBER, task, result, "1 222 3456789"); @@ -487,7 +487,7 @@ public void test107ModifyUserSetTelephoneNumber() throws Exception { public void test120ReconcileUser() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN reconcileUser(USER_JACK_OID, task, result); @@ -527,7 +527,7 @@ public void test120ReconcileUser() throws Exception { public void test121ModifyUserReplaceLocality() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN modifyUserReplace(USER_JACK_OID, UserType.F_LOCALITY, task, result, PrismTestUtil.createPolyString("Tortuga")); @@ -563,7 +563,7 @@ public void test121ModifyUserReplaceLocality() throws Exception { public void test140AssignDummy() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); @@ -595,7 +595,7 @@ public void test140AssignDummy() throws Exception { public void test149UnAssignDummy() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); @@ -626,7 +626,7 @@ public void test149UnAssignDummy() throws Exception { public void test150ModifyJackOrganizationalUnitRum() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN modifyUserReplace(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result, PrismTestUtil.createPolyString("F0004")); @@ -660,7 +660,7 @@ public void test150ModifyJackOrganizationalUnitRum() throws Exception { public void test151ModifyJackOrganizationalUnitOffense() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN modifyUserReplace(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result, PrismTestUtil.createPolyString("F0003")); @@ -694,7 +694,7 @@ public void test151ModifyJackOrganizationalUnitOffense() throws Exception { public void test152ModifyJackOrganizationalUnitAddRum() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN modifyUserAdd(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result, PrismTestUtil.createPolyString("F0004")); @@ -731,7 +731,7 @@ public void test152ModifyJackOrganizationalUnitAddRum() throws Exception { public void test153ModifyJackOrganizationalUnitDeleteOffense() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN modifyUserDelete(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result, PrismTestUtil.createPolyString("F0003")); @@ -767,7 +767,7 @@ public void test153ModifyJackOrganizationalUnitDeleteOffense() throws Exception public void test155ModifyJackOrganizationalUnitFD001() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN modifyUserAdd(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result, PrismTestUtil.createPolyString("FD001")); @@ -806,7 +806,7 @@ public void test155ModifyJackOrganizationalUnitFD001() throws Exception { public void test156ReconcileJack() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN reconcileUser(USER_JACK_OID, task, result); @@ -844,7 +844,7 @@ public void test156ReconcileJack() throws Exception { public void test157ModifyJackOrganizationalUnitFD0023() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN modifyUserAdd(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result, @@ -884,7 +884,7 @@ public void test157ModifyJackOrganizationalUnitFD0023() throws Exception { public void test159ModifyJackDeleteOrganizationalUnitFD002() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN modifyUserDelete(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result, @@ -925,7 +925,7 @@ public void test159ModifyJackDeleteOrganizationalUnitFD002() throws Exception { public void test160ModifyUserGivenNameAgain() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); @@ -968,7 +968,7 @@ public void test160ModifyUserGivenNameAgain() throws Exception { public void test162ModifyUserGivenNameAgainPhantomChange() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result); display("User before", userBefore); @@ -1006,7 +1006,7 @@ public void test162ModifyUserGivenNameAgainPhantomChange() throws Exception { public void test165ModifyUserGivenNameAgainAgain() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result); display("User before", userBefore); @@ -1053,7 +1053,7 @@ private void assertOnDemandOrgAssigned(String orgName, PrismObject use public void test170ModifyUserGuybrushEmployeeTypeThief() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1081,7 +1081,7 @@ public void test170ModifyUserGuybrushEmployeeTypeThief() throws Exception { public void test172ModifyUserGuybrushHonorificPrefix() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1111,7 +1111,7 @@ public void test172ModifyUserGuybrushHonorificPrefix() throws Exception { public void test174ModifyUserGuybrushHonorificPrefixNone() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1140,7 +1140,7 @@ public void test174ModifyUserGuybrushHonorificPrefixNone() throws Exception { public void test180ModifyUserGuybrushEmployeeTypeMarooned() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1170,7 +1170,7 @@ public void test180ModifyUserGuybrushEmployeeTypeMarooned() throws Exception { public void test184ModifyUserGuybrushEmployeeTypeNone() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1202,7 +1202,7 @@ public void test184ModifyUserGuybrushEmployeeTypeNone() throws Exception { public void test185ModifyUserGuybrushSubtypeMarooned() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1228,7 +1228,7 @@ public void test185ModifyUserGuybrushSubtypeMarooned() throws Exception { public void test189ModifyUserGuybrushSubtypeNone() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1262,7 +1262,7 @@ public void test189ModifyUserGuybrushSubtypeNone() throws Exception { public void test190ModifyUserGuybrushOrganizationWhateveric() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1293,7 +1293,7 @@ public void test190ModifyUserGuybrushOrganizationWhateveric() throws Exception { public void test191ModifyUserGuybrushOrganizationAutomatic() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1329,7 +1329,7 @@ public void test191ModifyUserGuybrushOrganizationAutomatic() throws Exception { public void test192ModifyUserGuybrushOrganizationAddMixed() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1377,7 +1377,7 @@ public void test192ModifyUserGuybrushOrganizationAddMixed() throws Exception { public void test193ModifyUserGuybrushOrganizationAddOutOfDomain() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1425,7 +1425,7 @@ public void test193ModifyUserGuybrushOrganizationAddOutOfDomain() throws Excepti public void test194ModifyUserGuybrushOrganizationDeleteMixed() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1469,7 +1469,7 @@ public void test194ModifyUserGuybrushOrganizationDeleteMixed() throws Exception public void test195ModifyUserGuybrushOrganizationDeleteOutOfDomain() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1510,7 +1510,7 @@ public void test195ModifyUserGuybrushOrganizationDeleteOutOfDomain() throws Exce public void test196GuybrushAssignCaptain() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1549,7 +1549,7 @@ public void test196GuybrushAssignCaptain() throws Exception { public void test197ModifyGuybrushEmployeeTypePirate() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN when(); @@ -1585,7 +1585,7 @@ public void test197ModifyGuybrushEmployeeTypePirate() throws Exception { public void test198AModifyUserGuybrushOrganizationAddInDomain() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1632,7 +1632,7 @@ public void test198AModifyUserGuybrushOrganizationAddInDomain() throws Exception public void test198BModifyUserGuybrushOrganizationDeleteMixed() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1675,7 +1675,7 @@ public void test198BModifyUserGuybrushOrganizationDeleteMixed() throws Exception public void test199AGuyBrushModifyEmployeeTypeWannabe() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1714,7 +1714,7 @@ public void test199AGuyBrushModifyEmployeeTypeWannabe() throws Exception { public void test199BGuyBrushUnassignCaptain() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1752,7 +1752,7 @@ public void test199BGuyBrushUnassignCaptain() throws Exception { public void test199CModifyUserGuybrushOrganizationCleanup() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1780,7 +1780,7 @@ public void test199CModifyUserGuybrushOrganizationCleanup() throws Exception { public void test200AddUserRapp() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject user = PrismTestUtil.parseObject(USER_RAPP_FILE); Collection> deltas = new ArrayList<>(); @@ -1814,7 +1814,7 @@ public void test200AddUserRapp() throws Exception { public void test201AddUserLargo() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // This simulates IMPORT to trigger the channel-limited mapping task.setChannel(QNameUtil.qNameToUri(SchemaConstants.CHANGE_CHANNEL_IMPORT)); @@ -1859,7 +1859,7 @@ public void test201AddUserLargo() throws Exception { public void test202AddUserMonkey() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject user = PrismTestUtil.parseObject(USER_THREE_HEADED_MONKEY_FILE); Collection> deltas = new ArrayList<>(); @@ -1897,7 +1897,7 @@ public void test202AddUserMonkey() throws Exception { public void test204AddUserHerman() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject user = PrismTestUtil.parseObject(USER_HERMAN_FILE); Collection> deltas = new ArrayList<>(); @@ -1930,7 +1930,7 @@ public void test204AddUserHerman() throws Exception { public void test220AssignRoleSailorToUserRapp() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN assignRole(USER_RAPP_OID, ROLE_SAILOR_OID, task, result); @@ -1962,7 +1962,7 @@ public void test220AssignRoleSailorToUserRapp() throws Exception { public void test229UnassignRoleSailorFromUserRapp() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN unassignRole(USER_RAPP_OID, ROLE_SAILOR_OID, task, result); @@ -1996,7 +1996,7 @@ public void test229UnassignRoleSailorFromUserRapp() throws Exception { public void test230AssignRoleCaptainToUserRapp() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN assignRole(USER_RAPP_OID, ROLE_CAPTAIN_OID, task, result); @@ -2028,7 +2028,7 @@ public void test230AssignRoleCaptainToUserRapp() throws Exception { public void test232ModifyUserRappCostCenter() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN modifyUserReplace(USER_RAPP_OID, UserType.F_COST_CENTER, task, result, "CC-RAPP"); @@ -2061,7 +2061,7 @@ public void test232ModifyUserRappCostCenter() throws Exception { public void test239UnassignRoleCaptainFromUserRapp() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN unassignRole(USER_RAPP_OID, ROLE_CAPTAIN_OID, task, result); @@ -2090,7 +2090,7 @@ public void test239UnassignRoleCaptainFromUserRapp() throws Exception { public void test240ModifyUserRappLocalityScabb() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = modelService.getObject(UserType.class, USER_RAPP_OID, null, task, result); display("User before", userBefore); @@ -2135,7 +2135,7 @@ public void test240ModifyUserRappLocalityScabb() throws Exception { public void test242AssignRoleRastamanToUserRapp() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN assignRole(USER_RAPP_OID, ROLE_RASTAMAN_OID, task, result); @@ -2173,7 +2173,7 @@ public void test242AssignRoleRastamanToUserRapp() throws Exception { public void test244ModifyUserRappLocalityCoffin() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = modelService.getObject(UserType.class, USER_RAPP_OID, null, task, result); display("User before", userBefore); @@ -2211,7 +2211,7 @@ public void test244ModifyUserRappLocalityCoffin() throws Exception { public void test245ModifyUserRappLocalityUnderReconcile() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = modelService.getObject(UserType.class, USER_RAPP_OID, null, task, result); display("User before", userBefore); @@ -2256,7 +2256,7 @@ public void test245ModifyUserRappLocalityUnderReconcile() throws Exception { public void test246ModifyUserRappTimezoneMonkey() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = modelService.getObject(UserType.class, USER_RAPP_OID, null, task, result); display("User before", userBefore); @@ -2296,7 +2296,7 @@ public void test246ModifyUserRappTimezoneMonkey() throws Exception { public void test247ModifyUserRappLocaleMI() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = modelService.getObject(UserType.class, USER_RAPP_OID, null, task, result); display("User before", userBefore); @@ -2333,7 +2333,7 @@ public void test247ModifyUserRappLocaleMI() throws Exception { public void test249UnassignRoleRastamanFromUserRapp() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN unassignRole(USER_RAPP_OID, ROLE_RASTAMAN_OID, task, result); @@ -2370,7 +2370,7 @@ public void test249UnassignRoleRastamanFromUserRapp() throws Exception { public void test300ImportStanFromEmeraldResource() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); DummyAccount dummyAccountBefore = new DummyAccount(ACCOUNT_STAN_USERNAME); @@ -2412,7 +2412,7 @@ public void test300ImportStanFromEmeraldResource() throws Exception { public void test302ModifyStanAccountAndReimport() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); DummyAccount dummyAccountBefore = dummyResourceEmerald.getAccountByUsername(ACCOUNT_STAN_USERNAME); @@ -2475,7 +2475,7 @@ public void test800NullTimeFrom() throws Exception { public void test802FuneralTimestamp() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); funeralTimestamp = clock.currentTimeXMLGregorianCalendar(); modifyUserReplace(USER_JACK_OID, getExtensionPath(PIRACY_FUNERAL_TIMESTAMP), task, result, funeralTimestamp); @@ -2652,7 +2652,7 @@ public void test813TalesBoomRecompute() throws Exception { public void test820TalesUnBoom() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); modifyUserReplace(USER_JACK_OID, getExtensionPath(PIRACY_TALES), task, result /* no value */); @@ -2701,7 +2701,7 @@ public void test820TalesUnBoom() throws Exception { public void test830PreLootBoom() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); modifyUserReplace(USER_JACK_OID, UserType.F_DESCRIPTION, task, result, "Rum is gone"); @@ -2796,7 +2796,7 @@ public void test832LootBoomConditionFalse() throws Exception { public void test835LootBoom() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN modifyUserReplace(USER_JACK_OID, UserType.F_GIVEN_NAME, task, result, createPolyString("Lootjack")); @@ -2830,7 +2830,7 @@ public void test835LootBoom() throws Exception { public void test840ResetFuneralTimestamp() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); modifyUserReplace(USER_JACK_OID, getExtensionPath(PIRACY_FUNERAL_TIMESTAMP), task, result /* no value */); @@ -2858,7 +2858,7 @@ public void test840ResetFuneralTimestamp() throws Exception { public void test843UnLoot() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN modifyUserReplace(USER_JACK_OID, UserType.F_GIVEN_NAME, task, result, createPolyString("Justjack")); @@ -2893,7 +2893,7 @@ public void test843UnLoot() throws Exception { public void test845ReLoot() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN modifyUserReplace(USER_JACK_OID, UserType.F_GIVEN_NAME, task, result, createPolyString("Lootjack")); @@ -2928,7 +2928,7 @@ public void test845ReLoot() throws Exception { public void test850AddCannibalLemonhead() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN String userOid = addObject(createCannibal(CANNIBAL_LEMONHEAD_USERNAME, null, false), task, result); @@ -2956,7 +2956,7 @@ public void test850AddCannibalLemonhead() throws Exception { public void test852AddCanibalRedSkull() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN String userOid = addObject(createCannibal(CANNIBAL_REDSKULL_USERNAME, "", false), task, result); @@ -2988,7 +2988,7 @@ public void test852AddCanibalRedSkull() throws Exception { public void test854AddCanibalShaprtooth() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN String userOid = addObject(createCannibal(CANNIBAL_SHARPTOOTH_USERNAME, "-P1M1D", false), task, result); @@ -3021,7 +3021,7 @@ public void test854AddCanibalShaprtooth() throws Exception { public void test856AddCanibalOrangeskin() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN String userOid = addObject(createCannibal(CANNIBAL_ORANGESKIN_USERNAME, "-P3M1D", false), task, result); @@ -3052,7 +3052,7 @@ public void test856AddCanibalOrangeskin() throws Exception { public void test858AddCanibalCherrybrain() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN String userOid = addObject(createCannibal(CANNIBAL_CHERRYBRAIN_USERNAME, "-P1Y1D", false), task, result); @@ -3085,7 +3085,7 @@ public void test858AddCanibalCherrybrain() throws Exception { public void test859AddCanibalPineapplenose() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN String userOid = addObject( @@ -3119,7 +3119,7 @@ public void test859AddCanibalPineapplenose() throws Exception { public void test860AddCannibalRottenLemonhead() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN String userOid = addObject(createCannibal(CANNIBAL_LEMONHEAD_USERNAME, null, true), task, result); @@ -3147,7 +3147,7 @@ public void test860AddCannibalRottenLemonhead() throws Exception { public void test862AddCanibalRottenRedSkull() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN String userOid = addObject(createCannibal(CANNIBAL_REDSKULL_USERNAME, "", true), task, result); @@ -3179,7 +3179,7 @@ public void test862AddCanibalRottenRedSkull() throws Exception { public void test864AddCanibalRottenShaprtooth() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN String userOid = addObject(createCannibal(CANNIBAL_SHARPTOOTH_USERNAME, "-P1M1D", true), task, result); @@ -3222,7 +3222,7 @@ public void test864AddCanibalRottenShaprtooth() throws Exception { public void test866AddCanibalRottenOrangeskin() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN String userOid = addObject(createCannibal(CANNIBAL_ORANGESKIN_USERNAME, "-P3M1D", true), task, result); @@ -3256,7 +3256,7 @@ public void test866AddCanibalRottenOrangeskin() throws Exception { public void test868AddCanibalRottenCherrybrain() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN String userOid = addObject(createCannibal(CANNIBAL_CHERRYBRAIN_USERNAME, "-P1Y1D", true), task, result); @@ -3287,7 +3287,7 @@ public void test868AddCanibalRottenCherrybrain() throws Exception { public void test869AddCanibalRottenPineapplenose() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN String userOid = addObject( @@ -3322,7 +3322,7 @@ public void test869AddCanibalRottenPineapplenose() throws Exception { public void test870AddCanibalRottenPotatoleg() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN String userOid = addObject( @@ -3374,7 +3374,7 @@ private PrismObject createCannibal(String name, String funeralDateOffs public void test900DeleteUser() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Collection> deltas = new ArrayList<>(); @@ -3406,7 +3406,7 @@ public void test950CreateUserJackWithoutTemplate() throws Exception { setDefaultUserTemplate(null); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); // WHEN @@ -3436,7 +3436,7 @@ public void test950CreateUserJackWithoutTemplate() throws Exception { public void test952ModifyJackOrganizationalUnitFD004() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN modifyUserAdd(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result, PrismTestUtil.createPolyString("FD004")); @@ -3467,7 +3467,7 @@ public void test960ReconcileUserJackWithTemplate() throws Exception { setDefaultUserTemplate(USER_TEMPLATE_COMPLEX_OID); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); // WHEN @@ -3494,7 +3494,7 @@ public void test960ReconcileUserJackWithTemplate() throws Exception { public void test970ModifyUserGuybrushEmployeeTypeUseless() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -3522,7 +3522,7 @@ public void test970ModifyUserGuybrushEmployeeTypeUseless() throws Exception { public void test980DeleteUserGivenName() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); UserType user = new UserType(prismContext) .name("test980DeleteUserGivenName") diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplateWithRanges.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplateWithRanges.java index f277164d543..650b4973138 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplateWithRanges.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplateWithRanges.java @@ -82,7 +82,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100RecomputeElaine() throws Exception { final String TEST_NAME = "test100RecomputeElaine"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestUserTemplateWithRanges.class.getName() + "." + TEST_NAME); @@ -108,7 +107,6 @@ public void test100RecomputeElaine() throws Exception { @Test public void test110ChangeManagerAndRecomputeElaine() throws Exception { final String TEST_NAME = "test110ChangeManagerAndRecomputeElaine"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestUserTemplateWithRanges.class.getName() + "." + TEST_NAME); @@ -136,7 +134,6 @@ public void test110ChangeManagerAndRecomputeElaine() throws Exception { @Test public void test120RestoreManagerAndRecomputeElaineAgain() throws Exception { final String TEST_NAME = "test120RestoreManagerAndRecomputeElaineAgain"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestUserTemplateWithRanges.class.getName() + "." + TEST_NAME); @@ -168,7 +165,6 @@ public void test120RestoreManagerAndRecomputeElaineAgain() throws Exception { @Test public void test140ChangeManagerAndRecomputeElaineAgain() throws Exception { final String TEST_NAME = "test140ChangeManagerAndRecomputeElaineAgain"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestUserTemplateWithRanges.class.getName() + "." + TEST_NAME); @@ -283,7 +279,6 @@ public void test210RemoveUnit1() throws Exception { @Test public void test220RemoveUnit2AndNumber() throws Exception { final String TEST_NAME = "test220RemoveUnit2AndNumber"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = getTestTask(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestVolatility.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestVolatility.java index 694125b76e9..7fe4da9d272 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestVolatility.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestVolatility.java @@ -92,7 +92,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100ImportLiveSyncTaskDummyHr() throws Exception { final String TEST_NAME = "test100ImportLiveSyncTaskDummyHr"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN TestVolatility.class.getName(); @@ -104,7 +103,7 @@ public void test100ImportLiveSyncTaskDummyHr() throws Exception { importSyncTask(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); waitForSyncTaskStart(); } @@ -112,7 +111,6 @@ public void test100ImportLiveSyncTaskDummyHr() throws Exception { @Test public void test110AddDummyHrAccountMancomb() throws Exception { final String TEST_NAME = "test110AddDummyHrAccountMancomb"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN TestVolatility.class.getName(); @@ -134,7 +132,7 @@ public void test110AddDummyHrAccountMancomb() throws Exception { waitForSyncTaskNextRun(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject accountMancombHr = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, getDummyResourceObject(RESOURCE_DUMMY_HR_NAME)); @@ -177,7 +175,6 @@ public void test110AddDummyHrAccountMancomb() throws Exception { @Test public void test120UpdateDummyHrAccountMancomb() throws Exception { final String TEST_NAME = "test120UpdateDummyHrAccountMancomb"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN TestVolatility.class.getName(); @@ -195,7 +192,7 @@ public void test120UpdateDummyHrAccountMancomb() throws Exception { waitForSyncTaskNextRun(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject accountMancombHr = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, getDummyResourceObject(RESOURCE_DUMMY_HR_NAME)); @@ -244,7 +241,6 @@ public void test120UpdateDummyHrAccountMancomb() throws Exception { @Test public void test200ModifyGuybrushAssignAccount() throws Exception { final String TEST_NAME = "test200ModifyGuybrushAssignAccount"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN TestVolatility.class.getName(); @@ -264,7 +260,7 @@ public void test200ModifyGuybrushAssignAccount() throws Exception { modelService.executeChanges(deltas, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject userGuybrush = findUserByUsername(ACCOUNT_GUYBRUSH_DUMMY_USERNAME); display("User guybrush", userGuybrush); @@ -298,7 +294,6 @@ public void test200ModifyGuybrushAssignAccount() throws Exception { @Test public void test300AddLargo() throws Exception { final String TEST_NAME = "test300AddLargo"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN TestVolatility.class.getName(); @@ -317,7 +312,7 @@ public void test300AddLargo() throws Exception { modelService.executeChanges(deltas, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject userLargo = findUserByUsername(ACCOUNT_LARGO_DUMMY_USERNAME); display("User largo", userLargo); @@ -354,7 +349,6 @@ public void test300AddLargo() throws Exception { @Test public void test400AddHerman() throws Exception { final String TEST_NAME = "test400AddHerman"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN TestVolatility.class.getName(); @@ -374,7 +368,7 @@ public void test400AddHerman() throws Exception { addObject(userBefore, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -397,7 +391,6 @@ public void test400AddHerman() throws Exception { @Test public void test402ModifyHermanMonster() throws Exception { final String TEST_NAME = "test402ModifyHermanMonster"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN TestVolatility.class.getName(); @@ -410,7 +403,7 @@ public void test402ModifyHermanMonster() throws Exception { createPolyString(DummyResource.VALUE_MONSTER)); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateGrouperJson.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateGrouperJson.java index 56e5d961125..0b666c1e6e1 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateGrouperJson.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateGrouperJson.java @@ -75,7 +75,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult testResultGrouper = modelService.testResource(RESOURCE_GROUPER_OID, task); @@ -93,7 +92,6 @@ private Task createTestTask(String TEST_NAME) { @Test public void test100AddAnderson() throws Exception { final String TEST_NAME = "test100AddAnderson"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult result = task.getResult(); @@ -140,7 +138,6 @@ private AsyncUpdateMessageType getAmqp091Message(File file) throws IOException { @Test public void test110AddAlumniAndStaff() throws Exception { final String TEST_NAME = "test110AddAlumniAndStaff"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult result = task.getResult(); @@ -187,7 +184,6 @@ public void test110AddAlumniAndStaff() throws Exception { @Test public void test200AddAlumniForAnderson() throws Exception { final String TEST_NAME = "test200AddAlumniForAnderson"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult result = task.getResult(); @@ -227,7 +223,6 @@ public void test200AddAlumniForAnderson() throws Exception { @Test public void test210AddStaffForAnderson() throws Exception { final String TEST_NAME = "test210AddStaffForAnderson"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult result = task.getResult(); @@ -267,7 +262,6 @@ public void test210AddStaffForAnderson() throws Exception { @Test public void test220AddAlumniForLewis() throws Exception { final String TEST_NAME = "test220AddAlumniForLewis"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult result = task.getResult(); @@ -307,7 +301,6 @@ public void test220AddAlumniForLewis() throws Exception { @Test public void test230AddLewis() throws Exception { final String TEST_NAME = "test230AddLewis"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult result = task.getResult(); @@ -347,7 +340,6 @@ public void test230AddLewis() throws Exception { @Test public void test240AddStaffForAnderson() throws Exception { final String TEST_NAME = "test240AddStaffForAnderson"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult result = task.getResult(); @@ -387,7 +379,6 @@ public void test240AddStaffForAnderson() throws Exception { @Test public void test250DeleteAlumniForAnderson() throws Exception { final String TEST_NAME = "test250DeleteAlumniForAnderson"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult result = task.getResult(); @@ -427,7 +418,6 @@ public void test250DeleteAlumniForAnderson() throws Exception { @Test public void test310DeleteStaff() throws Exception { final String TEST_NAME = "test310DeleteStaff"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateTaskMechanics.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateTaskMechanics.java index 1b73e8579a3..fa014a8eb28 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateTaskMechanics.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateTaskMechanics.java @@ -88,7 +88,7 @@ public void test000Sanity() throws ObjectNotFoundException { @Test public void test100SmallTaskNoWorkers() throws IOException, TimeoutException, CommonException { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); int usersBefore = getObjectCount(UserType.class); @@ -113,7 +113,7 @@ public void test100SmallTaskNoWorkers() throws IOException, TimeoutException, Co @Test public void test110SmallTaskOneWorker() throws IOException, TimeoutException, CommonException { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); int usersBefore = getObjectCount(UserType.class); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateUcf.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateUcf.java index 8e787c7be95..9f3e449ff30 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateUcf.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateUcf.java @@ -73,7 +73,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult testResultGrouper = modelService.testResource(RESOURCE_GROUPER_OID, task); @@ -90,7 +89,6 @@ private Task createTestTask(String TEST_NAME) { @Test public void test100AddAnderson() throws Exception { final String TEST_NAME = "test100AddAnderson"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult result = task.getResult(); @@ -130,7 +128,6 @@ public void test100AddAnderson() throws Exception { @Test public void test110AddAlumniAndStaff() throws Exception { final String TEST_NAME = "test110AddAlumni"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult result = task.getResult(); @@ -177,7 +174,6 @@ public void test110AddAlumniAndStaff() throws Exception { @Test public void test120AddWhite() throws Exception { final String TEST_NAME = "test120AddWhite"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult result = task.getResult(); @@ -217,7 +213,6 @@ public void test120AddWhite() throws Exception { @Test public void test200AddAlumniForAnderson() throws Exception { final String TEST_NAME = "test200AddAlumniForAnderson"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult result = task.getResult(); @@ -257,7 +252,6 @@ public void test200AddAlumniForAnderson() throws Exception { @Test public void test210AddStaffForAnderson() throws Exception { final String TEST_NAME = "test210AddStaffForAnderson"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult result = task.getResult(); @@ -297,7 +291,6 @@ public void test210AddStaffForAnderson() throws Exception { @Test public void test220AddAlumniForLewis() throws Exception { final String TEST_NAME = "test220AddAlumniForLewis"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult result = task.getResult(); @@ -337,7 +330,6 @@ public void test220AddAlumniForLewis() throws Exception { @Test public void test230MentionLewis() throws Exception { final String TEST_NAME = "test230MentionLewis"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult result = task.getResult(); @@ -377,7 +369,6 @@ public void test230MentionLewis() throws Exception { @Test public void test300DeleteAnderson() throws Exception { final String TEST_NAME = "test300DeleteAnderson"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult result = task.getResult(); @@ -409,7 +400,6 @@ public void test300DeleteAnderson() throws Exception { @Test public void test310DeleteStaff() throws Exception { final String TEST_NAME = "test310DeleteStaff"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestNotifyChange.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestNotifyChange.java index d552d613926..48d0fd78edf 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestNotifyChange.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestNotifyChange.java @@ -87,7 +87,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestNotifyChange.class.getName() + "." + TEST_NAME); OperationResult testResultGrouper = modelService.testResource(RESOURCE_GROUPER_OID, task); @@ -100,7 +99,6 @@ public void test000Sanity() throws Exception { @Test public void test100AddAnderson() throws Exception { final String TEST_NAME = "test100AddAnderson"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestNotifyChange.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -138,7 +136,6 @@ public void test100AddAnderson() throws Exception { @Test public void test105AddLewis() throws Exception { final String TEST_NAME = "test105AddLewis"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestNotifyChange.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -179,7 +176,6 @@ public void test105AddLewis() throws Exception { @Test public void test110AddAlumni() throws Exception { final String TEST_NAME = "test110AddAlumni"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestNotifyChange.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -217,7 +213,6 @@ public void test110AddAlumni() throws Exception { @Test public void test120AddStaff() throws Exception { final String TEST_NAME = "test120AddStaff"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestNotifyChange.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -255,7 +250,6 @@ public void test120AddStaff() throws Exception { @Test public void test200AddGroupsForAnderson() throws Exception { final String TEST_NAME = "test200AddGroupsForAnderson"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestNotifyChange.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -293,7 +287,6 @@ public void test200AddGroupsForAnderson() throws Exception { @Test public void test210AddGroupsForLewis() throws Exception { final String TEST_NAME = "test210AddGroupsForLewis"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestNotifyChange.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestRoleEntitlement.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestRoleEntitlement.java index ab0cc9f4cd2..3882a883656 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestRoleEntitlement.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestRoleEntitlement.java @@ -390,7 +390,7 @@ public void test119ModifyRoleDeleteEntitlement() throws Exception { modelService.executeChanges(deltas, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("executeChanges result", result, 2); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractManualResourceTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractManualResourceTest.java index 98bdeda2fb2..6e6d0062b94 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractManualResourceTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractManualResourceTest.java @@ -69,8 +69,6 @@ import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.ObjectNotFoundException; import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ImportOptionsType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType; @@ -107,8 +105,6 @@ public abstract class AbstractManualResourceTest extends AbstractConfiguredModel public static final QName RESOURCE_ACCOUNT_OBJECTCLASS = new QName(MidPointConstants.NS_RI, "AccountObjectClass"); - private static final Trace LOGGER = TraceManager.getTrace(AbstractManualResourceTest.class); - protected static final String NS_MANUAL_CONF = "http://midpoint.evolveum.com/xml/ns/public/connector/builtin-1/bundle/com.evolveum.midpoint.provisioning.ucf.impl.builtin/ManualConnector"; protected static final ItemName CONF_PROPERTY_DEFAULT_ASSIGNEE_QNAME = new ItemName(NS_MANUAL_CONF, "defaultAssignee"); @@ -390,18 +386,12 @@ public void test014Configuration() throws Exception { PrismProperty propDefaultAssignee = configurationContainer.findProperty(CONF_PROPERTY_DEFAULT_ASSIGNEE_QNAME); assertNotNull("No defaultAssignee conf prop", propDefaultAssignee); -// assertNotNull("No configuration properties container", confingurationPropertiesContainer); -// PrismContainerDefinition confPropDef = confingurationPropertiesContainer.getDefinition(); -// assertNotNull("No configuration properties container definition", confPropDef); - assertSteadyResources(); } @Test public void test016ParsedSchema() throws Exception { - final String TEST_NAME = "test016ParsedSchema"; // GIVEN - OperationResult result = new OperationResult(AbstractManualResourceTest.class.getName() + "." + TEST_NAME); // THEN // The returned type should have the schema pre-parsed @@ -1369,7 +1359,7 @@ public void test400PhantomAccount() throws Exception { Task task = getTestTask(); OperationResult result = task.getResult(); - setupPhantom(TEST_NAME); + setupPhantom(); // WHEN when(TEST_NAME); @@ -1418,7 +1408,7 @@ public void test400PhantomAccount() throws Exception { assertSteadyResources(); } - protected void setupPhantom(final String TEST_NAME) throws Exception { + protected void setupPhantom() throws Exception { // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1740,7 +1730,6 @@ public void test900SetUpRoles() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = task.getResult(); SystemConfigurationType systemConfiguration = getSystemConfiguration(); display("System config", systemConfiguration); @@ -1802,7 +1791,7 @@ public void test910ConcurrentRolesAssign() throws Exception { // WHEN when(TEST_NAME); - ParallelTestThread[] threads = multithread(TEST_NAME, + ParallelTestThread[] threads = multithread( (i) -> { login(userAdministrator); Task localTask = getTestTask(); @@ -1825,7 +1814,7 @@ public void test910ConcurrentRolesAssign() throws Exception { display("Repo shadow", shadowRepo); assertShadowNotDead(shadowRepo); - assertTest910ShadowRepo(shadowRepo, task, result); + assertTest910ShadowRepo(shadowRepo); Collection> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); PrismObject shadowModel = modelService.getObject(ShadowType.class, accountDrakeOid, options, task, result); @@ -1834,7 +1823,7 @@ public void test910ConcurrentRolesAssign() throws Exception { // assertObjects(CaseType.class, numberOfCasesBefore + getConcurrentTestNumberOfThreads()); } - protected void assertTest910ShadowRepo(PrismObject shadowRepo, Task task, OperationResult result) throws Exception { + protected void assertTest910ShadowRepo(PrismObject shadowRepo) throws Exception { assertShadowNotDead(shadowRepo); ObjectDeltaType addPendingDelta = null; for (PendingOperationType pendingOperation: shadowRepo.asObjectable().getPendingOperation()) { @@ -1880,7 +1869,7 @@ public void test919ConcurrentRoleUnassign() throws Exception { // WHEN when(TEST_NAME); - ParallelTestThread[] threads = multithread(TEST_NAME, + ParallelTestThread[] threads = multithread( (i) -> { display("Thread "+Thread.currentThread().getName()+" START"); login(userAdministrator); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGrouping.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGrouping.java index 8cdf9fa8d92..e18c11ba6af 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGrouping.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGrouping.java @@ -127,7 +127,7 @@ public void test400PhantomAccount() throws Exception { Task task = getTestTask(); OperationResult result = task.getResult(); - setupPhantom(TEST_NAME); + setupPhantom(); // WHEN (mid1) when("mid1"); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMapping.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMapping.java index 3d1c0fdc198..c3b8ecb86f0 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMapping.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMapping.java @@ -179,7 +179,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti public void test100ModifyUserAssignAccountDummyBlue() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); // WHEN @@ -233,7 +233,7 @@ public void test100ModifyUserAssignAccountDummyBlue() throws Exception { public void test101ModifyUserFullName() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); // WHEN @@ -269,7 +269,7 @@ public void test101ModifyUserFullName() throws Exception { public void test102ModifyUserFullNameRecon() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); // WHEN @@ -309,7 +309,7 @@ public void test102ModifyUserFullNameRecon() throws Exception { public void test104ModifyUserOrganizationalUnit() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); // WHEN @@ -340,7 +340,7 @@ public void test104ModifyUserOrganizationalUnit() throws Exception { public void test105ModifyAccountShip() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); PrismObject userJack = getUser(USER_JACK_OID); @@ -383,7 +383,7 @@ accountOid, getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).getAttributePat public void test106ModifyAccountShipReplaceEmpty() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); PrismObject userJack = getUser(USER_JACK_OID); @@ -422,7 +422,7 @@ accountOid, getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).getAttributePat public void test107ModifyAccountShipAgain() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); PrismObject userJack = getUser(USER_JACK_OID); @@ -465,7 +465,7 @@ accountOid, getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).getAttributePat public void test108ModifyAccountShipDelete() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); PrismObject userJack = getUser(USER_JACK_OID); @@ -509,7 +509,7 @@ accountOid, getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).getAttributePat public void test110AssignBlueTitanic() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN assignRole(USER_JACK_OID, ROLE_BLUE_TITANIC_OID, task, result); @@ -528,7 +528,7 @@ public void test110AssignBlueTitanic() throws Exception { public void test111Recompute() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN recomputeUser(USER_JACK_OID, task, result); @@ -552,7 +552,7 @@ public void test111Recompute() throws Exception { public void test112DisableBlueTitanicAssignment() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -579,7 +579,7 @@ public void test112DisableBlueTitanicAssignment() throws Exception { public void test113Recompute() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN recomputeUser(USER_JACK_OID, task, result); @@ -601,7 +601,7 @@ public void test113Recompute() throws Exception { public void test114Reconcile() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN reconcileUser(USER_JACK_OID, task, result); @@ -624,7 +624,7 @@ public void test114Reconcile() throws Exception { public void test115EnableBlueTitanicAssignment() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -648,7 +648,7 @@ public void test115EnableBlueTitanicAssignment() throws Exception { public void test118UnassignBlueTitanic() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -677,7 +677,7 @@ public void test118UnassignBlueTitanic() throws Exception { public void test120AssignBluePoetry() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assertDummyAccountAttribute(RESOURCE_DUMMY_BLUE_NAME, ACCOUNT_JACK_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_QUOTE_NAME, @@ -701,7 +701,7 @@ public void test120AssignBluePoetry() throws Exception { public void test121Recompute() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN recomputeUser(USER_JACK_OID, task, result); @@ -724,7 +724,7 @@ public void test121Recompute() throws Exception { public void test122DisableBlueTitanicAssignment() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -754,7 +754,7 @@ public void test122DisableBlueTitanicAssignment() throws Exception { public void test123Recompute() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN recomputeUser(USER_JACK_OID, task, result); @@ -778,7 +778,7 @@ public void test123Recompute() throws Exception { public void test124Reconcile() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN reconcileUser(USER_JACK_OID, task, result); @@ -803,7 +803,7 @@ public void test124Reconcile() throws Exception { public void test125EnableBluePoetryAssignment() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -829,7 +829,7 @@ public void test125EnableBluePoetryAssignment() throws Exception { public void test128UnassignBluePoetry() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -855,7 +855,7 @@ public void test128UnassignBluePoetry() throws Exception { public void test129ModifyUserUnassignAccountBlue() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); Collection> deltas = new ArrayList<>(); @@ -894,7 +894,7 @@ public void test129ModifyUserUnassignAccountBlue() throws Exception { public void test140AssignCobaltAccount() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -926,7 +926,7 @@ public void test140AssignCobaltAccount() throws Exception { public void test141DestroyAndRecompute() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_COBALT_NAME, ACCOUNT_JACK_DUMMY_USERNAME); dummyAccountBefore.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, @@ -957,7 +957,7 @@ public void test141DestroyAndRecompute() throws Exception { public void test142DestroyAndReconcile() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_COBALT_NAME, ACCOUNT_JACK_DUMMY_USERNAME); dummyAccountBefore.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, @@ -988,7 +988,7 @@ public void test142DestroyAndReconcile() throws Exception { public void test143ClearAndRecompute() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_COBALT_NAME, ACCOUNT_JACK_DUMMY_USERNAME); dummyAccountBefore.replaceAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME @@ -1022,7 +1022,7 @@ public void test143ClearAndRecompute() throws Exception { public void test150AssignCobaltNeverland() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN assignRole(USER_JACK_OID, ROLE_COBALT_NEVERLAND_OID, task, result); @@ -1043,7 +1043,7 @@ public void test150AssignCobaltNeverland() throws Exception { public void test151Recompute() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN recomputeUser(USER_JACK_OID, task, result); @@ -1066,7 +1066,7 @@ public void test151Recompute() throws Exception { public void test152DisableCobalNeverlandAssignment() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -1095,7 +1095,7 @@ public void test152DisableCobalNeverlandAssignment() throws Exception { public void test153Recompute() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN recomputeUser(USER_JACK_OID, task, result); @@ -1118,7 +1118,7 @@ public void test153Recompute() throws Exception { public void test154Reconcile() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN reconcileUser(USER_JACK_OID, task, result); @@ -1142,7 +1142,7 @@ public void test154Reconcile() throws Exception { public void test155DestroyAndRecompute() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_COBALT_NAME, ACCOUNT_JACK_DUMMY_USERNAME); dummyAccountBefore.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, @@ -1173,7 +1173,7 @@ public void test155DestroyAndRecompute() throws Exception { public void test156ClearAndRecompute() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_COBALT_NAME, ACCOUNT_JACK_DUMMY_USERNAME); dummyAccountBefore.replaceAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME @@ -1204,7 +1204,7 @@ public void test156ClearAndRecompute() throws Exception { public void test157EnableCobaltNeverlandAssignment() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -1230,7 +1230,7 @@ public void test157EnableCobaltNeverlandAssignment() throws Exception { public void test158UnassignCobaltNeverland() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -1254,7 +1254,7 @@ public void test158UnassignCobaltNeverland() throws Exception { public void test159UnassignCobaltAccount() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -1280,7 +1280,7 @@ public void test159UnassignCobaltAccount() throws Exception { public void test160ModifyUserAssignAccountDummyRed() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); Collection> deltas = new ArrayList<>(); @@ -1330,7 +1330,7 @@ public void test160ModifyUserAssignAccountDummyRed() throws Exception { public void test161ModifyUserFullName() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); // WHEN @@ -1361,7 +1361,7 @@ public void test161ModifyUserFullName() throws Exception { public void test162ModifyUserOrganizationalUnit() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); // WHEN @@ -1392,7 +1392,7 @@ public void test162ModifyUserOrganizationalUnit() throws Exception { public void test163ModifyAccountShip() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); PrismObject userJack = getUser(USER_JACK_OID); @@ -1436,7 +1436,7 @@ accountOid, getDummyResourceController(RESOURCE_DUMMY_RED_NAME).getAttributePath public void test164ModifyAccountShipReplaceEmpty() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); PrismObject userJack = getUser(USER_JACK_OID); @@ -1475,7 +1475,7 @@ accountOid, getDummyResourceController(RESOURCE_DUMMY_RED_NAME).getAttributePath public void test166ModifyAccountShipDelete() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); PrismObject userJack = getUser(USER_JACK_OID); @@ -1519,7 +1519,7 @@ accountOid, getDummyResourceController(RESOURCE_DUMMY_RED_NAME).getAttributePath public void test168ModifyUserOrganization() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); // WHEN @@ -1553,7 +1553,7 @@ public void test168ModifyUserOrganization() throws Exception { public void test178ModifyUserUnassignAccountRed() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); Collection> deltas = new ArrayList<>(); @@ -1609,7 +1609,7 @@ public void test178ModifyUserUnassignAccountRed() throws Exception { public void test179DeleteAccountRed() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); PrismObject userJack = getUser(USER_JACK_OID); @@ -1653,7 +1653,7 @@ public void test179DeleteAccountRed() throws Exception { public void test180ModifyUserAssignAccountDummyDefault() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); Collection> deltas = new ArrayList<>(); @@ -1703,7 +1703,7 @@ public void test180ModifyUserAssignAccountDummyDefault() throws Exception { public void test181ModifyUserFullName() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); // WHEN @@ -1737,7 +1737,7 @@ public void test181ModifyUserFullName() throws Exception { public void test182ModifyUserLocality() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); // WHEN @@ -1768,7 +1768,7 @@ public void test182ModifyUserLocality() throws Exception { public void test183ModifyAccountLocation() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); PrismObject userJack = getUser(USER_JACK_OID); @@ -1813,7 +1813,7 @@ public void test183ModifyAccountLocation() throws Exception { public void test184ModifyAccountLocationReplaceEmpty() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); PrismObject userJack = getUser(USER_JACK_OID); @@ -1852,7 +1852,7 @@ public void test184ModifyAccountLocationReplaceEmpty() throws Exception { public void test185ModifyAccountLocationDelete() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); PrismObject userJack = getUser(USER_JACK_OID); @@ -1891,7 +1891,7 @@ public void test185ModifyAccountLocationDelete() throws Exception { public void test188ModifyUserRename() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); // WHEN @@ -1923,7 +1923,7 @@ public void test188ModifyUserRename() throws Exception { public void test189ModifyUserUnassignAccountDummy() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); Collection> deltas = new ArrayList<>(); @@ -2019,7 +2019,7 @@ private void assertAccount(PrismObject userJack, String expectedFullNa public void test200ModifyUserAssignAccountDummyCrimson() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN when(); @@ -2050,7 +2050,7 @@ public void test200ModifyUserAssignAccountDummyCrimson() throws Exception { public void test202NativeModifyDummyCrimsonThenReconcile() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); dummyAccountBefore.replaceAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, @@ -2091,7 +2091,7 @@ public void test202NativeModifyDummyCrimsonThenReconcile() throws Exception { public void test204DummyCrimsonReconcile() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); display("Dummy account before", dummyAccountBefore); @@ -2134,7 +2134,7 @@ public void test204DummyCrimsonReconcile() throws Exception { public void test206DummyCrimsonReconcileIOError() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); display("Dummy account before", dummyAccountBefore); @@ -2183,7 +2183,7 @@ public void test206DummyCrimsonReconcileIOError() throws Exception { public void test208DummyCrimsonReconcileAgain() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); getDummyResource(RESOURCE_DUMMY_CRIMSON_NAME).resetBreakMode(); @@ -2226,7 +2226,7 @@ public void test208DummyCrimsonReconcileAgain() throws Exception { public void test210ModifyUserLocality() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); getDummyResource(RESOURCE_DUMMY_CRIMSON_NAME).resetBreakMode(); @@ -2269,7 +2269,7 @@ public void test210ModifyUserLocality() throws Exception { public void test212ModifyUserLocalityRecon() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); getDummyResource(RESOURCE_DUMMY_CRIMSON_NAME).resetBreakMode(); @@ -2316,7 +2316,7 @@ public void test212ModifyUserLocalityRecon() throws Exception { public void test214ModifyUserLocalityIOError() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); getDummyResource(RESOURCE_DUMMY_CRIMSON_NAME).resetBreakMode(); @@ -2366,7 +2366,7 @@ public void test214ModifyUserLocalityIOError() throws Exception { public void test220NativeModifyDummyCrimsonThenChangePassword() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); getDummyResource(RESOURCE_DUMMY_CRIMSON_NAME).resetBreakMode(); @@ -2417,7 +2417,7 @@ public void test220NativeModifyDummyCrimsonThenChangePassword() throws Exception public void test229ModifyUserUnassignAccountDummyCrimson() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN when(); @@ -2443,7 +2443,7 @@ public void test229ModifyUserUnassignAccountDummyCrimson() throws Exception { public void test250ModifyUserAssignAccountDummyLightCrimson() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // preconditions PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -2480,7 +2480,7 @@ public void test250ModifyUserAssignAccountDummyLightCrimson() throws Exception { public void test252NativeModifyDummyLightCrimsonThenReconcile() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); dummyAccountBefore.replaceAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, @@ -2521,7 +2521,7 @@ public void test252NativeModifyDummyLightCrimsonThenReconcile() throws Exception public void test254DummyLightCrimsonReconcile() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); display("Dummy account before", dummyAccountBefore); @@ -2565,7 +2565,7 @@ public void test254DummyLightCrimsonReconcile() throws Exception { public void test256DummyLightCrimsonReconcileIOError() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); display("Dummy account before", dummyAccountBefore); @@ -2614,7 +2614,7 @@ public void test256DummyLightCrimsonReconcileIOError() throws Exception { public void test258DummyLightCrimsonReconcileAgain() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); getDummyResource(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME).resetBreakMode(); @@ -2657,7 +2657,7 @@ public void test258DummyLightCrimsonReconcileAgain() throws Exception { public void test260ModifyUserLocality() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); getDummyResource(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME).resetBreakMode(); @@ -2700,7 +2700,7 @@ public void test260ModifyUserLocality() throws Exception { public void test262ModifyUserLocalityRecon() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); getDummyResource(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME).resetBreakMode(); @@ -2747,7 +2747,7 @@ public void test262ModifyUserLocalityRecon() throws Exception { public void test264ModifyUserLocalityIOError() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); getDummyResource(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME).resetBreakMode(); @@ -2797,7 +2797,7 @@ public void test264ModifyUserLocalityIOError() throws Exception { public void test270NativeModifyDummyLightCrimsonThenChangePassword() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); getDummyResource(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME).resetBreakMode(); @@ -2848,7 +2848,7 @@ public void test270NativeModifyDummyLightCrimsonThenChangePassword() throws Exce public void test279ModifyUserUnassignAccountDummyLightCrimson() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN when(); @@ -2878,7 +2878,7 @@ public void test279ModifyUserUnassignAccountDummyLightCrimson() throws Exception public void test300AssignGuybrushDummyYellow() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN when(); @@ -2912,7 +2912,7 @@ public void test300AssignGuybrushDummyYellow() throws Exception { public void test302ModifyGuybrushLocality() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN when(); @@ -2940,7 +2940,7 @@ public void test302ModifyGuybrushLocality() throws Exception { public void test309UnassignGuybrushDummyYellow() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN when(); @@ -2965,7 +2965,7 @@ public void test309UnassignGuybrushDummyYellow() throws Exception { public void test400ModifyUserAssignAccountDummyCrimsonCustomFunction() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN when(); @@ -2991,7 +2991,7 @@ public void test400ModifyUserAssignAccountDummyCrimsonCustomFunction() throws Ex public void test401ModifyUserLocalityDummyCrisomCustomFunction() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN when(); @@ -3018,7 +3018,7 @@ public void test401ModifyUserLocalityDummyCrisomCustomFunction() throws Exceptio public void test402ModifyDrinkDummyCustomFunctionCrimson() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN when(); @@ -3053,7 +3053,7 @@ public void test402ModifyDrinkDummyCustomFunctionCrimson() throws Exception { public void test420AssignAntinihilistToJack() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -3091,7 +3091,7 @@ public void test420AssignAntinihilistToJack() throws Exception { public void test422AssignAccountAndAntinihilistToJack() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null); @@ -3122,7 +3122,7 @@ public void test422AssignAccountAndAntinihilistToJack() throws Exception { public void test425UnassignAntinihilistFromJack() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -3151,7 +3151,7 @@ public void test425UnassignAntinihilistFromJack() throws Exception { public void test427UnassignAccountFromJack() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -3204,7 +3204,7 @@ public void test500AssignmentsCombinationSingle() throws Exception { public void test510AssignmentsCombinationCouple() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject jim = findUserByUsername(USER_JIM_NAME); @@ -3228,7 +3228,7 @@ public void test510AssignmentsCombinationCouple() throws Exception { public void test520DeleteUserAssignment() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject jim = findUserByUsername(USER_JIM_NAME); @@ -3259,7 +3259,7 @@ public void test520DeleteUserAssignment() throws Exception { public void test600AddService() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); final String PASSWORD = "pwd1234"; // WHEN @@ -3289,7 +3289,7 @@ public void test600AddService() throws Exception { public void test610ModifyServicePassword() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); final String NEW_PASSWORD = "dummy"; ProtectedStringType newPasswordProtected = new ProtectedStringType(); @@ -3326,7 +3326,7 @@ public void test610ModifyServicePassword() throws Exception { public void test650ImportFromInboundPwdCopy() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); final String PASSWORD = "secret"; @@ -3378,7 +3378,7 @@ public void test660ImportFromInboundPwdCopyModifyPassword() throws Exception { public void test670ImportFromInboundPwdGenerate() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); final String PASSWORD = "secret-gw"; @@ -3435,7 +3435,7 @@ public void test680ImportFromInboundPwdGenerateModifyPassword() throws Exception public void test700TimedOutbound() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); UserType user = new UserType(prismContext) .name("test700") diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestAssignmentErrors.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestAssignmentErrors.java index 6582f22a4b1..93ef24a369e 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestAssignmentErrors.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestAssignmentErrors.java @@ -104,8 +104,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test010RefinedSchemaWhite() throws Exception { - final String TEST_NAME = "test010RefinedSchemaWhite"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN // WHEN @@ -563,7 +561,6 @@ public void test220UserAssignAccountDeletedShadowRecomputeSync() throws Exceptio @Test public void test222UserAssignAccountDeletedShadowRecomputeNoSync() throws Exception { final String TEST_NAME = "test222UserAssignAccountDeletedShadowRecomputeNoSync"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN PrismObject user = setupUserAssignAccountDeletedShadowRecompute(TEST_NAME, RESOURCE_DUMMY_RED_OID, diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestBrokenResources.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestBrokenResources.java index 017b1132a86..12a4e8122d2 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestBrokenResources.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestBrokenResources.java @@ -259,7 +259,6 @@ public void test101GetAccountMurrayNoFetch() throws Exception { @Test public void test102GetAccountMurrayRaw() throws Exception { - TestUtil.displayTestTitle(this, "test102GetAccountMurrayRaw"); // GIVEN Task task = taskManager.createTaskInstance(TestBrokenResources.class.getName() + ".test102GetAccountMurrayRaw"); @@ -282,7 +281,6 @@ public void test102GetAccountMurrayRaw() throws Exception { @Test public void test120SearchAccountByUsernameJack() throws Exception { - TestUtil.displayTestTitle(this, "test120SearchAccountByUsernameJack"); // GIVEN Task task = taskManager.createTaskInstance(TestBrokenResources.class.getName() + ".test120SearchAccountByUsernameJack"); @@ -307,7 +305,6 @@ public void test120SearchAccountByUsernameJack() throws Exception { @Test public void test210TestResourceNotFound() throws Exception { - TestUtil.displayTestTitle(this, "test210TestResourceNotFound"); // GIVEN Task task = taskManager.createTaskInstance(TestBrokenResources.class.getName() + ".test210TestResourceNotFound"); @@ -381,7 +378,6 @@ public void test221GetResourceNotFoundResolveConnector() throws Exception { @Test public void test310TestResourceNoJars() throws Exception { - TestUtil.displayTestTitle(this, "test310TestResourceNoJars"); // GIVEN Task task = taskManager.createTaskInstance(TestBrokenResources.class.getName() + ".test310TestResourceNoJars"); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestModelWebServiceNegative.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestModelWebServiceNegative.java index 8ae33fe2e75..2737cf9bdf1 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestModelWebServiceNegative.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestModelWebServiceNegative.java @@ -24,7 +24,6 @@ import com.evolveum.midpoint.schema.constants.ObjectTypes; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.DummyResourceContoller; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType; @@ -64,7 +63,6 @@ public class TestModelWebServiceNegative extends AbstractInitializedModelIntegra @Test public void test100ModifyAccountExplicitType() throws Exception { final String TEST_NAME = "test100ModifyUserAddAccount"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestModelWebServiceNegative.class.getName() + "." + TEST_NAME); @@ -92,7 +90,6 @@ public void test100ModifyAccountExplicitType() throws Exception { @Test public void test110ModifyAccountImplicitType() throws Exception { final String TEST_NAME = "test110ModifyAccountImplicitType"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestModelWebServiceNegative.class.getName() + "." + TEST_NAME); @@ -117,7 +114,6 @@ public void test110ModifyAccountImplicitType() throws Exception { @Test public void test200ModifyAccountWrongExplicitType() throws Exception { final String TEST_NAME = "test200ModifyAccountWrongExplicitType"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestModelWebServiceNegative.class.getName() + "." + TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStructCaribbean.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStructCaribbean.java index dd2d3f9bd9d..be3601033a4 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStructCaribbean.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStructCaribbean.java @@ -75,7 +75,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100AddOrgCaribbean() throws Exception { final String TEST_NAME = "test100AddOrgCaribbean"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgStructCaribbean.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -85,7 +84,7 @@ public void test100AddOrgCaribbean() throws Exception { repoAddObjectsFromFile(ORG_CARIBBEAN_FILE, OrgType.class, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -111,7 +110,6 @@ public void test100AddOrgCaribbean() throws Exception { @Test public void test102RecomputeJamaica() throws Exception { final String TEST_NAME = "test102RecomputeJamaica"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgStructCaribbean.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -121,7 +119,7 @@ public void test102RecomputeJamaica() throws Exception { modelService.recompute(OrgType.class, ORG_CARIBBEAN_JAMAICA_OID, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -142,7 +140,6 @@ public void test102RecomputeJamaica() throws Exception { @Test public void test103ReconcileJamaica() throws Exception { final String TEST_NAME = "test103ReconcileJamaica"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgStructCaribbean.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -152,7 +149,7 @@ public void test103ReconcileJamaica() throws Exception { reconcileOrg(ORG_CARIBBEAN_JAMAICA_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -173,7 +170,6 @@ public void test103ReconcileJamaica() throws Exception { @Test public void test104RecomputeGovernor() throws Exception { final String TEST_NAME = "test104RecomputeGovernor"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgStructCaribbean.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -183,7 +179,7 @@ public void test104RecomputeGovernor() throws Exception { modelService.recompute(OrgType.class, ORG_GOVERNOR_OFFICE_OID, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -204,7 +200,6 @@ public void test104RecomputeGovernor() throws Exception { @Test public void test105ReconcileGovernor() throws Exception { final String TEST_NAME = "test105ReconcileGovernor"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgStructCaribbean.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -214,7 +209,7 @@ public void test105ReconcileGovernor() throws Exception { reconcileOrg(ORG_GOVERNOR_OFFICE_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -238,7 +233,6 @@ public void test105ReconcileGovernor() throws Exception { @Test public void test106RecomputeDoT() throws Exception { final String TEST_NAME = "test106RecomputeDoT"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgStructCaribbean.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -249,7 +243,7 @@ public void test106RecomputeDoT() throws Exception { ModelExecuteOptions.createReconcileFocus(), task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -275,7 +269,6 @@ public void test106RecomputeDoT() throws Exception { @Test public void test107ReconcileDoT() throws Exception { final String TEST_NAME = "test107ReconcileDoT"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgStructCaribbean.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -285,7 +278,7 @@ public void test107ReconcileDoT() throws Exception { reconcileOrg(ORG_CARIBBEAN_DEPARTMENT_OF_THINGS_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -315,7 +308,6 @@ public void test107ReconcileDoT() throws Exception { @Test public void test110RecomputeDoP() throws Exception { final String TEST_NAME = "test110RecomputeDoP"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgStructCaribbean.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -325,7 +317,7 @@ public void test110RecomputeDoP() throws Exception { modelService.recompute(OrgType.class, ORG_CARIBBEAN_DEPARTMENT_OF_PEOPLE_OID, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -350,7 +342,6 @@ public void test110RecomputeDoP() throws Exception { @Test public void test115AssignJackToDoP() throws Exception { final String TEST_NAME = "test115AssignJackToDoP"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgStructCaribbean.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -366,7 +357,7 @@ public void test115AssignJackToDoP() throws Exception { assignOrg(USER_JACK_OID, ORG_CARIBBEAN_DEPARTMENT_OF_PEOPLE_OID, null); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -401,7 +392,6 @@ public void test115AssignJackToDoP() throws Exception { @Test public void test120AssignBarbossaDoTManager() throws Exception { final String TEST_NAME = "test120AssignBarbossaDoTManager"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgStructCaribbean.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -414,7 +404,7 @@ public void test120AssignBarbossaDoTManager() throws Exception { assignOrg(USER_BARBOSSA_OID, ORG_CARIBBEAN_DEPARTMENT_OF_THINGS_OID, SchemaConstants.ORG_MANAGER); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -439,7 +429,6 @@ public void test120AssignBarbossaDoTManager() throws Exception { @Test public void test130AssignGibbsAsJacksDeputy() throws Exception { final String TEST_NAME = "test130AssignGibbsAsJacksDeputy"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgStructCaribbean.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -452,7 +441,7 @@ public void test130AssignGibbsAsJacksDeputy() throws Exception { assignDeputy(USER_GIBBS_OID, USER_JACK_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -479,7 +468,6 @@ public void test130AssignGibbsAsJacksDeputy() throws Exception { @Test public void test140AssignPintelAsBarbossasDeputy() throws Exception { final String TEST_NAME = "test140AssignPintelAsBarbossasDeputy"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgStructCaribbean.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -492,7 +480,7 @@ public void test140AssignPintelAsBarbossasDeputy() throws Exception { assignDeputy(USER_PINTEL_OID, USER_BARBOSSA_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStructMeta.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStructMeta.java index 18dba2fd6dc..2ebf0861ee3 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStructMeta.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStructMeta.java @@ -140,7 +140,6 @@ protected void assertUserNoOrg(PrismObject user) throws Exception { @Test public void test800JackAssignScummBar() throws Exception { final String TEST_NAME = "test800JackAssignScummBar"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgStruct.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -168,7 +167,6 @@ public void test800JackAssignScummBar() throws Exception { @Test public void test802JackAssignOrganized() throws Exception { final String TEST_NAME = "test802JackAssignOrganized"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgStruct.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -197,7 +195,6 @@ public void test802JackAssignOrganized() throws Exception { @Test public void test804JackUnAssignOrganized() throws Exception { final String TEST_NAME = "test804JackUnAssignOrganized"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgStruct.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -225,7 +222,6 @@ public void test804JackUnAssignOrganized() throws Exception { @Test public void test809JackUnassignScummBar() throws Exception { final String TEST_NAME = "test809JackUnassignScummBar"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgStruct.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -252,7 +248,6 @@ public void test809JackUnassignScummBar() throws Exception { @Test public void test810JackAssignScummBarOrganized() throws Exception { final String TEST_NAME = "test810JackAssignScummBarOrganized"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgStruct.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -288,7 +283,6 @@ public void test810JackAssignScummBarOrganized() throws Exception { @Test public void test890AddFictionalOrg() throws Exception { final String TEST_NAME = "test890AddFictionalOrg"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgStruct.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -298,7 +292,7 @@ public void test890AddFictionalOrg() throws Exception { addObject(ORG_FICTIONAL_FILE, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject org = getObject(OrgType.class, ORG_FICTIONAL_OID); assertNotNull("No fictional org", org); display("Fictional org", org); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefault.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefault.java index 05c126c9789..30355144993 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefault.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefault.java @@ -15,7 +15,6 @@ import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; @@ -54,7 +53,6 @@ protected void assertShadowLifecycle(PrismObject shadow, boolean foc @Test public void test202ReconcileUserJack() throws Exception { final String TEST_NAME = "test202ReconcileUserJack"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(AbstractPasswordTest.class.getName() + "." + TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefaultHashing.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefaultHashing.java index c3e82a13fa5..686e6527cfb 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefaultHashing.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefaultHashing.java @@ -66,7 +66,6 @@ protected void assertShadowLifecycle(PrismObject shadow, boolean foc @Test public void test202ReconcileUserJack() throws Exception { final String TEST_NAME = "test202ReconcileUserJack"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(AbstractPasswordTest.class.getName() + "." + TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestSegregationOfDuties.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestSegregationOfDuties.java index d6ae8a5d9e4..6ea4b6779b5 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestSegregationOfDuties.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestSegregationOfDuties.java @@ -553,7 +553,7 @@ public void test200GuybrushAssignRoleGold() throws Exception { assignRole(USER_GUYBRUSH_OID, ROLE_PRIZE_GOLD_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -586,7 +586,7 @@ public void test202GuybrushAssignRoleSilver() throws Exception { assignRole(USER_GUYBRUSH_OID, ROLE_PRIZE_SILVER_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -620,7 +620,7 @@ public void test204GuybrushAssignRoleSailor() throws Exception { assignRole(USER_GUYBRUSH_OID, ROLE_SAILOR_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -655,7 +655,7 @@ public void test206GuybrushAssignRoleBronze() throws Exception { assignRole(USER_GUYBRUSH_OID, ROLE_PRIZE_BRONZE_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -689,7 +689,7 @@ public void test208GuybrushUnassignRoleBronze() throws Exception { unassignRole(USER_GUYBRUSH_OID, ROLE_PRIZE_BRONZE_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -721,7 +721,7 @@ public void test209GuybrushUnassignRoleSailor() throws Exception { unassignRole(USER_GUYBRUSH_OID, ROLE_SAILOR_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -846,7 +846,7 @@ public void test212GuybrushAssignRoleGreen() throws Exception { assignRole(USER_GUYBRUSH_OID, ROLE_COLOR_GREEN_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -878,7 +878,7 @@ public void test214GuybrushAssignRoleColorNone() throws Exception { assignRole(USER_GUYBRUSH_OID, ROLE_COLOR_NONE_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -908,7 +908,7 @@ public void test216GuybrushAssignRoleBlue() throws Exception { assignRole(USER_GUYBRUSH_OID, ROLE_COLOR_BLUE_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1815,7 +1815,7 @@ public void test960JimGoldByMapping() throws Exception { assignRole(jim.getOid(), ROLE_PRIZE_GOLD_BY_MAPPING_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/scripting/TestScriptingBasic.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/scripting/TestScriptingBasic.java index 21e11841c53..47309a9d71e 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/scripting/TestScriptingBasic.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/scripting/TestScriptingBasic.java @@ -147,7 +147,6 @@ protected File getSystemConfigurationFile() { @Test public void test100EmptySequence() throws Exception { final String TEST_NAME = "test100EmptySequence"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = getTestTask(); @@ -167,7 +166,6 @@ public void test100EmptySequence() throws Exception { @Test public void test110EmptyPipeline() throws Exception { final String TEST_NAME = "test110EmptyPipeline"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = getTestTask(); @@ -187,7 +185,6 @@ public void test110EmptyPipeline() throws Exception { @Test public void test112Echo() throws Exception { final String TEST_NAME = "test112Echo"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(DOT_CLASS + TEST_NAME); @@ -210,7 +207,6 @@ public void test112Echo() throws Exception { @Test public void test120Log() throws Exception { final String TEST_NAME = "test120Log"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = getTestTask(); @@ -244,7 +240,6 @@ private T parseRealValue(File file) throws IOException, SchemaException { @Test public void test200SearchUser() throws Exception { final String TEST_NAME = "test200SearchUser"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = getTestTask(); @@ -265,7 +260,6 @@ public void test200SearchUser() throws Exception { @Test public void test202SearchUserWithExpressions() throws Exception { final String TEST_NAME = "test202SearchUserWithExpressions"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = getTestTask(); @@ -292,7 +286,6 @@ public void test202SearchUserWithExpressions() throws Exception { @Test public void test205SearchForResources() throws Exception { final String TEST_NAME = "test205SearchForResources"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = getTestTask(); @@ -312,7 +305,6 @@ public void test205SearchForResources() throws Exception { @Test public void test206SearchForRoles() throws Exception { final String TEST_NAME = "test206SearchForRoles"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = getTestTask(); @@ -332,7 +324,6 @@ public void test206SearchForRoles() throws Exception { @Test public void test210SearchForShadows() throws Exception { final String TEST_NAME = "test210SearchForShadows"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = getTestTask(); @@ -353,7 +344,6 @@ public void test210SearchForShadows() throws Exception { @Test public void test215SearchForShadowsNoFetch() throws Exception { final String TEST_NAME = "test215SearchForShadowsNoFetch"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = getTestTask(); @@ -374,7 +364,6 @@ public void test215SearchForShadowsNoFetch() throws Exception { @Test public void test220SearchForUsersAccounts() throws Exception { final String TEST_NAME = "test220SearchForUsersAccounts"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = getTestTask(); @@ -395,7 +384,6 @@ public void test220SearchForUsersAccounts() throws Exception { @Test public void test225SearchForUsersAccountsNoFetch() throws Exception { final String TEST_NAME = "test225SearchForUsersAccountsNoFetch"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = getTestTask(); @@ -416,7 +404,6 @@ public void test225SearchForUsersAccountsNoFetch() throws Exception { @Test public void test300DisableJack() throws Exception { final String TEST_NAME = "test300DisableJack"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = getTestTask(); @@ -438,7 +425,6 @@ public void test300DisableJack() throws Exception { @Test public void test310EnableJack() throws Exception { final String TEST_NAME = "test310EnableJack"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = getTestTask(); @@ -460,7 +446,6 @@ public void test310EnableJack() throws Exception { @Test public void test320DeleteAndAddJack() throws Exception { final String TEST_NAME = "test320DeleteAndAddJack"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = getTestTask(); @@ -482,7 +467,6 @@ public void test320DeleteAndAddJack() throws Exception { @Test public void test330ModifyJack() throws Exception { final String TEST_NAME = "test330ModifyJack"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = getTestTask(); @@ -504,7 +488,6 @@ public void test330ModifyJack() throws Exception { @Test public void test340ModifyJackBack() throws Exception { final String TEST_NAME = "test340ModifyJackBack"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = getTestTask(); @@ -526,7 +509,6 @@ public void test340ModifyJackBack() throws Exception { @Test public void test350RecomputeJack() throws Exception { final String TEST_NAME = "test350RecomputeJack"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = getTestTask(); @@ -547,7 +529,6 @@ public void test350RecomputeJack() throws Exception { @Test public void test360AssignToJack() throws Exception { final String TEST_NAME = "test360AssignToJack"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = getTestTask(); @@ -572,7 +553,6 @@ public void test360AssignToJack() throws Exception { @Test public void test370AssignToJackInBackground() throws Exception { final String TEST_NAME = "test370AssignToJackInBackground"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN OperationResult result = new OperationResult(DOT_CLASS + TEST_NAME); @@ -597,7 +577,6 @@ public void test370AssignToJackInBackground() throws Exception { @Test public void test380DisableJackInBackgroundSimple() throws Exception { final String TEST_NAME = "test380DisableJackInBackgroundSimple"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN OperationResult result = new OperationResult(DOT_CLASS + TEST_NAME); @@ -623,7 +602,6 @@ public void test380DisableJackInBackgroundSimple() throws Exception { @Test public void test390AssignToWill() throws Exception { final String TEST_NAME = "test390AssignToWill"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = getTestTask(); @@ -646,7 +624,6 @@ public void test390AssignToWill() throws Exception { @Test public void test391UnassignFromWill() throws Exception { final String TEST_NAME = "test391UnassignFromJack"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = getTestTask(); @@ -671,7 +648,6 @@ public void test391UnassignFromWill() throws Exception { @Test public void test392UnassignFromWill2() throws Exception { final String TEST_NAME = "test392UnassignFromWill2"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = getTestTask(); @@ -696,7 +672,6 @@ public void test392UnassignFromWill2() throws Exception { @Test public void test393UnassignFromWill3() throws Exception { final String TEST_NAME = "test393UnassignFromWill3"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = getTestTask(); @@ -721,7 +696,6 @@ public void test393UnassignFromWill3() throws Exception { @Test public void test394AssignToWill2() throws Exception { final String TEST_NAME = "test394AssignToWill2"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN QName customRelation = new QName("http://midpoint.evolveum.com/xml/ns/samples/piracy", "piracy:captain"); @@ -758,7 +732,6 @@ public void test394AssignToWill2() throws Exception { @Test public void test400PurgeSchema() throws Exception { final String TEST_NAME = "test400PurgeSchema"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = getTestTask(); @@ -793,7 +766,6 @@ public void test400PurgeSchema() throws Exception { @Test public void test410TestResource() throws Exception { final String TEST_NAME = "test410TestResource"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = getTestTask(); @@ -816,7 +788,6 @@ public void test410TestResource() throws Exception { @Test public void test420NotificationAboutJack() throws Exception { final String TEST_NAME = "test420NotificationAboutJack"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = getTestTask(); @@ -844,7 +815,6 @@ public void test420NotificationAboutJack() throws Exception { @Test public void test430NotificationAboutJackType2() throws Exception { final String TEST_NAME = "test430NotificationAboutJackType2"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = getTestTask(); @@ -877,7 +847,6 @@ public void test430NotificationAboutJackType2() throws Exception { @Test public void test500ScriptingUsers() throws Exception { final String TEST_NAME = "test500ScriptingUsers"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = getTestTask(); @@ -909,7 +878,6 @@ public void test500ScriptingUsers() throws Exception { @Test public void test505ScriptingUsersInBackground() throws Exception { final String TEST_NAME = "test505ScriptingUsersInBackground"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = getTestTask(); @@ -954,7 +922,6 @@ public void test505ScriptingUsersInBackground() throws Exception { @Test public void test507ScriptingUsersInBackgroundAssign() throws Exception { final String TEST_NAME = "test507ScriptingUsersInBackgroundAssign"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = getTestTask(); @@ -993,7 +960,6 @@ public void test507ScriptingUsersInBackgroundAssign() throws Exception { @Test public void test510GeneratePasswords() throws Exception { final String TEST_NAME = "test510GeneratePasswords"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = getTestTask(); @@ -1035,7 +1001,6 @@ public void test510GeneratePasswords() throws Exception { @Test public void test520GeneratePasswordsFullInput() throws Exception { final String TEST_NAME = "test520GeneratePasswordsFullInput"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(DOT_CLASS + TEST_NAME); @@ -1061,7 +1026,6 @@ public void test520GeneratePasswordsFullInput() throws Exception { @Test public void test530GeneratePasswordsReally() throws Exception { final String TEST_NAME = "test530GeneratePasswordsReally"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(DOT_CLASS + TEST_NAME); @@ -1103,7 +1067,6 @@ private void checkPassword(PipelineItem item, String userOid) @Test public void test540SearchUserResolveNamesForRoleMembershipRef() throws Exception { final String TEST_NAME = "test540SearchUserResolveNamesForRoleMembershipRef"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = getTestTask(); @@ -1129,7 +1092,6 @@ public void test540SearchUserResolveNamesForRoleMembershipRef() throws Exception @Test public void test545SearchUserResolveRoleMembershipRef() throws Exception { final String TEST_NAME = "test545SearchUserResolveRoleMembershipRef"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = getTestTask(); @@ -1155,7 +1117,6 @@ public void test545SearchUserResolveRoleMembershipRef() throws Exception { @Test public void test550UseVariables() throws Exception { final String TEST_NAME = "test550UseVariables"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(DOT_CLASS + TEST_NAME); @@ -1186,7 +1147,6 @@ public void test550UseVariables() throws Exception { @Test public void test560StartTaskFromTemplate() throws Exception { final String TEST_NAME = "test560StartTaskFromTemplate"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = getTestTask(); @@ -1235,7 +1195,6 @@ public void test560StartTaskFromTemplate() throws Exception { @Test public void test570IterativeScriptingTask() throws Exception { final String TEST_NAME = "test570IterativeScriptingTask"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = getTestTask(); @@ -1257,7 +1216,6 @@ public void test570IterativeScriptingTask() throws Exception { @Test(enabled = false) // probably obsolete public void test575ResumeTask() throws Exception { final String TEST_NAME = "test570ResumeTask"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = getTestTask(); @@ -1291,7 +1249,6 @@ public void test575ResumeTask() throws Exception { @Test public void test600ModifyJackPasswordInBackground() throws Exception { final String TEST_NAME = "test600ModifyJackPasswordInBackground"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN OperationResult result = new OperationResult(DOT_CLASS + TEST_NAME); @@ -1326,7 +1283,6 @@ public void test600ModifyJackPasswordInBackground() throws Exception { @Test public void test610ModifyJackPasswordImportingTask() throws Exception { final String TEST_NAME = "test610ModifyJackPasswordImportingTask"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task opTask = taskManager.createTaskInstance(DOT_CLASS + TEST_NAME); @@ -1365,7 +1321,6 @@ public void test610ModifyJackPasswordImportingTask() throws Exception { @Test public void test620ModifyJackPasswordViaExecuteChangesAsynchronously() throws Exception { final String TEST_NAME = "test620ModifyJackPasswordViaExecuteChangesAsynchronously"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task opTask = taskManager.createTaskInstance(DOT_CLASS + TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/AbstractSecurityTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/AbstractSecurityTest.java index 3e9868d3c02..df25b1bac44 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/AbstractSecurityTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/AbstractSecurityTest.java @@ -525,7 +525,6 @@ protected int getNumberOfRoles() { @Test public void test010SanitySelf() throws Exception { final String TEST_NAME = "test010SanitySelf"; - TestUtil.displayTestTitle(this, TEST_NAME); assertLoggedInUsername(USER_ADMINISTRATOR_USERNAME); // WHEN @@ -549,7 +548,6 @@ public void test010SanitySelf() throws Exception { @Test public void test020SanityArchetypedRoles() throws Exception { final String TEST_NAME = "test020SanityArchetypedRoles"; - TestUtil.displayTestTitle(this, TEST_NAME); assertLoggedInUsername(USER_ADMINISTRATOR_USERNAME); // WHEN, THEN diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityBasic.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityBasic.java index 1a18ff1be70..d6214f63375 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityBasic.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityBasic.java @@ -2171,7 +2171,7 @@ public void test261AutzAngelicaObjectFilterLocationCreateUserShadowRole() throws (task, result) -> addObject(USER_ANGELICA_FILE, task, result)); // THEN - TestUtil.displayThen(TEST_NAME); + then(); login(USER_ADMINISTRATOR_USERNAME); // user jack seemingly has no rights to search for angelika diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityPrincipal.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityPrincipal.java index d28ef006220..a632856dde0 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityPrincipal.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityPrincipal.java @@ -159,7 +159,7 @@ public void test061GuybrushConditionalRoleTrue() throws Exception { MidPointPrincipal principal = focusProfileService.getPrincipal(USER_GUYBRUSH_USERNAME, UserType.class); // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("Principal guybrush", principal); assertEquals("wrong username", USER_GUYBRUSH_USERNAME, principal.getUsername()); assertEquals("wrong oid", USER_GUYBRUSH_OID, principal.getOid()); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractInboundSyncTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractInboundSyncTest.java index f8545a70246..39693ba4aee 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractInboundSyncTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractInboundSyncTest.java @@ -30,7 +30,6 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.DummyResourceContoller; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.MiscUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; @@ -94,7 +93,6 @@ protected int getNumberOfExtraDummyUsers() { @Test public void test100ImportLiveSyncTaskDummyEmerald() throws Exception { final String TEST_NAME = "test100ImportLiveSyncTaskDummyEmerald"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN AbstractInboundSyncTest.class.getName(); @@ -106,7 +104,7 @@ public void test100ImportLiveSyncTaskDummyEmerald() throws Exception { importSyncTask(resourceDummyEmerald); // THEN - TestUtil.displayThen(TEST_NAME); + then(); waitForSyncTaskStart(resourceDummyEmerald); } @@ -114,7 +112,6 @@ public void test100ImportLiveSyncTaskDummyEmerald() throws Exception { @Test public void test110AddDummyEmeraldAccountMancomb() throws Exception { final String TEST_NAME = "test110AddDummyEmeraldAccountMancomb"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN AbstractInboundSyncTest.class.getName(); @@ -145,7 +142,7 @@ public void test110AddDummyEmeraldAccountMancomb() throws Exception { waitForSyncTaskNextRun(resourceDummyEmerald); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject accountMancomb = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, resourceDummyEmerald); display("Account mancomb", accountMancomb); @@ -173,7 +170,6 @@ public void test110AddDummyEmeraldAccountMancomb() throws Exception { @Test public void test120ModifyDummyEmeraldAccountMancombSeepbad() throws Exception { final String TEST_NAME = "test120ModifyDummyEmeraldAccountMancombSeepbad"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN AbstractInboundSyncTest.class.getName(); @@ -197,7 +193,7 @@ public void test120ModifyDummyEmeraldAccountMancombSeepbad() throws Exception { waitForSyncTaskNextRun(resourceDummyEmerald); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject accountAfter = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, resourceDummyEmerald); display("Account mancomb", accountAfter); @@ -229,7 +225,6 @@ public void test120ModifyDummyEmeraldAccountMancombSeepbad() throws Exception { @Test public void test122ModifyDummyEmeraldAccountMancombSeepNULL() throws Exception { final String TEST_NAME = "test122ModifyDummyEmeraldAccountMancombSeepNULL"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN AbstractInboundSyncTest.class.getName(); @@ -253,7 +248,7 @@ public void test122ModifyDummyEmeraldAccountMancombSeepNULL() throws Exception { waitForSyncTaskNextRun(resourceDummyEmerald); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject accountAfter = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, resourceDummyEmerald); display("Account mancomb", accountAfter); @@ -285,7 +280,6 @@ public void test122ModifyDummyEmeraldAccountMancombSeepNULL() throws Exception { @Test public void test124ModifyDummyEmeraldAccountMancombSeepevil() throws Exception { final String TEST_NAME = "test124ModifyDummyEmeraldAccountMancombSeepevil"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN AbstractInboundSyncTest.class.getName(); @@ -309,7 +303,7 @@ public void test124ModifyDummyEmeraldAccountMancombSeepevil() throws Exception { waitForSyncTaskNextRun(resourceDummyEmerald); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject accountAfter = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, resourceDummyEmerald); display("Account mancomb", accountAfter); @@ -341,7 +335,6 @@ public void test124ModifyDummyEmeraldAccountMancombSeepevil() throws Exception { @Test public void test126ModifyDummyEmeraldAccountMancombTitlePirate() throws Exception { final String TEST_NAME = "test126ModifyDummyEmeraldAccountMancombTitlePirate"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN AbstractInboundSyncTest.class.getName(); @@ -365,7 +358,7 @@ public void test126ModifyDummyEmeraldAccountMancombTitlePirate() throws Exceptio waitForSyncTaskNextRun(resourceDummyEmerald); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject accountAfter = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, resourceDummyEmerald); display("Account mancomb", accountAfter); @@ -398,7 +391,6 @@ public void test126ModifyDummyEmeraldAccountMancombTitlePirate() throws Exceptio @Test public void test127ModifyDummyEmeraldAccountMancombTitlePirateNull() throws Exception { final String TEST_NAME = "test127ModifyDummyEmeraldAccountMancombTitlePirateNull"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN AbstractInboundSyncTest.class.getName(); @@ -422,7 +414,7 @@ public void test127ModifyDummyEmeraldAccountMancombTitlePirateNull() throws Exce waitForSyncTaskNextRun(resourceDummyEmerald); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject accountAfter = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, resourceDummyEmerald); display("Account mancomb", accountAfter); @@ -455,7 +447,6 @@ public void test127ModifyDummyEmeraldAccountMancombTitlePirateNull() throws Exce @Test public void test129ModifyDummyEmeraldAccountMancombSeepgood() throws Exception { final String TEST_NAME = "test129ModifyDummyEmeraldAccountMancombSeepgood"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN AbstractInboundSyncTest.class.getName(); @@ -479,7 +470,7 @@ public void test129ModifyDummyEmeraldAccountMancombSeepgood() throws Exception { waitForSyncTaskNextRun(resourceDummyEmerald); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject accountAfter = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, resourceDummyEmerald); display("Account mancomb", accountAfter); @@ -521,7 +512,6 @@ public void test180NoChange() throws Exception { @Test public void test300AddDummyEmeraldAccountPosixUser() throws Exception { final String TEST_NAME = "test300AddDummyEmeraldAccountPosixUser"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN AbstractInboundSyncTest.class.getName(); @@ -551,7 +541,7 @@ public void test300AddDummyEmeraldAccountPosixUser() throws Exception { waitForSyncTaskNextRun(resourceDummyEmerald); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject accountPosixUser = findAccountByUsername(ACCOUNT_POSIXUSER_DUMMY_USERNAME, resourceDummyEmerald); display("Account posixuser", accountPosixUser); @@ -580,7 +570,6 @@ public void test300AddDummyEmeraldAccountPosixUser() throws Exception { @Test public void test310ModifyDummyEmeraldAccountPosixUserUidNumber() throws Exception { final String TEST_NAME = "test310ModifyDummyEmeraldAccountPosixUserUidNumber"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN AbstractInboundSyncTest.class.getName(); @@ -604,7 +593,7 @@ public void test310ModifyDummyEmeraldAccountPosixUserUidNumber() throws Exceptio waitForSyncTaskNextRun(resourceDummyEmerald); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject accountAfter = findAccountByUsername(ACCOUNT_POSIXUSER_DUMMY_USERNAME, resourceDummyEmerald); display("Account posixuser", accountAfter); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractObjTemplateSyncTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractObjTemplateSyncTest.java index 2a07e6e549b..5d541191928 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractObjTemplateSyncTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractObjTemplateSyncTest.java @@ -14,7 +14,6 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.DummyResourceContoller; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.MiscUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; @@ -109,7 +108,6 @@ protected int getWaitTimeout() { @Test public void test100ImportLiveSyncTaskDummyByzantine() throws Exception { final String TEST_NAME = "test100ImportLiveSyncTaskDummyByzantine"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN AbstractObjTemplateSyncTest.class.getName(); @@ -121,7 +119,7 @@ public void test100ImportLiveSyncTaskDummyByzantine() throws Exception { importSyncTask(resourceDummyByzantine); // THEN - TestUtil.displayThen(TEST_NAME); + then(); waitForSyncTaskStart(resourceDummyByzantine); } diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractSynchronizationStoryTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractSynchronizationStoryTest.java index c743e7f5bb8..eaaa30221f2 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractSynchronizationStoryTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractSynchronizationStoryTest.java @@ -482,7 +482,7 @@ public void test360ModifyUserAddDummyDefaultAccount() throws Exception { // DummyAccount wallyDummyAccount = getDummyResource(RESOURCE_DUMMY_GREEN_NAME).getAccountByUsername(ACCOUNT_WALLY_DUMMY_USERNAME); // // /// WHEN -// displayWhen(TEST_NAME); +// when(); // wallyDummyAccount.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Wally Bloodnose"); //// wallyDummyAccount.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_QUOTE_NAME, "Cola"); // @@ -498,7 +498,7 @@ public void test360ModifyUserAddDummyDefaultAccount() throws Exception { // waitForSyncTaskNextRun(resourceDummy); // // // THEN -// displayThen(TEST_NAME); +// then(); // // PrismObject userWally = findUserByUsername(ACCOUNT_WALLY_DUMMY_USERNAME); // display("User wally", userWally); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestProgressReporting.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestProgressReporting.java index da7da82a910..938d07ab5af 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestProgressReporting.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestProgressReporting.java @@ -83,7 +83,7 @@ public void test110ReconciliationSuspensionMultiNode() throws Exception { private void executeReconciliation(TestResource reconciliationTask, String accountPrefix, int workers) throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // GIVEN for (int i = 0; i < USERS; i++) { @@ -163,7 +163,7 @@ public void test160RecomputationSuspensionMultiNode() throws Exception { private void executeRecomputation(TestResource recomputationTask, String rolePrefix, int workers) throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // GIVEN System.out.println("Importing roles."); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestRecomputeTask.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestRecomputeTask.java index 582d0766293..cf2bec31476 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestRecomputeTask.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestRecomputeTask.java @@ -93,7 +93,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti public void test100RecomputeAll() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // Preconditions assertUsers(6); @@ -254,7 +254,7 @@ private void displayRoles(Task task, OperationResult result) throws ObjectNotFou public void test110RecomputeSome() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // Preconditions assertUsers(7); @@ -310,7 +310,7 @@ public void test110RecomputeSome() throws Exception { public void test120RecomputeByExpression() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); prepareNotifications(); // Preconditions @@ -369,7 +369,7 @@ public void test120RecomputeByExpression() throws Exception { public void test130RecomputeLight() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // Preconditions assertUsers(7); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestValidityRecomputeTask.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestValidityRecomputeTask.java index a178675fdad..bc2145bfb3d 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestValidityRecomputeTask.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestValidityRecomputeTask.java @@ -107,7 +107,7 @@ public void test100ImportValidityScannerTask() throws Exception { waitForValidityTaskFinish(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); assertLastScanTimestamp(TASK_VALIDITY_SCANNER_OID, startCal, endCal); @@ -202,7 +202,7 @@ private void testJackAssignRoleJudgeValid(final String TEST_NAME, ActivationType assignRole(USER_JACK_OID, ROLE_BIG_JUDGE_OID, activationType, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(null, USER_JACK_USERNAME); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME); @@ -211,7 +211,7 @@ private void testJackAssignRoleJudgeValid(final String TEST_NAME, ActivationType waitForValidityNextRunAssertSuccess(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(null, USER_JACK_USERNAME); PrismObject user = getUser(USER_JACK_OID); @@ -234,7 +234,7 @@ private void testJackAssignRoleJudgeInvalid(final String TEST_NAME, ActivationTy assignRole(USER_JACK_OID, ROLE_BIG_JUDGE_OID, activationType, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertNoDummyAccount(null, USER_JACK_USERNAME); // WHEN @@ -242,7 +242,7 @@ private void testJackAssignRoleJudgeInvalid(final String TEST_NAME, ActivationTy waitForValidityNextRunAssertSuccess(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertNoDummyAccount(null, USER_JACK_USERNAME); assertNoDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME); @@ -286,7 +286,7 @@ public void test120JackDisableAssignmentJudge() throws Exception { ActivationStatusType.DISABLED, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject user = getUser(USER_JACK_OID); display("User after", user); assertNoDummyAccount(null, USER_JACK_USERNAME); @@ -313,7 +313,7 @@ public void test122JackReplaceNullAdministrativeStatusAssignmentJudge() throws E null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject user = getUser(USER_JACK_OID); display("User after", user); assertDummyAccount(null, USER_JACK_USERNAME); @@ -337,7 +337,7 @@ public void test123JackDisableAssignmentJudge() throws Exception { ActivationStatusType.DISABLED, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject user = getUser(USER_JACK_OID); display("User after", user); assertNoDummyAccount(null, USER_JACK_USERNAME); @@ -361,7 +361,7 @@ public void test124JackEnableAssignmentJudge() throws Exception { ActivationStatusType.ENABLED, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject user = getUser(USER_JACK_OID); display("User after", user); assertDummyAccount(null, USER_JACK_USERNAME); @@ -387,7 +387,7 @@ public void test125JackDeleteAdministrativeStatusAssignmentJudge() throws Except task, result, ActivationStatusType.ENABLED); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject user = getUser(USER_JACK_OID); display("User after", user); assertDummyAccount(null, USER_JACK_USERNAME); @@ -413,7 +413,7 @@ public void test126JackAddAdministrativeStatusAssignmentJudge() throws Exception task, result, ActivationStatusType.ENABLED); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject user = getUser(USER_JACK_OID); display("User after", user); assertDummyAccount(null, USER_JACK_USERNAME); @@ -440,7 +440,7 @@ public void test127JackDeleteActivationAssignmentJudge() throws Exception { task, result, activationType); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject user = getUser(USER_JACK_OID); display("User after", user); assertDummyAccount(null, USER_JACK_USERNAME); @@ -469,7 +469,7 @@ public void test128JackAssignmentJudgeValidToSetInvalid() throws Exception { task, result, activationType); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject user = getUser(USER_JACK_OID); display("User after", user); assertNoDummyAccount(null, USER_JACK_USERNAME); @@ -496,7 +496,7 @@ public void test129JackAssignmentJudgeValidToSetValid() throws Exception { task, result, validTo); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject user = getUser(USER_JACK_OID); display("User after", user); assertDummyAccount(null, USER_JACK_USERNAME); @@ -538,7 +538,7 @@ public void test130BarbossaAssignJudgeEnabled() throws Exception { assignRole(USER_BARBOSSA_OID, ROLE_JUDGE_OID, activationType, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(null, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); // WHEN @@ -546,7 +546,7 @@ public void test130BarbossaAssignJudgeEnabled() throws Exception { waitForValidityNextRunAssertSuccess(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(null, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); assertDummyAccountAttribute(null, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, @@ -579,7 +579,7 @@ public void test131BarbossaAssignSailorEnabled() throws Exception { assignRole(USER_BARBOSSA_OID, ROLE_SAILOR_OID, activationType, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(null, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); // WHEN @@ -587,7 +587,7 @@ public void test131BarbossaAssignSailorEnabled() throws Exception { waitForValidityNextRunAssertSuccess(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(null, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); assertDummyAccountAttribute(null, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, @@ -620,7 +620,7 @@ public void test132BarbossaDisableAssignmentJudge() throws Exception { ActivationStatusType.DISABLED, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(null, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); // WHEN @@ -628,7 +628,7 @@ public void test132BarbossaDisableAssignmentJudge() throws Exception { waitForValidityNextRunAssertSuccess(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(null, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); assertNoDummyAccountAttribute(null, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME); @@ -660,7 +660,7 @@ public void test133BarbossaDisableAssignmentSailor() throws Exception { ActivationStatusType.DISABLED, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertNoDummyAccount(null, USER_BARBOSSA_USERNAME); // WHEN @@ -668,7 +668,7 @@ public void test133BarbossaDisableAssignmentSailor() throws Exception { waitForValidityNextRunAssertSuccess(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertNoDummyAccount(null, USER_BARBOSSA_USERNAME); PrismObject user = getUser(USER_BARBOSSA_OID); @@ -695,7 +695,7 @@ public void test134BarbossaEnableAssignmentJudge() throws Exception { ActivationStatusType.ENABLED, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(null, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); // WHEN @@ -732,7 +732,7 @@ public void test135BarbossaEnableAssignmentSailor() throws Exception { ActivationStatusType.ENABLED, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(null, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); // WHEN @@ -779,7 +779,7 @@ public void test136BarbossaDisableBothAssignments() throws Exception { modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertNoDummyAccount(null, USER_BARBOSSA_USERNAME); // WHEN @@ -787,7 +787,7 @@ public void test136BarbossaDisableBothAssignments() throws Exception { waitForValidityNextRunAssertSuccess(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertNoDummyAccount(null, USER_BARBOSSA_USERNAME); PrismObject user = getUser(USER_BARBOSSA_OID); @@ -830,7 +830,7 @@ public void test137BarbossaEnableBothAssignments() throws Exception { modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(null, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); // WHEN @@ -838,7 +838,7 @@ public void test137BarbossaEnableBothAssignments() throws Exception { waitForValidityNextRunAssertSuccess(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(null, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); assertDummyAccountAttribute(null, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, @@ -912,7 +912,7 @@ public void test139BarbossaDisableBothAssignmentsUnassign() throws Exception { modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertNoDummyAccount(null, USER_BARBOSSA_USERNAME); // WHEN @@ -920,7 +920,7 @@ public void test139BarbossaDisableBothAssignmentsUnassign() throws Exception { waitForValidityNextRunAssertSuccess(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertNoDummyAccount(null, USER_BARBOSSA_USERNAME); user = getUser(USER_BARBOSSA_OID); @@ -961,7 +961,7 @@ public void test140BarbossaAssignRedJudgeEnabled() throws Exception { assignRole(USER_BARBOSSA_OID, ROLE_RED_JUDGE_OID, activationType, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); // WHEN @@ -969,7 +969,7 @@ public void test140BarbossaAssignRedJudgeEnabled() throws Exception { waitForValidityNextRunAssertSuccess(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); assertDummyAccountAttribute(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, @@ -1002,7 +1002,7 @@ public void test141BarbossaAssignRedSailorEnabled() throws Exception { assignRole(USER_BARBOSSA_OID, ROLE_RED_SAILOR_OID, activationType, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); // WHEN @@ -1010,7 +1010,7 @@ public void test141BarbossaAssignRedSailorEnabled() throws Exception { waitForValidityNextRunAssertSuccess(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); assertDummyAccountAttribute(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, @@ -1043,7 +1043,7 @@ public void test142BarbossaDisableAssignmentRedJudge() throws Exception { ActivationStatusType.DISABLED, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); // WHEN @@ -1051,7 +1051,7 @@ public void test142BarbossaDisableAssignmentRedJudge() throws Exception { waitForValidityNextRunAssertSuccess(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); assertNoDummyAccountAttribute(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME); @@ -1083,7 +1083,7 @@ public void test143BarbossaDisableAssignmentRedSailor() throws Exception { ActivationStatusType.DISABLED, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, false); // WHEN @@ -1091,7 +1091,7 @@ public void test143BarbossaDisableAssignmentRedSailor() throws Exception { waitForValidityNextRunAssertSuccess(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, false); assertNoDummyAccountAttribute(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME); @@ -1122,7 +1122,7 @@ public void test144BarbossaEnableAssignmentRedJudge() throws Exception { ActivationStatusType.ENABLED, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); // WHEN @@ -1159,7 +1159,7 @@ public void test145BarbossaEnableAssignmentRedSailor() throws Exception { ActivationStatusType.ENABLED, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); // WHEN @@ -1212,7 +1212,7 @@ public void test146BarbossaDisableBothRedAssignments() throws Exception { modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, false); // WHEN @@ -1220,7 +1220,7 @@ public void test146BarbossaDisableBothRedAssignments() throws Exception { waitForValidityNextRunAssertSuccess(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, false); assertNoDummyAccountAttribute(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME); @@ -1267,7 +1267,7 @@ public void test147BarbossaEnableBothRedAssignments() throws Exception { modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); // WHEN @@ -1275,7 +1275,7 @@ public void test147BarbossaEnableBothRedAssignments() throws Exception { waitForValidityNextRunAssertSuccess(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); assertDummyAccountAttribute(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, @@ -1346,7 +1346,7 @@ public void test149BarbossaDisableBothRedAssignmentsUnassign() throws Exception modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, false); assertNoDummyAccount(null, USER_BARBOSSA_USERNAME); // to be on the safe side @@ -1355,7 +1355,7 @@ public void test149BarbossaDisableBothRedAssignmentsUnassign() throws Exception waitForValidityNextRunAssertSuccess(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, false); assertNoDummyAccountAttribute(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME); @@ -1398,7 +1398,7 @@ public void test190HermanGoesInvalid() throws Exception { waitForValidityNextRunAssertSuccess(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); // THEN XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -1429,7 +1429,7 @@ public void test200ImportTriggerScannerTask() throws Exception { waitForTaskFinish(TASK_TRIGGER_SCANNER_OID, true); // THEN - TestUtil.displayThen(TEST_NAME); + then(); XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); assertLastScanTimestamp(TASK_TRIGGER_SCANNER_OID, startCal, endCal); @@ -1541,7 +1541,7 @@ public void test215JackDummyAccountDeleteAfterMonth() throws Exception { waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertNoDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME); } @@ -1813,7 +1813,7 @@ public void test300HermanAssignJudgeNotYetValid() throws Exception { assignRole(USER_HERMAN_OID, ROLE_JUDGE_OID, activationType, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertNoDummyAccount(null, USER_HERMAN_USERNAME); } diff --git a/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java b/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java index c00a1c95917..5d81b70a551 100644 --- a/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java +++ b/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java @@ -45,6 +45,7 @@ import org.springframework.security.web.FilterInvocation; import org.testng.AssertJUnit; import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeMethod; import com.evolveum.icf.dummy.resource.*; import com.evolveum.midpoint.audit.api.AuditEventRecord; @@ -242,6 +243,11 @@ protected void cleanUpSecurity() { securityContext.setAuthentication(null); } + @BeforeMethod + protected void prepareBeforeTestMethod() { + dummyAuditService.clear(); + } + protected void initDummyResource(String name, DummyResourceContoller controller) { dummyResourceCollection.initDummyResource(name, controller); } @@ -1399,6 +1405,10 @@ protected AssignmentType createConstructionAssignment(String resourceOid, Shadow return assignmentType; } + protected AssignmentType createTargetAssignment(String targetOid, QName targetType) { + return FocusTypeUtil.createTargetAssignment(targetOid, targetType); + } + protected ObjectDelta createParametricAssignmentDelta( String userOid, String roleOid, String orgOid, String tenantOid, boolean adding) throws SchemaException { @@ -1805,14 +1815,6 @@ protected ShadowAsserter assertShadow(String username, PrismObject findShadowByNameViaModel(ShadowKindType kind, String intent, String name, - PrismObject resource, Task task, OperationResult result) - throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, - ConfigurationException, ExpressionEvaluationException { - return findShadowByNameViaModel(kind, intent, name, resource, schemaHelper.getOperationOptionsBuilder().noFetch().build(), - task, result); - } - protected PrismObject findShadowByNameViaModel(ShadowKindType kind, String intent, String name, PrismObject resource, Collection> options, Task task, OperationResult result) @@ -5598,34 +5600,6 @@ protected Consumer createShowTaskTreeConsumer(long period) { }; } - // highly experimental - public class TestCtx { - public final String name; - - public final Task task; - public final OperationResult result; - - TestCtx(Object testCase, String name) { - this.name = name; - TestUtil.displayTestTitle(testCase, name); - task = createPlainTask(name); - result = task.getResult(); - dummyAuditService.clear(); - } - - public void displayWhen() { - TestUtil.displayWhen(name); - } - - public void displayThen() { - TestUtil.displayThen(name); - } - } - - protected TestCtx createContext(Object testCase, String testName) { - return new TestCtx(testCase, testName); - } - protected T runPrivileged(Producer producer) { return securityContextManager.runPrivileged(producer); } diff --git a/model/notifications-impl/src/test/java/com/evolveum/midpoint/notifications/impl/TestTransportUtils.java b/model/notifications-impl/src/test/java/com/evolveum/midpoint/notifications/impl/TestTransportUtils.java index 3b26e115c42..a88ec58e19d 100644 --- a/model/notifications-impl/src/test/java/com/evolveum/midpoint/notifications/impl/TestTransportUtils.java +++ b/model/notifications-impl/src/test/java/com/evolveum/midpoint/notifications/impl/TestTransportUtils.java @@ -15,7 +15,6 @@ import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.task.api.TaskManager; import com.evolveum.midpoint.test.util.AbstractSpringTest; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.util.logging.Trace; @@ -68,8 +67,6 @@ public void setup() throws SchemaException, SAXException, IOException { public void test010CheckVariablesWhiteList() { final String TEST_NAME = "test010CheckVariablesWhiteList"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN NotificationTransportConfigurationType config = new NotificationTransportConfigurationType(); @@ -94,7 +91,7 @@ public void test010CheckVariablesWhiteList() { TransportUtil.validateRecipient(allowRecipient, forbiddenRecipient, recipients, config, task, task.getResult(), expressionFactory, MiscSchemaUtil.getExpressionProfile(), LOGGER); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertTrue("Expected <4> allowed recipient(s), but was <" +allowRecipient.size()+ ">", allowRecipient.size() == 4); assertTrue("janko@evodevel.com shoud be allowed, but isn't.", allowRecipient.contains("janko@evodevel.com")); @@ -111,8 +108,6 @@ public void test010CheckVariablesWhiteList() { public void test020CheckVariablesBlackList() { final String TEST_NAME = "test020CheckVariablesBlackList"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN NotificationTransportConfigurationType config = new NotificationTransportConfigurationType(); @@ -137,7 +132,7 @@ public void test020CheckVariablesBlackList() { TransportUtil.validateRecipient(allowRecipient, forbiddenRecipient, recipients, config, task, task.getResult(), expressionFactory, MiscSchemaUtil.getExpressionProfile(), LOGGER); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertTrue("Expected <4> forbidden recipient(s), but was <" +forbiddenRecipient.size()+ ">", forbiddenRecipient.size() == 4); assertTrue("janko@evodevel.com shoud be forbidden, but isn't.", forbiddenRecipient.contains("janko@evodevel.com")); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/AbstractTestAssignmentApproval.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/AbstractTestAssignmentApproval.java index bd3e28e5da6..4a4e43a605d 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/AbstractTestAssignmentApproval.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/AbstractTestAssignmentApproval.java @@ -155,7 +155,7 @@ public void test020DeleteRole1Assignment() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); LensContext context = createUserLensContext(); fillContextWithUser(context, userJackOid, result); @@ -180,7 +180,7 @@ public void test020DeleteRole1Assignment() throws Exception { public void test030AddRole1AssignmentAgain() throws Exception { login(userAdministrator); - importLead10(getTestTask(), getResult()); + importLead10(getTestTask(), getTestResult()); executeAssignRole1ToJack(false, false, null, null, false); } @@ -271,7 +271,7 @@ public void test100AddCreateDelegation() throws Exception { Task task = getTestTask(); task.setOwner(userAdministrator); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN assignDeputy(userJackDeputyOid, userJackOid, a -> { @@ -295,7 +295,7 @@ public void test130AddRole1aAssignmentWithDeputy() throws Exception { login(userAdministrator); Task task = getTestTask(); - importLead1Deputies(task, getResult()); + importLead1Deputies(task, getTestResult()); unassignAllRoles(userJackOid); executeAssignRole1ToJack(false, true, null, null, false); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentApprovalGlobal.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentApprovalGlobal.java index 81fbc9006e4..878a7c77c25 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentApprovalGlobal.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentApprovalGlobal.java @@ -64,7 +64,7 @@ public void test300ApprovalAndEnforce() throws Exception { login(userAdministrator); Task task = getTestTask(); task.setOwner(userAdministrator); - OperationResult result = getResult(); + OperationResult result = getTestResult(); try { assignRole(userJackOid, roleRole15Oid, task, result); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentsAdvanced.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentsAdvanced.java index 85c0c1d0d9a..6192a06a323 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentsAdvanced.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentsAdvanced.java @@ -279,7 +279,7 @@ public void test230DeleteRoles123AssignmentYById() throws Exception { public void test300ApprovalAndEnforce() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); try { assignRole(userJackOid, roleRole24Oid, task, result); @@ -327,7 +327,7 @@ public void test420AddRoles123AssignmentPreviewImmediate() throws Exception { public void test500NoApprovers() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assignRole(userJackOid, roleRole26Oid, task, result); String ref = result.findAsynchronousOperationReference(); // TODO use recompute + getAsync... when fixed @@ -353,7 +353,7 @@ public void test500NoApprovers() throws Exception { public void test600AssignRole29() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN when(); @@ -593,7 +593,7 @@ protected void afterFirstClockworkRun(CaseType rootCase, List subcases public void test630UnassignRole29() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN when(); @@ -935,7 +935,7 @@ protected void afterFirstClockworkRun(CaseType rootCase, List subcases public void test800AssignRole27() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN when(); @@ -957,7 +957,7 @@ public void test800AssignRole27() throws Exception { public void test810ModifyAssignmentOfRole27() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN when(); @@ -982,7 +982,7 @@ public void test810ModifyAssignmentOfRole27() throws Exception { public void test820UnassignRole27() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN when(); @@ -999,7 +999,7 @@ public void test820UnassignRole27() throws Exception { public void test900AssignIdempotentRole() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN when(); @@ -1039,7 +1039,7 @@ public void test900AssignIdempotentRole() throws Exception { public void test910AssignRoleWithIdempotentMetarole() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN when(); @@ -1219,7 +1219,7 @@ public List getApprovalSequence() { private void previewAssignRolesToJack(boolean immediate, boolean also24) throws Exception { String testName = getTestNameShort(); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); boolean TRACE = false; //noinspection ConstantConditions if (TRACE) { diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/association/TestAddAssociation.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/association/TestAddAssociation.java index 55f67f2bce0..78c40b15193 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/association/TestAddAssociation.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/association/TestAddAssociation.java @@ -25,7 +25,6 @@ import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.task.api.TaskManager; import com.evolveum.midpoint.test.IntegrationTestTools; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DebugUtil; import com.evolveum.midpoint.util.MiscUtil; import com.evolveum.midpoint.util.QNameUtil; @@ -144,7 +143,6 @@ protected File getSystemConfigurationFile() { */ @Test public void test010AddJackToTesters() throws Exception { - TestUtil.displayTestTitle(this, "test010AddJackToTesters"); executeTest("test010AddJackToTesters", USER_JACK_OID, new TestDetails() { @Override int subcasesCount() { @@ -225,7 +223,6 @@ boolean decideOnApproval(CaseType subcase, */ @Test public void test020AddElisabethToTestersRejected() throws Exception { - TestUtil.displayTestTitle(this, "test020AddElisabethToTestersRejected"); executeTest("test020AddElisabethToTestersRejected", USER_ELISABETH_OID, new TestDetails() { @Override int subcasesCount() { @@ -307,10 +304,9 @@ boolean decideOnApproval(CaseType subcase, @Test public void test100AddJackToGuests() throws Exception { final String TEST_NAME = "test100AddJackToGuests"; - TestUtil.displayTestTitle(this, TEST_NAME); Task modelTask = taskManager.createTaskInstance(TEST_NAME); - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); modelTask.setOwner(repositoryService.getObject(UserType.class, USER_ADMINISTRATOR_OID, null, result)); LensContext context = createUserLensContext(); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/AbstractTestObjectLifecycleApproval.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/AbstractTestObjectLifecycleApproval.java index fa21ff7c6a1..3562630c56f 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/AbstractTestObjectLifecycleApproval.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/AbstractTestObjectLifecycleApproval.java @@ -94,7 +94,7 @@ public void test010CreateRolePirate() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); RoleType pirate = new RoleType(prismContext); pirate.setName(PolyStringType.fromOrig("pirate")); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/TestObjectLifecycleAdvanced.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/TestObjectLifecycleAdvanced.java index 565677d3067..f1d95e13ee2 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/TestObjectLifecycleAdvanced.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/TestObjectLifecycleAdvanced.java @@ -87,7 +87,7 @@ public void test010CreateRoleEmployee() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject employee = prismContext.parseObject(ROLE_EMPLOYEE_FILE); executeTest(null, new TestDetails() { @@ -169,7 +169,7 @@ public void test020ActivateIncompleteRole() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); @SuppressWarnings({ "raw"}) ObjectDelta activateRoleDelta = prismContext.deltaFor(RoleType.class) @@ -203,7 +203,7 @@ public void test030ActivateIncompleteRoleAgain() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); @SuppressWarnings({ "raw"}) ObjectDelta activateRoleDelta = prismContext.deltaFor(RoleType.class) @@ -235,7 +235,7 @@ public void test040AddApprover() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assignRole(userEmployeeOwnerOid, roleEmployeeOid, SchemaConstants.ORG_APPROVER, task, result); result.computeStatus(); @@ -248,7 +248,7 @@ public void test045ActivateCompleteRole() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); @SuppressWarnings({ "raw"}) ObjectDelta activateRoleDelta = prismContext.deltaFor(RoleType.class) diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/TestObjectLifecycleApprovalGlobal.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/TestObjectLifecycleApprovalGlobal.java index 3f8163b3557..3d850e2f130 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/TestObjectLifecycleApprovalGlobal.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/TestObjectLifecycleApprovalGlobal.java @@ -75,7 +75,7 @@ public void test500CreateRoleJudge() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); RoleType judge = new RoleType(prismContext) .name("judge") diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/ManualResourceTest.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/ManualResourceTest.java index 4c6996006ca..2178349ac0f 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/ManualResourceTest.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/ManualResourceTest.java @@ -126,7 +126,7 @@ private PrismObject createUserWill() throws SchemaException { @Test public void test000Sanity() throws Exception { - OperationResult result = getResult(); + OperationResult result = getTestResult(); ResourceType repoResource = repositoryService.getObject(ResourceType.class, RESOURCE_MANUAL_OID, null, result).asObjectable(); @@ -167,7 +167,7 @@ public void test012TestConnection() throws Exception { public void test100AssignWillRoleOne() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); dummyTransport.clearMessages(); @@ -198,7 +198,7 @@ public void test100AssignWillRoleOne() throws Exception { public void test110CloseCaseAndRecomputeWill() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); dummyTransport.clearMessages(); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestDelegation.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestDelegation.java index ed9181d2ab0..87455061b2a 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestDelegation.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestDelegation.java @@ -76,7 +76,7 @@ public void test100CreateTask() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assignRole(userJackOid, ROLE_PRINCE_OID, task, result); // should start approval process assertNotAssignedRole(userJackOid, ROLE_PRINCE_OID, task, result); @@ -96,7 +96,7 @@ public void test110DelegateToGirthUnauthorized() throws Exception { login(getUserFromRepo(USER_KEEN_OID)); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); try { WorkItemDelegationRequestType request = new WorkItemDelegationRequestType(prismContext) @@ -117,7 +117,7 @@ public void test120DelegateToGirth() throws Exception { login(getUserFromRepo(USER_LONGSHANKS_OID)); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); WorkItemDelegationRequestType request = new WorkItemDelegationRequestType(prismContext) .delegate(ort(USER_GIRTH_OID)) @@ -149,7 +149,7 @@ public void test130DelegateToKeenByReplace() throws Exception { login(getUserFromRepo(USER_LONGSHANKS_OID)); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); WorkItemDelegationRequestType request = new WorkItemDelegationRequestType(prismContext) .delegate(ort(USER_KEEN_OID)) @@ -178,7 +178,7 @@ public void test140DelegateToNoneByReplace() throws Exception { login(getUserFromRepo(USER_KEEN_OID)); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); WorkItemDelegationRequestType request = new WorkItemDelegationRequestType(prismContext) .method(REPLACE_ASSIGNEES); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestEscalation.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestEscalation.java index ff1b8c6eab6..c61c6b2aa22 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestEscalation.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestEscalation.java @@ -90,7 +90,7 @@ public void test100CreateE1ApprovalCase() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assignRole(userJackOid, ROLE_E1_OID, task, result); // should start approval process assertNotAssignedRole(userJackOid, ROLE_E1_OID, task, result); @@ -118,7 +118,7 @@ public void test110NotifyAfter5Days() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); clock.overrideDuration("P5DT1H"); // at P5D there's a notify action waitForTaskNextRun(TASK_TRIGGER_SCANNER_OID, true, 20000, true); @@ -140,7 +140,7 @@ public void test120EscalateAfter12Days() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); clock.resetOverride(); clock.overrideDuration("P12DT1H"); // at -P2D (i.e. P12D) there is a delegate action @@ -162,7 +162,7 @@ public void test130CompleteAfter14Days() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); clock.resetOverride(); clock.overrideDuration("P14DT1H"); // at 0 (i.e. P14D) there is a delegate action @@ -184,7 +184,7 @@ public void test200CreateE2ApprovalCase() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); clock.resetOverride(); resetTriggerTask(TASK_TRIGGER_SCANNER_OID, TASK_TRIGGER_SCANNER_FILE, result); @@ -213,7 +213,7 @@ public void test210EscalateAfter3Days() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); dummyTransport.clearMessages(); @@ -246,7 +246,7 @@ public void test220Reject() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); dummyAuditService.clear(); dummyTransport.clearMessages(); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestEvents.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestEvents.java index 9e658bfa1a0..20d0089e4f4 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestEvents.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestEvents.java @@ -58,7 +58,7 @@ public void test100CreateTask() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assignRole(userJackOid, roleNoApproversOid, task, result); // should start approval process assertNotAssignedRole(userJackOid, roleNoApproversOid, task, result); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestMiscellaneous.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestMiscellaneous.java index be9289c51c6..b88911f0019 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestMiscellaneous.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestMiscellaneous.java @@ -103,7 +103,7 @@ public void test100RequesterComment() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // GIVEN @@ -168,7 +168,7 @@ public void test105RequesterCommentImmediate() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // GIVEN @@ -235,7 +235,7 @@ public void test110RequestPrunedRole() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // GIVEN @@ -273,7 +273,7 @@ public void test200GetRoleByTemplate() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // GIVEN setDefaultUserTemplate(TEMPLATE_ASSIGNING_CAPTAIN_OID); @@ -296,7 +296,7 @@ public void test210GetRoleByTemplateAfterAssignments() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // GIVEN setDefaultUserTemplate(TEMPLATE_ASSIGNING_CAPTAIN_AFTER_OID); @@ -320,7 +320,7 @@ public void test220GetRoleByFocusMappings() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // GIVEN setDefaultUserTemplate(null); @@ -342,7 +342,7 @@ public void test250SkippingApprovals() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // GIVEN setDefaultUserTemplate(null); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestParallelApprovals.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestParallelApprovals.java index 6f4dd217e22..2cd88368d46 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestParallelApprovals.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestParallelApprovals.java @@ -118,7 +118,7 @@ public void test100ParallelApprovals() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN when(); @@ -166,7 +166,7 @@ public void test110ParallelApprovalsAdd() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); if (listener != null) { taskManager.unregisterTaskListener(listener); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestSoD.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestSoD.java index 38630542a94..c1e72112817 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestSoD.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestSoD.java @@ -81,7 +81,7 @@ public void test010AssignRoleJudge() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN assignRole(userJackOid, roleJudgeOid, task, result); @@ -99,7 +99,7 @@ public void test020AssignRolePirate() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); PrismObject jack = getUser(userJackOid); String originalDescription = jack.asObjectable().getDescription(); @@ -213,7 +213,7 @@ public void test030AssignRoleRespectable() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // GIVEN unassignRole(userJackOid, rolePirateOid, task, result); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorDiscovery.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorDiscovery.java index 9324c59a487..2ca3777235c 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorDiscovery.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorDiscovery.java @@ -6,9 +6,7 @@ */ package com.evolveum.midpoint.provisioning.impl; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; +import static org.testng.AssertJUnit.*; import java.util.List; @@ -25,10 +23,7 @@ import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.IntegrationTestTools; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType; /** @@ -42,18 +37,13 @@ public class TestConnectorDiscovery extends AbstractIntegrationTest { @Autowired private ProvisioningService provisioningService; - private static final Trace LOGGER = TraceManager.getTrace(TestConnectorDiscovery.class); - @Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { provisioningService.postInit(initResult); } - /** * Check whether the connectors were discovered correctly and were added to the repository. - * @throws SchemaException - * */ @Test public void test001Connectors() throws Exception { @@ -67,14 +57,14 @@ public void test001Connectors() throws Exception { // THEN then(TEST_NAME); - assertFalse("No connector found",connectors.isEmpty()); - display("Found "+connectors.size()+" discovered connector"); + assertFalse("No connector found", connectors.isEmpty()); + display("Found " + connectors.size() + " discovered connector"); assertSuccess(result); for (PrismObject connector : connectors) { ConnectorType conn = connector.asObjectable(); - display("Found connector " +conn, conn); + display("Found connector " + conn, conn); IntegrationTestTools.assertConnectorSchemaSanity(conn, prismContext); } @@ -82,19 +72,17 @@ public void test001Connectors() throws Exception { } @Test - public void testListConnectors() throws Exception{ - TestUtil.displayTestTitle("testListConnectors"); - OperationResult result = new OperationResult(TestConnectorDiscovery.class.getName() - + ".listConnectorsTest"); + public void testListConnectors() throws Exception { + OperationResult result = createResult(); List> connectors = provisioningService.searchObjects(ConnectorType.class, null, null, null, result); assertNotNull(connectors); - for (PrismObject connector : connectors){ + for (PrismObject connector : connectors) { ConnectorType conn = connector.asObjectable(); System.out.println(conn.toString()); - System.out.println("connector name: "+ conn.getName()); - System.out.println("connector type: "+ conn.getConnectorType()); + System.out.println("connector name: " + conn.getName()); + System.out.println("connector type: " + conn.getConnectorType()); System.out.println("-----\n"); } @@ -102,7 +90,7 @@ public void testListConnectors() throws Exception{ } @Test - public void testSearchConnectorSimple() throws SchemaException{ + public void testSearchConnectorSimple() throws SchemaException { final String TEST_NAME = "testSearchConnectorSimple"; OperationResult result = new OperationResult(TestConnectorDiscovery.class.getName() + "." + TEST_NAME); @@ -111,19 +99,16 @@ public void testSearchConnectorSimple() throws SchemaException{ assertEquals("Type does not match", IntegrationTestTools.LDAP_CONNECTOR_TYPE, ldapConnector.asObjectable().getConnectorType()); } - @Test - public void testSearchConnectorAnd() throws SchemaException{ - TestUtil.displayTestTitle("testSearchConnectorAnd"); - OperationResult result = new OperationResult(TestConnectorDiscovery.class.getName() - + ".testSearchConnector"); + public void testSearchConnectorAnd() throws SchemaException { + OperationResult result = createResult(); ObjectQuery query = prismContext.queryFor(ConnectorType.class) .item(SchemaConstants.C_CONNECTOR_FRAMEWORK).eq(SchemaConstants.ICF_FRAMEWORK_URI) .and().item(SchemaConstants.C_CONNECTOR_CONNECTOR_TYPE).eq(IntegrationTestTools.LDAP_CONNECTOR_TYPE) .build(); - System.out.println("Query:\n"+query.debugDump()); + System.out.println("Query:\n" + query.debugDump()); List> connectors = repositoryService.searchObjects(ConnectorType.class, query, null, result); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestDBTable.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestDBTable.java index 10f98d45516..0d1d386b9c8 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestDBTable.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestDBTable.java @@ -71,17 +71,6 @@ public class TestDBTable extends AbstractIntegrationTest { @Autowired private ProvisioningService provisioningService; -// @Autowired -// private TaskManager taskManager; - - @Autowired - private SynchronizationServiceMock syncServiceMock; - - - /* (non-Javadoc) - * @see com.evolveum.midpoint.test.AbstractIntegrationTest#initSystem() - */ - @Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { // We need to switch off the encryption checks. Some values cannot be encrypted as we do @@ -110,9 +99,7 @@ public static void stopDb() throws Exception { @Test public void test000Integrity() throws ObjectNotFoundException, SchemaException { - TestUtil.displayTestTitle("test000Integrity"); - - OperationResult result = new OperationResult(TestDBTable.class.getName()+".test000Integrity"); + OperationResult result = createResult(); ResourceType resource = repositoryService.getObject(ResourceType.class, RESOURCE_DERBY_OID, null, result).asObjectable(); String connectorOid = resource.getConnectorRef().getOid(); @@ -123,8 +110,6 @@ public void test000Integrity() throws ObjectNotFoundException, SchemaException { @Test public void test001Connection() throws Exception { - final String TEST_NAME = "test001Connection"; - TestUtil.displayTestTitle(TEST_NAME); Task task = getTestTask(); OperationResult result = task.getResult(); @@ -148,11 +133,8 @@ public void test001Connection() throws Exception { @Test public void test002AddAccount() throws Exception { - final String TEST_NAME = "test002AddAccount"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - OperationResult result = new OperationResult(TestDBTable.class.getName() - + "." + TEST_NAME); + OperationResult result = createResult(); ShadowType account = parseObjectType(ACCOUNT_WILL_FILE, ShadowType.class); @@ -175,7 +157,6 @@ public void test002AddAccount() throws Exception { ShadowType provisioningAccountType = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result).asObjectable(); PrismAsserts.assertEqualsPolyString("Name not equal.", ACCOUNT_WILL_USERNAME, provisioningAccountType.getName()); -// assertEquals("will", provisioningAccountType.getName()); // Check database content @@ -198,11 +179,8 @@ public void test002AddAccount() throws Exception { // MID-1234 @Test(enabled=false) public void test005GetAccount() throws Exception { - final String TEST_NAME = "test005GetAccount"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - OperationResult result = new OperationResult(TestDBTable.class.getName() - + "." + TEST_NAME); + OperationResult result = createResult(); Task task = taskManager.createTaskInstance(); // WHEN diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/async/TestAsyncUpdate.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/async/TestAsyncUpdate.java index 1adb255a8d0..6826f485cf6 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/async/TestAsyncUpdate.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/async/TestAsyncUpdate.java @@ -118,7 +118,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { - OperationResult result = getResult(); + OperationResult result = getTestResult(); assertNotNull("Resource is null", resource); ResourceType repoResource = repositoryService.getObject(ResourceType.class, RESOURCE_ASYNC_OID, null, result).asObjectable(); @@ -137,7 +137,7 @@ public void test000Sanity() throws Exception { @Test public void test003Connection() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // Check that there is a schema, but no capabilities before test (pre-condition) ResourceType resourceBefore = repositoryService.getObject(ResourceType.class, RESOURCE_ASYNC_OID, @@ -183,7 +183,7 @@ public void test003Connection() throws Exception { @Test public void test004Configuration() throws Exception { - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN resource = provisioningService.getObject(ResourceType.class, RESOURCE_ASYNC_OID, null, null, result); @@ -224,7 +224,7 @@ public void test005ParsedSchema() throws Exception { @Test public void test100ListeningForShadowAdd() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // GIVEN @@ -256,7 +256,7 @@ public void test100ListeningForShadowAdd() throws Exception { @Test public void test110ListeningForValueAdd() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); prepareMessage(CHANGE_110); @@ -294,7 +294,7 @@ public void test110ListeningForValueAdd() throws Exception { @Test public void test112ListeningForValueAddMore() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); prepareMessage(CHANGE_112); @@ -332,7 +332,7 @@ public void test112ListeningForValueAddMore() throws Exception { @Test // MID-5832 public void test115ListeningForValueDelete() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); prepareMessage(CHANGE_115); @@ -370,7 +370,7 @@ public void test115ListeningForValueDelete() throws Exception { @Test // MID-5832 public void test117ListeningForValueReplace() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); prepareMessage(CHANGE_117); @@ -408,7 +408,7 @@ public void test117ListeningForValueReplace() throws Exception { @Test public void test120ListeningForShadowReplace() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); prepareMessage(CHANGE_120); @@ -435,7 +435,7 @@ public void test120ListeningForShadowReplace() throws Exception { @Test public void test125ListeningForNotificationOnly() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); if (!hasReadCapability()) { System.out.println("Skipping this test because there's no real read capability"); @@ -469,7 +469,7 @@ public void test125ListeningForNotificationOnly() throws Exception { @Test public void test130ListeningForShadowDelete() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); prepareMessage(CHANGE_130); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/AbstractCsvTest.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/AbstractCsvTest.java index a7772c97b4f..59fe76b1756 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/AbstractCsvTest.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/AbstractCsvTest.java @@ -6,16 +6,11 @@ */ package com.evolveum.midpoint.provisioning.impl.csv; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.*; import java.io.File; import java.util.Collections; import java.util.List; - import javax.xml.namespace.QName; import org.apache.commons.io.FileUtils; @@ -27,16 +22,11 @@ import org.w3c.dom.Element; import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl; -import com.evolveum.midpoint.prism.Containerable; -import com.evolveum.midpoint.prism.PrismContainer; -import com.evolveum.midpoint.prism.PrismContainerDefinition; -import com.evolveum.midpoint.prism.PrismContext; -import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.delta.PropertyDelta; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.provisioning.impl.AbstractProvisioningIntegrationTest; -import com.evolveum.midpoint.provisioning.impl.opendj.TestOpenDj; import com.evolveum.midpoint.schema.CapabilityUtil; import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.constants.SchemaConstants; @@ -50,16 +40,7 @@ import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.CachingMetadataType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ProvisioningScriptHostType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.XmlSchemaType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType; import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ScriptCapabilityType; import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ScriptCapabilityType.Host; @@ -68,7 +49,6 @@ * The test of Provisioning service on the API level. The test is using CSV resource. * * @author Radovan Semancik - * */ @ContextConfiguration(locations = "classpath:ctx-provisioning-test-main.xml") @DirtiesContext @@ -87,8 +67,6 @@ public abstract class AbstractCsvTest extends AbstractProvisioningIntegrationTes protected static final String ACCOUNT_JACK_FIRSTNAME = "Jack"; protected static final String ACCOUNT_JACK_LASTNAME = "Sparrow"; - private static final Trace LOGGER = TraceManager.getTrace(AbstractCsvTest.class); - protected static final String ATTR_FIRSTNAME = "firstname"; protected static final QName ATTR_FIRSTNAME_QNAME = new QName(RESOURCE_NS, ATTR_FIRSTNAME); @@ -120,14 +98,10 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Integrity() throws Exception { - final String TEST_NAME = "test000Integrity"; - TestUtil.displayTestTitle(TEST_NAME); - assertNotNull("Resource is null", resource); assertNotNull("ResourceType is null", resourceType); - OperationResult result = new OperationResult(AbstractCsvTest.class.getName() - + "." + TEST_NAME); + OperationResult result = createResult(); ResourceType resource = repositoryService.getObject(ResourceType.class, getResourceOid(), null, result).asObjectable(); @@ -143,15 +117,13 @@ public void test000Integrity() throws Exception { /** * This should be the very first test that works with the resource. - * + *

* The original repository object does not have resource schema. The schema * should be generated from the resource on the first use. This is the test * that executes testResource and checks whether the schema was generated. */ @Test public void test003Connection() throws Exception { - final String TEST_NAME = "test003Connection"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -200,8 +172,6 @@ public void test003Connection() throws Exception { @Test public void test004Configuration() throws Exception { - final String TEST_NAME = "test004Configuration"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -215,7 +185,7 @@ public void test004Configuration() throws Exception { PrismContainerDefinition confContDef = configurationContainer.getDefinition(); assertNotNull("No configuration container definition", confContDef); PrismContainer confingurationPropertiesContainer = - configurationContainer.findContainer(SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME); + configurationContainer.findContainer(SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME); assertNotNull("No configuration properties container", confingurationPropertiesContainer); PrismContainerDefinition confPropDef = confingurationPropertiesContainer.getDefinition(); assertNotNull("No configuration properties container definition", confPropDef); @@ -224,9 +194,6 @@ public void test004Configuration() throws Exception { @Test public void test005ParsedSchema() throws Exception { - final String TEST_NAME = "test005ParsedSchema"; - TestUtil.displayTestTitle(TEST_NAME); - // THEN // The returned type should have the schema pre-parsed assertNotNull(RefinedResourceSchemaImpl.hasParsedSchema(resourceType)); @@ -263,11 +230,8 @@ public void test005ParsedSchema() throws Exception { @Test public void test006Capabilities() throws Exception { - final String TEST_NAME = "test006Capabilities"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestOpenDj.class.getName()+"."+TEST_NAME); + OperationResult result = createResult(); // WHEN ResourceType resource = provisioningService.getObject(ResourceType.class, getResourceOid(), null, null, result).asObjectable(); @@ -278,11 +242,11 @@ public void test006Capabilities() throws Exception { CapabilityCollectionType nativeCapabilities = resource.getCapabilities().getNative(); List nativeCapabilitiesList = nativeCapabilities.getAny(); - assertFalse("Empty capabilities returned",nativeCapabilitiesList.isEmpty()); + assertFalse("Empty capabilities returned", nativeCapabilitiesList.isEmpty()); // Connector cannot do activation, this should be null ActivationCapabilityType capAct = CapabilityUtil.getCapability(nativeCapabilitiesList, ActivationCapabilityType.class); - assertNull("Found activation capability while not expecting it" ,capAct); + assertNull("Found activation capability while not expecting it", capAct); ScriptCapabilityType capScript = CapabilityUtil.getCapability(nativeCapabilitiesList, ScriptCapabilityType.class); assertNotNull("No script capability", capScript); @@ -293,25 +257,22 @@ public void test006Capabilities() throws Exception { List effectiveCapabilities = ResourceTypeUtil.getEffectiveCapabilities(resource); for (Object capability : effectiveCapabilities) { - System.out.println("Capability: "+CapabilityUtil.getCapabilityDisplayName(capability)+" : "+capability); + System.out.println("Capability: " + CapabilityUtil.getCapabilityDisplayName(capability) + " : " + capability); } } private void assertScriptHost(ScriptCapabilityType capScript, ProvisioningScriptHostType expectedHostType) { - for (Host host: capScript.getHost()) { + for (Host host : capScript.getHost()) { if (host.getType() == expectedHostType) { return; } } - AssertJUnit.fail("No script capability with host type "+expectedHostType); + AssertJUnit.fail("No script capability with host type " + expectedHostType); } @Test public void test100AddAccountJack() throws Exception { - final String TEST_NAME = "test100AddAccountJack"; - TestUtil.displayTestTitle(TEST_NAME); - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -322,15 +283,12 @@ public void test100AddAccountJack() throws Exception { provisioningService.addObject(shadowBefore, null, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertSuccess(result); } @Test public void test110GetAccountJack() throws Exception { - final String TEST_NAME = "test110GetAccountJack"; - TestUtil.displayTestTitle(TEST_NAME); - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -339,7 +297,7 @@ public void test110GetAccountJack() throws Exception { PrismObject shadow = provisioningService.getObject(ShadowType.class, getAccountJackOid(), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertSuccess(result); assertNotNull(shadow); @@ -366,9 +324,6 @@ public void test110GetAccountJack() throws Exception { @Test public void test120ModifyShadowPrimaryIdentifier() throws Exception { - final String TEST_NAME = "test120ModifyShadowPrimaryIdentifier"; - TestUtil.displayTestTitle(TEST_NAME); - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -386,7 +341,7 @@ public void test120ModifyShadowPrimaryIdentifier() throws Exception { null, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject repoShadow = repositoryService.getObject(ShadowType.class, shadowBefore.getOid(), null, result); ShadowType repoShadowType = repoShadow.asObjectable(); @@ -396,7 +351,4 @@ public void test120ModifyShadowPrimaryIdentifier() throws Exception { protected abstract void assertAccountJackAttributes(ShadowType shadowType); protected abstract void assertAccountJackAttributesRepo(ShadowType shadowType); - - protected abstract QName getQNameOfUID(); - } diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/TestCsvGuid.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/TestCsvGuid.java index d297382c807..9e634b4970e 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/TestCsvGuid.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/TestCsvGuid.java @@ -115,8 +115,4 @@ protected void assertAccountJackAttributesRepo(ShadowType repoShadowType) { assertEquals("Wrong uname (repo)", ACCOUNT_JACK_UNAME, getAttributeValue(repoShadowType, ATTR_UNAME_QNAME)); } - @Override - protected QName getQNameOfUID() { - return ATTR_GUID_QNAME; - } } diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/TestCsvUsername.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/TestCsvUsername.java index 594a44cbd82..4238e4ed075 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/TestCsvUsername.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/TestCsvUsername.java @@ -98,8 +98,4 @@ protected void assertAccountJackAttributesRepo(ShadowType repoShadowType) { assertEquals("Wrong identifier (repo)", ACCOUNT_JACK_USERNAME, getAttributeValue(repoShadowType, ATTR_USERNAME_QNAME)); } - @Override - protected QName getQNameOfUID() { - return ATTR_USERNAME_QNAME; - } } 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 5385cba9f16..6cc0bd94034 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 @@ -1060,7 +1060,6 @@ public void test043ApplyDefinitionAddResourceDelta() throws Exception { @Test public void test050SelfTest() throws Exception { final String TEST_NAME = "test050SelfTest"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = getTestTask(); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummy.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummy.java index 7d1d8349f26..4e0eadd4da7 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummy.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummy.java @@ -6,31 +6,18 @@ */ package com.evolveum.midpoint.provisioning.impl.dummy; +import static org.testng.AssertJUnit.*; + import static com.evolveum.midpoint.test.DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME; import static com.evolveum.midpoint.test.DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertTrue; import java.io.FileNotFoundException; import java.net.ConnectException; import java.time.ZonedDateTime; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Date; -import java.util.List; -import java.util.Set; - +import java.util.*; import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.*; -import com.evolveum.midpoint.prism.delta.*; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.prism.query.*; import org.apache.commons.lang.ArrayUtils; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; @@ -38,15 +25,12 @@ import org.testng.annotations.Listeners; import org.testng.annotations.Test; -import com.evolveum.icf.dummy.resource.ConflictException; -import com.evolveum.icf.dummy.resource.DummyAccount; -import com.evolveum.icf.dummy.resource.DummyDelta; -import com.evolveum.icf.dummy.resource.DummyDeltaType; -import com.evolveum.icf.dummy.resource.DummyGroup; -import com.evolveum.icf.dummy.resource.DummyPrivilege; -import com.evolveum.icf.dummy.resource.DummySyncStyle; -import com.evolveum.icf.dummy.resource.SchemaViolationException; +import com.evolveum.icf.dummy.resource.*; import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl; +import com.evolveum.midpoint.prism.*; +import com.evolveum.midpoint.prism.delta.*; +import com.evolveum.midpoint.prism.path.ItemPath; +import com.evolveum.midpoint.prism.query.*; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.prism.xml.XmlTypeConverter; @@ -54,47 +38,25 @@ import com.evolveum.midpoint.provisioning.api.ProvisioningOperationOptions; import com.evolveum.midpoint.provisioning.api.ResourceObjectShadowChangeDescription; import com.evolveum.midpoint.provisioning.impl.ProvisioningTestUtil; -import com.evolveum.midpoint.schema.GetOperationOptions; -import com.evolveum.midpoint.schema.ResourceShadowDiscriminator; -import com.evolveum.midpoint.schema.ResultHandler; -import com.evolveum.midpoint.schema.SearchResultList; -import com.evolveum.midpoint.schema.SearchResultMetadata; -import com.evolveum.midpoint.schema.SelectorOptions; +import com.evolveum.midpoint.schema.*; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.internals.InternalCounters; -import com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition; -import com.evolveum.midpoint.schema.processor.ResourceAttribute; -import com.evolveum.midpoint.schema.processor.ResourceAttributeContainer; -import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition; -import com.evolveum.midpoint.schema.processor.ResourceSchema; +import com.evolveum.midpoint.schema.processor.*; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.ObjectQueryUtil; import com.evolveum.midpoint.schema.util.ResourceTypeUtil; import com.evolveum.midpoint.schema.util.SchemaTestConstants; import com.evolveum.midpoint.schema.util.ShadowUtil; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.*; +import com.evolveum.midpoint.test.DummyResourceContoller; +import com.evolveum.midpoint.test.IntegrationTestTools; +import com.evolveum.midpoint.test.ObjectChecker; +import com.evolveum.midpoint.test.ProvisioningScriptSpec; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.Holder; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SecurityViolationException; -import com.evolveum.midpoint.util.exception.SystemException; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.LockoutStatusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationProvisioningScriptsType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultStatusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ProvisioningScriptType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationSituationType; +import com.evolveum.midpoint.util.exception.*; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; /** * The test of Provisioning service on the API level. The test is using dummy @@ -238,9 +200,9 @@ public void test101AddAccountWithoutName() throws Exception { /** * Make a native modification to an account and read it with max staleness option. * As there is no caching enabled this should throw an error. - * + *

* Note: This test is overridden in TestDummyCaching - * + *

* MID-3481 */ @Test @@ -292,9 +254,9 @@ public void test107AGetModifiedAccountFromCacheMax() throws Exception { /** * Make a native modification to an account and read it with high staleness option. * In this test there is no caching enabled, so this should return fresh data. - * + *

* Note: This test is overridden in TestDummyCaching - * + *

* MID-3481 */ @Test @@ -528,7 +490,6 @@ public boolean handle(PrismObject object, OperationResult parentResu DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "hook"); assertRepoCachingMetadata(shadowMeathook, startTs, endTs); - // And again ... foundObjects.clear(); @@ -576,23 +537,23 @@ public void test111SeachIterativeNoFetch() throws Exception { final List> foundObjects = new ArrayList<>(); ResultHandler handler = (shadow, parentResult) -> { - foundObjects.add(shadow); + foundObjects.add(shadow); - assertTrue(shadow.canRepresent(ShadowType.class)); - try { - checkCachedAccountShadow(shadow, parentResult, false, null, startTs); - } catch (SchemaException e) { - throw new SystemException(e.getMessage(), e); - } + assertTrue(shadow.canRepresent(ShadowType.class)); + try { + checkCachedAccountShadow(shadow, parentResult, false, null, startTs); + } catch (SchemaException e) { + throw new SystemException(e.getMessage(), e); + } - assertRepoCachingMetadata(shadow, null, startTs); + assertRepoCachingMetadata(shadow, null, startTs); - if (shadow.asObjectable().getName().getOrig().equals("meathook")) { - assertRepoShadowCachedAttributeValue(shadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "Sea Monkey"); - } + if (shadow.asObjectable().getName().getOrig().equals("meathook")) { + assertRepoShadowCachedAttributeValue(shadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "Sea Monkey"); + } - return true; - }; + return true; + }; Collection> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch()); @@ -632,11 +593,11 @@ public void test112SeachIterativeKindIntent() throws Exception { // WHEN provisioningService.searchObjectsIterative(ShadowType.class, query, null, - (object, parentResult) -> { - foundObjects.add(object); - return true; + (object, parentResult) -> { + foundObjects.add(object); + return true; }, - null, result); + null, result); // THEN result.computeStatus(); @@ -660,9 +621,9 @@ protected void assertProtected(List> shado private int countProtected(List> shadows) { int count = 0; - for (PrismObject shadow: shadows) { + for (PrismObject shadow : shadows) { if (shadow.asObjectable().isProtectedObject() != null && shadow.asObjectable().isProtectedObject()) { - count ++; + count++; } } return count; @@ -843,9 +804,9 @@ public void test118SearchAllAccountsLongStaleness() throws Exception { * This is supposed to return only cached data. Therefore * repo search is performed. But as caching is * not enabled in this test only errors will be returned. - * + *

* Note: This test is overridden in TestDummyCaching - * + *

* MID-3481 */ @Test @@ -877,11 +838,11 @@ public void test119SearchAllAccountsMaxStaleness() throws Exception { assertFalse("No shadows found", allShadows.isEmpty()); assertEquals("Wrong number of results", 4, allShadows.size()); - for (PrismObject shadow: allShadows) { + for (PrismObject shadow : allShadows) { display("Found shadow (error expected)", shadow); OperationResultType fetchResult = shadow.asObjectable().getFetchResult(); - assertNotNull("No fetch result status in "+shadow, fetchResult); - assertEquals("Wrong fetch result status in "+shadow, OperationResultStatusType.FATAL_ERROR, fetchResult.getStatus()); + assertNotNull("No fetch result status in " + shadow, fetchResult); + assertEquals("Wrong fetch result status in " + shadow, OperationResultStatusType.FATAL_ERROR, fetchResult.getStatus()); } assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); @@ -915,7 +876,7 @@ public void test120ModifyWillReplaceFullname() throws Exception { delta.checkConsistence(); assertDummyAccount(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid) - .assertAttribute(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Pirate Will Turner"); + .assertAttribute(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Pirate Will Turner"); syncServiceMock.assertNotifySuccessOnly(); @@ -1097,8 +1058,8 @@ public void test126ModifyAccountWillPassword() throws Exception { assertSuccess(result); assertDummyAccount(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid) - .assertPassword(ACCOUNT_WILL_PASSWORD_123) - .assertLastModifier(null); + .assertPassword(ACCOUNT_WILL_PASSWORD_123) + .assertLastModifier(null); accountWillCurrentPassword = ACCOUNT_WILL_PASSWORD_123; @@ -1143,8 +1104,8 @@ protected void testComparePassword(final String TEST_NAME, String tag, String sh then(TEST_NAME); assertSuccess(result); - display("Comparison result ("+tag+")", comparisonResult); - assertEquals("Wrong comparison result ("+tag+")", expectedResult, comparisonResult); + display("Comparison result (" + tag + ")", comparisonResult); + assertEquals("Wrong comparison result (" + tag + ")", expectedResult, comparisonResult); syncServiceMock.assertNoNotifcations(); } @@ -1236,7 +1197,6 @@ public void test131AddScript() throws Exception { // MID-1113 @Test public void test132ModifyScript() throws Exception { - final String TEST_NAME = "test132ModifyScript"; // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1423,7 +1383,7 @@ public void test150DisableAccount() throws Exception { delta.checkConsistence(); // check if activation was changed dummyAccount = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid); - assertFalse("Dummy account "+transformNameFromResource(ACCOUNT_WILL_USERNAME)+" is enabled, expected disabled", dummyAccount.isEnabled()); + assertFalse("Dummy account " + transformNameFromResource(ACCOUNT_WILL_USERNAME) + " is enabled, expected disabled", dummyAccount.isEnabled()); syncServiceMock.assertNotifySuccessOnly(); @@ -1500,7 +1460,7 @@ public void test152ActivationStatusUndefinedAccount() throws Exception { delta.checkConsistence(); // check if activation was changed dummyAccount = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid); - assertEquals("Wrong dummy account "+transformNameFromResource(ACCOUNT_WILL_USERNAME)+" enabled flag", + assertEquals("Wrong dummy account " + transformNameFromResource(ACCOUNT_WILL_USERNAME) + " enabled flag", null, dummyAccount.isEnabled()); syncServiceMock.assertNotifySuccessOnly(); @@ -1544,7 +1504,7 @@ public void test154EnableAccount() throws Exception { delta.checkConsistence(); // check if activation was changed dummyAccount = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid); - assertTrue("Dummy account "+transformNameFromResource(ACCOUNT_WILL_USERNAME)+" is disabled, expected enabled", dummyAccount.isEnabled()); + assertTrue("Dummy account " + transformNameFromResource(ACCOUNT_WILL_USERNAME) + " is disabled, expected enabled", dummyAccount.isEnabled()); syncServiceMock.assertNotifySuccessOnly(); @@ -1580,7 +1540,6 @@ public void test155SearchDisabledAccounts() throws Exception { assertSteadyResource(); } - @Test public void test156SetValidFrom() throws Exception { final String TEST_NAME = "test156SetValidFrom"; @@ -1600,8 +1559,6 @@ public void test156SetValidFrom() throws Exception { syncServiceMock.reset(); - long millis = VALID_FROM_MILLIS; - ObjectDelta delta = prismContext.deltaFactory().object().createModificationReplaceProperty(ShadowType.class, ACCOUNT_WILL_OID, SchemaConstants.PATH_ACTIVATION_VALID_FROM, XmlTypeConverter.createXMLGregorianCalendar(VALID_FROM_MILLIS)); @@ -1619,8 +1576,8 @@ public void test156SetValidFrom() throws Exception { delta.checkConsistence(); // check if activation was changed dummyAccount = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid); - assertEquals("Wrong account validFrom in account "+transformNameFromResource(ACCOUNT_WILL_USERNAME), new Date(VALID_FROM_MILLIS), dummyAccount.getValidFrom()); - assertTrue("Dummy account "+transformNameFromResource(ACCOUNT_WILL_USERNAME)+" is disabled, expected enabled", dummyAccount.isEnabled()); + assertEquals("Wrong account validFrom in account " + transformNameFromResource(ACCOUNT_WILL_USERNAME), new Date(VALID_FROM_MILLIS), dummyAccount.getValidFrom()); + assertTrue("Dummy account " + transformNameFromResource(ACCOUNT_WILL_USERNAME) + " is disabled, expected enabled", dummyAccount.isEnabled()); syncServiceMock.assertNotifySuccessOnly(); @@ -1646,8 +1603,6 @@ public void test157SetValidTo() throws Exception { syncServiceMock.reset(); - long millis = VALID_TO_MILLIS; - ObjectDelta delta = prismContext.deltaFactory().object().createModificationReplaceProperty(ShadowType.class, ACCOUNT_WILL_OID, SchemaConstants.PATH_ACTIVATION_VALID_TO, XmlTypeConverter.createXMLGregorianCalendar(VALID_TO_MILLIS)); @@ -1667,9 +1622,9 @@ public void test157SetValidTo() throws Exception { delta.checkConsistence(); // check if activation was changed dummyAccount = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid); - assertEquals("Wrong account validFrom in account "+transformNameFromResource(ACCOUNT_WILL_USERNAME), new Date(VALID_FROM_MILLIS), dummyAccount.getValidFrom()); - assertEquals("Wrong account validTo in account "+transformNameFromResource(ACCOUNT_WILL_USERNAME), new Date(VALID_TO_MILLIS), dummyAccount.getValidTo()); - assertTrue("Dummy account "+transformNameFromResource(ACCOUNT_WILL_USERNAME)+" is disabled, expected enabled", dummyAccount.isEnabled()); + assertEquals("Wrong account validFrom in account " + transformNameFromResource(ACCOUNT_WILL_USERNAME), new Date(VALID_FROM_MILLIS), dummyAccount.getValidFrom()); + assertEquals("Wrong account validTo in account " + transformNameFromResource(ACCOUNT_WILL_USERNAME), new Date(VALID_TO_MILLIS), dummyAccount.getValidTo()); + assertTrue("Dummy account " + transformNameFromResource(ACCOUNT_WILL_USERNAME) + " is disabled, expected enabled", dummyAccount.isEnabled()); syncServiceMock.assertNotifySuccessOnly(); @@ -1722,9 +1677,9 @@ public void test158DeleteValidToValidFrom() throws Exception { delta.checkConsistence(); // check if activation was changed dummyAccount = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid); - assertNull("Unexpected account validTo in account "+transformNameFromResource(ACCOUNT_WILL_USERNAME) + ": " + dummyAccount.getValidTo(), dummyAccount.getValidTo()); - assertNull("Unexpected account validFrom in account "+transformNameFromResource(ACCOUNT_WILL_USERNAME) + ": " + dummyAccount.getValidFrom(), dummyAccount.getValidFrom()); - assertTrue("Dummy account "+transformNameFromResource(ACCOUNT_WILL_USERNAME)+" is disabled, expected enabled", dummyAccount.isEnabled()); + assertNull("Unexpected account validTo in account " + transformNameFromResource(ACCOUNT_WILL_USERNAME) + ": " + dummyAccount.getValidTo(), dummyAccount.getValidTo()); + assertNull("Unexpected account validFrom in account " + transformNameFromResource(ACCOUNT_WILL_USERNAME) + ": " + dummyAccount.getValidFrom(), dummyAccount.getValidFrom()); + assertTrue("Dummy account " + transformNameFromResource(ACCOUNT_WILL_USERNAME) + " is disabled, expected enabled", dummyAccount.isEnabled()); syncServiceMock.assertNotifySuccessOnly(); @@ -1761,7 +1716,7 @@ public void test159GetLockedoutAccount() throws Exception { if (supportsActivation()) { PrismAsserts.assertPropertyValue(shadow, SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS, - LockoutStatusType.LOCKED); + LockoutStatusType.LOCKED); } else { PrismAsserts.assertNoItem(shadow, SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS); } @@ -1843,7 +1798,7 @@ public void test162UnlockAccount() throws Exception { delta.checkConsistence(); // check if activation was changed dummyAccount = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid); - assertFalse("Dummy account "+transformNameFromResource(ACCOUNT_WILL_USERNAME)+" is locked, expected unlocked", dummyAccount.isLockout()); + assertFalse("Dummy account " + transformNameFromResource(ACCOUNT_WILL_USERNAME) + " is locked, expected unlocked", dummyAccount.isLockout()); syncServiceMock.assertNotifySuccessOnly(); @@ -1875,7 +1830,7 @@ public void test163GetAccount() throws Exception { if (supportsActivation()) { PrismAsserts.assertPropertyValue(shadow, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, - ActivationStatusType.ENABLED); + ActivationStatusType.ENABLED); PrismAsserts.assertPropertyValue(shadow, SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS, LockoutStatusType.NORMAL); } else { @@ -1921,32 +1876,27 @@ public void test163SearchLockedAccounts() throws Exception { @Test public void test170SearchNull() throws Exception { - final String TEST_NAME = "test170SearchNull"; - testSeachIterative(TEST_NAME, null, null, true, true, false, + testSeachIterative(null, null, true, true, false, "meathook", "daemon", transformNameFromResource("morgan"), transformNameFromResource("Will")); } @Test public void test171SearchShipSeaMonkey() throws Exception { - final String TEST_NAME = "test171SearchShipSeaMonkey"; - testSeachIterativeSingleAttrFilter(TEST_NAME, + testSeachIterativeSingleAttrFilter( DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "Sea Monkey", null, true, "meathook"); } // See MID-1460 - @Test(enabled=false) + @Test(enabled = false) public void test172SearchShipNull() throws Exception { - final String TEST_NAME = "test172SearchShipNull"; - testSeachIterativeSingleAttrFilter(TEST_NAME, + testSeachIterativeSingleAttrFilter( DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, null, null, true, "daemon", "Will"); } @Test public void test173SearchWeaponCutlass() throws Exception { - final String TEST_NAME = "test173SearchWeaponCutlass"; - // Make sure there is an account on resource that the provisioning has // never seen before, so there is no shadow // for it yet. @@ -1959,16 +1909,15 @@ public void test173SearchWeaponCutlass() throws Exception { IntegrationTestTools.display("dummy", dummyResource.debugDump()); - testSeachIterativeSingleAttrFilter(TEST_NAME, + testSeachIterativeSingleAttrFilter( DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "cutlass", null, true, transformNameFromResource("morgan"), "carla"); } @Test public void test175SearchUidExact() throws Exception { - final String TEST_NAME = "test175SearchUidExact"; dummyResource.setDisableNameHintChecks(true); - testSeachIterativeSingleAttrFilter(TEST_NAME, + testSeachIterativeSingleAttrFilter( SchemaConstants.ICFS_UID, willIcfUid, null, true, transformNameFromResource("Will")); dummyResource.setDisableNameHintChecks(false); @@ -1976,16 +1925,14 @@ public void test175SearchUidExact() throws Exception { @Test public void test176SearchUidExactNoFetch() throws Exception { - final String TEST_NAME = "test176SearchUidExactNoFetch"; - testSeachIterativeSingleAttrFilter(TEST_NAME, SchemaConstants.ICFS_UID, willIcfUid, + testSeachIterativeSingleAttrFilter(SchemaConstants.ICFS_UID, willIcfUid, GetOperationOptions.createNoFetch(), false, transformNameFromResource("Will")); } @Test public void test177SearchIcfNameRepoized() throws Exception { - final String TEST_NAME = "test177SearchIcfNameRepoized"; - testSeachIterativeSingleAttrFilter(TEST_NAME, + testSeachIterativeSingleAttrFilter( SchemaConstants.ICFS_NAME, getWillRepoIcfName(), null, true, transformNameFromResource(ACCOUNT_WILL_USERNAME)); } @@ -1993,10 +1940,10 @@ SchemaConstants.ICFS_NAME, getWillRepoIcfName(), null, true, @Test public void test180SearchNullPagingOffset0Size3() throws Exception { final String TEST_NAME = "test180SearchNullPagingSize5"; - ObjectPaging paging = prismContext.queryFactory().createPaging(0,3); + ObjectPaging paging = prismContext.queryFactory().createPaging(0, 3); paging.setOrdering(createAttributeOrdering(SchemaConstants.ICFS_NAME)); SearchResultMetadata searchMetadata = testSeachIterativePaging(TEST_NAME, null, paging, null, - getSortedUsernames18x(0,3)); + getSortedUsernames18x(0, 3)); assertApproxNumberOfAllResults(searchMetadata, getTest18xApproxNumberOfSearchResults()); } @@ -2007,30 +1954,30 @@ public void test180SearchNullPagingOffset0Size3() throws Exception { @Test public void test181SearchNullPagingOffset0Size3Desc() throws Exception { final String TEST_NAME = "test181SearchNullPagingOffset0Size3Desc"; - ObjectPaging paging = prismContext.queryFactory().createPaging(0,3); + ObjectPaging paging = prismContext.queryFactory().createPaging(0, 3); paging.setOrdering(createAttributeOrdering(SchemaConstants.ICFS_NAME, OrderDirection.DESCENDING)); SearchResultMetadata searchMetadata = testSeachIterativePaging(TEST_NAME, null, paging, null, - getSortedUsernames18xDesc(0,3)); + getSortedUsernames18xDesc(0, 3)); assertApproxNumberOfAllResults(searchMetadata, getTest18xApproxNumberOfSearchResults()); } @Test public void test182SearchNullPagingOffset1Size2() throws Exception { final String TEST_NAME = "test182SearchNullPagingOffset1Size2"; - ObjectPaging paging = prismContext.queryFactory().createPaging(1,2); + ObjectPaging paging = prismContext.queryFactory().createPaging(1, 2); paging.setOrdering(createAttributeOrdering(SchemaConstants.ICFS_NAME)); SearchResultMetadata searchMetadata = testSeachIterativePaging(TEST_NAME, null, paging, null, - getSortedUsernames18x(1,2)); + getSortedUsernames18x(1, 2)); assertApproxNumberOfAllResults(searchMetadata, getTest18xApproxNumberOfSearchResults()); } @Test public void test183SearchNullPagingOffset2Size3Desc() throws Exception { final String TEST_NAME = "test183SearchNullPagingOffset1Size3Desc"; - ObjectPaging paging = prismContext.queryFactory().createPaging(2,3); + ObjectPaging paging = prismContext.queryFactory().createPaging(2, 3); paging.setOrdering(createAttributeOrdering(SchemaConstants.ICFS_NAME, OrderDirection.DESCENDING)); SearchResultMetadata searchMetadata = testSeachIterativePaging(TEST_NAME, null, paging, null, - getSortedUsernames18xDesc(2,3)); + getSortedUsernames18xDesc(2, 3)); assertApproxNumberOfAllResults(searchMetadata, getTest18xApproxNumberOfSearchResults()); } @@ -2062,24 +2009,21 @@ protected ObjectOrdering createAttributeOrdering(QName attrQname, OrderDirection @Test public void test194SearchIcfNameRepoizedNoFetch() throws Exception { - final String TEST_NAME = "test194SearchIcfNameRepoizedNoFetch"; - testSeachIterativeSingleAttrFilter(TEST_NAME, SchemaConstants.ICFS_NAME, getWillRepoIcfName(), + testSeachIterativeSingleAttrFilter(SchemaConstants.ICFS_NAME, getWillRepoIcfName(), GetOperationOptions.createNoFetch(), false, transformNameFromResource(ACCOUNT_WILL_USERNAME)); } @Test public void test195SearchIcfNameExact() throws Exception { - final String TEST_NAME = "test195SearchIcfNameExact"; - testSeachIterativeSingleAttrFilter(TEST_NAME, + testSeachIterativeSingleAttrFilter( SchemaConstants.ICFS_NAME, transformNameFromResource(ACCOUNT_WILL_USERNAME), null, true, transformNameFromResource(ACCOUNT_WILL_USERNAME)); } @Test public void test196SearchIcfNameExactNoFetch() throws Exception { - final String TEST_NAME = "test196SearchIcfNameExactNoFetch"; - testSeachIterativeSingleAttrFilter(TEST_NAME, SchemaConstants.ICFS_NAME, transformNameFromResource(ACCOUNT_WILL_USERNAME), + testSeachIterativeSingleAttrFilter(SchemaConstants.ICFS_NAME, transformNameFromResource(ACCOUNT_WILL_USERNAME), GetOperationOptions.createNoFetch(), false, transformNameFromResource(ACCOUNT_WILL_USERNAME)); } @@ -2087,19 +2031,16 @@ public void test196SearchIcfNameExactNoFetch() throws Exception { // TEMPORARY todo move to more appropriate place (model-intest?) @Test public void test197SearchIcfNameAndUidExactNoFetch() throws Exception { - final String TEST_NAME = "test197SearchIcfNameAndUidExactNoFetch"; - testSeachIterativeAlternativeAttrFilter(TEST_NAME, SchemaConstants.ICFS_NAME, transformNameFromResource(ACCOUNT_WILL_USERNAME), + testSeachIterativeAlternativeAttrFilter(SchemaConstants.ICFS_NAME, transformNameFromResource(ACCOUNT_WILL_USERNAME), SchemaConstants.ICFS_UID, willIcfUid, GetOperationOptions.createNoFetch(), false, transformNameFromResource(ACCOUNT_WILL_USERNAME)); } - @Test public void test198SearchNone() throws Exception { - final String TEST_NAME = "test198SearchNone"; ObjectFilter attrFilter = FilterCreationUtil.createNone(prismContext); - testSeachIterative(TEST_NAME, attrFilter, null, true, true, false); + testSeachIterative(attrFilter, null, true, true, false); } /** @@ -2120,7 +2061,7 @@ public void test199SearchOnAndOffResource() throws Exception { ResultHandler handler = new ResultHandler() { @Override public boolean handle(PrismObject object, OperationResult parentResult) { - AssertJUnit.fail("Handler called: "+object); + AssertJUnit.fail("Handler called: " + object); return false; } }; @@ -2161,7 +2102,7 @@ public void test196SearchOnAndOffResourceNoFetch() throws Exception { ResultHandler handler = new ResultHandler() { @Override public boolean handle(PrismObject object, OperationResult parentResult) { - AssertJUnit.fail("Handler called: "+object); + AssertJUnit.fail("Handler called: " + object); return false; } }; @@ -2193,13 +2134,13 @@ private ObjectQuery createOnOffQuery() throws SchemaException { return query; } - protected void testSeachIterativeSingleAttrFilter(final String TEST_NAME, String attrName, T attrVal, + protected void testSeachIterativeSingleAttrFilter(String attrName, T attrVal, GetOperationOptions rootOptions, boolean fullShadow, String... expectedAccountIds) throws Exception { - testSeachIterativeSingleAttrFilter(TEST_NAME, dummyResourceCtl.getAttributeQName(attrName), attrVal, + testSeachIterativeSingleAttrFilter(dummyResourceCtl.getAttributeQName(attrName), attrVal, rootOptions, fullShadow, expectedAccountIds); } - protected void testSeachIterativeSingleAttrFilter(final String TEST_NAME, QName attrQName, T attrVal, + protected void testSeachIterativeSingleAttrFilter(QName attrQName, T attrVal, GetOperationOptions rootOptions, boolean fullShadow, String... expectedAccountNames) throws Exception { ResourceSchema resourceSchema = RefinedResourceSchemaImpl.getResourceSchema(resource, prismContext); ObjectClassComplexTypeDefinition objectClassDef = resourceSchema.findObjectClassDefinition(SchemaTestConstants.ACCOUNT_OBJECT_CLASS_LOCAL_NAME); @@ -2207,12 +2148,12 @@ protected void testSeachIterativeSingleAttrFilter(final String TEST_NAME, QN ObjectFilter filter = prismContext.queryFor(ShadowType.class) .itemWithDef(attrDef, ShadowType.F_ATTRIBUTES, attrDef.getItemName()).eq(attrVal) .buildFilter(); - testSeachIterative(TEST_NAME, filter, rootOptions, fullShadow, true, false, expectedAccountNames); + testSeachIterative(filter, rootOptions, fullShadow, true, false, expectedAccountNames); } - protected void testSeachIterativeAlternativeAttrFilter(final String TEST_NAME, QName attr1QName, T attr1Val, - QName attr2QName, T attr2Val, - GetOperationOptions rootOptions, boolean fullShadow, String... expectedAccountNames) throws Exception { + protected void testSeachIterativeAlternativeAttrFilter(QName attr1QName, T attr1Val, + QName attr2QName, T attr2Val, + GetOperationOptions rootOptions, boolean fullShadow, String... expectedAccountNames) throws Exception { ResourceSchema resourceSchema = RefinedResourceSchemaImpl.getResourceSchema(resource, prismContext); ObjectClassComplexTypeDefinition objectClassDef = resourceSchema.findObjectClassDefinition(SchemaTestConstants.ACCOUNT_OBJECT_CLASS_LOCAL_NAME); ResourceAttributeDefinition attr1Def = objectClassDef.findAttributeDefinition(attr1QName); @@ -2221,14 +2162,14 @@ protected void testSeachIterativeAlternativeAttrFilter(final String TEST_NAM .itemWithDef(attr1Def, ShadowType.F_ATTRIBUTES, attr1Def.getItemName()).eq(attr1Val) .or().itemWithDef(attr2Def, ShadowType.F_ATTRIBUTES, attr2Def.getItemName()).eq(attr2Val) .buildFilter(); - testSeachIterative(TEST_NAME, filter, rootOptions, fullShadow, false, true, expectedAccountNames); + testSeachIterative(filter, rootOptions, fullShadow, false, true, expectedAccountNames); } - - private SearchResultMetadata testSeachIterative(final String TEST_NAME, ObjectFilter attrFilter, GetOperationOptions rootOptions, - final boolean fullShadow, boolean useObjectClassFilter, final boolean useRepo, String... expectedAccountNames) throws Exception { - OperationResult result = new OperationResult(TestDummy.class.getName() - + "." + TEST_NAME); + private SearchResultMetadata testSeachIterative( + ObjectFilter attrFilter, GetOperationOptions rootOptions, final boolean fullShadow, + boolean useObjectClassFilter, final boolean useRepo, String... expectedAccountNames) + throws Exception { + OperationResult result = createResult(); ObjectQuery query; if (useObjectClassFilter) { @@ -2272,9 +2213,8 @@ public boolean handle(PrismObject shadow, OperationResult parentResu Collection> options = SelectorOptions.createCollection(rootOptions); - // WHEN - when(TEST_NAME); + when(); SearchResultMetadata searchMetadata; if (useRepo) { searchMetadata = repositoryService.searchObjectsIterative(ShadowType.class, query, handler, null, true, result); @@ -2283,27 +2223,27 @@ public boolean handle(PrismObject shadow, OperationResult parentResu } // THEN - then(TEST_NAME); + then(); result.computeStatus(); display("searchObjectsIterative result", result); TestUtil.assertSuccess(result); display("found shadows", foundObjects); - for (String expectedAccountId: expectedAccountNames) { + for (String expectedAccountId : expectedAccountNames) { boolean found = false; - for (PrismObject foundObject: foundObjects) { + for (PrismObject foundObject : foundObjects) { if (expectedAccountId.equals(foundObject.asObjectable().getName().getOrig())) { found = true; break; } } if (!found) { - AssertJUnit.fail("Account "+expectedAccountId+" was expected to be found but it was not found (found "+foundObjects.size()+", expected "+expectedAccountNames.length+")"); + AssertJUnit.fail("Account " + expectedAccountId + " was expected to be found but it was not found (found " + foundObjects.size() + ", expected " + expectedAccountNames.length + ")"); } } - assertEquals("Wrong number of found objects ("+foundObjects+"): "+foundObjects, expectedAccountNames.length, foundObjects.size()); + assertEquals("Wrong number of found objects (" + foundObjects + "): " + foundObjects, expectedAccountNames.length, foundObjects.size()); if (!useRepo) { checkUniqueness(foundObjects); } @@ -2319,14 +2259,13 @@ private SearchResultMetadata testSeachIterativePaging(final String TEST_NAME, Ob + "." + TEST_NAME); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(RESOURCE_DUMMY_OID, new QName(ResourceTypeUtil.getResourceNamespace(resourceType), - SchemaConstants.ACCOUNT_OBJECT_CLASS_LOCAL_NAME), prismContext); + SchemaConstants.ACCOUNT_OBJECT_CLASS_LOCAL_NAME), prismContext); if (attrFilter != null) { AndFilter filter = (AndFilter) query.getFilter(); filter.getConditions().add(attrFilter); } query.setPaging(paging); - display("Query", query); final XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); @@ -2352,7 +2291,6 @@ public boolean handle(PrismObject shadow, OperationResult parentResu Collection> options = SelectorOptions.createCollection(rootOptions); - // WHEN when(TEST_NAME); SearchResultMetadata searchMetadata = provisioningService.searchObjectsIterative(ShadowType.class, query, options, handler, null, result); @@ -2366,15 +2304,15 @@ public boolean handle(PrismObject shadow, OperationResult parentResu display("found shadows", foundObjects); int i = 0; - for (String expectedAccountId: expectedAccountNames) { + for (String expectedAccountId : expectedAccountNames) { PrismObject foundObject = foundObjects.get(i); if (!expectedAccountId.equals(foundObject.asObjectable().getName().getOrig())) { - fail("Account "+expectedAccountId+" was expected to be found on "+i+" position, but it was not found (found "+foundObject.asObjectable().getName().getOrig()+")"); + fail("Account " + expectedAccountId + " was expected to be found on " + i + " position, but it was not found (found " + foundObject.asObjectable().getName().getOrig() + ")"); } i++; } - assertEquals("Wrong number of found objects ("+foundObjects+"): "+foundObjects, expectedAccountNames.length, foundObjects.size()); + assertEquals("Wrong number of found objects (" + foundObjects + "): " + foundObjects, expectedAccountNames.length, foundObjects.size()); checkUniqueness(foundObjects); assertSteadyResource(); @@ -2426,7 +2364,7 @@ public void test200AddGroup() throws Exception { // Check if the group was created in the dummy resource DummyGroup dummyGroup = getDummyGroupAssert(GROUP_PIRATES_NAME, piratesIcfUid); - assertNotNull("No dummy group "+GROUP_PIRATES_NAME, dummyGroup); + assertNotNull("No dummy group " + GROUP_PIRATES_NAME, dummyGroup); assertEquals("Description is wrong", "Scurvy pirates", dummyGroup.getAttributeValue("description")); assertTrue("The group is not enabled", dummyGroup.isEnabled()); @@ -2487,10 +2425,10 @@ private void checkGroupPirates(PrismObject shadow, OperationResult r @Test public void test203GetGroupNoFetch() throws Exception { - final String TEST_NAME="test203GetGroupNoFetch"; + final String TEST_NAME = "test203GetGroupNoFetch"; // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() - + "."+TEST_NAME); + + "." + TEST_NAME); GetOperationOptions rootOptions = new GetOperationOptions(); rootOptions.setNoFetch(true); @@ -2597,8 +2535,8 @@ public void test210AddPrivilege() throws Exception { // Check if the priv was created in the dummy resource DummyPrivilege dummyPriv = getDummyPrivilegeAssert(PRIVILEGE_PILLAGE_NAME, pillageIcfUid); - assertNotNull("No dummy priv "+PRIVILEGE_PILLAGE_NAME, dummyPriv); - assertEquals("Wrong privilege power", (Integer)100, dummyPriv.getAttributeValue(DummyResourceContoller.DUMMY_PRIVILEGE_ATTRIBUTE_POWER, Integer.class)); + assertNotNull("No dummy priv " + PRIVILEGE_PILLAGE_NAME, dummyPriv); + assertEquals("Wrong privilege power", (Integer) 100, dummyPriv.getAttributeValue(DummyResourceContoller.DUMMY_PRIVILEGE_ATTRIBUTE_POWER, Integer.class)); // Check if the shadow is still in the repo (e.g. that the consistency or sync haven't removed it) PrismObject shadowFromRepo = getShadowRepo(addedObjectOid); @@ -2694,7 +2632,7 @@ public void test214AddPrivilegeBargain() throws Exception { // Check if the group was created in the dummy resource DummyPrivilege dummyPriv = getDummyPrivilegeAssert(PRIVILEGE_BARGAIN_NAME, bargainIcfUid); - assertNotNull("No dummy priv "+PRIVILEGE_BARGAIN_NAME, dummyPriv); + assertNotNull("No dummy priv " + PRIVILEGE_BARGAIN_NAME, dummyPriv); // Check if the shadow is still in the repo (e.g. that the consistency or sync haven't removed it) PrismObject shadowFromRepo = getShadowRepo(addedObjectOid); @@ -2719,7 +2657,6 @@ private void checkPrivBargain(PrismObject shadow, OperationResult re shadow, new QName(SchemaConstants.NS_ICF_SCHEMA, "password"))); } - @Test public void test220EntitleAccountWillPirates() throws Exception { final String TEST_NAME = "test220EntitleAccountWillPirates"; @@ -2902,8 +2839,6 @@ public void test223EntitleAccountWillBargain() throws Exception { */ @Test public void test224GetPillagingPirateWill() throws Exception { - final String TEST_NAME = "test224GetPillagingPirateWill"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -2954,8 +2889,6 @@ public void test224GetPillagingPirateWill() throws Exception { */ @Test public void test225GetFoolishPirateWill() throws Exception { - final String TEST_NAME = "test225GetFoolishPirateWill"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -3024,8 +2957,6 @@ public void test225GetFoolishPirateWill() throws Exception { */ @Test public void test226WillNonsensePrivilege() throws Exception { - final String TEST_NAME = "test226WillNonsensePrivilege"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -3316,8 +3247,6 @@ private void assertAccountPiratesEntitled() throws Exception { @Test public void test238DetitleAccountWillPillage() throws Exception { - final String TEST_NAME = "test238DetitleAccountWillPillage"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -3358,14 +3287,11 @@ public void test238DetitleAccountWillPillage() throws Exception { display("Shadow after", shadow); assertEntitlementPriv(shadow, PRIVILEGE_BARGAIN_OID); - assertSteadyResource(); } @Test public void test239DetitleAccountWillBargain() throws Exception { - final String TEST_NAME = "test239DetitleAccountWillBargain"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -3410,7 +3336,6 @@ public void test239DetitleAccountWillBargain() throws Exception { */ @Test public void test260AddAccountLeChuck() throws Exception { - final String TEST_NAME = "test260AddAccountLeChuck"; // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -3494,7 +3419,6 @@ public void test260AddAccountLeChuck() throws Exception { */ @Test public void test265DeleteAccountLeChuck() throws Exception { - final String TEST_NAME = "test265DeleteAccountLeChuck"; // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -3544,8 +3468,6 @@ public void test265DeleteAccountLeChuck() throws Exception { @Test public void test298DeletePrivPillage() throws Exception { - final String TEST_NAME = "test298DeletePrivPillage"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -3583,8 +3505,6 @@ public void test298DeletePrivPillage() throws Exception { @Test public void test299DeleteGroupPirates() throws Exception { - final String TEST_NAME = "test299DeleteGroupPirates"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -3615,7 +3535,7 @@ public void test299DeleteGroupPirates() throws Exception { } DummyGroup dummyAccount = getDummyGroup(GROUP_PIRATES_NAME, piratesIcfUid); - assertNull("Dummy group '"+GROUP_PIRATES_NAME+"' is not gone from dummy resource", dummyAccount); + assertNull("Dummy group '" + GROUP_PIRATES_NAME + "' is not gone from dummy resource", dummyAccount); assertSteadyResource(); } @@ -3737,8 +3657,8 @@ public void test330ModifyAccountWillPasswordSelfService() throws Exception { // Check if the account was created in the dummy resource assertDummyAccount(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid) - .assertPassword(ACCOUNT_WILL_PASSWORD_321) - .assertLastModifier(getLastModifierName(ACCOUNT_WILL_USERNAME)); + .assertPassword(ACCOUNT_WILL_PASSWORD_321) + .assertLastModifier(getLastModifierName(ACCOUNT_WILL_USERNAME)); accountWillCurrentPassword = ACCOUNT_WILL_PASSWORD_321; @@ -3858,7 +3778,7 @@ public void test344ModifyWillDeleteGossipAvast() throws Exception { protected List> getGossipDelta(PlusMinusZero plusMinusZero, String... values) throws SchemaException { List> mods = prismContext.deltaFor(ShadowType.class) .property(dummyResourceCtl.getAttributePath(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME), null) - .mod(plusMinusZero, values) + .mod(plusMinusZero, values) .asItemDeltas(); display("Modifications", mods); return mods; @@ -3867,7 +3787,7 @@ public void test344ModifyWillDeleteGossipAvast() throws Exception { protected void assertAccountWillGossip(String... values) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { display("Account will", getDummyAccount(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid)); assertDummyAccount(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid) - .assertAttribute(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME, values); + .assertAttribute(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME, values); } protected void assertWillDummyGossipRecord(PlusMinusZero plusminus, String... expectedValues) { @@ -3882,19 +3802,18 @@ protected void assertWillDummyGossipRecord(PlusMinusZero plusminus, String... ex Collection valuesToConsider = null; switch (plusminus) { case PLUS: - valuesToConsider = (Collection)dummyDelta.getValuesAdded(); + valuesToConsider = (Collection) dummyDelta.getValuesAdded(); break; case MINUS: - valuesToConsider = (Collection)dummyDelta.getValuesDeleted(); + valuesToConsider = (Collection) dummyDelta.getValuesDeleted(); break; case ZERO: - valuesToConsider = (Collection)dummyDelta.getValuesReplaced(); + valuesToConsider = (Collection) dummyDelta.getValuesReplaced(); break; } - PrismAsserts.assertEqualsCollectionUnordered("Wrong values for "+plusminus+" in dummy resource delta", valuesToConsider, expectedValues); + PrismAsserts.assertEqualsCollectionUnordered("Wrong values for " + plusminus + " in dummy resource delta", valuesToConsider, expectedValues); } - protected String getLastModifierName(String expected) { return transformNameToResource(expected); } @@ -3904,12 +3823,11 @@ protected String getLastModifierName(String expected) { @Test public void test500AddProtectedAccount() throws Exception { final String TEST_NAME = "test500AddProtectedAccount"; - testAddProtectedAccount(TEST_NAME, ACCOUNT_DAVIEJONES_USERNAME); + testAddProtectedAccount(ACCOUNT_DAVIEJONES_USERNAME); } @Test public void test501GetProtectedAccountShadow() throws Exception { - final String TEST_NAME = "test501GetProtectedAccountShadow"; // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -3917,7 +3835,7 @@ public void test501GetProtectedAccountShadow() throws Exception { // WHEN PrismObject account = provisioningService.getObject(ShadowType.class, ACCOUNT_DAEMON_OID, null, task, result); - assertEquals(""+account+" is not protected", Boolean.TRUE, account.asObjectable().isProtectedObject()); + assertEquals("" + account + " is not protected", Boolean.TRUE, account.asObjectable().isProtectedObject()); checkUniqueness(account); result.computeStatus(); @@ -3932,7 +3850,6 @@ public void test501GetProtectedAccountShadow() throws Exception { */ @Test public void test502ModifyProtectedAccountShadowAttributes() throws Exception { - final String TEST_NAME = "test502ModifyProtectedAccountShadowAttributes"; // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -3982,7 +3899,7 @@ public void test503ModifyProtectedAccountShadowProperty() throws Exception { ObjectDelta shadowDelta = prismContext.deltaFactory().object() .createModificationReplaceProperty(ShadowType.class, ACCOUNT_DAEMON_OID, - ShadowType.F_SYNCHRONIZATION_SITUATION, SynchronizationSituationType.DISPUTED); + ShadowType.F_SYNCHRONIZATION_SITUATION, SynchronizationSituationType.DISPUTED); // WHEN provisioningService.modifyObject(ShadowType.class, ACCOUNT_DAEMON_OID, shadowDelta.getModifications(), null, null, task, result); @@ -4035,9 +3952,9 @@ public void test509DeleteProtectedAccountShadow() throws Exception { public void test510AddProtectedAccounts() throws Exception { final String TEST_NAME = "test510AddProtectedAccounts"; // GIVEN - testAddProtectedAccount(TEST_NAME, "Xavier"); - testAddProtectedAccount(TEST_NAME, "Xenophobia"); - testAddProtectedAccount(TEST_NAME, "nobody-adm"); + testAddProtectedAccount("Xavier"); + testAddProtectedAccount("Xenophobia"); + testAddProtectedAccount("nobody-adm"); testAddAccount("abcadm"); testAddAccount("piXel"); testAddAccount("supernaturalius"); @@ -4045,7 +3962,6 @@ public void test510AddProtectedAccounts() throws Exception { @Test public void test511AddProtectedAccountCaseIgnore() throws Exception { - final String TEST_NAME = "test511AddProtectedAccountCaseIgnore"; // GIVEN testAddAccount("xaxa"); testAddAccount("somebody-ADM"); @@ -4068,7 +3984,7 @@ private PrismObject createAccountShadow(String username) throws Sche return shadow; } - protected void testAddProtectedAccount(final String TEST_NAME, String username) throws Exception { + protected void testAddProtectedAccount(String username) throws Exception { Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -4078,7 +3994,7 @@ protected void testAddProtectedAccount(final String TEST_NAME, String username) // WHEN try { provisioningService.addObject(shadow, null, null, task, result); - AssertJUnit.fail("Expected security exception while adding '"+username+"' account"); + AssertJUnit.fail("Expected security exception while adding '" + username + "' account"); } catch (SecurityViolationException e) { displayExpectedException(e); } @@ -4136,8 +4052,8 @@ public void test520MigrationPrimaryIdentifierValueRefresh() throws Exception { assertSuccess(result); assertRepoShadow(ACCOUNT_RELIC_OID) - .assertName(ACCOUNT_RELIC_USERNAME) - .assertPrimaryIdentifierValue(ACCOUNT_RELIC_USERNAME); + .assertName(ACCOUNT_RELIC_USERNAME) + .assertPrimaryIdentifierValue(ACCOUNT_RELIC_USERNAME); assertSteadyResource(); } @@ -4186,7 +4102,7 @@ public void test600AddAccountAlreadyExist() throws Exception { display("Repository shadow", accountRepo); checkRepoAccountShadow(accountRepo); - assertEquals("Wrong ICF NAME in murray (repo) shadow", getMurrayRepoIcfName(), getIcfName(accountRepo)); + assertEquals("Wrong ICF NAME in murray (repo) shadow", getMurrayRepoIcfName(), getIcfName(accountRepo)); assertSteadyResource(); } @@ -4500,7 +4416,7 @@ public void testLiveSyncAddDrake(final String TEST_NAME, DummySyncStyle syncStyl } else { ObjectDelta objectDelta = lastChange.getObjectDelta(); assertNotNull("Delta present when not expecting it", objectDelta); - assertTrue("Delta is not add: "+objectDelta, objectDelta.isAdd()); + assertTrue("Delta is not add: " + objectDelta, objectDelta.isAdd()); } ShadowType currentShadowType = lastChange.getCurrentShadow().asObjectable(); @@ -4633,7 +4549,7 @@ public void testLiveSyncAddCorsairs(final String TEST_NAME, DummySyncStyle syncS } else { ObjectDelta objectDelta = lastChange.getObjectDelta(); assertNotNull("Delta present when not expecting it", objectDelta); - assertTrue("Delta is not add: "+objectDelta, objectDelta.isAdd()); + assertTrue("Delta is not add: " + objectDelta, objectDelta.isAdd()); } ShadowType currentShadowType = lastChange.getCurrentShadow().asObjectable(); @@ -4693,32 +4609,31 @@ public void testLiveSyncDeleteCorsairs(final String TEST_NAME, DummySyncStyle sy display("Synchronization result", result); TestUtil.assertSuccess("Synchronization result is not OK", result); - if (expectReaction) { syncServiceMock.assertNotifyChange(); syncServiceMock - .lastNotifyChange() + .lastNotifyChange() .display() .oldShadow() - .assertOid(corsairsShadowOid) - .attributes() - .assertAttributes(SchemaConstants.ICFS_NAME, SchemaConstants.ICFS_UID) - .assertValue(SchemaConstants.ICFS_NAME, GROUP_CORSAIRS_NAME) - .end() - .end() + .assertOid(corsairsShadowOid) + .attributes() + .assertAttributes(SchemaConstants.ICFS_NAME, SchemaConstants.ICFS_UID) + .assertValue(SchemaConstants.ICFS_NAME, GROUP_CORSAIRS_NAME) + .end() + .end() .delta() - .assertChangeType(ChangeType.DELETE) - .assertObjectTypeClass(ShadowType.class) - .assertOid(corsairsShadowOid) - .end() + .assertChangeType(ChangeType.DELETE) + .assertObjectTypeClass(ShadowType.class) + .assertOid(corsairsShadowOid) + .end() .currentShadow() - .assertOid(corsairsShadowOid) - .assertTombstone(); + .assertOid(corsairsShadowOid) + .assertTombstone(); assertRepoShadow(corsairsShadowOid) - .assertTombstone(); + .assertTombstone(); // Clean slate for next tests repositoryService.deleteObject(ShadowType.class, corsairsShadowOid, result); @@ -4769,18 +4684,18 @@ public void testLiveSyncDeleteDrake(final String TEST_NAME, DummySyncStyle syncS assertSyncOldShadow(oldShadow, getDrakeRepoIcfName()); syncServiceMock - .lastNotifyChange() + .lastNotifyChange() .delta() - .assertChangeType(ChangeType.DELETE) - .assertObjectTypeClass(ShadowType.class) - .assertOid(drakeAccountOid) - .end() + .assertChangeType(ChangeType.DELETE) + .assertObjectTypeClass(ShadowType.class) + .assertOid(drakeAccountOid) + .end() .currentShadow() - .assertTombstone() - .assertOid(drakeAccountOid); + .assertTombstone() + .assertOid(drakeAccountOid); assertRepoShadow(drakeAccountOid) - .assertTombstone(); + .assertTombstone(); checkAllShadows(); @@ -4869,14 +4784,11 @@ private void checkEntitlementShadow(PrismObject shadow, OperationRes IntegrationTestTools.checkEntitlementShadow(shadow.asObjectable(), resourceType, repositoryService, checker, objectClassLocalName, getUidMatchingRule(), prismContext, parentResult); } - private void checkAllShadows() throws SchemaException, ObjectNotFoundException, CommunicationException, - ConfigurationException { + private void checkAllShadows() throws SchemaException { ObjectChecker checker = null; IntegrationTestTools.checkAllShadows(resourceType, repositoryService, checker, prismContext); } - - protected void checkRepoEntitlementShadow(PrismObject repoShadow) { ProvisioningTestUtil.checkRepoEntitlementShadow(repoShadow); } @@ -4896,7 +4808,7 @@ protected void assertSyncOldShadow(PrismObject oldShadow, Collection> attributes = attributesContainer.getAttributes(); assertFalse("Attributes container is empty", attributes.isEmpty()); if (expectedNumberOfAttributes != null) { - assertEquals("Unexpected number of attributes", (int)expectedNumberOfAttributes, attributes.size()); + assertEquals("Unexpected number of attributes", (int) expectedNumberOfAttributes, attributes.size()); } ResourceAttribute icfsNameAttribute = attributesContainer.findAttribute(SchemaConstants.ICFS_NAME); assertNotNull("No ICF name attribute in old shadow", icfsNameAttribute); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyCaching.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyCaching.java index f10e971447a..46b00d64509 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyCaching.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyCaching.java @@ -115,7 +115,7 @@ public void test107AGetModifiedAccountFromCacheMax() throws Exception { PrismObject shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, options, null, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); display("getObject result", result); TestUtil.assertSuccess(result); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyCaseIgnore.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyCaseIgnore.java index a9fde1225a5..a9a20b0911c 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyCaseIgnore.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyCaseIgnore.java @@ -89,18 +89,14 @@ protected boolean isPreFetchResource() { @Test public void test175SearchUidCase() throws Exception { - final String TEST_NAME = "test175SearchUidCase"; - TestUtil.displayTestTitle(TEST_NAME); - testSeachIterativeSingleAttrFilter(TEST_NAME, + testSeachIterativeSingleAttrFilter( SchemaConstants.ICFS_UID, "wIlL", null, true, transformNameFromResource("Will")); } @Test public void test176SearchUidCaseNoFetch() throws Exception { - final String TEST_NAME = "test176SearchUidCaseNoFetch"; - TestUtil.displayTestTitle(TEST_NAME); - testSeachIterativeSingleAttrFilter(TEST_NAME, + testSeachIterativeSingleAttrFilter( SchemaConstants.ICFS_UID, "wIlL", GetOperationOptions.createNoFetch(), false, transformNameFromResource("Will")); } @@ -110,10 +106,7 @@ public void test176SearchUidCaseNoFetch() throws Exception { */ @Test public void test280EntitleAccountWillPiratesAlreadyThere() throws Exception { - final String TEST_NAME = "test280EntitleAccountWillPiratesAlreadyThere"; - TestUtil.displayTestTitle(TEST_NAME); - - Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyGroup groupPirates = getDummyGroup(GROUP_PIRATES_NAME, piratesIcfUid); @@ -151,11 +144,7 @@ public void test280EntitleAccountWillPiratesAlreadyThere() throws Exception { @Test public void test282DetitleAccountWillPirates() throws Exception { - final String TEST_NAME = "test282DetitleAccountWillPirates"; - TestUtil.displayTestTitle(TEST_NAME); - - Task task = taskManager.createTaskInstance(TestDummy.class.getName() - + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -192,10 +181,7 @@ public void test282DetitleAccountWillPirates() throws Exception { */ @Test public void test285EntitleAccountWillPiratesAlreadyThereCaseIgnore() throws Exception { - final String TEST_NAME = "test285EntitleAccountWillPiratesAlreadyThereCaseIgnore"; - TestUtil.displayTestTitle(TEST_NAME); - - Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyGroup groupPirates = getDummyGroup(GROUP_PIRATES_NAME, piratesIcfUid); @@ -233,11 +219,7 @@ public void test285EntitleAccountWillPiratesAlreadyThereCaseIgnore() throws Exce @Test public void test289DetitleAccountWillPirates() throws Exception { - final String TEST_NAME = "test289DetitleAccountWillPirates"; - TestUtil.displayTestTitle(TEST_NAME); - - Task task = taskManager.createTaskInstance(TestDummy.class.getName() - + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -273,11 +255,9 @@ public void test289DetitleAccountWillPirates() throws Exception { @Test public void test511AddProtectedAccountCaseIgnore() throws Exception { - final String TEST_NAME = "test511AddProtectedAccountCaseIgnore"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - testAddProtectedAccount(TEST_NAME, "xaxa"); - testAddProtectedAccount(TEST_NAME, "somebody-ADM"); - testAddProtectedAccount(TEST_NAME, "everybody-AdM"); + testAddProtectedAccount("xaxa"); + testAddProtectedAccount("somebody-ADM"); + testAddProtectedAccount("everybody-AdM"); } } 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 f93f189c57d..7ce0396340a 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 @@ -153,9 +153,6 @@ public void test400AddAccountElizabeth() throws Exception { */ @Test public void test410AssociateCrewWillElizabeth() throws Exception { - final String TEST_NAME = "test410AssociateCrewWillElizabeth"; - TestUtil.displayTestTitle(TEST_NAME); - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -172,7 +169,7 @@ public void test410AssociateCrewWillElizabeth() throws Exception { new OperationProvisioningScriptsType(), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); display("modifyObject result", result); TestUtil.assertSuccess(result); @@ -199,9 +196,6 @@ public void test410AssociateCrewWillElizabeth() throws Exception { */ @Test public void test419DisassociateCrewWillElizabeth() throws Exception { - final String TEST_NAME = "test419DisassociateCrewWillElizabeth"; - TestUtil.displayTestTitle(TEST_NAME); - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -218,7 +212,7 @@ public void test419DisassociateCrewWillElizabeth() throws Exception { new OperationProvisioningScriptsType(), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); display("modifyObject result", result); TestUtil.assertSuccess(result); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyLegacy.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyLegacy.java index 6c5cad67ebf..c9c3b37b2af 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyLegacy.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyLegacy.java @@ -12,7 +12,6 @@ import java.io.File; -import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; @@ -21,6 +20,7 @@ import org.w3c.dom.Element; import com.evolveum.icf.dummy.resource.DummyResource; +import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.provisioning.api.ProvisioningService; import com.evolveum.midpoint.schema.constants.ConnectorTestOperation; @@ -33,16 +33,12 @@ import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.IntegrationTestTools; -import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; import com.evolveum.midpoint.xml.ns._public.common.common_3.XmlSchemaType; /** * Test with legacy "ICF" schema. - * */ @ContextConfiguration(locations = "classpath:ctx-provisioning-test-main.xml") @DirtiesContext @@ -58,8 +54,6 @@ public class TestDummyLegacy extends AbstractIntegrationTest { private static final String RESOURCE_DUMMY_LEGACY_OID = "387a3400-4be6-11e5-b41a-001e8c717e5b"; private static final String RESOURCE_DUMMY_LEGACY_INSTANCE_ID = "legacy"; - private static final Trace LOGGER = TraceManager.getTrace(TestDummyLegacy.class); - private static final String OBJECTCLASS_NATIVE_ACCOUNT = "account"; private static final String OBJECTCLASS_NATIVE_GROUP = "group"; private static final String OBJECTCLASS_NATIVE_PRIVILEGE = "privilege"; @@ -78,7 +72,7 @@ public class TestDummyLegacy extends AbstractIntegrationTest { private static DummyResource dummyResourceLegacy; private DummyResourceContoller dummyResourceLegacyCtl; - @Autowired(required = true) + @Autowired private ProvisioningService provisioningService; @Override @@ -98,13 +92,10 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti dummyResourceLegacyCtl = DummyResourceContoller.create(RESOURCE_DUMMY_LEGACY_INSTANCE_ID); dummyResourceLegacyCtl.setResource(resourceLegacy); dummyResourceLegacy = dummyResourceLegacyCtl.getDummyResource(); -} + } @Test public void test100NativeIntegrity() throws Exception { - final String TEST_NAME = "test100NativeIntegrity"; - TestUtil.displayTestTitle(TEST_NAME); - display("Dummy resource instance", dummyResourceNative.toString()); assertNotNull("Resource is null", resourceNative); @@ -119,9 +110,6 @@ public void test100NativeIntegrity() throws Exception { @Test public void test103NativeTestResource() throws Exception { - final String TEST_NAME = "test103NativeTestResource"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -159,11 +147,8 @@ public void test103NativeTestResource() throws Exception { @Test public void test105NativeParsedSchema() throws Exception { - final String TEST_NAME = "test105NativeParsedSchema"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestDummyLegacy.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -188,15 +173,12 @@ public void test105NativeParsedSchema() throws Exception { @Test public void test200LegacyIntegrity() throws Exception { - final String TEST_NAME = "test200LegacyIntegrity"; - TestUtil.displayTestTitle(TEST_NAME); - display("Dummy resource instance", dummyResourceLegacy.toString()); assertNotNull("Resource is null", resourceLegacy); assertNotNull("ResourceType is null", resourceTypeLegacy); - Task task = taskManager.createTaskInstance(TestDummyLegacy.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ResourceType resource = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_LEGACY_OID, null, result) @@ -205,9 +187,6 @@ public void test200LegacyIntegrity() throws Exception { @Test public void test203LegacyTestResource() throws Exception { - final String TEST_NAME = "test203LegacyTestResource"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -245,11 +224,8 @@ public void test203LegacyTestResource() throws Exception { @Test public void test205LegacyParsedSchema() throws Exception { - final String TEST_NAME = "test205LegacyParsedSchema"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestDummyLegacy.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -274,12 +250,12 @@ public void test205LegacyParsedSchema() throws Exception { private void assertObjectClass(ResourceSchema schema, String objectClassLocalName) { ObjectClassComplexTypeDefinition ocDef = schema.findObjectClassDefinition(objectClassLocalName); - assertNotNull("No objectclass "+objectClassLocalName+" found in schema", ocDef); + assertNotNull("No objectclass " + objectClassLocalName + " found in schema", ocDef); } private void assertNoObjectClass(ResourceSchema schema, String objectClassLocalName) { ObjectClassComplexTypeDefinition ocDef = schema.findObjectClassDefinition(objectClassLocalName); - assertNull("Objectclass "+objectClassLocalName+" found in schema while not expecting it", ocDef); + assertNull("Objectclass " + objectClassLocalName + " found in schema while not expecting it", ocDef); } } diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyLimited.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyLimited.java index 1568690cf39..675d93a8937 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyLimited.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyLimited.java @@ -6,7 +6,6 @@ */ package com.evolveum.midpoint.provisioning.impl.dummy; -import static org.testng.AssertJUnit.assertNotNull; import static org.testng.AssertJUnit.assertNull; import static org.testng.AssertJUnit.assertTrue; @@ -96,11 +95,9 @@ protected String getLastModifierName(String expected) { @Test @Override public void test150DisableAccount() throws Exception { - final String TEST_NAME = "test150DisableAccount"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -137,17 +134,15 @@ public void test150DisableAccount() throws Exception { } @Override - public void test151SearchDisabledAccounts() throws Exception { + public void test151SearchDisabledAccounts() { // N/A } @Override public void test152ActivationStatusUndefinedAccount() throws Exception { - final String TEST_NAME = "test152ActivationStatusUndefinedAccount"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -187,11 +182,9 @@ public void test152ActivationStatusUndefinedAccount() throws Exception { @Test @Override public void test154EnableAccount() throws Exception { - final String TEST_NAME = "test154EnableAccount"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -229,23 +222,19 @@ public void test154EnableAccount() throws Exception { } @Override - public void test155SearchDisabledAccounts() throws Exception { + public void test155SearchDisabledAccounts() { // N/A } @Test @Override public void test156SetValidFrom() throws Exception { - final String TEST_NAME = "test156SetValidFrom"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); - long millis = VALID_FROM_MILLIS; - ObjectDelta delta = prismContext.deltaFactory().object().createModificationReplaceProperty(ShadowType.class, ACCOUNT_WILL_OID, SchemaConstants.PATH_ACTIVATION_VALID_FROM, XmlTypeConverter.createXMLGregorianCalendar(VALID_FROM_MILLIS)); @@ -282,16 +271,12 @@ public void test156SetValidFrom() throws Exception { @Test @Override public void test157SetValidTo() throws Exception { - final String TEST_NAME = "test157SetValidTo"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); - long millis = VALID_TO_MILLIS; - ObjectDelta delta = prismContext.deltaFactory().object().createModificationReplaceProperty(ShadowType.class, ACCOUNT_WILL_OID, SchemaConstants.PATH_ACTIVATION_VALID_TO, XmlTypeConverter.createXMLGregorianCalendar(VALID_TO_MILLIS)); @@ -327,11 +312,9 @@ public void test157SetValidTo() throws Exception { @Override public void test158DeleteValidToValidFrom() throws Exception { - final String TEST_NAME = "test158DeleteValidToValidFrom"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -378,23 +361,21 @@ public void test158DeleteValidToValidFrom() throws Exception { @Test @Override - public void test159GetLockedoutAccount() throws Exception { + public void test159GetLockedoutAccount() { // Not relevant } @Override - public void test160SearchLockedAccounts() throws Exception { + public void test160SearchLockedAccounts() { // N/A } @Test @Override public void test162UnlockAccount() throws Exception { - final String TEST_NAME = "test162UnlockAccount"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -417,7 +398,7 @@ public void test162UnlockAccount() throws Exception { // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); display("modifyObject result", result); TestUtil.assertFailure(result); @@ -445,13 +426,13 @@ protected Integer getTest18xApproxNumberOfSearchResults() { @Test @Override - public void test181SearchNullPagingOffset0Size3Desc() throws Exception { + public void test181SearchNullPagingOffset0Size3Desc() { // Nothing to do. No sorting support. So desc sorting won't work at all. } @Test @Override - public void test183SearchNullPagingOffset2Size3Desc() throws Exception { + public void test183SearchNullPagingOffset2Size3Desc() { // Nothing to do. No sorting support. So desc sorting won't work at all. } diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyNegative.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyNegative.java index abfca7c7cb1..89189cf44db 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyNegative.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyNegative.java @@ -6,9 +6,7 @@ */ package com.evolveum.midpoint.provisioning.impl.dummy; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.*; import java.io.File; @@ -30,8 +28,6 @@ import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.ObjectNotFoundException; import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; @@ -44,35 +40,32 @@ @DirtiesContext public class TestDummyNegative extends AbstractDummyTest { - private static final Trace LOGGER = TraceManager.getTrace(TestDummyNegative.class); - - private static final File ACCOUNT_ELAINE_RESOURCE_NOT_FOUND_FILE = new File(TEST_DIR, "account-elaine-resource-not-found.xml"); + private static final File ACCOUNT_ELAINE_RESOURCE_NOT_FOUND_FILE = + new File(TEST_DIR, "account-elaine-resource-not-found.xml"); @Test public void test110GetResourceBrokenSchemaNetwork() throws Exception { - testGetResourceBrokenSchema(BreakMode.NETWORK, "test110GetResourceBrokenSchemaNetwork"); + testGetResourceBrokenSchema(BreakMode.NETWORK); } @Test public void test111GetResourceBrokenSchemaGeneric() throws Exception { - testGetResourceBrokenSchema(BreakMode.GENERIC, "test111GetResourceBrokenSchemaGeneric"); + testGetResourceBrokenSchema(BreakMode.GENERIC); } @Test public void test112GetResourceBrokenSchemaIo() throws Exception { - testGetResourceBrokenSchema(BreakMode.IO, "test112GetResourceBrokenSchemaIO"); + testGetResourceBrokenSchema(BreakMode.IO); } @Test public void test113GetResourceBrokenSchemaRuntime() throws Exception { - testGetResourceBrokenSchema(BreakMode.RUNTIME, "test113GetResourceBrokenSchemaRuntime"); + testGetResourceBrokenSchema(BreakMode.RUNTIME); } - public void testGetResourceBrokenSchema(BreakMode breakMode, String testName) throws Exception { - TestUtil.displayTestTitle(testName); + public void testGetResourceBrokenSchema(BreakMode breakMode) throws Exception { // GIVEN - OperationResult result = new OperationResult(TestDummyNegative.class.getName() - + "."+testName); + OperationResult result = createResult(); // precondition PrismObject repoResource = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, result); @@ -155,12 +148,9 @@ public void test200AddAccountNullAttributes() throws Exception { @Test public void test201AddAccountEmptyAttributes() throws Exception { - TestUtil.displayTestTitle("test201AddAccountEmptyAttributes"); // GIVEN - Task task = taskManager.createTaskInstance(TestDummyNegative.class.getName() - + ".test201AddAccountEmptyAttributes"); - OperationResult result = new OperationResult(TestDummyNegative.class.getName() - + ".test201AddAccountEmptyAttributes"); + Task task = getTestTask(); + OperationResult result = getTestResult(); syncServiceMock.reset(); ShadowType accountType = parseObjectType(ACCOUNT_WILL_FILE, ShadowType.class); @@ -186,12 +176,9 @@ public void test201AddAccountEmptyAttributes() throws Exception { @Test public void test210AddAccountNoObjectclass() throws Exception { - TestUtil.displayTestTitle("test210AddAccountNoObjectclass"); // GIVEN - Task task = taskManager.createTaskInstance(TestDummyNegative.class.getName() - + ".test210AddAccountNoObjectclass"); - OperationResult result = new OperationResult(TestDummyNegative.class.getName() - + ".test210AddAccountNoObjectclass"); + Task task =getTestTask(); + OperationResult result = getTestResult(); syncServiceMock.reset(); ShadowType accountType = parseObjectType(ACCOUNT_WILL_FILE, ShadowType.class); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyParallelism.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyParallelism.java index ec8a899f9d3..c4af929d39e 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyParallelism.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyParallelism.java @@ -214,7 +214,7 @@ public void test200ParallelCreate() throws Exception { accountMorganOid = null; - ParallelTestThread[] threads = multithread(TEST_NAME, + ParallelTestThread[] threads = multithread( (i) -> { OperationResult localResult = task.getResult().createSubresult("thread-" + i); @@ -306,7 +306,7 @@ private PrismObject parallelModifyTest(final String TEST_NAME, Faila // WHEN when(TEST_NAME); - ParallelTestThread[] threads = multithread(TEST_NAME, + ParallelTestThread[] threads = multithread( (i) -> { OperationResult localResult = task.getResult().createSubresult("thread-" + i); @@ -364,7 +364,7 @@ public void test209ParallelDelete() throws Exception { when(TEST_NAME); Task task = getTestTask(); - ParallelTestThread[] threads = multithread(TEST_NAME, + ParallelTestThread[] threads = multithread( (i) -> { OperationResult localResult = task.getResult().createSubresult("thread-" + i); @@ -423,7 +423,7 @@ public void test210ParallelCreateSlow() throws Exception { // WHEN when(TEST_NAME); - ParallelTestThread[] threads = multithread(TEST_NAME, + ParallelTestThread[] threads = multithread( (i) -> { OperationResult localResult = task.getResult().createSubresult("thread-" + i); @@ -511,7 +511,7 @@ private PrismObject parallelModifyTestSlow(final String TEST_NAME, F // WHEN when(TEST_NAME); - ParallelTestThread[] threads = multithread(TEST_NAME, + ParallelTestThread[] threads = multithread( (i) -> { OperationResult localResult = task.getResult().createSubresult("thread-" + i); @@ -569,7 +569,7 @@ public void test229ParallelDeleteSlow() throws Exception { when(TEST_NAME); Task task = getTestTask(); - ParallelTestThread[] threads = multithread(TEST_NAME, + ParallelTestThread[] threads = multithread( (i) -> { OperationResult localResult = task.getResult().createSubresult("thread-" + i); @@ -644,7 +644,7 @@ public void test230ParallelGroupSearch() throws Exception { dummyResource.setOperationDelayRange(0); dummyResource.setSyncSearchHandlerStart(true); - ParallelTestThread[] threads = multithread(TEST_NAME, + ParallelTestThread[] threads = multithread( (i) -> { ObjectQuery query = createGroupNameQuery(GROUP_SCUM_NAME); @@ -744,7 +744,7 @@ public void test800ParallelReadAndModifyResource() throws Exception { long t0 = System.currentTimeMillis(); MutableBoolean readFinished = new MutableBoolean(); - ParallelTestThread[] threads = multithread(TEST_NAME, + ParallelTestThread[] threads = multithread( (threadIndex) -> { // roughly half the threads will try to mess with the resource diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyPrioritiesAndReadReplace.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyPrioritiesAndReadReplace.java index 355b1b9c202..36a48e894e9 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyPrioritiesAndReadReplace.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyPrioritiesAndReadReplace.java @@ -66,8 +66,6 @@ @Listeners({ com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class }) public class TestDummyPrioritiesAndReadReplace extends AbstractDummyTest { - private static final Trace LOGGER = TraceManager.getTrace(TestDummyPrioritiesAndReadReplace.class); - protected String willIcfUid; public static final File TEST_DIR = new File(TEST_DIR_DUMMY, "dummy-priorities-read-replace"); @@ -93,13 +91,9 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti // copied from TestDummy @Test public void test100AddAccount() throws Exception { - final String TEST_NAME = "test100AddAccount"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = taskManager.createTaskInstance(TestDummy.class.getName() - + "." + TEST_NAME); - OperationResult result = new OperationResult(TestDummy.class.getName() - + "." + TEST_NAME); + Task task = getTestTask(); + OperationResult result = task.getResult(); syncServiceMock.reset(); PrismObject account = prismContext.parseObject(getAccountWillFile()); @@ -176,11 +170,7 @@ public void test100AddAccount() throws Exception { @Test public void test123ModifyObjectReplace() throws Exception { - final String TEST_NAME = "test123ModifyObjectReplace"; - TestUtil.displayTestTitle(TEST_NAME); - - Task task = taskManager.createTaskInstance(TestDummyPrioritiesAndReadReplace.class.getName() - + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -273,11 +263,7 @@ private Collection parseUpdatedAttributes(String attributes) { @Test public void test150ModifyObjectAddDelete() throws Exception { - final String TEST_NAME = "test150ModifyObjectAddDelete"; - TestUtil.displayTestTitle(TEST_NAME); - - Task task = taskManager.createTaskInstance(TestDummyPrioritiesAndReadReplace.class.getName() - + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySchemaless.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySchemaless.java index 719a68665e9..6c0f979944c 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySchemaless.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySchemaless.java @@ -62,8 +62,6 @@ import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.CachingMetadataType; import com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilitiesType; import com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType; @@ -101,9 +99,6 @@ public class TestDummySchemaless extends AbstractProvisioningIntegrationTest { private static final File ACCOUNT_WILL_FILE = new File(TEST_DIR, "account-will.xml"); private static final String ACCOUNT_WILL_OID = "c0c010c0-d34d-b44f-f11d-33322212dddd"; - private static final String ACCOUNT_WILL_ICF_UID = "will"; - - private static final Trace LOGGER = TraceManager.getTrace(TestDummySchemaless.class); private PrismObject resourceSchemaless; private ResourceType resourceTypeSchemaless; @@ -113,7 +108,7 @@ public class TestDummySchemaless extends AbstractProvisioningIntegrationTest { private static DummyResource dummyResourceStaticSchema; private static DummyResourceContoller dummyResourceSchemalessCtl; - @Autowired(required = true) + @Autowired private ProvisioningService provisioningService; public TestDummySchemaless() { @@ -154,9 +149,6 @@ protected PrismObject getResource() { @Test public void test000Integrity() throws Exception { - final String TEST_NAME = "test000Integrity"; - TestUtil.displayTestTitle(TEST_NAME); - display("Dummy resource instance", dummyResourceSchemaless.toString()); assertNotNull("Resource is null", resourceSchemaless); @@ -187,8 +179,6 @@ public void test000Integrity() throws Exception { */ @Test public void test003ConnectionSchemaless() throws Exception { - final String TEST_NAME = "test003ConnectionSchemaless"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -229,10 +219,7 @@ public void test003ConnectionSchemaless() throws Exception { */ @Test public void test005ParsedSchemaSchemaless() throws Exception { - final String TEST_NAME = "test005ParsedSchemaSchemaless"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - OperationResult result = new OperationResult(TestDummySchemaless.class.getName() + "." + TEST_NAME); // THEN // The returned type should have the schema pre-parsed @@ -248,11 +235,8 @@ public void test005ParsedSchemaSchemaless() throws Exception { @Test public void test006GetObjectSchemaless() throws Exception { - final String TEST_NAME = "test006GetObjectSchemaless"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - OperationResult result = new OperationResult(TestDummySchemaless.class.getName() + "." + TEST_NAME); - + OperationResult result = createResult(); PrismObject resource = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_NO_SCHEMA_OID, null, null, result); assertNotNull("Resource is null", resource); ResourceType resourceType = resource.asObjectable(); @@ -262,10 +246,10 @@ public void test006GetObjectSchemaless() throws Exception { @Test public void test020ResourceStaticSchemaTest() throws Exception { - resourceStaticSchemaTest("test020ResourceStaticSchemaTest", 1); + resourceStaticSchemaTest(1); } - public void resourceStaticSchemaTest(final String TEST_NAME, int expectedConnectorInitCount) throws Exception { + public void resourceStaticSchemaTest(int expectedConnectorInitCount) throws Exception { // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -485,7 +469,7 @@ public void test040ReAddResourceStaticSchema() throws Exception { @Test public void test042ResourceStaticSchemaTestAgain() throws Exception { - resourceStaticSchemaTest("test042ResourceStaticSchemaTestAgain", 0); + resourceStaticSchemaTest(0); } /** @@ -506,8 +490,6 @@ public void test044ResourceStatciSchemaResourceAndConnectorCachingAgain() throws */ @Test public void test103ConnectionStaticSchema() throws Exception { - final String TEST_NAME = "test103ConnectionStaticSchema"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -547,10 +529,7 @@ public void test103ConnectionStaticSchema() throws Exception { */ @Test public void test105ParsedSchemaStaticSchema() throws Exception { - final String TEST_NAME = "test105ParsedSchemaStaticSchema"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - OperationResult result = new OperationResult(TestDummySchemaless.class.getName() + "." + TEST_NAME); // THEN // The returned type should have the schema pre-parsed @@ -567,10 +546,8 @@ public void test105ParsedSchemaStaticSchema() throws Exception { @Test public void test106GetObjectStaticSchema() throws Exception { - final String TEST_NAME = "test106GetObjectStaticSchema"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - OperationResult result = new OperationResult(TestDummySchemaless.class.getName() + "." + TEST_NAME); + OperationResult result = createResult(); PrismObject resource = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_STATIC_SCHEMA_OID, null, null, result); assertNotNull("Resource is null", resource); @@ -756,10 +733,8 @@ public void test107Capabilities() throws Exception { */ @Test public void test200AddAccount() throws Exception { - final String TEST_NAME = "test200AddAccount"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); + OperationResult result = createResult(); ShadowType account = parseObjectType(ACCOUNT_WILL_FILE, ShadowType.class); account.asPrismObject().checkConsistence(); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySecurity.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySecurity.java index 9d7f3656bf2..fd2efbd2ff7 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySecurity.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySecurity.java @@ -34,8 +34,6 @@ import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.util.exception.SecurityViolationException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationProvisioningScriptsType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; @@ -49,18 +47,13 @@ @DirtiesContext public class TestDummySecurity extends AbstractDummyTest { - private static final Trace LOGGER = TraceManager.getTrace(TestDummySecurity.class); private String willIcfUid; @Test public void test100AddAccountDrink() throws Exception { - final String TEST_NAME = "test100AddAccountDrink"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task syncTask = taskManager.createTaskInstance(TestDummySecurity.class.getName() - + "." + TEST_NAME); - OperationResult result = new OperationResult(TestDummySecurity.class.getName() - + "." + TEST_NAME); + Task syncTask = getTestTask(); + OperationResult result = getTestResult(); syncServiceMock.reset(); PrismObject account = prismContext.parseObject(ACCOUNT_WILL_FILE); @@ -75,12 +68,10 @@ public void test100AddAccountDrink() throws Exception { provisioningService.addObject(account, null, null, syncTask, result); AssertJUnit.fail("Unexpected success"); - } catch (SecurityViolationException e) { // This is expected display("Expected exception", e); } - } private void setAttribute(PrismObject account, String attrName, T val) throws SchemaException { @@ -93,13 +84,9 @@ private void setAttribute(PrismObject account, String attrName, @Test public void test199AddAccount() throws Exception { - final String TEST_NAME = "test199AddAccount"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task syncTask = taskManager.createTaskInstance(TestDummySecurity.class.getName() - + "." + TEST_NAME); - OperationResult result = new OperationResult(TestDummySecurity.class.getName() - + "." + TEST_NAME); + Task syncTask = getTestTask(); + OperationResult result = getTestResult(); syncServiceMock.reset(); PrismObject account = prismContext.parseObject(ACCOUNT_WILL_FILE); @@ -123,11 +110,7 @@ public void test199AddAccount() throws Exception { @Test public void test200ModifyAccountDrink() throws Exception { - final String TEST_NAME = "test200ModifyAccountDrink"; - TestUtil.displayTestTitle(TEST_NAME); - - Task task = taskManager.createTaskInstance(TestDummy.class.getName() - + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -157,11 +140,7 @@ public void test200ModifyAccountDrink() throws Exception { @Test public void test201ModifyAccountGossip() throws Exception { - final String TEST_NAME = "test201ModifyAccountGossip"; - TestUtil.displayTestTitle(TEST_NAME); - - Task task = taskManager.createTaskInstance(TestDummy.class.getName() - + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -191,11 +170,7 @@ public void test201ModifyAccountGossip() throws Exception { @Test public void test210ModifyAccountQuote() throws Exception { - final String TEST_NAME = "test210ModifyAccountQuote"; - TestUtil.displayTestTitle(TEST_NAME); - - Task task = taskManager.createTaskInstance(TestDummy.class.getName() - + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -222,11 +197,8 @@ public void test210ModifyAccountQuote() throws Exception { @Test public void test300GetAccount() throws Exception { - final String TEST_NAME = "test300GetAccount"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - OperationResult result = new OperationResult(TestDummy.class.getName() - + "." + TEST_NAME); + OperationResult result = createResult(); // WHEN PrismObject shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, null, result); @@ -240,18 +212,15 @@ public void test300GetAccount() throws Exception { assertNotNull("No dummy account", shadow); - checkAccountWill(shadow, result); + checkAccountWill(shadow); checkUniqueness(shadow); } @Test public void test310SearchAllShadows() throws Exception { - final String TEST_NAME = "test310SearchAllShadows"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - OperationResult result = new OperationResult(TestDummy.class.getName() - + "." + TEST_NAME); + OperationResult result = createResult(); ObjectQuery query = IntegrationTestTools.createAllShadowsQuery(resourceType, SchemaTestConstants.ICF_ACCOUNT_OBJECT_CLASS_LOCAL_NAME, prismContext); display("All shadows query", query); @@ -281,7 +250,7 @@ public void test310SearchAllShadows() throws Exception { // TODO: search - private void checkAccountWill(PrismObject shadow, OperationResult result) { + private void checkAccountWill(PrismObject shadow) { Collection> attributes = ShadowUtil.getAttributes(shadow); assertAttribute(shadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "Flying Dutchman"); assertAttribute(shadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "Sword", "LOVE"); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyUuidNonUniqueName.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyUuidNonUniqueName.java index 34034279e27..e3dc5771c71 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyUuidNonUniqueName.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyUuidNonUniqueName.java @@ -86,17 +86,13 @@ protected String getLastModifierName(String expected) { @Test public void test770AddAccountFettuciniAlfredo() throws Exception { - final String TEST_NAME = "test770AddAccountFettuciniAlfredo"; - TestUtil.displayTestTitle(TEST_NAME); - addFettucini(TEST_NAME, ACCOUNT_FETTUCINI_ALFREDO_FILE, ACCOUNT_FETTUCINI_ALFREDO_OID, ACCOUNT_FETTUCINI_ALFREDO_FULLNAME); + addFettucini(ACCOUNT_FETTUCINI_ALFREDO_FILE, ACCOUNT_FETTUCINI_ALFREDO_OID, ACCOUNT_FETTUCINI_ALFREDO_FULLNAME); searchFettucini(1); } @Test public void test772AddAccountFettuciniBill() throws Exception { - final String TEST_NAME = "test772AddAccountFettuciniBill"; - TestUtil.displayTestTitle(TEST_NAME); - addFettucini(TEST_NAME, ACCOUNT_FETTUCINI_BILL_FILE, ACCOUNT_FETTUCINI_BILL_OID, ACCOUNT_FETTUCINI_BILL_FULLNAME); + addFettucini(ACCOUNT_FETTUCINI_BILL_FILE, ACCOUNT_FETTUCINI_BILL_OID, ACCOUNT_FETTUCINI_BILL_FULLNAME); searchFettucini(2); } @@ -105,19 +101,17 @@ public void test772AddAccountFettuciniBill() throws Exception { */ @Test public void test774AddAccountFettuciniCarlo() throws Exception { - final String TEST_NAME = "test774AddAccountFettuciniCarlo"; - TestUtil.displayTestTitle(TEST_NAME); dummyResourceCtl.addAccount(ACCOUNT_FETTUCINI_NAME, ACCOUNT_FETTUCINI_CARLO_FULLNAME); searchFettucini(3); } @Override @Test - public void test600AddAccountAlreadyExist() throws Exception { + public void test600AddAccountAlreadyExist() { // DO nothing. This test is meaningless in non-unique environment } - private String addFettucini(final String TEST_NAME, File file, String oid, String expectedFullName) throws Exception { + private String addFettucini(File file, String oid, String expectedFullName) throws Exception { // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/manual/AbstractManualResourceTest.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/manual/AbstractManualResourceTest.java index ffad01ef3e3..d4799794fc7 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/manual/AbstractManualResourceTest.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/manual/AbstractManualResourceTest.java @@ -37,7 +37,6 @@ import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.provisioning.impl.AbstractProvisioningIntegrationTest; -import com.evolveum.midpoint.provisioning.impl.opendj.TestOpenDj; import com.evolveum.midpoint.schema.CapabilityUtil; import com.evolveum.midpoint.schema.GetOperationOptions; import com.evolveum.midpoint.schema.PointInTimeType; @@ -92,14 +91,11 @@ public abstract class AbstractManualResourceTest extends AbstractProvisioningInt protected static final String RESOURCE_MANUAL_OID = "8a8e19de-1a14-11e7-965f-6f995b457a8b"; protected static final File RESOURCE_SEMI_MANUAL_FILE = new File(TEST_DIR, "resource-semi-manual.xml"); - protected static final String RESOURCE_SEMI_MANUAL_OID = "8a8e19de-1a14-11e7-965f-6f995b457a8b"; public static final QName RESOURCE_ACCOUNT_OBJECTCLASS = new QName(MidPointConstants.NS_RI, "AccountObjectClass"); protected static final String MANUAL_CONNECTOR_TYPE = "ManualConnector"; - private static final Trace LOGGER = TraceManager.getTrace(AbstractManualResourceTest.class); - protected static final String NS_MANUAL_CONF = "http://midpoint.evolveum.com/xml/ns/public/connector/builtin-1/bundle/com.evolveum.midpoint.provisioning.ucf.impl.builtin/ManualConnector"; protected static final ItemName CONF_PROPERTY_DEFAULT_ASSIGNEE_QNAME = new ItemName(NS_MANUAL_CONF, "defaultAssignee"); @@ -163,14 +159,10 @@ protected boolean supportsBackingStore() { @Test public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; - TestUtil.displayTestTitle(TEST_NAME); - assertNotNull("Resource is null", resource); assertNotNull("ResourceType is null", resourceType); - OperationResult result = new OperationResult(AbstractManualResourceTest.class.getName() - + "." + TEST_NAME); + OperationResult result = createResult(); ResourceType repoResource = repositoryService.getObject(ResourceType.class, getResourceOid(), null, result).asObjectable(); @@ -188,8 +180,6 @@ public void test000Sanity() throws Exception { @Test public void test003Connection() throws Exception { - final String TEST_NAME = "test003Connection"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -241,11 +231,8 @@ public void test003Connection() throws Exception { @Test public void test004Configuration() throws Exception { - final String TEST_NAME = "test004Configuration"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - OperationResult result = new OperationResult(AbstractManualResourceTest.class.getName() - + "." + TEST_NAME); + OperationResult result = createResult(); // WHEN resource = provisioningService.getObject(ResourceType.class, getResourceOid(), null, null, result); @@ -266,10 +253,7 @@ public void test004Configuration() throws Exception { @Test public void test005ParsedSchema() throws Exception { - final String TEST_NAME = "test005ParsedSchema"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - OperationResult result = new OperationResult(AbstractManualResourceTest.class.getName() + "." + TEST_NAME); // THEN // The returned type should have the schema pre-parsed @@ -316,11 +300,8 @@ protected int getNumberOfAccountAttributeDefinitions() { @Test public void test006Capabilities() throws Exception { - final String TEST_NAME = "test006Capabilities"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestOpenDj.class.getName()+"."+TEST_NAME); + OperationResult result = createResult(); // WHEN ResourceType resource = provisioningService.getObject(ResourceType.class, getResourceOid(), null, null, result).asObjectable(); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjNegative.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjNegative.java index dd394529e1a..5747529310d 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjNegative.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjNegative.java @@ -138,11 +138,8 @@ public void test003Connection() throws Exception { @Test public void test004ResourceAndConnectorCaching() throws Exception { - TestUtil.displayTestTitle("test004ResourceAndConnectorCaching"); - - OperationResult result = new OperationResult(TestOpenDjNegative.class.getName()+".test004ResourceAndConnectorCaching"); - - Task task = taskManager.createTaskInstance(); + OperationResult result = createResult(); + Task task = createPlainTask(); // WHEN // This should NOT throw an exception. It should just indicate the failure in results resource = provisioningService.getObject(ResourceType.class,RESOURCE_OPENDJ_OID, null, task, result); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestSynchronization.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestSynchronization.java index 0ef479514be..459461e6b42 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestSynchronization.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestSynchronization.java @@ -7,16 +7,10 @@ package com.evolveum.midpoint.provisioning.impl.opendj; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.*; import java.io.File; -import com.evolveum.midpoint.schema.RepositoryQueryDiagRequest; -import com.evolveum.midpoint.schema.RepositoryQueryDiagResponse; -import com.evolveum.midpoint.schema.constants.SchemaConstants; -import com.evolveum.midpoint.util.QNameUtil; import org.opends.server.core.AddOperation; import org.opends.server.types.Entry; import org.opends.server.types.LDIFImportConfig; @@ -37,13 +31,17 @@ import com.evolveum.midpoint.provisioning.api.ResourceObjectShadowChangeDescription; import com.evolveum.midpoint.provisioning.impl.ProvisioningTestUtil; import com.evolveum.midpoint.provisioning.impl.mock.SynchronizationServiceMock; +import com.evolveum.midpoint.schema.RepositoryQueryDiagRequest; +import com.evolveum.midpoint.schema.RepositoryQueryDiagResponse; import com.evolveum.midpoint.schema.ResourceShadowDiscriminator; +import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.internals.InternalsConfig; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.util.TestUtil; +import com.evolveum.midpoint.util.QNameUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; @@ -65,10 +63,10 @@ public class TestSynchronization extends AbstractIntegrationTest { private ResourceType resourceType; - @Autowired(required=true) + @Autowired private ProvisioningService provisioningService; - @Autowired(required=true) + @Autowired private ResourceObjectChangeListener syncServiceMock; @BeforeClass @@ -77,9 +75,8 @@ public static void startLdap() throws Exception { } @AfterClass - public static void stopLdap() throws Exception { + public static void stopLdap() { openDJController.stop(); - } /* @@ -105,10 +102,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test010Sanity() throws Exception { - final String TEST_NAME = "test010Sanity"; - TestUtil.displayTestTitle(TEST_NAME); - final OperationResult result = new OperationResult(TestSynchronization.class.getName() - + "." + TEST_NAME); + final OperationResult result = createResult(); // WHEN PrismObject resource = provisioningService.getObject(ResourceType.class, resourceType.getOid(), null, taskManager.createTaskInstance(), result); @@ -132,17 +126,14 @@ public void test010Sanity() throws Exception { @Test public void test100SyncAddWill() throws Exception { - final String TEST_NAME = "test100SyncAddWill"; - TestUtil.displayTestTitle(TEST_NAME); - final OperationResult result = new OperationResult(TestSynchronization.class.getName() - + "." + TEST_NAME); + final OperationResult result = createResult(); Task syncTask = taskManager.getTask(SYNC_TASK_OID, result); AssertJUnit.assertNotNull(syncTask); assertSyncToken(syncTask, 0, result); - ((SynchronizationServiceMock)syncServiceMock).reset(); + ((SynchronizationServiceMock) syncServiceMock).reset(); - // create add change in embeded LDAP + // create add change in embedded LDAP LDIFImportConfig importConfig = new LDIFImportConfig(LDIF_WILL_FILE.getPath()); LDIFReader ldifReader = new LDIFReader(importConfig); Entry entry = ldifReader.readEntry(); @@ -183,26 +174,23 @@ public void test100SyncAddWill() throws Exception { .qNameToUri(SchemaConstants.SYNC_TOKEN) + "'"); RepositoryQueryDiagResponse valueResponse = repositoryService.executeQueryDiagnostics(valueRequest, result); System.out.println(valueResponse.getQueryResult()); - assertTrue("Unexpected repo query result on sync token: "+ valueResponse.getQueryResult(), valueResponse.getQueryResult().isEmpty()); + assertTrue("Unexpected repo query result on sync token: " + valueResponse.getQueryResult(), valueResponse.getQueryResult().isEmpty()); RepositoryQueryDiagRequest dictionaryRequest = new RepositoryQueryDiagRequest(); dictionaryRequest.setImplementationLevelQuery("select RExtItem i where i.name='" + QNameUtil.qNameToUri(SchemaConstants.SYNC_TOKEN) + "'"); RepositoryQueryDiagResponse dictionaryResponse = repositoryService.executeQueryDiagnostics(valueRequest, result); System.out.println(dictionaryResponse.getQueryResult()); - assertTrue("Unexpected repo query result on sync token definition: "+ dictionaryResponse.getQueryResult(), dictionaryResponse.getQueryResult().isEmpty()); + assertTrue("Unexpected repo query result on sync token definition: " + dictionaryResponse.getQueryResult(), dictionaryResponse.getQueryResult().isEmpty()); } @Test public void test500SyncAddProtected() throws Exception { - final String TEST_NAME = "test500SyncAddProtected"; - TestUtil.displayTestTitle(TEST_NAME); - final OperationResult result = new OperationResult(TestSynchronization.class.getName() - + "." + TEST_NAME); + final OperationResult result = createResult(); Task syncTask = taskManager.getTask(SYNC_TASK_OID, result); AssertJUnit.assertNotNull(syncTask); assertSyncToken(syncTask, 1, result); - ((SynchronizationServiceMock)syncServiceMock).reset(); + ((SynchronizationServiceMock) syncServiceMock).reset(); // create add change in embedded LDAP LDIFImportConfig importConfig = new LDIFImportConfig(LDIF_CALYPSO_FILE.getPath()); diff --git a/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/AbstractUcfDummyTest.java b/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/AbstractUcfDummyTest.java index 70b693ce1db..e0eab1fe6d3 100644 --- a/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/AbstractUcfDummyTest.java +++ b/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/AbstractUcfDummyTest.java @@ -27,6 +27,7 @@ import com.evolveum.midpoint.schema.SchemaConstantsGenerated; import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.processor.ResourceSchema; +import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.util.AbstractSpringTest; import com.evolveum.midpoint.util.PrettyPrinter; @@ -83,6 +84,9 @@ public void setup() throws Exception { connectorType = connector.asObjectable(); } + protected OperationResult createResult() { + return new OperationResult(contextName()); + } protected void assertPropertyDefinition(PrismContainer container, String propName, QName xsdType, int minOccurs, int maxOccurs) { diff --git a/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/TestUcfDummy.java b/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/TestUcfDummy.java index 2a792f38265..2060849a0ad 100644 --- a/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/TestUcfDummy.java +++ b/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/TestUcfDummy.java @@ -6,22 +6,16 @@ */ package com.evolveum.midpoint.provisioning.ucf.impl.connid; +import static org.testng.AssertJUnit.*; + import static com.evolveum.midpoint.test.IntegrationTestTools.display; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Set; - import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.impl.schema.PrismSchemaImpl; -import com.evolveum.midpoint.schema.processor.*; -import com.evolveum.midpoint.util.exception.*; import org.springframework.test.context.ContextConfiguration; import org.testng.AssertJUnit; import org.testng.annotations.Test; @@ -30,14 +24,8 @@ import com.evolveum.icf.dummy.connector.DummyConnector; import com.evolveum.icf.dummy.resource.DummyAccount; import com.evolveum.icf.dummy.resource.DummySyncStyle; -import com.evolveum.midpoint.prism.Item; -import com.evolveum.midpoint.prism.PrismContainer; -import com.evolveum.midpoint.prism.PrismContainerDefinition; -import com.evolveum.midpoint.prism.PrismContainerValue; -import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.PrismObjectDefinition; -import com.evolveum.midpoint.prism.PrismProperty; -import com.evolveum.midpoint.prism.PrismPropertyDefinition; +import com.evolveum.midpoint.prism.*; +import com.evolveum.midpoint.prism.impl.schema.PrismSchemaImpl; import com.evolveum.midpoint.prism.schema.PrismSchema; import com.evolveum.midpoint.prism.schema.SchemaRegistry; import com.evolveum.midpoint.prism.util.PrismAsserts; @@ -46,6 +34,7 @@ import com.evolveum.midpoint.provisioning.ucf.api.ShadowResultHandler; import com.evolveum.midpoint.schema.SchemaConstantsGenerated; import com.evolveum.midpoint.schema.constants.SchemaConstants; +import com.evolveum.midpoint.schema.processor.*; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus; import com.evolveum.midpoint.schema.util.ObjectTypeUtil; @@ -54,51 +43,36 @@ import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorConfigurationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; /** * Simple UCF tests. No real resource, just basic setup and sanity. - * - * @author Radovan Semancik - * + *

* This is an UCF test. It shold not need repository or other things from the midPoint spring context * except from the provisioning beans. But due to a general issue with spring context initialization * this is a lesser evil for now (MID-392) + * + * @author Radovan Semancik */ @ContextConfiguration(locations = { "classpath:ctx-ucf-connid-test.xml" }) public class TestUcfDummy extends AbstractUcfDummyTest { - private static final Trace LOGGER = TraceManager.getTrace(TestUcfDummy.class); - @Test - public void test000PrismContextSanity() throws Exception { - final String TEST_NAME = "test000PrismContextSanity"; - TestUtil.displayTestTitle(TEST_NAME); - + public void test000PrismContextSanity() { SchemaRegistry schemaRegistry = PrismTestUtil.getPrismContext().getSchemaRegistry(); PrismSchema schemaIcfc = schemaRegistry.findSchemaByNamespace(SchemaConstants.NS_ICF_CONFIGURATION); - assertNotNull("ICFC schema not found in the context ("+SchemaConstants.NS_ICF_CONFIGURATION+")", schemaIcfc); + assertNotNull("ICFC schema not found in the context (" + SchemaConstants.NS_ICF_CONFIGURATION + ")", schemaIcfc); PrismContainerDefinition configurationPropertiesDef = - schemaIcfc.findContainerDefinitionByElementName(SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME); - assertNotNull("icfc:configurationProperties not found in icfc schema ("+ - SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME+")", configurationPropertiesDef); + schemaIcfc.findContainerDefinitionByElementName(SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME); + assertNotNull("icfc:configurationProperties not found in icfc schema (" + + SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME + ")", configurationPropertiesDef); PrismSchema schemaIcfs = schemaRegistry.findSchemaByNamespace(SchemaConstants.NS_ICF_SCHEMA); - assertNotNull("ICFS schema not found in the context ("+SchemaConstants.NS_ICF_SCHEMA+")", schemaIcfs); + assertNotNull("ICFS schema not found in the context (" + SchemaConstants.NS_ICF_SCHEMA + ")", schemaIcfs); } @Test - public void test001ResourceSanity() throws Exception { - final String TEST_NAME = "test001ResourceSanity"; - TestUtil.displayTestTitle(TEST_NAME); - + public void test001ResourceSanity() { display("Resource", resource); assertEquals("Wrong oid", "ef2bc95b-76e0-59e2-86d6-9999dddddddd", resource.getOid()); @@ -117,21 +91,18 @@ public void test001ResourceSanity() throws Exception { PrismContainer configurationContainer = resource.findContainer(ResourceType.F_CONNECTOR_CONFIGURATION); assertContainerDefinition(configurationContainer, "configuration", ConnectorConfigurationType.COMPLEX_TYPE, 1, 1); PrismContainerValue configContainerValue = configurationContainer.getValue(); - Collection> configItems = configContainerValue.getItems(); + Collection> configItems = configContainerValue.getItems(); assertEquals("Wrong number of config items", 2, configItems.size()); PrismContainer dummyConfigPropertiesContainer = configurationContainer.findContainer( SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME); assertNotNull("No icfc:configurationProperties container", dummyConfigPropertiesContainer); - Collection> dummyConfigPropItems = dummyConfigPropertiesContainer.getValue().getItems(); + Collection> dummyConfigPropItems = dummyConfigPropertiesContainer.getValue().getItems(); assertEquals("Wrong number of dummy ConfigPropItems items", 4, dummyConfigPropItems.size()); } @Test public void test002ConnectorSchema() throws Exception { - final String TEST_NAME = "test002ConnectorSchema"; - TestUtil.displayTestTitle(TEST_NAME); - PrismSchema connectorSchema = connectorFactory.generateConnectorConfigurationSchema(connectorType); IntegrationTestTools.assertConnectorSchemaSanity(connectorSchema, "generated", true); assertEquals("Unexpected number of definitions", 3, connectorSchema.getDefinitions().size()); @@ -141,7 +112,7 @@ public void test002ConnectorSchema() throws Exception { display("Serialized XSD connector schema", DOMUtil.serializeDOMToString(xsdSchemaDom)); // Try to re-parse - PrismSchema reparsedConnectorSchema = PrismSchemaImpl.parse(DOMUtil.getFirstChildElement(xsdSchemaDom), true, "schema fetched from "+cc, PrismTestUtil.getPrismContext()); + PrismSchema reparsedConnectorSchema = PrismSchemaImpl.parse(DOMUtil.getFirstChildElement(xsdSchemaDom), true, "schema fetched from " + cc, PrismTestUtil.getPrismContext()); IntegrationTestTools.assertConnectorSchemaSanity(reparsedConnectorSchema, "re-parsed", true); // TODO: 3 definitions would be cleaner. But we can live with this assertEquals("Unexpected number of definitions in re-parsed schema", 6, reparsedConnectorSchema.getDefinitions().size()); @@ -150,14 +121,10 @@ public void test002ConnectorSchema() throws Exception { /** * Test listing connectors. Very simple. Just test that the list is * non-empty and that there are mandatory values filled in. - * @throws CommunicationException */ @Test public void test010ListConnectors() throws Exception { - final String TEST_NAME = "test010ListConnectors"; - TestUtil.displayTestTitle(TEST_NAME); - - OperationResult result = new OperationResult(TestUcfDummy.class+"."+TEST_NAME); + OperationResult result = createResult(); Set connectors = connectorFactory.listConnectors(null, result); System.out.println("---------------------------------------------------------------------"); @@ -180,14 +147,11 @@ public void test010ListConnectors() throws Exception { @Test public void test020CreateConfiguredConnector() throws Exception { - final String TEST_NAME = "test020CreateConfiguredConnector"; - TestUtil.displayTestTitle(TEST_NAME); - cc = connectorFactory.createConnectorInstance(connectorType, ResourceTypeUtil.getResourceNamespace(resourceType), "dummy", "description of dummy test connector instance"); assertNotNull("Failed to instantiate connector", cc); - OperationResult result = new OperationResult(TestUcfDummy.class.getName() + "." + TEST_NAME); + OperationResult result = createResult(); PrismContainerValue configContainer = resourceType.getConnectorConfiguration().asPrismContainerValue(); display("Configuration container", configContainer); @@ -201,9 +165,6 @@ public void test020CreateConfiguredConnector() throws Exception { @Test public void test022ConnectorStatsConfigured() throws Exception { - final String TEST_NAME = "test022ConnectorStatsConfigured"; - TestUtil.displayTestTitle(TEST_NAME); - // WHEN ConnectorOperationalStatus operationalStatus = cc.getOperationalStatus(); @@ -213,21 +174,18 @@ public void test022ConnectorStatsConfigured() throws Exception { assertEquals("Wrong connectorClassName", DummyConnector.class.getName(), operationalStatus.getConnectorClassName()); assertEquals("Wrong poolConfigMinSize", null, operationalStatus.getPoolConfigMinSize()); - assertEquals("Wrong poolConfigMaxSize", (Integer)10, operationalStatus.getPoolConfigMaxSize()); - assertEquals("Wrong poolConfigMinIdle", (Integer)1, operationalStatus.getPoolConfigMinIdle()); - assertEquals("Wrong poolConfigMaxIdle", (Integer)10, operationalStatus.getPoolConfigMaxIdle()); - assertEquals("Wrong poolConfigWaitTimeout", (Long)150000L, operationalStatus.getPoolConfigWaitTimeout()); - assertEquals("Wrong poolConfigMinEvictableIdleTime", (Long)120000L, operationalStatus.getPoolConfigMinEvictableIdleTime()); - assertEquals("Wrong poolStatusNumIdle", (Integer)0, operationalStatus.getPoolStatusNumIdle()); - assertEquals("Wrong poolStatusNumActive", (Integer)0, operationalStatus.getPoolStatusNumActive()); + assertEquals("Wrong poolConfigMaxSize", (Integer) 10, operationalStatus.getPoolConfigMaxSize()); + assertEquals("Wrong poolConfigMinIdle", (Integer) 1, operationalStatus.getPoolConfigMinIdle()); + assertEquals("Wrong poolConfigMaxIdle", (Integer) 10, operationalStatus.getPoolConfigMaxIdle()); + assertEquals("Wrong poolConfigWaitTimeout", (Long) 150000L, operationalStatus.getPoolConfigWaitTimeout()); + assertEquals("Wrong poolConfigMinEvictableIdleTime", (Long) 120000L, operationalStatus.getPoolConfigMinEvictableIdleTime()); + assertEquals("Wrong poolStatusNumIdle", (Integer) 0, operationalStatus.getPoolStatusNumIdle()); + assertEquals("Wrong poolStatusNumActive", (Integer) 0, operationalStatus.getPoolStatusNumActive()); } @Test public void test030ResourceSchema() throws Exception { - final String TEST_NAME = "test030ResourceSchema"; - TestUtil.displayTestTitle(TEST_NAME); - - OperationResult result = new OperationResult(TestUcfDummy.class + "." + TEST_NAME); + OperationResult result = createResult(); cc = connectorFactory.createConnectorInstance(connectorType, ResourceTypeUtil.getResourceNamespace(resourceType), "dummy", @@ -263,10 +221,7 @@ public void test030ResourceSchema() throws Exception { @Test public void test031ResourceSchemaAccountObjectClass() throws Exception { - final String TEST_NAME = "test031ResourceSchemaAccountObjectClass"; - TestUtil.displayTestTitle(TEST_NAME); - - OperationResult result = new OperationResult(TestUcfDummy.class + "." + TEST_NAME); + OperationResult result = createResult(); cc = connectorFactory.createConnectorInstance(connectorType, ResourceTypeUtil.getResourceNamespace(resourceType), "dummy", @@ -281,7 +236,6 @@ public void test031ResourceSchemaAccountObjectClass() throws Exception { cc.configure(configContainer, objectClassesToGenerate, result); - // WHEN resourceSchema = cc.fetchResourceSchema(result); @@ -296,9 +250,6 @@ public void test031ResourceSchemaAccountObjectClass() throws Exception { @Test public void test033ConnectorStatsInitialized() throws Exception { - final String TEST_NAME = "test033ConnectorStatsInitialized"; - TestUtil.displayTestTitle(TEST_NAME); - // WHEN ConnectorOperationalStatus operationalStatus = cc.getOperationalStatus(); @@ -308,19 +259,18 @@ public void test033ConnectorStatsInitialized() throws Exception { assertEquals("Wrong connectorClassName", DummyConnector.class.getName(), operationalStatus.getConnectorClassName()); assertEquals("Wrong poolConfigMinSize", null, operationalStatus.getPoolConfigMinSize()); - assertEquals("Wrong poolConfigMaxSize", (Integer)10, operationalStatus.getPoolConfigMaxSize()); - assertEquals("Wrong poolConfigMinIdle", (Integer)1, operationalStatus.getPoolConfigMinIdle()); - assertEquals("Wrong poolConfigMaxIdle", (Integer)10, operationalStatus.getPoolConfigMaxIdle()); - assertEquals("Wrong poolConfigWaitTimeout", (Long)150000L, operationalStatus.getPoolConfigWaitTimeout()); - assertEquals("Wrong poolConfigMinEvictableIdleTime", (Long)120000L, operationalStatus.getPoolConfigMinEvictableIdleTime()); - assertEquals("Wrong poolStatusNumIdle", (Integer)1, operationalStatus.getPoolStatusNumIdle()); - assertEquals("Wrong poolStatusNumActive", (Integer)0, operationalStatus.getPoolStatusNumActive()); + assertEquals("Wrong poolConfigMaxSize", (Integer) 10, operationalStatus.getPoolConfigMaxSize()); + assertEquals("Wrong poolConfigMinIdle", (Integer) 1, operationalStatus.getPoolConfigMinIdle()); + assertEquals("Wrong poolConfigMaxIdle", (Integer) 10, operationalStatus.getPoolConfigMaxIdle()); + assertEquals("Wrong poolConfigWaitTimeout", (Long) 150000L, operationalStatus.getPoolConfigWaitTimeout()); + assertEquals("Wrong poolConfigMinEvictableIdleTime", (Long) 120000L, operationalStatus.getPoolConfigMinEvictableIdleTime()); + assertEquals("Wrong poolStatusNumIdle", (Integer) 1, operationalStatus.getPoolStatusNumIdle()); + assertEquals("Wrong poolStatusNumActive", (Integer) 0, operationalStatus.getPoolStatusNumActive()); } @Test public void test040AddAccount() throws Exception { final String TEST_NAME = "test040AddAccount"; - TestUtil.displayTestTitle(this, TEST_NAME); OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME); @@ -342,15 +292,13 @@ public void test040AddAccount() throws Exception { // THEN DummyAccount dummyAccount = dummyResource.getAccountByUsername(ACCOUNT_JACK_USERNAME); - assertNotNull("Account "+ACCOUNT_JACK_USERNAME+" was not created", dummyAccount); - assertNotNull("Account "+ACCOUNT_JACK_USERNAME+" has no username", dummyAccount.getName()); + assertNotNull("Account " + ACCOUNT_JACK_USERNAME + " was not created", dummyAccount); + assertNotNull("Account " + ACCOUNT_JACK_USERNAME + " has no username", dummyAccount.getName()); } @Test public void test050Search() throws Exception { - final String TEST_NAME = "test050Search"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN final ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT); @@ -369,7 +317,7 @@ public boolean handle(PrismObject shadow) { } }; - OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME); + OperationResult result = createResult(); // WHEN cc.search(accountDefinition, null, handler, null, null, null, null, result); @@ -379,17 +327,16 @@ public boolean handle(PrismObject shadow) { } private void checkUcfShadow(PrismObject shadow, ObjectClassComplexTypeDefinition objectClassDefinition) { - assertNotNull("No objectClass in shadow "+shadow, shadow.asObjectable().getObjectClass()); - assertEquals("Wrong objectClass in shadow "+shadow, objectClassDefinition.getTypeName(), shadow.asObjectable().getObjectClass()); + assertNotNull("No objectClass in shadow " + shadow, shadow.asObjectable().getObjectClass()); + assertEquals("Wrong objectClass in shadow " + shadow, objectClassDefinition.getTypeName(), shadow.asObjectable().getObjectClass()); Collection> attributes = ShadowUtil.getAttributes(shadow); - assertNotNull("No attributes in shadow "+shadow, attributes); - assertFalse("Empty attributes in shadow "+shadow, attributes.isEmpty()); + assertNotNull("No attributes in shadow " + shadow, attributes); + assertFalse("Empty attributes in shadow " + shadow, attributes.isEmpty()); } @Test public void test100FetchEmptyChanges() throws Exception { final String TEST_NAME = "test100FetchEmptyChanges"; - TestUtil.displayTestTitle(this, TEST_NAME); OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME); ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT); @@ -417,7 +364,6 @@ public void test100FetchEmptyChanges() throws Exception { @Test public void test101FetchAddChange() throws Exception { final String TEST_NAME = "test101FetchAddChange"; - TestUtil.displayTestTitle(this, TEST_NAME); OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME); ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT); @@ -451,9 +397,8 @@ public void test101FetchAddChange() throws Exception { } @Test - public void test500SelfTest() throws Exception { + public void test500SelfTest() { final String TEST_NAME = "test500SelfTest"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN OperationResult testResult = new OperationResult(TestUcfDummy.class + "." + TEST_NAME); diff --git a/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/TestUcfDummyMulti.java b/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/TestUcfDummyMulti.java index c126d877e32..5ddb1efa7da 100644 --- a/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/TestUcfDummyMulti.java +++ b/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/TestUcfDummyMulti.java @@ -22,7 +22,6 @@ import com.evolveum.midpoint.prism.PrismContainerDefinition; import com.evolveum.midpoint.prism.PrismContainerValue; import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.prism.schema.PrismSchema; import com.evolveum.midpoint.prism.schema.SchemaRegistry; import com.evolveum.midpoint.prism.util.PrismTestUtil; @@ -59,10 +58,7 @@ public class TestUcfDummyMulti extends AbstractUcfDummyTest { private static final Trace LOGGER = TraceManager.getTrace(TestUcfDummyMulti.class); @Test - public void test000PrismContextSanity() throws Exception { - final String TEST_NAME = "test000PrismContextSanity"; - TestUtil.displayTestTitle(TEST_NAME); - + public void test000PrismContextSanity() { SchemaRegistry schemaRegistry = PrismTestUtil.getPrismContext().getSchemaRegistry(); PrismSchema schemaIcfc = schemaRegistry.findSchemaByNamespace(SchemaConstants.NS_ICF_CONFIGURATION); assertNotNull("ICFC schema not found in the context ("+SchemaConstants.NS_ICF_CONFIGURATION+")", schemaIcfc); @@ -76,15 +72,12 @@ public void test000PrismContextSanity() throws Exception { @Test public void test020CreateConfiguredConnector() throws Exception { - final String TEST_NAME = "test020CreateConfiguredConnector"; - TestUtil.displayTestTitle(TEST_NAME); - cc = connectorFactory.createConnectorInstance(connectorType, ResourceTypeUtil.getResourceNamespace(resourceType), "dummy", "description of dummy test connector instance"); assertNotNull("Failed to instantiate connector", cc); - OperationResult result = new OperationResult(TestUcfDummyMulti.class.getName() + "." + TEST_NAME); + OperationResult result = createResult(); PrismContainerValue configContainer = resourceType.getConnectorConfiguration().asPrismContainerValue(); display("Configuration container", configContainer); @@ -102,7 +95,6 @@ public void test020CreateConfiguredConnector() throws Exception { @Test public void test100AddAccount() throws Exception { final String TEST_NAME = "test100AddAccount"; - TestUtil.displayTestTitle(this, TEST_NAME); OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME); @@ -131,8 +123,6 @@ public void test100AddAccount() throws Exception { @Test public void test110SearchNonBlocking() throws Exception { - final String TEST_NAME = "test100SearchNonBlocking"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN final ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT); @@ -151,7 +141,7 @@ public boolean handle(PrismObject shadow) { } }; - OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME); + OperationResult result = createResult(); // WHEN cc.search(accountDefinition, null, handler, null, null, null, null, result); @@ -167,11 +157,9 @@ public boolean handle(PrismObject shadow) { @Test public void test200BlockingSearch() throws Exception { - final String TEST_NAME = "test200BlockingSearch"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - final OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME); + OperationResult result = createResult(); final ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT); // Determine object class from the schema @@ -236,15 +224,13 @@ public void run() { @Test public void test210TwoBlockingSearches() throws Exception { - final String TEST_NAME = "test210TwoBlockingSearches"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN final ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT); // Determine object class from the schema - final OperationResult result1 = new OperationResult(this.getClass().getName() + "." + TEST_NAME); + OperationResult result1 = createResult(); final List> searchResults1 = new ArrayList<>(); final ShadowResultHandler handler1 = new ShadowResultHandler() { @Override @@ -255,7 +241,7 @@ public boolean handle(PrismObject shadow) { } }; - final OperationResult result2 = new OperationResult(this.getClass().getName() + "." + TEST_NAME); + OperationResult result2 = createResult(); final List> searchResults2 = new ArrayList<>(); final ShadowResultHandler handler2 = new ShadowResultHandler() { @Override diff --git a/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/TestUcfOpenDj.java b/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/TestUcfOpenDj.java index 1ba8c8c3920..2dfa807d31a 100644 --- a/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/TestUcfOpenDj.java +++ b/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/TestUcfOpenDj.java @@ -6,11 +6,35 @@ */ package com.evolveum.midpoint.provisioning.ucf.impl.connid; +import static org.testng.AssertJUnit.*; + +import static com.evolveum.midpoint.test.IntegrationTestTools.assertNotEmpty; +import static com.evolveum.midpoint.test.IntegrationTestTools.display; + +import java.io.File; +import java.io.IOException; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import javax.xml.namespace.QName; + +import org.identityconnectors.framework.common.objects.Name; +import org.identityconnectors.framework.common.objects.Uid; +import org.opends.server.types.Entry; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.testng.Assert; +import org.testng.AssertJUnit; +import org.testng.annotations.*; +import org.w3c.dom.Document; +import org.xml.sax.SAXException; + import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.crypto.Protector; import com.evolveum.midpoint.prism.delta.PropertyDelta; -import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.path.ItemName; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.schema.PrismSchema; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; @@ -24,49 +48,23 @@ import com.evolveum.midpoint.schema.processor.*; import com.evolveum.midpoint.schema.result.AsynchronousOperationReturnValue; import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.schema.util.ShadowUtil; -import com.evolveum.midpoint.schema.util.SchemaDebugUtil; import com.evolveum.midpoint.schema.util.ResourceTypeUtil; +import com.evolveum.midpoint.schema.util.SchemaDebugUtil; +import com.evolveum.midpoint.schema.util.ShadowUtil; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.ldap.OpenDJController; import com.evolveum.midpoint.test.util.AbstractSpringTest; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.*; +import com.evolveum.midpoint.util.exception.ObjectNotFoundException; +import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType; import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.PagedSearchCapabilityType; -import com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType; -import com.evolveum.prism.xml.ns._public.types_3.ItemPathType; -import com.evolveum.prism.xml.ns._public.types_3.ModificationTypeType; -import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; -import com.evolveum.prism.xml.ns._public.types_3.RawType; - -import org.identityconnectors.framework.common.objects.Name; -import org.identityconnectors.framework.common.objects.Uid; -import org.opends.server.types.Entry; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.testng.Assert; -import org.testng.AssertJUnit; -import org.testng.annotations.*; -import org.w3c.dom.Document; -import org.xml.sax.SAXException; - -import javax.xml.namespace.QName; - -import java.io.File; -import java.io.IOException; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import static com.evolveum.midpoint.test.IntegrationTestTools.*; -import static org.testng.AssertJUnit.*; +import com.evolveum.prism.xml.ns._public.types_3.*; /** * Test UCF implementation with OpenDJ and ICF LDAP connector. @@ -76,11 +74,11 @@ * * @author Radovan Semancik * @author Katka Valalikova - *

- * This is an UCF test. It shold not need repository or other things - * from the midPoint spring context except from the provisioning beans. - * But due to a general issue with spring context initialization this is - * a lesser evil for now (MID-392) + *

+ * This is an UCF test. It shold not need repository or other things + * from the midPoint spring context except from the provisioning beans. + * But due to a general issue with spring context initialization this is + * a lesser evil for now (MID-392) */ @ContextConfiguration(locations = { "classpath:ctx-ucf-connid-test.xml" }) public class TestUcfOpenDj extends AbstractSpringTest { @@ -132,8 +130,6 @@ public static void stopLdap() { @BeforeMethod public void initUcf() throws Exception { - TestUtil.displayTestTitle("initUcf"); - // Resource PrismObject resource = PrismTestUtil.parseObject(RESOURCE_OPENDJ_FILE); resourceType = resource.asObjectable(); @@ -169,48 +165,38 @@ public void initUcf() throws Exception { } @AfterMethod - public void shutdownUcf() throws Exception { + public void shutdownUcf() { } - @Test - public void test010ConnectorSchemaSanity() throws Exception { - final String TEST_NAME = "test010ConnectorSchemaSanity"; - TestUtil.displayTestTitle(TEST_NAME); - + public void test010ConnectorSchemaSanity() { IntegrationTestTools.assertConnectorSchemaSanity(connectorSchema, "LDAP connector", true); PrismContainerDefinition configurationDefinition = connectorSchema.findItemDefinition(ResourceType.F_CONNECTOR_CONFIGURATION.getLocalPart(), PrismContainerDefinition.class); PrismContainerDefinition configurationPropertiesDefinition = - configurationDefinition.findContainerDefinition(SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME); + configurationDefinition.findContainerDefinition(SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME); - PrismPropertyDefinition propHost = configurationPropertiesDefinition.findPropertyDefinition(new ItemName(UcfTestUtil.CONNECTOR_LDAP_NS,"host")); + PrismPropertyDefinition propHost = configurationPropertiesDefinition.findPropertyDefinition(new ItemName(UcfTestUtil.CONNECTOR_LDAP_NS, "host")); assertNotNull("No definition for configuration property 'host' in connector schema", propHost); - PrismAsserts.assertDefinition(propHost, new QName(UcfTestUtil.CONNECTOR_LDAP_NS,"host"), DOMUtil.XSD_STRING, 1, 1); + PrismAsserts.assertDefinition(propHost, new QName(UcfTestUtil.CONNECTOR_LDAP_NS, "host"), DOMUtil.XSD_STRING, 1, 1); assertEquals("Wrong property 'host' display name", "Host", propHost.getDisplayName()); assertEquals("Wrong property 'host' help", "The name or IP address of the LDAP server host.", propHost.getHelp()); - assertEquals("Wrong property 'host' display order", (Integer)1, propHost.getDisplayOrder()); // MID-2642 + assertEquals("Wrong property 'host' display order", (Integer) 1, propHost.getDisplayOrder()); // MID-2642 - PrismPropertyDefinition propPort = configurationPropertiesDefinition.findPropertyDefinition(new ItemName(UcfTestUtil.CONNECTOR_LDAP_NS,"port")); + PrismPropertyDefinition propPort = configurationPropertiesDefinition.findPropertyDefinition(new ItemName(UcfTestUtil.CONNECTOR_LDAP_NS, "port")); assertNotNull("No definition for configuration property 'port' in connector schema", propPort); - PrismAsserts.assertDefinition(propPort, new QName(UcfTestUtil.CONNECTOR_LDAP_NS,"port"), DOMUtil.XSD_INT, 0, 1); + PrismAsserts.assertDefinition(propPort, new QName(UcfTestUtil.CONNECTOR_LDAP_NS, "port"), DOMUtil.XSD_INT, 0, 1); assertEquals("Wrong property 'port' display name", "Port number", propPort.getDisplayName()); assertEquals("Wrong property 'port' help", "LDAP server port number.", propPort.getHelp()); - assertEquals("Wrong property 'port' display order", (Integer)2, propPort.getDisplayOrder()); // MID-2642 + assertEquals("Wrong property 'port' display order", (Integer) 2, propPort.getDisplayOrder()); // MID-2642 } - @Test - public void test020ResourceSchemaSanity() throws Exception { - final String TEST_NAME = "test020ResourceSchemaSanity"; - TestUtil.displayTestTitle(TEST_NAME); - + public void test020ResourceSchemaSanity() { QName objectClassQname = new QName(ResourceTypeUtil.getResourceNamespace(resourceType), OpenDJController.OBJECT_CLASS_INETORGPERSON_NAME); ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findObjectClassDefinition(objectClassQname); assertNotNull("No object class definition " + objectClassQname, accountDefinition); -// assertEquals("Object class " + objectClassQname + " is not account", ShadowKindType.ACCOUNT, accountDefinition.getKind()); -// assertTrue("Object class " + objectClassQname + " is not default account", accountDefinition.isDefaultInAKind()); assertFalse("Object class " + objectClassQname + " is empty", accountDefinition.isEmpty()); assertFalse("Object class " + objectClassQname + " is empty", accountDefinition.isIgnored()); @@ -220,23 +206,23 @@ public void test020ResourceSchemaSanity() throws Exception { ResourceAttributeDefinition idPrimaryDef = accountDefinition.findAttributeDefinition( new QName(ResourceTypeUtil.getResourceNamespace(resourceType), OpenDJController.RESOURCE_OPENDJ_PRIMARY_IDENTIFIER_LOCAL_NAME)); - assertNotNull("No definition for attribute "+OpenDJController.RESOURCE_OPENDJ_PRIMARY_IDENTIFIER_LOCAL_NAME, idPrimaryDef); - assertTrue("Attribute "+OpenDJController.RESOURCE_OPENDJ_PRIMARY_IDENTIFIER_LOCAL_NAME+" in not an identifier",idPrimaryDef.isPrimaryIdentifier(accountDefinition)); - assertTrue("Attribute "+OpenDJController.RESOURCE_OPENDJ_PRIMARY_IDENTIFIER_LOCAL_NAME+" in not in identifiers list",identifiers.contains(idPrimaryDef)); - assertEquals("Attribute "+OpenDJController.RESOURCE_OPENDJ_PRIMARY_IDENTIFIER_LOCAL_NAME+" has wrong native name", OpenDJController.RESOURCE_OPENDJ_PRIMARY_IDENTIFIER_LOCAL_NAME, idPrimaryDef.getNativeAttributeName()); - assertEquals("Attribute "+OpenDJController.RESOURCE_OPENDJ_PRIMARY_IDENTIFIER_LOCAL_NAME+" has wrong framework name", Uid.NAME, idPrimaryDef.getFrameworkAttributeName()); + assertNotNull("No definition for attribute " + OpenDJController.RESOURCE_OPENDJ_PRIMARY_IDENTIFIER_LOCAL_NAME, idPrimaryDef); + assertTrue("Attribute " + OpenDJController.RESOURCE_OPENDJ_PRIMARY_IDENTIFIER_LOCAL_NAME + " in not an identifier", idPrimaryDef.isPrimaryIdentifier(accountDefinition)); + assertTrue("Attribute " + OpenDJController.RESOURCE_OPENDJ_PRIMARY_IDENTIFIER_LOCAL_NAME + " in not in identifiers list", identifiers.contains(idPrimaryDef)); + assertEquals("Attribute " + OpenDJController.RESOURCE_OPENDJ_PRIMARY_IDENTIFIER_LOCAL_NAME + " has wrong native name", OpenDJController.RESOURCE_OPENDJ_PRIMARY_IDENTIFIER_LOCAL_NAME, idPrimaryDef.getNativeAttributeName()); + assertEquals("Attribute " + OpenDJController.RESOURCE_OPENDJ_PRIMARY_IDENTIFIER_LOCAL_NAME + " has wrong framework name", Uid.NAME, idPrimaryDef.getFrameworkAttributeName()); ResourceAttributeDefinition idSecondaryDef = accountDefinition.findAttributeDefinition( new QName(ResourceTypeUtil.getResourceNamespace(resourceType), OpenDJController.RESOURCE_OPENDJ_SECONDARY_IDENTIFIER_LOCAL_NAME)); - assertNotNull("No definition for attribute "+SchemaConstants.ICFS_NAME, idSecondaryDef); - assertTrue("Attribute "+OpenDJController.RESOURCE_OPENDJ_SECONDARY_IDENTIFIER_LOCAL_NAME+" in not secondary identifier",idSecondaryDef.isSecondaryIdentifier(accountDefinition)); - assertFalse("Attribute "+OpenDJController.RESOURCE_OPENDJ_SECONDARY_IDENTIFIER_LOCAL_NAME+" in in identifiers list and it should NOT be",identifiers.contains(idSecondaryDef)); - assertTrue("Attribute "+OpenDJController.RESOURCE_OPENDJ_SECONDARY_IDENTIFIER_LOCAL_NAME+" in not in secomdary identifiers list",accountDefinition.getSecondaryIdentifiers().contains(idSecondaryDef)); - assertEquals("Attribute "+OpenDJController.RESOURCE_OPENDJ_SECONDARY_IDENTIFIER_LOCAL_NAME+" has wrong native name", OpenDJController.RESOURCE_OPENDJ_SECONDARY_IDENTIFIER_LOCAL_NAME, idSecondaryDef.getNativeAttributeName()); - assertEquals("Attribute "+OpenDJController.RESOURCE_OPENDJ_SECONDARY_IDENTIFIER_LOCAL_NAME+" has wrong framework name", Name.NAME, idSecondaryDef.getFrameworkAttributeName()); - - assertEquals("Unexpected identifiers: "+identifiers, 1, identifiers.size()); - assertEquals("Unexpected secondary identifiers: "+accountDefinition.getSecondaryIdentifiers(), 1, accountDefinition.getSecondaryIdentifiers().size()); + assertNotNull("No definition for attribute " + SchemaConstants.ICFS_NAME, idSecondaryDef); + assertTrue("Attribute " + OpenDJController.RESOURCE_OPENDJ_SECONDARY_IDENTIFIER_LOCAL_NAME + " in not secondary identifier", idSecondaryDef.isSecondaryIdentifier(accountDefinition)); + assertFalse("Attribute " + OpenDJController.RESOURCE_OPENDJ_SECONDARY_IDENTIFIER_LOCAL_NAME + " in in identifiers list and it should NOT be", identifiers.contains(idSecondaryDef)); + assertTrue("Attribute " + OpenDJController.RESOURCE_OPENDJ_SECONDARY_IDENTIFIER_LOCAL_NAME + " in not in secomdary identifiers list", accountDefinition.getSecondaryIdentifiers().contains(idSecondaryDef)); + assertEquals("Attribute " + OpenDJController.RESOURCE_OPENDJ_SECONDARY_IDENTIFIER_LOCAL_NAME + " has wrong native name", OpenDJController.RESOURCE_OPENDJ_SECONDARY_IDENTIFIER_LOCAL_NAME, idSecondaryDef.getNativeAttributeName()); + assertEquals("Attribute " + OpenDJController.RESOURCE_OPENDJ_SECONDARY_IDENTIFIER_LOCAL_NAME + " has wrong framework name", Name.NAME, idSecondaryDef.getFrameworkAttributeName()); + + assertEquals("Unexpected identifiers: " + identifiers, 1, identifiers.size()); + assertEquals("Unexpected secondary identifiers: " + accountDefinition.getSecondaryIdentifiers(), 1, accountDefinition.getSecondaryIdentifiers().size()); } private Collection> addSampleResourceObject(String name, String givenName, String familyName) @@ -245,7 +231,7 @@ private Collection> addSampleResourceObject(String name, St QName objectClassQname = new QName(ResourceTypeUtil.getResourceNamespace(resourceType), OpenDJController.OBJECT_CLASS_INETORGPERSON_NAME); ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findObjectClassDefinition(objectClassQname); - assertNotNull("No object class definition "+objectClassQname, accountDefinition); + assertNotNull("No object class definition " + objectClassQname, accountDefinition); ResourceAttributeContainer resourceObject = accountDefinition.instantiate(ShadowType.F_ATTRIBUTES); ResourceAttributeDefinition attributeDefinition = accountDefinition @@ -279,19 +265,9 @@ private Collection> addSampleResourceObject(String name, St return resourceAttributes; } - private String getEntryUuid(Collection> identifiers) { - for (ResourceAttribute identifier : identifiers) { - if (identifier.getElementName().equals(new QName(ResourceTypeUtil.getResourceNamespace(resourceType), OpenDJController.RESOURCE_OPENDJ_PRIMARY_IDENTIFIER_LOCAL_NAME))) { - return identifier.getValue(String.class).getValue(); - } - } - return null; - } - @Test public void test100AddDeleteObject() throws Exception { final String TEST_NAME = "test100AddDeleteObject"; - TestUtil.displayTestTitle(this, TEST_NAME); OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME); @@ -301,7 +277,7 @@ public void test100AddDeleteObject() throws Exception { for (ResourceAttribute resourceAttribute : identifiers) { if (SchemaConstants.ICFS_UID.equals(resourceAttribute.getElementName())) { uid = resourceAttribute.getValue(String.class).getValue(); - System.out.println("uuuuid:" + uid); + System.out.println("uuid:" + uid); assertNotNull(uid); } } @@ -326,7 +302,6 @@ public void test100AddDeleteObject() throws Exception { @Test public void test110ChangeModifyObject() throws Exception { final String TEST_NAME = "test110ChangeModifyObject"; - TestUtil.displayTestTitle(this, TEST_NAME); OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME); @@ -371,7 +346,6 @@ public void test110ChangeModifyObject() throws Exception { @Test public void test200FetchChanges() throws Exception { final String TEST_NAME = "test200FetchChanges"; - TestUtil.displayTestTitle(this, TEST_NAME); OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME); ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findObjectClassDefinition(OpenDJController.OBJECT_CLASS_INETORGPERSON_NAME); @@ -445,16 +419,11 @@ private PropertyModificationOperation createActivationChange(ActivationStatusTyp /** * Simple call to connector test() method. - * - * @throws Exception */ @Test - public void test300TestConnection() throws Exception { - final String TEST_NAME = "test300TestConnection"; - TestUtil.displayTestTitle(this, TEST_NAME); + public void test300TestConnection() { // GIVEN - - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = new OperationResult(contextName()); // WHEN @@ -472,16 +441,11 @@ public void test300TestConnection() throws Exception { /** * Simple call to connector test() method. - * - * @throws Exception */ @Test public void test310TestConnectionNegative() throws Exception { - final String TEST_NAME = "test310TestConnectionNegative"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = new OperationResult(contextName()); ConnectorInstance badConnector = factory.createConnectorInstance(connectorType, ResourceTypeUtil.getResourceNamespace(badResourceType), "bad resource", "bad resource description"); @@ -506,17 +470,12 @@ public void test310TestConnectionNegative() throws Exception { /** * Test fetching and translating resource schema. - * - * @throws Exception */ @Test public void test400FetchResourceSchema() throws Exception { - final String TEST_NAME = "test400FetchResourceSchema"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN // WHEN - // The schema was fetched during test init. Now just check if it was OK. // THEN @@ -561,14 +520,10 @@ public void test400FetchResourceSchema() throws Exception { @Test public void test410Capabilities() throws Exception { - final String TEST_NAME = "test410Capabilities"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = new OperationResult(contextName()); // WHEN - Collection capabilities = cc.fetchCapabilities(result); // THEN @@ -586,7 +541,6 @@ public void test410Capabilities() throws Exception { @Test public void test500FetchObject() throws Exception { final String TEST_NAME = "test500FetchObject"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN ResourceAttributeContainer resourceObject = createResourceObject( @@ -621,7 +575,6 @@ public void test500FetchObject() throws Exception { @Test public void test510Search() throws Exception { final String TEST_NAME = "test510Search"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findObjectClassDefinition(OpenDJController.OBJECT_CLASS_INETORGPERSON_NAME); @@ -647,7 +600,6 @@ public boolean handle(PrismObject object) { @Test public void test600CreateAccountWithPassword() throws Exception { final String TEST_NAME = "test600CreateAccountWithPassword"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN ResourceAttributeContainer resourceObject = createResourceObject( "uid=lechuck,ou=people,dc=example,dc=com", "Ghost Pirate LeChuck", "LeChuck"); @@ -687,7 +639,6 @@ public void test600CreateAccountWithPassword() throws Exception { @Test public void test610ChangePassword() throws Exception { final String TEST_NAME = "test610ChangePassword"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN ResourceAttributeContainer resourceObject = createResourceObject( "uid=drake,ou=People,dc=example,dc=com", "Sir Francis Drake", "Drake"); @@ -730,10 +681,10 @@ public void test610ChangePassword() throws Exception { RawType value = new RawType(passPsXnode, prismContext); propMod.getValue().add(value); - //set the modificaion type + //set the modification type propMod.setModificationType(ModificationTypeType.REPLACE); - PropertyDelta passDelta = (PropertyDelta)DeltaConvertor.createItemDelta(propMod, shadow.getDefinition()); + PropertyDelta passDelta = (PropertyDelta) DeltaConvertor.createItemDelta(propMod, shadow.getDefinition()); PropertyModificationOperation passwordModification = new PropertyModificationOperation(passDelta); changes.add(passwordModification); diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/AddGetObjectTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/AddGetObjectTest.java index 92f018c09cb..c99397ee8d8 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/AddGetObjectTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/AddGetObjectTest.java @@ -338,7 +338,7 @@ public void testAddGetSystemConfigFile() throws Exception { PrismObject securityPolicy = prismContext.parseObject(new File(FOLDER_BASIC, "security-policy-special.xml")); - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); String securityPolicyOid = "ce74cb86-c8e8-11e9-bee8-b37bf7a7ab4a"; String oid = repositoryService.addObject(securityPolicy, null, result); AssertJUnit.assertNotNull(oid); diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/BaseSQLRepoTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/BaseSQLRepoTest.java index 1f8cdd4b6a7..507cc2166e0 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/BaseSQLRepoTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/BaseSQLRepoTest.java @@ -7,6 +7,29 @@ package com.evolveum.midpoint.repo.sql; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertNotNull; + +import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; +import static com.evolveum.midpoint.schema.constants.MidPointConstants.NS_RI; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Method; +import java.util.*; +import java.util.stream.Collectors; +import javax.xml.namespace.QName; + +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.jetbrains.annotations.NotNull; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.orm.hibernate5.LocalSessionFactoryBean; +import org.testng.AssertJUnit; +import org.testng.annotations.*; +import org.xml.sax.SAXException; + import com.evolveum.midpoint.audit.api.AuditService; import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.crypto.Protector; @@ -41,29 +64,7 @@ import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; - import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.jetbrains.annotations.NotNull; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.orm.hibernate5.LocalSessionFactoryBean; -import org.testng.AssertJUnit; -import org.testng.annotations.*; -import org.xml.sax.SAXException; - -import javax.xml.namespace.QName; -import java.io.File; -import java.io.IOException; -import java.lang.reflect.Method; -import java.util.*; -import java.util.stream.Collectors; - -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; -import static com.evolveum.midpoint.schema.constants.MidPointConstants.NS_RI; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; /** * @author lazyman @@ -109,8 +110,6 @@ public class BaseSQLRepoTest extends AbstractSpringTest { @Autowired protected Protector protector; @Autowired protected TestQueryListener queryListener; - private static Set initializedClasses = new HashSet<>(); - protected boolean verbose = false; @BeforeSuite @@ -129,35 +128,33 @@ public void setFactory(SessionFactory factory) { this.factory = factory; } - private boolean isSystemInitialized() { - return initializedClasses.contains(this.getClass()); - } - - private void setSystemInitialized() { - initializedClasses.add(this.getClass()); - } - @BeforeClass public void beforeClass() throws Exception { System.out.println(">>>>>>>>>>>>>>>>>>>>>>>> START " + getClass().getName() + "<<<<<<<<<<<<<<<<<<<<<<<<"); - LOGGER.info(">>>>>>>>>>>>>>>>>>>>>>>> START {} <<<<<<<<<<<<<<<<<<<<<<<<", new Object[]{getClass().getName()}); + LOGGER.info(">>>>>>>>>>>>>>>>>>>>>>>> START {} <<<<<<<<<<<<<<<<<<<<<<<<", new Object[] { getClass().getName() }); } @AfterClass public void afterClass() { System.out.println(">>>>>>>>>>>>>>>>>>>>>>>> FINISH " + getClass().getName() + "<<<<<<<<<<<<<<<<<<<<<<<<"); - LOGGER.info(">>>>>>>>>>>>>>>>>>>>>>>> FINISH {} <<<<<<<<<<<<<<<<<<<<<<<<", new Object[]{getClass().getName()}); + LOGGER.info(">>>>>>>>>>>>>>>>>>>>>>>> FINISH {} <<<<<<<<<<<<<<<<<<<<<<<<", new Object[] { getClass().getName() }); } + private volatile boolean initSystemExecuted = false; + + // TODO inttest: consider @PostConstruct like in AbstractIntegrationTest @BeforeMethod public void beforeMethod(Method method) throws Exception { + if (initSystemExecuted) { + logger.trace("initSystem: already called for class {} - IGNORING", getClass().getName()); + return; + } + initSystemExecuted = true; System.out.println(">>>>>>>>>>>>>>>>>>>>>>>> START TEST" + getClass().getName() + "." + method.getName() + "<<<<<<<<<<<<<<<<<<<<<<<<"); - LOGGER.info(">>>>>>>>>>>>>>>>>>>>>>>> START {}.{} <<<<<<<<<<<<<<<<<<<<<<<<", new Object[]{getClass().getName(), method.getName()}); + logger.info(">>>>>>>>>>>>>>>>>>>>>>>> START {}.{} <<<<<<<<<<<<<<<<<<<<<<<<", + getClass().getName(), method.getName()); - if (!isSystemInitialized()) { - initSystem(); - setSystemInitialized(); - } + initSystem(); } @AfterMethod @@ -174,7 +171,7 @@ public void afterMethod(Method method) { } System.out.println(">>>>>>>>>>>>>>>>>>>>>>>> END TEST" + getClass().getName() + "." + method.getName() + "<<<<<<<<<<<<<<<<<<<<<<<<"); - LOGGER.info(">>>>>>>>>>>>>>>>>>>>>>>> END {}.{} <<<<<<<<<<<<<<<<<<<<<<<<", new Object[]{getClass().getName(), method.getName()}); + LOGGER.info(">>>>>>>>>>>>>>>>>>>>>>>> END {}.{} <<<<<<<<<<<<<<<<<<<<<<<<", new Object[] { getClass().getName(), method.getName() }); } protected boolean isH2() { @@ -223,13 +220,13 @@ protected PrismObject getObject(Class type, String return object; } - OperationResult createResult(String testName) { - return new OperationResult(testName); + protected OperationResult createResult() { + return new OperationResult(contextName()); } // TODO: merge with similar methods in AbstractIntegrationTest protected void display(String message, PrismObject object) { - System.out.println("\n"+message+"\n"+object.debugDump(1)); + System.out.println("\n" + message + "\n" + object.debugDump(1)); } protected S_ItemEntry deltaFor(Class objectClass) throws SchemaException { @@ -251,8 +248,10 @@ protected ItemFactory itemFactory() { @NotNull ObjectReference createRepoRef(QName type, String oid) { - return RObjectReference - .copyFromJAXB(createRef(type, oid, SchemaConstants.ORG_DEFAULT), new RObjectReference(), relationRegistry); + return RObjectReference.copyFromJAXB( + createRef(type, oid, SchemaConstants.ORG_DEFAULT), + new RObjectReference(), + relationRegistry); } ObjectReferenceType createRef(QName type, String oid) { diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/CertificationTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/CertificationTest.java index 82ca1fcc4c9..07390170b00 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/CertificationTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/CertificationTest.java @@ -66,7 +66,6 @@ public class CertificationTest extends BaseSQLRepoTest { private static final Trace LOGGER = TraceManager.getTrace(CertificationTest.class); private static final File TEST_DIR = new File("src/test/resources/cert"); public static final File CAMPAIGN_1_FILE = new File(TEST_DIR, "cert-campaign-1.xml"); - public static final String CAMPAIGN_1_OID = "e8c07a7a-1b11-11e8-9b32-1715a2e8273b"; public static final File CAMPAIGN_2_FILE = new File(TEST_DIR, "cert-campaign-2.xml"); public static final long CASE_9_ID = 105L; public static final long NEW_CASE_ID = 200L; @@ -208,8 +207,7 @@ public void test240AddCases() throws Exception { @Test public void test250DeleteCase() throws Exception { - final String TEST_NAME = "test250DeleteCase"; - OperationResult result = createResult(TEST_NAME); + OperationResult result = createResult(); PrismObject campaign10Before = getFullCampaign(campaign1Oid); display("Campaign 10 before", campaign10Before); @@ -582,7 +580,7 @@ private void checkCasesForCampaign(String oid, Integer expected, OperationResult } } - private void checkWorkItemsForCampaign(String oid, int expected, OperationResult result) throws SchemaException, ObjectNotFoundException { + private void checkWorkItemsForCampaign(String oid, int expected, OperationResult result) throws SchemaException { ObjectQuery query = prismContext.queryFor(AccessCertificationWorkItemType.class) .exists(T_PARENT) .block() @@ -596,7 +594,7 @@ private void checkWorkItemsForCampaign(String oid, int expected, OperationResult assertEquals("Wrong # of certification work items", expected, count); } - private void checkWorkItemsForCampaignAndCase(String oid, long caseId, int expected, OperationResult result) throws SchemaException, ObjectNotFoundException { + private void checkWorkItemsForCampaignAndCase(String oid, long caseId, int expected, OperationResult result) throws SchemaException { ObjectQuery query = prismContext.queryFor(AccessCertificationWorkItemType.class) .exists(T_PARENT) .block() @@ -611,7 +609,7 @@ private void checkWorkItemsForCampaignAndCase(String oid, long caseId, int expec assertEquals("Wrong # of certification work items", expected, count); } - private void checkCasesTotal(int expected, OperationResult result) throws SchemaException, ObjectNotFoundException { + private void checkCasesTotal(int expected, OperationResult result) throws SchemaException { ObjectQuery query = prismContext.queryFor(AccessCertificationCaseType.class) .build(); List cases = repositoryService.searchContainers(AccessCertificationCaseType.class, query, null, result); @@ -628,7 +626,7 @@ private void assertCasesFound(Integer expected, List workItems = repositoryService.searchContainers(AccessCertificationWorkItemType.class, null, null, result); assertWorkItemsCount(expected, workItems, ""); int count = repositoryService.countContainers(AccessCertificationWorkItemType.class, null, null, result); diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyAssignmentTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyAssignmentTest.java index e6eec60e1d0..70c016de7a1 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyAssignmentTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyAssignmentTest.java @@ -9,31 +9,32 @@ import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertNotNull; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.*; -import com.evolveum.midpoint.prism.*; -import com.evolveum.midpoint.prism.delta.ItemDelta; -import com.evolveum.midpoint.prism.delta.ObjectDelta; -import com.evolveum.midpoint.prism.util.PrismAsserts; -import com.evolveum.midpoint.schema.MidPointPrismContextFactory; -import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.xml.ns._public.common.common_3.*; +import static com.evolveum.midpoint.prism.util.PrismTestUtil.resetPrismContext; + +import java.io.File; +import java.util.List; -import org.hibernate.query.Query; import org.hibernate.Session; +import org.hibernate.query.Query; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.testng.AssertJUnit; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import java.io.File; -import java.util.List; +import com.evolveum.midpoint.prism.*; +import com.evolveum.midpoint.prism.delta.ItemDelta; +import com.evolveum.midpoint.prism.delta.ObjectDelta; +import com.evolveum.midpoint.prism.util.PrismAsserts; +import com.evolveum.midpoint.schema.MidPointPrismContextFactory; +import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; /** * @author lazyman */ -@ContextConfiguration(locations = {"../../../../../ctx-test.xml"}) +@ContextConfiguration(locations = { "../../../../../ctx-test.xml" }) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) public class ModifyAssignmentTest extends BaseSQLRepoTest { @@ -88,7 +89,6 @@ public void test010AddAssignment() throws Exception { .item(RoleType.F_ASSIGNMENT).add(assignment1) .asObjectDeltaCast(ROLE_OID); - OperationResult result = new OperationResult("add assignment"); // WHEN @@ -99,7 +99,7 @@ public void test010AddAssignment() throws Exception { //check role and its assignments and inducements PrismObject repoRole = getObject(RoleType.class, ROLE_OID); - System.out.println("role after: " + repoRole.debugDump()); + System.out.println("role after: " + repoRole.debugDump()); PrismContainer inducement = repoRole.findContainer(RoleType.F_INDUCEMENT); assertNotNull(inducement); @@ -124,7 +124,7 @@ public void test011AddInducement() throws Exception { AssignmentType inducement1 = new AssignmentType(prismContext) .id(5L) .beginConstruction() - .resourceRef(ORIGINAL_INDUCEMENT_5_TARGET_OID, ResourceType.COMPLEX_TYPE) + .resourceRef(ORIGINAL_INDUCEMENT_5_TARGET_OID, ResourceType.COMPLEX_TYPE) .end(); ObjectDelta delta = deltaFor(RoleType.class) @@ -163,7 +163,7 @@ public void test020ModifyAssignment() throws Exception { ObjectDelta delta = deltaFor(RoleType.class) .item(RoleType.F_ASSIGNMENT, 4L, AssignmentType.F_TARGET_REF) - .replace(new ObjectReferenceType().oid(NEW_ASSIGNMENT_4_TARGET_OID).type(RoleType.COMPLEX_TYPE)) + .replace(new ObjectReferenceType().oid(NEW_ASSIGNMENT_4_TARGET_OID).type(RoleType.COMPLEX_TYPE)) .asObjectDeltaCast(ROLE_OID); OperationResult result = new OperationResult("modify assignment"); @@ -199,7 +199,7 @@ public void test021ModifyInducement() throws Exception { ObjectDelta delta = deltaFor(RoleType.class) .item(RoleType.F_INDUCEMENT, 5L, AssignmentType.F_TARGET_REF) - .replace(new ObjectReferenceType().oid(NEW_INDUCEMENT_5_TARGET_OID).type(RoleType.COMPLEX_TYPE)) + .replace(new ObjectReferenceType().oid(NEW_INDUCEMENT_5_TARGET_OID).type(RoleType.COMPLEX_TYPE)) .asObjectDeltaCast(ROLE_OID); OperationResult result = new OperationResult("modify inducement"); @@ -228,7 +228,7 @@ public void test021ModifyInducement() throws Exception { assertEquals(NEW_INDUCEMENT_5_TARGET_OID, refValue.getOid()); assertEquals(RoleType.COMPLEX_TYPE, refValue.getTargetType()); - PrismProperty accConstruction = value5.findProperty(AssignmentType.F_CONSTRUCTION); + PrismProperty accConstruction = value5.findProperty(AssignmentType.F_CONSTRUCTION); AssertJUnit.assertNull(accConstruction); } @@ -262,7 +262,8 @@ public void test030DeleteAssignment() throws Exception { Session session = open(); try { - Query query = session.createNativeQuery("select count(*) from m_assignment where owner_oid=:oid and id=:id"); + Query query = session.createNativeQuery( + "select count(*) from m_assignment where owner_oid=:oid and id=:id"); query.setParameter("oid", delta.getOid()); query.setParameter("id", 4); Number number = (Number) query.uniqueResult(); @@ -318,7 +319,7 @@ public void test040RenameAssignmentToInducement() throws Exception { AssignmentType a = new AssignmentType(prismContext) .id(1L) .beginConstruction() - .resourceRef(MOVED_ASSIGNMENT_TARGET_OID, ResourceType.COMPLEX_TYPE) + .resourceRef(MOVED_ASSIGNMENT_TARGET_OID, ResourceType.COMPLEX_TYPE) .end(); AssignmentType in = a.clone(); @@ -350,10 +351,8 @@ public void test040RenameAssignmentToInducement() throws Exception { @Test public void test100AssignmentAdd() throws Exception { - final String TEST_NAME = "test100AssignmentAdd"; //given - - OperationResult result = createResult(TEST_NAME); + OperationResult result = createResult(); PrismObject roleBefore = getObject(RoleType.class, ROLE_OID); display("Role before", roleBefore); @@ -380,18 +379,15 @@ public void test100AssignmentAdd() throws Exception { assertEquals("Wrong assignment id", (Long) 7L, assignment.getValues().iterator().next().getId()); } - /** * Add and delete assignment in one operation. Make sure that the container id is not reused. - * + *

* MID-4463 */ @Test public void test110AssignmentAddDeleteIds() throws Exception { - final String TEST_NAME = "test110AssignmentAddDeleteIds"; //given - - OperationResult result = createResult(TEST_NAME); + OperationResult result = createResult(); PrismObject roleBefore = getObject(RoleType.class, ROLE_OID); display("Role before", roleBefore); @@ -406,8 +402,8 @@ public void test110AssignmentAddDeleteIds() throws Exception { List> deltas = deltaFor(RoleType.class) .item(RoleType.F_ASSIGNMENT) - .add(assignmentToAdd) - .delete(assignmentToDelete) + .add(assignmentToAdd) + .delete(assignmentToDelete) .asItemDeltas(); // WHEN diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyTest.java index 47766a8b491..b25246e5a49 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyTest.java @@ -123,9 +123,6 @@ protected RepoModifyOptions getModifyOptions() { @Test(expectedExceptions = ObjectAlreadyExistsException.class) public void test010ModifyWithExistingName() throws Exception { - final String TEST_NAME = "test010ModifyWithExistingName"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult result = new OperationResult("MODIFY"); File userFile = new File(TEST_DIR, "modify-user.xml"); @@ -153,9 +150,6 @@ public void test010ModifyWithExistingName() throws Exception { @Test(expectedExceptions = ObjectNotFoundException.class) public void test020ModifyNotExistingUser() throws Exception { - final String TEST_NAME = "test020ModifyNotExistingUser"; - TestUtil.displayTestTitle(TEST_NAME); - ObjectModificationType modification = PrismTestUtil.parseAtomicValue( MODIFY_USER_ADD_LINK, ObjectModificationType.COMPLEX_TYPE); @@ -166,9 +160,6 @@ public void test020ModifyNotExistingUser() throws Exception { @Test public void test030ModifyUserOnNonExistingAccountTest() throws Exception { - final String TEST_NAME = "test030ModifyUserOnNonExistingAccountTest"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult result = new OperationResult("MODIFY"); //add user @@ -202,11 +193,8 @@ public void test030ModifyUserOnNonExistingAccountTest() throws Exception { @Test public void test031ModifyUserOnExistingAccountTest() throws Exception { - final String TEST_NAME = "test031ModifyUserOnExistingAccountTest"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); //add account PrismObject account = prismContext.parseObject(ACCOUNT_FILE); @@ -242,10 +230,7 @@ public void test031ModifyUserOnExistingAccountTest() throws Exception { @Test public void test032ModifyTaskObjectRef() throws Exception { - final String TEST_NAME = "test032ModifyTaskObjectRef"; - TestUtil.displayTestTitle(TEST_NAME); - - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); File taskFile = new File(TEST_DIR, "task.xml"); System.out.println("ADD"); PrismObject task = prismContext.parseObject(taskFile); @@ -334,10 +319,7 @@ private void checkReference(String taskOid) { @Test // MID-4801 (this passed even before fixing that issue) public void test035ModifyTaskOwnerRef() throws Exception { - final String TEST_NAME = "test035ModifyTaskOwnerRef"; - TestUtil.displayTestTitle(TEST_NAME); - - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); TaskType task = new TaskType(prismContext) .oid("035") .name("task035") @@ -356,10 +338,7 @@ public void test035ModifyTaskOwnerRef() throws Exception { @Test // MID-4801 (this failed before fixing that issue) public void test036ModifyTaskOwnerRefAddAndDelete() throws Exception { - final String TEST_NAME = "test036ModifyTaskOwnerRefAddAndDelete"; - TestUtil.displayTestTitle(TEST_NAME); - - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); TaskType task = new TaskType(prismContext) .oid("036") .name("task036") @@ -380,10 +359,7 @@ public void test036ModifyTaskOwnerRefAddAndDelete() throws Exception { @Test // MID-4801 public void test050ModifyUserEmployeeNumber() throws Exception { - final String TEST_NAME = "test050ModifyUserEmployeeNumber"; - TestUtil.displayTestTitle(TEST_NAME); - - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); UserType user = new UserType(prismContext) .oid("050") .name("user050") @@ -403,10 +379,7 @@ public void test050ModifyUserEmployeeNumber() throws Exception { @Test // MID-4801 public void test055DeleteUserEmployeeNumberWrong() throws Exception { - final String TEST_NAME = "test055DeleteUserEmployeeNumberWrong"; - TestUtil.displayTestTitle(TEST_NAME); - - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); UserType user = new UserType(prismContext) .oid("055") .name("user055") @@ -430,10 +403,7 @@ public void test055DeleteUserEmployeeNumberWrong() throws Exception { @Test // MID-4801 public void test056EmptyUserEmployeeNumberDelta() throws Exception { - final String TEST_NAME = "test056EmptyUserEmployeeNumberDelta"; - TestUtil.displayTestTitle(TEST_NAME); - - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); UserType user = new UserType(prismContext) .oid("056") .name("user056") @@ -473,9 +443,6 @@ private void assertUserEmployeeNumber(String userOid, String expectedValue) { @Test public void test100ModifyUserAddRole() throws Exception { - final String TEST_NAME = "test100ModifyUserAddRole"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult parentResult = new OperationResult("Modify user -> add roles"); String userToModifyOid = "f65963e3-9d47-4b18-aaf3-bfc98bdfa000"; @@ -524,11 +491,8 @@ public void test100ModifyUserAddRole() throws Exception { */ @Test public void test120ModifyAccountMetadata() throws Exception { - final String TEST_NAME = "test120ModifyAccountMetadata"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createResult(); repositoryService.deleteObject(ShadowType.class, "1234567890", parentResult); // from earlier test @@ -569,7 +533,7 @@ public void test120ModifyAccountMetadata() throws Exception { PrismObject repoShadow = repositoryService.getObject(ShadowType.class, oid, null, parentResult); // THEN - TestUtil.displayThen(TEST_NAME); + then(); System.out.println("\nRepo shadow"); System.out.println(repoShadow.debugDump()); @@ -596,7 +560,7 @@ public void test120ModifyAccountMetadata() throws Exception { repositoryService.modifyObject(ShadowType.class, oid, modifications, getModifyOptions(), parentResult); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject afterModify = repositoryService.getObject(ShadowType.class, oid, null, parentResult); System.out.println("\nAfter modify 1"); @@ -624,7 +588,7 @@ public void test120ModifyAccountMetadata() throws Exception { // AssertJUnit.assertNull(afterModify.asObjectable().getObjectChange()); // THEN - TestUtil.displayThen(TEST_NAME); + then(); afterModify = repositoryService.getObject(ShadowType.class, oid, null, parentResult); System.out.println("\nAfter modify 2"); @@ -633,9 +597,6 @@ public void test120ModifyAccountMetadata() throws Exception { @Test public void test130ExtensionModify() throws Exception { - final String TEST_NAME = "test130ExtensionModify"; - TestUtil.displayTestTitle(TEST_NAME); - File userFile = new File(TEST_DIR, "user-with-extension.xml"); //add first user PrismObject user = prismContext.parseObject(userFile); @@ -670,9 +631,6 @@ public void test130ExtensionModify() throws Exception { @Test public void test140ModifyAccountSynchronizationSituation() throws Exception { - final String TEST_NAME = "test140ModifyAccountSynchronizationSituation"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult result = new OperationResult("testModifyAccountSynchronizationSituation"); //add account @@ -725,10 +683,7 @@ public void test140ModifyAccountSynchronizationSituation() throws Exception { @Test public void test142ModifyAccountAttributeSameValue() throws Exception { - final String TEST_NAME = "test142ModifyAccountAttributeSameValue"; - TestUtil.displayTestTitle(TEST_NAME); - - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); PrismObject account = prismContext.parseObject(ACCOUNT_ATTRIBUTE_FILE); repositoryService.addObject(account, null, result); @@ -751,10 +706,7 @@ public void test142ModifyAccountAttributeSameValue() throws Exception { @Test public void test144ModifyAccountAttributeDifferent() throws Exception { - final String TEST_NAME = "test144ModifyAccountAttributeDifferent"; - TestUtil.displayTestTitle(TEST_NAME); - - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); assertNotNull("account-attribute was not imported in previous tests", accountOid); @@ -775,10 +727,7 @@ public void test144ModifyAccountAttributeDifferent() throws Exception { @Test public void test148ModifyAssignmentExtension() throws Exception { - final String TEST_NAME = "test148ModifyAssignmentExtension"; - TestUtil.displayTestTitle(TEST_NAME); - - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); PrismObject user = prismContext.parseObject(new File(TEST_DIR, "user-with-assignment-extension.xml")); repositoryService.addObject(user, null, result); @@ -802,10 +751,7 @@ public void test148ModifyAssignmentExtension() throws Exception { @Test public void test150ModifyRoleAddInducements() throws Exception { - final String TEST_NAME = "test150ModifyRoleAddInducements"; - TestUtil.displayTestTitle(TEST_NAME); - - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); File roleFile = new File(TEST_DIR, "role-modify.xml"); //add first user @@ -853,9 +799,7 @@ public void test150ModifyRoleAddInducements() throws Exception { @Test public void test160ModifyWithPrecondition() throws Exception { - final String TEST_NAME = "test160ModifyWithPrecondition"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); // GIVEN String versionBefore = repositoryService.getVersion(RoleType.class, roleOid, result); @@ -879,9 +823,7 @@ public void test160ModifyWithPrecondition() throws Exception { @Test public void test162ModifyWithPrecondition2() throws Exception { - final String TEST_NAME = "test162ModifyWithPrecondition2"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); // GIVEN String versionBefore = repositoryService.getVersion(RoleType.class, roleOid, result); @@ -906,9 +848,7 @@ public void test162ModifyWithPrecondition2() throws Exception { @Test public void test164ModifyWithVersionPreconditionFalse() throws Exception { - final String TEST_NAME = "test164ModifyWithVersionPreconditionFalse"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); // GIVEN String versionBefore = repositoryService.getVersion(RoleType.class, roleOid, result); @@ -933,9 +873,7 @@ public void test164ModifyWithVersionPreconditionFalse() throws Exception { @Test public void test166ModifyWithVersionPreconditionTrue() throws Exception { - final String TEST_NAME = "test166ModifyWithVersionPreconditionTrue"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); // GIVEN String versionBefore = repositoryService.getVersion(RoleType.class, roleOid, result); @@ -955,10 +893,7 @@ public void test166ModifyWithVersionPreconditionTrue() throws Exception { @Test public void test200ReplaceAttributes() throws Exception { - final String TEST_NAME = "test200ReplaceAttributes"; - TestUtil.displayTestTitle(TEST_NAME); - - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); PrismObject account = prismContext.parseObject(ACCOUNT_ATTRIBUTE_FILE); account.setOid(null); @@ -1053,9 +988,6 @@ private void assertAttribute(PrismObject shadow, QName attrQName @Test public void test210ModifyObjectCollection() throws Exception { - final String TEST_NAME = "test210ModifyObjectCollection"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult result = new OperationResult("test210ModifyObjectCollection"); ObjectCollectionType collection = prismContext.createObjectable(ObjectCollectionType.class) @@ -1107,11 +1039,8 @@ public void test210ModifyObjectCollection() throws Exception { */ @Test public void test250AddShadowPendingOperations() throws Exception { - final String TEST_NAME = "test250AddShadowPendingOperations"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); PrismObject shadow = prismContext.createObjectable(ShadowType.class) .name("shadow1") @@ -1146,11 +1075,8 @@ public void test250AddShadowPendingOperations() throws Exception { */ @Test public void test260DeleteShadowPendingOperations() throws Exception { - final String TEST_NAME = "test260DeleteShadowPendingOperations"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); PrismObject shadow = prismContext.createObjectable(ShadowType.class) .name("shadow2") @@ -1187,11 +1113,8 @@ public void test260DeleteShadowPendingOperations() throws Exception { */ @Test public void test300AddCaseWorkItem() throws Exception { - final String TEST_NAME = "test300AddCaseWorkItem"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); PrismObject caseObject = prismContext.createObjectable(CaseType.class) .name("testcase1") @@ -1223,11 +1146,8 @@ public void test300AddCaseWorkItem() throws Exception { @Test public void test310ModifyCaseWorkItemAssignee() throws Exception { - final String TEST_NAME = "test310ModifyCaseWorkItemAssignee"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); final String OLD_OID = "0f4082cf-c0b6-4cd2-a3db-544c668bab0c"; final String NEW_OID = "4cbdc40b-5693-4174-8634-acd3e0b96168"; @@ -1261,11 +1181,8 @@ public void test310ModifyCaseWorkItemAssignee() throws Exception { @Test public void test320ModifyCaseWorkItemAssigneeAndCandidate() throws Exception { - final String TEST_NAME = "test320ModifyCaseWorkItemAssigneeAndCandidate"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); final String OLD_OID = "d886a44c-732d-44d4-8403-e7c44bbfba8b"; final String OLD2_OID = "9a28119e-1283-4328-9e2f-ef383728a4d1"; @@ -1332,11 +1249,8 @@ private List assertCandidate(String candidateOid, int expected @Test // MID-5104 public void test350ReplaceAssignmentModifyApprover() throws Exception { - final String TEST_NAME = "test350ReplaceAssignmentModifyApprover"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); PrismObject user = prismContext.createObjectable(UserType.class) .name("test350") @@ -1363,11 +1277,8 @@ public void test350ReplaceAssignmentModifyApprover() throws Exception { @Test // MID-5105 public void test360ReplaceModifyApprovers() throws Exception { - final String TEST_NAME = "test360ReplaceModifyApprovers"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); PrismObject user = prismContext.createObjectable(UserType.class) .name("test360") @@ -1457,11 +1368,8 @@ public void test410RemoveExtensionProtectedStringValueInMemory() throws Exceptio @Test // MID-5516 public void test420RemoveExtensionProtectedStringValueInRepo() throws Exception { - final String TEST_NAME = "test420RemoveExtensionProtectedStringValueInRepo"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); ProtectedStringType protectedValue = protector.encryptString("hi"); UserType jack = new UserType(prismContext) @@ -1496,11 +1404,8 @@ public void test420RemoveExtensionProtectedStringValueInRepo() throws Exception @Test // MID-5826 - fortunately, in 4.0 this works due to reworked handling of extension values in repo public void test450ReplaceExtensionItem() throws Exception { - final String TEST_NAME = "test400ReplaceExtensionItem"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); PrismObject user = prismContext.createObjectable(UserType.class) .name("test400") @@ -1538,11 +1443,8 @@ private void assertExtensionDateValue(String objectOid, int expected) { @Test(enabled = false) // MID-5958 public void test500ReferenceTargetNameAdding() throws Exception { - final String TEST_NAME = "test500ReferenceTargetNameAdding"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); PolyStringType parentName = new PolyStringType("Parent"); parentName.setNorm("Parent"); @@ -1578,11 +1480,8 @@ public void test500ReferenceTargetNameAdding() throws Exception { */ @Test public void test510ModifySystemConfiguration() throws Exception { - final String TEST_NAME = "test510ModifySystemConfiguration"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); PrismObject before = prismContext.parseObject(SYSTEM_CONFIGURATION_BEFORE_FILE); repositoryService.addObject(before, null, result); diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyTestReindex.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyTestReindex.java index 683b394c649..fdffc43c7db 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyTestReindex.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyTestReindex.java @@ -15,7 +15,6 @@ import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.repo.api.RepoModifyOptions; import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import org.hibernate.Session; @@ -48,9 +47,7 @@ protected RepoModifyOptions getModifyOptions() { @Test public void testReindexExtensionItem() throws Exception { - final String TEST_NAME = "testReindexExtensionItem"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); PrismObject user = prismContext.createObjectable(UserType.class) .name("unstable") @@ -77,12 +74,10 @@ public void testReindexExtensionItem() throws Exception { @Test // MID-5112 public void testReindexIndexOnlyItem() throws Exception { - final String TEST_NAME = "testReindexIndexOnlyItem"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); PrismObject user = prismContext.createObjectable(UserType.class) - .name(TEST_NAME) + .name(getTestNameShort()) .asPrismObject(); ItemPath INDEX_ONLY_PATH = ItemPath.create(UserType.F_EXTENSION, "indexOnly"); PrismPropertyDefinition indexOnlyDef = user.getDefinition().findPropertyDefinition(INDEX_ONLY_PATH); @@ -113,14 +108,12 @@ public void testReindexIndexOnlyItem() throws Exception { @Test // MID-5112 public void testReindexPhoto() throws Exception { - final String TEST_NAME = "testReindex"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); byte[] PHOTO = new byte[] { 1, 2, 3, 4 }; PrismObject user = prismContext.createObjectable(UserType.class) - .name(TEST_NAME) + .name(getTestNameShort()) .jpegPhoto(PHOTO) .asPrismObject(); @@ -137,14 +130,12 @@ public void testReindexPhoto() throws Exception { @Test // MID-5112 public void testReindexTaskResult() throws Exception { - final String TEST_NAME = "testReindexTaskResult"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); OperationResultType taskOperationResult = new OperationResultType().message("Hello there"); PrismObject task = prismContext.createObjectable(TaskType.class) - .name(TEST_NAME) + .name(getTestNameShort()) .result(taskOperationResult) .asPrismObject(); @@ -161,15 +152,13 @@ public void testReindexTaskResult() throws Exception { @Test // MID-5112 public void testReindexLookupTableRow() throws Exception { - final String TEST_NAME = "testReindexLookupTableRow"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); LookupTableRowType row = new LookupTableRowType(prismContext) .key("key") .label("label"); PrismObject table = prismContext.createObjectable(LookupTableType.class) - .name(TEST_NAME) + .name(getTestNameShort()) .row(row) .asPrismObject(); @@ -187,14 +176,12 @@ public void testReindexLookupTableRow() throws Exception { @Test // MID-5112 public void testReindexCertificationCampaignCase() throws Exception { - final String TEST_NAME = "testReindexCertificationCampaignCase"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); AccessCertificationCaseType aCase = new AccessCertificationCaseType(prismContext) .stageNumber(1); PrismObject campaign = prismContext.createObjectable(AccessCertificationCampaignType.class) - .name(TEST_NAME) + .name(getTestNameShort()) .stageNumber(1) ._case(aCase) .asPrismObject(); @@ -216,9 +203,7 @@ public void testReindexCertificationCampaignCase() throws Exception { */ @Test public void testReindexShadow() throws Exception { - final String TEST_NAME = "testReindexShadow"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); String APPROVER_OID = "9123090439201432"; PrismObject shadow = prismContext.createObjectable(ShadowType.class) diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyUser.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyUser.java index abc9e413cf7..a4e2d55862f 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyUser.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyUser.java @@ -65,10 +65,7 @@ public void test010Add() throws Exception { @Test public void test020ModifyUser() throws Exception { - final String TEST_NAME = "test020ModifyUser"; - TestUtil.displayTestTitle(TEST_NAME); - - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); ObjectModificationType modification = PrismTestUtil.parseAtomicValue( new File(FOLDER_BASIC, "t002.xml"), ObjectModificationType.COMPLEX_TYPE); @@ -81,7 +78,7 @@ public void test020ModifyUser() throws Exception { repositoryService.modifyObject(UserType.class, userOid, delta.getModifications(), result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -92,10 +89,7 @@ public void test020ModifyUser() throws Exception { @Test public void test021ModifyUserNoEmpNum() throws Exception { - final String TEST_NAME = "test021ModifyUserNoEmpNum"; - TestUtil.displayTestTitle(TEST_NAME); - - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); ObjectModificationType modification = PrismTestUtil.parseAtomicValue( new File(FOLDER_BASIC, "t002a.xml"), ObjectModificationType.COMPLEX_TYPE); @@ -108,7 +102,7 @@ public void test021ModifyUserNoEmpNum() throws Exception { repositoryService.modifyObject(UserType.class, userOid, delta.getModifications(), result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -119,10 +113,7 @@ public void test021ModifyUserNoEmpNum() throws Exception { @Test public void test022ModifyUserEmptyEmpNum() throws Exception { - final String TEST_NAME = "test022ModifyUserEmptyEmpNum"; - TestUtil.displayTestTitle(TEST_NAME); - - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); ObjectModificationType modification = PrismTestUtil.parseAtomicValue( new File(FOLDER_BASIC, "t002b.xml"), ObjectModificationType.COMPLEX_TYPE); @@ -135,7 +126,7 @@ public void test022ModifyUserEmptyEmpNum() throws Exception { repositoryService.modifyObject(UserType.class, userOid, delta.getModifications(), result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/OrgStructTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/OrgStructTest.java index b6e7efcadb2..0eed48ec6b6 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/OrgStructTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/OrgStructTest.java @@ -556,9 +556,7 @@ public void test009modifyOrgStructRemoveUser() throws Exception { @Test public void test011OrgFilter() throws Exception { - final String TEST_NAME = "test011OrgFilter"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = createResult(); ObjectQuery query = prismContext.queryFor(ObjectType.class) .isDirectChildOf(ORG_F001_OID) @@ -574,9 +572,7 @@ public void test011OrgFilter() throws Exception { @Test public void test100ParentOrgRefFilterNullRelation() throws Exception { - final String TEST_NAME = "test100ParentOrgRefFilterNullRelation"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = createResult(); ObjectQuery query = prismContext.queryFor(ObjectType.class) .item(ObjectType.F_PARENT_ORG_REF).ref(itemFactory().createReferenceValue(ORG_F001_OID)) @@ -591,9 +587,7 @@ public void test100ParentOrgRefFilterNullRelation() throws Exception { @Test public void test101ParentOrgRefFilterManagerRelation() throws Exception { - final String TEST_NAME = "test101ParentOrgRefFilterManagerRelation"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = createResult(); PrismReferenceValue refVal = itemFactory().createReferenceValue(ORG_F001_OID); refVal.setRelation(SchemaConstants.ORG_MANAGER); @@ -610,9 +604,7 @@ public void test101ParentOrgRefFilterManagerRelation() throws Exception { @Test public void test102ParentOrgRefFilterAnyRelation() throws Exception { - final String TEST_NAME = "test102ParentOrgRefFilterAnyRelation"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = createResult(); PrismReferenceValue refVal = itemFactory().createReferenceValue(ORG_F001_OID); refVal.setRelation(PrismConstants.Q_ANY); diff --git a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractHigherUnitTest.java b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractHigherUnitTest.java index 1915531dba4..61c43773027 100644 --- a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractHigherUnitTest.java +++ b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractHigherUnitTest.java @@ -65,7 +65,7 @@ import com.evolveum.midpoint.schema.util.ResourceTypeUtil; import com.evolveum.midpoint.schema.util.ShadowUtil; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.util.AbstractUnitTest; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DebugDumpable; @@ -496,10 +496,6 @@ protected PrismObject parseObject(File file) throws Sc return getPrismContext().parseObject(file); } - protected void displayTestTitle(String testName) { - TestUtil.displayTestTitle(this, testName); - } - protected void displayCleanup(String testName) { TestUtil.displayCleanup(testName); } 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 3c3c184e6dd..84de279f015 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 @@ -178,7 +178,7 @@ public abstract class AbstractIntegrationTest extends AbstractSpringTest { */ protected PredefinedTestMethodTracing predefinedTestMethodTracing; - private boolean initSystemExecuted = false; + private volatile boolean initSystemExecuted = false; /** * With TestNG+Spring we can use {@code PostConstruct} for class-wide initialization. @@ -249,7 +249,7 @@ public void startTestContext(ITestResult testResult) { Class testClass = testResult.getMethod().getTestClass().getRealClass(); String testMethodName = testResult.getMethod().getMethodName(); - TestUtil.displayTestTitle(testClass.getSimpleName() + "." + testMethodName); + displayTestTitle(testClass.getSimpleName() + "." + testMethodName); Task task = createTask(testMethodName); // TODO inttest do we need that subresult? :-) (Virgo's brave new world) @@ -267,6 +267,8 @@ public void startTestContext(ITestResult testResult) { // task.setResult(result); MidpointTestMethodContext.create(testClass, testMethodName, task, task.getResult()); + // TODO inttest: remove after fix in TracerImpl + TestNameHolder.setCurrentTestName(contextName()); } /** @@ -332,10 +334,6 @@ protected Task getTestTask() { return MidpointTestMethodContext.get().getTask(); } - public String getTestNameShort() { - return MidpointTestMethodContext.get().getTestNameShort(); - } - /** * Creates new {@link Task} with operation name prefixed with {@link #contextName()}. * For most tests this should be unnecessary and the default test-method-scoped task @@ -347,6 +345,13 @@ protected Task createPlainTask(String operationName) { return taskManager.createTaskInstance(contextName() + "." + operationName); } + /** + * Creates new {@link Task} with {@link #contextName()} as root operation name. + */ + protected Task createPlainTask() { + return taskManager.createTaskInstance(contextName()); + } + /** * Just like {@link #createPlainTask} but also calls overridable {@link #customizeTask}. */ @@ -365,21 +370,28 @@ protected void customizeTask(Task task) { // nothing by default } - /** - * Context name is "class-simple-name.method" if test method context is available, - * otherwise it is just simple name of the test class. - */ @NotNull - protected String contextName() { + public String contextName() { MidpointTestMethodContext context = MidpointTestMethodContext.get(); return context != null ? context.getTestName() : getClass().getSimpleName(); } + public String getTestNameShort() { + return MidpointTestMethodContext.get().getTestNameShort(); + } + /** * Creates new subresult for default pre-created test-method-scoped {@link Task}. */ protected OperationResult createSubresult(String subresultSuffix) { - return getResult().createSubresult(getTestNameShort() + "." + subresultSuffix); + return getTestResult().createSubresult(getTestNameShort() + "." + subresultSuffix); + } + + /** + * Creates new {@link OperationResult} with name equal to {@link #contextName()}. + */ + protected OperationResult createResult() { + return new OperationResult(contextName()); } /** @@ -387,7 +399,7 @@ protected OperationResult createSubresult(String subresultSuffix) { * This result can be freely used in test for some "main scope", it is not asserted in any * after method, only displayed. */ - protected OperationResult getResult() { + protected OperationResult getTestResult() { return MidpointTestMethodContext.get().getResult(); } @@ -2485,8 +2497,8 @@ protected void assertExceptionUserFriendly(CommonException e, String expectedMes assertEquals("Unexpected user friendly exception fallback message", expectedMessage, userFriendlyMessage.getFallbackMessage()); } - protected ParallelTestThread[] multithread(final String TEST_NAME, MultithreadRunner lambda, int numberOfThreads, Integer randomStartDelayRange) { - return TestUtil.multithread(TEST_NAME, lambda, numberOfThreads, randomStartDelayRange); + protected ParallelTestThread[] multithread(MultithreadRunner lambda, int numberOfThreads, Integer randomStartDelayRange) { + return TestUtil.multithread(lambda, numberOfThreads, randomStartDelayRange); } protected void randomDelay(Integer range) { diff --git a/repo/security-impl/src/test/java/com/evolveum/midpoint/security/impl/TestEmpty.java b/repo/security-impl/src/test/java/com/evolveum/midpoint/security/impl/TestEmpty.java index 8d518981e21..13767a27c58 100644 --- a/repo/security-impl/src/test/java/com/evolveum/midpoint/security/impl/TestEmpty.java +++ b/repo/security-impl/src/test/java/com/evolveum/midpoint/security/impl/TestEmpty.java @@ -75,9 +75,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; - TestUtil.displayTestTitle(TEST_NAME); - // TODO } diff --git a/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/tracing/TracerImpl.java b/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/tracing/TracerImpl.java index ed5e43b7970..94001b1a922 100644 --- a/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/tracing/TracerImpl.java +++ b/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/tracing/TracerImpl.java @@ -362,6 +362,7 @@ private Map createTemplateParameters(Task task, OperationResult rv.put(MACRO_OPERATION_NAME, operationName); rv.put(MACRO_OPERATION_NAME_SHORT, shorten(operationName)); String testName; + // TODO inttest: subclass TracerImpl in test scope with change here (use template method) if (TestNameHolder.getCurrentTestName() != null) { testName = TestNameHolder.getCurrentTestName(); } else { diff --git a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/AbstractTaskManagerTest.java b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/AbstractTaskManagerTest.java index eb527d03433..69c9b2ceb21 100644 --- a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/AbstractTaskManagerTest.java +++ b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/AbstractTaskManagerTest.java @@ -88,7 +88,6 @@ public class AbstractTaskManagerTest extends AbstractSpringTest { protected MockLongTaskHandler longTaskHandler; protected static OperationResult createResult(String test) { - TestUtil.displayTestTitle(test); return new OperationResult(TestQuartzTaskManagerContract.class.getName() + ".test" + test); } diff --git a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestWorkDistribution.java b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestWorkDistribution.java index 163051ece7a..8413a7e0918 100644 --- a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestWorkDistribution.java +++ b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestWorkDistribution.java @@ -629,7 +629,7 @@ public void test220WorkerSuspend() throws Exception { taskManager.resumeTask(worker3, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); String coordinatorTaskOid = coordinatorTaskOid(TEST_NAME); waitFor("waiting for all items to be processed", () -> getTotalItemsProcessed(coordinatorTaskOid) == 107 - 6, DEFAULT_TIMEOUT, 500); @@ -665,7 +665,7 @@ public void test220WorkerSuspend() throws Exception { taskManager.deleteTask(oidToDelete, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("Waiting for coordinator task close"); waitForTaskClose(coordinatorTaskOid, result, DEFAULT_TIMEOUT, 200); @@ -714,7 +714,7 @@ public void test230WorkerException() throws Exception { taskManager.resumeTask(worker3, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); String coordinatorTaskOid = coordinatorTaskOid(TEST_NAME); waitFor("waiting for all items to be processed", () -> getTotalItemsProcessed(coordinatorTaskOid) == 107 - 6, DEFAULT_TIMEOUT, 500); @@ -750,7 +750,7 @@ public void test230WorkerException() throws Exception { taskManager.closeTask(taskManager.getTask(oidToClose, result), result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("Waiting for coordinator task close"); waitForTaskClose(coordinatorTaskOid, result, DEFAULT_TIMEOUT, 200); diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Abstract389DsDnTest.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Abstract389DsDnTest.java index 348c7f16f3b..9b06ca531fd 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Abstract389DsDnTest.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Abstract389DsDnTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2014-2016 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -6,33 +6,20 @@ */ package com.evolveum.midpoint.testing.conntest; -import static com.evolveum.midpoint.test.IntegrationTestTools.display; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; import static org.testng.AssertJUnit.assertTrue; -import java.io.File; - import javax.xml.namespace.QName; -import org.testng.annotations.AfterClass; import org.testng.annotations.Listeners; import org.testng.annotations.Test; -import com.evolveum.midpoint.common.refinery.RefinedResourceSchema; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition; -import com.evolveum.midpoint.schema.processor.ResourceSchema; -import com.evolveum.midpoint.test.util.MidPointTestConstants; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; /** * @author semancik - * */ @Listeners({com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class}) public abstract class Abstract389DsDnTest extends Abstract389DsTest { @@ -53,10 +40,7 @@ protected boolean isUsingGroupShortcutAttribute() { } @Test - public void test025SchemaDn() throws Exception { - final String TEST_NAME = "test025SchemaDn"; - TestUtil.displayTestTitle(this, TEST_NAME); - + public void test025SchemaDn() { ResourceAttributeDefinition dnDef = accountObjectClassDefinition.findAttributeDefinition("dn"); display("DN defintion", dnDef); PrismAsserts.assertDefinition(dnDef, new QName(MidPointConstants.NS_RI, "dn"), DOMUtil.XSD_STRING, 1, 1); @@ -68,5 +52,4 @@ public void test025SchemaDn() throws Exception { assertTrue("Secodary identifiers are not empty: "+accountObjectClassDefinition.getSecondaryIdentifiers(), accountObjectClassDefinition.getSecondaryIdentifiers().isEmpty()); } - } diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Abstract389DsNsUniqueIdTest.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Abstract389DsNsUniqueIdTest.java index 70caf582e39..73234988f07 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Abstract389DsNsUniqueIdTest.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Abstract389DsNsUniqueIdTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2014-2016 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Abstract389DsTest.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Abstract389DsTest.java index 1f5558a4afc..8a34a8f3aa7 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Abstract389DsTest.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Abstract389DsTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2014-2016 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractEDirTest.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractEDirTest.java index d3d325dc760..f8a5f33bb80 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractEDirTest.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractEDirTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015-2016 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -6,20 +6,15 @@ */ package com.evolveum.midpoint.testing.conntest; +import static org.testng.AssertJUnit.*; + import static com.evolveum.midpoint.schema.constants.SchemaConstants.*; -import static org.testng.AssertJUnit.assertNotNull; -import static com.evolveum.midpoint.test.IntegrationTestTools.display; -import static org.testng.AssertJUnit.assertTrue; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; import java.io.File; import java.io.IOException; import java.util.Collection; - import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.path.ItemPath; import org.apache.directory.api.ldap.model.cursor.CursorException; import org.apache.directory.api.ldap.model.entry.Entry; import org.apache.directory.api.ldap.model.exception.LdapException; @@ -31,6 +26,7 @@ import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.delta.PropertyDelta; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.schema.SearchResultList; import com.evolveum.midpoint.schema.SearchResultMetadata; @@ -49,23 +45,14 @@ import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.MiscUtil; 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.ActivationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.LockoutStatusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; /** * @author semancik - * */ -@Listeners({com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class}) +@Listeners({ com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class }) public abstract class AbstractEDirTest extends AbstractLdapTest { protected static final File TEST_DIR = new File(MidPointTestConstants.TEST_RESOURCES_DIR, "edir"); @@ -165,10 +152,9 @@ private QName getAssociationGroupQName() { } protected String getOrgGroupsLdapSuffix() { - return "ou=orggroups,"+getLdapSuffix(); + return "ou=orggroups," + getLdapSuffix(); } - @Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { super.initSystem(initTask, initResult); @@ -187,9 +173,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; - TestUtil.displayTestTitle(this, TEST_NAME); - assertLdapPassword(ACCOUNT_JACK_UID, ACCOUNT_JACK_PASSWORD); assertEDirGroupMember(ACCOUNT_JACK_UID, GROUP_PIRATES_NAME); cleanupDelete(toAccountDn(USER_BARBOSSA_USERNAME)); @@ -200,10 +183,7 @@ public void test000Sanity() throws Exception { } @Test - public void test050Capabilities() throws Exception { - final String TEST_NAME = "test050Capabilities"; - TestUtil.displayTestTitle(this, TEST_NAME); - + public void test050Capabilities() { Collection nativeCapabilitiesCollection = ResourceTypeUtil.getNativeCapabilitiesCollection(resourceType); display("Native capabilities", nativeCapabilitiesCollection); @@ -215,11 +195,8 @@ public void test050Capabilities() throws Exception { @Test public void test100SeachJackByLdapUid() throws Exception { - final String TEST_NAME = "test100SeachJackByLdapUid"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = createUidQuery(ACCOUNT_JACK_UID); @@ -235,14 +212,14 @@ public void test100SeachJackByLdapUid() throws Exception { result.computeStatus(); TestUtil.assertSuccess(result); - assertEquals("Unexpected search result: "+shadows, 1, shadows.size()); + assertEquals("Unexpected search result: " + shadows, 1, shadows.size()); PrismObject shadow = shadows.get(0); display("Shadow", shadow); assertAccountShadow(shadow, toAccountDn(ACCOUNT_JACK_UID)); assertShadowLockout(shadow, LockoutStatusType.NORMAL); jackAccountOid = shadow.getOid(); - assertNotNull("Null OID in "+shadow, jackAccountOid); + assertNotNull("Null OID in " + shadow, jackAccountOid); assertCounterIncrement(InternalCounters.CONNECTOR_OPERATION_COUNT, 2); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); @@ -255,11 +232,8 @@ public void test100SeachJackByLdapUid() throws Exception { @Test public void test105SeachPiratesByCn() throws Exception { - final String TEST_NAME = "test105SeachPiratesByCn"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getGroupObjectClass(), prismContext); @@ -276,7 +250,7 @@ public void test105SeachPiratesByCn() throws Exception { result.computeStatus(); TestUtil.assertSuccess(result); - assertEquals("Unexpected search result: "+shadows, 1, shadows.size()); + assertEquals("Unexpected search result: " + shadows, 1, shadows.size()); PrismObject shadow = shadows.get(0); display("Shadow", shadow); @@ -293,11 +267,8 @@ public void test105SeachPiratesByCn() throws Exception { @Test public void test110GetJack() throws Exception { - final String TEST_NAME = "test110GetJack"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = createUidQuery(ACCOUNT_JACK_UID); @@ -326,11 +297,8 @@ public void test110GetJack() throws Exception { @Test public void test120JackLockout() throws Exception { - final String TEST_NAME = "test120JackLockout"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); makeBadLoginAttempt(ACCOUNT_JACK_UID); @@ -350,11 +318,11 @@ public void test120JackLockout() throws Exception { SearchResultList> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); - assertEquals("Unexpected search result: "+shadows, 1, shadows.size()); + assertEquals("Unexpected search result: " + shadows, 1, shadows.size()); PrismObject shadow = shadows.get(0); display("Shadow", shadow); @@ -375,16 +343,13 @@ public void test120JackLockout() throws Exception { */ @Test public void test150SeachAllAccounts() throws Exception { - final String TEST_NAME = "test150SeachAllAccounts"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); - SearchResultList> searchResultList = doSearch(TEST_NAME, query, NUMBER_OF_ACCOUNTS, task, result); + SearchResultList> searchResultList = doSearch(query, NUMBER_OF_ACCOUNTS, task, result); assertCounterIncrement(InternalCounters.CONNECTOR_OPERATION_COUNT, 1); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); @@ -397,18 +362,15 @@ public void test150SeachAllAccounts() throws Exception { @Test public void test190SeachLockedAccounts() throws Exception { - final String TEST_NAME = "test190SeachLockedAccounts"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassFilterPrefix(getResourceOid(), getAccountObjectClass(), prismContext) .and().item(ShadowType.F_ACTIVATION, ActivationType.F_LOCKOUT_STATUS).eq(LockoutStatusType.LOCKED) .build(); - SearchResultList> searchResultList = doSearch(TEST_NAME, query, 1, task, result); + SearchResultList> searchResultList = doSearch(query, 1, task, result); assertCounterIncrement(InternalCounters.CONNECTOR_OPERATION_COUNT, 1); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); @@ -426,11 +388,8 @@ public void test190SeachLockedAccounts() throws Exception { @Test public void test200AssignAccountBarbossa() throws Exception { - final String TEST_NAME = "test200AssignAccountBarbossa"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); long tsStart = System.currentTimeMillis(); @@ -439,7 +398,7 @@ public void test200AssignAccountBarbossa() throws Exception { assignAccountToUser(USER_BARBOSSA_OID, getResourceOid(), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -455,7 +414,7 @@ public void test200AssignAccountBarbossa() throws Exception { accountBarbossaOid = shadow.getOid(); Collection> identifiers = ShadowUtil.getPrimaryIdentifiers(shadow); String accountBarbossaIcfUid = (String) identifiers.iterator().next().getRealValue(); - assertNotNull("No identifier in "+shadow, accountBarbossaIcfUid); + assertNotNull("No identifier in " + shadow, accountBarbossaIcfUid); assertEquals("Wrong ICFS UID", MiscUtil.binaryToHex(entry.get(getPrimaryIdentifierAttributeName()).getBytes()), accountBarbossaIcfUid); @@ -463,19 +422,16 @@ public void test200AssignAccountBarbossa() throws Exception { assertPasswordAllowChange(shadow, null); ResourceAttribute createTimestampAttribute = ShadowUtil.getAttribute(shadow, new QName(MidPointConstants.NS_RI, "createTimestamp")); - assertNotNull("No createTimestamp in "+shadow, createTimestampAttribute); + assertNotNull("No createTimestamp in " + shadow, createTimestampAttribute); Long createTimestamp = createTimestampAttribute.getRealValue(); // LDAP server may be on a different host. Allow for some clock offset. - TestUtil.assertBetween("Wrong createTimestamp in "+shadow, roundTsDown(tsStart)-1000, roundTsUp(tsEnd)+1000, createTimestamp); + TestUtil.assertBetween("Wrong createTimestamp in " + shadow, roundTsDown(tsStart) - 1000, roundTsUp(tsEnd) + 1000, createTimestamp); } @Test public void test210ModifyAccountBarbossaTitle() throws Exception { - final String TEST_NAME = "test210ModifyAccountBarbossaTitle"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object() @@ -491,7 +447,7 @@ public void test210ModifyAccountBarbossaTitle() throws Exception { modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -505,11 +461,8 @@ public void test210ModifyAccountBarbossaTitle() throws Exception { @Test public void test220ModifyUserBarbossaPassword() throws Exception { - final String TEST_NAME = "test220ModifyUserBarbossaPassword"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ProtectedStringType userPasswordPs = new ProtectedStringType(); @@ -520,7 +473,7 @@ public void test220ModifyUserBarbossaPassword() throws Exception { modifyUserReplace(USER_BARBOSSA_OID, PATH_CREDENTIALS_PASSWORD_VALUE, task, result, userPasswordPs); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -535,11 +488,8 @@ public void test220ModifyUserBarbossaPassword() throws Exception { @Test public void test230DisableBarbossa() throws Exception { - final String TEST_NAME = "test230DisableBarbossa"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -547,7 +497,7 @@ public void test230DisableBarbossa() throws Exception { modifyUserReplace(USER_BARBOSSA_OID, PATH_ACTIVATION_ADMINISTRATIVE_STATUS, task, result, ActivationStatusType.DISABLED); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -564,11 +514,8 @@ public void test230DisableBarbossa() throws Exception { @Test public void test239EnableBarbossa() throws Exception { - final String TEST_NAME = "test239EnableBarbossa"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -576,7 +523,7 @@ public void test239EnableBarbossa() throws Exception { modifyUserReplace(USER_BARBOSSA_OID, PATH_ACTIVATION_ADMINISTRATIVE_STATUS, task, result, ActivationStatusType.ENABLED); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -596,11 +543,8 @@ public void test239EnableBarbossa() throws Exception { */ @Test public void test240ModifyAccountBarbossaPasswordAllowChangeFalse() throws Exception { - final String TEST_NAME = "test240ModifyAccountBarbossaPasswordAllowChangeFalse"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object() @@ -616,7 +560,7 @@ public void test240ModifyAccountBarbossaPasswordAllowChangeFalse() throws Except modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -638,11 +582,8 @@ public void test240ModifyAccountBarbossaPasswordAllowChangeFalse() throws Except */ @Test public void test250AssignGuybrushPirates() throws Exception { - final String TEST_NAME = "test250AssignGuybrushPirates"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_GUYBRUSH_OID, PATH_ACTIVATION_ADMINISTRATIVE_STATUS, task, result, ActivationStatusType.DISABLED); @@ -652,7 +593,7 @@ public void test250AssignGuybrushPirates() throws Exception { assignRole(USER_GUYBRUSH_OID, ROLE_PIRATES_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -673,11 +614,8 @@ public void test250AssignGuybrushPirates() throws Exception { @Test public void test260EnableGyubrush() throws Exception { - final String TEST_NAME = "test260EnableGyubrush"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -685,7 +623,7 @@ public void test260EnableGyubrush() throws Exception { modifyUserReplace(USER_GUYBRUSH_OID, PATH_ACTIVATION_ADMINISTRATIVE_STATUS, task, result, ActivationStatusType.ENABLED); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -704,11 +642,8 @@ public void test260EnableGyubrush() throws Exception { @Test public void test300AssignBarbossaPirates() throws Exception { - final String TEST_NAME = "test300AssignBarbossaPirates"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -716,7 +651,7 @@ public void test300AssignBarbossaPirates() throws Exception { assignRole(USER_BARBOSSA_OID, ROLE_PIRATES_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -737,11 +672,8 @@ public void test300AssignBarbossaPirates() throws Exception { @Test public void test390ModifyUserBarbossaRename() throws Exception { - final String TEST_NAME = "test390ModifyUserBarbossaRename"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -749,7 +681,7 @@ public void test390ModifyUserBarbossaRename() throws Exception { renameObject(UserType.class, USER_BARBOSSA_OID, USER_CPTBARBOSSA_USERNAME, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -772,11 +704,8 @@ public void test390ModifyUserBarbossaRename() throws Exception { @Test public void test500AddOrgMeleeIsland() throws Exception { - final String TEST_NAME = "test500AddOrgMeleeIsland"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject org = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(OrgType.class).instantiate(); @@ -794,7 +723,7 @@ public void test500AddOrgMeleeIsland() throws Exception { addObject(org, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -809,11 +738,8 @@ public void test500AddOrgMeleeIsland() throws Exception { @Test public void test510AssignGuybrushMeleeIsland() throws Exception { - final String TEST_NAME = "test510AssignGuybrushMeleeIsland"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -821,7 +747,7 @@ public void test510AssignGuybrushMeleeIsland() throws Exception { assignOrg(USER_GUYBRUSH_OID, orgMeleeIslandOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -839,11 +765,8 @@ public void test510AssignGuybrushMeleeIsland() throws Exception { @Test public void test520RenameOrgMeleeIsland() throws Exception { - final String TEST_NAME = "test520RenameOrgMeleeIsland"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -851,7 +774,7 @@ public void test520RenameOrgMeleeIsland() throws Exception { renameObject(OrgType.class, orgMeleeIslandOid, GROUP_MELA_NOVA_NAME, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -866,21 +789,18 @@ public void test520RenameOrgMeleeIsland() throws Exception { // Wait until the lockout of Jack expires, check status @Test public void test800JackLockoutExpires() throws Exception { - final String TEST_NAME = "test800JackLockoutExpires"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); long now = System.currentTimeMillis(); - long lockoutExpires = jackLockoutTimestamp + LOCKOUT_EXPIRATION_SECONDS*1000; + long lockoutExpires = jackLockoutTimestamp + LOCKOUT_EXPIRATION_SECONDS * 1000; if (now < lockoutExpires) { - display("Sleeping for "+(lockoutExpires-now)+"ms (waiting for lockout expiration)"); - Thread.sleep(lockoutExpires-now); + display("Sleeping for " + (lockoutExpires - now) + "ms (waiting for lockout expiration)"); + Thread.sleep(lockoutExpires - now); } now = System.currentTimeMillis(); - display("Time is now "+now); + display("Time is now " + now); ObjectQuery query = createUidQuery(ACCOUNT_JACK_UID); @@ -892,11 +812,11 @@ public void test800JackLockoutExpires() throws Exception { SearchResultList> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); - assertEquals("Unexpected search result: "+shadows, 1, shadows.size()); + assertEquals("Unexpected search result: " + shadows, 1, shadows.size()); PrismObject shadow = shadows.get(0); display("Shadow", shadow); @@ -914,17 +834,14 @@ public void test800JackLockoutExpires() throws Exception { @Test public void test810SeachLockedAccounts() throws Exception { - final String TEST_NAME = "test810SeachLockedAccounts"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassFilterPrefix(getResourceOid(), getAccountObjectClass(), prismContext) .and().item(ShadowType.F_ACTIVATION, ActivationType.F_LOCKOUT_STATUS).eq(LockoutStatusType.LOCKED) .build(); - SearchResultList> searchResultList = doSearch(TEST_NAME, query, 0, task, result); + SearchResultList> searchResultList = doSearch(query, 0, task, result); assertCounterIncrement(InternalCounters.CONNECTOR_OPERATION_COUNT, 1); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); @@ -932,11 +849,8 @@ public void test810SeachLockedAccounts() throws Exception { @Test public void test820JackLockoutAndUnlock() throws Exception { - final String TEST_NAME = "test820JackLockoutAndUnlock"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); makeBadLoginAttempt(ACCOUNT_JACK_UID); @@ -952,7 +866,7 @@ public void test820JackLockoutAndUnlock() throws Exception { SearchResultList> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result); result.computeStatus(); TestUtil.assertSuccess(result); - assertEquals("Unexpected search result: "+shadows, 1, shadows.size()); + assertEquals("Unexpected search result: " + shadows, 1, shadows.size()); PrismObject shadowLocked = shadows.get(0); display("Locked shadow", shadowLocked); assertAccountShadow(shadowLocked, toAccountDn(ACCOUNT_JACK_UID)); @@ -967,7 +881,7 @@ public void test820JackLockoutAndUnlock() throws Exception { LockoutStatusType.NORMAL); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -994,13 +908,10 @@ public void test820JackLockoutAndUnlock() throws Exception { @Test public void test890UnAssignBarbossaPirates() throws Exception { - final String TEST_NAME = "test890UnAssignBarbossaPirates"; - TestUtil.displayTestTitle(this, TEST_NAME); - // TODO: do this on another account. There is a bad interference with rename. // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1008,7 +919,7 @@ public void test890UnAssignBarbossaPirates() throws Exception { unassignRole(USER_BARBOSSA_OID, ROLE_PIRATES_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1029,11 +940,8 @@ public void test890UnAssignBarbossaPirates() throws Exception { @Test public void test899UnAssignAccountBarbossa() throws Exception { - final String TEST_NAME = "test899UnAssignAccountBarbossa"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1041,7 +949,7 @@ public void test899UnAssignAccountBarbossa() throws Exception { unassignAccountFromUser(USER_BARBOSSA_OID, getResourceOid(), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1058,21 +966,21 @@ public void test899UnAssignAccountBarbossa() throws Exception { protected void assertAccountShadow(PrismObject shadow, String dn) throws SchemaException { super.assertAccountShadow(shadow, dn); ResourceAttribute primaryIdAttr = ShadowUtil.getAttribute(shadow, getPrimaryIdentifierAttributeQName()); - assertNotNull("No primary identifier ("+getPrimaryIdentifierAttributeQName()+" in "+shadow, primaryIdAttr); + assertNotNull("No primary identifier (" + getPrimaryIdentifierAttributeQName() + " in " + shadow, primaryIdAttr); String primaryId = primaryIdAttr.getRealValue(); - assertTrue("Unexpected chars in primary ID: '"+primaryId+"'", primaryId.matches("[a-z0-9]+")); + assertTrue("Unexpected chars in primary ID: '" + primaryId + "'", primaryId.matches("[a-z0-9]+")); } protected void assertPasswordAllowChange(PrismObject shadow, Boolean expected) throws SchemaException { Boolean passwordAllowChange = ShadowUtil.getAttributeValue(shadow, new QName(MidPointConstants.NS_RI, "passwordAllowChange")); - assertEquals("Wrong passwordAllowChange in "+shadow, expected, passwordAllowChange); + assertEquals("Wrong passwordAllowChange in " + shadow, expected, passwordAllowChange); } private void makeBadLoginAttempt(String uid) throws LdapException, IOException { try { LdapNetworkConnection conn = ldapConnect(toAccountDn(uid), "thisIsAwRoNgPASSW0RD"); if (conn.isAuthenticated()) { - AssertJUnit.fail("Bad authentication went good for "+uid); + AssertJUnit.fail("Bad authentication went good for " + uid); } } catch (SecurityException e) { // this is expected @@ -1102,6 +1010,6 @@ private void assertEDirNoGroupMember(Entry accountEntry, String groupName) throw } protected String toOrgGroupDn(String cn) { - return "cn="+cn+","+getOrgGroupsLdapSuffix(); + return "cn=" + cn + "," + getOrgGroupsLdapSuffix(); } } diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractLdapConnTest.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractLdapConnTest.java index 9d78ba1afa9..856ab66fb89 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractLdapConnTest.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractLdapConnTest.java @@ -1,44 +1,36 @@ -package com.evolveum.midpoint.testing.conntest; /* * Copyright (c) 2010-2018 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 * and European Union Public License. See LICENSE file for details. */ +package com.evolveum.midpoint.testing.conntest; +import static org.testng.AssertJUnit.*; import static com.evolveum.midpoint.schema.constants.SchemaConstants.PATH_CREDENTIALS_PASSWORD_VALUE; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertTrue; -import static org.testng.AssertJUnit.assertNotNull; -import static com.evolveum.midpoint.test.IntegrationTestTools.display; -import static org.testng.AssertJUnit.assertEquals; import java.io.File; import java.io.IOException; import java.util.Collection; - import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; -import com.evolveum.midpoint.model.impl.sync.ReconciliationTaskHandler; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.util.MiscUtil; - +import org.apache.commons.lang.mutable.MutableInt; +import org.apache.directory.api.ldap.model.entry.Entry; +import org.apache.directory.api.ldap.model.exception.LdapException; import org.springframework.beans.factory.annotation.Autowired; 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 org.testng.annotations.Test; -import org.apache.commons.lang.mutable.MutableInt; -import org.apache.directory.api.ldap.model.entry.Entry; -import org.apache.directory.api.ldap.model.exception.LdapException; +import com.evolveum.midpoint.model.impl.sync.ReconciliationTaskHandler; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.delta.PropertyDelta; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.query.ObjectPaging; import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.prism.query.OrderDirection; @@ -58,33 +50,19 @@ import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; -import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SecurityViolationException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; +import com.evolveum.midpoint.util.MiscUtil; +import com.evolveum.midpoint.util.exception.*; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; /** * @author Radovan Semancik - * */ -@ContextConfiguration(locations = {"classpath:ctx-conntest-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-conntest-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) -@Listeners({com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class}) +@Listeners({ com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class }) public abstract class AbstractLdapConnTest extends AbstractLdapSynchronizationTest { - private static final Trace LOGGER = TraceManager.getTrace(AbstractLdapConnTest.class); - protected static final String ACCOUNT_IDM_DN = "uid=idm,ou=Administrators,dc=example,dc=com"; protected static final String ACCOUNT_0_UID = "u00000000"; protected static final String ACCOUNT_19_UID = "u00000019"; @@ -105,10 +83,10 @@ public abstract class AbstractLdapConnTest extends AbstractLdapSynchronizationTe private static final String USER_LARGO_GIVEN_NAME = "Largo"; private static final String USER_LARGO_FAMILY_NAME = "LaGrande"; - protected static final File ROLE_UNDEAD_FILE = new File (COMMON_DIR, "role-undead.xml"); + protected static final File ROLE_UNDEAD_FILE = new File(COMMON_DIR, "role-undead.xml"); protected static final String ROLE_UNDEAD_OID = "54885c40-ffcc-11e5-b782-63b3e4e2a69d"; - protected static final File ROLE_EVIL_FILE = new File (COMMON_DIR, "role-evil.xml"); + protected static final File ROLE_EVIL_FILE = new File(COMMON_DIR, "role-evil.xml"); protected static final String ROLE_EVIL_OID = "624b43ec-ffcc-11e5-8297-f392afa54704"; protected static final String GROUP_UNDEAD_CN = "undead"; @@ -149,7 +127,7 @@ protected File getResourceFile() { protected abstract String getAccount0Cn(); protected int getNumberOfAllAccounts() { - return NUMBER_OF_GENERATED_ACCOUNTS + (isIdmAdminInteOrgPerson()?1:0); + return NUMBER_OF_GENERATED_ACCOUNTS + (isIdmAdminInteOrgPerson() ? 1 : 0); } protected boolean hasAssociationShortcut() { @@ -191,8 +169,8 @@ public void test000Sanity() throws Exception { cleanupDelete(toGroupDn(GROUP_EVIL_CN)); if (needsGroupFakeMemeberEntry()) { - addLdapGroup(GROUP_UNDEAD_CN, GROUP_UNDEAD_DESCRIPTION, "uid=fake,"+getPeopleLdapSuffix()); - addLdapGroup(GROUP_EVIL_CN, GROUP_EVIL_DESCRIPTION, "uid=fake,"+getPeopleLdapSuffix()); + addLdapGroup(GROUP_UNDEAD_CN, GROUP_UNDEAD_DESCRIPTION, "uid=fake," + getPeopleLdapSuffix()); + addLdapGroup(GROUP_EVIL_CN, GROUP_EVIL_DESCRIPTION, "uid=fake," + getPeopleLdapSuffix()); } else { addLdapGroup(GROUP_UNDEAD_CN, GROUP_UNDEAD_DESCRIPTION); addLdapGroup(GROUP_EVIL_CN, GROUP_EVIL_DESCRIPTION); @@ -201,11 +179,8 @@ public void test000Sanity() throws Exception { @Test public void test100SeachAccount0ByLdapUid() throws Exception { - final String TEST_NAME = "test100SeachAccount0ByLdapUid"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = createUidQuery(ACCOUNT_0_UID); @@ -214,10 +189,10 @@ public void test100SeachAccount0ByLdapUid() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result); - assertEquals("Unexpected search result: "+shadows, 1, shadows.size()); + assertEquals("Unexpected search result: " + shadows, 1, shadows.size()); PrismObject shadow = shadows.get(0); assertAccountShadow(shadow, toAccountDn(ACCOUNT_0_UID)); @@ -238,16 +213,13 @@ public void test100SeachAccount0ByLdapUid() throws Exception { */ @Test public void test150SeachAllAccounts() throws Exception { - final String TEST_NAME = "test150SeachAllAccounts"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); - SearchResultList> searchResultList = doSearch(TEST_NAME, query, getNumberOfAllAccounts(), task, result); + SearchResultList> searchResultList = doSearch(query, getNumberOfAllAccounts(), task, result); assertConnectorOperationIncrement(1, getNumberOfAllAccounts() + 1); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); @@ -264,16 +236,13 @@ public void test150SeachAllAccounts() throws Exception { @Test public void test151CountAllAccounts() throws Exception { - final String TEST_NAME = "test151CountAllAccounts"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); - displayWhen(TEST_NAME); + when(); Integer count = modelService.countObjects(ShadowType.class, query, null, task, result); assertCountAllAccounts(count); @@ -282,7 +251,7 @@ public void test151CountAllAccounts() throws Exception { } protected void assertCountAllAccounts(Integer count) { - assertEquals("Wrong account count", (Integer)getNumberOfAllAccounts(), count); + assertEquals("Wrong account count", (Integer) getNumberOfAllAccounts(), count); } /** @@ -290,11 +259,8 @@ protected void assertCountAllAccounts(Integer count) { */ @Test public void test152SeachFirst50Accounts() throws Exception { - final String TEST_NAME = "test152SeachFirst50Accounts"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -303,7 +269,7 @@ public void test152SeachFirst50Accounts() throws Exception { paging.setMaxSize(50); query.setPaging(paging); - SearchResultList> searchResultList = doSearch(TEST_NAME, query, 50, task, result); + SearchResultList> searchResultList = doSearch(query, 50, task, result); assertConnectorOperationIncrement(1, 51); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); @@ -324,11 +290,8 @@ public void test152SeachFirst50Accounts() throws Exception { */ @Test public void test154SeachFirst222Accounts() throws Exception { - final String TEST_NAME = "test154SeachFirst222Accounts"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -337,7 +300,7 @@ public void test154SeachFirst222Accounts() throws Exception { paging.setMaxSize(222); query.setPaging(paging); - SearchResultList> searchResultList = doSearch(TEST_NAME, query, 222, task, result); + SearchResultList> searchResultList = doSearch(query, 222, task, result); assertConnectorOperationIncrement(1, 223); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); @@ -358,11 +321,8 @@ public void test154SeachFirst222Accounts() throws Exception { */ @Test public void test156SeachThroughEnd() throws Exception { - final String TEST_NAME = "test156SeachBeyondEnd"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -372,7 +332,7 @@ public void test156SeachThroughEnd() throws Exception { paging.setMaxSize(333); query.setPaging(paging); - SearchResultList> searchResultList = doSearch(TEST_NAME, query, 150, task, result); + SearchResultList> searchResultList = doSearch(query, 150, task, result); assertConnectorOperationIncrement(1, 151); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); @@ -390,11 +350,8 @@ public void test156SeachThroughEnd() throws Exception { */ @Test public void test158SeachBeyondEnd() throws Exception { - final String TEST_NAME = "test158SeachBeyondEnd"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -408,7 +365,7 @@ public void test158SeachBeyondEnd() throws Exception { if (isVlvSearchBeyondEndResurnsLastEntry()) { expectedEntries = 1; } - SearchResultList> searchResultList = doSearch(TEST_NAME, query, expectedEntries, task, result); + SearchResultList> searchResultList = doSearch(query, expectedEntries, task, result); // Fails for 389ds tests. For some unknown reason. And this is not that important. There are similar asserts in other tests that are passing. // assertConnectorOperationIncrement(1); @@ -425,11 +382,8 @@ public void test158SeachBeyondEnd() throws Exception { @Test public void test162SeachFirst50AccountsOffset0() throws Exception { - final String TEST_NAME = "test152SeachFirst50Accounts"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -439,7 +393,7 @@ public void test162SeachFirst50AccountsOffset0() throws Exception { paging.setMaxSize(50); query.setPaging(paging); - SearchResultList> searchResultList = doSearch(TEST_NAME, query, 50, task, result); + SearchResultList> searchResultList = doSearch(query, 50, task, result); assertConnectorOperationIncrement(1, 51); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); @@ -462,11 +416,8 @@ public void test162SeachFirst50AccountsOffset0() throws Exception { */ @Test public void test172Search50AccountsOffset20() throws Exception { - final String TEST_NAME = "test172Search50AccountsOffset20"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -474,7 +425,7 @@ public void test172Search50AccountsOffset20() throws Exception { ObjectPaging paging = prismContext.queryFactory().createPaging(20, 50); query.setPaging(paging); - SearchResultList> searchResultList = doSearch(TEST_NAME, query, 50, task, result); + SearchResultList> searchResultList = doSearch(query, 50, task, result); assertConnectorOperationIncrement(1, 51); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); @@ -494,11 +445,8 @@ public void test172Search50AccountsOffset20() throws Exception { */ @Test public void test174SeachFirst222AccountsOffset20() throws Exception { - final String TEST_NAME = "test174SeachFirst222AccountsOffset20"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -506,7 +454,7 @@ public void test174SeachFirst222AccountsOffset20() throws Exception { ObjectPaging paging = prismContext.queryFactory().createPaging(20, 222); query.setPaging(paging); - SearchResultList> searchResultList = doSearch(TEST_NAME, query, 222, task, result); + SearchResultList> searchResultList = doSearch(query, 222, task, result); assertConnectorOperationIncrement(1, 223); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); @@ -526,11 +474,8 @@ public void test174SeachFirst222AccountsOffset20() throws Exception { */ @Test public void test182Search50AccountsOffset20SortUid() throws Exception { - final String TEST_NAME = "test182Search50AccountsOffset20SortUid"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -539,10 +484,10 @@ public void test182Search50AccountsOffset20SortUid() throws Exception { paging.setOrdering(getAttributePath(resource, "uid"), OrderDirection.ASCENDING); query.setPaging(paging); - SearchResultList> shadows = doSearch(TEST_NAME, query, 50, task, result); + SearchResultList> shadows = doSearch(query, 50, task, result); - assertAccountShadow(shadows.get(0), toAccountDn(isIdmAdminInteOrgPerson()?ACCOUNT_19_UID:ACCOUNT_20_UID)); - assertAccountShadow(shadows.get(49), toAccountDn(isIdmAdminInteOrgPerson()?ACCOUNT_68_UID:ACCOUNT_69_UID)); + assertAccountShadow(shadows.get(0), toAccountDn(isIdmAdminInteOrgPerson() ? ACCOUNT_19_UID : ACCOUNT_20_UID)); + assertAccountShadow(shadows.get(49), toAccountDn(isIdmAdminInteOrgPerson() ? ACCOUNT_68_UID : ACCOUNT_69_UID)); assertConnectorOperationIncrement(1, 51); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); @@ -562,11 +507,8 @@ public void test182Search50AccountsOffset20SortUid() throws Exception { */ @Test public void test184SearchFirst222AccountsOffset20SortUid() throws Exception { - final String TEST_NAME = "test184SeachFirst222AccountsOffset20SortUid"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -575,10 +517,10 @@ public void test184SearchFirst222AccountsOffset20SortUid() throws Exception { paging.setOrdering(getAttributePath(resource, "uid"), OrderDirection.ASCENDING); query.setPaging(paging); - SearchResultList> shadows = doSearch(TEST_NAME, query, 222, task, result); + SearchResultList> shadows = doSearch(query, 222, task, result); - assertAccountShadow(shadows.get(0), toAccountDn(isIdmAdminInteOrgPerson()?ACCOUNT_19_UID:ACCOUNT_20_UID)); - assertAccountShadow(shadows.get(221), toAccountDn(isIdmAdminInteOrgPerson()?ACCOUNT_240_UID:ACCOUNT_241_UID)); + assertAccountShadow(shadows.get(0), toAccountDn(isIdmAdminInteOrgPerson() ? ACCOUNT_19_UID : ACCOUNT_20_UID)); + assertAccountShadow(shadows.get(221), toAccountDn(isIdmAdminInteOrgPerson() ? ACCOUNT_240_UID : ACCOUNT_241_UID)); assertConnectorOperationIncrement(1, 223); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); @@ -597,17 +539,14 @@ public void test184SearchFirst222AccountsOffset20SortUid() throws Exception { */ @Test public void test190SeachAllAccountsSizelimit() throws Exception { - final String TEST_NAME = "test190SeachAllAccountsSizelimit"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); query.setAllowPartialResults(true); - SearchResultList> resultList = doSearch(TEST_NAME, query, getSearchSizeLimit(), task, result); + SearchResultList> resultList = doSearch(query, getSearchSizeLimit(), task, result); assertConnectorOperationIncrement(1, getSearchSizeLimit() + 1); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); @@ -627,16 +566,13 @@ public void test190SeachAllAccountsSizelimit() throws Exception { */ @Test public void test195SearchInferno() throws Exception { - final String TEST_NAME = "test195SearchInferno"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); // WHEN - displayWhen(TEST_NAME); + when(); singleInfernoSearch(query, 30, 10, 30, "uid", task, result); singleInfernoSearch(query, 40, 5, 40, "cn", task, result); singleInfernoSearch(query, 15, 2, 15, "sn", task, result); @@ -674,20 +610,17 @@ public boolean handle(PrismObject object, OperationResult parentResu @Test public void test200AssignAccountToBarbossa() throws Exception { - final String TEST_NAME = "test200AssignAccountToBarbossa"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); long tsStart = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_BARBOSSA_OID, getResourceOid(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -705,29 +638,26 @@ public void test200AssignAccountToBarbossa() throws Exception { accountBarbossaOid = shadow.getOid(); Collection> identifiers = ShadowUtil.getPrimaryIdentifiers(shadow); accountBarbossaEntryId = (String) identifiers.iterator().next().getRealValue(); - assertNotNull("No identifier in "+shadow, accountBarbossaEntryId); + assertNotNull("No identifier in " + shadow, accountBarbossaEntryId); assertEquals("Wrong ICFS UID", getAttributeAsString(entry, getPrimaryIdentifierAttributeName()), accountBarbossaEntryId); assertLdapPassword(USER_BARBOSSA_USERNAME, USER_BARBOSSA_PASSWORD); ResourceAttribute createTimestampAttribute = ShadowUtil.getAttribute(shadow, new QName(MidPointConstants.NS_RI, "createTimestamp")); - assertNotNull("No createTimestamp in "+shadow, createTimestampAttribute); + assertNotNull("No createTimestamp in " + shadow, createTimestampAttribute); XMLGregorianCalendar createTimestamp = createTimestampAttribute.getRealValue(); long createTimestampMillis = XmlTypeConverter.toMillis(createTimestamp); // LDAP server may be on a different host. Allow for some clock offset. - TestUtil.assertBetween("Wrong createTimestamp in "+shadow, roundTsDown(tsStart)-1000, roundTsUp(tsEnd)+1000, createTimestampMillis); + TestUtil.assertBetween("Wrong createTimestamp in " + shadow, roundTsDown(tsStart) - 1000, roundTsUp(tsEnd) + 1000, createTimestampMillis); assertLdapConnectorInstances(1, 2); } @Test public void test210ModifyAccountBarbossaReplaceTitle() throws Exception { - final String TEST_NAME = "test210ModifyAccountBarbossaReplaceTitle"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object() @@ -739,11 +669,11 @@ public void test210ModifyAccountBarbossaReplaceTitle() throws Exception { delta.addModification(attrDelta); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -763,11 +693,8 @@ public void test210ModifyAccountBarbossaReplaceTitle() throws Exception { */ @Test public void test212ModifyAccountBarbossaAddTitleDuplicate() throws Exception { - final String TEST_NAME = "test212ModifyAccountBarbossaAddTitleDuplicate"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object() @@ -779,11 +706,11 @@ public void test212ModifyAccountBarbossaAddTitleDuplicate() throws Exception { delta.addModification(attrDelta); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -803,11 +730,8 @@ public void test212ModifyAccountBarbossaAddTitleDuplicate() throws Exception { */ @Test public void test213ModifyAccountBarbossaAddTitleDuplicateCapitalized() throws Exception { - final String TEST_NAME = "test213ModifyAccountBarbossaAddTitleDuplicateCapitalized"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object() @@ -819,11 +743,11 @@ public void test213ModifyAccountBarbossaAddTitleDuplicateCapitalized() throws Ex delta.addModification(attrDelta); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -839,22 +763,19 @@ public void test213ModifyAccountBarbossaAddTitleDuplicateCapitalized() throws Ex @Test public void test220ModifyUserBarbossaPassword() throws Exception { - final String TEST_NAME = "test220ModifyUserBarbossaPassword"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ProtectedStringType userPasswordPs = new ProtectedStringType(); userPasswordPs.setClearValue(USER_BARBOSSA_PASSWORD_2); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, PATH_CREDENTIALS_PASSWORD_VALUE, task, result, userPasswordPs); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -871,19 +792,16 @@ public void test220ModifyUserBarbossaPassword() throws Exception { @Test public void test230ModifyUserBarbossaEmployeeType() throws Exception { - final String TEST_NAME = "test230ModifyUserBarbossaEmployeeType"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, UserType.F_EMPLOYEE_TYPE, task, result, "Pirate"); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -899,19 +817,16 @@ public void test230ModifyUserBarbossaEmployeeType() throws Exception { @Test public void test232ModifyUserBarbossaEmployeeTypeAgain() throws Exception { - final String TEST_NAME = "test232ModifyUserBarbossaEmployeeTypeAgain"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, UserType.F_EMPLOYEE_TYPE, task, result, "Pirate"); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -927,19 +842,16 @@ public void test232ModifyUserBarbossaEmployeeTypeAgain() throws Exception { @Test public void test234ModifyUserBarbossaEmployeeTypeAgainCapitalized() throws Exception { - final String TEST_NAME = "test234ModifyUserBarbossaEmployeeTypeAgainCapitalized"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, UserType.F_EMPLOYEE_TYPE, task, result, "PIRATE"); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -955,19 +867,16 @@ public void test234ModifyUserBarbossaEmployeeTypeAgainCapitalized() throws Excep @Test public void test290ModifyUserBarbossaRename() throws Exception { - final String TEST_NAME = "test290ModifyUserBarbossaRename"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, UserType.F_NAME, task, result, PrismTestUtil.createPolyString(USER_CPTBARBOSSA_USERNAME)); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -999,22 +908,19 @@ public void test290ModifyUserBarbossaRename() throws Exception { */ @Test public void test292ModifyUserBarbossaRenameCapitalized() throws Exception { - final String TEST_NAME = "test292ModifyUserBarbossaRenameCapitalized"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberCounter(InternalCounters.CONNECTOR_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, UserType.F_NAME, task, result, PrismTestUtil.createPolyString(USER_CPTBARBOSSA_USERNAME.toUpperCase())); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1044,19 +950,16 @@ public void test292ModifyUserBarbossaRenameCapitalized() throws Exception { @Test public void test299UnAssignAccountBarbossa() throws Exception { - final String TEST_NAME = "test299UnAssignAccountBarbossa"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_BARBOSSA_OID, getResourceOid(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1070,23 +973,20 @@ public void test299UnAssignAccountBarbossa() throws Exception { } /** - * MID-2853: Unexpected association behaviour - removing roles does not always remove from groups + * MID-2853: Unexpected association behaviour - removing roles does not always remove from groups */ @Test public void test300AssignRoleEvilToLechuck() throws Exception { - final String TEST_NAME = "test300AssignRoleEvilToLechuck"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_LECHUCK_OID, ROLE_EVIL_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1112,23 +1012,20 @@ public void test300AssignRoleEvilToLechuck() throws Exception { } /** - * MID-2853: Unexpected association behaviour - removing roles does not always remove from groups + * MID-2853: Unexpected association behaviour - removing roles does not always remove from groups */ @Test public void test302AssignRoleUndeadToLechuck() throws Exception { - final String TEST_NAME = "test302AssignRoleUndeadToLechuck"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_LECHUCK_OID, ROLE_UNDEAD_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1151,23 +1048,20 @@ public void test302AssignRoleUndeadToLechuck() throws Exception { } /** - * MID-2853: Unexpected association behaviour - removing roles does not always remove from groups + * MID-2853: Unexpected association behaviour - removing roles does not always remove from groups */ @Test public void test306UnassignRoleEvilFromLechuck() throws Exception { - final String TEST_NAME = "test306UnassignRoleEvilFromLechuck"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_LECHUCK_OID, ROLE_EVIL_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1190,23 +1084,20 @@ public void test306UnassignRoleEvilFromLechuck() throws Exception { } /** - * MID-2853: Unexpected association behaviour - removing roles does not always remove from groups + * MID-2853: Unexpected association behaviour - removing roles does not always remove from groups */ @Test public void test309UnassignRoleUndeadFromLechuck() throws Exception { - final String TEST_NAME = "test309UnassignRoleUndeadFromLechuck"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_LECHUCK_OID, ROLE_UNDEAD_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1230,11 +1121,8 @@ public void test309UnassignRoleUndeadFromLechuck() throws Exception { @Test public void test310SeachGroupEvilByCn() throws Exception { - final String TEST_NAME = "test310SeachGroupEvilByCn"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getGroupObjectClass(), prismContext); ObjectQueryUtil.filterAnd(query.getFilter(), createAttributeFilter("cn", GROUP_EVIL_CN), prismContext); @@ -1243,10 +1131,10 @@ public void test310SeachGroupEvilByCn() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result); - assertEquals("Unexpected search result: "+shadows, 1, shadows.size()); + assertEquals("Unexpected search result: " + shadows, 1, shadows.size()); PrismObject shadow = shadows.get(0); assertGroupShadow(shadow, toGroupDn(GROUP_EVIL_CN)); @@ -1265,23 +1153,20 @@ public void test310SeachGroupEvilByCn() throws Exception { } /** - * MID-3209: Rename does not change group membership for associations, when resource does not implement its own referential integrity + * MID-3209: Rename does not change group membership for associations, when resource does not implement its own referential integrity */ @Test public void test312AssignRoleEvilToBarbossa() throws Exception { - final String TEST_NAME = "test312AssignRoleEvilToBarbossa"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_BARBOSSA_OID, ROLE_EVIL_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1298,7 +1183,7 @@ public void test312AssignRoleEvilToBarbossa() throws Exception { Collection> identifiers = ShadowUtil.getPrimaryIdentifiers(shadow); accountBarbossaEntryId = (String) identifiers.iterator().next().getRealValue(); - assertNotNull("No identifier in "+shadow, accountBarbossaEntryId); + assertNotNull("No identifier in " + shadow, accountBarbossaEntryId); Entry ldapEntryEvil = getLdapEntry(toGroupDn(GROUP_EVIL_CN)); display("Evil group", ldapEntryEvil); @@ -1314,15 +1199,12 @@ public void test312AssignRoleEvilToBarbossa() throws Exception { } /** - * MID-3209: Rename does not change group membership for associations, when resource does not implement its own referential integrity + * MID-3209: Rename does not change group membership for associations, when resource does not implement its own referential integrity */ @Test public void test314ModifyUserBarbossaRenameBack() throws Exception { - final String TEST_NAME = "test314ModifyUserBarbossaRenameBack"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_BARBOSSA_OID); @@ -1330,11 +1212,11 @@ public void test314ModifyUserBarbossaRenameBack() throws Exception { assertNotNull(userBefore); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, UserType.F_NAME, task, result, PrismTestUtil.createPolyString(USER_BARBOSSA_USERNAME)); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1374,11 +1256,8 @@ public void test314ModifyUserBarbossaRenameBack() throws Exception { */ @Test public void test320AddEvilUserLargo() throws Exception { - final String TEST_NAME = "test320AddEvilUserLargo"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = createUser(USER_LARGO_NAME, USER_LARGO_GIVEN_NAME, USER_LARGO_FAMILY_NAME, true); @@ -1387,11 +1266,11 @@ public void test320AddEvilUserLargo() throws Exception { display("user before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); addObject(userBefore, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1421,30 +1300,28 @@ public void test320AddEvilUserLargo() throws Exception { } @Test - public void test350SeachInvisibleAccount() throws Exception { - final String TEST_NAME = "test350SeachInvisibleAccount"; - displayTestTitle(TEST_NAME); - + public void test350SearchInvisibleAccount() throws Exception { // GIVEN createBilboEntry(); - SearchResultList> shadows = searchBilbo(TEST_NAME); + SearchResultList> shadows = searchBilbo(); - assertEquals("Unexpected search result: "+shadows, 1, shadows.size()); + assertEquals("Unexpected search result: " + shadows, 1, shadows.size()); PrismObject shadow = shadows.get(0); assertAccountShadow(shadow, toAccountDn(ACCOUNT_BILBO_UID)); } protected Entry createBilboEntry() throws LdapException, IOException { - Entry entry = createAccountEntry(ACCOUNT_BILBO_UID, ACCOUNT_BILBO_CN, ACCOUNT_BILBO_GIVENNAME, ACCOUNT_BILBO_SN); + Entry entry = createAccountEntry( + ACCOUNT_BILBO_UID, ACCOUNT_BILBO_CN, ACCOUNT_BILBO_GIVENNAME, ACCOUNT_BILBO_SN); entry.add(LDAP_ATTRIBUTE_ROOM_NUMBER, ROOM_NUMBER_INVISIBLE); addLdapEntry(entry); return entry; } - protected SearchResultList> searchBilbo(final String TEST_NAME) throws Exception { - Task task = createTask(TEST_NAME); + protected SearchResultList> searchBilbo() throws Exception { + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = createUidQuery(ACCOUNT_BILBO_UID); @@ -1453,15 +1330,15 @@ protected SearchResultList> searchBilbo(final String TES rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Bilbos", shadows); - assertLdapConnectorInstances(1,2); + assertLdapConnectorInstances(1, 2); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); return shadows; diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractLdapSynchronizationTest.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractLdapSynchronizationTest.java index dae58f0e751..86996c24951 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractLdapSynchronizationTest.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractLdapSynchronizationTest.java @@ -6,20 +6,11 @@ * and European Union Public License. See LICENSE file for details. */ - -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertTrue; import static org.testng.AssertJUnit.assertNotNull; -import static com.evolveum.midpoint.test.IntegrationTestTools.display; -import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertNull; import java.util.List; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.annotation.DirtiesContext.ClassMode; -import org.springframework.test.context.ContextConfiguration; -import org.testng.annotations.Test; import org.apache.directory.api.ldap.model.entry.DefaultModification; import org.apache.directory.api.ldap.model.entry.Modification; import org.apache.directory.api.ldap.model.entry.ModificationOperation; @@ -29,6 +20,10 @@ import org.apache.directory.api.ldap.model.message.ModifyDnResponse; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.ldap.client.api.LdapNetworkConnection; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.DirtiesContext.ClassMode; +import org.springframework.test.context.ContextConfiguration; +import org.testng.annotations.Test; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.util.PrismAsserts; @@ -37,8 +32,6 @@ import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.ObjectNotFoundException; import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; @@ -46,14 +39,11 @@ /** * @author Radovan Semancik - * */ -@ContextConfiguration(locations = {"classpath:ctx-conntest-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-conntest-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public abstract class AbstractLdapSynchronizationTest extends AbstractLdapTest { - private static final Trace LOGGER = TraceManager.getTrace(AbstractLdapSynchronizationTest.class); - protected static final String ACCOUNT_HT_UID = "ht"; protected static final String ACCOUNT_HT_CN = "Herman Toothrot"; protected static final String ACCOUNT_HT_GIVENNAME = "Herman"; @@ -69,7 +59,6 @@ public abstract class AbstractLdapSynchronizationTest extends AbstractLdapTest { protected static final String GROUP_FOOLS_CN = "fools"; protected static final String GROUP_FOOLS_DESCRIPTION = "not quite the shilling"; - protected abstract void assertStepSyncToken(String syncTaskOid, int step, long tsStart, long tsEnd) throws ObjectNotFoundException, SchemaException; protected boolean syncCanDetectDelete() { @@ -98,21 +87,18 @@ protected void assertAdditionalCapabilities(List nativeCapabilities) { @Test public void test800ImportSyncTask() throws Exception { - final String TEST_NAME = "test800ImportSyncTask"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); long tsStart = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); addObject(getSyncTaskFile(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -125,22 +111,19 @@ public void test800ImportSyncTask() throws Exception { @Test public void test801SyncAddAccountHt() throws Exception { - final String TEST_NAME = "test801SyncAddAccountHt"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); long tsStart = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); addLdapAccount(ACCOUNT_HT_UID, ACCOUNT_HT_CN, ACCOUNT_HT_GIVENNAME, ACCOUNT_HT_SN); waitForTaskNextRunAssertSuccess(getSyncTaskOid(), true); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); long tsEnd = System.currentTimeMillis(); @@ -148,7 +131,7 @@ public void test801SyncAddAccountHt() throws Exception { displayUsers(); PrismObject user = findUserByUsername(ACCOUNT_HT_UID); - assertNotNull("No user "+ACCOUNT_HT_UID+" created", user); + assertNotNull("No user " + ACCOUNT_HT_UID + " created", user); assertUser(user, user.getOid(), ACCOUNT_HT_UID, ACCOUNT_HT_CN, ACCOUNT_HT_GIVENNAME, ACCOUNT_HT_SN); assertStepSyncToken(getSyncTaskOid(), 1, tsStart, tsEnd); @@ -160,17 +143,14 @@ public void test801SyncAddAccountHt() throws Exception { */ @Test public void test802ModifyAccountHtSn() throws Exception { - final String TEST_NAME = "test802ModifyAccountHtSn"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); long tsStart = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); LdapNetworkConnection connection = ldapConnect(); Modification modSn = new DefaultModification(ModificationOperation.REPLACE_ATTRIBUTE, "sn", ACCOUNT_HT_SN_MODIFIED); connection.modify(toAccountDn(ACCOUNT_HT_UID, ACCOUNT_HT_CN), modSn); @@ -179,13 +159,13 @@ public void test802ModifyAccountHtSn() throws Exception { waitForTaskNextRunAssertSuccess(getSyncTaskOid(), true); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); long tsEnd = System.currentTimeMillis(); PrismObject user = findUserByUsername(ACCOUNT_HT_UID); - assertNotNull("No user "+ACCOUNT_HT_UID+" created", user); + assertNotNull("No user " + ACCOUNT_HT_UID + " created", user); assertUser(user, user.getOid(), ACCOUNT_HT_UID, ACCOUNT_HT_CN, ACCOUNT_HT_GIVENNAME, ACCOUNT_HT_SN_MODIFIED); assertStepSyncToken(getSyncTaskOid(), 2, tsStart, tsEnd); @@ -194,52 +174,46 @@ public void test802ModifyAccountHtSn() throws Exception { @Test public void test810SyncAddGroupMonkeys() throws Exception { - final String TEST_NAME = "test810SyncAddGroupMonkeys"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); long tsStart = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); if (needsGroupFakeMemeberEntry()) { - addLdapGroup(GROUP_MONKEYS_CN, GROUP_MONKEYS_DESCRIPTION, "uid=fake,"+getPeopleLdapSuffix()); + addLdapGroup(GROUP_MONKEYS_CN, GROUP_MONKEYS_DESCRIPTION, "uid=fake," + getPeopleLdapSuffix()); } else { addLdapGroup(GROUP_MONKEYS_CN, GROUP_MONKEYS_DESCRIPTION); } waitForTaskNextRunAssertSuccess(getSyncTaskOid(), true); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); long tsEnd = System.currentTimeMillis(); PrismObject role = findObjectByName(RoleType.class, GROUP_MONKEYS_CN); display("Role", role); - assertNotNull("no role "+GROUP_MONKEYS_CN, role); + assertNotNull("no role " + GROUP_MONKEYS_CN, role); PrismAsserts.assertPropertyValue(role, RoleType.F_DESCRIPTION, GROUP_MONKEYS_DESCRIPTION); - assertNotNull("No role "+GROUP_MONKEYS_CN+" created", role); + assertNotNull("No role " + GROUP_MONKEYS_CN + " created", role); assertStepSyncToken(getSyncTaskOid(), 3, tsStart, tsEnd); } @Test public void test817RenameAccount() throws Exception { - final String TEST_NAME = "test817RenameAccount"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); long tsStart = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); LdapNetworkConnection connection = ldapConnect(); ModifyDnRequest modDnRequest = new ModifyDnRequestImpl(); @@ -247,7 +221,7 @@ public void test817RenameAccount() throws Exception { modDnRequest.setNewRdn(toAccountRdn(ACCOUNT_HTM_UID, ACCOUNT_HTM_CN)); modDnRequest.setDeleteOldRdn(true); ModifyDnResponse modDnResponse = connection.modifyDn(modDnRequest); - display("Modified "+toAccountDn(ACCOUNT_HT_UID, ACCOUNT_HT_CN)+" -> "+toAccountRdn(ACCOUNT_HTM_UID, ACCOUNT_HTM_CN)+": "+modDnResponse); + display("Modified " + toAccountDn(ACCOUNT_HT_UID, ACCOUNT_HT_CN) + " -> " + toAccountRdn(ACCOUNT_HTM_UID, ACCOUNT_HTM_CN) + ": " + modDnResponse); doAdditionalRenameModifications(connection); @@ -256,15 +230,15 @@ public void test817RenameAccount() throws Exception { waitForTaskNextRunAssertSuccess(getSyncTaskOid(), true); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); long tsEnd = System.currentTimeMillis(); PrismObject user = findUserByUsername(ACCOUNT_HTM_UID); - assertNotNull("No user "+ACCOUNT_HTM_UID+" created", user); + assertNotNull("No user " + ACCOUNT_HTM_UID + " created", user); assertUser(user, user.getOid(), ACCOUNT_HTM_UID, getAccountHtmCnAfterRename(), ACCOUNT_HT_GIVENNAME, ACCOUNT_HT_SN_MODIFIED); - assertNull("User "+ACCOUNT_HT_UID+" still exist", findUserByUsername(ACCOUNT_HT_UID)); + assertNull("User " + ACCOUNT_HT_UID + " still exist", findUserByUsername(ACCOUNT_HT_UID)); assertStepSyncToken(getSyncTaskOid(), 4, tsStart, tsEnd); @@ -280,11 +254,8 @@ protected void doAdditionalRenameModifications(LdapNetworkConnection connection) @Test public void test818DeleteAccountHtm() throws Exception { - final String TEST_NAME = "test818DeleteAccountHtm"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = findUserByUsername(ACCOUNT_HTM_UID); @@ -292,21 +263,21 @@ public void test818DeleteAccountHtm() throws Exception { long tsStart = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); deleteLdapEntry(toAccountDn(ACCOUNT_HTM_UID, ACCOUNT_HTM_CN)); waitForTaskNextRunAssertSuccess(getSyncTaskOid(), true); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); long tsEnd = System.currentTimeMillis(); if (syncCanDetectDelete()) { - assertNull("User "+ACCOUNT_HTM_UID+" still exist", findUserByUsername(ACCOUNT_HTM_UID)); - assertNull("User "+ACCOUNT_HT_UID+" still exist", findUserByUsername(ACCOUNT_HT_UID)); + assertNull("User " + ACCOUNT_HTM_UID + " still exist", findUserByUsername(ACCOUNT_HTM_UID)); + assertNull("User " + ACCOUNT_HT_UID + " still exist", findUserByUsername(ACCOUNT_HT_UID)); } else { // Just delete the user so we have consistent state for subsequent tests deleteObject(UserType.class, user.getOid(), task, result); @@ -315,24 +286,20 @@ public void test818DeleteAccountHtm() throws Exception { assertStepSyncToken(getSyncTaskOid(), 5, tsStart, tsEnd); } - // TODO: sync with "ALL" object class @Test public void test819DeleteSyncTask() throws Exception { - final String TEST_NAME = "test819DeleteSyncTask"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); deleteObject(TaskType.class, getSyncTaskOid(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -341,21 +308,18 @@ public void test819DeleteSyncTask() throws Exception { @Test public void test820ImportSyncTaskInetOrgPerson() throws Exception { - final String TEST_NAME = "test820ImportSyncTaskInetOrgPerson"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); long tsStart = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); addObject(getSyncTaskInetOrgPersonFile(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -371,22 +335,19 @@ public void test820ImportSyncTaskInetOrgPerson() throws Exception { @Test public void test821SyncAddAccountHt() throws Exception { - final String TEST_NAME = "test821SyncAddAccountHt"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); long tsStart = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); addLdapAccount(ACCOUNT_HT_UID, ACCOUNT_HT_CN, ACCOUNT_HT_GIVENNAME, ACCOUNT_HT_SN); waitForTaskNextRunAssertSuccess(getSyncTaskOid(), true); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -395,7 +356,7 @@ public void test821SyncAddAccountHt() throws Exception { displayUsers(); PrismObject user = findUserByUsername(ACCOUNT_HT_UID); - assertNotNull("No user "+ACCOUNT_HT_UID+" created", user); + assertNotNull("No user " + ACCOUNT_HT_UID + " created", user); assertUser(user, user.getOid(), ACCOUNT_HT_UID, ACCOUNT_HT_CN, ACCOUNT_HT_GIVENNAME, ACCOUNT_HT_SN); assertStepSyncToken(getSyncTaskOid(), 6, tsStart, tsEnd); @@ -403,17 +364,14 @@ public void test821SyncAddAccountHt() throws Exception { @Test public void test822ModifyAccountHt() throws Exception { - final String TEST_NAME = "test822ModifyAccountHt"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); long tsStart = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); LdapNetworkConnection connection = ldapConnect(); Modification modCn = new DefaultModification(ModificationOperation.REPLACE_ATTRIBUTE, "sn", ACCOUNT_HT_SN_MODIFIED); connection.modify(toAccountDn(ACCOUNT_HT_UID, ACCOUNT_HT_CN), modCn); @@ -422,14 +380,14 @@ public void test822ModifyAccountHt() throws Exception { waitForTaskNextRunAssertSuccess(getSyncTaskOid(), true); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); long tsEnd = System.currentTimeMillis(); PrismObject user = findUserByUsername(ACCOUNT_HT_UID); - assertNotNull("No user "+ACCOUNT_HT_UID+" created", user); + assertNotNull("No user " + ACCOUNT_HT_UID + " created", user); assertUser(user, user.getOid(), ACCOUNT_HT_UID, ACCOUNT_HT_CN, ACCOUNT_HT_GIVENNAME, ACCOUNT_HT_SN_MODIFIED); assertStepSyncToken(getSyncTaskOid(), 7, tsStart, tsEnd); @@ -440,45 +398,39 @@ public void test822ModifyAccountHt() throws Exception { */ @Test public void test830AddGroupFools() throws Exception { - final String TEST_NAME = "test830AddGroupFools"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); long tsStart = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); addLdapGroup(GROUP_FOOLS_CN, GROUP_FOOLS_DESCRIPTION, toGroupDn("nobody")); waitForTaskNextRunAssertSuccess(getSyncTaskOid(), true); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); long tsEnd = System.currentTimeMillis(); PrismObject roleFools = findObjectByName(RoleType.class, GROUP_FOOLS_CN); - assertNull("Unexpected role "+roleFools, roleFools); + assertNull("Unexpected role " + roleFools, roleFools); assertStepSyncToken(getSyncTaskOid(), 8, tsStart, tsEnd); } @Test public void test837RenameAccount() throws Exception { - final String TEST_NAME = "test837RenameAccount"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); long tsStart = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); LdapNetworkConnection connection = ldapConnect(); ModifyDnRequest modDnRequest = new ModifyDnRequestImpl(); @@ -486,7 +438,7 @@ public void test837RenameAccount() throws Exception { modDnRequest.setNewRdn(toAccountRdn(ACCOUNT_HTM_UID, ACCOUNT_HTM_CN)); modDnRequest.setDeleteOldRdn(true); ModifyDnResponse modDnResponse = connection.modifyDn(modDnRequest); - display("Modified "+toAccountDn(ACCOUNT_HT_UID,ACCOUNT_HT_CN)+" -> "+toAccountRdn(ACCOUNT_HTM_UID, ACCOUNT_HTM_CN)+": "+modDnResponse); + display("Modified " + toAccountDn(ACCOUNT_HT_UID, ACCOUNT_HT_CN) + " -> " + toAccountRdn(ACCOUNT_HTM_UID, ACCOUNT_HTM_CN) + ": " + modDnResponse); doAdditionalRenameModifications(connection); @@ -495,15 +447,15 @@ public void test837RenameAccount() throws Exception { waitForTaskNextRunAssertSuccess(getSyncTaskOid(), true); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); long tsEnd = System.currentTimeMillis(); PrismObject user = findUserByUsername(ACCOUNT_HTM_UID); - assertNotNull("No user "+ACCOUNT_HTM_UID+" created", user); + assertNotNull("No user " + ACCOUNT_HTM_UID + " created", user); assertUser(user, user.getOid(), ACCOUNT_HTM_UID, getAccountHtmCnAfterRename(), ACCOUNT_HT_GIVENNAME, ACCOUNT_HT_SN_MODIFIED); - assertNull("User "+ACCOUNT_HT_UID+" still exist", findUserByUsername(ACCOUNT_HT_UID)); + assertNull("User " + ACCOUNT_HT_UID + " still exist", findUserByUsername(ACCOUNT_HT_UID)); assertStepSyncToken(getSyncTaskOid(), 9, tsStart, tsEnd); @@ -513,11 +465,8 @@ public void test837RenameAccount() throws Exception { @Test public void test838DeleteAccountHtm() throws Exception { - final String TEST_NAME = "test838DeleteAccountHtm"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = findUserByUsername(ACCOUNT_HTM_UID); @@ -525,20 +474,20 @@ public void test838DeleteAccountHtm() throws Exception { long tsStart = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); - deleteLdapEntry(toAccountDn(ACCOUNT_HTM_UID,ACCOUNT_HTM_CN)); + when(); + deleteLdapEntry(toAccountDn(ACCOUNT_HTM_UID, ACCOUNT_HTM_CN)); waitForTaskNextRunAssertSuccess(getSyncTaskOid(), true); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); long tsEnd = System.currentTimeMillis(); if (syncCanDetectDelete()) { - assertNull("User "+ACCOUNT_HTM_UID+" still exist", findUserByUsername(ACCOUNT_HTM_UID)); - assertNull("User "+ACCOUNT_HT_UID+" still exist", findUserByUsername(ACCOUNT_HT_UID)); + assertNull("User " + ACCOUNT_HTM_UID + " still exist", findUserByUsername(ACCOUNT_HTM_UID)); + assertNull("User " + ACCOUNT_HT_UID + " still exist", findUserByUsername(ACCOUNT_HT_UID)); } else { // Just delete the user so we have consistent state for subsequent tests deleteObject(UserType.class, user.getOid(), task, result); @@ -549,19 +498,16 @@ public void test838DeleteAccountHtm() throws Exception { @Test public void test839DeleteSyncTask() throws Exception { - final String TEST_NAME = "test839DeleteSyncTask"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); deleteObject(TaskType.class, getSyncTaskOid(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertNoObject(TaskType.class, getSyncTaskOid(), task, result); 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 70a8580a047..900752738bf 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 @@ -6,44 +6,18 @@ * and European Union Public License. See LICENSE file for details. */ +import static org.testng.AssertJUnit.*; import static com.evolveum.midpoint.test.IntegrationTestTools.LDAP_CONNECTOR_TYPE; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertTrue; -import static org.testng.AssertJUnit.assertNotNull; -import static com.evolveum.midpoint.test.IntegrationTestTools.display; -import static org.testng.AssertJUnit.assertEquals; import java.io.File; import java.io.IOException; -import java.security.cert.CertificateException; import java.security.cert.X509Certificate; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - +import java.util.*; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; import javax.xml.namespace.QName; -import com.evolveum.midpoint.common.refinery.RefinedResourceSchema; -import com.evolveum.midpoint.model.impl.sync.ReconciliationTaskHandler; -import com.evolveum.midpoint.prism.PrismConstants; -import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.aspect.ProfilingDataManager; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.annotation.DirtiesContext.ClassMode; -import org.springframework.test.context.ContextConfiguration; -import org.testng.AssertJUnit; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Listeners; -import org.testng.annotations.Test; import org.apache.directory.api.ldap.codec.api.DefaultConfigurableBinaryAttributeDetector; import org.apache.directory.api.ldap.model.cursor.CursorException; import org.apache.directory.api.ldap.model.cursor.CursorLdapReferralException; @@ -56,33 +30,31 @@ import org.apache.directory.api.ldap.model.exception.LdapException; import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException; import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException; -import org.apache.directory.api.ldap.model.message.BindRequest; -import org.apache.directory.api.ldap.model.message.BindRequestImpl; -import org.apache.directory.api.ldap.model.message.BindResponse; -import org.apache.directory.api.ldap.model.message.Response; -import org.apache.directory.api.ldap.model.message.ResultCodeEnum; -import org.apache.directory.api.ldap.model.message.SearchRequest; -import org.apache.directory.api.ldap.model.message.SearchRequestImpl; -import org.apache.directory.api.ldap.model.message.SearchResultEntry; -import org.apache.directory.api.ldap.model.message.SearchScope; +import org.apache.directory.api.ldap.model.message.*; import org.apache.directory.api.ldap.model.name.Ava; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.api.ldap.model.name.Rdn; import org.apache.directory.ldap.client.api.LdapNetworkConnection; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.DirtiesContext.ClassMode; +import org.springframework.test.context.ContextConfiguration; +import org.testng.AssertJUnit; +import org.testng.annotations.AfterClass; +import org.testng.annotations.Listeners; +import org.testng.annotations.Test; +import com.evolveum.midpoint.common.refinery.RefinedResourceSchema; +import com.evolveum.midpoint.model.impl.sync.ReconciliationTaskHandler; import com.evolveum.midpoint.model.test.AbstractModelIntegrationTest; +import com.evolveum.midpoint.prism.PrismConstants; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.match.MatchingRule; import com.evolveum.midpoint.prism.match.MatchingRuleRegistry; import com.evolveum.midpoint.prism.query.ObjectFilter; import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.prism.util.PrismAsserts; -import com.evolveum.midpoint.schema.CapabilityUtil; -import com.evolveum.midpoint.schema.GetOperationOptions; -import com.evolveum.midpoint.schema.ResultHandler; -import com.evolveum.midpoint.schema.SearchResultList; -import com.evolveum.midpoint.schema.SearchResultMetadata; -import com.evolveum.midpoint.schema.SelectorOptions; +import com.evolveum.midpoint.schema.*; import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.internals.InternalCounters; import com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition; @@ -94,35 +66,18 @@ import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.util.Lsof; import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; -import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SecurityViolationException; +import com.evolveum.midpoint.util.DOMUtil; +import com.evolveum.midpoint.util.aspect.ProfilingDataManager; +import com.evolveum.midpoint.util.exception.*; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilitiesType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemObjectsType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CreateCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.DeleteCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ReadCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.UpdateCapabilityType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; +import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.*; /** * @author Radovan Semancik - * */ -@ContextConfiguration(locations = {"classpath:ctx-conntest-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-conntest-test-main.xml" }) @Listeners({ com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public abstract class AbstractLdapTest extends AbstractModelIntegrationTest { @@ -155,12 +110,12 @@ public abstract class AbstractLdapTest extends AbstractModelIntegrationTest { // Barbossa after rename protected static final String USER_CPTBARBOSSA_USERNAME = "cptbarbossa"; - protected static final File USER_GUYBRUSH_FILE = new File (COMMON_DIR, "user-guybrush.xml"); + protected static final File USER_GUYBRUSH_FILE = new File(COMMON_DIR, "user-guybrush.xml"); protected static final String USER_GUYBRUSH_OID = "c0c010c0-d34d-b33f-f00d-111111111116"; protected static final String USER_GUYBRUSH_USERNAME = "guybrush"; protected static final String USER_GUYBRUSH_FULL_NAME = "Guybrush Threepwood"; - protected static final File USER_LECHUCK_FILE = new File (COMMON_DIR, "user-lechuck.xml"); + protected static final File USER_LECHUCK_FILE = new File(COMMON_DIR, "user-lechuck.xml"); protected static final String USER_LECHUCK_OID = "0201583e-ffca-11e5-a949-affff1aa5a60"; protected static final String USER_LECHUCK_USERNAME = "lechuck"; protected static final String USER_LECHUCK_FULL_NAME = "LeChuck"; @@ -201,7 +156,6 @@ protected void startResources() throws Exception { stopCommand = getStopSystemCommand(); } - public abstract String getStartSystemCommand(); public abstract String getStopSystemCommand(); @@ -270,11 +224,11 @@ protected String getLdapSuffix() { } protected String getPeopleLdapSuffix() { - return "ou=People,"+getLdapSuffix(); + return "ou=People," + getLdapSuffix(); } protected String getGroupsLdapSuffix() { - return "ou=groups,"+getLdapSuffix(); + return "ou=groups," + getLdapSuffix(); } public String getPrimaryIdentifierAttributeName() { @@ -282,7 +236,7 @@ public String getPrimaryIdentifierAttributeName() { } public QName getPrimaryIdentifierAttributeQName() { - return new QName(MidPointConstants.NS_RI,getPrimaryIdentifierAttributeName()); + return new QName(MidPointConstants.NS_RI, getPrimaryIdentifierAttributeName()); } protected abstract String getLdapGroupObjectClass(); @@ -321,7 +275,9 @@ protected QName getAssociationGroupName() { return new QName(MidPointConstants.NS_RI, "group"); } - protected String getLdapConnectorClassName() { return LDAP_CONNECTOR_TYPE; } + protected String getLdapConnectorClassName() { + return LDAP_CONNECTOR_TYPE; + } @Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { @@ -379,18 +335,14 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti } } - @Test public void test010Connection() throws Exception { - final String TEST_NAME = "test010Connection"; - displayTestTitle(TEST_NAME); - - Task task = createTask(TEST_NAME); + Task task = getTestTask(); - OperationResult testResult = provisioningService.testResource(getResourceOid(), task); + OperationResult testResult = provisioningService.testResource(getResourceOid(), task); - display("Test connection result",testResult); - TestUtil.assertSuccess("Test connection failed",testResult); + display("Test connection result", testResult); + TestUtil.assertSuccess("Test connection failed", testResult); if (isAssertOpenFiles()) { // Set lsof baseline only after the first connection. @@ -402,16 +354,13 @@ public void test010Connection() throws Exception { @Test public void test020Schema() throws Exception { - final String TEST_NAME = "test020Schema"; - displayTestTitle(TEST_NAME); - ResourceSchema resourceSchema = RefinedResourceSchema.getResourceSchema(resource, prismContext); display("Resource schema", resourceSchema); RefinedResourceSchema refinedSchema = RefinedResourceSchema.getRefinedSchema(resource); display("Refined schema", refinedSchema); accountObjectClassDefinition = refinedSchema.findObjectClassDefinition(getAccountObjectClass()); - assertNotNull("No definition for object class "+getAccountObjectClass(), accountObjectClassDefinition); + assertNotNull("No definition for object class " + getAccountObjectClass(), accountObjectClassDefinition); display("Account object class def", accountObjectClassDefinition); ResourceAttributeDefinition cnDef = accountObjectClassDefinition.findAttributeDefinition("cn"); @@ -442,9 +391,6 @@ protected QName getTimestampXsdType() { @Test public void test030Capabilities() throws Exception { - final String TEST_NAME = "test030Capabilities"; - displayTestTitle(TEST_NAME); - CapabilitiesType capabilities = resourceType.getCapabilities(); display("Resource capabilities", capabilities); assertNotNull("Null capabilities", capabilities); @@ -480,12 +426,11 @@ protected void assertAdditionalCapabilities(List nativeCapabilities) { protected void assertCapability(List capabilities, Class capabilityClass) { C capability = CapabilityUtil.getCapability(capabilities, capabilityClass); - assertNotNull("No "+capabilityClass.getSimpleName()+" capability", capability); - assertTrue("Capability "+capabilityClass.getSimpleName()+" is disabled", CapabilityUtil.isCapabilityEnabled(capability)); + assertNotNull("No " + capabilityClass.getSimpleName() + " capability", capability); + assertTrue("Capability " + capabilityClass.getSimpleName() + " is disabled", CapabilityUtil.isCapabilityEnabled(capability)); } - - protected ObjectFilter createAttributeFilter(String attrName, T attrVal) throws SchemaException { + protected ObjectFilter createAttributeFilter(String attrName, T attrVal) { ResourceAttributeDefinition ldapAttrDef = accountObjectClassDefinition.findAttributeDefinition(attrName); return prismContext.queryFor(ShadowType.class) .itemWithDef(ldapAttrDef, ShadowType.F_ATTRIBUTES, ldapAttrDef.getItemName()).eq(attrVal) @@ -498,20 +443,19 @@ protected ObjectQuery createUidQuery(String uid) throws SchemaException { return query; } - protected SearchResultList> doSearch(final String TEST_NAME, ObjectQuery query, int expectedSize, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - return doSearch(TEST_NAME, query, null, expectedSize, task, result); + protected SearchResultList> doSearch(ObjectQuery query, int expectedSize, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + return doSearch(query, null, expectedSize, task, result); } - protected SearchResultList> doSearch(final String TEST_NAME, ObjectQuery query, GetOperationOptions rootOptions, int expectedSize, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - final List> foundObjects = new ArrayList>(expectedSize); + protected SearchResultList> doSearch(ObjectQuery query, GetOperationOptions rootOptions, int expectedSize, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + final List> foundObjects = new ArrayList<>(expectedSize); ResultHandler handler = new ResultHandler() { @Override public boolean handle(PrismObject object, OperationResult parentResult) { -// LOGGER.trace("Found {}", object); String name = object.asObjectable().getName().getOrig(); - for(PrismObject foundShadow: foundObjects) { + for (PrismObject foundShadow : foundObjects) { if (!allowDuplicateSearchResults() && foundShadow.asObjectable().getName().getOrig().equals(name)) { - AssertJUnit.fail("Duplicate name "+name); + AssertJUnit.fail("Duplicate name " + name); } } foundObjects.add(object); @@ -528,8 +472,8 @@ public boolean handle(PrismObject object, OperationResult parentResu rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); - display("Searching shadows, options="+options+", query", query); + when(); + display("Searching shadows, options=" + options + ", query", query); SearchResultMetadata searchResultMetadata = modelService.searchObjectsIterative(ShadowType.class, query, handler, options, task, result); // THEN @@ -539,19 +483,17 @@ public boolean handle(PrismObject object, OperationResult parentResu if (expectedSize != foundObjects.size()) { if (foundObjects.size() < 10) { display("Found objects", foundObjects); - AssertJUnit.fail("Unexpected number of accounts. Expected "+expectedSize+", found "+foundObjects.size()+": "+foundObjects); + AssertJUnit.fail("Unexpected number of accounts. Expected " + expectedSize + ", found " + foundObjects.size() + ": " + foundObjects); } else { - AssertJUnit.fail("Unexpected number of accounts. Expected "+expectedSize+", found "+foundObjects.size()+" (too many to display)"); + AssertJUnit.fail("Unexpected number of accounts. Expected " + expectedSize + ", found " + foundObjects.size() + " (too many to display)"); } } - SearchResultList> resultList = new SearchResultList<>(foundObjects, searchResultMetadata); - - return resultList; + return new SearchResultList<>(foundObjects, searchResultMetadata); } protected Entry getLdapAccountByUid(String uid) throws LdapException, IOException, CursorException { - return searchLdapAccount("(uid="+uid+")"); + return searchLdapAccount("(uid=" + uid + ")"); } protected Entry getLdapAccountByCn(String cn) throws LdapException, IOException, CursorException { @@ -559,7 +501,7 @@ protected Entry getLdapAccountByCn(String cn) throws LdapException, IOException, } protected Entry getLdapAccountByCn(UserLdapConnectionConfig config, String cn) throws LdapException, IOException, CursorException { - return searchLdapAccount(config, "(cn="+cn+")"); + return searchLdapAccount(config, "(cn=" + cn + ")"); } protected Entry searchLdapAccount(String filter) throws LdapException, IOException, CursorException { @@ -571,10 +513,9 @@ protected Entry searchLdapAccount(UserLdapConnectionConfig config, String filter List entries = ldapSearch(config, connection, filter); ldapDisconnect(connection); - assertEquals("Unexpected number of entries for "+filter+": "+entries, 1, entries.size()); - Entry entry = entries.get(0); + assertEquals("Unexpected number of entries for " + filter + ": " + entries, 1, entries.size()); - return entry; + return entries.get(0); } protected Entry assertLdapAccount(String uid, String cn) throws LdapException, IOException, CursorException { @@ -585,13 +526,12 @@ protected Entry assertLdapAccount(String uid, String cn) throws LdapException, I protected Entry getLdapGroupByName(String name) throws LdapException, IOException, CursorException { LdapNetworkConnection connection = ldapConnect(); - List entries = ldapSearch(connection, "(&(cn="+name+")(objectClass="+getLdapGroupObjectClass()+"))"); + List entries = ldapSearch(connection, "(&(cn=" + name + ")(objectClass=" + getLdapGroupObjectClass() + "))"); ldapDisconnect(connection); - assertEquals("Unexpected number of entries for group cn="+name+": "+entries, 1, entries.size()); - Entry entry = entries.get(0); + assertEquals("Unexpected number of entries for group cn=" + name + ": " + entries, 1, entries.size()); - return entry; + return entries.get(0); } protected Entry assertLdapGroup(String cn) throws LdapException, IOException, CursorException { @@ -602,9 +542,9 @@ protected Entry assertLdapGroup(String cn) throws LdapException, IOException, Cu protected void assertNoLdapGroup(String cn) throws LdapException, IOException, CursorException { LdapNetworkConnection connection = ldapConnect(); - List entries = ldapSearch(connection, "(&(cn="+cn+")(objectClass="+getLdapGroupObjectClass()+"))"); + List entries = ldapSearch(connection, "(&(cn=" + cn + ")(objectClass=" + getLdapGroupObjectClass() + "))"); ldapDisconnect(connection); - assertEquals("Unexpected LDAP group "+cn+": "+entries, 0, entries.size()); + assertEquals("Unexpected LDAP group " + cn + ": " + entries, 0, entries.size()); } protected void assertAttribute(Entry entry, String attrName, String expectedValue) throws LdapInvalidAttributeValueException { @@ -614,18 +554,18 @@ protected void assertAttribute(Entry entry, String attrName, String expectedValu if (expectedValue == null) { return; } else { - AssertJUnit.fail("No attribute "+attrName+" in "+dn+", expected: "+expectedValue); + AssertJUnit.fail("No attribute " + attrName + " in " + dn + ", expected: " + expectedValue); } } else { - assertEquals("Wrong attribute "+attrName+" in "+dn, expectedValue, ldapAttribute.getString()); + assertEquals("Wrong attribute " + attrName + " in " + dn, expectedValue, ldapAttribute.getString()); } } - protected void assertNoAttribute(Entry entry, String attrName) throws LdapInvalidAttributeValueException { + protected void assertNoAttribute(Entry entry, String attrName) { String dn = entry.getDn().toString(); Attribute ldapAttribute = entry.get(attrName); if (ldapAttribute != null) { - AssertJUnit.fail("Unexpected attribute "+attrName+" in "+dn+": "+ldapAttribute); + AssertJUnit.fail("Unexpected attribute " + attrName + " in " + dn + ": " + ldapAttribute); } } @@ -633,14 +573,16 @@ protected void assertAttributeContains(Entry entry, String attrName, String expe assertAttributeContains(entry, attrName, expectedValue, null); } - protected void assertAttributeContains(Entry entry, String attrName, String expectedValue, MatchingRule matchingRule) throws LdapInvalidAttributeValueException, SchemaException { + protected void assertAttributeContains( + Entry entry, String attrName, String expectedValue, MatchingRule matchingRule) + throws SchemaException { String dn = entry.getDn().toString(); Attribute ldapAttribute = entry.get(attrName); if (ldapAttribute == null) { if (expectedValue == null) { return; } else { - AssertJUnit.fail("No attribute "+attrName+" in "+dn+", expected: "+expectedValue); + AssertJUnit.fail("No attribute " + attrName + " in " + dn + ", expected: " + expectedValue); } } else { List vals = new ArrayList<>(); @@ -658,7 +600,7 @@ protected void assertAttributeContains(Entry entry, String attrName, String expe } vals.add(value.getString()); } - AssertJUnit.fail("Wrong attribute "+attrName+" in "+dn+" expected to contain value " + expectedValue + " but it has values " + vals); + AssertJUnit.fail("Wrong attribute " + attrName + " in " + dn + " expected to contain value " + expectedValue + " but it has values " + vals); } } @@ -666,22 +608,18 @@ protected void assertAttributeNotContains(Entry entry, String attrName, String e assertAttributeNotContains(entry, attrName, expectedValue, null); } - protected void assertAttributeNotContains(Entry entry, String attrName, String expectedValue, MatchingRule matchingRule) throws LdapInvalidAttributeValueException, SchemaException { + protected void assertAttributeNotContains(Entry entry, String attrName, String expectedValue, MatchingRule matchingRule) throws SchemaException { String dn = entry.getDn().toString(); Attribute ldapAttribute = entry.get(attrName); - if (ldapAttribute == null) { - return; - } else { - Iterator> iterator = ldapAttribute.iterator(); - while (iterator.hasNext()) { - Value value = iterator.next(); + if (ldapAttribute != null) { + for (Value value : ldapAttribute) { if (matchingRule == null) { if (expectedValue.equals(value.getString())) { - AssertJUnit.fail("Attribute "+attrName+" in "+dn+" contains value " + expectedValue + ", but it should not have it"); + AssertJUnit.fail("Attribute " + attrName + " in " + dn + " contains value " + expectedValue + ", but it should not have it"); } } else { if (matchingRule.match(expectedValue, value.getString())) { - AssertJUnit.fail("Attribute "+attrName+" in "+dn+" contains value " + expectedValue + ", but it should not have it"); + AssertJUnit.fail("Attribute " + attrName + " in " + dn + " contains value " + expectedValue + ", but it should not have it"); } } } @@ -695,7 +633,7 @@ protected Entry getLdapEntry(String dn) throws LdapException, IOException, Curso return entry; } - protected Entry getLdapEntry(LdapNetworkConnection connection, String dn) throws LdapException, IOException, CursorException { + protected Entry getLdapEntry(LdapNetworkConnection connection, String dn) throws LdapException, CursorException { List entries = ldapSearch(connection, dn, "(objectclass=*)", SearchScope.OBJECT, "*"); if (entries.isEmpty()) { return null; @@ -705,15 +643,15 @@ protected Entry getLdapEntry(LdapNetworkConnection connection, String dn) throws protected void assertNoLdapAccount(String uid) throws LdapException, IOException, CursorException { LdapNetworkConnection connection = ldapConnect(); - List entries = ldapSearch(connection, "(uid="+uid+")"); + List entries = ldapSearch(connection, "(uid=" + uid + ")"); ldapDisconnect(connection); - assertEquals("Unexpected number of entries for uid="+uid+": "+entries, 0, entries.size()); + assertEquals("Unexpected number of entries for uid=" + uid + ": " + entries, 0, entries.size()); } protected void assertNoEntry(String dn) throws LdapException, IOException, CursorException { Entry entry = getLdapEntry(dn); - assertNull("Expected no entry "+dn+", but found "+entry, entry); + assertNull("Expected no entry " + dn + ", but found " + entry, entry); } protected void assertLdapGroupMember(Entry accountEntry, String groupName) throws LdapException, IOException, CursorException, SchemaException { @@ -748,7 +686,7 @@ protected List ldapSearch(UserLdapConnectionConfig config, LdapNetworkCon protected List ldapSearch(LdapNetworkConnection connection, String baseDn, String filter, SearchScope scope, String... attributes) throws LdapException, CursorException { LOGGER.trace("LDAP search base={}, filter={}, scope={}, attributes={}", - new Object[]{baseDn, filter, scope, attributes}); + baseDn, filter, scope, attributes); SearchRequest searchRequest = new SearchRequestImpl(); searchRequest.setBase(new Dn(baseDn)); @@ -757,21 +695,21 @@ protected List ldapSearch(LdapNetworkConnection connection, String baseDn searchRequest.addAttributes(attributes); searchRequest.ignoreReferrals(); - List entries = new ArrayList(); + List entries = new ArrayList<>(); try { SearchCursor searchCursor = connection.search(searchRequest); while (searchCursor.next()) { Response response = searchCursor.get(); if (response instanceof SearchResultEntry) { - Entry entry = ((SearchResultEntry)response).getEntry(); + Entry entry = ((SearchResultEntry) response).getEntry(); entries.add(entry); } } searchCursor.close(); } catch (IOException e) { - throw new IllegalStateException("IO Error: "+e.getMessage(), e); + throw new IllegalStateException("IO Error: " + e.getMessage(), e); } catch (CursorLdapReferralException e) { - throw new IllegalStateException("Got referral to: "+e.getReferralInfo(), e); + throw new IllegalStateException("Got referral to: " + e.getReferralInfo(), e); } return entries; } @@ -802,11 +740,12 @@ protected void assertLdapPassword(UserLdapConnectionConfig config, Entry entry, LOGGER.debug("Search-after-auth found {} entries", foundEntries); ldapDisconnect(conn); if (foundEntries != 1) { - throw new SecurityException("Cannot read my own entry ("+entry.getDn()+")"); + throw new SecurityException("Cannot read my own entry (" + entry.getDn() + ")"); } } - protected Entry addLdapAccount(String uid, String cn, String givenName, String sn) throws LdapException, IOException, CursorException { + protected Entry addLdapAccount(String uid, String cn, String givenName, String sn) + throws LdapException, IOException { Entry entry = createAccountEntry(uid, cn, givenName, sn); addLdapEntry(entry); return entry; @@ -816,9 +755,9 @@ protected void addLdapEntry(Entry entry) throws LdapException, IOException { LdapNetworkConnection connection = ldapConnect(); try { connection.add(entry); - display("Added LDAP account:\n"+entry); + display("Added LDAP account:\n" + entry); } catch (Exception e) { - display("Error adding entry:\n"+entry+"\nError: "+e.getMessage()); + display("Error adding entry:\n" + entry + "\nError: " + e.getMessage()); ldapDisconnect(connection); throw e; } @@ -835,17 +774,19 @@ protected Entry createAccountEntry(String uid, String cn, String givenName, Stri return entry; } - protected Entry addLdapGroup(String cn, String description, String... memberDns) throws LdapException, IOException, CursorException { + protected Entry addLdapGroup(String cn, String description, String... memberDns) + throws LdapException, IOException { LdapNetworkConnection connection = ldapConnect(); Entry entry = createGroupEntry(cn, description, memberDns); LOGGER.trace("Adding LDAP entry:\n{}", entry); connection.add(entry); - display("Added LDAP group:"+entry); + display("Added LDAP group:" + entry); ldapDisconnect(connection); return entry; } - protected Entry createGroupEntry(String cn, String description, String... memberDns) throws LdapException { + protected Entry createGroupEntry(String cn, String description, String... memberDns) + throws LdapException { Entry entry = new DefaultEntry(toGroupDn(cn), "objectclass", getLdapGroupObjectClass(), "cn", cn, @@ -859,7 +800,7 @@ protected Entry createGroupEntry(String cn, String description, String... member protected void deleteLdapEntry(String dn) throws LdapException, IOException { LdapNetworkConnection connection = ldapConnect(); connection.delete(dn); - display("Deleted LDAP entry: "+dn); + display("Deleted LDAP entry: " + dn); ldapDisconnect(connection); } @@ -878,7 +819,7 @@ protected void cleanupDelete(UserLdapConnectionConfig config, String dn) throws Entry entry = getLdapEntry(connection, dn); if (entry != null) { connection.delete(dn); - display("Cleaning up LDAP entry: "+dn); + display("Cleaning up LDAP entry: " + dn); } ldapDisconnect(connection); } @@ -888,19 +829,19 @@ protected String toAccountDn(String username, String fullName) { } protected String toAccountDn(String username) { - return "uid="+username+","+getPeopleLdapSuffix(); + return "uid=" + username + "," + getPeopleLdapSuffix(); } protected Rdn toAccountRdn(String username, String fullName) { try { return new Rdn(new Ava("uid", username)); } catch (LdapInvalidDnException e) { - throw new IllegalStateException(e.getMessage(),e); + throw new IllegalStateException(e.getMessage(), e); } } protected String toGroupDn(String cn) { - return "cn="+cn+","+getGroupsLdapSuffix(); + return "cn=" + cn + "," + getGroupsLdapSuffix(); } protected String getAttributeAsString(Entry entry, String primaryIdentifierAttributeName) throws LdapInvalidAttributeValueException { @@ -951,13 +892,12 @@ protected LdapNetworkConnection ldapConnect(UserLdapConnectionConfig config) thr if (useSsl()) { config.setUseSsl(true); TrustManager trustManager = new X509TrustManager() { - public void checkClientTrusted(X509Certificate[] chain, String authType) - throws CertificateException { - + public void checkClientTrusted(X509Certificate[] chain, String authType) { } - public void checkServerTrusted(X509Certificate[] chain, String authType) - throws CertificateException { + + public void checkServerTrusted(X509Certificate[] chain, String authType) { } + public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[0]; } @@ -970,7 +910,7 @@ public X509Certificate[] getAcceptedIssuers() { LdapNetworkConnection connection = new LdapNetworkConnection(config); boolean connected = connection.connect(); if (!connected) { - AssertJUnit.fail("Cannot connect to LDAP server "+config.getLdapHost()+":"+config.getLdapPort()); + AssertJUnit.fail("Cannot connect to LDAP server " + config.getLdapHost() + ":" + config.getLdapPort()); } LOGGER.trace("LDAP connected to {}:{}, executing bind as {}", config.getLdapHost(), config.getLdapPort(), config.getBindDn()); @@ -981,7 +921,7 @@ public X509Certificate[] getAcceptedIssuers() { BindResponse bindResponse = connection.bind(bindRequest); if (bindResponse.getLdapResult().getResultCode() != ResultCodeEnum.SUCCESS) { ldapDisconnect(connection); - throw new SecurityException("Bind as "+config.getBindDn()+" failed: "+bindResponse.getLdapResult().getDiagnosticMessage()+" ("+bindResponse.getLdapResult().getResultCode()+")"); + throw new SecurityException("Bind as " + config.getBindDn() + " failed: " + bindResponse.getLdapResult().getDiagnosticMessage() + " (" + bindResponse.getLdapResult().getResultCode() + ")"); } LOGGER.trace("LDAP connected to {}:{}, bound as {}", config.getLdapHost(), config.getLdapPort(), config.getBindDn()); @@ -997,20 +937,17 @@ protected void assertAccountShadow(PrismObject shadow, String dn) th assertShadowCommon(shadow, null, dn, resourceType, getAccountObjectClass(), ciMatchingRule, false); } - protected void assertAccountRepoShadow(PrismObject shadow, String dn) throws SchemaException { - assertShadowCommon(shadow, null, dnMatchingRule.normalize(dn), resourceType, getAccountObjectClass(), ciMatchingRule, false); - } - protected void assertGroupShadow(PrismObject shadow, String dn) throws SchemaException { assertShadowCommon(shadow, null, dn, resourceType, getGroupObjectClass(), ciMatchingRule, false, true); } protected long roundTsDown(long ts) { - return (((long)(ts/1000))*1000); + return (ts / 1000 * 1000); } + // TODO: for 10000 it produces 10001? I don't understand it (Virgo) protected long roundTsUp(long ts) { - return (((long)(ts/1000))*1000)+1; + return (ts / 1000 * 1000) + 1; } protected void assertStableSystem() throws NumberFormatException, IOException, InterruptedException { @@ -1052,7 +989,7 @@ protected void assertLdapConnectorInstances(int expectedConnectorInstances) thro } private ConnectorOperationalStatus findLdapConnectorStat(List stats) { - for (ConnectorOperationalStatus stat: stats) { + for (ConnectorOperationalStatus stat : stats) { if (stat.getConnectorClassName().equals(getLdapConnectorClassName())) { return stat; } diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Test389DsDnLocalhost.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Test389DsDnLocalhost.java index 666633fb6df..2c54dc94ad5 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Test389DsDnLocalhost.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Test389DsDnLocalhost.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2014-2015 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Test389DsDnPhobos.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Test389DsDnPhobos.java index 0f167f9aded..aae8da01a22 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Test389DsDnPhobos.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Test389DsDnPhobos.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2014-2016 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Test389DsNsUniqueIdLocalhost.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Test389DsNsUniqueIdLocalhost.java index ecc44d53859..02c1f21a7ca 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Test389DsNsUniqueIdLocalhost.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Test389DsNsUniqueIdLocalhost.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2014-2015 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Test389DsNsUniqueIdPhobos.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Test389DsNsUniqueIdPhobos.java index a88f6404a28..736f9d62c08 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Test389DsNsUniqueIdPhobos.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Test389DsNsUniqueIdPhobos.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2014-2016 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestEDirAthena.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestEDirAthena.java index ba2024cc87d..c718c30d625 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestEDirAthena.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestEDirAthena.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestEDirDeimos.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestEDirDeimos.java index ead23b75e9d..d940ddf2a74 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestEDirDeimos.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestEDirDeimos.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenDj.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenDj.java index 06e067bcee8..523e1dc72d1 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenDj.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenDj.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2014-2018 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenDjDumber.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenDjDumber.java index 6bd0c8ea72b..52b732d6870 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenDjDumber.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenDjDumber.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2016-2018 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -55,15 +55,12 @@ protected boolean isUsingGroupShortcutAttribute() { */ @Test @Override - public void test350SeachInvisibleAccount() throws Exception { - final String TEST_NAME = "test350SeachInvisibleAccount"; - displayTestTitle(TEST_NAME); - + public void test350SearchInvisibleAccount() throws Exception { // GIVEN createBilboEntry(); - SearchResultList> shadows = searchBilbo(TEST_NAME); + SearchResultList> shadows = searchBilbo(); - assertEquals("Unexpected search result: "+shadows, 0, shadows.size()); + assertEquals("Unexpected search result: " + shadows, 0, shadows.size()); } } diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenDjUnsafe.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenDjUnsafe.java index 27dcf672aaa..bf73f748678 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenDjUnsafe.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenDjUnsafe.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2016-2017 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -8,12 +8,6 @@ import java.io.File; -import org.testng.annotations.AfterClass; - -import com.evolveum.midpoint.test.util.MidPointTestConstants; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; - /** * Almost same sa TestOpenDj, but there is unsafeNameHint setting and maybe * some other possibly risky and alternative connector settings. @@ -26,5 +20,4 @@ public class TestOpenDjUnsafe extends TestOpenDj { protected File getResourceFile() { return new File(getBaseDir(), "resource-unsafe.xml"); } - } diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenLdap.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenLdap.java index ce6cd335672..6f920af9c4f 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenLdap.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenLdap.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2014-2017 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -6,18 +6,14 @@ */ package com.evolveum.midpoint.testing.conntest; -import static com.evolveum.midpoint.test.IntegrationTestTools.display; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertTrue; import java.io.File; import java.text.ParseException; import org.apache.directory.api.ldap.model.entry.Entry; import org.apache.directory.api.util.GeneralizedTime; -import org.apache.directory.ldap.client.api.LdapNetworkConnection; import org.testng.AssertJUnit; import org.testng.annotations.Test; @@ -42,7 +38,6 @@ /** * @author semancik - * */ public class TestOpenLdap extends AbstractLdapConnTest { @@ -58,12 +53,12 @@ protected File getBaseDir() { @Override public String getStartSystemCommand() { - return "sudo "+getScriptDirectoryName()+"/openldap-start"; + return "sudo " + getScriptDirectoryName() + "/openldap-start"; } @Override public String getStopSystemCommand() { - return "sudo "+getScriptDirectoryName()+"/openldap-stop"; + return "sudo " + getScriptDirectoryName() + "/openldap-stop"; } @Override @@ -98,15 +93,14 @@ protected int getSearchSizeLimit() { @Override protected String getPeopleLdapSuffix() { - return "ou=people,"+getLdapSuffix(); + return "ou=people," + getLdapSuffix(); } @Override protected String getGroupsLdapSuffix() { - return "ou=groups,"+getLdapSuffix(); + return "ou=groups," + getLdapSuffix(); } - @Override protected String getLdapGroupObjectClass() { return "groupOfNames"; @@ -144,38 +138,35 @@ protected void assertActivationCapability(ActivationCapabilityType activationCap @Override protected void assertStepSyncToken(String syncTaskOid, int step, long tsStart, long tsEnd) throws ObjectNotFoundException, SchemaException { - OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName()+".assertSyncToken"); + OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName() + ".assertSyncToken"); Task task = taskManager.getTask(syncTaskOid, result); result.computeStatus(); TestUtil.assertSuccess(result); PrismProperty syncTokenProperty = task.getExtensionPropertyOrClone(SchemaConstants.SYNC_TOKEN); - assertNotNull("No sync token in "+task, syncTokenProperty); + assertNotNull("No sync token in " + task, syncTokenProperty); String syncToken = syncTokenProperty.getRealValue(); - assertNotNull("No sync token in "+task, syncToken); + assertNotNull("No sync token in " + task, syncToken); IntegrationTestTools.display("Sync token", syncToken); GeneralizedTime syncTokenGt; try { syncTokenGt = new GeneralizedTime(syncToken); } catch (ParseException e) { - throw new RuntimeException(e.getMessage(),e); + throw new RuntimeException(e.getMessage(), e); } - TestUtil.assertBetween("Wrong time in sync token: "+syncToken, roundTsDown(tsStart), roundTsUp(tsEnd), syncTokenGt.getCalendar().getTimeInMillis()); + TestUtil.assertBetween("Wrong time in sync token: " + syncToken, roundTsDown(tsStart), roundTsUp(tsEnd), syncTokenGt.getCalendar().getTimeInMillis()); } @Test public void test700CheckBarbossaLockoutStatus() throws Exception { - final String TEST_NAME = "test700CheckBarbossaLockoutStatus"; - TestUtil.displayTestTitle(this, TEST_NAME); - // WHEN when(); PrismObject shadow = getShadowModel(accountBarbossaOid); // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("Shadow (model)", shadow); ActivationType activation = shadow.asObjectable().getActivation(); if (activation != null) { @@ -190,18 +181,14 @@ public void test700CheckBarbossaLockoutStatus() throws Exception { @Test public void test702LockOutBarbossa() throws Exception { - final String TEST_NAME = "test702LockOutBarbossa"; - TestUtil.displayTestTitle(this, TEST_NAME); - Entry entry = getLdapAccountByUid(USER_BARBOSSA_USERNAME); display("LDAP Entry before", entry); // WHEN when(); for (int i = 0; i < 10; i++) { - LdapNetworkConnection conn; try { - conn = ldapConnect(null, entry.getDn().toString(), "this password is wrong"); + ldapConnect(null, entry.getDn().toString(), "this password is wrong"); } catch (SecurityException e) { // Good bad attempt continue; @@ -210,7 +197,7 @@ public void test702LockOutBarbossa() throws Exception { } // THEN - TestUtil.displayThen(TEST_NAME); + then(); entry = assertLdapAccount(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME); display("LDAP Entry after", entry); @@ -223,14 +210,10 @@ public void test702LockOutBarbossa() throws Exception { assertEquals("Wrong lockout status", LockoutStatusType.LOCKED, lockoutStatus); } - @Test public void test705UnlockBarbossaAccount() throws Exception { - final String TEST_NAME = "test705UnlockBarbossaAccount"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta accountDelta = createModifyAccountShadowReplaceDelta(accountBarbossaOid, null, @@ -241,7 +224,7 @@ public void test705UnlockBarbossaAccount() throws Exception { executeChanges(accountDelta, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenLdapDumber.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenLdapDumber.java index e4760fc774f..8abdd9ed2de 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenLdapDumber.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenLdapDumber.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2017-2018 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -7,29 +7,10 @@ package com.evolveum.midpoint.testing.conntest; import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; import java.io.File; -import java.text.ParseException; - -import org.apache.directory.api.util.GeneralizedTime; -import org.testng.AssertJUnit; -import org.testng.annotations.Test; - -import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.PrismProperty; -import com.evolveum.midpoint.schema.constants.SchemaConstants; -import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; -import com.evolveum.midpoint.test.IntegrationTestTools; + import com.evolveum.midpoint.test.util.MidPointTestConstants; -import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.MiscUtil; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; /** * OpenLDAP, but without permissive modify, shortcut attributes, etc. @@ -56,7 +37,7 @@ protected boolean isUsingGroupShortcutAttribute() { // This is a dumb resource. It cannot count. @Override protected void assertCountAllAccounts(Integer count) { - assertEquals("Wrong account count", (Integer)null, count); + assertEquals("Wrong account count", (Integer) null, count); } } diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/UserLdapConnectionConfig.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/UserLdapConnectionConfig.java index 4ee9a7bc8c4..ab68de5aecb 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/UserLdapConnectionConfig.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/UserLdapConnectionConfig.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2016 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -10,7 +10,6 @@ /** * @author semancik - * */ public class UserLdapConnectionConfig extends LdapConnectionConfig { diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapCookedTest.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapCookedTest.java index 03097c3e42c..6612eb9a11c 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapCookedTest.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapCookedTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2016 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -6,7 +6,6 @@ */ package com.evolveum.midpoint.testing.conntest.ad; -import static com.evolveum.midpoint.test.IntegrationTestTools.display; import static org.testng.AssertJUnit.assertTrue; import java.util.Collection; @@ -15,7 +14,6 @@ import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.schema.util.ResourceTypeUtil; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; @@ -27,17 +25,13 @@ public abstract class AbstractAdLdapCookedTest extends AbstractAdLdapTest { @Test - public void test050Capabilities() throws Exception { - final String TEST_NAME = "test050Capabilities"; - TestUtil.displayTestTitle(this, TEST_NAME); - + public void test050Capabilities() { Collection nativeCapabilitiesCollection = ResourceTypeUtil.getNativeCapabilitiesCollection(resourceType); display("Native capabilities", nativeCapabilitiesCollection); assertTrue("No native activation capability", ResourceTypeUtil.hasResourceNativeActivationCapability(resourceType)); assertTrue("No native activation status capability", ResourceTypeUtil.hasResourceNativeActivationStatusCapability(resourceType)); -// assertTrue("No native lockout capability", ResourceTypeUtil.hasResourceNativeActivationLockoutCapability(resourceType)); - assertTrue("No native credentias capability", ResourceTypeUtil.isCredentialsCapabilityEnabled(resourceType, null)); + assertTrue("No native credentials capability", ResourceTypeUtil.isCredentialsCapabilityEnabled(resourceType, null)); } protected void assertAccountDisabled(PrismObject shadow) { diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapMultidomainRunAsTest.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapMultidomainRunAsTest.java index a11ef4aac24..85a4a6635e2 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapMultidomainRunAsTest.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapMultidomainRunAsTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2018 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -70,8 +70,6 @@ public void test226ModifyUserBarbossaPasswordSelfServicePassword1AgainAgain() th */ @Test public void test228ModifyUserBarbossaPasswordSelfServiceDesynchronized() throws Exception { - final String TEST_NAME = "test228ModifyUserBarbossaPasswordSelfServiceDesynchronized"; - displayTestTitle(TEST_NAME); // GIVEN // preconditions @@ -82,7 +80,7 @@ public void test228ModifyUserBarbossaPasswordSelfServiceDesynchronized() throws login(USER_BARBOSSA_USERNAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setChannel(SchemaConstants.CHANNEL_GUI_SELF_SERVICE_URI); OperationResult result = task.getResult(); @@ -90,11 +88,11 @@ public void test228ModifyUserBarbossaPasswordSelfServiceDesynchronized() throws USER_BARBOSSA_PASSWORD_AD_1, USER_BARBOSSA_PASSWORD_AD_3); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(objectDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); login(USER_ADMINISTRATOR_USERNAME); display(result); assertPartialError(result); diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapMultidomainTest.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapMultidomainTest.java index 0cad4fe7e1d..8dbd98711f8 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapMultidomainTest.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapMultidomainTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -6,24 +6,18 @@ */ package com.evolveum.midpoint.testing.conntest.ad; +import static org.testng.AssertJUnit.*; + import static com.evolveum.midpoint.schema.constants.SchemaConstants.PATH_CREDENTIALS_PASSWORD_VALUE; -import static com.evolveum.midpoint.test.IntegrationTestTools.LDAP_CONNECTOR_TYPE; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; import java.io.File; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.util.Collection; import java.util.List; - import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.path.ItemPath; import org.apache.directory.api.ldap.model.cursor.CursorException; import org.apache.directory.api.ldap.model.entry.DefaultEntry; import org.apache.directory.api.ldap.model.entry.Entry; @@ -41,6 +35,7 @@ import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.delta.PropertyDelta; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.query.ObjectPaging; import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.prism.query.OrderDirection; @@ -68,23 +63,14 @@ import com.evolveum.midpoint.util.MiscUtil; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.util.exception.SystemException; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; /** * @author semancik - * */ -@Listeners({com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class}) +@Listeners({ com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class }) public abstract class AbstractAdLdapMultidomainTest extends AbstractLdapTest { protected static final File TEST_DIR = new File(MidPointTestConstants.TEST_RESOURCES_DIR, "ad-ldap-multidomain"); @@ -121,7 +107,7 @@ public abstract class AbstractAdLdapMultidomainTest extends AbstractLdapTest { private static final QName EXTENSION_SHOW_IN_ADVANCED_VIEW_ONLY_QNAME = new QName(NS_EXTENSION, "showInAdvancedViewOnly"); protected static final File USER_SUBMAN_FILE = new File(TEST_DIR, "user-subman.xml"); - private static final String USER_SUBMAN_OID ="910ac45a-8bd6-11e6-9122-ef88d95095f0"; + private static final String USER_SUBMAN_OID = "910ac45a-8bd6-11e6-9122-ef88d95095f0"; private static final String USER_SUBMAN_USERNAME = "subman"; private static final String USER_SUBMAN_GIVEN_NAME = "Sub"; private static final String USER_SUBMAN_FAMILY_NAME = "Man"; @@ -134,7 +120,7 @@ public abstract class AbstractAdLdapMultidomainTest extends AbstractLdapTest { private static final String USER_SUBDOG_FULL_NAME = "Sub Dog"; protected static final File USER_SUBMARINE_FILE = new File(TEST_DIR, "user-submarine.xml"); - private static final String USER_SUBMARINE_OID ="c4377f86-8be9-11e6-8ef5-c3c56ff64b09"; + private static final String USER_SUBMARINE_OID = "c4377f86-8be9-11e6-8ef5-c3c56ff64b09"; private static final String USER_SUBMARINE_USERNAME = "submarine"; private static final String USER_SUBMARINE_GIVEN_NAME = "Sub"; private static final String USER_SUBMARINE_FAMILY_NAME = "Marine"; @@ -222,12 +208,12 @@ public String getPrimaryIdentifierAttributeName() { @Override protected String getPeopleLdapSuffix() { - return "CN=Users,"+getLdapSuffix(); + return "CN=Users," + getLdapSuffix(); } @Override protected String getGroupsLdapSuffix() { - return "CN=Users,"+getLdapSuffix(); + return "CN=Users," + getLdapSuffix(); } protected String getLdapSubSuffix() { @@ -235,7 +221,7 @@ protected String getLdapSubSuffix() { } protected String getPeopleLdapSubSuffix() { - return "CN=Users,"+getLdapSubSuffix(); + return "CN=Users," + getLdapSubSuffix(); } @Override @@ -268,7 +254,7 @@ protected boolean isGroupMemberMandatory() { } protected String getOrgsLdapSuffix() { - return "OU=Org,"+getLdapSuffix(); + return "OU=Org," + getLdapSuffix(); } private UserLdapConnectionConfig getSubLdapConnectionConfig() { @@ -285,7 +271,9 @@ private UserLdapConnectionConfig getSubLdapConnectionConfig() { protected abstract String getReconciliationTaskOid(); - protected String getLdapConnectorClassName() { return AdUtils.AD_CONNECTOR_TYPE; } + protected String getLdapConnectorClassName() { + return AdUtils.AD_CONNECTOR_TYPE; + } @Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { @@ -313,9 +301,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); - assertLdapPassword(ACCOUNT_JACK_SAM_ACCOUNT_NAME, ACCOUNT_JACK_FULL_NAME, ACCOUNT_JACK_PASSWORD); cleanupDelete(toAccountDn(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME)); cleanupDelete(toAccountDn(USER_CPTBARBOSSA_USERNAME, USER_CPTBARBOSSA_FULL_NAME)); @@ -335,12 +320,9 @@ public void test000Sanity() throws Exception { @Test @Override public void test020Schema() throws Exception { - final String TEST_NAME = "test020Schema"; - displayTestTitle(TEST_NAME); - -// IntegrationTestTools.displayXml("Resource XML", resource); + // IntegrationTestTools.displayXml("Resource XML", resource); accountObjectClassDefinition = AdUtils.assertAdResourceSchema(resource, getAccountObjectClass(), prismContext); - AdUtils.assertAdRefinedSchema(resource, getAccountObjectClass(), prismContext); + AdUtils.assertAdRefinedSchema(resource, getAccountObjectClass()); AdUtils.assertExchangeSchema(resource, getAccountObjectClass(), prismContext); ResourceSchema resourceSchema = RefinedResourceSchema.getResourceSchema(resource, prismContext); @@ -351,11 +333,8 @@ public void test020Schema() throws Exception { @Test public void test100SeachJackBySamAccountName() throws Exception { - final String TEST_NAME = "test100SeachJackBySamAccountName"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = createSamAccountNameQuery(ACCOUNT_JACK_SAM_ACCOUNT_NAME); @@ -364,14 +343,15 @@ public void test100SeachJackBySamAccountName() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); - SearchResultList> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result); + when(); + SearchResultList> shadows = + modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); - assertEquals("Unexpected search result: "+shadows, 1, shadows.size()); + assertEquals("Unexpected search result: " + shadows, 1, shadows.size()); PrismObject shadow = shadows.get(0); display("Shadow", shadow); @@ -391,17 +371,13 @@ public void test100SeachJackBySamAccountName() throws Exception { assertLdapConnectorInstances(1); } - /** * MID-3730 */ @Test public void test101SeachJackByDn() throws Exception { - final String TEST_NAME = "test101SeachJackByDn"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); String jackDn = toAccountDn(ACCOUNT_JACK_SAM_ACCOUNT_NAME, ACCOUNT_JACK_FULL_NAME); @@ -411,14 +387,14 @@ public void test101SeachJackByDn() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); - assertEquals("Unexpected search result: "+shadows, 1, shadows.size()); + assertEquals("Unexpected search result: " + shadows, 1, shadows.size()); PrismObject shadow = shadows.get(0); display("Shadow", shadow); @@ -440,16 +416,13 @@ public void test101SeachJackByDn() throws Exception { /** * Search for non-existent DN should return no results. It should NOT * throw an error. - * + *

* MID-3730 */ @Test public void test102SeachNotExistByDn() throws Exception { - final String TEST_NAME = "test102SeachNotExistByDn"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); String dn = toAccountDn("idonoexist", "I am a Fiction"); @@ -459,14 +432,14 @@ public void test102SeachNotExistByDn() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); - assertEquals("Unexpected search result: "+shadows, 0, shadows.size()); + assertEquals("Unexpected search result: " + shadows, 0, shadows.size()); // assertConnectorOperationIncrement(2); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); @@ -476,11 +449,8 @@ public void test102SeachNotExistByDn() throws Exception { @Test public void test105SeachPiratesByCn() throws Exception { - final String TEST_NAME = "test105SeachPiratesByCn"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getGroupObjectClass(), prismContext); @@ -490,14 +460,14 @@ public void test105SeachPiratesByCn() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); - assertEquals("Unexpected search result: "+shadows, 1, shadows.size()); + assertEquals("Unexpected search result: " + shadows, 1, shadows.size()); PrismObject shadow = shadows.get(0); display("Shadow", shadow); @@ -517,11 +487,8 @@ public void test105SeachPiratesByCn() throws Exception { @Test public void test110GetJack() throws Exception { - final String TEST_NAME = "test110GetJack"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberCounter(InternalCounters.CONNECTOR_OPERATION_COUNT); @@ -529,11 +496,11 @@ public void test110GetJack() throws Exception { long startOfTestMsTimestamp = AdUtils.getWin32Filetime(System.currentTimeMillis()); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject shadow = modelService.getObject(ShadowType.class, jackAccountOid, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Shadow", shadow); @@ -548,10 +515,10 @@ public void test110GetJack() throws Exception { assertAttribute(shadow, "description", "The best pirate the world has ever seen"); assertAttribute(shadow, "sAMAccountName", ACCOUNT_JACK_SAM_ACCOUNT_NAME); assertObjectCategory(shadow, OBJECT_CATEGORY_PERSON); - List lastLogonValues = ShadowUtil.getAttributeValues(shadow, new QName(getResourceNamespace(),"lastLogon")); - assertEquals("Wrong number of lastLong values: "+lastLogonValues, 1, lastLogonValues.size()); + List lastLogonValues = ShadowUtil.getAttributeValues(shadow, new QName(getResourceNamespace(), "lastLogon")); + assertEquals("Wrong number of lastLong values: " + lastLogonValues, 1, lastLogonValues.size()); if (lastLogonValues.get(0) > startOfTestMsTimestamp) { - fail("Wrong lastLogon, expected it to be less than "+startOfTestMsTimestamp+", but was "+lastLogonValues.get(0)); + fail("Wrong lastLogon, expected it to be less than " + startOfTestMsTimestamp + ", but was " + lastLogonValues.get(0)); } assertCounterIncrement(InternalCounters.CONNECTOR_OPERATION_COUNT, 1); @@ -560,17 +527,13 @@ public void test110GetJack() throws Exception { assertLdapConnectorInstances(1); } - /** * No paging. It should return all accounts. */ @Test public void test150SeachAllAccounts() throws Exception { - final String TEST_NAME = "test150SeachAllAccounts"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -579,7 +542,7 @@ public void test150SeachAllAccounts() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - SearchResultList> searchResultList = doSearch(TEST_NAME, query, + SearchResultList> searchResultList = doSearch(query, NUMBER_OF_ACCOUNTS, task, result); // TODO: Why 14? Why not 1? @@ -599,11 +562,8 @@ public void test150SeachAllAccounts() throws Exception { */ @Test public void test152SeachFirst2Accounts() throws Exception { - final String TEST_NAME = "test152SeachFirst2Accounts"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -612,7 +572,7 @@ public void test152SeachFirst2Accounts() throws Exception { paging.setMaxSize(2); query.setPaging(paging); - SearchResultList> searchResultList = doSearch(TEST_NAME, query, 2, task, result); + SearchResultList> searchResultList = doSearch(query, 2, task, result); // TODO: Why 2? Why not 1? assertCounterIncrement(InternalCounters.CONNECTOR_OPERATION_COUNT, 2); @@ -628,11 +588,8 @@ public void test152SeachFirst2Accounts() throws Exception { @Test public void test154SeachFirst11Accounts() throws Exception { - final String TEST_NAME = "test154SeachFirst11Accounts"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -641,7 +598,7 @@ public void test154SeachFirst11Accounts() throws Exception { paging.setMaxSize(11); query.setPaging(paging); - SearchResultList> searchResultList = doSearch(TEST_NAME, query, 11, task, result); + SearchResultList> searchResultList = doSearch(query, 11, task, result); // TODO: Why 2? Why not 1? assertCounterIncrement(InternalCounters.CONNECTOR_OPERATION_COUNT, 2); @@ -657,11 +614,8 @@ public void test154SeachFirst11Accounts() throws Exception { @Test public void test162SeachFirst2AccountsOffset0() throws Exception { - final String TEST_NAME = "test162SeachFirst2AccountsOffset0"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -671,7 +625,7 @@ public void test162SeachFirst2AccountsOffset0() throws Exception { paging.setMaxSize(2); query.setPaging(paging); - SearchResultList> searchResultList = doSearch(TEST_NAME, query, 2, task, result); + SearchResultList> searchResultList = doSearch(query, 2, task, result); // TODO: Why 2? Why not 1? assertCounterIncrement(InternalCounters.CONNECTOR_OPERATION_COUNT, 2); @@ -691,11 +645,8 @@ public void test162SeachFirst2AccountsOffset0() throws Exception { */ @Test public void test172Search2AccountsOffset1() throws Exception { - final String TEST_NAME = "test172Search2AccountsOffset1"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -703,7 +654,7 @@ public void test172Search2AccountsOffset1() throws Exception { ObjectPaging paging = prismContext.queryFactory().createPaging(1, 2); query.setPaging(paging); - SearchResultList> searchResultList = doSearch(TEST_NAME, query, 2, task, result); + SearchResultList> searchResultList = doSearch(query, 2, task, result); // TODO: Why 2? Why not 1? assertCounterIncrement(InternalCounters.CONNECTOR_OPERATION_COUNT, 2); @@ -723,11 +674,8 @@ public void test172Search2AccountsOffset1() throws Exception { */ @Test public void test174SeachFirst11AccountsOffset2() throws Exception { - final String TEST_NAME = "test174SeachFirst11AccountsOffset2"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -738,7 +686,7 @@ public void test174SeachFirst11AccountsOffset2() throws Exception { allowDuplicateSearchResults = true; // WHEN - SearchResultList> searchResultList = doSearch(TEST_NAME, query, 11, task, result); + SearchResultList> searchResultList = doSearch(query, 11, task, result); // THEN allowDuplicateSearchResults = false; @@ -761,11 +709,8 @@ public void test174SeachFirst11AccountsOffset2() throws Exception { */ @Test public void test182Search2AccountsOffset1SortCn() throws Exception { - final String TEST_NAME = "test182Search2AccountsOffset1SortCn"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -774,7 +719,7 @@ public void test182Search2AccountsOffset1SortCn() throws Exception { paging.setOrdering(getAttributePath(resource, "cn"), OrderDirection.ASCENDING); query.setPaging(paging); - SearchResultList> shadows = doSearch(TEST_NAME, query, 2, task, result); + SearchResultList> shadows = doSearch(query, 2, task, result); assertAccountShadow(shadows.get(0), "CN=Adolf Supperior,CN=Users,DC=ad,DC=evolveum,DC=com"); // assertAccountShadow(shadows.get(1), "CN=DiscoverySearchMailbox {D919BA05-46A6-415f-80AD-7E09334BB852},CN=Users,DC=ad,DC=evolveum,DC=com"); @@ -793,20 +738,17 @@ public void test182Search2AccountsOffset1SortCn() throws Exception { @Test public void test200AssignAccountBarbossa() throws Exception { - final String TEST_NAME = "test200AssignAccountBarbossa"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); long tsStart = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_BARBOSSA_OID, getResourceOid(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); long tsEnd = System.currentTimeMillis(); @@ -821,7 +763,7 @@ public void test200AssignAccountBarbossa() throws Exception { accountBarbossaOid = shadow.getOid(); Collection> identifiers = ShadowUtil.getPrimaryIdentifiers(shadow); String accountBarbossaIcfUid = (String) identifiers.iterator().next().getRealValue(); - assertNotNull("No identifier in "+shadow, accountBarbossaIcfUid); + assertNotNull("No identifier in " + shadow, accountBarbossaIcfUid); assertEquals("Wrong ICFS UID", AdUtils.formatGuidToDashedNotation(MiscUtil.binaryToHex(entry.get(getPrimaryIdentifierAttributeName()).getBytes())), @@ -834,11 +776,11 @@ public void test200AssignAccountBarbossa() throws Exception { // MID-4624 ResourceAttribute createTimestampAttribute = ShadowUtil.getAttribute(shadow, new QName(MidPointConstants.NS_RI, "createTimeStamp")); - assertNotNull("No createTimestamp in "+shadow, createTimestampAttribute); + assertNotNull("No createTimestamp in " + shadow, createTimestampAttribute); XMLGregorianCalendar createTimestamp = createTimestampAttribute.getRealValue(); long createTimestampMillis = XmlTypeConverter.toMillis(createTimestamp); // LDAP server may be on a different host. Allow for some clock offset. - TestUtil.assertBetween("Wrong createTimestamp in "+shadow, roundTsDown(tsStart)-120000, roundTsUp(tsEnd)+120000, createTimestampMillis); + TestUtil.assertBetween("Wrong createTimestamp in " + shadow, roundTsDown(tsStart) - 120000, roundTsUp(tsEnd) + 120000, createTimestampMillis); assertObjectCategory(shadow, OBJECT_CATEGORY_PERSON); @@ -847,11 +789,8 @@ public void test200AssignAccountBarbossa() throws Exception { @Test public void test210ModifyAccountBarbossaTitle() throws Exception { - final String TEST_NAME = "test210ModifyAccountBarbossaTitle"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object() @@ -859,15 +798,15 @@ public void test210ModifyAccountBarbossaTitle() throws Exception { QName attrQName = new QName(MidPointConstants.NS_RI, AdUtils.ATTRIBUTE_TITLE_NAME); ResourceAttributeDefinition attrDef = accountObjectClassDefinition.findAttributeDefinition(attrQName); PropertyDelta attrDelta = prismContext.deltaFactory().property().createModificationReplaceProperty( - ItemPath.create(ShadowType.F_ATTRIBUTES, attrQName), attrDef, "Captain"); + ItemPath.create(ShadowType.F_ATTRIBUTES, attrQName), attrDef, "Captain"); delta.addModification(attrDelta); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(delta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); Entry entry = assertLdapAccount(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME); @@ -885,11 +824,8 @@ public void test210ModifyAccountBarbossaTitle() throws Exception { @Test public void test212ModifyAccountBarbossaShowInAdvancedViewOnlyTrue() throws Exception { - final String TEST_NAME = "test212ModifyAccountBarbossaShowInAdvancedViewOnlyTrue"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object() @@ -901,11 +837,11 @@ public void test212ModifyAccountBarbossaShowInAdvancedViewOnlyTrue() throws Exce delta.addModification(attrDelta); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(delta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); Entry entry = assertLdapAccount(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME); @@ -926,14 +862,10 @@ public void test212ModifyAccountBarbossaShowInAdvancedViewOnlyTrue() throws Exce */ @Test public void test213ModifyUserBarbossaShowInAdvancedViewOnlyFalse() throws Exception { - final String TEST_NAME = "test213ModifyUserBarbossaShowInAdvancedViewOnlyFalse"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); - ObjectDelta delta = prismContext.deltaFactory().object() .createEmptyModifyDelta(ShadowType.class, accountBarbossaOid); QName attrQName = new QName(MidPointConstants.NS_RI, "showInAdvancedViewOnly"); @@ -943,12 +875,12 @@ public void test213ModifyUserBarbossaShowInAdvancedViewOnlyFalse() throws Except delta.addModification(attrDelta); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, ItemPath.create(UserType.F_EXTENSION, EXTENSION_SHOW_IN_ADVANCED_VIEW_ONLY_QNAME), task, result, Boolean.FALSE); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); Entry entry = assertLdapAccount(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME); @@ -972,28 +904,25 @@ public void test213ModifyUserBarbossaShowInAdvancedViewOnlyFalse() throws Except */ @Test public void test214ModifyAccountBarbossaProxyAddressesSimple() throws Exception { - final String TEST_NAME = "test214ModifyAccountBarbossaProxyAddressesSimple"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object() .createEmptyModifyDelta(ShadowType.class, accountBarbossaOid); QName attrQName = new QName(MidPointConstants.NS_RI, AdUtils.ATTRIBUTE_PROXY_ADDRESSES_NAME); ResourceAttributeDefinition attrDef = accountObjectClassDefinition.findAttributeDefinition(attrQName); - assertNotNull("No definition for attribute "+attrQName, attrDef); + assertNotNull("No definition for attribute " + attrQName, attrDef); PropertyDelta attrDelta = prismContext.deltaFactory().property().createModificationAddProperty( - ItemPath.create(ShadowType.F_ATTRIBUTES, attrQName), attrDef, PROXY_ADDRES_ADDR_UPCASE); + ItemPath.create(ShadowType.F_ATTRIBUTES, attrQName), attrDef, PROXY_ADDRES_ADDR_UPCASE); delta.addModification(attrDelta); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(delta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); Entry entry = assertLdapAccount(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME); @@ -1048,15 +977,12 @@ public void test226ModifyUserBarbossaPasswordSelfServicePassword1AgainAgain() th } protected void testModifyUserBarbossaPasswordSelfServiceSuccess(final String TEST_NAME, String oldPassword, String newPassword) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN - - // precondition assertLdapPassword(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, oldPassword); login(USER_BARBOSSA_USERNAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setChannel(SchemaConstants.CHANNEL_GUI_SELF_SERVICE_URI); OperationResult result = task.getResult(); @@ -1064,11 +990,11 @@ protected void testModifyUserBarbossaPasswordSelfServiceSuccess(final String TES oldPassword, newPassword); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(objectDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); login(USER_ADMINISTRATOR_USERNAME); assertSuccess(result); @@ -1080,12 +1006,10 @@ protected void testModifyUserBarbossaPasswordSelfServiceSuccess(final String TES } protected void testModifyUserBarbossaPasswordSelfServiceFailure(final String TEST_NAME, String oldPassword, String newPassword) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN - login(USER_BARBOSSA_USERNAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setChannel(SchemaConstants.CHANNEL_GUI_SELF_SERVICE_URI); OperationResult result = task.getResult(); @@ -1093,44 +1017,40 @@ protected void testModifyUserBarbossaPasswordSelfServiceFailure(final String TES oldPassword, newPassword); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(objectDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); login(USER_ADMINISTRATOR_USERNAME); assertPartialError(result); assertBarbossaEnabled(newPassword); assertUserAfter(USER_BARBOSSA_OID) - .assertPassword(newPassword); + .assertPassword(newPassword); assertLdapPassword(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, oldPassword); assertLdapConnectorInstances(2); } - @Test public void test230DisableUserBarbossa() throws Exception { - final String TEST_NAME = "test230DisableUserBarbossa"; - displayTestTitle(TEST_NAME); - // precondition assertLdapPassword(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, USER_BARBOSSA_PASSWORD_AD_1); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, task, result, ActivationStatusType.DISABLED); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertBarbossaDisabled(USER_BARBOSSA_PASSWORD_AD_1); @@ -1141,19 +1061,16 @@ public void test230DisableUserBarbossa() throws Exception { */ @Test public void test232ReconcileBarbossa() throws Exception { - final String TEST_NAME = "test232ReconcileBarbossa"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_BARBOSSA_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertBarbossaDisabled(USER_BARBOSSA_PASSWORD_AD_1); @@ -1164,21 +1081,18 @@ public void test232ReconcileBarbossa() throws Exception { */ @Test public void test236EnableUserBarbossa() throws Exception { - final String TEST_NAME = "test236EnableUserBarbossa"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, task, result, ActivationStatusType.ENABLED); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertBarbossaEnabled(USER_BARBOSSA_PASSWORD_AD_1); @@ -1191,19 +1105,16 @@ public void test236EnableUserBarbossa() throws Exception { */ @Test public void test237ReconcileBarbossa() throws Exception { - final String TEST_NAME = "test237ReconcileBarbossa"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_BARBOSSA_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertBarbossaEnabled(USER_BARBOSSA_PASSWORD_AD_1); @@ -1216,22 +1127,19 @@ public void test237ReconcileBarbossa() throws Exception { */ @Test public void test238DisableUserBarbossaRawAndReconcile() throws Exception { - final String TEST_NAME = "test238DisableUserBarbossaRawAndReconcile"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_BARBOSSA_OID, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, ModelExecuteOptions.createRaw(), task, result, ActivationStatusType.DISABLED); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_BARBOSSA_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertBarbossaDisabled(USER_BARBOSSA_PASSWORD_AD_1); @@ -1244,22 +1152,19 @@ public void test238DisableUserBarbossaRawAndReconcile() throws Exception { */ @Test public void test239EnableUserBarbossaRawAndReconcile() throws Exception { - final String TEST_NAME = "test239EnableUserBarbossaRawAndReconcile"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_BARBOSSA_OID, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, ModelExecuteOptions.createRaw(), task, result, ActivationStatusType.ENABLED); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_BARBOSSA_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertBarbossaEnabled(USER_BARBOSSA_PASSWORD_AD_1); @@ -1318,11 +1223,8 @@ private void assertBarbossaDisabled(String password) throws Exception { */ @Test public void test250AssignGuybrushPirates() throws Exception { - final String TEST_NAME = "test250AssignGuybrushPirates"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // ProtectedStringType userPasswordPs = new ProtectedStringType(); @@ -1333,11 +1235,11 @@ public void test250AssignGuybrushPirates() throws Exception { task, result, ActivationStatusType.DISABLED); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_PIRATES_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); Entry entry = assertLdapAccount(USER_GUYBRUSH_USERNAME, USER_GUYBRUSH_FULL_NAME); @@ -1366,22 +1268,19 @@ public void test250AssignGuybrushPirates() throws Exception { @Test public void test255ModifyUserGuybrushPassword() throws Exception { - final String TEST_NAME = "test255ModifyUserGuybrushPassword"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ProtectedStringType userPasswordPs = new ProtectedStringType(); userPasswordPs.setClearValue(USER_GUYBRUSH_PASSWORD_123); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_GUYBRUSH_OID, PATH_CREDENTIALS_PASSWORD_VALUE, task, result, userPasswordPs); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); Entry entry = assertLdapAccount(USER_GUYBRUSH_USERNAME, USER_GUYBRUSH_FULL_NAME); @@ -1400,21 +1299,18 @@ public void test255ModifyUserGuybrushPassword() throws Exception { @Test public void test260EnableGyubrush() throws Exception { - final String TEST_NAME = "test260EnableGyubrush"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_GUYBRUSH_OID, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, task, result, ActivationStatusType.ENABLED); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject user = getUser(USER_GUYBRUSH_OID); @@ -1439,11 +1335,8 @@ public void test260EnableGyubrush() throws Exception { */ @Test public void test270AssignAccountToEmptyhead() throws Exception { - final String TEST_NAME = "test270AssignAccountToEmptyhead"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = createUser(USER_EMPTYHEAD_NAME, USER_EMPTYHEAD_NAME, true); @@ -1452,11 +1345,11 @@ public void test270AssignAccountToEmptyhead() throws Exception { String userEmptyheadOid = userBefore.getOid(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(userEmptyheadOid, getResourceOid(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertPartialError(result); assertMessageContains(result.getMessage(), "does not meet the length, complexity, or history requirement"); @@ -1470,19 +1363,15 @@ public void test270AssignAccountToEmptyhead() throws Exception { */ @Test public void test295TestConnection() throws Exception { - final String TEST_NAME = "test295TestConnection"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); + Task task = getTestTask(); // WHEN - displayWhen(TEST_NAME); + when(); OperationResult testResult = modelService.testResource(getResourceOid(), task); // THEN - displayThen(TEST_NAME); + then(); display("Test connection result", testResult); TestUtil.assertSuccess("Test connection result", testResult); @@ -1493,19 +1382,16 @@ public void test295TestConnection() throws Exception { @Test public void test300AssignBarbossaPirates() throws Exception { - final String TEST_NAME = "test300AssignBarbossaPirates"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_BARBOSSA_OID, ROLE_PIRATES_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1527,11 +1413,8 @@ public void test300AssignBarbossaPirates() throws Exception { @Test public void test390ModifyUserBarbossaRename() throws Exception { - final String TEST_NAME = "test390ModifyUserBarbossaRename"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta objectDelta = createModifyUserReplaceDelta(USER_BARBOSSA_OID, UserType.F_NAME, @@ -1540,13 +1423,12 @@ public void test390ModifyUserBarbossaRename() throws Exception { PrismTestUtil.createPolyString(USER_CPTBARBOSSA_FULL_NAME)); Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); - // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1569,24 +1451,20 @@ public void test390ModifyUserBarbossaRename() throws Exception { // TODO: create account with a group membership - @Test public void test395UnAssignBarbossaPirates() throws Exception { - final String TEST_NAME = "test395UnAssignBarbossaPirates"; - displayTestTitle(TEST_NAME); - // TODO: do this on another account. There is a bad interference with rename. // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_BARBOSSA_OID, ROLE_PIRATES_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1608,19 +1486,16 @@ public void test395UnAssignBarbossaPirates() throws Exception { @Test public void test399UnAssignAccountBarbossa() throws Exception { - final String TEST_NAME = "test399UnAssignAccountBarbossa"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_BARBOSSA_OID, getResourceOid(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1635,11 +1510,8 @@ public void test399UnAssignAccountBarbossa() throws Exception { @Test public void test500AddOrgMeleeIsland() throws Exception { - final String TEST_NAME = "test500AddOrgMeleeIsland"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject org = instantiateObject(OrgType.class); @@ -1653,11 +1525,11 @@ public void test500AddOrgMeleeIsland() throws Exception { orgType.getAssignment().add(metaroleAssignment); // WHEN - displayWhen(TEST_NAME); + when(); addObject(org, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); orgMeleeIslandOid = org.getOid(); @@ -1680,19 +1552,16 @@ public void test500AddOrgMeleeIsland() throws Exception { @Test public void test510AssignGuybrushMeleeIsland() throws Exception { - final String TEST_NAME = "test510AssignGuybrushMeleeIsland"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignOrg(USER_GUYBRUSH_OID, orgMeleeIslandOid, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1715,11 +1584,8 @@ public void test510AssignGuybrushMeleeIsland() throws Exception { */ @Test public void test515AddOrgGroupMeleeIslandPirates() throws Exception { - final String TEST_NAME = "test515AddOrgGroupMeleeIslandPirates"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject role = instantiateObject(RoleType.class); @@ -1741,11 +1607,11 @@ public void test515AddOrgGroupMeleeIslandPirates() throws Exception { roleType.getAssignment().add(orgAssignment); // WHEN - displayWhen(TEST_NAME); + when(); addObject(role, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1770,19 +1636,16 @@ public void test515AddOrgGroupMeleeIslandPirates() throws Exception { */ @Test public void test520RenameMeleeIsland() throws Exception { - final String TEST_NAME = "test520RenameMeleeIsland"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); renameObject(OrgType.class, orgMeleeIslandOid, GROUP_MELEE_ISLAND_ALT_NAME, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1830,21 +1693,18 @@ public void test520RenameMeleeIsland() throws Exception { */ @Test public void test522ModifyMeleeIslandPirates() throws Exception { - final String TEST_NAME = "test522GetMeleeIslandPirates"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyObjectReplaceProperty(ShadowType.class, groupMeleeIslandPiratesOid, ItemPath.create(ShadowType.F_ATTRIBUTES, new QName(MidPointConstants.NS_RI, "description")), task, result, GROUP_MELEE_ISLAND_PIRATES_DESCRIPTION); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1858,19 +1718,16 @@ public void test522ModifyMeleeIslandPirates() throws Exception { @Test public void test524GetMeleeIslandPirates() throws Exception { - final String TEST_NAME = "test524GetMeleeIslandPirates"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject shadow = modelService.getObject(ShadowType.class, groupMeleeIslandPiratesOid, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Shadow after", shadow); @@ -1883,25 +1740,20 @@ public void test524GetMeleeIslandPirates() throws Exception { Entry entryOrgGroup = assertLdapOrgGroup(GROUP_MELEE_ISLAND_PIRATES_NAME, GROUP_MELEE_ISLAND_ALT_NAME); display("Melee org", entryOrgGroup); assertNoLdapOrgGroup(GROUP_MELEE_ISLAND_PIRATES_NAME, GROUP_MELEE_ISLAND_NAME); - -// assertLdapConnectorInstances(2); } @Test public void test595DeleteOrgGroupMeleeIslandPirates() throws Exception { - final String TEST_NAME = "test595DeleteOrgGroupMeleeIslandPirates"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); deleteObject(RoleType.class, roleMeleeIslandPiratesOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertNoLdapOrgGroup(GROUP_MELEE_ISLAND_PIRATES_NAME, GROUP_MELEE_ISLAND_ALT_NAME); @@ -1916,26 +1768,23 @@ public void test595DeleteOrgGroupMeleeIslandPirates() throws Exception { * We create "underMelee" org that gets into the way of the delete. * Melee cannot be deleted in an ordinary way. "tree delete" control must * be used. This is configured in the connector config. - * + *

* MID-5935 */ @Test public void test599DeleteOrgMeleeIsland() throws Exception { - final String TEST_NAME = "test599DeleteOrgMeleeIsland"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); createUnderMeleeEntry(); // WHEN - displayWhen(TEST_NAME); + when(); deleteObject(OrgType.class, orgMeleeIslandOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertNoLdapGroup(GROUP_MELEE_ISLAND_NAME); @@ -1960,21 +1809,18 @@ protected void createUnderMeleeEntry() throws LdapException, IOException { @Test public void test600AssignAccountSubman() throws Exception { - final String TEST_NAME = "test600AssignAccountSubman"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); long tsStart = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_SUBMAN_OID, ROLE_SUBMISSIVE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1991,7 +1837,7 @@ public void test600AssignAccountSubman() throws Exception { accountSubmanOid = shadow.getOid(); Collection> identifiers = ShadowUtil.getPrimaryIdentifiers(shadow); String accountBarbossaIcfUid = (String) identifiers.iterator().next().getRealValue(); - assertNotNull("No identifier in "+shadow, accountBarbossaIcfUid); + assertNotNull("No identifier in " + shadow, accountBarbossaIcfUid); assertEquals("Wrong ICFS UID", AdUtils.formatGuidToDashedNotation(MiscUtil.binaryToHex(entry.get(getPrimaryIdentifierAttributeName()).getBytes())), @@ -2003,31 +1849,28 @@ public void test600AssignAccountSubman() throws Exception { // MID-4624 ResourceAttribute createTimestampAttribute = ShadowUtil.getAttribute(shadow, new QName(MidPointConstants.NS_RI, "createTimeStamp")); - assertNotNull("No createTimestamp in "+shadow, createTimestampAttribute); + assertNotNull("No createTimestamp in " + shadow, createTimestampAttribute); XMLGregorianCalendar createTimestamp = createTimestampAttribute.getRealValue(); long createTimestampMillis = XmlTypeConverter.toMillis(createTimestamp); // LDAP server may be on a different host. Allow for some clock offset. - TestUtil.assertBetween("Wrong createTimestamp in "+shadow, roundTsDown(tsStart)-120000, roundTsUp(tsEnd)+120000, createTimestampMillis); + TestUtil.assertBetween("Wrong createTimestamp in " + shadow, roundTsDown(tsStart) - 120000, roundTsUp(tsEnd) + 120000, createTimestampMillis); // assertLdapConnectorInstances(2); } @Test public void test610ModifyUserSubmanTitle() throws Exception { - final String TEST_NAME = "test610ModifyUserSubmanTitle"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_SUBMAN_OID, UserType.F_TITLE, task, result, createPolyString("Underdog")); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); Entry entry = assertLdapSubAccount(USER_SUBMAN_USERNAME, USER_SUBMAN_FULL_NAME); @@ -2044,22 +1887,19 @@ public void test610ModifyUserSubmanTitle() throws Exception { @Test public void test620ModifyUserSubmanPassword() throws Exception { - final String TEST_NAME = "test620ModifyUserSubmanPassword"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ProtectedStringType userPasswordPs = new ProtectedStringType(); userPasswordPs.setClearValue("SuB.321"); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_SUBMAN_OID, PATH_CREDENTIALS_PASSWORD_VALUE, task, result, userPasswordPs); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); Entry entry = assertLdapSubAccount(USER_SUBMAN_USERNAME, USER_SUBMAN_FULL_NAME); @@ -2076,21 +1916,18 @@ public void test620ModifyUserSubmanPassword() throws Exception { @Test public void test630DisableUserSubman() throws Exception { - final String TEST_NAME = "test630DisableUserSubman"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_SUBMAN_OID, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, task, result, ActivationStatusType.DISABLED); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); // assertLdapConnectorInstances(2); @@ -2117,21 +1954,18 @@ public void test630DisableUserSubman() throws Exception { @Test public void test639EnableUserSubman() throws Exception { - final String TEST_NAME = "test639EnableUserBarbossa"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_SUBMAN_OID, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, task, result, ActivationStatusType.ENABLED); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject user = getUser(USER_SUBMAN_OID); @@ -2149,11 +1983,8 @@ public void test639EnableUserSubman() throws Exception { @Test public void test690ModifyUserSubmanRename() throws Exception { - final String TEST_NAME = "test690ModifyUserSubmanRename"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta objectDelta = createModifyUserReplaceDelta(USER_SUBMAN_OID, UserType.F_NAME, @@ -2162,11 +1993,11 @@ public void test690ModifyUserSubmanRename() throws Exception { createPolyString(USER_SUBDOG_FULL_NAME)); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(objectDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); Entry entry = assertLdapSubAccount(USER_SUBDOG_USERNAME, USER_SUBDOG_FULL_NAME); @@ -2188,19 +2019,16 @@ public void test690ModifyUserSubmanRename() throws Exception { @Test public void test699UnAssignAccountSubdog() throws Exception { - final String TEST_NAME = "test699UnAssignAccountSubdog"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_SUBMAN_OID, ROLE_SUBMISSIVE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertNoLdapSubAccount(USER_SUBMAN_USERNAME, USER_SUBMAN_FULL_NAME); @@ -2220,28 +2048,21 @@ public void test699UnAssignAccountSubdog() throws Exception { */ @Test public void test700AssignAccountSubmarineAndModify() throws Exception { - final String TEST_NAME = "test700AssignAccountSubmarineAndModify"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); - long tsStart = System.currentTimeMillis(); - // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_SUBMARINE_OID, ROLE_SUBMISSIVE_OID, task, result); modifyUserReplace(USER_SUBMARINE_OID, UserType.F_TITLE, task, result, PrismTestUtil.createPolyString("Underseadog")); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); - long tsEnd = System.currentTimeMillis(); - Entry entry = assertLdapSubAccount(USER_SUBMARINE_USERNAME, USER_SUBMARINE_FULL_NAME); display("Sub entry", entry); assertAttribute(entry, "title", "Underseadog"); @@ -2253,61 +2074,48 @@ public void test700AssignAccountSubmarineAndModify() throws Exception { accountSubmarineOid = shadow.getOid(); Collection> identifiers = ShadowUtil.getPrimaryIdentifiers(shadow); String accountIcfUid = (String) identifiers.iterator().next().getRealValue(); - assertNotNull("No identifier in "+shadow, accountIcfUid); + assertNotNull("No identifier in " + shadow, accountIcfUid); assertEquals("Wrong ICFS UID", AdUtils.formatGuidToDashedNotation(MiscUtil.binaryToHex(entry.get(getPrimaryIdentifierAttributeName()).getBytes())), accountIcfUid); assertAttribute(entry, AdUtils.ATTRIBUTE_USER_ACCOUNT_CONTROL_NAME, "512"); - -// assertLdapConnectorInstances(2); } @Test public void test809UnAssignAccountSubmarine() throws Exception { - final String TEST_NAME = "test809UnAssignAccountSubmarine"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_SUBMARINE_OID, ROLE_SUBMISSIVE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertNoLdapSubAccount(USER_SUBMARINE_USERNAME, USER_SUBMARINE_FULL_NAME); PrismObject user = getUser(USER_SUBMARINE_OID); assertNoLinkedAccount(user); - -// assertLdapConnectorInstances(2); } @Test public void test850ReconcileAccounts() throws Exception { - final String TEST_NAME = "test850ReconcileAccounts"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - assertUsers(6); // WHEN - displayWhen(TEST_NAME); + when(); addTask(getReconciliationTaskFile()); waitForTaskFinish(getReconciliationTaskOid(), true); // THEN - displayThen(TEST_NAME); + then(); assertUsers(15); // TODO @@ -2319,46 +2127,46 @@ public void test850ReconcileAccounts() throws Exception { protected void assertAccountShadow(PrismObject shadow, String dn) throws SchemaException { super.assertAccountShadow(shadow, dn); ResourceAttribute primaryIdAttr = ShadowUtil.getAttribute(shadow, getPrimaryIdentifierAttributeQName()); - assertNotNull("No primary identifier ("+getPrimaryIdentifierAttributeQName()+" in "+shadow, primaryIdAttr); + assertNotNull("No primary identifier (" + getPrimaryIdentifierAttributeQName() + " in " + shadow, primaryIdAttr); String primaryId = primaryIdAttr.getRealValue(); - assertTrue("Unexpected chars in primary ID: '"+primaryId+"'", primaryId.matches("[a-z0-9\\-]+")); + assertTrue("Unexpected chars in primary ID: '" + primaryId + "'", primaryId.matches("[a-z0-9\\-]+")); - ResourceAttribute objectSidAttr = ShadowUtil.getAttribute(shadow, new QName(MidPointConstants.NS_RI,AdUtils.ATTRIBUTE_OBJECT_SID_NAME)); - assertNotNull("No SID in "+shadow, objectSidAttr); + ResourceAttribute objectSidAttr = ShadowUtil.getAttribute(shadow, new QName(MidPointConstants.NS_RI, AdUtils.ATTRIBUTE_OBJECT_SID_NAME)); + assertNotNull("No SID in " + shadow, objectSidAttr); display("SID of " + dn + ": " + objectSidAttr); } protected void assertSid(PrismObject shadow, String expectedSid) throws SchemaException { - ResourceAttribute objectSidAttr = ShadowUtil.getAttribute(shadow, new QName(MidPointConstants.NS_RI,AdUtils.ATTRIBUTE_OBJECT_SID_NAME)); - assertNotNull("No SID in "+shadow, objectSidAttr); + ResourceAttribute objectSidAttr = ShadowUtil.getAttribute(shadow, new QName(MidPointConstants.NS_RI, AdUtils.ATTRIBUTE_OBJECT_SID_NAME)); + assertNotNull("No SID in " + shadow, objectSidAttr); display("SID of " + shadow + ": " + objectSidAttr); - assertEquals("Wrong SID in "+shadow, expectedSid, objectSidAttr.getRealValue()); + assertEquals("Wrong SID in " + shadow, expectedSid, objectSidAttr.getRealValue()); } private void assertObjectCategory(PrismObject shadow, String expectedObjectCategory) { - ResourceAttribute objectCategoryAttr = ShadowUtil.getAttribute(shadow, new QName(MidPointConstants.NS_RI,AdUtils.ATTRIBUTE_OBJECT_CATEGORY_NAME)); - assertNotNull("No objectCategory in "+shadow, objectCategoryAttr); + ResourceAttribute objectCategoryAttr = ShadowUtil.getAttribute(shadow, new QName(MidPointConstants.NS_RI, AdUtils.ATTRIBUTE_OBJECT_CATEGORY_NAME)); + assertNotNull("No objectCategory in " + shadow, objectCategoryAttr); display("objectCategory of " + shadow + ": " + objectCategoryAttr); - assertEquals("Wrong objectCategory in "+shadow, expectedObjectCategory, objectCategoryAttr.getRealValue()); + assertEquals("Wrong objectCategory in " + shadow, expectedObjectCategory, objectCategoryAttr.getRealValue()); } @Override protected Entry assertLdapAccount(String samAccountName, String cn) throws LdapException, IOException, CursorException { - Entry entry = searchLdapAccount("(cn="+cn+")"); + Entry entry = searchLdapAccount("(cn=" + cn + ")"); assertAttribute(entry, "cn", cn); assertAttribute(entry, AdUtils.ATTRIBUTE_SAM_ACCOUNT_NAME_NAME, samAccountName); return entry; } protected Entry assertLdapSubAccount(String samAccountName, String cn) throws LdapException, IOException, CursorException { - Entry entry = searchLdapAccount(getSubLdapConnectionConfig(), "(cn="+cn+")"); + Entry entry = searchLdapAccount(getSubLdapConnectionConfig(), "(cn=" + cn + ")"); assertAttribute(entry, "cn", cn); assertAttribute(entry, AdUtils.ATTRIBUTE_SAM_ACCOUNT_NAME_NAME, samAccountName); return entry; } @Override - protected void assertNoLdapAccount(String uid) throws LdapException, IOException, CursorException { + protected void assertNoLdapAccount(String uid) { throw new UnsupportedOperationException("Boom! Cannot do this here. This is bloody AD! We need full name!"); } @@ -2372,12 +2180,12 @@ protected void assertNoLdapSubAccount(String uid, String cn) throws LdapExceptio protected void assertNoLdapAccount(UserLdapConnectionConfig config, String uid, String cn) throws LdapException, IOException, CursorException { LdapNetworkConnection connection = ldapConnect(config); - List entriesCn = ldapSearch(config, connection, "(cn="+cn+")"); - List entriesSamAccountName = ldapSearch(config, connection, "(sAMAccountName="+uid+")"); + List entriesCn = ldapSearch(config, connection, "(cn=" + cn + ")"); + List entriesSamAccountName = ldapSearch(config, connection, "(sAMAccountName=" + uid + ")"); ldapDisconnect(connection); - assertEquals("Unexpected number of entries for cn="+cn+": "+entriesCn, 0, entriesCn.size()); - assertEquals("Unexpected number of entries for sAMAccountName="+uid+": "+entriesSamAccountName, 0, entriesSamAccountName.size()); + assertEquals("Unexpected number of entries for cn=" + cn + ": " + entriesCn, 0, entriesCn.size()); + assertEquals("Unexpected number of entries for sAMAccountName=" + uid + ": " + entriesSamAccountName, 0, entriesSamAccountName.size()); } @Override @@ -2387,11 +2195,11 @@ protected String toAccountDn(String username) { @Override protected String toAccountDn(String username, String fullName) { - return ("CN="+fullName+","+getPeopleLdapSuffix()); + return ("CN=" + fullName + "," + getPeopleLdapSuffix()); } protected String toAccountSubDn(String username, String fullName) { - return ("CN="+fullName+","+getPeopleLdapSubSuffix()); + return ("CN=" + fullName + "," + getPeopleLdapSubSuffix()); } @Override @@ -2399,22 +2207,22 @@ protected Rdn toAccountRdn(String username, String fullName) { try { return new Rdn(new Ava("CN", fullName)); } catch (LdapInvalidDnException e) { - throw new IllegalStateException(e.getMessage(),e); + throw new IllegalStateException(e.getMessage(), e); } } protected String toOrgDn(String cn) { - return "ou="+cn+","+getOrgsLdapSuffix(); + return "ou=" + cn + "," + getOrgsLdapSuffix(); } protected String toOrgGroupDn(String groupCn, String orgName) { - return "cn="+groupCn+","+toOrgDn(orgName); + return "cn=" + groupCn + "," + toOrgDn(orgName); } protected Entry assertLdapOrg(String orgName) throws LdapException, IOException, CursorException { String dn = toOrgDn(orgName); Entry entry = getLdapEntry(dn); - assertNotNull("No entry "+dn, entry); + assertNotNull("No entry " + dn, entry); assertAttribute(entry, "ou", orgName); return entry; } @@ -2422,14 +2230,14 @@ protected Entry assertLdapOrg(String orgName) throws LdapException, IOException, protected Entry assertNoLdapOrg(String orgName) throws LdapException, IOException, CursorException { String dn = toOrgDn(orgName); Entry entry = getLdapEntry(dn); - assertNull("Unexpected org entry "+entry, entry); + assertNull("Unexpected org entry " + entry, entry); return entry; } protected Entry assertLdapOrgGroup(String groupCn, String orgName) throws LdapException, IOException, CursorException { String dn = toOrgGroupDn(groupCn, orgName); Entry entry = getLdapEntry(dn); - assertNotNull("No entry "+dn, entry); + assertNotNull("No entry " + dn, entry); assertAttribute(entry, "cn", groupCn); return entry; } @@ -2437,7 +2245,7 @@ protected Entry assertLdapOrgGroup(String groupCn, String orgName) throws LdapEx protected Entry assertNoLdapOrgGroup(String groupCn, String orgName) throws LdapException, IOException, CursorException { String dn = toOrgGroupDn(groupCn, orgName); Entry entry = getLdapEntry(dn); - assertNull("Unexpected org group entry "+entry, entry); + assertNull("Unexpected org group entry " + entry, entry); return entry; } @@ -2450,7 +2258,7 @@ protected void assertLdapPassword(UserLdapConnectionConfig config, String uid, S assertLdapPassword(config, entry, password); } - protected void assertLdapPassword(String uid, String password) throws LdapException, IOException, CursorException { + protected void assertLdapPassword(String uid, String password) { throw new UnsupportedOperationException("Boom! Cannot do this here. This is bloody AD! We need full name!"); } @@ -2490,7 +2298,7 @@ public void assertAttribute(PrismObject shadow, String attrName, public void assertAttribute(PrismObject shadow, QName attrQname, T... expectedValues) { List actualValues = ShadowUtil.getAttributeValues(shadow, attrQname); - PrismAsserts.assertSets("attribute "+attrQname+" in " + shadow, actualValues, expectedValues); + PrismAsserts.assertSets("attribute " + attrQname + " in " + shadow, actualValues, expectedValues); } protected abstract void assertAccountDisabled(PrismObject shadow); diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapRawTest.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapRawTest.java index 7f7e51a8856..82cfcd54ba8 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapRawTest.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapRawTest.java @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2016 Evolveum and contributors +/* + * Copyright (c) 2016-2020 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 * and European Union Public License. See LICENSE file for details. @@ -18,7 +18,6 @@ import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.schema.util.ResourceTypeUtil; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; /** @@ -29,10 +28,7 @@ public abstract class AbstractAdLdapRawTest extends AbstractAdLdapTest { @Test - public void test050Capabilities() throws Exception { - final String TEST_NAME = "test050Capabilities"; - TestUtil.displayTestTitle(this, TEST_NAME); - + public void test050Capabilities() { Collection nativeCapabilitiesCollection = ResourceTypeUtil.getNativeCapabilitiesCollection(resourceType); display("Native capabilities", nativeCapabilitiesCollection); diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapTest.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapTest.java index 1ca13e9dc9d..7a95d721c5d 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapTest.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapTest.java @@ -1,36 +1,28 @@ -/** +/* * Copyright (c) 2015-2019 Evolveum and contributors - * + *

* This work is dual-licensed under the Apache License 2.0 * and European Union Public License. See LICENSE file for details. */ package com.evolveum.midpoint.testing.conntest.ad; +import static org.testng.AssertJUnit.*; + import static com.evolveum.midpoint.schema.constants.SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS; import static com.evolveum.midpoint.schema.constants.SchemaConstants.PATH_CREDENTIALS_PASSWORD_VALUE; import static com.evolveum.midpoint.testing.conntest.ad.AdUtils.*; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; import java.io.File; import java.io.IOException; -import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import java.util.Collection; import java.util.List; - import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.path.ItemPath; import org.apache.commons.lang.StringUtils; import org.apache.directory.api.ldap.model.cursor.CursorException; -import org.apache.directory.api.ldap.model.entry.DefaultEntry; -import org.apache.directory.api.ldap.model.entry.DefaultModification; -import org.apache.directory.api.ldap.model.entry.Entry; -import org.apache.directory.api.ldap.model.entry.Modification; -import org.apache.directory.api.ldap.model.entry.ModificationOperation; +import org.apache.directory.api.ldap.model.entry.*; import org.apache.directory.api.ldap.model.exception.LdapException; import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException; import org.apache.directory.api.ldap.model.name.Ava; @@ -44,6 +36,7 @@ import com.evolveum.midpoint.prism.PrismProperty; import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.delta.PropertyDelta; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.query.ObjectPaging; import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.prism.query.OrderDirection; @@ -70,23 +63,14 @@ import com.evolveum.midpoint.util.MiscUtil; import com.evolveum.midpoint.util.exception.ObjectNotFoundException; import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SystemException; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; /** * @author semancik - * */ -@Listeners({com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class}) +@Listeners({ com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class }) public abstract class AbstractAdLdapTest extends AbstractLdapSynchronizationTest { protected static final File TEST_DIR = new File(MidPointTestConstants.TEST_RESOURCES_DIR, "ad-ldap"); @@ -97,8 +81,6 @@ public abstract class AbstractAdLdapTest extends AbstractLdapSynchronizationTest protected static final File ROLE_META_ORG_FILE = new File(TEST_DIR, "role-meta-org.xml"); protected static final String ROLE_META_ORG_OID = "f2ad0ace-45d7-11e5-af54-001e8c717e5b"; - - protected static final String ACCOUNT_JACK_SAM_ACCOUNT_NAME = "jack"; protected static final String ACCOUNT_JACK_FULL_NAME = "Jack Sparrow"; protected static final String ACCOUNT_JACK_PASSWORD = "qwe.123"; @@ -118,7 +100,6 @@ public abstract class AbstractAdLdapTest extends AbstractLdapSynchronizationTest protected String jackAccountOid; protected String groupPiratesOid; - protected long jackLockoutTimestamp; protected String accountBarbossaOid; protected String orgMeleeIslandOid; protected String groupMeleeOid; @@ -175,12 +156,12 @@ public String getPrimaryIdentifierAttributeName() { @Override protected String getPeopleLdapSuffix() { - return "CN=Users,"+getLdapSuffix(); + return "CN=Users," + getLdapSuffix(); } @Override protected String getGroupsLdapSuffix() { - return "CN=Users,"+getLdapSuffix(); + return "CN=Users," + getLdapSuffix(); } @Override @@ -217,7 +198,9 @@ protected boolean isGroupMemberMandatory() { return false; } - protected String getLdapConnectorClassName() { return AdUtils.AD_CONNECTOR_TYPE; } + protected String getLdapConnectorClassName() { + return AdUtils.AD_CONNECTOR_TYPE; + } @Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { @@ -239,8 +222,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test @Override public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); super.test000Sanity(); assertLdapPassword(ACCOUNT_JACK_SAM_ACCOUNT_NAME, ACCOUNT_JACK_FULL_NAME, ACCOUNT_JACK_PASSWORD); @@ -254,9 +235,6 @@ public void test000Sanity() throws Exception { @Test @Override public void test020Schema() throws Exception { - final String TEST_NAME = "test020Schema"; - displayTestTitle(TEST_NAME); - accountObjectClassDefinition = AdUtils.assertAdResourceSchema(resource, getAccountObjectClass(), prismContext); assertLdapConnectorInstances(1); @@ -266,11 +244,8 @@ public void test020Schema() throws Exception { @Test public void test100SeachJackBySamAccountName() throws Exception { - final String TEST_NAME = "test100SeachJackBySamAccountName"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = createSamAccountNameQuery(ACCOUNT_JACK_SAM_ACCOUNT_NAME); @@ -279,14 +254,14 @@ public void test100SeachJackBySamAccountName() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN result.computeStatus(); TestUtil.assertSuccess(result); - assertEquals("Unexpected search result: "+shadows, 1, shadows.size()); + assertEquals("Unexpected search result: " + shadows, 1, shadows.size()); PrismObject shadow = shadows.get(0); display("Shadow", shadow); @@ -306,11 +281,8 @@ public void test100SeachJackBySamAccountName() throws Exception { @Test public void test105SeachPiratesByCn() throws Exception { - final String TEST_NAME = "test105SeachPiratesByCn"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getGroupObjectClass(), prismContext); @@ -320,14 +292,14 @@ public void test105SeachPiratesByCn() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN result.computeStatus(); TestUtil.assertSuccess(result); - assertEquals("Unexpected search result: "+shadows, 1, shadows.size()); + assertEquals("Unexpected search result: " + shadows, 1, shadows.size()); PrismObject shadow = shadows.get(0); display("Shadow", shadow); @@ -346,18 +318,15 @@ public void test105SeachPiratesByCn() throws Exception { @Test public void test110GetJack() throws Exception { - final String TEST_NAME = "test110GetJack"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberCounter(InternalCounters.CONNECTOR_OPERATION_COUNT); rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject shadow = modelService.getObject(ShadowType.class, jackAccountOid, null, task, result); // THEN @@ -382,17 +351,13 @@ public void test110GetJack() throws Exception { assertLdapConnectorInstances(1); } - /** * No paging. It should return all accounts. */ @Test public void test150SeachAllAccounts() throws Exception { - final String TEST_NAME = "test150SeachAllAccounts"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -401,7 +366,7 @@ public void test150SeachAllAccounts() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - SearchResultList> searchResultList = doSearch(TEST_NAME, query, + SearchResultList> searchResultList = doSearch(query, NUMBER_OF_ACCOUNTS, task, result); // TODO: why 11? should be 1 @@ -421,11 +386,8 @@ public void test150SeachAllAccounts() throws Exception { */ @Test public void test152SeachFirst2Accounts() throws Exception { - final String TEST_NAME = "test152SeachFirst2Accounts"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -434,7 +396,7 @@ public void test152SeachFirst2Accounts() throws Exception { paging.setMaxSize(2); query.setPaging(paging); - SearchResultList> searchResultList = doSearch(TEST_NAME, query, 2, task, result); + SearchResultList> searchResultList = doSearch(query, 2, task, result); assertCounterIncrement(InternalCounters.CONNECTOR_OPERATION_COUNT, 1); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); @@ -452,11 +414,8 @@ public void test152SeachFirst2Accounts() throws Exception { */ @Test public void test154SeachFirst11Accounts() throws Exception { - final String TEST_NAME = "test154SeachFirst11Accounts"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -465,7 +424,7 @@ public void test154SeachFirst11Accounts() throws Exception { paging.setMaxSize(11); query.setPaging(paging); - SearchResultList> searchResultList = doSearch(TEST_NAME, query, 11, task, result); + SearchResultList> searchResultList = doSearch(query, 11, task, result); assertCounterIncrement(InternalCounters.CONNECTOR_OPERATION_COUNT, 1); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); @@ -480,11 +439,8 @@ public void test154SeachFirst11Accounts() throws Exception { @Test public void test162SeachFirst2AccountsOffset0() throws Exception { - final String TEST_NAME = "test162SeachFirst2AccountsOffset0"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -494,7 +450,7 @@ public void test162SeachFirst2AccountsOffset0() throws Exception { paging.setMaxSize(2); query.setPaging(paging); - SearchResultList> searchResultList = doSearch(TEST_NAME, query, 2, task, result); + SearchResultList> searchResultList = doSearch(query, 2, task, result); assertCounterIncrement(InternalCounters.CONNECTOR_OPERATION_COUNT, 1); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); @@ -514,11 +470,8 @@ public void test162SeachFirst2AccountsOffset0() throws Exception { */ @Test public void test172Search2AccountsOffset1() throws Exception { - final String TEST_NAME = "test172Search2AccountsOffset1"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -526,7 +479,7 @@ public void test172Search2AccountsOffset1() throws Exception { ObjectPaging paging = prismContext.queryFactory().createPaging(1, 2); query.setPaging(paging); - SearchResultList> searchResultList = doSearch(TEST_NAME, query, 2, task, result); + SearchResultList> searchResultList = doSearch(query, 2, task, result); assertCounterIncrement(InternalCounters.CONNECTOR_OPERATION_COUNT, 1); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); @@ -546,11 +499,8 @@ public void test172Search2AccountsOffset1() throws Exception { */ @Test public void test174SeachFirst11AccountsOffset2() throws Exception { - final String TEST_NAME = "test174SeachFirst11AccountsOffset2"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -561,7 +511,7 @@ public void test174SeachFirst11AccountsOffset2() throws Exception { allowDuplicateSearchResults = true; // WHEN - SearchResultList> searchResultList = doSearch(TEST_NAME, query, 11, task, result); + SearchResultList> searchResultList = doSearch(query, 11, task, result); // THEN allowDuplicateSearchResults = false; @@ -584,11 +534,8 @@ public void test174SeachFirst11AccountsOffset2() throws Exception { */ @Test public void test182Search2AccountsOffset1SortCn() throws Exception { - final String TEST_NAME = "test182Search2AccountsOffset1SortCn"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -597,7 +544,7 @@ public void test182Search2AccountsOffset1SortCn() throws Exception { paging.setOrdering(getAttributePath(resource, "cn"), OrderDirection.ASCENDING); query.setPaging(paging); - SearchResultList> shadows = doSearch(TEST_NAME, query, 2, task, result); + SearchResultList> shadows = doSearch(query, 2, task, result); assertAccountShadow(shadows.get(0), "CN=Administrator,CN=Users,DC=win,DC=evolveum,DC=com"); assertAccountShadow(shadows.get(1), "CN=Chuck LeChuck,CN=Users,DC=win,DC=evolveum,DC=com"); @@ -615,20 +562,17 @@ public void test182Search2AccountsOffset1SortCn() throws Exception { @Test public void test200AssignAccountBarbossa() throws Exception { - final String TEST_NAME = "test200AssignAccountBarbossa"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); long tsStart = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_BARBOSSA_OID, getResourceOid(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); long tsEnd = System.currentTimeMillis(); @@ -643,7 +587,7 @@ public void test200AssignAccountBarbossa() throws Exception { accountBarbossaOid = shadow.getOid(); Collection> identifiers = ShadowUtil.getPrimaryIdentifiers(shadow); String accountBarbossaIcfUid = (String) identifiers.iterator().next().getRealValue(); - assertNotNull("No identifier in "+shadow, accountBarbossaIcfUid); + assertNotNull("No identifier in " + shadow, accountBarbossaIcfUid); assertEquals("Wrong ICFS UID", AdUtils.formatGuidToDashedNotation(MiscUtil.binaryToHex(entry.get(getPrimaryIdentifierAttributeName()).getBytes())), @@ -654,21 +598,18 @@ public void test200AssignAccountBarbossa() throws Exception { assertAttribute(entry, ATTRIBUTE_USER_ACCOUNT_CONTROL_NAME, "512"); ResourceAttribute createTimestampAttribute = ShadowUtil.getAttribute(shadow, new QName(MidPointConstants.NS_RI, "createTimeStamp")); - assertNotNull("No createTimestamp in "+shadow, createTimestampAttribute); + assertNotNull("No createTimestamp in " + shadow, createTimestampAttribute); XMLGregorianCalendar createTimestamp = createTimestampAttribute.getRealValue(); // LDAP server may be on a different host. Allow for some clock offset. - TestUtil.assertBetween("Wrong createTimestamp in "+shadow, roundTsDown(tsStart)-120000, roundTsUp(tsEnd)+120000, XmlTypeConverter.toMillis(createTimestamp)); + TestUtil.assertBetween("Wrong createTimestamp in " + shadow, roundTsDown(tsStart) - 120000, roundTsUp(tsEnd) + 120000, XmlTypeConverter.toMillis(createTimestamp)); assertLdapConnectorInstances(2); } @Test public void test210ModifyAccountBarbossaTitle() throws Exception { - final String TEST_NAME = "test210ModifyAccountBarbossaTitle"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object() @@ -680,11 +621,11 @@ public void test210ModifyAccountBarbossaTitle() throws Exception { delta.addModification(attrDelta); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -701,11 +642,8 @@ public void test210ModifyAccountBarbossaTitle() throws Exception { @Test public void test212ModifyAccountBarbossaShowInAdvancedViewOnlyTrue() throws Exception { - final String TEST_NAME = "test212ModifyAccountBarbossaShowInAdvancedViewOnlyTrue"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object() @@ -717,11 +655,11 @@ public void test212ModifyAccountBarbossaShowInAdvancedViewOnlyTrue() throws Exce delta.addModification(attrDelta); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -741,14 +679,10 @@ public void test212ModifyAccountBarbossaShowInAdvancedViewOnlyTrue() throws Exce */ @Test public void test213ModifyUserBarbossaShowInAdvancedViewOnlyFalse() throws Exception { - final String TEST_NAME = "test213ModifyUserBarbossaShowInAdvancedViewOnlyFalse"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); - ObjectDelta delta = prismContext.deltaFactory().object() .createEmptyModifyDelta(ShadowType.class, accountBarbossaOid); QName attrQName = new QName(MidPointConstants.NS_RI, "showInAdvancedViewOnly"); @@ -758,12 +692,12 @@ public void test213ModifyUserBarbossaShowInAdvancedViewOnlyFalse() throws Except delta.addModification(attrDelta); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, ItemPath.create(UserType.F_EXTENSION, EXTENSION_SHOW_IN_ADVANCED_VIEW_ONLY_QNAME), task, result, Boolean.FALSE); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); Entry entry = assertLdapAccount(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME); @@ -779,22 +713,19 @@ public void test213ModifyUserBarbossaShowInAdvancedViewOnlyFalse() throws Except @Test public void test220ModifyUserBarbossaPassword() throws Exception { - final String TEST_NAME = "test220ModifyUserBarbossaPassword"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ProtectedStringType userPasswordPs = new ProtectedStringType(); userPasswordPs.setClearValue(USER_BARBOSSA_PASSWORD_2); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, PATH_CREDENTIALS_PASSWORD_VALUE, task, result, userPasswordPs); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); Entry entry = assertLdapAccount(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME); @@ -814,22 +745,19 @@ public void test220ModifyUserBarbossaPassword() throws Exception { */ @Test public void test222ModifyUserBarbossaPasswordNational() throws Exception { - final String TEST_NAME = "test222ModifyUserBarbossaPasswordNational"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ProtectedStringType userPasswordPs = new ProtectedStringType(); userPasswordPs.setClearValue(USER_BARBOSSA_PASSWORD_AD_1); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, PATH_CREDENTIALS_PASSWORD_VALUE, task, result, userPasswordPs); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); Entry entry = assertLdapAccount(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME); @@ -846,22 +774,19 @@ public void test222ModifyUserBarbossaPasswordNational() throws Exception { @Test public void test230DisableUserBarbossa() throws Exception { - final String TEST_NAME = "test230DisableUserBarbossa"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // precondition assertLdapPassword(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, USER_BARBOSSA_PASSWORD_AD_1); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, PATH_ACTIVATION_ADMINISTRATIVE_STATUS, task, result, ActivationStatusType.DISABLED); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertLdapConnectorInstances(2); @@ -888,19 +813,16 @@ public void test230DisableUserBarbossa() throws Exception { @Test public void test239EnableUserBarbossa() throws Exception { - final String TEST_NAME = "test239EnableUserBarbossa"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, PATH_ACTIVATION_ADMINISTRATIVE_STATUS, task, result, ActivationStatusType.ENABLED); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject user = getUser(USER_BARBOSSA_OID); @@ -921,21 +843,18 @@ public void test239EnableUserBarbossa() throws Exception { */ @Test public void test250AssignGuybrushPirates() throws Exception { - final String TEST_NAME = "test250AssignGuybrushPirates"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_GUYBRUSH_OID, PATH_ACTIVATION_ADMINISTRATIVE_STATUS, task, result, ActivationStatusType.DISABLED); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_PIRATES_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); Entry entry = assertLdapAccount(USER_GUYBRUSH_USERNAME, USER_GUYBRUSH_FULL_NAME); @@ -957,22 +876,19 @@ public void test250AssignGuybrushPirates() throws Exception { @Test public void test255ModifyUserGuybrushPassword() throws Exception { - final String TEST_NAME = "test255ModifyUserGuybrushPassword"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ProtectedStringType userPasswordPs = new ProtectedStringType(); userPasswordPs.setClearValue("wanna.be.a.123"); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_GUYBRUSH_OID, PATH_CREDENTIALS_PASSWORD_VALUE, task, result, userPasswordPs); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -991,19 +907,16 @@ public void test255ModifyUserGuybrushPassword() throws Exception { @Test public void test260EnableGyubrush() throws Exception { - final String TEST_NAME = "test260EnableGyubrush"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_GUYBRUSH_OID, PATH_ACTIVATION_ADMINISTRATIVE_STATUS, task, result, ActivationStatusType.ENABLED); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1024,19 +937,16 @@ public void test260EnableGyubrush() throws Exception { @Test public void test300AssignBarbossaPirates() throws Exception { - final String TEST_NAME = "test300AssignBarbossaPirates"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_BARBOSSA_OID, ROLE_PIRATES_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1058,11 +968,8 @@ public void test300AssignBarbossaPirates() throws Exception { @Test public void test390ModifyUserBarbossaRename() throws Exception { - final String TEST_NAME = "test390ModifyUserBarbossaRename"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta objectDelta = createModifyUserReplaceDelta(USER_BARBOSSA_OID, UserType.F_NAME, @@ -1071,13 +978,12 @@ public void test390ModifyUserBarbossaRename() throws Exception { PrismTestUtil.createPolyString(USER_CPTBARBOSSA_FULL_NAME)); Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); - // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1100,24 +1006,20 @@ public void test390ModifyUserBarbossaRename() throws Exception { // TODO: create account with a group membership - @Test public void test395UnAssignBarbossaPirates() throws Exception { - final String TEST_NAME = "test395UnAssignBarbossaPirates"; - displayTestTitle(TEST_NAME); - // TODO: do this on another account. There is a bad interference with rename. // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_BARBOSSA_OID, ROLE_PIRATES_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1139,19 +1041,16 @@ public void test395UnAssignBarbossaPirates() throws Exception { @Test public void test399UnAssignAccountBarbossa() throws Exception { - final String TEST_NAME = "test399UnAssignAccountBarbossa"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_BARBOSSA_OID, getResourceOid(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1166,11 +1065,8 @@ public void test399UnAssignAccountBarbossa() throws Exception { @Test public void test500AddOrgMeleeIsland() throws Exception { - final String TEST_NAME = "test500AddOrgMeleeIsland"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject org = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(OrgType.class).instantiate(); @@ -1184,11 +1080,11 @@ public void test500AddOrgMeleeIsland() throws Exception { orgType.getAssignment().add(metaroleAssignment); // WHEN - displayWhen(TEST_NAME); + when(); addObject(org, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1205,19 +1101,16 @@ public void test500AddOrgMeleeIsland() throws Exception { @Test public void test510AssignGuybrushMeleeIsland() throws Exception { - final String TEST_NAME = "test510AssignGuybrushMeleeIsland"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignOrg(USER_GUYBRUSH_OID, orgMeleeIslandOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); Entry entry = assertLdapAccount(USER_GUYBRUSH_USERNAME, USER_GUYBRUSH_FULL_NAME); @@ -1239,8 +1132,8 @@ protected void doAdditionalRenameModifications(LdapNetworkConnection connection) Modification mod = new DefaultModification(ModificationOperation.REPLACE_ATTRIBUTE, ATTRIBUTE_SAM_ACCOUNT_NAME_NAME, ACCOUNT_HTM_UID); connection.modify(toAccountDn(ACCOUNT_HTM_UID, ACCOUNT_HTM_CN), mod); - display("Modified "+toAccountDn(ACCOUNT_HT_UID, ACCOUNT_HT_CN)+" " + ATTRIBUTE_SAM_ACCOUNT_NAME_NAME + - " -> "+ACCOUNT_HTM_UID+": "+mod); + display("Modified " + toAccountDn(ACCOUNT_HT_UID, ACCOUNT_HT_CN) + " " + ATTRIBUTE_SAM_ACCOUNT_NAME_NAME + + " -> " + ACCOUNT_HTM_UID + ": " + mod); } @Override @@ -1252,32 +1145,32 @@ protected String getAccountHtmCnAfterRename() { protected void assertAccountShadow(PrismObject shadow, String dn) throws SchemaException { super.assertAccountShadow(shadow, dn); ResourceAttribute primaryIdAttr = ShadowUtil.getAttribute(shadow, getPrimaryIdentifierAttributeQName()); - assertNotNull("No primary identifier ("+getPrimaryIdentifierAttributeQName()+" in "+shadow, primaryIdAttr); + assertNotNull("No primary identifier (" + getPrimaryIdentifierAttributeQName() + " in " + shadow, primaryIdAttr); String primaryId = primaryIdAttr.getRealValue(); - assertTrue("Unexpected chars in primary ID: '"+primaryId+"'", primaryId.matches("[a-z0-9\\-]+")); + assertTrue("Unexpected chars in primary ID: '" + primaryId + "'", primaryId.matches("[a-z0-9\\-]+")); } @Override protected Entry assertLdapAccount(String samAccountName, String cn) throws LdapException, IOException, CursorException { - Entry entry = searchLdapAccount("(cn="+cn+")"); + Entry entry = searchLdapAccount("(cn=" + cn + ")"); assertAttribute(entry, "cn", cn); assertAttribute(entry, ATTRIBUTE_SAM_ACCOUNT_NAME_NAME, samAccountName); return entry; } @Override - protected void assertNoLdapAccount(String uid) throws LdapException, IOException, CursorException { + protected void assertNoLdapAccount(String uid) { throw new UnsupportedOperationException("Boom! Cannot do this here. This is bloody AD! We need full name!"); } protected void assertNoLdapAccount(String uid, String cn) throws LdapException, IOException, CursorException { LdapNetworkConnection connection = ldapConnect(); - List entriesCn = ldapSearch(connection, "(cn="+cn+")"); - List entriesSamAccountName = ldapSearch(connection, "(sAMAccountName="+uid+")"); + List entriesCn = ldapSearch(connection, "(cn=" + cn + ")"); + List entriesSamAccountName = ldapSearch(connection, "(sAMAccountName=" + uid + ")"); ldapDisconnect(connection); - assertEquals("Unexpected number of entries for cn="+cn+": "+entriesCn, 0, entriesCn.size()); - assertEquals("Unexpected number of entries for sAMAccountName="+uid+": "+entriesSamAccountName, 0, entriesSamAccountName.size()); + assertEquals("Unexpected number of entries for cn=" + cn + ": " + entriesCn, 0, entriesCn.size()); + assertEquals("Unexpected number of entries for sAMAccountName=" + uid + ": " + entriesSamAccountName, 0, entriesSamAccountName.size()); } @Override @@ -1287,7 +1180,7 @@ protected String toAccountDn(String username) { @Override protected String toAccountDn(String username, String fullName) { - return "CN="+fullName+","+getPeopleLdapSuffix(); + return "CN=" + fullName + "," + getPeopleLdapSuffix(); } @Override @@ -1295,7 +1188,7 @@ protected Rdn toAccountRdn(String username, String fullName) { try { return new Rdn(new Ava("CN", fullName)); } catch (LdapInvalidDnException e) { - throw new IllegalStateException(e.getMessage(),e); + throw new IllegalStateException(e.getMessage(), e); } } @@ -1304,7 +1197,7 @@ protected void assertLdapPassword(String uid, String fullName, String password) assertLdapPassword(entry, password); } - protected void assertLdapPassword(String uid, String password) throws LdapException, IOException, CursorException { + protected void assertLdapPassword(String uid, String password) { throw new UnsupportedOperationException("Boom! Cannot do this here. This is bloody AD! We need full name!"); } @@ -1331,17 +1224,13 @@ protected Entry createAccountEntry(String uid, String cn, String givenName, Stri private byte[] encodePassword(String password) { String quotedPassword = "\"" + password + "\""; - try { - return quotedPassword.getBytes("UTF-16LE"); - } catch (UnsupportedEncodingException e) { - throw new SystemException(e.getMessage(), e); - } + return quotedPassword.getBytes(StandardCharsets.UTF_16LE); } @Override protected void assertStepSyncToken(String syncTaskOid, int step, long tsStart, long tsEnd) throws ObjectNotFoundException, SchemaException { - OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName()+".assertSyncToken"); + OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName() + ".assertSyncToken"); Task task = taskManager.getTask(syncTaskOid, result); PrismProperty syncTokenProperty = task.getExtensionPropertyOrClone(SchemaConstants.SYNC_TOKEN); assertNotNull("No sync token", syncTokenProperty); @@ -1357,7 +1246,7 @@ public void assertAttribute(PrismObject shadow, String attrName, public void assertAttribute(PrismObject shadow, QName attrQname, T... expectedValues) { List actualValues = ShadowUtil.getAttributeValues(shadow, attrQname); - PrismAsserts.assertSets("attribute "+attrQname+" in " + shadow, actualValues, expectedValues); + PrismAsserts.assertSets("attribute " + attrQname + " in " + shadow, actualValues, expectedValues); } protected abstract void assertAccountDisabled(PrismObject shadow); diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AdUtils.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AdUtils.java index 643bbbc1573..9f0251af1ac 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AdUtils.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AdUtils.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2016 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -6,11 +6,9 @@ */ package com.evolveum.midpoint.testing.conntest.ad; +import static org.testng.AssertJUnit.*; + import static com.evolveum.midpoint.test.IntegrationTestTools.display; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; import javax.xml.namespace.QName; @@ -25,14 +23,12 @@ import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition; import com.evolveum.midpoint.schema.processor.ResourceSchema; import com.evolveum.midpoint.schema.util.ResourceTypeUtil; -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; /** * @author semancik - * */ public class AdUtils { @@ -54,59 +50,53 @@ public class AdUtils { /** * Returns dashed GUID notation formatted from simple hex-encoded binary. - * + *

* E.g. "2f01c06bb1d0414e9a69dd3841a13506" -> "6bc0012f-d0b1-4e41-9a69-dd3841a13506" */ public static String formatGuidToDashedNotation(String hexValue) { if (hexValue == null) { return null; } - StringBuilder sb = new StringBuilder(); - sb.append(hexValue.substring(6, 8)); - sb.append(hexValue.substring(4, 6)); - sb.append(hexValue.substring(2, 4)); - sb.append(hexValue.substring(0, 2)); - sb.append('-'); - sb.append(hexValue.substring(10, 12)); - sb.append(hexValue.substring(8, 10)); - sb.append('-'); - sb.append(hexValue.substring(14, 16)); - sb.append(hexValue.substring(12, 14)); - sb.append('-'); - sb.append(hexValue.substring(16, 20)); - sb.append('-'); - sb.append(hexValue.substring(20, 32)); - return sb.toString(); + return hexValue.substring(6, 8) + + hexValue.substring(4, 6) + + hexValue.substring(2, 4) + + hexValue.substring(0, 2) + + '-' + + hexValue.substring(10, 12) + + hexValue.substring(8, 10) + + '-' + + hexValue.substring(14, 16) + + hexValue.substring(12, 14) + + '-' + + hexValue.substring(16, 20) + + '-' + + hexValue.substring(20, 32); } public static ObjectClassComplexTypeDefinition assertAdResourceSchema(PrismObject resource, QName accountObjectClass, PrismContext prismContext) throws SchemaException { - ResourceSchema resourceSchema = RefinedResourceSchema.getResourceSchema(resource, prismContext); - display("Resource schema", resourceSchema); - ResourceTypeUtil.validateSchema(resourceSchema, resource); - ObjectClassComplexTypeDefinition accountObjectClassDef = assertAdSchema(resourceSchema, resource, accountObjectClass, prismContext); - return accountObjectClassDef; + ResourceSchema resourceSchema = RefinedResourceSchema.getResourceSchema(resource, prismContext); + display("Resource schema", resourceSchema); + ResourceTypeUtil.validateSchema(resourceSchema, resource); + return assertAdSchema(resource, accountObjectClass); } public static ObjectClassComplexTypeDefinition assertAdResourceSchemaLongTimestamp(PrismObject resource, QName accountObjectClass, PrismContext prismContext) throws SchemaException { ResourceSchema resourceSchema = RefinedResourceSchema.getResourceSchema(resource, prismContext); display("Resource schema", resourceSchema); ResourceTypeUtil.validateSchema(resourceSchema, resource); - ObjectClassComplexTypeDefinition accountObjectClassDef = assertAdSchemaLongTimestamp(resourceSchema, resource, accountObjectClass, prismContext); - return accountObjectClassDef; -} + return assertAdSchemaLongTimestamp(resource, accountObjectClass); + } - public static ObjectClassComplexTypeDefinition assertAdRefinedSchema(PrismObject resource, QName accountObjectClass, PrismContext prismContext) throws SchemaException { + public static ObjectClassComplexTypeDefinition assertAdRefinedSchema(PrismObject resource, QName accountObjectClass) throws SchemaException { RefinedResourceSchema refinedSchema = RefinedResourceSchema.getRefinedSchema(resource); display("Refined schema", refinedSchema); RefinedResourceSchemaImpl.validateRefinedSchema(refinedSchema, resource); - ObjectClassComplexTypeDefinition accountObjectClassDef = assertAdSchema(refinedSchema, resource, accountObjectClass, prismContext); - return accountObjectClassDef; + return assertAdSchema(resource, accountObjectClass); } - // Assumes string timestamp - public static ObjectClassComplexTypeDefinition assertAdSchema(ResourceSchema resourceSchema, PrismObject resource, QName accountObjectClass, PrismContext prismContext) throws SchemaException { - ObjectClassComplexTypeDefinition accountObjectClassDefinition = assertAdSchemaBase(resourceSchema, resource, accountObjectClass, prismContext); + public static ObjectClassComplexTypeDefinition assertAdSchema(PrismObject resource, QName accountObjectClass) throws SchemaException { + ObjectClassComplexTypeDefinition accountObjectClassDefinition = assertAdSchemaBase(resource, accountObjectClass); ResourceAttributeDefinition createTimestampDef = accountObjectClassDefinition.findAttributeDefinition("createTimeStamp"); PrismAsserts.assertDefinition(createTimestampDef, new QName(MidPointConstants.NS_RI, "createTimeStamp"), @@ -126,8 +116,8 @@ public static ObjectClassComplexTypeDefinition assertAdSchema(ResourceSchema res } // Assumes string timestamp - public static ObjectClassComplexTypeDefinition assertAdSchemaLongTimestamp(ResourceSchema resourceSchema, PrismObject resource, QName accountObjectClass, PrismContext prismContext) throws SchemaException { - ObjectClassComplexTypeDefinition accountObjectClassDefinition = assertAdSchemaBase(resourceSchema, resource, accountObjectClass, prismContext); + public static ObjectClassComplexTypeDefinition assertAdSchemaLongTimestamp(PrismObject resource, QName accountObjectClass) throws SchemaException { + ObjectClassComplexTypeDefinition accountObjectClassDefinition = assertAdSchemaBase(resource, accountObjectClass); ResourceAttributeDefinition createTimestampDef = accountObjectClassDefinition.findAttributeDefinition("createTimeStamp"); PrismAsserts.assertDefinition(createTimestampDef, new QName(MidPointConstants.NS_RI, "createTimeStamp"), @@ -139,12 +129,12 @@ public static ObjectClassComplexTypeDefinition assertAdSchemaLongTimestamp(Resou return accountObjectClassDefinition; } - private static ObjectClassComplexTypeDefinition assertAdSchemaBase(ResourceSchema resourceSchema, PrismObject resource, QName accountObjectClass, PrismContext prismContext) throws SchemaException { + private static ObjectClassComplexTypeDefinition assertAdSchemaBase(PrismObject resource, QName accountObjectClass) throws SchemaException { RefinedResourceSchema refinedSchema = RefinedResourceSchema.getRefinedSchema(resource); display("Refined schema", refinedSchema); ObjectClassComplexTypeDefinition accountObjectClassDefinition = refinedSchema.findObjectClassDefinition(accountObjectClass); - assertNotNull("No definition for object class "+accountObjectClass, accountObjectClassDefinition); + assertNotNull("No definition for object class " + accountObjectClass, accountObjectClassDefinition); display("Account object class def", accountObjectClassDefinition); ResourceAttributeDefinition cnDef = accountObjectClassDefinition.findAttributeDefinition("cn"); @@ -208,16 +198,16 @@ private static ObjectClassComplexTypeDefinition assertAdSchemaBase(ResourceSchem public static void assertExchangeSchema(PrismObject resource, QName accountObjectClassQName, PrismContext prismContext) throws SchemaException { ResourceSchema resourceSchema = RefinedResourceSchema.getResourceSchema(resource, prismContext); - assertExchangeSchema(resourceSchema, resource, accountObjectClassQName, prismContext); + assertExchangeSchema(resourceSchema, accountObjectClassQName); RefinedResourceSchema refinedSchema = RefinedResourceSchema.getRefinedSchema(resource); - assertExchangeSchema(refinedSchema, resource, accountObjectClassQName, prismContext); + assertExchangeSchema(refinedSchema, accountObjectClassQName); } - public static void assertExchangeSchema(ResourceSchema resourceSchema, PrismObject resource, QName accountObjectClassQName, PrismContext prismContext) throws SchemaException { + public static void assertExchangeSchema(ResourceSchema resourceSchema, QName accountObjectClassQName) { 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); + 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); @@ -226,8 +216,8 @@ public static void assertExchangeSchema(ResourceSchema resourceSchema, PrismObje assertTrue("msExchHideFromAddressLists add", msExchHideFromAddressListsDef.canAdd()); ObjectClassComplexTypeDefinition accountObjectClassDef = resourceSchema.findObjectClassDefinition(accountObjectClassQName); - assertNotNull("No definition for object class "+accountObjectClassQName, accountObjectClassDef); - display("Object class "+accountObjectClassQName+" def", accountObjectClassDef); + assertNotNull("No definition for object class " + accountObjectClassQName, accountObjectClassDef); + display("Object class " + accountObjectClassQName + " def", accountObjectClassDef); ResourceAttributeDefinition accountMsExchHideFromAddressListsDef = accountObjectClassDef.findAttributeDefinition(ATTRIBUTE_MS_EXCH_HIDE_FROM_ADDRESS_LISTS_NAME); PrismAsserts.assertDefinition(accountMsExchHideFromAddressListsDef, new QName(MidPointConstants.NS_RI, ATTRIBUTE_MS_EXCH_HIDE_FROM_ADDRESS_LISTS_NAME), DOMUtil.XSD_BOOLEAN, 0, 1); diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapChimera.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapChimera.java index 44c13031044..037d2df093c 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapChimera.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapChimera.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapChimeraNativeSchema.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapChimeraNativeSchema.java index c2c481182ab..8a773c2d083 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapChimeraNativeSchema.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapChimeraNativeSchema.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -12,18 +12,13 @@ import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Listeners; -import org.testng.annotations.Test; - -import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; /** * Test for multi-domain AD (chimera-hydra) with native AD schema support and automatic objectCategory management. * * @author semancik */ -@ContextConfiguration(locations = {"classpath:ctx-conntest-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-conntest-test-main.xml" }) @Listeners({ com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public class TestAdLdapChimeraNativeSchema extends TestAdLdapChimera { diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapChimeraRunAs.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapChimeraRunAs.java index 7f606299409..a825ffd04b5 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapChimeraRunAs.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapChimeraRunAs.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -12,7 +12,6 @@ import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Listeners; -import org.testng.annotations.Test; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; @@ -20,9 +19,8 @@ /** * @author semancik - * */ -@ContextConfiguration(locations = {"classpath:ctx-conntest-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-conntest-test-main.xml" }) @Listeners({ com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public class TestAdLdapChimeraRunAs extends AbstractAdLdapMultidomainRunAsTest { diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapChimeraStrange.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapChimeraStrange.java index 11cb55ff27d..b61095d2354 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapChimeraStrange.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapChimeraStrange.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -6,24 +6,24 @@ */ package com.evolveum.midpoint.testing.conntest.ad; -import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; +import java.io.File; + 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 org.testng.annotations.Test; -import java.io.File; +import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; /** * Test for multi-domain AD (chimera-hydra) with some strange configuration. * * @author semancik */ -@ContextConfiguration(locations = {"classpath:ctx-conntest-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-conntest-test-main.xml" }) @Listeners({ com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public class TestAdLdapChimeraStrange extends TestAdLdapChimera { @@ -39,18 +39,15 @@ protected File getResourceFile() { */ @Test public void test599DeleteOrgMeleeIsland() throws Exception { - final String TEST_NAME = "test599DeleteOrgMeleeIsland"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); createUnderMeleeEntry(); try { // WHEN - displayWhen(TEST_NAME); + when(); deleteObject(OrgType.class, orgMeleeIslandOid, task, result); assertNotReached(); @@ -59,7 +56,7 @@ public void test599DeleteOrgMeleeIsland() throws Exception { } // THEN - displayThen(TEST_NAME); + then(); assertFailure(result); // assertLdapConnectorInstances(2); diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapLocalhost.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapLocalhost.java index b86e58f1e3d..a815eab005a 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapLocalhost.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapLocalhost.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015-2016 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -8,16 +8,8 @@ import java.io.File; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Listeners; - -import com.evolveum.midpoint.test.util.MidPointTestConstants; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; - /** * @author semancik - * */ public class TestAdLdapLocalhost extends AbstractAdLdapCookedTest { diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapMedusa.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapMedusa.java index 0ad0c35fd26..473bcc9eb49 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapMedusa.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapMedusa.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015-2016 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -8,16 +8,8 @@ import java.io.File; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Listeners; - -import com.evolveum.midpoint.test.util.MidPointTestConstants; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; - /** * @author semancik - * */ public class TestAdLdapMedusa extends AbstractAdLdapCookedTest { diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapRawLocalhost.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapRawLocalhost.java index a6dcf6d36cf..bdc5b139b5d 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapRawLocalhost.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapRawLocalhost.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2016 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -8,16 +8,8 @@ import java.io.File; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Listeners; - -import com.evolveum.midpoint.test.util.MidPointTestConstants; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; - /** * @author semancik - * */ public class TestAdLdapRawLocalhost extends AbstractAdLdapRawTest { diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapRawMedusa.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapRawMedusa.java index 02640240f47..4b5c5b7e0f7 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapRawMedusa.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapRawMedusa.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015-2016 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -8,16 +8,8 @@ import java.io.File; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Listeners; - -import com.evolveum.midpoint.test.util.MidPointTestConstants; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; - /** * @author semancik - * */ public class TestAdLdapRawMedusa extends AbstractAdLdapRawTest { diff --git a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestGenericSynchronization.java b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestGenericSynchronization.java index 05c076b59ae..b00c661b64e 100644 --- a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestGenericSynchronization.java +++ b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestGenericSynchronization.java @@ -203,10 +203,7 @@ private Entry createOrgEntry(String ou, String suffix) throws IOException, LDIFE @Test public void test100TreeImport() throws Exception { - final String TEST_NAME = "test100TreeImport"; - TestUtil.displayTestTitle(this, TEST_NAME); - - Task task = taskManager.createTaskInstance(TestLdap.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -215,14 +212,14 @@ public void test100TreeImport() throws Exception { new QName(RESOURCE_OPENDJ_NAMESPACE, "inetOrgPerson"), task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); waitForTaskFinish(task, true, 20000 + (ldapdUserCount + ldapOrgCount) * 2000); // THEN - TestUtil.displayThen(TEST_NAME); + then(); int userCount = modelService.countObjects(UserType.class, null, null, task, result); display("Users", userCount); @@ -230,10 +227,7 @@ public void test100TreeImport() throws Exception { } @Test - public void test200MoveRootChild() throws Exception { - final String TEST_NAME = "test200MoveRootChild"; - TestUtil.displayTestTitle(this, TEST_NAME); - + public void test200MoveRootChild() { //todo move one child of one root to root position } } diff --git a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdapUniversity.java b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdapUniversity.java index f6b97c688a6..50c21688018 100644 --- a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdapUniversity.java +++ b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdapUniversity.java @@ -128,14 +128,11 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100BigImportWithLinking() throws Exception { - final String TEST_NAME = "test100BigImportWithLinking"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN InternalsConfig.turnOffAllChecks(); - Task task = taskManager.createTaskInstance(TestLdapUniversity.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -151,14 +148,14 @@ public void test100BigImportWithLinking() throws Exception { new QName(RESOURCE_OPENDJ_NAMESPACE, "inetOrgPerson"), task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); waitForTaskFinish(task, true, 20000 + NUM_LDAP_ENTRIES*2000, 10000L); // THEN - TestUtil.displayThen(TEST_NAME); + then(); int userCount = modelService.countObjects(UserType.class, null, null, task, result); display("Users", userCount); @@ -201,12 +198,9 @@ private void assertUser(String name, Task task, OperationResult result) throws c @Test public void test120BigReconciliation() throws Exception { - final String TEST_NAME = "test120BigReconciliation"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestLdapUniversity.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -219,7 +213,7 @@ public void test120BigReconciliation() throws Exception { new QName(RESOURCE_OPENDJ_NAMESPACE, "inetOrgPerson"), task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); // TODO // OperationResult subresult = result.getLastSubresult(); // TestUtil.assertInProgress("reconciliation launch result", subresult); @@ -227,7 +221,7 @@ public void test120BigReconciliation() throws Exception { waitForTaskFinish(task, true, 20000 + NUM_LDAP_ENTRIES*2000, 10000L); // THEN - TestUtil.displayThen(TEST_NAME); + then(); int userCount = modelService.countObjects(UserType.class, null, null, task, result); display("Users", userCount); diff --git a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestRunAs.java b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestRunAs.java index 1dd54f64dda..15f0bbb61d5 100644 --- a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestRunAs.java +++ b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestRunAs.java @@ -103,9 +103,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; - TestUtil.displayTestTitle(this, TEST_NAME); - assertUsers(NUM_INITIAL_USERS); } diff --git a/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestRestServiceProxyAuthentication.java b/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestRestServiceProxyAuthentication.java index 2374012658f..7090cbecf66 100644 --- a/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestRestServiceProxyAuthentication.java +++ b/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestRestServiceProxyAuthentication.java @@ -12,7 +12,6 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.IntegrationTestTools; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemObjectsType; @@ -26,8 +25,6 @@ import javax.ws.rs.core.Response; import java.io.File; -import static com.evolveum.midpoint.test.util.TestUtil.displayTestTitle; - import static org.testng.AssertJUnit.assertNotNull; /** @@ -81,7 +78,7 @@ public void test001getUserSelfBySomebody() { when(); Response response = client.get(); - TestUtil.displayThen(TEST_NAME); + then(); assertStatus(response, 200); UserType userType = response.readEntity(UserType.class); AssertJUnit.assertNotNull("Returned entity in body must not be null.", userType); @@ -104,7 +101,7 @@ public void test002getUserSelfByEgoist() { when(); Response response = client.get(); - TestUtil.displayThen(TEST_NAME); + then(); assertStatus(response, 200); UserType userType = response.readEntity(UserType.class); assertNotNull("Returned entity in body must not be null.", userType); @@ -131,7 +128,7 @@ public void test003getUserAdministratorByEgoist() { when(); Response response = client.get(); - TestUtil.displayThen(TEST_NAME); + then(); assertStatus(response, 403); IntegrationTestTools.display("Audit", getDummyAuditService()); @@ -154,7 +151,7 @@ public void test004getUserSelfByHead() { when(); Response response = client.get(); - TestUtil.displayThen(TEST_NAME); + then(); assertStatus(response, 200); UserType userType = response.readEntity(UserType.class); assertNotNull("Returned entity in body must not be null.", userType); @@ -181,7 +178,7 @@ public void test005getUserSelfByProxyHead() { when(); Response response = client.get(); - TestUtil.displayThen(TEST_NAME); + then(); assertStatus(response, 403); IntegrationTestTools.display("Audit", getDummyAuditService()); diff --git a/testing/samples-test/src/test/java/com/evolveum/midpoint/samples/test/TestSampleImport.java b/testing/samples-test/src/test/java/com/evolveum/midpoint/samples/test/TestSampleImport.java index b5a7d7127e9..4ccb250a4d9 100644 --- a/testing/samples-test/src/test/java/com/evolveum/midpoint/samples/test/TestSampleImport.java +++ b/testing/samples-test/src/test/java/com/evolveum/midpoint/samples/test/TestSampleImport.java @@ -64,7 +64,7 @@ public void importOpenDJAdvanced() throws FileNotFoundException, SchemaException // } public void importSample(File sampleFile, Class type, String objectName) throws FileNotFoundException, SchemaException { - TestUtil.displayTestTitle(this, "Import sample "+sampleFile.getPath()); + sampleFile.getPath(); // GIVEN sampleFile.getName(); Task task = getTestTask(); diff --git a/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java b/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java index bb00c1d5fd1..3fc3469e137 100644 --- a/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java +++ b/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java @@ -390,7 +390,6 @@ public static void stopResources() throws Exception { @Test public void test000Integrity() throws Exception { final String TEST_NAME = "test000Integrity"; - TestUtil.displayTestTitle(this, TEST_NAME); assertNotNull(modelWeb); assertNotNull(modelService); assertNotNull(repositoryService); @@ -743,8 +742,6 @@ private void checkDerbyConfiguration(PrismObject resource, String */ @Test public void test003TestConnectionDerby() throws Exception { - TestUtil.displayTestTitle("test003TestConnectionDerby"); - // GIVEN checkRepoDerbyResource(); @@ -790,10 +787,8 @@ public void test003TestConnectionDerby() throws Exception { } @Test - public void test004Capabilities() throws ObjectNotFoundException, CommunicationException, SchemaException, - FaultMessage { - TestUtil.displayTestTitle("test004Capabilities"); - + public void test004Capabilities() + throws ObjectNotFoundException, CommunicationException, SchemaException, FaultMessage { // GIVEN checkRepoOpenDjResource(); @@ -851,9 +846,6 @@ public void test004Capabilities() throws ObjectNotFoundException, CommunicationE @Test public void test005resolveConnectorRef() throws Exception{ - - TestUtil.displayTestTitle("test005resolveConnectorRef"); - PrismObject resource = PrismTestUtil.parseObject(new File(RESOURCE_DUMMY_FILENAME)); ModelExecuteOptionsType options = new ModelExecuteOptionsType(); @@ -873,9 +865,6 @@ public void test005resolveConnectorRef() throws Exception{ @Test public void test006reimportResourceDummy() throws Exception{ - - TestUtil.displayTestTitle("test006reimportResourceDummy"); - //get object from repo (with version set and try to add it - it should be re-added, without error) OperationResult repoResult = new OperationResult("getObject"); @@ -1117,9 +1106,7 @@ private OperationResultType modifyObjectViaModelWS(ObjectDeltaType objectChange) */ @Test public void test014AddDerbyAccountToUser() throws IOException, JAXBException, FaultMessage, - ObjectNotFoundException, SchemaException, DirectoryException, SQLException { - TestUtil.displayTestTitle("test014AddDerbyAccountToUser"); - + ObjectNotFoundException, SchemaException, SQLException { // GIVEN checkRepoDerbyResource(); @@ -1228,8 +1215,6 @@ public void test014AddDerbyAccountToUser() throws IOException, JAXBException, Fa @Test public void test015AccountOwner() throws FaultMessage, ObjectNotFoundException, SchemaException, JAXBException { - TestUtil.displayTestTitle("test015AccountOwner"); - // GIVEN checkRepoOpenDjResource(); assertNoRepoCache(); @@ -1254,8 +1239,6 @@ public void test015AccountOwner() throws FaultMessage, ObjectNotFoundException, @Test public void test016ProvisioningSearchAccountsIterative() throws Exception { - TestUtil.displayTestTitle("test016ProvisioningSearchAccountsIterative"); - // GIVEN OperationResult result = new OperationResult(TestSanity.class.getName() + ".test016ProvisioningSearchAccountsIterative"); @@ -1822,10 +1805,8 @@ public void test031EnableUser() throws Exception { * The account will not be deleted, just the association to user will be broken. */ @Test - public void test040UnlinkDerbyAccountFromUser() throws FileNotFoundException, JAXBException, FaultMessage, - ObjectNotFoundException, SchemaException, DirectoryException, SQLException { - TestUtil.displayTestTitle("test040UnlinkDerbyAccountFromUser"); - + public void test040UnlinkDerbyAccountFromUser() + throws FaultMessage, ObjectNotFoundException, SchemaException { // GIVEN ObjectDeltaType objectChange = new ObjectDeltaType(); @@ -1873,10 +1854,8 @@ public void test040UnlinkDerbyAccountFromUser() throws FileNotFoundException, JA * The account was unlinked in the previous test, therefore no operation with user is needed. */ @Test - public void test041DeleteDerbyAccount() throws FileNotFoundException, JAXBException, FaultMessage, - ObjectNotFoundException, SchemaException, DirectoryException, SQLException { - TestUtil.displayTestTitle("test041DeleteDerbyAccount"); - + public void test041DeleteDerbyAccount() + throws FaultMessage, SchemaException, SQLException { // GIVEN assertNoRepoCache(); @@ -2048,8 +2027,7 @@ public void test048ModifyUserRemoveGivenName() throws Exception { * @throws JAXBException */ @Test - public void test049DeleteUser() throws SchemaException, FaultMessage, DirectoryException, JAXBException { - TestUtil.displayTestTitle("test049DeleteUser"); + public void test049DeleteUser() throws SchemaException, FaultMessage, DirectoryException { // GIVEN assertNoRepoCache(); @@ -3669,11 +3647,9 @@ public void test480ListResources() throws Exception { @Test public void test485ListResourcesWithBrokenResource() throws Exception { - TestUtil.displayTestTitle("test485ListResourcesWithBrokenResource"); - // GIVEN - Task task = taskManager.createTaskInstance(TestSanity.class.getName() + ".test410ListResourcesWithBrokenResource"); - final OperationResult result = task.getResult(); + Task task = getTestTask(); + final OperationResult result = getTestResult(); // WHEN List> resources = modelService.searchObjects(ResourceType.class, null, null, task, result); @@ -3703,8 +3679,6 @@ public void test485ListResourcesWithBrokenResource() throws Exception { @Test public void test500NotifyChangeCreateAccount() throws Exception{ - final String TEST_NAME = "test500NotifyChangeCreateAccount"; - Entry ldifEntry = openDJController.addEntryFromLdifFile(LDIF_ANGELIKA_FILENAME); display("Entry from LDIF", ldifEntry); @@ -3771,7 +3745,7 @@ public void test500NotifyChangeCreateAccount() throws Exception{ public void test501NotifyChangeModifyAccount() throws Exception{ final String TEST_NAME = "test501NotifyChangeModifyAccount"; - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createResult(); PrismObject userAngelika = findUserByUsername(ANGELIKA_NAME); assertNotNull("User with the name angelika must exist.", userAngelika); diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/TestBase.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/TestBase.java index b38963315e7..8a81e129941 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/TestBase.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/TestBase.java @@ -13,7 +13,6 @@ import java.io.InputStream; import java.lang.reflect.Method; import java.util.Properties; -import javax.naming.ConfigurationException; import com.codeborne.selenide.Selenide; import com.codeborne.selenide.testng.BrowserPerClass; @@ -96,7 +95,7 @@ public void beforeClass() throws IOException { basicPage = login.loginWithReloadLoginPage(username, password); } - private EnvironmentConfiguration buildEnvironmentConfiguration(Properties props) throws IOException { + private EnvironmentConfiguration buildEnvironmentConfiguration(Properties props) { EnvironmentConfiguration config = new EnvironmentConfiguration(); config.driver(WebDriver.valueOf(props.getProperty("webdriver"))); config.driverLocation(props.getProperty("webdriverLocation")); @@ -157,7 +156,7 @@ protected void importObject(File source) { importObject(source, false); } - protected String fetchMidpointHome() throws ConfigurationException { + protected String fetchMidpointHome() { AboutPage aboutPage = basicPage.aboutPage(); String mpHomeDir = aboutPage.getJVMproperty(PROPERTY_NAME_MIDPOINT_HOME); @@ -166,8 +165,9 @@ protected String fetchMidpointHome() throws ConfigurationException { return mpHomeDir; } else { - mpHomeDir = new StringBuilder(aboutPage.getSystemProperty(PROPERTY_NAME_USER_HOME)) - .append(aboutPage.getSystemProperty(PROPERTY_NAME_FILE_SEPARATOR)).append("midpoint").toString(); + mpHomeDir = aboutPage.getSystemProperty(PROPERTY_NAME_USER_HOME) + + aboutPage.getSystemProperty(PROPERTY_NAME_FILE_SEPARATOR) + + "midpoint"; LOG.info("Midpoint home parameter is empty! Using defaults: " + mpHomeDir); @@ -175,7 +175,7 @@ protected String fetchMidpointHome() throws ConfigurationException { return mpHomeDir; } - protected File initTestDirectory(String dir) throws ConfigurationException, IOException { + protected File initTestDirectory(String dir) throws IOException { String home = fetchMidpointHome(); File parentDir = new File(home, "schrodinger"); diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/TestSuiteConfig.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/TestSuiteConfig.java deleted file mode 100644 index 310b851b07c..00000000000 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/TestSuiteConfig.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright (c) 2010-2019 Evolveum and contributors - * - * This work is dual-licensed under the Apache License 2.0 - * and European Union Public License. See LICENSE file for details. - */ -package com.evolveum.midpoint.testing.schrodinger; - -import com.evolveum.midpoint.schrodinger.EnvironmentConfiguration; -import com.evolveum.midpoint.schrodinger.MidPoint; - -import com.evolveum.midpoint.schrodinger.page.BasicPage; -import com.evolveum.midpoint.schrodinger.page.configuration.AboutPage; -import org.apache.commons.lang3.ArrayUtils; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.testng.annotations.AfterSuite; -import org.testng.annotations.BeforeSuite; - -import java.io.IOException; - - -/** - * Created by matus on 7/10/2018. - */ -public class TestSuiteConfig extends TestBase { - - private static final Logger LOG = LoggerFactory.getLogger(TestSuiteConfig.class); - - @BeforeSuite - public void init() throws IOException { - - EnvironmentConfiguration config = new EnvironmentConfiguration(); - midPoint = new MidPoint(config); - } - - @AfterSuite - public void cleanUp() { - - } -} diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/labs/BasicProvisioningTest.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/labs/BasicProvisioningTest.java index 1c699c69d54..b28d9788e8b 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/labs/BasicProvisioningTest.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/labs/BasicProvisioningTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -6,7 +6,14 @@ */ package com.evolveum.midpoint.testing.schrodinger.labs; +import static com.codeborne.selenide.Selenide.$; + +import javax.xml.namespace.QName; + import com.codeborne.selenide.Condition; +import org.testng.Assert; +import org.testng.annotations.Test; + import com.evolveum.midpoint.schema.SchemaConstantsGenerated; import com.evolveum.midpoint.schrodinger.page.user.ListUsersPage; import com.evolveum.midpoint.schrodinger.page.user.UserPage; @@ -14,18 +21,12 @@ import com.evolveum.midpoint.testing.schrodinger.TestBase; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -import org.testng.Assert; -import org.testng.annotations.Test; - -import javax.xml.namespace.QName; - -import static com.codeborne.selenide.Selenide.$; /** * Created by honchar * covers LAB 4-1 */ -public class BasicProvisioningTest extends TestBase { +public class BasicProvisioningTest extends TestBase { private static final String USER_NAME_ATTRIBUTE = "Name"; private static final String USER_GIVEN_NAME_ATTRIBUTE = "Given name"; @@ -42,31 +43,31 @@ public class BasicProvisioningTest extends TestBase { private static final String USER_ADMINISTRATIVE_STATUS = "Enabled"; //todo dependsOnGroup - @Test(groups={"lab_4_1"}) - public void test001createUserKirk(){ + @Test(groups = { "lab_4_1" }) + public void test001createUserKirk() { //we use New user link in this test UserPage userPage = basicPage.newUser(); userPage .selectTabBasic() - .form() - .addAttributeValue(UserType.F_NAME, USER_NAME) - .addAttributeValue(UserType.F_FAMILY_NAME, USER_FAMILY_NAME) - .addAttributeValue(UserType.F_GIVEN_NAME, USER_GIVEN_NAME) - .setDropDownAttributeValue(ActivationType.F_ADMINISTRATIVE_STATUS, USER_ADMINISTRATIVE_STATUS) - .setPasswordFieldsValues(PASSWORD_FIELD_LABEL, USER_PASSWORD) - .and() - .and() + .form() + .addAttributeValue(UserType.F_NAME, USER_NAME) + .addAttributeValue(UserType.F_FAMILY_NAME, USER_FAMILY_NAME) + .addAttributeValue(UserType.F_GIVEN_NAME, USER_GIVEN_NAME) + .setDropDownAttributeValue(ActivationType.F_ADMINISTRATIVE_STATUS, USER_ADMINISTRATIVE_STATUS) + .setPasswordFieldsValues(PASSWORD_FIELD_LABEL, USER_PASSWORD) + .and() + .and() .clickSave(); ListUsersPage usersList = new ListUsersPage(); usersList .table() - .search() - .byName() - .inputValue(USER_NAME) - .updateSearch() - .and() + .search() + .byName() + .inputValue(USER_NAME) + .updateSearch() + .and() .clickByName(USER_NAME); //check name attribute value @@ -100,26 +101,26 @@ public void test001createUserKirk(){ } - @Test(groups={"lab_4_1"}) + @Test(groups = { "lab_4_1" }) public void test002addProjectionToUserKirk() { ListUsersPage users = basicPage.listUsers(); users .table() - .search() - .byName() - .inputValue(USER_NAME) - .updateSearch() + .search() + .byName() + .inputValue(USER_NAME) + .updateSearch() + .and() + .clickByName(USER_NAME) + .selectTabProjections() + .clickHeaderActionDropDown() + .addProjection() + .table() + .selectCheckboxByName(ImportResourceTest.RESOURCE_NAME) + .and() + .clickAdd() .and() - .clickByName(USER_NAME) - .selectTabProjections() - .clickHeaderActionDropDown() - .addProjection() - .table() - .selectCheckboxByName(ImportResourceTest.RESOURCE_NAME) - .and() - .clickAdd() - .and() - .clickSave() + .clickSave() .feedback() .isSuccess(); diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/AboutPageTest.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/AboutPageTest.java index fc33b506b4b..5a5797ba233 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/AboutPageTest.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/AboutPageTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -39,18 +39,14 @@ public void checkMidpointVersion() { @Test public void checkGitDescribeValue() { - Assert.assertTrue(!aboutPage - .gitDescribe() - .isEmpty() - ); + Assert.assertFalse( + aboutPage.gitDescribe().isEmpty()); } @Test public void checkBuildAt() { - Assert.assertTrue(!aboutPage - .buildAt() - .isEmpty() - ); + Assert.assertFalse( + aboutPage.buildAt().isEmpty()); } @Test // TODO fix select the right element @@ -96,6 +92,7 @@ public void checkReindexRepositoryObjectsCategory() { @Test public void checkReindexRepositoryObjectsDisplayName() { + // @formatter:off Assert.assertEquals(aboutPage .reindexRepositoryObjects() .feedback() @@ -104,29 +101,23 @@ public void checkReindexRepositoryObjectsDisplayName() { .summary() .fetchDisplayName() , REINDEX_REPO_TASK_DISPLAY_NAME_EXPECTED); + // @formatter:on } @Test public void checkJVMPropertiesMidpointHome(){ - - Assert.assertTrue( - !aboutPage.getJVMproperty(TestBase.PROPERTY_NAME_MIDPOINT_HOME).isEmpty() - ); - + Assert.assertFalse( + aboutPage.getJVMproperty(TestBase.PROPERTY_NAME_MIDPOINT_HOME).isEmpty()); } @Test public void checkJVMPropertiesXmx(){ - - Assert.assertTrue( - !aboutPage.getJVMproperty(PROPERTY_JVM_NAME_XMX).isEmpty() - ); - + Assert.assertFalse( + aboutPage.getJVMproperty(PROPERTY_JVM_NAME_XMX).isEmpty()); } @Test public void checkSystemProperty(){ - Assert.assertTrue( - !aboutPage.getSystemProperty(TestBase.PROPERTY_NAME_USER_HOME).isEmpty() - ); + Assert.assertFalse( + aboutPage.getSystemProperty(TestBase.PROPERTY_NAME_USER_HOME).isEmpty()); } } diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/BulkActionsTest.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/BulkActionsTest.java index 3faf0fd767a..bd427f04a86 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/BulkActionsTest.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/BulkActionsTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/AccountTests.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/AccountTests.java index f2fc4b012ac..155683cee9a 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/AccountTests.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/AccountTests.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -16,7 +16,6 @@ import org.testng.annotations.Test; import com.evolveum.midpoint.testing.schrodinger.TestBase; -import javax.naming.ConfigurationException; import java.io.File; import java.io.IOException; @@ -53,7 +52,7 @@ public class AccountTests extends TestBase { @Test(priority = 1, groups = TEST_GROUP_BEFORE_USER_DELETION) - public void createMidpointUser() throws IOException, ConfigurationException { + public void createMidpointUser() throws IOException { initTestDirectory(DIRECTORY_CURRENT_TEST); diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/AdvancedAccountTests.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/AdvancedAccountTests.java index 42d1878e767..625608686e5 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/AdvancedAccountTests.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/AdvancedAccountTests.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -11,7 +11,6 @@ import org.apache.commons.io.FileUtils; import org.testng.annotations.Test; -import javax.naming.ConfigurationException; import java.io.File; import java.io.IOException; @@ -25,7 +24,7 @@ public class AdvancedAccountTests extends TestBase { private static final String DIRECTORY_CURRENT_TEST = "advancedAccountTests"; @Test - public void initializeTestConfiguration() throws IOException, ConfigurationException { + public void initializeTestConfiguration() throws IOException { initTestDirectory(DIRECTORY_CURRENT_TEST); diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/AssignmentArchetypeTest.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/AssignmentArchetypeTest.java index 312fc24ca67..e2a8d08533a 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/AssignmentArchetypeTest.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/AssignmentArchetypeTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/CaseTests.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/CaseTests.java index 46b5c5a7138..90d0f0cb6eb 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/CaseTests.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/CaseTests.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -6,26 +6,22 @@ */ package com.evolveum.midpoint.testing.schrodinger.scenarios; +import java.io.File; + import com.codeborne.selenide.Condition; import com.codeborne.selenide.Selenide; import com.codeborne.selenide.SelenideElement; +import org.testng.Assert; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + import com.evolveum.midpoint.schrodinger.MidPoint; -import com.evolveum.midpoint.schrodinger.component.modal.ConfirmationModal; import com.evolveum.midpoint.schrodinger.component.modal.ForwardWorkitemModal; -import com.evolveum.midpoint.schrodinger.component.modal.ObjectBrowserModal; import com.evolveum.midpoint.schrodinger.page.cases.*; import com.evolveum.midpoint.schrodinger.page.user.ListUsersPage; import com.evolveum.midpoint.schrodinger.page.user.UserPage; import com.evolveum.midpoint.schrodinger.util.ConstantsUtil; import com.evolveum.midpoint.testing.schrodinger.TestBase; -import org.openqa.selenium.By; -import org.testng.Assert; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import java.io.File; - -import static com.codeborne.selenide.Selenide.$; /** * Created by honchar. diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/ObjectListArchetypeTests.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/ObjectListArchetypeTests.java index c40b325edc7..b382b71bf16 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/ObjectListArchetypeTests.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/ObjectListArchetypeTests.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -19,9 +19,7 @@ import org.testng.Assert; import org.testng.annotations.Test; -import javax.naming.ConfigurationException; import java.io.File; -import java.io.IOException; import static com.codeborne.selenide.Selenide.$; @@ -46,7 +44,7 @@ public class ObjectListArchetypeTests extends TestBase { public static final String OBJECT_LIST_ARCHETYPE_TESTS_GROUP = "bjectListArchetypeTests"; @Test(priority = 0, groups = OBJECT_LIST_ARCHETYPE_TESTS_GROUP) - public void importEmployeeArchetype() throws IOException, ConfigurationException { + public void importEmployeeArchetype() { importObject(EMPLOYEE_ARCHETYPE_FILE, true); } diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/OrgMembersTests.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/OrgMembersTests.java index f2d1e32ddcd..9a5ceda73c0 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/OrgMembersTests.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/OrgMembersTests.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -13,7 +13,6 @@ import com.evolveum.midpoint.schrodinger.page.user.UserPage; import com.evolveum.midpoint.schrodinger.util.Schrodinger; import com.evolveum.midpoint.testing.schrodinger.TestBase; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; import org.openqa.selenium.By; import org.testng.Assert; import org.testng.annotations.Test; diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/OrganizationStructureTests.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/OrganizationStructureTests.java index f027237e7be..572dd8c0dd5 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/OrganizationStructureTests.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/OrganizationStructureTests.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -6,7 +6,6 @@ */ package com.evolveum.midpoint.testing.schrodinger.scenarios; -import com.codeborne.selenide.Selenide; import com.evolveum.midpoint.schrodinger.page.configuration.ImportObjectPage; import com.evolveum.midpoint.schrodinger.page.resource.ListResourcesPage; import com.evolveum.midpoint.schrodinger.page.user.ListUsersPage; @@ -17,7 +16,6 @@ import org.testng.Assert; import org.testng.annotations.Test; -import javax.naming.ConfigurationException; import java.io.File; import java.io.IOException; @@ -50,7 +48,7 @@ public class OrganizationStructureTests extends TestBase { private static final String FILE_RESOUCE_NAME = "midpoint-advanced-sync.csv"; @Test - public void importOrgStructure() throws IOException, ConfigurationException { + public void importOrgStructure() throws IOException { initTestDirectory(DIRECTORY_CURRENT_TEST); @@ -72,7 +70,7 @@ public void importOrgStructure() throws IOException, ConfigurationException { @Test (dependsOnMethods ={IMPORT_ORG_STRUCT_DEPENDENCY}) public void assignOrgUnit(){ ListUsersPage users = basicPage.listUsers(); - UserPage userPage = (UserPage) users + UserPage userPage = users .table() .search() .byName() @@ -103,7 +101,7 @@ public void assignOrgUnit(){ @Test (dependsOnMethods ={ORG_UNIT_ACCOUNT_INDUCEMENT_DEPENDENCY}) public void unassignOrgUnit(){ ListUsersPage users = basicPage.listUsers(); - UserPage userPage = (UserPage) users + UserPage userPage = users .table() .search() .byName() @@ -133,7 +131,7 @@ public void orgUnitAccountInducement(){ refreshResourceSchema(NAME_CSV_RESOURCE_ADVANCED_SYNC); ListUsersPage users = basicPage.listUsers(); - UserPage userPage = (UserPage) users + UserPage userPage = users .table() .search() .byName() diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/PolyStringTests.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/PolyStringTests.java index 69230455451..9c54b39cd9c 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/PolyStringTests.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/PolyStringTests.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/PostAuthenticationTests.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/PostAuthenticationTests.java index 9b6358d9868..28197674c31 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/PostAuthenticationTests.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/PostAuthenticationTests.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/ScenariosCommons.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/ScenariosCommons.java index 74b57bb3e86..dcd241dbff9 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/ScenariosCommons.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/ScenariosCommons.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/SynchronizationTests.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/SynchronizationTests.java index b0fbaf1a184..f26d54d1bd3 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/SynchronizationTests.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/SynchronizationTests.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -10,7 +10,6 @@ import com.evolveum.midpoint.schrodinger.MidPoint; import com.evolveum.midpoint.schrodinger.component.user.UserProjectionsTab; import com.evolveum.midpoint.schrodinger.page.resource.ListResourcesPage; -import com.evolveum.midpoint.schrodinger.page.task.EditTaskPage; import com.evolveum.midpoint.schrodinger.page.task.ListTasksPage; import com.evolveum.midpoint.schrodinger.page.user.ListUsersPage; import org.apache.commons.io.FileUtils; @@ -20,11 +19,9 @@ import org.testng.annotations.Test; import com.evolveum.midpoint.testing.schrodinger.TestBase; -import javax.naming.ConfigurationException; import java.io.File; import java.io.IOException; - /** * Created by matus on 5/21/2018. */ @@ -48,7 +45,7 @@ public class SynchronizationTests extends TestBase { private static final String DIRECTORY_CURRENT_TEST = "synchronizationTests"; @Test(priority = 0) - public void setUpResourceAndSynchronizationTask() throws ConfigurationException, IOException { + public void setUpResourceAndSynchronizationTask() throws IOException { initTestDirectory(DIRECTORY_CURRENT_TEST); diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/UserAccountTests.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/UserAccountTests.java index 7c174553719..461f95553c0 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/UserAccountTests.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/UserAccountTests.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -20,8 +20,6 @@ public class UserAccountTests extends AccountTests { private static final String ENABLE_MP_USER_DEPENDENCY = "enableUser"; private static final String BULK_DISABLE_MP_USER_DEPENDENCY = "bulkDisableUsers"; - - @Test (dependsOnMethods = {CREATE_MP_USER_DEPENDENCY}, groups = TEST_GROUP_BEFORE_USER_DELETION) public void modifyUserAttribute(){ ListUsersPage usersPage = basicPage.listUsers(); diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/UserPhotoTests.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/UserPhotoTests.java index f48f37e0cb3..3a210a5ee98 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/UserPhotoTests.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/UserPhotoTests.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/CountingInspector.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/CountingInspector.java index 490d4910c7e..f089512377a 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/CountingInspector.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/CountingInspector.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2017 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -14,25 +14,21 @@ import org.testng.AssertJUnit; -import java.util.Set; - import com.evolveum.midpoint.schema.internals.InternalInspector; import com.evolveum.midpoint.util.DebugDumpable; import com.evolveum.midpoint.util.DebugUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentHolderType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; /** * @author semancik - * */ public class CountingInspector implements InternalInspector, DebugDumpable { @SuppressWarnings("rawtypes") - private Map readMap = new HashMap<>(); + private Map readMap = new HashMap<>(); - private Map roleEvaluationMap = new HashMap<>(); + private Map roleEvaluationMap = new HashMap<>(); @Override public void inspectRepositoryRead(Class type, String oid) { @@ -45,7 +41,7 @@ public void inspectRepositoryRead(Class type, String o } public void assertRead(Class type, int expectedCount) { - assertEquals("Unexpected number of reads of "+type.getSimpleName(), (Integer)expectedCount, readMap.get(type)); + assertEquals("Unexpected number of reads of " + type.getSimpleName(), (Integer) expectedCount, readMap.get(type)); } @Override @@ -59,15 +55,16 @@ public void inspectRoleEvaluation(F target, boo roleEvaluationMap.put(key, i); } - public void assertRoleEvaluations(String roleOid, int expectedCount) { - for(Entry entry: roleEvaluationMap.entrySet()) { + public void assertRoleEvaluations(String roleOid, int expectedCount) { + for (Entry entry : roleEvaluationMap.entrySet()) { if (roleOid.equals(entry.getKey().oid)) { - assertEquals("Wrong role evaluation count for role "+roleOid, (Integer)expectedCount, entry.getValue()); + assertEquals("Wrong role evaluation count for role " + roleOid, + (Integer) expectedCount, entry.getValue()); return; } } if (expectedCount != 0) { - AssertJUnit.fail("No evaluation count found for role "+roleOid); + AssertJUnit.fail("No evaluation count found for role " + roleOid); } } @@ -144,7 +141,5 @@ private CountingInspector getOuterType() { public String toString() { return "(" + oid + ":" + name + ")"; } - - } } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConsistencyMechanism.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConsistencyMechanism.java index d7eafdf0969..1a959d3fd8e 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConsistencyMechanism.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConsistencyMechanism.java @@ -620,7 +620,7 @@ public void test122AddAccountAlreadyExistUnlinked() throws Exception { assignAccount(UserType.class, USER_WILL_OID, RESOURCE_OPENDJ_OID, null, task, parentResult); // THEN - TestUtil.displayThen(TEST_NAME); + then(); String accountOid = checkUser(USER_WILL_OID, task, parentResult); // MidPointAsserts.assertAssignments(user, 1); @@ -732,7 +732,7 @@ public void test124AddAccountDirectAlreadyExists() throws Exception { @Test public void test130DeleteObjectNotFound() throws Exception { final String TEST_NAME = "test130DeleteObjectNotFound"; - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createResult(); repoAddShadowFromFile(ACCOUNT_GUYBRUSH_FILE, parentResult); repoAddObjectFromFile(USER_GUYBRUSH_FILENAME, parentResult); @@ -852,7 +852,7 @@ public void test142ModifyObjectNotFoundAssignedAccount() throws Exception { final String TEST_NAME = "test142ModifyObjectNotFoundAssignedAccountq"; // GIVEN - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createResult(); repoAddShadowFromFile(ACCOUNT_GUYBRUSH_MODIFY_DELETE_FILE, parentResult); repoAddObjectFromFile(USER_GUYBRUSH_NOT_FOUND_FILENAME, parentResult); @@ -884,7 +884,7 @@ public void test142ModifyObjectNotFoundAssignedAccount() throws Exception { // requestToExecuteChanges(REQUEST_ACCOUNT_MODIFY_NOT_FOUND_DELETE_ACCOUNT_FILE, ACCOUNT_GUYBRUSH_MODIFY_DELETE_OID, ShadowType.class, task, null, parentResult); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject userAfter = getUser(USER_GUYBRUSH_NOT_FOUND_OID); UserAsserter.forUser(userAfter) .assertLinks(1); @@ -914,7 +914,7 @@ public void test144GetObjectNotFoundAssignedAccount() throws Exception { final String TEST_NAME = "test144GetObjectNotFoundAssignedAccount"; // GIVEN - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createResult(); repoAddShadowFromFile(ACCOUNT_HECTOR_FILE, parentResult); repoAddObjectFromFile(USER_HECTOR_NOT_FOUND_FILENAME, parentResult); @@ -980,7 +980,7 @@ public void test150RecomputeUserAccountNotFound() throws Exception { recomputeUser(USER_GUYBRUSH_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1171,7 +1171,7 @@ public void test212AddModifyObjectCommunicationProblem() throws Exception { XMLGregorianCalendar lastRequestEndTs = clock.currentTimeXMLGregorianCalendar(); //THEN - TestUtil.displayThen(TEST_NAME); + then(); assertRepoShadow(accountOid) .display(TEST_NAME + "Shadow after") .assertKind(ShadowKindType.ACCOUNT) @@ -1225,7 +1225,7 @@ public void test214ModifyObjectCommunicationProblem() throws Exception { // GIVEN openDJController.assumeStopped(); - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createResult(); String accountOid = assertUserOneAccountRef(USER_JACK_OID); @@ -1244,7 +1244,7 @@ public void test214ModifyObjectCommunicationProblem() throws Exception { XMLGregorianCalendar lastRequestEndTs = clock.currentTimeXMLGregorianCalendar(); //THEN - TestUtil.displayThen(TEST_NAME); + then(); assertModelShadowNoFetch(ACCOUNT_JACKIE_OID) .display(TEST_NAME + "Shadow after") .assertKind(ShadowKindType.ACCOUNT) @@ -1339,7 +1339,7 @@ public void test230GetAccountCommunicationProblem() throws Exception { // GIVEN openDJController.assumeStopped(); - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); ShadowType account = modelService.getObject(ShadowType.class, ACCOUNT_DENIELS_OID, null, null, result).asObjectable(); @@ -1374,7 +1374,7 @@ public void test240AddObjectCommunicationProblemAlreadyExists() throws Exception // GIVEN openDJController.assumeRunning(); - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createResult(); Entry entry = openDJController.addEntryFromLdifFile(LDIF_ELAINE_FILE); Entry searchResult = openDJController.searchByUid("elaine"); @@ -1447,7 +1447,7 @@ public void test250ModifyFocusCommunicationProblem() throws Exception { // GIVEN openDJController.assumeStopped(); - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createResult(); assertUser(USER_JACK_OID, "User before") .assertLinks(1); @@ -1530,7 +1530,7 @@ public void test251ModifyFocusCommunicationProblemSecondTime() throws Exception // GIVEN openDJController.assumeStopped(); - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createResult(); assertUser(USER_JACKIE_OID, "User before") .assertLinks(1) @@ -1646,7 +1646,7 @@ public void test260GetDiscoveryAddCommunicationProblem() throws Exception { // GIVEN openDJController.assumeStopped(); display("OpenDJ stopped"); - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createResult(); repoAddObjectFromFile(USER_ANGELIKA_FILENAME, parentResult); @@ -1663,7 +1663,7 @@ public void test260GetDiscoveryAddCommunicationProblem() throws Exception { XMLGregorianCalendar lastRequestEndTs = clock.currentTimeXMLGregorianCalendar(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); parentResult.computeStatus(); assertInProgress(parentResult); @@ -1907,7 +1907,7 @@ public void test265ModifyUserPasswordCommunicationProblemRecon() throws Exceptio XMLGregorianCalendar lastRequestEndTs = clock.currentTimeXMLGregorianCalendar(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); //check the state after execution assertModelShadowNoFetch(shadowOid) .display(TEST_NAME + "Shadow after") @@ -1949,7 +1949,7 @@ public void test265ModifyUserPasswordCommunicationProblemRecon() throws Exceptio reconcileUser(USER_ALICE_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); openDJController.assertPassword(aliceAccountDn, "UNDEADmenTELLscaryTALES"); assertUser(USER_ALICE_OID, "User after") @@ -1968,7 +1968,7 @@ public void test270ModifyDiscoveryAddCommunicationProblem() throws Exception { // GIVEN openDJController.assumeStopped(); - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createResult(); // WHEN repoAddObjectFromFile(USER_BOB_NO_GIVEN_NAME_FILENAME, parentResult); @@ -2023,7 +2023,7 @@ public void test280ModifyObjectCommunicationProblemWeakMapping() throws Exceptio // GIVEN openDJController.assumeRunning(); - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createResult(); repoAddObjectFromFile(USER_JOHN_WEAK_FILENAME, parentResult); assertUser(USER_JOHN_WEAK_OID, "User before") @@ -2072,7 +2072,7 @@ public void test282ModifyObjectCommunicationProblemWeakAndStrongMapping() throws // GIVEN openDJController.assumeRunning(); - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createResult(); repoAddObjectFromFile(USER_DONALD_FILENAME, parentResult); @@ -2139,7 +2139,7 @@ public void test283GetObjectNoFetchShadowAndRecompute() throws Exception { // GIVEN openDJController.assumeRunning(); - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createResult(); assertUser(USER_DONALD_OID, "User before") .assertLinks(1); @@ -2176,7 +2176,7 @@ public void test283GetObjectNoFetchShadowAndRecompute() throws Exception { public void test284ModifyObjectAssignToGroupCommunicationProblem() throws Exception { final String TEST_NAME = "test284ModifyObjectAssignToGroupCommunicationProblem"; Task task = taskManager.createTaskInstance(); - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createResult(); // GIVEN openDJController.addEntriesFromLdifFile(LDIF_CREATE_ADMINS_GROUP_FILE); @@ -2251,7 +2251,7 @@ public void test400GetDiscoveryAddCommunicationProblemAlreadyExists() throws Exc // GIVEN openDJController.assumeStopped(); - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createResult(); repoAddObjectFromFile(USER_DISCOVERY_FILENAME, parentResult); @@ -2358,7 +2358,7 @@ public void test501AddUserChuckWithAssignment() throws Exception { addObject(USER_CHUCK_FILE); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); // assertEquals("Expected handled error but got: " + result.getStatus(), OperationResultStatus.HANDLED_ERROR, result.getStatus()); @@ -2420,7 +2420,7 @@ public void test502AssignAccountToHerman() throws Exception { assignAccount(UserType.class, USER_HERMAN_OID, RESOURCE_OPENDJ_OID, "internal", task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); // assertEquals("Expected handled error but got: " + result.getStatus(), OperationResultStatus.HANDLED_ERROR, result.getStatus()); @@ -2488,7 +2488,7 @@ public void test510UnlinkAndUnassignAccountMorgan() throws Exception { repositoryService.deleteObject(ShadowType.class, linkRef.getOid(), result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); // assertEquals("Expected handled error but got: " + result.getStatus(), OperationResultStatus.HANDLED_ERROR, result.getStatus()); @@ -2572,7 +2572,7 @@ public void test511AssignAccountMorgan() throws Exception { // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); // assertEquals("Expected handled error but got: " + result.getStatus(), OperationResultStatus.HANDLED_ERROR, result.getStatus()); @@ -2625,7 +2625,7 @@ public void test601GetDiscoveryModifyCommunicationProblemDirectAccount() throws String TEST_NAME = "test601GetDiscoveryModifyCommunicationProblemDirectAccount"; openDJController.assumeRunning(); - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createResult(); //prepare user repoAddObjectFromFile(USER_ALICE_FILENAME, parentResult); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelivery.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelivery.java index bc3090aafcd..e06f4483a81 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelivery.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelivery.java @@ -174,7 +174,7 @@ protected PrismObject getDefaultActor() { @Test public void test100Assign_IT_2_failure() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); try { assignRole(userBobOid, roleIt2Oid, task, result); // hard constraint @@ -187,7 +187,7 @@ public void test100Assign_IT_2_failure() throws Exception { @Test public void test110Assign_IT_2_success() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assignRole(userBarkeeperOid, roleIt2Oid, task, result); // hard constraint result.computeStatus(); @@ -199,7 +199,7 @@ public void test110Assign_IT_2_success() throws Exception { @Test public void test120Assign_IT_1() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assignRole(userBobOid, roleIt1Oid, task, result); // approval constraint @@ -225,7 +225,7 @@ public void test120Assign_IT_1() throws Exception { @Test public void test130Assign_IT_3() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assignRole(userCarlaOid, roleIt3Oid, task, result); // two approval constraints @@ -260,7 +260,7 @@ public void test130Assign_IT_3() throws Exception { @Test public void test140Assign_IT_4() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assignRole(userBarkeeperOid, roleIt4Oid, task, result); // approval constraint @@ -286,7 +286,7 @@ public void test140Assign_IT_4() throws Exception { @Test public void test150Assign_IT_5() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); assignRole(userBarkeeperOid, roleIt5Oid, task, result); // approval constraint diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDependencyRename.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDependencyRename.java index 16244825c7c..cf89687ba03 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDependencyRename.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDependencyRename.java @@ -103,7 +103,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestDependencyRename.class.getName() + "." + TEST_NAME); OperationResult testResultHr = modelService.testResource(RESOURCE_DUMMY_PHONEBOOK_OID, task); @@ -118,7 +117,6 @@ public void test000Sanity() throws Exception { @Test public void test100AddUserHerman() throws Exception { final String TEST_NAME = "test100AddUserHerman"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestDependencyRename.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -149,7 +147,6 @@ public void test100AddUserHerman() throws Exception { @Test public void test110HermanAssignRoleBasic() throws Exception { final String TEST_NAME = "test110HermanAssignRoleBasic"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestDependencyRename.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -184,7 +181,6 @@ public void test110HermanAssignRoleBasic() throws Exception { @Test public void test112HermanRename() throws Exception { final String TEST_NAME = "test112HermanRename"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestDependencyRename.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -219,7 +215,6 @@ public void test112HermanRename() throws Exception { @Test public void test120AddUserCapsizeWithBasicRole() throws Exception { final String TEST_NAME = "test120AddUserCapsizeWithBasicRole"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestDependencyRename.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestImportGroups.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestImportGroups.java index 6077ec64523..d9a4fe10b6f 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestImportGroups.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestImportGroups.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -46,7 +46,7 @@ protected void startResources() throws Exception { } @AfterClass - public static void stopResources() throws Exception { + public static void stopResources() { openDJController.stop(); } @@ -70,13 +70,10 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test001importGroups() throws Exception { - String TEST_NAME = "test001importGroups"; - addObject(TASK_IMPORT_GROUPS); waitForTaskFinish(TASK_IMPORT_GROUPS_OID, true); assertObjects(OrgType.class, DEFAULT_GROUPS + GROUPS); - } } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLargeGroups.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLargeGroups.java index d3f41c4f2ce..ccaf8a2e55d 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLargeGroups.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLargeGroups.java @@ -96,7 +96,7 @@ public void test000Sanity() throws Exception { @Test public void test100GetLargeGroup(ITestContext ctx) throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); final int MEMBERS = 20000; @@ -123,7 +123,7 @@ private void assert100LargeGroupSearch( throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); ResourceAttributeDefinition nameDefinition = libraryMidpointFunctions .getAttributeDefinition(resourceDummy, dummyResourceCtl.getGroupObjectClass(), SchemaConstants.ICFS_NAME); ObjectQuery query = prismContext.queryFor(ShadowType.class) diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMachineIntelligence.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMachineIntelligence.java index f0b2c578ffc..97e1a8bb4ce 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMachineIntelligence.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMachineIntelligence.java @@ -138,7 +138,6 @@ SchemaConstants.ICF_CONFIGURATION_PROPERTIES, new QName(NS_RESOURCE_CSV, "filePa @Test public void test010importActiveUserRUR() throws Exception { final String TEST_NAME = "test010importActiveUserRUR"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestMachineIntelligence.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -171,7 +170,6 @@ public void test010importActiveUserRUR() throws Exception { @Test public void test011importInactiveUserChappie() throws Exception { final String TEST_NAME = "test011importInactiveUserChappie"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestMachineIntelligence.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestManyThreads.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestManyThreads.java index 25be6e96eec..31b0ee6f658 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestManyThreads.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestManyThreads.java @@ -73,7 +73,7 @@ public void test000Sanity() throws Exception { @Test public void test100SearchResourceObjects() throws Exception { Task globalTask = getTestTask(); - OperationResult globalResult = getResult(); + OperationResult globalResult = getTestResult(); dummyResource.addAccount(new DummyAccount("jack")); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationCounts.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationCounts.java index c151404e28c..e6311798ce6 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationCounts.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationCounts.java @@ -137,7 +137,7 @@ public void test100AddAlice() throws Exception { addObject(USER_ALICE_FILE, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -184,7 +184,7 @@ public void test110AddBob() throws Exception { addObject(USER_BOB_FILE, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -232,7 +232,7 @@ public void test120ModifyBob() throws Exception { executeChanges(delta, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestPhotoAssignment.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestPhotoAssignment.java index 4d5373c6f15..2ee3377e80c 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestPhotoAssignment.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestPhotoAssignment.java @@ -59,9 +59,6 @@ protected PrismObject getDefaultActor() { @Test public void test100AssignJoeCard() throws Exception { - final String TEST_NAME = "test100AssignJoeCard"; - TestUtil.displayTestTitle(TEST_NAME); - TestPhotoAssignment.class.getName(); Task task = getTestTask(); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestReconNullValue.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestReconNullValue.java index 29a2ef7be47..689096a3fab 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestReconNullValue.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestReconNullValue.java @@ -130,7 +130,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestReconNullValue.class.getName() + "." + TEST_NAME); OperationResult testResultOpenDj = modelService.testResource(RESOURCE_OPENDJ_OID, task); @@ -146,7 +145,6 @@ public void test000Sanity() throws Exception { @Test public void test100CreateUsers() throws Exception { final String TEST_NAME = "test200CreateUsers"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestReconNullValue.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -159,7 +157,7 @@ public void test100CreateUsers() throws Exception { addObject(user0Before, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestRetirement.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestRetirement.java index 8e1826d628f..16995a607a3 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestRetirement.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestRetirement.java @@ -154,7 +154,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestRetirement.class.getName() + "." + TEST_NAME); OperationResult testResultOpenDj = modelService.testResource(RESOURCE_OPENDJ_OID, task); @@ -167,7 +166,6 @@ public void test000Sanity() throws Exception { @Test public void test050AddOrgRetired() throws Exception { final String TEST_NAME = "test050AddOrgRetired"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestRetirement.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -179,7 +177,7 @@ public void test050AddOrgRetired() throws Exception { addObject(orgBefore, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -206,7 +204,6 @@ public void test050AddOrgRetired() throws Exception { @Test public void test100AddOrgRoyulaCarpathia() throws Exception { final String TEST_NAME = "test100AddOrgRoyulaCarpathia"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestRetirement.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -218,7 +215,7 @@ public void test100AddOrgRoyulaCarpathia() throws Exception { addObject(orgBefore, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -235,7 +232,6 @@ public void test100AddOrgRoyulaCarpathia() throws Exception { @Test public void test110AddUserTeleke() throws Exception { final String TEST_NAME = "test110AddUserTeleke"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestRetirement.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -248,7 +244,7 @@ public void test110AddUserTeleke() throws Exception { addObject(userBefore, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -266,7 +262,6 @@ public void test110AddUserTeleke() throws Exception { @Test public void test200AddOrgCortuvHrad() throws Exception { final String TEST_NAME = "test200AddOrgCortuvHrad"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestRetirement.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -278,7 +273,7 @@ public void test200AddOrgCortuvHrad() throws Exception { addObject(orgBefore, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -296,7 +291,6 @@ public void test200AddOrgCortuvHrad() throws Exception { @Test public void test210AddUserGorc() throws Exception { final String TEST_NAME = "test210AddUserGorc"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestRetirement.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -309,7 +303,7 @@ public void test210AddUserGorc() throws Exception { addObject(userBefore, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -323,7 +317,6 @@ public void test210AddUserGorc() throws Exception { @Test public void test220AddOrgVysneVlkodlaky() throws Exception { final String TEST_NAME = "test220AddOrgVysneVlkodlaky"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestRetirement.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -335,7 +328,7 @@ public void test220AddOrgVysneVlkodlaky() throws Exception { addObject(orgBefore, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -353,7 +346,6 @@ public void test220AddOrgVysneVlkodlaky() throws Exception { @Test public void test230AddUserViljaDezi() throws Exception { final String TEST_NAME = "test230AddUserViljaDezi"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestRetirement.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -366,7 +358,7 @@ public void test230AddUserViljaDezi() throws Exception { addObject(userBefore, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -379,7 +371,6 @@ public void test230AddUserViljaDezi() throws Exception { @Test public void test300RetireUserGorc() throws Exception { final String TEST_NAME = "test300RetireUserGorc"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestRetirement.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -395,7 +386,7 @@ public void test300RetireUserGorc() throws Exception { modelService.executeChanges(deltas, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -409,7 +400,6 @@ public void test300RetireUserGorc() throws Exception { @Test public void test302ReconcileUserGorc() throws Exception { final String TEST_NAME = "test302ReconcileUserGorc"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestRetirement.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -418,7 +408,7 @@ public void test302ReconcileUserGorc() throws Exception { reconcileUser(userGorcOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -432,7 +422,6 @@ public void test302ReconcileUserGorc() throws Exception { @Test public void test303ReconcileUserGorcAgain() throws Exception { final String TEST_NAME = "test303ReconcileUserGorcAgain"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestRetirement.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -441,7 +430,7 @@ public void test303ReconcileUserGorcAgain() throws Exception { reconcileUser(userGorcOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccountsClassifier.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccountsClassifier.java index e9e5b580234..9a274c1ce23 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccountsClassifier.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccountsClassifier.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholds.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholds.java index 1d40c2414a1..ce2e78ebcee 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholds.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholds.java @@ -102,7 +102,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test001testImportBaseUsers() throws Exception { final String TEST_NAME = "test001testImportBaseUsers"; - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); importObjectFromFile(TASK_IMPORT_BASE_USERS_FILE); @@ -230,7 +230,7 @@ public void test500chageTaskPolicyRule() throws Exception { @Test public void test520changeActivationThreeAccounts() throws Exception { final String TEST_NAME = "test520changeActivationThreeAccounts"; - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); //GIVEN openDJController.executeLdifChange(LDIF_CHANGE_ACTIVATION_FILE); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsReconFull.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsReconFull.java index 7242b07ed4b..7248b772322 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsReconFull.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsReconFull.java @@ -87,7 +87,7 @@ public void test600chageTaskPolicyRule() throws Exception { @Test public void test610testFullRecon() throws Exception { final String TEST_NAME = "test610testFullRecon"; - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); //WHEN when(TEST_NAME); @@ -107,7 +107,7 @@ public void test610testFullRecon() throws Exception { @Test public void test611testFullRecon() throws Exception { final String TEST_NAME = "test611testFullRecon"; - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); openDJController.delete("uid=user10,ou=People,dc=example,dc=com"); openDJController.delete("uid=user11,ou=People,dc=example,dc=com"); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUniversity.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUniversity.java index 4b8b7869619..1b7f34b5261 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUniversity.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUniversity.java @@ -116,7 +116,7 @@ protected void startResources() throws Exception { } @AfterClass - public static void stopResources() throws Exception { + public static void stopResources() { openDJController.stop(); } @@ -163,7 +163,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestUniversity.class.getName() + "." + TEST_NAME); OperationResult testResultHr = modelService.testResource(RESOURCE_DUMMY_HR_OID, task); @@ -180,8 +179,6 @@ public void test000Sanity() throws Exception { @Test public void test100AddComeniusUniversity() throws Exception { final String TEST_NAME = "test100AddComeniusUniversity"; - TestUtil.displayTestTitle(this, TEST_NAME); - Task task = taskManager.createTaskInstance(TestUniversity.class.getName() + "." + TEST_NAME); DummyPrivilege comenius = new DummyPrivilege("UK"); @@ -205,8 +202,6 @@ public void test100AddComeniusUniversity() throws Exception { @Test public void test110AddComeniusStructure() throws Exception { final String TEST_NAME = "test110AddComeniusStructure"; - TestUtil.displayTestTitle(this, TEST_NAME); - Task task = taskManager.createTaskInstance(TestUniversity.class.getName() + "." + TEST_NAME); DummyPrivilege srcFmfi = new DummyPrivilege("FMFI"); srcFmfi.addAttributeValue(DUMMY_PRIVILEGE_ATTRIBUTE_HR_ORGPATH, "UK"); @@ -280,8 +275,6 @@ private void assertNoGroupMembers(PrismObject org) throws Exception { @Test public void test120MoveComputingCentre() throws Exception { final String TEST_NAME = "test120MoveComputingCentre"; - TestUtil.displayTestTitle(this, TEST_NAME); - Task task = taskManager.createTaskInstance(TestUniversity.class.getName() + "." + TEST_NAME); DummyPrivilege srcVc = dummyResourceHr.getPrivilegeByName("VC"); @@ -330,172 +323,6 @@ public void test120MoveComputingCentre() throws Exception { assertNoGroupMembers(vc); } -// @Test -// public void test500ReconcileOpenDJDefault() throws Exception { -// final String TEST_NAME = "test500ReconcileOpenDJDefault"; -// TestUtil.displayTestTile(this, TEST_NAME); -// -// // GIVEN -// Task task = createTask(TestInsurance.class.getName() + "." + TEST_NAME); -// OperationResult result = task.getResult(); -// assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); -// -// List> users = modelService.searchObjects(UserType.class, null, null, task, result); -// display("Users before recon", users); -// assertUsers(15); -// -// reconciliationTaskResultListener.clear(); -// -// // WHEN -// when(); -// importObjectFromFile(TASK_RECON_OPENDJ_DEFAULT_SINGLE_FILE); -// -// // THEN -// TestUtil.displayThen(TEST_NAME); -// -// waitForTaskFinish(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID, false); -// -// // THEN -// TestUtil.displayThen(TEST_NAME); -// -// reconciliationTaskResultListener.assertResult(RESOURCE_OPENDJ_OID, 0, 17, 0, 0); -// -// users = modelService.searchObjects(UserType.class, null, null, task, result); -// display("Users after recon", users); -// -// assertUsers(18); -// -// // Task result -// PrismObject reconTaskAfter = getTask(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID); -// OperationResultType reconTaskResult = reconTaskAfter.asObjectable().getResult(); -// display("Recon task result", reconTaskResult); -// TestUtil.assertSuccess(reconTaskResult); -// } -// -// @Test -// public void test502ReconcileOpenDJDefaultAgain() throws Exception { -// final String TEST_NAME = "test502ReconcileOpenDJDefaultAgain"; -// TestUtil.displayTestTile(this, TEST_NAME); -// -// // GIVEN -// Task task = createTask(TestInsurance.class.getName() + "." + TEST_NAME); -// OperationResult result = task.getResult(); -// assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); -// -// assertUsers(18); -// reconciliationTaskResultListener.clear(); -// -// // WHEN -// when(); -// restartTask(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID); -// -// // THEN -// TestUtil.displayThen(TEST_NAME); -// -// waitForTaskFinish(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID, false); -// -// // THEN -// TestUtil.displayThen(TEST_NAME); -// -// reconciliationTaskResultListener.assertResult(RESOURCE_OPENDJ_OID, 0, 17, 0, 0); -// -// assertUsers(18); -// -// // Task result -// PrismObject reconTaskAfter = getTask(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID); -// OperationResultType reconTaskResult = reconTaskAfter.asObjectable().getResult(); -// display("Recon task result", reconTaskResult); -// TestUtil.assertSuccess(reconTaskResult); -// } -// -// @Test -// public void test510ReconcileOpenDJLdapGroup() throws Exception { -// final String TEST_NAME = "test510ReconcileOpenDJLdapGroup"; -// TestUtil.displayTestTile(this, TEST_NAME); -// -// // GIVEN -// Task task = createTask(TestInsurance.class.getName() + "." + TEST_NAME); -// OperationResult result = task.getResult(); -// assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); -// -// List> users = modelService.searchObjects(UserType.class, null, null, task, result); -// display("Users before recon", users); -// assertUsers(18); -// -// reconciliationTaskResultListener.clear(); -// -// // WHEN -// when(); -// importObjectFromFile(TASK_RECON_OPENDJ_LDAPGROUP_SINGLE_FILE); -// -// // THEN -// TestUtil.displayThen(TEST_NAME); -// -// waitForTaskFinish(TASK_RECON_OPENDJ_LDAPGROUP_SINGLE_OID, false); -// -// // THEN -// TestUtil.displayThen(TEST_NAME); -// -// reconciliationTaskResultListener.assertResult(RESOURCE_OPENDJ_OID, 0, 2, 0, 0); -// -// users = modelService.searchObjects(UserType.class, null, null, task, result); -// display("Users after recon", users); -// -// assertUsers(18); -// -// // Task result -// PrismObject reconTaskAfter = getTask(TASK_RECON_OPENDJ_LDAPGROUP_SINGLE_OID); -// OperationResultType reconTaskResult = reconTaskAfter.asObjectable().getResult(); -// display("Recon task result", reconTaskResult); -// TestUtil.assertSuccess(reconTaskResult); -// } -// -// @Test -// public void test550ReconcileOpenDJAfterMembershipChange() throws Exception { -// final String TEST_NAME = "test550ReconcileOpenDJAfterMembershipChange"; -// TestUtil.displayTestTile(this, TEST_NAME); -// -// // We manually remove Lemonhead from R_canibalism group -// // And check whether reconciliation re-adds him again -// -// // GIVEN -// Task task = createTask(TestInsurance.class.getName() + "." + TEST_NAME); -// OperationResult result = task.getResult(); -// assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); -// -// Collection membersBeforeTest = openDJController.getGroupUniqueMembers(RESP_CANIBALISM_DN); -// System.out.println("group members before test = " + membersBeforeTest); -// assertTrue(RESP_CANIBALISM_DN + " does not contain " + ACCOUNT_LEMONHEAD_DN, membersBeforeTest.contains(ACCOUNT_LEMONHEAD_DN)); -// -// openDJController.removeGroupUniqueMember(RESP_CANIBALISM_DN, ACCOUNT_LEMONHEAD_DN); -// -// System.out.println("group members after removal = " + openDJController.getGroupUniqueMembers(RESP_CANIBALISM_DN)); -// -// openDJController.assertNoUniqueMember(RESP_CANIBALISM_DN, ACCOUNT_LEMONHEAD_DN); -// -// // WHEN -// when(); -// restartTask(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID); -// -// // THEN -// TestUtil.displayThen(TEST_NAME); -// -// waitForTaskFinish(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID, false); -// -// // THEN -// TestUtil.displayThen(TEST_NAME); -// -// // Task result -// PrismObject reconTaskAfter = getTask(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID); -// OperationResultType reconTaskResult = reconTaskAfter.asObjectable().getResult(); -// display("Recon task result", reconTaskResult); -// TestUtil.assertSuccess(reconTaskResult); -// -// Collection membersAfterTest = openDJController.getGroupUniqueMembers(RESP_CANIBALISM_DN); -// System.out.println("group members after test = " + membersAfterTest); -// assertTrue(RESP_CANIBALISM_DN + " does not contain " + ACCOUNT_LEMONHEAD_DN, membersAfterTest.contains(ACCOUNT_LEMONHEAD_DN.toLowerCase())); // ...it seems to get lowercased during the reconciliation -// } - private PrismObject getAndAssertFunctionalOrg(String orgName) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, DirectoryException, ExpressionEvaluationException { PrismObject org = getOrg(orgName); PrismAsserts.assertPropertyValue(org, OrgType.F_ORG_TYPE, "functional"); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestVillage.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestVillage.java index a884ac5eb61..a4ecef6ab49 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestVillage.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestVillage.java @@ -303,7 +303,7 @@ public void test020ResourceOpenDjGet() throws Exception { modelService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -346,7 +346,7 @@ public void test022ResourceOpenDjRefinedSchema() throws Exception { long t1 = System.currentTimeMillis(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -735,7 +735,7 @@ public void test152ModifySrcAccountHermanDeleteOrg() throws Exception { waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_SOURCE_OID, true); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject user = findUserByUsername(getUsername(ACCOUNT_HERMAN_FIST_NAME, ACCOUNT_HERMAN_LAST_NAME, null)); assertUserNoRole(user, ACCOUNT_HERMAN_FIST_NAME, ACCOUNT_HERMAN_LAST_NAME, null); assertLocGov(user, null, null); @@ -750,7 +750,7 @@ public void test152ModifySrcAccountHermanDeleteOrg() throws Exception { public void test200CreateUserAssignOrgPwdPolicy() throws Exception { final String TEST_NAME = "test200CreateUserAssignOrgPwdPolicy"; Task task = getTestTask(); - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); //prepare password policies addObject(GLOBAL_PASSWORD_POLICY_FILE); @@ -859,7 +859,7 @@ ShadowType.F_ATTRIBUTES, new QName(RESOURCE_OPENDJ_NAMESPACE, "cn")).eq("admins" SearchResultList> groupShadows = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -882,7 +882,7 @@ public void test319DeleteProjectJollyRoger() throws Exception { deleteObject(OrgType.class, ORG_PROJECT_JOLLY_ROGER_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -909,7 +909,7 @@ public void test350AddRepoUserNoEmployeeNumberRecompute() throws Exception { recomputeUser(USER_MURRAY_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperAsyncUpdate.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperAsyncUpdate.java index 6b924082f22..6e43ab21c65 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperAsyncUpdate.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperAsyncUpdate.java @@ -78,7 +78,7 @@ public void test000Sanity() throws Exception { @Test public void test010CreateUsers() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); addObject(USER_BANDERSON, task, result); addObject(USER_JLEWIS685, task, result); @@ -96,7 +96,7 @@ public void test010CreateUsers() throws Exception { public void test110AddAlumni() throws Exception { Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // GIVEN @@ -148,7 +148,7 @@ public void test110AddAlumni() throws Exception { public void test115AddStaff() throws Exception { Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // GIVEN @@ -199,7 +199,7 @@ public void test115AddStaff() throws Exception { public void test200AddAlumniForAnderson() throws Exception { Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // GIVEN @@ -235,7 +235,7 @@ public void test200AddAlumniForAnderson() throws Exception { @Test public void test202RecomputeAnderson() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN @@ -265,7 +265,7 @@ public void test202RecomputeAnderson() throws Exception { public void test210AddStaffForAnderson() throws Exception { Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // GIVEN @@ -296,7 +296,7 @@ public void test210AddStaffForAnderson() throws Exception { @Test public void test212RecomputeAnderson() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN @@ -329,7 +329,7 @@ public void test212RecomputeAnderson() throws Exception { public void test220AddAlumniForLewis() throws Exception { Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // GIVEN @@ -360,7 +360,7 @@ public void test220AddAlumniForLewis() throws Exception { public void test221AddStaffForLewis() throws Exception { Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // GIVEN @@ -391,7 +391,7 @@ public void test221AddStaffForLewis() throws Exception { @Test public void test222RecomputeLewis() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN @@ -423,7 +423,7 @@ public void test222RecomputeLewis() throws Exception { public void test230AddAlumniForNobody() throws Exception { Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // GIVEN @@ -450,7 +450,7 @@ public void test230AddAlumniForNobody() throws Exception { public void test250DeleteAlumniForAnderson() throws Exception { Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // GIVEN @@ -480,7 +480,7 @@ public void test250DeleteAlumniForAnderson() throws Exception { @Test public void test252RecomputeAnderson() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // WHEN @@ -510,7 +510,7 @@ public void test252RecomputeAnderson() throws Exception { public void test305RenameStaff() throws Exception { Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // GIVEN @@ -568,7 +568,7 @@ public void test305RenameStaff() throws Exception { public void test310DeleteStaff() throws Exception { Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // GIVEN @@ -618,7 +618,7 @@ public void test310DeleteStaff() throws Exception { @Test public void test312ScavengeGroups() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); // GIVEN diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperLargeGroupImport.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperLargeGroupImport.java index d2bd3c71cfc..e12b5d5ab3e 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperLargeGroupImport.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperLargeGroupImport.java @@ -54,7 +54,7 @@ public void test000Sanity() throws Exception { @Test public void test100ImportGroups() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); task.setOwner(userAdministrator); addObject(TASK_IMPORT_GROUPS, task, result); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperLargeGroupReconciliation.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperLargeGroupReconciliation.java index 55f0b77fd5b..8b7d80bf8d7 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperLargeGroupReconciliation.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperLargeGroupReconciliation.java @@ -54,7 +54,7 @@ public void test000Sanity() throws Exception { @Test public void test100ReconcileGroups() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); task.setOwner(userAdministrator); addObject(TASK_RECONCILE_GROUPS, task, result); @@ -68,7 +68,7 @@ public void test100ReconcileGroups() throws Exception { @Test public void test110ReconcileGroupsAgain() throws Exception { Task task = getTestTask(); - OperationResult result = getResult(); + OperationResult result = getTestResult(); task.setOwner(userAdministrator); deleteGroupMember(ALUMNI_NAME, 3); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/AbstractLdapTest.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/AbstractLdapTest.java index 63cfd3e2954..427c2c02e65 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/AbstractLdapTest.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/AbstractLdapTest.java @@ -115,7 +115,7 @@ protected ObjectDelta createAssignmentOrgDelta(String orgOid, String ro protected void assignRoleToOrg(String orgOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - assignRoleToOrg(orgOid, roleOid, (ActivationType) null, task, result); + assignRoleToOrg(orgOid, roleOid, null, task, result); } protected void assignRoleToOrg(String orgOid, String roleOid, ActivationType activationType, Task task, @@ -128,7 +128,7 @@ protected void assignRoleToOrg(String orgOid, String roleOid, ActivationType act protected void unassignRoleFromOrg(String orgOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - unassignRoleFromOrg(orgOid, roleOid, (ActivationType) null, task, result); + unassignRoleFromOrg(orgOid, roleOid, null, task, result); } protected void unassignRoleFromOrg(String orgOid, String roleOid, ActivationType activationType, Task task, @@ -138,11 +138,6 @@ protected void unassignRoleFromOrg(String orgOid, String roleOid, ActivationType modifyOrgAssignment(orgOid, roleOid, RoleType.COMPLEX_TYPE, null, task, null, activationType, false, result); } - protected void assertOrgNotAssignedRole(PrismObject focus, String roleOid) { - assertNotAssigned(focus, roleOid, RoleType.COMPLEX_TYPE); - // assertNotAssigned(user, roleOid, RoleType.COMPLEX_TYPE); - } - // TODO: maybe a replacement for MidpointAsserts.assertNotAssigned() // it can be used not only for user protected void assertNotAssigned(PrismObject focus, String targetOid, QName refType) { diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapSyncMassive.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapSyncMassive.java index 8e5f35e9235..b8d5754221d 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapSyncMassive.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapSyncMassive.java @@ -416,7 +416,7 @@ public void test232UserRecomputeParallel() throws Exception { when(TEST_NAME); int segmentSize = users.size() / NUMBER_OF_TEST_THREADS; - ParallelTestThread[] threads = multithread(TEST_NAME, + ParallelTestThread[] threads = multithread( (threadIndex) -> { for (int i = segmentSize * threadIndex; i < segmentSize * threadIndex + segmentSize; i++) { PrismObject user = users.get(i); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapVirtualGroup.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapVirtualGroup.java index 7253de1ae88..63c7327a3f1 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapVirtualGroup.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapVirtualGroup.java @@ -192,7 +192,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestLdapVirtualGroup.class.getName() + "." + TEST_NAME); OperationResult testResultOpenDj = modelService.testResource(RESOURCE_OPENDJ_OID, task); @@ -207,7 +206,6 @@ public void test000Sanity() throws Exception { @Test public void test090AddItRoleHR() throws Exception { final String TEST_NAME = "test090AddItRoleHR"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestLdapVirtualGroup.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -218,7 +216,7 @@ public void test090AddItRoleHR() throws Exception { modelService.recompute(RoleType.class, ROLE_IT_HR_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -236,7 +234,6 @@ public void test090AddItRoleHR() throws Exception { @Test public void test100AddItDevRole() throws Exception { final String TEST_NAME = "test100AddItDevRole"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestLdapVirtualGroup.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -248,7 +245,7 @@ public void test100AddItDevRole() throws Exception { addObject(roleBefore, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -265,7 +262,6 @@ public void test100AddItDevRole() throws Exception { @Test public void test110AddItOpRole() throws Exception { final String TEST_NAME = "test100AddItOpRole"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestLdapVirtualGroup.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -277,7 +273,7 @@ public void test110AddItOpRole() throws Exception { addObject(roleBefore, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -294,7 +290,6 @@ public void test110AddItOpRole() throws Exception { @Test public void test200CreateUsers() throws Exception { final String TEST_NAME = "test200CreateUsers"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestLdapVirtualGroup.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -315,7 +310,7 @@ public void test200CreateUsers() throws Exception { addObject(user3Before, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -339,7 +334,6 @@ public void test200CreateUsers() throws Exception { public void test210AssignItHrRoleToUser0() throws Exception { final String TEST_NAME = "test210AssignItHrRoleToUser0"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestLdapVirtualGroup.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -351,7 +345,7 @@ public void test210AssignItHrRoleToUser0() throws Exception { assignRole(user0Before.getOid(), ROLE_IT_HR_OID); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -371,7 +365,6 @@ public void test210AssignItHrRoleToUser0() throws Exception { public void test220AssignItDevRoleToUser1() throws Exception { final String TEST_NAME = "test220AssignItDevRoleToUser1"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestLdapVirtualGroup.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -383,7 +376,7 @@ public void test220AssignItDevRoleToUser1() throws Exception { assignRole(user1Before.getOid(), roleItDevOid); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -403,7 +396,6 @@ public void test220AssignItDevRoleToUser1() throws Exception { public void test230AssignJobRoleToUser2() throws Exception { final String TEST_NAME = "test230AssignJobRoleToUser2"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestLdapVirtualGroup.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -417,7 +409,7 @@ public void test230AssignJobRoleToUser2() throws Exception { assignRole(user2Before.getOid(), ROLE_JOB_DEVOPS_OID); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -439,7 +431,6 @@ public void test230AssignJobRoleToUser2() throws Exception { public void test240AssignJobRoleMultiJobToUser3() throws Exception { final String TEST_NAME = "test230AssignJobRoleMultiJobToUser3"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestLdapVirtualGroup.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -453,7 +444,7 @@ public void test240AssignJobRoleMultiJobToUser3() throws Exception { assignRole(user3Before.getOid(), ROLE_JOB_MULTIJOBS_OID); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/hierarchy/AbstractLdapHierarchyTest.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/hierarchy/AbstractLdapHierarchyTest.java index 8de2884c922..e709f451cc9 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/hierarchy/AbstractLdapHierarchyTest.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/hierarchy/AbstractLdapHierarchyTest.java @@ -7,12 +7,10 @@ package com.evolveum.midpoint.testing.story.ldap.hierarchy; - import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertNotNull; import java.io.File; - import javax.xml.namespace.QName; import org.opends.server.types.DirectoryException; @@ -37,33 +35,16 @@ import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.testing.story.ldap.AbstractLdapTest; -import com.evolveum.midpoint.util.exception.CommonException; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; -import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.PolicyViolationException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SecurityViolationException; -import com.evolveum.midpoint.util.exception.SystemException; -import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; +import com.evolveum.midpoint.util.exception.*; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; /** * Common superclass for LDAP hierarchy tests TestLdapFlat, TestLdapNested * * @author Radovan Semancik - * */ -@ContextConfiguration(locations = {"classpath:ctx-story-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-story-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public abstract class AbstractLdapHierarchyTest extends AbstractLdapTest { @@ -134,7 +115,7 @@ protected void startResources() throws Exception { } @AfterClass - public static void stopResources() throws Exception { + public static void stopResources() { openDJController.stop(); } @@ -142,7 +123,6 @@ public static void stopResources() throws Exception { public void initSystem(Task initTask, OperationResult initResult) throws Exception { super.initSystem(initTask, initResult); - // Resources resourceOpenDj = importAndGetObjectFromFile(ResourceType.class, getResourceOpenDjFile(), RESOURCE_OPENDJ_OID, initTask, initResult); resourceOpenDjType = resourceOpenDj.asObjectable(); @@ -169,7 +149,6 @@ public void test000Sanity() throws Exception { @Test public void test100AddOrgRoyulaCarpathia() throws Exception { - final String TEST_NAME = "test100AddOrgRoyulaCarpathia"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -181,7 +160,7 @@ public void test100AddOrgRoyulaCarpathia() throws Exception { addObject(orgBefore, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -197,7 +176,6 @@ public void test100AddOrgRoyulaCarpathia() throws Exception { @Test public void test110AddUserTeleke() throws Exception { - final String TEST_NAME = "test110AddUserTeleke"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -210,7 +188,7 @@ public void test110AddUserTeleke() throws Exception { addObject(userBefore, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -227,7 +205,6 @@ public void test110AddUserTeleke() throws Exception { @Test public void test200AddOrgCortuvHrad() throws Exception { - final String TEST_NAME = "test200AddOrgCortuvHrad"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -239,7 +216,7 @@ public void test200AddOrgCortuvHrad() throws Exception { addObject(orgBefore, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -256,7 +233,6 @@ public void test200AddOrgCortuvHrad() throws Exception { @Test public void test210AddUserGorc() throws Exception { - final String TEST_NAME = "test210AddUserGorc"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -269,7 +245,7 @@ public void test210AddUserGorc() throws Exception { addObject(userBefore, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -282,7 +258,6 @@ public void test210AddUserGorc() throws Exception { @Test public void test220AddOrgVysneVlkodlaky() throws Exception { - final String TEST_NAME = "test220AddOrgVysneVlkodlaky"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -294,7 +269,7 @@ public void test220AddOrgVysneVlkodlaky() throws Exception { addObject(orgBefore, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -311,7 +286,6 @@ public void test220AddOrgVysneVlkodlaky() throws Exception { @Test public void test230AddUserViljaDezi() throws Exception { - final String TEST_NAME = "test230AddUserViljaDezi"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -324,7 +298,7 @@ public void test230AddUserViljaDezi() throws Exception { addObject(userBefore, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -336,7 +310,6 @@ public void test230AddUserViljaDezi() throws Exception { @Test public void test300RenameOrgCortuvHrad() throws Exception { - final String TEST_NAME = "test300RenameOrgCortuvHrad"; Task task = getTestTask(); OperationResult result = task.getResult(); @@ -348,7 +321,7 @@ public void test300RenameOrgCortuvHrad() throws Exception { modifyObjectReplaceProperty(OrgType.class, orgCortuvHradOid, OrgType.F_NAME, task, result, new PolyString(ORG_CORTUV_HRAD_NAME2)); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -428,8 +401,8 @@ public void test322MoveOrgZblo() throws Exception { ObjectDelta delta = orgBefore.createModifyDelta(); PrismContainerValue oldAssignment = null; - for (PrismContainerValue aval: orgBefore.findContainer(OrgType.F_ASSIGNMENT).getValues()) { - oldAssignment = (PrismContainerValue)aval; + for (PrismContainerValue aval : orgBefore.findContainer(OrgType.F_ASSIGNMENT).getValues()) { + oldAssignment = (PrismContainerValue) aval; if (OrgType.COMPLEX_TYPE.equals(oldAssignment.asContainerable().getTargetRef().getType())) { break; } @@ -443,7 +416,7 @@ public void test322MoveOrgZblo() throws Exception { // WHEN when(TEST_NAME); - display("Modifying "+orgBefore+"with delta", delta); + display("Modifying " + orgBefore + "with delta", delta); modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN @@ -471,7 +444,7 @@ public void test322MoveOrgZblo() throws Exception { assertSubOrgs(orgVysneVlkodlakyOid, 0); } - protected void recomputeIfNeeded(String changedOrgOid) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + protected void recomputeIfNeeded(String changedOrgOid) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { // nothing to do by default } @@ -516,17 +489,19 @@ private PrismObject createOrg(String name, String parentOrgOid) throws return org; } - protected PrismObject getAndAssertUser(String username, String directOrgGroupname, String... indirectGroupNames) throws SchemaException, CommonException, SecurityViolationException, CommunicationException, ConfigurationException, DirectoryException { + protected PrismObject getAndAssertUser( + String username, String directOrgGroupname, String... indirectGroupNames) + throws CommonException, DirectoryException { PrismObject user = findUserByUsername(username); display("user", user); String shadowOid = getLinkRefOid(user, RESOURCE_OPENDJ_OID, ShadowKindType.ACCOUNT, SchemaConstants.INTENT_DEFAULT); PrismObject accountShadow = getShadowModel(shadowOid); - display("Account "+username+" shadow", accountShadow); + display("Account " + username + " shadow", accountShadow); // TODO assert shadow content - Entry accountEntry = openDJController.searchSingle("uid="+username); - assertNotNull("No account LDAP entry for "+username, accountEntry); + Entry accountEntry = openDJController.searchSingle("uid=" + username); + assertNotNull("No account LDAP entry for " + username, accountEntry); display("account entry", openDJController.toHumanReadableLdifoid(accountEntry)); openDJController.assertObjectClass(accountEntry, "inetOrgPerson"); @@ -541,11 +516,11 @@ protected PrismObject getAndAssertFunctionalOrg(String orgName, String String groupOid = getLinkRefOid(org, RESOURCE_OPENDJ_OID, ShadowKindType.ENTITLEMENT, LDAP_GROUP_INTENT); PrismObject groupShadow = getShadowModel(groupOid); - display("Org "+orgName+" group shadow", groupShadow); + display("Org " + orgName + " group shadow", groupShadow); // TODO assert shadow content - Entry groupEntry = openDJController.searchSingle("cn="+orgName); - assertNotNull("No group LDAP entry for "+orgName, groupEntry); + Entry groupEntry = openDJController.searchSingle("cn=" + orgName); + assertNotNull("No group LDAP entry for " + orgName, groupEntry); display("OU GROUP entry", openDJController.toHumanReadableLdifoid(groupEntry)); openDJController.assertObjectClass(groupEntry, "groupOfUniqueNames"); @@ -557,8 +532,8 @@ protected PrismObject getAndAssertFunctionalOrg(String orgName, String protected PrismObject getOrg(String orgName) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { PrismObject org = findObjectByName(OrgType.class, orgName); - assertNotNull("The org "+orgName+" is missing!", org); - display("Org "+orgName, org); + assertNotNull("The org " + orgName + " is missing!", org); + display("Org " + orgName, org); PrismAsserts.assertPropertyValue(org, OrgType.F_NAME, PrismTestUtil.createPolyString(orgName)); return org; } @@ -572,7 +547,6 @@ protected void dumpLdap() throws DirectoryException { display("LDAP server content", openDJController.dumpEntries()); } - protected void assertGroupMembers(PrismObject org, String... members) throws Exception { String groupOid = getLinkRefOid(org, RESOURCE_OPENDJ_OID, ShadowKindType.ENTITLEMENT, "org-group"); PrismObject groupShadow = getShadowModel(groupOid); @@ -592,7 +566,7 @@ protected void reconcileAllUsers() throws SchemaException, ObjectNotFoundExcepti @Override public boolean handle(PrismObject object, OperationResult parentResult) { try { - display("reconciling "+object); + display("reconciling " + object); reconcileUser(object.getOid(), task, parentResult); } catch (SchemaException | PolicyViolationException | ExpressionEvaluationException | ObjectNotFoundException | ObjectAlreadyExistsException | CommunicationException @@ -613,7 +587,7 @@ protected void reconcileAllOrgs() throws SchemaException, ObjectNotFoundExceptio @Override public boolean handle(PrismObject object, OperationResult parentResult) { try { - display("reconciling "+object); + display("reconciling " + object); reconcileOrg(object.getOid(), task, parentResult); } catch (SchemaException | PolicyViolationException | ExpressionEvaluationException | ObjectNotFoundException | ObjectAlreadyExistsException | CommunicationException diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/AbstractNotoriousTest.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/AbstractNotoriousTest.java index a3c1e4aa325..3a2fd84849e 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/AbstractNotoriousTest.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/AbstractNotoriousTest.java @@ -35,8 +35,6 @@ import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.testing.story.AbstractStoryTest; import com.evolveum.midpoint.testing.story.CountingInspector; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; @@ -90,8 +88,6 @@ public abstract class AbstractNotoriousTest extends AbstractStoryTest { protected static final String ROLE_LEVEL_B_ROLETYPE = "levelB"; protected static final String ROLE_LEVEL_B_OID_FORMAT = "00000000-0000-ffff-2b00-000000%06d"; - private static final Trace LOGGER = TraceManager.getTrace(AbstractNotoriousTest.class); - protected CountingInspector inspector; protected abstract String getNotoriousOid(); @@ -138,7 +134,7 @@ protected void fillLevelBRole(RoleType roleType, int i) { .roleType(ROLE_LEVEL_B_ROLETYPE); } - protected void fillNotorious(AbstractRoleType roleType) throws Exception { + protected void fillNotorious(AbstractRoleType roleType) { for(int i=0; i < NUMBER_OF_LEVEL_B_ROLES; i++) { roleType.beginInducement() .targetRef(generateRoleBOid(i), RoleType.COMPLEX_TYPE) @@ -161,8 +157,6 @@ private String generateRoleBOid(int num) { @Test public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; - assertObjects(RoleType.class, NUMBER_OF_LEVEL_A_ROLES + NUMBER_OF_LEVEL_B_ROLES + NUMBER_OF_ORDINARY_ROLES + getNumberOfExtraRoles()); assertObjects(OrgType.class, getNumberOfExtraOrgs()); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/TestNotoriousOrg.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/TestNotoriousOrg.java index 772760669e3..45bb548d52e 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/TestNotoriousOrg.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/TestNotoriousOrg.java @@ -6,71 +6,42 @@ */ package com.evolveum.midpoint.testing.story.notorious; -import static org.testng.AssertJUnit.assertEquals; - import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.function.Consumer; - import javax.xml.namespace.QName; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; -import org.testng.annotations.Test; -import com.evolveum.midpoint.model.api.context.ModelContext; import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.PrismObjectDefinition; -import com.evolveum.midpoint.prism.delta.ItemDelta; -import com.evolveum.midpoint.prism.delta.ObjectDelta; -import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.schema.constants.SchemaConstants; -import com.evolveum.midpoint.schema.internals.InternalInspector; -import com.evolveum.midpoint.schema.internals.InternalMonitor; import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.schema.util.MiscSchemaUtil; -import com.evolveum.midpoint.schema.util.ObjectTypeUtil; -import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.util.MidPointTestConstants; -import com.evolveum.midpoint.util.DebugDumpable; -import com.evolveum.midpoint.util.DebugUtil; -import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; /** * Testing bushy roles hierarchy. Especially reuse of the same role * in the rich role hierarchy. It looks like this: - * - * user - * | - * +------+------+-----+-----+-.... - * | | | | | - * v v v v v - * Ra1 Ra2 Ra3 Ra4 Ra5 - * | | | | | - * +------+------+-----+-----+ - * | - * v - * notorious org - * | - * +------+------+-----+-----+-.... - * | | | | | - * v v v v v - * Rb1 Rb2 Rb3 Rb4 Rb5 - * + *

+ * user + * | + * +------+------+-----+-----+-.... + * | | | | | + * v v v v v + * Ra1 Ra2 Ra3 Ra4 Ra5 + * | | | | | + * +------+------+-----+-----+ + * | + * v + * notorious org + * | + * +------+------+-----+-----+-.... + * | | | | | + * v v v v v + * Rb1 Rb2 Rb3 Rb4 Rb5 + *

* Naive mode of evaluation would imply cartesian product of all Rax and Rbx * combinations. That's painfully inefficient. Therefore make sure that the * notorious roles is evaluated only once and the results of the evaluation @@ -78,7 +49,7 @@ * * @author Radovan Semancik */ -@ContextConfiguration(locations = {"classpath:ctx-story-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-story-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public class TestNotoriousOrg extends AbstractNotoriousTest { @@ -128,7 +99,7 @@ protected void addNotoriousRole(OperationResult result) throws Exception { @Override protected void assertNotoriousParentOrgRefRelations(PrismObject userAfter, QName... relations) { - for (QName relation: relations) { + for (QName relation : relations) { assertHasOrg(userAfter, getNotoriousOid(), relation); } } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/TestSupernotoriousOrg.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/TestSupernotoriousOrg.java index 1b562cc5785..7f2b7bb278a 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/TestSupernotoriousOrg.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/TestSupernotoriousOrg.java @@ -6,37 +6,38 @@ */ package com.evolveum.midpoint.testing.story.notorious; -import com.evolveum.midpoint.prism.query.ObjectQuery; -import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; +import java.io.File; + 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 org.testng.annotations.Test; -import java.io.File; +import com.evolveum.midpoint.prism.query.ObjectQuery; +import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; /** * Testing bushy roles hierarchy. Especially reuse of the same role * in the rich role hierarchy. It looks like this: - * - * user - * | - * +------+------+-----+-----+-.... - * | | | | | - * v v v v v - * Ra1 Ra2 Ra3 Ra4 Ra5 - * | | | | | - * +------+------+-----+-----+ - * | - * v - * +--assignment--> supernotorious org - * | | - * | +------+------+-----+-----+-.... - * | | | | | | - * | v v v v v - * +-- Rb1 Rb2 Rb3 Rb4 Rb5 ---.. - * + *

+ * user + * | + * +------+------+-----+-----+-.... + * | | | | | + * v v v v v + * Ra1 Ra2 Ra3 Ra4 Ra5 + * | | | | | + * +------+------+-----+-----+ + * | + * v + * +--assignment--> supernotorious org + * | | + * | +------+------+-----+-----+-.... + * | | | | | | + * | v v v v v + * +-- Rb1 Rb2 Rb3 Rb4 Rb5 ---.. + *

* Naive mode of evaluation would imply cartesian product of all Rax and Rbx * combinations. That's painfully inefficient. Therefore make sure that the * notorious roles is evaluated only once and the results of the evaluation @@ -44,7 +45,7 @@ * * @author Radovan Semancik */ -@ContextConfiguration(locations = {"classpath:ctx-story-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-story-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) @Listeners({ com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class }) public class TestSupernotoriousOrg extends TestNotoriousOrg { @@ -65,22 +66,18 @@ protected File getNotoriousFile() { @Override protected void fillLevelBRole(RoleType roleType, int i) { super.fillLevelBRole(roleType, i); - roleType - .beginAssignment() + roleType.beginAssignment() .targetRef(getNotoriousOid(), getNotoriousType()) -// .focusType(RoleType.COMPLEX_TYPE) - .end(); + .end(); } @Test public void test010LevelBRolesSanity() throws Exception { - final String TEST_NAME = "test010LevelBRolesSanity"; - - ObjectQuery query = queryFor(RoleType.class).item(RoleType.F_ROLE_TYPE).eq(ROLE_LEVEL_B_ROLETYPE).build(); + ObjectQuery query = queryFor(RoleType.class) + .item(RoleType.F_ROLE_TYPE).eq(ROLE_LEVEL_B_ROLETYPE) + .build(); searchObjectsIterative(RoleType.class, query, - role -> { - assertRoleMembershipRef(role, getNotoriousOid()); - }, NUMBER_OF_LEVEL_B_ROLES); + role -> assertRoleMembershipRef(role, getNotoriousOid()), NUMBER_OF_LEVEL_B_ROLES); } @Override diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/perf/TestImport.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/perf/TestImport.java index 58978bd40cb..de0a4585da6 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/perf/TestImport.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/perf/TestImport.java @@ -131,7 +131,7 @@ public void test100RunImport() throws Exception { importObjectFromFile(TASK_IMPORT_FILE, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); long lastProfilingStarted = 0; long start = System.currentTimeMillis(); for (;;) { From 0100a4eb0be843c431b08bf0fe2a8d924521055b Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Sun, 1 Mar 2020 08:53:29 +0100 Subject: [PATCH 64/97] certification-impl: test compilation fixes around obtaining tasks --- .../certification/test/TestRoleInducementCertification.java | 2 +- .../midpoint/certification/test/TestSoDCertification.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestRoleInducementCertification.java b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestRoleInducementCertification.java index 40e383a3634..68960a14648 100644 --- a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestRoleInducementCertification.java +++ b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestRoleInducementCertification.java @@ -835,7 +835,7 @@ public void test320CheckAfterClose() throws Exception { login(userAdministrator.asPrismObject()); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); diff --git a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestSoDCertification.java b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestSoDCertification.java index 861dd83d113..0f5c0f26fdf 100644 --- a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestSoDCertification.java +++ b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestSoDCertification.java @@ -440,7 +440,7 @@ public void test210CheckAfterClose() throws Exception { login(userAdministrator.asPrismObject()); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); From 7e9a9aa78f71c53a93f083bf331d18f0e9a0dec8 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Sun, 1 Mar 2020 08:53:52 +0100 Subject: [PATCH 65/97] admin-gui/pom.xml: reportedly missing slf4j-api, fixed --- gui/admin-gui/pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gui/admin-gui/pom.xml b/gui/admin-gui/pom.xml index 805fd7e838c..67c6dbe3ac7 100644 --- a/gui/admin-gui/pom.xml +++ b/gui/admin-gui/pom.xml @@ -815,6 +815,11 @@ 4.1-SNAPSHOT test + + + org.slf4j + slf4j-api + From b392821c05e7bd0093651231fb800430d44fd6a0 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Sun, 1 Mar 2020 08:55:27 +0100 Subject: [PATCH 66/97] reintroduced field-clearing on Spring test classes, moved to superclass model-intest were indeed very slow, hopefully this helps (again) --- .../test/util/AbstractSpringTest.java | 48 +++++++++++++++++++ ...bstractConfiguredModelIntegrationTest.java | 44 ----------------- 2 files changed, 48 insertions(+), 44 deletions(-) diff --git a/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/AbstractSpringTest.java b/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/AbstractSpringTest.java index 49fe1a4def1..ab0fe6c306e 100644 --- a/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/AbstractSpringTest.java +++ b/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/AbstractSpringTest.java @@ -6,9 +6,13 @@ */ package com.evolveum.midpoint.test.util; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; + import org.jetbrains.annotations.NotNull; import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; import org.testng.ITestResult; +import org.testng.annotations.AfterClass; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; @@ -64,4 +68,48 @@ public String contextName() { public String getTestNameShort() { return TEST_CONTEXT_THREAD_LOCAL.get().getMethod().getMethodName(); } + + /** + * This method null all fields which are not static, final or primitive type. + *

+ * All this is just to make GC work during DirtiesContext after every test class, + * because test class instances are not GCed immediately. + * If they hold autowired fields like sessionFactory (for example + * through SqlRepositoryService impl), their memory footprint is getting big. + *

+ * Note that this does not work for components injected through constructor into + * final fields - if we need this cleanup, make the field non-final. + */ + @AfterClass(alwaysRun = true) + protected void clearClassFields() throws Exception { + logger.trace("Clearing all fields for test class {}", getClass().getName()); + clearClassFields(this, getClass()); + } + + private void clearClassFields(Object object, Class forClass) throws Exception { + if (forClass.getSuperclass() != null) { + clearClassFields(object, forClass.getSuperclass()); + } + + for (Field field : forClass.getDeclaredFields()) { + if (Modifier.isFinal(field.getModifiers()) + || Modifier.isStatic(field.getModifiers()) + || field.getType().isPrimitive()) { + continue; + } + + nullField(object, field); + } + } + + private void nullField(Object obj, Field field) throws Exception { + logger.info("Setting {} to null on {}.", field.getName(), obj.getClass().getSimpleName()); + boolean accessible = field.isAccessible(); +// boolean accessible = field.canAccess(obj); // TODO: after ditching JDK 8 + if (!accessible) { + field.setAccessible(true); + } + field.set(obj, null); + field.setAccessible(accessible); + } } diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/AbstractConfiguredModelIntegrationTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/AbstractConfiguredModelIntegrationTest.java index 7f8d12e1f24..222b2c92c08 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/AbstractConfiguredModelIntegrationTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/AbstractConfiguredModelIntegrationTest.java @@ -37,8 +37,6 @@ import java.io.File; import java.io.IOException; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.Collection; import java.util.Date; @@ -48,7 +46,6 @@ /** * @author semancik - * */ public class AbstractConfiguredModelIntegrationTest extends AbstractModelIntegrationTest { @@ -613,47 +610,6 @@ protected PrismObject getDefaultActor() { return userAdministrator; } - // TODO inttest: let's try it without this after 6 years -// @AfterClass(alwaysRun = true) - public void clearClassFields() throws Exception { - logger.trace("Clearing all fields for test class {}", getClass().getName()); - nullAllFields(this, getClass()); - } - - /** - * This method null all fields which are not static, final or primitive type. - * - * All this is just to make GC work during DirtiesContext after every test class, - * because memory consumption is too big. Test class instances can't be GCed - * immediately. If they holds autowired fields like sessionFactory (for example - * through SqlRepositoryService impl), their memory footprint is getting big. - */ - public void nullAllFields(Object object, Class forClass) throws Exception { - if (forClass.getSuperclass() != null) { - nullAllFields(object, forClass.getSuperclass()); - } - - for (Field field : forClass.getDeclaredFields()) { - if (Modifier.isFinal(field.getModifiers()) - || Modifier.isStatic(field.getModifiers()) - || field.getType().isPrimitive()) { - continue; - } - - nullField(object, field); - } - } - - private void nullField(Object obj, Field field) throws Exception { - logger.info("Setting {} to null on {}.", new Object[]{field.getName(), obj.getClass().getSimpleName()}); - boolean accessible = field.isAccessible(); - if (!accessible) { - field.setAccessible(true); - } - field.set(obj, null); - field.setAccessible(accessible); - } - protected PrismSchema getPiracySchema() { return prismContext.getSchemaRegistry().findSchemaByNamespace(NS_PIRACY); } From 788ef3d9171f9a5b07b61c44cdc751421949a231 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Sun, 1 Mar 2020 11:07:55 +0100 Subject: [PATCH 67/97] AbstractModelIntegrationTest: more createTask fixes in support methods --- .../test/AbstractModelIntegrationTest.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java b/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java index 5d81b70a551..6a2311c57e3 100644 --- a/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java +++ b/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java @@ -4742,7 +4742,7 @@ protected Task createTask(String operationName, MidPointPrincipal principal) { } protected void modifyRoleAddConstruction(String roleOid, long inducementId, String resourceOid) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = createPlainTask("modifyRoleAddConstruction"); + Task task = createTask("modifyRoleAddConstruction"); OperationResult result = task.getResult(); ConstructionType construction = new ConstructionType(); ObjectReferenceType resourceRedRef = new ObjectReferenceType(); @@ -4897,7 +4897,7 @@ protected AssignmentType findAssignmentByTargetRequired(PrismObject role = modelService.getObject(RoleType.class, roleOid, null, task, result); for (AssignmentType inducement : role.asObjectable().getInducement()) { @@ -4911,7 +4911,7 @@ protected AssignmentType findInducementByTarget(String roleOid, String targetOid protected void modifyRoleDeleteInducementTarget(String roleOid, String targetOid, ModelExecuteOptions options) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = createPlainTask("modifyRoleDeleteInducementTarget"); + Task task = createTask("modifyRoleDeleteInducementTarget"); OperationResult result = task.getResult(); AssignmentType inducement = findInducementByTarget(roleOid, targetOid); ObjectDelta roleDelta = @@ -5137,7 +5137,7 @@ protected void assertAllowRequestAssignmentItems( String userOid, String targetRoleOid, ItemPath... expectedAllowedItemPaths) throws SchemaException, SecurityViolationException, CommunicationException, ObjectNotFoundException, ConfigurationException, ExpressionEvaluationException { - Task task = createPlainTask("assertAllowRequestAssignmentItems"); + Task task = createTask("assertAllowRequestAssignmentItems"); OperationResult result = task.getResult(); assertAllowRequestAssignmentItems(userOid, targetRoleOid, task, result, expectedAllowedItemPaths); assertSuccess(result); @@ -5226,7 +5226,10 @@ protected void assertDummyPasswordNotEmpty(String instance, String userId) throw } } - protected void reconcileUser(String oid, Task task, OperationResult result) throws CommunicationException, ObjectAlreadyExistsException, ExpressionEvaluationException, PolicyViolationException, SchemaException, SecurityViolationException, ConfigurationException, ObjectNotFoundException { + protected void reconcileUser(String oid, Task task, OperationResult result) + throws SchemaException, CommunicationException, ObjectAlreadyExistsException, + ExpressionEvaluationException, PolicyViolationException, SecurityViolationException, + ConfigurationException, ObjectNotFoundException { reconcileUser(oid, null, task, result); } @@ -5272,7 +5275,7 @@ protected List getAuditRecords(int maxRecords, Task task, Oper protected List getObjectAuditRecords(String oid) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - Task task = createPlainTask("getObjectAuditRecords"); + Task task = createTask("getObjectAuditRecords"); OperationResult result = task.getResult(); Map params = new HashMap<>(); params.put("targetOid", oid); @@ -5347,7 +5350,7 @@ protected PrismObject getUserFromRepo(String oid, OperationResult resu // just guessing (good enough for testing) protected boolean isH2() { - Task task = createPlainTask("isH2"); + Task task = createTask("isH2"); RepositoryDiag diag = modelDiagnosticService.getRepositoryDiag(task, task.getResult()); return diag.isEmbedded() || "org.h2.Driver".equals(diag.getDriverShortName()); } @@ -5521,7 +5524,7 @@ protected void assertPasswordCompliesWithPolicy( PrismObject user, String passwordPolicyOid) throws EncryptionException, ObjectNotFoundException, ExpressionEvaluationException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException { - Task task = createPlainTask("assertPasswordCompliesWithPolicy"); + Task task = createTask("assertPasswordCompliesWithPolicy"); OperationResult result = task.getResult(); assertPasswordCompliesWithPolicy(user, passwordPolicyOid, task, result); assertSuccess(result); @@ -5590,7 +5593,7 @@ protected Consumer createShowTaskTreeConsumer(long period) { return task -> { try { if (lastTimeShown.get() + period < System.currentTimeMillis()) { - // TODO inttest: task. is missing in master, is it good? + // TODO inttest: task. (for result) is missing in master, is it good? dumpTaskTree(task.getOid(), task.getResult()); lastTimeShown.set(System.currentTimeMillis()); } From 3b667c17a90988a7ca1824723c74e62a3e517770 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Sun, 1 Mar 2020 11:08:38 +0100 Subject: [PATCH 68/97] model: removed unused testng-*.xml suite files in "model" root --- model/testng-integration.xml | 10 ---------- model/testng-unit.xml | 10 ---------- 2 files changed, 20 deletions(-) delete mode 100644 model/testng-integration.xml delete mode 100644 model/testng-unit.xml diff --git a/model/testng-integration.xml b/model/testng-integration.xml deleted file mode 100644 index 86d7187deb6..00000000000 --- a/model/testng-integration.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - diff --git a/model/testng-unit.xml b/model/testng-unit.xml deleted file mode 100644 index 136f8aa1e9b..00000000000 --- a/model/testng-unit.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - From 9eeff94d290fc57ce7de112c9cc2debcb0389048 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Sun, 1 Mar 2020 11:28:21 +0100 Subject: [PATCH 69/97] UnitTestMixin: added "given" and "expect" (=when+then combo) methods --- .../midpoint/tools/testng/UnitTestMixin.java | 43 ++++++++++++++++++- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/UnitTestMixin.java b/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/UnitTestMixin.java index e546a17deb2..6a045eedb17 100644 --- a/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/UnitTestMixin.java +++ b/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/UnitTestMixin.java @@ -59,6 +59,26 @@ default void displayDefaultTestFooter(ITestResult testResult) { logger().info(TEST_LOG_PREFIX + " FINISHED in " + testMsDuration + " ms" + TEST_LOG_SUFFIX); } + /** + * Displays "given" subsection header with test name. + * Even better, use {@link #given(String)} and provide human readable description. + */ + default void given() { + given(null); + } + + /** + * Displays "given" subsection header with test name and provided description (nullable). + */ + default void given(String description) { + String testName = getTestNameShort(); + if (description == null) { + description = ""; + } + System.out.println(TEST_OUT_SECTION_PREFIX + testName + ": GIVEN " + description + TEST_OUT_SECTION_SUFFIX); + logger().info(TEST_LOG_SECTION_PREFIX + testName + ": GIVEN " + description + TEST_LOG_SECTION_SUFFIX); + } + /** * Displays "when" subsection header with test name. * Even better, use {@link #when(String)} and provide human readable description. @@ -96,6 +116,25 @@ default void then(String description) { logger().info(TEST_LOG_SECTION_PREFIX + testName + ": THEN " + description); } - // TODO introduce "expect" as well? sometimes we use when/then combined section - // in such a case instead of "given - when/then" we should have "given - expect" + /** + * Displays "expect" subsection header with test name. + * Even better, use {@link #expect(String)} and provide human readable description. + */ + default void expect() { + expect(null); + } + + /** + * Displays "expect" subsection header with test name and provided description (nullable). + * This is for tests with simpler given-expect structure. + * In other words, if "when" and "then" can't be clearly separated, we want "expect". + */ + default void expect(String description) { + String testName = getTestNameShort(); + if (description == null) { + description = ""; + } + System.out.println(TEST_OUT_SECTION_PREFIX + testName + ": EXPECT " + description + TEST_OUT_SECTION_SUFFIX); + logger().info(TEST_LOG_SECTION_PREFIX + testName + ": EXPECT " + description + TEST_LOG_SECTION_SUFFIX); + } } From a35d70780b26f69de850f8fe77e039968772e2b9 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Sun, 1 Mar 2020 11:29:15 +0100 Subject: [PATCH 70/97] AbstractModelIntegrationTest: added createTask(principal) without name This uses context-name as the task operation name. --- .../midpoint/model/test/AbstractModelIntegrationTest.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java b/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java index 6a2311c57e3..d065c807589 100644 --- a/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java +++ b/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java @@ -4741,6 +4741,13 @@ protected Task createTask(String operationName, MidPointPrincipal principal) { return task; } + protected Task createTask(MidPointPrincipal principal) { + Task task = createPlainTask(); + task.setOwner(principal.getFocus().asPrismObject()); + task.setChannel(DEFAULT_CHANNEL); + return task; + } + protected void modifyRoleAddConstruction(String roleOid, long inducementId, String resourceOid) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { Task task = createTask("modifyRoleAddConstruction"); OperationResult result = task.getResult(); From f7a83ac201c1ebfee4625b887c0c554bb21d8f54 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Sun, 1 Mar 2020 13:22:39 +0100 Subject: [PATCH 71/97] AbstractModelIntegrationTest: fix of NPE on dummyAuditService DummyAuditService is not a managed component, so we can safely init it in constructor and then we don't have to check its nullity. NPE happened in TestLoggingConfiguration test that (for good reasons) didn't call super.initSystem(). --- .../midpoint/model/test/AbstractModelIntegrationTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java b/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java index d065c807589..216faf9d544 100644 --- a/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java +++ b/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java @@ -203,7 +203,7 @@ public abstract class AbstractModelIntegrationTest extends AbstractIntegrationTe protected boolean verbose = false; public AbstractModelIntegrationTest() { - super(); + dummyAuditService = DummyAuditService.getInstance(); } @Override @@ -211,7 +211,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti logger.trace("initSystem"); dummyResourceCollection = new DummyResourceCollection(modelService); startResources(); - dummyAuditService = DummyAuditService.getInstance(); InternalsConfig.reset(); InternalsConfig.setAvoidLoggingChange(isAvoidLoggingChange()); // Make sure the checks are turned on From d784836d8109fe99aeac620881342a02a8d57e95 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Sun, 1 Mar 2020 13:23:20 +0100 Subject: [PATCH 72/97] model-intest: more fixes and cleanup in test classes --- .../AbstractDirectManualResourceTest.java | 18 +- .../AbstractGroupingManualResourceTest.java | 2 +- .../manual/AbstractManualResourceTest.java | 2 +- .../model/intest/manual/TestSemiManual.java | 2 +- .../intest/manual/TestSemiManualDisable.java | 30 +- .../model/intest/multi/TestMultiResource.java | 454 ++++------ .../intest/password/AbstractPasswordTest.java | 813 +++++++----------- .../intest/password/TestPasswordDefault.java | 8 +- .../password/TestPasswordDefaultHashing.java | 27 +- 9 files changed, 481 insertions(+), 875 deletions(-) diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractDirectManualResourceTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractDirectManualResourceTest.java index f381bcdffc4..de7092e860d 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractDirectManualResourceTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractDirectManualResourceTest.java @@ -31,8 +31,6 @@ import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.asserter.ShadowAsserter; import com.evolveum.midpoint.test.asserter.UserAsserter; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType; import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultStatusType; @@ -100,12 +98,8 @@ public abstract class AbstractDirectManualResourceTest extends AbstractManualRes protected static final File ROLE_TWO_SEMI_MANUAL_DISABLE_SLOW_PROPOSED_FILE = new File(TEST_DIR, "role-two-semi-manual-disable-slow-proposed.xml"); protected static final String ROLE_TWO_SEMI_MANUAL_DISABLE_SLOW_PROPOSED_OID = "5ecd6fa6-a200-11e7-b0cb-af5e1792d327"; - private static final Trace LOGGER = TraceManager.getTrace(AbstractDirectManualResourceTest.class); - private XMLGregorianCalendar roleTwoValidFromTimestamp; - protected String accountBarbossaOid; - @Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { super.initSystem(initTask, initResult); @@ -1448,12 +1442,10 @@ protected void assertDeprovisionedTimedOutUser(UserAsserter userAsserter, */ @Test public void test349CleanUp() throws Exception { - final String TEST_NAME = "test349CleanUp"; - - cleanupUser(TEST_NAME, userWillOid, USER_WILL_NAME, accountWillOid); + cleanupUser(userWillOid, USER_WILL_NAME, accountWillOid); } - protected void cleanupUser(final String TEST_NAME, String userOid, String username, String accountOid) throws Exception { + protected void cleanupUser(String userOid, String username, String accountOid) throws Exception { // nothing to do here } @@ -1816,11 +1808,10 @@ public void test518RecomputeWillAfter180min() throws Exception { */ @Test public void test519CleanUp() throws Exception { - final String TEST_NAME = "test519CleanUp"; Task task = getTestTask(); OperationResult result = task.getResult(); - cleanupUser(TEST_NAME, userWillOid, USER_WILL_NAME, accountWillOid); + cleanupUser(userWillOid, USER_WILL_NAME, accountWillOid); // Make sure that all pending operations are expired clockForward("PT1H"); @@ -2102,11 +2093,10 @@ protected void assertTest528Deltas(PrismObject shadowRepo, Operation */ @Test public void test529CleanUp() throws Exception { - final String TEST_NAME = "test529CleanUp"; Task task = getTestTask(); OperationResult result = task.getResult(); - cleanupUser(TEST_NAME, userWillOid, USER_WILL_NAME, accountWillOid); + cleanupUser(userWillOid, USER_WILL_NAME, accountWillOid); // Make sure that all pending operations are expired clockForward("PT3H"); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractGroupingManualResourceTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractGroupingManualResourceTest.java index 476c278df47..7705244dbb7 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractGroupingManualResourceTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractGroupingManualResourceTest.java @@ -941,7 +941,7 @@ public void test330UpdateBackingStoreAndRecomputeWill() throws Exception { public void test349CleanUp() throws Exception { final String TEST_NAME = "test349CleanUp"; - cleanupUser(TEST_NAME, userWillOid, USER_WILL_NAME, accountWillOid); + cleanupUser(userWillOid, USER_WILL_NAME, accountWillOid); } // TODO: test400: create -> modify -> propagation diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractManualResourceTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractManualResourceTest.java index 6e6d0062b94..d28acdaf035 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractManualResourceTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractManualResourceTest.java @@ -2320,7 +2320,7 @@ private void assertManual(AbstractWriteCapabilityType cap) { assertEquals("Manual flag not set in capability "+cap, Boolean.TRUE, cap.isManual()); } - protected void cleanupUser(final String TEST_NAME, String userOid, String username, String accountOid) throws Exception { + protected void cleanupUser(String userOid, String username, String accountOid) throws Exception { // nothing to do here } diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManual.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManual.java index eb098f3af39..4b644fa1207 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManual.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManual.java @@ -318,7 +318,7 @@ public void test717RecomputeJackAfter130min() throws Exception { public void test719CleanUp() throws Exception { final String TEST_NAME = "test719CleanUp"; - cleanupUser(TEST_NAME, USER_JACK_OID, USER_JACK_USERNAME, accountJackOid); + cleanupUser(USER_JACK_OID, USER_JACK_USERNAME, accountJackOid); } @Override diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualDisable.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualDisable.java index 9f7de901187..f3f9117599b 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualDisable.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualDisable.java @@ -24,8 +24,6 @@ import com.evolveum.midpoint.test.asserter.ShadowAsserter; import com.evolveum.midpoint.test.asserter.UserAsserter; import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.PendingOperationExecutionStatusType; @@ -43,8 +41,6 @@ @Listeners({ com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class }) public class TestSemiManualDisable extends TestSemiManual { - private static final Trace LOGGER = TraceManager.getTrace(TestSemiManualDisable.class); - @Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { super.initSystem(initTask, initResult); @@ -150,9 +146,8 @@ protected void assertWillUnassignPendingOperationCompleted(ShadowAsserter } @Override - protected void cleanupUser(final String TEST_NAME, String userOid, String username, String accountOid) throws Exception { - - Task task = getTestTask(); + protected void cleanupUser(String userOid, String username, String accountOid) throws Exception { + Task task = createTask("cleanupUser"); OperationResult result = task.getResult(); backingStore.deleteAccount(username); @@ -175,7 +170,6 @@ protected void cleanupUser(final String TEST_NAME, String userOid, String userna @Test @Override public void test416PhoenixAccountUnassignCloseCase() throws Exception { - final String TEST_NAME = "test416PhoenixAccountUnassignCloseCase"; // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -183,22 +177,22 @@ public void test416PhoenixAccountUnassignCloseCase() throws Exception { closeCase(phoenixLastCaseOid); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_PHOENIX_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); // Make sure the operation will be picked up by propagation task clockForward("PT3M"); // WHEN - when(TEST_NAME); + when(); runPropagation(); // THEN - then(TEST_NAME); + then(); PrismObject userAfter = getUser(USER_PHOENIX_OID); display("User after", userAfter); @@ -220,28 +214,27 @@ public void test416PhoenixAccountUnassignCloseCase() throws Exception { @Test @Override public void test418AssignPhoenixAccountAgain() throws Exception { - final String TEST_NAME = "test418AssignPhoenixAccountAgain"; // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_PHOENIX_OID, getResourceOid(), null, task, result); // THEN - then(TEST_NAME); + then(); phoenixLastCaseOid = assertInProgress(result); // Make sure the operation will be picked up by propagation task clockForward("PT3M"); // WHEN - when(TEST_NAME); + when(); runPropagation(); // THEN - then(TEST_NAME); + then(); PrismObject userAfter = getUser(USER_PHOENIX_OID); display("User after", userAfter); @@ -296,9 +289,6 @@ protected void assertTest526Deltas(PrismObject shadowRepo, Operation protected void assertTest528Deltas(PrismObject shadowRepo, OperationResult result) { assertPendingOperationDeltas(shadowRepo, 3); - ObjectDeltaType deltaModify = null; - ObjectDeltaType deltaAdd = null; - ObjectDeltaType deltaDelete = null; for (PendingOperationType pendingOperation: shadowRepo.asObjectable().getPendingOperation()) { assertEquals("Wrong status in pending delta", OperationResultStatusType.SUCCESS, pendingOperation.getResultStatus()); } diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiResource.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiResource.java index 103ab7f653d..8811e89d649 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiResource.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiResource.java @@ -24,7 +24,6 @@ import com.evolveum.icf.dummy.resource.ConflictException; import com.evolveum.icf.dummy.resource.SchemaViolationException; import com.evolveum.midpoint.model.api.ModelExecuteOptions; -import com.evolveum.midpoint.model.intest.password.AbstractPasswordTest; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.schema.ObjectDeltaOperation; @@ -176,41 +175,36 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test110JackAssignRoleDummiesFull() throws Exception { - final String TEST_NAME = "test110JackAssignRoleDummiesFull"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - jackAssignRoleDummies(TEST_NAME); + jackAssignRoleDummies(); } @Test public void test113JackRenameFull() throws Exception { - final String TEST_NAME = "test113JackRenameFull"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - jackRename(TEST_NAME); + jackRename(); } @Test public void test114JackUnAssignRoleDummiesFull() throws Exception { - final String TEST_NAME = "test114JackUnAssignRoleDummiesFull"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - jackUnAssignRoleDummies(TEST_NAME); + jackUnAssignRoleDummies(); } // TODO: lavender resource with failure @Test public void test115JackAssignRoleDummiesFullErrorIvory() throws Exception { - final String TEST_NAME = "test115JackAssignRoleDummiesFullErrorIvory"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); getDummyResource().setAddBreakMode(BreakMode.NETWORK); - jackAssignRoleDummiesError(TEST_NAME, ROLE_DUMMIES_IVORY_OID, RESOURCE_DUMMY_IVORY_NAME, true); + jackAssignRoleDummiesError(ROLE_DUMMIES_IVORY_OID, RESOURCE_DUMMY_IVORY_NAME, true); } @Test public void test116JackUnAssignRoleDummiesFullErrorIvory() throws Exception { - final String TEST_NAME = "test116JackUnAssignRoleDummiesFullErrorIvory"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); getDummyResource().setAddBreakMode(BreakMode.NETWORK); - jackUnassignRoleDummiesError(TEST_NAME, ROLE_DUMMIES_IVORY_OID, RESOURCE_DUMMY_IVORY_OID); + jackUnassignRoleDummiesError(ROLE_DUMMIES_IVORY_OID, RESOURCE_DUMMY_IVORY_OID); } /** @@ -220,24 +214,20 @@ public void test116JackUnAssignRoleDummiesFullErrorIvory() throws Exception { */ @Test public void test117JackAssignRoleDummiesFullErrorBeige() throws Exception { - final String TEST_NAME = "test117JackAssignRoleDummiesFullErrorBeige"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); getDummyResource().setAddBreakMode(BreakMode.NETWORK); - jackAssignRoleDummiesError(TEST_NAME, ROLE_DUMMIES_BEIGE_OID, RESOURCE_DUMMY_BEIGE_NAME, false); + jackAssignRoleDummiesError(ROLE_DUMMIES_BEIGE_OID, RESOURCE_DUMMY_BEIGE_NAME, false); } @Test public void test118JackUnAssignRoleDummiesFullErrorBeige() throws Exception { - final String TEST_NAME = "test118JackUnAssignRoleDummiesFullErrorBeige"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); getDummyResource().setAddBreakMode(BreakMode.NETWORK); - jackUnassignRoleDummiesError(TEST_NAME, ROLE_DUMMIES_BEIGE_OID, null); + jackUnassignRoleDummiesError(ROLE_DUMMIES_BEIGE_OID, null); } @Test public void test120JackAssignRoleDummiesRelative() throws Exception { - final String TEST_NAME = "test120JackAssignRoleDummiesRelative"; - getDummyResource().resetBreakMode(); // Clean up user Task task = getTestTask(); @@ -245,7 +235,7 @@ public void test120JackAssignRoleDummiesRelative() throws Exception { modifyUserReplace(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - jackAssignRoleDummies(TEST_NAME); + jackAssignRoleDummies(); } /** @@ -254,7 +244,6 @@ public void test120JackAssignRoleDummiesRelative() throws Exception { */ @Test public void test121JackTryDeleteAccount() throws Exception { - final String TEST_NAME = "test121JackTryDeleteAccount"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); getDummyResource().resetBreakMode(); @@ -281,16 +270,14 @@ public void test121JackTryDeleteAccount() throws Exception { @Test public void test123JackRenameRelative() throws Exception { - final String TEST_NAME = "test123JackRenameRelative"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - jackRename(TEST_NAME); + jackRename(); } @Test public void test129JackUnAssignRoleDummiesRelative() throws Exception { - final String TEST_NAME = "test129JackUnAssignRoleDummiesRelative"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - jackUnAssignRoleDummies(TEST_NAME); + jackUnAssignRoleDummies(); } /** @@ -298,8 +285,6 @@ public void test129JackUnAssignRoleDummiesRelative() throws Exception { */ @Test public void test200JackAssignDummyIvory() throws Exception { - final String TEST_NAME = "test200JackAssignDummyIvory"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -332,8 +317,6 @@ public void test200JackAssignDummyIvory() throws Exception { */ @Test public void test209JackUnAssignDummyIvory() throws Exception { - final String TEST_NAME = "test209JackUnAssignDummyIvory"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -364,8 +347,6 @@ public void test209JackUnAssignDummyIvory() throws Exception { */ @Test public void test210JackAssignDummyBeige() throws Exception { - final String TEST_NAME = "test210JackAssignDummyBeige"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -375,11 +356,11 @@ public void test210JackAssignDummyBeige() throws Exception { modifyUserReplace(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_BEIGE_OID, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -401,8 +382,6 @@ public void test210JackAssignDummyBeige() throws Exception { */ @Test public void test219JackUnAssignDummyBeige() throws Exception { - final String TEST_NAME = "test219JackUnAssignDummyBeige"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -412,11 +391,11 @@ public void test219JackUnAssignDummyBeige() throws Exception { modifyUserReplace(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result); // WHEN - when(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_BEIGE_OID, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -435,8 +414,6 @@ public void test219JackUnAssignDummyBeige() throws Exception { */ @Test public void test220JackAssignDummyBeigeAndDefault() throws Exception { - final String TEST_NAME = "test220JackAssignDummyBeigeAndDefault"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -449,11 +426,11 @@ public void test220JackAssignDummyBeigeAndDefault() throws Exception { userDelta.addModification(createAssignmentModification(RESOURCE_DUMMY_OID, ShadowKindType.ACCOUNT, null, true)); // WHEN - when(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userJack = getUser(USER_JACK_OID); @@ -473,18 +450,16 @@ public void test220JackAssignDummyBeigeAndDefault() throws Exception { */ @Test public void test221JackRecompute() throws Exception { - final String TEST_NAME = "test221JackRecompute"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userJack = getUser(USER_JACK_OID); @@ -506,8 +481,6 @@ public void test221JackRecompute() throws Exception { */ @Test public void test223JackKillDefaultDummyAccounAndRecompute() throws Exception { - final String TEST_NAME = "test223JackKillDefaultDummyAccounAndRecompute"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -516,11 +489,11 @@ public void test223JackKillDefaultDummyAccounAndRecompute() throws Exception { display("dummy resource before", getDummyResource()); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -544,8 +517,6 @@ public void test223JackKillDefaultDummyAccounAndRecompute() throws Exception { */ @Test public void test224JackKillBeigeAccounAndRecompute() throws Exception { - final String TEST_NAME = "test224JackKillBeigeAccounAndRecompute"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -554,11 +525,11 @@ public void test224JackKillBeigeAccounAndRecompute() throws Exception { display("beige dummy resource before", getDummyResource(RESOURCE_DUMMY_BEIGE_NAME)); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, ModelExecuteOptions.createReconcile(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -602,8 +573,6 @@ public void test224JackKillBeigeAccounAndRecompute() throws Exception { @Test public void test225ForceDeleteDeadShadow() throws Exception { - final String TEST_NAME = "test225ForceDeleteDeadShadow"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -618,11 +587,11 @@ public void test225ForceDeleteDeadShadow() throws Exception { .getOid(); // WHEN - when(TEST_NAME); + when(); forceDeleteObject(ShadowType.class, deadBeigeShadowOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertNoShadow(deadBeigeShadowOid); @@ -656,8 +625,6 @@ public void test225ForceDeleteDeadShadow() throws Exception { */ @Test public void test226JackKillBothAccountsAndRecompute() throws Exception { - final String TEST_NAME = "test226JackKillBothAccountsAndRecompute"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -673,11 +640,11 @@ public void test226JackKillBothAccountsAndRecompute() throws Exception { display("beige dummy resource before", getDummyResource(RESOURCE_DUMMY_BEIGE_NAME)); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, ModelExecuteOptions.createReconcile(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -733,22 +700,20 @@ public void test226JackKillBothAccountsAndRecompute() throws Exception { */ @Test public void test227ModifyUserJackDefaultDummyBrokenSchemaViolation() throws Exception { - final String TEST_NAME = "test227ModifyUserJackDefaultDummyBrokenSchemaViolation"; - // GIVEN - Task task = taskManager.createTaskInstance(TestMultiResource.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); getDummyResource().setModifyBreakMode(BreakMode.SCHEMA); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, createPolyString("Cpt. Jack Sparrow")); // THEN - then(TEST_NAME); + then(); assertPartialError(result); assertUserAfter(USER_JACK_OID) @@ -800,21 +765,19 @@ public void test227ModifyUserJackDefaultDummyBrokenSchemaViolation() throws Exce */ @Test public void test228ModifyUserJackDefaultDummyNoError() throws Exception { - final String TEST_NAME = "test228ModifyUserJackDefaultDummyNoError"; - // GIVEN - Task task = taskManager.createTaskInstance(TestMultiResource.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); getDummyResource().resetBreakMode(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, createPolyString(USER_JACK_FULL_NAME)); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -862,8 +825,6 @@ public void test228ModifyUserJackDefaultDummyNoError() throws Exception { */ @Test public void test229JackUnassignDummyBeigeAndDefault() throws Exception { - final String TEST_NAME = "test229JackUnassignDummyBeigeAndDefault"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -874,11 +835,11 @@ public void test229JackUnassignDummyBeigeAndDefault() throws Exception { userDelta.addModification(createAssignmentModification(RESOURCE_DUMMY_OID, ShadowKindType.ACCOUNT, null, false)); // WHEN - when(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); String deadShadowOid = assertUserAfter(USER_JACK_OID) @@ -898,7 +859,7 @@ public void test229JackUnassignDummyBeigeAndDefault() throws Exception { assertNoDummyAccount(RESOURCE_DUMMY_BEIGE_NAME, ACCOUNT_JACK_DUMMY_USERNAME); // CLEANUP - make sure we have clean slate for next tests - displayCleanup(TEST_NAME); + displayCleanup(contextName()); forceDeleteShadow(deadShadowOid); assertNoShadow(deadShadowOid); @@ -912,8 +873,6 @@ public void test229JackUnassignDummyBeigeAndDefault() throws Exception { */ @Test public void test250JackAssignDummyLavender() throws Exception { - final String TEST_NAME = "test250JackAssignDummyLavender"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -948,18 +907,17 @@ public void test250JackAssignDummyLavender() throws Exception { * The "dummies" role assigns two dummy resources that are in a dependency. The value of DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME is propagated from one * resource through the user to the other resource. If dependency does not work then no value is propagated. */ - public void jackAssignRoleDummies(final String TEST_NAME) throws Exception { - - Task task = getTestTask(); + public void jackAssignRoleDummies() throws Exception { + Task task = createTask("jackAssignRoleDummies"); OperationResult result = task.getResult(); clearJackOrganizationalUnit(task, result); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_DUMMIES_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -1002,28 +960,28 @@ public void jackAssignRoleDummies(final String TEST_NAME) throws Exception { .assertAttribute(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "The crew of The Lost Souls"); } - public void jackRename(final String TEST_NAME) throws Exception { + public void jackRename() throws Exception { Task task = getTestTask(); OperationResult result = task.getResult(); - jackRename(TEST_NAME, "jackie", "Jackie Sparrow", task, result); - jackRename(TEST_NAME, USER_JACK_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, task, result); + jackRename("jackie", "Jackie Sparrow", task, result); + jackRename(USER_JACK_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, task, result); } - public void jackRename(final String TEST_NAME, String toName, String toFullName, Task task, OperationResult result) throws Exception { - + public void jackRename(String toName, String toFullName, Task task, OperationResult result) + throws Exception { ObjectDelta objectDelta = createModifyUserReplaceDelta(USER_JACK_OID, UserType.F_NAME, PrismTestUtil.createPolyString(toName)); objectDelta.addModificationReplaceProperty(UserType.F_FULL_NAME, PrismTestUtil.createPolyString(toFullName)); Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1059,21 +1017,20 @@ public void jackRename(final String TEST_NAME, String toName, String toFullName, assertDummyAccountAttribute(RESOURCE_DUMMY_BEIGE_NAME, toName, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "The crew of The Lost Souls"); } - public void jackUnAssignRoleDummies(final String TEST_NAME) throws Exception { - + public void jackUnAssignRoleDummies() throws Exception { Task task = getTestTask(); OperationResult result = task.getResult(); List linkOidsBefore = assertUserBefore(USER_JACK_OID) - .links() + .links() .getOids(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_DUMMIES_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -1096,23 +1053,23 @@ public void jackUnAssignRoleDummies(final String TEST_NAME) throws Exception { * The "dummies" role assigns two dummy resources that are in a dependency. The value of DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME is propagated from one * resource through the user to the other resource. If dependency does not work then no value is propagated. */ - public void jackAssignRoleDummiesError(final String TEST_NAME, String roleOid, String dummyResourceName, - boolean expectAccount) throws Exception { + public void jackAssignRoleDummiesError( + String roleOid, String dummyResourceName, boolean expectAccount) throws Exception { Task task = getTestTask(); OperationResult result = task.getResult(); clearJackOrganizationalUnit(task, result); assertUserBefore(USER_JACK_OID) - .assertAssignments(0) - .assertLinks(0); + .assertAssignments(0) + .assertLinks(0); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, roleOid, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); display(result); TestUtil.assertResultStatus(result, OperationResultStatus.IN_PROGRESS); @@ -1140,16 +1097,17 @@ private void clearJackOrganizationalUnit(Task task, OperationResult result) thro modifyUserReplace(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result); } - public void jackUnassignRoleDummiesError(final String TEST_NAME, String roleOid, String otherResourceOid) throws Exception { + public void jackUnassignRoleDummiesError( + String roleOid, String otherResourceOid) throws Exception { Task task = getTestTask(); OperationResult result = task.getResult(); UserAsserter userBeforeAsserter = assertUserBefore(USER_JACK_OID); String dummyShadowOid = userBeforeAsserter - .links() + .links() .by() - .resourceOid(RESOURCE_DUMMY_OID) + .resourceOid(RESOURCE_DUMMY_OID) .find() .resolveTarget() .assertConception() @@ -1166,11 +1124,11 @@ public void jackUnassignRoleDummiesError(final String TEST_NAME, String roleOid, } // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, roleOid, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); display(result); // there is a failure while reading dummy account - it was not created @@ -1215,7 +1173,6 @@ public void jackUnassignRoleDummiesError(final String TEST_NAME, String roleOid, @Test public void test300AddAndAssignRelative() throws Exception { - final String TEST_NAME = "test300AddAndAssignRelative"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Task task = getTestTask(); @@ -1243,11 +1200,11 @@ public void test300AddAndAssignRelative() throws Exception { assertDefaultDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_BLUE_OID, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1274,18 +1231,17 @@ public void test300AddAndAssignRelative() throws Exception { @Test public void test310AddedAccountAndUnassignRelative() throws Exception { - final String TEST_NAME = "test310AddedAccountAndUnassignRelative"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_BLUE_OID, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1314,18 +1270,17 @@ public void test310AddedAccountAndUnassignRelative() throws Exception { */ @Test public void test319UnassignDummyRelative() throws Exception { - final String TEST_NAME = "test319UnassignDummyRelative"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1349,7 +1304,6 @@ public void test319UnassignDummyRelative() throws Exception { */ @Test public void test350AddAccountLavender() throws Exception { - final String TEST_NAME = "test350AddAccountLavender"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); Task task = getTestTask(); @@ -1359,7 +1313,7 @@ public void test350AddAccountLavender() throws Exception { // WHEN try { - when(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); AssertJUnit.fail("Unexpected success"); @@ -1369,7 +1323,7 @@ public void test350AddAccountLavender() throws Exception { } // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertFailure(result); @@ -1379,7 +1333,6 @@ public void test350AddAccountLavender() throws Exception { @Test public void test352AddAccountIvory() throws Exception { - final String TEST_NAME = "test352AddAccountIvory"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); Task task = getTestTask(); @@ -1388,11 +1341,11 @@ public void test352AddAccountIvory() throws Exception { ObjectDelta userDelta = createModifyUserAddDummyAccount(USER_JACK_OID, RESOURCE_DUMMY_IVORY_NAME); // WHEN - when(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1402,7 +1355,6 @@ public void test352AddAccountIvory() throws Exception { @Test public void test354AddAccountBeige() throws Exception { - final String TEST_NAME = "test354AddAccountBeige"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); Task task = getTestTask(); @@ -1411,11 +1363,11 @@ public void test354AddAccountBeige() throws Exception { ObjectDelta userDelta = createModifyUserAddDummyAccount(USER_JACK_OID, RESOURCE_DUMMY_BEIGE_NAME); // WHEN - when(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1425,7 +1377,6 @@ public void test354AddAccountBeige() throws Exception { @Test public void test360AddAccountDummy() throws Exception { - final String TEST_NAME = "test360AddAccountDummy"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); Task task = getTestTask(); @@ -1434,11 +1385,11 @@ public void test360AddAccountDummy() throws Exception { ObjectDelta userDelta = createModifyUserAddAccount(USER_JACK_OID, getDummyResourceObject()); // WHEN - when(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1451,7 +1402,6 @@ public void test360AddAccountDummy() throws Exception { */ @Test public void test362AddAccountLavender() throws Exception { - final String TEST_NAME = "test362AddAccountLavender"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); Task task = getTestTask(); @@ -1460,11 +1410,11 @@ public void test362AddAccountLavender() throws Exception { ObjectDelta userDelta = createModifyUserAddDummyAccount(USER_JACK_OID, RESOURCE_DUMMY_LAVENDER_NAME); // WHEN - when(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1477,7 +1427,6 @@ public void test362AddAccountLavender() throws Exception { */ @Test public void test370DeleteAccountDummy() throws Exception { - final String TEST_NAME = "test370DeleteAccountDummy"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); Task task = getTestTask(); @@ -1487,7 +1436,7 @@ public void test370DeleteAccountDummy() throws Exception { // WHEN try { - when(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); AssertJUnit.fail("Unexpected success"); @@ -1497,7 +1446,7 @@ public void test370DeleteAccountDummy() throws Exception { } // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertFailure(result); @@ -1513,7 +1462,6 @@ public void test370DeleteAccountDummy() throws Exception { */ @Test public void test372UnlinkAccountDummy() throws Exception { - final String TEST_NAME = "test372UnlinkAccountDummy"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); Task task = getTestTask(); @@ -1523,7 +1471,7 @@ public void test372UnlinkAccountDummy() throws Exception { // WHEN try { - when(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); AssertJUnit.fail("Unexpected success"); @@ -1533,7 +1481,7 @@ public void test372UnlinkAccountDummy() throws Exception { } // THEN - then(TEST_NAME); + then(); assertFailure(result); PrismObject user = getUser(USER_JACK_OID); @@ -1545,7 +1493,6 @@ public void test372UnlinkAccountDummy() throws Exception { @Test public void test374DeleteAccountLavender() throws Exception { - final String TEST_NAME = "test374DeleteAccountLavender"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); Task task = getTestTask(); @@ -1553,11 +1500,11 @@ public void test374DeleteAccountLavender() throws Exception { ObjectDelta userDelta = createModifyUserDeleteDummyAccount(USER_JACK_OID, RESOURCE_DUMMY_LAVENDER_NAME); - when(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject user = getUser(USER_JACK_OID); @@ -1573,7 +1520,6 @@ public void test374DeleteAccountLavender() throws Exception { */ @Test public void test376DeleteAccountDummy() throws Exception { - final String TEST_NAME = "test376DeleteAccountDummy"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); Task task = getTestTask(); @@ -1581,11 +1527,11 @@ public void test376DeleteAccountDummy() throws Exception { ObjectDelta userDelta = createModifyUserDeleteAccount(USER_JACK_OID, getDummyResourceObject()); - when(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertNoDummyAccount(RESOURCE_DUMMY_LAVENDER_NAME, ACCOUNT_JACK_DUMMY_USERNAME); @@ -1598,7 +1544,6 @@ public void test376DeleteAccountDummy() throws Exception { */ @Test public void test378DeleteAccountBeige() throws Exception { - final String TEST_NAME = "test378DeleteAccountBeige"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); Task task = getTestTask(); @@ -1606,11 +1551,11 @@ public void test378DeleteAccountBeige() throws Exception { ObjectDelta userDelta = createModifyUserDeleteDummyAccount(USER_JACK_OID, RESOURCE_DUMMY_BEIGE_NAME); - when(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertNoDummyAccount(RESOURCE_DUMMY_LAVENDER_NAME, ACCOUNT_JACK_DUMMY_USERNAME); @@ -1624,7 +1569,6 @@ public void test378DeleteAccountBeige() throws Exception { */ @Test public void test379DeleteAccountIvory() throws Exception { - final String TEST_NAME = "test379DeleteAccountIvory"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); Task task = getTestTask(); @@ -1632,11 +1576,11 @@ public void test379DeleteAccountIvory() throws Exception { ObjectDelta userDelta = createModifyUserDeleteDummyAccount(USER_JACK_OID, RESOURCE_DUMMY_IVORY_NAME); - when(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertNoDummyAccount(RESOURCE_DUMMY_LAVENDER_NAME, ACCOUNT_JACK_DUMMY_USERNAME); @@ -1651,7 +1595,6 @@ public void test379DeleteAccountIvory() throws Exception { */ @Test public void test380AddAccountPeru() throws Exception { - final String TEST_NAME = "test380AddAccountPeru"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); getDummyResource().resetBreakMode(); @@ -1664,11 +1607,11 @@ public void test380AddAccountPeru() throws Exception { ObjectDelta userDelta = createModifyUserAddDummyAccount(USER_JACK_OID, RESOURCE_DUMMY_PERU_NAME); // WHEN - when(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertDummyAccount(RESOURCE_DUMMY_PERU_NAME, ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true); @@ -1677,7 +1620,6 @@ public void test380AddAccountPeru() throws Exception { @Test public void test382AddAccountYellow() throws Exception { - final String TEST_NAME = "test382AddAccountYellow"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); Task task = getTestTask(); @@ -1686,11 +1628,11 @@ public void test382AddAccountYellow() throws Exception { ObjectDelta userDelta = createModifyUserAddDummyAccount(USER_JACK_OID, RESOURCE_DUMMY_YELLOW_NAME); // WHEN - when(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userJack = getUser(USER_JACK_OID); @@ -1712,10 +1654,8 @@ public void test382AddAccountYellow() throws Exception { */ @Test public void test385ModifyUserJackPasswordA() throws Exception { - final String TEST_NAME = "test385ModifyUserJackPasswordA"; - // GIVEN - Task task = taskManager.createTaskInstance(AbstractPasswordTest.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -1744,7 +1684,6 @@ public void test385ModifyUserJackPasswordA() throws Exception { @Test public void test389DeleteAccountPeru() throws Exception { - final String TEST_NAME = "test389DeleteAccountPeru"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); Task task = getTestTask(); @@ -1752,11 +1691,11 @@ public void test389DeleteAccountPeru() throws Exception { ObjectDelta userDelta = createModifyUserDeleteDummyAccount(USER_JACK_OID, RESOURCE_DUMMY_PERU_NAME); - when(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertNoDummyAccount(RESOURCE_DUMMY_PERU_NAME, ACCOUNT_JACK_DUMMY_USERNAME); @@ -1770,8 +1709,6 @@ public void test389DeleteAccountPeru() throws Exception { @Test public void test400DavidAndGoliathAssignRole() throws Exception { - final String TEST_NAME = "test400DavidAndGoliathAssignRole"; - // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -1785,11 +1722,11 @@ public void test400DavidAndGoliathAssignRole() throws Exception { dummyAuditService.clear(); // WHEN - when(TEST_NAME); + when(); assignRole(userBefore.getOid(), ROLE_FIGHT_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertDavidGoliath(userBefore.getOid(), "stone", USER_WORLD_NAME, true, true, true); @@ -1855,8 +1792,6 @@ private void assertDavidGoliath(String userOid, String ou, String name, boolean @Test public void test401DavidAndGoliathModifyOu() throws Exception { - final String TEST_NAME = "test401DavidAndGoliathModifyOu"; - // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -1867,11 +1802,11 @@ public void test401DavidAndGoliathModifyOu() throws Exception { dummyAuditService.clear(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(userBefore.getOid(), UserType.F_ORGANIZATIONAL_UNIT, task, result, PrismTestUtil.createPolyString("rock")); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertDavidGoliath(userBefore.getOid(), "rock", USER_WORLD_NAME, true, true, true); @@ -1901,8 +1836,6 @@ public void test401DavidAndGoliathModifyOu() throws Exception { @Test public void test403DavidAndGoliathDisableUser() throws Exception { - final String TEST_NAME = "test403DavidAndGoliathDisableUser"; - // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -1914,11 +1847,11 @@ public void test403DavidAndGoliathDisableUser() throws Exception { dummyAuditService.clear(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(userBefore.getOid(), ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.DISABLED); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertDavidGoliath(userBefore.getOid(), "rock", USER_WORLD_NAME, false, false, false); @@ -1939,8 +1872,6 @@ public void test403DavidAndGoliathDisableUser() throws Exception { @Test public void test404DavidAndGoliathEnableUser() throws Exception { - final String TEST_NAME = "test404DavidAndGoliathEnableUser"; - // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -1951,11 +1882,11 @@ public void test404DavidAndGoliathEnableUser() throws Exception { dummyAuditService.clear(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(userBefore.getOid(), ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.ENABLED); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertDavidGoliath(userBefore.getOid(), "rock", USER_WORLD_NAME, true, true, true); @@ -1976,8 +1907,6 @@ public void test404DavidAndGoliathEnableUser() throws Exception { @Test public void test405DavidAndGoliathDisableAccountDavid() throws Exception { - final String TEST_NAME = "test405DavidAndGoliathDisableAccountDavid"; - // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -1990,11 +1919,11 @@ public void test405DavidAndGoliathDisableAccountDavid() throws Exception { dummyAuditService.clear(); // WHEN - when(TEST_NAME); + when(); modifyAccountShadowReplace(accountDavidOid, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.DISABLED); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertDavidGoliath(userBefore.getOid(), "rock", USER_WORLD_NAME, true, false, true); @@ -2015,8 +1944,6 @@ public void test405DavidAndGoliathDisableAccountDavid() throws Exception { */ @Test public void test406DavidAndGoliathRecompute() throws Exception { - final String TEST_NAME = "test406DavidAndGoliathRecompute"; - // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -2028,11 +1955,11 @@ public void test406DavidAndGoliathRecompute() throws Exception { dummyAuditService.clear(); // WHEN - when(TEST_NAME); + when(); recomputeUser(userBefore.getOid(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertDavidGoliath(userBefore.getOid(), "rock", USER_WORLD_NAME, true, false, true); @@ -2044,8 +1971,6 @@ public void test406DavidAndGoliathRecompute() throws Exception { @Test public void test408DavidAndGoliathEnableAccountDavid() throws Exception { - final String TEST_NAME = "test408DavidAndGoliathEnableAccountDavid"; - // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -2058,11 +1983,11 @@ public void test408DavidAndGoliathEnableAccountDavid() throws Exception { dummyAuditService.clear(); // WHEN - when(TEST_NAME); + when(); modifyAccountShadowReplace(accountDavidOid, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.ENABLED); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertDavidGoliath(userBefore.getOid(), "rock", USER_WORLD_NAME, true, true, true); @@ -2080,8 +2005,6 @@ public void test408DavidAndGoliathEnableAccountDavid() throws Exception { @Test public void test410DavidAndGoliathRename() throws Exception { - final String TEST_NAME = "test410DavidAndGoliathRename"; - // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -2092,11 +2015,11 @@ public void test410DavidAndGoliathRename() throws Exception { dummyAuditService.clear(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(userBefore.getOid(), UserType.F_NAME, task, result, PrismTestUtil.createPolyString(USER_FIELD_NAME)); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertDavidGoliath(userBefore.getOid(), "rock", USER_FIELD_NAME, true, true, true); @@ -2126,8 +2049,6 @@ public void test410DavidAndGoliathRename() throws Exception { @Test public void test419DavidAndGoliathUnassignRole() throws Exception { - final String TEST_NAME = "test419DavidAndGoliathUnassignRole"; - // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -2138,11 +2059,11 @@ public void test419DavidAndGoliathUnassignRole() throws Exception { dummyAuditService.clear(); // WHEN - when(TEST_NAME); + when(); unassignRole(userBefore.getOid(), ROLE_FIGHT_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result, 2); assertUserAfter(userBefore.getOid()) @@ -2169,8 +2090,6 @@ public void test419DavidAndGoliathUnassignRole() throws Exception { @Test public void test420DavidAndGoliathAssignRoleGoliathDown() throws Exception { - final String TEST_NAME = "test420DavidAndGoliathAssignRoleGoliathDown"; - // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -2196,11 +2115,11 @@ public void test420DavidAndGoliathAssignRoleGoliathDown() throws Exception { dummyAuditService.clear(); // WHEN - when(TEST_NAME); + when(); assignRole(userBefore.getOid(), ROLE_FIGHT_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); // explicitly recompute status here. It was computed before. // Inner errors are expected - but those should be pending on retry assertInProgress(result); @@ -2247,8 +2166,6 @@ public void test420DavidAndGoliathAssignRoleGoliathDown() throws Exception { */ @Test public void test421DavidAndGoliathAssignRoleGoliathUpRecompute() throws Exception { - final String TEST_NAME = "test421DavidAndGoliathAssignRoleGoliathUpRecompute"; - // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); getDummyResource(RESOURCE_DUMMY_GOLIATH_NAME).resetBreakMode(); @@ -2263,7 +2180,7 @@ public void test421DavidAndGoliathAssignRoleGoliathUpRecompute() throws Exceptio recomputeUser(userBefore.getOid(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(userBefore.getOid()) @@ -2301,8 +2218,6 @@ public void test421DavidAndGoliathAssignRoleGoliathUpRecompute() throws Exceptio */ @Test public void test422DavidAndGoliathAssignRoleGoliathUpRecompute() throws Exception { - final String TEST_NAME = "test422DavidAndGoliathAssignRoleGoliathUpRecompute"; - // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); getDummyResource(RESOURCE_DUMMY_GOLIATH_NAME).resetBreakMode(); @@ -2319,7 +2234,7 @@ public void test422DavidAndGoliathAssignRoleGoliathUpRecompute() throws Exceptio recomputeUser(userBefore.getOid(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(userBefore.getOid()) @@ -2354,8 +2269,6 @@ public void test422DavidAndGoliathAssignRoleGoliathUpRecompute() throws Exceptio */ @Test public void test423DavidAndGoliathAssignRoleGoliathUpReconcile() throws Exception { - final String TEST_NAME = "test423DavidAndGoliathAssignRoleGoliathUpReconcile"; - // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); getDummyResource(RESOURCE_DUMMY_GOLIATH_NAME).resetBreakMode(); @@ -2370,7 +2283,7 @@ public void test423DavidAndGoliathAssignRoleGoliathUpReconcile() throws Exceptio reconcileUser(userBefore.getOid(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertDavidGoliath(userBefore.getOid(), "rock", USER_FIELD_NAME, true, true, true); @@ -2383,8 +2296,6 @@ public void test423DavidAndGoliathAssignRoleGoliathUpReconcile() throws Exceptio @Test public void test428DavidAndGoliathUnassignRole() throws Exception { - final String TEST_NAME = "test428DavidAndGoliathUnassignRole"; - // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); getDummyResource(RESOURCE_DUMMY_GOLIATH_NAME).resetBreakMode(); @@ -2396,11 +2307,11 @@ public void test428DavidAndGoliathUnassignRole() throws Exception { PrismObject userBefore = findUserByUsername(USER_FIELD_NAME); // WHEN - when(TEST_NAME); + when(); unassignRole(userBefore.getOid(), ROLE_FIGHT_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); deadShadowOid = assertUserAfter(userBefore.getOid()) @@ -2434,8 +2345,6 @@ public void test428DavidAndGoliathUnassignRole() throws Exception { */ @Test public void test429ExpireDeadShadow() throws Exception { - final String TEST_NAME = "test429ExpireDeadShadow"; - // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); getDummyResource(RESOURCE_DUMMY_DAVID_NAME).resetBreakMode(); @@ -2450,11 +2359,11 @@ public void test429ExpireDeadShadow() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); reconcileUser(userBefore.getOid(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(userBefore.getOid()) @@ -2470,8 +2379,6 @@ public void test429ExpireDeadShadow() throws Exception { @Test public void test430DavidAndGoliathAssignRoleDavidDown() throws Exception { - final String TEST_NAME = "test430DavidAndGoliathAssignRoleDavidDown"; - // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -2495,11 +2402,11 @@ public void test430DavidAndGoliathAssignRoleDavidDown() throws Exception { dummyAuditService.clear(); // WHEN - when(TEST_NAME); + when(); assignRole(userBefore.getOid(), ROLE_FIGHT_OID, task, result); // THEN - then(TEST_NAME); + then(); // assertInProgress(result); assertUserAfter(userBefore.getOid()) @@ -2527,15 +2434,11 @@ public void test430DavidAndGoliathAssignRoleDavidDown() throws Exception { dummyAuditService.assertHasDelta(0,ChangeType.ADD, ShadowType.class); dummyAuditService.assertExecutionDeltas(1,1); dummyAuditService.assertHasDelta(1,ChangeType.MODIFY, UserType.class); -// dummyAuditService.assertExecutionDeltas(2,1); -// dummyAuditService.asserHasDelta(2,ChangeType.MODIFY, UserType.class); } @Test public void test440DavidAndGoliathAssignRoleAndCreateUserInOneStep() throws Exception { - final String TEST_NAME = "test440DavidAndGoliathAssignRoleAndCreateUserInOneStep"; - getDummyResource(RESOURCE_DUMMY_GOLIATH_NAME).resetBreakMode(); getDummyResource(RESOURCE_DUMMY_DAVID_NAME).resetBreakMode(); Task task = getTestTask(); @@ -2546,16 +2449,16 @@ public void test440DavidAndGoliathAssignRoleAndCreateUserInOneStep() throws Exce AssertJUnit.assertNotNull("User must not be null.", userWorld); - ObjectDelta delta = prismContext.deltaFactory().object().createDeleteDelta(UserType.class, userWorld.getOid() - ); + ObjectDelta delta = prismContext.deltaFactory().object() + .createDeleteDelta(UserType.class, userWorld.getOid()); Collection> deltas = new ArrayList<>(); deltas.add(delta); modelService.executeChanges(deltas, null, task, result); OperationResult deleteResult = new OperationResult("Check if user was deleted properly."); try { - repositoryService.getObject(UserType.class, userWorld.getOid(), null, deleteResult); - } catch (ObjectNotFoundException ex){ + repositoryService.getObject(UserType.class, userWorld.getOid(), null, deleteResult); + } catch (ObjectNotFoundException ex) { //this is OK, we deleted user before } @@ -2573,53 +2476,23 @@ public void test440DavidAndGoliathAssignRoleAndCreateUserInOneStep() throws Exce targetRef.getValue().setTargetType(RoleType.COMPLEX_TYPE); userBefore.findOrCreateContainer(UserType.F_ASSIGNMENT).add((PrismContainerValue) cval); - - -// userBefore.asObjectable().getAssignmentNew().add(cval.asContainerable()); - // this should add user and at the sate time assign the role fight..-> // the result of the operation have to be the same as in test 400 addObject(userBefore); dummyAuditService.clear(); - // WHEN - when(TEST_NAME); -// assignRole(userBefore.getOid(), ROLE_FIGHT_OID, task, result); - - // THEN - then(TEST_NAME); + expect(); assertSuccess(result); assertDavidGoliath(userBefore.getOid(), "stone", USER_WORLD_NAME, true, true, true); // Check audit display("Audit", dummyAuditService); -// dummyAuditService.assertRecords(4); -// dummyAuditService.assertSimpleRecordSanity(); -// dummyAuditService.assertAnyRequestDeltas(); -// dummyAuditService.assertExecutionDeltas(0,3); -// dummyAuditService.asserHasDelta(0,ChangeType.MODIFY, UserType.class); -// dummyAuditService.asserHasDelta(0,ChangeType.ADD, ShadowType.class); -// dummyAuditService.assertExecutionDeltas(1,3); -// dummyAuditService.asserHasDelta(1,ChangeType.MODIFY, UserType.class); -// dummyAuditService.asserHasDelta(1,ChangeType.ADD, ShadowType.class); -// dummyAuditService.assertExecutionDeltas(2,2); -// dummyAuditService.asserHasDelta(2,ChangeType.MODIFY, UserType.class); -// dummyAuditService.asserHasDelta(2,ChangeType.MODIFY, ShadowType.class); -// dummyAuditService.assertExecutionSuccess(); -// -// // Have a closer look at the last shadow modify delta. Make sure there are no phantom changes. -// ObjectDeltaOperation executionDeltaOp = dummyAuditService.getExecutionDelta(2, ChangeType.MODIFY, ShadowType.class); -// ObjectDelta executionDelta = executionDeltaOp.getObjectDelta(); -// display("Last execution delta", executionDelta); -// PrismAsserts.assertModifications("Phantom changes in last delta:", executionDelta, 2); } @Test public void test500PrepareJack() throws Exception { - final String TEST_NAME = "test500PrepareJack"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -2634,11 +2507,11 @@ public void test500PrepareJack() throws Exception { assertLinks(userBefore, 1); // WHEN - when(TEST_NAME); + when(); deleteUserAccount(USER_JACK_OID, RESOURCE_DUMMY_YELLOW_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2653,8 +2526,6 @@ public void test500PrepareJack() throws Exception { @Test public void test501JackAssignDummyDarkYellow() throws Exception { - final String TEST_NAME = "test501JackAssignDummyDarkYellow"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -2666,11 +2537,11 @@ public void test501JackAssignDummyDarkYellow() throws Exception { assertLinks(userBefore, 0); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_DARK_YELLOW_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2683,8 +2554,6 @@ public void test501JackAssignDummyDarkYellow() throws Exception { @Test public void test502JackAssignDummyDarkPeru() throws Exception { - final String TEST_NAME = "test502JackAssignDummyDarkPeru"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -2693,11 +2562,11 @@ public void test502JackAssignDummyDarkPeru() throws Exception { display("User before", userBefore); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_DARK_PERU_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2714,8 +2583,6 @@ public void test502JackAssignDummyDarkPeru() throws Exception { */ @Test public void test504JackUnassignDummyDarkPeru() throws Exception { - final String TEST_NAME = "test504JackUnassignDummyDarkPeru"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -2724,11 +2591,11 @@ public void test504JackUnassignDummyDarkPeru() throws Exception { display("User before", userBefore); // WHEN - when(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_DARK_PERU_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2742,8 +2609,6 @@ public void test504JackUnassignDummyDarkPeru() throws Exception { @Test public void test507JackUnassignDummyDarkYellow() throws Exception { - final String TEST_NAME = "test507JackUnassignDummyDarkYellow"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -2752,11 +2617,11 @@ public void test507JackUnassignDummyDarkYellow() throws Exception { display("User before", userBefore); // WHEN - when(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_DARK_YELLOW_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2770,8 +2635,6 @@ public void test507JackUnassignDummyDarkYellow() throws Exception { @Test public void test508JackDeleteDummyDarkYellowAccount() throws Exception { - final String TEST_NAME = "test508JackDeleteDummyDarkYellowAccount"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -2780,11 +2643,11 @@ public void test508JackDeleteDummyDarkYellowAccount() throws Exception { display("User before", userBefore); // WHEN - when(TEST_NAME); + when(); deleteUserAccount(USER_JACK_OID, RESOURCE_DUMMY_DARK_YELLOW_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2798,8 +2661,6 @@ public void test508JackDeleteDummyDarkYellowAccount() throws Exception { @Test public void test509JackDeleteDummyDarkPeruAccount() throws Exception { - final String TEST_NAME = "test509JackDeleteDummyDarkPeruAccount"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -2808,11 +2669,11 @@ public void test509JackDeleteDummyDarkPeruAccount() throws Exception { display("User before", userBefore); // WHEN - when(TEST_NAME); + when(); deleteUserAccount(USER_JACK_OID, RESOURCE_DUMMY_DARK_PERU_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2826,8 +2687,6 @@ public void test509JackDeleteDummyDarkPeruAccount() throws Exception { @Test public void test510JackAssignRoleDarkYellowPeru() throws Exception { - final String TEST_NAME = "test510JackAssignRoleDarkYellowPeru"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -2841,11 +2700,11 @@ public void test510JackAssignRoleDarkYellowPeru() throws Exception { assertAssignments(userBefore, 0); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_DARK_YELLOW_PERU_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2862,8 +2721,6 @@ public void test510JackAssignRoleDarkYellowPeru() throws Exception { */ @Test public void test519JackUnassignDarkRoleYellowPeru() throws Exception { - final String TEST_NAME = "test519JackUnassignDarkRoleYellowPeru"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -2872,11 +2729,11 @@ public void test519JackUnassignDarkRoleYellowPeru() throws Exception { display("User before", userBefore); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_DARK_YELLOW_PERU_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2890,8 +2747,6 @@ public void test519JackUnassignDarkRoleYellowPeru() throws Exception { @Test public void test520JackAssignRoleDarkYellowPeru() throws Exception { - final String TEST_NAME = "test520JackAssignRoleDarkYellowPeru"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -2905,11 +2760,11 @@ public void test520JackAssignRoleDarkYellowPeru() throws Exception { assertAssignments(userBefore, 0); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_DARK_YELLOW_PERU_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2926,8 +2781,6 @@ public void test520JackAssignRoleDarkYellowPeru() throws Exception { */ @Test public void test529JackUnassignRoleDarkYellowPeru() throws Exception { - final String TEST_NAME = "test529JackUnassignRoleDarkYellowPeru"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -2937,11 +2790,11 @@ public void test529JackUnassignRoleDarkYellowPeru() throws Exception { AssignmentType currentAssignment = findAssignmentByTargetRequired(userBefore, ROLE_DARK_YELLOW_PERU_OID); // WHEN - when(TEST_NAME); + when(); unassign(UserType.class, USER_JACK_OID, currentAssignment.getId(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2952,5 +2805,4 @@ public void test529JackUnassignRoleDarkYellowPeru() throws Exception { assertDummyAccount(RESOURCE_DUMMY_DARK_YELLOW_NAME, ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, false); assertDummyAccount(RESOURCE_DUMMY_DARK_PERU_NAME, ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, false); } - } diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/AbstractPasswordTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/AbstractPasswordTest.java index cc860a3a5b1..f6084f01349 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/AbstractPasswordTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/AbstractPasswordTest.java @@ -11,17 +11,8 @@ import java.io.File; import java.util.Collection; import java.util.List; - import javax.xml.datatype.XMLGregorianCalendar; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.test.DummyResourceContoller; -import com.evolveum.midpoint.test.IntegrationTestTools; -import com.evolveum.midpoint.test.util.MidPointTestConstants; -import com.evolveum.midpoint.util.exception.*; -import com.evolveum.midpoint.xml.ns._public.common.common_3.*; -import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; - import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; @@ -35,6 +26,7 @@ import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.PrismReferenceValue; import com.evolveum.midpoint.prism.delta.ObjectDelta; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.prism.xml.XmlTypeConverter; @@ -46,13 +38,18 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.DummyResourceContoller; +import com.evolveum.midpoint.test.IntegrationTestTools; +import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; +import com.evolveum.midpoint.util.exception.*; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; +import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; /** * @author semancik - * */ -@ContextConfiguration(locations = {"classpath:ctx-model-intest-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-model-intest-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public abstract class AbstractPasswordTest extends AbstractInitializedModelIntegrationTest { @@ -161,12 +158,11 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; - AccountActivationNotifierType accountActivationNotifier = null; - SystemConfigurationType systemConfig = getObject(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value()).asObjectable(); + SystemConfigurationType systemConfig = getObject(SystemConfigurationType.class, + SystemObjectsType.SYSTEM_CONFIGURATION.value()).asObjectable(); IntegrationTestTools.displayXml("system config", systemConfig.asPrismObject()); - for (EventHandlerType handler: systemConfig.getNotificationConfiguration().getHandler()) { + for (EventHandlerType handler : systemConfig.getNotificationConfiguration().getHandler()) { display("Handler: ", handler); List accountActivationNotifiers = handler.getAccountActivationNotifier(); if (!accountActivationNotifiers.isEmpty()) { @@ -180,8 +176,6 @@ public void test000Sanity() throws Exception { @Test public void test010AddPasswordPolicy() throws Exception { - final String TEST_NAME = "test010AddPasswordPolicy"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -202,8 +196,6 @@ public void test010AddPasswordPolicy() throws Exception { @Test public void test012AddSecurityPolicy() throws Exception { - final String TEST_NAME = "test012AddSecurityPolicy"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -224,15 +216,10 @@ public void test012AddSecurityPolicy() throws Exception { @Test public void test050CheckJackPassword() throws Exception { - final String TEST_NAME = "test050CheckJackPassword"; - // GIVEN, WHEN // this happens during test initialization when user-jack.xml is added // THEN - Task task = getTestTask(); - OperationResult result = task.getResult(); - PrismObject userJack = getUser(USER_JACK_OID); display("User after change execution", userJack); assertUserJack(userJack, "Jack Sparrow"); @@ -241,11 +228,8 @@ public void test050CheckJackPassword() throws Exception { assertUserPassword(userJack, USER_JACK_PASSWORD, CredentialsStorageTypeType.ENCRYPTION); } - @Test public void test051ModifyUserJackPassword() throws Exception { - final String TEST_NAME = "test051ModifyUserJackPassword"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -254,11 +238,11 @@ public void test051ModifyUserJackPassword() throws Exception { XMLGregorianCalendar startCal = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); modifyUserChangePassword(USER_JACK_OID, USER_PASSWORD_1_CLEAR, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -277,8 +261,6 @@ public void test051ModifyUserJackPassword() throws Exception { @Test public void test060CheckJackPasswordModelInteraction() throws Exception { - final String TEST_NAME = "test060CheckJackPasswordModelInteraction"; - if (getPasswordStorageType() == CredentialsStorageTypeType.NONE) { // Nothing to check in this case return; @@ -311,8 +293,6 @@ public void test060CheckJackPasswordModelInteraction() throws Exception { @Test public void test070AddUserHerman() throws Exception { - final String TEST_NAME = "test070AddUserHerman"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -321,11 +301,11 @@ public void test070AddUserHerman() throws Exception { XMLGregorianCalendar startCal = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); addObject(USER_HERMAN_FILE, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -345,8 +325,6 @@ public void test070AddUserHerman() throws Exception { @Test public void test100JackAssignAccountDummy() throws Exception { - final String TEST_NAME = "test100JackAssignAccountDummy"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -355,11 +333,11 @@ public void test100JackAssignAccountDummy() throws Exception { XMLGregorianCalendar startCal = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -398,8 +376,6 @@ public void test100JackAssignAccountDummy() throws Exception { */ @Test public void test110ModifyUserJackPassword() throws Exception { - final String TEST_NAME = "test110ModifyUserJackPassword"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -447,8 +423,6 @@ public void test110ModifyUserJackPassword() throws Exception { */ @Test public void test111ModifyAccountJackPassword() throws Exception { - final String TEST_NAME = "test111ModifyAccountJackPassword"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -482,8 +456,6 @@ public void test111ModifyAccountJackPassword() throws Exception { */ @Test public void test112ModifyJackPasswordUserAndAccount() throws Exception { - final String TEST_NAME = "test112ModifyJackPasswordUserAndAccount"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -526,14 +498,11 @@ public void test112ModifyJackPasswordUserAndAccount() throws Exception { assertSingleUserPasswordNotification(USER_JACK_USERNAME, USER_PASSWORD_4_CLEAR); } - /** * Add red and ugly dummy resource to the mix. This would be fun. */ @Test public void test120JackAssignAccountDummyRedAndUgly() throws Exception { - final String TEST_NAME = "test120JackAssignAccountDummyRedAndUgly"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -562,17 +531,17 @@ public void test120JackAssignAccountDummyRedAndUgly() throws Exception { // User and default dummy account should have unchanged passwords assertUserPassword(userJack, USER_PASSWORD_4_CLEAR); - assertDummyPassword(USER_JACK_USERNAME, USER_PASSWORD_5_CLEAR); + assertDummyPassword(USER_JACK_USERNAME, USER_PASSWORD_5_CLEAR); - assertPasswordMetadata(userJack, false, lastPasswordChangeStart, lastPasswordChangeEnd); + assertPasswordMetadata(userJack, false, lastPasswordChangeStart, lastPasswordChangeEnd); - if (isPasswordEncryption()) { - assertAccountPasswordNotifications(2); - assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_4_CLEAR); - assertHasAccountPasswordNotification(RESOURCE_DUMMY_UGLY_NAME, USER_JACK_USERNAME, USER_JACK_EMPLOYEE_NUMBER); - } else { - assertSingleAccountPasswordNotification(RESOURCE_DUMMY_UGLY_NAME, USER_JACK_USERNAME, USER_JACK_EMPLOYEE_NUMBER); - } + if (isPasswordEncryption()) { + assertAccountPasswordNotifications(2); + assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_4_CLEAR); + assertHasAccountPasswordNotification(RESOURCE_DUMMY_UGLY_NAME, USER_JACK_USERNAME, USER_JACK_EMPLOYEE_NUMBER); + } else { + assertSingleAccountPasswordNotification(RESOURCE_DUMMY_UGLY_NAME, USER_JACK_USERNAME, USER_JACK_EMPLOYEE_NUMBER); + } assertNoUserPasswordNotifications(); } @@ -582,8 +551,6 @@ public void test120JackAssignAccountDummyRedAndUgly() throws Exception { */ @Test public void test121ModifyJackPasswordUserAndAccountRed() throws Exception { - final String TEST_NAME = "test121ModifyJackPasswordUserAndAccountRed"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -632,7 +599,7 @@ public void test121ModifyJackPasswordUserAndAccountRed() throws Exception { displayAccountPasswordNotifications(); assertAccountPasswordNotifications(2); assertHasAccountPasswordNotification(null, USER_JACK_USERNAME, USER_PASSWORD_1_CLEAR); - assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_1_CLEAR); + assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_1_CLEAR); assertSingleUserPasswordNotification(USER_JACK_USERNAME, USER_PASSWORD_1_CLEAR); } @@ -641,7 +608,6 @@ public void test121ModifyJackPasswordUserAndAccountRed() throws Exception { */ @Test public void test122ModifyAccountUglyJackPasswordBad() throws Exception { - final String TEST_NAME = "test122ModifyAccountUglyJackPasswordBad"; prepareTest(); // GIVEN @@ -650,11 +616,11 @@ public void test122ModifyAccountUglyJackPasswordBad() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modifyAccountChangePassword(accountJackUglyOid, "#badPassword!", task, result); // THEN - then(TEST_NAME); + then(); assertPartialError(result); assertDummyPassword(RESOURCE_DUMMY_UGLY_NAME, ACCOUNT_JACK_DUMMY_USERNAME, USER_JACK_EMPLOYEE_NUMBER); @@ -663,7 +629,6 @@ public void test122ModifyAccountUglyJackPasswordBad() throws Exception { assertNoUserPasswordNotifications(); } - /** * Jack employee number is mapped to ugly resource password. * Change employee number to something that does NOT comply with ugly resource password policy. @@ -671,15 +636,13 @@ public void test122ModifyAccountUglyJackPasswordBad() throws Exception { */ @Test public void test125ModifyJackEmployeeNumberBad() throws Exception { - final String TEST_NAME = "test125ModifyJackEmployeeNumberBad"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_EMPLOYEE_NUMBER, task, result, USER_JACK_EMPLOYEE_NUMBER_NEW_BAD); @@ -710,8 +673,6 @@ public void test125ModifyJackEmployeeNumberBad() throws Exception { */ @Test public void test128ModifyJackEmployeeNumberGood() throws Exception { - final String TEST_NAME = "test128ModifyJackEmployeeNumberGood"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -747,8 +708,6 @@ public void test128ModifyJackEmployeeNumberGood() throws Exception { */ @Test public void test130JackAssignAccountDummyBlack() throws Exception { - final String TEST_NAME = "test130JackAssignAccountDummyBlack"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -773,7 +732,7 @@ public void test130JackAssignAccountDummyBlack() throws Exception { assertUserPassword(userJack, USER_PASSWORD_1_CLEAR); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true); assertDummyPassword(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, USER_PASSWORD_1_CLEAR); - assertDummyPassword(ACCOUNT_JACK_DUMMY_USERNAME, USER_PASSWORD_1_CLEAR); + assertDummyPassword(ACCOUNT_JACK_DUMMY_USERNAME, USER_PASSWORD_1_CLEAR); assertDummyPassword(RESOURCE_DUMMY_UGLY_NAME, ACCOUNT_JACK_DUMMY_USERNAME, USER_JACK_EMPLOYEE_NUMBER_NEW_GOOD); assertPasswordMetadata(userJack, false, lastPasswordChangeStart, lastPasswordChangeEnd); @@ -789,8 +748,6 @@ public void test130JackAssignAccountDummyBlack() throws Exception { */ @Test public void test132ModifyAccountBlackJackPasswordBad() throws Exception { - final String TEST_NAME = "test132ModifyAccountBlackJackPasswordBad"; - // GIVEN AbstractPasswordTest.class.getName(); Task task = getTestTask(); @@ -798,11 +755,11 @@ public void test132ModifyAccountBlackJackPasswordBad() throws Exception { prepareTest(); // WHEN - when(TEST_NAME); + when(); modifyAccountChangePassword(accountJackBlackOid, USER_PASSWORD_A_CLEAR, task, result); // THEN - then(TEST_NAME); + then(); assertPartialError(result); assertDummyPasswordConditional(RESOURCE_DUMMY_BLACK_NAME, ACCOUNT_JACK_DUMMY_USERNAME, USER_PASSWORD_1_CLEAR); @@ -813,8 +770,6 @@ public void test132ModifyAccountBlackJackPasswordBad() throws Exception { @Test public void test139JackUnassignAccountDummyBlack() throws Exception { - final String TEST_NAME = "test139JackUnassignAccountDummyBlack"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -838,7 +793,7 @@ public void test139JackUnassignAccountDummyBlack() throws Exception { assertUserPassword(userJack, USER_PASSWORD_1_CLEAR); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true); assertDummyPassword(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, USER_PASSWORD_1_CLEAR); - assertDummyPassword(ACCOUNT_JACK_DUMMY_USERNAME, USER_PASSWORD_1_CLEAR); + assertDummyPassword(ACCOUNT_JACK_DUMMY_USERNAME, USER_PASSWORD_1_CLEAR); assertDummyPassword(RESOURCE_DUMMY_UGLY_NAME, ACCOUNT_JACK_DUMMY_USERNAME, USER_JACK_EMPLOYEE_NUMBER_NEW_GOOD); assertPasswordMetadata(userJack, false, lastPasswordChangeStart, lastPasswordChangeEnd); @@ -855,19 +810,17 @@ public void test139JackUnassignAccountDummyBlack() throws Exception { */ @Test public void test140JackAssignAccountDummyYellow() throws Exception { - final String TEST_NAME = "test140JackAssignAccountDummyYellow"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_YELLOW_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userJack = getUser(USER_JACK_OID); @@ -884,7 +837,7 @@ public void test140JackAssignAccountDummyYellow() throws Exception { assertUserPassword(userJack, USER_PASSWORD_1_CLEAR); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true); assertDummyPassword(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, USER_PASSWORD_1_CLEAR); - assertDummyPassword(ACCOUNT_JACK_DUMMY_USERNAME, USER_PASSWORD_1_CLEAR); + assertDummyPassword(ACCOUNT_JACK_DUMMY_USERNAME, USER_PASSWORD_1_CLEAR); assertDummyPassword(RESOURCE_DUMMY_UGLY_NAME, ACCOUNT_JACK_DUMMY_USERNAME, USER_JACK_EMPLOYEE_NUMBER_NEW_GOOD); assertPasswordMetadata(userJack, false, lastPasswordChangeStart, lastPasswordChangeEnd); @@ -902,8 +855,6 @@ public void test140JackAssignAccountDummyYellow() throws Exception { */ @Test public void test142ModifyUserJackPasswordAA() throws Exception { - final String TEST_NAME = "test142ModifyUserJackPasswordAA"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -912,11 +863,11 @@ public void test142ModifyUserJackPasswordAA() throws Exception { lastPasswordChangeStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); modifyUserChangePassword(USER_JACK_OID, USER_PASSWORD_AA_CLEAR, task, result); // THEN - then(TEST_NAME); + then(); assertPartialError(result); lastPasswordChangeEnd = clock.currentTimeXMLGregorianCalendar(); @@ -935,7 +886,7 @@ public void test142ModifyUserJackPasswordAA() throws Exception { // User and default dummy account should have unchanged passwords assertUserPassword(userJack, USER_PASSWORD_AA_CLEAR); - assertDummyPassword(ACCOUNT_JACK_DUMMY_USERNAME, USER_PASSWORD_AA_CLEAR); + assertDummyPassword(ACCOUNT_JACK_DUMMY_USERNAME, USER_PASSWORD_AA_CLEAR); // this one is not changed assertDummyPassword(RESOURCE_DUMMY_UGLY_NAME, ACCOUNT_JACK_DUMMY_USERNAME, USER_JACK_EMPLOYEE_NUMBER_NEW_GOOD); @@ -946,7 +897,7 @@ public void test142ModifyUserJackPasswordAA() throws Exception { displayUserPasswordNotifications(); assertAccountPasswordNotifications(2); assertHasAccountPasswordNotification(null, USER_JACK_USERNAME, USER_PASSWORD_AA_CLEAR); - assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_AA_CLEAR); + assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_AA_CLEAR); assertSingleUserPasswordNotification(USER_JACK_USERNAME, USER_PASSWORD_AA_CLEAR); } @@ -957,19 +908,17 @@ public void test142ModifyUserJackPasswordAA() throws Exception { */ @Test public void test150AssignMonkeyDummyAccount() throws Exception { - final String TEST_NAME = "test150AssignMonkeyDummyAccount"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_THREE_HEADED_MONKEY_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -980,7 +929,6 @@ public void test150AssignMonkeyDummyAccount() throws Exception { assertDummyAccount(null, USER_THREE_HEADED_MONKEY_NAME, USER_THREE_HEADED_MONKEY_FULL_NAME, true); } - /** * Three headed monkey has no credentials. No password, nothing. * Just three heads. @@ -988,8 +936,6 @@ public void test150AssignMonkeyDummyAccount() throws Exception { */ @Test public void test152ModifyUserMonkeyPassword() throws Exception { - final String TEST_NAME = "test152ModifyUserMonkeyPassword"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -998,11 +944,11 @@ public void test152ModifyUserMonkeyPassword() throws Exception { lastPasswordChangeStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); modifyUserChangePassword(USER_THREE_HEADED_MONKEY_OID, USER_PASSWORD_1_CLEAR, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); lastPasswordChangeEnd = clock.currentTimeXMLGregorianCalendar(); @@ -1019,19 +965,17 @@ public void test152ModifyUserMonkeyPassword() throws Exception { */ @Test public void test154ModifyUserMonkeyPasswordA() throws Exception { - final String TEST_NAME = "test154ModifyUserMonkeyPasswordA"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); modifyUserChangePassword(USER_THREE_HEADED_MONKEY_OID, USER_PASSWORD_A_CLEAR, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -1042,22 +986,20 @@ public void test154ModifyUserMonkeyPasswordA() throws Exception { @Test public void test200ApplyPasswordPolicyHistoryLength() throws Exception { - final String TEST_NAME = "test200ApplyPasswordPolicyHistoryLength"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); applyPasswordPolicy(PASSWORD_POLICY_GLOBAL_OID, getSecurityPolicyOid(), task, result); modifyObjectReplaceProperty(SecurityPolicyType.class, getSecurityPolicyOid(), ItemPath.create(SecurityPolicyType.F_CREDENTIALS, CredentialsPolicyType.F_PASSWORD, PasswordCredentialsPolicyType.F_HISTORY_LENGTH), task, result, 3); // THEN - then(TEST_NAME); + then(); assertSuccess(result); } @@ -1069,8 +1011,6 @@ public void test200ApplyPasswordPolicyHistoryLength() throws Exception { */ @Test public void test204UnassignAccountRed() throws Exception { - final String TEST_NAME = "test204UnassignAccountRed"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1086,11 +1026,11 @@ public void test204UnassignAccountRed() throws Exception { .createDeleteDelta(ShadowType.class, accountJackRedOid); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(userDelta, shadowDelta), null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1106,7 +1046,7 @@ public void test204UnassignAccountRed() throws Exception { // User and default dummy account should have unchanged passwords assertUserPassword(userAfter, USER_PASSWORD_AA_CLEAR); - assertDummyPassword(ACCOUNT_JACK_DUMMY_USERNAME, USER_PASSWORD_AA_CLEAR); + assertDummyPassword(ACCOUNT_JACK_DUMMY_USERNAME, USER_PASSWORD_AA_CLEAR); // this one is not changed assertDummyPassword(RESOURCE_DUMMY_UGLY_NAME, ACCOUNT_JACK_DUMMY_USERNAME, USER_JACK_EMPLOYEE_NUMBER_NEW_GOOD); @@ -1124,8 +1064,6 @@ public void test204UnassignAccountRed() throws Exception { */ @Test public void test206ReconcileUserJack() throws Exception { - final String TEST_NAME = "test206ReconcileUserJack"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1152,7 +1090,7 @@ public void test206ReconcileUserJack() throws Exception { // User and default dummy account should have unchanged passwords assertUserPassword(userAfter, USER_PASSWORD_AA_CLEAR); - assertDummyPassword(ACCOUNT_JACK_DUMMY_USERNAME, USER_PASSWORD_AA_CLEAR); + assertDummyPassword(ACCOUNT_JACK_DUMMY_USERNAME, USER_PASSWORD_AA_CLEAR); // this one is not changed assertDummyPassword(RESOURCE_DUMMY_UGLY_NAME, ACCOUNT_JACK_DUMMY_USERNAME, USER_JACK_EMPLOYEE_NUMBER_NEW_GOOD); @@ -1168,7 +1106,7 @@ public void test206ReconcileUserJack() throws Exception { */ @Test public void test210ModifyUserJackPasswordGood() throws Exception { - doTestModifyUserJackPasswordSuccessWithHistory("test210ModifyUserJackPasswordGood", + doTestModifyUserJackPasswordSuccessWithHistory( USER_PASSWORD_VALID_1, USER_PASSWORD_AA_CLEAR); } @@ -1178,8 +1116,6 @@ public void test210ModifyUserJackPasswordGood() throws Exception { */ @Test public void test212ReconcileUserJack() throws Exception { - final String TEST_NAME = "test212ReconcileUserJack"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1201,8 +1137,6 @@ public void test212ReconcileUserJack() throws Exception { */ @Test public void test214RecomputeUserJack() throws Exception { - final String TEST_NAME = "test214RecomputeUserJack"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1223,7 +1157,7 @@ public void test214RecomputeUserJack() throws Exception { */ @Test public void test220ModifyUserJackPasswordBadA() throws Exception { - doTestModifyUserJackPasswordFailureWithHistory("test220ModifyUserJackPasswordBadA", + doTestModifyUserJackPasswordFailureWithHistory( USER_PASSWORD_1_CLEAR, USER_PASSWORD_VALID_1, USER_PASSWORD_AA_CLEAR); } @@ -1234,8 +1168,6 @@ public void test220ModifyUserJackPasswordBadA() throws Exception { */ @Test public void test222ModifyUserJackPasswordBadContainer() throws Exception { - final String TEST_NAME = "test222ModifyUserJackPasswordBadContainer"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1248,7 +1180,7 @@ public void test222ModifyUserJackPasswordBadContainer() throws Exception { ObjectDelta objectDelta = prismContext.deltaFactory().object() .createModificationReplaceContainer(UserType.class, USER_JACK_OID, - ItemPath.create(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD), + ItemPath.create(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD), passwordType); Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); @@ -1276,7 +1208,7 @@ public void test222ModifyUserJackPasswordBadContainer() throws Exception { */ @Test public void test224ModifyUserJackPasswordBadJack() throws Exception { - doTestModifyUserJackPasswordFailureWithHistory("test224ModifyUserJackPasswordBadJack", + doTestModifyUserJackPasswordFailureWithHistory( USER_PASSWORD_JACK_CLEAR, USER_PASSWORD_VALID_1, USER_PASSWORD_AA_CLEAR); } @@ -1286,7 +1218,7 @@ public void test224ModifyUserJackPasswordBadJack() throws Exception { */ @Test public void test226ModifyUserJackPasswordBadSparrow() throws Exception { - doTestModifyUserJackPasswordFailureWithHistory("test226ModifyUserJackPasswordBadSparrow", + doTestModifyUserJackPasswordFailureWithHistory( USER_PASSWORD_SPARROW_CLEAR, USER_PASSWORD_VALID_1, USER_PASSWORD_AA_CLEAR); } @@ -1296,7 +1228,7 @@ public void test226ModifyUserJackPasswordBadSparrow() throws Exception { */ @Test public void test230ModifyUserJackPasswordGoodAgain() throws Exception { - doTestModifyUserJackPasswordSuccessWithHistory("test230ModifyUserJackPasswordGoodAgain", + doTestModifyUserJackPasswordSuccessWithHistory( USER_PASSWORD_VALID_2, USER_PASSWORD_AA_CLEAR, USER_PASSWORD_VALID_1); } @@ -1305,7 +1237,7 @@ public void test230ModifyUserJackPasswordGoodAgain() throws Exception { */ @Test public void test235ModifyUserJackPasswordGoodSameAsCurrent() throws Exception { - doTestModifyUserJackPasswordFailureWithHistory("test235ModifyUserJackPasswordGoodSameAsCurrent", + doTestModifyUserJackPasswordFailureWithHistory( USER_PASSWORD_VALID_2, USER_PASSWORD_VALID_2, USER_PASSWORD_AA_CLEAR, USER_PASSWORD_VALID_1); } @@ -1314,7 +1246,7 @@ public void test235ModifyUserJackPasswordGoodSameAsCurrent() throws Exception { */ @Test public void test236ModifyUserJackPasswordGoodInHistory() throws Exception { - doTestModifyUserJackPasswordFailureWithHistory("test236ModifyUserJackPasswordGoodInHistory", + doTestModifyUserJackPasswordFailureWithHistory( USER_PASSWORD_VALID_1, USER_PASSWORD_VALID_2, USER_PASSWORD_AA_CLEAR, USER_PASSWORD_VALID_1); } @@ -1323,7 +1255,7 @@ public void test236ModifyUserJackPasswordGoodInHistory() throws Exception { */ @Test public void test237ModifyUserJackPasswordBadInHistory() throws Exception { - doTestModifyUserJackPasswordFailureWithHistory("test237ModifyUserJackPasswordBadInHistory", + doTestModifyUserJackPasswordFailureWithHistory( USER_PASSWORD_AA_CLEAR, USER_PASSWORD_VALID_2, USER_PASSWORD_AA_CLEAR, USER_PASSWORD_VALID_1); } @@ -1334,7 +1266,7 @@ public void test237ModifyUserJackPasswordBadInHistory() throws Exception { */ @Test public void test240ModifyUserJackPasswordGoodAgainOverHistory() throws Exception { - doTestModifyUserJackPasswordSuccessWithHistory("test240ModifyUserJackPasswordGoodAgainOverHistory", + doTestModifyUserJackPasswordSuccessWithHistory( USER_PASSWORD_VALID_3, USER_PASSWORD_VALID_1, USER_PASSWORD_VALID_2); } @@ -1345,7 +1277,7 @@ public void test240ModifyUserJackPasswordGoodAgainOverHistory() throws Exception */ @Test public void test241ModifyUserJackPasswordGoodAgainOverHistoryAgain() throws Exception { - doTestModifyUserJackPasswordSuccessWithHistory("test241ModifyUserJackPasswordGoodAgainOverHistoryAgain", + doTestModifyUserJackPasswordSuccessWithHistory( USER_PASSWORD_VALID_4, USER_PASSWORD_VALID_2, USER_PASSWORD_VALID_3); } @@ -1355,12 +1287,13 @@ public void test241ModifyUserJackPasswordGoodAgainOverHistoryAgain() throws Exce */ @Test public void test248ModifyUserJackPasswordGoodReuse() throws Exception { - doTestModifyUserJackPasswordSuccessWithHistory("test248ModifyUserJackPasswordGoodReuse", + doTestModifyUserJackPasswordSuccessWithHistory( USER_PASSWORD_VALID_1, USER_PASSWORD_VALID_3, USER_PASSWORD_VALID_4); } - private void doTestModifyUserJackPasswordSuccessWithHistory(final String TEST_NAME, - String newPassword, String... expectedPasswordHistory) throws Exception { + private void doTestModifyUserJackPasswordSuccessWithHistory( + String newPassword, String... expectedPasswordHistory) + throws Exception { // GIVEN Task task = getTestTask(); @@ -1382,12 +1315,13 @@ private void doTestModifyUserJackPasswordSuccessWithHistory(final String TEST_NA displayAccountPasswordNotifications(); assertAccountPasswordNotifications(2); assertHasAccountPasswordNotification(null, USER_JACK_USERNAME, newPassword); - assertHasAccountPasswordNotification(RESOURCE_DUMMY_YELLOW_NAME, USER_JACK_USERNAME, newPassword); + assertHasAccountPasswordNotification(RESOURCE_DUMMY_YELLOW_NAME, USER_JACK_USERNAME, newPassword); assertSingleUserPasswordNotification(USER_JACK_USERNAME, newPassword); } - private void doTestModifyUserJackPasswordFailureWithHistory(final String TEST_NAME, - String newPassword, String oldPassword, String... expectedPasswordHistory) throws Exception { + private void doTestModifyUserJackPasswordFailureWithHistory( + String newPassword, String oldPassword, String... expectedPasswordHistory) + throws Exception { // GIVEN Task task = getTestTask(); @@ -1442,8 +1376,6 @@ private void assertJackPasswordsWithHistory(String expectedCurrentPassword, Stri */ @Test public void test300TwoParentOrgRefs() throws Exception { - final String TEST_NAME = "test300TwoParentOrgRefs"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1504,8 +1436,6 @@ public void test300TwoParentOrgRefs() throws Exception { */ @Test public void test310PreparePasswordStrengthTests() throws Exception { - final String TEST_NAME = "test310PreparePasswordStrengthTests"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1516,12 +1446,12 @@ public void test310PreparePasswordStrengthTests() throws Exception { unassignOrg(USER_JACK_OID, ORG_GOVERNOR_OFFICE_OID, SchemaConstants.ORG_MANAGER, task, result); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_RED_OID, null, task, result); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_BLUE_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1547,8 +1477,8 @@ public void test310PreparePasswordStrengthTests() throws Exception { if (isPasswordEncryption()) { assertAccountPasswordNotifications(2); - assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_VALID_1); - assertHasAccountPasswordNotification(RESOURCE_DUMMY_BLUE_NAME, USER_JACK_USERNAME, USER_PASSWORD_VALID_1); + assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_VALID_1); + assertHasAccountPasswordNotification(RESOURCE_DUMMY_BLUE_NAME, USER_JACK_USERNAME, USER_PASSWORD_VALID_1); } else { assertNoAccountPasswordNotifications(); @@ -1558,19 +1488,17 @@ public void test310PreparePasswordStrengthTests() throws Exception { @Test public void test312ChangeUserPassword() throws Exception { - final String TEST_NAME = "test312ChangeUserPassword"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); modifyUserChangePassword(USER_JACK_OID, USER_PASSWORD_VALID_2, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1599,13 +1527,13 @@ public void test312ChangeUserPassword() throws Exception { if (isPasswordEncryption()) { assertAccountPasswordNotifications(2); assertHasAccountPasswordNotification(null, USER_JACK_USERNAME, USER_PASSWORD_VALID_2); - assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_VALID_2); - // not BLUE, it already has a password + assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_VALID_2); + // not BLUE, it already has a password } else { assertAccountPasswordNotifications(3); assertHasAccountPasswordNotification(null, USER_JACK_USERNAME, USER_PASSWORD_VALID_2); - assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_VALID_2); - assertHasAccountPasswordNotification(RESOURCE_DUMMY_BLUE_NAME, USER_JACK_USERNAME, USER_PASSWORD_VALID_2); + assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_VALID_2); + assertHasAccountPasswordNotification(RESOURCE_DUMMY_BLUE_NAME, USER_JACK_USERNAME, USER_PASSWORD_VALID_2); } assertSingleUserPasswordNotification(USER_JACK_USERNAME, USER_PASSWORD_VALID_2); } @@ -1619,8 +1547,6 @@ public void test312ChangeUserPassword() throws Exception { */ @Test public void test314RemovePasswordFail() throws Exception { - final String TEST_NAME = "test314RemovePasswordFail"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1630,7 +1556,7 @@ public void test314RemovePasswordFail() throws Exception { try { // WHEN+THEN - when(TEST_NAME); + when(); try { modifyUserReplace(USER_JACK_OID, PASSWORD_VALUE_PATH, task, result /*, no value */); fail("unexpected success"); @@ -1646,7 +1572,7 @@ public void test314RemovePasswordFail() throws Exception { private void setPasswordMinOccurs(Integer value, Task task, OperationResult result) throws CommonException { ObjectDelta delta = prismContext.deltaFor(SecurityPolicyType.class) .item(SecurityPolicyType.F_CREDENTIALS, CredentialsPolicyType.F_PASSWORD, PasswordCredentialsPolicyType.F_MIN_OCCURS) - .replace(value) + .replace(value) .asObjectDeltaCast(getSecurityPolicyOid()); executeChanges(delta, null, task, result); } @@ -1656,19 +1582,17 @@ private void setPasswordMinOccurs(Integer value, Task task, OperationResult resu */ @Test public void test315RemovePassword() throws Exception { - final String TEST_NAME = "test315RemovePassword"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, PASSWORD_VALUE_PATH, task, result /*, no value */); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1703,19 +1627,17 @@ public void test315RemovePassword() throws Exception { */ @Test public void test316UserRecompute() throws Exception { - final String TEST_NAME = "test316UserRecompute"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1753,39 +1675,37 @@ public void test316UserRecompute() throws Exception { */ @Test public void test318ChangeUserPassword() throws Exception { - final String TEST_NAME = "test318ChangeUserPassword"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); modifyUserChangePassword(USER_JACK_OID, USER_PASSWORD_VALID_3, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = assertUserAfter(USER_JACK_OID) - .assertPassword(USER_PASSWORD_VALID_3, getPasswordStorageType()) - .assertLinks(4) - .getObject(); + .assertPassword(USER_PASSWORD_VALID_3, getPasswordStorageType()) + .assertLinks(4) + .getObject(); // default password mapping is normal assertDummyAccountByUsername(null, ACCOUNT_JACK_DUMMY_USERNAME) - .assertPassword(USER_PASSWORD_VALID_3) - // Admin password reset, no runAs - .assertLastModifier(null); + .assertPassword(USER_PASSWORD_VALID_3) + // Admin password reset, no runAs + .assertLastModifier(null); // RED password mapping is strong assertDummyAccountByUsername(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME) - .assertFullName(USER_JACK_FULL_NAME) - .assertEnabled() - .assertPassword(USER_PASSWORD_VALID_3) - // and RED resource has no runAs capability - .assertLastModifier(null); + .assertFullName(USER_JACK_FULL_NAME) + .assertEnabled() + .assertPassword(USER_PASSWORD_VALID_3) + // and RED resource has no runAs capability + .assertLastModifier(null); // password mapping is weak assertDummyAccount(RESOURCE_DUMMY_BLUE_NAME, ACCOUNT_JACK_DUMMY_USERNAME, USER_JACK_FULL_NAME, true); @@ -1797,26 +1717,24 @@ public void test318ChangeUserPassword() throws Exception { displayAccountPasswordNotifications(); assertAccountPasswordNotifications(2); assertHasAccountPasswordNotification(null, USER_JACK_USERNAME, USER_PASSWORD_VALID_3); - assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_VALID_3); - // not BLUE, it already has a password + assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_VALID_3); + // not BLUE, it already has a password assertSingleUserPasswordNotification(USER_JACK_USERNAME, USER_PASSWORD_VALID_3); } @Test public void test320ChangeEmployeeNumber() throws Exception { - final String TEST_NAME = "test320ChangeEmployeeNumber"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_EMPLOYEE_NUMBER, task, result, "emp0000"); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1837,19 +1755,17 @@ public void test320ChangeEmployeeNumber() throws Exception { @Test public void test330RemoveEmployeeNumber() throws Exception { - final String TEST_NAME = "test330RemoveEmployeeNumber"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_EMPLOYEE_NUMBER, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1875,8 +1791,6 @@ public void test330RemoveEmployeeNumber() throws Exception { */ @Test public void test340ModifyUserMonkeyPasswordAA() throws Exception { - final String TEST_NAME = "test340ModifyUserMonkeyPasswordAA"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1884,7 +1798,7 @@ public void test340ModifyUserMonkeyPasswordAA() throws Exception { try { // WHEN - when(TEST_NAME); + when(); modifyUserChangePassword(USER_THREE_HEADED_MONKEY_OID, USER_PASSWORD_AA_CLEAR, task, result); @@ -1895,7 +1809,7 @@ public void test340ModifyUserMonkeyPasswordAA() throws Exception { } // THEN - then(TEST_NAME); + then(); assertFailure(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -1911,19 +1825,17 @@ public void test340ModifyUserMonkeyPasswordAA() throws Exception { */ @Test public void test341RecomputeMonkey() throws Exception { - final String TEST_NAME = "test341RecomputeMonkey"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_THREE_HEADED_MONKEY_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -1939,19 +1851,17 @@ public void test341RecomputeMonkey() throws Exception { */ @Test public void test342ReconcileMonkey() throws Exception { - final String TEST_NAME = "test342ReconcileMonkey"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_THREE_HEADED_MONKEY_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -1967,8 +1877,6 @@ public void test342ReconcileMonkey() throws Exception { */ @Test public void test343ModifyUserMonkeyDescription() throws Exception { - final String TEST_NAME = "test343ModifyUserMonkeyDescription"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1980,11 +1888,11 @@ public void test343ModifyUserMonkeyDescription() throws Exception { assertDummyAccount(null, USER_THREE_HEADED_MONKEY_NAME); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_THREE_HEADED_MONKEY_OID, UserType.F_DESCRIPTION, task, result, "Look behind you! A three-headed MONKEY!"); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -2003,20 +1911,18 @@ public void test343ModifyUserMonkeyDescription() throws Exception { */ @Test public void test344ModifyUserMonkeyLocality() throws Exception { - final String TEST_NAME = "test343ModifyUserMonkeyDescription"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_THREE_HEADED_MONKEY_OID, UserType.F_LOCALITY, task, result, createPolyString("Monkey Island")); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -2037,20 +1943,18 @@ public void test344ModifyUserMonkeyLocality() throws Exception { */ @Test public void test345AssignMonkeyAccountBlue() throws Exception { - final String TEST_NAME = "test345AssignMonkeyAccountBlue"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_THREE_HEADED_MONKEY_OID, RESOURCE_DUMMY_BLUE_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertPartialError(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -2067,20 +1971,18 @@ public void test345AssignMonkeyAccountBlue() throws Exception { */ @Test public void test346UnassignMonkeyAccountBlue() throws Exception { - final String TEST_NAME = "test346UnassignMonkeyAccountBlue"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); unassignAccountFromUser(USER_THREE_HEADED_MONKEY_OID, RESOURCE_DUMMY_BLUE_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -2100,20 +2002,18 @@ public void test346UnassignMonkeyAccountBlue() throws Exception { */ @Test public void test347AssignMonkeyAccountYellow() throws Exception { - final String TEST_NAME = "test347AssignMonkeyAccountYellow"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_THREE_HEADED_MONKEY_OID, RESOURCE_DUMMY_YELLOW_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertPartialError(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -2128,20 +2028,18 @@ public void test347AssignMonkeyAccountYellow() throws Exception { @Test public void test348UnassignMonkeyAccountYellow() throws Exception { - final String TEST_NAME = "test348UnassignMonkeyAccountYellow"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); unassignAccountFromUser(USER_THREE_HEADED_MONKEY_OID, RESOURCE_DUMMY_YELLOW_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -2162,19 +2060,17 @@ public void test348UnassignMonkeyAccountYellow() throws Exception { */ @Test public void test349AssignMonkeyPirate() throws Exception { - final String TEST_NAME = "test349AssignMonkeyPirate"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_THREE_HEADED_MONKEY_OID, ROLE_PIRATE_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -2197,19 +2093,17 @@ public void test349AssignMonkeyPirate() throws Exception { */ @Test public void test350DisableMonkey() throws Exception { - final String TEST_NAME = "test350DisableMonkey"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_THREE_HEADED_MONKEY_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.DISABLED); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -2232,19 +2126,17 @@ public void test350DisableMonkey() throws Exception { */ @Test public void test351EnableMonkey() throws Exception { - final String TEST_NAME = "test351EnableMonkey"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_THREE_HEADED_MONKEY_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.ENABLED); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -2267,19 +2159,17 @@ public void test351EnableMonkey() throws Exception { */ @Test public void test352UnassignMonkeyPirate() throws Exception { - final String TEST_NAME = "test352UnassignMonkeyPirate"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_THREE_HEADED_MONKEY_OID, ROLE_PIRATE_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -2301,19 +2191,17 @@ public void test352UnassignMonkeyPirate() throws Exception { */ @Test public void test354ModifyUserMonkeyPasswordValid1() throws Exception { - final String TEST_NAME = "test354ModifyUserMonkeyPasswordValid1"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); modifyUserChangePassword(USER_THREE_HEADED_MONKEY_OID, USER_PASSWORD_VALID_1, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -2329,19 +2217,17 @@ public void test354ModifyUserMonkeyPasswordValid1() throws Exception { */ @Test public void test355ModifyUserMonkeyDescriptionAgain() throws Exception { - final String TEST_NAME = "test355ModifyUserMonkeyDescriptionAgain"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_THREE_HEADED_MONKEY_OID, UserType.F_DESCRIPTION, task, result, "Look behind you! A three-headed MONKEY!"); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -2356,8 +2242,6 @@ public void test355ModifyUserMonkeyDescriptionAgain() throws Exception { */ @Test public void test400AddUserRappWithAssignment() throws Exception { - final String TEST_NAME = "test400AddUserRappWithAssignment"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -2366,18 +2250,18 @@ public void test400AddUserRappWithAssignment() throws Exception { AssignmentType assignmentType = createConstructionAssignment(RESOURCE_DUMMY_OID, null, null); UserType userBeforeType = userBefore.asObjectable(); userBeforeType - .fullName(createPolyStringType(USER_RAPP_FULLNAME)) - .emailAddress(USER_RAPP_EMAIL); // Make sure Rapp has e-mail address otherwise the notifications will not be sent to transport + .fullName(createPolyStringType(USER_RAPP_FULLNAME)) + .emailAddress(USER_RAPP_EMAIL); // Make sure Rapp has e-mail address otherwise the notifications will not be sent to transport userBeforeType.getAssignment().add(assignmentType); setPassword(userBefore, USER_PASSWORD_VALID_1); display("User before", userBefore); // WHEN - when(TEST_NAME); + when(); addObject(userBefore, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_RAPP_OID); @@ -2406,19 +2290,17 @@ public void test400AddUserRappWithAssignment() throws Exception { */ @Test public void test401UserRappRecompute() throws Exception { - final String TEST_NAME = "test401UserRappRecompute"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_RAPP_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_RAPP_OID); @@ -2447,8 +2329,6 @@ public void test401UserRappRecompute() throws Exception { */ @Test public void test402AssignRappDummyRed() throws Exception { - final String TEST_NAME = "test402AssignRappDummyRed"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -2458,11 +2338,11 @@ public void test402AssignRappDummyRed() throws Exception { display("User before", userBefore); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_RAPP_OID, RESOURCE_DUMMY_RED_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_RAPP_OID); @@ -2511,8 +2391,6 @@ public void test402AssignRappDummyRed() throws Exception { */ @Test public void test403UserRappRecompute() throws Exception { - final String TEST_NAME = "test403UserRappRecompute"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -2522,11 +2400,11 @@ public void test403UserRappRecompute() throws Exception { display("User before", userBefore); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_RAPP_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_RAPP_OID); @@ -2573,8 +2451,6 @@ public void test403UserRappRecompute() throws Exception { */ @Test public void test404InitializeRappDummyRed() throws Exception { - final String TEST_NAME = "test404InitializeRappDummyRed"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -2587,11 +2463,11 @@ public void test404InitializeRappDummyRed() throws Exception { ObjectDelta shadowDelta = createAccountInitializationDelta(accountRedOid, USER_PASSWORD_VALID_1); // WHEN - when(TEST_NAME); + when(); executeChanges(shadowDelta, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_RAPP_OID); @@ -2638,8 +2514,6 @@ public void test404InitializeRappDummyRed() throws Exception { */ @Test public void test405UserRappRecompute() throws Exception { - final String TEST_NAME = "test405UserRappRecompute"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -2649,11 +2523,11 @@ public void test405UserRappRecompute() throws Exception { display("User before", userBefore); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_RAPP_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2701,8 +2575,6 @@ public void test405UserRappRecompute() throws Exception { */ @Test public void test410AssignRappDummyLifecycle() throws Exception { - final String TEST_NAME = "test410AssignRappDummyLifecycle"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -2712,11 +2584,11 @@ public void test410AssignRappDummyLifecycle() throws Exception { display("User before", userBefore); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_RAPP_OID, RESOURCE_DUMMY_LIFECYCLE_OID, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2735,7 +2607,6 @@ public void test410AssignRappDummyLifecycle() throws Exception { assertShadowLifecycle(accountShadowLifecycle, false); // assertShadowLifecycle(accountShadowLifecycle, SchemaConstants.LIFECYCLE_ACTIVE); - assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_RAPP_USERNAME, USER_RAPP_FULLNAME, true); assertDummyPassword(RESOURCE_DUMMY_RED_NAME, USER_RAPP_USERNAME, USER_PASSWORD_VALID_1); assertUserPassword(userAfter, USER_PASSWORD_VALID_1); @@ -2748,8 +2619,6 @@ public void test410AssignRappDummyLifecycle() throws Exception { @Test public void test412InitializeRappDummyLifecycle() throws Exception { - final String TEST_NAME = "test412InitializeRappDummyLifecycle"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -2767,11 +2636,11 @@ public void test412InitializeRappDummyLifecycle() throws Exception { shadowDelta.addModificationReplaceProperty(ObjectType.F_LIFECYCLE_STATE, SchemaConstants.LIFECYCLE_ACTIVE); // WHEN - when(TEST_NAME); + when(); executeChanges(shadowDelta, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2825,8 +2694,6 @@ public void test412InitializeRappDummyLifecycle() throws Exception { @Test public void test414UserRappRecompute() throws Exception { - final String TEST_NAME = "test414UserRappRecompute"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -2836,11 +2703,11 @@ public void test414UserRappRecompute() throws Exception { display("User before", userBefore); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_RAPP_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_RAPP_OID); @@ -2895,8 +2762,6 @@ public void test414UserRappRecompute() throws Exception { @Test public void test416UserRappSubtypeWreck() throws Exception { - final String TEST_NAME = "test416UserRappSubtypeWreck"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -2906,11 +2771,11 @@ public void test416UserRappSubtypeWreck() throws Exception { display("User before", userBefore); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_RAPP_OID, UserType.F_SUBTYPE, task, result, "WRECK"); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_RAPP_OID); @@ -2971,8 +2836,6 @@ public void test416UserRappSubtypeWreck() throws Exception { */ @Test public void test420AddUserDrakeWithAssignment() throws Exception { - final String TEST_NAME = "test420AddUserDrakeWithAssignment"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -2984,16 +2847,16 @@ public void test420AddUserDrakeWithAssignment() throws Exception { display("User before", userBefore); // WHEN - when(TEST_NAME); + when(); addObject(userBefore, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); String accountOid = assertUserAfter(USER_DRAKE_OID) .singleLink() - .getOid(); + .getOid(); assertRepoShadow(accountOid) // Lifecycle state is always proposed, even for encrypted passwords. @@ -3012,8 +2875,6 @@ public void test420AddUserDrakeWithAssignment() throws Exception { */ @Test public void test500JackAssignResourceSouvenir() throws Exception { - final String TEST_NAME = "test500JackAssignResourceSouvenir"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -3035,11 +2896,11 @@ public void test500JackAssignResourceSouvenir() throws Exception { assertUserPassword(userBefore, USER_PASSWORD_VALID_3); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_SOUVENIR_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3074,8 +2935,6 @@ public void test500JackAssignResourceSouvenir() throws Exception { */ @Test public void test502JackInitializeAccountSouvenir() throws Exception { - final String TEST_NAME = "test502JackInitializeAccountSouvenir"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -3084,11 +2943,11 @@ public void test502JackInitializeAccountSouvenir() throws Exception { ObjectDelta shadowDelta = createAccountInitializationDelta(accountJackSouvenirOid, PASSWORD_ALLIGATOR); // WHEN - when(TEST_NAME); + when(); executeChanges(shadowDelta, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3119,8 +2978,6 @@ public void test502JackInitializeAccountSouvenir() throws Exception { */ @Test public void test510JackAssignResourceMaverick() throws Exception { - final String TEST_NAME = "test510JackAssignResourceMaverick"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -3134,11 +2991,11 @@ public void test510JackAssignResourceMaverick() throws Exception { assertUserPassword(userBefore, USER_PASSWORD_VALID_3); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_MAVERICK_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3164,8 +3021,6 @@ public void test510JackAssignResourceMaverick() throws Exception { */ @Test public void test512JackInitializeAccountMaverickAlligator() throws Exception { - final String TEST_NAME = "test512JackInitializeAccountMaverick"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -3174,11 +3029,11 @@ public void test512JackInitializeAccountMaverickAlligator() throws Exception { ObjectDelta shadowDelta = createAccountInitializationDelta(accountJackMaverickOid, PASSWORD_ALLIGATOR); // WHEN - when(TEST_NAME); + when(); executeChanges(shadowDelta, null, task, result); // THEN - then(TEST_NAME); + then(); assertPartialError(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3200,8 +3055,6 @@ public void test512JackInitializeAccountMaverickAlligator() throws Exception { */ @Test public void test514JackInitializeAccountMaverickCrododile() throws Exception { - final String TEST_NAME = "test514JackInitializeAccountMaverickCrododile"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -3210,11 +3063,11 @@ public void test514JackInitializeAccountMaverickCrododile() throws Exception { ObjectDelta shadowDelta = createAccountInitializationDelta(accountJackMaverickOid, PASSWORD_CROCODILE); // WHEN - when(TEST_NAME); + when(); executeChanges(shadowDelta, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3240,19 +3093,17 @@ public void test514JackInitializeAccountMaverickCrododile() throws Exception { */ @Test public void test516JackChangePasswordResourceMaverickAlligator() throws Exception { - final String TEST_NAME = "test516JackChangePasswordResourceMaverickAlligator"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); modifyAccountChangePassword(accountJackMaverickOid, PASSWORD_ALLIGATOR, task, result); // THEN - then(TEST_NAME); + then(); assertPartialError(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3270,19 +3121,17 @@ public void test516JackChangePasswordResourceMaverickAlligator() throws Exceptio */ @Test public void test518JackChangePasswordResourceMaverickGiantLizard() throws Exception { - final String TEST_NAME = "test518JackChangePasswordResourceMaverickGiantLizard"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); modifyAccountChangePassword(accountJackMaverickOid, PASSWORD_GIANT_LIZARD, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3299,8 +3148,6 @@ public void test518JackChangePasswordResourceMaverickGiantLizard() throws Except */ @Test public void test530JackUnassignResourceSouvenir() throws Exception { - final String TEST_NAME = "test530JackUnassignResourceSouvenir"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -3313,11 +3160,11 @@ public void test530JackUnassignResourceSouvenir() throws Exception { assertLinks(userBefore, 6); // WHEN - when(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_SOUVENIR_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3336,8 +3183,6 @@ public void test530JackUnassignResourceSouvenir() throws Exception { */ @Test public void test532JackChangePasswordResourceBlueAlligator() throws Exception { - final String TEST_NAME = "test532JackChangePasswordResourceBlueAlligator"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -3350,11 +3195,11 @@ public void test532JackChangePasswordResourceBlueAlligator() throws Exception { accountJackBlueOid = assertAccount(userBefore, RESOURCE_DUMMY_BLUE_OID); // WHEN - when(TEST_NAME); + when(); modifyAccountChangePassword(accountJackBlueOid, PASSWORD_ALLIGATOR, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3375,19 +3220,17 @@ public void test532JackChangePasswordResourceBlueAlligator() throws Exception { */ @Test public void test535ModifyUserJackPasswordAlligator() throws Exception { - final String TEST_NAME = "test535ModifyUserJackPasswordAlligator"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); modifyUserChangePassword(USER_JACK_OID, PASSWORD_ALLIGATOR, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3405,8 +3248,6 @@ public void test535ModifyUserJackPasswordAlligator() throws Exception { */ @Test public void test539JackUnassignResourceMaverick() throws Exception { - final String TEST_NAME = "test539JackUnassignResourceMaverick"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -3419,11 +3260,11 @@ public void test539JackUnassignResourceMaverick() throws Exception { assertLinks(userBefore, 5); // WHEN - when(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_MAVERICK_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3440,7 +3281,7 @@ public void test539JackUnassignResourceMaverick() throws Exception { */ @Test public void test550JackManyPasswordChangesClear() throws Exception { - testJackManyPasswordChanges("test550JackManyPasswordChangesClear", "TesT550x", null); + testJackManyPasswordChanges("TesT550x", null); } /** @@ -3448,13 +3289,13 @@ public void test550JackManyPasswordChangesClear() throws Exception { */ @Test public void test552JackManyPasswordChangesEncrypted() throws Exception { - testJackManyPasswordChanges("test552JackManyPasswordChangesEncrypted", "TesT552x", CredentialsStorageTypeType.ENCRYPTION); + testJackManyPasswordChanges("TesT552x", CredentialsStorageTypeType.ENCRYPTION); } /** * MID-4507 */ - public void testJackManyPasswordChanges(final String TEST_NAME, String passwordPrefix, CredentialsStorageTypeType storageType) throws Exception { + public void testJackManyPasswordChanges(String passwordPrefix, CredentialsStorageTypeType storageType) throws Exception { // GIVEN prepareTest(); @@ -3466,13 +3307,14 @@ public void testJackManyPasswordChanges(final String TEST_NAME, String passwordP assertLinks(userBefore, 4); for (int i = 1; i < 10; i++) { - testJackManyPasswordChangesAttempt(TEST_NAME, passwordPrefix, storageType, i); + testJackManyPasswordChangesAttempt(passwordPrefix, storageType, i); } - } - private void testJackManyPasswordChangesAttempt(String TEST_NAME, String passwordPrefix, CredentialsStorageTypeType storageType, int i) throws Exception { - Task task = getTestTask(); + private void testJackManyPasswordChangesAttempt( + String passwordPrefix, CredentialsStorageTypeType storageType, int i) + throws Exception { + Task task = createTask("testJackManyPasswordChangesAttempt-" + i); OperationResult result = task.getResult(); String newPassword = passwordPrefix + i; @@ -3483,11 +3325,11 @@ private void testJackManyPasswordChangesAttempt(String TEST_NAME, String passwor } // WHEN - when(TEST_NAME + "-" + i); - modifyUserReplace(USER_JACK_OID, PASSWORD_VALUE_PATH, task, result, userPasswordPs); + when("iteration-" + i); + modifyUserReplace(USER_JACK_OID, PASSWORD_VALUE_PATH, task, result, userPasswordPs); // THEN - then(TEST_NAME + "-" + i); + then("iteration-" + i); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3502,15 +3344,13 @@ private void testJackManyPasswordChangesAttempt(String TEST_NAME, String passwor /** * Jack changing his own password. He does it as an admin * and there is no old password specified. RunAs should NOT be used. - * + *

* This also sets predictable password for next test. - * + *

* MID-4661 */ @Test public void test560ChangeJackPasswordSuperuser() throws Exception { - final String TEST_NAME = "test560ChangeJackPasswordSuperuser"; - // GIVEN prepareTest(); @@ -3518,24 +3358,24 @@ public void test560ChangeJackPasswordSuperuser() throws Exception { // preconditions assertUserBefore(USER_JACK_OID) - .displayWithProjections() - .assertLinks(4); + .displayWithProjections() + .assertLinks(4); assertDummyAccountByUsername(null, ACCOUNT_JACK_DUMMY_USERNAME) - .assertLastModifier(null); + .assertLastModifier(null); login(USER_JACK_USERNAME); - Task task = createTask(TEST_NAME, getSecurityContextPrincipal()); + Task task = createTask(getSecurityContextPrincipal()); task.setChannel(SchemaConstants.CHANNEL_GUI_USER_URI); OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modifyUserChangePassword(USER_JACK_OID, USER_PASSWORD_VALID_4, task, result); // THEN - then(TEST_NAME); + then(); login(USER_ADMINISTRATOR_USERNAME); assertSuccess(result); @@ -3546,16 +3386,16 @@ public void test560ChangeJackPasswordSuperuser() throws Exception { // default password mapping is normal assertDummyAccountByUsername(null, ACCOUNT_JACK_DUMMY_USERNAME) - .assertPassword(USER_PASSWORD_VALID_4) - .assertLastModifier(null); + .assertPassword(USER_PASSWORD_VALID_4) + .assertLastModifier(null); // RED password mapping is strong assertDummyAccountByUsername(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME) - .assertFullName(USER_JACK_FULL_NAME) - .assertEnabled() - .assertPassword(USER_PASSWORD_VALID_4) - // and RED resource has no runAs capability - .assertLastModifier(null); + .assertFullName(USER_JACK_FULL_NAME) + .assertEnabled() + .assertPassword(USER_PASSWORD_VALID_4) + // and RED resource has no runAs capability + .assertLastModifier(null); // BLUE password mapping is weak, we do not really care about password change here // we do not really care about ugly resource either @@ -3563,36 +3403,34 @@ public void test560ChangeJackPasswordSuperuser() throws Exception { displayAccountPasswordNotifications(); assertAccountPasswordNotifications(2); assertHasAccountPasswordNotification(null, USER_JACK_USERNAME, USER_PASSWORD_VALID_4); - assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_VALID_4); - // not BLUE, it already has a password + assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_VALID_4); + // not BLUE, it already has a password assertSingleUserPasswordNotification(USER_JACK_USERNAME, USER_PASSWORD_VALID_4); } /** * Self-service password change. User's own identity should be used * to change password on resource that have runAs capability. - * + *

* MID-4661 */ @Test public void test562ChangeJackPasswordSelfService() throws Exception { - final String TEST_NAME = "test562ChangeJackPasswordSelfService"; - // GIVEN prepareTest(); // preconditions assertUserBefore(USER_JACK_OID) - .displayWithProjections() - .assertLinks(4); + .displayWithProjections() + .assertLinks(4); assertDummyAccountByUsername(null, ACCOUNT_JACK_DUMMY_USERNAME) - .assertPassword(USER_PASSWORD_VALID_4) - .assertLastModifier(null); + .assertPassword(USER_PASSWORD_VALID_4) + .assertLastModifier(null); login(USER_JACK_USERNAME); - Task task = createTask(TEST_NAME, getSecurityContextPrincipal()); + Task task = createTask(getSecurityContextPrincipal()); task.setChannel(SchemaConstants.CHANNEL_GUI_SELF_SERVICE_URI); OperationResult result = task.getResult(); @@ -3600,11 +3438,11 @@ public void test562ChangeJackPasswordSelfService() throws Exception { USER_PASSWORD_VALID_4, USER_PASSWORD_VALID_5); // WHEN - when(TEST_NAME); + when(); executeChanges(objectDelta, null, task, result); // THEN - then(TEST_NAME); + then(); login(USER_ADMINISTRATOR_USERNAME); assertSuccess(result); @@ -3615,16 +3453,16 @@ public void test562ChangeJackPasswordSelfService() throws Exception { // default password mapping is normal assertDummyAccountByUsername(null, ACCOUNT_JACK_DUMMY_USERNAME) - .assertPassword(USER_PASSWORD_VALID_5) - .assertLastModifier(ACCOUNT_JACK_DUMMY_USERNAME); + .assertPassword(USER_PASSWORD_VALID_5) + .assertLastModifier(ACCOUNT_JACK_DUMMY_USERNAME); // RED password mapping is strong assertDummyAccountByUsername(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME) - .assertFullName(USER_JACK_FULL_NAME) - .assertEnabled() - .assertPassword(USER_PASSWORD_VALID_5) - // and RED resource has no runAs capability - .assertLastModifier(null); + .assertFullName(USER_JACK_FULL_NAME) + .assertEnabled() + .assertPassword(USER_PASSWORD_VALID_5) + // and RED resource has no runAs capability + .assertLastModifier(null); // BLUE password mapping is weak, we do not really care about password change here // we do not really care about ugly resource either @@ -3632,8 +3470,8 @@ public void test562ChangeJackPasswordSelfService() throws Exception { displayAccountPasswordNotifications(); assertAccountPasswordNotifications(2); assertHasAccountPasswordNotification(null, USER_JACK_USERNAME, USER_PASSWORD_VALID_5); - assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_VALID_5); - // not BLUE, it already has a password + assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_VALID_5); + // not BLUE, it already has a password assertSingleUserPasswordNotification(USER_JACK_USERNAME, USER_PASSWORD_VALID_5); } @@ -3642,29 +3480,26 @@ public void test562ChangeJackPasswordSelfService() throws Exception { * Old password is (strangely) specified. * But as this is not user changing its own password then RunAs * should NOT be used. - * + *

* MID-4661 */ @Test public void test564ChangeJackPasswordAdmin() throws Exception { - final String TEST_NAME = "test564ChangeJackPasswordAdmin"; - // GIVEN - prepareTest(); // preconditions assertUserBefore(USER_JACK_OID) - .displayWithProjections() - .assertLinks(4); + .displayWithProjections() + .assertLinks(4); assertDummyAccountByUsername(null, ACCOUNT_JACK_DUMMY_USERNAME) - .assertPassword(USER_PASSWORD_VALID_5) - .assertLastModifier(ACCOUNT_JACK_DUMMY_USERNAME); + .assertPassword(USER_PASSWORD_VALID_5) + .assertLastModifier(ACCOUNT_JACK_DUMMY_USERNAME); login(USER_ADMINISTRATOR_USERNAME); - Task task = createTask(TEST_NAME, getSecurityContextPrincipal()); + Task task = createTask(getSecurityContextPrincipal()); task.setChannel(SchemaConstants.CHANNEL_GUI_USER_URI); OperationResult result = task.getResult(); @@ -3672,11 +3507,11 @@ public void test564ChangeJackPasswordAdmin() throws Exception { USER_PASSWORD_VALID_5, USER_PASSWORD_VALID_6); // WHEN - when(TEST_NAME); + when(); executeChanges(objectDelta, null, task, result); // THEN - then(TEST_NAME); + then(); login(USER_ADMINISTRATOR_USERNAME); assertSuccess(result); @@ -3687,16 +3522,16 @@ public void test564ChangeJackPasswordAdmin() throws Exception { // default password mapping is normal assertDummyAccountByUsername(null, ACCOUNT_JACK_DUMMY_USERNAME) - .assertPassword(USER_PASSWORD_VALID_6) - .assertLastModifier(null); + .assertPassword(USER_PASSWORD_VALID_6) + .assertLastModifier(null); // RED password mapping is strong assertDummyAccountByUsername(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME) - .assertFullName(USER_JACK_FULL_NAME) - .assertEnabled() - .assertPassword(USER_PASSWORD_VALID_6) - // and RED resource has no runAs capability - .assertLastModifier(null); + .assertFullName(USER_JACK_FULL_NAME) + .assertEnabled() + .assertPassword(USER_PASSWORD_VALID_6) + // and RED resource has no runAs capability + .assertLastModifier(null); // BLUE password mapping is weak, we do not really care about password change here // we do not really care about ugly resource either @@ -3704,13 +3539,11 @@ public void test564ChangeJackPasswordAdmin() throws Exception { displayAccountPasswordNotifications(); assertAccountPasswordNotifications(2); assertHasAccountPasswordNotification(null, USER_JACK_USERNAME, USER_PASSWORD_VALID_6); - assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_VALID_6); - // not BLUE, it already has a password + assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_VALID_6); + // not BLUE, it already has a password assertSingleUserPasswordNotification(USER_JACK_USERNAME, USER_PASSWORD_VALID_6); } - - protected ObjectDelta createAccountInitializationDelta(String accountOid, String newAccountPassword) { ObjectDelta shadowDelta = prismContext.deltaFactory().object() .createEmptyModifyDelta(ShadowType.class, accountOid); @@ -3771,7 +3604,7 @@ protected void assertShadowLifecycle(PrismObject shadow, String expe if (expectedLifecycle == null) { String actualLifecycle = shadow.asObjectable().getLifecycleState(); if (actualLifecycle != null && !SchemaConstants.LIFECYCLE_ACTIVE.equals(actualLifecycle)) { - fail("Expected default lifecycle for "+shadow+", but was "+actualLifecycle); + fail("Expected default lifecycle for " + shadow + ", but was " + actualLifecycle); } } else { PrismAsserts.assertPropertyValue(shadow, ObjectType.F_LIFECYCLE_STATE, expectedLifecycle); @@ -3793,8 +3626,6 @@ private void assertShadowPasswordMetadata(PrismObject shadow, */ @Test public void test900ModifyUserElainePassword() throws Exception { - final String TEST_NAME = "test900ModifyUserElainePassword"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -3822,14 +3653,12 @@ public void test900ModifyUserElainePassword() throws Exception { displayAccountPasswordNotifications(); assertAccountPasswordNotifications(3); assertHasAccountPasswordNotification(null, USER_ELAINE_USERNAME, USER_PASSWORD_VALID_1); - assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_ELAINE_USERNAME, USER_PASSWORD_VALID_1); - assertHasAccountPasswordNotification(RESOURCE_DUMMY_BLUE_NAME, USER_ELAINE_USERNAME, USER_PASSWORD_VALID_1); + assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_ELAINE_USERNAME, USER_PASSWORD_VALID_1); + assertHasAccountPasswordNotification(RESOURCE_DUMMY_BLUE_NAME, USER_ELAINE_USERNAME, USER_PASSWORD_VALID_1); } @Test public void test902SetPasswordMinAge() throws Exception { - final String TEST_NAME = "test900SetPasswordMinAge"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -3859,8 +3688,6 @@ public void test902SetPasswordMinAge() throws Exception { */ @Test public void test904ModifyUserElainePasswordAgain() throws Exception { - final String TEST_NAME = "test904ModifyUserElainePasswordAgain"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -3892,8 +3719,6 @@ public void test904ModifyUserElainePasswordAgain() throws Exception { @Test public void test906ModifyUserElainePasswordLater() throws Exception { - final String TEST_NAME = "test906ModifyUserElainePasswordLater"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -3919,8 +3744,8 @@ public void test906ModifyUserElainePasswordLater() throws Exception { displayAccountPasswordNotifications(); assertAccountPasswordNotifications(2); assertHasAccountPasswordNotification(null, USER_ELAINE_USERNAME, USER_PASSWORD_VALID_3); - assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_ELAINE_USERNAME, USER_PASSWORD_VALID_3); - // BLUE resource already has a password + assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_ELAINE_USERNAME, USER_PASSWORD_VALID_3); + // BLUE resource already has a password assertSingleUserPasswordNotification(USER_ELAINE_USERNAME, USER_PASSWORD_VALID_3); } @@ -3930,8 +3755,6 @@ public void test906ModifyUserElainePasswordLater() throws Exception { */ @Test public void test910AddUserWithNoPasswordFail() throws Exception { - final String TEST_NAME = "test910AddUserWithNoPasswordFail"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -3941,7 +3764,7 @@ public void test910AddUserWithNoPasswordFail() throws Exception { try { // WHEN+THEN - when(TEST_NAME); + when(); try { UserType user = new UserType(prismContext).name("passwordless"); addObject(user.asPrismObject(), task, result); @@ -3956,12 +3779,10 @@ public void test910AddUserWithNoPasswordFail() throws Exception { } /** - * MID-4593 + * MID-4593 */ @Test public void test920AddCredentials() throws Exception { - final String TEST_NAME = "test920AddCredentials"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -3980,7 +3801,7 @@ public void test920AddCredentials() throws Exception { value.setClearValue(PASSWORD_HELLO_WORLD); CredentialsType credentials = new CredentialsType(prismContext) .beginPassword() - .value(value) + .value(value) .end(); ObjectDelta objectDelta = prismContext.deltaFor(UserType.class) .item(UserType.F_CREDENTIALS).add(credentials) @@ -3996,12 +3817,10 @@ public void test920AddCredentials() throws Exception { } /** - * MID-4593 + * MID-4593 */ @Test public void test922ReplaceCredentials() throws Exception { - final String TEST_NAME = "test922ReplaceCredentials"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -4020,7 +3839,7 @@ public void test922ReplaceCredentials() throws Exception { value.setClearValue(PASSWORD_HELLO_WORLD); CredentialsType credentials = new CredentialsType(prismContext) .beginPassword() - .value(value) + .value(value) .end(); ObjectDelta objectDelta = prismContext.deltaFor(UserType.class) .item(UserType.F_CREDENTIALS).replace(credentials) @@ -4036,12 +3855,10 @@ public void test922ReplaceCredentials() throws Exception { } /** - * MID-4593 + * MID-4593 */ @Test public void test924AddPassword() throws Exception { - final String TEST_NAME = "test924AddPassword"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -4073,12 +3890,10 @@ public void test924AddPassword() throws Exception { } /** - * MID-4593 + * MID-4593 */ @Test public void test926ReplacePassword() throws Exception { - final String TEST_NAME = "test926ReplacePassword"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -4110,12 +3925,10 @@ public void test926ReplacePassword() throws Exception { } /** - * MID-4593 + * MID-4593 */ @Test public void test928AddPasswordValue() throws Exception { - final String TEST_NAME = "test928AddPasswordValue"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -4146,12 +3959,10 @@ public void test928AddPasswordValue() throws Exception { } /** - * MID-4593 + * MID-4593 */ @Test public void test929ReplacePasswordValue() throws Exception { - final String TEST_NAME = "test929ReplacePasswordValue"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -4189,15 +4000,13 @@ public void test929ReplacePasswordValue() throws Exception { */ @Test public void test950RemoveGlobalPasswordPolicy() throws Exception { - final String TEST_NAME = "test950RemoveGlobalPasswordPolicy"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); applyPasswordPolicy(null, getSecurityPolicyOid(), task, result); modifyObjectReplaceProperty(SecurityPolicyType.class, getSecurityPolicyOid(), ItemPath.create(SecurityPolicyType.F_CREDENTIALS, CredentialsPolicyType.F_PASSWORD, PasswordCredentialsPolicyType.F_HISTORY_LENGTH), @@ -4210,7 +4019,7 @@ public void test950RemoveGlobalPasswordPolicy() throws Exception { task, result /* no value */); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject securityPolicyAfter = getObject(SecurityPolicyType.class, getSecurityPolicyOid()); @@ -4227,8 +4036,6 @@ public void test950RemoveGlobalPasswordPolicy() throws Exception { */ @Test public void test952SetupOrgPolicy() throws Exception { - final String TEST_NAME = "test952SetupOrgPolicy"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -4236,11 +4043,11 @@ public void test952SetupOrgPolicy() throws Exception { PrismObject securityPolicy = prismContext.createObject(SecurityPolicyType.class); securityPolicy.asObjectable() - .name("Ministry security policy") - .beginCredentials() + .name("Ministry security policy") + .beginCredentials() .beginPassword() - .valuePolicyRef(PASSWORD_POLICY_GLOBAL_OID, ValuePolicyType.COMPLEX_TYPE) - .historyLength(ORG_MINISTRY_OF_OFFENSE_PASSWORD_HISTORY_LENGTH); + .valuePolicyRef(PASSWORD_POLICY_GLOBAL_OID, ValuePolicyType.COMPLEX_TYPE) + .historyLength(ORG_MINISTRY_OF_OFFENSE_PASSWORD_HISTORY_LENGTH); ministrySecurityPolicyOid = addObject(securityPolicy, task, result); PrismReferenceValue securityPolicyRef = itemFactory().createReferenceValue(); @@ -4249,11 +4056,11 @@ public void test952SetupOrgPolicy() throws Exception { OrgType.F_SECURITY_POLICY_REF, task, result, securityPolicyRef); // WHEN - when(TEST_NAME); + when(); assignOrg(USER_THREE_HEADED_MONKEY_OID, ORG_MINISTRY_OF_OFFENSE_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject ministryPolicyAfter = getObject(OrgType.class, ORG_MINISTRY_OF_OFFENSE_OID); @@ -4275,8 +4082,6 @@ public void test952SetupOrgPolicy() throws Exception { */ @Test public void test954ModifyUserMonkeyPasswordAA() throws Exception { - final String TEST_NAME = "test954ModifyUserMonkeyPasswordAA"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -4284,7 +4089,7 @@ public void test954ModifyUserMonkeyPasswordAA() throws Exception { try { // WHEN - when(TEST_NAME); + when(); modifyUserChangePassword(USER_THREE_HEADED_MONKEY_OID, USER_PASSWORD_AA_CLEAR, task, result); @@ -4295,7 +4100,7 @@ public void test954ModifyUserMonkeyPasswordAA() throws Exception { } // THEN - then(TEST_NAME); + then(); assertFailure(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -4310,20 +4115,18 @@ public void test954ModifyUserMonkeyPasswordAA() throws Exception { */ @Test public void test956ModifyUserJackPasswordAA() throws Exception { - final String TEST_NAME = "test956ModifyUserJackPasswordAA"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); modifyUserChangePassword(USER_JACK_OID, USER_PASSWORD_AA_CLEAR, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -4339,19 +4142,17 @@ public void test956ModifyUserJackPasswordAA() throws Exception { */ @Test public void test961RecomputeMonkey() throws Exception { - final String TEST_NAME = "test961RecomputeMonkey"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_THREE_HEADED_MONKEY_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -4367,19 +4168,17 @@ public void test961RecomputeMonkey() throws Exception { */ @Test public void test962ReconcileMonkey() throws Exception { - final String TEST_NAME = "test962ReconcileMonkey"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_THREE_HEADED_MONKEY_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -4395,20 +4194,18 @@ public void test962ReconcileMonkey() throws Exception { */ @Test public void test964ModifyUserMonkeyLocality() throws Exception { - final String TEST_NAME = "test964ModifyUserMonkeyLocality"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_THREE_HEADED_MONKEY_OID, UserType.F_LOCALITY, task, result, createPolyString("Scabb Island")); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -4429,20 +4226,18 @@ public void test964ModifyUserMonkeyLocality() throws Exception { */ @Test public void test965AssignMonkeyAccountBlue() throws Exception { - final String TEST_NAME = "test965AssignMonkeyAccountBlue"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_THREE_HEADED_MONKEY_OID, RESOURCE_DUMMY_BLUE_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -4463,20 +4258,18 @@ public void test965AssignMonkeyAccountBlue() throws Exception { */ @Test public void test966AssignMonkeyAccountYellow() throws Exception { - final String TEST_NAME = "test966AssignMonkeyAccountYellow"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_THREE_HEADED_MONKEY_OID, RESOURCE_DUMMY_YELLOW_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertPartialError(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -4496,31 +4289,29 @@ public void test966AssignMonkeyAccountYellow() throws Exception { */ @Test public void test970ReapplyGlobalPasswordPolicy() throws Exception { - final String TEST_NAME = "test970ReapplyGlobalPasswordPolicy"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // preconditions - assertUserBefore(USER_JACK_OID) - .displayWithProjections() - .assertLinks(4); + assertUserBefore(USER_JACK_OID) + .displayWithProjections() + .assertLinks(4); - // Make sure that no global password policy is applied by setting some insane passwords + // Make sure that no global password policy is applied by setting some insane passwords modifyUserChangePassword(USER_JACK_OID, USER_PASSWORD_LLL_CLEAR); modifyUserChangePassword(USER_JACK_OID, USER_PASSWORD_A_CLEAR); // WHEN - when(TEST_NAME); + when(); applyPasswordPolicy(PASSWORD_POLICY_GLOBAL_OID, getSecurityPolicyOid(), task, result); modifyObjectReplaceProperty(SecurityPolicyType.class, getSecurityPolicyOid(), ItemPath.create(SecurityPolicyType.F_CREDENTIALS, CredentialsPolicyType.F_PASSWORD, PasswordCredentialsPolicyType.F_HISTORY_LENGTH), task, result, GLOBAL_POLICY_NEW_PASSWORD_HISTORY_LENGTH); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject securityPolicyAfter = getObject(SecurityPolicyType.class, getSecurityPolicyOid()); @@ -4539,15 +4330,13 @@ public void test970ReapplyGlobalPasswordPolicy() throws Exception { */ @Test public void test972ChangePasswordJack() throws Exception { - final String TEST_NAME = "test970ReapplyGlobalPasswordPolicy"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); modifyUserChangePassword(USER_JACK_OID, USER_PASSWORD_VALID_1); modifyUserChangePassword(USER_JACK_OID, USER_PASSWORD_VALID_2); @@ -4568,7 +4357,7 @@ public void test972ChangePasswordJack() throws Exception { modifyUserChangePassword(USER_JACK_OID, USER_PASSWORD_VALID_1); // THEN - then(TEST_NAME); + then(); assertSuccess(result); } @@ -4581,15 +4370,13 @@ public void test972ChangePasswordJack() throws Exception { */ @Test public void test974ChangePasswordJack() throws Exception { - final String TEST_NAME = "test970ReapplyGlobalPasswordPolicy"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); modifyUserChangePassword(USER_THREE_HEADED_MONKEY_OID, USER_PASSWORD_VALID_1); modifyUserChangePassword(USER_THREE_HEADED_MONKEY_OID, USER_PASSWORD_VALID_2); @@ -4610,18 +4397,16 @@ public void test974ChangePasswordJack() throws Exception { modifyUserChangePassword(USER_THREE_HEADED_MONKEY_OID, USER_PASSWORD_VALID_2); // THEN - then(TEST_NAME); + then(); assertSuccess(result); - } - private void modifyUserChangePasswordPolicyViolation(String userOid, String newPassword) throws CommonException { - Task task = getTestTask(); + Task task = createTask("modifyUserChangePasswordPolicyViolation"); OperationResult result = task.getResult(); try { modifyUserChangePassword(userOid, newPassword, task, result); - fail("Change of password '"+newPassword+"' succeeded for user "+userOid+", expected failure"); + fail("Change of password '" + newPassword + "' succeeded for user " + userOid + ", expected failure"); } catch (PolicyViolationException e) { assertFailure(result); } @@ -4639,7 +4424,7 @@ protected PrismObject getBlueShadow(PrismObject userAfter) Collection> options = getOperationOptionsBuilder() .item(SchemaConstants.PATH_PASSWORD_VALUE).retrieve() .build(); - PrismObject shadow = modelService.getObject(ShadowType.class, accountBlueOid, options , task, result); + PrismObject shadow = modelService.getObject(ShadowType.class, accountBlueOid, options, task, result); result.computeStatus(); TestUtil.assertSuccess("getObject(Account) result not success", result); display("Blue shadow", shadow); @@ -4655,15 +4440,15 @@ protected void assertCachedResourcePassword(PrismObject shadow, Stri if (expectedPassword == null && credentials == null) { return; } - assertNotNull("Missing credentendials in repo shadow "+shadow, credentials); + assertNotNull("Missing credentendials in repo shadow " + shadow, credentials); PasswordType passwordType = credentials.getPassword(); if (expectedPassword == null && passwordType == null) { return; } - assertNotNull("Missing password credential in repo shadow "+shadow, passwordType); + assertNotNull("Missing password credential in repo shadow " + shadow, passwordType); ProtectedStringType protectedStringType = passwordType.getValue(); - assertNotNull("No password value in repo shadow "+shadow, protectedStringType); - assertProtectedString("Wrong password value in repo shadow "+shadow, expectedPassword, protectedStringType, CredentialsStorageTypeType.HASHING); + assertNotNull("No password value in repo shadow " + shadow, protectedStringType); + assertProtectedString("Wrong password value in repo shadow " + shadow, expectedPassword, protectedStringType, CredentialsStorageTypeType.HASHING); } private void assertPasswordCreateMetadata(PrismObject user) { diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefault.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefault.java index 30355144993..bfaf30dd3c7 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefault.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefault.java @@ -52,10 +52,8 @@ protected void assertShadowLifecycle(PrismObject shadow, boolean foc */ @Test public void test202ReconcileUserJack() throws Exception { - final String TEST_NAME = "test202ReconcileUserJack"; - // GIVEN - Task task = taskManager.createTaskInstance(AbstractPasswordTest.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -63,11 +61,11 @@ public void test202ReconcileUserJack() throws Exception { assertLinks(userBefore, 4); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertPartialError(result); PrismObject userAfter = getUser(USER_JACK_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefaultHashing.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefaultHashing.java index 686e6527cfb..568bc8c4301 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefaultHashing.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefaultHashing.java @@ -65,10 +65,8 @@ protected void assertShadowLifecycle(PrismObject shadow, boolean foc */ @Test public void test202ReconcileUserJack() throws Exception { - final String TEST_NAME = "test202ReconcileUserJack"; - // GIVEN - Task task = taskManager.createTaskInstance(AbstractPasswordTest.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -124,7 +122,6 @@ protected void assert31xBluePasswordAfterPasswordChange(PrismObject us protected void assertAccountActivationNotification(String dummyResourceName, String username) { checkDummyTransportMessages(NOTIFIER_ACCOUNT_ACTIVATION_NAME, 1); String body = getDummyTransportMessageBody(NOTIFIER_ACCOUNT_ACTIVATION_NAME, 0); - //String expectedPrefix = getExpectedAccountPasswordNotificationBodyPrefix(dummyResourceName, username); if (!body.contains("activat")) { fail("Activation not mentioned in "+dummyResourceName+" dummy account activation notification message : "+body); } @@ -143,20 +140,18 @@ protected void assertAccountActivationNotification(String dummyResourceName, Str @Test @Override public void test345AssignMonkeyAccountBlue() throws Exception { - final String TEST_NAME = "test345AssignMonkeyAccountBlue"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_THREE_HEADED_MONKEY_OID, RESOURCE_DUMMY_BLUE_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -168,7 +163,7 @@ public void test345AssignMonkeyAccountBlue() throws Exception { assertDummyAccount(RESOURCE_DUMMY_BLUE_NAME, USER_THREE_HEADED_MONKEY_NAME); // CLEANUP - displayCleanup(TEST_NAME); + displayCleanup(contextName()); unassignAccountFromUser(USER_THREE_HEADED_MONKEY_OID, RESOURCE_DUMMY_BLUE_OID, null, task, result); @@ -191,20 +186,18 @@ public void test345AssignMonkeyAccountBlue() throws Exception { @Test @Override public void test347AssignMonkeyAccountYellow() throws Exception { - final String TEST_NAME = "test347AssignMonkeyYellow"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_THREE_HEADED_MONKEY_OID, RESOURCE_DUMMY_YELLOW_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -217,7 +210,7 @@ public void test347AssignMonkeyAccountYellow() throws Exception { assertNoDummyAccount(RESOURCE_DUMMY_BLUE_NAME, USER_THREE_HEADED_MONKEY_NAME); // CLEANUP - displayCleanup(TEST_NAME); + displayCleanup(contextName()); unassignAccountFromUser(USER_THREE_HEADED_MONKEY_OID, RESOURCE_DUMMY_YELLOW_OID, null, task, result); @@ -241,20 +234,18 @@ public void test347AssignMonkeyAccountYellow() throws Exception { @Test @Override public void test966AssignMonkeyAccountYellow() throws Exception { - final String TEST_NAME = "test966AssignMonkeyAccountYellow"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_THREE_HEADED_MONKEY_OID, RESOURCE_DUMMY_YELLOW_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); From 8663788ced7d52f75c6a799873e1607151d22fe6 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Sun, 1 Mar 2020 22:08:03 +0100 Subject: [PATCH 73/97] TestLdapSyncMassive/TestLdapUniversity: cleanup/reformat --- .../testing/longtest/TestLdapUniversity.java | 161 ++++++------------ .../story/ldap/TestLdapSyncMassive.java | 23 +-- 2 files changed, 59 insertions(+), 125 deletions(-) diff --git a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdapUniversity.java b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdapUniversity.java index 50c21688018..b1a65c9d822 100644 --- a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdapUniversity.java +++ b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdapUniversity.java @@ -6,6 +6,25 @@ */ package com.evolveum.midpoint.testing.longtest; +import static org.testng.AssertJUnit.assertEquals; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import javax.xml.namespace.QName; + +import org.apache.commons.io.IOUtils; +import org.opends.server.types.Entry; +import org.opends.server.types.LDIFImportConfig; +import org.opends.server.util.LDIFException; +import org.opends.server.util.LDIFReader; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.DirtiesContext.ClassMode; +import org.springframework.test.context.ContextConfiguration; +import org.testng.annotations.AfterClass; +import org.testng.annotations.Test; + import com.evolveum.midpoint.common.LoggingConfigurationManager; import com.evolveum.midpoint.common.ProfilingConfigurationManager; import com.evolveum.midpoint.common.configuration.api.MidpointConfiguration; @@ -16,7 +35,6 @@ import com.evolveum.midpoint.schema.internals.InternalsConfig; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; @@ -24,59 +42,29 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemObjectsType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -import org.apache.commons.io.IOUtils; -import org.opends.server.types.Entry; -import org.opends.server.types.LDIFImportConfig; -import org.opends.server.util.LDIFException; -import org.opends.server.util.LDIFReader; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.annotation.DirtiesContext.ClassMode; -import org.springframework.test.context.ContextConfiguration; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Test; - -import javax.xml.namespace.QName; -import java.io.File; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.List; - -import static org.testng.AssertJUnit.assertEquals; /** - * * @author Pavol Mederly - * */ -@ContextConfiguration(locations = {"classpath:ctx-longtest-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-longtest-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public class TestLdapUniversity extends AbstractModelIntegrationTest { - public static final File TEST_DIR = new File(MidPointTestConstants.TEST_RESOURCES_DIR, "ldap-university"); - public static final File SYSTEM_CONFIGURATION_FILE = new File(COMMON_DIR, "system-configuration.xml"); - public static final String SYSTEM_CONFIGURATION_OID = SystemObjectsType.SYSTEM_CONFIGURATION.value(); protected static final File USER_ADMINISTRATOR_FILE = new File(COMMON_DIR, "user-administrator.xml"); protected static final String USER_ADMINISTRATOR_OID = "00000000-0000-0000-0000-000000000002"; - protected static final String USER_ADMINISTRATOR_USERNAME = "administrator"; protected static final File ROLE_SUPERUSER_FILE = new File(COMMON_DIR, "role-superuser.xml"); - protected static final String ROLE_SUPERUSER_OID = "00000000-0000-0000-0000-000000000004"; protected static final File RESOURCE_OPENDJ_FILE = new File(COMMON_DIR, "resource-opendj-university.xml"); - protected static final String RESOURCE_OPENDJ_NAME = "Localhost OpenDJ"; protected static final String RESOURCE_OPENDJ_OID = "10000000-0000-0000-0000-000000000003"; protected static final String RESOURCE_OPENDJ_NAMESPACE = MidPointConstants.NS_RI; // Make it at least 1501 so it will go over the 3000 entries size limit private static final int NUM_LDAP_ENTRIES = 3100; - private static final String LDAP_GROUP_PIRATES_DN = "cn=Pirates,ou=groups,dc=example,dc=com"; - protected ResourceType resourceOpenDjType; protected PrismObject resourceOpenDj; @@ -89,7 +77,7 @@ protected void startResources() throws Exception { } @AfterClass - public static void stopResources() throws Exception { + public static void stopResources() { openDJController.stop(); } @@ -137,140 +125,104 @@ public void test100BigImportWithLinking() throws Exception { OperationResult result = task.getResult(); loadEntries("u"); - createUsers("u", new OperationResult("createUsers")); // we do not want to have all this in the task's result + createUsers(new OperationResult("createUsers")); // we do not want to have all this in the task's result display("e0", findUserByUsername("e0")); - // WHEN when(); - //task.setExtensionPropertyValue(SchemaConstants.MODEL_EXTENSION_WORKER_THREADS, 5); modelService.importFromResource(RESOURCE_OPENDJ_OID, new QName(RESOURCE_OPENDJ_NAMESPACE, "inetOrgPerson"), task, result); - // THEN then(); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); - waitForTaskFinish(task, true, 20000 + NUM_LDAP_ENTRIES*2000, 10000L); + waitForTaskFinish(task, true, 20000 + NUM_LDAP_ENTRIES * 2000, 10000L); - // THEN then(); - int userCount = modelService.countObjects(UserType.class, null, null, task, result); display("Users", userCount); - assertEquals("Unexpected number of users", NUM_LDAP_ENTRIES+1, userCount); + assertEquals("Unexpected number of users", NUM_LDAP_ENTRIES + 1, userCount); display("e0(u0)", findUserByUsername("e0(u0)")); display("e1(u1)", findUserByUsername("e1(u1)")); - assertUser("e0(u0)", task, result); - assertUser("e1(u1)", task, result); + assertUser("e0(u0)"); + assertUser("e1(u1)"); } - private void createUsers(String prefix, OperationResult result) throws ObjectAlreadyExistsException, SchemaException { - final int TICK=100; + private void createUsers(OperationResult result) throws ObjectAlreadyExistsException, SchemaException { + final int TICK = 100; long start = System.currentTimeMillis(); - for(int i=0; i < NUM_LDAP_ENTRIES; i++) { + for (int i = 0; i < NUM_LDAP_ENTRIES; i++) { UserType userType = (UserType) prismContext.getSchemaRegistry().findObjectDefinitionByType(UserType.COMPLEX_TYPE).instantiate().asObjectable(); - if (i%2 == 0) { + if (i % 2 == 0) { userType.setName(createPolyStringType("e" + i)); } else { userType.setName(createPolyStringType("e" + i + "(u" + i + ")")); } - userType.setEmployeeNumber("e"+i); + userType.setEmployeeNumber("e" + i); repositoryService.addObject(userType.asPrismObject(), null, result); - if ((i+1)%TICK == 0 && (i+1) namesToAdd = new ArrayList<>(BATCH); - for(int i=0; i < NUM_LDAP_ENTRIES; i++) { - String name = "user"+i; - Entry entry = createEntry(prefix+i, "e"+i, name); + for (int i = 0; i < NUM_LDAP_ENTRIES; i++) { + String name = "user" + i; + Entry entry = createEntry(prefix + i, "e" + i, name); openDJController.addEntry(entry); -// namesToAdd.add(entry.getDN().toNormalizedString()); -// if (namesToAdd.size() == BATCH) { -// addToGroups(namesToAdd); -// namesToAdd.clear(); -// } - if ((i+1)%TICK == 0 && (i+1) namesToAdd) throws IOException, LDIFException { - for (int groupIndex = 1; groupIndex <= 10; groupIndex++) { - openDJController.addGroupUniqueMembers(groupDn(groupIndex), namesToAdd); - } + display("Loaded " + NUM_LDAP_ENTRIES + " LDAP entries in " + ((ldapPopEnd - ldapPopStart) / 1000) + " seconds"); } private Entry createEntry(String uid, String empno, String name) throws IOException, LDIFException { StringBuilder sb = new StringBuilder(); - String dn = "uid="+uid+","+openDJController.getSuffixPeople(); + String dn = "uid=" + uid + "," + openDJController.getSuffixPeople(); sb.append("dn: ").append(dn).append("\n"); sb.append("objectClass: inetOrgPerson\n"); sb.append("uid: ").append(uid).append("\n"); @@ -279,19 +231,6 @@ private Entry createEntry(String uid, String empno, String name) throws IOExcept sb.append("sn: ").append(name).append("\n"); LDIFImportConfig importConfig = new LDIFImportConfig(IOUtils.toInputStream(sb.toString(), StandardCharsets.UTF_8)); LDIFReader ldifReader = new LDIFReader(importConfig); - Entry ldifEntry = ldifReader.readEntry(); - return ldifEntry; - } - - private String toDn(String username) { - return "uid="+username+","+OPENDJ_PEOPLE_SUFFIX; - } - - private String groupDn(int groupIndex) { - return "cn="+groupCn(groupIndex)+","+OPENDJ_GROUPS_SUFFIX; - } - - private String groupCn(int groupIndex) { - return String.format("g%02d", groupIndex); + return ldifReader.readEntry(); } } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapSyncMassive.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapSyncMassive.java index b8d5754221d..7c2e8628a71 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapSyncMassive.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapSyncMassive.java @@ -104,7 +104,7 @@ protected void startResources() throws Exception { } @AfterClass - public static void stopResources() throws Exception { + public static void stopResources() { openDJController.stop(); } @@ -119,7 +119,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; Task task = getTestTask(); OperationResult testResultOpenDj = modelService.testResource(RESOURCE_OPENDJ_OID, task); @@ -278,8 +277,6 @@ private String goblinUsername(int i) { */ @Test public void test200SyncAddKraken() throws Exception { - final String TEST_NAME = "test200SyncAddKraken"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -393,7 +390,7 @@ public void test230UserRecomputeSequential() throws Exception { when(TEST_NAME); for (PrismObject user : users) { - reconcile(TEST_NAME, user); + reconcile(user); } // THEN @@ -420,7 +417,7 @@ public void test232UserRecomputeParallel() throws Exception { (threadIndex) -> { for (int i = segmentSize * threadIndex; i < segmentSize * threadIndex + segmentSize; i++) { PrismObject user = users.get(i); - reconcile(TEST_NAME, user); + reconcile(user); } }, NUMBER_OF_TEST_THREADS, TEST_THREADS_RANDOM_START_RANGE); @@ -434,7 +431,10 @@ public void test232UserRecomputeParallel() throws Exception { assertLdapConnectorInstances(1, NUMBER_OF_TEST_THREADS); } - private void reconcile(final String TEST_NAME, PrismObject user) throws CommunicationException, ObjectAlreadyExistsException, ExpressionEvaluationException, PolicyViolationException, SchemaException, SecurityViolationException, ConfigurationException, ObjectNotFoundException { + private void reconcile(PrismObject user) + throws SchemaException, ObjectAlreadyExistsException, ExpressionEvaluationException, + PolicyViolationException, CommunicationException, SecurityViolationException, + ConfigurationException, ObjectNotFoundException { user.getName(); Task task = getTestTask(); OperationResult result = task.getResult(); @@ -503,13 +503,8 @@ private void assertThreadCount(int tolerance) { } private boolean isWithinTolerance(int baseline, int currentCount, int tolerance) { - if (currentCount > baseline + tolerance) { - return false; - } - if (currentCount < baseline - tolerance) { - return false; - } - return true; + return currentCount <= baseline + tolerance + && currentCount >= baseline - tolerance; } private void assertSyncTokenIncrement(int expectedIncrement) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { From ff1c49b82ddf2d5d2fd47ef781224eeb23189907 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Sun, 1 Mar 2020 22:37:22 +0100 Subject: [PATCH 74/97] TestLdapSyncMassive fix 232: reconcile uses createTask, not getTestTask --- .../story/ldap/TestLdapSyncMassive.java | 53 +++++++++---------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapSyncMassive.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapSyncMassive.java index 7c2e8628a71..5007adb0cc2 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapSyncMassive.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapSyncMassive.java @@ -39,11 +39,10 @@ * management related to sync (e.g. MID-5099) * * @author Radovan Semancik - * */ -@ContextConfiguration(locations = {"classpath:ctx-story-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-story-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) -public class TestLdapSyncMassive extends AbstractLdapTest { +public class TestLdapSyncMassive extends AbstractLdapTest { public static final File TEST_DIR = new File(LDAP_TEST_DIR, "sync-massive"); @@ -179,7 +178,7 @@ public void test110SyncAddWill() throws Exception { assertLdapConnectorInstances(1); assertUserAfterByUsername(ACCOUNT_WILL_LDAP_UID) - .assertFullName(ACCOUNT_WILL_LDAP_CN); + .assertFullName(ACCOUNT_WILL_LDAP_CN); assertThreadCount(); @@ -218,7 +217,6 @@ public void test112SyncAddGoods() throws Exception { } - /** * Add "goblin" users, each with an LDAP account. * We do not really needs them now. But these will make @@ -239,9 +237,9 @@ public void test150AddGoblins() throws Exception { String username = goblinUsername(i); PrismObject goblin = createUser(username, "Goblin", Integer.toString(i), true); goblin.asObjectable(). - beginAssignment() + beginAssignment() .beginConstruction() - .resourceRef(RESOURCE_OPENDJ_OID, ResourceType.COMPLEX_TYPE); + .resourceRef(RESOURCE_OPENDJ_OID, ResourceType.COMPLEX_TYPE); addObject(goblin); } @@ -265,8 +263,6 @@ public void test150AddGoblins() throws Exception { } - - private String goblinUsername(int i) { return String.format("goblin%05d", i); } @@ -281,7 +277,7 @@ public void test200SyncAddKraken() throws Exception { OperationResult result = task.getResult(); ImportOptionsType options = new ImportOptionsType() - .overwrite(true); + .overwrite(true); importObjectFromFile(RESOURCE_OPENDJ_FILE_BAD, options, task, result); OperationResult testResultOpenDj = modelService.testResource(RESOURCE_OPENDJ_OID, task); @@ -290,7 +286,7 @@ public void test200SyncAddKraken() throws Exception { PrismObject resourceAfter = modelService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, task, result); assertResource(resourceAfter, "after") - .assertHasSchema(); + .assertHasSchema(); assertLdapConnectorInstances(1, INSTANCES_MAX); } @@ -436,7 +432,7 @@ private void reconcile(PrismObject user) PolicyViolationException, CommunicationException, SecurityViolationException, ConfigurationException, ObjectNotFoundException { user.getName(); - Task task = getTestTask(); + Task task = createTask("user." + user.getName()); OperationResult result = task.getResult(); reconcileUser(user.getOid(), task, result); @@ -449,7 +445,7 @@ private void reconcile(PrismObject user) private void syncAddAttemptGood(String prefix, int index) throws Exception { String uid = String.format("%s%05d", prefix, index); - String cn = prefix+" "+index; + String cn = prefix + " " + index; addAttemptEntry(uid, cn, Integer.toString(index)); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_OID, true); @@ -457,7 +453,7 @@ private void syncAddAttemptGood(String prefix, int index) throws Exception { assertSyncTokenIncrement(1); assertUserAfterByUsername(uid) - .assertFullName(cn); + .assertFullName(cn); assertThreadCount(); } @@ -465,7 +461,7 @@ private void syncAddAttemptGood(String prefix, int index) throws Exception { private void syncAddAttemptBad(String prefix, int index) throws Exception { String uid = String.format("%s%05d", prefix, index); - String cn = prefix+" "+index; + String cn = prefix + " " + index; addAttemptEntry(uid, cn, Integer.toString(index)); OperationResult taskResult = waitForTaskNextRun(TASK_LIVE_SYNC_OID); @@ -478,16 +474,16 @@ private void syncAddAttemptBad(String prefix, int index) throws Exception { private void addAttemptEntry(String uid, String cn, String sn) throws Exception { Entry entry = openDJController.addEntry( - "dn: uid="+uid+",ou=People,dc=example,dc=com\n" + - "uid: "+uid+"\n" + - "cn: "+cn+"\n" + - "sn: "+sn+"\n" + - "givenname: "+uid+"\n" + - "objectclass: top\n" + - "objectclass: person\n" + - "objectclass: organizationalPerson\n" + - "objectclass: inetOrgPerson" - ); + "dn: uid=" + uid + ",ou=People,dc=example,dc=com\n" + + "uid: " + uid + "\n" + + "cn: " + cn + "\n" + + "sn: " + sn + "\n" + + "givenname: " + uid + "\n" + + "objectclass: top\n" + + "objectclass: person\n" + + "objectclass: organizationalPerson\n" + + "objectclass: inetOrgPerson" + ); display("Added generated entry", entry); } @@ -498,7 +494,7 @@ private void assertThreadCount() { private void assertThreadCount(int tolerance) { int currentThreadCount = Thread.activeCount(); if (!isWithinTolerance(threadCountBaseline, currentThreadCount, tolerance)) { - fail("Thread count out of tolerance: "+currentThreadCount+" ("+(currentThreadCount-threadCountBaseline)+")"); + fail("Thread count out of tolerance: " + currentThreadCount + " (" + (currentThreadCount - threadCountBaseline) + ")"); } } @@ -510,9 +506,9 @@ private boolean isWithinTolerance(int baseline, int currentCount, int tolerance) private void assertSyncTokenIncrement(int expectedIncrement) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { PrismObject syncTask = getTask(TASK_LIVE_SYNC_OID); Integer currentSyncToken = ObjectTypeUtil.getExtensionItemRealValue(syncTask, SchemaConstants.SYNC_TOKEN); - display("Sync token, last="+lastSyncToken+", current="+currentSyncToken+", expectedIncrement="+expectedIncrement); + display("Sync token, last=" + lastSyncToken + ", current=" + currentSyncToken + ", expectedIncrement=" + expectedIncrement); if (currentSyncToken != lastSyncToken + expectedIncrement) { - fail("Expected sync token increment "+expectedIncrement+", but it was "+(currentSyncToken-lastSyncToken)); + fail("Expected sync token increment " + expectedIncrement + ", but it was " + (currentSyncToken - lastSyncToken)); } lastSyncToken = currentSyncToken; } @@ -522,5 +518,4 @@ protected void dumpLdap() throws DirectoryException { display("LDAP server tree", openDJController.dumpTree()); } - } From 62c8a9db08000445c658b1f8b724a570425d4494 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Sat, 29 Feb 2020 22:00:53 +0100 Subject: [PATCH 75/97] Add resource state change info tests (MID-6019) Also: - cleaned up the code a bit (moved into ResourceOperationalStateManager) - introduced experimental concept of AssertionPredicate for testing --- .../midpoint/prism/Containerable.java | 5 + .../midpoint/prism/xml/XmlTypeConverter.java | 2 +- .../xml/ns/public/common/common-core-3.xsd | 12 +- .../midpoint/model/intest/TestResources.java | 2 +- .../intest/negative/TestBrokenResources.java | 36 +- .../test/AbstractModelIntegrationTest.java | 7 - .../impl/ProvisioningServiceImpl.java | 16 +- .../provisioning/impl/ResourceManager.java | 245 ++++--------- .../impl/ResourceOperationalStateManager.java | 115 ++++++ .../CommunicationExceptionHandler.java | 16 +- .../impl/errorhandling/ErrorHandler.java | 4 +- .../provisioning/impl/csv/TestCsvBroken.java | 345 ++++++++++++++++++ .../impl/dummy/AbstractBasicDummyTest.java | 40 +- .../resources/csv/resource-csv-broken.xml | 27 ++ .../provisioning-impl/testng-integration.xml | 1 + .../test/AbstractIntegrationTest.java | 9 + .../test/asserter/ResourceAsserter.java | 23 ++ .../predicate/AssertionPredicate.java | 19 + .../AssertionPredicateEvaluation.java | 40 ++ .../predicate/GenericAssertionPredicate.java | 39 ++ .../SimplifiedGenericAssertionPredicate.java | 38 ++ .../predicate/StringAssertionPredicates.java | 22 ++ .../predicate/TimeAssertionPredicates.java | 49 +++ .../prism/PrismContainerAsserter.java | 7 + .../prism/PrismContainerValueAsserter.java | 12 + 25 files changed, 901 insertions(+), 230 deletions(-) create mode 100644 provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ResourceOperationalStateManager.java create mode 100644 provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/TestCsvBroken.java create mode 100644 provisioning/provisioning-impl/src/test/resources/csv/resource-csv-broken.xml create mode 100644 repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/predicate/AssertionPredicate.java create mode 100644 repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/predicate/AssertionPredicateEvaluation.java create mode 100644 repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/predicate/GenericAssertionPredicate.java create mode 100644 repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/predicate/SimplifiedGenericAssertionPredicate.java create mode 100644 repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/predicate/StringAssertionPredicates.java create mode 100644 repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/predicate/TimeAssertionPredicates.java diff --git a/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/Containerable.java b/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/Containerable.java index 74475f47a66..fa374c3da57 100644 --- a/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/Containerable.java +++ b/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/Containerable.java @@ -14,6 +14,11 @@ */ public interface Containerable extends Serializable { + static PrismContainerValue asPrismContainerValue(Containerable containerable) { + //noinspection unchecked + return containerable != null ? containerable.asPrismContainerValue() : null; + } + PrismContainerValue asPrismContainerValue(); /** diff --git a/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/xml/XmlTypeConverter.java b/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/xml/XmlTypeConverter.java index 955b237b550..96383d23cf6 100644 --- a/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/xml/XmlTypeConverter.java +++ b/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/xml/XmlTypeConverter.java @@ -175,7 +175,7 @@ public static XMLGregorianCalendar createXMLGregorianCalendar(int year, int mont } public static long toMillis(XMLGregorianCalendar xmlCal) { - if (xmlCal == null){ + if (xmlCal == null) { return 0; } return xmlCal.toGregorianCalendar().getTimeInMillis(); diff --git a/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd b/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd index 9119d235e00..3a88cc654de 100755 --- a/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd +++ b/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd @@ -6332,7 +6332,7 @@ - Holds the information when the change of availabilityStatus was made. + Previous values of the operationalState item. 4.1 @@ -6444,7 +6444,7 @@ Structure containing metadata about operational state of the resource. - E.g. if resource is up or down, when it was last checked, etc. + E.g. if resource is up or down, when it was last changed, etc. It should not contain configuration, just the operational state. @@ -6456,7 +6456,7 @@ - Describes the reason for changing availability status of the resource. + The reason for the last change of availability status. 4.1 @@ -6466,7 +6466,7 @@ - Holds the information when the change of availabilityStatus was made. + The time of the last change of availability status. 4.1 @@ -6476,7 +6476,7 @@ - Holds the information when the change of availabilityStatus was made. + The node that recorded the last change of availability status. 4.1 @@ -6484,7 +6484,7 @@ - + diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestResources.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestResources.java index 147bfdca3eb..004cab768fb 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestResources.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestResources.java @@ -1087,7 +1087,7 @@ private void modifyConfigurationDiffExpressionRaw(final String TEST_NAME, assertCounterIncrement(InternalCounters.CONNECTOR_INSTANCE_CONFIGURATION_COUNT, 1); assertCounterIncrement(InternalCounters.RESOURCE_SCHEMA_FETCH_COUNT, 1); assertCounterIncrement(InternalCounters.CONNECTOR_CAPABILITIES_FETCH_COUNT, 1); - assertCounterIncrement(InternalCounters.RESOURCE_SCHEMA_PARSE_COUNT, 2); + assertCounterIncrement(InternalCounters.RESOURCE_SCHEMA_PARSE_COUNT, 3); PrismObject resourceAfter = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result); display("Resource after", resourceAfter); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestBrokenResources.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestBrokenResources.java index 49ba88ecd0e..3e833ae47e3 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestBrokenResources.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestBrokenResources.java @@ -6,6 +6,9 @@ */ package com.evolveum.midpoint.model.intest.negative; +import static com.evolveum.midpoint.test.asserter.predicate.TimeAssertionPredicates.approximatelyCurrent; +import static com.evolveum.midpoint.test.asserter.predicate.StringAssertionPredicates.startsWith; + import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertNotNull; @@ -13,6 +16,8 @@ import java.util.Collection; import com.evolveum.midpoint.prism.delta.DeltaFactory; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; + import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; @@ -48,14 +53,6 @@ import com.evolveum.midpoint.util.exception.SystemException; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultStatusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; /** * Tests the model service contract by using a broken CSV resource. Tests for negative test cases, mostly @@ -339,14 +336,31 @@ public void test220GetResourceNotFound() throws Exception { PrismObject resource = modelService.getObject(ResourceType.class, RESOURCE_CSVFILE_NOTFOUND_OID, null, task, result); // THEN - display("getObject resource", resource); + String localNodeId = taskManager.getNodeId(); + assertResource(resource, "resource after") + .display() + .operationalState() + .assertAny() + .assertPropertyEquals(OperationalStateType.F_LAST_AVAILABILITY_STATUS, AvailabilityStatusType.BROKEN) + .assertPropertyEquals(OperationalStateType.F_NODE_ID, localNodeId) + .assertPropertyValueSatisfies(OperationalStateType.F_TIMESTAMP, approximatelyCurrent(60000)) + .assertPropertyValueSatisfies(OperationalStateType.F_MESSAGE, startsWith("Status set to BROKEN")) + .end() + .operationalStateHistory() + .assertSize(1) + .value(0) + .assertPropertyEquals(OperationalStateType.F_LAST_AVAILABILITY_STATUS, AvailabilityStatusType.BROKEN) + .assertPropertyEquals(OperationalStateType.F_NODE_ID, localNodeId) + .assertPropertyValueSatisfies(OperationalStateType.F_TIMESTAMP, approximatelyCurrent(60000)) + .assertPropertyValueSatisfies(OperationalStateType.F_MESSAGE, startsWith("Status set to BROKEN")); + result.computeStatus(); display("getObject result", result); - assertEquals("Expected partial errror in result", OperationResultStatus.PARTIAL_ERROR, result.getStatus()); + assertEquals("Expected partial error in result", OperationResultStatus.PARTIAL_ERROR, result.getStatus()); OperationResultType fetchResult = resource.asObjectable().getFetchResult(); display("resource.fetchResult", fetchResult); - assertEquals("Expected partial errror in fetchResult", OperationResultStatusType.PARTIAL_ERROR, fetchResult.getStatus()); + assertEquals("Expected partial error in fetchResult", OperationResultStatusType.PARTIAL_ERROR, fetchResult.getStatus()); // TODO: better asserts assertNotNull("Null resource", resource); diff --git a/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java b/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java index 6f40c32830a..adaf8f4b605 100644 --- a/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java +++ b/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java @@ -6123,13 +6123,6 @@ protected ResourceAsserter assertResource(String oid, String message) thro return assertResource(resource, message); } - protected ResourceAsserter assertResource(PrismObject user, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - ResourceAsserter asserter = ResourceAsserter.forResource(user, message); - initializeAsserter(asserter); - asserter.display(); - return asserter; - } - protected ResourceAsserter assertResourceAfter(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { ResourceAsserter asserter = assertResource(oid, "after"); asserter.assertOid(oid); diff --git a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ProvisioningServiceImpl.java b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ProvisioningServiceImpl.java index b9b3618a6f1..8f960e70d5d 100644 --- a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ProvisioningServiceImpl.java +++ b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ProvisioningServiceImpl.java @@ -190,14 +190,6 @@ public PrismObject getObject(Class type, String oid ProvisioningUtil.recordFatalError(LOGGER, result, "Schema violation", ex); exceptionRecorded = true; throw ex; - } catch (CommunicationException ex) { - ProvisioningUtil.recordFatalError(LOGGER, result, "Error communicating with resource", ex); - exceptionRecorded = true; - throw ex; - } catch (ConfigurationException ex) { - ProvisioningUtil.recordFatalError(LOGGER, result, "Bad resource configuration", ex); - exceptionRecorded = true; - throw ex; } catch (ExpressionEvaluationException ex) { ProvisioningUtil.recordFatalError(LOGGER, result, "Expression error", ex); exceptionRecorded = true; @@ -753,7 +745,7 @@ public PrismObject deleteObject(Class type, String @Override public Object executeScript(String resourceOid, ProvisioningScriptType script, Task task, OperationResult parentResult) throws ObjectNotFoundException, SchemaException, - CommunicationException, ConfigurationException, SecurityViolationException, ObjectAlreadyExistsException, ExpressionEvaluationException { + CommunicationException, ConfigurationException, ExpressionEvaluationException { Validate.notNull(resourceOid, "Oid of object for script execution must not be null."); Validate.notNull(parentResult, "Operation result must not be null."); @@ -767,7 +759,7 @@ public Object executeScript(String resourceOid, Provision scriptResult = resourceManager.executeScript(resourceOid, script, task, result); - } catch (CommunicationException | SchemaException | ConfigurationException | SecurityViolationException | ExpressionEvaluationException | RuntimeException | Error e) { + } catch (CommunicationException | SchemaException | ConfigurationException | ExpressionEvaluationException | RuntimeException | Error e) { ProvisioningUtil.recordFatalError(LOGGER, result, null, e); throw e; } @@ -811,7 +803,6 @@ public OperationResult testResource(String resourceOid, Task task) throws Object } @Deprecated - @SuppressWarnings({ "rawtypes", "unchecked" }) @Override public List> listResourceObjects(String resourceOid, QName objectClass, ObjectPaging paging, Task task, OperationResult parentResult) throws SchemaException, @@ -857,7 +848,7 @@ public List> listResourceObjects(String resour @Override public void refreshShadow(PrismObject shadow, ProvisioningOperationOptions options, Task task, OperationResult parentResult) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, - ObjectAlreadyExistsException, SecurityViolationException, ExpressionEvaluationException { + ExpressionEvaluationException { Validate.notNull(shadow, "Shadow for refresh must not be null."); OperationResult result = parentResult.createSubresult(OPERATION_REFRESH_SHADOW); @@ -1062,7 +1053,6 @@ public List getConnectorOperationalStatus(String res return stats; } - @SuppressWarnings("unchecked") @Override public void applyDefinition(ObjectDelta delta, Task task, OperationResult parentResult) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, ExpressionEvaluationException { diff --git a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ResourceManager.java b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ResourceManager.java index 2a1d56ff889..6231541fabd 100644 --- a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ResourceManager.java +++ b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ResourceManager.java @@ -9,12 +9,8 @@ import java.util.*; -import javax.xml.datatype.DatatypeConstants; -import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; -import com.evolveum.midpoint.common.Clock; -import com.evolveum.midpoint.common.Utils; import com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition; import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl; import com.evolveum.midpoint.prism.*; @@ -22,8 +18,6 @@ import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.schema.MutablePrismSchema; import com.evolveum.midpoint.schema.processor.*; -import com.evolveum.midpoint.task.api.TaskManager; -import com.evolveum.midpoint.util.MiscUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.SchemaDefinitionType; @@ -50,7 +44,6 @@ import com.evolveum.midpoint.schema.CapabilityUtil; import com.evolveum.midpoint.schema.GetOperationOptions; import com.evolveum.midpoint.schema.constants.ConnectorTestOperation; -import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.internals.InternalCounters; import com.evolveum.midpoint.schema.internals.InternalMonitor; import com.evolveum.midpoint.schema.result.OperationResult; @@ -79,8 +72,6 @@ import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.SchemaCapabilityType; import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ScriptCapabilityType; -import static java.util.Collections.singletonList; - @Component public class ResourceManager { @@ -91,21 +82,18 @@ public class ResourceManager { @Autowired private ConnectorManager connectorManager; @Autowired private PrismContext prismContext; @Autowired private ExpressionFactory expressionFactory; - @Autowired private TaskManager taskManager; - @Autowired private Clock clock; + @Autowired private ResourceOperationalStateManager operationalStateManager; private static final Trace LOGGER = TraceManager.getTrace(ResourceManager.class); private static final String OP_COMPLETE_RESOURCE = ResourceManager.class.getName() + ".completeResource"; - private static final int MAX_OPERATIONAL_HISOTRY_SIZE = 5; /** * Completes a resource that has been - we expect - just retrieved from the repository, usually by a search operation. */ PrismObject completeResource(PrismObject repositoryObject, GetOperationOptions options, Task task, OperationResult parentResult) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, - ConfigurationException, CommunicationException { + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException { String oid = repositoryObject.getOid(); boolean readonly = GetOperationOptions.isReadOnly(options); @@ -125,7 +113,7 @@ PrismObject completeResource(PrismObject repositoryO * Gets a resource. */ public PrismObject getResource(String oid, GetOperationOptions options, Task task, OperationResult parentResult) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, ConfigurationException, CommunicationException { + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException { boolean readonly = GetOperationOptions.isReadOnly(options); PrismObject cachedResource = resourceCache.getIfLatest(oid, readonly, parentResult); if (cachedResource != null) { @@ -155,8 +143,7 @@ private PrismObject readResourceFromRepository(String oid, Operati */ private PrismObject completeAndCacheResource(PrismObject repositoryObject, GetOperationOptions options, Task task, OperationResult parentResult) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, - ConfigurationException, CommunicationException { + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException { checkMutable(repositoryObject); @@ -258,7 +245,7 @@ private PrismObject completeResourceInternal(PrismObject resource) { private void completeSchemaAndCapabilities(PrismObject resource, ResourceSchema resourceSchema, boolean fetchedSchema, - Map> capabilityMap, Task task, OperationResult result) + Map> capabilityMap, OperationResult result) throws SchemaException, CommunicationException, ObjectNotFoundException, GenericFrameworkException, ConfigurationException { Collection> modifications = new ArrayList<>(); @@ -342,7 +329,7 @@ private void completeSchemaAndCapabilities(PrismObject resource, R LOGGER.trace("Fetching resource schema for {}", resource); - resourceSchema = fetchResourceSchema(resource, capabilityMap, task, result); + resourceSchema = fetchResourceSchema(resource, capabilityMap, result); if (resourceSchema == null) { LOGGER.warn("No resource schema fetched from {}", resource); @@ -354,23 +341,29 @@ private void completeSchemaAndCapabilities(PrismObject resource, R } } - if (fetchedSchema) { - adjustSchemaForSimulatedCapabilities(resource, resourceSchema); - modifications.add(createSchemaUpdateDelta(resource, resourceSchema)); - - // We have successfully fetched the resource schema. Therefore the resource must be up. - modifications.add(createResourceAvailabilityStatusDelta(AvailabilityStatusType.UP)); - } else { - if (resourceSchema != null) { + if (resourceSchema != null) { + if (fetchedSchema) { + adjustSchemaForSimulatedCapabilities(resource, resourceSchema); + modifications.add(createSchemaUpdateDelta(resource, resourceSchema)); + AvailabilityStatusType previousStatus = ResourceTypeUtil.getLastAvailabilityStatus(resource.asObjectable()); + if (previousStatus != AvailabilityStatusType.UP) { + modifications.addAll(operationalStateManager.createAndLogOperationalStateDeltas(previousStatus, + AvailabilityStatusType.UP, resource.toString(), + "resource schema was successfully fetched", resource)); + } else { + // just for sure (if the status changed in the meanwhile) + modifications.add(operationalStateManager.createAvailabilityStatusDelta(AvailabilityStatusType.UP)); + } + } else { CachingMetadataType schemaCachingMetadata = resource.asObjectable().getSchema().getCachingMetadata(); if (schemaCachingMetadata == null) { schemaCachingMetadata = MiscSchemaUtil.generateCachingMetadata(); modifications.add( prismContext.deltaFactory().property().createModificationReplaceProperty( - ItemPath.create(ResourceType.F_SCHEMA, CapabilitiesType.F_CACHING_METADATA), - resource.getDefinition(), - schemaCachingMetadata) - ); + ItemPath.create(ResourceType.F_SCHEMA, CapabilitiesType.F_CACHING_METADATA), + resource.getDefinition(), + schemaCachingMetadata) + ); } } } @@ -455,6 +448,7 @@ private void completeConnectorCapabilities(ConnectorSpec connectorSpec, Capabili CachingMetadataType cachingMetadata = MiscSchemaUtil.generateCachingMetadata(); capType.setCachingMetadata(cachingMetadata); + //noinspection unchecked ObjectDelta capabilitiesReplaceDelta = prismContext.deltaFactory().object() .createModificationReplaceContainer(ResourceType.class, connectorSpec.getResource().getOid(), itemPath, capType.asPrismContainerValue().clone()); @@ -541,6 +535,7 @@ private void applyConnectorSchemaToResource(ConnectorSpec connectorSpec, PrismOb configurationContainer.applyDefinition(configurationContainerDefinition, true); try { + //noinspection unchecked configurationContainer.accept(visitable -> { if ((visitable instanceof PrismProperty)) { try { @@ -614,7 +609,7 @@ private void evaluateExpression(PrismProperty configurationProperty, Pris PrismValueDeltaSetTriple> expressionOutputTriple = expression.evaluate(expressionContext, result); Collection> expressionOutputValues = expressionOutputTriple.getNonNegativeValues(); - if (expressionOutputValues != null && !expressionOutputValues.isEmpty()) { + if (!expressionOutputValues.isEmpty()) { Iterator> iterator = expressionOutputValues.iterator(); PrismPropertyValue firstValue = iterator.next(); configurationPropertyValue.setValue(firstValue.getValue()); @@ -628,7 +623,7 @@ private void evaluateExpression(PrismProperty configurationProperty, Pris } } - private ResourceSchema fetchResourceSchema(PrismObject resource, Map> capabilityMap, Task task, OperationResult parentResult) + private ResourceSchema fetchResourceSchema(PrismObject resource, Map> capabilityMap, OperationResult parentResult) throws CommunicationException, GenericFrameworkException, ConfigurationException, ObjectNotFoundException, SchemaException { ConnectorSpec connectorSpec = selectConnectorSpec(resource, capabilityMap, SchemaCapabilityType.class); if (connectorSpec == null) { @@ -664,17 +659,17 @@ public void testConnection(PrismObject resource, Task task, Operat String resourceOid = resource.getOid(); - String operationCtx = "test resource " + resourceOid + "connection"; + String operationDesc = "test resource " + resourceOid + "connection"; List allConnectorSpecs; try { allConnectorSpecs = getAllConnectorSpecs(resource); } catch (SchemaException e) { - operationCtx += ", getting all connectors failed: " + e.getMessage(); + String statusChangeReason = operationDesc + ", getting all connectors failed: " + e.getMessage(); if (LOGGER.isTraceEnabled()) { LOGGER.error("Configuration error: {}", e.getMessage(), e); } - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, statusChangeReason, task, parentResult, true); parentResult.recordFatalError("Configuration error: " + e.getMessage(), e); return; } @@ -705,22 +700,22 @@ public void testConnection(PrismObject resource, Task task, Operat ResourceSchema schema; try { - schema = fetchResourceSchema(resource, capabilityMap, task, schemaResult); + schema = fetchResourceSchema(resource, capabilityMap, schemaResult); } catch (CommunicationException e) { - operationCtx += " failed while fetching schema: " + e.getMessage(); + String statusChangeReason = operationDesc + " failed while fetching schema: " + e.getMessage(); if (LOGGER.isTraceEnabled()) { LOGGER.error("Communication error: {}", e.getMessage(), e); } - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.DOWN, operationCtx, task, parentResult, true); + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.DOWN, statusChangeReason, task, parentResult, true); schemaResult.recordFatalError("Communication error: " + e.getMessage(), e); return; } catch (GenericFrameworkException | ConfigurationException | ObjectNotFoundException | SchemaException | RuntimeException e) { - operationCtx += " failed while fetching schema: " + e.getMessage(); + String statusChangeReason = operationDesc + " failed while fetching schema: " + e.getMessage(); if (LOGGER.isTraceEnabled()) { LOGGER.error("Error: {}", e.getMessage(), e); } - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, statusChangeReason, task, parentResult, true); schemaResult.recordFatalError("Error: " + e.getMessage(), e); return; } @@ -731,19 +726,19 @@ public void testConnection(PrismObject resource, Task task, Operat try { schema = RefinedResourceSchemaImpl.getResourceSchema(resource, prismContext); } catch (SchemaException e) { - operationCtx += " failed while parsing refined schema: " + e.getMessage(); + String statusChangeReason = operationDesc + " failed while parsing refined schema: " + e.getMessage(); if (LOGGER.isTraceEnabled()) { LOGGER.error("Error: {}", e.getMessage(), e); } - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, statusChangeReason, task, parentResult, true); schemaResult.recordFatalError(e); return; } if (schema == null || schema.isEmpty()) { String msg = "Connector does not support schema and no static schema available"; - operationCtx += ". " + msg; - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); + String statusChangeReason = operationDesc + ". " + msg; + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, statusChangeReason, task, parentResult, true); schemaResult.recordFatalError(msg); return; } @@ -754,29 +749,31 @@ public void testConnection(PrismObject resource, Task task, Operat // have full schema caching capability. PrismObject completedResource; try { - completedResource = completeResourceInternal(resource, schema, true, capabilityMap, null, task, schemaResult); + // Re-fetching from repository to get up-to-date availability status (to avoid phantom state change records). + PrismObject repoResource = repositoryService.getObject(ResourceType.class, resourceOid, null, schemaResult); + completedResource = completeResourceInternal(repoResource, schema, true, capabilityMap, null, task, schemaResult); } catch (ObjectNotFoundException e) { String msg = "Object not found (unexpected error, probably a bug): " + e.getMessage(); - operationCtx += " failed while completing resource. " + msg; - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); + String statusChangeReason = operationDesc + " failed while completing resource. " + msg; + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, statusChangeReason, task, parentResult, true); schemaResult.recordFatalError(msg, e); return; } catch (SchemaException e) { String msg = "Schema processing error (probably connector bug): " + e.getMessage(); - operationCtx += " failed while completing resource. " + msg; - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); + String statusChangeReason = operationDesc + " failed while completing resource. " + msg; + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, statusChangeReason, task, parentResult, true); schemaResult.recordFatalError(msg, e); return; } catch (ExpressionEvaluationException e) { String msg = "Expression error: " + e.getMessage(); - operationCtx += " failed while completing resource. " + msg; - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); + String statusChangeReason = operationDesc + " failed while completing resource. " + msg; + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, statusChangeReason, task, parentResult, true); schemaResult.recordFatalError(msg, e); return; } catch (RuntimeException e) { String msg = "Unspecified exception: " + e.getMessage(); - operationCtx += " failed while completing resource. " + msg; - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); + String statusChangeReason = operationDesc + " failed while completing resource. " + msg; + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, statusChangeReason, task, parentResult, true); schemaResult.recordFatalError(msg, e); return; } @@ -786,8 +783,8 @@ public void testConnection(PrismObject resource, Task task, Operat try { updateResourceSchema(allConnectorSpecs, parentResult, completedResource); } catch (SchemaException | ObjectNotFoundException | CommunicationException | ConfigurationException | RuntimeException e) { - operationCtx += " failed while updating resource schema: " + e.getMessage(); - modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, operationCtx, task, parentResult, true); + String statusChangeReason = operationDesc + " failed while updating resource schema: " + e.getMessage(); + modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.BROKEN, statusChangeReason, task, parentResult, true); parentResult.recordFatalError("Couldn't update resource schema: " + e.getMessage(), e); return; } @@ -1016,130 +1013,49 @@ private void testConnectionConnector(ConnectorSpec connectorSpec, Map resource = null; + String resourceDesc; + PrismObject resource; if (skipGetResource) { + resource = null; currentStatus = null; - description = "resource " + resourceOid; + resourceDesc = "resource " + resourceOid; } else { try { resource = getResource(resourceOid, GetOperationOptions.createNoFetch(), task, result); - } catch (SchemaException | ExpressionEvaluationException | ConfigurationException | CommunicationException e) { + } catch (SchemaException | ExpressionEvaluationException e) { // We actually do not expect any of these exceptions here. The resource is most probably in use result.recordFatalError("Unexpected exception: " + e.getMessage(), e); throw new SystemException("Unexpected exception: " + e.getMessage(), e); } ResourceType resourceBean = resource.asObjectable(); currentStatus = ResourceTypeUtil.getLastAvailabilityStatus(resourceBean); - description = resource.toString(); + resourceDesc = resource.toString(); } if (newStatus != currentStatus) { - //info becasue it's for diagnosing the issues with resource availability - LOGGER.info("Availability status changed from {} to {} for {} because {}", currentStatus, newStatus, description, operationCtx); try { - String message = "Availability status changed from " + currentStatus + " to " + newStatus + " for " + description + " because " +operationCtx; - List> modifications = createOperationalStateDelta(newStatus, message, resource);//singletonList(createResourceAvailabilityStatusDelta(newStatus)); + List> modifications = operationalStateManager.createAndLogOperationalStateDeltas(currentStatus, newStatus, + resourceDesc, statusChangeReason, resource); repositoryService.modifyObject(ResourceType.class, resourceOid, modifications, result); result.computeStatusIfUnknown(); InternalMonitor.recordCount(InternalCounters.RESOURCE_REPOSITORY_MODIFY_COUNT); } catch (SchemaException | ObjectAlreadyExistsException e) { - throw new SystemException("Unexpected exception: " + e.getMessage(), e); + throw new SystemException("Unexpected exception while recording operation state change: " + e.getMessage(), e); } } } - private List> createOperationalStateDelta(AvailabilityStatusType status, String message, PrismObject resource) throws SchemaException { - OperationalStateType state = new OperationalStateType(prismContext); - state.setMessage(message); - state.setLastAvailabilityStatus(status); - state.setNodeId(taskManager.getNodeId()); - state.setTimestamp(clock.currentTimeXMLGregorianCalendar()); - - ItemDelta lastAvailabilityStatus = prismContext.deltaFor(ResourceType.class).item(ResourceType.F_OPERATIONAL_STATE).replace(state).asItemDelta(); - - List> deltas = new ArrayList<>(); - deltas.add(lastAvailabilityStatus); - addHistoryDeltas(resource, state, deltas); - return deltas; - } - - private void addHistoryDeltas(PrismObject resource, OperationalStateType newState, List> deltas) throws SchemaException { - cleanupHistoryDeltas(resource, deltas); - - ItemDelta addNewDelta = prismContext.deltaFor(ResourceType.class).item(ResourceType.F_OPERATIONAL_STATE_HISTORY).add(newState.clone()).asItemDelta(); - deltas.add(addNewDelta); - } - - private void cleanupHistoryDeltas(PrismObject resource, List> deltas) throws SchemaException { - if (resource == null) { - return; - } - - List history = new ArrayList<>(resource.asObjectable().getOperationalStateHistory()); - int historySize = history.size(); - if (historySize >= MAX_OPERATIONAL_HISOTRY_SIZE) { - Comparator timestampCompare = (r1, r2) -> { - OperationalStateType state1 = (OperationalStateType) r1; - OperationalStateType state2 = (OperationalStateType) r2; - if (state1 == null) { - return (state2 == null ? DatatypeConstants.EQUAL : DatatypeConstants.GREATER); - } - - if (state2 == null) { - return (state1 == null ? DatatypeConstants.EQUAL : DatatypeConstants.LESSER); - } - - XMLGregorianCalendar gc1 = state1.getTimestamp(); - XMLGregorianCalendar gc2 = state2.getTimestamp(); - - Long t1 = MiscUtil.asLong(gc1); - Long t2 = MiscUtil.asLong(gc2); - return t2.compareTo(t1); - }; - - Collections.sort(history, timestampCompare); - if (MAX_OPERATIONAL_HISOTRY_SIZE == historySize) { - ItemDelta deleteOldDelta = prismContext.deltaFor(ResourceType.class) - .item(ResourceType.F_OPERATIONAL_STATE_HISTORY) - .delete(history.get(historySize - 1).clone()) - .asItemDelta(); - deltas.add(deleteOldDelta); - } - - // in case the resource was not available last time we updated history - // there might me more then MAX_OPERATIONAL_HISOTY_SIZE records, so - // just remove them now. - if (MAX_OPERATIONAL_HISOTRY_SIZE < historySize) { - int recordsToDelete = historySize - MAX_OPERATIONAL_HISOTRY_SIZE + 1; - for (int i = 1; i <= recordsToDelete; i++) { - ItemDelta deleteOldDelta = prismContext.deltaFor(ResourceType.class) - .item(ResourceType.F_OPERATIONAL_STATE_HISTORY) - .delete(history.get(historySize - i).clone()) - .asItemDelta(); - deltas.add(deleteOldDelta); - } - } - } - } - - private ItemDelta createResourceAvailabilityStatusDelta(AvailabilityStatusType status) throws SchemaException { - return prismContext.deltaFor(ResourceType.class) - .item(SchemaConstants.PATH_OPERATIONAL_STATE_LAST_AVAILABILITY_STATUS).replace(status) - .asItemDelta(); - } - /** * Adjust scheme with respect to capabilities. E.g. disable attributes that * are used for special purpose (such as account activation simulation). @@ -1165,7 +1081,7 @@ private void adjustSchemaForSimulatedCapabilities(PrismObject reso ResourceAttributeDefinition attributeDefinition = objectClassDefinition .findAttributeDefinition(attributeName); if (attributeDefinition != null) { - if (ignore == null || ignore.booleanValue()) { + if (ignore == null || ignore) { ((MutableItemDefinition) attributeDefinition).setProcessing(ItemProcessing.IGNORE); } } else { @@ -1189,6 +1105,7 @@ private void adjustSchemaForSimulatedCapabilities(PrismObject reso } } + // TODO should this one be used? private void checkSchema(PrismSchema schema) throws SchemaException { // This is resource schema, it should contain only // ResourceObjectDefinitions @@ -1213,7 +1130,7 @@ private void checkResourceObjectDefinition(ResourceAttributeContainerDefinition } } - public void applyDefinition(ObjectDelta delta, ResourceType resourceWhenNoOid, GetOperationOptions options, Task task, OperationResult objectResult) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + public void applyDefinition(ObjectDelta delta, ResourceType resourceWhenNoOid, GetOperationOptions options, Task task, OperationResult objectResult) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException { if (delta.isAdd()) { PrismObject resource = delta.getObjectToAdd(); @@ -1271,8 +1188,8 @@ public void applyDefinition(ObjectDelta delta, ResourceType resour } } - PrismObject connector = null; - ConnectorType connectorType = null; + PrismObject connector; + ConnectorType connectorType; try { connector = repositoryService.getObject(ConnectorType.class, connectorOid, null, objectResult); connectorType = connector.asObjectable(); @@ -1286,7 +1203,7 @@ public void applyDefinition(ObjectDelta delta, ResourceType resour // Mark the error ... there is nothing more to do objectResult.recordPartialError("Connector (OID:" + connectorOid + ") referenced from the resource has schema problems: " + e.getMessage(), e); LOGGER.error("Connector (OID:{}) referenced from the imported resource \"{}\" has schema problems: {}-{}", - new Object[]{connectorOid, resourceType.getName(), e.getMessage(), e}); + connectorOid, resourceType.getName(), e.getMessage(), e); return; } @@ -1319,6 +1236,7 @@ public void applyDefinition(ObjectDelta delta, ResourceType resour } PrismContainer configContainer = resourceType.asPrismObject().findContainer(ResourceType.F_CONNECTOR_CONFIGURATION); + //noinspection unchecked configContainer.applyDefinition(configContainerDef); for (ItemDelta itemDelta : delta.getModifications()){ @@ -1353,8 +1271,7 @@ private void applyItemDefinitio } public void applyDefinition(PrismObject resource, Task task, OperationResult parentResult) - throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, - ExpressionEvaluationException { + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException { applyConnectorSchemasToResource(resource, task, parentResult); } @@ -1362,7 +1279,7 @@ public void applyDefinition(ObjectQuery query, OperationResult result) { // TODO: not implemented yet } - public Object executeScript(String resourceOid, ProvisioningScriptType script, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + public Object executeScript(String resourceOid, ProvisioningScriptType script, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, ExpressionEvaluationException { PrismObject resource = getResource(resourceOid, null, task, result); ConnectorSpec connectorSpec = selectConnectorSpec(resource, ScriptCapabilityType.class); if (connectorSpec == null) { @@ -1484,15 +1401,8 @@ private CapabilitiesType applyObjectClassCapabilities(CapabilitiesType connector } private boolean hasConfiguredCapabilities(CapabilitiesType supportedCapabilities) { - if (supportedCapabilities.getConfigured() == null) { - return false; - } - - if (supportedCapabilities.getConfigured().getAny().isEmpty()) { - return false; - - } - return true; + CapabilityCollectionType configured = supportedCapabilities.getConfigured(); + return configured != null && !configured.getAny().isEmpty(); } private ConnectorSpec selectConnectorSpec(PrismObject resource, Map> capabilityMap, Class capabilityClass) throws SchemaException { @@ -1556,6 +1466,7 @@ private ConnectorSpec getConnectorSpec(PrismObject resource, Conne if (StringUtils.isBlank(connectorOid)) { throw new SchemaException("No connector OID in additional connector in "+resource); } + //noinspection unchecked PrismContainer connectorConfiguration = additionalConnectorType.asPrismContainerValue().findContainer(ConnectorInstanceSpecificationType.F_CONNECTOR_CONFIGURATION); String connectorName = additionalConnectorType.getName(); if (StringUtils.isBlank(connectorName)) { diff --git a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ResourceOperationalStateManager.java b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ResourceOperationalStateManager.java new file mode 100644 index 00000000000..e154c808483 --- /dev/null +++ b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ResourceOperationalStateManager.java @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2020 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ + +package com.evolveum.midpoint.provisioning.impl; + +import static java.util.Collections.emptyList; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; + +import com.evolveum.midpoint.prism.util.CloneUtil; +import com.evolveum.midpoint.schema.constants.SchemaConstants; +import com.evolveum.midpoint.util.logging.Trace; +import com.evolveum.midpoint.util.logging.TraceManager; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.evolveum.midpoint.common.Clock; +import com.evolveum.midpoint.prism.PrismContext; +import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.prism.delta.ItemDelta; +import com.evolveum.midpoint.prism.xml.XmlTypeConverter; +import com.evolveum.midpoint.task.api.TaskManager; +import com.evolveum.midpoint.util.exception.SchemaException; +import com.evolveum.midpoint.xml.ns._public.common.common_3.AvailabilityStatusType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationalStateType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; + +/** + * Manages resource operational state record and its history. + */ +@Component +public class ResourceOperationalStateManager { + + private static final Trace LOGGER = TraceManager.getTrace(ResourceOperationalStateManager.class); + + // TODO make this configurable + private static final int MAX_OPERATIONAL_HISTORY_SIZE = 5; + + @Autowired private PrismContext prismContext; + @Autowired private TaskManager taskManager; + @Autowired private Clock clock; + + List> createAndLogOperationalStateDeltas(AvailabilityStatusType previousStatus, + AvailabilityStatusType newStatus, String resourceDesc, String statusChangeReason, + PrismObject resource) throws SchemaException { + + String stateChangeClause; + if (previousStatus != null) { + stateChangeClause = "changed from " + previousStatus + " to " + newStatus; + } else { + stateChangeClause = "set to " + newStatus; + } + + // The level is INFO because it's needed for diagnosing the issues with resource availability. + LOGGER.info("Availability status {} for {} because {}", stateChangeClause, resourceDesc, statusChangeReason); + + OperationalStateType changeStateRecord = new OperationalStateType(prismContext); + changeStateRecord.setLastAvailabilityStatus(newStatus); + changeStateRecord.setMessage("Status " + stateChangeClause + " because " + statusChangeReason); + changeStateRecord.setNodeId(taskManager.getNodeId()); + changeStateRecord.setTimestamp(clock.currentTimeXMLGregorianCalendar()); + + List> deltas = new ArrayList<>(); + deltas.add(createOperationalStateDelta(changeStateRecord.clone())); + if (resource != null) { + deltas.addAll(createHistoryCleanupDeltas(resource)); + } else { + // no resource loaded -> no history cleanup can be done + } + deltas.add(createHistoryAddDelta(changeStateRecord)); + return deltas; + } + + private ItemDelta createOperationalStateDelta(OperationalStateType newState) throws SchemaException { + return prismContext.deltaFor(ResourceType.class) + .item(ResourceType.F_OPERATIONAL_STATE).replace(newState) + .asItemDelta(); + } + + private ItemDelta createHistoryAddDelta(OperationalStateType newState) throws SchemaException { + return prismContext.deltaFor(ResourceType.class) + .item(ResourceType.F_OPERATIONAL_STATE_HISTORY).add(newState) + .asItemDelta(); + } + + @SuppressWarnings("SameParameterValue") + ItemDelta createAvailabilityStatusDelta(AvailabilityStatusType status) throws SchemaException { + return prismContext.deltaFor(ResourceType.class) + .item(SchemaConstants.PATH_OPERATIONAL_STATE_LAST_AVAILABILITY_STATUS).replace(status) + .asItemDelta(); + } + + private List> createHistoryCleanupDeltas(PrismObject resource) throws SchemaException { + List history = new ArrayList<>(resource.asObjectable().getOperationalStateHistory()); + int historySize = history.size(); + if (historySize >= MAX_OPERATIONAL_HISTORY_SIZE) { + history.sort(Comparator.comparing(state -> XmlTypeConverter.toMillis(state.getTimestamp()))); + int numberOfRecordsToDelete = historySize - MAX_OPERATIONAL_HISTORY_SIZE + 1; + List recordsToDelete = history.subList(0, numberOfRecordsToDelete); + return prismContext.deltaFor(ResourceType.class) + .item(ResourceType.F_OPERATIONAL_STATE_HISTORY) + .deleteRealValues(CloneUtil.cloneCollectionMembers(recordsToDelete)) + .asItemDeltas(); + } else { + return emptyList(); + } + } +} diff --git a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/errorhandling/CommunicationExceptionHandler.java b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/errorhandling/CommunicationExceptionHandler.java index e6c839ae967..afeb72da37f 100644 --- a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/errorhandling/CommunicationExceptionHandler.java +++ b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/errorhandling/CommunicationExceptionHandler.java @@ -61,8 +61,8 @@ public PrismObject handleGetError(ProvisioningContext ctx, OperationResult result = parentResult.createSubresult(OPERATION_HANDLE_GET_ERROR); result.addParam("exception", cause.getMessage()); - String operationCtx = "getting " + repositoryShadow + " ended with communication problem, " + cause.getMessage(); - markResourceDown(resource.getOid(), operationCtx, result, task); + String stateChangeReason = "getting " + repositoryShadow + " ended with communication problem, " + cause.getMessage(); + markResourceDown(resource.getOid(), stateChangeReason, result, task); // nothing to do, just return the shadow from the repo and set fetch // result.. @@ -102,8 +102,8 @@ public OperationResultStatus handleAddError(ProvisioningContext ctx, OperationResult result = parentResult.createSubresult(OPERATION_HANDLE_ADD_ERROR); result.addParam("exception", cause.getMessage()); - String operationCtx = "adding " + shadowToAdd + " ended with communication problem, " + cause.getMessage(); - markResourceDown(ctx.getResourceOid(), operationCtx, result, task); + String stateChangeReason = "adding " + shadowToAdd + " ended with communication problem, " + cause.getMessage(); + markResourceDown(ctx.getResourceOid(), stateChangeReason, result, task); handleRetriesAndAttempts(ctx, opState, options, cause, result); return postponeAdd(ctx, shadowToAdd, opState, failedOperationResult, result); } @@ -118,8 +118,8 @@ public OperationResultStatus handleModifyError(ProvisioningContext ctx, PrismObj OperationResult result = parentResult.createSubresult(OPERATION_HANDLE_MODIFY_ERROR); result.addParam("exception", cause.getMessage()); - String operationCtx = "modifying " + repoShadow + " ended with communication problem, " + cause.getMessage(); - markResourceDown(ctx.getResourceOid(), operationCtx, result, task); + String stateChangeReason = "modifying " + repoShadow + " ended with communication problem, " + cause.getMessage(); + markResourceDown(ctx.getResourceOid(), stateChangeReason, result, task); handleRetriesAndAttempts(ctx, opState, options, cause, result); return postponeModify(ctx, repoShadow, modifications, opState, failedOperationResult, result); } @@ -133,8 +133,8 @@ public OperationResultStatus handleDeleteError(ProvisioningContext ctx, PrismObj ExpressionEvaluationException { OperationResult result = parentResult.createSubresult(OPERATION_HANDLE_DELETE_ERROR); result.addParam("exception", cause.getMessage()); - String operationCtx = "deleting " + repoShadow + " ended with communication problem, " + cause.getMessage(); - markResourceDown(ctx.getResourceOid(), operationCtx, result, task); + String stateChangeReason = "deleting " + repoShadow + " ended with communication problem, " + cause.getMessage(); + markResourceDown(ctx.getResourceOid(), stateChangeReason, result, task); handleRetriesAndAttempts(ctx, opState, options, cause, result); return postponeDelete(ctx, repoShadow, opState, failedOperationResult, result); } diff --git a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/errorhandling/ErrorHandler.java b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/errorhandling/ErrorHandler.java index 16687c7bed2..7a6eeee39dd 100644 --- a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/errorhandling/ErrorHandler.java +++ b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/errorhandling/ErrorHandler.java @@ -184,8 +184,8 @@ protected void recordCompletionError(Exception cause, } } - void markResourceDown(String resourceOid, String operationCtx, OperationResult parentResult, Task task) throws ObjectNotFoundException { - resourceManager.modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.DOWN, operationCtx, task, parentResult, false); + void markResourceDown(String resourceOid, String changeReason, OperationResult parentResult, Task task) throws ObjectNotFoundException { + resourceManager.modifyResourceAvailabilityStatus(resourceOid, AvailabilityStatusType.DOWN, changeReason, task, parentResult, false); } protected boolean isOperationRetryEnabled(ResourceType resource) { diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/TestCsvBroken.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/TestCsvBroken.java new file mode 100644 index 00000000000..13d3911a558 --- /dev/null +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/TestCsvBroken.java @@ -0,0 +1,345 @@ +/* + * Copyright (c) 2010-2017 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ +package com.evolveum.midpoint.provisioning.impl.csv; + +import static org.testng.AssertJUnit.assertEquals; + +import static com.evolveum.midpoint.test.asserter.predicate.StringAssertionPredicates.startsWith; +import static com.evolveum.midpoint.test.asserter.predicate.TimeAssertionPredicates.timeBetween; + +import java.io.File; +import java.util.List; +import javax.xml.namespace.QName; + +import org.apache.commons.io.FileUtils; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.ContextConfiguration; +import org.testng.annotations.Test; + +import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.prism.PrismPropertyDefinition; +import com.evolveum.midpoint.prism.delta.ItemDelta; +import com.evolveum.midpoint.prism.path.ItemPath; +import com.evolveum.midpoint.prism.query.ObjectQuery; +import com.evolveum.midpoint.provisioning.impl.AbstractProvisioningIntegrationTest; +import com.evolveum.midpoint.schema.constants.SchemaConstants; +import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.TestResource; +import com.evolveum.midpoint.test.util.TestUtil; +import com.evolveum.midpoint.util.DOMUtil; +import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; +import com.evolveum.midpoint.util.exception.ObjectNotFoundException; +import com.evolveum.midpoint.util.exception.SchemaException; +import com.evolveum.midpoint.xml.ns._public.common.common_3.AvailabilityStatusType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationalStateType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; + +/** + * Testing broken CSV e.g. with respect to availability status setting (MID-6019). + * + */ +@ContextConfiguration(locations = "classpath:ctx-provisioning-test-main.xml") +@DirtiesContext +public class TestCsvBroken extends AbstractProvisioningIntegrationTest { + + protected static final File TEST_DIR = new File("src/test/resources/csv/"); + + private static final TestResource RESOURCE_CSV_BROKEN = new TestResource(TEST_DIR, "resource-csv-broken.xml", "3e02a0b0-8c9a-4d45-b1b4-cf9b9b6e7918"); + + private static final String CSV_CONNECTOR_TYPE = "com.evolveum.polygon.connector.csv.CsvConnector"; + + private static final File CSV_SOURCE_FILE = new File(TEST_DIR, "midpoint-guid.csv"); + + private static final File CSV_FILE_OK = new File("target/midpoint.csv"); + private static final File CSV_FILE_NON_EXISTING = new File("target/non-existing-file.csv"); + + private OperationalStateType oldestStateRecord; + + @Override + public void initSystem(Task initTask, OperationResult initResult) throws Exception { + super.initSystem(initTask, initResult); + + addResourceFromFile(RESOURCE_CSV_BROKEN.file, CSV_CONNECTOR_TYPE, initResult); + + FileUtils.copyFile(CSV_SOURCE_FILE, CSV_FILE_OK); + } + + /** + * Testing the connection on broken resource. Availability status should be set to BROKEN. + */ + @Test + public void test100Connection() throws Exception { + final String TEST_NAME = "test100Connection"; + TestUtil.displayTestTitle(TEST_NAME); + + // GIVEN + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + // WHEN + long before = System.currentTimeMillis(); + OperationResult testResult = provisioningService.testResource(RESOURCE_CSV_BROKEN.oid, task); + long after = System.currentTimeMillis(); + + // THEN + display("Test result", testResult); + TestUtil.assertFailure("Test resource succeeded unexpectedly", testResult); + + PrismObject resourceRepoAfter = repositoryService.getObject(ResourceType.class, RESOURCE_CSV_BROKEN.oid, + null, result); + + String localNodeId = taskManager.getNodeId(); + assertResource(resourceRepoAfter, "Resource after test") + .display() + .operationalState() + .assertAny() + .assertPropertyEquals(OperationalStateType.F_LAST_AVAILABILITY_STATUS, AvailabilityStatusType.BROKEN) + .assertPropertyEquals(OperationalStateType.F_NODE_ID, localNodeId) + .assertPropertyValueSatisfies(OperationalStateType.F_TIMESTAMP, timeBetween(before, after)) + .assertPropertyValueSatisfies(OperationalStateType.F_MESSAGE, startsWith("Status set to BROKEN because testing connection")) + .end() + .operationalStateHistory() + .assertSize(1) + .value(0) + .assertPropertyEquals(OperationalStateType.F_LAST_AVAILABILITY_STATUS, AvailabilityStatusType.BROKEN) + .assertPropertyEquals(OperationalStateType.F_NODE_ID, localNodeId) + .assertPropertyValueSatisfies(OperationalStateType.F_TIMESTAMP, timeBetween(before, after)) + .assertPropertyValueSatisfies(OperationalStateType.F_MESSAGE, startsWith("Status set to BROKEN because testing connection")); + + oldestStateRecord = resourceRepoAfter.asObjectable().getOperationalState(); + assertContainsOldestStateRecord(resourceRepoAfter); + } + + /** + * Fixing the resource and testing again. Availability status should be set to UP. + */ + @Test + public void test110FixResourceAndTestConnection() throws Exception { + final String TEST_NAME = "test110FixResourceAndTestConnection"; + TestUtil.displayTestTitle(TEST_NAME); + + // GIVEN + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + setCsvFile(RESOURCE_CSV_BROKEN.oid, CSV_FILE_OK.getPath(), result); + + // WHEN + long before = System.currentTimeMillis(); + OperationResult testResult = provisioningService.testResource(RESOURCE_CSV_BROKEN.oid, task); + long after = System.currentTimeMillis(); + + // THEN + display("Test result", testResult); + TestUtil.assertSuccess("Test resource failed", testResult); + + PrismObject resourceRepoAfter = repositoryService.getObject(ResourceType.class, RESOURCE_CSV_BROKEN.oid, + null, result); + + String localNodeId = taskManager.getNodeId(); + assertResource(resourceRepoAfter, "Resource after test") + .display() + .operationalState() + .assertAny() + .assertPropertyEquals(OperationalStateType.F_LAST_AVAILABILITY_STATUS, AvailabilityStatusType.UP) + .assertPropertyEquals(OperationalStateType.F_NODE_ID, localNodeId) + .assertPropertyValueSatisfies(OperationalStateType.F_TIMESTAMP, timeBetween(before, after)) + .assertPropertyValueSatisfies(OperationalStateType.F_MESSAGE, startsWith("Status changed from BROKEN to UP because testing connection")) + .end() + .operationalStateHistory() + .assertSize(2) + // TODO ordering of values is fragile + .value(0) + .assertPropertyEquals(OperationalStateType.F_LAST_AVAILABILITY_STATUS, AvailabilityStatusType.BROKEN) + .assertPropertyEquals(OperationalStateType.F_NODE_ID, localNodeId) + .assertPropertyValueSatisfies(OperationalStateType.F_MESSAGE, startsWith("Status set to BROKEN because testing connection")) + .end() + .value(1) + .assertPropertyEquals(OperationalStateType.F_LAST_AVAILABILITY_STATUS, AvailabilityStatusType.UP) + .assertPropertyEquals(OperationalStateType.F_NODE_ID, localNodeId) + .assertPropertyValueSatisfies(OperationalStateType.F_TIMESTAMP, timeBetween(before, after)) + .assertPropertyValueSatisfies(OperationalStateType.F_MESSAGE, startsWith("Status changed from BROKEN to UP because testing connection")) + .end(); + + assertContainsOldestStateRecord(resourceRepoAfter); + } + + /** + * Breaking the resource and testing again. Availability status should be set to DOWN (why not BROKEN?) + */ + @Test + public void test120BreakResourceAndTestConnection() throws Exception { + final String TEST_NAME = "test120BreakResourceAndTestConnection"; + TestUtil.displayTestTitle(TEST_NAME); + + // GIVEN + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + setCsvFile(RESOURCE_CSV_BROKEN.oid, CSV_FILE_NON_EXISTING.getPath(), result); + + // WHEN + long before = System.currentTimeMillis(); + OperationResult testResult = provisioningService.testResource(RESOURCE_CSV_BROKEN.oid, task); + long after = System.currentTimeMillis(); + + // THEN + display("Test result", testResult); + TestUtil.assertFailure("Test resource succeeded unexpectedly", testResult); + + PrismObject resourceRepoAfter = repositoryService.getObject(ResourceType.class, RESOURCE_CSV_BROKEN.oid, + null, result); + + String localNodeId = taskManager.getNodeId(); + assertResource(resourceRepoAfter, "Resource after test") + .display() + .operationalState() + .assertAny() + .assertPropertyEquals(OperationalStateType.F_LAST_AVAILABILITY_STATUS, AvailabilityStatusType.DOWN) // todo why DOWN and not BROKEN as before? + .assertPropertyEquals(OperationalStateType.F_NODE_ID, localNodeId) + .assertPropertyValueSatisfies(OperationalStateType.F_TIMESTAMP, timeBetween(before, after)) + .assertPropertyValueSatisfies(OperationalStateType.F_MESSAGE, startsWith("Status set to DOWN because testing connection")) + .end() + .operationalStateHistory() + .assertSize(3); + + assertContainsOldestStateRecord(resourceRepoAfter); + } + + /** + * Fixing the resource and executing searchObjects + getObject. Availability status should be set to UP. + */ + @Test + public void test130FixResourceAndSearchObjects() throws Exception { + final String TEST_NAME = "test130FixResourceAndSearchObjects"; + TestUtil.displayTestTitle(TEST_NAME); + + // GIVEN + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + setCsvFile(RESOURCE_CSV_BROKEN.oid, CSV_FILE_OK.getPath(), result); + + /* + * We need to remove cached configured connector instances. Otherwise the changed configuration will not get + * propagated to the cached connector instances. + * + * TODO Is this behavior OK? Shouldn't we fix it? + */ + connectorManager.invalidate(null, null, null); + + // WHEN + ObjectQuery query = prismContext.queryFor(ShadowType.class) + .item(ShadowType.F_RESOURCE_REF).ref(RESOURCE_CSV_BROKEN.oid) + .and().item(ShadowType.F_OBJECT_CLASS).eq(SchemaConstants.RI_ACCOUNT_OBJECT_CLASS) + .build(); + + long before = System.currentTimeMillis(); + List> resourceObjects = provisioningService.searchObjects(ShadowType.class, query, null, task, result); + display("Resource objects found", resourceObjects); + assertEquals("Wrong # of CSV resource objects", 2, resourceObjects.size()); + + /* + * It looks like successful searchObjects operation does not trigger setting resource availability to UP. + * But getObject does, so let's use it here. + * + * TODO Is this behavior OK? Shouldn't we fix this? + */ + provisioningService.getObject(ShadowType.class, resourceObjects.get(0).getOid(), null, task, result); + + long after = System.currentTimeMillis(); + + // THEN + result.computeStatus(); + TestUtil.assertSuccess("searchObjects/getObject failed", result); + + PrismObject resourceRepoAfter = repositoryService.getObject(ResourceType.class, RESOURCE_CSV_BROKEN.oid, + null, result); + + String localNodeId = taskManager.getNodeId(); + assertResource(resourceRepoAfter, "Resource after test") + .display() + .operationalState() + .assertAny() + .assertPropertyEquals(OperationalStateType.F_LAST_AVAILABILITY_STATUS, AvailabilityStatusType.UP) + .assertPropertyEquals(OperationalStateType.F_NODE_ID, localNodeId) + .assertPropertyValueSatisfies(OperationalStateType.F_TIMESTAMP, timeBetween(before, after)) + .assertPropertyValueSatisfies(OperationalStateType.F_MESSAGE, startsWith("Status changed from DOWN to UP")) + .end() + .operationalStateHistory() + .assertSize(4); + + assertContainsOldestStateRecord(resourceRepoAfter); + } + + /** + * Introducing two more status changes and checking that history entry cleanup works well. + */ + @Test + public void test140TwoMoreStatusChanges() throws Exception { + final String TEST_NAME = "test140TwoMoreStatusChanges"; + TestUtil.displayTestTitle(TEST_NAME); + + // GIVEN + Task task = createTask(TEST_NAME); + OperationResult result = task.getResult(); + + + // WHEN + long before = System.currentTimeMillis(); + setCsvFile(RESOURCE_CSV_BROKEN.oid, CSV_FILE_NON_EXISTING.getPath(), result); + provisioningService.testResource(RESOURCE_CSV_BROKEN.oid, task); + setCsvFile(RESOURCE_CSV_BROKEN.oid, CSV_FILE_OK.getPath(), result); + provisioningService.testResource(RESOURCE_CSV_BROKEN.oid, task); + long after = System.currentTimeMillis(); + + // THEN + PrismObject resourceRepoAfter = repositoryService.getObject(ResourceType.class, RESOURCE_CSV_BROKEN.oid, + null, result); + + String localNodeId = taskManager.getNodeId(); + assertResource(resourceRepoAfter, "Resource after test") + .display() + .operationalState() + .assertAny() + .assertPropertyEquals(OperationalStateType.F_LAST_AVAILABILITY_STATUS, AvailabilityStatusType.UP) + .assertPropertyEquals(OperationalStateType.F_NODE_ID, localNodeId) + .assertPropertyValueSatisfies(OperationalStateType.F_TIMESTAMP, timeBetween(before, after)) + .assertPropertyValueSatisfies(OperationalStateType.F_MESSAGE, startsWith("Status changed from DOWN to UP because testing connection")) + .end() + .operationalStateHistory() + .assertSize(5); // not 6, because 5 is the limit + + assertDoesNotContainOldestStateRecord(resourceRepoAfter); + } + + private void setCsvFile(String resourceOid, String file, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException { + QName propertyName = new QName("filePath"); + ItemPath propertyPath = ItemPath.create(ResourceType.F_CONNECTOR_CONFIGURATION, SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME, propertyName); + PrismPropertyDefinition propertyDefinition = prismContext.definitionFactory().createPropertyDefinition(propertyName, DOMUtil.XSD_STRING); + List> deltas = deltaFor(ResourceType.class) + .item(propertyPath, propertyDefinition) + .replace(file) + .asItemDeltas(); + repositoryService.modifyObject(ResourceType.class, resourceOid, deltas, result); + } + + private void assertContainsOldestStateRecord(PrismObject resource) { + assertContainsOldestStateRecord(resource, true); + } + + private void assertDoesNotContainOldestStateRecord(PrismObject resource) { + assertContainsOldestStateRecord(resource, false); + } + + private void assertContainsOldestStateRecord(PrismObject resource, boolean expected) { + boolean actual = resource.asObjectable().getOperationalStateHistory().contains(oldestStateRecord); + assertEquals("Mismatch in oldest state record existence", expected, actual); + } +} 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 ba73749f654..67b6bb14454 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 @@ -11,6 +11,10 @@ package com.evolveum.midpoint.provisioning.impl.dummy; import static com.evolveum.midpoint.test.IntegrationTestTools.assertProvisioningAccountShadow; +import static com.evolveum.midpoint.test.asserter.predicate.TimeAssertionPredicates.approximatelyCurrent; + +import static com.evolveum.midpoint.test.asserter.predicate.StringAssertionPredicates.startsWith; + import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertFalse; import static org.testng.AssertJUnit.assertNotNull; @@ -27,6 +31,8 @@ import com.evolveum.midpoint.prism.path.ItemName; import com.evolveum.midpoint.prism.path.ItemPath; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; + import org.apache.commons.lang.StringUtils; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; @@ -92,18 +98,6 @@ import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.CachingMetadataType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilitiesType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.XmlSchemaType; import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType; import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.AddRemoveAttributeValuesCapabilityType; import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CountObjectsCapabilityType; @@ -351,7 +345,24 @@ public void test020Connection() throws Exception { PrismObject resourceRepoAfter = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, result); ResourceType resourceTypeRepoAfter = resourceRepoAfter.asObjectable(); - display("Resource after test", resourceTypeRepoAfter); + + String localNodeId = taskManager.getNodeId(); + assertResource(resourceRepoAfter, "Resource after test") + .display() + .operationalState() + .assertAny() + .assertPropertyEquals(OperationalStateType.F_LAST_AVAILABILITY_STATUS, AvailabilityStatusType.UP) + .assertPropertyEquals(OperationalStateType.F_NODE_ID, localNodeId) + .assertPropertyValueSatisfies(OperationalStateType.F_TIMESTAMP, approximatelyCurrent(60000)) + .assertPropertyValueSatisfies(OperationalStateType.F_MESSAGE, startsWith("Status set to UP")) + .end() + .operationalStateHistory() + .assertSize(1) + .value(0) + .assertPropertyEquals(OperationalStateType.F_LAST_AVAILABILITY_STATUS, AvailabilityStatusType.UP) + .assertPropertyEquals(OperationalStateType.F_NODE_ID, localNodeId) + .assertPropertyValueSatisfies(OperationalStateType.F_TIMESTAMP, approximatelyCurrent(60000)) + .assertPropertyValueSatisfies(OperationalStateType.F_MESSAGE, startsWith("Status set to UP")); XmlSchemaType xmlSchemaTypeAfter = resourceTypeRepoAfter.getSchema(); assertNotNull("No schema after test connection", xmlSchemaTypeAfter); @@ -812,7 +823,8 @@ public void test030ResourceAndConnectorCachingTestConnection() throws Exception assertCounterIncrement(InternalCounters.RESOURCE_SCHEMA_FETCH_COUNT, 1); assertCounterIncrement(InternalCounters.CONNECTOR_SCHEMA_PARSE_COUNT, 0); assertCounterIncrement(InternalCounters.CONNECTOR_CAPABILITIES_FETCH_COUNT, 1); - assertCounterIncrement(InternalCounters.RESOURCE_SCHEMA_PARSE_COUNT, 1); + // Test connection contains one extra resource read from repository + assertCounterIncrement(InternalCounters.RESOURCE_SCHEMA_PARSE_COUNT, 2); PrismObject resourceRepoAfter = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task.getResult()); diff --git a/provisioning/provisioning-impl/src/test/resources/csv/resource-csv-broken.xml b/provisioning/provisioning-impl/src/test/resources/csv/resource-csv-broken.xml new file mode 100644 index 00000000000..fd844d3161e --- /dev/null +++ b/provisioning/provisioning-impl/src/test/resources/csv/resource-csv-broken.xml @@ -0,0 +1,27 @@ + + + + + + Test CSV: broken + + + + target/non-existing-file.csv + utf-8 + , + ; + guid + uname + password + + + + diff --git a/provisioning/provisioning-impl/testng-integration.xml b/provisioning/provisioning-impl/testng-integration.xml index 133cb591bbf..e5e596c42fb 100644 --- a/provisioning/provisioning-impl/testng-integration.xml +++ b/provisioning/provisioning-impl/testng-integration.xml @@ -56,6 +56,7 @@ + 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 bb4a0011e02..cdc7f42639e 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 @@ -61,7 +61,9 @@ import com.evolveum.midpoint.task.api.TaskManager; import com.evolveum.midpoint.task.api.Tracer; import com.evolveum.midpoint.test.asserter.AbstractAsserter; +import com.evolveum.midpoint.test.asserter.ResourceAsserter; import com.evolveum.midpoint.test.asserter.ShadowAsserter; +import com.evolveum.midpoint.test.asserter.UserAsserter; import com.evolveum.midpoint.test.asserter.prism.PolyStringAsserter; import com.evolveum.midpoint.test.asserter.prism.PrismObjectAsserter; import com.evolveum.midpoint.test.asserter.refinedschema.RefinedResourceSchemaAsserter; @@ -915,6 +917,13 @@ protected void assertObjectSanity(PrismObject object) { new PrismObjectAsserter<>(object).assertSanity(); } + protected ResourceAsserter assertResource(PrismObject resource, String message) { + ResourceAsserter asserter = ResourceAsserter.forResource(resource, message); + initializeAsserter(asserter); + asserter.display(); + return asserter; + } + protected void assertUser(PrismObject user, String oid, String name, String fullName, String givenName, String familyName) { assertUser(user, oid, name, fullName, givenName, familyName, null); } diff --git a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/ResourceAsserter.java b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/ResourceAsserter.java index 910b9c98bbc..52e83703e06 100644 --- a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/ResourceAsserter.java +++ b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/ResourceAsserter.java @@ -6,13 +6,20 @@ */ package com.evolveum.midpoint.test.asserter; +import com.evolveum.midpoint.prism.PrismContainer; +import com.evolveum.midpoint.prism.PrismContainerValue; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.schema.util.ResourceTypeUtil; +import com.evolveum.midpoint.test.asserter.prism.PrismContainerAsserter; +import com.evolveum.midpoint.test.asserter.prism.PrismContainerValueAsserter; import com.evolveum.midpoint.test.asserter.prism.PrismObjectAsserter; import com.evolveum.midpoint.util.exception.SchemaException; +import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationalStateType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; import org.w3c.dom.Element; +import static com.evolveum.midpoint.prism.Containerable.asPrismContainerValue; + import static org.testng.AssertJUnit.assertNotNull; /** @@ -118,4 +125,20 @@ public ResourceAsserter assertNoTrigger() { super.assertNoTrigger(); return this; } + + public PrismContainerValueAsserter> operationalState() { + PrismContainerValue operationalState = asPrismContainerValue(getObject().asObjectable().getOperationalState()); + PrismContainerValueAsserter> asserter = + new PrismContainerValueAsserter<>(operationalState, this, getDetails()); + copySetupTo(asserter); + return asserter; + } + + public PrismContainerAsserter> operationalStateHistory() { + PrismContainer operationalStateHistory = getObject().findContainer(ResourceType.F_OPERATIONAL_STATE_HISTORY); + PrismContainerAsserter> asserter = + new PrismContainerAsserter<>(operationalStateHistory, this, getDetails()); + copySetupTo(asserter); + return asserter; + } } diff --git a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/predicate/AssertionPredicate.java b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/predicate/AssertionPredicate.java new file mode 100644 index 00000000000..dd9d7db993d --- /dev/null +++ b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/predicate/AssertionPredicate.java @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2020 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ + +package com.evolveum.midpoint.test.asserter.predicate; + +/** + * Predicate to be used in assertions. + * + * Experimental. + */ +public interface AssertionPredicate { + + AssertionPredicateEvaluation evaluate(T value); + +} diff --git a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/predicate/AssertionPredicateEvaluation.java b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/predicate/AssertionPredicateEvaluation.java new file mode 100644 index 00000000000..0b4b82254bc --- /dev/null +++ b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/predicate/AssertionPredicateEvaluation.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2020 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ + +package com.evolveum.midpoint.test.asserter.predicate; + +/** + * Evaluation of a predicate used within an assertion. + * + * Experimental. + */ +public class AssertionPredicateEvaluation { + + private final boolean success; + private final String failureDescription; + + private AssertionPredicateEvaluation(boolean success, String failureDescription) { + this.success = success; + this.failureDescription = failureDescription; + } + + public static AssertionPredicateEvaluation success() { + return new AssertionPredicateEvaluation(true, null); + } + + public static AssertionPredicateEvaluation failure(String description) { + return new AssertionPredicateEvaluation(false, description); + } + + public boolean hasFailed() { + return !success; + } + + public String getFailureDescription() { + return failureDescription; + } +} diff --git a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/predicate/GenericAssertionPredicate.java b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/predicate/GenericAssertionPredicate.java new file mode 100644 index 00000000000..625958f82a0 --- /dev/null +++ b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/predicate/GenericAssertionPredicate.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2020 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ + +package com.evolveum.midpoint.test.asserter.predicate; + +import org.jetbrains.annotations.NotNull; + +import java.util.function.Function; +import java.util.function.Predicate; + +/** + * Generic assertion predicate defined using Java Predicate and a function that generates the failure description. + * + * Experimental. + */ +public class GenericAssertionPredicate implements AssertionPredicate { + + @NotNull private final Predicate predicate; + @NotNull private final Function failureDescriptionGenerator; + + @SuppressWarnings("WeakerAccess") // useful for general public + public GenericAssertionPredicate(@NotNull Predicate predicate, @NotNull Function failureDescriptionGenerator) { + this.predicate = predicate; + this.failureDescriptionGenerator = failureDescriptionGenerator; + } + + @Override + public AssertionPredicateEvaluation evaluate(T value) { + if (predicate.test(value)) { + return AssertionPredicateEvaluation.success(); + } else { + return AssertionPredicateEvaluation.failure(failureDescriptionGenerator.apply(value)); + } + } +} diff --git a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/predicate/SimplifiedGenericAssertionPredicate.java b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/predicate/SimplifiedGenericAssertionPredicate.java new file mode 100644 index 00000000000..556fd14788f --- /dev/null +++ b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/predicate/SimplifiedGenericAssertionPredicate.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2020 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ + +package com.evolveum.midpoint.test.asserter.predicate; + +import java.util.function.Function; +import java.util.function.Predicate; + +import org.jetbrains.annotations.NotNull; + +/** + * Generic assertion predicate defined using function that generates the failure description (or null if test passes). + * + * Experimental. + */ +public class SimplifiedGenericAssertionPredicate implements AssertionPredicate { + + @NotNull private final Function failureDescriptionGenerator; + + @SuppressWarnings("WeakerAccess") // useful for general public + public SimplifiedGenericAssertionPredicate(@NotNull Function failureDescriptionGenerator) { + this.failureDescriptionGenerator = failureDescriptionGenerator; + } + + @Override + public AssertionPredicateEvaluation evaluate(T value) { + String failureDescription = failureDescriptionGenerator.apply(value); + if (failureDescription != null) { + return AssertionPredicateEvaluation.failure(failureDescription); + } else { + return AssertionPredicateEvaluation.success(); + } + } +} diff --git a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/predicate/StringAssertionPredicates.java b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/predicate/StringAssertionPredicates.java new file mode 100644 index 00000000000..3959592b431 --- /dev/null +++ b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/predicate/StringAssertionPredicates.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2020 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ + +package com.evolveum.midpoint.test.asserter.predicate; + +/** + * Methods for construction of string assertion predicates. + * + * Experimental. + */ +public class StringAssertionPredicates { + + public static AssertionPredicate startsWith(String prefix) { + return new GenericAssertionPredicate<>( + value -> value.startsWith(prefix), + value -> "'" + value + "' does not start with '" + prefix + "'"); + } +} diff --git a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/predicate/TimeAssertionPredicates.java b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/predicate/TimeAssertionPredicates.java new file mode 100644 index 00000000000..a8596d92b1d --- /dev/null +++ b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/predicate/TimeAssertionPredicates.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2020 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ + +package com.evolveum.midpoint.test.asserter.predicate; + +import com.evolveum.midpoint.prism.xml.XmlTypeConverter; + +import org.jetbrains.annotations.NotNull; + +import javax.xml.datatype.XMLGregorianCalendar; +import java.util.Date; + +/** + * Methods for construction of various time-related assertion predicates. + * + * Experimental. + */ +public class TimeAssertionPredicates { + + public static AssertionPredicate approximatelyCurrent(long tolerance) { + return new GenericAssertionPredicate<>( + value -> Math.abs(XmlTypeConverter.toMillis(value) - System.currentTimeMillis()) <= tolerance, + value -> "value of " + value + " is not within tolerance of " + tolerance + " regarding current time"); + } + + public static AssertionPredicate timeBetween(long min, long max) { + return new SimplifiedGenericAssertionPredicate<>( + value -> timeIsBetweenFailureMessage(XmlTypeConverter.toMillis(value), min, max)); + } + + private static String timeIsBetweenFailureMessage(long value, long min, long max) { + if (value < min) { + return "Time " + formatTime(value) + " is earlier than expected " + formatTime(min); + } else if (value > max) { + return "Time " + formatTime(value) + " is later than expected " + formatTime(max); + } else { + return null; + } + } + + @NotNull + private static String formatTime(long value) { + return new Date(value) + " (" + value + ")"; + } +} diff --git a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/prism/PrismContainerAsserter.java b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/prism/PrismContainerAsserter.java index c5fdbceec45..22127168aa4 100644 --- a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/prism/PrismContainerAsserter.java +++ b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/prism/PrismContainerAsserter.java @@ -44,6 +44,13 @@ public PrismItemAsserter, RA> assertIncomplete() { return this; } + public PrismContainerValueAsserter> value(int index) { + PrismContainerValueAsserter> asserter = + new PrismContainerValueAsserter<>(getItem().getValues().get(index), this, getDetails()); + copySetupTo(asserter); + return asserter; + } + protected String desc() { return getDetails(); } diff --git a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/prism/PrismContainerValueAsserter.java b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/prism/PrismContainerValueAsserter.java index 5cd9dac828c..265d00e8e7a 100644 --- a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/prism/PrismContainerValueAsserter.java +++ b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/prism/PrismContainerValueAsserter.java @@ -29,6 +29,8 @@ import com.evolveum.midpoint.prism.PrismValue; import com.evolveum.midpoint.prism.path.ItemName; import com.evolveum.midpoint.prism.util.PrismAsserts; +import com.evolveum.midpoint.test.asserter.predicate.AssertionPredicate; +import com.evolveum.midpoint.test.asserter.predicate.AssertionPredicateEvaluation; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.QNameUtil; @@ -113,6 +115,16 @@ public PrismContainerValueAsserter assertPropertyEquals(QName propName return this; } + public PrismContainerValueAsserter assertPropertyValueSatisfies(QName propName, AssertionPredicate predicate) { + PrismProperty prop = findProperty(propName); + T value = prop != null ? prop.getRealValue() : null; + AssertionPredicateEvaluation evaluation = predicate.evaluate(value); + if (evaluation.hasFailed()) { + fail("Property " + propName + " value of '" + value + "' does not satisfy predicate: " + evaluation.getFailureDescription()); + } + return this; + } + public PrismContainerValueAsserter assertPropertyValuesEqual(QName propName, T... expectedValues) { PrismProperty property = findProperty(propName); assertNotNull("No property "+propName+" in "+desc(), property); From 99e6d48602d3355d0a41bf1502ffe1f94c73aa85 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Sun, 1 Mar 2020 23:41:42 +0100 Subject: [PATCH 76/97] Fix XML namespaces in task archetypes (once more) --- .../initial-objects/508-archetype-task-single-bulk-action.xml | 2 +- .../509-archetype-task-iterative-bulk-action.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gui/admin-gui/src/main/resources/initial-objects/508-archetype-task-single-bulk-action.xml b/gui/admin-gui/src/main/resources/initial-objects/508-archetype-task-single-bulk-action.xml index 1aae4f05787..21cc8be36c8 100644 --- a/gui/admin-gui/src/main/resources/initial-objects/508-archetype-task-single-bulk-action.xml +++ b/gui/admin-gui/src/main/resources/initial-objects/508-archetype-task-single-bulk-action.xml @@ -23,7 +23,7 @@ vacant - extension/mext:executeScript + extension/scext:executeScript visible diff --git a/gui/admin-gui/src/main/resources/initial-objects/509-archetype-task-iterative-bulk-action.xml b/gui/admin-gui/src/main/resources/initial-objects/509-archetype-task-iterative-bulk-action.xml index 3efb36d68b2..e0fdccdb9b9 100644 --- a/gui/admin-gui/src/main/resources/initial-objects/509-archetype-task-iterative-bulk-action.xml +++ b/gui/admin-gui/src/main/resources/initial-objects/509-archetype-task-iterative-bulk-action.xml @@ -40,7 +40,7 @@ visible - extension/mext:executeScript + extension/scext:executeScript visible From 7cc2040961bd338ca6a4301d9939edebad52b363 Mon Sep 17 00:00:00 2001 From: kate Date: Mon, 2 Mar 2020 01:59:27 +0100 Subject: [PATCH 77/97] task panel menu items visibility --- .../gui/api/util/WebComponentUtil.java | 42 ++++++++++ .../data/column/InlineMenuButtonColumn.java | 10 ++- .../web/page/admin/server/PageTask.java | 81 ++++--------------- .../web/page/admin/server/TaskTablePanel.java | 53 +++++++++++- 4 files changed, 114 insertions(+), 72 deletions(-) diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/util/WebComponentUtil.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/util/WebComponentUtil.java index e7e918594dd..6dd9916b265 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/util/WebComponentUtil.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/util/WebComponentUtil.java @@ -647,6 +647,48 @@ public static TaskType createSingleRecurrenceTask(String taskName, QName applica return task; } + public static boolean canSuspendTask(TaskType task, PageBase pageBase) { + return pageBase.isAuthorized(ModelAuthorizationAction.SUSPEND_TASK, task.asPrismObject()) + && (isRunnableTask(task) || isRunningTask(task)) + && !isWorkflowTask(task); + } + + public static boolean canResumeTask(TaskType task, PageBase pageBase) { + return pageBase.isAuthorized(ModelAuthorizationAction.RESUME_TASK, task.asPrismObject()) + && (isSuspendedTask(task) || (isClosedTask(task) && isRecurringTask(task))) + && !isWorkflowTask(task); + } + + public static boolean canRunNowTask(TaskType task, PageBase pageBase) { + return pageBase.isAuthorized(ModelAuthorizationAction.RUN_TASK_IMMEDIATELY, task.asPrismObject()) + && (isRunnableTask(task) || (isClosedTask(task) && !isRecurringTask(task))) + && !isWorkflowTask(task); + } + + public static boolean isRunnableTask(TaskType task) { + return task != null && TaskExecutionStatusType.RUNNABLE == task.getExecutionStatus(); + } + + public static boolean isRunningTask(TaskType task) { + return task != null && task.getNodeAsObserved() != null; + } + + public static boolean isSuspendedTask(TaskType task) { + return task != null && TaskExecutionStatusType.SUSPENDED == task.getExecutionStatus(); + } + + public static boolean isClosedTask(TaskType task) { + return task != null && TaskExecutionStatusType.CLOSED == task.getExecutionStatus(); + } + + public static boolean isRecurringTask(TaskType task) { + return task != null && TaskRecurrenceType.RECURRING == task.getRecurrence(); + } + + public static boolean isWorkflowTask(TaskType task) { + return task != null && TaskCategory.WORKFLOW.equals(task.getCategory()); + } + public static void iterativeExecuteBulkAction(PageBase pageBase, ExecuteScriptType script, Task task, OperationResult result ) throws SchemaException, SecurityViolationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException{ diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/data/column/InlineMenuButtonColumn.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/data/column/InlineMenuButtonColumn.java index d4e484b2d99..efaea3a857c 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/data/column/InlineMenuButtonColumn.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/data/column/InlineMenuButtonColumn.java @@ -72,7 +72,7 @@ public Component getHeader(String componentId) { private Component getPanel(String componentId, IModel rowModel, int numberOfButtons, boolean isHeaderPanel) { List filteredMenuItems = new ArrayList<>(); - List cloneMenuItems = cloneColumnMenuActionIfUse(menuItems); + List cloneMenuItems = cloneColumnMenuActionIfUse(menuItems, rowModel); for (InlineMenuItem menuItem : (rowModel != null && rowModel.getObject() instanceof InlineMenuable ? ((InlineMenuable)rowModel.getObject()).getMenuItems() : cloneMenuItems)){ if (isHeaderPanel && !menuItem.isHeaderMenuItem()){ @@ -97,14 +97,14 @@ private Component getPanel(String componentId, IModel rowModel, List buttonMenuItems = new ArrayList<>(); menuItems.forEach(menuItem -> { if (menuItem instanceof ButtonInlineMenuItem){ - if (isHeaderPanel && !menuItem.isHeaderMenuItem()){ + if (isHeaderPanel && !menuItem.isHeaderMenuItem() || !menuItem.getVisible().getObject()){ return; } buttonMenuItems.add((ButtonInlineMenuItem) menuItem); } }); - return new MenuMultiButtonPanel(componentId, rowModel, numberOfButtons, Model.ofList(filteredMenuItems)) { + return new MenuMultiButtonPanel(componentId, rowModel, buttonMenuItems.size(), Model.ofList(filteredMenuItems)) { private static final long serialVersionUID = 1L; @@ -247,10 +247,11 @@ private boolean isPanelVisible(boolean isHeaderPanel){ return false; } - private List cloneColumnMenuActionIfUse(List menuItems) { + private List cloneColumnMenuActionIfUse(List menuItems, IModel rowModel) { List clonedMenuItems = new ArrayList(menuItems.size()); for (InlineMenuItem item : menuItems) { if (item.getAction() instanceof ColumnMenuAction) { + ((ColumnMenuAction)item.getAction()).setRowModel(rowModel); InlineMenuItem clonedItem; ColumnMenuAction clonedAction = new ColumnMenuAction() { @@ -273,6 +274,7 @@ public void onError(AjaxRequestTarget target) { } }; + clonedAction.setRowModel(rowModel); if (item instanceof ButtonInlineMenuItem) { clonedItem = new ButtonInlineMenuItem(item.getLabel(), item.isSubmit()) { diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTask.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTask.java index 6bcfacc066e..34703f4dd6b 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTask.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTask.java @@ -2,14 +2,12 @@ import com.evolveum.midpoint.gui.api.GuiStyleConstants; import com.evolveum.midpoint.gui.api.model.LoadableModel; -import com.evolveum.midpoint.gui.api.prism.ItemWrapper; import com.evolveum.midpoint.gui.api.prism.PrismContainerWrapper; import com.evolveum.midpoint.gui.api.prism.PrismObjectWrapper; import com.evolveum.midpoint.gui.api.util.WebComponentUtil; import com.evolveum.midpoint.gui.impl.prism.ItemEditabilityHandler; import com.evolveum.midpoint.gui.impl.prism.ItemPanelSettingsBuilder; import com.evolveum.midpoint.gui.impl.prism.ItemVisibilityHandler; -import com.evolveum.midpoint.model.api.ModelAuthorizationAction; import com.evolveum.midpoint.prism.Containerable; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.delta.ObjectDelta; @@ -160,7 +158,7 @@ public void onClick(AjaxRequestTarget target) { afterOperation(target, result); } }; - suspend.add(new VisibleBehaviour(this::canSuspend)); + suspend.add(new VisibleBehaviour(() -> WebComponentUtil.canSuspendTask(getTask(), PageTask.this))); suspend.add(AttributeAppender.append("class", "btn-danger")); repeatingView.add(suspend); @@ -173,7 +171,7 @@ public void onClick(AjaxRequestTarget target) { } }; resume.add(AttributeAppender.append("class", "btn-primary")); - resume.add(new VisibleBehaviour(this::canResume)); + resume.add(new VisibleBehaviour(() -> WebComponentUtil.canResumeTask(getTask(), PageTask.this))); repeatingView.add(resume); AjaxButton runNow = new AjaxButton(repeatingView.newChildId(), createStringResource("pageTaskEdit.button.runNow")) { @@ -186,7 +184,7 @@ public void onClick(AjaxRequestTarget target) { } }; runNow.add(AttributeAppender.append("class", "btn-success")); - runNow.add(new VisibleBehaviour(this::canRunNow)); + runNow.add(new VisibleBehaviour(() -> WebComponentUtil.canRunNowTask(getTask(), PageTask.this))); repeatingView.add(runNow); AjaxIconButton refreshNow = new AjaxIconButton(repeatingView.newChildId(), new Model<>("fa fa-refresh"), createStringResource("autoRefreshPanel.refreshNow")) { @@ -301,65 +299,6 @@ private String createResumePauseButton() { return "fa fa-play"; } - private boolean canSuspend() { - PrismObject task = getObjectWrapper().getObject(); - TaskType taskType = task.asObjectable(); - return isAuthorized(ModelAuthorizationAction.SUSPEND_TASK, task) - && isRunnable(taskType) || isRunning() - && !isWorkflow(task.asObjectable()); - } - - private boolean canResume() { - PrismObject task = getObjectWrapper().getObject(); - TaskType taskType = task.asObjectable(); - return isAuthorized(ModelAuthorizationAction.RESUME_TASK, task) - && (isSuspended(taskType) || (isClosed(taskType) && isRecurring(taskType))) - && !isWorkflow(taskType); - } - - - private boolean canRunNow() { - PrismObject task = getObjectWrapper().getObject(); - TaskType taskType = task.asObjectable(); - return isAuthorized(ModelAuthorizationAction.RUN_TASK_IMMEDIATELY, task) - && (isRunnable(taskType) || (isClosed(taskType) && !isRecurring(taskType))) - && !isWorkflow(taskType); - } - - private boolean isRunnable(TaskType task) { - return TaskExecutionStatusType.RUNNABLE == task.getExecutionStatus(); - } - - private boolean isRunning() { - PrismObject task = getObjectWrapper().getObject(); - TaskType taskType = task.asObjectable(); - return taskType.getNodeAsObserved() != null; - } - - private boolean isNotRunning(){ - return !isRunning(); - } - - private boolean isSuspended(TaskType task) { - return TaskExecutionStatusType.SUSPENDED == task.getExecutionStatus(); - } - - private boolean isClosed(TaskType task) { - return TaskExecutionStatusType.CLOSED == task.getExecutionStatus(); - } - - private boolean isRecurring(TaskType task) { - return TaskRecurrenceType.RECURRING == task.getRecurrence(); - } - - private boolean isWorkflow(TaskType task) { - return TaskCategory.WORKFLOW.equals(task.getCategory()); - } - - private TaskType getTask(){ - return getObjectWrapper().getObject().asObjectable(); - } - private IModel createSummaryPanelModel() { return isEditingFocus() ? @@ -533,10 +472,14 @@ private ItemVisibility getBasicTabVisibility(ItemPath path) { } private ItemEditabilityHandler getTaskEditabilityHandler(){ - ItemEditabilityHandler editableHandler = wrapper -> !isRunning(); + ItemEditabilityHandler editableHandler = wrapper -> !WebComponentUtil.isRunningTask(getTask()); return editableHandler; } + private TaskType getTask(){ + return getObjectWrapper().getObject().asObjectable(); + } + @Override protected Class getRestartResponsePage() { return PageTasks.class; @@ -573,7 +516,7 @@ protected boolean shouldTrigger() { @Override public int getRefreshInterval() { - TaskType task = getObjectWrapper().getObject().asObjectable(); + TaskType task = getTask(); TaskDtoExecutionStatus exec = TaskDtoExecutionStatus.fromTaskExecutionStatus(task.getExecutionStatus(), task.getNodeAsObserved() != null); if (exec == null) { return REFRESH_INTERVAL_IF_CLOSED; @@ -613,9 +556,13 @@ public void refresh(AjaxRequestTarget target) { } + private boolean isNotRunning(){ + return !WebComponentUtil.isRunningTask(getTask()); + } + public boolean isRefreshEnabled() { if (refreshEnabled == null) { - return isRunning(); + return WebComponentUtil.isRunningTask(getTask()); } return refreshEnabled; diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/TaskTablePanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/TaskTablePanel.java index 257a98922db..f334c8330c8 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/TaskTablePanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/TaskTablePanel.java @@ -9,6 +9,7 @@ import com.evolveum.midpoint.gui.api.GuiStyleConstants; import com.evolveum.midpoint.gui.api.component.MainObjectListPanel; +import com.evolveum.midpoint.gui.api.model.ReadOnlyModel; import com.evolveum.midpoint.gui.api.util.WebComponentUtil; import com.evolveum.midpoint.model.api.ModelPublicConstants; import com.evolveum.midpoint.model.api.TaskService; @@ -407,6 +408,17 @@ public IModel getConfirmationMessageModel() { String actionName = createStringResource("pageTasks.message.suspendAction").getString(); return TaskTablePanel.this.getTaskConfirmationMessageModel((ColumnMenuAction) getAction(), actionName); } + + @Override + public IModel getVisible() { + IModel> rowModel = ((ColumnMenuAction) getAction()).getRowModel(); + if (rowModel == null){ + return Model.of(Boolean.TRUE); + } + SelectableBean rowModelObj = (SelectableBean)rowModel.getObject(); + boolean visible = WebComponentUtil.canSuspendTask(rowModelObj.getValue(), TaskTablePanel.this.getPageBase()); + return Model.of(visible); + } }); items.add(new ButtonInlineMenuItem(createStringResource("pageTasks.button.resumeTask")) { private static final long serialVersionUID = 1L; @@ -433,8 +445,20 @@ public IModel getConfirmationMessageModel() { String actionName = createStringResource("pageTasks.message.resumeAction").getString(); return TaskTablePanel.this.getTaskConfirmationMessageModel((ColumnMenuAction) getAction(), actionName); } + + @Override + public IModel getVisible() { + IModel> rowModel = ((ColumnMenuAction) getAction()).getRowModel(); + if (rowModel == null){ + return Model.of(Boolean.TRUE); + } + SelectableBean rowModelObj = (SelectableBean)rowModel.getObject(); + boolean visible = WebComponentUtil.canResumeTask(rowModelObj.getValue(), TaskTablePanel.this.getPageBase()); + return Model.of(visible); + } + }); - items.add(new InlineMenuItem(createStringResource("pageTasks.button.scheduleTask")) { + items.add(new ButtonInlineMenuItem(createStringResource("pageTasks.button.scheduleTask")) { private static final long serialVersionUID = 1L; @Override @@ -449,11 +473,27 @@ public void onClick(AjaxRequestTarget target) { }; } + @Override + public String getButtonIconCssClass() { + return GuiStyleConstants.CLASS_START_MENU_ITEM; + } + @Override public IModel getConfirmationMessageModel() { String actionName = createStringResource("pageTasks.message.runNowAction").getString(); return TaskTablePanel.this.getTaskConfirmationMessageModel((ColumnMenuAction) getAction(), actionName); } + + @Override + public IModel getVisible() { + IModel> rowModel = ((ColumnMenuAction) getAction()).getRowModel(); + if (rowModel == null){ + return Model.of(Boolean.TRUE); + } + SelectableBean rowModelObj = (SelectableBean)rowModel.getObject(); + return Model.of(WebComponentUtil.canRunNowTask(rowModelObj.getValue(), TaskTablePanel.this.getPageBase())); + } + }); items.add(new InlineMenuItem(createStringResource("pageTasks.button.deleteTask")) { private static final long serialVersionUID = 1L; @@ -617,6 +657,17 @@ public IModel getConfirmationMessageModel() { String actionName = createStringResource("pageTasks.message.deleteWorkState").getString(); return TaskTablePanel.this.getTaskConfirmationMessageModel((ColumnMenuAction) getAction(), actionName); } + + @Override + public IModel getVisible() { + IModel> rowModel = ((ColumnMenuAction) getAction()).getRowModel(); + if (rowModel == null){ + return Model.of(Boolean.TRUE); + } + SelectableBean rowModelObj = (SelectableBean)rowModel.getObject(); + return Model.of(WebComponentUtil.canSuspendTask(rowModelObj.getValue(), TaskTablePanel.this.getPageBase())); + } + }; items.add(deleteWorkState); From 067b7b497492e62d0b4f83dd55305737322a6822 Mon Sep 17 00:00:00 2001 From: Hiroyuki Wada Date: Mon, 2 Mar 2020 00:59:32 +0900 Subject: [PATCH 78/97] MID-6092 Fix filtering by orgRef or tenantRef in role members tab --- .../admin/roles/MemberOperationsHelper.java | 14 +- .../evolveum/midpoint/gui/TestPageRole.java | 142 ++++++++++++++++++ .../web/AbstractGuiIntegrationTest.java | 24 +++ .../test/AbstractModelIntegrationTest.java | 4 + 4 files changed, 180 insertions(+), 4 deletions(-) create mode 100644 gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestPageRole.java diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/roles/MemberOperationsHelper.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/roles/MemberOperationsHelper.java index 25dad9df661..89e618dfdbf 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/roles/MemberOperationsHelper.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/roles/MemberOperationsHelper.java @@ -264,19 +264,25 @@ public static ObjectQuery createDirectMemberQuery(R q0 = prismContext.queryFor(FocusType.class) .type(objectType); } - S_AtomicFilterExit q = q0.item(FocusType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF) + + // Use exists filter to build a query like this: + // $a/targetRef = oid1 and $a/tenantRef = oid2 and $a/orgRef = oid3 + S_AtomicFilterExit q = q0.exists(FocusType.F_ASSIGNMENT) + .block() + .item(AssignmentType.F_TARGET_REF) .ref(createReferenceValuesList(targetObject, relations)); + if (tenant != null && tenant.getObjectType() != null) { - q = q.and().item(FocusType.F_ASSIGNMENT, AssignmentType.F_TENANT_REF).ref(ObjectTypeUtil.createObjectRef(tenant.getObjectType(), + q = q.and().item(AssignmentType.F_TENANT_REF).ref(ObjectTypeUtil.createObjectRef(tenant.getObjectType(), prismContext).asReferenceValue()); } if (project != null && project.getObjectType() != null) { - q = q.and().item(FocusType.F_ASSIGNMENT, AssignmentType.F_ORG_REF).ref(ObjectTypeUtil.createObjectRef(project.getObjectType(), + q = q.and().item(AssignmentType.F_ORG_REF).ref(ObjectTypeUtil.createObjectRef(project.getObjectType(), prismContext).asReferenceValue()); } - ObjectQuery query = q.build(); + ObjectQuery query = q.endBlock().build(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Searching members of role {} with query:\n{}", targetObject.getOid(), query.debugDump()); } diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestPageRole.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestPageRole.java new file mode 100644 index 00000000000..041226e4219 --- /dev/null +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestPageRole.java @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2010-2018 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ +package com.evolveum.midpoint.gui; + +import com.evolveum.midpoint.gui.test.TestMidPointSpringApplication; +import com.evolveum.midpoint.model.api.ModelExecuteOptions; +import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.util.logging.Trace; +import com.evolveum.midpoint.util.logging.TraceManager; +import com.evolveum.midpoint.web.AbstractInitializedGuiIntegrationTest; +import com.evolveum.midpoint.web.page.admin.roles.AbstractRoleMemberPanel; +import com.evolveum.midpoint.web.page.admin.roles.PageRole; +import com.evolveum.midpoint.web.util.OnePageParameterEncoder; +import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType; +import org.apache.wicket.Page; +import org.apache.wicket.request.mapper.parameter.PageParameters; +import org.apache.wicket.util.tester.FormTester; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.DirtiesContext.ClassMode; +import org.springframework.test.context.ActiveProfiles; +import org.testng.annotations.Test; + +import static com.evolveum.midpoint.web.AdminGuiTestConstants.USER_JACK_OID; +import static com.evolveum.midpoint.web.AdminGuiTestConstants.USER_JACK_USERNAME; +import static org.testng.Assert.assertNotNull; + +/** + * @author Hiroyuki Wada + */ +@DirtiesContext(classMode = ClassMode.AFTER_CLASS) +@ActiveProfiles("test") +@SpringBootTest(classes = TestMidPointSpringApplication.class) +public class TestPageRole extends AbstractInitializedGuiIntegrationTest { + + private static final Trace LOGGER = TraceManager.getTrace(TestPageOrg.class); + + private static final String MAIN_FORM = "mainPanel:mainForm"; + private static final String PATH_FORM_NAME = "tabPanel:panel:main:values:0:value:propertiesLabel:properties:0:property:values:0:valueContainer:form:input:originValueContainer:origValueWithButton:origValue:input"; + private static final String FORM_SAVE = "save"; + + @Override + public void initSystem(Task initTask, OperationResult initResult) throws Exception { + super.initSystem(initTask, initResult); + PrismObject systemConfig = parseObject(SYSTEM_CONFIGURATION_FILE); + + LOGGER.info("adding system config page"); + addObject(systemConfig, ModelExecuteOptions.createOverwrite(), initTask, initResult); + } + + @Test + public void test001testAddNewRole() throws Exception { + renderPage(PageRole.class); + + FormTester formTester = tester.newFormTester(MAIN_FORM, false); + formTester.setValue(PATH_FORM_NAME, "newRole"); + formTester = formTester.submit(FORM_SAVE); + + Thread.sleep(5000); + + PrismObject newRole = findObjectByName(RoleType.class, "newRole"); + assertNotNull(newRole, "New role not created."); + LOGGER.info("created role: {}", newRole.debugDump()); + } + + /** + * MID-6092 + */ + @Test + public void test002testMembers() throws Exception { + // GIVEN + PrismObject role1 = createObject(RoleType.class, "Role0001"); + PrismObject role2 = createObject(RoleType.class, "Role0002"); + String role1Oid = addObject(role1); + String role2Oid = addObject(role2); + Task task = createTask("assign"); + // Assign Role0001 with orgRef P0001 + assignParametricRole(USER_JACK_OID, role1Oid, ORG_SAVE_ELAINE_OID, null, task, task.getResult()); + assignRole(USER_ADMINISTRATOR_OID, role1Oid); + // Assign Role0002 with orgRef P0001 + assignParametricRole(USER_ADMINISTRATOR_OID, role2Oid, ORG_SAVE_ELAINE_OID, null, task, task.getResult()); + + String panel = "mainPanel:mainForm:tabPanel:panel"; + String memberTable = panel + ":form:memberContainer:memberTable:mainForm:table:box:tableContainer:table"; + + // WHEN + // Open Role0001 page + renderPage(PageRole.class, role1Oid); + // Show Members tab + clickOnTab(8); + + // THEN + tester.assertComponent(panel, AbstractRoleMemberPanel.class); + tester.debugComponentTrees(":rows:.*:cells:3:cell:link:label"); + // It should show all members who are assigned Role0001 + tester.hasLabel(memberTable + ":body:rows:1:cells:3:cell:link:label", USER_ADMINISTRATOR_USERNAME); + tester.hasLabel(memberTable + ":body:rows:2:cells:3:cell:link:label", USER_JACK_USERNAME); + tester.assertNotExists(memberTable + ":body:rows:3:cells:3:cell:link:label"); + + // WHEN + // Choose P0001 in 'Org/Project' filter selection + tester.clickLink(panel + ":form:project:inputContainer:choose"); + tester.clickLink("mainPopup:content:table:mainForm:table:box:tableContainer:table:body:rows:7:cells:2:cell:link"); + executeModalWindowCloseCallback("mainPopup"); + + // THEN + // It should show only one user who is assigned Role0001 with orgRef P0001 + tester.debugComponentTrees(":rows:.*:cells:3:cell:link:label"); + tester.hasLabel(memberTable + ":body:rows:3:cells:3:cell:link:label", USER_JACK_USERNAME); + tester.assertNotExists(memberTable + ":body:rows:4:cells:3:cell:link:label"); + } + + private void clickOnTab(int order) { + tester.assertRenderedPage(PageRole.class); + String tabPath = "mainPanel:mainForm:tabPanel:tabs-container:tabs:" + order + ":link"; + tester.clickLink(tabPath); + } + + private Page renderPage(Class expectedRenderedPageClass) { + return renderPage(expectedRenderedPageClass, null); + } + + private Page renderPage(Class expectedRenderedPageClass, String oid) { + LOGGER.info("render page role"); + PageParameters params = new PageParameters(); + if (oid != null) { + params.add(OnePageParameterEncoder.PARAMETER, oid); + } + Page pageRole = tester.startPage(expectedRenderedPageClass, params); + + tester.assertRenderedPage(expectedRenderedPageClass); + + return pageRole; + } +} diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/AbstractGuiIntegrationTest.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/AbstractGuiIntegrationTest.java index fa5772a76b3..f11cea93bab 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/AbstractGuiIntegrationTest.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/AbstractGuiIntegrationTest.java @@ -17,6 +17,11 @@ import java.util.Locale; import javax.xml.namespace.QName; +import org.apache.wicket.Component; +import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior; +import org.apache.wicket.behavior.AbstractAjaxBehavior; +import org.apache.wicket.behavior.Behavior; +import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow; import org.apache.wicket.util.tester.WicketTester; import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Autowired; @@ -310,4 +315,23 @@ protected Task createSimpleTask(String operation) { task.setChannel(SchemaConstants.CHANNEL_GUI_USER_URI); return task; } + + /** + * Emulate closing ModalWindow component. + * @param path + */ + protected void executeModalWindowCloseCallback(String path) { + Component component = tester.getComponentFromLastRenderedPage(path); + if (!(component instanceof ModalWindow)) { + fail("path: '" + path + "' is not ModalWindow: " + component.getClass()); + } + for (Behavior behavior : ((ModalWindow)component).getBehaviors()) { + if (behavior instanceof AbstractDefaultAjaxBehavior) { + String name = behavior.getClass().getSimpleName(); + if (name.startsWith("WindowClosedBehavior")) { + tester.executeBehavior((AbstractAjaxBehavior) behavior); + } + } + } + } } diff --git a/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java b/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java index 6f40c32830a..c883d72cce2 100644 --- a/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java +++ b/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java @@ -1452,11 +1452,15 @@ protected ObjectDelta createParametricAssignmentDelta(String userOid, if (orgOid != null) { PrismReference orgRef = cval.findOrCreateReference(AssignmentType.F_ORG_REF); orgRef.getValue().setOid(orgOid); + orgRef.getValue().setTargetType(OrgType.COMPLEX_TYPE); + orgRef.getValue().setRelation(ORG_DEFAULT); } if (tenantOid != null) { PrismReference tenantRef = cval.findOrCreateReference(AssignmentType.F_TENANT_REF); tenantRef.getValue().setOid(tenantOid); + tenantRef.getValue().setTargetType(OrgType.COMPLEX_TYPE); + tenantRef.getValue().setRelation(ORG_DEFAULT); } From 0a3f79ea0081b50601b4b61b671a830a6e50da7a Mon Sep 17 00:00:00 2001 From: lskublik Date: Mon, 2 Mar 2020 08:32:16 +0100 Subject: [PATCH 79/97] fix for redirect URL when hostname contains context path (MID-6091) --- .../web/boot/EmbeddedTomcatAutoConfiguration.java | 4 ++-- .../MidPointTomcatServletWebServerFactory.java | 10 +++++----- .../midpoint/web/boot/MidpointResponse.java | 14 ++++++++------ 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/boot/EmbeddedTomcatAutoConfiguration.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/boot/EmbeddedTomcatAutoConfiguration.java index 09e484b2a69..2885428b1ca 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/boot/EmbeddedTomcatAutoConfiguration.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/boot/EmbeddedTomcatAutoConfiguration.java @@ -59,14 +59,14 @@ public static class EmbeddedTomcat { private int port; @Value("${server.servlet.context-path}") - private String servletPath; + private String contextPath; @Autowired private SystemObjectCache systemObjectCache; @Bean public TomcatServletWebServerFactory tomcatEmbeddedServletContainerFactory() { - MidPointTomcatServletWebServerFactory tomcat = new MidPointTomcatServletWebServerFactory(servletPath, systemObjectCache); + MidPointTomcatServletWebServerFactory tomcat = new MidPointTomcatServletWebServerFactory(contextPath, systemObjectCache); if(enableAjp) { Connector ajpConnector = new Connector("AJP/1.3"); diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/boot/MidPointTomcatServletWebServerFactory.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/boot/MidPointTomcatServletWebServerFactory.java index 9fd50ea7388..ae21a95efe5 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/boot/MidPointTomcatServletWebServerFactory.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/boot/MidPointTomcatServletWebServerFactory.java @@ -41,12 +41,12 @@ public class MidPointTomcatServletWebServerFactory extends TomcatServletWebServe private int backgroundProcessorDelay; - private String servletPath; + private String contextPath; private SystemObjectCache systemObjectCache; - public MidPointTomcatServletWebServerFactory(String servletPath, SystemObjectCache systemObjectCache){ - this.servletPath = servletPath; + public MidPointTomcatServletWebServerFactory(String contextPath, SystemObjectCache systemObjectCache){ + this.contextPath = contextPath; this.systemObjectCache = systemObjectCache; } @@ -94,9 +94,9 @@ public Response createResponse() { if (protocolHandler instanceof AbstractAjpProtocol) { int packetSize = ((AbstractAjpProtocol) protocolHandler).getPacketSize(); return new MidpointResponse(packetSize - org.apache.coyote.ajp.Constants.SEND_HEAD_LEN, - servletPath, systemObjectCache); + contextPath, systemObjectCache); } else { - return new MidpointResponse(servletPath, systemObjectCache); + return new MidpointResponse(contextPath, systemObjectCache); } } }; diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/boot/MidpointResponse.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/boot/MidpointResponse.java index e1dba06f142..d36c41e7575 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/boot/MidpointResponse.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/boot/MidpointResponse.java @@ -28,17 +28,17 @@ public class MidpointResponse extends Response { private static final Trace LOGGER = TraceManager.getTrace(MidpointResponse.class); - private String servletPath; + private String contextPath; private SystemObjectCache systemObjectCache; public MidpointResponse(String servletPath, SystemObjectCache systemObjectCache) { this(OutputBuffer.DEFAULT_BUFFER_SIZE, servletPath, systemObjectCache); } - public MidpointResponse(int outputBufferSize, String servletPath, SystemObjectCache systemObjectCache) { + public MidpointResponse(int outputBufferSize, String contextPath, SystemObjectCache systemObjectCache) { super(outputBufferSize); - this.servletPath = servletPath; + this.contextPath = contextPath; this.systemObjectCache = systemObjectCache; } @@ -49,15 +49,17 @@ public void setHeader(String name, String value) { if (publicUrlPrefix != null && StringUtils.isNotBlank(value)) { if (value.startsWith(".")) { value = publicUrlPrefix + value.substring(1); - } else if (StringUtils.isBlank(servletPath)) { + } else if (StringUtils.isBlank(contextPath)) { if (value.startsWith("/")) { value = publicUrlPrefix + value; } else { String partAfterSchema = value.substring(value.indexOf("://") + 3); value = publicUrlPrefix + partAfterSchema.substring(partAfterSchema.indexOf("/")); } - } else if (value.contains(servletPath + "/")) { - value = publicUrlPrefix + value.substring(value.indexOf(servletPath) + servletPath.length()); + } else if (value.contains(contextPath + "/")) { + String partAfterHostname = value.substring(value.indexOf("://") + 3); + partAfterHostname = partAfterHostname.substring(partAfterHostname.indexOf("/")); + value = publicUrlPrefix + partAfterHostname.substring(partAfterHostname.indexOf(contextPath) + contextPath.length()); } } } From a45fb2ebac84548487f025d38d6b94649d429f61 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Mon, 2 Mar 2020 10:46:21 +0100 Subject: [PATCH 80/97] tons of tests: removed TEST_NAME from when/then or completely --- .../TestIntegrationObjectWrapperFactory.java | 46 +- .../midpoint/web/TestIntegrationSecurity.java | 18 +- .../com/evolveum/midpoint/prism/TestDiff.java | 71 +--- .../midpoint/prism/TestExtraSchema.java | 17 +- .../com/evolveum/midpoint/prism/TestFind.java | 50 +-- .../lens/TestAbstractAssignmentEvaluator.java | 56 +-- .../impl/lens/TestAssignmentProcessor.java | 4 +- .../model/impl/lens/TestClockwork.java | 12 +- .../model/impl/lens/TestPolicyRules2.java | 92 ++-- .../model/impl/lens/TestProjector.java | 8 +- .../model/impl/lens/TestReconScript.java | 4 +- .../impl/misc/ShadowIntegrityCheckerTest.java | 4 +- .../impl/sync/TestSynchronizationService.java | 48 +-- .../model/impl/visualizer/TestVisualizer.java | 56 +-- .../midpoint/model/intest/TestActivation.java | 110 ++--- .../midpoint/model/intest/TestAudit.java | 52 +-- .../midpoint/model/intest/TestCaseIgnore.java | 40 +- .../model/intest/TestConsistencySimple.java | 4 +- .../midpoint/model/intest/TestDeputy.java | 140 +++--- .../model/intest/TestEntitlements.java | 272 ++++++------ .../midpoint/model/intest/TestInbounds.java | 28 +- .../midpoint/model/intest/TestIntent.java | 16 +- .../midpoint/model/intest/TestIteration.java | 168 ++++---- .../model/intest/TestIterativeTasks.java | 4 +- .../midpoint/model/intest/TestLifecycle.java | 40 +- .../intest/TestModelServiceContract.java | 60 +-- .../model/intest/TestPreviewChanges.java | 88 ++-- .../midpoint/model/intest/TestResources.java | 72 ++-- .../model/intest/TestTolerantAttributes.java | 8 +- .../intest/TestUserTemplateWithRanges.java | 36 +- .../intest/archetypes/TestArchetypes.java | 82 ++-- .../intest/archetypes/TestCollections.java | 28 +- .../model/intest/gensync/TestEditSchema.java | 140 +++--- .../intest/gensync/TestRoleEntitlement.java | 20 +- .../AbstractDirectManualResourceTest.java | 136 +++--- .../AbstractGroupingManualResourceTest.java | 52 +-- .../manual/AbstractManualResourceTest.java | 158 +++---- .../manual/TestDummyItsmIntegration.java | 60 +-- .../model/intest/manual/TestSemiManual.java | 16 +- .../TestSemiManualGroupingProposed.java | 8 +- .../mapping/TestMappingAutoInbound.java | 56 +-- .../intest/mapping/TestMappingInbound.java | 68 +-- .../model/intest/misc/TestMigration.java | 12 +- .../midpoint/model/intest/misc/TestMisc.java | 78 ++-- .../intest/misc/TestUuidNonUniqueName.java | 20 +- .../model/intest/multi/TestMultiAccount.java | 24 +- .../intest/negative/TestAssignmentErrors.java | 20 +- .../intest/negative/TestBrokenResources.java | 56 +-- .../model/intest/orgstruct/TestOrgStruct.java | 36 +- .../intest/persona/AbstractPersonaTest.java | 40 +- .../intest/persona/TestPersonaPassword.java | 4 +- .../intest/rbac/TestAssignmentValidity.java | 196 ++++----- .../midpoint/model/intest/rbac/TestRbac.java | 402 +++++++++--------- .../intest/rbac/TestSegregationOfDuties.java | 104 ++--- .../intest/security/TestSecurityAdvanced.java | 128 +++--- .../intest/security/TestSecurityBasic.java | 106 ++--- .../intest/security/TestSecurityMedium.java | 6 +- .../security/TestSecurityMultitenant.java | 58 +-- .../security/TestSecurityPrincipal.java | 20 +- .../sync/AbstractObjTemplateSyncTest.java | 4 +- .../AbstractSynchronizationStoryTest.java | 64 +-- .../model/intest/sync/TestImportRecon.java | 178 ++++---- .../intest/sync/TestInboundLiveSyncTask.java | 4 +- .../intest/sync/TestInboundReconTask.java | 8 +- .../model/intest/sync/TestLiveSyncTask.java | 4 +- .../sync/TestLiveSyncTaskMechanics.java | 56 +-- .../intest/sync/TestParallelDiscovery.java | 6 +- .../sync/TestParallelSynchronization.java | 6 +- .../midpoint/model/intest/sync/TestUuid.java | 24 +- .../sync/TestValidityRecomputeTask.java | 4 +- .../evolveum/midpoint/report/TestReport.java | 12 +- .../midpoint/report/TestReportWebService.java | 24 +- .../impl/TestConnectorDiscovery.java | 4 +- .../impl/TestConnectorManager.java | 8 +- .../provisioning/impl/csv/TestCsvBroken.java | 34 +- .../impl/dummy/AbstractBasicDummyTest.java | 336 ++++++--------- .../provisioning/impl/dummy/TestDummy.java | 172 ++++---- .../impl/dummy/TestDummyCaching.java | 22 +- .../impl/dummy/TestDummyConsistency.java | 170 ++++---- .../impl/dummy/TestDummyExtra.java | 8 +- .../impl/dummy/TestDummyNegative.java | 8 +- .../impl/dummy/TestDummyParallelism.java | 79 ++-- .../TestDummyResourceAndSchemaCaching.java | 4 +- .../impl/dummy/TestDummySchemaless.java | 12 +- .../manual/AbstractManualResourceTest.java | 124 +++--- .../provisioning/impl/opendj/TestOpenDj.java | 208 ++++----- .../impl/opendj/TestOpenDjDumber.java | 4 +- .../common/commandline/TestCommandLine.java | 8 +- .../test/AbstractIntegrationTest.java | 7 + .../midpoint/testing/longtest/TestLdap.java | 46 +- .../testing/longtest/TestLdapComplex.java | 20 +- .../midpoint/testing/longtest/TestRunAs.java | 28 +- .../testing/rest/TestAbstractRestService.java | 260 +++++------ .../midpoint/testing/sanity/TestSanity.java | 24 +- .../TestConfiguredCapabilitiesActivation.java | 8 +- .../story/TestConsistencyMechanism.java | 20 +- .../testing/story/TestDelayedEnable.java | 136 +++--- .../testing/story/TestExistentialIssues.java | 28 +- .../story/TestInboundOutboundAssociation.java | 56 +-- .../testing/story/TestLimitedResources.java | 36 +- .../testing/story/TestLiveSyncMadness.java | 12 +- .../midpoint/testing/story/TestMapleLeaf.java | 34 +- .../testing/story/TestMappingMadness.java | 32 +- .../story/TestMisbehavingResources.java | 24 +- .../testing/story/TestNormalizers.java | 8 +- .../testing/story/TestNullAttribute.java | 4 +- .../testing/story/TestOperationPerf.java | 4 +- .../midpoint/testing/story/TestOrgSync.java | 32 +- .../story/TestPlentyOfAssignments.java | 40 +- .../testing/story/TestReconNullValue.java | 20 +- .../midpoint/testing/story/TestScience.java | 4 +- .../testing/story/TestServiceAccounts.java | 44 +- .../story/TestServiceAccountsClassifier.java | 34 +- .../testing/story/TestShadowsPerformance.java | 18 +- .../midpoint/testing/story/TestStrings.java | 8 +- .../testing/story/TestThresholds.java | 6 +- .../story/TestThresholdsReconFull.java | 4 +- .../midpoint/testing/story/TestUnix.java | 186 ++++---- .../testing/story/TestUnixTolerantAux.java | 20 +- .../midpoint/testing/story/TestVillage.java | 8 +- .../midpoint/testing/story/TestWriter.java | 8 +- .../ldap/TestLdapAssociationPerformance.java | 34 +- .../testing/story/ldap/TestLdapComplex.java | 116 ++--- .../story/ldap/TestLdapDependency.java | 32 +- .../testing/story/ldap/TestLdapMutilated.java | 32 +- .../story/ldap/TestLdapReconPerformance.java | 18 +- .../story/ldap/TestLdapSyncMassive.java | 43 +- .../hierarchy/AbstractLdapHierarchyTest.java | 12 +- .../notorious/AbstractNotoriousTest.java | 104 ++--- .../testing/story/security/TestPrivacy.java | 4 +- .../story/security/TestRoleMembers.java | 12 +- 131 files changed, 3363 insertions(+), 3616 deletions(-) diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestIntegrationObjectWrapperFactory.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestIntegrationObjectWrapperFactory.java index 04ae8a6ea5e..06178e18898 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestIntegrationObjectWrapperFactory.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestIntegrationObjectWrapperFactory.java @@ -28,7 +28,6 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.IntegrationTestTools; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.*; import com.evolveum.midpoint.web.AbstractInitializedGuiIntegrationTest; import com.evolveum.midpoint.web.AdminGuiTestConstants; @@ -123,7 +122,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti PrismObject systemConfig = parseObject(SYSTEM_CONFIGURATION_FILE); -// LOGGER.info("adding system config page"); addObject(systemConfig, ModelExecuteOptions.createOverwrite(), initTask, initResult); } @@ -136,7 +134,7 @@ public void test100CreateWrapperUserJack() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assertLoggedInUserOid(USER_ADMINISTRATOR_OID); PrismObject user = getUser(USER_JACK_OID); @@ -147,7 +145,7 @@ public void test100CreateWrapperUserJack() throws Exception { PrismObjectWrapper objectWrapper = factory.createObjectWrapper(user, ItemStatus.NOT_CHANGED, context); // THEN - then(TEST_NAME); + then(); IntegrationTestTools.display("Wrapper after", objectWrapper); @@ -220,7 +218,7 @@ public void test110CreateWrapperUserNewEmpty() throws Exception { PrismObject user = getUserDefinition().instantiate(); // WHEN - when(TEST_NAME); + when(); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -233,7 +231,7 @@ public void test110CreateWrapperUserNewEmpty() throws Exception { PrismObjectWrapper objectWrapper = factory.createObjectWrapper(user, ItemStatus.ADDED, context); // THEN - then(TEST_NAME); + then(); IntegrationTestTools.display("Wrapper after", objectWrapper); @@ -290,7 +288,7 @@ public void test112CreateWrapperUserNewman() throws Exception { PrismObject user = getUserDefinition().instantiate(); // WHEN - when(TEST_NAME); + when(); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -310,7 +308,7 @@ public void test112CreateWrapperUserNewman() throws Exception { WrapperTestUtil.fillInPropertyWrapper(modelServiceLocator, mainContainerValueWrapper, extensionPath(PIRACY_SHIP), USER_NEWMAN_SHIP); // THEN - then(TEST_NAME); + then(); IntegrationTestTools.display("Wrapper after", objectWrapper); @@ -368,7 +366,7 @@ public void test102CreateWrapperUserEmpty() throws Exception { PrismObject userOld = user.clone(); // WHEN - when(TEST_NAME); + when(); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -380,7 +378,7 @@ public void test102CreateWrapperUserEmpty() throws Exception { PrismObjectWrapper objectWrapper = factory.createObjectWrapper(user, ItemStatus.NOT_CHANGED, context); // THEN - then(TEST_NAME); + then(); IntegrationTestTools.display("Wrapper after", objectWrapper); @@ -430,7 +428,7 @@ public void test150CreateWrapperShadow() throws Exception { PrismObject shadowOld = shadow.clone(); // WHEN - when(TEST_NAME); + when(); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -445,7 +443,7 @@ public void test150CreateWrapperShadow() throws Exception { // THEN - then(TEST_NAME); + then(); display("Wrapper after", objectWrapper); WrapperTestUtil.assertWrapper(objectWrapper, getString("prismContainer.mainPanelDisplayName"), "shadow description", shadow, shadowOld, ItemStatus.NOT_CHANGED); @@ -596,14 +594,14 @@ public void test220AssignRoleLandluberToWally() throws Exception { assertGroupMember(dummyGroup, USER_WALLY_NAME); // WHEN - when(TEST_NAME); + when(); PrismObjectWrapper objectWrapper = createObjectWrapper(task, shadow, ItemStatus.NOT_CHANGED); assertTrue("Wrong wrapper created. Expected ShadowWrapper but was " + objectWrapper.getClass().getSimpleName(), objectWrapper instanceof ShadowWrapper); ShadowWrapper shadowWrapper = (ShadowWrapper) objectWrapper; // THEN - then(TEST_NAME); + then(); display("Wrapper after", shadowWrapper); @@ -705,11 +703,11 @@ public void test241OrgScummBarModifyTransformProperties() throws Exception { IntegrationTestTools.display("Wrapper after", objectWrapper); // WHEN - when(TEST_NAME); + when(); ObjectDelta objectDelta = objectWrapper.getObjectDelta(); // THEN - then(TEST_NAME); + then(); display("Delta", objectDelta); ItemPath ahoyPath = ItemPath.create(ObjectType.F_EXTENSION, PIRACY_TRANSFORM, valueWrapperA.getNewValue().getId(), PIRACY_REPLACEMENT); PrismAsserts.assertPropertyReplace(objectDelta, ahoyPath, "Ahoy"); @@ -752,11 +750,11 @@ public void test242OrgScummBarAddTransform() throws Exception { IntegrationTestTools.display("Wrapper after", objectWrapper); // WHEN - when(TEST_NAME); + when(); ObjectDelta objectDelta = objectWrapper.getObjectDelta(); // THEN - then(TEST_NAME); + then(); display("Delta", objectDelta); ItemPath transformPath = ItemPath.create(ObjectType.F_EXTENSION, PIRACY_TRANSFORM); PrismAsserts.assertModifications(objectDelta, 1); @@ -804,11 +802,11 @@ public void test250OrgMinistryOrRumModifyTransformDescription() throws Exception IntegrationTestTools.display("Wrapper after", objectWrapper); // WHEN - when(TEST_NAME); + when(); ObjectDelta objectDelta = objectWrapper.getObjectDelta(); // THEN - then(TEST_NAME); + then(); display("Delta", objectDelta); PrismAsserts.assertModifications(objectDelta, 1); @@ -882,12 +880,12 @@ public void test800EditSchemaJackPropReadAllModifySomeUser() throws Exception { display("user before", user); // WHEN - when(TEST_NAME); + when(); PrismObjectWrapper objectWrapper = createObjectWrapper(getTestTask(), user, ItemStatus.NOT_CHANGED); // THEN - then(TEST_NAME); + then(); IntegrationTestTools.display("Wrapper after", objectWrapper); assertEquals("Wrong object wrapper readOnly", Boolean.FALSE, (Boolean)objectWrapper.isReadOnly()); @@ -954,12 +952,12 @@ public void test802EditSchemaJackPropReadSomeModifySomeUser() throws Exception { display("user before", user); // WHEN - when(TEST_NAME); + when(); PrismObjectWrapper objectWrapper = createObjectWrapper(task, user, ItemStatus.NOT_CHANGED); // THEN - then(TEST_NAME); + then(); IntegrationTestTools.display("Wrapper after", objectWrapper); assertEquals("Wrong object wrapper readOnly", Boolean.FALSE, (Boolean)objectWrapper.isReadOnly()); diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestIntegrationSecurity.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestIntegrationSecurity.java index 7dffcbdf538..98999722901 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestIntegrationSecurity.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestIntegrationSecurity.java @@ -101,7 +101,7 @@ public void test100DecideNoRole() throws Exception { Authentication authentication = createPasswordAuthentication(USER_JACK_USERNAME, UserType.class); // WHEN - when(TEST_NAME); + when(); assertAllow(authentication, "/login"); assertAllow(authentication, "/"); @@ -112,7 +112,7 @@ public void test100DecideNoRole() throws Exception { assertDeny(authentication, "/admin/config/debugs"); // THEN - then(TEST_NAME); + then(); } @Test @@ -128,7 +128,7 @@ public void test110DecideRoleUiAllowAll() throws Exception { Authentication authentication = createPasswordAuthentication(USER_JACK_USERNAME, UserType.class); // WHEN - when(TEST_NAME); + when(); assertAllow(authentication, "/login"); assertAllow(authentication, "/"); @@ -139,7 +139,7 @@ public void test110DecideRoleUiAllowAll() throws Exception { assertAllow(authentication, "/admin/config/debugs"); // THEN - then(TEST_NAME); + then(); } @Test @@ -155,7 +155,7 @@ public void test120DecideRoleUiDenyAll() throws Exception { Authentication authentication = createPasswordAuthentication(USER_JACK_USERNAME, UserType.class); // WHEN - when(TEST_NAME); + when(); assertAllow(authentication, "/login"); assertAllow(authentication, "/"); @@ -166,7 +166,7 @@ public void test120DecideRoleUiDenyAll() throws Exception { assertDeny(authentication, "/admin/config/debugs"); // THEN - then(TEST_NAME); + then(); } @@ -186,7 +186,7 @@ public void test200DecideRoleUiDenyAllow() throws Exception { Authentication authentication = createPasswordAuthentication(USER_JACK_USERNAME, UserType.class); // WHEN - when(TEST_NAME); + when(); assertAllow(authentication, "/login"); assertAllow(authentication, "/"); @@ -197,7 +197,7 @@ public void test200DecideRoleUiDenyAllow() throws Exception { assertDeny(authentication, "/admin/config/debugs"); // THEN - then(TEST_NAME); + then(); } @@ -220,7 +220,7 @@ public void test300ConflictingAuthorizationIds() throws Exception { login(USER_JACK_USERNAME); // THEN - then(TEST_NAME); + then(); assertLoggedInUsername(USER_JACK_USERNAME); } diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestDiff.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestDiff.java index 33525d65dfc..96fd23d3838 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestDiff.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestDiff.java @@ -6,7 +6,6 @@ */ package com.evolveum.midpoint.prism; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; import static org.testng.AssertJUnit.assertNull; import static com.evolveum.midpoint.prism.PrismInternalTestUtil.*; import static org.testng.AssertJUnit.assertEquals; @@ -26,15 +25,15 @@ import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.util.DebugUtil; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; /** * @author semancik - * */ -public class TestDiff { +public class TestDiff extends AbstractUnitTest { @BeforeSuite public void setupDebug() throws SchemaException, SAXException, IOException { @@ -44,7 +43,6 @@ public void setupDebug() throws SchemaException, SAXException, IOException { @Test public void testUserSimplePropertyDiffNoChange() throws Exception { - System.out.println("\n\n===[ testUserSimplePropertyDiffNoChange ]===\n"); // GIVEN PrismObjectDefinition userDef = getUserTypeDefinition(); @@ -68,7 +66,6 @@ public void testUserSimplePropertyDiffNoChange() throws Exception { @Test public void testPropertySimplePropertyDiffNoChange() throws Exception { - System.out.println("\n\n===[ testPropertySimplePropertyDiffNoChange ]===\n"); // GIVEN PrismObjectDefinition userDef = getUserTypeDefinition(); @@ -91,7 +88,6 @@ public void testPropertySimplePropertyDiffNoChange() throws Exception { @Test public void testPropertySimplePropertyDiffNoChangeStatic() throws Exception { - System.out.println("\n\n===[ testPropertySimplePropertyDiffNoChangeStatic ]===\n"); // GIVEN PrismObjectDefinition userDef = getUserTypeDefinition(); @@ -114,7 +110,6 @@ public void testPropertySimplePropertyDiffNoChangeStatic() throws Exception { @Test public void testUserSimplePropertyDiffReplace() throws Exception { - System.out.println("\n\n===[ testUserSimplePropertyDiffReplace ]===\n"); // GIVEN PrismObjectDefinition userDef = getUserTypeDefinition(); @@ -140,7 +135,6 @@ public void testUserSimplePropertyDiffReplace() throws Exception { @Test public void testPropertyUserSimplePropertyDiffReplace() throws Exception { - System.out.println("\n\n===[ testPropertyUserSimplePropertyDiffReplace ]===\n"); // GIVEN PrismObjectDefinition userDef = getUserTypeDefinition(); @@ -166,7 +160,6 @@ public void testPropertyUserSimplePropertyDiffReplace() throws Exception { @Test public void testPropertyUserSimplePropertyDiffReplaceStatic() throws Exception { - System.out.println("\n\n===[ testPropertyUserSimplePropertyDiffReplaceStatic ]===\n"); // GIVEN PrismObjectDefinition userDef = getUserTypeDefinition(); @@ -192,8 +185,6 @@ public void testPropertyUserSimplePropertyDiffReplaceStatic() throws Exception { @Test public void testUserSimpleDiffMultiNoChange() throws Exception { - System.out.println("\n\n===[ testUserSimpleDiffMultiNoChange ]===\n"); - // GIVEN PrismObjectDefinition userDef = getUserTypeDefinition(); @@ -221,8 +212,6 @@ public void testUserSimpleDiffMultiNoChange() throws Exception { @Test public void testPropertyUserSimpleDiffMultiNoChange() throws Exception { - System.out.println("\n\n===[ testPropertyUserSimpleDiffMultiNoChange ]===\n"); - // GIVEN PrismObjectDefinition userDef = getUserTypeDefinition(); @@ -247,8 +236,6 @@ public void testPropertyUserSimpleDiffMultiNoChange() throws Exception { @Test public void testPropertyUserSimpleDiffMultiNoChangeStatic() throws Exception { - System.out.println("\n\n===[ testPropertyUserSimpleDiffMultiNoChangeStatic ]===\n"); - // GIVEN PrismObjectDefinition userDef = getUserTypeDefinition(); @@ -273,8 +260,6 @@ public void testPropertyUserSimpleDiffMultiNoChangeStatic() throws Exception { @Test public void testUserSimpleDiffMultiAdd() throws Exception { - System.out.println("\n\n===[ testUserSimpleDiffMulti ]===\n"); - // GIVEN PrismObjectDefinition userDef = getUserTypeDefinition(); @@ -305,8 +290,6 @@ public void testUserSimpleDiffMultiAdd() throws Exception { @Test public void testPropertyUserSimpleDiffMultiAdd() throws Exception { - System.out.println("\n\n===[ testPropertyUserSimpleDiffMultiAdd ]===\n"); - // GIVEN PrismObjectDefinition userDef = getUserTypeDefinition(); @@ -335,8 +318,6 @@ public void testPropertyUserSimpleDiffMultiAdd() throws Exception { @Test public void testPropertyUserSimpleDiffMultiAddStatic() throws Exception { - System.out.println("\n\n===[ testPropertyUserSimpleDiffMultiAddStatic ]===\n"); - // GIVEN PrismObjectDefinition userDef = getUserTypeDefinition(); @@ -365,8 +346,6 @@ public void testPropertyUserSimpleDiffMultiAddStatic() throws Exception { @Test public void testPropertyUserSimpleDiffMultiAddStaticNull1() throws Exception { - System.out.println("\n\n===[ testPropertyUserSimpleDiffMultiAddStaticNull1 ]===\n"); - // GIVEN PrismObjectDefinition userDef = getUserTypeDefinition(); @@ -388,8 +367,6 @@ public void testPropertyUserSimpleDiffMultiAddStaticNull1() throws Exception { @Test public void testPropertyUserSimpleDiffMultiAddStaticNull2() throws Exception { - System.out.println("\n\n===[ testPropertyUserSimpleDiffMultiAddStaticNull2 ]===\n"); - // GIVEN PrismObjectDefinition userDef = getUserTypeDefinition(); @@ -411,8 +388,6 @@ public void testPropertyUserSimpleDiffMultiAddStaticNull2() throws Exception { @Test public void testContainerSimpleDiffModificationsNoChange() throws Exception { - System.out.println("\n\n===[ testContainerSimpleDiffModificationsNoChange ]===\n"); - // GIVEN PrismObjectDefinition userDef = getUserTypeDefinition(); PrismContainerDefinition assignmentContDef = userDef.findContainerDefinition(UserType.F_ASSIGNMENT); @@ -437,8 +412,6 @@ public void testContainerSimpleDiffModificationsNoChange() throws Exception { @Test public void testContainerDiffModificationsDesciption() throws Exception { - System.out.println("\n\n===[ testContainerDiffModificationsDesciption ]===\n"); - // GIVEN PrismObjectDefinition userDef = getUserTypeDefinition(); PrismContainerDefinition assignmentContDef = userDef.findContainerDefinition(UserType.F_ASSIGNMENT); @@ -469,8 +442,6 @@ public void testContainerDiffModificationsDesciption() throws Exception { @Test public void testContainerValueDiffDesciptionNoPath() throws Exception { - System.out.println("\n\n===[ testContainerValueDiffDesciptionNoPath ]===\n"); - // GIVEN PrismObjectDefinition userDef = getUserTypeDefinition(); PrismContainerDefinition assignmentContDef = userDef.findContainerDefinition(UserType.F_ASSIGNMENT); @@ -496,42 +467,4 @@ public void testContainerValueDiffDesciptionNoPath() throws Exception { "chamalalia patlama paprtala"); ItemDeltaCollectionsUtil.checkConsistence(modifications); } - -// @Test -// public void testContainerValueDiffDesciptionPath() throws Exception { -// System.out.println("\n\n===[ testContainerValueDiffDesciptionPath ]===\n"); -// -// // GIVEN -// PrismObjectDefinition userDef = getUserTypeDefinition(); -// PrismContainerDefinition assignmentContDef = userDef.findContainerDefinition(UserType.F_ASSIGNMENT); -// -// PrismContainer ass1 = assignmentContDef.instantiate(); -// PrismContainerValue ass1cval = ass1.createNewValue(); -// ass1cval.setPropertyRealValue(AssignmentType.F_DESCRIPTION, "blah blah"); -// -// PrismContainer ass2 = assignmentContDef.instantiate(); -// PrismContainerValue ass2cval = ass2.createNewValue(); -// ass2cval.setPropertyRealValue(AssignmentType.F_DESCRIPTION, "chamalalia patlama paprtala"); -// -// ItemPath pathPrefix = ItemPath.create( -// new NameItemPathSegment(UserType.F_ASSIGNMENT), -// new IdItemPathSegment("1")); -// -// // WHEN -// Collection modifications = ass1cval.diff(ass2cval, pathPrefix, true, false); -// -// // THEN -// assertNotNull(modifications); -// System.out.println(DebugUtil.debugDump(modifications)); -// assertEquals("Unexpected number of midifications", 1, modifications.size()); -// PrismAsserts.assertPropertyReplace( -// modifications, -// ItemPath.create( -// new NameItemPathSegment(UserType.F_ASSIGNMENT), -// new IdItemPathSegment("1"), -// new NameItemPathSegment(AssignmentType.F_DESCRIPTION)), -// "chamalalia patlama paprtala"); -// ItemDelta.checkConsistence(modifications); -// } - } diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestExtraSchema.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestExtraSchema.java index b70ae0367d4..4162831196c 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestExtraSchema.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestExtraSchema.java @@ -34,11 +34,12 @@ import com.evolveum.midpoint.prism.foo.UserType; import com.evolveum.midpoint.prism.schema.PrismSchema; import com.evolveum.midpoint.prism.util.PrismAsserts; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; -public class TestExtraSchema { +public class TestExtraSchema extends AbstractUnitTest { public static final String NS_USER_2_EXT = "http://example.com/xml/ns/user-2-extension"; @@ -53,8 +54,6 @@ public class TestExtraSchema { */ @Test public void testExtraSchema() throws SAXException, IOException, SchemaException { - System.out.println("===[ testExtraSchema ]==="); - Document dataDoc = DOMUtil.parseFile(new File(COMMON_DIR_PATH, "root-foo.xml")); PrismContext context = constructPrismContext(); @@ -68,8 +67,6 @@ public void testExtraSchema() throws SAXException, IOException, SchemaException Validator validator = javaxSchema.newValidator(); DOMResult validationResult = new DOMResult(); validator.validate(new DOMSource(dataDoc),validationResult); -// System.out.println("Validation result:"); -// System.out.println(DOMUtil.serializeDOMToString(validationResult.getNode())); } /** @@ -78,8 +75,6 @@ public void testExtraSchema() throws SAXException, IOException, SchemaException */ @Test public void testUserExtensionSchemaLoad() throws SAXException, IOException, SchemaException { - System.out.println("===[ testUserExtensionSchemaLoad ]==="); - PrismContext context = constructPrismContext(); SchemaRegistryImpl reg = (SchemaRegistryImpl) context.getSchemaRegistry(); reg.registerPrismSchemasFromDirectory(EXTRA_SCHEMA_DIR); @@ -105,7 +100,6 @@ public void testUserExtensionSchemaLoad() throws SAXException, IOException, Sche @Test public void testUserExtensionSchemaParseUser() throws SAXException, IOException, SchemaException { - System.out.println("===[ testUserExtensionSchemaParseUser ]==="); Document dataDoc = DOMUtil.parseFile(USER_JACK_FILE_XML); PrismContext context = constructPrismContext(); @@ -128,15 +122,10 @@ public void testUserExtensionSchemaParseUser() throws SAXException, IOException, Validator validator = javaxSchema.newValidator(); DOMResult validationResult = new DOMResult(); validator.validate(new DOMSource(dataDoc),validationResult); -// System.out.println("Validation result:"); -// System.out.println(DOMUtil.serializeDOMToString(validationResult.getNode())); - } @Test public void testUserExtensionSchemaSchemaRegistry() throws SAXException, IOException, SchemaException { - System.out.println("===[ testUserExtensionSchemaAsObjectSchema ]==="); - PrismContext context = constructPrismContext(); SchemaRegistryImpl reg = (SchemaRegistryImpl) context.getSchemaRegistry(); reg.registerPrismSchemasFromDirectory(EXTRA_SCHEMA_DIR); @@ -207,8 +196,6 @@ private void assertDefinitionOrder(List definitions, Q */ @Test public void testTypeOverride() throws SAXException, IOException, SchemaException { - System.out.println("===[ testTypeOverride ]==="); - PrismContext context = constructPrismContext(); SchemaRegistryImpl reg = (SchemaRegistryImpl) context.getSchemaRegistry(); reg.registerPrismSchemasFromDirectory(EXTRA_SCHEMA_DIR); diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestFind.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestFind.java index 3b6466a5e45..40e4d330273 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestFind.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestFind.java @@ -6,14 +6,13 @@ */ package com.evolveum.midpoint.prism; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; +import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertTrue; + import static com.evolveum.midpoint.prism.PrismInternalTestUtil.*; -import static org.testng.AssertJUnit.assertEquals; import java.io.IOException; -import com.evolveum.midpoint.prism.path.ItemPath; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; import org.xml.sax.SAXException; @@ -21,16 +20,17 @@ import com.evolveum.midpoint.prism.foo.AccountConstructionType; import com.evolveum.midpoint.prism.foo.AssignmentType; import com.evolveum.midpoint.prism.foo.UserType; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.prism.util.PrismTestUtil; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; /** * @author semancik - * */ -public class TestFind { +public class TestFind extends AbstractUnitTest { @BeforeSuite public void setupDebug() throws SchemaException, SAXException, IOException { @@ -40,9 +40,6 @@ public void setupDebug() throws SchemaException, SAXException, IOException { @Test public void testFindString() throws SchemaException, SAXException, IOException { - final String TEST_NAME = "testFindString"; - System.out.println("===[ "+TEST_NAME+" ]==="); - // GIVEN PrismObject user = createUser(); ItemPath path = UserType.F_DESCRIPTION; @@ -51,15 +48,12 @@ public void testFindString() throws SchemaException, SAXException, IOException { PrismProperty nameProperty = findProperty(user, path); // THEN - assertEquals("Wrong property value (path="+path+")", USER_JACK_DESCRIPTION, nameProperty.getRealValue()); + assertEquals("Wrong property value (path=" + path + ")", USER_JACK_DESCRIPTION, nameProperty.getRealValue()); assertTrue("QName found something other", nameProperty == (PrismProperty) user.findProperty(UserType.F_DESCRIPTION)); } @Test public void testFindPolyString() throws SchemaException, SAXException, IOException { - final String TEST_NAME = "testFindPolyString"; - System.out.println("===[ "+TEST_NAME+" ]==="); - // GIVEN PrismObject user = createUser(); ItemPath path = UserType.F_POLY_NAME; @@ -74,9 +68,6 @@ public void testFindPolyString() throws SchemaException, SAXException, IOExcepti @Test public void testFindPolyStringOrig() throws SchemaException, SAXException, IOException { - final String TEST_NAME = "testFindPolyStringOrig"; - System.out.println("===[ "+TEST_NAME+" ]==="); - // GIVEN ItemPath path = ItemPath.create(UserType.F_POLY_NAME, PolyString.F_ORIG); @@ -84,14 +75,11 @@ public void testFindPolyStringOrig() throws SchemaException, SAXException, IOExc Object found = findUser(path); // THEN - assertEquals("Wrong property value (path="+path+")", USER_JACK_POLYNAME_ORIG, found); + assertEquals("Wrong property value (path=" + path + ")", USER_JACK_POLYNAME_ORIG, found); } @Test public void testFindPolyStringNorm() throws SchemaException, SAXException, IOException { - final String TEST_NAME = "testFindPolyStringNorm"; - System.out.println("===[ "+TEST_NAME+" ]==="); - // GIVEN ItemPath path = ItemPath.create(UserType.F_POLY_NAME, PolyString.F_NORM); @@ -99,14 +87,11 @@ public void testFindPolyStringNorm() throws SchemaException, SAXException, IOExc Object found = findUser(path); // THEN - assertEquals("Wrong property value (path="+path+")", USER_JACK_POLYNAME_NORM, found); + assertEquals("Wrong property value (path=" + path + ")", USER_JACK_POLYNAME_NORM, found); } @Test public void testFindExtensionBar() throws SchemaException, SAXException, IOException { - final String TEST_NAME = "testFindExtensionBar"; - System.out.println("===[ "+TEST_NAME+" ]==="); - // GIVEN ItemPath path = ItemPath.create(UserType.F_EXTENSION, EXTENSION_BAR_ELEMENT); @@ -114,14 +99,11 @@ public void testFindExtensionBar() throws SchemaException, SAXException, IOExcep PrismProperty property = findUserProperty(path); // THEN - assertEquals("Wrong property value (path="+path+")", "BAR", property.getAnyRealValue()); + assertEquals("Wrong property value (path=" + path + ")", "BAR", property.getAnyRealValue()); } @Test public void testFindAssignment1Description() throws SchemaException, SAXException, IOException { - final String TEST_NAME = "testFindAssignment1Description"; - System.out.println("===[ "+TEST_NAME+" ]==="); - // GIVEN ItemPath path = ItemPath.create(UserType.F_ASSIGNMENT, USER_ASSIGNMENT_1_ID, AssignmentType.F_DESCRIPTION); @@ -129,14 +111,11 @@ public void testFindAssignment1Description() throws SchemaException, SAXExceptio PrismProperty property = findUserProperty(path); // THEN - assertEquals("Wrong property value (path="+path+")", "Assignment 1", property.getRealValue()); + assertEquals("Wrong property value (path=" + path + ")", "Assignment 1", property.getRealValue()); } @Test public void testFindAssignment2Construction() throws SchemaException, SAXException, IOException { - final String TEST_NAME = "testFindAssignment2ConstructionHowto"; - System.out.println("===[ "+TEST_NAME+" ]==="); - // GIVEN ItemPath path = ItemPath.create(UserType.F_ASSIGNMENT, USER_ASSIGNMENT_2_ID, AssignmentType.F_ACCOUNT_CONSTRUCTION); @@ -144,14 +123,11 @@ public void testFindAssignment2Construction() throws SchemaException, SAXExcepti PrismProperty property = findUserProperty(path); // THEN - assertEquals("Wrong property value (path="+path+")", "Just do it", property.getRealValue().getHowto()); + assertEquals("Wrong property value (path=" + path + ")", "Just do it", property.getRealValue().getHowto()); } @Test public void testFindAssignment() throws SchemaException, SAXException, IOException { - final String TEST_NAME = "testFindAssignment"; - System.out.println("===[ "+TEST_NAME+" ]==="); - // GIVEN ItemPath path = UserType.F_ASSIGNMENT; @@ -160,7 +136,7 @@ public void testFindAssignment() throws SchemaException, SAXException, IOExcepti // THEN PrismContainerValue value2 = container.getValue(USER_ASSIGNMENT_2_ID); - assertEquals("Wrong value2 description (path="+path+")", "Assignment 2", value2.findProperty(AssignmentType.F_DESCRIPTION).getRealValue()); + assertEquals("Wrong value2 description (path=" + path + ")", "Assignment 2", value2.findProperty(AssignmentType.F_DESCRIPTION).getRealValue()); } private T findUser(ItemPath path) throws SchemaException, SAXException, IOException { @@ -217,10 +193,8 @@ private PrismContainer findContainer(PrismObject createUser() throws SchemaException, SAXException, IOException { return PrismTestUtil.parseObject(USER_JACK_FILE_XML); } - } diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAbstractAssignmentEvaluator.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAbstractAssignmentEvaluator.java index 9d62fc40462..8414436d4a8 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAbstractAssignmentEvaluator.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAbstractAssignmentEvaluator.java @@ -124,12 +124,12 @@ public void test100Direct() throws Exception { ItemDeltaItem,PrismContainerDefinition> assignmentIdi = createAssignmentIdi(assignmentType); // WHEN - when(TEST_NAME); + when(); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, "testDirect", false, task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -163,12 +163,12 @@ public void test110DirectExpression() throws Exception { ItemDeltaItem,PrismContainerDefinition> assignmentIdi = createAssignmentIdi(assignmentType); // WHEN - when(TEST_NAME); + when(); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, "testDirect", false, task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -210,12 +210,12 @@ public void test120DirectExpressionReplaceDescription() throws Exception { display("Assignment IDI", assignmentIdi); // WHEN - when(TEST_NAME); + when(); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, "testDirect", false, task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertNotNull(evaluatedAssignment); @@ -271,12 +271,12 @@ public void test130DirectExpressionReplaceDescriptionFromNull() throws Exception assignmentIdi.recompute(); // WHEN - when(TEST_NAME); + when(); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, "testDirect", false, task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertNotNull(evaluatedAssignment); @@ -344,12 +344,12 @@ public void test140RoleVisitor() throws Exception { ItemDeltaItem,PrismContainerDefinition> assignmentIdi = createAssignmentIdi(assignmentType); // WHEN - when(TEST_NAME); + when(); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, TEST_NAME, false, task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertNotNull(evaluatedAssignment); @@ -389,12 +389,12 @@ public void test142RoleVisitorDisabledAssignment() throws Exception { ItemDeltaItem,PrismContainerDefinition> assignmentIdi = createAssignmentIdi(assignmentType); // WHEN - when(TEST_NAME); + when(); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, TEST_NAME, false, task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -434,12 +434,12 @@ public void test150RoleEngineer() throws Exception { ItemDeltaItem,PrismContainerDefinition> assignmentIdi = createAssignmentIdi(assignmentType); // WHEN - when(TEST_NAME); + when(); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, "testRoleEngineer", false, task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertNotNull(evaluatedAssignment); @@ -485,12 +485,12 @@ public void test160AddRoleEngineer() throws Exception { ItemDeltaItem,PrismContainerDefinition> assignmentIdi = createAssignmentIdi(assignmentType); // WHEN - when(TEST_NAME); + when(); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, TEST_NAME, false, task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertNotNull(evaluatedAssignment); @@ -557,12 +557,12 @@ public void test170RoleManagerChangeCostCenter() throws Exception { ItemDeltaItem,PrismContainerDefinition> assignmentIdi = createAssignmentIdi(assignmentType); // WHEN - when(TEST_NAME); + when(); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, TEST_NAME, false, task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -620,12 +620,12 @@ public void test180RoleManagerRemoveCostCenter() throws Exception { ItemDeltaItem,PrismContainerDefinition> assignmentIdi = createAssignmentIdi(assignmentType); // WHEN - when(TEST_NAME); + when(); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, TEST_NAME, false, task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -678,12 +678,12 @@ public void test200DisableEngineerEmployeeInducement() throws Exception { ItemDeltaItem,PrismContainerDefinition> assignmentIdi = createAssignmentIdi(assignmentType); // WHEN - when(TEST_NAME); + when(); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, "testRoleEngineer", false, task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -738,12 +738,12 @@ public void test300DisableRoleEmployee() throws Exception { ItemDeltaItem,PrismContainerDefinition> assignmentIdi = createAssignmentIdi(assignmentType); // WHEN - when(TEST_NAME); + when(); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, "testRoleEngineer", false, task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -792,12 +792,12 @@ public void test310DisableRoleEngineer() throws Exception { ItemDeltaItem,PrismContainerDefinition> assignmentIdi = createAssignmentIdi(assignmentType); // WHEN - when(TEST_NAME); + when(); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, "testRoleEngineer", false, task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -853,11 +853,11 @@ public void test400UserFred() throws Exception { addFocusDeltaToContext(lensContext, descriptionDelta); // WHEN - when(TEST_NAME); + when(); projector.project(lensContext, "test", task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); DeltaSetTriple> triple = lensContext.getEvaluatedAssignmentTriple(); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor.java index 2f95b98a7a4..8796cdf2065 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor.java @@ -380,11 +380,11 @@ public void test031DeleteAssignmentModifyAccount() throws Exception { assertFocusModificationSanity(context); // WHEN - when(TEST_NAME); + when(); assignmentProcessor.processAssignments(context, getNow(), task, result); // THEN - then(TEST_NAME); + then(); display("Output context", context.dump(true)); display("result", result); assertSuccess(result); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestClockwork.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestClockwork.java index a4b349e7b25..07aae4b0647 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestClockwork.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestClockwork.java @@ -100,7 +100,7 @@ public void test010SerializeAddUserBarbossa() throws Exception { fillContextWithAddUserDelta(context, bill); // WHEN - when(TEST_NAME); + when(); clockwork.click(context, task, result); // one round - compute projections display("Context before serialization", context); @@ -116,7 +116,7 @@ public void test010SerializeAddUserBarbossa() throws Exception { display("Context after deserialization", context); // THEN - then(TEST_NAME); + then(); assertEquals("Secondary deltas are not preserved - their number differs", context.getFocusContext().getSecondaryDeltas().size(), context2.getFocusContext().getSecondaryDeltas().size()); for (int i = 0; i < context.getFocusContext().getSecondaryDeltas().size(); i++) { assertTrue("Secondary delta #" + i + " is not preserved correctly, " @@ -146,11 +146,11 @@ public void test020AssignAccountToJackSync() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - when(TEST_NAME); + when(); clockwork.run(context, task, result); // THEN - then(TEST_NAME); + then(); mockClockworkHook.setRecord(false); display("Output context", context); display("Hook contexts", mockClockworkHook); @@ -223,11 +223,11 @@ public void test053ModifyUserBarbossaDisable() throws Exception { assertFocusModificationSanity(context); // WHEN - when(TEST_NAME); + when(); clockwork.run(context, task, result); // THEN - then(TEST_NAME); + then(); display("Output context", context); assertTrue(context.getFocusContext().getPrimaryDelta().getChangeType() == ChangeType.MODIFY); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules2.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules2.java index 32459a7fc3f..233aa8d0b47 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules2.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules2.java @@ -145,11 +145,11 @@ public void test100JackAttemptAssignRoleStudent() throws Exception { assertFocusModificationSanity(context); // WHEN - when(TEST_NAME); + when(); projector.project(context, ACTIVITY_DESCRIPTION, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); dumpPolicyRules(context); @@ -187,11 +187,11 @@ public void test110JoeAttemptAssignRoleStudent() throws Exception { assertFocusModificationSanity(context); // WHEN - when(TEST_NAME); + when(); projector.project(context, ACTIVITY_DESCRIPTION, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -237,11 +237,11 @@ public void test120JackAttemptToMoveTo1900AndAssignRoleStudent() throws Exceptio assertFocusModificationSanity(context); // WHEN - when(TEST_NAME); + when(); projector.project(context, ACTIVITY_DESCRIPTION, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -289,12 +289,12 @@ public void test130JackMoveTo1900AndAssignRoleStudent() throws Exception { assertFocusModificationSanity(context); // WHEN - when(TEST_NAME); + when(); clockwork.run(context, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -343,13 +343,13 @@ public void test135JackChangeValidTo() throws Exception { assertFocusModificationSanity(context); // WHEN - when(TEST_NAME); + when(); // cannot run the clockwork as in the secondary state the deltas are no longer considered (!) projector.project(context, ACTIVITY_DESCRIPTION, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -385,12 +385,12 @@ public void test140JackNoChange() throws Exception { assertFocusModificationSanity(context); // WHEN - when(TEST_NAME); + when(); projector.project(context, ACTIVITY_DESCRIPTION, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -443,12 +443,12 @@ public void test142JackNoChangeButTaskExists() throws Exception { assertFocusModificationSanity(context); // WHEN - when(TEST_NAME); + when(); projector.project(context, ACTIVITY_DESCRIPTION, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -492,11 +492,11 @@ public void test150FrankAttemptToAssignRoleStudentButDisabled() throws Exception assertFocusModificationSanity(context); // WHEN - when(TEST_NAME); + when(); projector.project(context, ACTIVITY_DESCRIPTION, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -532,11 +532,11 @@ public void test160AttemptToAddPeter() throws Exception { assertFocusModificationSanity(context); // WHEN - when(TEST_NAME); + when(); projector.project(context, ACTIVITY_DESCRIPTION, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -571,11 +571,11 @@ public void test170AddPeter() throws Exception { assertFocusModificationSanity(context); // WHEN - when(TEST_NAME); + when(); clockwork.run(context, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -628,12 +628,12 @@ public void test180StudentRecompute() throws Exception { assertFocusModificationSanity(context); // WHEN - when(TEST_NAME); + when(); projector.project(context, ACTIVITY_DESCRIPTION, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -663,13 +663,13 @@ public void test200AddUnresolvable() throws Exception { assertFocusModificationSanity(context); // WHEN - when(TEST_NAME); + when(); try { clockwork.run(context, task, result); - then(TEST_NAME); + then(); fail("unexpected success"); } catch (ObjectNotFoundException e) { - then(TEST_NAME); + then(); System.out.println("Expected exception: " + e); e.printStackTrace(System.out); if (!e.getMessage().contains("No policy constraint named 'unresolvable' could be found")) { @@ -693,13 +693,13 @@ public void test210AddCyclic() throws Exception { assertFocusModificationSanity(context); // WHEN - when(TEST_NAME); + when(); try { clockwork.run(context, task, result); - then(TEST_NAME); + then(); fail("unexpected success"); } catch (SchemaException e) { - then(TEST_NAME); + then(); System.out.println("Expected exception: " + e); e.printStackTrace(System.out); if (!e.getMessage().contains("Trying to resolve cyclic reference to constraint")) { @@ -723,10 +723,10 @@ public void test220AddChained() throws Exception { assertFocusModificationSanity(context); // WHEN - when(TEST_NAME); + when(); clockwork.run(context, task, result); - then(TEST_NAME); + then(); display("Output context", context); Map rules = new HashMap<>(); @@ -782,13 +782,13 @@ public void test230AddAmbiguous() throws Exception { assertFocusModificationSanity(context); // WHEN - when(TEST_NAME); + when(); try { clockwork.run(context, task, result); - then(TEST_NAME); + then(); fail("unexpected success"); } catch (SchemaException e) { - then(TEST_NAME); + then(); System.out.println("Expected exception: " + e); e.printStackTrace(System.out); if (!e.getMessage().contains("Conflicting definitions of 'constraint-B'")) { @@ -816,13 +816,13 @@ public void test300ModifyInducement() throws Exception { assertFocusModificationSanity(context); // WHEN - when(TEST_NAME); + when(); try { clockwork.run(context, task, result); - then(TEST_NAME); + then(); fail("unexpected success"); } catch (PolicyViolationException e) { - then(TEST_NAME); + then(); System.out.println("Expected exception: " + e); e.printStackTrace(System.out); if (!getTranslatedMessage(e).contains("Role \"Immutable inducements\" is to be modified")) { @@ -850,9 +850,9 @@ public void test310ModifyInducementPass() throws Exception { assertFocusModificationSanity(context); // WHEN - when(TEST_NAME); + when(); clockwork.run(context, task, result); - then(TEST_NAME); + then(); result.computeStatus(); assertSuccess("unexpected failure", result); } @@ -876,9 +876,9 @@ public void test320ModifyInducementPass2() throws Exception { assertFocusModificationSanity(context); // WHEN - when(TEST_NAME); + when(); clockwork.run(context, task, result); - then(TEST_NAME); + then(); result.computeStatus(); assertSuccess("unexpected failure", result); } @@ -902,13 +902,13 @@ public void test330AddInducement() throws Exception { assertFocusModificationSanity(context); // WHEN - when(TEST_NAME); + when(); try { clockwork.run(context, task, result); - then(TEST_NAME); + then(); fail("unexpected success"); } catch (PolicyViolationException e) { - then(TEST_NAME); + then(); System.out.println("Expected exception: " + e); e.printStackTrace(System.out); if (!getTranslatedMessage(e).contains("Role \"No inducements add or delete\" is to be modified")) { @@ -936,13 +936,13 @@ public void test340AddInducementViaExpression() throws Exception { assertFocusModificationSanity(context); // WHEN - when(TEST_NAME); + when(); try { clockwork.run(context, task, result); - then(TEST_NAME); + then(); fail("unexpected success"); } catch (PolicyViolationException e) { - then(TEST_NAME); + then(); System.out.println("Expected exception: " + e); e.printStackTrace(System.out); if (!getTranslatedMessage(e).contains("Role \"No inducements add or delete (expression)\" is to be modified")) { diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjector.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjector.java index 00b3ca9ddf7..9e6cbe449a1 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjector.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjector.java @@ -574,11 +574,11 @@ public void test260ModifyAccountBarbossaDrinkReplace() throws Exception { assertFocusModificationSanity(context); // WHEN - when(TEST_NAME); + when(); projector.project(context, "test", task, result); // THEN - then(TEST_NAME); + then(); assertPartialError(result); } @@ -848,11 +848,11 @@ public void test301AssignConflictingAccountToJack() throws Exception { assertFocusModificationSanity(context); // WHEN - when(TEST_NAME); + when(); projector.project(context, "test", task, result); // THEN - then(TEST_NAME); + then(); display("Output context", context); assertTrue(context.getFocusContext().getPrimaryDelta().getChangeType() == ChangeType.MODIFY); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestReconScript.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestReconScript.java index 1fbea682b71..dacc10e3118 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestReconScript.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestReconScript.java @@ -210,7 +210,7 @@ public void test006TestReconDelete() throws Exception{ repositoryService.modifyObject(TaskType.class, TASK_RECON_DUMMY_OID, modifications, parentResult); // WHEN - when(TEST_NAME); + when(); waitForTaskStart(TASK_RECON_DUMMY_OID, false); @@ -219,7 +219,7 @@ public void test006TestReconDelete() throws Exception{ waitForTaskFinish(TASK_RECON_DUMMY_OID, false); // THEN - then(TEST_NAME); + then(); PrismObject shadow = repositoryService.getObject(ShadowType.class, ACCOUNT_BEFORE_SCRIPT_OID, null, parentResult); ShadowAsserter.forShadow(shadow) diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/misc/ShadowIntegrityCheckerTest.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/misc/ShadowIntegrityCheckerTest.java index 2cf2e2b294b..1946f65eb3d 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/misc/ShadowIntegrityCheckerTest.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/misc/ShadowIntegrityCheckerTest.java @@ -80,11 +80,11 @@ public void test100FixDuplicatesWithDifferentObjectClasses() throws Exception { repoAddObjectFromFile(TASK_SHADOW_INTEGRITY_CHECK_FILE, result); // WHEN - when(TEST_NAME); + when(); waitForTaskCloseOrSuspend(TASK_SHADOW_INTEGRITY_CHECK_OID); // THEN - then(TEST_NAME); + then(); PrismObject taskAfter = getTask(TASK_SHADOW_INTEGRITY_CHECK_OID); display("task after", taskAfter); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/sync/TestSynchronizationService.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/sync/TestSynchronizationService.java index 079fcc25b49..c6ba6e0e3a9 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/sync/TestSynchronizationService.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/sync/TestSynchronizationService.java @@ -160,11 +160,11 @@ public void test020ModifyLootAbsolute() throws Exception { change.setSourceChannel(SchemaConstants.CHANGE_CHANNEL_LIVE_SYNC_URI); // WHEN - when(TEST_NAME); + when(); synchronizationService.notifyChange(change, task, result); // THEN - then(TEST_NAME); + then(); LensContext context = cleanDebugListener(); display("Resulting context (as seen by debug listener)", context); @@ -357,11 +357,11 @@ public void test039DeletedAccountJack() throws Exception { change.setObjectDelta(syncDelta); // WHEN - when(TEST_NAME); + when(); synchronizationService.notifyChange(change, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); LensContext context = cleanDebugListener(); @@ -430,11 +430,11 @@ public void test050AddedAccountCalypso() throws Exception { change.setResource(getDummyResourceObject()); // WHEN - when(TEST_NAME); + when(); synchronizationService.notifyChange(change, task, result); // THEN - then(TEST_NAME); + then(); LensContext context = cleanDebugListener(); display("Resulting context (as seen by debug listener)", context); @@ -477,11 +477,11 @@ public void test051CalypsoRecon() throws Exception { display("Change notification", change); // WHEN - when(TEST_NAME); + when(); synchronizationService.notifyChange(change, task, result); // THEN - then(TEST_NAME); + then(); LensContext context = cleanDebugListener(); display("Resulting context (as seen by debug listener)", context); @@ -527,11 +527,11 @@ public void test100AddedAccountJack() throws Exception { change.setResource(getDummyResourceObject()); // WHEN - when(TEST_NAME); + when(); synchronizationService.notifyChange(change, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); LensContext context = cleanDebugListener(); @@ -590,11 +590,11 @@ public void test199DeletedAccountJackTotal() throws Exception { repositoryService.deleteObject(ShadowType.class, accountShadowJackDummyOid, result); // WHEN - when(TEST_NAME); + when(); synchronizationService.notifyChange(change, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result, 1); LensContext context = cleanDebugListener(); @@ -657,11 +657,11 @@ public void test200AddedAccountJackSchemaViolation() throws Exception { change.setResource(getDummyResourceObject()); // WHEN - when(TEST_NAME); + when(); synchronizationService.notifyChange(change, task, result); // THEN - then(TEST_NAME); + then(); getDummyResource().resetBreakMode(); assertPartialError(result); @@ -720,11 +720,11 @@ public void test202UpdatedAccountJackSchemaViolation() throws Exception { change.setResource(getDummyResourceObject()); // WHEN - when(TEST_NAME); + when(); synchronizationService.notifyChange(change, task, result); // THEN - then(TEST_NAME); + then(); getDummyResource().resetBreakMode(); assertPartialError(result); @@ -772,11 +772,11 @@ public void test210AssignJackDummy() throws Exception { getDummyResource().resetBreakMode(); // WHEN - when(TEST_NAME); + when(); assignAccount(UserType.class, USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); LensContext context = cleanDebugListener(); @@ -820,11 +820,11 @@ public void test212AssignJackDummyLimited() throws Exception { getDummyResource().resetBreakMode(); // WHEN - when(TEST_NAME); + when(); assignAccount(UserType.class, USER_JACK_OID, RESOURCE_DUMMY_LIMITED_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); LensContext context = cleanDebugListener(); @@ -897,11 +897,11 @@ public void test214UpdatedAccountJackLimited() throws Exception { getDummyResource().setBreakMode(BreakMode.ASSERTION_ERROR); // WHEN - when(TEST_NAME); + when(); synchronizationService.notifyChange(change, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); getDummyResource().resetBreakMode(); @@ -975,11 +975,11 @@ public void test300AddedGroupPirates() throws Exception { change.setResource(getDummyResourceObject()); // WHEN - when(TEST_NAME); + when(); synchronizationService.notifyChange(change, task, result); // THEN - when(TEST_NAME); + when(); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/visualizer/TestVisualizer.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/visualizer/TestVisualizer.java index e0321310816..967ff147547 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/visualizer/TestVisualizer.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/visualizer/TestVisualizer.java @@ -75,11 +75,11 @@ public void test100UserBasic() throws Exception { u.asObjectable().setFullName(new PolyStringType("User User123")); /// WHEN - when(TEST_NAME); + when(); final Scene scene = visualizer.visualize(u, task, task.getResult()); // THEN - then(TEST_NAME); + then(); display("scene", scene); // TODO some asserts @@ -113,11 +113,11 @@ public void test110UserWithContainers() throws Exception { ut.getAssignment().add(ass3); /// WHEN - when(TEST_NAME); + when(); final Scene scene = visualizer.visualize(u, task, task.getResult()); // THEN - then(TEST_NAME); + then(); display("scene", scene); // TODO some asserts @@ -133,11 +133,11 @@ public void test200UserDeltaBasic() throws Exception { .asObjectDelta(USER_ADMINISTRATOR_OID); /// WHEN - when(TEST_NAME); + when(); final Scene scene = visualizer.visualizeDelta((ObjectDelta) delta, task, task.getResult()); // THEN - then(TEST_NAME); + then(); display("scene", scene); // TODO some asserts @@ -163,11 +163,11 @@ public void test210UserDeltaContainers() throws Exception { .asObjectDelta(USER_ADMINISTRATOR_OID); /// WHEN - when(TEST_NAME); + when(); final Scene scene = visualizer.visualizeDelta((ObjectDelta) delta, task, task.getResult()); // THEN - then(TEST_NAME); + then(); display("scene", scene); // TODO some asserts @@ -184,11 +184,11 @@ public void test212UserDeltaContainerSimple() throws Exception { .asObjectDelta(USER_ADMINISTRATOR_OID); /// WHEN - when(TEST_NAME); + when(); final List scenes = visualizer.visualizeDeltas((List) Collections.singletonList(delta), task, task.getResult()); // THEN - then(TEST_NAME); + then(); display("scenes", scenes); // TODO some asserts @@ -215,11 +215,11 @@ public void test220UserContainerReplace() throws Exception { .asObjectDelta(USER_ADMINISTRATOR_OID); /// WHEN - when(TEST_NAME); + when(); final Scene scene = visualizer.visualizeDelta((ObjectDelta) delta, task, task.getResult()); // THEN - then(TEST_NAME); + then(); display("scene", scene); // TODO some asserts @@ -242,11 +242,11 @@ public void test230UserContainerDelete() throws Exception { .asObjectDelta(USER_ADMINISTRATOR_OID); /// WHEN - when(TEST_NAME); + when(); final Scene scene = visualizer.visualizeDelta((ObjectDelta) delta, task, task.getResult()); // THEN - then(TEST_NAME); + then(); display("scene", scene); // TODO some asserts @@ -271,7 +271,7 @@ public void test300UserAssignmentPreview() throws Exception { delta.applyDefinitionIfPresent(jack.getDefinition(), false); /// WHEN - when(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(Collections.>singletonList(delta), null, task, task.getResult()); List> primaryDeltas = new ArrayList<>(); List> secondaryDeltas = new ArrayList<>(); @@ -281,7 +281,7 @@ public void test300UserAssignmentPreview() throws Exception { List secondaryScenes = modelInteractionService.visualizeDeltas(secondaryDeltas, task, task.getResult()); // THEN - then(TEST_NAME); + then(); display("primary scenes", primaryScenes); display("secondary scenes", secondaryScenes); @@ -304,13 +304,13 @@ public void test305UserAssignmentAdd() throws Exception { .asObjectDelta(USER_JACK_OID); /// WHEN - when(TEST_NAME); + when(); final Scene scene = visualizer.visualizeDelta(delta, task, task.getResult()); modelService.executeChanges(Collections.>singletonList(delta), null, task, task.getResult()); // THEN - then(TEST_NAME); + then(); display("scene", scene); display("jack with assignment", getUser(USER_JACK_OID)); @@ -327,7 +327,7 @@ public void test307UserDisablePreview() throws Exception { .asObjectDelta(USER_JACK_OID); /// WHEN - when(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(Collections.>singletonList(delta), null, task, task.getResult()); List> primaryDeltas = new ArrayList<>(); List> secondaryDeltas = new ArrayList<>(); @@ -337,7 +337,7 @@ public void test307UserDisablePreview() throws Exception { List secondaryScenes = modelInteractionService.visualizeDeltas(secondaryDeltas, task, task.getResult()); // THEN - then(TEST_NAME); + then(); display("primary scenes", primaryScenes); display("secondary scenes", secondaryScenes); @@ -376,11 +376,11 @@ public void test310UserLinkRefDelete() throws Exception { .asObjectDelta(USER_JACK_OID); /// WHEN - when(TEST_NAME); + when(); final Scene scene = visualizer.visualizeDelta(delta, task, task.getResult()); // THEN - then(TEST_NAME); + then(); display("scene", scene); // TODO some asserts @@ -396,11 +396,11 @@ public void test320UserLinkRefAdd() throws Exception { .asObjectDelta(USER_JACK_OID); /// WHEN - when(TEST_NAME); + when(); final Scene scene = visualizer.visualizeDelta(delta, task, task.getResult()); // THEN - then(TEST_NAME); + then(); display("scene", scene); // TODO some asserts @@ -416,11 +416,11 @@ public void test330UserLinkRefReplaceNoOp() throws Exception { .asObjectDelta(USER_JACK_OID); /// WHEN - when(TEST_NAME); + when(); final Scene scene = visualizer.visualizeDelta(delta, task, task.getResult()); // THEN - then(TEST_NAME); + then(); display("scene", scene); // TODO some asserts @@ -436,11 +436,11 @@ public void test340UserLinkRefReplaceOp() throws Exception { .asObjectDelta(USER_JACK_OID); /// WHEN - when(TEST_NAME); + when(); final Scene scene = visualizer.visualizeDelta(delta, task, task.getResult()); // THEN - then(TEST_NAME); + then(); display("scene", scene); // TODO some asserts diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestActivation.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestActivation.java index d3859cedadb..693be663603 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestActivation.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestActivation.java @@ -769,11 +769,11 @@ public void test118ModifyJackActivationUserAndAccount() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("executeChanges result", result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); @@ -809,11 +809,11 @@ public void test120ModifyUserJackAssignAccountDummyRed() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_RED_OID, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("executeChanges result", result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); @@ -867,11 +867,11 @@ public void test121ModifyJackUserAndAccountRed() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("executeChanges result", result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); @@ -937,11 +937,11 @@ public void test138ModifyJackEnabled() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.ENABLED); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("executeChanges result", result); @@ -1006,11 +1006,11 @@ public void test140ModifyUserJackAssignAccountDummyRed() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_RED_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); @@ -1055,11 +1055,11 @@ public void test147ModifyUserJackUnassignAccountDummyRedRaw() throws Exception { ObjectDelta userDelta = createAccountAssignmentUserDelta(USER_JACK_OID, RESOURCE_DUMMY_RED_OID, null, false); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(userDelta), ModelExecuteOptions.createRaw(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userJack = getUser(USER_JACK_OID); @@ -1102,11 +1102,11 @@ public void test149RecomputeJack() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); @@ -1154,11 +1154,11 @@ public void test150ModifyUserJackAssignYellowAccount() throws Exception { XMLGregorianCalendar start = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - then(TEST_NAME); + then(); XMLGregorianCalendar end = clock.currentTimeXMLGregorianCalendar(); assertSuccess(result); @@ -1198,11 +1198,11 @@ public void test151ReconcileJack() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1241,12 +1241,12 @@ public void test152ModifyAccountsJackDisable() throws Exception { ObjectDelta yellowDelta = createModifyAccountShadowReplaceDelta(accountYellowOid, null, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, ActivationStatusType.DISABLED); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(dummyDelta, yellowDelta), null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userJack = getUser(USER_JACK_OID); @@ -1256,13 +1256,13 @@ public void test152ModifyAccountsJackDisable() throws Exception { checkAdminStatusFor15x(userJack, true, false, false); // WHEN (2) - now let's do a reconciliation on both resources - when(TEST_NAME); + when(); ObjectDelta innocentDelta = createModifyUserReplaceDelta(USER_JACK_OID, UserType.F_LOCALITY, userJack.asObjectable().getLocality().toPolyString()); modelService.executeChanges(MiscSchemaUtil.createCollection(innocentDelta), ModelExecuteOptions.createReconcile(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); assertSuccess("executeChanges result (after reconciliation)", result); @@ -1357,11 +1357,11 @@ public void test160ModifyUserJackAssignAccountKhaki() throws Exception { XMLGregorianCalendar start = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_KHAKI_OID, null, task, result); // THEN - then(TEST_NAME); + then(); XMLGregorianCalendar end = clock.currentTimeXMLGregorianCalendar(); result.computeStatus(); TestUtil.assertSuccess("executeChanges result", result); @@ -1891,11 +1891,11 @@ public void test230JackUnassignRepoRecompute() throws Exception { assertDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, "Jack Sparrow", true); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, "Jack Sparrow", false); @@ -1913,11 +1913,11 @@ public void test231JackRecomputeReconcile() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, ModelExecuteOptions.createReconcile(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, "Jack Sparrow", false); @@ -1953,11 +1953,11 @@ public void test240AddUserRappDraft() throws Exception { display("User before", userBefore); // WHEN - when(TEST_NAME); + when(); addObject(userBefore, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1994,11 +1994,11 @@ public void test241RecomputeRappDraft() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_RAPP_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2036,11 +2036,11 @@ public void test242RappAssignCaptain() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_RAPP_OID, ROLE_CAPTAIN_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2073,12 +2073,12 @@ public void test245ActivateRapp() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_RAPP_OID, UserType.F_LIFECYCLE_STATE, task, result, SchemaConstants.LIFECYCLE_ACTIVE); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2115,12 +2115,12 @@ public void test248DeactivateRapp() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_RAPP_OID, UserType.F_LIFECYCLE_STATE, task, result, SchemaConstants.LIFECYCLE_ARCHIVED); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2151,11 +2151,11 @@ public void test249DeleteUserRapp() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); deleteObject(UserType.class, USER_RAPP_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2183,12 +2183,12 @@ public void test300AddDummyGreenAccountMancomb() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Melee Island"); /// WHEN - when(TEST_NAME); + when(); getDummyResource(RESOURCE_DUMMY_GREEN_NAME).addAccount(account); // THEN - then(TEST_NAME); + then(); PrismObject accountMancomb = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); display("Account shadow after", accountMancomb); @@ -2222,17 +2222,17 @@ public void test310ImportAccountsFromDummyGreen() throws Exception { assertNull("Unexpected user mancomb before import", userMancomb); // WHEN - when(TEST_NAME); + when(); modelService.importFromResource(RESOURCE_DUMMY_GREEN_OID, new QName(getDummyResourceController(RESOURCE_DUMMY_GREEN_NAME).getNamespace(), SchemaConstants.ACCOUNT_OBJECT_CLASS_LOCAL_NAME), task, result); // THEN - then(TEST_NAME); + then(); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); waitForTaskFinish(task, true, 40000); - then(TEST_NAME); + then(); userMancomb = findUserByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME); assertNotNull("No user mancomb after import", userMancomb); @@ -2611,11 +2611,11 @@ public void test600AddUser1() throws Exception { ObjectDelta addDelta = user1.createAddDelta(); // WHEN - when(TEST_NAME); + when(); Collection> executedChanges = executeChanges(addDelta, null, task, result); // THEN - then(TEST_NAME); + then(); user1 = getUser(ObjectDeltaOperation.findFocusDeltaOidInCollection(executedChanges)); display("User after change execution", user1); @@ -2699,11 +2699,11 @@ public void test700ModifyJackRemoveAdministrativeStatus() throws Exception { PrismAsserts.assertNoItem(userBefore, SchemaConstants.PATH_ACTIVATION_VALID_TO); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2745,11 +2745,11 @@ public void test702ModifyJackFuneralTimestampBeforeNow() throws Exception { XMLGregorianCalendar hourAgo = XmlTypeConverter.createXMLGregorianCalendar(clock.currentTimeMillis() - 60 * 60 * 1000); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, getExtensionPath(PIRACY_FUNERAL_TIMESTAMP), task, result, hourAgo); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2788,11 +2788,11 @@ public void test704ModifyJackFuneralTimestampAfterNow() throws Exception { XMLGregorianCalendar hourAhead = XmlTypeConverter.createXMLGregorianCalendar(clock.currentTimeMillis() + 60 * 60 * 1000); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, getExtensionPath(PIRACY_FUNERAL_TIMESTAMP), task, result, hourAhead); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2840,11 +2840,11 @@ public void test750AddAndDeleteUserWithPrecreate() throws Exception { assertSuccess(result); // WHEN - when(TEST_NAME); + when(); deleteObject(UserType.class, oid, task, result); // THEN - then(TEST_NAME); + then(); // There's a hidden FATAL_ERROR when unlinking deleted shadow (benign ... but it prevents us from asserting success tree-wide) //assertSuccess(result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestAudit.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestAudit.java index b1b276cf692..2c542850a86 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestAudit.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestAudit.java @@ -137,12 +137,12 @@ public void test100ModifyUserJackKid() throws Exception { initialTs = getTimeSafely(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_TITLE, task, result, createPolyString("Kid")); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -169,12 +169,12 @@ public void test105CreateUserHerman() throws Exception { hermanInitialTs = getTimeSafely(); // WHEN - when(TEST_NAME); + when(); addObject(userHermanBefore, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -201,12 +201,12 @@ public void test110ModifyUserJackSailor() throws Exception { ActivationStatusType.DISABLED); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -231,12 +231,12 @@ public void test115ModifyUserHermanMarooned() throws Exception { objectDelta.addModification(createAssignmentModification(RESOURCE_DUMMY_OID, ShadowKindType.ACCOUNT, null, true)); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject user = getUser(USER_HERMAN_OID); @@ -262,12 +262,12 @@ public void test120ModifyUserJackCaptain() throws Exception { ActivationStatusType.ENABLED); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); jackCaptainTs = getTimeSafely(); @@ -297,13 +297,13 @@ public void test125ModifyUserHermanHermit() throws Exception { null, null, null, true)); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject user = getUser(USER_HERMAN_OID); @@ -328,13 +328,13 @@ public void test135ModifyUserHermanCivilisedHermit() throws Exception { null, null, null, false)); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject user = getUser(USER_HERMAN_OID); @@ -358,13 +358,13 @@ public void test200ReconstructJackSailor() throws Exception { PrismAsserts.assertPropertyValue(userBefore, UserType.F_TITLE, createPolyString("Captain")); // WHEN - when(TEST_NAME); + when(); PrismObject jackReconstructed = modelAuditService.reconstructObject(UserType.class, USER_JACK_OID, jackSailorEid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("Reconstructed jack", jackReconstructed); @@ -388,13 +388,13 @@ public void test210ReconstructJackKid() throws Exception { PrismAsserts.assertPropertyValue(userBefore, UserType.F_TITLE, createPolyString("Captain")); // WHEN - when(TEST_NAME); + when(); PrismObject jackReconstructed = modelAuditService.reconstructObject(UserType.class, USER_JACK_OID, jackKidEid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("Reconstructed jack", jackReconstructed); @@ -423,13 +423,13 @@ public void test250ReconstructHermanCreated() throws Exception { assertAssignments(userBefore, 1); // WHEN - when(TEST_NAME); + when(); PrismObject hermanReconstructed = modelAuditService.reconstructObject(UserType.class, USER_HERMAN_OID, hermanCreatedEid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("Reconstructed herman", hermanReconstructed); @@ -454,13 +454,13 @@ public void test252ReconstructHermanMarooned() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); PrismObject hermanReconstructed = modelAuditService.reconstructObject(UserType.class, USER_HERMAN_OID, hermanMaroonedEid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("Reconstructed herman", hermanReconstructed); @@ -486,13 +486,13 @@ public void test254ReconstructHermanHermit() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); PrismObject hermanReconstructed = modelAuditService.reconstructObject(UserType.class, USER_HERMAN_OID, hermanHermitEid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("Reconstructed herman", hermanReconstructed); @@ -516,7 +516,7 @@ public void test300QueryUnknown() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); AuditEventRecord record = new AuditEventRecord(AuditEventType.SYNCHRONIZATION, AuditEventStage.EXECUTION); record.setOutcome(OperationResultStatus.UNKNOWN); @@ -527,7 +527,7 @@ public void test300QueryUnknown() throws Exception { List records = modelAuditService.listRecords("select * from m_audit_event as aer where aer.outcome = :outcome", params, task, result); // THEN - then(TEST_NAME); + then(); display("records", records); assertEquals("Wrong # of records", 1, records.size()); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestCaseIgnore.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestCaseIgnore.java index b633cd98702..630832a6d11 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestCaseIgnore.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestCaseIgnore.java @@ -118,11 +118,11 @@ public void test131ModifyUserJackAssignAccount() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); executeChanges(accountAssignmentUserDelta, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); assertCounterIncrement(InternalCounters.CONNECTOR_INSTANCE_INITIALIZATION_COUNT, 0); // MID-4779 @@ -172,7 +172,7 @@ public void test133SeachAccountShadows() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - when(TEST_NAME); + when(); SearchResultList> foundShadows = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN @@ -264,7 +264,7 @@ public void test150JackAssignRoleX() throws Exception { assignRole(USER_JACK_OID, ROLE_X_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -307,7 +307,7 @@ public void test152GetJack() throws Exception { PrismObject userJack = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -351,7 +351,7 @@ public void test159JackUnAssignRoleX() throws Exception { unassignRole(USER_JACK_OID, ROLE_X_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -379,11 +379,11 @@ public void test160JackAssignRoleBasic() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_UPCASE_BASIC_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -427,11 +427,11 @@ public void test161JackAssignRoleJoker() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_JOKER_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -479,11 +479,11 @@ public void test165JackUnAssignRoleJoker() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_JOKER_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -527,11 +527,11 @@ public void test169JackUnAssignRoleBasic() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_UPCASE_BASIC_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -561,11 +561,11 @@ public void test170JackAssignRoleJoker() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_JOKER_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); // Make sure this is repository so we do not destroy the "evidence" yet. @@ -608,11 +608,11 @@ public void test179JackUnAssignRoleJoker() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_JOKER_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); // Make sure this is repository so we do not destroy the "evidence" yet. @@ -662,11 +662,11 @@ public void test200GuybrushAssignRoleFools() throws Exception { assertShadows(4); // WHEN - when(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_FOOL_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertShadows(6); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConsistencySimple.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConsistencySimple.java index 984a5eb11f7..a328bd9bbec 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConsistencySimple.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConsistencySimple.java @@ -198,7 +198,7 @@ private void executeTest(final String TEST_NAME, FocusOperation focusOperation, result = task.getResult(); // WHEN - when(TEST_NAME); + when(); switch (focusOperation) { case RECOMPUTE: recomputeUser(USER_JACK_OID, task, result); @@ -213,7 +213,7 @@ private void executeTest(final String TEST_NAME, FocusOperation focusOperation, } // THEN - then(TEST_NAME); + then(); result.computeStatus(); display("Result", result); if (ASSERT_SUCCESS) { diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestDeputy.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestDeputy.java index 7dfec2c6dcc..08282141cc0 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestDeputy.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestDeputy.java @@ -79,12 +79,12 @@ public void test100AssignDeputyNoBigDeal() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -115,12 +115,12 @@ public void test109UnassignDeputyNoBigDeal() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -150,12 +150,12 @@ public void test110AssignJackPirate() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -187,12 +187,12 @@ public void test112AssignDeputyPirate() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -229,12 +229,12 @@ public void test119UnassignDeputyPirate() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -270,12 +270,12 @@ public void test120AssignbarbossaDeputyOfGuybrush() throws Exception { assertLinks(userGuybrushBefore, 1); // WHEN - when(TEST_NAME); + when(); assignDeputy(USER_BARBOSSA_OID, USER_GUYBRUSH_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -308,12 +308,12 @@ public void test122AssignGuybrushPirate() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_PIRATE_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -346,12 +346,12 @@ public void test124RecomputeBarbossa() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_BARBOSSA_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -386,12 +386,12 @@ public void test126UnassignGuybrushPirate() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_GUYBRUSH_OID, ROLE_PIRATE_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -424,12 +424,12 @@ public void test128RecomputeBarbossa() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_BARBOSSA_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -456,12 +456,12 @@ public void test129UnassignBarbossaDeputyOfGuybrush() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignDeputy(USER_BARBOSSA_OID, USER_GUYBRUSH_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -507,12 +507,12 @@ public void test150AssignJackMoreRoles() throws Exception { null, null, (ActivationType) null, true))); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(userDelta), null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -544,14 +544,14 @@ public void test152AssignbarbossaDeputyLimitedDeputy() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_PIRATE_OID), createOrgReference(ORG_MINISTRY_OF_RUM_OID, SchemaConstants.ORG_MANAGER)); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -580,14 +580,14 @@ public void test154UnassignbarbossaDeputyLimitedDeputy() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_PIRATE_OID), createOrgReference(ORG_MINISTRY_OF_RUM_OID, SchemaConstants.ORG_MANAGER)); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -613,7 +613,7 @@ public void test156AssignbarbossaDeputyLimitedDeputyRed() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_RED_SAILOR_OID), @@ -621,7 +621,7 @@ public void test156AssignbarbossaDeputyLimitedDeputyRed() throws Exception { ); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -653,7 +653,7 @@ public void test159UnassignbarbossaDeputyLimitedDeputyRed() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); unassignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_RED_SAILOR_OID), @@ -661,7 +661,7 @@ public void test159UnassignbarbossaDeputyLimitedDeputyRed() throws Exception { ); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -691,14 +691,14 @@ public void test160AssignbarbossaDeputyLimitedDeputyEmpty() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_EMPTY_OID) ); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -730,14 +730,14 @@ public void test162UnassignbarbossaDeputyLimitedDeputyEmpty() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); unassignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_EMPTY_OID) ); // THEN - then(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -769,11 +769,11 @@ public void test170AddRoleDrinker() throws Exception { display("Adding role", role); // WHEN - when(TEST_NAME); + when(); addObject(role, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject roleAfter = getObject(RoleType.class, ROLE_DRINKER_OID); @@ -790,11 +790,11 @@ public void test172AssignJackRoleDrinker() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_DRINKER_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userJackAfter = getUser(USER_JACK_OID); @@ -819,14 +819,14 @@ public void test174AssignBarbossaDeputyLimitedDeputyDrinker() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_DRINKER_OID) ); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userJackAfter = getUser(USER_JACK_OID); @@ -865,7 +865,7 @@ public void test176AssignbarGuybrushLimitedDeputyOfBarbossa() throws Exception { // WHEN - when(TEST_NAME); + when(); assignDeputyLimits(USER_GUYBRUSH_OID, USER_BARBOSSA_OID, assignment -> assignment.beginLimitTargetContent().allowTransitive(true), @@ -874,7 +874,7 @@ public void test176AssignbarGuybrushLimitedDeputyOfBarbossa() throws Exception { ); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userGuybrushAfter = getUser(USER_GUYBRUSH_OID); @@ -897,14 +897,14 @@ public void test178UnassignBarbossaDeputyLimitedDeputyDrinker() throws Exception XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); unassignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_DRINKER_OID) ); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -940,7 +940,7 @@ public void test179UnassignbarGuybrushLimitedDeputyOfBarbossa() throws Exception OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignDeputyLimits(USER_GUYBRUSH_OID, USER_BARBOSSA_OID, assignment -> assignment.beginLimitTargetContent().allowTransitive(true), @@ -949,7 +949,7 @@ public void test179UnassignbarGuybrushLimitedDeputyOfBarbossa() throws Exception ); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userGuybrushAfter = getUser(USER_GUYBRUSH_OID); @@ -968,12 +968,12 @@ public void test180AssignBarbossaDeputyOfJack() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userBarbossaAfter = getUser(USER_BARBOSSA_OID); @@ -1004,14 +1004,14 @@ public void test182AssignGuybrushLimitedDeputyOfBarbossa() throws Exception { // WHEN - when(TEST_NAME); + when(); assignDeputyLimits(USER_GUYBRUSH_OID, USER_BARBOSSA_OID, task, result, createRoleReference(ROLE_DRINKER_OID) ); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userGuybrushAfter = getUser(USER_GUYBRUSH_OID); @@ -1031,14 +1031,14 @@ public void test184UnassignGuybrushLimitedDeputyOfBarbossa() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignDeputyLimits(USER_GUYBRUSH_OID, USER_BARBOSSA_OID, task, result, createRoleReference(ROLE_DRINKER_OID) ); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userGuybrushAfter = getUser(USER_GUYBRUSH_OID); @@ -1067,12 +1067,12 @@ public void test186AssignGuybrushDeputyOfBarbossa() throws Exception { // WHEN - when(TEST_NAME); + when(); assignDeputy(USER_GUYBRUSH_OID, USER_BARBOSSA_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userGuybrushAfter = getUser(USER_GUYBRUSH_OID); @@ -1092,12 +1092,12 @@ public void test188UnassignGuybrushDeputyOfBarbossa() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignDeputy(USER_GUYBRUSH_OID, USER_BARBOSSA_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userGuybrushAfter = getUser(USER_GUYBRUSH_OID); @@ -1115,12 +1115,12 @@ public void test189UnassignBarbossaDeputyOfJack() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userBarbossaAfter = getUser(USER_BARBOSSA_OID); @@ -1138,7 +1138,7 @@ public void test190AssignBarbossaDeputyLimitedDeputyEmptyDrinker() throws Except OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_EMPTY_OID), @@ -1146,7 +1146,7 @@ public void test190AssignBarbossaDeputyLimitedDeputyEmptyDrinker() throws Except ); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1178,7 +1178,7 @@ public void test192UnassignbarbossaDeputyLimitedDeputyEmptyDrinker() throws Exce XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); unassignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_EMPTY_OID), @@ -1186,7 +1186,7 @@ public void test192UnassignbarbossaDeputyLimitedDeputyEmptyDrinker() throws Exce ); // THEN - then(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -1220,14 +1220,14 @@ public void test800ImportValidityScannerTask() throws Exception { XMLGregorianCalendar startCal = clock.currentTimeXMLGregorianCalendar(); /// WHEN - when(TEST_NAME); + when(); importObjectFromFile(TASK_VALIDITY_SCANNER_FILENAME); waitForTaskStart(TASK_VALIDITY_SCANNER_OID, false); waitForTaskFinish(TASK_VALIDITY_SCANNER_OID, true); // THEN - then(TEST_NAME); + then(); XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); assertLastScanTimestamp(TASK_VALIDITY_SCANNER_OID, startCal, endCal); } @@ -1255,13 +1255,13 @@ public void test802AssignBarbossaDeputyOfJack() throws Exception { activationType.setValidTo(XmlTypeConverter.addDuration(startTs, "PT2H")); // WHEN - when(TEST_NAME); + when(); assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, assignment -> assignment.setActivation(activationType), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -1301,12 +1301,12 @@ public void test804BarbosaThreeHoursLater() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); waitForTaskNextRunAssertSuccess(TASK_VALIDITY_SCANNER_OID, true); // THEN - then(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestEntitlements.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestEntitlements.java index c2246560801..e55a004f50a 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestEntitlements.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestEntitlements.java @@ -204,11 +204,11 @@ public void test110AssociateGuybrushToSwashbucklers() throws Exception { SHADOW_GROUP_DUMMY_SWASHBUCKLERS_OID, prismContext); // WHEN - when(TEST_NAME); + when(); executeChanges(delta, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertDummyGroupByName(null, GROUP_DUMMY_SWASHBUCKLERS_NAME) @@ -224,11 +224,11 @@ public void test200AssignRoleSwashbucklerToJack() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -254,11 +254,11 @@ public void test209UnAssignRoleSwashbucklerFromJack() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -321,11 +321,11 @@ public void test222AssignRoleMapmakerToWally() throws Exception { PrismObject user = findUserByUsername(USER_WALLY_NAME); // WHEN - when(TEST_NAME); + when(); assignRole(user.getOid(), ROLE_MAPMAKER_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertGroupMember(GROUP_DUMMY_LANDLUBERS_NAME, USER_WALLY_NAME, getDummyResource()); @@ -360,11 +360,11 @@ public void test224UnassignRoleMapmakerFromWally() throws Exception { PrismObject user = findUserByUsername(USER_WALLY_NAME); // WHEN - when(TEST_NAME); + when(); unassignRole(user.getOid(), ROLE_MAPMAKER_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); DummyGroup dummyGroup = getDummyResource().getGroupByName(GROUP_DUMMY_MAPMAKERS_NAME); @@ -382,11 +382,11 @@ public void test300AddRoleWimp() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); addObject(ROLE_WIMP_FILE, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); DummyGroup dummyGroup = getDummyResource().getGroupByName(GROUP_DUMMY_WIMPS_NAME); @@ -414,11 +414,11 @@ public void test302AddRoleBrute() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); addObject(ROLE_BRUTE_FILE, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -441,11 +441,11 @@ public void test304AddRoleThug() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); addObject(ROLE_THUG_FILE, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -470,11 +470,11 @@ public void test310AssignRoleWimpToLargo() throws Exception { addObject(USER_LARGO_FILE); // WHEN - when(TEST_NAME); + when(); assignRole(USER_LARGO_OID, ROLE_WIMP_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -494,11 +494,11 @@ public void test312AssignRoleBruteToLargo() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_LARGO_OID, ROLE_BRUTE_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -518,11 +518,11 @@ public void test313UnAssignRoleBruteFromLargo() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_LARGO_OID, ROLE_BRUTE_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -552,11 +552,11 @@ public void test314AssignRoleThugToLargo() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_LARGO_OID, ROLE_THUG_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -576,11 +576,11 @@ public void test315UnAssignRoleThugFromLargo() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_LARGO_OID, ROLE_THUG_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -613,11 +613,11 @@ public void test317RenameLargo() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_LARGO_OID, UserType.F_NAME, task, result, PrismTestUtil.createPolyString("newLargo")); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -644,11 +644,11 @@ public void test319UnassignRoleWimpFromLargo() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_LARGO_OID, ROLE_WIMP_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -682,11 +682,11 @@ public void test320AssignRoleBruteToRapp() throws Exception { addObject(USER_RAPP_FILE); // WHEN - when(TEST_NAME); + when(); assignRole(USER_RAPP_OID, ROLE_BRUTE_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -706,11 +706,11 @@ public void test322AssignRoleWimpToRapp() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_RAPP_OID, ROLE_WIMP_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -737,11 +737,11 @@ public void test324AssignRoleThugToRapp() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_RAPP_OID, ROLE_THUG_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -775,11 +775,11 @@ public void test327UnassignRoleWimpFromRapp() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_RAPP_OID, ROLE_WIMP_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -816,11 +816,11 @@ public void test328UnassignRoleThugFromRapp() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_RAPP_OID, ROLE_THUG_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -860,11 +860,11 @@ public void test329UnAssignRoleBruteFromRapp() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_RAPP_OID, ROLE_BRUTE_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -898,12 +898,12 @@ public void test350AssignOrangeAccountToGuybrushAndRapp() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_ORANGE_OID, null, task, result); assignAccountToUser(USER_RAPP_OID, RESOURCE_DUMMY_ORANGE_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); DummyAccount accountGuybrush = assertDummyAccount(RESOURCE_DUMMY_ORANGE_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); @@ -930,11 +930,11 @@ public void test351AssignRoleCrewOfGuybrushToRapp() throws Exception { assertDummyAccount(RESOURCE_DUMMY_ORANGE_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); // WHEN - when(TEST_NAME); + when(); assignRole(USER_RAPP_OID, ROLE_CREW_OF_GUYBRUSH_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userGuybrushAfter = getUser(USER_GUYBRUSH_OID); @@ -974,11 +974,11 @@ public void test358UnassignRoleCrewOfGuybrushToRapp() throws Exception { assertDummyAccount(RESOURCE_DUMMY_ORANGE_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_RAPP_OID, ROLE_CREW_OF_GUYBRUSH_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userGuybrushAfter = getUser(USER_GUYBRUSH_OID); @@ -1006,12 +1006,12 @@ public void test359UnassignOrangeAccountFromGuybrushAndRapp() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignAccountFromUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_ORANGE_OID, null, task, result); unassignAccountFromUser(USER_RAPP_OID, RESOURCE_DUMMY_ORANGE_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertNoDummyAccount(RESOURCE_DUMMY_ORANGE_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); @@ -1028,11 +1028,11 @@ public void test600AssignRolePirateToJack() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject user = getUser(USER_JACK_OID); @@ -1062,11 +1062,11 @@ public void test610AssignRoleSwashbucklerToJack() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject user = getUser(USER_JACK_OID); @@ -1095,11 +1095,11 @@ public void test620UnAssignSwashbucklerFromJack() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject user = getUser(USER_JACK_OID); @@ -1142,11 +1142,11 @@ public void test630AssignRoleSwashbucklerToJackValidity() throws Exception { jackSwashbucklerAssignmentActivation.setValidTo(validTo); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, jackSwashbucklerAssignmentActivation, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1276,11 +1276,11 @@ public void test659UnassignRoleSwashbucklerFromJack() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, jackSwashbucklerAssignmentActivation.clone(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1315,11 +1315,11 @@ public void test699UnassignRolePirateFromJack() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1351,11 +1351,11 @@ public void test700ReconcileGuybrush() throws Exception { assertGroupMember(getDummyGroup(null, GROUP_DUMMY_SWASHBUCKLERS_NAME), USER_GUYBRUSH_USERNAME); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - then(TEST_NAME); + then(); dumpUserAndAccounts(getUser(USER_GUYBRUSH_OID), task, result); assertNoGroupMember(getDummyGroup(null, GROUP_DUMMY_SWASHBUCKLERS_NAME), USER_GUYBRUSH_USERNAME); @@ -1419,11 +1419,11 @@ public void test715AssociateGuybrushToThugs() throws Exception { ObjectDelta delta = ObjectDeltaCollectionsUtil.summarize(delta1, delta2); // WHEN - when(TEST_NAME); + when(); executeChanges(delta, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertGroupMember(GROUP_THUG_NAME, ACCOUNT_GUYBRUSH_DUMMY_ORANGE_USERNAME, getDummyResource(RESOURCE_DUMMY_ORANGE_NAME)); @@ -1446,11 +1446,11 @@ public void test720ReconcileGuybrush() throws Exception { assertGroupMember(getDummyGroup(null, GROUP_DUMMY_LANDLUBERS_NAME), USER_GUYBRUSH_USERNAME); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); dumpUserAndAccounts(getUser(USER_GUYBRUSH_OID), task, result); assertGroupMember(GROUP_DUMMY_LANDLUBERS_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, getDummyResource()); @@ -1470,11 +1470,11 @@ public void test729CleanupGuybrush() throws Exception { PrismObject userBefore = dumpUserAndAccounts(USER_GUYBRUSH_OID); // WHEN - when(TEST_NAME); + when(); unassignAll(userBefore, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = dumpUserAndAccounts(USER_GUYBRUSH_OID); assertAssignments(userAfter, 0); @@ -1508,11 +1508,11 @@ public void test750PrepareGuybrushFuturePerfect() throws Exception { assertLinks(userBefore, 0); // WHEN - when(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_ORG_GROUPING_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = dumpUserAndAccounts(USER_GUYBRUSH_OID); assertAssignments(userAfter, 1); @@ -1541,11 +1541,11 @@ public void test752GuybrushFuturePerfect() throws Exception { getDummyResourceController().addGroup(orgGroupName(OU_CLUB_SCI_FI)); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = dumpUserAndAccounts(USER_GUYBRUSH_OID); assertAssignments(userAfter, 1); @@ -1566,11 +1566,11 @@ public void test759CleanupGuybrush() throws Exception { dumpUserAndAccounts(USER_GUYBRUSH_OID); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_GUYBRUSH_OID, ROLE_ORG_GROUPING_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = dumpUserAndAccounts(USER_GUYBRUSH_OID); assertAssignments(userAfter, 0); @@ -1594,11 +1594,11 @@ public void test760GuybrushOrgGroupsRepo() throws Exception { assertLinks(userBefore, 0); // WHEN - when(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_ORG_GROUPING_REPO_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = dumpUserAndAccounts(USER_GUYBRUSH_OID); assertAssignments(userAfter, 1); @@ -1618,11 +1618,11 @@ public void test765ReconcileGuybrush() throws Exception { dummyAuditService.clear(); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = dumpUserAndAccounts(USER_GUYBRUSH_OID); assertAssignments(userAfter, 1); @@ -1650,11 +1650,11 @@ public void test769CleanupGuybrush() throws Exception { dumpUserAndAccounts(USER_GUYBRUSH_OID); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_GUYBRUSH_OID, ROLE_ORG_GROUPING_REPO_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = dumpUserAndAccounts(USER_GUYBRUSH_OID); assertAssignments(userAfter, 0); @@ -1674,11 +1674,11 @@ public void test780AssignGuybrushSwashbuckler() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - then(TEST_NAME); + then(); dumpUserAndAccounts(getUser(USER_GUYBRUSH_OID), task, result); assertGroupMember(getDummyGroup(null, GROUP_DUMMY_SWASHBUCKLERS_NAME), USER_GUYBRUSH_USERNAME); @@ -1702,11 +1702,11 @@ public void test781GuybrushTheLostSwashbuckler() throws Exception { assertNoGroupMember(getDummyGroup(null, GROUP_DUMMY_SWASHBUCKLERS_NAME), USER_GUYBRUSH_USERNAME); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - then(TEST_NAME); + then(); dumpUserAndAccounts(getUser(USER_GUYBRUSH_OID), task, result); assertGroupMember(getDummyGroup(null, GROUP_DUMMY_SWASHBUCKLERS_NAME), USER_GUYBRUSH_USERNAME); @@ -1721,11 +1721,11 @@ public void test784UnassignGuybrushSwashbuckler() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_GUYBRUSH_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - then(TEST_NAME); + then(); dumpUserAndAccounts(getUser(USER_GUYBRUSH_OID), task, result); assertNoGroupMember(getDummyGroup(null, GROUP_DUMMY_SWASHBUCKLERS_NAME), USER_GUYBRUSH_USERNAME); @@ -1743,11 +1743,11 @@ public void test785AssignGuybrushBlueSwashbuckler() throws Exception { addObject(group, task, result); // WHEN - when(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_SWASHBUCKLER_BLUE_OID, task, result); // THEN - then(TEST_NAME); + then(); dumpUserAndAccounts(getUser(USER_GUYBRUSH_OID), task, result); assertGroupMember(getDummyGroup(RESOURCE_DUMMY_BLUE_NAME, GROUP_DUMMY_SWASHBUCKLERS_NAME), USER_GUYBRUSH_USERNAME); @@ -1771,11 +1771,11 @@ public void test786GuybrushTheLostBlueSwashbuckler() throws Exception { assertNoGroupMember(getDummyGroup(RESOURCE_DUMMY_BLUE_NAME, GROUP_DUMMY_SWASHBUCKLERS_NAME), USER_GUYBRUSH_USERNAME); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - then(TEST_NAME); + then(); dumpUserAndAccounts(getUser(USER_GUYBRUSH_OID), task, result); assertGroupMember(getDummyGroup(RESOURCE_DUMMY_BLUE_NAME, GROUP_DUMMY_SWASHBUCKLERS_NAME), USER_GUYBRUSH_USERNAME); @@ -1790,11 +1790,11 @@ public void test789UnassignGuybrushBlueSwashbuckler() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_GUYBRUSH_OID, ROLE_SWASHBUCKLER_BLUE_OID, task, result); // THEN - then(TEST_NAME); + then(); dumpUserAndAccounts(getUser(USER_GUYBRUSH_OID), task, result); assertNoGroupMember(getDummyGroup(RESOURCE_DUMMY_BLUE_NAME, GROUP_DUMMY_SWASHBUCKLERS_NAME), USER_GUYBRUSH_USERNAME); @@ -1817,11 +1817,11 @@ public void test800AssignRoleSwashbucklerToJackNone() throws Exception { assertJackClean(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1847,11 +1847,11 @@ public void test805ReconcileJackNone() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1875,11 +1875,11 @@ public void test809UnAssignRoleSwashbucklerFromJackNone() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1905,11 +1905,11 @@ public void test810AssignRoleSwashbucklerToJackPositive() throws Exception { assertJackClean(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1933,11 +1933,11 @@ public void test815ReconcileJackPositive() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1961,11 +1961,11 @@ public void test817UnAssignRoleSwashbucklerFromJackPositive() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1988,11 +1988,11 @@ public void test819ReconcileJackPositive() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2023,11 +2023,11 @@ public void test820RecomputeJackFull() throws Exception { assertDefaultDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2053,11 +2053,11 @@ public void test822AssignRoleSwashbucklerToJackFull() throws Exception { assertJackClean(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2081,11 +2081,11 @@ public void test825ReconcileJackFull() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2109,11 +2109,11 @@ public void test827UnAssignRoleSwashbucklerFromJackFull() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2136,11 +2136,11 @@ public void test829ReconcileJackFull() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2167,11 +2167,11 @@ public void test830AssignJackAccountDummy() throws Exception { assertJackClean(); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2197,11 +2197,11 @@ public void test840AssignRoleSwashbucklerToJackNone() throws Exception { assertJackJustAccount(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2225,11 +2225,11 @@ public void test849UnassignRoleSwashbucklerFromJackNone() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2255,11 +2255,11 @@ public void test850AssignRoleSwashbucklerToJackPositive() throws Exception { assertJackJustAccount(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2283,11 +2283,11 @@ public void test859UnassignRoleSwashbucklerToJackPositive() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2312,11 +2312,11 @@ public void test860RecomputeJackFull() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2342,11 +2342,11 @@ public void test862AssignRoleSwashbucklerToJackFull() throws Exception { assertJackJustAccount(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2370,11 +2370,11 @@ public void test869UnassignRoleSwashbucklerToJackFull() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2397,11 +2397,11 @@ public void test899UnAssignAccountJackDummy() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); // WHEN - when(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestInbounds.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestInbounds.java index dbb61ea263b..0ac1594591b 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestInbounds.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestInbounds.java @@ -62,11 +62,11 @@ public void test000Sanity() throws Exception { Task task = getTestTask(); // WHEN - when(TEST_NAME); + when(); OperationResult testResult = modelService.testResource(RESOURCE_DUMMY_ORANGE_OID, task); // THEN - then(TEST_NAME); + then(); TestUtil.assertSuccess("Test orange resource", testResult); DummyResource dummyResourceOrange = getDummyResource(RESOURCE_DUMMY_ORANGE_NAME); @@ -89,11 +89,11 @@ public void test101ModifyUserSubtypePirate() throws Exception { .createXMLGregorianCalendar(System.currentTimeMillis())); // WHEN - when(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); jackEmployeeNumber = assertUserAfter(USER_JACK_OID) @@ -128,11 +128,11 @@ public void test102ModifyUserSubtypeBuccaneer() throws Exception { USER_JACK_OID, UserType.F_SUBTYPE, "BUCCANEER"); // WHEN - when(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -202,11 +202,11 @@ public void test200AssignAccountOrange() throws Exception { display("User before", userBefore); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_ORANGE_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -765,11 +765,11 @@ public void test264ModifyAccountOrangeQuoteWoodchuckRecon() throws Exception { display("Account orange before", dummyAccountBefore); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -811,11 +811,11 @@ public void test297ModifyAccountOrangeGossipRecon() throws Exception { display("Account orange before", dummyAccountBefore); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_GUYBRUSH_OID, ROLE_THIEF_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -849,11 +849,11 @@ public void test299UnassignAccountOrange() throws Exception { assertAssignments(userBefore, 1); // WHEN - when(TEST_NAME); + when(); unassignAccountFromUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_ORANGE_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIntent.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIntent.java index 2d8521ef034..e6dc0fc48a9 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIntent.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIntent.java @@ -69,11 +69,11 @@ public void test131ModifyUserJackAssignAccountDefault() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); @@ -128,11 +128,11 @@ public void test132ModifyUserJackAssignAccountTest() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1); @@ -193,11 +193,11 @@ public void test135ModifyUserJackFullName() throws Exception { preTestCleanup(AssignmentPolicyEnforcementType.RELATIVE); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, PrismTestUtil.createPolyString("cpt. Jack Sparrow")); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 2); @@ -261,11 +261,11 @@ public void test147ModifyUserJackUnAssignAccountDefault() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIteration.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIteration.java index ce2f1ccd008..06195eb4c2a 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIteration.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIteration.java @@ -244,11 +244,11 @@ public void test100JackAssignAccountDummyConflicting() throws Exception { ObjectDelta accountAssignmentUserDelta = createAccountAssignmentUserDelta(USER_JACK_OID, RESOURCE_DUMMY_OID, null, true); // WHEN - when(TEST_NAME); + when(); executeChanges(accountAssignmentUserDelta, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userJack = getUser(USER_JACK_OID); @@ -313,11 +313,11 @@ public void test200JackAssignAccountDummyPinkConflicting() throws Exception { .createModifyDelta(USER_JACK_OID, modifications, UserType.class); // WHEN - when(TEST_NAME); + when(); executeChanges(accountAssignmentUserDelta, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userJack = getUser(USER_JACK_OID); @@ -373,11 +373,11 @@ public void test210GuybrushAssignAccountDummyPink() throws Exception { ObjectDelta accountAssignmentUserDelta = createAccountAssignmentUserDelta(USER_GUYBRUSH_OID, RESOURCE_DUMMY_PINK_OID, null, true); // WHEN - when(TEST_NAME); + when(); executeChanges(accountAssignmentUserDelta, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userGuybrush = getUser(USER_GUYBRUSH_OID); @@ -439,11 +439,11 @@ public void test220DeWattAssignAccountDummyPinkCaseIgnore() throws Exception { dummyAuditService.clear(); // WHEN - when(TEST_NAME); + when(); executeChanges(accountAssignmentUserDelta, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -501,11 +501,11 @@ public void test230ScroogeAddAccountDummyConflictingNoShadow() throws Exception userScrooge.asObjectable().getLinkRef().add(linkRef); // WHEN - when(TEST_NAME); + when(); executeChanges(DeltaFactory.Object.createAddDelta(userScrooge), null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result, 2); PrismObject userScroogeAfter = findUserByUsername("scrooge"); @@ -549,14 +549,14 @@ public void test235HackerAddAccountDummyEternalConflict() throws Exception { deltas.add(DeltaFactory.Object.createAddDelta(userJoeHacker)); // WHEN - when(TEST_NAME); + when(); // wrong behavior is throwing "java.lang.IllegalStateException: Model operation took too many clicks (limit is 30). Is there a cycle?" // good behavior is reporting ObjectAlreadyExistsException here modelService.executeChanges(deltas, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); display("Result", result); TestUtil.assertPartialError(result); @@ -594,11 +594,11 @@ public void test240LargoAssignAccountDummyConflictingNoShadow() throws Exception ObjectDelta accountAssignmentUserDelta = createAccountAssignmentUserDelta(USER_LARGO_OID, RESOURCE_DUMMY_PINK_OID, null, true); // WHEN - when(TEST_NAME); + when(); executeChanges(accountAssignmentUserDelta, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result, 2); PrismObject userLargo = getUser(USER_LARGO_OID); @@ -661,11 +661,11 @@ public void test260JupiterConflictNoShadowSyncBack() throws Exception { PrismObject userJupiter = PrismTestUtil.parseObject(USER_JUPITER_FILE); // WHEN - when(TEST_NAME); + when(); executeChanges(DeltaFactory.Object.createAddDelta(userJupiter), null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result, 2); PrismObject userJupiterAfter = findUserByUsername(USER_JUPITER_NAME); // jupiter @@ -714,11 +714,11 @@ protected void cleanUpJupiter(String TEST_NAME) throws SchemaException, ObjectAl ObjectDelta delta = createAccountAssignmentUserDelta(jupiterUserOid, RESOURCE_DUMMY_FUCHSIA_OID, "default", false); // WHEN - when(TEST_NAME); + when(); executeChanges(delta, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userJupiterAfter = findUserByUsername(USER_JUPITER_NAME); // jupiter @@ -760,11 +760,11 @@ public void test264JupiterConflictNoShadowSyncBackSeparate() throws Exception { ObjectDelta delta = createAccountAssignmentUserDelta(jupiterUserOid, RESOURCE_DUMMY_FUCHSIA_OID, "default", true); // WHEN - when(TEST_NAME); + when(); executeChanges(delta, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result, 2); PrismObject userJupiterAfter = findUserByUsername(USER_JUPITER_NAME); // jupiter @@ -825,11 +825,11 @@ public void test270JupiterConflictOtherNoShadowSyncBack() throws Exception { ObjectDelta delta = createAccountAssignmentUserDelta(jupiterUserOid, RESOURCE_DUMMY_FUCHSIA_OID, "default", true); // WHEN - when(TEST_NAME); + when(); executeChanges(delta, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result, 2); PrismObject userJupiterAfter = findUserByUsername(USER_JUPITER_NAME); // jupiter @@ -920,11 +920,11 @@ public void test280RenameBobNoShadow() throws Exception { deltas.add(objectDelta); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - then(TEST_NAME); + then(); PrismObject userBobAfter = getUser(userBobOid); display("User after change execution", userBobAfter); assertUser(userBobAfter, userBobOid, "bobby", "Bobby Andrews", null, null, null); @@ -980,11 +980,11 @@ public void test282RenamePeterNoShadowSync() throws Exception { deltas.add(objectDelta); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - then(TEST_NAME); + then(); PrismObject userPeteAfter = getUser(userPeterOid); display("User after change execution", userPeteAfter); assertUser(userPeteAfter, userPeterOid, "pete", "Pete Crenshaw", null, null, null); @@ -1048,11 +1048,11 @@ public void test290AlfredConflictNoShadowSyncBackAdd() throws Exception { ObjectDelta delta = DeltaFactory.Object.createAddDelta(userAlfred); // WHEN - when(TEST_NAME); + when(); executeChanges(delta, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result, 2); PrismObject userAlfredAfter = findUserByUsername(USER_ALFRED_NAME); // alfred @@ -1097,11 +1097,11 @@ public void test300JackAssignAccountDummyVioletConflicting() throws Exception { deltas.add(accountAssignmentUserDelta); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1155,11 +1155,11 @@ public void test350GuybrushAssignAccountDummyViolet() throws Exception { deltas.add(accountAssignmentUserDelta); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1214,11 +1214,11 @@ public void test360HermanAssignAccountDummyViolet() throws Exception { deltas.add(accountAssignmentUserDelta); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1303,11 +1303,11 @@ public void test500JackAssignAccountDummyMagenta() throws Exception { deltas.add(accountAssignmentUserDelta); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1383,11 +1383,11 @@ public void test510DrakeAssignAccountDummyMagenta() throws Exception { deltas.add(accountAssignmentUserDelta); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1446,11 +1446,11 @@ public void test520DrakeModifyLocality() throws Exception { dummyAuditService.clear(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_DRAKE_OID, UserType.F_LOCALITY, task, result, PrismTestUtil.createPolyString("London")); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1514,11 +1514,11 @@ public void test530GuybrushAssignAccountDummyMagenta() throws Exception { deltas.add(accountAssignmentUserDelta); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1576,11 +1576,11 @@ public void test532GuybrushModifyDescription() throws Exception { dummyAuditService.clear(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_DESCRIPTION, task, result, DESCRIPTION_RUM); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1639,12 +1639,12 @@ public void test600JackRename() throws Exception { dummyAuditService.clear(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_NAME, task, result, PrismTestUtil.createPolyString(USER_JACK_RENAMED_NAME)); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1716,7 +1716,7 @@ public void test710DarkVioletAddLeChuck() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, LECHUCK_FULLNAME); // WHEN - when(TEST_NAME); + when(); display("Adding dummy account", account.debugDump()); getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).addAccount(account); @@ -1724,7 +1724,7 @@ public void test710DarkVioletAddLeChuck() throws Exception { waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - then(TEST_NAME); + then(); assertUserNick(ACCOUNT_LECHUCK_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME); } @@ -1743,7 +1743,7 @@ public void test712DarkVioletAddCharles() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, LECHUCK_FULLNAME); // WHEN - when(TEST_NAME); + when(); display("Adding dummy account", account.debugDump()); getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).addAccount(account); @@ -1751,7 +1751,7 @@ public void test712DarkVioletAddCharles() throws Exception { waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - then(TEST_NAME); + then(); assertUserNick(ACCOUNT_LECHUCK_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME); assertUserNick(ACCOUNT_CHARLES_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME+".1"); } @@ -1772,7 +1772,7 @@ public void test714DarkVioletAddShinetop() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Melee Island"); // WHEN - when(TEST_NAME); + when(); display("Adding dummy account", account.debugDump()); getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).addAccount(account); @@ -1780,7 +1780,7 @@ public void test714DarkVioletAddShinetop() throws Exception { waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - then(TEST_NAME); + then(); assertUserNick(ACCOUNT_LECHUCK_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME); assertUserNick(ACCOUNT_CHARLES_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME+".1"); assertUserNick(ACCOUNT_SHINETOP_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME+".2", "Melee Island"); @@ -1794,14 +1794,14 @@ public void test716DarkVioletDeleteCharles() throws Exception { dummyAuditService.clear(); // WHEN - when(TEST_NAME); + when(); getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).deleteAccountByName(ACCOUNT_CHARLES_USERNAME); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - then(TEST_NAME); + then(); assertUserNick(ACCOUNT_LECHUCK_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME); assertNoUserNick(ACCOUNT_CHARLES_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME+".1"); assertUserNick(ACCOUNT_SHINETOP_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME+".2", "Melee Island"); @@ -1817,14 +1817,14 @@ public void test720DarkVioletModifyShinetopLocation() throws Exception { DummyAccount account = getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).getAccountByUsername(ACCOUNT_SHINETOP_USERNAME); // WHEN - when(TEST_NAME); + when(); account.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Monkey Island"); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - then(TEST_NAME); + then(); displayAllUsers(); assertUserNick(ACCOUNT_LECHUCK_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME); assertNoUserNick(ACCOUNT_CHARLES_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME+".1"); @@ -1841,14 +1841,14 @@ public void test722DarkVioletModifyShinetopFullName() throws Exception { DummyAccount account = getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).getAccountByUsername(ACCOUNT_SHINETOP_USERNAME); // WHEN - when(TEST_NAME); + when(); account.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, CHUCKIE_FULLNAME); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - then(TEST_NAME); + then(); displayAllUsers(); assertUserNick(ACCOUNT_LECHUCK_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME); assertNoUserNick(ACCOUNT_CHARLES_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME+".1"); @@ -1876,7 +1876,7 @@ public void test724DarkVioletAddLe_Chuck() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Melee Island"); // WHEN - when(TEST_NAME); + when(); display("Adding dummy account", account.debugDump()); getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).addAccount(account); @@ -1884,7 +1884,7 @@ public void test724DarkVioletAddLe_Chuck() throws Exception { waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - then(TEST_NAME); + then(); displayAllUsers(); assertUserNick(ACCOUNT_LECHUCK_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME); assertUserNick(ACCOUNT_LE_CHUCK_USERNAME, LE_CHUCK_FULLNAME, LE_CHUCK_FULLNAME+".1", "Melee Island"); @@ -1910,7 +1910,7 @@ public void test730DarkVioletAddBarbossa() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, USER_BARBOSSA_USERNAME); // WHEN - when(TEST_NAME); + when(); display("Adding dummy account", account.debugDump()); getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).addAccount(account); @@ -1918,7 +1918,7 @@ public void test730DarkVioletAddBarbossa() throws Exception { waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - then(TEST_NAME); + then(); assertUserNick(USER_BARBOSSA_USERNAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_USERNAME+".1"); } @@ -1942,7 +1942,7 @@ public void test732DarkVioletAddBarbossa() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, USER_BARBOSSA_USERNAME); // WHEN - when(TEST_NAME); + when(); display("Adding dummy account", account.debugDump()); getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).addAccount(account); @@ -1950,7 +1950,7 @@ public void test732DarkVioletAddBarbossa() throws Exception { waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - then(TEST_NAME); + then(); assertUserNick(USER_BARBOSSA_USERNAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_USERNAME+".1"); assertUserNick("YA" + USER_BARBOSSA_USERNAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_USERNAME+".4"); } @@ -1973,7 +1973,7 @@ public void test750DarkVioletAddMatusalem() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, RUM_FULLNAME); // WHEN - when(TEST_NAME); + when(); display("Adding dummy account", account.debugDump()); getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).addAccount(account); @@ -1981,7 +1981,7 @@ public void test750DarkVioletAddMatusalem() throws Exception { waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - then(TEST_NAME); + then(); assertUserNick(ACCOUNT_MATUSALEM_USERNAME, RUM_FULLNAME, RUM_FULLNAME); } @@ -2002,7 +2002,7 @@ public void test752DarkVioletAddDiplomatico() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, RUM_FULLNAME); // WHEN - when(TEST_NAME); + when(); display("Adding dummy account", account.debugDump()); getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).addAccount(account); @@ -2010,7 +2010,7 @@ public void test752DarkVioletAddDiplomatico() throws Exception { waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - then(TEST_NAME); + then(); displayAllUsers(); assertUserNick(ACCOUNT_MATUSALEM_USERNAME, RUM_FULLNAME, RUM_FULLNAME); @@ -2037,7 +2037,7 @@ public void test754DarkVioletAddMilionario() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Peru"); // WHEN - when(TEST_NAME); + when(); display("Adding dummy account", account.debugDump()); getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).addAccount(account); @@ -2045,7 +2045,7 @@ public void test754DarkVioletAddMilionario() throws Exception { waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - then(TEST_NAME); + then(); assertUserNick(ACCOUNT_MATUSALEM_USERNAME, RUM_FULLNAME, RUM_FULLNAME); assertUserNick(ACCOUNT_DIPLOMATICO_USERNAME, RUM_FULLNAME, RUM_FULLNAME+iterationTokenDiplomatico); @@ -2063,14 +2063,14 @@ public void test756DarkVioletDeleteDiplomatico() throws Exception { dummyAuditService.clear(); // WHEN - when(TEST_NAME); + when(); getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).deleteAccountByName(ACCOUNT_DIPLOMATICO_USERNAME); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - then(TEST_NAME); + then(); assertUserNick(ACCOUNT_MATUSALEM_USERNAME, RUM_FULLNAME, RUM_FULLNAME); assertNoUserNick(ACCOUNT_DIPLOMATICO_USERNAME, RUM_FULLNAME, RUM_FULLNAME+iterationTokenDiplomatico); assertUserNick(ACCOUNT_MILLONARIO_USERNAME, RUM_FULLNAME, RUM_FULLNAME+iterationTokenMillonario, "Peru"); @@ -2088,14 +2088,14 @@ public void test760DarkVioletModifyMillonarioLocation() throws Exception { DummyAccount account = getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).getAccountByUsername(ACCOUNT_MILLONARIO_USERNAME); // WHEN - when(TEST_NAME); + when(); account.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Northern Peru"); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - then(TEST_NAME); + then(); displayAllUsers(); assertUserNick(ACCOUNT_MATUSALEM_USERNAME, RUM_FULLNAME, RUM_FULLNAME); assertNoUserNick(ACCOUNT_DIPLOMATICO_USERNAME, RUM_FULLNAME, RUM_FULLNAME+iterationTokenDiplomatico); @@ -2117,14 +2117,14 @@ public void test762DarkVioletModifyMillonarioFullName() throws Exception { DummyAccount account = getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).getAccountByUsername(ACCOUNT_MILLONARIO_USERNAME); // WHEN - when(TEST_NAME); + when(); account.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, RON_FULLNAME); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - then(TEST_NAME); + then(); displayAllUsers(); assertUserNick(ACCOUNT_MATUSALEM_USERNAME, RUM_FULLNAME, RUM_FULLNAME); assertNoUserNick(ACCOUNT_DIPLOMATICO_USERNAME, RUM_FULLNAME, RUM_FULLNAME+iterationTokenDiplomatico); @@ -2147,14 +2147,14 @@ public void test764DarkVioletModifyMatusalemFullName() throws Exception { DummyAccount account = getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).getAccountByUsername(ACCOUNT_MATUSALEM_USERNAME); // WHEN - when(TEST_NAME); + when(); account.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, RON_FULLNAME); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - then(TEST_NAME); + then(); displayAllUsers(); assertNoUserNick(ACCOUNT_MATUSALEM_USERNAME, RUM_FULLNAME, RUM_FULLNAME); String iterationTokenMatusalem = lookupIterationTokenByAdditionalName(ACCOUNT_MATUSALEM_USERNAME); @@ -2183,11 +2183,11 @@ public void test800UniqeEmailAddUserAlfredoFettucini() throws Exception { USER_FETTUCINI_NICKNAME, true); // WHEN - when(TEST_NAME); + when(); addObject(user, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2220,11 +2220,11 @@ public void test802UniqeEmailAddUserBillFettucini() throws Exception { USER_BILL_FETTUCINI_FAMILY_NAME, USER_FETTUCINI_NICKNAME, true); // WHEN - when(TEST_NAME); + when(); addObject(user, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(user.getOid()); @@ -2267,12 +2267,12 @@ public void test820SubtypeSetByInbound() throws Exception { assertEquals("Wrong # of shadows", 2, shadows.size()); // WHEN - when(TEST_NAME); + when(); importAccountsFromResourceTaskHandler.importSingleShadow(shadows.get(0).getOid(), task, result); importAccountsFromResourceTaskHandler.importSingleShadow(shadows.get(1).getOid(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); ObjectQuery userQuery = prismContext.queryFor(UserType.class) diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIterativeTasks.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIterativeTasks.java index 0627035f7d0..a795680593f 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIterativeTasks.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIterativeTasks.java @@ -75,11 +75,11 @@ public void test100RunBucketsMultithreaded() throws Exception { // GIVEN // WHEN - when(TEST_NAME); + when(); addTask(TASK_BUCKETS_MULTITHREADED_FILE); // THEN - then(TEST_NAME); + then(); waitForTaskFinish(TASK_BUCKETS_MULTITHREADED_OID, false); } diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestLifecycle.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestLifecycle.java index 0c31c4ca91c..b08bf160ffe 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestLifecycle.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestLifecycle.java @@ -93,7 +93,7 @@ public void test050SetupJack() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_HEADMASTER_OID, task, result); assignRole(USER_JACK_OID, ROLE_GAMBLER_OID, task, result); @@ -103,7 +103,7 @@ public void test050SetupJack() throws Exception { modifyUserReplace(USER_JACK_OID, UserType.F_TELEPHONE_NUMBER, task, result, USER_JACK_TELEPHONE_NUMBER); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -122,11 +122,11 @@ public void test052PrincipalJackDraft() throws Exception { // GIVEN // WHEN - when(TEST_NAME); + when(); MidPointPrincipal principal = focusProfileService.getPrincipal(USER_JACK_USERNAME, UserType.class); // THEN - then(TEST_NAME); + then(); assertNotAuthorized(principal, AUTZ_COMMAND_URL); assertNotAuthorized(principal, AUTZ_GAMBLE_URL); assertNotAuthorized(principal, AUTZ_APPARATE_URL); @@ -146,11 +146,11 @@ public void test060TransitionJackToProposed() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_LIFECYCLE_STATE, task, result, SchemaConstants.LIFECYCLE_PROPOSED); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -171,11 +171,11 @@ public void test062PrincipalJackProposed() throws Exception { // GIVEN // WHEN - when(TEST_NAME); + when(); MidPointPrincipal principal = focusProfileService.getPrincipal(USER_JACK_USERNAME, UserType.class); // THEN - then(TEST_NAME); + then(); assertNotAuthorized(principal, AUTZ_COMMAND_URL); // Although we are in the proposed lifecycle and assignments would not be active by default // the proposed lifecycle is forcing activation to enabled. Therefore also assignments are @@ -200,11 +200,11 @@ public void test090TransitionJackToDefaultActive() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_LIFECYCLE_STATE, task, result /* no value */); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -223,11 +223,11 @@ public void test092PrincipalJackDefaultActive() throws Exception { // GIVEN // WHEN - when(TEST_NAME); + when(); MidPointPrincipal principal = focusProfileService.getPrincipal(USER_JACK_USERNAME, UserType.class); // THEN - then(TEST_NAME); + then(); assertNotAuthorized(principal, AUTZ_COMMAND_URL); assertAuthorized(principal, AUTZ_GAMBLE_URL); assertAuthorized(principal, AUTZ_APPARATE_URL); @@ -252,12 +252,12 @@ public void test100AssignJackCaretaker() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_CARETAKER_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -276,12 +276,12 @@ public void test102UnassignJackHeadmaster() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_HEADMASTER_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -304,12 +304,12 @@ public void test110UnassignJackCaretaker() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_CARETAKER_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -331,12 +331,12 @@ public void test112UnassignJackCaretaker() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_HEADMASTER_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelServiceContract.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelServiceContract.java index 716a1b09af2..bd8c306af06 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelServiceContract.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelServiceContract.java @@ -184,14 +184,14 @@ public void test099ModifyUserAddAccountFailing() throws Exception { try { // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); assertNotReached(); } catch (UnsupportedOperationException e) { // THEN - then(TEST_NAME); + then(); display("Expected exception", e); } @@ -246,11 +246,11 @@ public void test100ModifyUserAddAccount() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); modifyUserAddAccount(USER_JACK_OID, ACCOUNT_JACK_DUMMY_FILE, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); @@ -732,11 +732,11 @@ public void test119ModifyUserDeleteAccount() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("executeChanges result", result, 2); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); @@ -800,11 +800,11 @@ public void test120AddAccount() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); Collection> executeChanges = executeChanges(accountDelta, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); @@ -1112,11 +1112,11 @@ public void test131ModifyUserJackAssignAccount() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); @@ -1280,11 +1280,11 @@ public void test135ModifyUserJackAssignAccountAgain() throws Exception { preTestCleanup(AssignmentPolicyEnforcementType.FULL); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess("executeChanges result", result); PrismObject userJack = getUser(USER_JACK_OID); @@ -1345,11 +1345,11 @@ public void test136JackRecomputeNoChange() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1568,11 +1568,11 @@ public void test148ModifyUserJackUnassignAccountPositiveEnforcement() throws Exc assertSteadyResources(); // WHEN - when(TEST_NAME); + when(); executeChanges(deltas, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); // There is strong mapping. Complete account is fetched. assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1); @@ -2341,11 +2341,11 @@ public void test190ModifyUserJackAssignAccountAndModify() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); executeChanges(deltas, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); @@ -2467,11 +2467,11 @@ public void test191ModifyUserJackModifyAssignment() throws Exception { display("Deltas to execute execution", deltas); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("executeChanges result", result); @@ -2528,12 +2528,12 @@ public void test192ModifyUserJack() throws Exception { preTestCleanup(AssignmentPolicyEnforcementType.FULL); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, PrismTestUtil.createPolyString("Magnificent Captain Jack Sparrow")); // THEN - then(TEST_NAME); + then(); assertSuccess(result); // Strong mappings assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1); @@ -2699,11 +2699,11 @@ public void test195ModifyUserJackLocationSea() throws Exception { preTestCleanup(AssignmentPolicyEnforcementType.FULL); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_LOCALITY, task, result, createPolyString("sea")); // THEN - then(TEST_NAME); + then(); assertSuccess(result); // Strong mappings assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1); @@ -2971,11 +2971,11 @@ public void test210AddUserMorganWithAssignment() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); @@ -3047,11 +3047,11 @@ public void test212RenameUserMorgan() throws Exception { preTestCleanup(AssignmentPolicyEnforcementType.FULL); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_MORGAN_OID, UserType.F_NAME, task, result, PrismTestUtil.createPolyString("sirhenry")); // THEN - then(TEST_NAME); + then(); assertSuccess(result); // Strong mappings assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1); @@ -3223,11 +3223,11 @@ public void test300AddUserJackWithAssignmentBlue() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestPreviewChanges.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestPreviewChanges.java index 10b72e71d90..c90edae8443 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestPreviewChanges.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestPreviewChanges.java @@ -464,11 +464,11 @@ public void test200ModifyUserGuybrushDeleteAccount() throws Exception { display("Input deltas: ", deltas); // WHEN - when(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(deltas, new ModelExecuteOptions(), task, result); // THEN - then(TEST_NAME); + then(); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -507,11 +507,11 @@ public void test210GuybrushAddAccount() throws Exception { display("Input deltas: ", deltas); // WHEN - when(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(deltas, new ModelExecuteOptions(), task, result); // THEN - then(TEST_NAME); + then(); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -560,11 +560,11 @@ public void test212ModifyUserAddAccountRef() throws Exception { display("Input deltas: ", userDelta); // WHEN - when(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(deltas, new ModelExecuteOptions(), task, result); // THEN - then(TEST_NAME); + then(); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -612,12 +612,12 @@ public void test220PreviewJackAssignRolePirate() throws Exception { ROLE_PIRATE_OID, RoleType.COMPLEX_TYPE, null, null, null, true); // WHEN - when(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertPreviewJackAssignRolePirate(modelContext); @@ -643,12 +643,12 @@ public void test221PreviewJackAssignRolePirateReconcile() throws Exception { ROLE_PIRATE_OID, RoleType.COMPLEX_TYPE, null, null, null, true); // WHEN - when(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), ModelExecuteOptions.createReconcile(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertPreviewJackAssignRolePirate(modelContext); @@ -744,13 +744,13 @@ public void test230GuybrushAssignAccountDummy() throws Exception { ModelExecuteOptions options = ModelExecuteOptions.createReconcile(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_GUYBRUSH_OID, ItemPath.create(UserType.F_EXTENSION, PIRACY_WEAPON), task, result, "tongue"); assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); accountGuybrushOid = assertUserAfter(USER_GUYBRUSH_OID) @@ -778,12 +778,12 @@ public void test231PreviewGuybrushModifyAccountFullName() throws Exception { accountGuybrushOid, dummyResourceCtl.getAttributeFullnamePath(), "Mighty Pirate Guybrush Threepwood"); // WHEN - when(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(accountDelta), null, task, result); // THEN - then(TEST_NAME); + then(); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -831,12 +831,12 @@ public void test232PreviewGuybrushModifyAccountShip() throws Exception { "The Mad Monkey"); // WHEN - when(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(accountDelta), null, task, result); // THEN - then(TEST_NAME); + then(); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -882,12 +882,12 @@ public void test233PreviewGuybrushAddRolePirate() throws Exception { ROLE_PIRATE_OID, RoleType.COMPLEX_TYPE, null, null, null, true); // WHEN - when(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - then(TEST_NAME); + then(); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -950,12 +950,12 @@ public void test234PreviewGuybrushAddRolePirateRecon() throws Exception { ModelExecuteOptions options = ModelExecuteOptions.createReconcile(); // WHEN - when(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), options, task, result); // THEN - then(TEST_NAME); + then(); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -1016,12 +1016,12 @@ public void test236PreviewGuybrushAddRoleSailor() throws Exception { ROLE_SAILOR_OID, RoleType.COMPLEX_TYPE, null, null, null, true); // WHEN - when(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - then(TEST_NAME); + then(); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -1069,12 +1069,12 @@ public void test238PreviewGuybrushAddRoleSailorOwner() throws Exception { ROLE_SAILOR_OID, RoleType.COMPLEX_TYPE, SchemaConstants.ORG_OWNER, null, null, true); // WHEN - when(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - then(TEST_NAME); + then(); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -1103,11 +1103,11 @@ public void test239GuybrushUnAssignAccountDummy() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); // WHEN - when(TEST_NAME); + when(); unassignAccountFromUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1128,11 +1128,11 @@ public void test240GuybrushAssignAccountDummyRelative() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_RELATIVE_OID, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1159,12 +1159,12 @@ public void test242PreviewGuybrushAddRolePirateRelative() throws Exception { ROLE_PIRATE_RELATIVE_OID, RoleType.COMPLEX_TYPE, null, null, null, true); // WHEN - when(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - then(TEST_NAME); + then(); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -1226,12 +1226,12 @@ public void test244PreviewGuybrushAddRolePirateRelativeRecon() throws Exception ROLE_PIRATE_RELATIVE_OID, RoleType.COMPLEX_TYPE, null, null, null, true); // WHEN - when(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), ModelExecuteOptions.createReconcile(), task, result); // THEN - then(TEST_NAME); + then(); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -1287,11 +1287,11 @@ public void test249GuybrushUnAssignAccountDummyRelative() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); // WHEN - when(TEST_NAME); + when(); unassignAccountFromUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_RELATIVE_OID, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1461,11 +1461,11 @@ ACCOUNT_SHADOW_ELAINE_DUMMY_RED_OID, getDummyResourceObject(RESOURCE_DUMMY_RED_N display("Input deltas: ", deltas); // WHEN - when(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(deltas, new ModelExecuteOptions(), task, result); // THEN - then(TEST_NAME); + then(); display("Preview context", modelContext); assertPartialError(result); } @@ -1493,12 +1493,12 @@ public void test401ModifyElaineAccountDummyRedDeleteAdd() throws Exception { display("Input deltas: ", deltas); // WHEN - when(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(deltas, new ModelExecuteOptions(), task, result); display("Preview context", modelContext); // THEN - then(TEST_NAME); + then(); assertPartialError(result); } @@ -1640,11 +1640,11 @@ public void test600ModifyElaineUserDummyReplace() throws Exception { display("Input deltas: ", deltas); // WHEN - when(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(deltas, new ModelExecuteOptions(), task, result); // THEN - then(TEST_NAME); + then(); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -1743,11 +1743,11 @@ ACCOUNT_SHADOW_ELAINE_DUMMY_BLUE_OID, getDummyResourceObject(RESOURCE_DUMMY_BLUE display("Input deltas: ", deltas); // WHEN - when(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(deltas, new ModelExecuteOptions(), task, result); // THEN - then(TEST_NAME); + then(); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -2097,12 +2097,12 @@ public void test710PreviewGuybrushHavingRoleSailorOwner() throws Exception { ObjectDelta empty = prismContext.deltaFor(UserType.class).asObjectDeltaCast(USER_GUYBRUSH_OID); // WHEN - when(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(singleton(empty), createEvaluateAllAssignmentRelationsOnRecompute(), task, result); // THEN - then(TEST_NAME); + then(); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestResources.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestResources.java index 471ab730792..0fac7c4f8be 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestResources.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestResources.java @@ -165,11 +165,11 @@ public void test050GetResourceRaw() throws Exception { Collection> options = SelectorOptions.createCollection(GetOperationOptions.createRaw()); // WHEN - when(TEST_NAME); + when(); PrismObject resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, options , task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("Resource", resource); @@ -215,12 +215,12 @@ public void test052GetResourceNoFetch() throws Exception { GetOperationOptions.createNoFetch()); // WHEN - when(TEST_NAME); + when(); PrismObject resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, options, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("Resource", resource); @@ -266,12 +266,12 @@ public void test053GetResourceNoFetchAgain() throws Exception { GetOperationOptions.createNoFetch()); // WHEN - when(TEST_NAME); + when(); PrismObject resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, options, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("Resource", resource); @@ -320,12 +320,12 @@ public void test055GetResourceNoFetchReadOnly() throws Exception { Collection> options = SelectorOptions.createCollection(option); // WHEN - when(TEST_NAME); + when(); PrismObject resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, options, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("Resource", resource); @@ -366,11 +366,11 @@ public void test100SearchResourcesNoFetch() throws Exception { Collection> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch()); // WHEN - when(TEST_NAME); + when(); List> resources = modelService.searchObjects(ResourceType.class, null, options, task, result); // THEN - then(TEST_NAME); + then(); assertNotNull("null search return", resources); assertFalse("Empty search return", resources.isEmpty()); assertEquals("Unexpected number of resources found", 2, resources.size()); @@ -416,11 +416,11 @@ public void test102SearchResourcesNoFetchReadOnly() throws Exception { Collection> options = SelectorOptions.createCollection(option); // WHEN - when(TEST_NAME); + when(); List> resources = modelService.searchObjects(ResourceType.class, null, options, task, result); // THEN - then(TEST_NAME); + then(); assertNotNull("null search return", resources); assertFalse("Empty search return", resources.isEmpty()); assertEquals("Unexpected number of resources found", 2, resources.size()); @@ -472,11 +472,11 @@ public void test105SearchResourcesIterativeNoFetch() throws Exception { Collection> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch()); // WHEN - when(TEST_NAME); + when(); modelService.searchObjectsIterative(ResourceType.class, null, handler, options, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertFalse("Empty search return", resources.isEmpty()); @@ -525,11 +525,11 @@ public void test107SearchResourcesIterativeNoFetchReadOnly() throws Exception { Collection> options = SelectorOptions.createCollection(option); // WHEN - when(TEST_NAME); + when(); modelService.searchObjectsIterative(ResourceType.class, null, handler, options, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertFalse("Empty search return", resources.isEmpty()); @@ -561,11 +561,11 @@ public void test110GetResourceDummy() throws Exception { rememberCounter(InternalCounters.PRISM_OBJECT_CLONE_COUNT); // WHEN - when(TEST_NAME); + when(); PrismObject resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null , task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertCounterIncrement(InternalCounters.PRISM_OBJECT_CLONE_COUNT, 4); @@ -606,12 +606,12 @@ public void test112GetResourceDummyReadOnly() throws Exception { GetOperationOptions.createReadOnly()); // WHEN - when(TEST_NAME); + when(); PrismObject resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, options , task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertCounterIncrement(InternalCounters.PRISM_OBJECT_CLONE_COUNT, 1); @@ -645,11 +645,11 @@ public void test120SearchResources() throws Exception { assertSteadyResources(); // WHEN - when(TEST_NAME); + when(); List> resources = modelService.searchObjects(ResourceType.class, null, null, task, result); // THEN - then(TEST_NAME); + then(); assertNotNull("null search return", resources); assertFalse("Empty search return", resources.isEmpty()); assertEquals("Unexpected number of resources found", 2, resources.size()); @@ -832,11 +832,11 @@ public void test210GetResourceDummyRed() throws Exception { rememberCounter(InternalCounters.PRISM_OBJECT_CLONE_COUNT); // WHEN - when(TEST_NAME); + when(); PrismObject resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_RED_OID, null , task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertCounterIncrement(InternalCounters.PRISM_OBJECT_CLONE_COUNT, 1); @@ -876,11 +876,11 @@ public void test750GetResourceRaw() throws Exception { Collection> options = SelectorOptions.createCollection(GetOperationOptions.createRaw()); // WHEN - when(TEST_NAME); + when(); PrismObject resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, options , task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("Resource", resource); @@ -909,11 +909,11 @@ public void test752GetResourceDummy() throws Exception { rememberCounter(InternalCounters.PRISM_OBJECT_CLONE_COUNT); // WHEN - when(TEST_NAME); + when(); PrismObject resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null , task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertCounterIncrement(InternalCounters.PRISM_OBJECT_CLONE_COUNT, 1); @@ -941,11 +941,11 @@ public void test760ModifyConfigurationString() throws Exception { "whatever wherever"); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(resourceDelta), null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject resourceAfter = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result); @@ -967,12 +967,12 @@ public void test761ModifyConfigurationStringRaw() throws Exception { "whatever raw wherever"); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(resourceDelta), ModelExecuteOptions.createRaw(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject resourceAfter = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result); @@ -1050,11 +1050,11 @@ private void modifyConfigurationDiffExpressionRaw(final String TEST_NAME, display("Diff delta", diffDelta); // WHEN - when(TEST_NAME); + when(); executeChanges(diffDelta, ModelExecuteOptions.createRaw(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertCounterIncrement(InternalCounters.CONNECTOR_INSTANCE_INITIALIZATION_COUNT, 0); @@ -1108,11 +1108,11 @@ public void test800GetResourceDummy() throws Exception { rememberCounter(InternalCounters.PRISM_OBJECT_CLONE_COUNT); // WHEN - when(TEST_NAME); + when(); PrismObject resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null , task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertCounterIncrement(InternalCounters.PRISM_OBJECT_CLONE_COUNT, 1); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTolerantAttributes.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTolerantAttributes.java index ed0398bfe67..b4fa08c557f 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTolerantAttributes.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTolerantAttributes.java @@ -136,11 +136,11 @@ UserType.F_DESCRIPTION, getUserDefinition().findPropertyDefinition(UserType.F_DE Collection> deltas = (Collection)MiscUtil.createCollection(userDelta); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(deltas, ModelExecuteOptions.createReconcile(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); // Check value in "quote attribute" @@ -322,11 +322,11 @@ public void test105ModifyAddNonTolerantAttribute() throws Exception { Collection> deltas = (Collection)MiscUtil.createCollection(userDelta); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(deltas, ModelExecuteOptions.createReconcile(), task, result); // THEN - then(TEST_NAME); + then(); assertPartialError(result); } diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplateWithRanges.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplateWithRanges.java index 650b4973138..012a91338dc 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplateWithRanges.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplateWithRanges.java @@ -359,7 +359,7 @@ public void test300GuybrushBloodyNose() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); executeChanges( deltaFor(UserType.class) .item(UserType.F_TITLE).add(PolyString.fromOrig(ROLE_BLOODY_NOSE_NAME)) @@ -367,7 +367,7 @@ public void test300GuybrushBloodyNose() throws Exception { null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_GUYBRUSH_OID) @@ -390,7 +390,7 @@ public void test309GuybrushNotBloody() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); executeChanges( deltaFor(UserType.class) .item(UserType.F_TITLE).delete(PolyString.fromOrig(ROLE_BLOODY_NOSE_NAME)) @@ -398,7 +398,7 @@ public void test309GuybrushNotBloody() throws Exception { null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_GUYBRUSH_OID) @@ -420,7 +420,7 @@ public void test310GuybrushBloodyNoseFuneral() throws Exception { GUYBRUSH_FUNERAL_DATE_123456_CAL); // WHEN - when(TEST_NAME); + when(); executeChanges( deltaFor(UserType.class) .item(UserType.F_TITLE).add(PolyString.fromOrig(ROLE_BLOODY_NOSE_NAME)) @@ -428,7 +428,7 @@ public void test310GuybrushBloodyNoseFuneral() throws Exception { null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_GUYBRUSH_OID) @@ -451,7 +451,7 @@ public void test319GuybrushNoBloodyNoseFuneral() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); executeChanges( deltaFor(UserType.class) .item(UserType.F_TITLE).delete(PolyString.fromOrig(ROLE_BLOODY_NOSE_NAME)) @@ -459,7 +459,7 @@ public void test319GuybrushNoBloodyNoseFuneral() throws Exception { null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_GUYBRUSH_OID) @@ -481,7 +481,7 @@ public void test320GuybrushBloodyNose() throws Exception { /* no value */); // WHEN - when(TEST_NAME); + when(); executeChanges( deltaFor(UserType.class) .item(UserType.F_TITLE).add(PolyString.fromOrig(ROLE_BLOODY_NOSE_NAME)) @@ -489,7 +489,7 @@ public void test320GuybrushBloodyNose() throws Exception { null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_GUYBRUSH_OID) @@ -512,12 +512,12 @@ public void test322GuybrushSetFuneral() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_GUYBRUSH_OID, getExtensionPath(PIRACY_FUNERAL_TIMESTAMP), task, result, GUYBRUSH_FUNERAL_DATE_123456_CAL); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_GUYBRUSH_OID) @@ -540,12 +540,12 @@ public void test324GuybrushSetFuneral22222() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_GUYBRUSH_OID, getExtensionPath(PIRACY_FUNERAL_TIMESTAMP), task, result, GUYBRUSH_FUNERAL_DATE_22222_CAL); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_GUYBRUSH_OID) @@ -570,12 +570,12 @@ public void test326GuybrushNoFuneral() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_GUYBRUSH_OID, getExtensionPath(PIRACY_FUNERAL_TIMESTAMP), task, result /* no value */); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_GUYBRUSH_OID) @@ -597,7 +597,7 @@ public void test329GuybrushNoBloodyNose() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); executeChanges( deltaFor(UserType.class) .item(UserType.F_TITLE).delete(PolyString.fromOrig(ROLE_BLOODY_NOSE_NAME)) @@ -605,7 +605,7 @@ public void test329GuybrushNoBloodyNose() throws Exception { null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_GUYBRUSH_OID) diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestArchetypes.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestArchetypes.java index 03a87443c3f..6d7b95dad37 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestArchetypes.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestArchetypes.java @@ -145,11 +145,11 @@ public void test050AddArchetypeTest() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); addObject(ARCHETYPE_TEST_FILE, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject archetypeTest = modelService.getObject(ArchetypeType.class, ARCHETYPE_TEST_OID, null, task, result); @@ -164,13 +164,13 @@ public void test060AddArchetypesAndRoles() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); addObject(ARCHETYPE_BUSINESS_ROLE_FILE, task, result); addObject(ROLE_BUSINESS_CAPTAIN_FILE, task, result); addObject(ROLE_BUSINESS_BOSUN_FILE, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject roleBusinessCaptainAfter = assertRoleAfter(ROLE_BUSINESS_CAPTAIN_OID) @@ -203,11 +203,11 @@ public void test070AssignGuybrushUserAdministrator() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_USER_ADMINISTRATOR_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); // TODO: assert guybrush @@ -222,12 +222,12 @@ public void test100AssignJackArchetypeEmployee() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignArchetype(USER_JACK_OID, ARCHETYPE_EMPLOYEE_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = assertUserAfter(USER_JACK_OID) @@ -269,12 +269,12 @@ public void test102SearchEmployeeArchetypeRef() throws Exception { .build(); // WHEN - when(TEST_NAME); + when(); SearchResultList> searchResults = modelService.searchObjects(UserType.class, query, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("Search results", searchResults); assertEquals("Wrong number of search results", 1, searchResults.size()); @@ -369,12 +369,12 @@ public void test109UnassignJackArchetypeEmployee() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignArchetype(USER_JACK_OID, ARCHETYPE_EMPLOYEE_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = assertUserAfter(USER_JACK_OID) @@ -401,12 +401,12 @@ public void test110AssignJackRoleEmployeeBase() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_EMPLOYEE_BASE_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = assertUserAfter(USER_JACK_OID) @@ -456,12 +456,12 @@ public void test115UnassignJackRoleEmployeeBase() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_EMPLOYEE_BASE_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = assertUserAfter(USER_JACK_OID) @@ -499,12 +499,12 @@ public void test120AssignJackArchetypeTest() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignArchetype(USER_JACK_OID, ARCHETYPE_TEST_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -534,12 +534,12 @@ public void test129UnassignJackArchetypeTest() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignArchetype(USER_JACK_OID, ARCHETYPE_TEST_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -565,12 +565,12 @@ public void test130AssignJackArchetypeContractor() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignArchetype(USER_JACK_OID, ARCHETYPE_CONTRACTOR_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -597,12 +597,12 @@ public void test132JackContractorRecompute() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -630,12 +630,12 @@ public void test135UnassignJackArchetypeContractor() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignArchetype(USER_JACK_OID, ARCHETYPE_CONTRACTOR_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -666,12 +666,12 @@ public void test137JackEmpnoAndRecompute() throws Exception { modifyUserReplace(USER_JACK_OID, UserType.F_EMPLOYEE_NUMBER, task, result, "Number ONE"); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -700,12 +700,12 @@ public void test140AddMeathookContractor() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); addObject(USER_MEATHOOK_FILE, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_MEATHOOK_OID) @@ -734,12 +734,12 @@ public void test150AddWannabe() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); addObject(USER_WANNABE_FILE, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_WANNABE_OID) @@ -769,12 +769,12 @@ public void test160AddSelfMadeMan() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); addObject(USER_SELF_MADE_MAN_FILE, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_SELF_MADE_MAN_OID) @@ -806,7 +806,7 @@ public void test162AddFraudster() throws Exception { try { // WHEN - when(TEST_NAME); + when(); addObject(USER_FRAUDSTER_FILE, task, result); @@ -817,7 +817,7 @@ public void test162AddFraudster() throws Exception { } // THEN - then(TEST_NAME); + then(); assertFailure(result); assertNoObject(UserType.class, USER_FRAUDSTER_OID); @@ -831,13 +831,13 @@ public void test200AssignJackBarbossaArchetypeEmployee() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignArchetype(USER_JACK_OID, ARCHETYPE_EMPLOYEE_OID, task, result); assignArchetype(USER_BARBOSSA_OID, ARCHETYPE_EMPLOYEE_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -892,12 +892,12 @@ public void test203DisableBarbossa() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.DISABLED); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -952,7 +952,7 @@ public void test300jackAssignArchetypeRaw() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); try { assignArchetype(USER_JACK_OID, ARCHETYPE_CONTRACTOR_OID, task, result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestCollections.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestCollections.java index 83e52c98dd2..739febe6312 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestCollections.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestCollections.java @@ -70,11 +70,11 @@ public void test000Sanity() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); collectionActiveUsers = modelService.getObject(ObjectCollectionType.class, COLLECTION_ACTIVE_USERS_OID, null, task, result); // THEN - then(TEST_NAME); + then(); display("Collection", collectionActiveUsers); assertSuccess(result); assertNotNull("No collection", collectionActiveUsers); @@ -89,11 +89,11 @@ public void test100CompileCollectionView() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); collectionViewActiveUsers = modelInteractionService.compileObjectCollectionView(collectionActiveUsers, null, task, result); // THEN - then(TEST_NAME); + then(); display("Active users collection view", collectionViewActiveUsers); assertSuccess(result); assertNotNull("Null view", collectionActiveUsers); @@ -116,11 +116,11 @@ public void test102SearchCollectionUsers() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); SearchResultList> users = modelService.searchObjects(UserType.class, prismContext.queryFactory().createQuery(collectionViewActiveUsers.getFilter()), null, task, result); // THEN - then(TEST_NAME); + then(); display("Users in collection", users); assertSuccess(result); assertEquals("Wrong number of users in collection", getNumberOfUsers(), users.size()); @@ -135,11 +135,11 @@ public void test110CollectionStatsAllEnabled() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); CollectionStats stats = modelInteractionService.determineCollectionStats(collectionViewActiveUsers, task, result); // THEN - then(TEST_NAME); + then(); display("Collection stats", stats); assertSuccess(result); assertNotNull("Null stats", stats); @@ -158,11 +158,11 @@ public void test112EvaluateRulesAllEnabled() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); Collection evaluatedRules = modelInteractionService.evaluateCollectionPolicyRules(collectionActiveUsers, collectionViewActiveUsers, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertEvaluatedPolicyRules(evaluatedRules, collectionActiveUsers) @@ -182,11 +182,11 @@ public void test120CollectionStatsOneDisabled() throws Exception { numberOfDisabledUsers++; // WHEN - when(TEST_NAME); + when(); CollectionStats stats = modelInteractionService.determineCollectionStats(collectionViewActiveUsers, task, result); // THEN - then(TEST_NAME); + then(); display("Collection stats", stats); assertSuccess(result); assertNotNull("Null stats", stats); @@ -205,11 +205,11 @@ public void test122EvaluateRulesOneDisabled() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); Collection evaluatedRules = modelInteractionService.evaluateCollectionPolicyRules(collectionActiveUsers, collectionViewActiveUsers, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertEvaluatedPolicyRules(evaluatedRules, collectionActiveUsers) diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestEditSchema.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestEditSchema.java index 434df21b22e..792da9674d7 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestEditSchema.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestEditSchema.java @@ -89,11 +89,11 @@ public void test100LookupLanguagesGet() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -119,11 +119,11 @@ public void test102LookupLanguagesGetExclude() throws Exception { .build(); // WHEN - when(TEST_NAME); + when(); PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, options, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -145,11 +145,11 @@ public void test110LookupLanguagesGetAll() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); checkLookupResult(lookup, new String[]{"en_US", "en", "English (US)"}, @@ -167,7 +167,7 @@ public void test120LookupLanguagesGetByKeyExact() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() .item(LookupTableType.F_ROW) @@ -178,7 +178,7 @@ public void test120LookupLanguagesGetByKeyExact() throws Exception { PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); checkLookupResult(lookup, new String[] { "sk_SK", "sk", "Slovak" }); @@ -193,7 +193,7 @@ public void test121LookupLanguagesGetByKeyStartingWith() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() .item(LookupTableType.F_ROW) @@ -204,7 +204,7 @@ public void test121LookupLanguagesGetByKeyStartingWith() throws Exception { PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); checkLookupResult(lookup, new String[]{"en_US", "en", "English (US)"}, @@ -220,7 +220,7 @@ public void test122LookupLanguagesGetByKeyContaining() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() .item(LookupTableType.F_ROW) @@ -231,7 +231,7 @@ public void test122LookupLanguagesGetByKeyContaining() throws Exception { PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); checkLookupResult(lookup, new String[]{"tr_TR", "tr", "Turkish"}); @@ -246,7 +246,7 @@ public void test123LookupLanguagesGetByKeyContainingWithPaging() throws Exceptio OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() .item(LookupTableType.F_ROW) @@ -260,7 +260,7 @@ public void test123LookupLanguagesGetByKeyContainingWithPaging() throws Exceptio PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); checkLookupResult(lookup, new String[] { "sk_SK", "sk", "Slovak" }); @@ -275,7 +275,7 @@ public void test124LookupLanguagesGetByKeyContainingReturningNothing() throws Ex OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() .item(LookupTableType.F_ROW) @@ -286,7 +286,7 @@ public void test124LookupLanguagesGetByKeyContainingReturningNothing() throws Ex PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); IntegrationTestTools.display("Languages", lookup); @@ -308,7 +308,7 @@ public void test130LookupLanguagesGetByValueExact() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() .item(LookupTableType.F_ROW) @@ -319,7 +319,7 @@ public void test130LookupLanguagesGetByValueExact() throws Exception { PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); checkLookupResult(lookup, new String[] { "sk_SK", "sk", "Slovak" }); @@ -338,7 +338,7 @@ public void test131LookupLanguagesGetByLabelStartingWith() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); String fragment = "Eng"; GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() @@ -350,7 +350,7 @@ public void test131LookupLanguagesGetByLabelStartingWith() throws Exception { PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); checkLookupResult(lookup, new String[]{"en_US", "en", "English (US)"}, @@ -366,7 +366,7 @@ public void test133LookupLanguagesGetByValueContainingWithPaging() throws Except OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() .item(LookupTableType.F_ROW) @@ -380,7 +380,7 @@ public void test133LookupLanguagesGetByValueContainingWithPaging() throws Except PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); checkLookupResult(lookup, new String[] { "en_US", "en", "English (US)" }); @@ -398,7 +398,7 @@ public void test140LookupLanguagesGetByIdExisting() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); Collection> options = SelectorOptions.createCollection( prismContext.path(LookupTableType.F_ROW, 1L), @@ -406,7 +406,7 @@ public void test140LookupLanguagesGetByIdExisting() throws Exception { PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, options, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); checkLookupResult(lookup, new String[] { "en_US", "en", "English (US)" }); @@ -445,11 +445,11 @@ public void test150LookupLanguagesAddRowFull() throws Exception { LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -491,11 +491,11 @@ public void test152LookupLanguagesAddRowKeyLabel() throws Exception { LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -538,11 +538,11 @@ public void test154LookupLanguagesAddRowKeyValue() throws Exception { LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -587,7 +587,7 @@ public void test156LookupLanguagesAddRowExistingKey() throws Exception { LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); // WHEN - when(TEST_NAME); + when(); boolean exception = false; try { modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); @@ -597,7 +597,7 @@ public void test156LookupLanguagesAddRowExistingKey() throws Exception { AssertJUnit.assertFalse(exception); // as per description in https://wiki.evolveum.com/display/midPoint/Development+with+LookupTable // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -647,11 +647,11 @@ public void test162LookupLanguagesDeleteRowFullNoId() throws Exception { LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -695,11 +695,11 @@ public void test164LookupLanguagesDeleteRowFullId() throws Exception { LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); // WHEN - when(TEST_NAME); + when(); executeChanges(delta, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); @@ -737,11 +737,11 @@ public void test166LookupLanguagesDeleteRowIdOnly() throws Exception { LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); // WHEN - when(TEST_NAME); + when(); executeChanges(delta, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); @@ -778,11 +778,11 @@ public void test168LookupLanguagesDeleteRowByKey() throws Exception { LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); @@ -831,11 +831,11 @@ public void test170LookupLanguagesReplaceRows() throws Exception { LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row1, row2, row3); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -871,13 +871,13 @@ public void test180LookupLanguagesReplaceObject() throws Exception { ObjectDelta delta = DeltaFactory.Object.createAddDelta(replacement); // WHEN - when(TEST_NAME); + when(); ModelExecuteOptions options = ModelExecuteOptions.createOverwrite(); options.setRaw(true); modelService.executeChanges(MiscSchemaUtil.createCollection(delta), options, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -911,11 +911,11 @@ public void test182LookupLanguagesReimport() throws Exception { options.setKeepOid(true); // WHEN - when(TEST_NAME); + when(); modelService.importObjectsFromFile(LOOKUP_LANGUAGES_FILE, options, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -972,11 +972,11 @@ public void test200EditSchemaUser() throws Exception { PrismObject user = userDef.instantiate(); // WHEN - when(TEST_NAME); + when(); PrismObjectDefinition editDef = getEditObjectDefinition(user); // THEN - then(TEST_NAME); + then(); PrismAsserts.assertEmphasized(editDef, UserType.F_NAME, true); @@ -1046,11 +1046,11 @@ public void test210UserDefinition() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); PrismObject user = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1116,11 +1116,11 @@ public void test213ModifiedUserJack() throws Exception { modifyObjectReplaceProperty(UserType.class, USER_JACK_OID, UserType.F_PREFERRED_LANGUAGE, task, result, "en_PR"); // WHEN - when(TEST_NAME); + when(); PrismObject user = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertPropertyValues(user, UserType.F_ADDITIONAL_NAME, (propDef, name) -> { @@ -1206,11 +1206,11 @@ public void test250EditSchemaRole() throws Exception { PrismObject role = roleDef.instantiate(); // WHEN - when(TEST_NAME); + when(); PrismObjectDefinition editDef = getEditObjectDefinition(role); // THEN - then(TEST_NAME); + then(); // TODO PrismPropertyDefinition requestableDef = editDef.findPropertyDefinition(RoleType.F_REQUESTABLE); @@ -1231,11 +1231,11 @@ public void test260EditShadowSchemaKindIntent() throws Exception { ResourceShadowDiscriminator discr = new ResourceShadowDiscriminator(RESOURCE_DUMMY_OID, ShadowKindType.ACCOUNT, null, null, false); // WHEN - when(TEST_NAME); + when(); PrismObjectDefinition editDef = modelInteractionService.getEditShadowDefinition(discr, AuthorizationPhaseType.REQUEST, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismPropertyDefinition nameDef = editDef.findPropertyDefinition(ShadowType.F_NAME); @@ -1273,11 +1273,11 @@ public void test261EditShadowSchemaObjectclass() throws Exception { IntegrationTestTools.display("Discr", discr); // WHEN - when(TEST_NAME); + when(); PrismObjectDefinition editDef = modelInteractionService.getEditShadowDefinition(discr, AuthorizationPhaseType.REQUEST, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismPropertyDefinition nameDef = editDef.findPropertyDefinition(ShadowType.F_NAME); @@ -1305,11 +1305,11 @@ public void test263EditShadowSchemaEmpty() throws Exception { IntegrationTestTools.display("Discr", discr); // WHEN - when(TEST_NAME); + when(); PrismObjectDefinition editDef = modelInteractionService.getEditShadowDefinition(discr, AuthorizationPhaseType.REQUEST, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismPropertyDefinition nameDef = editDef.findPropertyDefinition(ShadowType.F_NAME); @@ -1332,11 +1332,11 @@ public void test265EditShadowSchemaNull() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); PrismObjectDefinition editDef = modelInteractionService.getEditShadowDefinition(null, AuthorizationPhaseType.REQUEST, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismPropertyDefinition nameDef = editDef.findPropertyDefinition(ShadowType.F_NAME); @@ -1361,11 +1361,11 @@ public void test310CustomRelations() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); List relations = modelInteractionService.getRelationDefinitions(); // THEN - then(TEST_NAME); + then(); display("Relations", relations); assertRelationDef(relations, SchemaConstants.ORG_MANAGER, "RelationTypes.manager"); assertRelationDef(relations, SchemaConstants.ORG_OWNER, "Master"); @@ -1391,12 +1391,12 @@ public void test800OtisEditSchemaUser() throws Exception { PrismObject user = userDef.instantiate(); // WHEN - when(TEST_NAME); + when(); PrismObjectDefinition editDef = getEditObjectDefinition(user); display("Otis edit schema", editDef); // THEN - then(TEST_NAME); + then(); PrismPropertyDefinition nameDef = editDef.findPropertyDefinition(UserType.F_NAME); assertNotNull("No definition for name in user", nameDef); @@ -1457,11 +1457,11 @@ public void test810OtisGetJack() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); PrismObject user = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1540,11 +1540,11 @@ public void test820OtisSearchUsers() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); SearchResultList> users = modelService.searchObjects(UserType.class, null, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestRoleEntitlement.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestRoleEntitlement.java index 3882a883656..a168e1316c3 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestRoleEntitlement.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestRoleEntitlement.java @@ -437,11 +437,11 @@ public void test120AddEntitlement() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); Collection> executedChanges = executeChanges(groupDelta, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); @@ -493,11 +493,11 @@ public void test121ModifyRoleLinkEntitlement() throws Exception { roleDelta.addModification(linkDelta); // WHEN - when(TEST_NAME); + when(); executeChanges(roleDelta, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject role = getRole(ROLE_PIRATE_OID); @@ -635,11 +635,11 @@ public void test131ModifyRoleAssignEntitlement() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(assignmentDelta); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess("executeChanges result", result); PrismObject role = getRole(ROLE_PIRATE_OID); @@ -1153,11 +1153,11 @@ public void test200AddRoleSwashbuckler() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); executeChanges(roleDelta, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); @@ -1217,11 +1217,11 @@ public void test210ModifyRoleSwashbucklerRiskLevel() throws Exception { .assertItems(PIRACY_COST_CENTER); // WHEN - when(TEST_NAME); + when(); modifyObjectReplaceProperty(RoleType.class, ROLE_SWASHBUCKLER_OID, RoleType.F_RISK_LEVEL, task, result, "99"); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertRoleAfter(ROLE_SWASHBUCKLER_OID) diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractDirectManualResourceTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractDirectManualResourceTest.java index de7092e860d..687ebaf670e 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractDirectManualResourceTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractDirectManualResourceTest.java @@ -126,11 +126,11 @@ public void test220ModifyUserWillDisable() throws Exception { accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(userWillOid, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.DISABLED); // THEN - then(TEST_NAME); + then(); display("result", result); willLastCaseOid = assertInProgress(result); @@ -211,11 +211,11 @@ public void test230ModifyAccountWillChangePasswordAndEnable() throws Exception { accountWillSecondReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); executeChanges(delta, null, task, result); // THEN - then(TEST_NAME); + then(); display("result", result); willSecondLastCaseOid = assertInProgress(result); @@ -293,12 +293,12 @@ public void test240CloseDisableCaseAndReadAccountWill() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); PrismObject shadowModel = modelService.getObject(ShadowType.class, accountWillOid, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); accountWillCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -384,11 +384,11 @@ public void test250RecomputeWillAfter5min() throws Exception { display("Shadow before", shadowBefore); // WHEN - when(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = repositoryService.getObject(ShadowType.class, accountWillOid, null, result); @@ -468,12 +468,12 @@ public void test252UpdateBackingStoreAndGetAccountWill() throws Exception { backingStoreUpdateWill(USER_WILL_FULL_NAME_PIRATE, INTEREST_ONE, ActivationStatusType.DISABLED, USER_WILL_PASSWORD_OLD); // WHEN - when(TEST_NAME); + when(); PrismObject shadowModel = modelService.getObject(ShadowType.class, accountWillOid, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("Model shadow", shadowModel); @@ -528,11 +528,11 @@ public void test260ClosePasswordChangeCaseAndRecomputeWill() throws Exception { accountWillSecondCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); accountWillSecondCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -633,11 +633,11 @@ public void test270RecomputeWillAfter7min() throws Exception { display("Shadow before", shadowBefore); // WHEN - when(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = assertRepoShadow(accountWillOid) @@ -728,12 +728,12 @@ public void test272UpdateBackingStoreAndGetAccountWill() throws Exception { backingStoreUpdateWill(USER_WILL_FULL_NAME_PIRATE, INTEREST_ONE, ActivationStatusType.ENABLED, USER_WILL_PASSWORD_NEW); // WHEN - when(TEST_NAME); + when(); PrismObject shadowModel = modelService.getObject(ShadowType.class, accountWillOid, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); ShadowAsserter.forShadow(shadowModel, "model") @@ -789,11 +789,11 @@ public void test274RecomputeWillAfter22min() throws Exception { display("Shadow before", shadowBefore); // WHEN - when(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = assertRepoShadow(accountWillOid) @@ -871,11 +871,11 @@ public void test280RecomputeWillAfter27min() throws Exception { clockForward("PT5M"); // WHEN - when(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = assertRepoShadow(accountWillOid) @@ -944,11 +944,11 @@ public void test290RecomputeWillAfter32min() throws Exception { clockForward("PT5M"); // WHEN - when(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = repositoryService.getObject(ShadowType.class, accountWillOid, null, result); @@ -1008,11 +1008,11 @@ public void test300UnassignAccountWill() throws Exception { accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); unassignRole(userWillOid, getRoleOneOid(), task, result); // THEN - then(TEST_NAME); + then(); display("result", result); willLastCaseOid = assertInProgress(result); @@ -1080,11 +1080,11 @@ public void test302RecomputeWill() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - then(TEST_NAME); + then(); display("result", result); assertSuccess(result); @@ -1154,12 +1154,12 @@ public void test310CloseCaseAndReconcileWill() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); // We need reconcile and not recompute here. We need to fetch the updated case status. reconcileUser(userWillOid, task, result); // THEN - then(TEST_NAME); + then(); display("result", result); assertSuccess(result); @@ -1217,11 +1217,11 @@ public void test320RecomputeWillAfter5min() throws Exception { clockForward("PT5M"); // WHEN - when(TEST_NAME); + when(); reconcileUser(userWillOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); ShadowAsserter shadowRepoAsserter = assertRepoShadow(accountWillOid) @@ -1271,14 +1271,14 @@ public void test330UpdateBackingStoreAndRecomputeWill() throws Exception { displayBackingStore(); // WHEN - when(TEST_NAME); + when(); // Reconcile is needed here. Recompute means noFetch which means that we won't // discover that an account is missing from backing store which means that the // quantum state won't collapse. reconcileUser(userWillOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); ShadowAsserter shadowRepoAsserter = assertRepoShadow(accountWillOid) @@ -1333,11 +1333,11 @@ public void test340RecomputeWillAfter25min() throws Exception { clockForward("PT20M"); // WHEN - when(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(userWillOid) @@ -1374,11 +1374,11 @@ public void test342RecomputeWillAfter35min() throws Exception { clockForward("PT10M"); // WHEN - when(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertRepoShadow(accountWillOid); @@ -1412,11 +1412,11 @@ public void test344RecomputeWillAfter165min() throws Exception { clockForward("PT130M"); // WHEN - when(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); UserAsserter userAfterAsserter = assertUserAfter(userWillOid); @@ -1475,11 +1475,11 @@ public void test510UnassignWillRoleOne() throws Exception { accountWillSecondReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); unassignRole(userWillOid, getRoleOneOid(), task, result); // THEN - then(TEST_NAME); + then(); display("result", result); willSecondLastCaseOid = assertInProgress(result); @@ -1543,11 +1543,11 @@ public void test512ReconcileWill() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); reconcileUser(userWillOid, task, result); // THEN - then(TEST_NAME); + then(); display("result", result); assertSuccess(result); @@ -1618,12 +1618,12 @@ public void test515CloseCasesAndReconcileWill() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); // We need reconcile and not recompute here. We need to fetch the updated case status. reconcileUser(userWillOid, task, result); // THEN - then(TEST_NAME); + then(); display("result", result); assertSuccess(result); @@ -1715,11 +1715,11 @@ public void test516RecomputeWillAfter20min() throws Exception { clockForward("PT20M"); // WHEN - when(TEST_NAME); + when(); reconcileUser(userWillOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(userWillOid) @@ -1749,11 +1749,11 @@ public void test517RecomputeWillAfter50min() throws Exception { clockForward("PT15M"); // WHEN - when(TEST_NAME); + when(); reconcileUser(userWillOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertRepoShadow(accountWillOid); @@ -1785,11 +1785,11 @@ public void test518RecomputeWillAfter180min() throws Exception { clockForward("PT130M"); // WHEN - when(TEST_NAME); + when(); reconcileUser(userWillOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(userWillOid) @@ -1847,11 +1847,11 @@ public void test522AssignWillRoleTwoValidFrom() throws Exception { activationType.setValidFrom(roleTwoValidFromTimestamp); // WHEN - when(TEST_NAME); + when(); assignRole(userWillOid, getRoleTwoOid(), activationType, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); accountWillOid = assertUserAfter(userWillOid) @@ -1881,11 +1881,11 @@ public void test524TwoHoursForRoleTwo() throws Exception { accountWillSecondReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); reconcileUser(userWillOid, task, result); // THEN - then(TEST_NAME); + then(); display("result", result); willSecondLastCaseOid = assertInProgress(result); @@ -1949,12 +1949,12 @@ public void test525CloseCasesAndReconcileWill() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); // We need reconcile and not recompute here. We need to fetch the updated case status. reconcileUser(userWillOid, task, result); // THEN - then(TEST_NAME); + then(); display("result", result); assertSuccess(result); @@ -1985,12 +1985,12 @@ public void test526UnassignWillBothRoles() throws Exception { accountWillSecondReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); unassignAll(userBefore, task, result); // THEN - then(TEST_NAME); + then(); display("result", result); willLastCaseOid = assertInProgress(result); @@ -2044,12 +2044,12 @@ public void test528CloseCaseAndRecomputeWill() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); // We need reconcile and not recompute here. We need to fetch the updated case status. reconcileUser(userWillOid, task, result); // THEN - then(TEST_NAME); + then(); display("result", result); assertSuccess(result); @@ -2118,11 +2118,11 @@ public void test800ImportShadowRefreshTask() throws Exception { // GIVEN // WHEN - when(TEST_NAME); + when(); addTask(TASK_SHADOW_REFRESH_FILE); // THEN - then(TEST_NAME); + then(); waitForTaskStart(TASK_SHADOW_REFRESH_OID, false); } @@ -2162,11 +2162,11 @@ public void test820AssignAccountJack() throws Exception { accountJackReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, getResourceOid(), null, task, result); // THEN - then(TEST_NAME); + then(); display("result", result); jackLastCaseOid = assertInProgress(result); @@ -2199,12 +2199,12 @@ public void test830CloseCaseWillAndWaitForRefresh() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); restartTask(TASK_SHADOW_REFRESH_OID); waitForTaskFinish(TASK_SHADOW_REFRESH_OID, false); // THEN - then(TEST_NAME); + then(); assertSuccess(result); accountWillCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -2224,11 +2224,11 @@ public void test840AddToBackingStoreAndGetAccountWill() throws Exception { backingStoreProvisionWill(INTEREST_ONE); // WHEN - when(TEST_NAME); + when(); PrismObject shadowModel = modelService.getObject(ShadowType.class, accountWillOid, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); ShadowAsserter.forShadow(shadowModel, "model") diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractGroupingManualResourceTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractGroupingManualResourceTest.java index 7705244dbb7..5d527898428 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractGroupingManualResourceTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractGroupingManualResourceTest.java @@ -170,11 +170,11 @@ public void test220ModifyUserWillDisable() throws Exception { accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(userWillOid, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.DISABLED); // THEN - then(TEST_NAME); + then(); display("result", result); willLastCaseOid = assertInProgress(result); @@ -258,11 +258,11 @@ public void test230ModifyAccountWillChangePasswordAndEnable() throws Exception { accountWillSecondReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); executeChanges(delta, null, task, result); // THEN - then(TEST_NAME); + then(); display("result", result); assertInProgress(result); @@ -341,11 +341,11 @@ public void test232RunPropagationBeforeInterval() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); runPropagation(); // THEN - then(TEST_NAME); + then(); assertAccountWillAfterChangePasswordAndEnable(TEST_NAME); } @@ -366,11 +366,11 @@ public void test235RunPropagationAfterInterval() throws Exception { accountWillExecutionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); runPropagation(); // THEN - then(TEST_NAME); + then(); accountWillExecutionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -473,12 +473,12 @@ public void test240CloseCaseAndReadAccountWill() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); PrismObject shadowModel = modelService.getObject(ShadowType.class, accountWillOid, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); accountWillCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -503,11 +503,11 @@ public void test250RecomputeWillAfter5min() throws Exception { display("Shadow before", shadowBefore); // WHEN - when(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertAccountWillAfterChangePasswordAndEnableCaseClosed(TEST_NAME, null); @@ -530,12 +530,12 @@ public void test272UpdateBackingStoreAndGetAccountWill() throws Exception { backingStoreUpdateWill(USER_WILL_FULL_NAME_PIRATE, INTEREST_ONE, ActivationStatusType.ENABLED, USER_WILL_PASSWORD_NEW); // WHEN - when(TEST_NAME); + when(); PrismObject shadowModel = modelService.getObject(ShadowType.class, accountWillOid, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); ShadowAsserter shadowModelAsserter = ShadowAsserter.forShadow(shadowModel, "model") @@ -585,12 +585,12 @@ public void test273GetAccountWill() throws Exception { clockForward("PT15M"); // WHEN - when(TEST_NAME); + when(); PrismObject shadowModel = modelService.getObject(ShadowType.class, accountWillOid, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); ShadowAsserter shadowModelAsserter = ShadowAsserter.forShadow(shadowModel, "model") @@ -639,11 +639,11 @@ public void test290RecomputeWillAfter15min() throws Exception { clockForward("PT15M"); // WHEN - when(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = repositoryService.getObject(ShadowType.class, accountWillOid, null, result); @@ -698,11 +698,11 @@ public void test300UnassignAccountWill() throws Exception { accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); unassignRole(userWillOid, getRoleOneOid(), task, result); // THEN - then(TEST_NAME); + then(); display("result", result); willLastCaseOid = assertInProgress(result); @@ -775,11 +775,11 @@ public void test302RunPropagationAfterInterval() throws Exception { accountWillExecutionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); runPropagation(); // THEN - then(TEST_NAME); + then(); accountWillExecutionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -850,12 +850,12 @@ public void test310CloseCaseAndRecomputeWill() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); // We need reconcile and not recompute here. We need to fetch the updated case status. reconcileUser(userWillOid, task, result); // THEN - then(TEST_NAME); + then(); display("result", result); assertSuccess(result); @@ -900,11 +900,11 @@ public void test330UpdateBackingStoreAndRecomputeWill() throws Exception { displayBackingStore(); // WHEN - when(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = repositoryService.getObject(ShadowType.class, accountWillOid, null, result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractManualResourceTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractManualResourceTest.java index d28acdaf035..271fe7c6c52 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractManualResourceTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractManualResourceTest.java @@ -318,11 +318,11 @@ public void testConnection(final String TEST_NAME, boolean initialized) throws E } // WHEN - when(TEST_NAME); + when(); OperationResult testResult = modelService.testResource(getResourceOid(), task); // THEN - then(TEST_NAME); + then(); display("Test result", testResult); TestUtil.assertSuccess("Test resource failed (result)", testResult); @@ -500,19 +500,19 @@ public void testResourceCaching(final String TEST_NAME) throws Exception { assertSteadyResources(); // WHEN - when(TEST_NAME); + when(); PrismObject resourceReadOnlyAgain = modelService.getObject( ResourceType.class, getResourceOid(), GetOperationOptions.createReadOnlyCollection(), task, result); assertSteadyResources(); // WHEN - when(TEST_NAME); + when(); PrismObject resourceAgain = modelService.getObject( ResourceType.class, getResourceOid(), null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); // assertTrue("Resource instance changed", resourceBefore == resourceReadOnlyAgain); @@ -531,11 +531,11 @@ public void test020ReimportResource() throws Exception { options.setOverwrite(true); // WHEN - when(TEST_NAME); + when(); modelService.importObjectsFromFile(getResourceFile(), options, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); } @@ -571,11 +571,11 @@ public void test030ReimportResourceAgain() throws Exception { options.setOverwrite(true); // WHEN - when(TEST_NAME); + when(); modelService.importObjectsFromFile(getResourceFile(), options, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); } @@ -590,11 +590,11 @@ public void test032UseResource() throws Exception { ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(getResourceOid(), ShadowKindType.ACCOUNT, null, prismContext); // WHEN - when(TEST_NAME); + when(); SearchResultList> accounts = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("Found accounts", accounts); @@ -682,11 +682,11 @@ public void test101GetAccountWillFuture() throws Exception { Collection> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); // WHEN - when(TEST_NAME); + when(); PrismObject shadowModel = modelService.getObject(ShadowType.class, accountWillOid, options, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("Model shadow", shadowModel); @@ -713,11 +713,11 @@ public void test102RecomputeWill() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertAccountWillAfterAssign(TEST_NAME, USER_WILL_FULL_NAME, PendingOperationExecutionStatusType.EXECUTION_PENDING); @@ -738,11 +738,11 @@ public void test103RunPropagation() throws Exception { clockForward("PT2M"); // WHEN - when(TEST_NAME); + when(); runPropagation(); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertCounterIncrement(InternalCounters.CONNECTOR_MODIFICATION_COUNT, 1); @@ -763,11 +763,11 @@ public void test104RecomputeWill() throws Exception { rememberCounter(InternalCounters.CONNECTOR_MODIFICATION_COUNT); // WHEN - when(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertCounterIncrement(InternalCounters.CONNECTOR_MODIFICATION_COUNT, 0); @@ -788,11 +788,11 @@ public void test105RunPropagationAgain() throws Exception { rememberCounter(InternalCounters.CONNECTOR_MODIFICATION_COUNT); // WHEN - when(TEST_NAME); + when(); runPropagation(); // THEN - then(TEST_NAME); + then(); assertCounterIncrement(InternalCounters.CONNECTOR_MODIFICATION_COUNT, 0); assertAccountWillAfterAssign(TEST_NAME, USER_WILL_FULL_NAME, PendingOperationExecutionStatusType.EXECUTING); @@ -815,11 +815,11 @@ public void test106AddToBackingStoreAndGetAccountWill() throws Exception { displayBackingStore(); // WHEN - when(TEST_NAME); + when(); PrismObject shadowModel = modelService.getObject(ShadowType.class, accountWillOid, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("Model shadow", shadowModel); @@ -858,11 +858,11 @@ public void test108GetAccountWillFuture() throws Exception { Collection> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); // WHEN - when(TEST_NAME); + when(); PrismObject shadowModel = modelService.getObject(ShadowType.class, accountWillOid, options, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("Model shadow", shadowModel); @@ -907,12 +907,12 @@ public void test110CloseCaseAndRecomputeWill() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); // We need reconcile and not recompute here. We need to fetch the updated case status. reconcileUser(userWillOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); accountWillCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -934,11 +934,11 @@ public void test114RunPropagation() throws Exception { rememberCounter(InternalCounters.CONNECTOR_MODIFICATION_COUNT); // WHEN - when(TEST_NAME); + when(); runPropagation(); // THEN - then(TEST_NAME); + then(); assertCounterIncrement(InternalCounters.CONNECTOR_MODIFICATION_COUNT, 0); assertWillAfterCreateCaseClosed(TEST_NAME, true); @@ -959,11 +959,11 @@ public void test120RecomputeWillAfter5min() throws Exception { clockForward("PT5M"); // WHEN - when(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertRepoShadow(accountWillOid) @@ -1001,11 +1001,11 @@ public void test130RecomputeWillAfter25min() throws Exception { clockForward("PT20M"); // WHEN - when(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertRepoShadow(accountWillOid) @@ -1043,11 +1043,11 @@ public void test132RecomputeWillAfter32min() throws Exception { clockForward("PT7M"); // WHEN - when(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertRepoShadow(accountWillOid) @@ -1078,11 +1078,11 @@ public void test200ModifyUserWillFullname() throws Exception { accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(userWillOid, UserType.F_FULL_NAME, task, result, createPolyString(USER_WILL_FULL_NAME_PIRATE)); // THEN - then(TEST_NAME); + then(); display("result", result); willLastCaseOid = assertInProgress(result); @@ -1101,11 +1101,11 @@ public void test202RecomputeWill() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertAccountWillAfterFullNameModification(TEST_NAME, PendingOperationExecutionStatusType.EXECUTION_PENDING); @@ -1121,11 +1121,11 @@ public void test203RunPropagation() throws Exception { clockForward("PT2M"); // WHEN - when(TEST_NAME); + when(); runPropagation(); // THEN - then(TEST_NAME); + then(); assertAccountWillAfterFullNameModification(TEST_NAME, PendingOperationExecutionStatusType.EXECUTING); @@ -1140,11 +1140,11 @@ public void test204RecomputeWill() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertAccountWillAfterFullNameModification(TEST_NAME, PendingOperationExecutionStatusType.EXECUTING); @@ -1167,11 +1167,11 @@ public void test206CloseCaseAndRecomputeWill() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); accountWillCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -1242,11 +1242,11 @@ public void test210RecomputeWillAfter5min() throws Exception { clockForward("PT5M"); // WHEN - when(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = repositoryService.getObject(ShadowType.class, accountWillOid, null, result); @@ -1301,12 +1301,12 @@ public void test212UpdateBackingStoreAndGetAccountWill() throws Exception { backingStoreUpdateWill(USER_WILL_FULL_NAME_PIRATE, INTEREST_ONE, ActivationStatusType.ENABLED, USER_WILL_PASSWORD_OLD); // WHEN - when(TEST_NAME); + when(); PrismObject shadowModel = modelService.getObject(ShadowType.class, accountWillOid, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertShadowActivationAdministrativeStatus(shadowModel, ActivationStatusType.ENABLED); @@ -1362,11 +1362,11 @@ public void test400PhantomAccount() throws Exception { setupPhantom(); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_PHANTOM_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); // This should theoretically always return IN_PROGRESS, as there is // reconciliation operation going on. But due to various "peculiarities" @@ -1378,11 +1378,11 @@ public void test400PhantomAccount() throws Exception { } // WHEN - when(TEST_NAME); + when(); runPropagation(); // THEN - then(TEST_NAME); + then(); PrismObject userAfter = getUser(USER_PHANTOM_OID); display("User after", userAfter); @@ -1435,22 +1435,22 @@ public void test410AssignPhoenixAccount() throws Exception { addObject(USER_PHOENIX_FILE); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_PHOENIX_OID, getResourceOid(), null, task, result); // THEN - then(TEST_NAME); + then(); assertInProgress(result); // Make sure the operation will be picked up by propagation task clockForward("PT3M"); // WHEN - when(TEST_NAME); + when(); runPropagation(); // THEN - then(TEST_NAME); + then(); PrismObject userAfter = getUser(USER_PHOENIX_OID); display("User after", userAfter); @@ -1482,11 +1482,11 @@ public void test412AddPhoenixToBackingStoreAndCloseTicket() throws Exception { closeCase(phoenixLastCaseOid); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_PHOENIX_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_PHOENIX_OID); @@ -1519,11 +1519,11 @@ public void test413PhoenixLetOperationsExpire() throws Exception { clockForward("PT1H"); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_PHOENIX_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_PHOENIX_OID); @@ -1554,22 +1554,22 @@ public void test414UnassignPhoenixAccount() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignAccountFromUser(USER_PHOENIX_OID, getResourceOid(), null, task, result); // THEN - then(TEST_NAME); + then(); assertInProgress(result); // Make sure the operation will be picked up by propagation task clockForward("PT3M"); // WHEN - when(TEST_NAME); + when(); runPropagation(); // THEN - then(TEST_NAME); + then(); PrismObject userAfter = getUser(USER_PHOENIX_OID); display("User after", userAfter); @@ -1599,22 +1599,22 @@ public void test416PhoenixAccountUnassignCloseCase() throws Exception { closeCase(phoenixLastCaseOid); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_PHOENIX_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); // Make sure the operation will be picked up by propagation task clockForward("PT3M"); // WHEN - when(TEST_NAME); + when(); runPropagation(); // THEN - then(TEST_NAME); + then(); PrismObject userAfter = getUser(USER_PHOENIX_OID); display("User after", userAfter); @@ -1644,22 +1644,22 @@ public void test418AssignPhoenixAccountAgain() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_PHOENIX_OID, getResourceOid(), null, task, result); // THEN - then(TEST_NAME); + then(); phoenixLastCaseOid = assertInProgress(result); // Make sure the operation will be picked up by propagation task clockForward("PT3M"); // WHEN - when(TEST_NAME); + when(); runPropagation(); // THEN - then(TEST_NAME); + then(); PrismObject userAfter = getUser(USER_PHOENIX_OID); display("User after", userAfter); @@ -1789,7 +1789,7 @@ public void test910ConcurrentRolesAssign() throws Exception { final long TIMEOUT = 60000L; // WHEN - when(TEST_NAME); + when(); ParallelTestThread[] threads = multithread( (i) -> { @@ -1801,7 +1801,7 @@ public void test910ConcurrentRolesAssign() throws Exception { }, getConcurrentTestNumberOfThreads(), getConcurrentTestRandomStartDelayRangeAssign()); // THEN - then(TEST_NAME); + then(); waitForThreads(threads, TIMEOUT); PrismObject userAfter = getUser(USER_DRAKE_OID); @@ -1867,7 +1867,7 @@ public void test919ConcurrentRoleUnassign() throws Exception { final long TIMEOUT = 60000L; // WHEN - when(TEST_NAME); + when(); ParallelTestThread[] threads = multithread( (i) -> { @@ -1885,7 +1885,7 @@ public void test919ConcurrentRoleUnassign() throws Exception { }, getConcurrentTestNumberOfThreads(), getConcurrentTestRandomStartDelayRangeUnassign()); // THEN - then(TEST_NAME); + then(); waitForThreads(threads, TIMEOUT); PrismObject userAfter = getUser(USER_DRAKE_OID); @@ -2058,11 +2058,11 @@ protected void assignWillRoleOne(final String TEST_NAME, String expectedFullName accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); assignRole(userWillOid, getRoleOneOid(), task, result); // THEN - then(TEST_NAME); + then(); display("result", result); willLastCaseOid = assertInProgress(result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestDummyItsmIntegration.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestDummyItsmIntegration.java index 3a0ca88ecf2..7c530853a82 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestDummyItsmIntegration.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestDummyItsmIntegration.java @@ -125,11 +125,11 @@ public void test012TestConnection() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); OperationResult testResult = modelService.testResource(RESOURCE_DUMMY_ITSM_OID, task); // THEN - then(TEST_NAME); + then(); display("Test result", testResult); TestUtil.assertSuccess("Test resource failed (result)", testResult); @@ -153,11 +153,11 @@ public void test100AssignAccountToJack() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_ITSM_OID, null, task, result); // THEN - then(TEST_NAME); + then(); display("result", result); jackLastTicketIdentifier = assertInProgress(result); @@ -184,11 +184,11 @@ public void test102CloseTicketAndRecomputeJack() throws Exception { closeDummyTicket(jackLastTicketIdentifier); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -208,11 +208,11 @@ public void test104UnassignAccountFromJack() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_ITSM_OID, null, task, result); // THEN - then(TEST_NAME); + then(); display("result", result); jackLastTicketIdentifier = assertInProgress(result); @@ -242,11 +242,11 @@ public void test108CloseTicketAndRecomputeJack() throws Exception { dumpItsm(); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -276,11 +276,11 @@ public void test109LetItExpire() throws Exception { clockForward("PT3H"); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -300,11 +300,11 @@ public void test110AssignItsmAccountToJackCommunicationError() throws Exception DummyItsm.getInstance().setFailureClass(CommunicationException.class); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_ITSM_OID, null, task, result); // THEN - then(TEST_NAME); + then(); DummyItsm.getInstance().clearFailureClass(); assertInProgress(result); @@ -341,12 +341,12 @@ public void test111ReconcileJackFixed() throws Exception { display("Repo shadow before", shadowRepoBefore); // WHEN - when(TEST_NAME); + when(); // This in fact should be a call to reconcile, not refresh directly (TODO: MID-4542) provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - then(TEST_NAME); + then(); display("result", result); jackLastTicketIdentifier = assertInProgress(result); @@ -380,11 +380,11 @@ public void test112CloseTicketAndRecomputeJackCommunicationError() throws Except DummyItsm.getInstance().setFailureClass(CommunicationException.class); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); DummyItsm.getInstance().clearFailureClass(); assertPartialError(result); @@ -416,11 +416,11 @@ public void test113RecomputeJackFixed() throws Exception { DummyItsm.getInstance().clearFailureClass(); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -450,11 +450,11 @@ public void test114UnassignAccountFromJackCommunicationError() throws Exception DummyItsm.getInstance().setFailureClass(CommunicationException.class); // WHEN - when(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_ITSM_OID, null, task, result); // THEN - then(TEST_NAME); + then(); display("result", result); DummyItsm.getInstance().clearFailureClass(); assertResultStatus(result, OperationResultStatus.IN_PROGRESS); @@ -507,12 +507,12 @@ public void test115ReconcileJackFixed() throws Exception { display("Repo shadow before", shadowRepoBefore); // WHEN - when(TEST_NAME); + when(); // This in fact should be a call to reconcile, not refresh directly (TODO: MID-4542) provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - then(TEST_NAME); + then(); display("result", result); jackLastTicketIdentifier = assertInProgress(result); @@ -547,11 +547,11 @@ public void test117CloseTicketAndRecomputeJackCommunicationError() throws Except DummyItsm.getInstance().setFailureClass(CommunicationException.class); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); DummyItsm.getInstance().clearFailureClass(); assertPartialError(result); @@ -586,12 +586,12 @@ public void test118RecomputeJackFixed() throws Exception { display("Repo shadow before", shadowRepoBefore); // WHEN - when(TEST_NAME); + when(); // This in fact should be a call to reconcile, not refresh directly (TODO: MID-4542) provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -624,11 +624,11 @@ public void test119LetItExpire() throws Exception { clockForward("PT3H"); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManual.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManual.java index 4b644fa1207..bb63a51ae4b 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManual.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManual.java @@ -134,11 +134,11 @@ public void test700AssignAccountJackExisting() throws Exception { accountJackReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, getResourceOid(), null, task, result); // THEN - then(TEST_NAME); + then(); display("result", result); assertSuccess(result, 2); assertNull("Unexpected ticket in result", result.getAsynchronousOperationReference()); @@ -185,11 +185,11 @@ public void test710UnassignAccountJack() throws Exception { accountJackReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, getResourceOid(), null, task, result); // THEN - then(TEST_NAME); + then(); display("result", result); jackLastCaseOid = assertInProgress(result); @@ -242,12 +242,12 @@ public void test712CloseCaseAndRecomputeJack() throws Exception { accountJackCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); // We need reconcile and not recompute here. We need to fetch the updated case status. reconcileUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); display("result", result); assertSuccess(result); @@ -295,12 +295,12 @@ public void test717RecomputeJackAfter130min() throws Exception { clock.overrideDuration("PT130M"); // WHEN - when(TEST_NAME); + when(); // We need reconcile and not recompute here. We need to fetch the updated case status. reconcileUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); display("result", result); assertSuccess(result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGroupingProposed.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGroupingProposed.java index 67ba3cfe7c5..bbff1af65b9 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGroupingProposed.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGroupingProposed.java @@ -128,11 +128,11 @@ public void test500AssignBigmouthRoleOne() throws Exception { display("User before", userBefore); // WHEN - when(TEST_NAME); + when(); assignRole(userBigmouthOid, getRoleOneOid(), task, result); // THEN - then(TEST_NAME); + then(); display("result", result); bigmouthLastCaseOid = assertInProgress(result); @@ -182,11 +182,11 @@ public void test502RunPropagation() throws Exception { clockForward("PT20M"); // WHEN - when(TEST_NAME); + when(); runPropagation(); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PendingOperationExecutionStatusType executionStage = PendingOperationExecutionStatusType.EXECUTING; diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingAutoInbound.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingAutoInbound.java index 878f66eb00b..9dded5516b8 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingAutoInbound.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingAutoInbound.java @@ -78,18 +78,18 @@ public void test100ImportFromResource() throws Exception { assertUsers(getNumberOfUsers()); // WHEN - when(TEST_NAME); + when(); modelService.importFromResource(RESOURCE_DUMMY_AUTOGREEN_OID, new QName(MidPointConstants.NS_RI, SchemaConstants.ACCOUNT_OBJECT_CLASS_LOCAL_NAME), task, result); // THEN - then(TEST_NAME); + then(); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); waitForTaskFinish(task, true, 40000); // THEN - then(TEST_NAME); + then(); assertSuccess(task.getResult()); SearchResultList> users = modelService.searchObjects(UserType.class, null, null, task, result); @@ -121,11 +121,11 @@ public void test110ModifyAccountTitleCraticAndReconcile() throws Exception { accountHerman.replaceAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "cratic"); // WHEN - when(TEST_NAME); + when(); reconcileUser(userHermanOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(userHermanOid); @@ -149,11 +149,11 @@ public void test112ModifyAccountTitleDidacticGraphicAndReconcile() throws Except accountHerman.replaceAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "didactic", "graphic"); // WHEN - when(TEST_NAME); + when(); reconcileUser(userHermanOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(userHermanOid); @@ -187,18 +187,18 @@ public void test200ImportFromResourceAssociations() throws Exception { dummyGroup.addMember(USER_HERMAN_USERNAME); // WHEN - when(TEST_NAME); + when(); modelService.importFromResource(RESOURCE_DUMMY_AUTOGREEN_OID, new QName(MidPointConstants.NS_RI, "AccountObjectClass"), task, result); // THEN - then(TEST_NAME); + then(); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); waitForTaskFinish(task, true, 40000); // THEN - then(TEST_NAME); + then(); assertSuccess(task.getResult()); SearchResultList> users = modelService.searchObjects(UserType.class, null, null, task, result); @@ -226,12 +226,12 @@ public void test300ModifyAccountDirectAssign() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(userHermanOid, ROLE_ADMINS_OID); reconcileUser(userHermanOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(userHermanOid); @@ -264,18 +264,18 @@ public void test301removeUserFromAutoGroup() throws Exception { // WHEN - when(TEST_NAME); + when(); modelService.importFromResource(RESOURCE_DUMMY_AUTOGREEN_OID, new QName(MidPointConstants.NS_RI, "AccountObjectClass"), task, result); // THEN - then(TEST_NAME); + then(); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); waitForTaskFinish(task, true, 70000); // THEN - then(TEST_NAME); + then(); assertSuccess(task.getResult()); PrismObject userAfter = getUser(userHermanOid); @@ -307,11 +307,11 @@ public void test402assignAutoGroupDirectly() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(userHermanOid, ROLE_AUTOCRATIC_OID); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertDummyGroupMember(RESOURCE_DUMMY_AUTOGREEN_NAME, GROUP_DUMMY_TESTERS_NAME, USER_HERMAN_USERNAME); @@ -340,11 +340,11 @@ public void test403removeAllAssignments() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignRole(userHermanOid, ROLE_ADMINS_OID); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(userHermanOid); @@ -371,18 +371,18 @@ public void test404importAssociationAutotesters() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modelService.importFromResource(RESOURCE_DUMMY_AUTOGREEN_OID, new QName(MidPointConstants.NS_RI, "AccountObjectClass"), task, result); // THEN - then(TEST_NAME); + then(); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); waitForTaskFinish(task, true, 40000); // THEN - then(TEST_NAME); + then(); assertSuccess(task.getResult()); PrismObject userAfter = getUser(userHermanOid); @@ -401,11 +401,11 @@ public void test405assignRoleAutocraticDirectly() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(userHermanOid, ROLE_AUTOCRATIC_OID); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(userHermanOid); @@ -429,11 +429,11 @@ public void test406unassignRoleAutocraticDirectly() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignRole(userHermanOid, ROLE_AUTOCRATIC_OID); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(userHermanOid); @@ -460,11 +460,11 @@ public void test407addHermanToTestersReconcile() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); reconcileUser(userHermanOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(task.getResult()); PrismObject userAfter = getUser(userHermanOid); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingInbound.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingInbound.java index a68a563bd79..7ee0521a493 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingInbound.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingInbound.java @@ -97,11 +97,11 @@ public void test010SanitySchema() throws Exception { Task task = getTestTask(); /// WHEN - when(TEST_NAME); + when(); OperationResult testResult = modelService.testResource(RESOURCE_DUMMY_TEA_GREEN_OID, task); // THEN - then(TEST_NAME); + then(); TestUtil.assertSuccess(testResult); ResourceType resourceType = getDummyResourceType(RESOURCE_DUMMY_TEA_GREEN_NAME); @@ -125,11 +125,11 @@ public void test100ImportLiveSyncTaskDummyTeaGreen() throws Exception { OperationResult result = task.getResult(); /// WHEN - when(TEST_NAME); + when(); importSyncTask(); // THEN - then(TEST_NAME); + then(); waitForSyncTaskStart(); } @@ -153,14 +153,14 @@ public void test110AddDummyTeaGreenAccountMancomb() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, "water"); /// WHEN - when(TEST_NAME); + when(); getDummyResource(RESOURCE_DUMMY_TEA_GREEN_NAME).addAccount(account); waitForSyncTaskNextRun(); // THEN - then(TEST_NAME); + then(); PrismObject accountMancomb = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, getDummyResourceObject(RESOURCE_DUMMY_TEA_GREEN_NAME)); display("Account mancomb", accountMancomb); @@ -204,7 +204,7 @@ public void test120ModifyMancombPhotoSource() throws Exception { OperationResult result = task.getResult(); /// WHEN - when(TEST_NAME); + when(); DummyAccount account = getDummyResource(RESOURCE_DUMMY_TEA_GREEN_NAME) .getAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME); @@ -215,7 +215,7 @@ public void test120ModifyMancombPhotoSource() throws Exception { waitForSyncTaskNextRun(); // THEN - then(TEST_NAME); + then(); PrismObject accountMancomb = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, getDummyResourceObject(RESOURCE_DUMMY_TEA_GREEN_NAME)); display("Account mancomb", accountMancomb); @@ -239,7 +239,7 @@ public void test130ModifyMancombPhotoSourceAndReconcile() throws Exception { OperationResult result = task.getResult(); /// WHEN - when(TEST_NAME); + when(); // stop the task to avoid interference with the reconciliations suspendTask(TASK_LIVE_SYNC_DUMMY_TEA_GREEN_OID); @@ -256,7 +256,7 @@ public void test130ModifyMancombPhotoSourceAndReconcile() throws Exception { reconcileUser(userMancomb.getOid(), task, result); // THEN - then(TEST_NAME); + then(); PrismObject accountMancomb = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, getDummyResourceObject(RESOURCE_DUMMY_TEA_GREEN_NAME)); display("Account mancomb", accountMancomb); @@ -278,7 +278,7 @@ public void test140ModifyMancombPhotoInRepo() throws Exception { OperationResult result = task.getResult(); /// WHEN - when(TEST_NAME); + when(); PrismObject userMancomb = findUserByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME); assertNotNull("User mancomb has disappeared", userMancomb); @@ -289,7 +289,7 @@ public void test140ModifyMancombPhotoInRepo() throws Exception { executeChanges(delta, ModelExecuteOptions.createReconcile(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); @@ -318,7 +318,7 @@ public void test150UserReconcile() throws Exception { //assertUsers(5); /// WHEN - when(TEST_NAME); + when(); PrismObject userMancomb = findUserByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME); assertNotNull("User mancomb has disappeared", userMancomb); @@ -326,7 +326,7 @@ public void test150UserReconcile() throws Exception { reconcileUser(userMancomb.getOid(), task, result); // THEN - then(TEST_NAME); + then(); PrismObject accountMancomb = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, getDummyResourceObject(RESOURCE_DUMMY_TEA_GREEN_NAME)); display("Account mancomb", accountMancomb); @@ -372,7 +372,7 @@ public void test300DeleteDummyTeaGreenAccountMancomb() throws Exception { OperationResult result = task.getResult(); /// WHEN - when(TEST_NAME); + when(); getDummyResource(RESOURCE_DUMMY_TEA_GREEN_NAME).deleteAccountByName(ACCOUNT_MANCOMB_DUMMY_USERNAME); display("Dummy (tea green) resource", getDummyResource(RESOURCE_DUMMY_TEA_GREEN_NAME).debugDump()); @@ -382,7 +382,7 @@ public void test300DeleteDummyTeaGreenAccountMancomb() throws Exception { waitForSyncTaskNextRun(); // THEN - then(TEST_NAME); + then(); assertNoDummyAccount(RESOURCE_DUMMY_TEA_GREEN_NAME, ACCOUNT_MANCOMB_DUMMY_USERNAME); @@ -410,11 +410,11 @@ public void test399DeleteDummyTeaGreenAccountMancomb() throws Exception { OperationResult result = task.getResult(); /// WHEN - when(TEST_NAME); + when(); deleteObject(TaskType.class, TASK_LIVE_SYNC_DUMMY_TEA_GREEN_OID, task, result); // THEN - then(TEST_NAME); + then(); assertNoObject(TaskType.class, TASK_LIVE_SYNC_DUMMY_TEA_GREEN_OID); } @@ -437,7 +437,7 @@ public void test400AddUserLeeloo() throws Exception { getDummyResource(RESOURCE_DUMMY_TEA_GREEN_NAME).addAccount(account); /// WHEN - when(TEST_NAME); + when(); modelService.importFromResource(RESOURCE_DUMMY_TEA_GREEN_OID, new QName(MidPointConstants.NS_RI, SchemaConstants.ACCOUNT_OBJECT_CLASS_LOCAL_NAME), task, result); @@ -446,7 +446,7 @@ public void test400AddUserLeeloo() throws Exception { waitForTaskFinish(task, true); // THEN - then(TEST_NAME); + then(); userLeelooOid = assertUserAfterByUsername(ACCOUNT_LEELOO_USERNAME) .assertFullName(ACCOUNT_LEELOO_FULL_NAME_MULTIPASS) @@ -482,12 +482,12 @@ public void test402UserLeelooRecompute() throws Exception { dummyAuditService.clear(); /// WHEN - when(TEST_NAME); + when(); recomputeUser(userLeelooOid, task, result); // THEN - then(TEST_NAME); + then(); assertUserAfterByUsername(ACCOUNT_LEELOO_USERNAME) .assertFullName(ACCOUNT_LEELOO_FULL_NAME_MULTIPASS) @@ -515,12 +515,12 @@ public void test404UserLeelooReconcile() throws Exception { dummyAuditService.clear(); /// WHEN - when(TEST_NAME); + when(); reconcileUser(userLeelooOid, task, result); // THEN - then(TEST_NAME); + then(); assertUserAfterByUsername(ACCOUNT_LEELOO_USERNAME) .assertFullName(ACCOUNT_LEELOO_FULL_NAME_MULTIPASS) @@ -556,12 +556,12 @@ public void test410UserLeeloominaiReconcile() throws Exception { dummyAuditService.clear(); /// WHEN - when(TEST_NAME); + when(); reconcileUser(userLeelooOid, task, result); // THEN - then(TEST_NAME); + then(); assertUserAfterByUsername(ACCOUNT_LEELOO_USERNAME) .assertFullName(ACCOUNT_LEELOO_FULL_NAME_LEELOOMINAI) @@ -594,12 +594,12 @@ public void test412UserLeeloominaiRecompute() throws Exception { dummyAuditService.clear(); /// WHEN - when(TEST_NAME); + when(); recomputeUser(userLeelooOid, task, result); // THEN - then(TEST_NAME); + then(); assertUserAfterByUsername(ACCOUNT_LEELOO_USERNAME) .assertFullName(ACCOUNT_LEELOO_FULL_NAME_LEELOOMINAI) @@ -627,12 +627,12 @@ public void test414UserLeeloominaiReconcile() throws Exception { dummyAuditService.clear(); /// WHEN - when(TEST_NAME); + when(); reconcileUser(userLeelooOid, task, result); // THEN - then(TEST_NAME); + then(); assertUserAfterByUsername(ACCOUNT_LEELOO_USERNAME) .assertFullName(ACCOUNT_LEELOO_FULL_NAME_LEELOOMINAI) @@ -668,12 +668,12 @@ public void test420UserLeelooStrangeReconcile() throws Exception { dummyAuditService.clear(); /// WHEN - when(TEST_NAME); + when(); reconcileUser(userLeelooOid, task, result); // THEN - then(TEST_NAME); + then(); assertUserAfterByUsername(ACCOUNT_LEELOO_USERNAME) .assertFullName(ACCOUNT_LEELOO_FULL_NAME_LEELOOMINAI) @@ -707,12 +707,12 @@ public void test424UserLeelooStrangeReconcile() throws Exception { dummyAuditService.clear(); /// WHEN - when(TEST_NAME); + when(); reconcileUser(userLeelooOid, task, result); // THEN - then(TEST_NAME); + then(); assertUserAfterByUsername(ACCOUNT_LEELOO_USERNAME) .assertFullName(ACCOUNT_LEELOO_FULL_NAME_LEELOOMINAI) diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestMigration.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestMigration.java index c52aeb6d7ad..482e0c5684a 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestMigration.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestMigration.java @@ -61,11 +61,11 @@ public void test050SanityLost1() throws Exception { final String TEST_NAME = "test050SanityLost1"; // WHEN - when(TEST_NAME); + when(); PrismObject shadowLost1Repo = getShadowRepo(SHADOW_ACCOUNT_DUMMY_LOST1_OID); // THEN - then(TEST_NAME); + then(); assertShadow(shadowLost1Repo, "Repo shadow") .assertPrimaryIdentifierValue(null); @@ -82,12 +82,12 @@ public void test100RefreshTaskDefault() throws Exception { addObject(TASK_SHADOW_REFRESH_FILE); // WHEN - when(TEST_NAME); + when(); waitForTaskStart(TASK_SHADOW_REFRESH_OID, false); waitForTaskFinish(TASK_SHADOW_REFRESH_OID, false); // THEN - then(TEST_NAME); + then(); PrismObject shadowLost1Repo = getShadowRepo(SHADOW_ACCOUNT_DUMMY_LOST1_OID); assertShadow(shadowLost1Repo, "Repo shadow") @@ -106,12 +106,12 @@ public void test110RefreshTaskExplicitDummy() throws Exception { addObject(TASK_SHADOW_REFRESH_EXPLICIT_DUMMY_FILE); // WHEN - when(TEST_NAME); + when(); waitForTaskStart(TASK_SHADOW_REFRESH_EXPLICIT_DUMMY_OID, false); waitForTaskFinish(TASK_SHADOW_REFRESH_EXPLICIT_DUMMY_OID, false); // THEN - then(TEST_NAME); + then(); PrismObject shadowLost1Repo = getShadowRepo(SHADOW_ACCOUNT_DUMMY_LOST1_OID); assertShadow(shadowLost1Repo, "Repo shadow") diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestMisc.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestMisc.java index 09ae4a27cc4..0afde18db71 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestMisc.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestMisc.java @@ -98,11 +98,11 @@ public void test100GetRepositoryDiag() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); RepositoryDiag diag = modelDiagnosticService.getRepositoryDiag(task, result); // THEN - then(TEST_NAME); + then(); display("Diag", diag); assertSuccess(result); @@ -119,11 +119,11 @@ public void test110RepositorySelfTest() throws Exception { Task task = getTestTask(); // WHEN - when(TEST_NAME); + when(); OperationResult testResult = modelDiagnosticService.repositorySelfTest(task); // THEN - then(TEST_NAME); + then(); display("Repository self-test result", testResult); TestUtil.assertSuccess("Repository self-test result", testResult); @@ -139,12 +139,12 @@ public void test200ExportUsers() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); List> users = modelService.searchObjects(UserType.class, null, SelectorOptions.createCollection(GetOperationOptions.createRaw()), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertEquals("Unexpected number of users", 6, users.size()); @@ -187,11 +187,11 @@ public void test210SearchUsersMatchingRulesPolystringNorm() throws Exception { .build(); // WHEN - when(TEST_NAME); + when(); List> users = modelService.searchObjects(UserType.class, query,null , task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertEquals("Unexpected number of users", 1, users.size()); @@ -221,7 +221,7 @@ public void test212SearchUsersMatchingRulesPolystringIgnoreCase() throws Excepti try { // WHEN - when(TEST_NAME); + when(); List> users = modelService.searchObjects(UserType.class, query, null, task, result); } catch (SystemException e) { @@ -249,11 +249,11 @@ public void test214SearchUsersMatchingRulesStringIgnoreCase() throws Exception { .build(); // WHEN - when(TEST_NAME); + when(); List> users = modelService.searchObjects(UserType.class, query,null , task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertEquals("Unexpected number of users", 1, users.size()); @@ -282,11 +282,11 @@ public void test216SearchUsersMatchingRulesStringNorm() throws Exception { .build(); // WHEN - when(TEST_NAME); + when(); List> users = modelService.searchObjects(UserType.class, query,null , task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertEquals("Unexpected number of users", 0, users.size()); @@ -305,11 +305,11 @@ public void test300RecomputeJack() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -329,11 +329,11 @@ public void test302UpdateKeyJack() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, getExtensionPath(PIRACY_KEY), task, result, KEY); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -352,11 +352,11 @@ public void test310AddUserClean() throws Exception { PrismObject userBefore = createUser(USER_CLEAN_NAME, USER_CLEAN_GIVEN_NAME, USER_CLEAN_FAMILY_NAME, true); // WHEN - when(TEST_NAME); + when(); addObject(userBefore, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); userCleanOid = userBefore.getOid(); @@ -378,11 +378,11 @@ public void test312UpdateBinaryIdClean() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(userCleanOid, getExtensionPath(PIRACY_BINARY_ID), task, result, KEY); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(userCleanOid); @@ -401,11 +401,11 @@ public void test320DefaultRelations() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); List relations = modelInteractionService.getRelationDefinitions(); // THEN - then(TEST_NAME); + then(); display("Relations", relations); assertRelationDef(relations, SchemaConstants.ORG_MANAGER, "RelationTypes.manager"); assertRelationDef(relations, SchemaConstants.ORG_OWNER, "RelationTypes.owner"); @@ -424,11 +424,11 @@ public void test400ImportRoleWithFilters() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modelService.importObjectsFromFile(ROLE_IMPORT_FILTERS_FILE, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject roleAfter = getRole(ROLE_IMPORT_FILTERS_OID); @@ -452,11 +452,11 @@ public void test500AddHocProvisioningScriptAssignJackResourceScripty() throws Ex assertAssignments(userBefore, 0); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_SCRIPTY_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -486,11 +486,11 @@ public void test502GetAccountJackResourceScripty() throws Exception { String accountOid = getSingleLinkOid(userBefore); // WHEN - when(TEST_NAME); + when(); PrismObject accountShadow = modelService.getObject(ShadowType.class, accountOid, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertAttribute(accountShadow.asObjectable(), @@ -518,11 +518,11 @@ public void test504GetAccountJackResourceScriptyAgain() throws Exception { String accountOid = getSingleLinkOid(userBefore); // WHEN - when(TEST_NAME); + when(); PrismObject accountShadow = modelService.getObject(ShadowType.class, accountOid, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertAttribute(accountShadow.asObjectable(), @@ -557,12 +557,12 @@ public void test506ModifyResourceGetAccountJackResourceScripty() throws Exceptio display("Resource version before", resourceBefore.getVersion()); // WHEN - when(TEST_NAME); + when(); modifyObjectReplaceProperty(ResourceType.class, RESOURCE_SCRIPTY_OID, ResourceType.F_DESCRIPTION, null, task, result, "Whatever"); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject resourceAfter = getObject(ResourceType.class, RESOURCE_SCRIPTY_OID); @@ -595,11 +595,11 @@ public void test600jackAssignRoleShip() throws Exception { // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_SHIP_OID); //THEN - then(TEST_NAME); + then(); PrismObject userAfter = getUser(USER_JACK_OID); display("User before", userAfter); assertAssignments(userAfter, 2); @@ -626,11 +626,11 @@ public void test601jackUnassignResourceAccount() throws Exception { assertAssignments(userBefore, 2); // WHEN - when(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_SCRIPTY_OID, null); //THEN - then(TEST_NAME); + then(); PrismObject userAfter = getUser(USER_JACK_OID); display("User after", userAfter); assertAssignments(userAfter, 1); @@ -654,11 +654,11 @@ public void test602jackUnssigndRoleShip() throws Exception { // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_SHIP_OID); //THEN - then(TEST_NAME); + then(); PrismObject userAfter = getUser(USER_JACK_OID); display("User before", userAfter); assertAssignments(userAfter, 0); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestUuidNonUniqueName.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestUuidNonUniqueName.java index 35d5ae1f0ed..a29f8f769d0 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestUuidNonUniqueName.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestUuidNonUniqueName.java @@ -72,11 +72,11 @@ public void test010TestResourceConnection() throws Exception { Task task = getTestTask(); // WHEN - when(TEST_NAME); + when(); OperationResult result = modelService.testResource(RESOURCE_DUMMY_UUID_NONUNIQUE_NAME_OID, task); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertResourceAfter(RESOURCE_DUMMY_UUID_NONUNIQUE_NAME_OID) @@ -93,11 +93,11 @@ public void test020RefinedSchema() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); PrismObject resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_UUID_NONUNIQUE_NAME_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertResourceAfter(RESOURCE_DUMMY_UUID_NONUNIQUE_NAME_OID) @@ -127,11 +127,11 @@ public void test100AssignAccountToJackSparrow() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_UUID_NONUNIQUE_NAME_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); accountJackSparrowUid = assertUserAfter(USER_JACK_OID) @@ -163,11 +163,11 @@ public void test102GetAccountJackSparrow() throws Exception { .getOid(); // WHEN - when(TEST_NAME); + when(); PrismObject shadow = modelService.getObject(ShadowType.class, accountJackSparrowOid, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertShadow(shadow, "getObject") @@ -193,11 +193,11 @@ public void test110AssignAccountToJackSkellington() throws Exception { assertEquals(USER_SKELLINGTON_GIVEN_NAME, USER_JACK_GIVEN_NAME); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_SKELLINGTON_OID, RESOURCE_DUMMY_UUID_NONUNIQUE_NAME_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); accountJackSkellingtonUid = assertUserAfter(USER_SKELLINGTON_OID) diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiAccount.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiAccount.java index 0f3ec3aa302..0478db721c0 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiAccount.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiAccount.java @@ -101,11 +101,11 @@ public void test010ImportAccountsFromDummyMultiGreen() throws Exception { assertUsers(getNumberOfUsers()); // WHEN - when(TEST_NAME); + when(); importMultiGreenAccounts(task, result); // THEN - then(TEST_NAME); + then(); // No accounts on multigreen resource yet. No users should be created. assertUsers(getNumberOfUsers()); @@ -134,11 +134,11 @@ public void test020ImportPaulAtreides() throws Exception { assertUsers(getNumberOfUsers()); // WHEN - when(TEST_NAME); + when(); importMultiGreenAccounts(task, result); // THEN - then(TEST_NAME); + then(); accountPaulOid = assertUserAfterByUsername(ACCOUNT_PAUL_ATREIDES_USERNAME) .displayWithProjections() @@ -178,11 +178,11 @@ public void test100ImportMuadDib() throws Exception { assertUsers(getNumberOfUsers() + 1); // WHEN - when(TEST_NAME); + when(); importMultiGreenAccounts(task, result); // THEN - then(TEST_NAME); + then(); accountMuaddibOid = assertUserAfterByUsername(ACCOUNT_PAUL_ATREIDES_USERNAME) .displayWithProjections() @@ -226,11 +226,11 @@ public void test102ReconcileUserPaul() throws Exception { userPaulOid = findUserByUsername(ACCOUNT_PAUL_ATREIDES_USERNAME).getOid(); // WHEN - when(TEST_NAME); + when(); reconcileUser(userPaulOid, task, result); // THEN - then(TEST_NAME); + then(); accountMuaddibOid = assertUserAfter(userPaulOid) .displayWithProjections() @@ -287,11 +287,11 @@ public void test200ImportDuke() throws Exception { assertUsers(getNumberOfUsers() + 1); // WHEN - when(TEST_NAME); + when(); importMultiGreenAccounts(task, result); // THEN - then(TEST_NAME); + then(); accountDukeOid = assertUserAfterByUsername(ACCOUNT_PAUL_ATREIDES_USERNAME) .displayWithProjections() @@ -355,11 +355,11 @@ public void test210ImportMahdi() throws Exception { assertUsers(getNumberOfUsers() + 1); // WHEN - when(TEST_NAME); + when(); importMultiGreenAccounts(task, result); // THEN - then(TEST_NAME); + then(); accountMahdiOid = assertUserAfterByUsername(ACCOUNT_PAUL_ATREIDES_USERNAME) .displayWithProjections() diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestAssignmentErrors.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestAssignmentErrors.java index 93ef24a369e..aac4c28f7c7 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestAssignmentErrors.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestAssignmentErrors.java @@ -218,12 +218,12 @@ public void test101AddUserCharlesAssignBlankAccount() throws Exception { ObjectDelta userDelta = DeltaFactory.Object.createAddDelta(userCharles); // WHEN - when(TEST_NAME); + when(); //we do not expect this to throw an exception. instead the fatal error in the result is excpected Collection> executedChanges = executeChanges(userDelta, null, task, result); // THEN - then(TEST_NAME); + then(); assertFailure(result); // Even though the operation failed the addition of a user should be successful. Let's check if user was really added. @@ -265,12 +265,12 @@ public void test200UserLemonheadAssignAccountBrokenNetwork() throws Exception { dummyAuditService.clear(); // WHEN - when(TEST_NAME); + when(); // not expected that it fails, instead the error in the result is expected modelService.executeChanges(deltas, null, task, result); // THEN - then(TEST_NAME); + then(); display(result); // account cannot be updated due to a network error. The operation was postponed, therefore // it is "in progress". @@ -351,14 +351,14 @@ public void test210UserSharptoothAssignAccountBrokenGeneric() throws Exception { try { // WHEN - when(TEST_NAME); + when(); //not expected that it fails, instead the error in the result is expected modelService.executeChanges(deltas, null, task, result); assertNotReached(); } catch (GenericConnectorException e) { // THEN - then(TEST_NAME); + then(); display("Expected exception", e); } assertFailure(result); @@ -404,11 +404,11 @@ public void test212UserSharptoothAssignAccountRecovery() throws Exception { dummyAuditService.clear(); // WHEN - when(TEST_NAME); + when(); recomputeUser(userSharptoothOid, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -477,11 +477,11 @@ public void testUserSharptoothChangePasswordError(final String TEST_NAME, BreakM dummyAuditService.clear(); // WHEN - when(TEST_NAME); + when(); modifyUserChangePassword(userSharptoothOid, newPassword, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertStatus(result, expectedResultStatus); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestBrokenResources.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestBrokenResources.java index 233bd122a1a..72fff14fd9f 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestBrokenResources.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestBrokenResources.java @@ -819,11 +819,11 @@ public void test400AssignTwoResouresNotFound() throws Exception { ObjectDelta userDelta = createAssignTwoResourcesDelta(RESOURCE_CSVFILE_NOTFOUND_OID); // WHEN - when(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); display("executeChanges result", result); assertPartialError(result); @@ -851,13 +851,13 @@ public void test401AssignTwoResouresBroken() throws Exception { try { // WHEN - when(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); assertNotReached(); } catch (GenericConnectorException e) { // THEN - then(TEST_NAME); + then(); display("Expected exception", e); } @@ -896,11 +896,11 @@ public void test500AssignResourceBlack() throws Exception { assertNoDummyAccount(RESOURCE_DUMMY_BLACK_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_BLACK_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -928,11 +928,11 @@ public void test502ModifyUserEmployeeNumberNone() throws Exception { prepareTest5xx(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_EMPLOYEE_NUMBER, task, result, "none"); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -960,11 +960,11 @@ public void test509UnassignResourceBlack() throws Exception { prepareTest5xx(); // WHEN - when(TEST_NAME); + when(); unassignAccountFromUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_BLACK_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -999,14 +999,14 @@ public void test510AssignResourceBlackError() throws Exception { try { // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_BLACK_OID, null, task, result); assertNotReached(); } catch (GenericConnectorException e) { // THEN - then(TEST_NAME); + then(); display("Expected exception", e); } @@ -1038,11 +1038,11 @@ public void test512ReconcileUser() throws Exception { prepareTest5xx(); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - then(TEST_NAME); + then(); // Errors deep inside the results are expected assertSuccess(result, 2); @@ -1070,14 +1070,14 @@ public void test514ModifyUserEmployeeNumberRuntime() throws Exception { try { // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_EMPLOYEE_NUMBER, task, result, DummyResource.POWERFAIL_ARG_ERROR_RUNTIME); assertNotReached(); } catch (RuntimeException e) { // THEN - then(TEST_NAME); + then(); display("Expected exception", e); assertEquals("Wrong exception message", "Booom! PowerFail script failed (runtime)", e.getMessage()); } @@ -1110,14 +1110,14 @@ public void test518UnassignResourceBlack() throws Exception { try { // WHEN - when(TEST_NAME); + when(); unassignAccountFromUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_BLACK_OID, null, task, result); assertNotReached(); } catch (RuntimeException e) { // THEN - then(TEST_NAME); + then(); display("Expected exception", e); assertEquals("Wrong exception message", "Booom! PowerFail script failed (runtime)", e.getMessage()); } @@ -1150,11 +1150,11 @@ public void test519ReconcileUser() throws Exception { prepareTest5xx(); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1186,11 +1186,11 @@ public void test520AssignResourceEbonyError() throws Exception { assertNoDummyAccount(RESOURCE_DUMMY_EBONY_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_EBONY_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertPartialError(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1220,11 +1220,11 @@ public void test524ModifyUserEmployeeNumberRuntime() throws Exception { prepareTest5xx(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_EMPLOYEE_NUMBER, task, result, DummyResource.POWERFAIL_ARG_ERROR_RUNTIME); // THEN - then(TEST_NAME); + then(); assertPartialError(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1257,11 +1257,11 @@ public void test528UnassignResourceEbony() throws Exception { .assertLinks(1); // WHEN - when(TEST_NAME); + when(); unassignAccountFromUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_EBONY_OID, null, task, result); // THEN - then(TEST_NAME); + then(); display("Result", result); assertPartialError(result); @@ -1305,7 +1305,7 @@ public void test600GuybrushAssignAccountDummyViolet() throws Exception { try { // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_BROKEN_VIOLET_OID, null, task, result); assertNotReached(); @@ -1314,7 +1314,7 @@ public void test600GuybrushAssignAccountDummyViolet() throws Exception { } // THEN - then(TEST_NAME); + then(); assertFailure(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStruct.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStruct.java index 56c55b67d26..c85598f81ba 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStruct.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStruct.java @@ -318,11 +318,11 @@ public void test208JackUnassignAll() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignAllReplace(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userJack = getUser(USER_JACK_OID); @@ -567,11 +567,11 @@ public void test230JackRecompute() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertRefs23x(); @@ -596,11 +596,11 @@ public void test232JackDestroyRefsAndRecompute() throws Exception { rememberCounter(InternalCounters.CONNECTOR_OPERATION_COUNT); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, ModelExecuteOptions.createReconcile(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertRefs23x(); @@ -638,11 +638,11 @@ public void test234JackDestroyRefsAndLightRecompute() throws Exception { options.setReconcileFocus(true); // WHEN - when(TEST_NAME); + when(); modelService.recompute(UserType.class, USER_JACK_OID, options, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertRefs23x(); @@ -692,11 +692,11 @@ public void test300JackUnassignAllOrgs() throws Exception { .createModifyDelta(USER_JACK_OID, modifications, UserType.class); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(userDelta), null, task, result); // THEN - then(TEST_NAME); + then(); PrismObject userJack = getUser(USER_JACK_OID); display("User jack after", userJack); assertAssignedNoOrg(userJack); @@ -865,13 +865,13 @@ public void test310JackConflictParentOrgRefAndAssignmentsAddOrg() throws Excepti try { // WHEN - when(TEST_NAME); + when(); addObject(orgBefore, task, result); assertNotReached(); } catch (PolicyViolationException e) { // THEN - then(TEST_NAME); + then(); display("Expected exception", e); assertFailure(result); } @@ -1457,11 +1457,11 @@ public void test425JackUnassignDeletedOrg() throws Exception { deleteObject(OrgType.class, ORG_TEMP_OID, task, result); // WHEN - when(TEST_NAME); + when(); unassignOrg(USER_JACK_OID, ORG_TEMP_OID, task, result); // THEN - then(TEST_NAME); + then(); display("result", result); result.computeStatus(); TestUtil.assertSuccess(result, 1); @@ -1632,11 +1632,11 @@ public void test440JackModifyEmployeeTypeRolePirate() throws Exception { assertNoAssignments(userBefore); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_SUBTYPE, task, result, "ROLE:Pirate"); // THEN - then(TEST_NAME); + then(); PrismObject userAfter = getUser(USER_JACK_OID); display("User after", userAfter); assertAssignments(userAfter, 1); @@ -1769,11 +1769,11 @@ public void test510JackEndPirate() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modifyUserChangePassword(USER_JACK_OID, "X.marks.the.SPOT", task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/AbstractPersonaTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/AbstractPersonaTest.java index 63b4e41e6a4..0d55ea714ea 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/AbstractPersonaTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/AbstractPersonaTest.java @@ -64,11 +64,11 @@ public void test100AssignRolePersonaAdminToJack() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_PERSONA_ADMIN_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -100,11 +100,11 @@ public void test102RecomputeUserJack() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserJack11x(); @@ -119,11 +119,11 @@ public void test103ReconcileUserJack() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserJack11x(); @@ -138,11 +138,11 @@ public void test104RecomputeJackAdminPersona() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); recomputeUser(userJackAdminPersonaOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserJack11x(); @@ -157,11 +157,11 @@ public void test105ReconcileJackAdminPersona() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); reconcileUser(userJackAdminPersonaOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserJack11x(); @@ -193,11 +193,11 @@ public void test120ModifyJackGivenName() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_GIVEN_NAME, task, result, createPolyString(USER_JACK_GIVEN_NAME_NEW)); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -232,11 +232,11 @@ public void test140ModifyUserJackPassword() throws Exception { XMLGregorianCalendar startCal = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); modifyUserChangePassword(USER_JACK_OID, USER_PASSWORD_2_CLEAR, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -269,11 +269,11 @@ public void test142ModifyPersonaPassword() throws Exception { XMLGregorianCalendar startCal = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); modifyUserChangePassword(personaBefore.getOid(), USER_PASSWORD_3_CLEAR, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -309,11 +309,11 @@ public void test145ModifyPersonaPasswordBack() throws Exception { XMLGregorianCalendar startCal = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); modifyUserChangePassword(personaBefore.getOid(), USER_PASSWORD_2_CLEAR, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -344,11 +344,11 @@ public void test199UnassignRolePersonaAdminFromJack() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_PERSONA_ADMIN_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/TestPersonaPassword.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/TestPersonaPassword.java index 41cb92f31c7..cdeb66a56fe 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/TestPersonaPassword.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/TestPersonaPassword.java @@ -82,7 +82,7 @@ public void test145ModifyPersonaPasswordBack() throws Exception { try { // WHEN - when(TEST_NAME); + when(); modifyUserChangePassword(personaBefore.getOid(), USER_PASSWORD_2_CLEAR, task, result); @@ -93,7 +93,7 @@ public void test145ModifyPersonaPasswordBack() throws Exception { } // THEN - then(TEST_NAME); + then(); assertFailure(result); XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestAssignmentValidity.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestAssignmentValidity.java index 80283c31490..72cbcf99b77 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestAssignmentValidity.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestAssignmentValidity.java @@ -63,11 +63,11 @@ public void test100JackAssignRolePirateValidTo() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, activationType, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -97,11 +97,11 @@ public void test102Forward15min() throws Exception { clockForward("PT15M"); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -131,11 +131,11 @@ public void test104JackAssignRolePirateAgain() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -161,11 +161,11 @@ public void test106JackUnassignRolePirateValid() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -208,12 +208,12 @@ public void test110JackAssignRolePirateValidToRaw() throws Exception { ModelExecuteOptions options = ModelExecuteOptions.createRaw(); // WHEN - when(TEST_NAME); + when(); modifyUserAssignment(USER_JACK_OID, ROLE_PIRATE_OID, RoleType.COMPLEX_TYPE, null, task, null, activationType, true, options, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -241,11 +241,11 @@ public void test111RecomputeJack() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -273,11 +273,11 @@ public void test112Forward15min() throws Exception { clockForward("PT15M"); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -307,11 +307,11 @@ public void test114JackAssignRolePirateAgain() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -354,11 +354,11 @@ public void test120JackAssignRoleSailorValidTo() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, activationType, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -388,11 +388,11 @@ public void test122Forward15min() throws Exception { clockForward("PT15M"); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -422,11 +422,11 @@ public void test124JackAssignRoleSailorAgain() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -470,12 +470,12 @@ public void test130JackAssignRoleSailorValidToRaw() throws Exception { ModelExecuteOptions options = ModelExecuteOptions.createRaw(); // WHEN - when(TEST_NAME); + when(); modifyUserAssignment(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, RoleType.COMPLEX_TYPE, null, task, null, activationType, true, options, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -503,11 +503,11 @@ public void test131RecomputeJack() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -535,11 +535,11 @@ public void test132Forward15min() throws Exception { clockForward("PT15M"); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -569,11 +569,11 @@ public void test134JackAssignRoleSailorAgain() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -617,12 +617,12 @@ public void test140JackAssignRoleSailorValidToRaw() throws Exception { ModelExecuteOptions options = ModelExecuteOptions.createRaw(); // WHEN - when(TEST_NAME); + when(); modifyUserAssignment(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, RoleType.COMPLEX_TYPE, null, task, null, activationType, true, options, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -647,12 +647,12 @@ public void test142Forward15min() throws Exception { Task task = getTestTask(); // WHEN - when(TEST_NAME); + when(); clockForward("PT15M"); // do NOT recompute // THEN - then(TEST_NAME); + then(); PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); @@ -681,11 +681,11 @@ public void test144JackAssignRoleSailorAgain() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -721,11 +721,11 @@ public void test150JackAssignRolePirate() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -760,11 +760,11 @@ public void test151JackAssignRoleSailorValidTo() throws Exception { activationType.setValidTo(jackPirateValidTo); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, activationType, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -796,11 +796,11 @@ public void test153Forward15min() throws Exception { clockForward("PT15M"); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -830,11 +830,11 @@ public void test154JackAssignRoleSailorAgain() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -868,11 +868,11 @@ public void test160JackAssignRolePirate() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -908,12 +908,12 @@ public void test161JackAssignRoleSailorValidToRaw() throws Exception { ModelExecuteOptions options = ModelExecuteOptions.createRaw(); // WHEN - when(TEST_NAME); + when(); modifyUserAssignment(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, RoleType.COMPLEX_TYPE, null, task, null, activationType, true, options, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -951,11 +951,11 @@ public void test162RecomputeJack() throws Exception { activationType.setValidTo(jackPirateValidTo); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -987,11 +987,11 @@ public void test163Forward15min() throws Exception { clockForward("PT15M"); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1021,11 +1021,11 @@ public void test164JackAssignRoleSailorAgain() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1059,11 +1059,11 @@ public void test170JackAssignRolePirate() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1097,11 +1097,11 @@ public void test171JackAssignRoleWeakSingerValidTo() throws Exception { activationType.setValidTo(jackPirateValidTo); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_WEAK_SINGER_OID, activationType, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1133,11 +1133,11 @@ public void test173Forward15min() throws Exception { clockForward("PT15M"); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1168,11 +1168,11 @@ public void test174JackAssignRoleSingerAgain() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_WEAK_SINGER_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1211,12 +1211,12 @@ public void test180JackAssignRoleSailorValidToRaw() throws Exception { activationType.setValidTo(jackPirateValidTo); // WHEN - when(TEST_NAME); + when(); modifyUserAssignment(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, RoleType.COMPLEX_TYPE, null, task, null, activationType, true, ModelExecuteOptions.createRaw(), result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1243,12 +1243,12 @@ public void test182Forward15minAndAssignRaw() throws Exception { clockForward("PT15M"); // WHEN - when(TEST_NAME); + when(); modifyUserAssignment(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, RoleType.COMPLEX_TYPE, null, task, null, null, true, ModelExecuteOptions.createRaw(), result); // THEN - then(TEST_NAME); + then(); PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); @@ -1272,11 +1272,11 @@ public void test184RecomputeJack() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1313,12 +1313,12 @@ public void test200JackAssignCurrentPirateFutureSailor() throws Exception { activationType.setValidFrom(getTimestamp("P1M")); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); assignRole(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, activationType, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1346,11 +1346,11 @@ public void test202RecomputeJack() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1376,11 +1376,11 @@ public void test204ReconcileJack() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1416,12 +1416,12 @@ public void test210JackAssignCurrentPirateFutureRichSailor() throws Exception { activationType.setValidFrom(getTimestamp("P1M")); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); assignRole(USER_JACK_OID, ROLE_STRONG_RICH_SAILOR_OID, activationType, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1449,11 +1449,11 @@ public void test212RecomputeJack() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1479,11 +1479,11 @@ public void test214ReconcileJack() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1519,11 +1519,11 @@ public void test220JackAssignFutureRichSailor() throws Exception { activationType.setValidFrom(getTimestamp("P1M")); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_STRONG_RICH_SAILOR_OID, activationType, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1563,14 +1563,14 @@ public void test230JackAssignRoleStrongRichSailorValidTo() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); // beware of the order: weapon is weak and is set differently by role (cutlass) and resource (from user extension: pistol, mouth) // the assert expects cutlass, so the pirate role assignment must go first assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); assignRole(USER_JACK_OID, ROLE_STRONG_RICH_SAILOR_OID, activationType, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -1600,11 +1600,11 @@ public void test232Forward15min() throws Exception { clockForward("PT15M"); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1644,14 +1644,14 @@ public void test240JackAssignRoleRichSailorValidTo() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); // beware of the order: weapon is weak and is set differently by role (cutlass) and resource (from user extension: pistol, mouth) // the assert expects cutlass, so the pirate role assignment must go first assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); assignRole(USER_JACK_OID, ROLE_RICH_SAILOR_OID, activationType, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -1681,11 +1681,11 @@ public void test242Forward15min() throws Exception { clockForward("PT15M"); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1722,14 +1722,14 @@ public void test250JackAssignFocusExistsResource() throws Exception { AssignmentType assignment = ObjectTypeUtil.createAssignmentTo(resourceDummyFocusExists, prismContext).activation(activation); // WHEN - when(TEST_NAME); + when(); ObjectDelta delta = prismContext.deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT).add(assignment) .asObjectDeltaCast(USER_JACK_OID); executeChanges(delta, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1754,11 +1754,11 @@ public void test252RecomputeJack() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1783,11 +1783,11 @@ public void test254ReconcileJack() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1884,11 +1884,11 @@ private void unassignAll(final String TEST_NAME) throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); unassignAll(userBefore, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestRbac.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestRbac.java index 6dc75cf4c3a..5469a6bd64e 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestRbac.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestRbac.java @@ -151,7 +151,7 @@ public void test101JackAssignRolePirate() throws Exception { assignRole(USER_JACK_OID, ROLE_PIRATE_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -204,7 +204,7 @@ public void test102JackModifyUserLocality() throws Exception { createPolyString(LOCALITY_TORTUGA)); // THEN - then(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -237,7 +237,7 @@ public void test110UnAssignRolePirate() throws Exception { unassignRole(USER_JACK_OID, ROLE_PIRATE_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -288,11 +288,11 @@ public void test120JackAssignRolePirateWhileAlreadyHasAccount() throws Exception EXISTING_GOSSIP); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -810,11 +810,11 @@ public void test154JackAssignRoleIndianOceanPirate() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_INDIAN_OCEAN_PIRATE_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); display("Result", result); TestUtil.assertSuccess(result); @@ -922,21 +922,21 @@ public void testJackAssignRolePirateRelationNoPrivs(final String TEST_NAME, QNam assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME); // WHEN (1) - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, relation, getDefaultOptions(), task, result); // THEN (1) - then(TEST_NAME); + then(); assertSuccess(result); assertJackAssignRolePirateRelationNoPrivs(relation); // WHEN (2) - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, getDefaultOptions(), task, result); // THEN (2) - then(TEST_NAME); + then(); assertSuccess(result); assertJackAssignRolePirateRelationNoPrivs(relation); @@ -966,7 +966,7 @@ public void testJackUnassignRolePirateRelationNoPrivs(final String TEST_NAME, QN unassignRole(USER_JACK_OID, ROLE_PIRATE_OID, relation, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -1242,11 +1242,11 @@ public void test502JackModifyUserLocality() throws Exception { EXISTING_GOSSIP); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_LOCALITY, getDefaultOptions(), task, result, createPolyString("Isla de Muerta")); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1427,11 +1427,11 @@ public void test532JackModifyAssignmentRoleCleric() throws Exception { UserType.class, USER_JACK_OID, itemPath, "soul"); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(assignmentDelta), getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1461,11 +1461,11 @@ public void test539JackUnAssignRoleCleric() throws Exception { UserType.class, USER_JACK_OID, UserType.F_ASSIGNMENT, assignmentType); // WHEN - when(TEST_NAME); + when(); executeChanges(assignmentDelta, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1490,11 +1490,11 @@ public void test540JackAssignRoleWannabe() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_WANNABE_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1519,11 +1519,11 @@ public void test541JackRemoveHonorificSuffixWannabe() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_HONORIFIC_SUFFIX, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1547,11 +1547,11 @@ public void test542JackModifySubtypeWannabe() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_SUBTYPE, getDefaultOptions(), task, result, "wannabe"); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1576,11 +1576,11 @@ public void test543JackRemoveHonorificPrefixWannabe() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_HONORIFIC_PREFIX, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1604,12 +1604,12 @@ public void test544JackSetHonorificSuffixWannabe() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_HONORIFIC_SUFFIX, getDefaultOptions(), task, result, PrismTestUtil.createPolyString("PhD.")); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1635,12 +1635,12 @@ public void test545JackRestoreHonorificPrefixWannabe() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_HONORIFIC_PREFIX, getDefaultOptions(), task, result, PrismTestUtil.createPolyString("captain")); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1665,11 +1665,11 @@ public void test549JackUnassignRoleWannabe() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_WANNABE_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1696,7 +1696,7 @@ public void test600JackAssignRoleJudge() throws Exception { assignRole(USER_JACK_OID, ROLE_JUDGE_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1737,7 +1737,7 @@ public void test602JackAssignRolePirate() throws Exception { } // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertFailure(result); @@ -1764,11 +1764,11 @@ public void test605JackUnAssignRoleJudgeAssignRolePirate() throws Exception { userDelta.addModification(createAssignmentModification(ROLE_PIRATE_OID, RoleType.COMPLEX_TYPE, null, null, null, true)); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(userDelta), getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1798,11 +1798,11 @@ public void test609JackUnAssignRolePirate() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_PIRATE_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1826,7 +1826,7 @@ public void test610ElaineAssignRoleGovernor() throws Exception { assignRole(USER_ELAINE_OID, ROLE_GOVERNOR_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1866,7 +1866,7 @@ public void test612JackAssignRoleGovernor() throws Exception { } // THEN - then(TEST_NAME); + then(); assertFailure(result); assertNoAssignments(USER_JACK_OID); @@ -1902,7 +1902,7 @@ public void test613JackAssignRoleGovernorAsApprover() throws Exception { } // THEN - then(TEST_NAME); + then(); assertFailure(result); assertNoAssignments(USER_JACK_OID); @@ -1930,11 +1930,11 @@ public void test620LemonheadAssignRoleCanibal() throws Exception { assertAssignees(ROLE_CANNIBAL_OID, 0); // WHEN - when(TEST_NAME); + when(); assignRole(user.getOid(), ROLE_CANNIBAL_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertAssignedRole(user.getOid(), ROLE_CANNIBAL_OID, result); @@ -1960,11 +1960,11 @@ public void test622SharptoothAssignRoleCanibal() throws Exception { assertAssignees(ROLE_CANNIBAL_OID, 1); // WHEN - when(TEST_NAME); + when(); assignRole(user.getOid(), ROLE_CANNIBAL_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertAssignedRole(user.getOid(), ROLE_CANNIBAL_OID, result); @@ -1990,11 +1990,11 @@ public void test624RedskullAssignRoleCanibal() throws Exception { assertAssignees(ROLE_CANNIBAL_OID, 2); // WHEN - when(TEST_NAME); + when(); assignRole(user.getOid(), ROLE_CANNIBAL_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertAssignedRole(user.getOid(), ROLE_CANNIBAL_OID, result); @@ -2021,7 +2021,7 @@ public void test625BignoseAssignRoleCanibal() throws Exception { try { // WHEN - when(TEST_NAME); + when(); assignRole(user.getOid(), ROLE_CANNIBAL_OID, getDefaultOptions(), task, result); AssertJUnit.fail("Unexpected success"); @@ -2032,7 +2032,7 @@ public void test625BignoseAssignRoleCanibal() throws Exception { } // THEN - then(TEST_NAME); + then(); assertFailure(result); assertNoAssignments(user.getOid()); @@ -2052,11 +2052,11 @@ public void test627SharptoothUnassignRoleCanibal() throws Exception { assertAssignees(ROLE_CANNIBAL_OID, 3); // WHEN - when(TEST_NAME); + when(); unassignRole(userSharptoothOid, ROLE_CANNIBAL_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertNoAssignments(userSharptoothOid); @@ -2078,7 +2078,7 @@ public void test628RedskullUnassignRoleCanibal() throws Exception { try { // WHEN - when(TEST_NAME); + when(); unassignRole(userRedskullOid, ROLE_CANNIBAL_OID, getDefaultOptions(), task, result); AssertJUnit.fail("Unexpected success"); @@ -2089,7 +2089,7 @@ public void test628RedskullUnassignRoleCanibal() throws Exception { } // THEN - then(TEST_NAME); + then(); assertFailure(result); assertAssignedRole(userRedskullOid, ROLE_CANNIBAL_OID, result); @@ -2119,7 +2119,7 @@ public void test630RappAssignRoleCannibalAsOwner() throws Exception { assignRole(USER_RAPP_OID, ROLE_CANNIBAL_OID, SchemaConstants.ORG_OWNER, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertAssignees(ROLE_CANNIBAL_OID, 2); @@ -2147,7 +2147,7 @@ public void test632RappUnassignRoleCannibalAsOwner() throws Exception { try { // WHEN - when(TEST_NAME); + when(); // null namespace to test no-namespace "owner" relation unassignRole(USER_RAPP_OID, ROLE_CANNIBAL_OID, QNameUtil.nullNamespace(SchemaConstants.ORG_OWNER), getDefaultOptions(), task, result); @@ -2159,7 +2159,7 @@ public void test632RappUnassignRoleCannibalAsOwner() throws Exception { } // THEN - then(TEST_NAME); + then(); assertFailure(result); assertAssignees(ROLE_CANNIBAL_OID, 2); @@ -2189,7 +2189,7 @@ public void test634BignoseAssignRoleCannibalAsOwner() throws Exception { assignRole(userBignoseOid, ROLE_CANNIBAL_OID, SchemaConstants.ORG_OWNER, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(userBignoseOid) @@ -2224,7 +2224,7 @@ public void test636BignoseUnassignRoleCannibalAsOwner() throws Exception { unassignRole(userBignoseOid, ROLE_CANNIBAL_OID, SchemaConstants.ORG_OWNER, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(userBignoseOid) @@ -2249,11 +2249,11 @@ public void test649ElaineUnassignRoleGovernor() throws Exception { assertAssignees(ROLE_GOVERNOR_OID, 1); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_ELAINE_OID, ROLE_GOVERNOR_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_ELAINE_OID); @@ -2276,11 +2276,11 @@ public void test650BignoseAssignRoleCannibalAsOwner() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(userBignoseOid, ROLE_CANNIBAL_OID, SchemaConstants.ORG_OWNER, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(userBignoseOid) @@ -2298,11 +2298,11 @@ public void test651BignoseAssignRoleCannibalAsApprover() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(userBignoseOid, ROLE_CANNIBAL_OID, SchemaConstants.ORG_APPROVER, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(userBignoseOid) @@ -2324,11 +2324,11 @@ public void test655BignoseAssignRoleCannibal() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(userBignoseOid, ROLE_CANNIBAL_OID, SchemaConstants.ORG_DEFAULT, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(userBignoseOid) @@ -2348,11 +2348,11 @@ public void test656BignoseUnassignRoleCannibal() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignRole(userBignoseOid, ROLE_CANNIBAL_OID, SchemaConstants.ORG_DEFAULT, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(userBignoseOid) @@ -2380,7 +2380,7 @@ public void test658BignoseUnassignRoleCannibalAsOwner() throws Exception { executeChanges(userDelta, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(userBignoseOid) @@ -2400,11 +2400,11 @@ public void test700JackAssignRoleJudge() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_JUDGE_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertAssignedRole(USER_JACK_OID, ROLE_JUDGE_OID, result); @@ -2426,11 +2426,11 @@ public void test701JackModifyJudgeDeleteConstructionRecompute() throws Exception display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); modifyRoleDeleteInducement(ROLE_JUDGE_OID, 1111L, true, getDefaultOptions(), task); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertInProgressOrSuccess(result); @@ -2456,11 +2456,11 @@ public void test702JackModifyJudgeAddInducementHonorabilityRecompute() throws Ex display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); modifyRoleAddInducementTarget(ROLE_JUDGE_OID, ROLE_HONORABILITY_OID, true, getDefaultOptions()); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertInProgressOrSuccess(result); @@ -2494,11 +2494,11 @@ public void test703JackModifyJudgeDeleteInducementHonorabilityRecompute() throws display("Role judge", roleJudge); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, ModelExecuteOptions.createReconcile(getDefaultOptions()), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2525,11 +2525,11 @@ public void test709JackUnAssignRoleJudge() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_JUDGE_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2550,11 +2550,11 @@ public void test710JackAssignRoleEmpty() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_EMPTY_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2575,11 +2575,11 @@ public void test712JackModifyEmptyRoleAddInducementPirateRecompute() throws Exce display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); modifyRoleAddInducementTarget(ROLE_EMPTY_OID, ROLE_PIRATE_OID, true, getDefaultOptions()); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertInProgressOrSuccess(result); @@ -2608,11 +2608,11 @@ public void test714JackModifyEmptyRoleDeleteInducementPirateRecompute() throws E modifyRoleDeleteInducementTarget(ROLE_EMPTY_OID, ROLE_PIRATE_OID, getDefaultOptions()); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2633,11 +2633,11 @@ public void test719JackUnAssignRoleEmpty() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_EMPTY_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2660,11 +2660,11 @@ public void test720JackAssignRoleGovernorTenantRef() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); assignParametricRole(USER_JACK_OID, ROLE_GOVERNOR_OID, null, ORG_SCUMM_BAR_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2691,11 +2691,11 @@ public void test729JackUnassignRoleGovernorTenantRef() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); unassignParametricRole(USER_JACK_OID, ROLE_GOVERNOR_OID, null, ORG_SCUMM_BAR_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2720,11 +2720,11 @@ public void test750JackAssignRoleOmnimanager() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_PROJECT_OMNINAMAGER_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2755,11 +2755,11 @@ public void test755AddProjectAndRecomputeJack() throws Exception { addObject(ORG_PROJECT_RECLAIM_BLACK_PEARL_FILE); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, ModelExecuteOptions.createReconcile(getDefaultOptions()), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2786,11 +2786,11 @@ public void test759JackUnassignRoleOmnimanager() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_PROJECT_OMNINAMAGER_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2823,11 +2823,11 @@ public void test760JackAssignRoleWeakGossiper() throws Exception { assertDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, false); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_WEAK_GOSSIPER_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2856,11 +2856,11 @@ public void test761JackRecompute() throws Exception { assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2889,11 +2889,11 @@ public void test762JackReconcile() throws Exception { assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2924,11 +2924,11 @@ public void test763PreviewChanges() throws Exception { ); // WHEN - when(TEST_NAME); + when(); ModelContext context = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("Preview context", context); @@ -2980,11 +2980,11 @@ public void test764JackAssignRoleSailor() throws Exception { assertAssignedRole(userBefore, ROLE_WEAK_GOSSIPER_OID); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_SAILOR_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3018,11 +3018,11 @@ public void test765JackRecompute() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3056,11 +3056,11 @@ public void test766JackReconcile() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3096,11 +3096,11 @@ public void test767JackUnAssignRoleWeakGossiper() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_WEAK_GOSSIPER_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3133,11 +3133,11 @@ public void test768JackRecompute() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3170,11 +3170,11 @@ public void test769JackUnAssignRoleSailor() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_SAILOR_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3204,11 +3204,11 @@ public void test770JackAssignRoleSailor() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_SAILOR_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3243,11 +3243,11 @@ public void test772JackAssignRoleGossiper() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_WEAK_GOSSIPER_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3283,11 +3283,11 @@ public void test774JackUnAssignRoleSailor() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_SAILOR_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3317,11 +3317,11 @@ public void test775JackUnAssignRoleGossiper() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_WEAK_GOSSIPER_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3357,11 +3357,11 @@ public void test778JackAssignRoleGossiperAndSailor() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(deltas, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3402,11 +3402,11 @@ public void test779JackUnassignRoleGossiperAndSailor() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(deltas, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3438,11 +3438,11 @@ public void test780JackAssignRoleWeakSinger() throws Exception { assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_WEAK_SINGER_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3475,11 +3475,11 @@ public void test781JackAssignRoleWeakGossiper() throws Exception { assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_WEAK_GOSSIPER_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3510,11 +3510,11 @@ public void test782JackAssignRoleSailor() throws Exception { assertAssignedRole(userBefore, ROLE_WEAK_GOSSIPER_OID); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_SAILOR_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3552,11 +3552,11 @@ public void test783JackUnassignRoleSailor() throws Exception { assertAssignedRole(userBefore, ROLE_WEAK_SINGER_OID); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_SAILOR_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3587,11 +3587,11 @@ public void test784JackUnAssignRoleWeakSinger() throws Exception { assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_WEAK_SINGER_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3621,11 +3621,11 @@ public void test785JackUnAssignRoleGossiper() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_WEAK_GOSSIPER_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3661,11 +3661,11 @@ public void test786JackAssignRoleGossiperAndSinger() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(deltas, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3701,11 +3701,11 @@ public void test788JackUnassignRoleGossiperAndSinger() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(deltas, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3738,11 +3738,11 @@ public void test790JackAssignRoleWeakSinger() throws Exception { assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_WEAK_SINGER_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3782,11 +3782,11 @@ public void test791JackSwitchRolesGossiperAndSinger() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(deltas, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3817,11 +3817,11 @@ public void test792JackAssignRoleSailor() throws Exception { assertAssignedRole(userBefore, ROLE_WEAK_GOSSIPER_OID); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_SAILOR_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3866,11 +3866,11 @@ public void test793JackSwitchRolesSingerAndGossiper() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(deltas, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3912,11 +3912,11 @@ public void test794JackSwitchRolesSailorAndGossiper() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(deltas, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3952,11 +3952,11 @@ public void test795JackSwitchRolesSingerAndSailor() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(deltas, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3998,11 +3998,11 @@ public void test796JackSwitchRolesSailorAndGovernor() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(deltas, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4045,11 +4045,11 @@ public void test799JackUnassignGovernorAndWeakGossiper() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(deltas, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4071,14 +4071,14 @@ public void test800ModifyRoleImmutable() throws Exception { try { // WHEN - when(TEST_NAME); + when(); modifyObjectReplaceProperty(RoleType.class, ROLE_IMMUTABLE_OID, RoleType.F_DESCRIPTION, getDefaultOptions(), task, result, "whatever"); AssertJUnit.fail("Unexpected success"); } catch (PolicyViolationException e) { // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertFailure(result); } @@ -4103,11 +4103,11 @@ public void test802AddGlobalImmutableRole() throws Exception { display("Role before", role); // WHEN - when(TEST_NAME); + when(); addObject(role, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4126,14 +4126,14 @@ public void test804ModifyRoleImmutableGlobalIdentifier() throws Exception { try { // WHEN - when(TEST_NAME); + when(); modifyObjectReplaceProperty(RoleType.class, ROLE_IMMUTABLE_GLOBAL_OID, RoleType.F_IDENTIFIER, getDefaultOptions(), task, result, "whatever"); AssertJUnit.fail("Unexpected success"); } catch (PolicyViolationException e) { // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertFailure(result); } @@ -4153,14 +4153,14 @@ public void test805ModifyRoleImmutableGlobalDescription() throws Exception { try { // WHEN - when(TEST_NAME); + when(); modifyObjectReplaceProperty(RoleType.class, ROLE_IMMUTABLE_GLOBAL_OID, RoleType.F_DESCRIPTION, getDefaultOptions(), task, result, "whatever"); AssertJUnit.fail("Unexpected success"); } catch (PolicyViolationException e) { // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertFailure(result); } @@ -4186,11 +4186,11 @@ public void test812AddGlobalImmutableDescriptionRole() throws Exception { display("Role before", role); // WHEN - when(TEST_NAME); + when(); addObject(role, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4211,13 +4211,13 @@ public void test814ModifyRoleImmutableDescriptionGlobalIdentifier() throws Excep OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); final String NEW_VALUE = "whatever"; modifyObjectReplaceProperty(RoleType.class, ROLE_IMMUTABLE_DESCRIPTION_GLOBAL_OID, RoleType.F_IDENTIFIER, getDefaultOptions(), task, result, NEW_VALUE); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4236,14 +4236,14 @@ public void test815ModifyRoleImmutableGlobalDescription() throws Exception { try { // WHEN - when(TEST_NAME); + when(); modifyObjectReplaceProperty(RoleType.class, ROLE_IMMUTABLE_DESCRIPTION_GLOBAL_OID, RoleType.F_DESCRIPTION, getDefaultOptions(), task, result, "whatever"); AssertJUnit.fail("Unexpected success"); } catch (PolicyViolationException e) { // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertFailure(result); } @@ -4265,13 +4265,13 @@ public void test826AddNonCreateableRole() throws Exception { try { // WHEN - when(TEST_NAME); + when(); addObject(role, getDefaultOptions(), task, result); AssertJUnit.fail("Unexpected success"); } catch (PolicyViolationException e) { // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertFailure(result); } @@ -4291,7 +4291,7 @@ public void test826bAddCreateableRole() throws Exception { display("Role before", role); // WHEN - when(TEST_NAME); + when(); addObject(role, getDefaultOptions(), task, result); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4316,13 +4316,13 @@ public void test827AddImmutableAssignRole() throws Exception { try { // WHEN - when(TEST_NAME); + when(); addObject(role, getDefaultOptions(), task, result); AssertJUnit.fail("Unexpected success"); } catch (PolicyViolationException e) { // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertFailure(result); } @@ -4344,12 +4344,12 @@ public void test828ModifyUntouchableMetarole() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modifyObjectReplaceProperty(RoleType.class, ROLE_META_UNTOUCHABLE_OID, RoleType.F_DESCRIPTION, getDefaultOptions(), task, result, "Touche!"); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4366,12 +4366,12 @@ public void test830ModifyRoleJudge() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modifyObjectReplaceProperty(RoleType.class, ROLE_JUDGE_OID, RoleType.F_DESCRIPTION, getDefaultOptions(), task, result, "whatever"); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4393,13 +4393,13 @@ public void test840AssignRoleNonAssignable() throws Exception { try { // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_NON_ASSIGNABLE_OID, getDefaultOptions(), task, result); AssertJUnit.fail("Unexpected success"); } catch (PolicyViolationException e) { // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertFailure(result); } @@ -4422,11 +4422,11 @@ public void test850JackAssignRoleBloodyFool() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_BLOODY_FOOL_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4460,11 +4460,11 @@ public void test855JackModifyFoolMetaroleDeleteInducement() throws Exception { assertInducements(roleBefore, 2); // WHEN - when(TEST_NAME); + when(); modifyRoleDeleteInducement(ROLE_META_FOOL_OID, 10002L, false, getDefaultOptions(), task); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4486,11 +4486,11 @@ public void test857JackReconcile() throws Exception { display("User jack before", userBefore); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4527,11 +4527,11 @@ public void test870AssignRoleScreaming() throws Exception { display("user jack", userJackBefore); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_SCREAMING_OID, getDefaultOptions(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userJackAfter = getUser(USER_JACK_OID); @@ -4567,7 +4567,7 @@ public void test880GlobalRuleOnChange() throws Exception { // WHEN - when(TEST_NAME); + when(); executeChangesAssertSuccess(delta, getDefaultOptions(), task, result); } @@ -4581,12 +4581,12 @@ public void test890DeleteRoleUndeletable() throws Exception { try { // WHEN - when(TEST_NAME); + when(); deleteObject(RoleType.class, ROLE_UNDELETABLE_OID, task, result); AssertJUnit.fail("Unexpected success"); } catch (PolicyViolationException e) { // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertFailure(result); } @@ -4602,12 +4602,12 @@ public void test892DeleteRoleUndeletableGlobal() throws Exception { try { // WHEN - when(TEST_NAME); + when(); deleteObject(RoleType.class, ROLE_UNDELETABLE_GLOBAL_OID, task, result); AssertJUnit.fail("Unexpected success"); } catch (PolicyViolationException e) { // THEN - then(TEST_NAME); + then(); System.out.println("Got expected exception: " + e.getMessage()); result.computeStatus(); TestUtil.assertFailure(result); @@ -4627,14 +4627,14 @@ public void test900ModifyDetectingRole() throws Exception { display("Role before", roleBefore); // WHEN - when(TEST_NAME); + when(); ObjectDelta delta = prismContext.deltaFor(RoleType.class) .item(RoleType.F_NAME).replace(PolyString.fromOrig("modified")) .asObjectDeltaCast(ROLE_DETECTING_MODIFICATIONS_OID); executeChanges(delta, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestSegregationOfDuties.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestSegregationOfDuties.java index 6ea4b6779b5..bbad6e9095e 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestSegregationOfDuties.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestSegregationOfDuties.java @@ -811,11 +811,11 @@ public void test210GuybrushAssignRoleRed() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_COLOR_RED_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -933,11 +933,11 @@ public void test219GuybrushUnassignRoleBlue() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_GUYBRUSH_OID, ROLE_COLOR_BLUE_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -960,11 +960,11 @@ public void test220GuybrushAssignRoleBlue() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_COLOR_BLUE_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -999,11 +999,11 @@ public void test221GuybrushDestroyAndRecompute() throws Exception { display("User before", userBefore); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_GUYBRUSH_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result, 2); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1039,11 +1039,11 @@ public void test222GuybrushDestroyAndAssignRoleRed() throws Exception { display("User before", userBefore); // WHEN - when(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_COLOR_RED_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result, 2); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1069,11 +1069,11 @@ public void test229GuybrushUnassignRoleRed() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_GUYBRUSH_OID, ROLE_COLOR_RED_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1132,11 +1132,11 @@ public void test240GuybrushAssignRoleExecutiveOne() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_EXECUTIVE_1_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1174,11 +1174,11 @@ public void test244GuybrushAssignRoleExecutiveTwo() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_EXECUTIVE_2_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1219,11 +1219,11 @@ public void test246GuybrushUnassignRoleExecutiveOne() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_GUYBRUSH_OID, ROLE_EXECUTIVE_1_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1263,11 +1263,11 @@ public void test249GuybrushUnassignRoleExecutiveTwo() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_GUYBRUSH_OID, ROLE_EXECUTIVE_2_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1290,11 +1290,11 @@ public void test250GuybrushAssignRoleControllingOne() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_CONTROLLING_1_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1332,11 +1332,11 @@ public void test259GuybrushUnassignRoleControllingOne() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_GUYBRUSH_OID, ROLE_CONTROLLING_1_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1356,11 +1356,11 @@ public void test800ApplyGlobalPolicyRulesExclusion() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); transplantGlobalPolicyRulesAdd(CONFIG_WITH_GLOBAL_RULES_EXCLUSION_FILE, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); List globalPolicyRules = getSystemConfiguration().getGlobalPolicyRule(); @@ -1377,11 +1377,11 @@ public void test810GuybrushAssignRoleCitizenSk() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_CITIZEN_SK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1416,11 +1416,11 @@ public void test814GuybrushAssignRoleEmpty() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_EMPTY_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1438,11 +1438,11 @@ public void test818GuybrushUnassignRoleCitizenSk() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_GUYBRUSH_OID, ROLE_CITIZEN_SK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1462,11 +1462,11 @@ public void test819GuybrushUnassignRoleEmpty() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_GUYBRUSH_OID, ROLE_EMPTY_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1487,11 +1487,11 @@ public void test820GuybrushAssignRoleCriminal() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_CRIMINAL_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1512,11 +1512,11 @@ public void test822GuybrushAssignRoleMinister() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_MINISTER_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1536,11 +1536,11 @@ public void test826GuybrushUnassignRoleCriminal() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_GUYBRUSH_OID, ROLE_CRIMINAL_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1558,11 +1558,11 @@ public void test829GuybrushUnassignRoleMinister() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_GUYBRUSH_OID, ROLE_MINISTER_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1580,11 +1580,11 @@ public void test900ApplyGlobalPolicyRulesSoDApproval() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); transplantGlobalPolicyRulesAdd(CONFIG_WITH_GLOBAL_RULES_SOD_APPROVAL_FILE, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); List globalPolicyRules = getSystemConfiguration().getGlobalPolicyRule(); @@ -1606,11 +1606,11 @@ public void test920GuybrushAssignRoleCriminal() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_CRIMINAL_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1638,11 +1638,11 @@ public void test922GuybrushPreviewAssignRoleMinister() throws Exception { ROLE_MINISTER_OID, RoleType.COMPLEX_TYPE, null, null, null, true); // WHEN - when(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("Preview context", modelContext); @@ -1712,11 +1712,11 @@ public void test929GuybrushUnassignRoleCriminal() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_GUYBRUSH_OID, ROLE_CRIMINAL_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1831,7 +1831,7 @@ private PrismObject assignRolePolicyFailure(String TEST_NAME, String u try { // WHEN - when(TEST_NAME); + when(); assignRole(userOid, roleOid, task, result); assertNotReached(); @@ -1840,7 +1840,7 @@ private PrismObject assignRolePolicyFailure(String TEST_NAME, String u System.out.println("Got expected exception: " + e.getMessage()); // THEN - then(TEST_NAME); + then(); assertFailure(result); } diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityAdvanced.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityAdvanced.java index f211fe54dcc..db98a3d791c 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityAdvanced.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityAdvanced.java @@ -164,7 +164,7 @@ public void test000Sanity() throws Exception { cleanupAutzTest(USER_JACK_OID); // WHEN - when(TEST_NAME); + when(); assertSearch(UserType.class, null, NUMBER_OF_ALL_USERS); assertSearch(RoleType.class, null, getNumberOfRoles()); @@ -208,13 +208,13 @@ public void test080AutzJackEndUserPassword() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); assertAllow("set jack's password", (task, result) -> modifyUserSetPassword(USER_JACK_OID, "nbusr123", task, result)); // THEN - then(TEST_NAME); + then(); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -237,7 +237,7 @@ public void test100AutzJackPersonaManagement() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); @@ -263,7 +263,7 @@ public void test102AutzLechuckPersonaManagement() throws Exception { login(USER_LECHUCK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertGetDeny(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); @@ -293,7 +293,7 @@ public void test110AutzJackPersonaAdmin() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertAllow("assign application role 1 to jack", (task, result) -> assignRole(USER_JACK_OID, ROLE_PERSONA_ADMIN_OID, task, result)); @@ -352,7 +352,7 @@ public void test120AutzJackDelagator() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertReadAllow(NUMBER_OF_ALL_USERS); assertAddDeny(); @@ -399,7 +399,7 @@ public void test120AutzJackDelagator() throws Exception { login(USER_BARBOSSA_USERNAME); // WHEN - when(TEST_NAME); + when(); display("Logged in as Barbossa"); assertReadAllow(NUMBER_OF_ALL_USERS); @@ -409,7 +409,7 @@ public void test120AutzJackDelagator() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); display("Logged in as Jack"); assertAllow("undelegate from Barbossa", @@ -425,7 +425,7 @@ public void test120AutzJackDelagator() throws Exception { login(USER_BARBOSSA_USERNAME); // WHEN - when(TEST_NAME); + when(); display("Logged in as Barbossa"); assertReadDeny(); @@ -459,7 +459,7 @@ public void test122AutzJackDelagatorValidity() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); PrismObject userJack = getUser(USER_JACK_OID); assertAssignments(userJack, 1); @@ -499,7 +499,7 @@ public void test122AutzJackDelagatorValidity() throws Exception { login(USER_BARBOSSA_USERNAME); // WHEN - when(TEST_NAME); + when(); display("Logged in as Barbossa"); // Delegation is not active yet. No access. @@ -528,7 +528,7 @@ public void test122AutzJackDelagatorValidity() throws Exception { login(USER_BARBOSSA_USERNAME); // WHEN - when(TEST_NAME); + when(); display("Logged in as Barbossa"); assertReadAllow(NUMBER_OF_ALL_USERS); @@ -543,7 +543,7 @@ public void test122AutzJackDelagatorValidity() throws Exception { login(USER_BARBOSSA_USERNAME); // WHEN - when(TEST_NAME); + when(); display("Logged in as Barbossa"); // Delegation is not active any more. No access. @@ -554,7 +554,7 @@ public void test122AutzJackDelagatorValidity() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); display("Logged in as Jack"); assertAllow("undelegate from Barbossa", @@ -571,7 +571,7 @@ public void test122AutzJackDelagatorValidity() throws Exception { login(USER_BARBOSSA_USERNAME); // WHEN - when(TEST_NAME); + when(); display("Logged in as Barbossa"); assertReadDeny(); @@ -605,7 +605,7 @@ public void test124AutzJackDelagatorPlusValidity() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); PrismObject userJack = getUser(USER_JACK_OID); assertAssignments(userJack, 1); @@ -645,7 +645,7 @@ public void test124AutzJackDelagatorPlusValidity() throws Exception { login(USER_BARBOSSA_USERNAME); // WHEN - when(TEST_NAME); + when(); display("Logged in as Barbossa"); // Delegation is not active yet. No access. @@ -674,7 +674,7 @@ public void test124AutzJackDelagatorPlusValidity() throws Exception { login(USER_BARBOSSA_USERNAME); // WHEN - when(TEST_NAME); + when(); display("Logged in as Barbossa"); assertReadAllow(NUMBER_OF_ALL_USERS); @@ -703,7 +703,7 @@ public void test124AutzJackDelagatorPlusValidity() throws Exception { login(USER_BARBOSSA_USERNAME); // WHEN - when(TEST_NAME); + when(); display("Logged in as Barbossa"); // Delegation is not active any more. No access. @@ -714,7 +714,7 @@ public void test124AutzJackDelagatorPlusValidity() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); display("Logged in as Jack"); assertAllow("undelegate from Barbossa", @@ -731,7 +731,7 @@ public void test124AutzJackDelagatorPlusValidity() throws Exception { login(USER_BARBOSSA_USERNAME); // WHEN - when(TEST_NAME); + when(); display("Logged in as Barbossa"); assertReadDeny(); @@ -763,7 +763,7 @@ public void test150AutzJackApproverUnassignRoles() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertGetAllow(RoleType.class, ROLE_ORDINARY_OID); assertGetDeny(RoleType.class, ROLE_PERSONA_ADMIN_OID); // no assignment @@ -804,7 +804,7 @@ public void test151AutzJackApproverUnassignRolesAndRead() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertGetAllow(RoleType.class, ROLE_ORDINARY_OID); assertGetAllow(RoleType.class, ROLE_PERSONA_ADMIN_OID); // no assignment @@ -845,7 +845,7 @@ public void test154AutzJackApproverRead() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); PrismObject roleOrdinary = assertGetAllow(RoleType.class, ROLE_ORDINARY_OID); assertNoRoleMembershipRef(roleOrdinary); @@ -910,7 +910,7 @@ public void test155AutzJackApproverSelf() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertGetDeny(RoleType.class, ROLE_ORDINARY_OID); assertGetDeny(RoleType.class, ROLE_PERSONA_ADMIN_OID); @@ -966,7 +966,7 @@ public void test157AutzJackReadRoleMembers() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); PrismObject roleOrdinary = assertGetAllow(RoleType.class, ROLE_ORDINARY_OID); assertNoRoleMembershipRef(roleOrdinary); @@ -1018,7 +1018,7 @@ public void test158AutzJackReadRoleMembersWrong() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); PrismObject roleOrdinary = assertGetAllow(RoleType.class, ROLE_ORDINARY_OID); assertNoRoleMembershipRef(roleOrdinary); @@ -1070,7 +1070,7 @@ public void test159AutzJackReadRoleMembersNone() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); PrismObject roleOrdinary = assertGetAllow(RoleType.class, ROLE_ORDINARY_OID); assertNoRoleMembershipRef(roleOrdinary); @@ -1174,7 +1174,7 @@ public void test200AutzJackModifyOrgunit() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertAddDeny(); @@ -1235,7 +1235,7 @@ public void test202AutzJackModifyOrgunitAndAssignRole() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertAddDeny(); @@ -1308,7 +1308,7 @@ public void test220AutzJackRoleExpressionNoConstCenter() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertReadDeny(); assertAddDeny(); @@ -1351,7 +1351,7 @@ public void test222AutzJackRoleExpressionConstCenterBusiness() throws Exception login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertReadDeny(); assertAddDeny(); @@ -1393,7 +1393,7 @@ public void test230AttorneyCaribbeanUnlimited() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertReadAllow(); assertAddDeny(); @@ -1464,7 +1464,7 @@ public void test232ManagerAttorneyNoOrg() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertReadAllow(); assertAddDeny(); @@ -1510,7 +1510,7 @@ public void test234ManagerAttorneyRum() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertReadAllow(); assertAddDeny(); @@ -1578,7 +1578,7 @@ public void test235ManagerAttorneyRumRogersEntitled() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertReadAllow(); assertAddDeny(); @@ -1648,7 +1648,7 @@ public void test236ManagerAttorneyCaribbeanRum() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertReadAllow(); assertAddDeny(); @@ -1727,7 +1727,7 @@ public void test250AssignRequestableSelfOtherApporver() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertReadAllow(); assertAddDeny(); @@ -1820,7 +1820,7 @@ public void test252AssignRequestableSelfOtherApporverEmptyDelta() throws Excepti login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertReadAllow(); assertAddDeny(); @@ -1889,7 +1889,7 @@ public void test254AssignUnassignRequestableSelf() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertReadAllow(); assertAddDeny(); @@ -1925,7 +1925,7 @@ public void test256AssignUnassignRequestableSelfEmptyDelta() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertReadAllow(); assertAddDeny(); @@ -1959,7 +1959,7 @@ public void test260AutzJackLimitedRoleAdministrator() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_JACK_OID, SelectorOptions.createCollection(GetOperationOptions.createRaw())); @@ -2097,7 +2097,7 @@ public void test262AutzJackLimitedRoleAdministratorAndAssignApplicationRoles() t login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertReadAllow(); assertReadDenyRaw(); @@ -2222,7 +2222,7 @@ public void test264AutzJackLimitedReadRoleAdministrator() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_JACK_OID, SelectorOptions.createCollection(GetOperationOptions.createRaw())); @@ -2323,7 +2323,7 @@ public void test266AutzJackRoleAdministrator() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_JACK_OID, SelectorOptions.createCollection(GetOperationOptions.createRaw())); @@ -2380,7 +2380,7 @@ public void test270AutzJackModifyPolicyException() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertReadDenyRaw(); @@ -2437,7 +2437,7 @@ public void test272AutzJackModifyPolicyExceptionFirstRule() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertReadDenyRaw(); @@ -2538,7 +2538,7 @@ public void test280AutzJackModifyPolicyExceptionAndAssignOrg() throws Exception login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertReadDenyRaw(); @@ -2573,7 +2573,7 @@ public void test282AutzJackModifyPolicyExceptionAndAssignOrgDeny() throws Except login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertReadDenyRaw(); @@ -2606,7 +2606,7 @@ public void test283AutzJackModifyPolicyAssignOrg() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertReadDenyRaw(); @@ -2650,7 +2650,7 @@ public void test300AutzJackExceptAssignment() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); PrismObject userJack = getUser(USER_JACK_OID); display("Jack", userJack); @@ -2713,7 +2713,7 @@ public void test302AutzJackExceptAdministrativeStatus() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); PrismObject userJack = getUser(USER_JACK_OID); display("Jack", userJack); @@ -2782,7 +2782,7 @@ public void test304AutzJackPropExceptAssignmentReadSomeModifySomeUser() throws E login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); PrismObject userJack = assertAlmostFullJackRead(2); PrismAsserts.assertPropertyValue(userJack, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, ActivationStatusType.ENABLED); @@ -2839,7 +2839,7 @@ public void test306AutzJackPropExceptAssignmentExceptAdministrativeStatus() thro login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); PrismObject userJack = assertAlmostFullJackRead(2); // read of administrativeStatus is not allowed be either role @@ -2896,7 +2896,7 @@ public void test308AutzJackPropExceptAssignmentAssignApplicationRoles() throws E login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); PrismObject userJack = getUser(USER_JACK_OID); display("Jack", userJack); @@ -2994,12 +2994,12 @@ public void test310AutzJackPropSubtypeDenyEscapingZoneOfControl() throws Excepti .assertSubtype(USER_JACK_SUBTYPE); // WHEN - when(TEST_NAME); + when(); assertModifyDeny(UserType.class, USER_JACK_OID, UserType.F_SUBTYPE, "escape"); // WHEN - then(TEST_NAME); + then(); assertUserAfter(USER_JACK_OID) .assertName(USER_JACK_USERNAME) @@ -3029,14 +3029,14 @@ public void test312AutzJackPropSubtypeAllowEscapingZoneOfControl() throws Except .assertSubtype(USER_JACK_SUBTYPE); // WHEN - when(TEST_NAME); + when(); assertModifyAllow(UserType.class, USER_JACK_OID, UserType.F_SUBTYPE, "escape"); assertModifyDeny(UserType.class, USER_JACK_OID, UserType.F_SUBTYPE, "escape again"); assertModifyDeny(UserType.class, USER_JACK_OID, UserType.F_SUBTYPE, USER_JACK_SUBTYPE); // WHEN - then(TEST_NAME); + then(); assertUserAfter(USER_JACK_OID) .assertName(USER_JACK_USERNAME) @@ -3111,7 +3111,7 @@ public void test330AutzJackEndUserWithPrivacy() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); PrismObject userJack = assertGetAllow(UserType.class, USER_JACK_OID); display("Jack", userJack); @@ -3163,7 +3163,7 @@ public void test340AutzJackSuperUserAndExecRead() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertSearch(UserType.class, createOrgSubtreeQuery(ORG_MINISTRY_OF_OFFENSE_OID), USER_LECHUCK_OID, USER_GUYBRUSH_OID, userCobbOid, USER_ESTEVAN_OID); assertSearch(UserType.class, createOrgSubtreeAndNameQuery(ORG_MINISTRY_OF_OFFENSE_OID, USER_GUYBRUSH_USERNAME), USER_GUYBRUSH_OID); @@ -3190,7 +3190,7 @@ public void test350AutzJackResourceRead() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); PrismObject resource = getObject(ResourceType.class, RESOURCE_DUMMY_VAULT_OID); @@ -3212,7 +3212,7 @@ public void test360AutzAdminResourceRead() throws Exception { login(USER_ADMINISTRATOR_USERNAME); // WHEN - when(TEST_NAME); + when(); PrismObject resource = getObject(ResourceType.class, RESOURCE_DUMMY_VAULT_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityBasic.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityBasic.java index d6214f63375..8415dd4df18 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityBasic.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityBasic.java @@ -100,7 +100,7 @@ public void test201AutzJackSuperuserRole() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertSuperuserAccess(NUMBER_OF_ALL_USERS); assertGlobalStateUntouched(); @@ -242,7 +242,7 @@ public void test204AutzJackSelfRole() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); @@ -295,7 +295,7 @@ public void test204aAutzJackCaseObjectSelfRole() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); @@ -348,7 +348,7 @@ public void test204bAutzJackCaseAssigneeSelfRole() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); @@ -404,7 +404,7 @@ public void test204cAutzJackCaseAssigneeSelfWithDelegatesRole() throws Exception login(USER_DEPUTY_1_NAME); // WHEN - when(TEST_NAME); + when(); assertGetDeny(UserType.class, USER_JACK_OID); assertGetAllow(UserType.class, USER_DEPUTY_1_OID); @@ -468,7 +468,7 @@ public void test204dAutzJackCaseAssigneeSelfWithNonWorkItemsDelegatesRole() thro login(USER_DEPUTY_2_NAME); // WHEN - when(TEST_NAME); + when(); assertGetDeny(UserType.class, USER_JACK_OID); assertGetAllow(UserType.class, USER_DEPUTY_2_OID); @@ -528,7 +528,7 @@ public void test205AutzJackObjectFilterModifyCaribbeanfRole() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertReadAllow(); assertReadDenyRaw(); @@ -553,7 +553,7 @@ public void test207AutzJackObjectFilterCaribbeanRole() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_JACK_OID, SelectorOptions.createCollection(GetOperationOptions.createRaw())); @@ -591,7 +591,7 @@ public void test207rAutzJackObjectFilterCaribbeanRole() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertGetAllow(UserType.class, USER_JACK_OID, SelectorOptions.createCollection(GetOperationOptions.createRaw())); @@ -644,7 +644,7 @@ public void testAutzJackReadSomeRoles(final String TEST_NAME, String roleOid) th login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertReadDeny(); assertReadDenyRaw(); @@ -701,7 +701,7 @@ public void test210AutzJackPropReadAllModifySome() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertReadAllow(); assertReadDenyRaw(); @@ -738,7 +738,7 @@ public void test211AutzJackPropReadAllModifySomeUser() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_JACK_OID, SelectorOptions.createCollection(GetOperationOptions.createRaw())); @@ -786,7 +786,7 @@ public void test212AutzJackPropReadAllModifySomeUserPartial() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_JACK_OID, SelectorOptions.createCollection(GetOperationOptions.createRaw())); @@ -883,7 +883,7 @@ public void test217AutzJackPropGetSearchSomeModifySomeUser() throws Exception { private void doReadSomeModifySomeUser(final String TEST_NAME) throws Exception { // WHEN - when(TEST_NAME); + when(); PrismObject userJack = getUser(USER_JACK_OID); display("Jack", userJack); @@ -920,7 +920,7 @@ public void testAutzJackPropReadSomeModifySome(final String TEST_NAME, String ro login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertReadSomeModifySome(1); @@ -936,7 +936,7 @@ public void test218AutzJackPropReadSomeModifySomeExecAll() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertReadAllow(); @@ -1016,7 +1016,7 @@ public void test219AutzJackPropReadSomeModifySomeFullName() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertReadAllow(); @@ -1175,7 +1175,7 @@ public void test220AutzJackPropDenyModifySome() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertReadAllow(); @@ -1240,7 +1240,7 @@ public void test230AutzJackMasterMinistryOfRum() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertReadDeny(3); assertAddDeny(); @@ -1271,7 +1271,7 @@ public void test232AutzJackReadOrgMinistryOfRum() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertReadDeny(0); assertAddDeny(); @@ -1308,7 +1308,7 @@ public void test240AutzJackManagerFullControlNoOrg() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertReadDeny(0); assertAddDeny(); @@ -1359,7 +1359,7 @@ public void test241AutzJackManagerFullControlMemberMinistryOfRum() throws Except login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertJack24xMember(accountOid, true); @@ -1387,7 +1387,7 @@ public void test242AutzJackManagerFullControlManagerMinistryOfRum() throws Excep login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertJack24xManager(TEST_NAME, true); @@ -1418,7 +1418,7 @@ public void test243AutzJackManagerFullControlManagerMinistryOfRumAndDefense() th login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertJack24xManagerDefense(TEST_NAME, true); @@ -1444,7 +1444,7 @@ public void test245AutzJackManagerUserAdminMemberMinistryOfRum() throws Exceptio login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertJack24xMember(accountOid, false); @@ -1472,7 +1472,7 @@ public void test246AutzJackManagerUserAdminManagerMinistryOfRum() throws Excepti login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertJack24xManager(TEST_NAME, false); @@ -1501,7 +1501,7 @@ public void test247AutzJackManagerUserAdminManagerMinistryOfRumAndDefense() thro login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertJack24xManagerDefense(TEST_NAME, false); @@ -1747,7 +1747,7 @@ public void test250AutzJackSelfAccountsRead() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); @@ -1815,7 +1815,7 @@ public void test255AutzJackSelfAccountsReadWrite() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); @@ -1880,7 +1880,7 @@ public void test256AutzJackSelfAccountsPartialControl() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); @@ -1962,7 +1962,7 @@ public void test258AutzJackSelfAccountsPartialControlPassword() throws Exception login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); @@ -2025,7 +2025,7 @@ public void test259AutzJackSelfAccountsPartialControl() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); @@ -2093,7 +2093,7 @@ public void test260AutzJackObjectFilterLocationShadowRole() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); // WHEN - when(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_JACK_OID, SelectorOptions.createCollection(GetOperationOptions.createRaw())); @@ -2165,7 +2165,7 @@ public void test261AutzAngelicaObjectFilterLocationCreateUserShadowRole() throws assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); // WHEN - when(TEST_NAME); + when(); assertAllow("add user angelica", (task, result) -> addObject(USER_ANGELICA_FILE, task, result)); @@ -2196,7 +2196,7 @@ public void test270AutzJackAssignApplicationRoles() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertReadAllow(NUMBER_OF_ALL_USERS + 1); assertAddDeny(); @@ -2250,7 +2250,7 @@ public void test272AutzJackAssignAnyRoles() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertReadAllow(NUMBER_OF_ALL_USERS + 1); assertAddDeny(); @@ -2309,7 +2309,7 @@ public void test273AutzJackRedyAssignmentExceptionRules() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertReadAllow(NUMBER_OF_ALL_USERS + 1); assertAddDeny(); @@ -2362,7 +2362,7 @@ public void test274AutzJackAssignNonApplicationRoles() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertReadAllow(NUMBER_OF_ALL_USERS + 1); assertAddDeny(); @@ -2409,7 +2409,7 @@ public void test275aAutzJackAssignRequestableRoles() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertReadAllow(NUMBER_OF_ALL_USERS + 1); assertAddDeny(); @@ -2463,7 +2463,7 @@ public void test275bAutzJackAssignRequestableOrgs() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); PrismObject user = getUser(USER_JACK_OID); assertAssignments(user, 1); assertAssignedRole(user, ROLE_END_USER_REQUESTABLE_ABSTRACTROLES_OID); @@ -2508,7 +2508,7 @@ public void test275cAutzJackAssignRequestableRolesAndInduceAnyRole() throws Exce login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertReadAllow(NUMBER_OF_ALL_USERS + 1); assertAddDeny(); @@ -2563,7 +2563,7 @@ public void test276AutzJackAssignRequestableRolesWithOrgRef() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertReadAllow(NUMBER_OF_ALL_USERS + 1); assertAddDeny(); @@ -2616,7 +2616,7 @@ public void test277AutzJackAssignRequestableRolesWithOrgRefSecondTime() throws E login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertReadAllow(NUMBER_OF_ALL_USERS + 1); assertAddDeny(); @@ -2698,7 +2698,7 @@ public void test278AutzJackAssignRequestableRolesWithOrgRefTweakedDelta() throws login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertReadAllow(NUMBER_OF_ALL_USERS + 1); assertAddDeny(); @@ -2766,7 +2766,7 @@ public void test279AutzJackAssignRequestableRolesWithTenantRef() throws Exceptio login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertReadAllow(NUMBER_OF_ALL_USERS + 1); assertAddDeny(); @@ -2824,7 +2824,7 @@ public void test280AutzJackEndUser() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertGetDeny(UserType.class, USER_JACK_OID, SelectorOptions.createCollection(GetOperationOptions.createRaw())); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); @@ -2907,7 +2907,7 @@ public void test281AutzJackEndUserSecondTime() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); PrismObject user = getUser(USER_JACK_OID); assertAssignments(user, 1); @@ -2973,7 +2973,7 @@ public void test282AutzJackEndUserAndModify() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertReadAllow(NUMBER_OF_ALL_USERS + 1); assertAddDeny(); @@ -3014,7 +3014,7 @@ public void test283AutzJackModifyAndEndUser() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertReadAllow(NUMBER_OF_ALL_USERS + 1); assertAddDeny(); @@ -3047,7 +3047,7 @@ public void test285AutzJackEndUserAndAdd() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertReadAllow(NUMBER_OF_ALL_USERS + 1); @@ -3078,7 +3078,7 @@ public void test295AutzJackAssignOrgRelation() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); ObjectFilter jackAssignableRoleFilter = assertAssignableRoleSpecification(getUser(USER_JACK_OID)) .relationDefault() @@ -3236,7 +3236,7 @@ public void test370AutzJackLimitedUserAdmin() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertGetAllow(UserType.class, USER_GUYBRUSH_OID); @@ -3263,7 +3263,7 @@ public void test380AutzJackSelfTaskOwner() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertGetDeny(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityMedium.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityMedium.java index 919de863ea2..0f03b6409da 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityMedium.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityMedium.java @@ -58,7 +58,7 @@ public void test000Sanity() throws Exception { cleanupAutzTest(USER_JACK_OID); // WHEN - when(TEST_NAME); + when(); assertSearch(UserType.class, null, NUMBER_OF_ALL_USERS); assertSearch(RoleType.class, null, getNumberOfRoles()); @@ -84,7 +84,7 @@ public void test100AutzEmployeeManager() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertGetDeny(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); @@ -114,7 +114,7 @@ public void test102AutzEmployeeManagerAddEmployee() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertAddAllow(USER_EMPLOYEE_FRED_FILE); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityMultitenant.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityMultitenant.java index 3c9f56708a8..1449864b2ee 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityMultitenant.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityMultitenant.java @@ -216,7 +216,7 @@ public void test000Sanity() throws Exception { cleanupAutzTest(USER_JACK_OID); // WHEN - when(TEST_NAME); + when(); assertSearch(UserType.class, null, NUMBER_OF_ALL_USERS); assertSearch(RoleType.class, null, getNumberOfRoles()); @@ -246,11 +246,11 @@ public void test010ImportOrgstruct() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); importObjectsFromFileNotRaw(ORG_MULTITENANT_FILE, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); dumpOrgTree(); @@ -382,7 +382,7 @@ public void test100AutzLetoRead() throws Exception { login(USER_LETO_ATREIDES_NAME); // WHEN - when(TEST_NAME); + when(); // Matching tenant assertGetAllow(UserType.class, USER_LETO_ATREIDES_OID); @@ -406,7 +406,7 @@ public void test100AutzLetoRead() throws Exception { assertSearch(OrgType.class, null, ORG_ATREIDES_OID, ORG_CALADAN_OID); // THEN - then(TEST_NAME); + then(); assertGlobalStateUntouched(); } @@ -423,7 +423,7 @@ public void test102AutzLetoAdd() throws Exception { login(USER_LETO_ATREIDES_NAME); // WHEN - when(TEST_NAME); + when(); // Matching tenant assertAddAllow(USER_DUNCAN_FILE); @@ -435,7 +435,7 @@ public void test102AutzLetoAdd() throws Exception { assertAddDeny(USER_DMURR_FILE); // THEN - then(TEST_NAME); + then(); login(USER_ADMINISTRATOR_USERNAME); @@ -467,7 +467,7 @@ public void test104AutzLetoModify() throws Exception { login(USER_LETO_ATREIDES_NAME); // WHEN - when(TEST_NAME); + when(); // Matching tenant assertModifyAllow(UserType.class, USER_PAUL_ATREIDES_OID, UserType.F_LOCALITY, createPolyString("Arrakis")); @@ -479,7 +479,7 @@ public void test104AutzLetoModify() throws Exception { assertModifyDeny(UserType.class, USER_EDRIC_OID, UserType.F_LOCALITY, createPolyString("Whatever")); // THEN - then(TEST_NAME); + then(); assertGlobalStateUntouched(); } @@ -498,7 +498,7 @@ public void test106AutzLetoAddResourceTask() throws Exception { login(USER_LETO_ATREIDES_NAME); // WHEN - when(TEST_NAME); + when(); // Matching tenant assertAddDummyResourceAllow(RESOURCE_DUMMY_CASTLE_CALADAN_FILE); @@ -510,7 +510,7 @@ public void test106AutzLetoAddResourceTask() throws Exception { assertAddDummyResourceDeny(RESOURCE_DUMMY_JUNCTION_FILE); // THEN - then(TEST_NAME); + then(); login(USER_ADMINISTRATOR_USERNAME); @@ -543,7 +543,7 @@ public void test109AutzLetoDelete() throws Exception { login(USER_LETO_ATREIDES_NAME); // WHEN - when(TEST_NAME); + when(); // Matching tenant assertDeleteAllow(UserType.class, USER_DUNCAN_OID); @@ -555,7 +555,7 @@ public void test109AutzLetoDelete() throws Exception { assertDeleteDeny(UserType.class, USER_DMURR_OID); // THEN - then(TEST_NAME); + then(); assertGlobalStateUntouched(); } @@ -572,7 +572,7 @@ public void test110AutzLetoAddOrgs() throws Exception { login(USER_LETO_ATREIDES_NAME); // WHEN - when(TEST_NAME); + when(); // Matching tenant assertAddAllow(ORG_ARRAKIS_FILE); @@ -585,7 +585,7 @@ public void test110AutzLetoAddOrgs() throws Exception { assertAddDeny(ORG_JUNCTION_FILE); // THEN - then(TEST_NAME); + then(); login(USER_ADMINISTRATOR_USERNAME); @@ -626,7 +626,7 @@ public void test112AutzLetoProtectTenant() throws Exception { login(USER_LETO_ATREIDES_NAME); // WHEN - when(TEST_NAME); + when(); // Matching tenant assertAddDeny(ORG_ATREIDES_SUBTENANT_FILE); @@ -677,7 +677,7 @@ public void test112AutzLetoProtectTenant() throws Exception { assertDeleteDeny(OrgType.class, ORG_GUILD_OID); // THEN - then(TEST_NAME); + then(); assertGlobalStateUntouched(); } @@ -695,7 +695,7 @@ public void test114AutzLetoKeepWithinTenant() throws Exception { login(USER_LETO_ATREIDES_NAME); // WHEN - when(TEST_NAME); + when(); assertAddAllow(ROLE_ATREIDES_GUARD_FILE); @@ -740,7 +740,7 @@ public void test114AutzLetoKeepWithinTenant() throws Exception { (task, result) -> unassignOrg(OrgType.class, ORG_CASTLE_CALADAN_OID, ORG_CALADAN_OID, task, result)); // THEN - then(TEST_NAME); + then(); assertGlobalStateUntouched(); } @@ -757,7 +757,7 @@ public void test116AutzLetoProtectTenantAdminRole() throws Exception { login(USER_LETO_ATREIDES_NAME); // WHEN - when(TEST_NAME); + when(); assertAddDeny(ROLE_ATREIDES_HACKER_FILE); @@ -797,7 +797,7 @@ public void test116AutzLetoProtectTenantAdminRole() throws Exception { RoleType.F_POLICY_EXCEPTION, task, result, policyException)); // THEN - then(TEST_NAME); + then(); assertGlobalStateUntouched(); } @@ -816,7 +816,7 @@ public void test118AutzLetoBusinessRoles() throws Exception { assertAddAllow(ROLE_ATREIDES_GUARD_FILE); // WHEN - when(TEST_NAME); + when(); assertAddAllow(ROLE_ATREIDES_SWORDMASTER_FILE); @@ -835,7 +835,7 @@ public void test118AutzLetoBusinessRoles() throws Exception { assertDeleteAllow(RoleType.class, ROLE_ATREIDES_SWORDMASTER_OID); // THEN - then(TEST_NAME); + then(); assertGlobalStateUntouched(); } @@ -855,7 +855,7 @@ public void test120AutzPaulEndUser() throws Exception { login(USER_PAUL_ATREIDES_NAME); // WHEN - when(TEST_NAME); + when(); // Requestable role assertAllow("assign guard to paul", @@ -874,7 +874,7 @@ public void test120AutzPaulEndUser() throws Exception { (task, result) -> assignRole(USER_PAUL_ATREIDES_OID, ROLE_CORRINO_EMPEROR_OID, task, result)); // THEN - then(TEST_NAME); + then(); assertGlobalStateUntouched(); } @@ -891,7 +891,7 @@ public void test122AutzDuncanRoleManager() throws Exception { login(USER_DUNCAN_NAME); // WHEN - when(TEST_NAME); + when(); assertDeny("assign guard to paul", (task, result) -> assignRole(USER_PAUL_ATREIDES_OID, ROLE_ATREIDES_GUARD_OID, task, result)); @@ -915,7 +915,7 @@ public void test122AutzDuncanRoleManager() throws Exception { (task, result) -> induceOrg(RoleType.class, ROLE_ATREIDES_SWORDMASTER_OID, ORG_CALADAN_OID, task, result)); // THEN - then(TEST_NAME); + then(); assertGlobalStateUntouched(); } @@ -937,7 +937,7 @@ public void test130AutzEdricRead() throws Exception { login(USER_EDRIC_NAME); // WHEN - when(TEST_NAME); + when(); // Wrong tenant assertGetDeny(UserType.class, USER_LETO_ATREIDES_OID); @@ -955,7 +955,7 @@ public void test130AutzEdricRead() throws Exception { assertSearch(OrgType.class, null, 0); // THEN - then(TEST_NAME); + then(); assertGlobalStateUntouched(); } diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityPrincipal.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityPrincipal.java index a632856dde0..93c14b2ce37 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityPrincipal.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityPrincipal.java @@ -274,11 +274,11 @@ public void test110GuybrushRoleNicePirate() throws Exception { resetAuthentication(); // WHEN - when(TEST_NAME); + when(); MidPointPrincipal principal = focusProfileService.getPrincipal(USER_GUYBRUSH_USERNAME, UserType.class); // THEN - then(TEST_NAME); + then(); display("Principal guybrush", principal); assertEquals("Wrong number of authorizations", 2, principal.getAuthorities().size()); @@ -298,11 +298,11 @@ public void test111GuybrushRoleCaptain() throws Exception { resetAuthentication(); // WHEN - when(TEST_NAME); + when(); MidPointPrincipal principal = focusProfileService.getPrincipal(USER_GUYBRUSH_USERNAME, UserType.class); // THEN - then(TEST_NAME); + then(); display("Principal guybrush", principal); assertEquals("Wrong number of authorizations", 3, principal.getAuthorities().size()); @@ -323,11 +323,11 @@ public void test119GuybrushUnassignRoles() throws Exception { resetAuthentication(); // WHEN - when(TEST_NAME); + when(); MidPointPrincipal principal = focusProfileService.getPrincipal(USER_JACK_USERNAME, UserType.class); // THEN - then(TEST_NAME); + then(); assertEquals("Wrong number of authorizations", 0, principal.getAuthorities().size()); assertNotAuthorized(principal, AUTZ_LOOT_URL); @@ -352,11 +352,11 @@ public void test120JackRoleIndirectPirate() throws Exception { resetAuthentication(); // WHEN - when(TEST_NAME); + when(); MidPointPrincipal principal = focusProfileService.getPrincipal(USER_JACK_USERNAME, UserType.class); // THEN - then(TEST_NAME); + then(); display("Principal guybrush", principal); assertEquals("Wrong number of authorizations", 1, principal.getAuthorities().size()); @@ -384,11 +384,11 @@ public void test122JackOrgIndirectPirate() throws Exception { resetAuthentication(); // WHEN - when(TEST_NAME); + when(); MidPointPrincipal principal = focusProfileService.getPrincipal(USER_JACK_USERNAME, UserType.class); // THEN - then(TEST_NAME); + then(); display("Principal guybrush", principal); assertEquals("Wrong number of authorizations", 1, principal.getAuthorities().size()); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractObjTemplateSyncTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractObjTemplateSyncTest.java index 5d541191928..3b4ecc9aab3 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractObjTemplateSyncTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractObjTemplateSyncTest.java @@ -148,7 +148,7 @@ public void test110AddDummyByzantineAccountMancomb() throws Exception { account.addAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME, gossip); /// WHEN - when(TEST_NAME); + when(); display("Adding dummy account", account.debugDump()); @@ -157,7 +157,7 @@ public void test110AddDummyByzantineAccountMancomb() throws Exception { waitForSyncTaskNextRun(resourceDummyByzantine); // THEN - then(TEST_NAME); + then(); PrismObject accountMancomb = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, resourceDummyByzantine); display("Account mancomb", accountMancomb); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractSynchronizationStoryTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractSynchronizationStoryTest.java index eaaa30221f2..3693fdd6e0d 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractSynchronizationStoryTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractSynchronizationStoryTest.java @@ -112,11 +112,11 @@ public void test100ImportLiveSyncTaskDummyGreen() throws Exception { OperationResult result = task.getResult(); /// WHEN - when(TEST_NAME); + when(); importSyncTask(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); // THEN - then(TEST_NAME); + then(); waitForSyncTaskStart(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); } @@ -143,14 +143,14 @@ public void test110AddDummyGreenAccountMancomb() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Melee Island"); /// WHEN - when(TEST_NAME); + when(); getDummyResource(RESOURCE_DUMMY_GREEN_NAME).addAccount(account); waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); // THEN - then(TEST_NAME); + then(); PrismObject accountMancomb = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); display("Account mancomb", accountMancomb); @@ -198,11 +198,11 @@ public void test200ImportLiveSyncTaskDummyBlue() throws Exception { OperationResult result = task.getResult(); /// WHEN - when(TEST_NAME); + when(); importSyncTask(getDummyResourceObject(RESOURCE_DUMMY_BLUE_NAME)); // THEN - then(TEST_NAME); + then(); waitForSyncTaskStart(getDummyResourceObject(RESOURCE_DUMMY_BLUE_NAME)); } @@ -222,14 +222,14 @@ public void test210AddDummyGreenAccountWally() throws Exception { prepareNotifications(); /// WHEN - when(TEST_NAME); + when(); getDummyResourceController(RESOURCE_DUMMY_GREEN_NAME).addAccount(ACCOUNT_WALLY_DUMMY_USERNAME, "Wally Feed", "Scabb Island"); // Wait for sync task to pick up the change waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); // THEN - then(TEST_NAME); + then(); dumpSyncTaskTree(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME), result); @@ -274,7 +274,7 @@ public void test220AddDummyBlueAccountWally() throws Exception { prepareNotifications(); /// WHEN - when(TEST_NAME); + when(); getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).addAccount(ACCOUNT_WALLY_DUMMY_USERNAME, "Wally Feed", "Scabb Island"); // Wait for sync task to pick up the change @@ -288,7 +288,7 @@ public void test220AddDummyBlueAccountWally() throws Exception { waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject(RESOURCE_DUMMY_BLUE_NAME)); // THEN - then(TEST_NAME); + then(); dumpSyncTaskTree(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME), result); dumpSyncTaskTree(getDummyResourceObject(RESOURCE_DUMMY_BLUE_NAME), result); @@ -338,7 +338,7 @@ public void test315AddDummyBlueAccountMancomb() throws Exception { prepareNotifications(); /// WHEN - when(TEST_NAME); + when(); getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).addAccount(ACCOUNT_MANCOMB_DUMMY_USERNAME, "Mancomb Seepgood", "Melee Island"); // Wait for sync task to pick up the change @@ -351,7 +351,7 @@ public void test315AddDummyBlueAccountMancomb() throws Exception { waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject(RESOURCE_DUMMY_BLUE_NAME)); // THEN - then(TEST_NAME); + then(); // The ckecks are simplified here because the developer has a lazy mood :-) assertDummyAccount(RESOURCE_DUMMY_BLUE_NAME, ACCOUNT_MANCOMB_DUMMY_USERNAME, "Mancomb Seepgood", true); @@ -393,11 +393,11 @@ public void test350ImportLiveSyncTaskDummyDefault() throws Exception { OperationResult result = task.getResult(); /// WHEN - when(TEST_NAME); + when(); importSyncTask(getDummyResourceObject()); // THEN - then(TEST_NAME); + then(); waitForSyncTaskStart(getDummyResourceObject()); @@ -428,11 +428,11 @@ public void test360ModifyUserAddDummyDefaultAccount() throws Exception { Collection> deltas = (Collection)MiscUtil.createCollection(userDelta); /// WHEN - when(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - then(TEST_NAME); + then(); dumpSyncTaskTree(getDummyResourceObject(), result); dumpSyncTaskTree(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME), result); @@ -545,7 +545,7 @@ public void test370ModifyDummyGreenAccountWally() throws Exception { DummyAccount wallyDummyAccount = getDummyResource(RESOURCE_DUMMY_GREEN_NAME).getAccountByUsername(ACCOUNT_WALLY_DUMMY_USERNAME); /// WHEN - when(TEST_NAME); + when(); wallyDummyAccount.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Wally B. Feed"); // Wait for sync task to pick up the change @@ -560,7 +560,7 @@ public void test370ModifyDummyGreenAccountWally() throws Exception { waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject()); // THEN - then(TEST_NAME); + then(); dumpSyncTaskTree(getDummyResourceObject(), result); dumpSyncTaskTree(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME), result); @@ -627,7 +627,7 @@ public void test380ModifyUserWallyFullName() throws Exception { DummyAccount wallyDummyAccount = getDummyResource(RESOURCE_DUMMY_GREEN_NAME).getAccountByUsername(ACCOUNT_WALLY_DUMMY_USERNAME); /// WHEN - when(TEST_NAME); + when(); modifyUserReplace(userWallyOid, UserType.F_FULL_NAME, task, result, PrismTestUtil.createPolyString("Bloodnose")); // Wait for sync tasks to pick up the change and have some chance to screw things @@ -643,7 +643,7 @@ public void test380ModifyUserWallyFullName() throws Exception { waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); // THEN - then(TEST_NAME); + then(); dumpSyncTaskTree(getDummyResourceObject(), result); dumpSyncTaskTree(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME), result); @@ -697,7 +697,7 @@ public void test382ModifyUserWallyLocality() throws Exception { DummyAccount wallyDummyAccount = getDummyResource(RESOURCE_DUMMY_GREEN_NAME).getAccountByUsername(ACCOUNT_WALLY_DUMMY_USERNAME); /// WHEN - when(TEST_NAME); + when(); modifyUserReplace(userWallyOid, UserType.F_LOCALITY, task, result, PrismTestUtil.createPolyString("Plunder island")); // Wait for sync tasks to pick up the change and have some chance to screw things @@ -713,7 +713,7 @@ public void test382ModifyUserWallyLocality() throws Exception { waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); // THEN - then(TEST_NAME); + then(); dumpSyncTaskTree(getDummyResourceObject(), result); dumpSyncTaskTree(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME), result); @@ -776,7 +776,7 @@ public void test400DeleteDummyDefaultAccount() throws Exception { prepareNotifications(); /// WHEN - when(TEST_NAME); + when(); getDummyResource().deleteAccountByName(ACCOUNT_WALLY_DUMMY_USERNAME); display("Dummy (default) resource", getDummyResource().debugDump()); @@ -787,7 +787,7 @@ public void test400DeleteDummyDefaultAccount() throws Exception { waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); // THEN - then(TEST_NAME); + then(); dumpSyncTaskTree(getDummyResourceObject(), result); dumpSyncTaskTree(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME), result); @@ -844,7 +844,7 @@ public void test410DeleteDummyGreenAccount() throws Exception { prepareNotifications(); /// WHEN - when(TEST_NAME); + when(); getDummyResource(RESOURCE_DUMMY_GREEN_NAME).deleteAccountByName(ACCOUNT_WALLY_DUMMY_USERNAME); // Make sure we have steady state @@ -853,7 +853,7 @@ public void test410DeleteDummyGreenAccount() throws Exception { waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); // THEN - then(TEST_NAME); + then(); dumpSyncTaskTree(getDummyResourceObject(), result); dumpSyncTaskTree(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME), result); @@ -941,14 +941,14 @@ public void test510AddDummyGreenAccountWallyUserTemplate() throws Exception { assumeUserTemplate(USER_TEMPLATE_SYNC_OID, getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME).asObjectable(), null, result); /// WHEN - when(TEST_NAME); + when(); getDummyResourceController(RESOURCE_DUMMY_GREEN_NAME).addAccount(ACCOUNT_WALLY_DUMMY_USERNAME, "Wally Feed", "Scabb Island"); // Wait for sync task to pick up the change waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); // THEN - then(TEST_NAME); + then(); PrismObject accountWallyGreen = checkWallyAccount(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME), getDummyResource(RESOURCE_DUMMY_GREEN_NAME), "green", "Wally Feed"); assertShadowOperationalData(accountWallyGreen, SynchronizationSituationType.LINKED); @@ -992,14 +992,14 @@ public void test600AddDummyGreenAccountCalypso() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "The Seven Seas"); /// WHEN - when(TEST_NAME); + when(); getDummyResource(RESOURCE_DUMMY_GREEN_NAME).addAccount(account); waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); // THEN - then(TEST_NAME); + then(); PrismObject accountShadow = findAccountByUsername(ACCOUNT_CALYPSO_DUMMY_USERNAME, getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); display("Account calypso", accountShadow); @@ -1038,14 +1038,14 @@ public void test700AddDummyGreenAccountXjojo() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Scabb Island"); /// WHEN - when(TEST_NAME); + when(); getDummyResource(RESOURCE_DUMMY_GREEN_NAME).addAccount(account); waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); // THEN - then(TEST_NAME); + then(); PrismObject accountAfter = findAccountByUsername("Xjojo", getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); display("Account after", accountAfter); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestImportRecon.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestImportRecon.java index 3bad0e2f56f..f46bdf4fead 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestImportRecon.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestImportRecon.java @@ -374,11 +374,11 @@ public void test100ImportStanFromResourceDummy() throws Exception { loginImportUser(); // WHEN - when(TEST_NAME); + when(); modelService.importFromResource(ACCOUNT_STAN_OID, task, result); // THEN - then(TEST_NAME); + then(); display(result); assertSuccess(result); @@ -430,11 +430,11 @@ public void test150ImportFromResourceDummy() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - when(TEST_NAME); + when(); modelService.importFromResource(RESOURCE_DUMMY_OID, new QName(RESOURCE_DUMMY_NAMESPACE, "AccountObjectClass"), task, result); // THEN - then(TEST_NAME); + then(); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); @@ -443,7 +443,7 @@ public void test150ImportFromResourceDummy() throws Exception { waitForTaskFinish(task, true, 40000); // THEN - then(TEST_NAME); + then(); TestUtil.assertSuccess(task.getResult()); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 6); @@ -489,11 +489,11 @@ public void test155ImportFromResourceDummyAgain() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - when(TEST_NAME); + when(); modelService.importFromResource(RESOURCE_DUMMY_OID, new QName(RESOURCE_DUMMY_NAMESPACE, "AccountObjectClass"), task, result); // THEN - then(TEST_NAME); + then(); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); @@ -502,7 +502,7 @@ public void test155ImportFromResourceDummyAgain() throws Exception { waitForTaskFinish(task, true, 40000); // THEN - then(TEST_NAME); + then(); assertSuccess(task.getResult()); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 3); @@ -557,11 +557,11 @@ public void test160ImportFromResourceDummyLime() throws Exception { loginImportUser(); // WHEN - when(TEST_NAME); + when(); modelService.importFromResource(RESOURCE_DUMMY_LIME_OID, new QName(RESOURCE_DUMMY_LIME_NAMESPACE, "AccountObjectClass"), task, result); // THEN - then(TEST_NAME); + then(); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); @@ -570,7 +570,7 @@ public void test160ImportFromResourceDummyLime() throws Exception { waitForTaskFinish(task, true, 40000); // THEN - then(TEST_NAME); + then(); TestUtil.assertSuccess(task.getResult()); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 2); @@ -635,11 +635,11 @@ public void test162ImportFromResourceDummyLimeRappOrganizationScummBar() throws rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - when(TEST_NAME); + when(); modelService.importFromResource(RESOURCE_DUMMY_LIME_OID, new QName(RESOURCE_DUMMY_LIME_NAMESPACE, "AccountObjectClass"), task, result); // THEN - then(TEST_NAME); + then(); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); @@ -648,7 +648,7 @@ public void test162ImportFromResourceDummyLimeRappOrganizationScummBar() throws waitForTaskFinish(task, true, 40000); // THEN - then(TEST_NAME); + then(); TestUtil.assertSuccess(task.getResult()); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 2); @@ -720,11 +720,11 @@ public void test164ImportFromResourceDummyLimeRappOrganizationNull() throws Exce rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - when(TEST_NAME); + when(); modelService.importFromResource(RESOURCE_DUMMY_LIME_OID, new QName(RESOURCE_DUMMY_LIME_NAMESPACE, "AccountObjectClass"), task, result); // THEN - then(TEST_NAME); + then(); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); @@ -733,7 +733,7 @@ public void test164ImportFromResourceDummyLimeRappOrganizationNull() throws Exce waitForTaskFinish(task, true, 40000); // THEN - then(TEST_NAME); + then(); assertSuccess(task.getResult()); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 2); @@ -813,16 +813,16 @@ public void test200ReconcileDummy() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - when(TEST_NAME); + when(); importObjectFromFile(TASK_RECONCILE_DUMMY_SINGLE_FILE); // THEN - then(TEST_NAME); + then(); waitForTaskFinish(TASK_RECONCILE_DUMMY_OID, false); // THEN - then(TEST_NAME); + then(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 6); reconciliationTaskResultListener.assertResult(RESOURCE_DUMMY_OID, 0, 7, 0, 0); @@ -912,12 +912,12 @@ public void test210ReconcileDummyBroken() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - when(TEST_NAME); + when(); restartTask(TASK_RECONCILE_DUMMY_OID); waitForTaskFinish(TASK_RECONCILE_DUMMY_OID, false, DEFAULT_TASK_WAIT_TIMEOUT, true); // THEN - then(TEST_NAME); + then(); List> users = modelService.searchObjects(UserType.class, null, null, task, result); display("Users after reconciliation (broken resource)", users); @@ -978,12 +978,12 @@ public void test219ReconcileDummyFixed() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - when(TEST_NAME); + when(); restartTask(TASK_RECONCILE_DUMMY_OID); waitForTaskFinish(TASK_RECONCILE_DUMMY_OID, false, DEFAULT_TASK_WAIT_TIMEOUT, true); // THEN - then(TEST_NAME); + then(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 6); reconciliationTaskResultListener.assertResult(RESOURCE_DUMMY_OID, 0, 7, 0, 0); @@ -1063,12 +1063,12 @@ public void test220ReconcileDummyBrokenGuybrush() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - when(TEST_NAME); + when(); restartTask(TASK_RECONCILE_DUMMY_OID); waitForTaskFinish(TASK_RECONCILE_DUMMY_OID, false, DEFAULT_TASK_WAIT_TIMEOUT, true); // THEN - then(TEST_NAME); + then(); List> users = modelService.searchObjects(UserType.class, null, null, task, result); display("Users after reconciliation (broken resource account)", users); @@ -1132,12 +1132,12 @@ public void test229ReconcileDummyFixed() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - when(TEST_NAME); + when(); restartTask(TASK_RECONCILE_DUMMY_OID); waitForTaskFinish(TASK_RECONCILE_DUMMY_OID, false, DEFAULT_TASK_WAIT_TIMEOUT, true); // THEN - then(TEST_NAME); + then(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 6); reconciliationTaskResultListener.assertResult(RESOURCE_DUMMY_OID, 0, 7, 0, 0); @@ -1222,12 +1222,12 @@ public void test230ReconcileDummyRename() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - when(TEST_NAME); + when(); restartTask(TASK_RECONCILE_DUMMY_OID); waitForTaskFinish(TASK_RECONCILE_DUMMY_OID, false, DEFAULT_TASK_WAIT_TIMEOUT, true); // THEN - then(TEST_NAME); + then(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 6); reconciliationTaskResultListener.assertResult(RESOURCE_DUMMY_OID, 0, 7, 0, 1); @@ -1338,15 +1338,15 @@ public void test300ReconcileDummyAzureAddAccountOtis() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - when(TEST_NAME); + when(); importObjectFromFile(TASK_RECONCILE_DUMMY_AZURE_FILE); // THEN - then(TEST_NAME); + then(); waitForTaskFinish(TASK_RECONCILE_DUMMY_AZURE_OID, false); - then(TEST_NAME); + then(); List> users = modelService.searchObjects(UserType.class, null, null, task, result); display("Users after reconcile", users); @@ -1401,15 +1401,15 @@ public void test310ReconcileDummyAzureAgain() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - when(TEST_NAME); + when(); restartTask(TASK_RECONCILE_DUMMY_AZURE_OID); // THEN - then(TEST_NAME); + then(); waitForTaskFinish(TASK_RECONCILE_DUMMY_AZURE_OID, false); - then(TEST_NAME); + then(); reconciliationTaskResultListener.assertResult(RESOURCE_DUMMY_AZURE_OID, 0, 1, 0, 0); List> users = modelService.searchObjects(UserType.class, null, null, task, result); @@ -1470,15 +1470,15 @@ public void test320ReconcileDummyAzureDeleteOtis() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - when(TEST_NAME); + when(); restartTask(TASK_RECONCILE_DUMMY_AZURE_OID); // THEN - then(TEST_NAME); + then(); waitForTaskFinish(TASK_RECONCILE_DUMMY_AZURE_OID, false); - then(TEST_NAME); + then(); List> users = modelService.searchObjects(UserType.class, null, null, task, result); display("Users after reconcile", users); @@ -1544,15 +1544,15 @@ public void test330ReconcileDummyAzureAddAccountRapp() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - when(TEST_NAME); + when(); restartTask(TASK_RECONCILE_DUMMY_AZURE_OID); // THEN - then(TEST_NAME); + then(); waitForTaskFinish(TASK_RECONCILE_DUMMY_AZURE_OID, false); - then(TEST_NAME); + then(); List> users = modelService.searchObjects(UserType.class, null, null, task, result); display("Users after reconcile", users); @@ -1651,15 +1651,15 @@ public void test332ModifyUserRappAndReconcileDummyAzure() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - when(TEST_NAME); + when(); restartTask(TASK_RECONCILE_DUMMY_AZURE_OID); // THEN - then(TEST_NAME); + then(); waitForTaskFinish(TASK_RECONCILE_DUMMY_AZURE_OID, false); - then(TEST_NAME); + then(); List> users = modelService.searchObjects(UserType.class, null, null, task, result); display("Users after reconcile", users); @@ -1725,15 +1725,15 @@ public void test334AssignRoleCorpseToRappAndReconcileDummyAzure() throws Excepti reconciliationTaskResultListener.clear(); // WHEN - when(TEST_NAME); + when(); restartTask(TASK_RECONCILE_DUMMY_AZURE_OID); // THEN - then(TEST_NAME); + then(); waitForTaskFinish(TASK_RECONCILE_DUMMY_AZURE_OID, false); - then(TEST_NAME); + then(); List> users = modelService.searchObjects(UserType.class, null, null, task, result); display("Users after reconcile", users); @@ -1795,15 +1795,15 @@ public void test339ReconcileDummyAzureDeleteRapp() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - when(TEST_NAME); + when(); restartTask(TASK_RECONCILE_DUMMY_AZURE_OID); // THEN - then(TEST_NAME); + then(); waitForTaskFinish(TASK_RECONCILE_DUMMY_AZURE_OID, false); - then(TEST_NAME); + then(); List> users = modelService.searchObjects(UserType.class, null, null, task, result); display("Users after reconcile", users); @@ -1861,15 +1861,15 @@ public void test400ReconcileDummyLimeAddAccount() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - when(TEST_NAME); + when(); importObjectFromFile(TASK_RECONCILE_DUMMY_LIME_FILE); // THEN - then(TEST_NAME); + then(); waitForTaskFinish(TASK_RECONCILE_DUMMY_LIME_OID, false); - then(TEST_NAME); + then(); List> users = modelService.searchObjects(UserType.class, null, null, task, result); display("Users after reconcile", users); @@ -1916,11 +1916,11 @@ public void test401ReconcileDummyLimeKateOnlyEmpty() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - when(TEST_NAME); + when(); reconcileUser(userBefore.getOid(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1964,11 +1964,11 @@ public void test402ReconcileDummyLimeKateOnlyGrog() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - when(TEST_NAME); + when(); reconcileUser(userBefore.getOid(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2012,11 +2012,11 @@ public void test403ReconcileDummyLimeKateOnlyNoValue() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - when(TEST_NAME); + when(); reconcileUser(userBefore.getOid(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2057,11 +2057,11 @@ public void test404ReconcileDummyLimeKateOnlyRum() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - when(TEST_NAME); + when(); reconcileUser(userBefore.getOid(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2104,11 +2104,11 @@ public void test405ReconcileDummyLimeKateOnlyEmpty() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - when(TEST_NAME); + when(); reconcileUser(userBefore.getOid(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2148,11 +2148,11 @@ public void test406ReconcileDummyLimeKateOnlyEmptyAgain() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - when(TEST_NAME); + when(); reconcileUser(userBefore.getOid(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2193,11 +2193,11 @@ public void test410ReconcileDummyLimeKatePassword() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - when(TEST_NAME); + when(); reconcileUser(userBefore.getOid(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(ACCOUNT_CAPSIZE_NAME); @@ -2237,15 +2237,15 @@ public void test420ReconcileDummyLimeDeleteLinkedAccount() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - when(TEST_NAME); + when(); restartTask(TASK_RECONCILE_DUMMY_LIME_OID); // THEN - then(TEST_NAME); + then(); waitForTaskFinish(TASK_RECONCILE_DUMMY_LIME_OID, false); - then(TEST_NAME); + then(); List> users = modelService.searchObjects(UserType.class, null, null, task, result); display("Users after reconcile", users); @@ -2294,11 +2294,11 @@ public void test500ImportTAugustusFromResourceDummy() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - when(TEST_NAME); + when(); modelService.importFromResource(ACCOUNT_TAUGUSTUS_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); loginAdministrator(); @@ -2363,11 +2363,11 @@ public void test502ImportAugustusFromResourceDummy() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - when(TEST_NAME); + when(); modelService.importFromResource(ACCOUNT_AUGUSTUS_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); loginAdministrator(); @@ -2449,11 +2449,11 @@ public void test510ImportFromResourceDummy() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - when(TEST_NAME); + when(); modelService.importFromResource(RESOURCE_DUMMY_OID, new QName(RESOURCE_DUMMY_NAMESPACE, "AccountObjectClass"), task, result); // THEN - then(TEST_NAME); + then(); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); @@ -2462,7 +2462,7 @@ public void test510ImportFromResourceDummy() throws Exception { waitForTaskFinish(task, true, 40000); // THEN - then(TEST_NAME); + then(); TestUtil.assertSuccess(task.getResult()); // First fetch: search in import handler @@ -2521,7 +2521,7 @@ public void test520ReconResourceDummyFilter() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - when(TEST_NAME); + when(); // runPrivileged is necessary for TestImportReconAuthorizations as importObjectFromFile() is using raw operations runPrivileged(() -> { try { @@ -2552,11 +2552,11 @@ public void test600SearchAllDummyAccounts() throws Exception { new QName(RESOURCE_DUMMY_NAMESPACE, "AccountObjectClass"), prismContext); // WHEN - when(TEST_NAME); + when(); SearchResultList> objects = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2581,11 +2581,11 @@ public void test610SearchDummyAccountsNameSubstring() throws Exception { .build(); // WHEN - when(TEST_NAME); + when(); SearchResultList> objects = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2608,16 +2608,16 @@ public void test900DeleteDummyShadows() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - when(TEST_NAME); + when(); importObjectFromFile(TASK_DELETE_DUMMY_SHADOWS_FILE); // THEN - then(TEST_NAME); + then(); waitForTaskFinish(TASK_DELETE_DUMMY_SHADOWS_OID, true, 20000); // THEN - then(TEST_NAME); + then(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); PrismObject deleteTask = getTask(TASK_DELETE_DUMMY_SHADOWS_OID); @@ -2653,16 +2653,16 @@ public void test910DeleteDummyAccounts() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - when(TEST_NAME); + when(); importObjectFromFile(TASK_DELETE_DUMMY_ACCOUNTS_FILE); // THEN - then(TEST_NAME); + then(); waitForTaskFinish(TASK_DELETE_DUMMY_ACCOUNTS_OID, true, 20000); // THEN - then(TEST_NAME); + then(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 2); PrismObject deleteTask = getTask(TASK_DELETE_DUMMY_ACCOUNTS_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundLiveSyncTask.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundLiveSyncTask.java index 86a4e3d1cbf..43f832182c5 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundLiveSyncTask.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundLiveSyncTask.java @@ -72,14 +72,14 @@ public void test199DeleteDummyEmeraldAccountMancomb() throws Exception { assertUsers(7); /// WHEN - when(TEST_NAME); + when(); dummyResourceEmerald.deleteAccountByName(ACCOUNT_MANCOMB_DUMMY_USERNAME); waitForSyncTaskNextRun(resourceDummyEmerald); // THEN - then(TEST_NAME); + then(); PrismObject accountMancomb = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, resourceDummyEmerald); display("Account mancomb", accountMancomb); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundReconTask.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundReconTask.java index 50ec734dc3d..6526d66f8b4 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundReconTask.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundReconTask.java @@ -78,12 +78,12 @@ public void test180NoChange() throws Exception { assertUsers(7); /// WHEN - when(TEST_NAME); + when(); waitForSyncTaskNextRun(resourceDummyEmerald); // THEN - then(TEST_NAME); + then(); PrismObject accountMancomb = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, resourceDummyEmerald); display("Account mancomb", accountMancomb); @@ -120,14 +120,14 @@ public void test199DeleteDummyEmeraldAccountMancomb() throws Exception { assertUsers(7); /// WHEN - when(TEST_NAME); + when(); dummyResourceEmerald.deleteAccountByName(ACCOUNT_MANCOMB_DUMMY_USERNAME); waitForSyncTaskNextRun(resourceDummyEmerald); // THEN - then(TEST_NAME); + then(); PrismObject accountMancomb = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, resourceDummyEmerald); display("Account mancomb", accountMancomb); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTask.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTask.java index 980e8f3ca5f..0420f24253a 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTask.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTask.java @@ -100,7 +100,7 @@ public void test999DeletingNotUpdatedShadowDummyGreen() throws Exception { accountJack.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "The Seven Seas"); /// WHEN - when(TEST_NAME); + when(); getDummyResource(RESOURCE_DUMMY_GREEN_NAME).addAccount(accountJack); waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); @@ -112,7 +112,7 @@ public void test999DeletingNotUpdatedShadowDummyGreen() throws Exception { rerunTask(TASK_DELETE_NOT_UPDATED_SHADOWS_OID); // THEN - then(TEST_NAME); + then(); PrismObject userCarol = findUserByUsername(ACCOUNT_CAROL_DUMMY_USERNAME); display("User carol", userCarol); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTaskMechanics.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTaskMechanics.java index f9c947c72e5..9bcbaa572e3 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTaskMechanics.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTaskMechanics.java @@ -158,13 +158,13 @@ public void test100SuspendWhileIcfSync() throws Exception { interruptedSyncResource.getDummyResource().setOperationDelayOffset(2000); // WHEN - when(TEST_NAME); + when(); waitForTaskNextStart(TASK_SLOW_RESOURCE_OID, false, 2000, true); // starts the task boolean suspended = suspendTask(TASK_SLOW_RESOURCE_OID, 10000); // THEN - then(TEST_NAME); + then(); assertTrue("Task was not suspended", suspended); Task taskAfter = taskManager.getTaskWithResult(TASK_SLOW_RESOURCE_OID, result); @@ -189,13 +189,13 @@ public void test105SuspendWhileIcfSyncImprecise() throws Exception { interruptedSyncImpreciseResource.getDummyResource().setOperationDelayOffset(500); // WHEN - when(TEST_NAME); + when(); waitForTaskNextStart(TASK_SLOW_RESOURCE_IMPRECISE_OID, false, 2000, true); // starts the task boolean suspended = suspendTask(TASK_SLOW_RESOURCE_IMPRECISE_OID, 5000); // THEN - then(TEST_NAME); + then(); assertTrue("Task was not suspended", suspended); Task taskAfter = taskManager.getTaskWithResult(TASK_SLOW_RESOURCE_IMPRECISE_OID, result); @@ -228,14 +228,14 @@ public void test110SuspendWhileProcessing() throws Exception { DummyInterruptedSyncResource.delay = 100; // WHEN - when(TEST_NAME); + when(); waitForTaskNextStart(TASK_SLOW_MODEL_OID, false, 2000, true); // starts the task Thread.sleep(4000); boolean suspended = suspendTask(TASK_SLOW_MODEL_OID, 5000); // THEN - then(TEST_NAME); + then(); assertTrue("Task was not suspended", suspended); Task taskAfter = taskManager.getTaskWithResult(TASK_SLOW_MODEL_OID, result); @@ -284,14 +284,14 @@ public void test115SuspendWhileProcessingImprecise() throws Exception { DummyInterruptedSyncImpreciseResource.delay = 100; // WHEN - when(TEST_NAME); + when(); waitForTaskNextStart(TASK_SLOW_MODEL_IMPRECISE_OID, false, 2000, true); // starts the task Thread.sleep(4000); boolean suspended = suspendTask(TASK_SLOW_MODEL_IMPRECISE_OID, 5000); // THEN - then(TEST_NAME); + then(); assertTrue("Task was not suspended", suspended); Task taskAfter = taskManager.getTaskWithResult(TASK_SLOW_MODEL_IMPRECISE_OID, result); @@ -329,12 +329,12 @@ public void test120Batched() throws Exception { DummyInterruptedSyncResource.errorOn = getUserName(24, true); // WHEN - when(TEST_NAME); + when(); waitForTaskNextRun(TASK_BATCHED_OID, false, 10000, true); // THEN - then(TEST_NAME); + then(); Task taskAfter = taskManager.getTaskWithResult(TASK_BATCHED_OID, result); displayTaskWithOperationStats("Task after", taskAfter); @@ -344,12 +344,12 @@ public void test120Batched() throws Exception { assertObjects(UserType.class, query, 10); // WHEN - when(TEST_NAME); + when(); waitForTaskNextRun(TASK_BATCHED_OID, false, 10000, true); // THEN - then(TEST_NAME); + then(); taskAfter = taskManager.getTaskWithResult(TASK_BATCHED_OID, result); displayTaskWithOperationStats("Task after", taskAfter); @@ -359,12 +359,12 @@ public void test120Batched() throws Exception { assertObjects(UserType.class, query, 20); // WHEN 3 (with error) - when(TEST_NAME); + when(); waitForTaskNextRun(TASK_BATCHED_OID, false, 10000, true); // THEN 3 (with error) - then(TEST_NAME); + then(); taskAfter = taskManager.getTaskWithResult(TASK_BATCHED_OID, result); displayTaskWithOperationStats("Task after", taskAfter); @@ -396,7 +396,7 @@ public void test125BatchedImprecise() throws Exception { DummyInterruptedSyncImpreciseResource.delay = 0; // WHEN - when(TEST_NAME); + when(); try { waitForTaskNextRun(TASK_BATCHED_IMPRECISE_OID, false, 10000, true); @@ -406,7 +406,7 @@ public void test125BatchedImprecise() throws Exception { } // THEN - then(TEST_NAME); + then(); Task taskAfter = taskManager.getTaskWithResult(TASK_BATCHED_IMPRECISE_OID, result); displayTaskWithOperationStats("Task after", taskAfter); @@ -444,12 +444,12 @@ public void test130Error() throws Exception { DummyInterruptedSyncResource.errorOn = getUserName(ERROR_ON, true); // WHEN - when(TEST_NAME); + when(); waitForTaskNextRun(TASK_ERROR_OID, false, 10000, true); // THEN - then(TEST_NAME); + then(); Task taskAfter = taskManager.getTaskWithResult(TASK_ERROR_OID, result); displayTaskWithOperationStats("Task after", taskAfter); @@ -466,12 +466,12 @@ public void test130Error() throws Exception { // Another run - should fail the same // WHEN - when(TEST_NAME); + when(); waitForTaskNextRun(TASK_ERROR_OID, false, 10000, true); // THEN - then(TEST_NAME); + then(); taskAfter = taskManager.getTaskWithResult(TASK_ERROR_OID, result); displayTaskWithOperationStats("Task after", taskAfter); @@ -505,7 +505,7 @@ public void test135ErrorImprecise() throws Exception { DummyInterruptedSyncImpreciseResource.errorOn = getUserName(ERROR_ON, false); // WHEN - when(TEST_NAME); + when(); try { waitForTaskNextRun(TASK_ERROR_IMPRECISE_OID, false, 10000, true); @@ -515,7 +515,7 @@ public void test135ErrorImprecise() throws Exception { } // THEN - then(TEST_NAME); + then(); Task taskAfter = taskManager.getTaskWithResult(TASK_ERROR_IMPRECISE_OID, result); displayTaskWithOperationStats("Task after", taskAfter); @@ -534,12 +534,12 @@ public void test135ErrorImprecise() throws Exception { // Another run - should fail the same // WHEN - when(TEST_NAME); + when(); waitForTaskNextRun(TASK_ERROR_IMPRECISE_OID, false, 10000, true); // THEN - then(TEST_NAME); + then(); taskAfter = taskManager.getTaskWithResult(TASK_ERROR_IMPRECISE_OID, result); displayTaskWithOperationStats("Task after", taskAfter); @@ -572,12 +572,12 @@ public void test140DryRun() throws Exception { DummyInterruptedSyncResource.errorOn = null; // WHEN - when(TEST_NAME); + when(); waitForTaskNextRun(TASK_DRY_RUN.oid, false, 10000, true); // THEN - then(TEST_NAME); + then(); Task taskAfter = taskManager.getTaskWithResult(TASK_DRY_RUN.oid, result); displayTaskWithOperationStats("Task after", taskAfter); @@ -611,12 +611,12 @@ public void test150DryRunWithUpdate() throws Exception { DummyInterruptedSyncResource.errorOn = null; // WHEN - when(TEST_NAME); + when(); waitForTaskNextRun(TASK_DRY_RUN_WITH_UPDATE.oid, false, 10000, true); // THEN - then(TEST_NAME); + then(); Task taskAfter = taskManager.getTaskWithResult(TASK_DRY_RUN_WITH_UPDATE.oid, result); displayTaskWithOperationStats("Task after", taskAfter); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelDiscovery.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelDiscovery.java index c03a5a0006a..12889136655 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelDiscovery.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelDiscovery.java @@ -255,11 +255,11 @@ public void test100Synchronize() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - when(TEST_NAME); + when(); addObject(getSyncTaskFile(), task, result); // THEN - then(TEST_NAME); + then(); if (DISTRIBUTION == Distribution.MULTITHREADED) { waitForTaskFinish(getSyncTaskOid(), true, 600000); @@ -268,7 +268,7 @@ public void test100Synchronize() throws Exception { } // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelSynchronization.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelSynchronization.java index 351c8e4f790..c17274ea029 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelSynchronization.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelSynchronization.java @@ -214,11 +214,11 @@ public void test100Synchronize() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - when(TEST_NAME); + when(); addObject(getSyncTaskFile(), task, result); // THEN - then(TEST_NAME); + then(); if (DISTRIBUTION == Distribution.MULTITHREADED) { waitForTaskFinish(getSyncTaskOid(), true, 600000); @@ -227,7 +227,7 @@ public void test100Synchronize() throws Exception { } // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestUuid.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestUuid.java index adcd85eea7b..9a937271afa 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestUuid.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestUuid.java @@ -136,16 +136,16 @@ public void test200ReconcileDummyUuid() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - when(TEST_NAME); + when(); importObjectFromFile(TASK_RECONCILE_DUMMY_UUID_FILE); // THEN - then(TEST_NAME); + then(); waitForTaskFinish(TASK_RECONCILE_DUMMY_UUID_OID, false); // THEN - then(TEST_NAME); + then(); reconciliationTaskResultListener.assertResult(RESOURCE_DUMMY_UUID_OID, 0, 0, 0, 0); List> users = modelService.searchObjects(UserType.class, null, null, task, result); @@ -191,16 +191,16 @@ public void test210ReconcileDummyUuidAddAugustus() throws Exception { Task taskBefore = taskManager.getTask(TASK_RECONCILE_DUMMY_UUID_OID, result); // WHEN - when(TEST_NAME); + when(); restartTask(TASK_RECONCILE_DUMMY_UUID_OID); // THEN - then(TEST_NAME); + then(); waitForTaskNextRunAssertSuccess(taskBefore, true); // THEN - then(TEST_NAME); + then(); reconciliationTaskResultListener.assertResult(RESOURCE_DUMMY_UUID_OID, 0, 1, 0, 0); List> users = modelService.searchObjects(UserType.class, null, null, task, result); @@ -272,16 +272,16 @@ public void test220ReconcileDummyUuidDeleteAddAugustus() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - when(TEST_NAME); + when(); restartTask(TASK_RECONCILE_DUMMY_UUID_OID); // THEN - then(TEST_NAME); + then(); waitForTaskNextRunAssertSuccess(taskBefore, true); // THEN - then(TEST_NAME); + then(); reconciliationTaskResultListener.assertResult(RESOURCE_DUMMY_UUID_OID, 0, 1, 0, 1); List> users = modelService.searchObjects(UserType.class, null, null, task, result); @@ -360,16 +360,16 @@ public void test230ReconcileDummyUuidDeleteAugustusAddAugustina() throws Excepti reconciliationTaskResultListener.clear(); // WHEN - when(TEST_NAME); + when(); restartTask(TASK_RECONCILE_DUMMY_UUID_OID); // THEN - then(TEST_NAME); + then(); waitForTaskNextRunAssertSuccess(taskBefore, true); // THEN - then(TEST_NAME); + then(); reconciliationTaskResultListener.assertResult(RESOURCE_DUMMY_UUID_OID, 0, 1, 0, 2); List> users = modelService.searchObjects(UserType.class, null, null, task, result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestValidityRecomputeTask.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestValidityRecomputeTask.java index bc2145bfb3d..2a56e031ceb 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestValidityRecomputeTask.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestValidityRecomputeTask.java @@ -1449,12 +1449,12 @@ public void test205AccountRedElaineDisable() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modifyAccountShadowReplace(ACCOUNT_SHADOW_ELAINE_DUMMY_RED_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.DISABLED); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject accountShadow = getShadowModel(ACCOUNT_SHADOW_ELAINE_DUMMY_RED_OID); diff --git a/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReport.java b/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReport.java index 88256a649f0..378e5ba532f 100644 --- a/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReport.java +++ b/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReport.java @@ -75,7 +75,7 @@ public void test100ReportUserList() throws Exception { PrismObject report = getObject(ReportType.class, REPORT_USER_LIST_OID); // WHEN - when(TEST_NAME); + when(); reportManager.runReport(report, null, task, result); assertInProgress(result); @@ -85,7 +85,7 @@ public void test100ReportUserList() throws Exception { waitForTaskFinish(task.getOid(), true); // THEN - then(TEST_NAME); + then(); PrismObject finishedTask = getTask(task.getOid()); display("Background task", finishedTask); @@ -139,7 +139,7 @@ public void test200ReportUserListScript() throws Exception { PrismObject report = getObject(ReportType.class, REPORT_USER_LIST_SCRIPT_OID); // WHEN - when(TEST_NAME); + when(); reportManager.runReport(report, null, task, result); assertInProgress(result); @@ -149,7 +149,7 @@ public void test200ReportUserListScript() throws Exception { waitForTaskFinish(task.getOid(), true); // THEN - then(TEST_NAME); + then(); PrismObject finishedTask = getTask(task.getOid()); display("Background task", finishedTask); @@ -200,7 +200,7 @@ protected PrismObject runReport(final String TEST_NAME, PrismObject runReport(final String TEST_NAME, PrismObject finishedTask = getTask(task.getOid()); display("Background task (finished)", finishedTask); diff --git a/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReportWebService.java b/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReportWebService.java index 2ea0f78ad26..0b22a72d490 100644 --- a/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReportWebService.java +++ b/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReportWebService.java @@ -74,11 +74,11 @@ public void test100ProcessReportUserList() throws Exception { RemoteReportParametersType parameters = createReportParameters(); // WHEN - when(TEST_NAME); + when(); ObjectListType userList = reportWebService.processReport(REPORT_USER_LIST_EXPRESSIONS_CSV_OID, query, parameters, null); // THEN - then(TEST_NAME); + then(); display("Returned user list ("+userList.getObject().size()+" objects)", userList); assertUserList(userList); @@ -94,14 +94,14 @@ public void test110ProcessReportUserListNoReportOid() throws Exception { try { // WHEN - when(TEST_NAME); + when(); reportWebService.processReport(null, query, parameters, null); assertNotReached(); } catch (Fault f) { // THEN - then(TEST_NAME); + then(); display("Expected fault", f); } } @@ -116,14 +116,14 @@ public void test112ProcessReportUserListInvalidReportOid() throws Exception { try { // WHEN - when(TEST_NAME); + when(); reportWebService.processReport("l00n3y", query, parameters, null); assertNotReached(); } catch (Fault f) { // THEN - then(TEST_NAME); + then(); display("Expected fault", f); } } @@ -143,14 +143,14 @@ public void test115ProcessReportUserListUnauthorizedReader() throws Exception { try { // WHEN - when(TEST_NAME); + when(); reportWebService.processReport(REPORT_USER_LIST_EXPRESSIONS_CSV_OID, query, parameters, null); assertNotReached(); } catch (Fault f) { // THEN - then(TEST_NAME); + then(); display("Expected fault", f); } finally { login(USER_ADMINISTRATOR_USERNAME); @@ -172,14 +172,14 @@ public void test116ProcessReportUserListUnauthorizedRunner() throws Exception { try { // WHEN - when(TEST_NAME); + when(); reportWebService.processReport(REPORT_USER_LIST_EXPRESSIONS_CSV_OID, query, parameters, null); assertNotReached(); } catch (Fault f) { // THEN - then(TEST_NAME); + then(); display("Expected fault", f); } finally { login(USER_ADMINISTRATOR_USERNAME); @@ -202,7 +202,7 @@ public void test119ProcessReportUserListReaderRunner() throws Exception { try { // WHEN - when(TEST_NAME); + when(); userList = reportWebService.processReport(REPORT_USER_LIST_EXPRESSIONS_CSV_OID, query, parameters, null); } finally { @@ -210,7 +210,7 @@ public void test119ProcessReportUserListReaderRunner() throws Exception { } // THEN - then(TEST_NAME); + then(); display("Returned user list ("+userList.getObject().size()+" objects)", userList); assertUserList(userList); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorDiscovery.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorDiscovery.java index 2ca3777235c..4879e39b057 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorDiscovery.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorDiscovery.java @@ -52,11 +52,11 @@ public void test001Connectors() throws Exception { OperationResult result = new OperationResult(TestConnectorDiscovery.class.getName() + "." + TEST_NAME); // WHEN - when(TEST_NAME); + when(); List> connectors = repositoryService.searchObjects(ConnectorType.class, null, null, result); // THEN - then(TEST_NAME); + then(); assertFalse("No connector found", connectors.isEmpty()); display("Found " + connectors.size() + " discovered connector"); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorManager.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorManager.java index 1ecc9f9b1c9..c75e77340c4 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorManager.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorManager.java @@ -51,11 +51,11 @@ public void test100ListConnectorFactories() throws Exception { OperationResult result = new OperationResult(TestConnectorDiscovery.class.getName() + "." + TEST_NAME); // WHEN - when(TEST_NAME); + when(); Collection connectorFactories = connectorManager.getConnectorFactories(); // THEN - then(TEST_NAME); + then(); assertNotNull("Null connector factories", connectorFactories); assertFalse("No connector factories found", connectorFactories.isEmpty()); display("Found "+connectorFactories.size()+" connector factories"); @@ -81,11 +81,11 @@ public void test110SelfTest() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); connectorManager.connectorFrameworkSelfTest(result, task); // THEN - then(TEST_NAME); + then(); assertSuccess(result); } diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/TestCsvBroken.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/TestCsvBroken.java index 13d3911a558..d0028ce10d6 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/TestCsvBroken.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/TestCsvBroken.java @@ -75,11 +75,8 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti */ @Test public void test100Connection() throws Exception { - final String TEST_NAME = "test100Connection"; - TestUtil.displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); + given(); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -121,11 +118,8 @@ public void test100Connection() throws Exception { */ @Test public void test110FixResourceAndTestConnection() throws Exception { - final String TEST_NAME = "test110FixResourceAndTestConnection"; - TestUtil.displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); + given(); + Task task = getTestTask(); OperationResult result = task.getResult(); setCsvFile(RESOURCE_CSV_BROKEN.oid, CSV_FILE_OK.getPath(), result); @@ -175,11 +169,8 @@ public void test110FixResourceAndTestConnection() throws Exception { */ @Test public void test120BreakResourceAndTestConnection() throws Exception { - final String TEST_NAME = "test120BreakResourceAndTestConnection"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); setCsvFile(RESOURCE_CSV_BROKEN.oid, CSV_FILE_NON_EXISTING.getPath(), result); @@ -217,11 +208,8 @@ public void test120BreakResourceAndTestConnection() throws Exception { */ @Test public void test130FixResourceAndSearchObjects() throws Exception { - final String TEST_NAME = "test130FixResourceAndSearchObjects"; - TestUtil.displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); + given(); + Task task = getTestTask(); OperationResult result = task.getResult(); setCsvFile(RESOURCE_CSV_BROKEN.oid, CSV_FILE_OK.getPath(), result); @@ -283,14 +271,10 @@ public void test130FixResourceAndSearchObjects() throws Exception { */ @Test public void test140TwoMoreStatusChanges() throws Exception { - final String TEST_NAME = "test140TwoMoreStatusChanges"; - TestUtil.displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); + given(); + Task task = getTestTask(); OperationResult result = task.getResult(); - // WHEN long before = System.currentTimeMillis(); setCsvFile(RESOURCE_CSV_BROKEN.oid, CSV_FILE_NON_EXISTING.getPath(), result); 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 b07a124a9c7..7757f9fff87 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 @@ -5,34 +5,21 @@ * and European Union Public License. See LICENSE file for details. */ -/* - * - */ package com.evolveum.midpoint.provisioning.impl.dummy; -import static com.evolveum.midpoint.test.IntegrationTestTools.assertProvisioningAccountShadow; -import static com.evolveum.midpoint.test.asserter.predicate.TimeAssertionPredicates.approximatelyCurrent; +import static org.testng.AssertJUnit.*; +import static com.evolveum.midpoint.test.IntegrationTestTools.assertProvisioningAccountShadow; import static com.evolveum.midpoint.test.asserter.predicate.StringAssertionPredicates.startsWith; - -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertTrue; +import static com.evolveum.midpoint.test.asserter.predicate.TimeAssertionPredicates.approximatelyCurrent; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Set; - import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.path.ItemName; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.xml.ns._public.common.common_3.*; - import org.apache.commons.lang.StringUtils; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; @@ -47,33 +34,22 @@ import com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition; 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; -import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.PrismProperty; -import com.evolveum.midpoint.prism.PrismPropertyDefinition; +import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.crypto.EncryptionException; import com.evolveum.midpoint.prism.delta.DiffUtil; import com.evolveum.midpoint.prism.delta.ObjectDelta; +import com.evolveum.midpoint.prism.impl.schema.PrismSchemaImpl; import com.evolveum.midpoint.prism.match.MatchingRule; +import com.evolveum.midpoint.prism.path.ItemName; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.schema.PrismSchema; -import com.evolveum.midpoint.prism.impl.schema.PrismSchemaImpl; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.provisioning.impl.ProvisioningContext; -import com.evolveum.midpoint.provisioning.impl.opendj.TestOpenDj; import com.evolveum.midpoint.provisioning.ucf.api.AttributesToReturn; import com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance; import com.evolveum.midpoint.provisioning.util.ProvisioningUtil; -import com.evolveum.midpoint.schema.CapabilityUtil; -import com.evolveum.midpoint.schema.DeltaConvertor; -import com.evolveum.midpoint.schema.GetOperationOptions; -import com.evolveum.midpoint.schema.ResourceShadowDiscriminator; -import com.evolveum.midpoint.schema.SearchResultList; -import com.evolveum.midpoint.schema.SelectorOptions; +import com.evolveum.midpoint.schema.*; import com.evolveum.midpoint.schema.constants.ConnectorTestOperation; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.internals.InternalCounters; @@ -84,31 +60,16 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.result.OperationResultStatus; import com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus; -import com.evolveum.midpoint.schema.util.ConnectorTypeUtil; -import com.evolveum.midpoint.schema.util.ObjectTypeUtil; -import com.evolveum.midpoint.schema.util.ResourceTypeUtil; -import com.evolveum.midpoint.schema.util.SchemaTestConstants; -import com.evolveum.midpoint.schema.util.ShadowUtil; +import com.evolveum.midpoint.schema.util.*; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.ObjectChecker; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.AddRemoveAttributeValuesCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CountObjectsCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CountObjectsSimulateType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.PasswordCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ReadCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.RunAsCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ScriptCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.TestConnectionCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.UpdateCapabilityType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; +import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.*; import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; /** @@ -122,8 +83,6 @@ @Listeners({ com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class }) public class AbstractBasicDummyTest extends AbstractDummyTest { - private static final Trace LOGGER = TraceManager.getTrace(AbstractBasicDummyTest.class); - protected CachingMetadataType capabilitiesCachingMetadataType; protected String willIcfUid; protected XMLGregorianCalendar lastPasswordModifyStart; @@ -146,21 +105,18 @@ protected int getExpectedRefinedSchemaDefinitions() { } @AfterClass - public static void assertCleanShutdown() throws Exception { + public static void assertCleanShutdown() { dummyResource.assertNoConnections(); } @Test public void test000Integrity() throws Exception { - final String TEST_NAME = "test000Integrity"; - display("Dummy resource instance", dummyResource.toString()); assertNotNull("Resource is null", resource); assertNotNull("ResourceType is null", resourceType); - OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() - + "." + TEST_NAME); + OperationResult result = createResult(); ResourceType resource = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, result) .asObjectable(); @@ -183,9 +139,8 @@ public void test000Integrity() throws Exception { */ @Test public void test010ListConnectors() throws Exception { - final String TEST_NAME = "test010ListConnectors"; // GIVEN - OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() + "." + TEST_NAME); + OperationResult result = createResult(); // WHEN List> connectors = repositoryService.searchObjects(ConnectorType.class, @@ -220,8 +175,7 @@ public void test010ListConnectors() throws Exception { PrismContainerDefinition definition = schema.findItemDefinition(ResourceType.F_CONNECTOR_CONFIGURATION.getLocalPart(), PrismContainerDefinition.class); assertNotNull("Definition of property container not found", definition); - PrismContainerDefinition pcd = (PrismContainerDefinition) definition; - assertFalse("Empty definition", pcd.isEmpty()); + assertFalse("Empty definition", definition.isEmpty()); } } @@ -231,14 +185,13 @@ public void test010ListConnectors() throws Exception { */ @Test public void test012ConnectorRediscovery() { - final String TEST_NAME = "test012ConnectorRediscovery"; - // GIVEN - OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() + "." + TEST_NAME); + given(); + OperationResult result = createResult(); - // WHEN + when(); Set discoverLocalConnectors = connectorManager.discoverLocalConnectors(result); - // THEN + then(); assertSuccess("discoverLocalConnectors failed", result); assertTrue("Rediscovered something", discoverLocalConnectors.isEmpty()); } @@ -249,9 +202,8 @@ public void test012ConnectorRediscovery() { */ @Test public void test015ListResourcesNoFetch() throws Exception { - final String TEST_NAME = "test015ListResourcesNoFetch"; // GIVEN - Task task = taskManager.createTaskInstance(AbstractBasicDummyTest.class.getName() + "." + TEST_NAME); + Task task = createPlainTask(); OperationResult result = task.getResult(); Collection> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch()); @@ -271,7 +223,7 @@ public void test015ListResourcesNoFetch() throws Exception { XmlSchemaType xmlSchemaType = resourceType.getSchema(); if (xmlSchemaType != null) { Element xsdSchemaElement = ResourceTypeUtil.getResourceXsdSchema(resourceType); - assertNull("Found schema in "+resource, xsdSchemaElement); + assertNull("Found schema in " + resource, xsdSchemaElement); } } @@ -285,15 +237,14 @@ public void test015ListResourcesNoFetch() throws Exception { /** * This should be the very first test that works with the resource. - * + *

* The original repository object does not have resource schema. The schema * should be generated from the resource on the first use. This is the test * that executes testResource and checks whether the schema was generated. */ @Test public void test020Connection() throws Exception { - final String TEST_NAME = "test020Connection"; - // GIVEN + given(); Task task = getTestTask(); OperationResult result = task.getResult(); @@ -345,19 +296,19 @@ public void test020Connection() throws Exception { assertResource(resourceRepoAfter, "Resource after test") .display() .operationalState() - .assertAny() - .assertPropertyEquals(OperationalStateType.F_LAST_AVAILABILITY_STATUS, AvailabilityStatusType.UP) - .assertPropertyEquals(OperationalStateType.F_NODE_ID, localNodeId) - .assertPropertyValueSatisfies(OperationalStateType.F_TIMESTAMP, approximatelyCurrent(60000)) - .assertPropertyValueSatisfies(OperationalStateType.F_MESSAGE, startsWith("Status set to UP")) - .end() + .assertAny() + .assertPropertyEquals(OperationalStateType.F_LAST_AVAILABILITY_STATUS, AvailabilityStatusType.UP) + .assertPropertyEquals(OperationalStateType.F_NODE_ID, localNodeId) + .assertPropertyValueSatisfies(OperationalStateType.F_TIMESTAMP, approximatelyCurrent(60000)) + .assertPropertyValueSatisfies(OperationalStateType.F_MESSAGE, startsWith("Status set to UP")) + .end() .operationalStateHistory() - .assertSize(1) - .value(0) - .assertPropertyEquals(OperationalStateType.F_LAST_AVAILABILITY_STATUS, AvailabilityStatusType.UP) - .assertPropertyEquals(OperationalStateType.F_NODE_ID, localNodeId) - .assertPropertyValueSatisfies(OperationalStateType.F_TIMESTAMP, approximatelyCurrent(60000)) - .assertPropertyValueSatisfies(OperationalStateType.F_MESSAGE, startsWith("Status set to UP")); + .assertSize(1) + .value(0) + .assertPropertyEquals(OperationalStateType.F_LAST_AVAILABILITY_STATUS, AvailabilityStatusType.UP) + .assertPropertyEquals(OperationalStateType.F_NODE_ID, localNodeId) + .assertPropertyValueSatisfies(OperationalStateType.F_TIMESTAMP, approximatelyCurrent(60000)) + .assertPropertyValueSatisfies(OperationalStateType.F_MESSAGE, startsWith("Status set to UP")); XmlSchemaType xmlSchemaTypeAfter = resourceTypeRepoAfter.getSchema(); assertNotNull("No schema after test connection", xmlSchemaTypeAfter); @@ -402,15 +353,14 @@ protected void assertResourceAfterTest() { @Test public void test021Configuration() throws Exception { - final String TEST_NAME = "test021Configuration"; - // GIVEN - OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() + "." + TEST_NAME); + given(); + OperationResult result = createResult(); - // WHEN + when(); resource = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, null, result); resourceType = resource.asObjectable(); - // THEN + then(); assertSuccess(result); assertCounterIncrement(InternalCounters.RESOURCE_SCHEMA_PARSE_COUNT, 0); @@ -454,11 +404,7 @@ protected void assertConfigurationProperty(PrismProperty confProp) { @Test public void test022ParsedSchema() throws Exception { - final String TEST_NAME = "test022ParsedSchema"; - // GIVEN - - // THEN - // The returned type should have the schema pre-parsed + expect("The returned type should have the schema pre-parsed"); assertNotNull(RefinedResourceSchemaImpl.hasParsedSchema(resourceType)); // Also test if the utility method returns the same thing @@ -483,7 +429,6 @@ public void test022ParsedSchema() throws Exception { @Test public void test023RefinedSchema() throws Exception { - final String TEST_NAME = "test023RefinedSchema"; // GIVEN // WHEN @@ -530,7 +475,7 @@ public void test023RefinedSchema() throws Exception { assertTrue("No NAME read", nameDef.canRead()); assertTrue("NAME definition not in identifiers", accountDef.getSecondaryIdentifiers().contains(nameDef)); // MID-3144 - assertEquals("Wrong NAME displayOrder", (Integer)110, nameDef.getDisplayOrder()); + assertEquals("Wrong NAME displayOrder", (Integer) 110, nameDef.getDisplayOrder()); assertEquals("Wrong NAME displayName", "Username", nameDef.getDisplayName()); RefinedAttributeDefinition fullnameDef = accountDef.findAttributeDefinition("fullname"); @@ -551,9 +496,9 @@ public void test023RefinedSchema() throws Exception { rememberRefinedResourceSchema(refinedSchema); - for (Definition def: refinedSchema.getDefinitions()) { + for (Definition def : refinedSchema.getDefinitions()) { if (!(def instanceof RefinedObjectClassDefinition)) { - fail("Non-refined definition sneaked into resource schema: "+def); + fail("Non-refined definition sneaked into resource schema: " + def); } } @@ -570,7 +515,6 @@ public void test023RefinedSchema() throws Exception { */ @Test public void test024ParsedSchemaAgain() throws Exception { - final String TEST_NAME = "test024ParsedSchemaAgain"; // GIVEN // THEN @@ -589,17 +533,14 @@ public void test024ParsedSchemaAgain() throws Exception { @Test public void test028Capabilities() throws Exception { - final String TEST_NAME = "test028Capabilities"; + given(); + OperationResult result = createResult(); - // GIVEN - OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() - + "." + TEST_NAME); - - // WHEN + when(); PrismObject resource = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, null, result); ResourceType resourceType = resource.asObjectable(); - // THEN + then(); result.computeStatus(); display("getObject result", result); TestUtil.assertSuccess(result); @@ -722,11 +663,8 @@ protected void assertNativeCredentialsCapability(CredentialsCapabilityType capCr */ @Test public void test029CapabilitiesRepo() throws Exception { - final String TEST_NAME = "test029CapabilitiesRepo"; - // GIVEN - OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() - + "." + TEST_NAME); + OperationResult result = createResult(); // WHEN PrismObject resource = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, result); @@ -786,18 +724,15 @@ public void test029CapabilitiesRepo() throws Exception { * Create steady state of the system by invoking test connection again. * Previous operations may have modified the resource, which may have changed * resource version which might have interfered with caching. - * @throws Exception */ @Test public void test030ResourceAndConnectorCachingTestConnection() throws Exception { - final String TEST_NAME = "test030ResourceAndConnectorCachingTestConnection"; - Task task = getTestTask(); - // WHEN + when(); OperationResult testResult = provisioningService.testResource(RESOURCE_DUMMY_OID, task); - // THEN + then(); display("Test result", testResult); assertSuccess(testResult); @@ -827,10 +762,8 @@ public void test030ResourceAndConnectorCachingTestConnection() throws Exception @Test public void test032ResourceAndConnectorCaching() throws Exception { - final String TEST_NAME = "test032ResourceAndConnectorCaching"; - // GIVEN - OperationResult result = new OperationResult(TestOpenDj.class.getName() + "." + TEST_NAME); + OperationResult result = createResult(); ConnectorInstance configuredConnectorInstance = resourceManager.getConfiguredConnectorInstance( resource, ReadCapabilityType.class, false, result); assertNotNull("No configuredConnectorInstance", configuredConnectorInstance); @@ -838,12 +771,12 @@ public void test032ResourceAndConnectorCaching() throws Exception { assertNotNull("No resource schema", resourceSchema); // WHEN - when(TEST_NAME); - PrismObject resourceAgain = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, - null, null, result); + when(); + PrismObject resourceAgain = provisioningService.getObject( + ResourceType.class, RESOURCE_DUMMY_OID, null, null, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); ResourceType resourceTypeAgain = resourceAgain.asObjectable(); @@ -877,7 +810,7 @@ public void test032ResourceAndConnectorCaching() throws Exception { resourceAgain.asObjectable().setFetchResult(null); ObjectDelta dummyResourceDiff = DiffUtil.diff(resource, resourceAgain); display("Dummy resource diff", dummyResourceDiff); - assertTrue("The resource read again is not the same as the original. diff:"+dummyResourceDiff, dummyResourceDiff.isEmpty()); + assertTrue("The resource read again is not the same as the original. diff:" + dummyResourceDiff, dummyResourceDiff.isEmpty()); // Now we stick our nose deep inside the provisioning impl. But we need // to make sure that the @@ -888,13 +821,12 @@ public void test032ResourceAndConnectorCaching() throws Exception { assertTrue("Connector instance was not cached", configuredConnectorInstance == configuredConnectorInstanceAgain); // Check if the connector still works. - OperationResult testResult = new OperationResult(TestOpenDj.class.getName() + "."+TEST_NAME+".test"); + OperationResult testResult = createResult("test"); configuredConnectorInstanceAgain.test(testResult); testResult.computeStatus(); TestUtil.assertSuccess("Connector test failed", testResult); // Test connection should also refresh the connector by itself. So check if it has been refreshed - ConnectorInstance configuredConnectorInstanceAfterTest = resourceManager.getConfiguredConnectorInstance( resourceAgain, ReadCapabilityType.class, false, result); assertNotNull("No configuredConnectorInstance (again)", configuredConnectorInstanceAfterTest); @@ -945,8 +877,7 @@ public void test034ResourceAndConnectorCachingForceFresh() throws Exception { assertTrue("Connector instance was changed", configuredConnectorInstance == configuredConnectorInstanceAgain); // Check if the connector still works - OperationResult testResult = new OperationResult(TestOpenDj.class.getName() - + ".test011ResourceAndConnectorCachingForceFresh.test"); + OperationResult testResult = createResult("test"); configuredConnectorInstanceAgain.test(testResult); testResult.computeStatus(); TestUtil.assertSuccess("Connector test failed", testResult); @@ -958,11 +889,8 @@ public void test034ResourceAndConnectorCachingForceFresh() throws Exception { assertSteadyResource(); } - @Test public void test040ApplyDefinitionShadow() throws Exception { - final String TEST_NAME = "test040ApplyDefinitionShadow"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -978,7 +906,7 @@ public void test040ApplyDefinitionShadow() throws Exception { TestUtil.assertSuccess(result); account.checkConsistence(true, true); - ShadowUtil.checkConsistence(account, TEST_NAME); + ShadowUtil.checkConsistence(account, getTestNameShort()); TestUtil.assertSuccess("applyDefinition(account) result", result); assertSteadyResource(); @@ -986,8 +914,6 @@ public void test040ApplyDefinitionShadow() throws Exception { @Test public void test041ApplyDefinitionAddShadowDelta() throws Exception { - final String TEST_NAME = "test041ApplyDefinitionAddShadowDelta"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1012,8 +938,6 @@ public void test041ApplyDefinitionAddShadowDelta() throws Exception { @Test public void test042ApplyDefinitionResource() throws Exception { - final String TEST_NAME = "test042ApplyDefinitionResource"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1041,8 +965,6 @@ public void test042ApplyDefinitionResource() throws Exception { @Test public void test043ApplyDefinitionAddResourceDelta() throws Exception { - final String TEST_NAME = "test043ApplyDefinitionAddResourceDelta"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1070,12 +992,10 @@ public void test043ApplyDefinitionAddResourceDelta() throws Exception { } @Test - public void test050SelfTest() throws Exception { - final String TEST_NAME = "test050SelfTest"; - + public void test050SelfTest() { // GIVEN Task task = getTestTask(); - OperationResult testResult = new OperationResult(AbstractBasicDummyTest.class + "." + TEST_NAME); + OperationResult testResult = task.getResult(); // WHEN provisioningService.provisioningSelfTest(testResult, task); @@ -1087,7 +1007,7 @@ public void test050SelfTest() throws Exception { // There may be warning about illegal key size on some platforms. As far as it is warning and not error we are OK // the system will fall back to a interoperable key size if (testResult.getStatus() != OperationResultStatus.SUCCESS && testResult.getStatus() != OperationResultStatus.WARNING) { - AssertJUnit.fail("Self-test failed: "+testResult); + AssertJUnit.fail("Self-test failed: " + testResult); } } @@ -1096,8 +1016,6 @@ public void test050SelfTest() throws Exception { @Test public void test080TestAttributesToReturn() throws Exception { - final String TEST_NAME = "test080TestAttributesToReturn"; - // GIVEN Task task = taskManager.createTaskInstance(); OperationResult result = task.getResult(); @@ -1112,7 +1030,7 @@ public void test080TestAttributesToReturn() throws Exception { display("attributesToReturn", attributesToReturn); assertFalse("wrong isReturnDefaultAttributes", attributesToReturn.isReturnDefaultAttributes()); Collection attrs = new ArrayList<>(); - for (ResourceAttributeDefinition attributeToReturnDef: attributesToReturn.getAttributesToReturn()) { + for (ResourceAttributeDefinition attributeToReturnDef : attributesToReturn.getAttributesToReturn()) { attrs.add(attributeToReturnDef.getItemName().getLocalPart()); } // No "memebers" attribute here @@ -1123,7 +1041,6 @@ public void test080TestAttributesToReturn() throws Exception { @Test public void test090ConnectorStatsAfterSomeUse() throws Exception { - final String TEST_NAME = "test090ConnectorStatsAfterSomeUse"; // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1141,21 +1058,19 @@ public void test090ConnectorStatsAfterSomeUse() throws Exception { assertEquals("Wrong connectorClassName", getDummyConnectorClass().getName(), operationalStatus.getConnectorClassName()); assertEquals("Wrong poolConfigMinSize", null, operationalStatus.getPoolConfigMinSize()); - assertEquals("Wrong poolConfigMaxSize", (Integer)10, operationalStatus.getPoolConfigMaxSize()); - assertEquals("Wrong poolConfigMinIdle", (Integer)1, operationalStatus.getPoolConfigMinIdle()); - assertEquals("Wrong poolConfigMaxIdle", (Integer)10, operationalStatus.getPoolConfigMaxIdle()); - assertEquals("Wrong poolConfigWaitTimeout", (Long)150000L, operationalStatus.getPoolConfigWaitTimeout()); - assertEquals("Wrong poolConfigMinEvictableIdleTime", (Long)120000L, operationalStatus.getPoolConfigMinEvictableIdleTime()); - assertEquals("Wrong poolStatusNumIdle", (Integer)1, operationalStatus.getPoolStatusNumIdle()); - assertEquals("Wrong poolStatusNumActive", (Integer)0, operationalStatus.getPoolStatusNumActive()); + assertEquals("Wrong poolConfigMaxSize", (Integer) 10, operationalStatus.getPoolConfigMaxSize()); + assertEquals("Wrong poolConfigMinIdle", (Integer) 1, operationalStatus.getPoolConfigMinIdle()); + assertEquals("Wrong poolConfigMaxIdle", (Integer) 10, operationalStatus.getPoolConfigMaxIdle()); + assertEquals("Wrong poolConfigWaitTimeout", (Long) 150000L, operationalStatus.getPoolConfigWaitTimeout()); + assertEquals("Wrong poolConfigMinEvictableIdleTime", (Long) 120000L, operationalStatus.getPoolConfigMinEvictableIdleTime()); + assertEquals("Wrong poolStatusNumIdle", (Integer) 1, operationalStatus.getPoolStatusNumIdle()); + assertEquals("Wrong poolStatusNumActive", (Integer) 0, operationalStatus.getPoolStatusNumActive()); assertSteadyResource(); } - @Test public void test100AddAccountWill() throws Exception { - final String TEST_NAME = "test100AddAccountWill"; // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1169,11 +1084,11 @@ public void test100AddAccountWill() throws Exception { XMLGregorianCalendar start = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); String addedObjectOid = provisioningService.addObject(account, null, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar end = clock.currentTimeXMLGregorianCalendar(); @@ -1192,8 +1107,8 @@ public void test100AddAccountWill() throws Exception { ActivationType activationRepo = accountRepo.asObjectable().getActivation(); if (supportsActivation()) { - assertNotNull("No activation in "+accountRepo+" (repo)", activationRepo); - assertEquals("Wrong activation enableTimestamp in "+accountRepo+" (repo)", ACCOUNT_WILL_ENABLE_TIMESTAMP, activationRepo.getEnableTimestamp()); + assertNotNull("No activation in " + accountRepo + " (repo)", activationRepo); + assertEquals("Wrong activation enableTimestamp in " + accountRepo + " (repo)", ACCOUNT_WILL_ENABLE_TIMESTAMP, activationRepo.getEnableTimestamp()); } else { assertNull("Activation sneaked in (repo)", activationRepo); } @@ -1216,10 +1131,10 @@ public void test100AddAccountWill() throws Exception { ActivationType activationProvisioning = accountTypeProvisioning.getActivation(); if (supportsActivation()) { - assertNotNull("No activation in "+accountProvisioning+" (provisioning)", activationProvisioning); - assertEquals("Wrong activation administrativeStatus in "+accountProvisioning+" (provisioning)", + assertNotNull("No activation in " + accountProvisioning + " (provisioning)", activationProvisioning); + assertEquals("Wrong activation administrativeStatus in " + accountProvisioning + " (provisioning)", ActivationStatusType.ENABLED, activationProvisioning.getAdministrativeStatus()); - TestUtil.assertEqualsTimestamp("Wrong activation enableTimestamp in "+accountProvisioning+" (provisioning)", + TestUtil.assertEqualsTimestamp("Wrong activation enableTimestamp in " + accountProvisioning + " (provisioning)", ACCOUNT_WILL_ENABLE_TIMESTAMP, activationProvisioning.getEnableTimestamp()); } else { assertNull("Activation sneaked in (provisioning)", activationProvisioning); @@ -1285,7 +1200,7 @@ protected void checkRepoAccountShadowWillBasic(PrismObject accountRe protected void assertPrimaryIdentifierValue(PrismObject shadow, String expected) { if (shadow.asObjectable().getLifecycleState() == null || shadow.asObjectable().getLifecycleState().equals(SchemaConstants.LIFECYCLE_ACTIVE)) { - assertEquals("Wrong primaryIdentifierValue in "+shadow, expected, shadow.asObjectable().getPrimaryIdentifierValue()); + assertEquals("Wrong primaryIdentifierValue in " + shadow, expected, shadow.asObjectable().getPrimaryIdentifierValue()); } } @@ -1306,10 +1221,8 @@ protected void checkRepoAccountShadowWill(PrismObject accountRepo, X @Test public void test102GetAccount() throws Exception { - final String TEST_NAME = "test102GetAccount"; // GIVEN - OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() - + "." + TEST_NAME); + OperationResult result = createResult(); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); @@ -1346,10 +1259,8 @@ public void test102GetAccount() throws Exception { @Test public void test103GetAccountNoFetch() throws Exception { - final String TEST_NAME="test103GetAccountNoFetch"; // GIVEN - OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() - + "."+TEST_NAME); + OperationResult result = createResult(); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); GetOperationOptions rootOptions = new GetOperationOptions(); @@ -1363,7 +1274,6 @@ public void test103GetAccountNoFetch() throws Exception { ACCOUNT_WILL_OID, options, null, result); // THEN - XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); display("getObject result", result); assertSuccess(result); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); @@ -1372,7 +1282,7 @@ public void test103GetAccountNoFetch() throws Exception { assertNotNull("No dummy account", shadow); - checkAccountShadow(shadow, result, false, startTs, endTs); + checkAccountShadow(shadow, result, false); // This is noFetch. Therefore the read should NOT update the caching timestamp checkRepoAccountShadowWill(shadow, null, startTs); @@ -1383,8 +1293,6 @@ public void test103GetAccountNoFetch() throws Exception { @Test public void test105ApplyDefinitionModifyDelta() throws Exception { - final String TEST_NAME = "test105ApplyDefinitionModifyDelta"; - // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -1412,9 +1320,8 @@ public void test105ApplyDefinitionModifyDelta() throws Exception { */ @Test public void test106GetModifiedAccount() throws Exception { - final String TEST_NAME = "test106GetModifiedAccount"; // GIVEN - OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() + "." + TEST_NAME); + OperationResult result = createResult(); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); DummyAccount accountWill = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid); @@ -1425,11 +1332,11 @@ public void test106GetModifiedAccount() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); PrismObject shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, null, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1); @@ -1464,19 +1371,17 @@ public void test106GetModifiedAccount() throws Exception { } @Test - public void test999Shutdown() throws Exception { - final String TEST_NAME = "test999Shutdown"; - - // WHEN + public void test999Shutdown() { + when(); provisioningService.shutdown(); - // THEN + then(); dummyResource.assertNoConnections(); } protected void checkAccountWill(PrismObject shadow, OperationResult result, XMLGregorianCalendar startTs, XMLGregorianCalendar endTs) throws SchemaException, EncryptionException { - checkAccountShadow(shadow, result, true, startTs, endTs); + checkAccountShadow(shadow, result, true); Collection> attributes = ShadowUtil.getAttributes(shadow); assertAttribute(shadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "Flying Dutchman"); assertAttribute(shadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "Sword", "LOVE"); @@ -1487,49 +1392,47 @@ protected void checkAccountWill(PrismObject shadow, OperationResult /** * We do not know what the timestamp should be */ - protected void assertRepoCachingMetadata(PrismObject shadowRepo) { - assertNull("Unexpected caching metadata in "+shadowRepo, shadowRepo.asObjectable().getCachingMetadata()); - } - protected void assertRepoCachingMetadata(PrismObject shadowRepo, XMLGregorianCalendar start, XMLGregorianCalendar end) { - assertNull("Unexpected caching metadata in "+shadowRepo, shadowRepo.asObjectable().getCachingMetadata()); + assertNull("Unexpected caching metadata in " + shadowRepo, shadowRepo.asObjectable().getCachingMetadata()); } protected void assertCachingMetadata(PrismObject shadow, boolean expectedCached, XMLGregorianCalendar startTs, XMLGregorianCalendar endTs) { - assertNull("Unexpected caching metadata in "+shadow, shadow.asObjectable().getCachingMetadata()); + assertNull("Unexpected caching metadata in " + shadow, shadow.asObjectable().getCachingMetadata()); } - protected void checkAccountShadow(PrismObject shadowType, OperationResult parentResult, boolean fullShadow, XMLGregorianCalendar startTs, - XMLGregorianCalendar endTs) throws SchemaException { + protected void checkAccountShadow( + PrismObject shadowType, OperationResult parentResult, boolean fullShadow) + throws SchemaException { ObjectChecker checker = createShadowChecker(fullShadow); ShadowUtil.checkConsistence(shadowType, parentResult.getOperation()); - IntegrationTestTools.checkAccountShadow(shadowType.asObjectable(), resourceType, repositoryService, checker, getUidMatchingRule(), prismContext, parentResult); + IntegrationTestTools.checkAccountShadow(shadowType.asObjectable(), resourceType, + repositoryService, checker, getUidMatchingRule(), prismContext, parentResult); } protected ObjectChecker createShadowChecker(final boolean fullShadow) { return (shadow) -> { - String icfName = ShadowUtil.getSingleStringAttributeValue(shadow, - SchemaTestConstants.ICFS_NAME); - assertNotNull("No ICF NAME", icfName); - assertEquals("Wrong shadow name ("+shadow.getName()+")", StringUtils.lowerCase(icfName), StringUtils.lowerCase(shadow.getName().getOrig())); - assertNotNull("No kind in "+shadow, shadow.getKind()); - - if (shadow.getKind() == ShadowKindType.ACCOUNT) { - if (fullShadow) { - assertNotNull( - "Missing fullname attribute", - ShadowUtil.getSingleStringAttributeValue(shadow, - new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "fullname"))); - if (supportsActivation()) { - assertNotNull("no activation", shadow.getActivation()); - assertNotNull("no activation status", shadow.getActivation().getAdministrativeStatus()); - assertEquals("not enabled", ActivationStatusType.ENABLED, shadow.getActivation().getAdministrativeStatus()); - } + String icfName = ShadowUtil.getSingleStringAttributeValue(shadow, + SchemaTestConstants.ICFS_NAME); + assertNotNull("No ICF NAME", icfName); + assertEquals("Wrong shadow name (" + shadow.getName() + ")", StringUtils.lowerCase(icfName), StringUtils.lowerCase(shadow.getName().getOrig())); + assertNotNull("No kind in " + shadow, shadow.getKind()); + + if (shadow.getKind() == ShadowKindType.ACCOUNT) { + if (fullShadow) { + assertNotNull( + "Missing fullname attribute", + ShadowUtil.getSingleStringAttributeValue(shadow, + new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "fullname"))); + if (supportsActivation()) { + assertNotNull("no activation", shadow.getActivation()); + assertNotNull("no activation status", shadow.getActivation().getAdministrativeStatus()); + assertEquals("not enabled", ActivationStatusType.ENABLED, shadow.getActivation().getAdministrativeStatus()); } - - assertProvisioningAccountShadow(shadow.asPrismObject(), resourceType, RefinedAttributeDefinition.class); } - }; + + assertProvisioningAccountShadow(shadow.asPrismObject(), resourceType, RefinedAttributeDefinition.class); + } + }; } protected void assertRepoShadowCachedAttributeValue(PrismObject shadowRepo, String attrName, T... attrValues) { @@ -1543,7 +1446,7 @@ protected void assertRepoShadowCacheActivation(PrismObject shadowRep return; } ActivationStatusType administrativeStatus = activationType.getAdministrativeStatus(); - assertNull("Unexpected activation administrativeStatus in repo shadow "+shadowRepo+": "+administrativeStatus, administrativeStatus); + assertNull("Unexpected activation administrativeStatus in repo shadow " + shadowRepo + ": " + administrativeStatus, administrativeStatus); } protected void assertRepoShadowCredentials(PrismObject shadowRepo, String expectedPassword) throws SchemaException, EncryptionException { @@ -1551,12 +1454,12 @@ protected void assertRepoShadowCredentials(PrismObject shadowRepo, S if (expectedPassword == null && credentials == null) { return; } - assertNotNull("Missing credentendials in repo shadow "+shadowRepo, credentials); + assertNotNull("Missing credentendials in repo shadow " + shadowRepo, credentials); PasswordType passwordType = credentials.getPassword(); if (expectedPassword == null && passwordType == null) { return; } - assertNotNull("Missing password credential in repo shadow "+shadowRepo, passwordType); + assertNotNull("Missing password credential in repo shadow " + shadowRepo, passwordType); // TODO: assert password meta-data assertRepoShadowPasswordValue(shadowRepo, passwordType, expectedPassword); } @@ -1564,8 +1467,7 @@ protected void assertRepoShadowCredentials(PrismObject shadowRepo, S protected void assertRepoShadowPasswordValue(PrismObject shadowRepo, PasswordType passwordType, String expectedPassword) throws SchemaException, EncryptionException { ProtectedStringType passwordValue = passwordType.getValue(); - assertNull("Unexpected password value in repo shadow "+shadowRepo, passwordValue); + assertNull("Unexpected password value in repo shadow " + shadowRepo, passwordValue); } - } diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummy.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummy.java index 4e0eadd4da7..d744cae6d98 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummy.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummy.java @@ -223,7 +223,7 @@ public void test107AGetModifiedAccountFromCacheMax() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); try { @@ -232,7 +232,7 @@ public void test107AGetModifiedAccountFromCacheMax() throws Exception { assertNotReached(); } catch (ConfigurationException e) { // Caching is disabled, this is expected. - then(TEST_NAME); + then(); display("Expected exception", e); assertFailure(result); } @@ -276,12 +276,12 @@ public void test107BGetModifiedAccountFromCacheHighStaleness() throws Exception XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); PrismObject shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, options, null, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); display("getObject result", result); TestUtil.assertSuccess(result); @@ -322,11 +322,11 @@ public void test108GetAccountLowStaleness() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); PrismObject shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, options, null, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); display("getObject result", result); TestUtil.assertSuccess(result); @@ -338,7 +338,7 @@ public void test108GetAccountLowStaleness() throws Exception { assertNotNull("No dummy account", shadow); - checkAccountShadow(shadow, result, true, startTs, endTs); + checkAccountShadow(shadow, result, true); assertAttribute(shadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "Very Nice Pirate"); assertAttribute(shadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "Interceptor"); assertAttribute(shadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "Sword", "LOVE"); @@ -443,7 +443,7 @@ public boolean handle(PrismObject object, OperationResult parentResu assertTrue(object.canRepresent(ShadowType.class)); try { - checkAccountShadow(object, parentResult, true, startTs, endTs); + checkAccountShadow(object, parentResult, true); } catch (SchemaException e) { throw new SystemException(e.getMessage(), e); } @@ -693,11 +693,11 @@ public void test115CountAllAccounts() throws Exception { display("All shadows query", query); // WHEN - when(TEST_NAME); + when(); Integer count = provisioningService.countObjects(ShadowType.class, query, null, null, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("Found " + count + " shadows"); @@ -866,12 +866,12 @@ public void test120ModifyWillReplaceFullname() throws Exception { delta.checkConsistence(); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); delta.checkConsistence(); @@ -899,12 +899,12 @@ public void test121ModifyObjectAddPirate() throws Exception { delta.checkConsistence(); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); delta.checkConsistence(); @@ -933,12 +933,12 @@ public void test122ModifyObjectAddCaptain() throws Exception { delta.checkConsistence(); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); delta.checkConsistence(); @@ -966,12 +966,12 @@ public void test123ModifyObjectDeletePirate() throws Exception { delta.checkConsistence(); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); delta.checkConsistence(); @@ -1003,12 +1003,12 @@ public void test124ModifyAccountWillAddCaptainAgain() throws Exception { delta.checkConsistence(); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); delta.checkConsistence(); @@ -1049,12 +1049,12 @@ public void test126ModifyAccountWillPassword() throws Exception { display("ObjectDelta", delta); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertDummyAccount(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid) @@ -1096,12 +1096,12 @@ protected void testComparePassword(final String TEST_NAME, String tag, String sh syncServiceMock.reset(); // WHEN (match) - when(TEST_NAME); + when(); ItemComparisonResult comparisonResult = provisioningService.compare(ShadowType.class, shadowOid, SchemaConstants.PATH_PASSWORD_VALUE, expectedPassword, task, result); // THEN (match) - then(TEST_NAME); + then(); assertSuccess(result); display("Comparison result (" + tag + ")", comparisonResult); @@ -1125,11 +1125,11 @@ public void test129NullAttributeValue() throws Exception { willDummyAccount.replaceAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, null); // WHEN - when(TEST_NAME); + when(); PrismObject accountWill = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); ResourceAttributeContainer attributesContainer = ShadowUtil.getAttributesContainer(accountWill); @@ -1447,12 +1447,12 @@ public void test152ActivationStatusUndefinedAccount() throws Exception { delta.checkConsistence(); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); display("modifyObject result", result); TestUtil.assertSuccess(result); @@ -1609,12 +1609,12 @@ public void test157SetValidTo() throws Exception { delta.checkConsistence(); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); display("modifyObject result", result); TestUtil.assertSuccess(result); @@ -1664,12 +1664,12 @@ public void test158DeleteValidToValidFrom() throws Exception { delta.checkConsistence(); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); display("modifyObject result", result); TestUtil.assertSuccess(result); @@ -1699,11 +1699,11 @@ public void test159GetLockedoutAccount() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); PrismObject shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, null, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); display("getObject result", result); TestUtil.assertSuccess(result); @@ -1785,12 +1785,12 @@ public void test162UnlockAccount() throws Exception { delta.checkConsistence(); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); display("modifyObject result", result); TestUtil.assertSuccess(result); @@ -2202,7 +2202,7 @@ public boolean handle(PrismObject shadow, OperationResult parentResu assertTrue(shadow.canRepresent(ShadowType.class)); if (!useRepo) { try { - checkAccountShadow(shadow, parentResult, fullShadow, startTs, endTs); + checkAccountShadow(shadow, parentResult, fullShadow); } catch (SchemaException e) { throw new SystemException(e.getMessage(), e); } @@ -2281,7 +2281,7 @@ public boolean handle(PrismObject shadow, OperationResult parentResu assertTrue(shadow.canRepresent(ShadowType.class)); try { - checkAccountShadow(shadow, parentResult, true, startTs, endTs); + checkAccountShadow(shadow, parentResult, true); } catch (SchemaException e) { throw new SystemException(e.getMessage(), e); } @@ -2292,11 +2292,11 @@ public boolean handle(PrismObject shadow, OperationResult parentResu Collection> options = SelectorOptions.createCollection(rootOptions); // WHEN - when(TEST_NAME); + when(); SearchResultMetadata searchMetadata = provisioningService.searchObjectsIterative(ShadowType.class, query, options, handler, null, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); display("searchObjectsIterative result", result); TestUtil.assertSuccess(result); @@ -2674,12 +2674,12 @@ public void test220EntitleAccountWillPirates() throws Exception { delta.checkConsistence(); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); display("modifyObject result", result); TestUtil.assertSuccess(result); @@ -3029,12 +3029,12 @@ public void test230DetitleAccountWillPirates() throws Exception { delta.checkConsistence(); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); delta.checkConsistence(); assertAccountPiratesDetitled(); @@ -3061,12 +3061,12 @@ public void test232EntitleAccountWillPiratesIdentifiersName() throws Exception { delta.checkConsistence(); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); delta.checkConsistence(); assertAccountPiratesEntitled(); @@ -3093,12 +3093,12 @@ public void test233DetitleAccountWillPiratesIdentifiersName() throws Exception { delta.checkConsistence(); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); delta.checkConsistence(); assertAccountPiratesDetitled(); @@ -3125,12 +3125,12 @@ public void test234EntitleAccountWillPiratesIdentifiersUid() throws Exception { delta.checkConsistence(); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); delta.checkConsistence(); assertAccountPiratesEntitled(); @@ -3157,12 +3157,12 @@ public void test235DetitleAccountWillPiratesIdentifiersUid() throws Exception { delta.checkConsistence(); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); delta.checkConsistence(); assertAccountPiratesDetitled(); @@ -3556,12 +3556,12 @@ public void test300AccountRename() throws Exception { delta.checkConsistence(); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); delta.checkConsistence(); @@ -3609,12 +3609,12 @@ public void test310ModifyMorganEnlistTimestamp() throws Exception { delta.checkConsistence(); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); delta.checkConsistence(); @@ -3647,12 +3647,12 @@ public void test330ModifyAccountWillPasswordSelfService() throws Exception { ProvisioningOperationOptions options = ProvisioningOperationOptions.createRunAsAccountOid(ACCOUNT_WILL_OID); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), options, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); // Check if the account was created in the dummy resource @@ -3697,11 +3697,11 @@ public void test340ModifyWillReplaceGossipBloodAvast() throws Exception { List> mods = getGossipDelta(PlusMinusZero.ZERO, WILL_GOSSIP_BLOOD_OF_A_PIRATE, WILL_GOSSIP_AVAST); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, ACCOUNT_WILL_OID, mods, null, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertAccountWillGossip(WILL_GOSSIP_BLOOD_OF_A_PIRATE, WILL_GOSSIP_AVAST); @@ -3729,11 +3729,11 @@ public void test342ModifyWillAddGossipEunuch() throws Exception { List> mods = getGossipDelta(PlusMinusZero.PLUS, WILL_GOSSIP_EUNUCH); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, ACCOUNT_WILL_OID, mods, null, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertAccountWillGossip(WILL_GOSSIP_BLOOD_OF_A_PIRATE, WILL_GOSSIP_AVAST, WILL_GOSSIP_EUNUCH); @@ -3761,11 +3761,11 @@ public void test344ModifyWillDeleteGossipAvast() throws Exception { List> mods = getGossipDelta(PlusMinusZero.MINUS, WILL_GOSSIP_AVAST); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, ACCOUNT_WILL_OID, mods, null, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertAccountWillGossip(WILL_GOSSIP_BLOOD_OF_A_PIRATE, WILL_GOSSIP_EUNUCH); @@ -3928,14 +3928,14 @@ public void test509DeleteProtectedAccountShadow() throws Exception { try { // WHEN - when(TEST_NAME); + when(); provisioningService.deleteObject(ShadowType.class, ACCOUNT_DAEMON_OID, null, null, task, result); AssertJUnit.fail("Expected security exception while deleting 'daemon' account"); } catch (SecurityViolationException e) { // This is expected - then(TEST_NAME); + then(); display("Expected exception", e); } @@ -4044,11 +4044,11 @@ public void test520MigrationPrimaryIdentifierValueRefresh() throws Exception { repositoryService.addObject(shadowBefore, null, result); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); - then(TEST_NAME); + then(); assertSuccess(result); assertRepoShadow(ACCOUNT_RELIC_OID) @@ -4080,14 +4080,14 @@ public void test600AddAccountAlreadyExist() throws Exception { display("Adding shadow", account); // WHEN - when(TEST_NAME); + when(); try { provisioningService.addObject(account, null, null, task, result); assertNotReached(); } catch (ObjectAlreadyExistsException e) { // This is expected - then(TEST_NAME); + then(); display("Expected exception", e); } @@ -4128,7 +4128,7 @@ public void test800LiveSyncInit() throws Exception { ProvisioningTestUtil.getDefaultAccountObjectClass(resourceType)); // WHEN - when(TEST_NAME); + when(); provisioningService.synchronize(coords, syncTokenTask, null, result); // THEN @@ -4168,7 +4168,7 @@ public void test801LiveSyncAddBlackbeard() throws Exception { ProvisioningTestUtil.getDefaultAccountObjectClass(resourceType)); // WHEN - when(TEST_NAME); + when(); provisioningService.synchronize(coords, syncTokenTask, null, result); // THEN @@ -4230,7 +4230,7 @@ public void test802LiveSyncModifyBlackbeard() throws Exception { ProvisioningTestUtil.getDefaultAccountObjectClass(resourceType)); // WHEN - when(TEST_NAME); + when(); provisioningService.synchronize(coords, syncTokenTask, null, result); // THEN @@ -4393,11 +4393,11 @@ public void testLiveSyncAddDrake(final String TEST_NAME, DummySyncStyle syncStyl objectClass); // WHEN - when(TEST_NAME); + when(); provisioningService.synchronize(coords, syncTokenTask, null, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); display("Synchronization result", result); TestUtil.assertSuccess("Synchronization result is not OK", result); @@ -4464,11 +4464,11 @@ public void testLiveSyncModifyDrake(final String TEST_NAME, DummySyncStyle syncS objectClass); // WHEN - when(TEST_NAME); + when(); provisioningService.synchronize(coords, syncTokenTask, null, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); display("Synchronization result", result); TestUtil.assertSuccess("Synchronization result is not OK", result); @@ -4524,11 +4524,11 @@ public void testLiveSyncAddCorsairs(final String TEST_NAME, DummySyncStyle syncS objectClass); // WHEN - when(TEST_NAME); + when(); provisioningService.synchronize(coords, syncTokenTask, null, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); display("Synchronization result", result); TestUtil.assertSuccess("Synchronization result is not OK", result); @@ -4600,11 +4600,11 @@ public void testLiveSyncDeleteCorsairs(final String TEST_NAME, DummySyncStyle sy objectClass); // WHEN - when(TEST_NAME); + when(); provisioningService.synchronize(coords, syncTokenTask, null, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); display("Synchronization result", result); TestUtil.assertSuccess("Synchronization result is not OK", result); @@ -4666,11 +4666,11 @@ public void testLiveSyncDeleteDrake(final String TEST_NAME, DummySyncStyle syncS objectClass); // WHEN - when(TEST_NAME); + when(); provisioningService.synchronize(coords, syncTokenTask, null, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); display("Synchronization result", result); TestUtil.assertSuccess("Synchronization result is not OK", result); @@ -4721,11 +4721,11 @@ public void test890LiveSyncModifyProtectedAccount() throws Exception { ProvisioningTestUtil.getDefaultAccountObjectClass(resourceType)); // WHEN - when(TEST_NAME); + when(); provisioningService.synchronize(coords, syncTokenTask, null, result); // THEN - then(TEST_NAME); + then(); display("Synchronization result", result); assertSuccess(result); @@ -4767,7 +4767,7 @@ public void test901FailResourceNotFound() throws Exception { protected void checkCachedAccountShadow(PrismObject shadowType, OperationResult parentResult, boolean fullShadow, XMLGregorianCalendar startTs, XMLGregorianCalendar endTs) throws SchemaException { - checkAccountShadow(shadowType, parentResult, fullShadow, startTs, endTs); + checkAccountShadow(shadowType, parentResult, fullShadow); } private void checkGroupShadow(PrismObject shadow, OperationResult parentResult) throws SchemaException { diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyCaching.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyCaching.java index 46b00d64509..7d1a9fc67c0 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyCaching.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyCaching.java @@ -176,12 +176,12 @@ public void test107BGetModifiedAccountFromCacheHighStaleness() throws Exception XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); PrismObject shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, options, null, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); @@ -237,13 +237,13 @@ public void test107CSkipCachingForIncompleteAttributes() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); PrismObject shadow = provisioningService .getObject(ShadowType.class, ACCOUNT_WILL_OID, null, null, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1); @@ -374,18 +374,6 @@ protected void assertRepoShadowPasswordValue(PrismObject shadowRepo, assertProtectedString("Wrong password value in repo shadow "+shadowRepo, expectedPassword, protectedStringType, CredentialsStorageTypeType.HASHING); } - /** - * We do not know what the timestamp should be. But some timestamp should be there. - */ - @Override - protected void assertRepoCachingMetadata(PrismObject shadowFromRepo) { - CachingMetadataType cachingMetadata = shadowFromRepo.asObjectable().getCachingMetadata(); - assertNotNull("No caching metadata in "+shadowFromRepo, cachingMetadata); - - assertNotNull("Missing retrieval timestamp in caching metadata in "+shadowFromRepo, - cachingMetadata.getRetrievalTimestamp()); - } - @Override protected void assertRepoCachingMetadata(PrismObject shadowFromRepo, XMLGregorianCalendar start, XMLGregorianCalendar end) { CachingMetadataType cachingMetadata = shadowFromRepo.asObjectable().getCachingMetadata(); @@ -437,7 +425,7 @@ protected void assertRepoShadowCachedAttributeValue(PrismObject @Override protected void checkCachedAccountShadow(PrismObject shadow, OperationResult parentResult, boolean fullShadow, XMLGregorianCalendar startTs, XMLGregorianCalendar endTs) throws SchemaException { - super.checkAccountShadow(shadow, parentResult, fullShadow, startTs, endTs); + super.checkAccountShadow(shadow, parentResult, fullShadow); if (fullShadow) { assertCachingMetadata(shadow, true, startTs, endTs); } diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyConsistency.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyConsistency.java index 2e31f398d06..efc65c67e37 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyConsistency.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyConsistency.java @@ -116,11 +116,11 @@ public void test050AddAccountWill() throws Exception { display("Adding shadow", account); // WHEN - when(TEST_NAME); + when(); String addedObjectOid = provisioningService.addObject(account, null, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertEquals(ACCOUNT_WILL_OID, addedObjectOid); syncServiceMock.assertNotifySuccessOnly(); @@ -179,11 +179,11 @@ public void test100AddAccountMorganCommunicationFailure() throws Exception { lastRequestStartTs = lastAttemptStartTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); String addedObjectOid = provisioningService.addObject(account, null, null, task, result); // THEN - then(TEST_NAME); + then(); display("Result", result); assertInProgress(result); assertEquals(ACCOUNT_MORGAN_OID, addedObjectOid); @@ -240,11 +240,11 @@ public void test104RefreshAccountMorganCommunicationFailure() throws Exception { PrismObject shadowRepoBefore = getShadowRepo(ACCOUNT_MORGAN_OID); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - then(TEST_NAME); + then(); display("Result", result); assertSuccess(result); syncServiceMock.assertNoNotifcations(); @@ -272,7 +272,7 @@ public void test105GetForceRefreshAccountMorganCommunicationFailure() throws Exc try { // WHEN - when(TEST_NAME); + when(); provisioningService.getObject(ShadowType.class, ACCOUNT_MORGAN_OID, options, task, result); @@ -283,7 +283,7 @@ public void test105GetForceRefreshAccountMorganCommunicationFailure() throws Exc } // THEN - then(TEST_NAME); + then(); display("Result", result); assertFailure(result); syncServiceMock.assertNoNotifcations(); @@ -315,11 +315,11 @@ public void test106RefreshAccountMorganCommunicationFailureRetry() throws Except lastAttemptStartTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - then(TEST_NAME); + then(); display("Result", result); result.computeStatus(); TestUtil.assertResultStatus(result, OperationResultStatus.HANDLED_ERROR); @@ -354,11 +354,11 @@ public void test108RefreshAccountMorganCommunicationFailureRetryAgain() throws E lastAttemptStartTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - then(TEST_NAME); + then(); display("Result", result); result.computeStatus(); TestUtil.assertResultStatus(result, OperationResultStatus.HANDLED_ERROR); @@ -479,11 +479,11 @@ public void test109RefreshAccountMorganDead() throws Exception { PrismObject shadowRepoBefore = getShadowRepo(ACCOUNT_MORGAN_OID); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - then(TEST_NAME); + then(); display("Result", result); assertSuccess(result); syncServiceMock.assertNoNotifcations(); @@ -514,11 +514,11 @@ public void test110AddAccountMorganAgainCommunicationFailure() throws Exception lastRequestStartTs = lastAttemptStartTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); shadowMorganOid = provisioningService.addObject(account, null, null, task, result); // THEN - then(TEST_NAME); + then(); display("Result", result); assertInProgress(result); account.checkConsistence(); @@ -549,11 +549,11 @@ public void test114RefreshAccountMorganCommunicationFailure() throws Exception { PrismObject shadowRepoBefore = getShadowRepo(shadowMorganOid); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - then(TEST_NAME); + then(); display("Result", result); assertSuccess(result); syncServiceMock.assertNoNotifcations(); @@ -585,11 +585,11 @@ public void test116RefreshAccountMorganRetrySuccess() throws Exception { lastAttemptStartTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - then(TEST_NAME); + then(); display("Result", result); assertSuccess(result); lastAttemptEndTs = clock.currentTimeXMLGregorianCalendar(); @@ -618,12 +618,12 @@ public void test120ModifyMorganFullNameCommunicationFailure() throws Exception { display("ObjectDelta", delta); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), null, null, task, result); // THEN - then(TEST_NAME); + then(); assertInProgress(result); lastRequestEndTs = lastAttemptEndTs = clock.currentTimeXMLGregorianCalendar(); syncServiceMock.assertNotifyInProgressOnly(); @@ -652,11 +652,11 @@ public void test124RefreshAccountMorganCommunicationFailure() throws Exception { PrismObject shadowRepoBefore = getShadowRepo(shadowMorganOid); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - then(TEST_NAME); + then(); display("Result", result); assertSuccess(result); syncServiceMock.assertNoNotifcations(); @@ -688,11 +688,11 @@ public void test126RefreshAccountMorganCommunicationFailureRetry() throws Except lastAttemptStartTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - then(TEST_NAME); + then(); display("Result", result); result.computeStatus(); TestUtil.assertResultStatus(result, OperationResultStatus.HANDLED_ERROR); @@ -727,11 +727,11 @@ public void test128RefreshAccountMorganCommunicationFailureRetryAgain() throws E lastAttemptStartTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - then(TEST_NAME); + then(); display("Result", result); result.computeStatus(); TestUtil.assertResultStatus(result, OperationResultStatus.HANDLED_ERROR); @@ -761,11 +761,11 @@ public void test129RefreshAccountMorganFailed() throws Exception { PrismObject shadowRepoBefore = getShadowRepo(shadowMorganOid); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - then(TEST_NAME); + then(); display("Result", result); assertSuccess(result); syncServiceMock.assertNoNotifcations(); @@ -789,12 +789,12 @@ public void test130ModifyMorganFullNameAgainCommunicationFailure() throws Except display("ObjectDelta", delta); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), null, null, task, result); // THEN - then(TEST_NAME); + then(); assertInProgress(result); lastRequestEndTs = lastAttemptEndTs = clock.currentTimeXMLGregorianCalendar(); syncServiceMock.assertNotifyInProgressOnly(); @@ -824,12 +824,12 @@ public void test132GetAccountMorganCommunicationFailure() throws Exception { dummyResource.setBreakMode(BreakMode.NETWORK); // WHEN - when(TEST_NAME); + when(); provisioningService.getObject(ShadowType.class, shadowMorganOid, null, task, result); // THEN - then(TEST_NAME); + then(); display("Result", result); assertPartialError(result); syncServiceMock.assertNoNotifcations(); @@ -860,7 +860,7 @@ public void test133GetAccountMorganStalenessZeroCommunicationFailure() throws Ex try { // WHEN - when(TEST_NAME); + when(); provisioningService.getObject(ShadowType.class, shadowMorganOid, options, task, result); @@ -871,7 +871,7 @@ public void test133GetAccountMorganStalenessZeroCommunicationFailure() throws Ex } // THEN - then(TEST_NAME); + then(); display("Result", result); assertFailure(result); syncServiceMock.assertNoNotifcations(); @@ -901,11 +901,11 @@ public void test134GetAccountMorganForceRefreshRetryCommunicationFailure() throw Collection> options = SelectorOptions.createCollection(GetOperationOptions.createForceRefresh()); // WHEN - when(TEST_NAME); + when(); provisioningService.getObject(ShadowType.class, shadowMorganOid, options, task, result); // THEN - then(TEST_NAME); + then(); display("Result", result); assertPartialError(result); lastAttemptEndTs = clock.currentTimeXMLGregorianCalendar(); @@ -938,11 +938,11 @@ public void test136RefreshAccountMorganRetrySuccess() throws Exception { lastAttemptStartTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - then(TEST_NAME); + then(); display("Result", result); assertSuccess(result); lastAttemptEndTs = clock.currentTimeXMLGregorianCalendar(); @@ -971,11 +971,11 @@ public void test170DeleteMorganCommunicationFailure() throws Exception { display("ObjectDelta", delta); // WHEN - when(TEST_NAME); + when(); provisioningService.deleteObject(ShadowType.class, shadowMorganOid, null, null, task, result); // THEN - then(TEST_NAME); + then(); assertInProgress(result); lastRequestEndTs = lastAttemptEndTs = clock.currentTimeXMLGregorianCalendar(); syncServiceMock.assertNotifyInProgressOnly(); @@ -1004,11 +1004,11 @@ public void test174RefreshAccountMorganCommunicationFailure() throws Exception { PrismObject shadowRepoBefore = getShadowRepo(shadowMorganOid); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - then(TEST_NAME); + then(); display("Result", result); assertSuccess(result); syncServiceMock.assertNoNotifcations(); @@ -1040,11 +1040,11 @@ public void test176RefreshAccountMorganCommunicationFailureRetry() throws Except lastAttemptStartTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - then(TEST_NAME); + then(); display("Result", result); result.computeStatus(); TestUtil.assertResultStatus(result, OperationResultStatus.HANDLED_ERROR); @@ -1079,11 +1079,11 @@ public void test178RefreshAccountMorganCommunicationFailureRetryAgain() throws E lastAttemptStartTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - then(TEST_NAME); + then(); display("Result", result); result.computeStatus(); TestUtil.assertResultStatus(result, OperationResultStatus.HANDLED_ERROR); @@ -1112,11 +1112,11 @@ public void test179RefreshAccountMorganFailed() throws Exception { PrismObject shadowRepoBefore = getShadowRepo(shadowMorganOid); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - then(TEST_NAME); + then(); display("Result", result); assertSuccess(result); syncServiceMock.assertNoNotifcations(); @@ -1140,11 +1140,11 @@ public void test180DeleteMorganCommunicationFailureAgain() throws Exception { display("ObjectDelta", delta); // WHEN - when(TEST_NAME); + when(); PrismObject returnedShadow = provisioningService.deleteObject(ShadowType.class, shadowMorganOid, null, null, task, result); // THEN - then(TEST_NAME); + then(); assertInProgress(result); lastRequestEndTs = lastAttemptEndTs = clock.currentTimeXMLGregorianCalendar(); syncServiceMock.assertNotifyInProgressOnly(); @@ -1179,11 +1179,11 @@ public void test186RefreshAccountMorganRetrySuccess() throws Exception { lastAttemptStartTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - then(TEST_NAME); + then(); display("Result", result); assertSuccess(result); lastAttemptEndTs = clock.currentTimeXMLGregorianCalendar(); @@ -1219,11 +1219,11 @@ public void test190AccountMorganDeadExpireOperation() throws Exception { PrismObject shadowRepoBefore = getShadowRepo(ACCOUNT_MORGAN_OID); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - then(TEST_NAME); + then(); display("Result", result); assertSuccess(result); syncServiceMock.assertNoNotifcations(); @@ -1304,11 +1304,11 @@ public void test192AccountMorganSecondDeadExpireOperation() throws Exception { PrismObject shadowRepoBefore = getShadowRepo(shadowMorganOid); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - then(TEST_NAME); + then(); display("Result", result); assertSuccess(result); syncServiceMock.assertNoNotifcations(); @@ -1373,11 +1373,11 @@ public void test194AccountMorganDeadExpireShadow() throws Exception { PrismObject shadowRepoBefore = getShadowRepo(ACCOUNT_MORGAN_OID); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - then(TEST_NAME); + then(); display("Result", result); assertSuccess(result); syncServiceMock.assertNotifySuccessOnly(); @@ -1409,11 +1409,11 @@ public void test196AccountMorganSecondDeadExpireShadow() throws Exception { PrismObject shadowRepoBefore = getShadowRepo(shadowMorganOid); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - then(TEST_NAME); + then(); display("Result", result); assertSuccess(result); syncServiceMock.assertNotifySuccessOnly(); @@ -1447,12 +1447,12 @@ public void test800AddAccountMorganAlreadyExists() throws Exception { display("Adding shadow", account); // WHEN - when(TEST_NAME); + when(); try { provisioningService.addObject(account, null, null, task, result); assertNotReached(); } catch (ObjectAlreadyExistsException e) { - then(TEST_NAME); + then(); display("expected exception", e); } @@ -1526,12 +1526,12 @@ public void test802AddAccountMorganAlreadyExistsAgain() throws Exception { display("Adding shadow", account); // WHEN - when(TEST_NAME); + when(); try { provisioningService.addObject(account, null, null, task, result); assertNotReached(); } catch (ObjectAlreadyExistsException e) { - then(TEST_NAME); + then(); display("expected exception", e); } @@ -1612,11 +1612,11 @@ public void test804AddAccountElizabeth() throws Exception { display("Adding shadow", account); // WHEN - when(TEST_NAME); + when(); provisioningService.addObject(account, null, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); account.checkConsistence(); @@ -1647,17 +1647,17 @@ public void test806RenameAccountElizabethAlreadyExists() throws Exception { ACCOUNT_BETTY_USERNAME); // WHEN - when(TEST_NAME); + when(); try { provisioningService.modifyObject(ShadowType.class, ACCOUNT_ELIZABETH_OID, delta.getModifications(), null, null, task, result); assertNotReached(); } catch (ObjectAlreadyExistsException e) { - then(TEST_NAME); + then(); display("expected exception", e); } // THEN - then(TEST_NAME); + then(); assertFailure(result); PrismObject conflictingShadowRepo = findAccountShadowByUsername(ACCOUNT_BETTY_USERNAME, getResource(), result); @@ -1726,17 +1726,17 @@ public void test808RenameAccountElizabethAlreadyExistsAgain() throws Exception { ACCOUNT_BETTY_USERNAME); // WHEN - when(TEST_NAME); + when(); try { provisioningService.modifyObject(ShadowType.class, ACCOUNT_ELIZABETH_OID, delta.getModifications(), null, null, task, result); assertNotReached(); } catch (ObjectAlreadyExistsException e) { - then(TEST_NAME); + then(); display("expected exception", e); } // THEN - then(TEST_NAME); + then(); assertFailure(result); PrismObject conflictingShadowRepo = findAccountShadowByUsername(ACCOUNT_BETTY_USERNAME, getResource(), result); @@ -1817,11 +1817,11 @@ public void test810GetAccountMorganNotFound() throws Exception { dummyResourceCtl.deleteAccount(ACCOUNT_MORGAN_NAME); // WHEN - when(TEST_NAME); + when(); PrismObject provisioningShadow = provisioningService.getObject(ShadowType.class, shadowMorganOid, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); // @formatter:off @@ -1888,12 +1888,12 @@ public void test812ModifyAccountWillNotFound() throws Exception { ACCOUNT_WILL_OID, dummyResourceCtl.getAttributeFullnamePath(), "Pirate Will Turner"); // WHEN - when(TEST_NAME); + when(); try { provisioningService.modifyObject(ShadowType.class, ACCOUNT_WILL_OID, delta.getModifications(), null, null, task, result); assertNotReached(); } catch (ObjectNotFoundException e) { - then(TEST_NAME); + then(); display("expected exception", e); } @@ -1959,11 +1959,11 @@ public void test814DeleteAccountElizabethNotFound() throws Exception { dummyResourceCtl.deleteAccount(ACCOUNT_ELIZABETH_USERNAME); // WHEN - when(TEST_NAME); + when(); provisioningService.deleteObject(ShadowType.class, ACCOUNT_ELIZABETH_OID, null, null, task, result); // THEN - then(TEST_NAME); + then(); display("Result", result); assertHadnledError(result); @@ -2030,16 +2030,16 @@ public void test816AddAccountElizabethAfterDeathAlreadyExists() throws Exception display("Adding shadow", account); // WHEN - when(TEST_NAME); + when(); try { provisioningService.addObject(account, null, null, task, result); } catch (ObjectAlreadyExistsException e) { - then(TEST_NAME); + then(); display("expected exception", e); } // THEN - then(TEST_NAME); + then(); assertFailure(result); // @formatter:off @@ -2094,11 +2094,11 @@ public void test900GetAccountMurrayPending() throws Exception { repoAddObjectFromFile(ACCOUNT_SHADOW_MURRAY_PENDING_FILE, result); // WHEN - when(TEST_NAME); + when(); PrismObject accountMurray = provisioningService.getObject(ShadowType.class, ACCOUNT_SHADOW_MURRAY_PENDING_OID, null, task, result); // THEN - then(TEST_NAME); + then(); display("Result", result); assertSuccess(result); accountMurray.checkConsistence(); 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 7ce0396340a..60e2e3e4daf 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 @@ -118,11 +118,11 @@ public void test400AddAccountElizabeth() throws Exception { XMLGregorianCalendar start = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); String addedObjectOid = provisioningService.addObject(account, null, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar end = clock.currentTimeXMLGregorianCalendar(); @@ -245,11 +245,11 @@ public void test499DeleteAccountElizabeth() throws Exception { syncServiceMock.reset(); // WHEN - when(TEST_NAME); + when(); provisioningService.deleteObject(ShadowType.class, ACCOUNT_ELIZABETH_OID, null, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); syncServiceMock.assertNotifySuccessOnly(); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyNegative.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyNegative.java index 89189cf44db..d75acc9e32e 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyNegative.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyNegative.java @@ -106,10 +106,10 @@ public void test190GetResource() throws Exception { syncServiceMock.reset(); // WHEN - when(TEST_NAME); + when(); PrismObject resource = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result); - then(TEST_NAME); + then(); assertSuccess(result); display("Resource after", resource); @@ -133,7 +133,7 @@ public void test200AddAccountNullAttributes() throws Exception { try { // WHEN - when(TEST_NAME); + when(); provisioningService.addObject(account, null, null, task, result); assertNotReached(); @@ -142,7 +142,7 @@ public void test200AddAccountNullAttributes() throws Exception { display("Expected exception", e); } - then(TEST_NAME); + then(); syncServiceMock.assertNotifyFailureOnly(); } diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyParallelism.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyParallelism.java index c4af929d39e..b0a269c8174 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyParallelism.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyParallelism.java @@ -123,8 +123,6 @@ protected void assertWillRepoShadowAfterCreate(PrismObject repoShado @Test public void test120ModifyWillReplaceFullname() throws Exception { - final String TEST_NAME = "test120ModifyWillReplaceFullname"; - Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -135,12 +133,12 @@ public void test120ModifyWillReplaceFullname() throws Exception { delta.checkConsistence(); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertDummyAccount(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid) @@ -162,18 +160,16 @@ public void test120ModifyWillReplaceFullname() throws Exception { @Test public void test190DeleteWill() throws Exception { - final String TEST_NAME = "test190DeleteWill"; - Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); // WHEN - when(TEST_NAME); + when(); provisioningService.deleteObject(ShadowType.class, ACCOUNT_WILL_OID, null, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); syncServiceMock.assertNotifySuccessOnly(); @@ -201,7 +197,6 @@ public void test190DeleteWill() throws Exception { */ @Test public void test200ParallelCreate() throws Exception { - final String TEST_NAME = "test200ParallelCreate"; // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -210,7 +205,7 @@ public void test200ParallelCreate() throws Exception { rememberDummyResourceWriteOperationCount(null); // WHEN - when(TEST_NAME); + when(); accountMorganOid = null; @@ -240,7 +235,7 @@ public void test200ParallelCreate() throws Exception { }, CONCURRENT_TEST_THREAD_COUNT_HIGH, CONCURRENT_TEST_MAX_START_DELAY_FAST); // THEN - then(TEST_NAME); + then(); waitForThreads(threads, WAIT_TIMEOUT); successCounter.assertCount("Wrong number of successful operations", 1); @@ -265,9 +260,7 @@ public void test200ParallelCreate() throws Exception { */ @Test public void test202ParallelModifyCaptainMorgan() throws Exception { - final String TEST_NAME = "test202ParallelModifyCaptainMorgan"; - - PrismObject shadowAfter = parallelModifyTest(TEST_NAME, + PrismObject shadowAfter = parallelModifyTest( () -> prismContext.deltaFactory().object().createModificationReplaceProperty(ShadowType.class, accountMorganOid, dummyResourceCtl.getAttributeFullnamePath(), "Captain Morgan")); @@ -284,9 +277,7 @@ public void test202ParallelModifyCaptainMorgan() throws Exception { */ @Test public void test204ParallelModifyDisable() throws Exception { - final String TEST_NAME = "test204ParallelModifyDisable"; - - PrismObject shadowAfter = parallelModifyTest(TEST_NAME, + PrismObject shadowAfter = parallelModifyTest( () -> prismContext.deltaFactory().object().createModificationReplaceProperty(ShadowType.class, accountMorganOid, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, ActivationStatusType.DISABLED)); @@ -294,7 +285,8 @@ public void test204ParallelModifyDisable() throws Exception { assertActivationAdministrativeStatus(shadowAfter, ActivationStatusType.DISABLED); } - private PrismObject parallelModifyTest(final String TEST_NAME, FailableProducer> deltaProducer) throws Exception { + private PrismObject parallelModifyTest( + FailableProducer> deltaProducer) throws Exception { // GIVEN Task task = getTestTask(); @@ -304,7 +296,7 @@ private PrismObject parallelModifyTest(final String TEST_NAME, Faila rememberDummyResourceWriteOperationCount(null); // WHEN - when(TEST_NAME); + when(); ParallelTestThread[] threads = multithread( (i) -> { @@ -337,7 +329,7 @@ private PrismObject parallelModifyTest(final String TEST_NAME, Faila }, CONCURRENT_TEST_THREAD_COUNT, CONCURRENT_TEST_MAX_START_DELAY_FAST); // THEN - then(TEST_NAME); + then(); waitForThreads(threads, WAIT_TIMEOUT); PrismObject shadowAfter = provisioningService.getObject(ShadowType.class, accountMorganOid, null, task, result); @@ -354,14 +346,12 @@ private PrismObject parallelModifyTest(final String TEST_NAME, Faila @Test public void test209ParallelDelete() throws Exception { - final String TEST_NAME = "test209ParallelDelete"; - // GIVEN final Counter successCounter = new Counter(); rememberDummyResourceWriteOperationCount(null); // WHEN - when(TEST_NAME); + when(); Task task = getTestTask(); ParallelTestThread[] threads = multithread( @@ -394,7 +384,7 @@ public void test209ParallelDelete() throws Exception { }, CONCURRENT_TEST_THREAD_COUNT, CONCURRENT_TEST_MAX_START_DELAY_FAST); // THEN - then(TEST_NAME); + then(); waitForThreads(threads, WAIT_TIMEOUT); successCounter.assertCount("Wrong number of successful operations", 1); @@ -412,7 +402,6 @@ public void test209ParallelDelete() throws Exception { @Test public void test210ParallelCreateSlow() throws Exception { - final String TEST_NAME = "test210ParallelCreateSlow"; // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -421,7 +410,7 @@ public void test210ParallelCreateSlow() throws Exception { rememberDummyResourceWriteOperationCount(null); // WHEN - when(TEST_NAME); + when(); ParallelTestThread[] threads = multithread( (i) -> { @@ -447,7 +436,7 @@ public void test210ParallelCreateSlow() throws Exception { }, CONCURRENT_TEST_THREAD_COUNT, null); // THEN - then(TEST_NAME); + then(); waitForThreads(threads, WAIT_TIMEOUT); successCounter.assertCount("Wrong number of successful operations", 1); @@ -470,9 +459,7 @@ public void test210ParallelCreateSlow() throws Exception { */ @Test public void test212ParallelModifyElizabethSlow() throws Exception { - final String TEST_NAME = "test212ParallelModifyElizabethSlow"; - - PrismObject shadowAfter = parallelModifyTestSlow(TEST_NAME, + PrismObject shadowAfter = parallelModifyTestSlow( () -> prismContext.deltaFactory().object().createModificationReplaceProperty(ShadowType.class, accountElizabethOid, dummyResourceCtl.getAttributeFullnamePath(), "Miss Swan")); @@ -489,9 +476,7 @@ public void test212ParallelModifyElizabethSlow() throws Exception { */ @Test public void test214ParallelModifyDisableSlow() throws Exception { - final String TEST_NAME = "test214ParallelModifyDisableSlow"; - - PrismObject shadowAfter = parallelModifyTestSlow(TEST_NAME, + PrismObject shadowAfter = parallelModifyTestSlow( () -> prismContext.deltaFactory().object().createModificationReplaceProperty(ShadowType.class, accountElizabethOid, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, ActivationStatusType.DISABLED)); @@ -499,18 +484,17 @@ public void test214ParallelModifyDisableSlow() throws Exception { assertActivationAdministrativeStatus(shadowAfter, ActivationStatusType.DISABLED); } - private PrismObject parallelModifyTestSlow(final String TEST_NAME, FailableProducer> deltaProducer) throws Exception { + private PrismObject parallelModifyTestSlow( + FailableProducer> deltaProducer) throws Exception { - // GIVEN + given(); Task task = getTestTask(); OperationResult result = task.getResult(); final Counter successCounter = new Counter(); rememberDummyResourceWriteOperationCount(null); - // WHEN - when(TEST_NAME); - + when(); ParallelTestThread[] threads = multithread( (i) -> { OperationResult localResult = task.getResult().createSubresult("thread-" + i); @@ -542,7 +526,7 @@ private PrismObject parallelModifyTestSlow(final String TEST_NAME, F }, CONCURRENT_TEST_THREAD_COUNT, null); // THEN - then(TEST_NAME); + then(); waitForThreads(threads, WAIT_TIMEOUT); PrismObject shadowAfter = provisioningService.getObject(ShadowType.class, accountElizabethOid, null, task, result); @@ -559,14 +543,12 @@ private PrismObject parallelModifyTestSlow(final String TEST_NAME, F @Test public void test229ParallelDeleteSlow() throws Exception { - final String TEST_NAME = "test229ParallelDeleteSlow"; - // GIVEN final Counter successCounter = new Counter(); rememberDummyResourceWriteOperationCount(null); // WHEN - when(TEST_NAME); + when(); Task task = getTestTask(); ParallelTestThread[] threads = multithread( @@ -602,7 +584,7 @@ public void test229ParallelDeleteSlow() throws Exception { }, CONCURRENT_TEST_THREAD_COUNT, null); // THEN - then(TEST_NAME); + then(); waitForThreads(threads, WAIT_TIMEOUT); successCounter.assertCount("Wrong number of successful operations", 1); @@ -628,7 +610,6 @@ public void test229ParallelDeleteSlow() throws Exception { */ @Test public void test230ParallelGroupSearch() throws Exception { - final String TEST_NAME = "test230ParallelGroupSearch"; // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); @@ -669,13 +650,13 @@ public void test230ParallelGroupSearch() throws Exception { Thread.sleep(100); // WHEN - when(TEST_NAME); + when(); // Unblock the handlers. And here we go! dummyResource.unblockAll(); // THEN - then(TEST_NAME); + then(); waitForThreads(threads, WAIT_TIMEOUT); dummyResource.setSyncSearchHandlerStart(false); @@ -716,8 +697,6 @@ private ObjectQuery createGroupNameQuery(String groupName) throws SchemaExceptio */ @Test public void test800ParallelReadAndModifyResource() throws Exception { - final String TEST_NAME = "test800ParallelReadAndModifyResource"; - Task task = getTestTask(); OperationResult result = task.getResult(); @@ -739,7 +718,7 @@ public void test800ParallelReadAndModifyResource() throws Exception { } // WHEN - when(TEST_NAME); + when(); long t0 = System.currentTimeMillis(); MutableBoolean readFinished = new MutableBoolean(); @@ -814,7 +793,7 @@ public void test800ParallelReadAndModifyResource() throws Exception { }, CONCURRENT_TEST_THREAD_COUNT_HIGH, CONCURRENT_TEST_MAX_START_DELAY_FAST); // THEN - then(TEST_NAME); + then(); waitForThreads(threads, WAIT_TIMEOUT); PrismObject resourceAfter = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyResourceAndSchemaCaching.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyResourceAndSchemaCaching.java index 20726ce0d4b..adb7fa38a6e 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyResourceAndSchemaCaching.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyResourceAndSchemaCaching.java @@ -87,11 +87,11 @@ public void test010GetResource() throws Exception { rememberResourceCacheStats(); // WHEN - when(TEST_NAME); + when(); PrismObject resourceProvisioning = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, null, result); // THEN - then(TEST_NAME); + then(); display("Resource", resource); assertSuccess(result); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySchemaless.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySchemaless.java index 6c0f979944c..9776c3ffeb7 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySchemaless.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySchemaless.java @@ -368,12 +368,12 @@ public void resourceStatciSchemaResourceAndConnectorCaching(final String TEST_NA assertStaticSchemaSanity(resourceSchemaBefore); // WHEN - when(TEST_NAME); + when(); PrismObject resourceAgain = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_STATIC_SCHEMA_OID, null, null, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); ResourceType resourceTypeAgain = resourceAgain.asObjectable(); @@ -445,11 +445,11 @@ public void test040ReAddResourceStaticSchema() throws Exception { fillInConnectorRef(resourceNew, IntegrationTestTools.DUMMY_CONNECTOR_TYPE, result); // WHEN - when(TEST_NAME); + when(); provisioningService.addObject(resourceNew, null, ProvisioningOperationOptions.createOverwrite(true), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertCounterIncrement(InternalCounters.RESOURCE_SCHEMA_FETCH_COUNT, 0); @@ -677,12 +677,12 @@ public void test107Capabilities() throws Exception { OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); // WHEN - when(TEST_NAME); + when(); ResourceType resourceType = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_STATIC_SCHEMA_OID, null, null, result) .asObjectable(); // THEN - then(TEST_NAME); + then(); assertSuccess(result); // Check native capabilities diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/manual/AbstractManualResourceTest.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/manual/AbstractManualResourceTest.java index d4799794fc7..3e7d4c05d47 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/manual/AbstractManualResourceTest.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/manual/AbstractManualResourceTest.java @@ -348,11 +348,11 @@ public void test100AddAccountWill() throws Exception { accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); String addedObjectOid = provisioningService.addObject(account, null, null, task, result); // THEN - then(TEST_NAME); + then(); display("result", result); willLastCaseOid = assertInProgress(result); @@ -415,11 +415,11 @@ public void test102GetAccountWillFuture() throws Exception { Collection> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); // WHEN - when(TEST_NAME); + when(); PrismObject shadowProvisioning = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, options, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("Provisioning shadow", shadowProvisioning); @@ -450,11 +450,11 @@ public void test104RefreshAccountWill() throws Exception { display("Shadow before", shadowBefore); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -504,11 +504,11 @@ public void test106AddToBackingStoreAndGetAccountWill() throws Exception { syncServiceMock.reset(); // WHEN - when(TEST_NAME); + when(); PrismObject shadowProvisioning = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("Provisioning shadow", shadowProvisioning); @@ -545,11 +545,11 @@ public void test108GetAccountWillFuture() throws Exception { Collection> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); // WHEN - when(TEST_NAME); + when(); PrismObject shadowProvisioning = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, options, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("Provisioning shadow", shadowProvisioning); @@ -587,7 +587,7 @@ public void test109GetAccountWillFutureNoFetch() throws Exception { options.setNoFetch(true); // WHEN - when(TEST_NAME); + when(); PrismObject shadowProvisioningFuture = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, SelectorOptions.createCollection(options), @@ -595,7 +595,7 @@ public void test109GetAccountWillFutureNoFetch() throws Exception { // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("Provisioning shadow (future,noFetch)", shadowProvisioningFuture); @@ -633,11 +633,11 @@ public void test110CloseCaseAndRefreshAccountWill() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); accountWillCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -693,11 +693,11 @@ public void test120RefreshAccountWillAfter5min() throws Exception { display("Shadow before", shadowBefore); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -745,11 +745,11 @@ public void test130RefreshAccountWillAfter16min() throws Exception { display("Shadow before", shadowBefore); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -797,11 +797,11 @@ public void test132RefreshAccountWillAfter27min() throws Exception { display("Shadow before", shadowBefore); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -838,12 +838,12 @@ public void test200ModifyAccountWillFullname() throws Exception { accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), null, null, task, result); // THEN - then(TEST_NAME); + then(); display("result", result); willLastCaseOid = assertInProgress(result); @@ -916,11 +916,11 @@ public void test202RefreshAccountWill() throws Exception { display("Shadow before", shadowBefore); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -1000,11 +1000,11 @@ public void test204CloseCaseAndRefreshAccountWill() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); accountWillCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -1091,11 +1091,11 @@ public void test210RefreshAccountWillAfter5min() throws Exception { display("Shadow before", shadowBefore); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -1159,11 +1159,11 @@ public void test212UpdateBackingStoreAndGetAccountWill() throws Exception { backingStoreUpdateWill(ACCOUNT_WILL_FULLNAME_PIRATE, ActivationStatusType.ENABLED, ACCOUNT_WILL_PASSWORD_OLD); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -1225,12 +1225,12 @@ public void test220ModifyAccountWillDisable() throws Exception { accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), null, null, task, result); // THEN - then(TEST_NAME); + then(); display("result", result); willLastCaseOid = assertInProgress(result); @@ -1311,12 +1311,12 @@ public void test230ModifyAccountWillChangePasswordAndEnable() throws Exception { accountWillSecondReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), null, null, task, result); // THEN - then(TEST_NAME); + then(); display("result", result); willSecondLastCaseOid = assertInProgress(result); @@ -1395,12 +1395,12 @@ public void test240CloseDisableCaseAndReadAccountWill() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); PrismObject shadowProvisioning = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); accountWillCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -1507,11 +1507,11 @@ public void test250RefreshAccountWillAfter5min() throws Exception { display("Shadow before", shadowBefore); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -1594,11 +1594,11 @@ public void test252UpdateBackingStoreAndGetAccountWill() throws Exception { backingStoreUpdateWill(ACCOUNT_WILL_FULLNAME_PIRATE, ActivationStatusType.DISABLED, ACCOUNT_WILL_PASSWORD_OLD); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -1663,11 +1663,11 @@ public void test260ClosePasswordChangeCaseAndRefreshAccountWill() throws Excepti accountWillSecondCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); accountWillSecondCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -1758,11 +1758,11 @@ public void test270RefreshAccountWillAfter7min() throws Exception { display("Shadow before", shadowBefore); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -1856,11 +1856,11 @@ public void test271RefreshAccountWillAfter12min() throws Exception { display("Shadow before", shadowBefore); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -1951,11 +1951,11 @@ public void test272UpdateBackingStoreAndGetAccountWill() throws Exception { backingStoreUpdateWill(ACCOUNT_WILL_FULLNAME_PIRATE, ActivationStatusType.ENABLED, ACCOUNT_WILL_PASSWORD_NEW); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -2015,11 +2015,11 @@ public void test280RefreshAccountWillAfter5min() throws Exception { display("Shadow before", shadowBefore); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -2103,11 +2103,11 @@ public void test290RefreshAccountWillAfter5min() throws Exception { display("Shadow before", shadowBefore); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -2165,11 +2165,11 @@ public void test300DeleteAccountWill() throws Exception { accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); provisioningService.deleteObject(ShadowType.class, ACCOUNT_WILL_OID, null, null, task, result); // THEN - then(TEST_NAME); + then(); display("result", result); willLastCaseOid = assertInProgress(result); @@ -2231,7 +2231,7 @@ public void test302GetAccountWillFuture() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); PrismObject shadowProvisioningFuture = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)), @@ -2239,7 +2239,7 @@ public void test302GetAccountWillFuture() throws Exception { // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("Provisioning shadow (future)", shadowProvisioningFuture); @@ -2259,7 +2259,7 @@ public void test303GetAccountWillFutureNoFetch() throws Exception { options.setNoFetch(true); // WHEN - when(TEST_NAME); + when(); PrismObject shadowProvisioningFuture = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, SelectorOptions.createCollection(options), @@ -2267,7 +2267,7 @@ public void test303GetAccountWillFutureNoFetch() throws Exception { // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("Provisioning shadow (future,noFetch)", shadowProvisioningFuture); @@ -2296,11 +2296,11 @@ public void test310CloseCaseAndRefreshAccountWill() throws Exception { display("Shadow before", shadowBefore); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); accountWillCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -2360,11 +2360,11 @@ public void test320RefreshAccountWillAfter5min() throws Exception { display("Shadow before", shadowBefore); // WHEN - when(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDj.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDj.java index d74e11b05b3..ac1590ab088 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDj.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDj.java @@ -677,11 +677,11 @@ public void test110GetObject() throws Exception { PropertyReferenceListType resolve = new PropertyReferenceListType(); // WHEN - when(TEST_NAME); + when(); ShadowType provisioningShadow = provisioningService.getObject(ShadowType.class, ACCOUNT_JBOND_OID, null, task, result).asObjectable(); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertNotNull(provisioningShadow); @@ -793,11 +793,11 @@ public void test112GetObjectNotFoundResource() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); PrismObject shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_BAD_OID, null, task, result); // THEN - when(TEST_NAME); + when(); ShadowAsserter.forShadow(shadow, "provisioning") .assertTombstone(); @@ -828,11 +828,11 @@ public void test120AddAccountWill() throws Exception { display("Account before", accountBefore); // WHEN - when(TEST_NAME); + when(); String addedObjectOid = provisioningService.addObject(accountBefore, null, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertEquals(ACCOUNT_WILL_OID, addedObjectOid); @@ -914,11 +914,11 @@ public void test130AddDeleteAccountSparrow() throws Exception { assertEquals(ACCOUNT_SPARROW_OID, addedObjectOid); // WHEN - when(TEST_NAME); + when(); provisioningService.deleteObject(ShadowType.class, ACCOUNT_SPARROW_OID, null, null, task, result); // THEN - then(TEST_NAME); + then(); ShadowType objType = null; try { @@ -971,12 +971,12 @@ public void test140AddAndModifyAccountJack() throws Exception { display("Object change",delta); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, objectChange.getOid(), delta.getModifications(), null, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1033,12 +1033,12 @@ public void test145ModifyAccountJackJpegPhoto() throws Exception { display("Modifications",modifications); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, ACCOUNT_JACK_OID, modifications, null, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); Entry entry = openDJController.searchByUid("rename"); @@ -1093,12 +1093,12 @@ public void test147ModifyAccountJackGivenNameDuplicit() throws Exception { display("Modifications",modifications); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, ACCOUNT_JACK_OID, modifications, null, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1154,11 +1154,11 @@ public void test150ChangePassword() throws Exception { display("Object change",delta); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), null, null, task, result); // THEN - then(TEST_NAME); + then(); // Check if object was modified in LDAP Entry entryAfter = openDJController.searchAndAssertByEntryUuid(uid); @@ -1267,11 +1267,11 @@ public boolean handle(PrismObject prismObject, OperationResult paren }; // WHEN - when(TEST_NAME); + when(); SearchResultMetadata searchMetadata = provisioningService.searchObjectsIterative(ShadowType.class, query, null, handler, task, result); // THEN - then(TEST_NAME); + then(); display("Count", objects.size()); assertEquals("Unexpected number of shadows", 9, objects.size()); @@ -1314,11 +1314,11 @@ public boolean handle(PrismObject prismObject, OperationResult paren }; // WHEN - when(TEST_NAME); + when(); SearchResultMetadata searchMetadata = provisioningService.searchObjectsIterative(ShadowType.class, query, null, handler, task, result); // THEN - then(TEST_NAME); + then(); display("Count", objects.size()); assertEquals("Unexpected number of shadows", 3, objects.size()); @@ -1361,11 +1361,11 @@ public boolean handle(PrismObject prismObject, OperationResult paren }; // WHEN - when(TEST_NAME); + when(); SearchResultMetadata searchMetadata = provisioningService.searchObjectsIterative(ShadowType.class, query, null, handler, task, result); // THEN - then(TEST_NAME); + then(); display("Count", objects.size()); assertEquals("Unexpected number of shadows", 3, objects.size()); @@ -1413,12 +1413,12 @@ public void test170DisableAccount() throws Exception{ display("Object change",delta); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, objectChange.getOid(), delta.getModifications(), null, null, task, result); // THEN - then(TEST_NAME); + then(); ShadowType accountType = provisioningService.getObject(ShadowType.class, ACCOUNT_DISABLE_SIMULATED_OID, null, taskManager.createTaskInstance(), result).asObjectable(); @@ -1713,12 +1713,12 @@ public void test202SearchObjectsCompexFilter() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - when(TEST_NAME); + when(); List> objListType = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1746,12 +1746,12 @@ public void test203SearchObjectsByDnExists() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - when(TEST_NAME); + when(); List> objListType = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); for (PrismObject objType : objListType) { @@ -1787,12 +1787,12 @@ public void test205SearchObjectsByDnNotExists() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - when(TEST_NAME); + when(); List> objListType = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); for (PrismObject objType : objListType) { @@ -1824,12 +1824,12 @@ public void test206SearchObjectsCompexFilterStartsWith() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - when(TEST_NAME); + when(); List> objListType = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); for (PrismObject objType : objListType) { @@ -1861,12 +1861,12 @@ public void test230SearchObjectsPagedNoOffset() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - when(TEST_NAME); + when(); SearchResultList> searchResults = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("Search resutls", searchResults); @@ -1896,12 +1896,12 @@ public void test231SearchObjectsPagedOffsetZero() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - when(TEST_NAME); + when(); SearchResultList> searchResults = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("Search resutls", searchResults); @@ -1931,11 +1931,11 @@ public void test232SearchObjectsPagedOffset() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - when(TEST_NAME); + when(); SearchResultList> searchResults = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); assertSuccess(result); display("Search resutls", searchResults); @@ -1969,12 +1969,12 @@ public void test233SearchObjectsPagedNoOffsetSortSn() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - when(TEST_NAME); + when(); SearchResultList> searchResults = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); assertSuccess(result); display("Search resutls", searchResults); @@ -2007,12 +2007,12 @@ public void test234SearchObjectsPagedOffsetSortSn() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - when(TEST_NAME); + when(); List> searchResults = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); assertSuccess(result); display("Search resutls", searchResults); @@ -2051,11 +2051,11 @@ public void test250CountAccounts() throws Exception { ObjectQuery query = getQueryConverter().createObjectQuery(ShadowType.class, queryType); // WHEN - when(TEST_NAME); + when(); Integer count = provisioningService.countObjects(ShadowType.class, query, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("All accounts count", count); @@ -2077,11 +2077,11 @@ public void test252CountLdapGroups() throws Exception { ObjectQuery query = getQueryConverter().createObjectQuery(ShadowType.class, queryType); // WHEN - when(TEST_NAME); + when(); Integer count = provisioningService.countObjects(ShadowType.class, query, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("All LDAP groups count", count); @@ -2166,11 +2166,11 @@ public void test320AddAccountPosix() throws Exception { display("Adding account", object); // WHEN - when(TEST_NAME); + when(); String addedObjectOid = provisioningService.addObject(object.asPrismObject(), null, null, task, result); // THEN - then(TEST_NAME); + then(); assertEquals(ACCOUNT_POSIX_MCMUTTON_OID, addedObjectOid); ShadowType repoShadowType = getShadowRepo(ACCOUNT_POSIX_MCMUTTON_OID).asObjectable(); @@ -2218,12 +2218,12 @@ public void test322ModifyAccountPosix() throws Exception { display("Object change",delta); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, objectChange.getOid(), delta.getModifications(), null, null, taskManager.createTaskInstance(), result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2258,11 +2258,11 @@ public void test329DeleteAccountPosix() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); provisioningService.deleteObject(ShadowType.class, ACCOUNT_POSIX_MCMUTTON_OID, null, null, task, result); // THEN - then(TEST_NAME); + then(); try { provisioningService.getObject(ShadowType.class, ACCOUNT_POSIX_MCMUTTON_OID, null, task, result); @@ -2306,12 +2306,12 @@ public void test330SearchForPosixAccount() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - when(TEST_NAME); + when(); List> objListType = provisioningService.searchObjects(ShadowType.class, query, null, null, result); // THEN - then(TEST_NAME); + then(); for (PrismObject objType : objListType) { assertNotNull("Null search result", objType); display("found object", objType); @@ -2345,11 +2345,11 @@ public void test400AddGroupSwashbucklers() throws Exception { display("Adding object", object); // WHEN - when(TEST_NAME); + when(); String addedObjectOid = provisioningService.addObject(object.asPrismObject(), null, null, task, result); // THEN - then(TEST_NAME); + then(); assertEquals(GROUP_SWASHBUCKLERS_OID, addedObjectOid); ShadowType shadowType = getShadowRepo(GROUP_SWASHBUCKLERS_OID).asObjectable(); @@ -2386,11 +2386,11 @@ public void test402AddAccountMorganWithAssociation() throws Exception { IntegrationTestTools.display("Adding object", object); // WHEN - when(TEST_NAME); + when(); String addedObjectOid = provisioningService.addObject(object.asPrismObject(), null, null, task, result); // THEN - then(TEST_NAME); + then(); assertEquals(ACCOUNT_MORGAN_OID, addedObjectOid); assertRepoShadow(ACCOUNT_MORGAN_OID) @@ -2437,7 +2437,7 @@ public void test403modifyMorganReplaceAssociation() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); ObjectModificationType modification = prismContext.parserFor(FILE_MODIFY_ASSOCIATION_REPLACE).parseRealValue(ObjectModificationType.class); ObjectDelta delta = DeltaConvertor.createObjectDelta(modification, ShadowType.class, prismContext); try { @@ -2448,7 +2448,7 @@ public void test403modifyMorganReplaceAssociation() throws Exception { } // THEN - then(TEST_NAME); + then(); assertRepoShadow(ACCOUNT_MORGAN_OID) .assertName(ACCOUNT_MORGAN_DN); @@ -2490,12 +2490,12 @@ public void test405GetGroupSwashbucklers() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); PrismObject provisioningShadow = provisioningService.getObject(ShadowType.class, GROUP_SWASHBUCKLERS_OID, null, task, result); // THEN - then(TEST_NAME); + then(); ShadowType provisioningShadowType = provisioningShadow.asObjectable(); assertEquals("Wrong ICF name (provisioning)", dnMatchingRule.normalize(GROUP_SWASHBUCKLERS_DN), dnMatchingRule.normalize(provisioningShadowType.getName().getOrig())); @@ -2530,11 +2530,11 @@ public void test410CreateLdapGroupAndSearchGroups() throws Exception { RESOURCE_OPENDJ_GROUP_OBJECTCLASS, prismContext); // WHEN - when(TEST_NAME); + when(); SearchResultList> resultList = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); assertSuccess(result); display("Search result", resultList); @@ -2564,11 +2564,11 @@ public void test412CreateLdapGroupWithMemberAndGet() throws Exception { RESOURCE_OPENDJ_GROUP_OBJECTCLASS, prismContext); // WHEN - when(TEST_NAME); + when(); PrismObject shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_MORGAN_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("Account shadow after", shadow); @@ -2595,11 +2595,11 @@ public void test414AddGroupCorsairsAssociateUser() throws Exception { IntegrationTestTools.display("Adding object", object); // WHEN - when(TEST_NAME); + when(); String addedObjectOid = provisioningService.addObject(object.asPrismObject(), null, null, task, result); // THEN - then(TEST_NAME); + then(); assertEquals(GROUP_CORSAIRS_OID, addedObjectOid); ShadowType shadowType = getShadowRepo(GROUP_CORSAIRS_OID).asObjectable(); @@ -2623,12 +2623,12 @@ public void test416AssociateUserToCorsairs() throws Exception { delta.checkConsistence(); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - then(TEST_NAME); + then(); Entry groupEntry = openDJController.fetchEntry(GROUP_CORSAIRS_DN); display("LDAP group", groupEntry); @@ -2646,11 +2646,11 @@ public void test418GetMorgan() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); PrismObject shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_MORGAN_OID, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); assertSuccess(result); display("Shadow", shadow); @@ -2716,11 +2716,11 @@ public void test450ListGroupsObjectclass() throws Exception { display("query", query); // WHEN - when(TEST_NAME); + when(); SearchResultList> objects = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - then(TEST_NAME); + then(); display("found objects", objects); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2742,11 +2742,11 @@ public void test452ListLdapGroupsKindIntent() throws Exception { display("query", query); // WHEN - when(TEST_NAME); + when(); SearchResultList> objects = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - then(TEST_NAME); + then(); display("found objects", objects); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2768,11 +2768,11 @@ public void test454ListSpecialGroupsKindIntent() throws Exception { display("query", query); // WHEN - when(TEST_NAME); + when(); SearchResultList> objects = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - then(TEST_NAME); + then(); display("found objects", objects); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2795,11 +2795,11 @@ public void test456AddGroupSpecialists() throws Exception { display("Adding object", object); // WHEN - when(TEST_NAME); + when(); String addedObjectOid = provisioningService.addObject(object.asPrismObject(), null, null, task, result); // THEN - then(TEST_NAME); + then(); assertEquals(GROUP_SPECIALISTS_OID, addedObjectOid); ShadowType shadowType = getShadowRepo(GROUP_SPECIALISTS_OID).asObjectable(); @@ -2837,11 +2837,11 @@ public void test457ListLdapGroupsKindIntent() throws Exception { display("query", query); // WHEN - when(TEST_NAME); + when(); SearchResultList> objects = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - then(TEST_NAME); + then(); display("found objects", objects); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2863,11 +2863,11 @@ public void test458ListSpecialGroupsKindIntent() throws Exception { display("query", query); // WHEN - when(TEST_NAME); + when(); SearchResultList> objects = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - then(TEST_NAME); + then(); display("found objects", objects); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2897,11 +2897,11 @@ public void test460ListOrganizationalUnitPeopleKindIntent() throws Exception { display("query", query); // WHEN - when(TEST_NAME); + when(); SearchResultList> objects = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - then(TEST_NAME); + then(); display("found objects", objects); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2928,11 +2928,11 @@ public void test470AddAccountPolyDescription() throws Exception { display("Account before", accountBefore); // WHEN - when(TEST_NAME); + when(); String addedObjectOid = provisioningService.addObject(accountBefore, null, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); Entry entry = openDJController.fetchEntry(ACCOUNT_POLY_DN); @@ -2981,12 +2981,12 @@ public void test472ModifyAccountJackDescriptionOrig() throws Exception { display("Modifications",modifications); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, ACCOUNT_JACK_OID, modifications, null, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); Entry entry = openDJController.searchByUid("rename"); @@ -3032,12 +3032,12 @@ public void test474ModifyAccountJackDescriptionLangEnSk() throws Exception { display("Modifications", modifications); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, ACCOUNT_JACK_OID, modifications, null, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); Entry entry = openDJController.searchByUid("rename"); @@ -3084,12 +3084,12 @@ public void test476ModifyAccountJackDescriptionLangEnSkRuHr() throws Exception { display("Modifications",modifications); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, ACCOUNT_JACK_OID, modifications, null, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); Entry entry = openDJController.searchByUid("rename"); @@ -3136,12 +3136,12 @@ public void test478ModifyAccountJackDescriptionLangEnSkRuHr() throws Exception { display("Modifications",modifications); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, ACCOUNT_JACK_OID, modifications, null, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); Entry entry = openDJController.searchByUid("rename"); @@ -3187,12 +3187,12 @@ public void test478bModifyAccountJackDeleteDescription() throws Exception { display("Modifications", modifications); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, ACCOUNT_JACK_OID, modifications, null, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); Entry entry = openDJController.searchByUid("rename"); @@ -3239,12 +3239,12 @@ public void test479ModifyAccountJackDescriptionJack() throws Exception { display("Modifications",modifications); // WHEN - when(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, ACCOUNT_JACK_OID, modifications, null, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); Entry entry = openDJController.searchByUid("rename"); @@ -3277,11 +3277,11 @@ public void test480AddOuSuper() throws Exception { display("Adding object", object); // WHEN - when(TEST_NAME); + when(); String addedObjectOid = provisioningService.addObject(object.asPrismObject(), null, null, task, result); // THEN - then(TEST_NAME); + then(); assertEquals(OU_SUPER_OID, addedObjectOid); ShadowType shadowType = getShadowRepo(OU_SUPER_OID).asObjectable(); @@ -3323,11 +3323,11 @@ public void test489DeleteOuSuperWithSub() throws Exception { createSubOrg(); // WHEN - when(TEST_NAME); + when(); provisioningService.deleteObject(ShadowType.class, OU_SUPER_OID, null, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertNoRepoShadow(OU_SUPER_OID); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjDumber.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjDumber.java index fbfe2d48ed5..46cc1db8b42 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjDumber.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjDumber.java @@ -88,7 +88,7 @@ public void test489DeleteOuSuperWithSub() throws Exception { try { // WHEN - when(TEST_NAME); + when(); provisioningService.deleteObject(ShadowType.class, OU_SUPER_OID, null, null, task, result); assertNotReached(); @@ -97,7 +97,7 @@ public void test489DeleteOuSuperWithSub() throws Exception { } // THEN - then(TEST_NAME); + then(); assertFailure(result); } diff --git a/repo/repo-common/src/test/java/com/evolveum/midpoint/repo/common/commandline/TestCommandLine.java b/repo/repo-common/src/test/java/com/evolveum/midpoint/repo/common/commandline/TestCommandLine.java index 89d76bf2c45..2a1bc6bf71d 100644 --- a/repo/repo-common/src/test/java/com/evolveum/midpoint/repo/common/commandline/TestCommandLine.java +++ b/repo/repo-common/src/test/java/com/evolveum/midpoint/repo/common/commandline/TestCommandLine.java @@ -68,11 +68,11 @@ public void test100PlainExecuteEcho() throws Exception { CommandLineScriptType scriptType = getScript(REPORT_PLAIN_ECHO_FILE); // WHEN - when(TEST_NAME); + when(); commandLineScriptExecutor.executeScript(scriptType, null, "test", task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); } @@ -95,11 +95,11 @@ public void test110RedirExecuteEcho() throws Exception { VAR_HELLOTEXT, "Hello World", PrimitiveType.STRING); // WHEN - when(TEST_NAME); + when(); commandLineScriptExecutor.executeScript(scriptType, variables, "test", task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); File targetFile = new File(MidPointTestConstants.TARGET_DIR_PATH, "echo-out"); 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 f5e60823f6b..6e8f0d44cbb 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 @@ -396,6 +396,13 @@ protected OperationResult createResult() { return new OperationResult(contextName()); } + /** + * Creates new {@link OperationResult} with name prefixed by {@link #contextName()}. + */ + protected OperationResult createResult(String nameSuffix) { + return new OperationResult(contextName() + "." + nameSuffix); + } + /** * Returns default {@link OperationResult} for pre-created test-method-scoped {@link Task}. * This result can be freely used in test for some "main scope", it is not asserted in any diff --git a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdap.java b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdap.java index 7b1635fa197..c22cb9645a0 100644 --- a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdap.java +++ b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdap.java @@ -167,11 +167,11 @@ public void test200AssignRolePiratesToBarbossa() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_BARBOSSA_OID, ROLE_PIRATE_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -208,11 +208,11 @@ public void test202AssignLdapAccountToGuybrush() throws Exception { assertTrue("Photo bytes do not match (user before)", Arrays.equals(photoIn, userJpegPhotoBefore)); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_OPENDJ_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); Entry entry = assertOpenDjAccount(USER_GUYBRUSH_USERNAME, USER_GUYBRUSH_FULL_NAME, true); @@ -258,11 +258,11 @@ public void test204AssignRolePiratesToGuybrush() throws Exception { ); // WHEN - when(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_PIRATE_OID, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -297,12 +297,12 @@ public void test400RenameLeChuckConflicting() throws Exception { assertOpenDjAccount(ACCOUNT_CHARLES_NAME, "Charles L. Charles", true); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(userLechuckOid, UserType.F_NAME, task, result, PrismTestUtil.createPolyString(ACCOUNT_CHARLES_NAME)); // THEN - then(TEST_NAME); + then(); assertOpenDjAccount(ACCOUNT_CHARLES_NAME, "Charles L. Charles", true); assertOpenDjAccount(ACCOUNT_CHARLES_NAME + "1", "LeChuck", true); assertNoOpenDjAccount(ACCOUNT_LECHUCK_NAME); @@ -338,16 +338,16 @@ public boolean handle(PrismObject shadow, OperationResult parentResu }; // WHEN - when(TEST_NAME); + when(); modelService.searchObjectsIterative(ShadowType.class, query, handler, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); // THEN - then(TEST_NAME); + then(); assertEquals("Unexpected number of search results", NUM_LDAP_ENTRIES + 8, count.getValue()); @@ -369,20 +369,20 @@ public void test810BigImport() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); //task.setExtensionPropertyValue(SchemaConstants.MODEL_EXTENSION_WORKER_THREADS, 2); modelService.importFromResource(RESOURCE_OPENDJ_OID, new QName(RESOURCE_OPENDJ_NAMESPACE, "inetOrgPerson"), task, result); // THEN - then(TEST_NAME); + then(); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); waitForTaskFinish(task, true, 20000 + NUM_LDAP_ENTRIES*2000); // THEN - then(TEST_NAME); + then(); int userCount = modelService.countObjects(UserType.class, null, null, task, result); display("Users", userCount); @@ -407,19 +407,19 @@ public void test820BigReconciliation() throws Exception { ResourceType resource = modelService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, task, result).asObjectable(); // WHEN - when(TEST_NAME); + when(); reconciliationTaskHandler.launch(resource, new QName(RESOURCE_OPENDJ_NAMESPACE, "inetOrgPerson"), task, result); // THEN - then(TEST_NAME); + then(); // OperationResult subresult = result.getLastSubresult(); // TestUtil.assertInProgress("reconciliation launch result", subresult); waitForTaskFinish(task, true, 20000 + NUM_LDAP_ENTRIES*2000); // THEN - then(TEST_NAME); + then(); int userCount = modelService.countObjects(UserType.class, null, null, task, result); display("Users", userCount); @@ -439,16 +439,16 @@ public void test900DeleteShadows() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - when(TEST_NAME); + when(); importObjectFromFile(TASK_DELETE_OPENDJ_SHADOWS_FILE); // THEN - then(TEST_NAME); + then(); waitForTaskFinish(TASK_DELETE_OPENDJ_SHADOWS_OID, true, 20000 + NUM_LDAP_ENTRIES*2000); // THEN - then(TEST_NAME); + then(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); @@ -486,16 +486,16 @@ public void test910DeleteAccounts() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - when(TEST_NAME); + when(); importObjectFromFile(TASK_DELETE_OPENDJ_ACCOUNTS_FILE); // THEN - then(TEST_NAME); + then(); waitForTaskFinish(TASK_DELETE_OPENDJ_ACCOUNTS_OID, true, 20000 + NUM_LDAP_ENTRIES*3000); // THEN - then(TEST_NAME); + then(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, (2*NUM_LDAP_ENTRIES)/100+2); diff --git a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdapComplex.java b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdapComplex.java index 53e78733a37..c5a89119d0f 100644 --- a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdapComplex.java +++ b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdapComplex.java @@ -140,20 +140,20 @@ public void test100BigImport() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); //task.setExtensionPropertyValue(SchemaConstants.MODEL_EXTENSION_WORKER_THREADS, 2); modelService.importFromResource(RESOURCE_OPENDJ_OID, new QName(RESOURCE_OPENDJ_NAMESPACE, "inetOrgPerson"), task, result); // THEN - then(TEST_NAME); + then(); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); waitForTaskFinish(task, true, 20000 + NUM_LDAP_ENTRIES*2000); // THEN - then(TEST_NAME); + then(); int userCount = modelService.countObjects(UserType.class, null, null, task, result); display("Users", userCount); @@ -179,7 +179,7 @@ public void test120BigReconciliation() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); //task.setExtensionPropertyValue(SchemaConstants.MODEL_EXTENSION_WORKER_THREADS, 2); ResourceType resource = modelService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, task, result).asObjectable(); @@ -187,7 +187,7 @@ public void test120BigReconciliation() throws Exception { new QName(RESOURCE_OPENDJ_NAMESPACE, "AccountObjectClass"), task, result); // THEN - then(TEST_NAME); + then(); // TODO // OperationResult subresult = result.getLastSubresult(); // TestUtil.assertInProgress("reconciliation launch result", subresult); @@ -195,7 +195,7 @@ public void test120BigReconciliation() throws Exception { waitForTaskFinish(task, true, 20000 + NUM_LDAP_ENTRIES*2000); // THEN - then(TEST_NAME); + then(); int userCount = modelService.countObjects(UserType.class, null, null, task, result); display("Users", userCount); @@ -218,11 +218,11 @@ public void test500GuybrushAssignSecurity() throws Exception { addObject(USER_GUYBRUSH_FILE); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_OPENDJ_OID, INTENT_SECURITY, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -252,11 +252,11 @@ public void test502RuinGuybrushAccountAndReconcile() throws Exception { openDJController.assertHasNoObjectClass(entryBefore, OBJECTCLASS_USER_SECURITY_INFORMATION); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); diff --git a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestRunAs.java b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestRunAs.java index 15f0bbb61d5..edf7c67c3e4 100644 --- a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestRunAs.java +++ b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestRunAs.java @@ -118,11 +118,11 @@ public void test100AssignAccountDummyToBarbossa() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_BARBOSSA_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_BARBOSSA_OID); @@ -149,11 +149,11 @@ public void test109UnassignAccountDummyFromBarbossa() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignAccountFromUser(USER_BARBOSSA_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_BARBOSSA_OID); @@ -172,12 +172,12 @@ public void test200CleanupPlain() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, UserType.F_ORGANIZATION, task, result /* no value */); modifyUserReplace(USER_BARBOSSA_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result /* no value */); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_BARBOSSA_OID); @@ -213,13 +213,13 @@ public void test210BarbossaSetOrganizationPlain() throws Exception { rememberCounter(InternalCounters.REPOSITORY_READ_COUNT); // WHEN - when(TEST_NAME); + when(); long starMillis = System.currentTimeMillis(); modifyUserReplace(USER_BARBOSSA_OID, UserType.F_ORGANIZATION, task, result, createPolyString(ORG_PIRATES)); long endMillis = System.currentTimeMillis(); // THEN - then(TEST_NAME); + then(); assertSuccess(result); long readCountIncremenet = getCounterIncrement(InternalCounters.REPOSITORY_READ_COUNT); @@ -243,12 +243,12 @@ public void test300CleanupRunAs() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, UserType.F_ORGANIZATION, task, result /* no value */); modifyUserReplace(USER_BARBOSSA_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result /* no value */); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_BARBOSSA_OID); @@ -284,13 +284,13 @@ public void test310BarbossaSetOrganizationRunAs() throws Exception { rememberCounter(InternalCounters.REPOSITORY_READ_COUNT); // WHEN - when(TEST_NAME); + when(); long starMillis = System.currentTimeMillis(); modifyUserReplace(USER_BARBOSSA_OID, UserType.F_ORGANIZATION, task, result, createPolyString(ORG_PIRATES)); long endMillis = System.currentTimeMillis(); // THEN - then(TEST_NAME); + then(); assertSuccess(result); long readCountIncrement = getCounterIncrement(InternalCounters.REPOSITORY_READ_COUNT); @@ -325,7 +325,7 @@ private void warmUp(final String TEST_NAME) throws Exception { rememberCounter(InternalCounters.REPOSITORY_READ_COUNT); // WHEN - when(TEST_NAME); + when(); long firstTime = warmUpRound(0, task, result); long lastTime = 0; long sumTime = firstTime; @@ -335,7 +335,7 @@ private void warmUp(final String TEST_NAME) throws Exception { } // THEN - then(TEST_NAME); + then(); assertSuccess(result); long readCountIncremenet = getCounterIncrement(InternalCounters.REPOSITORY_READ_COUNT); diff --git a/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestAbstractRestService.java b/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestAbstractRestService.java index bec83ffed9c..222f11d87f7 100644 --- a/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestAbstractRestService.java +++ b/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestAbstractRestService.java @@ -145,10 +145,10 @@ public void test001GetUserAdministrator() { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.get(); - then(TEST_NAME); + then(); assertStatus(response, 200); UserType userType = response.readEntity(UserType.class); assertNotNull("Returned entity in body must not be null.", userType); @@ -168,10 +168,10 @@ public void test002GetNonExistingUser() { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.get(); - then(TEST_NAME); + then(); assertStatus(response, 404); OperationResultType result = response.readEntity(OperationResultType.class); assertNotNull("Error response must contain operation result", result); @@ -192,10 +192,10 @@ public void test003GetNoAuthHeaders() { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.get(); - then(TEST_NAME); + then(); assertStatus(response, 401); display("Audit", getDummyAuditService()); @@ -212,10 +212,10 @@ public void test004GetAuthBadUsernameNullPassword() { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.get(); - then(TEST_NAME); + then(); assertStatus(response, 401); display("Audit", getDummyAuditService()); @@ -232,10 +232,10 @@ public void test005GetAuthBadUsernameEmptyPassword() { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.get(); - then(TEST_NAME); + then(); assertStatus(response, 401); display("Audit", getDummyAuditService()); @@ -252,10 +252,10 @@ public void test006GetAuthBadUsernameBadPassword() { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.get(); - then(TEST_NAME); + then(); assertStatus(response, 401); display("Audit", getDummyAuditService()); @@ -272,10 +272,10 @@ public void test007GetAuthNoPassword() { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.get(); - then(TEST_NAME); + then(); assertStatus(response, 401); display("Audit", getDummyAuditService()); @@ -292,10 +292,10 @@ public void test016GetAuthBadPassword() { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.get(); - then(TEST_NAME); + then(); assertStatus(response, 401); display("Audit", getDummyAuditService()); @@ -312,10 +312,10 @@ public void test017GetUnauthorizedUser() { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.get(); - then(TEST_NAME); + then(); assertStatus(response, 401); display("Audit", getDummyAuditService()); @@ -332,10 +332,10 @@ public void test018GetUserAdministratorByCyclops() { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.get(); - then(TEST_NAME); + then(); assertStatus(response, 403); display("Audit", getDummyAuditService()); @@ -352,10 +352,10 @@ public void test019GetUserAdministratorBySomebody() { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.get(); - then(TEST_NAME); + then(); assertStatus(response, 200); @@ -377,10 +377,10 @@ public void test102AddUserTemplate() throws Exception { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.post(getRepoFile(USER_TEMPLATE_FILE)); - then(TEST_NAME); + then(); displayResponse(response); assertStatus(response, 201); @@ -400,10 +400,10 @@ public void test103AddUserBadTargetCollection() throws Exception { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.post(getRepoFile(USER_DARTHADDER_FILE)); - then(TEST_NAME); + then(); displayResponse(response); assertStatus(response, 400); @@ -427,10 +427,10 @@ public void test104AddAccountRawResourceDoesNotExist() throws Exception { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.post(getRepoFile(ACCOUT_CHUCK_FILE)); - then(TEST_NAME); + then(); displayResponse(response); // expecting hadnled error because resource doesn't exist.. it is OK, but let's say admin about that @@ -466,10 +466,10 @@ public void test120AddRoleAdder() throws Exception { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.post(getRepoFile(ROLE_ADDER_FILE)); - then(TEST_NAME); + then(); displayResponse(response); assertStatus(response, 201); @@ -488,10 +488,10 @@ public void test121AddUserDarthAdder() throws Exception { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.post(getRepoFile(USER_DARTHADDER_FILE)); - then(TEST_NAME); + then(); displayResponse(response); assertStatus(response, 201); @@ -510,10 +510,10 @@ public void test122AddRoleModifierAsDarthAdder() throws Exception { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.post(getRepoFile(ROLE_MODIFIER_FILE)); - then(TEST_NAME); + then(); displayResponse(response); assertStatus(response, 201); @@ -532,10 +532,10 @@ public void test123DarthAdderAssignModifierHimself() throws Exception { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.post(MiscUtil.readFile(getRequestFile(MODIFICATION_ASSIGN_ROLE_MODIFIER))); - then(TEST_NAME); + then(); displayResponse(response); assertStatus(response, 403); OperationResultType result = response.readEntity(OperationResultType.class); @@ -558,10 +558,10 @@ public void test124DarthAdderAssignModifierByAdministrator() throws Exception { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.post(MiscUtil.readFile(getRequestFile(MODIFICATION_ASSIGN_ROLE_MODIFIER))); - then(TEST_NAME); + then(); displayResponse(response); assertStatus(response, 204); @@ -584,10 +584,10 @@ public void test130DarthAdderDisableHimself() throws Exception { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.post(MiscUtil.readFile(getRequestFile(MODIFICATION_DISABLE))); - then(TEST_NAME); + then(); displayResponse(response); assertStatus(response, 204); @@ -610,10 +610,10 @@ public void test131GetUserAdministratorByDarthAdder() { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.get(); - then(TEST_NAME); + then(); assertStatus(response, 401); // assertNoEmptyResponse(response); @@ -631,10 +631,10 @@ public void test132DarthAdderEnableByAdministrator() throws Exception { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.post(MiscUtil.readFile(getRequestFile(MODIFICATION_ENABLE))); - then(TEST_NAME); + then(); displayResponse(response); assertStatus(response, 204); @@ -657,10 +657,10 @@ public void test133GetUserAdministratorByDarthAdder() { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.get(); - then(TEST_NAME); + then(); assertStatus(response, 200); UserType userType = response.readEntity(UserType.class); assertNotNull("Returned entity in body must not be null.", userType); @@ -680,10 +680,10 @@ public void test135AddUserNopasswordAsDarthAdder() throws Exception { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.post(getRepoFile(USER_NOPASSWORD_FILE)); - then(TEST_NAME); + then(); displayResponse(response); assertStatus(response, 201); @@ -702,10 +702,10 @@ public void test140GetUserAdministratorByNopassword() { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.get(); - then(TEST_NAME); + then(); assertStatus(response, 401); // assertNoEmptyResponse(response); @@ -723,10 +723,10 @@ public void test141GetUserAdministratorByNopasswordBadPassword() { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.get(); - then(TEST_NAME); + then(); assertStatus(response, 401); // assertNoEmptyResponse(response); @@ -744,10 +744,10 @@ public void test200searchAllUsers() { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.post(new QueryType()); - then(TEST_NAME); + then(); displayResponse(response); assertStatus(response, 200); @@ -768,11 +768,11 @@ public void test401AddUserTemplateOverwrite() throws Exception { getDummyAuditService().clear(); // WHEN - when(TEST_NAME); + when(); Response response = client.post(getRepoFile(USER_TEMPLATE_FILE)); // THEN - then(TEST_NAME); + then(); displayResponse(response); assertEquals("Expected 201 but got " + response.getStatus(), 201, response.getStatus()); @@ -802,11 +802,11 @@ public void test410AddFunctionLibraryHello() throws Exception { getDummyAuditService().clear(); // WHEN - when(TEST_NAME); + when(); Response response = client.post(getRepoFile(FUNCTION_LIBRARY_HELLO_FILE)); // THEN - then(TEST_NAME); + then(); displayResponse(response); assertEquals("Expected 201 but got " + response.getStatus(), 201, response.getStatus()); @@ -831,10 +831,10 @@ public void test412GetFunctionLibraryHello() { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.get(); - then(TEST_NAME); + then(); assertStatus(response, 200); FunctionLibraryType libType = response.readEntity(FunctionLibraryType.class); assertNotNull("Returned entity in body must not be null.", libType); @@ -860,10 +860,10 @@ public void test501generateValue() throws Exception { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_GENERATE)); - then(TEST_NAME); + then(); displayResponse(response); traceResponse(response); @@ -884,10 +884,10 @@ public void test502generateValueBadPath() throws Exception { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_GENERATE_BAD_PATH)); - then(TEST_NAME); + then(); displayResponse(response); assertEquals("Expected 400 but got " + response.getStatus(), 400, response.getStatus()); @@ -906,10 +906,10 @@ public void test503generateValueExecute() throws Exception { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_GENERATE_EXECUTE)); - then(TEST_NAME); + then(); displayResponse(response); traceResponse(response); @@ -933,10 +933,10 @@ public void test504checkGeneratedValue() throws Exception { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.get(); - then(TEST_NAME); + then(); displayResponse(response); assertEquals("Expected 200 but got " + response.getStatus(), 200, response.getStatus()); @@ -954,10 +954,10 @@ public void test505generatePasswordExecute() throws Exception { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_GENERATE_PASSWORD_EXECUTE)); - then(TEST_NAME); + then(); displayResponse(response); assertEquals("Expected 200 but got " + response.getStatus(), 200, response.getStatus()); @@ -980,10 +980,10 @@ public void test506generateHonorificPrefixNameExecute() throws Exception { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_GENERATE_HONORIFIC_PREFIX_EXECUTE)); - then(TEST_NAME); + then(); displayResponse(response); traceResponse(response); @@ -1046,10 +1046,10 @@ public void test510validateValueExplicit() throws Exception { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_VALIDATE_EXPLICIT)); - then(TEST_NAME); + then(); displayResponse(response); traceResponse(response); @@ -1070,10 +1070,10 @@ public void test511validateValueExplicitConflict() throws Exception { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_VALIDATE_EXPLICIT_CONFLICT)); - then(TEST_NAME); + then(); displayResponse(response); traceResponse(response, true); @@ -1094,10 +1094,10 @@ public void test512validateValueImplicitSingle() throws Exception { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_VALIDATE_IMPLICIT_SINGLE)); - then(TEST_NAME); + then(); displayResponse(response); assertEquals("Expected 200 but got " + response.getStatus(), 200, response.getStatus()); @@ -1117,10 +1117,10 @@ public void test513validateValueImplicitMulti() throws Exception { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_VALIDATE_IMPLICIT_MULTI)); - then(TEST_NAME); + then(); displayResponse(response); traceResponse(response); @@ -1140,10 +1140,10 @@ public void test514validateValueImplicitMultiConflict() throws Exception { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_VALIDATE_IMPLICIT_MULTI_CONFLICT)); - then(TEST_NAME); + then(); displayResponse(response); traceResponse(response); @@ -1164,10 +1164,10 @@ public void test515validatePasswordHistoryConflict() throws Exception { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_VALIDATE_PASSWORD_PASSWORD_HISTORY_CONFLICT)); - then(TEST_NAME); + then(); displayResponse(response); traceResponse(response, true); @@ -1188,10 +1188,10 @@ public void test516validateValueExplicitNoValuePolicy() throws Exception { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_VALIDATE_EXPLICIT_NO_VALUE_POLICY)); - then(TEST_NAME); + then(); displayResponse(response); traceResponse(response); @@ -1212,10 +1212,10 @@ public void test517generateValueExplicit() throws Exception { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_GENERATE_EXPLICIT)); - then(TEST_NAME); + then(); displayResponse(response); traceResponse(response); @@ -1241,10 +1241,10 @@ public void test518validateValueImplicitPassword() throws Exception { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_VALIDATE_IMPLICIT_PASSWORD)); - then(TEST_NAME); + then(); displayResponse(response); traceResponse(response); @@ -1270,10 +1270,10 @@ public void test520GeneratePasswordsUsingScripting() throws Exception { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.post(getRepoFile(SCRIPT_GENERATE_PASSWORDS)); - then(TEST_NAME); + then(); displayResponse(response); traceResponse(response); @@ -1324,10 +1324,10 @@ public void test530ModifyValidToUsingScripting() throws Exception { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.post(getRepoFile(SCRIPT_MODIFY_VALID_TO)); - then(TEST_NAME); + then(); displayResponse(response); traceResponse(response); @@ -1457,11 +1457,11 @@ public void test600ModifySecurityQuestionReplaceAnswerId1Existing() throws Excep getDummyAuditService().clear(); // WHEN - when(TEST_NAME); + when(); Response response = client.post(getRequestFile(MODIFICATION_REPLACE_ANSWER_ID_1_VALUE)); // THEN - then(TEST_NAME); + then(); displayResponse(response); traceResponse(response); @@ -1501,11 +1501,11 @@ public void test602ModifySecurityQuestionReplaceTwoAnswersExisting() throws Exce getDummyAuditService().clear(); // WHEN - when(TEST_NAME); + when(); Response response = client.post(getRequestFile(MODIFICATION_REPLACE_TWO_ANSWERS)); // THEN - then(TEST_NAME); + then(); displayResponse(response); traceResponse(response); @@ -1537,11 +1537,11 @@ public void test604ModifySecurityQuestionReplaceNoAnswer() throws Exception { getDummyAuditService().clear(); // WHEN - when(TEST_NAME); + when(); Response response = client.post(getRequestFile(MODIFICATION_REPLACE_NO_ANSWER)); // THEN - then(TEST_NAME); + then(); displayResponse(response); traceResponse(response); @@ -1573,11 +1573,11 @@ public void test606ModifySecurityQuestionReplaceAnswer() throws Exception { getDummyAuditService().clear(); // WHEN - when(TEST_NAME); + when(); Response response = client.post(getRequestFile(MODIFICATION_REPLACE_ANSWER)); // THEN - then(TEST_NAME); + then(); displayResponse(response); traceResponse(response); @@ -1605,10 +1605,10 @@ public void test607validateSecurityAnswerCheckExpressionFail() throws Exception getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_VALIDATE_SECURITY_ANSWER_CHECK_EXPRESSION_FAIL)); - then(TEST_NAME); + then(); displayResponse(response); traceResponse(response); @@ -1629,10 +1629,10 @@ public void test608validateSecurityAnswerCheckExpression() throws Exception { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_VALIDATE_SECURITY_ANSWER_CHECK_EXPRESSION)); - then(TEST_NAME); + then(); displayResponse(response); assertEquals("Expected 200 but got " + response.getStatus(), 200, response.getStatus()); @@ -1702,10 +1702,10 @@ public void test610ModifyPasswordForceChange() throws Exception { getDummyAuditService().clear(); - when(TEST_NAME); + when(); Response response = client.post(getRequestFile(MODIFICATION_FORCE_PASSWORD_CHANGE)); - then(TEST_NAME); + then(); displayResponse(response); traceResponse(response); @@ -1717,10 +1717,10 @@ public void test610ModifyPasswordForceChange() throws Exception { getDummyAuditService().assertLoginLogout(SchemaConstants.CHANNEL_REST_URI); getDummyAuditService().assertHasDelta(1, ChangeType.MODIFY, UserType.class); - when(TEST_NAME); + when(); response = client.get(); - then(TEST_NAME); + then(); displayResponse(response); assertEquals("Expected 200 but got " + response.getStatus(), 200, response.getStatus()); @@ -1742,13 +1742,13 @@ public void test612ResetPassword() throws Exception { getDummyAuditService().clear(); - when(TEST_NAME); + when(); // ExecuteCredentialResetRequestType executeCredentialResetRequest = new ExecuteCredentialResetRequestType(); // executeCredentialResetRequest.setResetMethod("passwordReset"); // executeCredentialResetRequest.setUserEntry("123passwd456"); Response response = client.post(getRequestFile(EXECUTE_CREDENTIAL_RESET)); - then(TEST_NAME); + then(); displayResponse(response); traceResponse(response); @@ -1760,11 +1760,11 @@ public void test612ResetPassword() throws Exception { getDummyAuditService().assertLoginLogout(SchemaConstants.CHANNEL_REST_URI); getDummyAuditService().assertHasDelta(1, ChangeType.MODIFY, UserType.class); - when(TEST_NAME); + when(); client = prepareClient(); response = client.path("/users/" + USER_DARTHADDER_OID).get(); - then(TEST_NAME); + then(); displayResponse(response); assertEquals("Expected 200 but got " + response.getStatus(), 200, response.getStatus()); @@ -1787,10 +1787,10 @@ public void test650SuspendNonExistingTask() { WebClient client = prepareClient(); client.path("/tasks/123456/suspend"); - when(TEST_NAME); + when(); Response response = client.post(null); - then(TEST_NAME); + then(); displayResponse(response); assertEquals("Expected 404 but got " + response.getStatus(), 404, response.getStatus()); @@ -1803,10 +1803,10 @@ public void test652SuspendWrongObject() { WebClient client = prepareClient(); client.path("/tasks/00000000-0000-0000-0000-000000000002/suspend"); - when(TEST_NAME); + when(); Response response = client.post(null); - then(TEST_NAME); + then(); displayResponse(response); assertEquals("Expected 400 but got " + response.getStatus(), 400, response.getStatus()); @@ -1819,10 +1819,10 @@ public void test660ResumeNonExistingTask() { WebClient client = prepareClient(); client.path("/tasks/123456/resume"); - when(TEST_NAME); + when(); Response response = client.post(null); - then(TEST_NAME); + then(); displayResponse(response); assertEquals("Expected 404 but got " + response.getStatus(), 404, response.getStatus()); @@ -1835,10 +1835,10 @@ public void test662ResumeWrongObject() { WebClient client = prepareClient(); client.path("/tasks/00000000-0000-0000-0000-000000000002/resume"); - when(TEST_NAME); + when(); Response response = client.post(null); - then(TEST_NAME); + then(); displayResponse(response); assertEquals("Expected 400 but got " + response.getStatus(), 400, response.getStatus()); @@ -1851,10 +1851,10 @@ public void test670ScheduleNonExistingTask() { WebClient client = prepareClient(); client.path("/tasks/123456/run"); - when(TEST_NAME); + when(); Response response = client.post(null); - then(TEST_NAME); + then(); displayResponse(response); assertEquals("Expected 404 but got " + response.getStatus(), 404, response.getStatus()); @@ -1867,10 +1867,10 @@ public void test672ScheduleWrongObject() { WebClient client = prepareClient(); client.path("/tasks/00000000-0000-0000-0000-000000000002/run"); - when(TEST_NAME); + when(); Response response = client.post(null); - then(TEST_NAME); + then(); displayResponse(response); assertEquals("Expected 400 but got " + response.getStatus(), 400, response.getStatus()); @@ -1883,10 +1883,10 @@ public void test680DeleteNonExistingTask() { WebClient client = prepareClient(); client.path("/tasks/123456"); - when(TEST_NAME); + when(); Response response = client.delete(); - then(TEST_NAME); + then(); displayResponse(response); assertEquals("Expected 404 but got " + response.getStatus(), 404, response.getStatus()); @@ -1899,10 +1899,10 @@ public void test682DeleteWrongObject() { WebClient client = prepareClient(); client.path("/tasks/00000000-0000-0000-0000-000000000002"); - when(TEST_NAME); + when(); Response response = client.delete(); - then(TEST_NAME); + then(); displayResponse(response); assertEquals("Expected 400 but got " + response.getStatus(), 400, response.getStatus()); diff --git a/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java b/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java index 3fc3469e137..b3d1da1607f 100644 --- a/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java +++ b/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java @@ -984,11 +984,11 @@ public void test013AddOpenDjAccountToUser() throws Exception { REQUEST_USER_MODIFY_ADD_ACCOUNT_OPENDJ_FILENAME, ObjectDeltaType.class); // WHEN - when(TEST_NAME); + when(); OperationResultType result = modifyObjectViaModelWS(objectChange); // THEN - then(TEST_NAME); + then(); assertNoRepoCache(); displayJaxb("modifyObject result", result, SchemaConstants.C_RESULT); TestUtil.assertSuccess("modifyObject has failed", result); @@ -1608,11 +1608,11 @@ public void test030DisableUser() throws Exception { assertNoRepoCache(); // WHEN - when(TEST_NAME); + when(); OperationResultType result = modifyObjectViaModelWS(objectChange); // THEN - then(TEST_NAME); + then(); assertNoRepoCache(); displayJaxb("modifyObject result:", result, SchemaConstants.C_RESULT); TestUtil.assertSuccess("modifyObject has failed", result); @@ -1669,12 +1669,12 @@ public void test030DisableUser() throws Exception { assertNoRepoCache(); // WHEN - when(TEST_NAME); + when(); modelWeb.getObject(ObjectTypes.SHADOW.getTypeQName(), accountShadowOidOpendj, options, objectHolder, resultHolder); // THEN - then(TEST_NAME); + then(); assertNoRepoCache(); displayJaxb("getObject result", resultHolder.value, SchemaConstants.C_RESULT); TestUtil.assertSuccess("getObject has failed", resultHolder.value); @@ -2837,7 +2837,7 @@ public void test301LiveSyncCreate() throws Exception { display("Sync token before", tokenBefore.toString()); // WHEN - when(TEST_NAME); + when(); Entry entry = openDJController.addEntryFromLdifFile(LDIF_WILL_FILENAME); display("Entry from LDIF", entry); @@ -2846,7 +2846,7 @@ public void test301LiveSyncCreate() throws Exception { basicWaitForSyncChangeDetection(syncCycle, tokenBefore, 2, result); // THEN - then(TEST_NAME); + then(); // Search for the user that should be created now UserType user = searchUserByName(WILL_NAME); @@ -2917,7 +2917,7 @@ public void test303LiveSyncLink() throws Exception { // AssertJUnit.assertEquals(userOid, oidHolder.value); //WHEN - when(TEST_NAME); + when(); //create account for e which should be correlated final OperationResult result = new OperationResult(TestSanity.class.getName() @@ -2935,7 +2935,7 @@ public void test303LiveSyncLink() throws Exception { basicWaitForSyncChangeDetection(syncCycle, tokenBefore, 1, result); // THEN - then(TEST_NAME); + then(); //check user and account ref userType = searchUserByName("e"); @@ -3061,11 +3061,11 @@ public void test400ImportFromResource() throws Exception { display("Entry from LDIF", addEntry); // WHEN - when(TEST_NAME); + when(); TaskType taskType = modelWeb.importFromResource(RESOURCE_OPENDJ_OID, RESOURCE_OPENDJ_ACCOUNT_OBJECTCLASS); // THEN - then(TEST_NAME); + then(); assertNoRepoCache(); displayJaxb("importFromResource result", taskType.getResult(), SchemaConstants.C_RESULT); AssertJUnit.assertEquals("importFromResource has failed", OperationResultStatusType.IN_PROGRESS, taskType.getResult().getStatus()); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConfiguredCapabilitiesActivation.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConfiguredCapabilitiesActivation.java index 79fa02276d9..65a2d3a6cd0 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConfiguredCapabilitiesActivation.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConfiguredCapabilitiesActivation.java @@ -86,12 +86,12 @@ public void test100ImportAccount() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modelService.importFromResource(SHADOW_SAMPLE_ACTIVATION_SIMULATED_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); /* List configuredCapabilities = resourceNoAAD.asObjectable().getCapabilities().getConfigured().getAny(); @@ -122,7 +122,7 @@ public void test110AssignJackPirate() throws Exception { //THEN - then(TEST_NAME); + then(); UserAsserter userAfterAsserter = assertUserAfter(USER_JACK_OID); userAfterAsserter .activation() @@ -176,7 +176,7 @@ public void test112ModifyActivationJack() throws Exception { modifyUserReplace(USER_JACK_OID, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, task, result, ActivationStatusType.DISABLED); //THEN - then(TEST_NAME); + then(); UserAsserter userAfterAsserter = assertUserAfter(USER_JACK_OID); userAfterAsserter diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConsistencyMechanism.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConsistencyMechanism.java index 1a959d3fd8e..515a3e934c3 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConsistencyMechanism.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConsistencyMechanism.java @@ -417,11 +417,11 @@ public void test100AddUser() throws Exception { OperationResult repoResult = new OperationResult("getObject"); // WHEN - when(TEST_NAME); + when(); PrismObject uObject = repositoryService.getObject(UserType.class, USER_JACK_OID, null, repoResult); // THEN - then(TEST_NAME); + then(); assertSuccess(repoResult); assertUser(uObject,"repo") @@ -754,7 +754,7 @@ public void test130DeleteObjectNotFound() throws Exception { clockForward("PT20M"); - then(TEST_NAME); + then(); provisioningService.refreshShadow(shadowRepo, null, task, parentResult); try { @@ -813,7 +813,7 @@ public void test140ModifyObjectNotFoundLinkedAccount() throws Exception { // requestToExecuteChanges(REQUEST_ACCOUNT_MODIFY_NOT_FOUND_DELETE_ACCOUNT_FILE, ACCOUNT_GUYBRUSH_OID, ShadowType.class, task, null, result); // THEN - then(TEST_NAME); + then(); PrismObject shadowAfter = getShadowRepo(ACCOUNT_GUYBRUSH_OID); ShadowAsserter.forShadow(shadowAfter) .assertTombstone() @@ -2160,11 +2160,11 @@ public void test283GetObjectNoFetchShadowAndRecompute() throws Exception { .assertNoModification(createAttributePath(LDAP_ATTRIBUTE_EMPLOYEE_TYPE)); //WHEN - when(TEST_NAME); + when(); recomputeUser(USER_DONALD_OID, ModelExecuteOptions.createReconcile(), task, parentResult); //THEN - then(TEST_NAME); + then(); assertModelShadow(shadowOid) .attributes() .assertValue(LDAP_ATTRIBUTE_GIVENNAME, "don") @@ -2196,7 +2196,7 @@ public void test284ModifyObjectAssignToGroupCommunicationProblem() throws Except String shadowOid = getLinkRefOid(USER_DONALD_OID, RESOURCE_OPENDJ_OID); // WHEN - when(TEST_NAME); + when(); AssignmentType adminRoleAssignment = new AssignmentType(prismContext); adminRoleAssignment.setTargetRef(ObjectTypeUtil.createObjectRef(ROLE_LDAP_ADMINS_OID, ObjectTypes.ROLE)); @@ -2305,11 +2305,11 @@ public void test500AddUserMorganWithAssignment() throws Exception { // WHEN - when(TEST_NAME); + when(); addObject(USER_MORGAN_FILE, task, result); // THEN - then(TEST_NAME); + then(); PrismObject userMorgan = modelService.getObject(UserType.class, USER_MORGAN_OID, null, task, result); display("User morgan after", userMorgan); @@ -2416,7 +2416,7 @@ public void test502AssignAccountToHerman() throws Exception { //REQUEST_USER_MODIFY_ADD_ACCOUNT_COMMUNICATION_PROBLEM //WHEN - when(TEST_NAME); + when(); assignAccount(UserType.class, USER_HERMAN_OID, RESOURCE_OPENDJ_OID, "internal", task, result); // THEN diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelayedEnable.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelayedEnable.java index 46d2e20b741..298f1898120 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelayedEnable.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelayedEnable.java @@ -117,12 +117,12 @@ public void test100AddUserMancomb() throws Exception { hrCreateTsStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); addObject(USER_MANCOMB_FILE, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); hrCreateTsEnd = clock.currentTimeXMLGregorianCalendar(); @@ -143,12 +143,12 @@ public void test102UserMancombTriggerScannerAgain() throws Exception { displayCurrentTime(); // WHEN - when(TEST_NAME); + when(); runTriggerScanner(); // THEN - then(TEST_NAME); + then(); assertMancombCreated(); @@ -168,12 +168,12 @@ public void test104UserMancombRecompute() throws Exception { displayCurrentTime(); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_MANCOMB_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertMancombCreated(); @@ -210,12 +210,12 @@ public void test110UserMancombRunTriggerScannerDay1() throws Exception { clockForward("P1D"); // WHEN - when(TEST_NAME); + when(); runTriggerScanner(); // THEN - then(TEST_NAME); + then(); assertMancombEnabled(); @@ -236,12 +236,12 @@ public void test112UserMancombRecomputeDay1() throws Exception { clockForward("P1D"); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_MANCOMB_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertMancombEnabled(); @@ -270,12 +270,12 @@ public void test114UserMancombRunTriggerScannerDay1Again() throws Exception { final String TEST_NAME = "test114UserMancombRunTriggerScannerDay1Again"; // WHEN - when(TEST_NAME); + when(); runTriggerScanner(); // THEN - then(TEST_NAME); + then(); assertMancombEnabled(); @@ -293,12 +293,12 @@ public void test116UserMancombRecomputeDay1Again() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_MANCOMB_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertMancombEnabled(); @@ -320,12 +320,12 @@ public void test120UserMancombHrDisable() throws Exception { hrModifyTsStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_MANCOMB_OID, getExtensionPath(EXT_HR_STATUS_QNAME), task, result, EXT_HR_STATUS_DISABLED); // THEN - then(TEST_NAME); + then(); assertSuccess(result); hrModifyTsEnd = clock.currentTimeXMLGregorianCalendar(); @@ -359,12 +359,12 @@ public void test122UserMancombRecompute() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_MANCOMB_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertMancombHalfDisabled(); @@ -380,12 +380,12 @@ public void test124UserMancombDay1TriggerScanner() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); runTriggerScanner(); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertMancombHalfDisabled(); @@ -407,12 +407,12 @@ public void test130UserMancombTriggerScannerDay2() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); runTriggerScanner(); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertMancombDisabled(); @@ -445,12 +445,12 @@ public void test132UserMancombRecomputeDay2() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_MANCOMB_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertMancombDisabled(); @@ -466,12 +466,12 @@ public void test132UserMancombRecomputeDay2Again() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_MANCOMB_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertMancombDisabled(); @@ -493,12 +493,12 @@ public void test140UserMancombRecomputeDay3() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_MANCOMB_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertMancombDisabled(); @@ -516,12 +516,12 @@ public void test200HrLivesyncTask() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); addObject(TASK_DUMMY_HR_FILE, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); waitForTaskStart(TASK_DUMMY_HR_OID, true); @@ -546,12 +546,12 @@ public void test210HrAddUserGuybrush() throws Exception { hrCreateTsStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); syncWithHr(); // THEN - then(TEST_NAME); + then(); assertSuccess(result); hrCreateTsEnd = clock.currentTimeXMLGregorianCalendar(); @@ -572,12 +572,12 @@ public void test212HrUserGuybrushSyncAgain() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); syncWithHr(); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertGuybrushCreated(assertUserAfter(userGuybrushOid)); @@ -595,12 +595,12 @@ public void test214HrUserGuybrushRunTriggers() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); runTriggerScanner(); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertGuybrushCreated(assertUserAfter(userGuybrushOid)); @@ -618,12 +618,12 @@ public void test216HrUserGuybrushRecompute() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); recomputeUser(userGuybrushOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertGuybrushCreated(assertUserAfter(userGuybrushOid)); @@ -641,12 +641,12 @@ public void test218HrUserGuybrushReconcile() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); reconcileUser(userGuybrushOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertGuybrushCreated(assertUserAfter(userGuybrushOid)); @@ -680,12 +680,12 @@ public void test220HrUserGuybrushDay1() throws Exception { clockForward("P1D"); // WHEN - when(TEST_NAME); + when(); runTriggerScanner(); // THEN - then(TEST_NAME); + then(); assertGuybrushEnabled(); @@ -700,12 +700,12 @@ public void test222HrUserGuybrushDay1SyncAgain() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); syncWithHr(); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertGuybrushEnabled(); @@ -723,12 +723,12 @@ public void test224HrUserGuybrushDay1TriggerScanAgain() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); runTriggerScanner(); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertGuybrushEnabled(); @@ -744,12 +744,12 @@ public void test226HrUserGuybrushDay1Recompute() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); recomputeUser(userGuybrushOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertGuybrushEnabled(); @@ -765,12 +765,12 @@ public void test228HrUserGuybrushDay1Reconcile() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); reconcileUser(userGuybrushOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertGuybrushEnabled(); @@ -804,12 +804,12 @@ public void test230HrDisableGuybrush() throws Exception { hrModifyTsStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - when(TEST_NAME); + when(); syncWithHr(); // THEN - then(TEST_NAME); + then(); hrModifyTsEnd = clock.currentTimeXMLGregorianCalendar(); @@ -823,12 +823,12 @@ public void test232GuybrushHrSyncAgain() throws Exception { final String TEST_NAME = "test232GuybrushHrSyncAgain"; // WHEN - when(TEST_NAME); + when(); syncWithHr(); // THEN - then(TEST_NAME); + then(); assertGuybrushHalfDisabled(); @@ -843,12 +843,12 @@ public void test234GuybrushRecompute() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); recomputeUser(userGuybrushOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertGuybrushHalfDisabled(); @@ -864,12 +864,12 @@ public void test236GuybrushReconcile() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); reconcileUser(userGuybrushOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertGuybrushHalfDisabled(); @@ -884,12 +884,12 @@ public void test238GuybrushrunTriggersAgain() throws Exception { clockForward("PT1H"); // WHEN - when(TEST_NAME); + when(); runTriggerScanner(); // THEN - then(TEST_NAME); + then(); assertGuybrushHalfDisabled(); @@ -920,12 +920,12 @@ public void test240HrUserGuybrushDay2() throws Exception { clockForward("P1D"); // WHEN - when(TEST_NAME); + when(); runTriggerScanner(); // THEN - then(TEST_NAME); + then(); assertGuybrushDisabled(); @@ -940,12 +940,12 @@ public void test242GuybrushRecompute() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); recomputeUser(userGuybrushOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertGuybrushDisabled(); @@ -958,12 +958,12 @@ public void test244GuybrushHrSyncAgain() throws Exception { final String TEST_NAME = "test244GuybrushHrSyncAgain"; // WHEN - when(TEST_NAME); + when(); syncWithHr(); // THEN - then(TEST_NAME); + then(); assertGuybrushDisabled(); @@ -978,12 +978,12 @@ public void test246GuybrushReconcile() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); reconcileUser(userGuybrushOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertGuybrushDisabled(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestExistentialIssues.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestExistentialIssues.java index a7dadceac97..da29dec8b14 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestExistentialIssues.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestExistentialIssues.java @@ -64,12 +64,12 @@ public void test100DisableUserDescartes() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_DESCARTES_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.DISABLED); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUserFromRepo(USER_DESCARTES_OID); @@ -92,12 +92,12 @@ public void test110DescartesAssignLazyAccount() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_DESCARTES_OID, RESOURCE_DUMMY_LAZY_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUserFromRepo(USER_DESCARTES_OID); @@ -120,12 +120,12 @@ public void test112EnableDescartes() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_DESCARTES_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.ENABLED); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUserFromRepo(USER_DESCARTES_OID); @@ -148,12 +148,12 @@ public void test114DisableDescartes() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_DESCARTES_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.DISABLED); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUserFromRepo(USER_DESCARTES_OID); @@ -176,12 +176,12 @@ public void test116ReenableDescartes() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_DESCARTES_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.ENABLED); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUserFromRepo(USER_DESCARTES_OID); @@ -204,12 +204,12 @@ public void test120DescartesUnassignLazyAccount() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignAccountFromUser(USER_DESCARTES_OID, RESOURCE_DUMMY_LAZY_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUserFromRepo(USER_DESCARTES_OID); @@ -232,12 +232,12 @@ public void test129DeleteDescartes() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); deleteObject(UserType.class, USER_DESCARTES_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertNoObject(UserType.class, USER_DESCARTES_OID); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInboundOutboundAssociation.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInboundOutboundAssociation.java index dc2397998b5..caee18d43ec 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInboundOutboundAssociation.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInboundOutboundAssociation.java @@ -103,12 +103,12 @@ public void test100ImportGroupPirates() throws Exception { getDummyResourceDir().addGroup(group); // WHEN - when(TEST_NAME); + when(); liveSyncDir(); // THEN - then(TEST_NAME); + then(); display("dir after", getDummyResourceDir()); @@ -137,11 +137,11 @@ public void test110AssignJackDirAccount() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignAccount(UserType.class, USER_JACK_OID, RESOURCE_DUMMY_DIR_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("dir after", getDummyResourceDir()); @@ -165,11 +165,11 @@ public void test115Stability() throws Exception { final String TEST_NAME = "test110AssignJackDirAccount"; // WHEN - when(TEST_NAME); + when(); liveSyncDir(); // THEN - then(TEST_NAME); + then(); display("dir after", getDummyResourceDir()); @@ -196,12 +196,12 @@ public void test120AddJackToGroupPirates() throws Exception { .replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, "rum"); // WHEN - when(TEST_NAME); + when(); liveSyncDir(); // THEN - then(TEST_NAME); + then(); display("dir after", getDummyResourceDir()); @@ -228,11 +228,11 @@ public void test130JackUnassignRolePirates() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, rolePiratesOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("dir after", getDummyResourceDir()); @@ -257,11 +257,11 @@ public void test140JackAssignRolePirates() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, rolePiratesOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("dir after", getDummyResourceDir()); @@ -294,11 +294,11 @@ public void test142JackUnAssignDirAccount() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignAccount(UserType.class, USER_JACK_OID, RESOURCE_DUMMY_DIR_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("dir after", getDummyResourceDir()); @@ -329,11 +329,11 @@ public void test149JackUnassignRolePirates() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, rolePiratesOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("dir after", getDummyResourceDir()); @@ -356,11 +356,11 @@ public void test150AssignJackDirAccount() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignAccount(UserType.class, USER_JACK_OID, RESOURCE_DUMMY_DIR_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("dir after", getDummyResourceDir()); @@ -384,11 +384,11 @@ public void test152JackAssignRolePirates() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, rolePiratesOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("dir after", getDummyResourceDir()); @@ -425,11 +425,11 @@ public void test153JackUnassignRolePiratesPreview() throws Exception { null, (Consumer)null, false); // WHEN - when(TEST_NAME); + when(); ModelContext previewContext = previewChanges(focusDelta, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertPreviewContext(previewContext) @@ -467,11 +467,11 @@ public void test154JackUnassignRolePirates() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, rolePiratesOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("dir after", getDummyResourceDir()); @@ -499,11 +499,11 @@ public void test159JackUnassignDirAccount() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignAccount(UserType.class, USER_JACK_OID, RESOURCE_DUMMY_DIR_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("dir after", getDummyResourceDir()); @@ -529,11 +529,11 @@ public void test200MancombAssignAccount() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_MANCOMB_OID, RESOURCE_DUMMY_DIR_OID, "default", task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("dir after", getDummyResourceDir()); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLimitedResources.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLimitedResources.java index 791da411293..c03a84eec7f 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLimitedResources.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLimitedResources.java @@ -73,12 +73,12 @@ public void test000Sanity() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); PrismObject resourceNoAAD = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_NO_ATTRIBUTE_ADD_DELETE_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); List configuredCapabilities = resourceNoAAD.asObjectable().getCapabilities().getConfigured().getAny(); @@ -96,11 +96,11 @@ public void test100AssignJackAccountNoAttributeAddDelete() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_NO_ATTRIBUTE_ADD_DELETE_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -118,12 +118,12 @@ public void test102AddJackOrganizationalUnitTreasureHunt() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modifyUserAdd(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result, createPolyString(OU_TREASURE_HUNT)); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -141,12 +141,12 @@ public void test104AddJackOrganizationalUnitLootingSailing() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modifyUserAdd(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result, createPolyString(OU_LOOTING), createPolyString(OU_SAILING)); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -164,12 +164,12 @@ public void test106DeleteJackOrganizationalUnitLooting() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modifyUserDelete(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result, createPolyString(OU_LOOTING)); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -190,12 +190,12 @@ public void test108DeleteJackOrganizationalUnitTreasureHuntSailing() throws Exce OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modifyUserDelete(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result, createPolyString(OU_TREASURE_HUNT), createPolyString(OU_SAILING)); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -213,11 +213,11 @@ public void test109UnassignJackAccountNoAttributeAddDelete() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_NO_ATTRIBUTE_ADD_DELETE_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -239,11 +239,11 @@ public void test110AssignJackAccountNoCreate() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_NO_CREATE_OID, null, task, result); // THEN - then(TEST_NAME); + then(); display("Result", result); assertSuccess(result, 2); @@ -262,11 +262,11 @@ public void test119UnassignJackAccountNoCreate() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_NO_CREATE_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLiveSyncMadness.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLiveSyncMadness.java index 0ddf08f3d0c..d00dec1ef17 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLiveSyncMadness.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLiveSyncMadness.java @@ -122,12 +122,12 @@ public void test100AddHrAccountHerman() throws Exception { dummyResourceHr.addAccount(newAccount); // WHEN - when(TEST_NAME); + when(); restartTask(TASK_LIVE_SYNC_DUMMY_HR_OID); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_HR_OID, true); // THEN - then(TEST_NAME); + then(); assertUserAfterByUsername(ACCOUNT_HERMAN_USERNAME) .assertFullName(ACCOUNT_HERMAN_FIST_NAME + " " + ACCOUNT_HERMAN_LAST_NAME) .assertTitle("Mr. " + ACCOUNT_HERMAN_LAST_NAME) @@ -160,12 +160,12 @@ public void test110RenameHrAccountHerman() throws Exception { account.replaceAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_HR_LAST_NAME, ACCOUNT_HT_LAST_NAME); // WHEN - when(TEST_NAME); + when(); restartTask(TASK_LIVE_SYNC_DUMMY_HR_OID); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_HR_OID, true); // THEN - then(TEST_NAME); + then(); assertUserAfterByUsername(ACCOUNT_HERMAN_USERNAME) .assertFullName(ACCOUNT_HT_FIST_NAME + " " + ACCOUNT_HT_LAST_NAME) .assertTitle("Mr. " + ACCOUNT_HT_LAST_NAME) @@ -199,12 +199,12 @@ public void test112HrAccountHermanEmptyDelta() throws Exception { dummyResourceHr.recordEmptyDeltaForAccountByUsername(ACCOUNT_HERMAN_USERNAME, DummyDeltaType.MODIFY); // WHEN - when(TEST_NAME); + when(); restartTask(TASK_LIVE_SYNC_DUMMY_HR_OID); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_HR_OID, true); // THEN - then(TEST_NAME); + then(); assertUserAfterByUsername(ACCOUNT_HERMAN_USERNAME) .assertFullName(ACCOUNT_HT_FIST_NAME + " " + ACCOUNT_HT_LAST_NAME) .assertTitle("Mr. " + ACCOUNT_HT_LAST_NAME) diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMapleLeaf.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMapleLeaf.java index 2948e4ae570..2282610f438 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMapleLeaf.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMapleLeaf.java @@ -158,11 +158,11 @@ public void test001addUser() throws Exception { final String TEST_NAME = "test001addUser"; //when - when(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_OPENDJ_OID, "default"); //then - then(TEST_NAME); + then(); PrismObject user = getUser(USER_JACK_OID); assertNotNull("User is null", user); @@ -189,11 +189,11 @@ public void test002assignRoleSquirrel() throws Exception { final String TEST_NAME = "test002assignRoleSquirrel"; //when - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_SQUIRREL_OID); //then - then(TEST_NAME); + then(); PrismObject user = getUser(USER_JACK_OID); assertNotNull("User is null", user); @@ -220,11 +220,11 @@ public void test003unassignRoleSquirrel() throws Exception { final String TEST_NAME = "test003unassignRoleSquirrel"; //when - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_SQUIRREL_OID); //then - then(TEST_NAME); + then(); PrismObject user = getUser(USER_JACK_OID); assertNotNull("User is null", user); @@ -252,11 +252,11 @@ public void test004assignRoleMapleLeafFaculty() throws Exception { final String TEST_NAME = "test004assignRoleMapleLeafFaculty"; //when - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_MAPLE_LEAF_FACULTY_OID); //then - then(TEST_NAME); + then(); PrismObject user = getUser(USER_JACK_OID); assertNotNull("User is null", user); @@ -292,11 +292,11 @@ public void test005assignRoleMapleLeafGraduate() throws Exception { final String TEST_NAME = "test005assignRoleMapleLeafGraduate"; //when - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_MAPLE_LEAF_GRADUATE_OID); //then - then(TEST_NAME); + then(); PrismObject user = getUser(USER_JACK_OID); assertNotNull("User is null", user); @@ -324,11 +324,11 @@ public void test006unassignRoleMapleLeafFaculty() throws Exception { final String TEST_NAME = "test006unassignRoleMapleLeafFaculty"; //when - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_MAPLE_LEAF_FACULTY_OID); //then - then(TEST_NAME); + then(); PrismObject user = getUser(USER_JACK_OID); assertNotNull("User is null", user); @@ -374,7 +374,7 @@ public void test100changePasswordForceChange() throws Exception { AssertJUnit.assertNotNull("Unexpected value in car license: " + carLicenseBefore.getRealValue(), carLicenseBefore.getRealValue()); //when - when(TEST_NAME); + when(); passwd = new ProtectedStringType(); passwd.setClearValue("somenewValue"); userDelta = createModifyUserReplaceDelta(USER_JACK_OID, SchemaConstants.PATH_PASSWORD_VALUE, passwd); @@ -384,7 +384,7 @@ public void test100changePasswordForceChange() throws Exception { //THEN - then(TEST_NAME); + then(); PrismObject userAfter = getUser(USER_JACK_OID); UserType userTypeAfter = userAfter.asObjectable(); @@ -416,7 +416,7 @@ public void test101resetPassword() throws Exception { openDJController.assertPassword("uid=jack,ou=People,dc=example,dc=com", "oldValue"); //when - when(TEST_NAME); + when(); PrismObject user = getUser(USER_JACK_OID); ExecuteCredentialResetRequestType executeCredentialResetRequest = new ExecuteCredentialResetRequestType(); executeCredentialResetRequest.setResetMethod("passwordReset"); @@ -424,7 +424,7 @@ public void test101resetPassword() throws Exception { modelInteractionService.executeCredentialsReset(user, executeCredentialResetRequest, task, result); //THEN - then(TEST_NAME); + then(); PrismObject userAfter = getUser(USER_JACK_OID); UserType userTypeAfter = userAfter.asObjectable(); @@ -476,7 +476,7 @@ public void test201SetUndefinedAdministrativeStatus() throws Exception { assertNotLinked(USER_JACK_OID, accountOid); //THEN - then(TEST_NAME); + then(); modelService.importFromResource(accountOid, task, result); PrismObject userAfter = getUser(USER_JACK_OID); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMappingMadness.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMappingMadness.java index 21479a6e6ed..3498d4e043d 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMappingMadness.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMappingMadness.java @@ -88,7 +88,7 @@ public void test100AssignJackDummyAccounts() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_TOLERANT_OID, null, task, result); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_TOLERANT_RANGE_OID, null, task, result); @@ -96,7 +96,7 @@ public void test100AssignJackDummyAccounts() throws Exception { assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_NONTOLERANT_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertJackPirateAccount(RESOURCE_DUMMY_TOLERANT_NAME); @@ -119,12 +119,12 @@ public void test105ModifyJackTitleCaptain() throws Exception { setAccountQuotes(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_TITLE, task, result, createPolyString(JACK_TITLE_CAPTAIN)); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertDummyAccountByUsername(RESOURCE_DUMMY_TOLERANT_NAME, USER_JACK_USERNAME) @@ -189,12 +189,12 @@ public void test110ModifyJackTitleWhatever() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_TITLE, task, result, createPolyString(JACK_TITLE_WHATEVER_UPPER)); // THEN - then(TEST_NAME); + then(); assertSuccess(result); // Mappings return null, which means no value. @@ -262,12 +262,12 @@ public void test112ReconcileJackWhatever() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertDummyAccountByUsername(RESOURCE_DUMMY_TOLERANT_NAME, USER_JACK_USERNAME) @@ -324,12 +324,12 @@ public void test120MadJack() throws Exception { setAccountMad(getDummyAccount(RESOURCE_DUMMY_SMART_RANGE_NAME, USER_JACK_USERNAME)); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertJackMadAccount(RESOURCE_DUMMY_TOLERANT_NAME); @@ -355,12 +355,12 @@ public void test130ModifyJackTitleWhateverLower() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_TITLE, task, result, createPolyString(JACK_TITLE_WHATEVER_LOWER)); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertJackMadAccount(RESOURCE_DUMMY_TOLERANT_NAME); @@ -385,12 +385,12 @@ public void test140ModifyJackTitleEmpty() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_TITLE, task, result /* no value */); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertJackMadAccount(RESOURCE_DUMMY_TOLERANT_NAME); @@ -420,7 +420,7 @@ public void test199UnassignJackDummyAccount() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_TOLERANT_OID, null, task, result); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_TOLERANT_RANGE_OID, null, task, result); @@ -428,7 +428,7 @@ public void test199UnassignJackDummyAccount() throws Exception { unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_NONTOLERANT_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertNoDummyAccount(RESOURCE_DUMMY_TOLERANT_NAME, USER_JACK_USERNAME); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMisbehavingResources.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMisbehavingResources.java index be297c34378..ebc1092b601 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMisbehavingResources.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMisbehavingResources.java @@ -58,12 +58,12 @@ public void test010SanityAssignJackDummyAccount() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertDummyAccountByUsername(null, USER_JACK_USERNAME) @@ -78,12 +78,12 @@ public void test019SanityUnassignJackDummyAccount() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertNoDummyAccount(USER_JACK_USERNAME); @@ -102,12 +102,12 @@ public void test100AssignJackDummyAccountTimeout() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertInProgress(result); assertNoDummyAccount(USER_JACK_USERNAME); @@ -124,12 +124,12 @@ public void test102AssignJackDummyAccounRetry() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertDummyAccountByUsername(null, USER_JACK_USERNAME) @@ -149,12 +149,12 @@ public void test110ModifyJackDummyAccountTimeout() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, createPolyString(USER_JACK_FULL_NAME_CAPTAIN)); // THEN - then(TEST_NAME); + then(); assertInProgress(result); assertDummyAccountByUsername(null, USER_JACK_USERNAME) @@ -173,12 +173,12 @@ public void test112ModifyJackDummyAccounRetry() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertDummyAccountByUsername(null, USER_JACK_USERNAME) diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNormalizers.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNormalizers.java index 580aff0d27a..1b2ffc68d07 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNormalizers.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNormalizers.java @@ -91,12 +91,12 @@ public void test100AddUserJack() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); addObject(AbstractStoryTest.USER_JACK_FILE, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUserFromRepo(AbstractStoryTest.USER_JACK_OID); @@ -111,12 +111,12 @@ public void test110AddUserTeleke() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); addObject(USER_TELEKE_FILE, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUserFromRepo(USER_TELEKE_OID); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNullAttribute.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNullAttribute.java index efb79ced34e..3dc48c61c9f 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNullAttribute.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNullAttribute.java @@ -263,12 +263,12 @@ public void test030UserSmackRemoveAttribute() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(delta); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_SMACK_OID); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationPerf.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationPerf.java index 4c0fabaff69..47276fc6d25 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationPerf.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationPerf.java @@ -127,12 +127,12 @@ public void testAddUser(final String TEST_NAME, File userFile, String userOid, i long startMillis = System.currentTimeMillis(); // WHEN - when(TEST_NAME); + when(); addObject(userBefore, task, result); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOrgSync.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOrgSync.java index d6ab0a71b0c..4c6145ede8f 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOrgSync.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOrgSync.java @@ -481,12 +481,12 @@ public void test108RedskullGoesVegetarian() throws Exception { DummyAccount account = dummyResourceHr.getAccountByUsername(ACCOUNT_REDSKULL_USERNAME); // WHEN - when(TEST_NAME); + when(); account.removeAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_HR_RESPONSIBILITIES, RESP_CANIBALISM); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_HR_OID, true); // THEN - then(TEST_NAME); + then(); PrismObject user = findUserByUsername(ACCOUNT_REDSKULL_USERNAME); assertNotNull("No redskull user", user); display("User", user); @@ -519,12 +519,12 @@ public void test109HrDeleteRedskull() throws Exception { Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); // WHEN - when(TEST_NAME); + when(); dummyResourceHr.deleteAccountByName(ACCOUNT_REDSKULL_USERNAME); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_HR_OID, true); // THEN - then(TEST_NAME); + then(); PrismObject user = findUserByUsername(ACCOUNT_REDSKULL_USERNAME); display("User", user); assertNull("Redskull user not gone", user); @@ -1012,17 +1012,17 @@ public void test500ReconcileOpenDJDefault() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - when(TEST_NAME); + when(); importObjectFromFile(TASK_RECON_OPENDJ_DEFAULT_SINGLE_FILE); // THEN - then(TEST_NAME); + then(); waitForTaskFinish(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID, false, TASK_WAIT_TIMEOUT); waitForTaskCloseOrSuspend(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID); // THEN - then(TEST_NAME); + then(); reconciliationTaskResultListener.assertResult(RESOURCE_OPENDJ_OID, 0, 17, 0, 0); @@ -1052,17 +1052,17 @@ public void test502ReconcileOpenDJDefaultAgain() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - when(TEST_NAME); + when(); restartTask(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID); // THEN - then(TEST_NAME); + then(); waitForTaskFinish(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID, false, TASK_WAIT_TIMEOUT); waitForTaskCloseOrSuspend(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID); // THEN - then(TEST_NAME); + then(); reconciliationTaskResultListener.assertResult(RESOURCE_OPENDJ_OID, 0, 17, 0, 0); @@ -1092,17 +1092,17 @@ public void test510ReconcileOpenDJLdapGroup() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - when(TEST_NAME); + when(); importObjectFromFile(TASK_RECON_OPENDJ_LDAPGROUP_SINGLE_FILE); // THEN - then(TEST_NAME); + then(); waitForTaskFinish(TASK_RECON_OPENDJ_LDAPGROUP_SINGLE_OID, false); waitForTaskCloseOrSuspend(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID); // THEN - then(TEST_NAME); + then(); reconciliationTaskResultListener.assertResult(RESOURCE_OPENDJ_OID, 0, 2, 0, 0); @@ -1143,17 +1143,17 @@ public void test550ReconcileOpenDJAfterMembershipChange() throws Exception { openDJController.assertNoUniqueMember(RESP_CANIBALISM_DN, ACCOUNT_LEMONHEAD_DN); // WHEN - when(TEST_NAME); + when(); restartTask(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID); // THEN - then(TEST_NAME); + then(); waitForTaskFinish(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID, false, TASK_WAIT_TIMEOUT); waitForTaskCloseOrSuspend(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID); // THEN - then(TEST_NAME); + then(); // Task result PrismObject reconTaskAfter = getTask(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestPlentyOfAssignments.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestPlentyOfAssignments.java index 9680a9833fe..cdc4d95ee19 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestPlentyOfAssignments.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestPlentyOfAssignments.java @@ -185,12 +185,12 @@ public void test100AddCheese() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - when(TEST_NAME); + when(); addObject(cheeseBefore, task, result); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -228,12 +228,12 @@ public void test110RecomputeCheese() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_CHEESE_OID, task, result); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -272,12 +272,12 @@ public void test120CheesePreviewChanges() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - when(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -329,7 +329,7 @@ public void test200DummyGroups() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); PrismObjectDefinition shadowDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(ShadowType.class); PrismObjectDefinition roleDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(RoleType.class); @@ -382,7 +382,7 @@ public void test200DummyGroups() throws Exception { } // THEN - then(TEST_NAME); + then(); assertSuccess(result); Collection dummyGroups = getDummyResource().listGroups(); @@ -412,12 +412,12 @@ public void test210AddBob() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - when(TEST_NAME); + when(); addObject(userBefore, task, result); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -456,12 +456,12 @@ public void test212RecomputeBob() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_BOB_OID, task, result); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -500,12 +500,12 @@ public void test2124ReconcileBob() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_BOB_OID, task, result); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -567,12 +567,12 @@ public void test220AddAlice() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - when(TEST_NAME); + when(); addObject(userBefore, task, result); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -612,12 +612,12 @@ public void test222RecomputeAlice() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_ALICE_OID, task, result); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -656,12 +656,12 @@ public void test224ReconcileAlice() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - when(TEST_NAME); + when(); reconcileUser(USER_ALICE_OID, task, result); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestReconNullValue.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestReconNullValue.java index 689096a3fab..f8b782b990d 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestReconNullValue.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestReconNullValue.java @@ -201,12 +201,12 @@ public void test130AddHonorificPrefix() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(delta); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getObjectByName(UserType.class, USER_0_NAME); @@ -258,12 +258,12 @@ public void test140dDeleteHonorificPrefixGivenName() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(delta); // WHEN - when(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getObjectByName(UserType.class, USER_0_NAME); @@ -316,14 +316,14 @@ public void test150RemoveTitleRA() throws Exception { dumpLdap(); // WHEN - when(TEST_NAME); + when(); modelService.recompute(UserType.class, userBefore.getOid(), null, task, result); display("LDAP after reconcile"); dumpLdap(); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getObjectByName(UserType.class, USER_0_NAME); @@ -375,14 +375,14 @@ public void test160SetGivenNameAttributeAndReconcile() throws Exception { dumpLdap(); // WHEN - when(TEST_NAME); + when(); modelService.recompute(UserType.class, userBefore.getOid(), null, task, result); display("LDAP after reconcile"); dumpLdap(); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getObjectByName(UserType.class, USER_0_NAME); @@ -427,14 +427,14 @@ public void test170ReplaceGivenNameEmpty() throws Exception { dumpLdap(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(userBefore.getOid(), UserType.F_GIVEN_NAME, task, result /* no value */); display("LDAP after reconcile"); dumpLdap(); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getObjectByName(UserType.class, USER_0_NAME); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestScience.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestScience.java index b97552521b4..f2a5018b26a 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestScience.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestScience.java @@ -178,11 +178,11 @@ public void test100JackAssignRoleStatistics() throws Exception { display("User before", userBefore); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_STATISTICS_OID, task, result); // WHEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = repositoryService.getObject(UserType.class, USER_JACK_OID, null, result); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccounts.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccounts.java index 23bdbdcd2d5..faadfa0a273 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccounts.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccounts.java @@ -89,12 +89,12 @@ public void test100StartSyncTask() throws Exception { assertServices(0); // WHEN - when(TEST_NAME); + when(); importObjectFromFile(TASK_LIVE_SYNC_DUMMY_FILE); // THEN - then(TEST_NAME); + then(); waitForTaskStart(TASK_LIVE_SYNC_DUMMY_OID, true); @@ -115,14 +115,14 @@ public void test101AddServiceAccountSync() throws Exception { ACCOUNT_RUM_STORAGE_DUMMY_FULLNAME); // WHEN - when(TEST_NAME); + when(); getDummyResource().addAccount(account); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_OID, true); // THEN - then(TEST_NAME); + then(); assertServices(1); @@ -158,7 +158,7 @@ serviceAccountShadowOid, getDummyResourceController().getAttributeFullnamePath() try { // WHEN - when(TEST_NAME); + when(); executeChanges(delta, null, task, result); @@ -166,7 +166,7 @@ serviceAccountShadowOid, getDummyResourceController().getAttributeFullnamePath() } catch (UnsupportedOperationException e) { // THEN - then(TEST_NAME); + then(); display("expected exception", e); } @@ -205,7 +205,7 @@ public void test104DeleteServiceAccount() throws Exception { try { // WHEN - when(TEST_NAME); + when(); executeChanges(delta, null, task, result); @@ -213,7 +213,7 @@ public void test104DeleteServiceAccount() throws Exception { } catch (UnsupportedOperationException e) { // THEN - then(TEST_NAME); + then(); display("expected exception", e); } @@ -248,14 +248,14 @@ public void test108DeleteServiceAccountSync() throws Exception { assertServices(1); // WHEN - when(TEST_NAME); + when(); getDummyResource().deleteAccountByName(ACCOUNT_RUM_STORAGE_DUMMY_USERNAME); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_OID, true); // THEN - then(TEST_NAME); + then(); assertNoServiceByName(ACCOUNT_RUM_STORAGE_DUMMY_USERNAME); assertServices(0); @@ -269,12 +269,12 @@ public void test109StopLivesyncTask() throws Exception { assertServices(0); // WHEN - when(TEST_NAME); + when(); suspendTask(TASK_LIVE_SYNC_DUMMY_OID); // THEN - then(TEST_NAME); + then(); assertTaskExecutionStatus(TASK_LIVE_SYNC_DUMMY_OID, TaskExecutionStatus.SUSPENDED); } @@ -286,12 +286,12 @@ public void test120StartReconTask() throws Exception { assertServices(0); // WHEN - when(TEST_NAME); + when(); importObjectFromFile(TASK_RECONCILE_DUMMY_FILE); // THEN - then(TEST_NAME); + then(); waitForTaskStart(TASK_RECONCILE_DUMMY_OID, true); @@ -312,14 +312,14 @@ public void test121AddServiceAccountRecon() throws Exception { ACCOUNT_MAGAZINE_DUMMY_FULLNAME); // WHEN - when(TEST_NAME); + when(); getDummyResource().addAccount(account); waitForTaskNextRunAssertSuccess(TASK_RECONCILE_DUMMY_OID, true); // THEN - then(TEST_NAME); + then(); assertServices(1); @@ -338,14 +338,14 @@ public void test128DeleteServiceAccountRecon() throws Exception { assertServices(1); // WHEN - when(TEST_NAME); + when(); getDummyResource().deleteAccountByName(ACCOUNT_MAGAZINE_DUMMY_USERNAME); waitForTaskNextRunAssertSuccess(TASK_RECONCILE_DUMMY_OID, true); // THEN - then(TEST_NAME); + then(); assertNoServiceByName(ACCOUNT_MAGAZINE_DUMMY_USERNAME); assertServices(0); @@ -358,12 +358,12 @@ public void test129StopReconTask() throws Exception { assertServices(1); // WHEN - when(TEST_NAME); + when(); suspendTask(TASK_RECONCILE_DUMMY_OID); // THEN - then(TEST_NAME); + then(); assertTaskExecutionStatus(TASK_RECONCILE_DUMMY_OID, TaskExecutionStatus.SUSPENDED); } @@ -393,7 +393,7 @@ public void test140CreateServiceAccount() throws Exception { try { // WHEN - when(TEST_NAME); + when(); executeChanges(delta, null, task, result); @@ -401,7 +401,7 @@ public void test140CreateServiceAccount() throws Exception { } catch (UnsupportedOperationException e) { // THEN - then(TEST_NAME); + then(); display("expected exception", e); } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccountsClassifier.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccountsClassifier.java index 9a274c1ce23..ed369f339ef 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccountsClassifier.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccountsClassifier.java @@ -81,7 +81,7 @@ public void test001assigneJackEmployeeRole() throws Exception { final String TEST_NAME = "test001assigneJackEmployeeRole"; //WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_EMPLOYEE_OID); //THEN @@ -99,7 +99,7 @@ public void test100createServiceJira() throws Exception { addObject(SERVICE_JIRA_FILE); //THEN - then(TEST_NAME); + then(); PrismObject service = getObject(ServiceType.class, SERVICE_JIRA_OID); display("Service magazine after", service); assertNotNull("No magazine service", service); @@ -116,11 +116,11 @@ public void test101jiraAssignResourceNoneEnforcement() throws Exception { //GIVEN //WHEN - when(TEST_NAME); + when(); assignAccount(ServiceType.class, SERVICE_JIRA_OID, RESOURCE_DUMMY_CLASSIFIER_OID, "service"); //THEN - then(TEST_NAME); + then(); PrismObject service = getObject(ServiceType.class, SERVICE_JIRA_OID); display("Service magazine after", service); assertNotNull("No magazine service", service); @@ -137,12 +137,12 @@ public void test150StartReconTask() throws Exception { assertServices(1); // WHEN - when(TEST_NAME); + when(); importObjectFromFile(TASK_RECONCILE_DUMMY_CLASSIFIER_FILE); // THEN - then(TEST_NAME); + then(); waitForTaskStart(TASK_RECONCILE_DUMMY_CLASSIFIER_OID, true); @@ -161,14 +161,14 @@ public void test151LinkServiceAccountRecon() throws Exception { account.setEnabled(true); // WHEN - when(TEST_NAME); + when(); getDummyResource().addAccount(account); waitForTaskNextRunAssertSuccess(TASK_RECONCILE_DUMMY_CLASSIFIER_OID, true); // THEN - then(TEST_NAME); + then(); assertServices(1); PrismObject serviceJirafter = getObject(ServiceType.class, SERVICE_JIRA_OID); @@ -190,14 +190,14 @@ public void test152InactivateUnmatchedAccountRecon() throws Exception { account.setEnabled(true); // WHEN - when(TEST_NAME); + when(); getDummyResource().addAccount(account); waitForTaskNextRunAssertSuccess(TASK_RECONCILE_DUMMY_CLASSIFIER_OID, true); // THEN - then(TEST_NAME); + then(); assertServices(1); @@ -213,7 +213,7 @@ public void test200createServiceGithub() throws Exception { addObject(SERVICE_GITHUB_FILE); //THEN - then(TEST_NAME); + then(); PrismObject service = getObject(ServiceType.class, SERVICE_GITHUB_OID); display("Service github after", service); assertNotNull("No github service", service); @@ -226,11 +226,11 @@ public void test210createAccountGithub() throws Exception { final String TEST_NAME = "test210createAccountGithub"; //WHEN - when(TEST_NAME); + when(); addObject(SHADOW_GITHUB_FILE); // THEN - then(TEST_NAME); + then(); PrismObject shadowGithub = getShadowModel(SHADOW_GITHUB_OID); display("Shadow github after", shadowGithub); @@ -249,11 +249,11 @@ public void test215githubAssignResourceNoneEnforcement() throws Exception { //GIVEN //WHEN - when(TEST_NAME); + when(); assignAccount(ServiceType.class, SERVICE_GITHUB_OID, RESOURCE_DUMMY_CLASSIFIER_OID, "service"); //THEN - then(TEST_NAME); + then(); PrismObject service = getObject(ServiceType.class, SERVICE_GITHUB_OID); display("Service github after", service); assertNotNull("No github service", service); @@ -275,11 +275,11 @@ public void test220linkAccountGithubAndFixIntent() throws Exception { assertNoLinkedAccount(serviceGithubBefore); // WHEN - when(TEST_NAME); + when(); waitForTaskNextRunAssertSuccess(TASK_RECONCILE_DUMMY_CLASSIFIER_OID, true); // THEN - then(TEST_NAME); + then(); assertServices(2); PrismObject serviceGithubAfter = getObject(ServiceType.class, SERVICE_GITHUB_OID); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestShadowsPerformance.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestShadowsPerformance.java index a87c1ed2071..c4d16a6485b 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestShadowsPerformance.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestShadowsPerformance.java @@ -102,11 +102,11 @@ public void test010Sanity() throws Exception { Task task = getTestTask(); // WHEN - when(TEST_NAME); + when(); OperationResult result = modelService.testResource(RESOURCE_DUMMY_OID, task); // THEN - then(TEST_NAME); + then(); result.computeStatusIfUnknown(); assertSuccess(result); } @@ -125,11 +125,11 @@ public void test100ImportAccounts() throws Exception { } // WHEN - when(TEST_NAME); + when(); addTask(TASK_IMPORT_FILE); // THEN - then(TEST_NAME); + then(); Task taskAfter = waitForTaskFinish(TASK_IMPORT_OID, true, SYNC_TASK_WAIT_TIMEOUT); display("task after", prismContext.xmlSerializer().serialize(taskAfter.getUpdatedTaskObject())); @@ -155,11 +155,11 @@ public void test200DeleteAccountsAndReconcile() throws Exception { assertEquals("Wrong # of remaining accounts", 0, dummyResourceCtl.getDummyResource().listAccounts().size()); // WHEN - when(TEST_NAME); + when(); addTask(TASK_RECONCILIATION_FILE); // THEN - then(TEST_NAME); + then(); Task taskAfter = waitForTaskFinish(TASK_RECONCILIATION_OID, true, 0L, SYNC_TASK_WAIT_TIMEOUT, false, 100, null); display("task after", prismContext.xmlSerializer().serialize(taskAfter.getUpdatedTaskObject())); @@ -185,11 +185,11 @@ public void test210DeleteShadows() throws Exception { assertEquals("Wrong # of remaining accounts", 0, dummyResourceCtl.getDummyResource().listAccounts().size()); // WHEN - when(TEST_NAME); + when(); addTask(TASK_BULK_DELETE_FILE); // THEN - then(TEST_NAME); + then(); Task taskAfter = waitForTaskFinish(TASK_BULK_DELETE_OID, true, 0L, SYNC_TASK_WAIT_TIMEOUT, false, 100, null); display("task after", prismContext.xmlSerializer().serialize(taskAfter.getUpdatedTaskObject())); @@ -216,7 +216,7 @@ public void test900Summarize() { display("Summary (" + NUMBER_OF_GENERATED_USERS + " users)", sb.toString()); // THEN - then(TEST_NAME); + then(); // TODO: more thresholds diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestStrings.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestStrings.java index eb138289cec..ae36a4e2de8 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestStrings.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestStrings.java @@ -213,11 +213,11 @@ public void test100SimpleAssignmentStart() throws Exception { dummyTransport.clearMessages(); // WHEN - when(TEST_NAME); + when(); assignRole(userBobOid, roleATest1Oid, task, task.getResult()); // THEN - then(TEST_NAME); + then(); assertNotAssignedRole(getUser(userBobOid), roleATest1Oid); CaseWorkItemType workItem = getWorkItem(task, result); @@ -282,7 +282,7 @@ public void test102SimpleAssignmentApproveByLechuck() throws Exception { CaseWorkItemType workItem = getWorkItem(task, result); // WHEN - when(TEST_NAME); + when(); PrismObject lechuck = getUserFromRepo(userLechuckOid); login(lechuck); workflowService.completeWorkItem(WorkItemId.of(workItem), @@ -290,7 +290,7 @@ public void test102SimpleAssignmentApproveByLechuck() throws Exception { task, result); // THEN - then(TEST_NAME); + then(); login(userAdministrator); List workItems = getWorkItems(task, result); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholds.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholds.java index ce2e78ebcee..3dc5e213d21 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholds.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholds.java @@ -170,7 +170,7 @@ public void test110importAccounts() throws Exception { assertUsers(getNumberOfUsers()); //WHEN - when(TEST_NAME); + when(); OperationResult reconResult = waitForTaskResume(getTaskOid(), false, TASK_IMPORT_TIMEOUT); assertFailure(reconResult); @@ -195,7 +195,7 @@ public void test111importAccountsAgain() throws Exception { assertUsers(getNumberOfUsers()+getProcessedUsers()); //WHEN - when(TEST_NAME); + when(); OperationResult reconResult = waitForTaskResume(getTaskOid(), false, TASK_IMPORT_TIMEOUT); assertFailure(reconResult); @@ -236,7 +236,7 @@ public void test520changeActivationThreeAccounts() throws Exception { openDJController.executeLdifChange(LDIF_CHANGE_ACTIVATION_FILE); //WHEN - when(TEST_NAME); + when(); OperationResult reconResult = waitForTaskResume(getTaskOid(), false, 20000); assertFailure(reconResult); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsReconFull.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsReconFull.java index 7248b772322..90d8365c2e1 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsReconFull.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsReconFull.java @@ -90,7 +90,7 @@ public void test610testFullRecon() throws Exception { OperationResult result = createResult(); //WHEN - when(TEST_NAME); + when(); OperationResult reconResult = waitForTaskResume(TASK_RECONCILE_OPENDJ_SIMULATE_EXECUTE_OID, true, 20000); assertSuccess(reconResult); @@ -117,7 +117,7 @@ public void test611testFullRecon() throws Exception { openDJController.delete("uid=user15,ou=People,dc=example,dc=com"); //WHEN - when(TEST_NAME); + when(); OperationResult reconResult = waitForTaskNextRun(TASK_RECONCILE_OPENDJ_SIMULATE_EXECUTE_OID, true, 20000, false); assertSuccess(reconResult); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnix.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnix.java index a5ee28b4bc2..142f64003b6 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnix.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnix.java @@ -345,11 +345,11 @@ public void test100AddUserHermanBasic() throws Exception { PrismObject user = createUser(USER_HERMAN_USERNAME, USER_HERMAN_FIST_NAME, USER_HERMAN_LAST_NAME, ROLE_BASIC_OID); // WHEN - when(TEST_NAME); + when(); addObject(user, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_HERMAN_USERNAME); @@ -372,11 +372,11 @@ public void test110AddUserMancombUnix() throws Exception { PrismObject user = createUser(USER_MANCOMB_USERNAME, USER_MANCOMB_FIST_NAME, USER_MANCOMB_LAST_NAME, ROLE_UNIX_OID); // WHEN - when(TEST_NAME); + when(); addObject(user, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_MANCOMB_USERNAME); @@ -400,11 +400,11 @@ public void test111AccountMancombEditObjectClassDefinition() throws Exception { display("shadow", shadow); // WHEN - when(TEST_NAME); + when(); RefinedObjectClassDefinition editObjectClassDefinition = modelInteractionService.getEditObjectClassDefinition(shadow, resourceOpenDj, AuthorizationPhaseType.REQUEST, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); display("OC def", editObjectClassDefinition); @@ -428,11 +428,11 @@ public void test119DeleteUserMancombUnix() throws Exception { PrismObject userBefore = findUserByUsername(USER_MANCOMB_USERNAME); // WHEN - when(TEST_NAME); + when(); deleteObject(UserType.class, userBefore.getOid(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_MANCOMB_USERNAME); @@ -453,11 +453,11 @@ public void test120AddUserLargo() throws Exception { PrismObject user = createUser(USER_LARGO_USERNAME, USER_LARGO_FIST_NAME, USER_LARGO_LAST_NAME, (String)null); // WHEN - when(TEST_NAME); + when(); addObject(user, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -476,11 +476,11 @@ public void test122AssignUserLargoBasic() throws Exception { PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - when(TEST_NAME); + when(); assignRole(userBefore.getOid(), ROLE_BASIC_OID); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -506,11 +506,11 @@ public void test124AssignUserLargoUnix() throws Exception { long startTs = System.currentTimeMillis(); // WHEN - when(TEST_NAME); + when(); assignRole(userBefore.getOid(), ROLE_UNIX_OID); // THEN - then(TEST_NAME); + then(); assertSuccess(result); long endTs = System.currentTimeMillis(); @@ -538,11 +538,11 @@ public void test125RecomputeUserLargo() throws Exception { PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - when(TEST_NAME); + when(); recomputeUser(userBefore.getOid(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -566,11 +566,11 @@ public void test126UnAssignUserLargoUnix() throws Exception { PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - when(TEST_NAME); + when(); unassignRole(userBefore.getOid(), ROLE_UNIX_OID); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -594,11 +594,11 @@ public void test127RecomputeUserLargo() throws Exception { PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - when(TEST_NAME); + when(); recomputeUser(userBefore.getOid(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -622,11 +622,11 @@ public void test128UnAssignUserLargoBasic() throws Exception { PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - when(TEST_NAME); + when(); unassignRole(userBefore.getOid(), ROLE_BASIC_OID); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -649,11 +649,11 @@ public void test129RecomputeUserLargo() throws Exception { PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - when(TEST_NAME); + when(); recomputeUser(userBefore.getOid(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -676,11 +676,11 @@ public void test130AssignUserLargoUnix() throws Exception { PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - when(TEST_NAME); + when(); assignRole(userBefore.getOid(), ROLE_UNIX_OID); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -706,11 +706,11 @@ public void test131ReconcileUserLargo() throws Exception { dummyAuditService.clear(); // WHEN - when(TEST_NAME); + when(); reconcileUser(userBefore.getOid(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -764,11 +764,11 @@ public void test132MeddleWithAccountAndReconcileUserLargo() throws Exception { dummyAuditService.clear(); // WHEN - when(TEST_NAME); + when(); reconcileUser(userBefore.getOid(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -815,11 +815,11 @@ public void test133ReconcileUserLargoAgain() throws Exception { dummyAuditService.clear(); // WHEN - when(TEST_NAME); + when(); reconcileUser(userBefore.getOid(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -850,11 +850,11 @@ public void test134AssignUserLargoBasic() throws Exception { dummyAuditService.clear(); // WHEN - when(TEST_NAME); + when(); assignRole(userBefore.getOid(), ROLE_BASIC_OID); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -886,11 +886,11 @@ public void test135UnAssignUserLargoUnix() throws Exception { dummyAuditService.clear(); // WHEN - when(TEST_NAME); + when(); unassignRole(userBefore.getOid(), ROLE_UNIX_OID); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -950,11 +950,11 @@ public void test136MeddleWithAccountAndReconcileUserLargo() throws Exception { dummyAuditService.clear(); // WHEN - when(TEST_NAME); + when(); reconcileUser(userBefore.getOid(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -993,11 +993,11 @@ public void test137ReconcileUserLargoAgain() throws Exception { dummyAuditService.clear(); // WHEN - when(TEST_NAME); + when(); reconcileUser(userBefore.getOid(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -1034,11 +1034,11 @@ public void test138UnAssignUserLargoBasic() throws Exception { PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - when(TEST_NAME); + when(); unassignRole(userBefore.getOid(), ROLE_BASIC_OID); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -1063,11 +1063,11 @@ public void test200AddLdapGroupMonkeyIsland() throws Exception { PrismObject role = createLdapGroupRole(ROLE_MONKEY_ISLAND_NAME); // WHEN - when(TEST_NAME); + when(); addObject(role, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject roleAfter = getObject(RoleType.class, role.getOid()); @@ -1091,11 +1091,11 @@ public void test202AssignUserHermanMonkeyIsland() throws Exception { PrismObject user = findUserByUsername(USER_HERMAN_USERNAME); // WHEN - when(TEST_NAME); + when(); assignRole(user.getOid(), roleMonkeyIslandOid); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_HERMAN_USERNAME); @@ -1119,11 +1119,11 @@ public void test210AddUnixGroupVillains() throws Exception { PrismObject role = createUnixGroupRole(ROLE_VILLAINS_NAME, ROLE_META_UNIXGROUP_OID); // WHEN - when(TEST_NAME); + when(); addObject(role, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject roleAfter = getObject(RoleType.class, role.getOid()); @@ -1147,11 +1147,11 @@ public void test211AssignUserLargoUnix() throws Exception { PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - when(TEST_NAME); + when(); assignRole(userBefore.getOid(), ROLE_UNIX_OID); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -1175,11 +1175,11 @@ public void test212AssignUserLargoVillains() throws Exception { PrismObject user = findUserByUsername(USER_LARGO_USERNAME); // WHEN - when(TEST_NAME); + when(); assignRole(user.getOid(), roleVillainsOid); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -1205,11 +1205,11 @@ public void test250AddUserRangerBasic() throws Exception { PrismObject user = createUser(USER_RANGER_USERNAME, USER_RANGER_FIST_NAME, USER_RANGER_LAST_NAME, ROLE_BASIC_OID); // WHEN - when(TEST_NAME); + when(); addObject(user, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_RANGER_USERNAME); @@ -1232,11 +1232,11 @@ public void test251AssignUserRangerBasic() throws Exception { PrismObject userBefore = findUserByUsername(USER_RANGER_USERNAME); // WHEN - when(TEST_NAME); + when(); assignRole(userBefore.getOid(), ROLE_BASIC_OID); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_RANGER_USERNAME); @@ -1260,11 +1260,11 @@ public void test252AddUnixGroupRangers() throws Exception { PrismObject role = createUnixGroupRole(ROLE_RANGERS_NAME, ROLE_META_UNIXGROUP2_OID); // WHEN - when(TEST_NAME); + when(); addObject(role, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject roleAfter = getObject(RoleType.class, role.getOid()); @@ -1288,11 +1288,11 @@ public void test253AddUnixGroupSeals() throws Exception { PrismObject role = createUnixGroupRole(ROLE_SEALS_NAME, ROLE_META_UNIXGROUP2_OID); // WHEN - when(TEST_NAME); + when(); addObject(role, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject roleAfter = getObject(RoleType.class, role.getOid()); @@ -1318,11 +1318,11 @@ public void test254AssignUserRangerRangers() throws Exception { PrismObject user = findUserByUsername(USER_RANGER_USERNAME); // WHEN - when(TEST_NAME); + when(); assignRole(user.getOid(), roleRangersOid); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_RANGER_USERNAME); @@ -1331,7 +1331,7 @@ public void test254AssignUserRangerRangers() throws Exception { assertUser(userAfter, USER_RANGER_USERNAME, USER_RANGER_FIST_NAME, USER_RANGER_LAST_NAME); String accountOid = getSingleLinkOid(userAfter); - then(TEST_NAME); + then(); PrismObject shadow = getShadowModel(accountOid); display("Shadow (model)", shadow); String accountRangerDn = assertPosixAccount(shadow, USER_RANGER_UID_NUMBER); @@ -1359,11 +1359,11 @@ public void test255AssignUserRangerSeals() throws Exception { PrismObject user = findUserByUsername(USER_RANGER_USERNAME); // WHEN - when(TEST_NAME); + when(); assignRole(user.getOid(), roleSealsOid); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_RANGER_USERNAME); @@ -1392,11 +1392,11 @@ public void test256UnAssignUserRangerSealsKeepRangers() throws Exception { PrismObject userBefore = findUserByUsername(USER_RANGER_USERNAME); // WHEN - when(TEST_NAME); + when(); unassignRole(userBefore.getOid(), roleSealsOid); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_RANGER_USERNAME); @@ -1430,11 +1430,11 @@ public void test257RenameUserAndAccountsCheckGroupmembership() throws Exception PrismObject userBefore = findUserByUsername(USER_RANGER_USERNAME); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(userBefore.getOid(), UserType.F_NAME, task, result, new PolyString("usranger", "usranger")); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_RANGER_USERNAME_RENAMED); @@ -1469,11 +1469,11 @@ public void test260DeleteUserUsrangerUnix() throws Exception { PrismObject userBefore = findUserByUsername(USER_RANGER_USERNAME_RENAMED); // WHEN - when(TEST_NAME); + when(); deleteObject(UserType.class, userBefore.getOid(), task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_RANGER_USERNAME_RENAMED); @@ -1495,11 +1495,11 @@ public void test270RenameUnixGroupSeals() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); renameObject(RoleType.class, roleSealsOid, ROLE_WALRUSES_NAME, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject roleAfter = getObject(RoleType.class, roleSealsOid); @@ -1532,7 +1532,7 @@ public void test300AddUserCapsizeUnixFail() throws Exception { try { // WHEN - when(TEST_NAME); + when(); addObject(user, task, result); AssertJUnit.fail("Unexpected success"); @@ -1542,7 +1542,7 @@ public void test300AddUserCapsizeUnixFail() throws Exception { } // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertFailure(result); @@ -1574,11 +1574,11 @@ public void test310AddUserWallyUnix() throws Exception { PrismObject user = createUser(USER_WALLY_USERNAME, USER_WALLY_FIST_NAME, USER_WALLY_LAST_NAME, ROLE_UNIX_OID); // WHEN - when(TEST_NAME); + when(); addObject(user, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_WALLY_USERNAME); @@ -1624,11 +1624,11 @@ public void test312AccountWallyRemovePosixObjectclassNative() throws Exception { display("Wally LDAP account before", entryWallyBefore); // WHEN - when(TEST_NAME); + when(); PrismObject shadow = modelService.getObject(ShadowType.class, accountWallyOid, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1674,11 +1674,11 @@ public void test314AccountWallyAddPosixObjectclassNative() throws Exception { display("Wally LDAP account before", entryWallyBefore); // WHEN - when(TEST_NAME); + when(); PrismObject shadow = modelService.getObject(ShadowType.class, accountWallyOid, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1706,11 +1706,11 @@ public void test400ListAllAccountsObjectClass() throws Exception { OPENDJ_ACCOUNT_STRUCTURAL_OBJECTCLASS_NAME, prismContext); // WHEN - when(TEST_NAME); + when(); SearchResultList> objects = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1729,11 +1729,11 @@ public void test401ListAllAccountsKindIntent() throws Exception { display("query", query); // WHEN - when(TEST_NAME); + when(); SearchResultList> objects = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1752,11 +1752,11 @@ public void test402ListLdapGroupsKindIntent() throws Exception { display("query", query); // WHEN - when(TEST_NAME); + when(); SearchResultList> objects = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - then(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1775,11 +1775,11 @@ public void test403ListUnixGroupsKindIntent() throws Exception { display("query", query); // WHEN - when(TEST_NAME); + when(); SearchResultList> objects = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("found objects", objects); @@ -1796,11 +1796,11 @@ public void test500AddUserStan() throws Exception { addRoleAssignment(user, roleMonkeyIslandOid); // WHEN - when(TEST_NAME); + when(); addObject(user, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_STAN_USERNAME); @@ -1841,11 +1841,11 @@ public void test510StanDisablePosixAssocAndReconcile() throws Exception { repositoryService.modifyObject(UserType.class, userStan.getOid(), itemDeltas, result); // WHEN - when(TEST_NAME); + when(); reconcileUser(userStan.getOid(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_STAN_USERNAME); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnixTolerantAux.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnixTolerantAux.java index 024bd61cb6d..97170f9dcd2 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnixTolerantAux.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnixTolerantAux.java @@ -118,11 +118,11 @@ public void test140AssignUserLargoBasic() throws Exception { PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - when(TEST_NAME); + when(); assignRole(userBefore.getOid(), ROLE_BASIC_OID); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -166,11 +166,11 @@ public void test142MeddleWithAccountAndReconcileUserLargo() throws Exception { dummyAuditService.clear(); // WHEN - when(TEST_NAME); + when(); reconcileUser(userBefore.getOid(), task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -198,11 +198,11 @@ public void test144AssignUserLargoUnix() throws Exception { PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - when(TEST_NAME); + when(); assignRole(userBefore.getOid(), ROLE_UNIX_OID); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -228,11 +228,11 @@ public void test146UnassignUserLargoUnix() throws Exception { PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - when(TEST_NAME); + when(); unassignRole(userBefore.getOid(), ROLE_UNIX_OID); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -258,11 +258,11 @@ public void test149UnAssignUserLargoBasic() throws Exception { PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - when(TEST_NAME); + when(); unassignRole(userBefore.getOid(), ROLE_BASIC_OID); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestVillage.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestVillage.java index a4ecef6ab49..29f17288224 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestVillage.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestVillage.java @@ -773,12 +773,12 @@ public void test200CreateUserAssignOrgPwdPolicy() throws Exception { ObjectDelta addUserMikeDelta = DeltaFactory.Object.createAddDelta(userMikeBefore); // WHEN - when(TEST_NAME); + when(); //The user's password has length 4..if the policy is not chosen correctly, it fails modelService.executeChanges(MiscUtil.createCollection(addUserMikeDelta), null, task, result); // THEN - then(TEST_NAME); + then(); assertPartialError(result); //TODO: assert added user @@ -815,11 +815,11 @@ public void test300AddProjectJollyRoger() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); addObject(ORG_PROJECT_JOLLY_ROGER_FILE, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PrismObject org = getObject(OrgType.class, ORG_PROJECT_JOLLY_ROGER_OID); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestWriter.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestWriter.java index 33e204882cf..b8b915efe06 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestWriter.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestWriter.java @@ -77,12 +77,12 @@ public void test100AssignJackDummyAccount() throws Exception { modifyUserReplace(USER_JACK_OID, UserType.F_LOCALITY, task, result, createPolyString(USER_JACK_LOCALITY)); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_WRITER_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertDummyAccountByUsername(RESOURCE_WRITER_DUMMY_NAME, USER_JACK_USERNAME) @@ -100,12 +100,12 @@ public void test110ModifyCaptainJack() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, createPolyString(USER_JACK_FULL_NAME_CAPTAIN)); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertDummyAccountByUsername(RESOURCE_WRITER_DUMMY_NAME, USER_JACK_USERNAME) diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapAssociationPerformance.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapAssociationPerformance.java index 3f8401ccfbb..5040f9f9ec4 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapAssociationPerformance.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapAssociationPerformance.java @@ -170,13 +170,13 @@ public void test010Sanity() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); addObject(ROLE_TEST_FILE, task, result); addObject(USER_TEST_FILE, task, result); // THEN - then(TEST_NAME); + then(); dumpLdap(); openDJController.assertUniqueMember("cn=role-test,ou=groups,dc=example,dc=com", "uid=user-test,ou=people,dc=example,dc=com"); @@ -194,7 +194,7 @@ public void test020GenerateRoles() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); resetPerformanceCollectors(); @@ -210,7 +210,7 @@ public void test020GenerateRoles() throws Exception { IntegrationTestTools.setSilentConsole(false); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); recordDuration(TEST_NAME, (endMillis - startMillis)); @@ -242,7 +242,7 @@ public void test100AddUsers() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); resetPerformanceCollectors(); @@ -271,7 +271,7 @@ public void test100AddUsers() throws Exception { IntegrationTestTools.setSilentConsole(false); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); recordDuration(TEST_NAME, (endMillis - startMillis)); @@ -313,7 +313,7 @@ public void test110RecomputeUsers() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); getRepoPerformanceMonitor().clearGlobalPerformanceInformation(); resetGlobalCachePerformanceCollector(); @@ -323,7 +323,7 @@ public void test110RecomputeUsers() throws Exception { waitForTaskFinish(TASK_RECOMPUTE_1_OID, true, RECOMPUTE_TASK_WAIT_TIMEOUT); // THEN - then(TEST_NAME); + then(); recordDuration(TEST_NAME,getRunDurationMillis(TASK_RECOMPUTE_1_OID)); @@ -357,7 +357,7 @@ public void test120RecomputeUsersNoRoleAndShadowCache() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); getRepoPerformanceMonitor().clearGlobalPerformanceInformation(); resetGlobalCachePerformanceCollector(); @@ -367,7 +367,7 @@ public void test120RecomputeUsersNoRoleAndShadowCache() throws Exception { waitForTaskFinish(TASK_RECOMPUTE_NO_CACHE_OID, true, RECOMPUTE_TASK_WAIT_TIMEOUT); // THEN - then(TEST_NAME); + then(); recordDuration(TEST_NAME,getRunDurationMillis(TASK_RECOMPUTE_NO_CACHE_OID)); @@ -401,7 +401,7 @@ public void test130RecomputeUsersMultinode() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); getRepoPerformanceMonitor().clearGlobalPerformanceInformation(); resetGlobalCachePerformanceCollector(); @@ -413,7 +413,7 @@ public void test130RecomputeUsersMultinode() throws Exception { IntegrationTestTools.setSilentConsole(false); // THEN - then(TEST_NAME); + then(); recordDuration(TEST_NAME, getTreeRunDurationMillis(TASK_RECOMPUTE_MULTINODE_OID)); @@ -449,7 +449,7 @@ public void test140RecomputeUsersMultinodeMultithreaded() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); getRepoPerformanceMonitor().clearGlobalPerformanceInformation(); resetGlobalCachePerformanceCollector(); @@ -461,7 +461,7 @@ public void test140RecomputeUsersMultinodeMultithreaded() throws Exception { IntegrationTestTools.setSilentConsole(false); // THEN - then(TEST_NAME); + then(); recordDuration(TEST_NAME, getTreeRunDurationMillis(TASK_RECOMPUTE_MULTINODE_MULTITHREADED_OID)); @@ -498,7 +498,7 @@ public void test200RecomputeUsersNoDefaultRoleCache() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); PrismObject newConfiguration = parseObject(SYSTEM_CONFIGURATION_NO_ROLE_CACHE_FILE); repositoryService.addObject(newConfiguration, RepoAddOptions.createOverwrite(), result); @@ -510,7 +510,7 @@ public void test200RecomputeUsersNoDefaultRoleCache() throws Exception { waitForTaskFinish(TASK_RECOMPUTE_4_OID, true, RECOMPUTE_TASK_WAIT_TIMEOUT); // THEN - then(TEST_NAME); + then(); recordDuration(TEST_NAME,getRunDurationMillis(TASK_RECOMPUTE_4_OID)); @@ -549,7 +549,7 @@ public void test900Summarize() throws Exception { display("Summary ("+NUMBER_OF_GENERATED_USERS+" users, "+NUMBER_OF_GENERATED_ROLES+" roles)", sb.toString()); // THEN - then(TEST_NAME); + then(); // TODO: more thresholds diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapComplex.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapComplex.java index fee50ac709c..da122427ed7 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapComplex.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapComplex.java @@ -204,11 +204,11 @@ public void test010Shadows() throws Exception { ObjectQuery query = ObjectQueryUtil.createResourceQuery(RESOURCE_OPENDJ_OID, prismContext); // WHEN - when(TEST_NAME); + when(); SearchResultList> shadows = repositoryService.searchObjects(ShadowType.class, query, null, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("Found shadows", shadows); @@ -225,11 +225,11 @@ public void test050AssignAccountOpenDjSimple() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_OPENDJ_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); accountJackOid = assertUserAfter(USER_JACK_OID) @@ -261,11 +261,11 @@ public void test055Shadows() throws Exception { display("Query", query); // WHEN - when(TEST_NAME); + when(); SearchResultList> shadows = repositoryService.searchObjects(ShadowType.class, query, null, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("Found shadows", shadows); @@ -279,11 +279,11 @@ public void test059UnassignAccountOpenDjSimple() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_OPENDJ_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -312,11 +312,11 @@ public void test100ModifyJackFullNameLang() throws Exception { newFullName.setLang(MiscUtil.paramsToMap(JACK_FULL_NAME_LANG_EN_SK)); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, newFullName); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -342,11 +342,11 @@ public void test110AssignAccountOpenDjLang() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_OPENDJ_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); accountJackOid = assertUserAfter(USER_JACK_OID) @@ -380,11 +380,11 @@ public void test112ModifyJackFullNameLangEnSkRuHr() throws Exception { newFullName.setLang(MiscUtil.paramsToMap(JACK_FULL_NAME_LANG_EN_SK_RU_HR)); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, newFullName); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -417,11 +417,11 @@ public void test114ModifyJackFullNameLangCzHr() throws Exception { newFullName.setLang(MiscUtil.paramsToMap(JACK_FULL_NAME_LANG_CZ_HR)); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, newFullName); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -454,11 +454,11 @@ public void test116ModifyJackFullNameLangCaptain() throws Exception { newFullName.setLang(MiscUtil.paramsToMap(JACK_FULL_NAME_LANG_CAPTAIN_EN_CZ_SK)); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, newFullName); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -489,11 +489,11 @@ public void test118ModifyJackFullNameCaptain() throws Exception { PolyString newFullName = new PolyString(USER_JACK_FULL_NAME_CAPTAIN); // WHEN - when(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, newFullName); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -519,11 +519,11 @@ public void test119UnassignAccountOpenDjLang() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_OPENDJ_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -556,11 +556,11 @@ public void test120ModifyJackTitleMap() throws Exception { .asObjectDelta(USER_JACK_OID); // WHEN - when(TEST_NAME); + when(); executeChanges(delta, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -586,11 +586,11 @@ public void test130AssignAccountOpenDjTitleMap() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_OPENDJ_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); accountJackOid = assertUserAfter(USER_JACK_OID) @@ -633,11 +633,11 @@ public void test132AssignAccountOpenDjTitleMapAdd() throws Exception { .asObjectDelta(USER_JACK_OID); // WHEN - when(TEST_NAME); + when(); executeChanges(delta, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); accountJackOid = assertUserAfter(USER_JACK_OID) @@ -680,11 +680,11 @@ public void test134AssignAccountOpenDjTitleMapDelete() throws Exception { .asObjectDelta(USER_JACK_OID); // WHEN - when(TEST_NAME); + when(); executeChanges(delta, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); accountJackOid = assertUserAfter(USER_JACK_OID) @@ -727,11 +727,11 @@ public void test138AssignAccountOpenDjTitleMapReplace() throws Exception { .asObjectDelta(USER_JACK_OID); // WHEN - when(TEST_NAME); + when(); executeChanges(delta, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); accountJackOid = assertUserAfter(USER_JACK_OID) @@ -763,11 +763,11 @@ public void test139UnassignAccountOpenDjTitleMap() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_OPENDJ_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -792,11 +792,11 @@ public void test150AssignAccountOpenDj() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_OPENDJ_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); accountJackOid = assertUserAfter(USER_JACK_OID) @@ -853,11 +853,11 @@ public void test152JackMultivalueDescriptionGet() throws Exception { .getOid(); // WHEN - when(TEST_NAME); + when(); PrismObject shadow = modelService.getObject(ShadowType.class, accountJackOid, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); PolyString descriptionShadowAttribute = (PolyString) assertShadow(shadow, "Jack's shadow after read") @@ -892,11 +892,11 @@ public void test300Shadows() throws Exception { ObjectQuery query = ObjectQueryUtil.createResourceQuery(RESOURCE_OPENDJ_OID, prismContext); // WHEN - when(TEST_NAME); + when(); SearchResultList> shadows = repositoryService.searchObjects(ShadowType.class, query, null, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("Found shadows", shadows); @@ -914,7 +914,7 @@ public void test310SearchLdapAccounts() throws Exception { ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, ShadowKindType.ACCOUNT, SchemaConstants.INTENT_DEFAULT, prismContext); // WHEN - when(TEST_NAME); + when(); searchObjectsIterative(ShadowType.class, query, o -> display("Found object", o), 4); } @@ -932,11 +932,11 @@ public void test312Shadows() throws Exception { ObjectQuery query = ObjectQueryUtil.createResourceQuery(RESOURCE_OPENDJ_OID, prismContext); // WHEN - when(TEST_NAME); + when(); SearchResultList> shadows = repositoryService.searchObjects(ShadowType.class, query, null, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("Found shadows", shadows); @@ -982,7 +982,7 @@ public void test320SearchLdapAccountsBelow() throws Exception { ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, ShadowKindType.ACCOUNT, SchemaConstants.INTENT_DEFAULT, prismContext); // WHEN - when(TEST_NAME); + when(); searchObjectsIterative(ShadowType.class, query, o -> display("Found object", o), 4); } @@ -998,7 +998,7 @@ public void test400SearchLdapProjectGroups() throws Exception { ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, ShadowKindType.ENTITLEMENT, INTENT_LDAP_PROJECT_GROUP, prismContext); // WHEN - when(TEST_NAME); + when(); // Group "pirates" already exists searchObjectsIterative(ShadowType.class, query, o -> display("Found object", o), 1); @@ -1015,7 +1015,7 @@ public void test401SearchLdapOrgGroups() throws Exception { ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, ShadowKindType.ENTITLEMENT, INTENT_LDAP_ORG_GROUP, prismContext); // WHEN - when(TEST_NAME); + when(); searchObjectsIterative(ShadowType.class, query, o -> display("Found object", o), 0); } @@ -1033,11 +1033,11 @@ public void test410CreateProjectKeelhaul() throws Exception { .targetRef(ORG_PROJECT_TOP_OID, OrgType.COMPLEX_TYPE); // WHEN - when(TEST_NAME); + when(); addObject(projectKeelhaul); // THEN - then(TEST_NAME); + then(); PrismObject orgKeelhaul = findObjectByName(OrgType.class, PROJECT_KEELHAUL_NAME); projectKeelhaulOid = orgKeelhaul.getOid(); groupKeelhaulOid = assertOrg(orgKeelhaul, "after") @@ -1062,11 +1062,11 @@ public void test412CreateProjectWalkThePlank() throws Exception { .targetRef(ORG_PROJECT_TOP_OID, OrgType.COMPLEX_TYPE); // WHEN - when(TEST_NAME); + when(); addObject(projectKeelhaul); // THEN - then(TEST_NAME); + then(); PrismObject orgWalkThePlank = findObjectByName(OrgType.class, PROJECT_WALK_THE_PLANK_NAME); projectWalkThePlankOid = orgWalkThePlank.getOid(); groupWalkThePlankOid = assertOrg(orgWalkThePlank, "after") @@ -1094,11 +1094,11 @@ public void test415CreateOrgRumDepartment() throws Exception { .targetRef(ORG_FUNCTIONAL_TOP_OID, OrgType.COMPLEX_TYPE); // WHEN - when(TEST_NAME); + when(); addObject(orgBefore); // THEN - then(TEST_NAME); + then(); PrismObject orgAfter = findObjectByName(OrgType.class, ORG_RUM_DEPARTMENT_NAME); orgRumDepartmentOid = orgAfter.getOid(); assertNotNull("Null org oid", orgRumDepartmentOid); @@ -1133,11 +1133,11 @@ public void test420AssignJackToKeelhaul() throws Exception { .getOid(); // WHEN - when(TEST_NAME); + when(); assignOrg(USER_JACK_OID, projectKeelhaulOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); openDJController.assertUniqueMembers("cn="+PROJECT_KEELHAUL_NAME+",ou=groups,dc=example,dc=com", "uid="+USER_JACK_USERNAME+",ou=people,dc=example,dc=com"); @@ -1173,11 +1173,11 @@ public void test422AssignJackToWalkThePlank() throws Exception { .getOid(); // WHEN - when(TEST_NAME); + when(); assignOrg(USER_JACK_OID, projectWalkThePlankOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); openDJController.assertUniqueMembers("cn="+PROJECT_KEELHAUL_NAME+",ou=groups,dc=example,dc=com", "uid="+USER_JACK_USERNAME+",ou=people,dc=example,dc=com"); @@ -1213,11 +1213,11 @@ public void test424AssignJackToRumDepartment() throws Exception { .getOid(); // WHEN - when(TEST_NAME); + when(); assignOrg(USER_JACK_OID, orgRumDepartmentOid, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); openDJController.assertUniqueMembers("cn="+PROJECT_KEELHAUL_NAME+",ou=groups,dc=example,dc=com", "uid="+USER_JACK_USERNAME+",ou=people,dc=example,dc=com"); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapDependency.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapDependency.java index 92dc00f4ef5..d9f3d2ad58f 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapDependency.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapDependency.java @@ -157,12 +157,12 @@ public void test100AddOrgIT() throws Exception { PrismObject orgBefore = createOrg(ORG_IT_NAME, ORG_TOP_OID); // WHEN - when(TEST_NAME); + when(); display("Adding org", orgBefore); addObject(orgBefore, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); dumpOrgTree(); @@ -184,12 +184,12 @@ public void test150AssignFunctionalRoleToITOrg() throws Exception { PrismObject orgBefore = getOrg(ORG_IT_NAME); // WHEN - when(TEST_NAME); + when(); display("orgBefore: ", orgBefore); assignRoleToOrg(orgItOid, ROLE_META_ORG_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); dumpOrgTree(); @@ -213,12 +213,12 @@ public void test170UnassignFunctionalRoleFromITOrg() throws Exception { PrismObject orgBefore = getOrg(ORG_IT_NAME); // WHEN - when(TEST_NAME); + when(); display("unassigning vip role org", orgBefore); unassignRoleFromOrg(orgItOid, ROLE_META_ORG_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); dumpOrgTree(); @@ -243,12 +243,12 @@ public void test200AddOrgHR() throws Exception { PrismObject orgBefore = createOrg(ORG_HR_NAME, ORG_TOP_OID); // WHEN - when(TEST_NAME); + when(); display("Adding org", orgBefore); addObject(orgBefore, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); dumpOrgTree(); @@ -270,13 +270,13 @@ public void test250AssignFunctionalAndVipRoleToHROrg() throws Exception { PrismObject orgBefore = getOrg(ORG_HR_NAME); // WHEN - when(TEST_NAME); + when(); display("orgBefore: ", orgBefore); assignRoleToOrg(orgHrOid, ROLE_META_ORG_OID, task, result); assignRoleToOrg(orgHrOid, ROLE_META_ORG_VIP_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); dumpOrgTree(); @@ -302,12 +302,12 @@ public void test270UnassignVipRoleFromHROrg() throws Exception { PrismObject orgBefore = getOrg(ORG_HR_NAME); // WHEN - when(TEST_NAME); + when(); display("unassigning vip role org", orgBefore); unassignRoleFromOrg(orgHrOid, ROLE_META_ORG_VIP_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); dumpOrgTree(); @@ -334,13 +334,13 @@ public void test280AssignVipAndSuperVipRoleToHROrg() throws Exception { PrismObject orgBefore = getOrg(ORG_HR_NAME); // WHEN - when(TEST_NAME); + when(); display("orgBefore: ", orgBefore); assignRoleToOrg(orgHrOid, ROLE_META_ORG_VIP_OID, task, result); assignRoleToOrg(orgHrOid, ROLE_META_ORG_SUPERVIP_OID, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); dumpOrgTree(); @@ -370,7 +370,7 @@ public void test290UnassignVipRoleFromHROrg() throws Exception { try { // WHEN - when(TEST_NAME); + when(); unassignRoleFromOrg(orgHrOid, ROLE_META_ORG_VIP_OID, task, result); assertNotReached(); @@ -380,7 +380,7 @@ public void test290UnassignVipRoleFromHROrg() throws Exception { } // THEN - then(TEST_NAME); + then(); assertFailure(result); dumpOrgTree(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapMutilated.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapMutilated.java index a49eb893d71..11b4c1649aa 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapMutilated.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapMutilated.java @@ -118,11 +118,11 @@ public void test010Shadows() throws Exception { ObjectQuery query = ObjectQueryUtil.createResourceQuery(RESOURCE_OPENDJ_OID, prismContext); // WHEN - when(TEST_NAME); + when(); SearchResultList> shadows = repositoryService.searchObjects(ShadowType.class, query, null, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("Found shadows", shadows); @@ -139,11 +139,11 @@ public void test100AssignAccountOpenDjSimple() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_OPENDJ_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); accountJackOid = assertUserAfter(USER_JACK_OID) @@ -173,11 +173,11 @@ public void test105Shadows() throws Exception { display("Query", query); // WHEN - when(TEST_NAME); + when(); SearchResultList> shadows = repositoryService.searchObjects(ShadowType.class, query, null, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("Found shadows", shadows); @@ -191,11 +191,11 @@ public void test109UnassignAccountOpenDjSimple() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_OPENDJ_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -224,11 +224,11 @@ public void test300Shadows() throws Exception { ObjectQuery query = ObjectQueryUtil.createResourceQuery(RESOURCE_OPENDJ_OID, prismContext); // WHEN - when(TEST_NAME); + when(); SearchResultList> shadows = repositoryService.searchObjects(ShadowType.class, query, null, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("Found shadows", shadows); @@ -246,7 +246,7 @@ public void test310SearchLdapAccounts() throws Exception { ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, ShadowKindType.ACCOUNT, SchemaConstants.INTENT_DEFAULT, prismContext); // WHEN - when(TEST_NAME); + when(); searchObjectsIterative(ShadowType.class, query, o -> display("Found object", o), 0); } @@ -263,11 +263,11 @@ public void test312Shadows() throws Exception { ObjectQuery query = ObjectQueryUtil.createResourceQuery(RESOURCE_OPENDJ_OID, prismContext); // WHEN - when(TEST_NAME); + when(); SearchResultList> shadows = repositoryService.searchObjects(ShadowType.class, query, null, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); display("Found shadows", shadows); @@ -296,11 +296,11 @@ public void test320AssignAccountOpenDj() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_OPENDJ_OID, null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); accountJackOid = assertUserAfter(USER_JACK_OID) @@ -326,7 +326,7 @@ public void test322SearchLdapAccounts() throws Exception { ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, ShadowKindType.ACCOUNT, SchemaConstants.INTENT_DEFAULT, prismContext); // WHEN - when(TEST_NAME); + when(); searchObjectsIterative(ShadowType.class, query, o -> display("Found object", o), 1); } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapReconPerformance.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapReconPerformance.java index f96c9536d51..2cd7a79ce71 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapReconPerformance.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapReconPerformance.java @@ -112,7 +112,7 @@ public void test010GenerateUsers() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - when(TEST_NAME); + when(); // Add objects using model, we also want to create LDAP accounts generateObjects(UserType.class, NUMBER_OF_GENERATED_USERS, GENERATED_USER_NAME_FORMAT, GENERATED_USER_OID_FORMAT, (user,i) -> { @@ -128,7 +128,7 @@ public void test010GenerateUsers() throws Exception { result); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); recordDuration(TEST_NAME, (endMillis - startMillis)); @@ -154,13 +154,13 @@ public void test100Reconcile1ThreadLdap0() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); addTask(TASK_RECON_1_OPENDJ_FILE); waitForTaskFinish(TASK_RECON_1_OPENDJ_OID, true, RECON_TASK_WAIT_TIMEOUT); // THEN - then(TEST_NAME); + then(); recordDuration(TEST_NAME,getRunDurationMillis(TASK_RECON_1_OPENDJ_OID)); @@ -197,13 +197,13 @@ public void test200ReconcileLdap0() throws Exception { OperationResult result = task.getResult(); // WHEN - when(TEST_NAME); + when(); addTask(TASK_RECON_4_OPENDJ_FILE); waitForTaskFinish(TASK_RECON_4_OPENDJ_OID, true, RECON_TASK_WAIT_TIMEOUT); // THEN - then(TEST_NAME); + then(); recordDuration(TEST_NAME,getRunDurationMillis(TASK_RECON_4_OPENDJ_OID)); @@ -278,13 +278,13 @@ private long testReconcileLdapRestartWhen(final String TEST_NAME, String taskOid rememberConnectorResourceCounters(); // WHEN - when(TEST_NAME); + when(); restartTask(taskOid); waitForTaskFinish(taskOid, true, RECON_TASK_WAIT_TIMEOUT); // THEN - then(TEST_NAME); + then(); long duration = recordDuration(TEST_NAME, getRunDurationMillis(taskOid)); @@ -312,7 +312,7 @@ public void test900Summarize() throws Exception { display("Summary ("+NUMBER_OF_GENERATED_USERS+" users)", sb.toString()); // THEN - then(TEST_NAME); + then(); if (reconDuration1ThreadBaseline < reconDuration4ThreadBaseline) { fail("Multi-thread recon SLOWER than single-thread! singlethread="+reconDuration1ThreadBaseline+"ms, multithread="+reconDuration4ThreadBaseline+"ms"); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapSyncMassive.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapSyncMassive.java index 5007adb0cc2..c76ac333cad 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapSyncMassive.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapSyncMassive.java @@ -21,7 +21,6 @@ import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.schema.SearchResultList; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.ObjectTypeUtil; @@ -47,7 +46,6 @@ public class TestLdapSyncMassive extends AbstractLdapTest { public static final File TEST_DIR = new File(LDAP_TEST_DIR, "sync-massive"); private static final String RESOURCE_OPENDJ_OID = "10000000-0000-0000-0000-000000000003"; - private static final String RESOURCE_OPENDJ_NAMESPACE = MidPointConstants.NS_RI; private static final File RESOURCE_OPENDJ_FILE_BAD = new File(TEST_DIR, "resource-opendj-bad.xml"); @@ -59,8 +57,6 @@ public class TestLdapSyncMassive extends AbstractLdapTest { private static final String ACCOUNT_WILL_LDAP_CN = "Will Turner"; private static final File ACCOUNT_KRAKEN_LDIF_FILE = new File(TEST_DIR, "kraken.ldif"); - private static final String ACCOUNT_KRAKEN_LDAP_UID = "kraken"; - private static final String ACCOUNT_KRAKEN_LDAP_CN = "Kraken Krakenoff"; private static final int THREAD_COUNT_TOLERANCE = 10; private static final int THREAD_COUNT_TOLERANCE_BIG = 20; @@ -80,7 +76,6 @@ public class TestLdapSyncMassive extends AbstractLdapTest { */ private static final int INSTANCES_MAX = 3; - private PrismObject resourceOpenDj; private Integer lastSyncToken; private int threadCountBaseline; @@ -112,7 +107,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti super.initSystem(initTask, initResult); // Resources - resourceOpenDj = importAndGetObjectFromFile(ResourceType.class, getResourceOpenDjFile(), RESOURCE_OPENDJ_OID, initTask, initResult); + PrismObject resourceOpenDj = importAndGetObjectFromFile(ResourceType.class, getResourceOpenDjFile(), RESOURCE_OPENDJ_OID, initTask, initResult); openDJController.setResource(resourceOpenDj); } @@ -133,12 +128,12 @@ public void test080ImportSyncTask() throws Exception { final String TEST_NAME = "test080ImportSyncTask"; // WHEN - when(TEST_NAME); + when(); importObjectFromFile(TASK_LIVE_SYNC_FILE); // THEN - then(TEST_NAME); + then(); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_OID, true); @@ -166,12 +161,12 @@ public void test110SyncAddWill() throws Exception { display("Entry from LDIF", entry); // WHEN - when(TEST_NAME); + when(); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_OID, true); // THEN - then(TEST_NAME); + then(); assertSyncTokenIncrement(1); @@ -204,14 +199,14 @@ public void test112SyncAddGoods() throws Exception { final String TEST_NAME = "test112SyncAddGoods"; // WHEN - when(TEST_NAME); + when(); for (int i = 0; i < SYNC_ADD_ATTEMPTS; i++) { syncAddAttemptGood("good", i); } // THEN - then(TEST_NAME); + then(); dumpLdap(); @@ -231,7 +226,7 @@ public void test150AddGoblins() throws Exception { final String TEST_NAME = "test150AddGoblins"; // WHEN - when(TEST_NAME); + when(); for (int i = 0; i < NUMBER_OF_GOBLINS; i++) { String username = goblinUsername(i); @@ -244,7 +239,7 @@ public void test150AddGoblins() throws Exception { } // THEN - then(TEST_NAME); + then(); dumpLdap(); assertLdapConnectorInstances(1, INSTANCES_MAX); @@ -303,12 +298,12 @@ public void test210SyncAddKraken() throws Exception { display("Entry from LDIF", entry); // WHEN - when(TEST_NAME); + when(); OperationResult taskResult = waitForTaskNextRun(TASK_LIVE_SYNC_OID); // THEN - then(TEST_NAME); + then(); assertPartialError(taskResult); assertSyncTokenIncrement(0); @@ -338,14 +333,14 @@ public void test212SyncAddBads() throws Exception { final String TEST_NAME = "test212SyncAddBads"; // WHEN - when(TEST_NAME); + when(); for (int i = 0; i < SYNC_ADD_ATTEMPTS; i++) { syncAddAttemptBad("bad", i); } // THEN - then(TEST_NAME); + then(); dumpLdap(); @@ -360,12 +355,12 @@ public void test219StopSyncTask() throws Exception { final String TEST_NAME = "test219StopSyncTask"; // WHEN - when(TEST_NAME); + when(); suspendTask(TASK_LIVE_SYNC_OID); // THEN - then(TEST_NAME); + then(); assertSyncTokenIncrement(0); assertLdapConnectorInstances(1, INSTANCES_MAX); @@ -383,14 +378,14 @@ public void test230UserRecomputeSequential() throws Exception { SearchResultList> users = modelService.searchObjects(UserType.class, null, null, task, result); // WHEN - when(TEST_NAME); + when(); for (PrismObject user : users) { reconcile(user); } // THEN - then(TEST_NAME); + then(); assertLdapConnectorInstances(1, INSTANCES_MAX); assertThreadCount(); @@ -406,7 +401,7 @@ public void test232UserRecomputeParallel() throws Exception { SearchResultList> users = modelService.searchObjects(UserType.class, null, null, task, result); // WHEN - when(TEST_NAME); + when(); int segmentSize = users.size() / NUMBER_OF_TEST_THREADS; ParallelTestThread[] threads = multithread( @@ -419,7 +414,7 @@ public void test232UserRecomputeParallel() throws Exception { }, NUMBER_OF_TEST_THREADS, TEST_THREADS_RANDOM_START_RANGE); // THEN - then(TEST_NAME); + then(); waitForThreads(threads, PARALLEL_TEST_TIMEOUT); // When system is put under load, this means more threads. But not huge number of threads. diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/hierarchy/AbstractLdapHierarchyTest.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/hierarchy/AbstractLdapHierarchyTest.java index e709f451cc9..7cc6a954121 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/hierarchy/AbstractLdapHierarchyTest.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/hierarchy/AbstractLdapHierarchyTest.java @@ -349,11 +349,11 @@ public void test310RenameUserGorc() throws Exception { USER_GORC_GIVEN_NAME, USER_GORC_FAMILY_NAME, orgCortuvHradOid); // WHEN - when(TEST_NAME); + when(); modifyObjectReplaceProperty(UserType.class, userGorcOid, UserType.F_NAME, task, result, new PolyString(USER_GORC_USERNAME2)); // THEN - then(TEST_NAME); + then(); assertSuccess(result); dumpOrgTree(); @@ -371,12 +371,12 @@ public void test320AddOrgRoyulaDiabolica() throws Exception { PrismObject orgBefore = createOrg(ORG_ROYULA_DIABOLICA_NAME, ORG_TOP_OID); // WHEN - when(TEST_NAME); + when(); display("Adding org", orgBefore); addObject(orgBefore, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); dumpOrgTree(); @@ -414,13 +414,13 @@ public void test322MoveOrgZblo() throws Exception { delta.addModificationAddContainer(OrgType.F_ASSIGNMENT, newAssignmentType); // WHEN - when(TEST_NAME); + when(); display("Modifying " + orgBefore + "with delta", delta); modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - then(TEST_NAME); + then(); assertSuccess(result); dumpOrgTree(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/AbstractNotoriousTest.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/AbstractNotoriousTest.java index 3a2fd84849e..12072fbb84f 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/AbstractNotoriousTest.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/AbstractNotoriousTest.java @@ -176,11 +176,11 @@ public void test100AssignRa0ToJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, generateRoleAOid(0), task, result); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -211,11 +211,11 @@ public void test102RecomputeJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -249,11 +249,11 @@ public void test104PreviewChangesJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - when(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -282,11 +282,11 @@ public void test109UnassignRa0FromJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, generateRoleAOid(0), task, result); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -315,11 +315,11 @@ public void test110Assign5ARolesToJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - when(TEST_NAME); + when(); assignJackARoles(5, task, result); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -347,11 +347,11 @@ public void test112RecomputeJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -379,11 +379,11 @@ public void test119Unassign5ARolesFromJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - when(TEST_NAME); + when(); unassignJackARoles(5, task, result); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -412,11 +412,11 @@ public void test120AssignAllARolesToJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - when(TEST_NAME); + when(); assignJackARoles(NUMBER_OF_LEVEL_A_ROLES, task, result); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -444,11 +444,11 @@ public void test122RecomputeJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -482,11 +482,11 @@ public void test124PreviewChangesJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - when(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -515,11 +515,11 @@ public void test129UnassignAllARolesFromJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - when(TEST_NAME); + when(); unassignJackARoles(NUMBER_OF_LEVEL_A_ROLES, task, result); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -549,11 +549,11 @@ public void test130AssignRb0ToJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, generateRoleBOid(0), task, result); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -591,11 +591,11 @@ public void test132AssignRa0ToJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, generateRoleAOid(0), task, result); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -626,11 +626,11 @@ public void test134RecomputeJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -661,11 +661,11 @@ public void test136UnassignRb0FromJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, generateRoleBOid(0), task, result); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -697,11 +697,11 @@ public void test138AssignRb0ToJackAgain() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - when(TEST_NAME); + when(); assignRole(USER_JACK_OID, generateRoleBOid(0), task, result); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -732,11 +732,11 @@ public void test140RecomputeJackAgain() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -767,11 +767,11 @@ public void test142RecomputeJackAlt() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -802,11 +802,11 @@ public void test144UnassignRa0FromJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, generateRoleAOid(0), task, result); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -838,11 +838,11 @@ public void test149UnassignRb0FromJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - when(TEST_NAME); + when(); unassignRole(USER_JACK_OID, generateRoleBOid(0), task, result); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -879,12 +879,12 @@ public void test150AssignNotoriousDefaultToJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - when(TEST_NAME); + when(); modifyAssignmentHolderAssignment(UserType.class, USER_JACK_OID, getNotoriousOid(), getNotoriousType(), null, task, null, null, true, result); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -921,12 +921,12 @@ public void test152AssignNotoriousAltRelationToJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - when(TEST_NAME); + when(); modifyAssignmentHolderAssignment(UserType.class, USER_JACK_OID, getNotoriousOid(), getNotoriousType(), getAltRelation(), task, null, null, true, result); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -964,11 +964,11 @@ public void test154RecomputeJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -1010,11 +1010,11 @@ public void test156RecomputeJackAlt() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - when(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -1052,12 +1052,12 @@ public void test158UnassignNotoriousDefaultFromJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - when(TEST_NAME); + when(); modifyAssignmentHolderAssignment(UserType.class, USER_JACK_OID, getNotoriousOid(), getNotoriousType(), null, task, null, null, false, result); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -1093,12 +1093,12 @@ public void test159UnassignNotoriousAltRelationFromJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - when(TEST_NAME); + when(); modifyAssignmentHolderAssignment(UserType.class, USER_JACK_OID, getNotoriousOid(), getNotoriousType(), getAltRelation(), task, null, null, false, result); // THEN - then(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestPrivacy.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestPrivacy.java index 93b6373a6d5..1d32777e2bd 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestPrivacy.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestPrivacy.java @@ -79,7 +79,7 @@ public void test100AutzJackReadSearch() throws Exception { login(USER_JACK_USERNAME); // WHEN - when(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_GUYBRUSH_OID); assertGetAllow(UserType.class, USER_ELAINE_OID); @@ -89,7 +89,7 @@ public void test100AutzJackReadSearch() throws Exception { USER_ADMINISTRATOR_OID, USER_GUYBRUSH_OID, USER_ELAINE_OID, USER_JACK_OID); // THEN - then(TEST_NAME); + then(); } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestRoleMembers.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestRoleMembers.java index 44f0e68ae1f..2667cb20ab3 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestRoleMembers.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestRoleMembers.java @@ -88,7 +88,7 @@ public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; // WHEN - when(TEST_NAME); + when(); assertUserBefore(USER_GUYBRUSH_OID) .assertName(USER_GUYBRUSH_USERNAME) @@ -124,7 +124,7 @@ public void test000Sanity() throws Exception { assertFalse("Preview evaluated assignment triple is empty", evaluatedAssignmentTriple.isEmpty()); // THEN - then(TEST_NAME); + then(); } @@ -138,7 +138,7 @@ public void test100AutzGuybrushNoMembers() throws Exception { login(USER_GUYBRUSH_USERNAME); // WHEN - when(TEST_NAME); + when(); PrismObject userMancomb = assertGetAllow(UserType.class, USER_MANCOMB_OID); assertUser(userMancomb, "mancomb") @@ -170,7 +170,7 @@ public void test100AutzGuybrushNoMembers() throws Exception { assertNull("Preview evaluated assignment triple sneaked in", evaluatedAssignmentTriple); // THEN - then(TEST_NAME); + then(); } @@ -198,7 +198,7 @@ public void test105AutzElaineMembers() throws Exception { login(USER_ELAINE_USERNAME); // WHEN - when(TEST_NAME); + when(); PrismObject userMancomb = assertGetAllow(UserType.class, USER_MANCOMB_OID); assertUser(userMancomb, "mancomb") @@ -218,7 +218,7 @@ public void test105AutzElaineMembers() throws Exception { .assertRoleMemberhipRefs(1); // THEN - then(TEST_NAME); + then(); } From 46a8c068967c6a29f34e8de526b0f6b7a351a9d8 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Mon, 2 Mar 2020 11:20:17 +0100 Subject: [PATCH 81/97] Make lightweight ID generator more robust We tolerate clock leaping back for 10 seconds. Hopefully it's enough. --- .../LightweightIdentifierGeneratorImpl.java | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/LightweightIdentifierGeneratorImpl.java b/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/LightweightIdentifierGeneratorImpl.java index 20fae37f7ad..9723e3cb00a 100644 --- a/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/LightweightIdentifierGeneratorImpl.java +++ b/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/LightweightIdentifierGeneratorImpl.java @@ -19,9 +19,11 @@ @Service public class LightweightIdentifierGeneratorImpl implements LightweightIdentifierGenerator { - long lastTimestamp; - int lastSequence; - int hostIdentifier; + private static final long BACKWARD_TIME_ALLOWANCE = 10 * 1000L; + + private long lastTimestamp; // monotonic increasing sequence + private int lastSequence; // incremented by 1, occasionally reset to 0 + private int hostIdentifier; // currently unused public LightweightIdentifierGeneratorImpl() { lastTimestamp = 0; @@ -29,22 +31,22 @@ public LightweightIdentifierGeneratorImpl() { hostIdentifier = 0; } - /* (non-Javadoc) - * @see com.evolveum.midpoint.task.api.LightweightIdentifierGenerator#generate() - */ @Override public synchronized LightweightIdentifier generate() { long timestamp = System.currentTimeMillis(); - if (timestamp == lastTimestamp) { - // Nothing to do - } else if (timestamp > lastTimestamp) { - // reset the last timestamp and sequence conunter + if (timestamp > lastTimestamp) { + // update the last timestamp and reset sequence counter lastTimestamp = timestamp; lastSequence = 0; + } else if (timestamp < lastTimestamp - BACKWARD_TIME_ALLOWANCE) { + throw new IllegalStateException("The time has moved back more than " + BACKWARD_TIME_ALLOWANCE + + " milliseconds, possible consistency violation. Current time = " + timestamp + ", last time = " + + lastTimestamp + ", difference is " + (lastTimestamp - timestamp) + "."); } else { - throw new IllegalStateException("The time has moved back, possible consistency violation"); + // Usually timestamp == lastTimestamp here. But even if the time moved back a few seconds we stay calm + // and simply keep lastTimestamp unchanged. We will probably get a few identifiers with increasing sequence + // numbers and nothing wrong will happen. } return new LightweightIdentifier(timestamp, hostIdentifier, ++lastSequence); } - } From df26e924ae88888de8cabe9c33b68429427cf2e4 Mon Sep 17 00:00:00 2001 From: kate Date: Mon, 2 Mar 2020 12:34:26 +0100 Subject: [PATCH 82/97] page title fix (MID-4984) --- .../midpoint/web/page/admin/PageAdminObjectDetails.java | 4 ++++ .../web/page/admin/resources/PageResourceWizard.java | 2 +- .../evolveum/midpoint/web/page/self/PageOrgSelfProfile.java | 6 ++++++ .../midpoint/web/page/self/PageRoleSelfProfile.java | 6 ++++++ .../midpoint/web/page/self/PageServiceSelfProfile.java | 6 ++++++ .../midpoint/web/page/self/PageUserSelfProfile.java | 6 ++++++ 6 files changed, 29 insertions(+), 1 deletion(-) diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/PageAdminObjectDetails.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/PageAdminObjectDetails.java index f5f5b26f744..7ce9022c6fd 100755 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/PageAdminObjectDetails.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/PageAdminObjectDetails.java @@ -27,6 +27,7 @@ import com.evolveum.midpoint.web.component.prism.ValueStatus; import com.evolveum.midpoint.web.component.util.SelectableBean; import com.evolveum.midpoint.web.component.util.VisibleBehaviour; +import com.evolveum.midpoint.web.page.admin.configuration.PageSystemConfiguration; import com.evolveum.midpoint.web.page.admin.server.OperationalButtonsPanel; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; @@ -149,6 +150,9 @@ protected void onTimer(AjaxRequestTarget target) { @Override protected IModel createPageTitleModel() { + if (PageAdminObjectDetails.this instanceof PageSystemConfiguration){ + return super.createPageTitleModel(); + } String simpleName = getObjectSimpleName(); String lokalizedSimpleName = new StringResourceModel("ObjectType." + simpleName).setDefaultValue(simpleName).getString(); if (isAdd()) { diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/PageResourceWizard.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/PageResourceWizard.java index bfe400afc8e..9aeaa55a20e 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/PageResourceWizard.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/PageResourceWizard.java @@ -161,7 +161,7 @@ protected IModel createPageTitleModel() { @Override protected String load() { if (editedResourceOid == null) { - return PageResourceWizard.super.createPageTitleModel().getObject(); + return createStringResource("PageResourceWizard.title").getString(); } String name = WebComponentUtil.getName(modelRaw.getObject()); return createStringResource("PageResourceWizard.title.edit", name).getString(); diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/self/PageOrgSelfProfile.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/self/PageOrgSelfProfile.java index f4119684d30..0b179a5c8ea 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/self/PageOrgSelfProfile.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/self/PageOrgSelfProfile.java @@ -10,6 +10,7 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; +import org.apache.wicket.model.IModel; import org.apache.wicket.model.Model; import org.apache.wicket.request.mapper.parameter.PageParameters; @@ -61,6 +62,11 @@ protected boolean isSelfProfile(){ return true; } + @Override + protected IModel createPageTitleModel() { + return createStringResource("PageAdmin.menu.profile"); + } + @Override protected void createBreadcrumb() { super.createBreadcrumb(); diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/self/PageRoleSelfProfile.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/self/PageRoleSelfProfile.java index 196144a632b..28cf1dfc1a2 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/self/PageRoleSelfProfile.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/self/PageRoleSelfProfile.java @@ -12,6 +12,7 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; +import org.apache.wicket.model.IModel; import org.apache.wicket.model.Model; import org.apache.wicket.request.mapper.parameter.PageParameters; @@ -65,6 +66,11 @@ protected boolean isSelfProfile(){ return true; } + @Override + protected IModel createPageTitleModel() { + return createStringResource("PageAdmin.menu.profile"); + } + @Override protected void createBreadcrumb() { super.createBreadcrumb(); diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/self/PageServiceSelfProfile.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/self/PageServiceSelfProfile.java index 35a7511657c..9ffabf6b0cc 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/self/PageServiceSelfProfile.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/self/PageServiceSelfProfile.java @@ -10,6 +10,7 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.ServiceType; +import org.apache.wicket.model.IModel; import org.apache.wicket.model.Model; import org.apache.wicket.request.mapper.parameter.PageParameters; @@ -63,6 +64,11 @@ protected boolean isSelfProfile(){ return true; } + @Override + protected IModel createPageTitleModel() { + return createStringResource("PageAdmin.menu.profile"); + } + @Override protected void createBreadcrumb() { super.createBreadcrumb(); diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/self/PageUserSelfProfile.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/self/PageUserSelfProfile.java index 5c2a2cd9f47..616af5d3479 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/self/PageUserSelfProfile.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/self/PageUserSelfProfile.java @@ -8,6 +8,7 @@ import com.evolveum.midpoint.gui.api.GuiStyleConstants; +import org.apache.wicket.model.IModel; import org.apache.wicket.model.Model; import org.apache.wicket.request.mapper.parameter.PageParameters; @@ -65,6 +66,11 @@ protected String getObjectOidParameter() { } + @Override + protected IModel createPageTitleModel() { + return createStringResource("PageAdmin.menu.profile"); + } + @Override protected boolean isSelfProfile(){ return true; From c87d0a09a817c39ca4f66a8f8ee8e1e0d33e31b8 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Mon, 2 Mar 2020 13:01:58 +0100 Subject: [PATCH 83/97] UnitTestMixin: added getTestName(ITestResult) + footer prints test name --- .../midpoint/tools/testng/AbstractUnitTest.java | 2 +- .../midpoint/tools/testng/UnitTestMixin.java | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/AbstractUnitTest.java b/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/AbstractUnitTest.java index 3c87709dba1..6e54b72cfdb 100644 --- a/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/AbstractUnitTest.java +++ b/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/AbstractUnitTest.java @@ -49,7 +49,7 @@ public Logger logger() { public String contextName() { ITestResult context = TEST_CONTEXT_THREAD_LOCAL.get(); return context != null - ? getClass().getSimpleName() + "." + context.getMethod().getMethodName() + ? getTestName(context) : getClass().getSimpleName(); } diff --git a/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/UnitTestMixin.java b/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/UnitTestMixin.java index 6a045eedb17..f542cdb2aaa 100644 --- a/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/UnitTestMixin.java +++ b/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/UnitTestMixin.java @@ -36,6 +36,15 @@ public interface UnitTestMixin { */ @NotNull String contextName(); + /** + * Returns test name (as "class-simple-name.method") from {@link ITestResult}. + */ + @NotNull + default String getTestName(ITestResult context) { + return context.getTestClass().getRealClass().getSimpleName() + + "." + context.getMethod().getMethodName(); + } + /** * Returns short test name - typically just a method name (without class). * See also {@link #contextName()} if class name is required. @@ -55,8 +64,9 @@ default void displayTestTitle(String testName) { default void displayDefaultTestFooter(ITestResult testResult) { long testMsDuration = testResult.getEndMillis() - testResult.getStartMillis(); - System.out.println(TEST_OUT_FOOTER_PREFIX + " FINISHED in " + testMsDuration + " ms" + TEST_OUT_FOOTER_SUFFIX); - logger().info(TEST_LOG_PREFIX + " FINISHED in " + testMsDuration + " ms" + TEST_LOG_SUFFIX); + String testName = getTestName(testResult); + System.out.println(TEST_OUT_FOOTER_PREFIX + testName + " FINISHED in " + testMsDuration + " ms" + TEST_OUT_FOOTER_SUFFIX); + logger().info(TEST_LOG_PREFIX + testName + " FINISHED in " + testMsDuration + " ms" + TEST_LOG_SUFFIX); } /** From a6bb6adaca080818743c477377d6fe790192a1eb Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Mon, 2 Mar 2020 13:04:08 +0100 Subject: [PATCH 84/97] more prism-impl tests extend from AbstractPrismTest (+AbstractUnitTest) --- .../midpoint/prism/AbstractPrismTest.java | 4 +- .../com/evolveum/midpoint/prism/TestDiff.java | 28 ++-- .../midpoint/prism/TestExtraSchema.java | 34 ++--- .../com/evolveum/midpoint/prism/TestFind.java | 36 ++--- .../midpoint/prism/TestFundamentals.java | 31 +---- .../com/evolveum/midpoint/prism/TestPath.java | 56 +++----- .../midpoint/prism/TestPerformance.java | 4 +- .../midpoint/prism/TestPrismContext.java | 84 ++---------- .../prism/TestPrismObjectConstruction.java | 119 ++++------------- .../midpoint/prism/TestPrismParsing.java | 90 ++++--------- .../midpoint/prism/TestPrismParsingXml.java | 11 +- .../prism/TestPrismSchemaConstruction.java | 44 +++--- .../midpoint/prism/TestPropertyArrayList.java | 31 ++--- .../midpoint/prism/TestTypeConversion.java | 21 ++- .../midpoint/prism/TestUnknownItems.java | 31 ++--- .../midpoint/prism/TestXmlSerialization.java | 11 +- .../prism/lex/TestProtectedString.java | 10 +- .../prism/match/TestMatchingRule.java | 34 ++--- .../midpoint/prism/query/TestObjectQuery.java | 52 +++----- .../prism/query/TestQueryBuilder.java | 126 ++++++++---------- .../prism/query/TestQueryConverters.java | 52 +++----- 21 files changed, 280 insertions(+), 629 deletions(-) diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/AbstractPrismTest.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/AbstractPrismTest.java index f827e59b2ba..7ddcaf24f5a 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/AbstractPrismTest.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/AbstractPrismTest.java @@ -45,7 +45,7 @@ public class AbstractPrismTest extends AbstractUnitTest { protected static final long ASSIGNMENT_ABRAKADABRA_ID = 222L; @BeforeSuite - public void setupDebug() throws SchemaException, SAXException, IOException { + public void initPrismContext() throws SchemaException, SAXException, IOException { PrettyPrinter.setDefaultNamespacePrefix(DEFAULT_NAMESPACE_PREFIX); PrismTestUtil.resetPrismContext(new PrismInternalTestUtil()); } @@ -70,7 +70,7 @@ protected PolyString createPolyString(String orig) { return PrismTestUtil.createPolyString(orig); } - protected PrismContext getPrismContext() { + protected static PrismContext getPrismContext() { return PrismTestUtil.getPrismContext(); } diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestDiff.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestDiff.java index 96fd23d3838..15832e98ca6 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestDiff.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestDiff.java @@ -6,40 +6,30 @@ */ package com.evolveum.midpoint.prism; -import static org.testng.AssertJUnit.assertNull; -import static com.evolveum.midpoint.prism.PrismInternalTestUtil.*; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; +import static org.testng.AssertJUnit.*; + +import static com.evolveum.midpoint.prism.PrismInternalTestUtil.USER_JACK_OID; -import java.io.IOException; import java.util.Collection; -import com.evolveum.midpoint.prism.delta.*; -import com.evolveum.midpoint.prism.path.ItemPath; -import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; -import org.xml.sax.SAXException; +import com.evolveum.midpoint.prism.delta.ItemDelta; +import com.evolveum.midpoint.prism.delta.ItemDeltaCollectionsUtil; +import com.evolveum.midpoint.prism.delta.ObjectDelta; +import com.evolveum.midpoint.prism.delta.PropertyDelta; import com.evolveum.midpoint.prism.foo.AssignmentType; import com.evolveum.midpoint.prism.foo.UserType; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.util.DebugUtil; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; /** * @author semancik */ -public class TestDiff extends AbstractUnitTest { - - @BeforeSuite - public void setupDebug() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(DEFAULT_NAMESPACE_PREFIX); - PrismTestUtil.resetPrismContext(new PrismInternalTestUtil()); - } +public class TestDiff extends AbstractPrismTest { @Test public void testUserSimplePropertyDiffNoChange() throws Exception { diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestExtraSchema.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestExtraSchema.java index 4162831196c..495dada9c76 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestExtraSchema.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestExtraSchema.java @@ -7,44 +7,38 @@ package com.evolveum.midpoint.prism; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNull; -import static com.evolveum.midpoint.prism.PrismInternalTestUtil.*; +import static org.testng.AssertJUnit.*; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; +import static com.evolveum.midpoint.prism.PrismInternalTestUtil.*; import java.io.File; import java.io.IOException; import java.util.List; - import javax.xml.namespace.QName; import javax.xml.transform.dom.DOMResult; import javax.xml.transform.dom.DOMSource; import javax.xml.validation.Schema; import javax.xml.validation.Validator; -import com.evolveum.midpoint.prism.path.ItemName; -import com.evolveum.midpoint.prism.impl.schema.SchemaRegistryImpl; import org.testng.annotations.Test; import org.w3c.dom.Document; import org.xml.sax.SAXException; import com.evolveum.midpoint.prism.foo.UserType; +import com.evolveum.midpoint.prism.impl.schema.SchemaRegistryImpl; +import com.evolveum.midpoint.prism.path.ItemName; import com.evolveum.midpoint.prism.schema.PrismSchema; import com.evolveum.midpoint.prism.util.PrismAsserts; -import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; -public class TestExtraSchema extends AbstractUnitTest { +public class TestExtraSchema extends AbstractPrismTest { public static final String NS_USER_2_EXT = "http://example.com/xml/ns/user-2-extension"; - private static final ItemName USER_EXTENSION_TYPE_QNAME = new ItemName(NS_USER_EXT,"UserExtensionType"); - private static final ItemName USER_2_EXTENSION_TYPE_QNAME = new ItemName(NS_USER_2_EXT,"User2ExtensionType"); + private static final ItemName USER_EXTENSION_TYPE_QNAME = new ItemName(NS_USER_EXT, "UserExtensionType"); + private static final ItemName USER_2_EXTENSION_TYPE_QNAME = new ItemName(NS_USER_2_EXT, "User2ExtensionType"); private static final ItemName USER_EXT_2_ELEMENT = new ItemName(NS_USER_2_EXT, "ext2"); @@ -66,7 +60,7 @@ public void testExtraSchema() throws SAXException, IOException, SchemaException Validator validator = javaxSchema.newValidator(); DOMResult validationResult = new DOMResult(); - validator.validate(new DOMSource(dataDoc),validationResult); + validator.validate(new DOMSource(dataDoc), validationResult); } /** @@ -121,7 +115,7 @@ public void testUserExtensionSchemaParseUser() throws SAXException, IOException, assertNotNull(javaxSchema); Validator validator = javaxSchema.newValidator(); DOMResult validationResult = new DOMResult(); - validator.validate(new DOMSource(dataDoc),validationResult); + validator.validate(new DOMSource(dataDoc), validationResult); } @Test @@ -152,9 +146,9 @@ private void assertUserDefinition(PrismObjectDefinition userDef) { System.out.println(extDef.debugDump()); assertTrue("Extension is not dynamic", extDef.isRuntimeSchema()); - assertTrue("Wrong extension type "+extDef.getTypeName(), + assertTrue("Wrong extension type " + extDef.getTypeName(), USER_EXTENSION_TYPE_QNAME.equals(extDef.getTypeName()) || USER_2_EXTENSION_TYPE_QNAME.equals(extDef.getTypeName())); - assertEquals("Wrong extension displayOrder", (Integer)1000, extDef.getDisplayOrder()); + assertEquals("Wrong extension displayOrder", (Integer) 1000, extDef.getDisplayOrder()); PrismPropertyDefinition barPropDef = extDef.findPropertyDefinition(USER_EXT_BAR_ELEMENT); assertNotNull("No 'bar' definition in user extension", barPropDef); @@ -186,8 +180,8 @@ private void assertUserDefinition(PrismObjectDefinition userDef) { } private void assertDefinitionOrder(List definitions, QName elementName, int i) { - assertEquals("Wrong definition, expected that "+PrettyPrinter.prettyPrint(elementName)+" definition will be at index " + - i + " but there was a "+definitions.get(i).getItemName()+" instead", elementName, definitions.get(i).getItemName()); + assertEquals("Wrong definition, expected that " + PrettyPrinter.prettyPrint(elementName) + " definition will be at index " + + i + " but there was a " + definitions.get(i).getItemName() + " instead", elementName, definitions.get(i).getItemName()); } /** @@ -205,7 +199,7 @@ public void testTypeOverride() throws SAXException, IOException, SchemaException System.out.println("Parsed root schema:"); System.out.println(schema.debugDump()); - PrismContainerDefinition rootContDef = schema.findContainerDefinitionByElementName(new QName(NS_ROOT,"root")); + PrismContainerDefinition rootContDef = schema.findContainerDefinitionByElementName(new QName(NS_ROOT, "root")); assertNotNull("Not definition", rootContDef); PrismContainerDefinition extensionContDef = rootContDef.findContainerDefinition(new ItemName(NS_FOO, "extension")); assertNotNull("Not definition", extensionContDef); diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestFind.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestFind.java index 40e4d330273..a9001b4fe5e 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestFind.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestFind.java @@ -13,9 +13,7 @@ import java.io.IOException; -import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; -import org.xml.sax.SAXException; import com.evolveum.midpoint.prism.foo.AccountConstructionType; import com.evolveum.midpoint.prism.foo.AssignmentType; @@ -23,23 +21,15 @@ import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.tools.testng.AbstractUnitTest; -import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; /** * @author semancik */ -public class TestFind extends AbstractUnitTest { - - @BeforeSuite - public void setupDebug() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(DEFAULT_NAMESPACE_PREFIX); - PrismTestUtil.resetPrismContext(new PrismInternalTestUtil()); - } +public class TestFind extends AbstractPrismTest { @Test - public void testFindString() throws SchemaException, SAXException, IOException { + public void testFindString() throws SchemaException, IOException { // GIVEN PrismObject user = createUser(); ItemPath path = UserType.F_DESCRIPTION; @@ -53,7 +43,7 @@ public void testFindString() throws SchemaException, SAXException, IOException { } @Test - public void testFindPolyString() throws SchemaException, SAXException, IOException { + public void testFindPolyString() throws SchemaException, IOException { // GIVEN PrismObject user = createUser(); ItemPath path = UserType.F_POLY_NAME; @@ -67,7 +57,7 @@ public void testFindPolyString() throws SchemaException, SAXException, IOExcepti } @Test - public void testFindPolyStringOrig() throws SchemaException, SAXException, IOException { + public void testFindPolyStringOrig() throws SchemaException, IOException { // GIVEN ItemPath path = ItemPath.create(UserType.F_POLY_NAME, PolyString.F_ORIG); @@ -79,7 +69,7 @@ public void testFindPolyStringOrig() throws SchemaException, SAXException, IOExc } @Test - public void testFindPolyStringNorm() throws SchemaException, SAXException, IOException { + public void testFindPolyStringNorm() throws SchemaException, IOException { // GIVEN ItemPath path = ItemPath.create(UserType.F_POLY_NAME, PolyString.F_NORM); @@ -91,7 +81,7 @@ public void testFindPolyStringNorm() throws SchemaException, SAXException, IOExc } @Test - public void testFindExtensionBar() throws SchemaException, SAXException, IOException { + public void testFindExtensionBar() throws SchemaException, IOException { // GIVEN ItemPath path = ItemPath.create(UserType.F_EXTENSION, EXTENSION_BAR_ELEMENT); @@ -103,7 +93,7 @@ public void testFindExtensionBar() throws SchemaException, SAXException, IOExcep } @Test - public void testFindAssignment1Description() throws SchemaException, SAXException, IOException { + public void testFindAssignment1Description() throws SchemaException, IOException { // GIVEN ItemPath path = ItemPath.create(UserType.F_ASSIGNMENT, USER_ASSIGNMENT_1_ID, AssignmentType.F_DESCRIPTION); @@ -115,7 +105,7 @@ public void testFindAssignment1Description() throws SchemaException, SAXExceptio } @Test - public void testFindAssignment2Construction() throws SchemaException, SAXException, IOException { + public void testFindAssignment2Construction() throws SchemaException, IOException { // GIVEN ItemPath path = ItemPath.create(UserType.F_ASSIGNMENT, USER_ASSIGNMENT_2_ID, AssignmentType.F_ACCOUNT_CONSTRUCTION); @@ -127,7 +117,7 @@ public void testFindAssignment2Construction() throws SchemaException, SAXExcepti } @Test - public void testFindAssignment() throws SchemaException, SAXException, IOException { + public void testFindAssignment() throws SchemaException, IOException { // GIVEN ItemPath path = UserType.F_ASSIGNMENT; @@ -139,7 +129,7 @@ public void testFindAssignment() throws SchemaException, SAXException, IOExcepti assertEquals("Wrong value2 description (path=" + path + ")", "Assignment 2", value2.findProperty(AssignmentType.F_DESCRIPTION).getRealValue()); } - private T findUser(ItemPath path) throws SchemaException, SAXException, IOException { + private T findUser(ItemPath path) throws SchemaException, IOException { PrismObject user = createUser(); return find(user, path); } @@ -157,7 +147,7 @@ private T find(PrismObject user, ItemPath path) { return (T) found; } - private PrismProperty findUserProperty(ItemPath path) throws SchemaException, SAXException, IOException { + private PrismProperty findUserProperty(ItemPath path) throws SchemaException, IOException { PrismObject user = createUser(); return findProperty(user, path); } @@ -175,7 +165,7 @@ private PrismProperty findProperty(PrismObject user, ItemPath p return property; } - private PrismContainer findUserContainer(ItemPath path) throws SchemaException, SAXException, IOException { + private PrismContainer findUserContainer(ItemPath path) throws SchemaException, IOException { PrismObject user = createUser(); return findContainer(user, path); } @@ -193,7 +183,7 @@ private PrismContainer findContainer(PrismObject createUser() throws SchemaException, SAXException, IOException { + public PrismObject createUser() throws SchemaException, IOException { return PrismTestUtil.parseObject(USER_JACK_FILE_XML); } diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestFundamentals.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestFundamentals.java index 54b5e605bfe..fecaf227235 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestFundamentals.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestFundamentals.java @@ -6,41 +6,26 @@ */ package com.evolveum.midpoint.prism; -import static com.evolveum.midpoint.prism.PrismInternalTestUtil.*; import static org.testng.AssertJUnit.assertEquals; -import java.io.IOException; import java.util.ArrayList; import java.util.Collection; +import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.impl.PrismPropertyValueImpl; -import com.evolveum.midpoint.prism.impl.xnode.MapXNodeImpl; -import com.evolveum.prism.xml.ns._public.types_3.RawType; -import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; -import org.xml.sax.SAXException; +import com.evolveum.midpoint.prism.impl.PrismPropertyValueImpl; +import com.evolveum.midpoint.prism.impl.xnode.MapXNodeImpl; import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; - -import javax.xml.namespace.QName; +import com.evolveum.prism.xml.ns._public.types_3.RawType; /** * @author Radovan Semancik - * */ -public class TestFundamentals { - - @BeforeSuite - public void setupDebug() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(DEFAULT_NAMESPACE_PREFIX); - PrismTestUtil.resetPrismContext(new PrismInternalTestUtil()); - } +public class TestFundamentals extends AbstractPrismTest { @Test - public void testPrismValueContainsRealValue() throws Exception { - System.out.println("\n\n===[ testPrismValueContainsRealValue ]===\n"); + public void testPrismValueContainsRealValue() { // GIVEN PrismPropertyValue valFoo1 = new PrismPropertyValueImpl<>("foo"); PrismPropertyValue valBar1 = new PrismPropertyValueImpl<>("bar"); @@ -70,8 +55,7 @@ public void testPrismValueContainsRealValue() throws Exception { } @Test - public void testRawTypeClone() throws Exception { - System.out.println("\n\n===[ testRawTypeClone ]===\n"); + public void testRawTypeClone() { // GIVEN QName typeQName = new QName("abcdef"); MapXNodeImpl mapXNode = new MapXNodeImpl(); @@ -84,5 +68,4 @@ public void testRawTypeClone() throws Exception { // THEN assertEquals("Wrong or missing type QName", typeQName, rawTypeClone.getXnode().getTypeQName()); } - } diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPath.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPath.java index dcee348b8f3..27e8abb6530 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPath.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPath.java @@ -6,39 +6,28 @@ */ package com.evolveum.midpoint.prism; -import static com.evolveum.midpoint.prism.PrismInternalTestUtil.*; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.*; -import java.io.IOException; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.function.Function; - import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.path.*; -import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; -import org.xml.sax.SAXException; -import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; +import com.evolveum.midpoint.prism.path.*; /** * @author semancik - * */ -public class TestPath { +public class TestPath extends AbstractPrismTest { private static final String NS = "http://example.com/"; private static Map> creators = new HashMap<>(); + static { creators.put('C', seq -> getPrismContext().path(seq)); creators.put('S', ItemPath::create); @@ -46,16 +35,8 @@ public class TestPath { creators.put('R', seq -> creators.get("CSN".charAt((int) (Math.random() * 3))).apply(seq)); } - @BeforeSuite - public void setupDebug() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(DEFAULT_NAMESPACE_PREFIX); - PrismTestUtil.resetPrismContext(new PrismInternalTestUtil()); - } - @Test public void testPathNormalize() { - System.out.println("\n\n===[ testPathNormalize ]===\n"); - PrismContext prismContext = getPrismContext(); // GIVEN @@ -131,8 +112,6 @@ public void testPathCompareHalf2() { } private void testPathCompare(String source) { - System.out.println("\n\n===[ testPathCompare (" + source + ") ]===\n"); - // GIVEN // /foo @@ -239,9 +218,7 @@ private ItemPath create(String source, int index, Object... components) { } @Test - public void testPathRemainder() throws Exception { - System.out.println("\n\n===[ testPathRemainder ]===\n"); - + public void testPathRemainder() { PrismContext prismContext = getPrismContext(); // GIVEN @@ -251,7 +228,7 @@ public void testPathRemainder() throws Exception { UniformItemPath pathFoo123 = prismContext.path(new QName(NS, "foo"), 123L); UniformItemPath pathFooBar = prismContext.path(new QName(NS, "foo"), new QName(NS, "bar")); UniformItemPath pathFooNullBar = prismContext.path(new QName(NS, "foo"), null, - new QName(NS, "bar")); + new QName(NS, "bar")); // WHEN UniformItemPath remainder1 = pathFooBar.remainder(pathFooNull); @@ -261,20 +238,20 @@ public void testPathRemainder() throws Exception { } private void assertNormalizedPath(UniformItemPath normalized, Object... expected) { - assertEquals("wrong path length",normalized.size(), expected.length); - for(int i=0; i> map, Class clazz, QName typeName) { - assertEquals("Wrong xsdType->class mapping for "+typeName, clazz, map.get(typeName)); - } - @Test public void testBasicSchemas() throws SchemaException, SAXException, IOException { - System.out.println("===[ testBasicSchemas ]==="); - // WHEN PrismContext prismContext = constructInitializedPrismContext(); @@ -100,7 +84,7 @@ public void testBasicSchemas() throws SchemaException, SAXException, IOException System.out.println(fooSchema.debugDump()); // Assert USER definition - PrismObjectDefinition userDefinition = fooSchema.findObjectDefinitionByElementName(new QName(NS_FOO,"user")); + PrismObjectDefinition userDefinition = fooSchema.findObjectDefinitionByElementName(new QName(NS_FOO, "user")); assertNotNull("No user definition", userDefinition); System.out.println("User definition:"); System.out.println(userDefinition.debugDump()); @@ -111,7 +95,7 @@ public void testBasicSchemas() throws SchemaException, SAXException, IOException assertUserDefinition(userDefinition); // Assert ACCOUNT definition - PrismObjectDefinition accountDefinition = fooSchema.findObjectDefinitionByElementName(new QName(NS_FOO,"account")); + PrismObjectDefinition accountDefinition = fooSchema.findObjectDefinitionByElementName(new QName(NS_FOO, "account")); assertNotNull("No account definition", accountDefinition); System.out.println("Account definition:"); System.out.println(accountDefinition.debugDump()); @@ -186,8 +170,6 @@ private void assertAccountDefinition(PrismObjectDefinition accountD @Test public void testExtensionSchema() throws SchemaException, SAXException, IOException { - System.out.println("===[ testExtensionSchema ]==="); - // GIVEN PrismContext prismContext = constructInitializedPrismContext(); assertNotNull("No prism context", prismContext); @@ -196,19 +178,19 @@ public void testExtensionSchema() throws SchemaException, SAXException, IOExcept PrismPropertyDefinition ignoredTypeDef = schemaRegistry.findPropertyDefinitionByElementName(EXTENSION_IGNORED_TYPE_ELEMENT); PrismAsserts.assertDefinition(ignoredTypeDef, EXTENSION_IGNORED_TYPE_ELEMENT, DOMUtil.XSD_STRING, 0, -1); - assertTrue("Element "+EXTENSION_IGNORED_TYPE_ELEMENT+" is NOT ignored", ignoredTypeDef.isIgnored()); + assertTrue("Element " + EXTENSION_IGNORED_TYPE_ELEMENT + " is NOT ignored", ignoredTypeDef.isIgnored()); PrismPropertyDefinition stringTypeDef = schemaRegistry.findPropertyDefinitionByElementName(EXTENSION_STRING_TYPE_ELEMENT); PrismAsserts.assertDefinition(stringTypeDef, EXTENSION_STRING_TYPE_ELEMENT, DOMUtil.XSD_STRING, 0, -1); - assertFalse("Element "+EXTENSION_STRING_TYPE_ELEMENT+" is ignored", stringTypeDef.isIgnored()); + assertFalse("Element " + EXTENSION_STRING_TYPE_ELEMENT + " is ignored", stringTypeDef.isIgnored()); PrismPropertyDefinition singleStringTypeDef = schemaRegistry.findPropertyDefinitionByElementName(EXTENSION_SINGLE_STRING_TYPE_ELEMENT); PrismAsserts.assertDefinition(singleStringTypeDef, EXTENSION_SINGLE_STRING_TYPE_ELEMENT, DOMUtil.XSD_STRING, 0, 1); - assertFalse("Element "+EXTENSION_SINGLE_STRING_TYPE_ELEMENT+" is ignored", singleStringTypeDef.isIgnored()); + assertFalse("Element " + EXTENSION_SINGLE_STRING_TYPE_ELEMENT + " is ignored", singleStringTypeDef.isIgnored()); PrismPropertyDefinition intTypeDef = schemaRegistry.findPropertyDefinitionByElementName(EXTENSION_INT_TYPE_ELEMENT); PrismAsserts.assertDefinition(intTypeDef, EXTENSION_INT_TYPE_ELEMENT, DOMUtil.XSD_INT, 0, -1); - assertFalse("Element "+EXTENSION_INT_TYPE_ELEMENT+" is ignored", intTypeDef.isIgnored()); + assertFalse("Element " + EXTENSION_INT_TYPE_ELEMENT + " is ignored", intTypeDef.isIgnored()); PrismContainerDefinition meleeContextDefinition = schemaRegistry.findContainerDefinitionByElementName(EXTENSION_MELEE_CONTEXT_ELEMENT); PrismAsserts.assertDefinition(meleeContextDefinition, EXTENSION_MELEE_CONTEXT_ELEMENT, EXTENSION_MELEE_CONTEXT_TYPE_QNAME, 0, 1); @@ -219,8 +201,6 @@ public void testExtensionSchema() throws SchemaException, SAXException, IOExcept @Test public void testSchemaToDom() throws SchemaException, SAXException, IOException { - System.out.println("===[ testSchemaToDom ]==="); - // GIVEN PrismContext prismContext = constructInitializedPrismContext(); PrismSchema fooSchema = prismContext.getSchemaRegistry().findSchemaByNamespace(NS_FOO); @@ -231,48 +211,4 @@ public void testSchemaToDom() throws SchemaException, SAXException, IOException // THEN assertNotNull("No foo XSD DOM", fooXsd); } - - // This is not supposed to work with foo schema. It container ObjectReferenceType which does - // not survive roundtrip -// @Test -// public void testSchemaParsingRoundTrip() throws SchemaException, SAXException, IOException { -// System.out.println("===[ testSchemaParsingRoundTrip ]==="); -// -// // GIVEN -// PrismContext prismContext = constructInitializedPrismContext(); -// PrismSchema fooSchema = prismContext.getSchemaRegistry().findSchemaByNamespace(NS_FOO); -// -// // WHEN -// Document fooXsd = fooSchema.serializeToXsd(); -// -// // THEN -// assertNotNull("No foo XSD DOM", fooXsd); -// System.out.println("Serialized schema"); -// System.out.println(DOMUtil.serializeDOMToString(fooXsd)); -// -// // WHEN -// PrismSchema parsedSchema = PrismSchema.parse(DOMUtil.getFirstChildElement(fooXsd), prismContext); -// -// // THEN -// assertNotNull("No parsed schema", parsedSchema); -// System.out.println("Parsed schema"); -// System.out.println(parsedSchema.dump()); -// -// // Assert USER definition -// PrismObjectDefinition userDefinition = parsedSchema.findObjectDefinitionByElementName(new QName(NS_FOO,"user")); -// assertNotNull("No user definition", userDefinition); -// System.out.println("User definition:"); -// System.out.println(userDefinition.dump()); -// -// assertUserDefinition(userDefinition); -// -// // Assert ACCOUNT definition -// PrismObjectDefinition accountDefinition = parsedSchema.findObjectDefinitionByElementName(new QName(NS_FOO,"account")); -// assertNotNull("No account definition", accountDefinition); -// System.out.println("Account definition:"); -// System.out.println(accountDefinition.dump()); -// -// assertAccountDefinition(accountDefinition); -// } - } diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismObjectConstruction.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismObjectConstruction.java index f681b3c29c8..8e518c8cae4 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismObjectConstruction.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismObjectConstruction.java @@ -6,23 +6,18 @@ */ package com.evolveum.midpoint.prism; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertTrue; + import static com.evolveum.midpoint.prism.PrismInternalTestUtil.*; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; -import static org.testng.AssertJUnit.assertTrue; -import static org.testng.AssertJUnit.assertEquals; import java.io.IOException; import java.util.List; - import javax.xml.namespace.QName; import javax.xml.transform.dom.DOMSource; import javax.xml.validation.Schema; import javax.xml.validation.Validator; -import com.evolveum.midpoint.prism.impl.PrismContainerImpl; -import com.evolveum.midpoint.prism.impl.PrismObjectImpl; -import com.evolveum.midpoint.prism.impl.PrismReferenceValueImpl; -import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; import org.w3c.dom.Document; import org.xml.sax.SAXException; @@ -30,27 +25,21 @@ import com.evolveum.midpoint.prism.foo.ActivationType; import com.evolveum.midpoint.prism.foo.AssignmentType; import com.evolveum.midpoint.prism.foo.UserType; +import com.evolveum.midpoint.prism.impl.PrismContainerImpl; +import com.evolveum.midpoint.prism.impl.PrismReferenceValueImpl; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; /** * @author semancik - * */ -public class TestPrismObjectConstruction { +public class TestPrismObjectConstruction extends AbstractPrismTest { private static final String USER_OID = "1234567890"; private static final String ACCOUNT1_OID = "11100000111"; private static final String ACCOUNT2_OID = "11100000222"; - - @BeforeSuite - public void setupDebug() { - PrettyPrinter.setDefaultNamespacePrefix(DEFAULT_NAMESPACE_PREFIX); - } - /** * Construct object with schema. Starts by instantiating a definition and working downwards. * All the items in the object should have proper definition. @@ -58,8 +47,8 @@ public void setupDebug() { @Test public void testConstructionWithSchema() throws Exception { // GIVEN - PrismContext ctx = constructInitializedPrismContext(); - PrismObjectDefinition userDefinition = getFooSchema(ctx).findObjectDefinitionByElementName(new QName(NS_FOO,"user")); + PrismContext ctx = getPrismContext(); + PrismObjectDefinition userDefinition = getFooSchema(ctx).findObjectDefinitionByElementName(new QName(NS_FOO, "user")); // WHEN PrismObject user = userDefinition.instantiate(); @@ -73,64 +62,11 @@ public void testConstructionWithSchema() throws Exception { assertUserDrake(user, true, ctx); } - /** - * Construct object without schema. Starts by creating object "out of the blue" and - * the working downwards. - */ - @Test(enabled = false) // definition-less containers are no longer supported - public void testDefinitionlessConstruction() throws Exception { - // GIVEN - // No context needed - - // WHEN - PrismObject user = new PrismObjectImpl<>(USER_QNAME, UserType.class); - // Fill-in object values, no schema checking - fillInUserDrake(user, false); - - // THEN - System.out.println("User:"); - System.out.println(user.debugDump()); - // Check if the values are correct, no schema checking - PrismContext ctx = constructInitializedPrismContext(); - assertUserDrake(user, false, ctx); - } - - /** - * Construct object without schema. Starts by creating object "out of the blue" and - * the working downwards. Then apply the schema. Check definitions. - */ -// @Test - public void testDefinitionlessConstructionAndSchemaApplication() throws Exception { - // GIVEN - // No context needed (yet) - PrismObject user = new PrismObjectImpl<>(USER_QNAME, UserType.class); - // Fill-in object values, no schema checking - fillInUserDrake(user, false); - // Make sure the object is OK - PrismContext ctx = constructInitializedPrismContext(); - assertUserDrake(user, false, ctx); - - - PrismObjectDefinition userDefinition = - getFooSchema(ctx).findObjectDefinitionByElementName(new QName(NS_FOO,"user")); - - // WHEN - user.applyDefinition(userDefinition); - - // THEN - System.out.println("User:"); - System.out.println(user.debugDump()); - - // Check schema now - assertUserDrake(user, true, ctx); - - } - @Test public void testClone() throws Exception { // GIVEN - PrismContext ctx = constructInitializedPrismContext(); - PrismObjectDefinition userDefinition = getFooSchema(ctx).findObjectDefinitionByElementName(new QName(NS_FOO,"user")); + PrismContext ctx = getPrismContext(); + PrismObjectDefinition userDefinition = getFooSchema(ctx).findObjectDefinitionByElementName(new QName(NS_FOO, "user")); PrismObject user = userDefinition.instantiate(); fillInUserDrake(user, true); // precondition @@ -149,8 +85,8 @@ public void testClone() throws Exception { @Test public void testCloneEquals() throws Exception { // GIVEN - PrismContext ctx = constructInitializedPrismContext(); - PrismObjectDefinition userDefinition = getFooSchema(ctx).findObjectDefinitionByElementName(new QName(NS_FOO,"user")); + PrismContext ctx = getPrismContext(); + PrismObjectDefinition userDefinition = getFooSchema(ctx).findObjectDefinitionByElementName(new QName(NS_FOO, "user")); PrismObject user = userDefinition.instantiate(); fillInUserDrake(user, true); PrismObject clone = user.clone(); @@ -160,7 +96,6 @@ public void testCloneEquals() throws Exception { assertTrue("Clone not equivalent", clone.equivalent(user)); } - private void fillInUserDrake(PrismObject user, boolean assertDefinitions) throws SchemaException { user.setOid(USER_OID); @@ -168,7 +103,7 @@ private void fillInUserDrake(PrismObject user, boolean assertDefinitio PrismProperty fullNameProperty = user.findOrCreateProperty(USER_FULLNAME_QNAME); assertEquals(USER_FULLNAME_QNAME, fullNameProperty.getElementName()); PrismAsserts.assertParentConsistency(user); - if (assertDefinitions) PrismAsserts.assertDefinition(fullNameProperty, DOMUtil.XSD_STRING, 1, 1); + if (assertDefinitions) { PrismAsserts.assertDefinition(fullNameProperty, DOMUtil.XSD_STRING, 1, 1); } fullNameProperty.setRealValue("Sir Fancis Drake"); PrismProperty fullNamePropertyAgain = user.findOrCreateProperty(USER_FULLNAME_QNAME); // The "==" is there by purpose. We really want to make sure that is the same *instance*, that is was not created again @@ -178,7 +113,7 @@ private void fillInUserDrake(PrismObject user, boolean assertDefinitio PrismContainer activationContainer = user.findOrCreateContainer(USER_ACTIVATION_QNAME); assertEquals(USER_ACTIVATION_QNAME, activationContainer.getElementName()); PrismAsserts.assertParentConsistency(user); - if (assertDefinitions) PrismAsserts.assertDefinition(activationContainer, ACTIVATION_TYPE_QNAME, 0, 1); + if (assertDefinitions) { PrismAsserts.assertDefinition(activationContainer, ACTIVATION_TYPE_QNAME, 0, 1); } PrismContainer activationContainerAgain = user.findOrCreateContainer(USER_ACTIVATION_QNAME); // The "==" is there by purpose. We really want to make sure that is the same *instance*, that is was not created again assertTrue("Property not the same", activationContainer == activationContainerAgain); @@ -187,7 +122,7 @@ private void fillInUserDrake(PrismObject user, boolean assertDefinitio PrismProperty enabledProperty = user.findOrCreateProperty(USER_ENABLED_PATH); assertEquals(USER_ENABLED_QNAME, enabledProperty.getElementName()); PrismAsserts.assertParentConsistency(user); - if (assertDefinitions) PrismAsserts.assertDefinition(enabledProperty, DOMUtil.XSD_BOOLEAN, 0, 1); + if (assertDefinitions) { PrismAsserts.assertDefinition(enabledProperty, DOMUtil.XSD_BOOLEAN, 0, 1); } enabledProperty.setRealValue(true); PrismProperty enabledPropertyAgain = activationContainer.findOrCreateProperty(USER_ENABLED_QNAME); // The "==" is there by purpose. We really want to make sure that is the same *instance*, that is was not created again @@ -198,7 +133,7 @@ private void fillInUserDrake(PrismObject user, boolean assertDefinitio PrismContainer assignmentContainer = user.getValue().findOrCreateContainer(USER_ASSIGNMENT_QNAME); assertEquals(USER_ASSIGNMENT_QNAME, assignmentContainer.getElementName()); PrismAsserts.assertParentConsistency(user); - if (assertDefinitions) PrismAsserts.assertDefinition(assignmentContainer, ASSIGNMENT_TYPE_QNAME, 0, -1); + if (assertDefinitions) { PrismAsserts.assertDefinition(assignmentContainer, ASSIGNMENT_TYPE_QNAME, 0, -1); } PrismContainer assignmentContainerAgain = user.findOrCreateContainer(USER_ASSIGNMENT_QNAME); // The "==" is there by purpose. We really want to make sure that is the same *instance*, that is was not created again assertTrue("Property not the same", assignmentContainer == assignmentContainerAgain); @@ -231,7 +166,7 @@ private void fillInUserDrake(PrismObject user, boolean assertDefinitio // accountRef PrismReference accountRef = user.findOrCreateReference(USER_ACCOUNTREF_QNAME); assertEquals(USER_ACCOUNTREF_QNAME, accountRef.getElementName()); - if (assertDefinitions) PrismAsserts.assertDefinition(accountRef, OBJECT_REFERENCE_TYPE_QNAME, 0, -1); + if (assertDefinitions) { PrismAsserts.assertDefinition(accountRef, OBJECT_REFERENCE_TYPE_QNAME, 0, -1); } accountRef.add(new PrismReferenceValueImpl(ACCOUNT1_OID)); accountRef.add(new PrismReferenceValueImpl(ACCOUNT2_OID)); PrismReference accountRefAgain = user.findOrCreateReference(USER_ACCOUNTREF_QNAME); @@ -244,7 +179,7 @@ private void fillInUserDrake(PrismObject user, boolean assertDefinitio PrismContainer extensionContainer = user.findOrCreateContainer(USER_EXTENSION_QNAME); assertEquals(USER_EXTENSION_QNAME, extensionContainer.getElementName()); PrismAsserts.assertParentConsistency(user); - if (assertDefinitions) PrismAsserts.assertDefinition(extensionContainer, DOMUtil.XSD_ANY, 0, 1); + if (assertDefinitions) { PrismAsserts.assertDefinition(extensionContainer, DOMUtil.XSD_ANY, 0, 1); } PrismContainer extensionContainerAgain = user.findOrCreateContainer(USER_EXTENSION_QNAME); // The "==" is there by purpose. We really want to make sure that is the same *instance*, that is was not created again assertTrue("Extension not the same", extensionContainer == extensionContainerAgain); @@ -254,7 +189,7 @@ private void fillInUserDrake(PrismObject user, boolean assertDefinitio PrismProperty stringTypeProperty = extensionContainer.findOrCreateProperty(EXTENSION_STRING_TYPE_ELEMENT); assertEquals(EXTENSION_STRING_TYPE_ELEMENT, stringTypeProperty.getElementName()); PrismAsserts.assertParentConsistency(user); - if (assertDefinitions) PrismAsserts.assertDefinition(stringTypeProperty, DOMUtil.XSD_STRING, 0, -1); + if (assertDefinitions) { PrismAsserts.assertDefinition(stringTypeProperty, DOMUtil.XSD_STRING, 0, -1); } // TODO @@ -274,42 +209,42 @@ private void assertUserDrake(PrismObject user, boolean assertDefinitio private void assertUserDrakeContent(PrismObject user, boolean assertDefinitions) { // fullName PrismProperty fullNameProperty = user.findProperty(USER_FULLNAME_QNAME); - if (assertDefinitions) PrismAsserts.assertDefinition(fullNameProperty, DOMUtil.XSD_STRING, 1, 1); + if (assertDefinitions) { PrismAsserts.assertDefinition(fullNameProperty, DOMUtil.XSD_STRING, 1, 1); } assertEquals("Wrong fullname", "Sir Fancis Drake", fullNameProperty.getValue().getValue()); // activation PrismContainer activationContainer = user.findContainer(USER_ACTIVATION_QNAME); assertEquals(USER_ACTIVATION_QNAME, activationContainer.getElementName()); - if (assertDefinitions) PrismAsserts.assertDefinition(activationContainer, ACTIVATION_TYPE_QNAME, 0, 1); + if (assertDefinitions) { PrismAsserts.assertDefinition(activationContainer, ACTIVATION_TYPE_QNAME, 0, 1); } // activation/enabled PrismProperty enabledProperty = user.findProperty(USER_ENABLED_PATH); assertEquals(USER_ENABLED_QNAME, enabledProperty.getElementName()); - if (assertDefinitions) PrismAsserts.assertDefinition(enabledProperty, DOMUtil.XSD_BOOLEAN, 0, 1); + if (assertDefinitions) { PrismAsserts.assertDefinition(enabledProperty, DOMUtil.XSD_BOOLEAN, 0, 1); } assertEquals("Wrong enabled", true, enabledProperty.getValue().getValue()); // assignment PrismContainer assignmentContainer = user.findContainer(USER_ASSIGNMENT_QNAME); assertEquals(USER_ASSIGNMENT_QNAME, assignmentContainer.getElementName()); - if (assertDefinitions) PrismAsserts.assertDefinition(assignmentContainer, ASSIGNMENT_TYPE_QNAME, 0, -1); + if (assertDefinitions) { PrismAsserts.assertDefinition(assignmentContainer, ASSIGNMENT_TYPE_QNAME, 0, -1); } // assignment values List assValues = assignmentContainer.getValues(); assertEquals("Wrong number of assignment values", 3, assValues.size()); // assignment values: blue PrismContainerValue assBlueValue = assValues.get(0); PrismProperty assBlueDescriptionProperty = assBlueValue.findProperty(USER_DESCRIPTION_QNAME); - if (assertDefinitions) PrismAsserts.assertDefinition(assBlueDescriptionProperty, DOMUtil.XSD_STRING, 0, 1); + if (assertDefinitions) { PrismAsserts.assertDefinition(assBlueDescriptionProperty, DOMUtil.XSD_STRING, 0, 1); } assertEquals("Wrong blue assignment description", "Assignment created out of the blue", assBlueDescriptionProperty.getValue().getValue()); // assignment values: cyan PrismContainerValue assCyanValue = assValues.get(1); PrismProperty assCyanDescriptionProperty = assCyanValue.findProperty(USER_DESCRIPTION_QNAME); - if (assertDefinitions) PrismAsserts.assertDefinition(assCyanDescriptionProperty, DOMUtil.XSD_STRING, 0, 1); + if (assertDefinitions) { PrismAsserts.assertDefinition(assCyanDescriptionProperty, DOMUtil.XSD_STRING, 0, 1); } assertEquals("Wrong cyan assignment description", "Assignment created out of the cyan", assCyanDescriptionProperty.getValue().getValue()); // assignment values: red PrismContainerValue assRedValue = assValues.get(2); PrismProperty assRedDescriptionProperty = assRedValue.findProperty(USER_DESCRIPTION_QNAME); - if (assertDefinitions) PrismAsserts.assertDefinition(assRedDescriptionProperty, DOMUtil.XSD_STRING, 0, 1); + if (assertDefinitions) { PrismAsserts.assertDefinition(assRedDescriptionProperty, DOMUtil.XSD_STRING, 0, 1); } assertEquals("Wrong red assignment description", "Assignment created out of the red", assRedDescriptionProperty.getValue().getValue()); // accountRef PrismReference accountRef = user.findReference(USER_ACCOUNTREF_QNAME); - if (assertDefinitions) PrismAsserts.assertDefinition(accountRef, OBJECT_REFERENCE_TYPE_QNAME, 0, -1); + if (assertDefinitions) { PrismAsserts.assertDefinition(accountRef, OBJECT_REFERENCE_TYPE_QNAME, 0, -1); } PrismAsserts.assertReferenceValue(accountRef, ACCOUNT1_OID); PrismAsserts.assertReferenceValue(accountRef, ACCOUNT2_OID); assertEquals("accountRef size", 2, accountRef.getValues().size()); diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismParsing.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismParsing.java index a1abf46fbec..b94e3878088 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismParsing.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismParsing.java @@ -6,11 +6,9 @@ */ package com.evolveum.midpoint.prism; +import static org.testng.AssertJUnit.*; + import static com.evolveum.midpoint.prism.PrismInternalTestUtil.*; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertTrue; import java.io.File; import java.io.IOException; @@ -20,33 +18,29 @@ import java.util.HashSet; import java.util.Set; import java.util.stream.Collectors; - import javax.xml.datatype.Duration; import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.foo.AccountType; -import com.evolveum.midpoint.prism.impl.PrismReferenceValueImpl; -import com.evolveum.midpoint.prism.path.ItemName; -import com.evolveum.midpoint.prism.path.ItemPath; -import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; import org.xml.sax.SAXException; import com.evolveum.midpoint.prism.delta.DiffUtil; import com.evolveum.midpoint.prism.delta.ObjectDelta; +import com.evolveum.midpoint.prism.foo.AccountType; import com.evolveum.midpoint.prism.foo.UserType; +import com.evolveum.midpoint.prism.impl.PrismReferenceValueImpl; +import com.evolveum.midpoint.prism.path.ItemName; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.xml.XmlTypeConverter; import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; /** * @author semancik - * */ -public abstract class TestPrismParsing { +public abstract class TestPrismParsing extends AbstractPrismTest { protected abstract String getSubdirName(); @@ -57,12 +51,7 @@ protected File getCommonSubdir() { } protected File getFile(String baseName) { - return new File(getCommonSubdir(), baseName+"."+getFilenameSuffix()); - } - - @BeforeSuite - public void setupDebug() { - PrettyPrinter.setDefaultNamespacePrefix(DEFAULT_NAMESPACE_PREFIX); + return new File(getCommonSubdir(), baseName + "." + getFilenameSuffix()); } protected abstract String getOutputFormat(); @@ -70,7 +59,7 @@ public void setupDebug() { @Test public void test100PrismParseFile() throws Exception { // GIVEN - PrismContext prismContext = constructInitializedPrismContext(); + PrismContext prismContext = getPrismContext(); // WHEN PrismObject user = prismContext.parseObject(getFile(USER_JACK_FILE_BASENAME)); @@ -86,7 +75,7 @@ public void test100PrismParseFile() throws Exception { @Test public void test110PrismParseFileNoNs() throws Exception { // GIVEN - PrismContext prismContext = constructInitializedPrismContext(); + PrismContext prismContext = getPrismContext(); // WHEN PrismObject user = prismContext.parseObject(getFile(USER_JACK_NO_NS_BASENAME)); @@ -102,7 +91,7 @@ public void test110PrismParseFileNoNs() throws Exception { @Test public void test120PrismParseFileObject() throws Exception { // GIVEN - PrismContext prismContext = constructInitializedPrismContext(); + PrismContext prismContext = getPrismContext(); // WHEN PrismObject user = prismContext.parseObject(getFile(USER_JACK_OBJECT_BASENAME)); @@ -118,7 +107,7 @@ public void test120PrismParseFileObject() throws Exception { @Test public void test130PrismParseFileAdhoc() throws Exception { // GIVEN - PrismContext prismContext = constructInitializedPrismContext(); + PrismContext prismContext = getPrismContext(); // WHEN PrismObject user = prismContext.parseObject(getFile(USER_JACK_ADHOC_BASENAME)); @@ -149,7 +138,7 @@ public void test220RoundTripObject() throws Exception { private void roundTrip(File file, boolean expectFullPolyName, boolean withIncomplete) throws SchemaException, SAXException, IOException { // GIVEN - PrismContext prismContext = constructInitializedPrismContext(); + PrismContext prismContext = getPrismContext(); PrismObject originalUser = prismContext.parseObject(file); System.out.println("Input parsed user:"); @@ -168,8 +157,6 @@ private void roundTrip(File file, boolean expectFullPolyName, boolean withIncomp System.out.println(userXml); assertNotNull(userXml); - validateXml(userXml, prismContext); - // WHEN PrismObject parsedUser = prismContext.parseObject(userXml); System.out.println("Re-parsed user:"); @@ -182,20 +169,19 @@ private void roundTrip(File file, boolean expectFullPolyName, boolean withIncomp System.out.println("Diff:"); System.out.println(diff.debugDump()); - assertTrue("Diff: "+diff, diff.isEmpty()); + assertTrue("Diff: " + diff, diff.isEmpty()); - assertTrue("Users not equal", originalUser.equals(parsedUser)); + assertEquals("Users not equal", parsedUser, originalUser); } - @Test public void test230RoundTripAdhoc() throws Exception { roundTripAdhoc(getFile(USER_JACK_ADHOC_BASENAME)); } - private void roundTripAdhoc(File file) throws SchemaException, SAXException, IOException { + private void roundTripAdhoc(File file) throws SchemaException, IOException { // GIVEN - PrismContext prismContext = constructInitializedPrismContext(); + PrismContext prismContext = getPrismContext(); PrismObject originalUser = prismContext.parseObject(file); System.out.println("Input parsed user:"); @@ -214,8 +200,6 @@ private void roundTripAdhoc(File file) throws SchemaException, SAXException, IOE System.out.println(userXml); assertNotNull(userXml); - validateXml(userXml, prismContext); - // WHEN PrismObject parsedUser = prismContext.parseObject(userXml); System.out.println("Re-parsed user:"); @@ -227,11 +211,10 @@ private void roundTripAdhoc(File file) throws SchemaException, SAXException, IOE assertTrue("Users not equal", originalUser.equals(parsedUser)); } - @Test public void test300MeleeContext() throws Exception { // GIVEN - PrismContext prismContext = constructInitializedPrismContext(); + PrismContext prismContext = getPrismContext(); PrismObject userJack = prismContext.parseObject(getFile(USER_JACK_FILE_BASENAME)); PrismContainer meleeContextContainer = userJack.findOrCreateContainer(ItemPath.create(UserType.F_EXTENSION, EXTENSION_MELEE_CONTEXT_ELEMENT)); @@ -274,7 +257,7 @@ public void test300MeleeContext() throws Exception { // Make the original user jack suitable for comparison. // Some of the accountRef information is (intentionally) lost in re-parsing therefore erase it before comparing PrismReference jackAccountRef = userJack.findReference(UserType.F_ACCOUNT_REF); - for (PrismReferenceValue accRefVal: jackAccountRef.getValues()) { + for (PrismReferenceValue accRefVal : jackAccountRef.getValues()) { String oid = accRefVal.getOid(); QName targetType = accRefVal.getTargetType(); accRefVal.setObject(null); @@ -289,7 +272,7 @@ public void test300MeleeContext() throws Exception { @Test public void test400UserWill() throws Exception { // GIVEN - PrismContext prismContext = constructInitializedPrismContext(); + PrismContext prismContext = getPrismContext(); // WHEN PrismObject user = prismContext.parseObject(getFile(USER_WILL_FILE_BASENAME)); @@ -305,7 +288,7 @@ public void test400UserWill() throws Exception { @Test public void test410UserWillRoundTrip() throws Exception { // GIVEN - PrismContext prismContext = constructInitializedPrismContext(); + PrismContext prismContext = getPrismContext(); // WHEN PrismObject user = prismContext.parseObject(getFile(USER_WILL_FILE_BASENAME)); @@ -340,7 +323,7 @@ public void test410UserWillRoundTrip() throws Exception { @Test public void test500UserElisabethRoundTrip() throws Exception { // GIVEN - PrismContext prismContext = constructInitializedPrismContext(); + PrismContext prismContext = getPrismContext(); // WHEN PrismObject user = prismContext.parseObject(getFile(USER_ELISABETH_FILE_BASENAME)); @@ -376,7 +359,7 @@ public void test500UserElisabethRoundTrip() throws Exception { @Test public void test600AccountBarbossa() throws Exception { // GIVEN - PrismContext prismContext = constructInitializedPrismContext(); + PrismContext prismContext = getPrismContext(); // WHEN PrismObject account = prismContext.parseObject(getFile(ACCOUNT_BARBOSSA_FILE_BASENAME)); @@ -399,7 +382,6 @@ public void test600AccountBarbossa() throws Exception { )), names); } - protected void assertUserAdhoc(PrismObject user, boolean expectRawInConstructions, boolean withIncomplete) throws SchemaException { user.checkConsistence(); assertUserJackContent(user, expectRawInConstructions, true, withIncomplete); @@ -407,7 +389,6 @@ protected void assertUserAdhoc(PrismObject user, boolean expectRawInCo assertVisitor(user, 58); } - private void assertUserExtensionAdhoc(PrismObject user) { PrismContainer extension = user.getExtension(); @@ -417,9 +398,9 @@ private void assertUserExtensionAdhoc(PrismObject user) { assertNull("Extension ID", extensionValue.getId()); PrismAsserts.assertPropertyValue(extension, USER_ADHOC_BOTTLES_ELEMENT, 20); - ItemPath bottlesPath = ItemPath.create(new QName(NS_FOO,"extension"), USER_ADHOC_BOTTLES_ELEMENT); + ItemPath bottlesPath = ItemPath.create(new QName(NS_FOO, "extension"), USER_ADHOC_BOTTLES_ELEMENT); PrismProperty bottlesProperty = user.findProperty(bottlesPath); - assertNotNull("Property "+bottlesPath+" not found", bottlesProperty); + assertNotNull("Property " + bottlesPath + " not found", bottlesProperty); PrismAsserts.assertPropertyValue(bottlesProperty, 20); PrismPropertyDefinition bottlesPropertyDef = bottlesProperty.getDefinition(); assertNotNull("No definition for bottles", bottlesPropertyDef); @@ -511,9 +492,9 @@ private void assertUserWillExtension(PrismObject user) { PrismAsserts.assertDefinition(indexedStringPropertyDef, EXTENSION_SINGLE_STRING_TYPE_ELEMENT, DOMUtil.XSD_STRING, 0, -1); assertEquals("'Indexed' attribute on 'singleStringType' property is wrong", Boolean.FALSE, indexedStringPropertyDef.isIndexed()); - ItemPath barPath = ItemPath.create(new QName(NS_FOO,"extension"), EXTENSION_BAR_ELEMENT); + ItemPath barPath = ItemPath.create(new QName(NS_FOO, "extension"), EXTENSION_BAR_ELEMENT); PrismProperty barProperty = user.findProperty(barPath); - assertNotNull("Property "+barPath+" not found", barProperty); + assertNotNull("Property " + barPath + " not found", barProperty); PrismAsserts.assertPropertyValue(barProperty, "BAR"); PrismPropertyDefinition barPropertyDef = barProperty.getDefinition(); assertNotNull("No definition for bar", barPropertyDef); @@ -525,11 +506,10 @@ private void assertUserWillExtension(PrismObject user) { PrismAsserts.assertDefinition(multiPropertyDef, EXTENSION_MULTI_ELEMENT, DOMUtil.XSD_STRING, 1, -1); assertNull("'Indexed' attribute on 'multi' property is not null", multiPropertyDef.isIndexed()); - PrismAsserts.assertPropertyValue(extension, EXTENSION_BAR_ELEMENT, "BAR"); PrismAsserts.assertPropertyValue(extension, EXTENSION_NUM_ELEMENT, 42); Collection> multiPVals = extension.findProperty(EXTENSION_MULTI_ELEMENT).getValues(); - assertEquals("Multi",3,multiPVals.size()); + assertEquals("Multi", 3, multiPVals.size()); } @@ -537,7 +517,6 @@ private void assertUserElisabeth(PrismObject user) throws SchemaExcept user.checkConsistence(); user.assertDefinitions("test"); assertUserElisabethExtension(user); - //assertVisitor(user,55); } private void assertUserElisabethExtension(PrismObject user) { @@ -548,23 +527,10 @@ private void assertUserElisabethExtension(PrismObject user) { assertTrue("Extension parent", extensionValue.getParent() == extension); assertNull("Extension ID", extensionValue.getId()); -// PrismProperty stringType = extension.findProperty(EXTENSION_STRING_TYPE_ELEMENT); -// PrismAsserts.assertPropertyValue(stringType, "BARbar", "FOObar"); -// PrismPropertyDefinition stringTypePropertyDef = stringType.getDefinition(); -// PrismAsserts.assertDefinition(stringTypePropertyDef, EXTENSION_STRING_TYPE_ELEMENT, DOMUtil.XSD_STRING, 0, -1); -// assertNull("'Indexed' attribute on 'stringType' property is not null", stringTypePropertyDef.isIndexed()); - PrismProperty secondaryStringType = extension.findProperty(EXTENSION_SECONDARY_SECONDARY_STRING_TYPE_ELEMENT); PrismAsserts.assertPropertyValue(secondaryStringType, "string1"); PrismPropertyDefinition secondaryStringTypePropertyDef = secondaryStringType.getDefinition(); PrismAsserts.assertDefinition(secondaryStringTypePropertyDef, EXTENSION_SINGLE_STRING_TYPE_ELEMENT, DOMUtil.XSD_STRING, 0, -1); assertNull("'Indexed' attribute on 'secondaryStringType' property is not null", secondaryStringTypePropertyDef.isIndexed()); } - - protected void validateXml(String xmlString, PrismContext prismContext) throws SAXException, IOException { - } - - protected void displayTestTitle(final String TEST_NAME) { - getSubdirName(); - } } diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismParsingXml.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismParsingXml.java index c37bc01a3c4..e6079a44141 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismParsingXml.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismParsingXml.java @@ -95,7 +95,7 @@ public void testPrismParseXxe() throws Exception { } @Test - public void testPrismParseDomXxe() throws Exception { + public void testPrismParseDomXxe() { try { // WHEN DOMUtil.parseFile(getFile(USER_JACK_XXE_BASENAME)); @@ -108,13 +108,4 @@ public void testPrismParseDomXxe() throws Exception { } } - - @Override - protected void validateXml(String xmlString, PrismContext prismContext) throws SAXException, IOException { -// Document xmlDocument = DOMUtil.parseDocument(xmlString); -// Schema javaxSchema = prismContext.getSchemaRegistry().getJavaxSchema(); -// Validator validator = javaxSchema.newValidator(); -// validator.setResourceResolver(prismContext.getEntityResolver()); -// validator.validate(new DOMSource(xmlDocument)); - } } diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismSchemaConstruction.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismSchemaConstruction.java index faacb8c154e..9ee7119f5b4 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismSchemaConstruction.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismSchemaConstruction.java @@ -6,26 +6,24 @@ */ package com.evolveum.midpoint.prism; -import static org.testng.AssertJUnit.assertFalse; -import static com.evolveum.midpoint.prism.PrismInternalTestUtil.*; +import static org.testng.AssertJUnit.*; + +import static com.evolveum.midpoint.prism.PrismInternalTestUtil.DEFAULT_NAMESPACE_PREFIX; +import static com.evolveum.midpoint.prism.PrismInternalTestUtil.constructInitializedPrismContext; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; -import static org.testng.AssertJUnit.assertEquals; import java.io.IOException; import java.util.Collection; import java.util.Iterator; - import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.path.ItemName; -import com.evolveum.midpoint.prism.impl.schema.PrismSchemaImpl; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.xml.sax.SAXException; +import com.evolveum.midpoint.prism.impl.schema.PrismSchemaImpl; +import com.evolveum.midpoint.prism.path.ItemName; import com.evolveum.midpoint.prism.schema.PrismSchema; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.util.DOMUtil; @@ -34,9 +32,8 @@ /** * @author semancik - * */ -public class TestPrismSchemaConstruction { +public class TestPrismSchemaConstruction extends AbstractPrismTest { private static final String NS_MY_SCHEMA = "http://midpoint.evolveum.com/xml/ns/test/my-1"; private static final String WEAPON_TYPE_LOCAL_NAME = "WeaponType"; @@ -49,7 +46,6 @@ public class TestPrismSchemaConstruction { private static final String WEAPON_PASSWORD_LOCAL_NAME = "password"; private static final String WEAPON_BLADE_LOCAL_NAME = "blade"; - @BeforeSuite public void setupDebug() { PrettyPrinter.setDefaultNamespacePrefix(DEFAULT_NAMESPACE_PREFIX); @@ -57,8 +53,6 @@ public void setupDebug() { @Test public void testConstructSchema() throws SchemaException, SAXException, IOException { - System.out.println("===[ testConstructSchema ]==="); - // GIVEN PrismContext ctx = constructInitializedPrismContext(); @@ -73,8 +67,6 @@ public void testConstructSchema() throws SchemaException, SAXException, IOExcept @Test public void testSchemaRoundtrip() throws Exception { - System.out.println("===[ testSchemaRoundtrip ]==="); - // GIVEN PrismContext ctx = constructInitializedPrismContext(); @@ -83,29 +75,23 @@ public void testSchemaRoundtrip() throws Exception { @Test public void testSchemaRoundtripLoopShareContext() throws Exception { - System.out.println("===[ testSchemaRoundtripLoopShareContext ]==="); - PrismContext ctx = constructInitializedPrismContext(); - for(int i=0; i < SCHEMA_ROUNDTRIP_LOOP_ATTEMPTS; i++) { - System.out.println("\n--- attempt "+i+"---"); + for (int i = 0; i < SCHEMA_ROUNDTRIP_LOOP_ATTEMPTS; i++) { + System.out.println("\n--- attempt " + i + "---"); schemaRoundtrip(ctx); } } @Test public void testSchemaRoundtripLoopNewContext() throws Exception { - System.out.println("===[ testSchemaRoundtripLoopNewContext ]==="); - - for(int i=0; i < SCHEMA_ROUNDTRIP_LOOP_ATTEMPTS; i++) { - System.out.println("\n--- attempt "+i+"---"); + for (int i = 0; i < SCHEMA_ROUNDTRIP_LOOP_ATTEMPTS; i++) { + System.out.println("\n--- attempt " + i + "---"); PrismContext ctx = constructInitializedPrismContext(); schemaRoundtrip(ctx); } } - - private void schemaRoundtrip(PrismContext ctx) throws SchemaException, SAXException, IOException { - + private void schemaRoundtrip(PrismContext ctx) throws SchemaException { PrismSchema schema = constructSchema(ctx); assertSchema(schema); @@ -155,7 +141,7 @@ private void assertSchema(PrismSchema schema) { assertEquals("Unexpected number of definitions in schema", 2, definitions.size()); Iterator schemaDefIter = definitions.iterator(); - ComplexTypeDefinition weaponTypeDef = (ComplexTypeDefinition)schemaDefIter.next(); + ComplexTypeDefinition weaponTypeDef = (ComplexTypeDefinition) schemaDefIter.next(); assertEquals("Unexpected number of definitions in weaponTypeDef", 5, weaponTypeDef.getDefinitions().size()); Iterator weaponTypeDefIter = weaponTypeDef.getDefinitions().iterator(); PrismPropertyDefinition kindPropertyDef = (PrismPropertyDefinition) weaponTypeDefIter.next(); @@ -180,12 +166,12 @@ private void assertSchema(PrismSchema schema) { assertEquals("Wrong createTimestampPropertyDef displayName", "Create timestamp", createTimestampPropertyDef.getDisplayName()); assertTrue("createTimestampPropertyDef not operational", createTimestampPropertyDef.isOperational()); - PrismContainerDefinition weaponContDef = (PrismContainerDefinition)schemaDefIter.next(); + PrismContainerDefinition weaponContDef = (PrismContainerDefinition) schemaDefIter.next(); assertEquals("Wrong complex type def in weaponContDef", weaponTypeDef, weaponContDef.getComplexTypeDefinition()); } private void assertPrefix(String expectedPrefix, Element element) { - assertEquals("Wrong prefix on element "+DOMUtil.getQName(element), expectedPrefix, element.getPrefix()); + assertEquals("Wrong prefix on element " + DOMUtil.getQName(element), expectedPrefix, element.getPrefix()); } } diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPropertyArrayList.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPropertyArrayList.java index 58a6f9ba185..caef2815478 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPropertyArrayList.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPropertyArrayList.java @@ -6,24 +6,21 @@ */ package com.evolveum.midpoint.prism; -import com.evolveum.midpoint.prism.foo.UserType; -import com.evolveum.midpoint.prism.impl.xjc.PropertyArrayList; -import com.evolveum.midpoint.util.DOMUtil; -import org.testng.AssertJUnit; -import org.testng.annotations.Test; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.xml.sax.SAXException; +import static org.testng.AssertJUnit.assertEquals; + +import static com.evolveum.midpoint.prism.PrismInternalTestUtil.*; import java.io.File; -import java.io.IOException; -import static com.evolveum.midpoint.prism.PrismInternalTestUtil.*; -import static org.testng.AssertJUnit.*; +import org.testng.annotations.Test; +import org.w3c.dom.Document; +import org.w3c.dom.Element; -public class TestPropertyArrayList { +import com.evolveum.midpoint.prism.foo.UserType; +import com.evolveum.midpoint.prism.impl.xjc.PropertyArrayList; +import com.evolveum.midpoint.util.DOMUtil; - public static final String USER_JACK_XXE_BASENAME = "user-jack-xxe"; +public class TestPropertyArrayList extends AbstractPrismTest { private String getSubdirName() { return "xml"; @@ -38,7 +35,7 @@ private File getCommonSubdir() { } private File getFile(String baseName) { - return new File(getCommonSubdir(), baseName+"."+getFilenameSuffix()); + return new File(getCommonSubdir(), baseName + "." + getFilenameSuffix()); } @Test @@ -51,16 +48,16 @@ public void testPrismParseDom() throws Exception { PrismObject user = prismContext.parserFor(userElement).parse(); PrismProperty property = user.findProperty(UserType.F_ADDITIONAL_NAMES); - PropertyArrayList propertyArrayList = new PropertyArrayList(property, user.getValue()); + PropertyArrayList propertyArrayList = new PropertyArrayList<>(property, user.getValue()); // WHEN - System.out.println("Additional names before test: " ); + System.out.println("Additional names before test: "); System.out.println(property.debugDump()); String testName = "test-name"; propertyArrayList.set(1, "test-name"); // THEN - System.out.println("Additional names after test: " ); + System.out.println("Additional names after test: "); System.out.println(property.debugDump()); assertEquals(testName, propertyArrayList.get(1)); } diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestTypeConversion.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestTypeConversion.java index 0aa24a14f30..9ca2a6f0a85 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestTypeConversion.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestTypeConversion.java @@ -17,6 +17,7 @@ import com.evolveum.midpoint.prism.impl.xml.XmlTypeConverterInternal; import com.evolveum.midpoint.prism.util.CloneUtil; import org.testng.AssertJUnit; +import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; import org.w3c.dom.Document; @@ -26,6 +27,7 @@ import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.xml.XmlTypeConverter; import com.evolveum.midpoint.prism.xml.XsdTypeMapper; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.PrettyPrinter; @@ -33,19 +35,14 @@ * @author semancik * */ -public class TestTypeConversion { +public class TestTypeConversion extends AbstractPrismTest { private static final String MY_NS = "http://midpoint.evolveum.com/xml/ns/testing/xmlconversion"; private static final String MY_ELEMENT_NAME = "foo"; private static final QName MY_ELEMENT_QNAME = new QName(MY_NS, MY_ELEMENT_NAME); - @BeforeSuite - public void setupDebug() { - PrettyPrinter.setDefaultNamespacePrefix(DEFAULT_NAMESPACE_PREFIX); - } - @Test - public void testXmlDateTimeType() throws Exception { + public void testXmlDateTimeType() { assertEquals("Wrong datetime class", XMLGregorianCalendar.class, XsdTypeMapper.toJavaType(DOMUtil.XSD_DATETIME)); assertEquals("Wrong datetime class", DOMUtil.XSD_DATETIME, XsdTypeMapper.toXsdType(XMLGregorianCalendar.class)); } @@ -62,7 +59,7 @@ public void testXmlDateTimeValue() throws Exception { } @Test - public void testJavaStringToXMLGregorianCalendar() throws Exception { + public void testJavaStringToXMLGregorianCalendar() { String stringDate = "1975-05-30T21:30:00.000Z"; // WHEN @@ -74,12 +71,12 @@ public void testJavaStringToXMLGregorianCalendar() throws Exception { } @Test - public void testJavaStringToXMLGregorianCalendarWrongFormat() throws Exception { + public void testJavaStringToXMLGregorianCalendarWrongFormat() { String stringDate = "blah blah blah"; try { // WHEN - XMLGregorianCalendar xmlGregorianCalendar = JavaTypeConverter.convert(XMLGregorianCalendar.class, stringDate); + JavaTypeConverter.convert(XMLGregorianCalendar.class, stringDate); AssertJUnit.fail("Unexpected success"); } catch (IllegalArgumentException e) { @@ -90,7 +87,7 @@ public void testJavaStringToXMLGregorianCalendarWrongFormat() throws Exception { } @Test - public void testJavaXMLGregorianCalendarToString() throws Exception { + public void testJavaXMLGregorianCalendarToString() { XMLGregorianCalendar cal = XmlTypeConverter.createXMLGregorianCalendar(1975, 5, 30, 21, 30, 0); // WHEN @@ -101,7 +98,7 @@ public void testJavaXMLGregorianCalendarToString() throws Exception { } @Test - public void testJavaXMLGregorianCalendarToLong() throws Exception { + public void testJavaXMLGregorianCalendarToLong() { XMLGregorianCalendar cal = XmlTypeConverter.createXMLGregorianCalendar(1975, 5, 30, 21, 30, 0); // WHEN diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestUnknownItems.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestUnknownItems.java index 6669fbc0d1e..cd9dee52bdd 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestUnknownItems.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestUnknownItems.java @@ -6,39 +6,33 @@ */ package com.evolveum.midpoint.prism; -import com.evolveum.midpoint.prism.foo.UserType; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; +import static org.testng.AssertJUnit.assertNotNull; + +import static com.evolveum.midpoint.prism.PrismInternalTestUtil.constructInitializedPrismContext; import java.io.File; -import static com.evolveum.midpoint.prism.PrismInternalTestUtil.DEFAULT_NAMESPACE_PREFIX; -import static com.evolveum.midpoint.prism.PrismInternalTestUtil.constructInitializedPrismContext; -import static org.testng.AssertJUnit.assertNotNull; +import org.testng.annotations.Test; + +import com.evolveum.midpoint.prism.foo.UserType; +import com.evolveum.midpoint.util.exception.SchemaException; /** * See MID-3249. * * @author mederly */ -public class TestUnknownItems { +public class TestUnknownItems extends AbstractPrismTest { public static final String TEST_DIR = "src/test/resources/common/xml"; public static final File WRONG_ITEM_FILE = new File(TEST_DIR + "/user-wrong-item.xml"); public static final File WRONG_NAMESPACE_FILE = new File(TEST_DIR + "/user-wrong-namespace.xml"); - @BeforeSuite - public void setupDebug() { - PrettyPrinter.setDefaultNamespacePrefix(DEFAULT_NAMESPACE_PREFIX); - } - @Test(expectedExceptions = SchemaException.class) public void test010ParseWrongItemStrict() throws Exception { // GIVEN - PrismContext prismContext = constructInitializedPrismContext(); + PrismContext prismContext = getPrismContext(); // WHEN+THEN try { @@ -52,7 +46,7 @@ public void test010ParseWrongItemStrict() throws Exception { @Test public void test020ParseWrongItemCompat() throws Exception { // GIVEN - PrismContext prismContext = constructInitializedPrismContext(); + PrismContext prismContext = getPrismContext(); // WHEN PrismObject user = prismContext.parserFor(WRONG_ITEM_FILE).compat().parse(); @@ -70,7 +64,7 @@ public void test020ParseWrongItemCompat() throws Exception { @Test(enabled = false, expectedExceptions = SchemaException.class) public void test110ParseWrongNamespaceStrict() throws Exception { // GIVEN - PrismContext prismContext = constructInitializedPrismContext(); + PrismContext prismContext = getPrismContext(); // WHEN+THEN PrismObject user = prismContext.parseObject(WRONG_NAMESPACE_FILE); @@ -82,7 +76,7 @@ public void test110ParseWrongNamespaceStrict() throws Exception { @Test public void test120ParseWrongNamespaceCompat() throws Exception { // GIVEN - PrismContext prismContext = constructInitializedPrismContext(); + PrismContext prismContext = getPrismContext(); // WHEN PrismObject user = prismContext.parserFor(WRONG_NAMESPACE_FILE).compat().parse(); @@ -93,5 +87,4 @@ public void test120ParseWrongNamespaceCompat() throws Exception { assertNotNull(user); } - } diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestXmlSerialization.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestXmlSerialization.java index 785f7d94158..907918d6078 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestXmlSerialization.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestXmlSerialization.java @@ -29,19 +29,12 @@ * @author mederly * */ -public class TestXmlSerialization { - - @BeforeSuite - public void setupDebug() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(DEFAULT_NAMESPACE_PREFIX); - PrismTestUtil.resetPrismContext(new PrismInternalTestUtil()); - } +public class TestXmlSerialization extends AbstractPrismTest { @Test public void testHandlingInvalidChars() throws Exception { // GIVEN - - PrismContext prismContext = PrismTestUtil.getPrismContext(); + PrismContext prismContext = getPrismContext(); // WHEN diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/TestProtectedString.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/TestProtectedString.java index 949d09e696d..ae8f976ee9b 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/TestProtectedString.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/TestProtectedString.java @@ -6,6 +6,7 @@ */ package com.evolveum.midpoint.prism.lex; +import com.evolveum.midpoint.prism.AbstractPrismTest; import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.impl.PrismContextImpl; import com.evolveum.midpoint.prism.PrismInternalTestUtil; @@ -28,15 +29,8 @@ /** * @author mederly - * */ -public class TestProtectedString { - - @BeforeSuite - public void setupDebug() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(DEFAULT_NAMESPACE_PREFIX); - PrismTestUtil.resetPrismContext(new PrismInternalTestUtil()); - } +public class TestProtectedString extends AbstractPrismTest { @Test public void testParseProtectedStringEncrypted() throws Exception { diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/match/TestMatchingRule.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/match/TestMatchingRule.java index 48f9bf3ea77..edc80b4acbe 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/match/TestMatchingRule.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/match/TestMatchingRule.java @@ -6,42 +6,25 @@ */ package com.evolveum.midpoint.prism.match; -import static org.testng.AssertJUnit.assertEquals; -import static com.evolveum.midpoint.prism.PrismInternalTestUtil.DEFAULT_NAMESPACE_PREFIX; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.*; -import java.io.IOException; +import org.testng.annotations.Test; +import com.evolveum.midpoint.prism.AbstractPrismTest; import com.evolveum.midpoint.prism.PrismConstants; import com.evolveum.midpoint.prism.impl.match.MatchingRuleRegistryFactory; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import com.evolveum.midpoint.prism.PrismInternalTestUtil; import com.evolveum.midpoint.prism.polystring.PolyString; -import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; /** * @author semancik - * */ -public class TestMatchingRule { +public class TestMatchingRule extends AbstractPrismTest { - private static MatchingRuleRegistry matchingRuleRegistry; - - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(DEFAULT_NAMESPACE_PREFIX); - PrismTestUtil.resetPrismContext(new PrismInternalTestUtil()); - - matchingRuleRegistry = MatchingRuleRegistryFactory.createRegistry(); - } + private static MatchingRuleRegistry matchingRuleRegistry = + MatchingRuleRegistryFactory.createRegistry(); @Test public void testStringDefault() throws Exception { @@ -149,13 +132,12 @@ public void testXml() throws Exception { assertNormalized(rule, "FOO BAR ", "FOO BAR "); } - private void assertMatch(MatchingRule rule, T a, T b) throws SchemaException { - assertTrue("Values '"+a+"' and '"+b+"' does not match; rule: "+rule, rule.match(a, b)); + assertTrue("Values '" + a + "' and '" + b + "' does not match; rule: " + rule, rule.match(a, b)); } private void assertNoMatch(MatchingRule rule, T a, T b) throws SchemaException { - assertFalse("Values '"+a+"' and '"+b+"' DOES match but they should not; rule: "+rule, rule.match(a, b)); + assertFalse("Values '" + a + "' and '" + b + "' DOES match but they should not; rule: " + rule, rule.match(a, b)); } private void assertNormalized(MatchingRule rule, String expected, String original) throws SchemaException { diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/query/TestObjectQuery.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/query/TestObjectQuery.java index 2038b521098..416314100f6 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/query/TestObjectQuery.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/query/TestObjectQuery.java @@ -7,41 +7,28 @@ package com.evolveum.midpoint.prism.query; +import javax.xml.namespace.QName; + +import org.testng.AssertJUnit; +import org.testng.annotations.Test; + +import com.evolveum.midpoint.prism.AbstractPrismTest; import com.evolveum.midpoint.prism.MutablePrismPropertyDefinition; import com.evolveum.midpoint.prism.PrismInternalTestUtil; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.foo.AssignmentType; import com.evolveum.midpoint.prism.foo.UserType; -import com.evolveum.midpoint.prism.match.MatchingRuleRegistry; import com.evolveum.midpoint.prism.impl.match.MatchingRuleRegistryFactory; +import com.evolveum.midpoint.prism.match.MatchingRuleRegistry; import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; -import org.testng.AssertJUnit; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; -import javax.xml.namespace.QName; -import java.io.IOException; - -import static com.evolveum.midpoint.prism.PrismInternalTestUtil.DEFAULT_NAMESPACE_PREFIX; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; - -public class TestObjectQuery { +public class TestObjectQuery extends AbstractPrismTest { - private static MatchingRuleRegistry matchingRuleRegistry; - - @BeforeSuite - public void setupDebug() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(DEFAULT_NAMESPACE_PREFIX); - PrismTestUtil.resetPrismContext(new PrismInternalTestUtil()); - - matchingRuleRegistry = MatchingRuleRegistryFactory.createRegistry(); - } + private static MatchingRuleRegistry matchingRuleRegistry = + MatchingRuleRegistryFactory.createRegistry(); @Test public void testMatchAndFilter() throws Exception { @@ -50,12 +37,11 @@ public void testMatchAndFilter() throws Exception { getPrismContext().queryFor(UserType.class) .item(UserType.F_GIVEN_NAME).eq("Jack").matchingCaseIgnore() .and().item(UserType.F_FULL_NAME).contains("arr") - .buildFilter(); + .buildFilter(); boolean match = ObjectQuery.match(user, filter, matchingRuleRegistry); AssertJUnit.assertTrue("filter does not match object", match); } - @Test public void testMatchOrFilter() throws Exception { PrismObject user = PrismTestUtil.parseObject(PrismInternalTestUtil.USER_JACK_FILE_XML); @@ -125,17 +111,17 @@ public void testMatchEqualEmptyAgainstNonEmptyItem() throws Exception { public void testComplexMatch() throws Exception { PrismObject user = PrismTestUtil.parseObject(PrismInternalTestUtil.USER_JACK_FILE_XML); // System.out.println("user given name" + user.asObjectable().getGivenName()); - System.out.println("definition: " +user.findItem(UserType.F_FAMILY_NAME).getDefinition().debugDump()); + System.out.println("definition: " + user.findItem(UserType.F_FAMILY_NAME).getDefinition().debugDump()); ObjectFilter filter = getPrismContext().queryFor(UserType.class) .item(UserType.F_FAMILY_NAME).eq("Sparrow") .and().item(UserType.F_FULL_NAME).contains("arr") .and() - .block() - .item(UserType.F_GIVEN_NAME).eq("Jack") - .or().item(UserType.F_GIVEN_NAME).eq("Jackie") - .endBlock() - .buildFilter(); + .block() + .item(UserType.F_GIVEN_NAME).eq("Jack") + .or().item(UserType.F_GIVEN_NAME).eq("Jackie") + .endBlock() + .buildFilter(); boolean match = ObjectQuery.match(user, filter, matchingRuleRegistry); AssertJUnit.assertTrue("filter does not match object", match); } @@ -167,7 +153,7 @@ public void testExistsNegative() throws Exception { PrismObject user = PrismTestUtil.parseObject(PrismInternalTestUtil.USER_JACK_FILE_XML); ObjectFilter filter = getPrismContext().queryFor(UserType.class) .exists(UserType.F_ASSIGNMENT) - .item(AssignmentType.F_DESCRIPTION).eq("Assignment NONE") + .item(AssignmentType.F_DESCRIPTION).eq("Assignment NONE") .buildFilter(); boolean match = ObjectQuery.match(user, filter, matchingRuleRegistry); AssertJUnit.assertFalse("filter matches object, but it should not", match); @@ -178,7 +164,7 @@ public void testExistsPositive() throws Exception { PrismObject user = PrismTestUtil.parseObject(PrismInternalTestUtil.USER_JACK_FILE_XML); ObjectFilter filter = getPrismContext().queryFor(UserType.class) .exists(UserType.F_ASSIGNMENT) - .item(AssignmentType.F_DESCRIPTION).eq("Assignment 2") + .item(AssignmentType.F_DESCRIPTION).eq("Assignment 2") .buildFilter(); boolean match = ObjectQuery.match(user, filter, matchingRuleRegistry); AssertJUnit.assertTrue("filter does not match object, but it should", match); diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/query/TestQueryBuilder.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/query/TestQueryBuilder.java index 632c0c2d2e6..19852abbfd1 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/query/TestQueryBuilder.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/query/TestQueryBuilder.java @@ -7,79 +7,61 @@ package com.evolveum.midpoint.prism.query; +import static com.evolveum.midpoint.prism.PrismInternalTestUtil.NS_FOO; +import static com.evolveum.midpoint.prism.util.PrismTestUtil.getSchemaRegistry; + +import java.lang.reflect.Method; +import javax.xml.namespace.QName; + +import org.testng.AssertJUnit; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.foo.AssignmentType; import com.evolveum.midpoint.prism.foo.UserType; import com.evolveum.midpoint.prism.impl.query.*; -import com.evolveum.midpoint.prism.match.MatchingRuleRegistry; -import com.evolveum.midpoint.prism.impl.match.MatchingRuleRegistryFactory; import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; -import org.testng.AssertJUnit; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import javax.xml.namespace.QName; -import java.io.IOException; -import java.lang.reflect.Method; - -import static com.evolveum.midpoint.prism.PrismInternalTestUtil.DEFAULT_NAMESPACE_PREFIX; -import static com.evolveum.midpoint.prism.PrismInternalTestUtil.NS_FOO; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getSchemaRegistry; /** * Here are the most simple tests for Query Builder. * More advanced tests are part of QueryInterpreterTest in repo-sql-impl-test. - * + *

* These tests are strict in the sense they check the exact structure of created queries. * Repo tests check just the HQL outcome. */ -public class TestQueryBuilder { +public class TestQueryBuilder extends AbstractPrismTest { public static final QName USER_TYPE_QNAME = new QName(NS_FOO, "UserType"); public static final QName ASSIGNMENT_TYPE_QNAME = new QName(NS_FOO, "AssignmentType"); - private static MatchingRuleRegistry matchingRuleRegistry; - - @BeforeSuite - public void setupDebug() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(DEFAULT_NAMESPACE_PREFIX); - PrismTestUtil.resetPrismContext(new PrismInternalTestUtil()); - - matchingRuleRegistry = MatchingRuleRegistryFactory.createRegistry(); - } @BeforeMethod - public void beforeMethod(Method method) throws Exception { + public void beforeMethod(Method method) { System.out.println(">>>>>>>>>>>>>>>>>>>>>>>> START TEST" + getClass().getName() + "." + method.getName() + "<<<<<<<<<<<<<<<<<<<<<<<<"); } @Test - public void test100EmptyFilter() throws Exception{ + public void test100EmptyFilter() { ObjectQuery actual = getPrismContext().queryFor(UserType.class).build(); ObjectQuery expected = ObjectQueryImpl.createObjectQuery((ObjectFilter) null); compare(actual, expected); } @Test - public void test110EmptyBlock() throws Exception{ + public void test110EmptyBlock() { ObjectQuery actual = getPrismContext().queryFor(UserType.class).block().endBlock().build(); ObjectQuery expected = ObjectQueryImpl.createObjectQuery((ObjectFilter) null); compare(actual, expected); } @Test - public void test112EmptyBlocks() throws Exception{ + public void test112EmptyBlocks() { ObjectQuery actual = getPrismContext().queryFor(UserType.class) .block() - .block() - .block() - .endBlock() - .endBlock() + .block() + .block() + .endBlock() + .endBlock() .endBlock() .build(); ObjectQuery expected = ObjectQueryImpl.createObjectQuery((ObjectFilter) null); @@ -87,7 +69,7 @@ public void test112EmptyBlocks() throws Exception{ } @Test(expectedExceptions = IllegalStateException.class) - public void test113BlocksLeftOpen() throws Exception{ + public void test113BlocksLeftOpen() { getPrismContext().queryFor(UserType.class) .block() .block() @@ -98,7 +80,7 @@ public void test113BlocksLeftOpen() throws Exception{ } @Test(expectedExceptions = IllegalStateException.class) - public void test114NoOpenBlocks() throws Exception{ + public void test114NoOpenBlocks() { getPrismContext().queryFor(UserType.class) .block() .block() @@ -109,28 +91,28 @@ public void test114NoOpenBlocks() throws Exception{ } @Test - public void test120All() throws Exception{ + public void test120All() { ObjectQuery actual = getPrismContext().queryFor(UserType.class).all().build(); ObjectQuery expected = ObjectQueryImpl.createObjectQuery(AllFilterImpl.createAll()); compare(actual, expected); } @Test - public void test122AllInBlock() throws Exception{ + public void test122AllInBlock() { ObjectQuery actual = getPrismContext().queryFor(UserType.class).block().all().endBlock().build(); ObjectQuery expected = ObjectQueryImpl.createObjectQuery(AllFilterImpl.createAll()); compare(actual, expected); } @Test - public void test130SingleEquals() throws Exception{ + public void test130SingleEquals() { ObjectQuery actual = getPrismContext().queryFor(UserType.class).item(UserType.F_LOCALITY).eq("Caribbean").build(); ObjectQuery expected = ObjectQueryImpl.createObjectQuery(createEqual(UserType.F_LOCALITY, UserType.class, null, "Caribbean")); compare(actual, expected); } @Test - public void test132SingleAnd() throws Exception{ + public void test132SingleAnd() { ObjectQuery actual = getPrismContext().queryFor(UserType.class) .item(UserType.F_LOCALITY).eq("Caribbean") .and().item(UserType.F_DESCRIPTION).eq("desc") @@ -145,7 +127,7 @@ public void test132SingleAnd() throws Exception{ } @Test - public void test134SingleOrWithNot() throws Exception{ + public void test134SingleOrWithNot() { ObjectQuery actual = getPrismContext().queryFor(UserType.class) .item(UserType.F_LOCALITY).eq("Caribbean") .or().not().item(UserType.F_DESCRIPTION).eq("desc") @@ -162,16 +144,16 @@ public void test134SingleOrWithNot() throws Exception{ } @Test - public void test136AndOrNotSequence() throws Exception{ + public void test136AndOrNotSequence() { ObjectQuery actual = getPrismContext().queryFor(UserType.class) .item(UserType.F_LOCALITY).eq("Caribbean") .or() - .not().item(UserType.F_DESCRIPTION).eq("desc") - .and().all() - .and().none() + .not().item(UserType.F_DESCRIPTION).eq("desc") + .and().all() + .and().none() .or() - .undefined() - .and().not().none() + .undefined() + .and().not().none() .build(); ObjectQuery expected = ObjectQueryImpl.createObjectQuery( OrFilterImpl.createOr( @@ -195,7 +177,7 @@ public void test136AndOrNotSequence() throws Exception{ } @Test - public void test140TypeWithEquals() throws Exception{ + public void test140TypeWithEquals() { ObjectQuery actual = getPrismContext().queryFor(UserType.class) .type(UserType.class) .item(UserType.F_LOCALITY).eq("Caribbean") @@ -210,7 +192,7 @@ public void test140TypeWithEquals() throws Exception{ } @Test - public void test142TypeWithEqualsInBlock() throws Exception{ + public void test142TypeWithEqualsInBlock() { ObjectQuery actual = getPrismContext().queryFor(UserType.class) .type(UserType.class) .block() @@ -227,7 +209,7 @@ public void test142TypeWithEqualsInBlock() throws Exception{ } @Test - public void test144TypeWithEqualsAndAllInBlock() throws Exception{ + public void test144TypeWithEqualsAndAllInBlock() { ObjectQuery actual = getPrismContext().queryFor(UserType.class) .type(UserType.class) .block() @@ -248,7 +230,7 @@ public void test144TypeWithEqualsAndAllInBlock() throws Exception{ } @Test - public void test144TypeInTypeInType() throws Exception{ + public void test144TypeInTypeInType() { ObjectQuery actual = getPrismContext().queryFor(UserType.class) .type(UserType.class) .type(AssignmentType.class) @@ -271,7 +253,7 @@ public void test144TypeInTypeInType() throws Exception{ } @Test - public void test146TypeAndSomething() throws Exception{ + public void test146TypeAndSomething() { ObjectQuery actual = getPrismContext().queryFor(UserType.class) .type(UserType.class) .none() @@ -290,7 +272,7 @@ public void test146TypeAndSomething() throws Exception{ } @Test - public void test148TypeEmpty() throws Exception{ + public void test148TypeEmpty() { ObjectQuery actual = getPrismContext().queryFor(UserType.class) .type(UserType.class) .block().endBlock() @@ -305,7 +287,7 @@ public void test148TypeEmpty() throws Exception{ } @Test - public void test149TypeEmptyAndAll() throws Exception{ + public void test149TypeEmptyAndAll() { ObjectQuery actual = getPrismContext().queryFor(UserType.class) .type(UserType.class) .block().endBlock() @@ -324,7 +306,7 @@ public void test149TypeEmptyAndAll() throws Exception{ } @Test - public void test150ExistsWithEquals() throws Exception{ + public void test150ExistsWithEquals() throws Exception { ObjectQuery actual = getPrismContext().queryFor(UserType.class) .exists(UserType.F_ASSIGNMENT) .item(AssignmentType.F_DESCRIPTION).startsWith("desc1") @@ -341,12 +323,12 @@ public void test150ExistsWithEquals() throws Exception{ getPrismContext(), null, "desc1", true, false) ) - ); + ); compare(actual, expected); } @Test - public void test151ExistsWithEquals2() throws Exception{ + public void test151ExistsWithEquals2() throws Exception { ObjectQuery actual = getPrismContext().queryFor(UserType.class) .exists(UserType.F_ASSIGNMENT) .item(AssignmentType.F_NOTE).endsWith("DONE.") @@ -368,11 +350,11 @@ public void test151ExistsWithEquals2() throws Exception{ } @Test - public void test152ExistsWithEqualsInBlock() throws Exception{ + public void test152ExistsWithEqualsInBlock() throws Exception { ObjectQuery actual = getPrismContext().queryFor(UserType.class) .exists(UserType.F_ASSIGNMENT) .block() - .item(AssignmentType.F_NOTE).endsWith("DONE.") + .item(AssignmentType.F_NOTE).endsWith("DONE.") .endBlock() .build(); ComplexTypeDefinition assCtd = getPrismContext().getSchemaRegistry().findComplexTypeDefinitionByCompileTimeClass(AssignmentType.class); @@ -392,12 +374,12 @@ public void test152ExistsWithEqualsInBlock() throws Exception{ } @Test - public void test154ExistsWithEqualsAndAllInBlock() throws Exception{ + public void test154ExistsWithEqualsAndAllInBlock() throws Exception { ObjectQuery actual = getPrismContext().queryFor(UserType.class) .exists(UserType.F_ASSIGNMENT) .block() .item(AssignmentType.F_NOTE).endsWith("DONE.") - .and().all() + .and().all() .endBlock() .build(); ComplexTypeDefinition assCtd = getPrismContext().getSchemaRegistry().findComplexTypeDefinitionByCompileTimeClass(AssignmentType.class); @@ -421,10 +403,10 @@ public void test154ExistsWithEqualsAndAllInBlock() throws Exception{ } @Test - public void test156ExistsAndSomething() throws Exception{ + public void test156ExistsAndSomething() throws Exception { ObjectQuery actual = getPrismContext().queryFor(UserType.class) .exists(UserType.F_ASSIGNMENT) - .none() + .none() .and().all() .build(); @@ -444,7 +426,7 @@ public void test156ExistsAndSomething() throws Exception{ } @Test - public void test200OrderByName() throws Exception{ + public void test200OrderByName() { ObjectQuery actual = getPrismContext().queryFor(UserType.class) .asc(UserType.F_NAME) .build(); @@ -471,7 +453,7 @@ public void test210OrderByNameAndId() { } @Test - public void test300EqualItem() throws Exception { + public void test300EqualItem() { ObjectQuery actual = getPrismContext().queryFor(UserType.class) .item(UserType.F_LOCALITY).eq().item(UserType.F_NAME) .build(); @@ -489,14 +471,14 @@ public void test300EqualItem() throws Exception { } @Test - public void test310LessThanItem() throws Exception { + public void test310LessThanItem() { PrismObjectDefinition userDef = getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class); PrismPropertyDefinition nameDef = userDef.findPropertyDefinition(UserType.F_NAME); PrismPropertyDefinition localityDef = userDef.findPropertyDefinition(UserType.F_LOCALITY); ObjectQuery actual = getPrismContext().queryFor(UserType.class) .item(UserType.F_LOCALITY, localityDef) - .le() - .item(UserType.F_NAME, nameDef) + .le() + .item(UserType.F_NAME, nameDef) .build(); ObjectQuery expected = ObjectQueryImpl.createObjectQuery( LessFilterImpl.createLess(UserType.F_LOCALITY, localityDef, null, diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/query/TestQueryConverters.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/query/TestQueryConverters.java index b703d1e6d22..3b3e3b42dc0 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/query/TestQueryConverters.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/query/TestQueryConverters.java @@ -7,48 +7,40 @@ package com.evolveum.midpoint.prism.query; +import static org.testng.AssertJUnit.*; + import static com.evolveum.midpoint.prism.PrismInternalTestUtil.DEFAULT_NAMESPACE_PREFIX; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.createPolyString; import static com.evolveum.midpoint.prism.util.PrismTestUtil.displayQuery; import static com.evolveum.midpoint.prism.util.PrismTestUtil.getFilterCondition; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; import java.io.File; import java.io.IOException; - import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.prism.xnode.MapXNode; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; import org.w3c.dom.Element; import org.xml.sax.SAXException; +import com.evolveum.midpoint.prism.AbstractPrismTest; import com.evolveum.midpoint.prism.PrismConstants; import com.evolveum.midpoint.prism.PrismInternalTestUtil; import com.evolveum.midpoint.prism.foo.UserType; -import com.evolveum.midpoint.prism.util.PrismAsserts; -import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.prism.impl.xnode.ListXNodeImpl; import com.evolveum.midpoint.prism.impl.xnode.MapXNodeImpl; -import com.evolveum.midpoint.tools.testng.AbstractUnitTest; +import com.evolveum.midpoint.prism.path.ItemPath; +import com.evolveum.midpoint.prism.util.PrismAsserts; +import com.evolveum.midpoint.prism.util.PrismTestUtil; +import com.evolveum.midpoint.prism.xnode.MapXNode; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.DomAsserts; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.prism.xml.ns._public.query_3.QueryType; import com.evolveum.prism.xml.ns._public.query_3.SearchFilterType; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; -public class TestQueryConverters extends AbstractUnitTest { - - private static final Trace LOGGER = TraceManager.getTrace(TestQueryConverters.class); +public class TestQueryConverters extends AbstractPrismTest { private static final File TEST_DIR = new File("src/test/resources/query"); @@ -108,12 +100,12 @@ public void testFilterUserAndJaxb() throws Exception { ObjectFilter first = getFilterCondition(filter, 0); PrismAsserts.assertEqualsFilter(first, UserType.F_GIVEN_NAME, DOMUtil.XSD_STRING, - ItemPath.create(new QName(null,UserType.F_GIVEN_NAME.getLocalPart()))); + ItemPath.create(new QName(null, UserType.F_GIVEN_NAME.getLocalPart()))); PrismAsserts.assertEqualsFilterValue((EqualFilter) first, "Jack"); ObjectFilter second = getFilterCondition(filter, 1); PrismAsserts.assertEqualsFilter(second, UserType.F_LOCALITY, DOMUtil.XSD_STRING, - ItemPath.create(new QName(null,UserType.F_LOCALITY.getLocalPart()))); + ItemPath.create(new QName(null, UserType.F_LOCALITY.getLocalPart()))); PrismAsserts.assertEqualsFilterValue((EqualFilter) second, "Caribbean"); QueryType convertedQueryType = toQueryType(query); @@ -168,13 +160,12 @@ public void testFilterTypeUserNone() throws Exception { System.out.println(convertedQueryType.debugDump()); Element filterClauseElement = convertedQueryType.getFilter().getFilterClauseAsElement(getPrismContext()); - LOGGER.info(convertedQueryType.getFilter().getFilterClauseXNode().debugDump()); - + logger.info(convertedQueryType.getFilter().getFilterClauseXNode().debugDump()); System.out.println("Serialized filter (JAXB->DOM)"); String filterAsString = DOMUtil.serializeDOMToString(filterClauseElement); System.out.println(filterAsString); - LOGGER.info(filterAsString); + logger.info(filterAsString); DomAsserts.assertElementQName(filterClauseElement, new QName(PrismConstants.NS_QUERY, "type")); } @@ -199,12 +190,12 @@ public void testFilterNotInOid() throws Exception { System.out.println(convertedQueryType.debugDump()); Element filterClauseElement = convertedQueryType.getFilter().getFilterClauseAsElement(getPrismContext()); - LOGGER.info(convertedQueryType.getFilter().getFilterClauseXNode().debugDump()); + logger.info(convertedQueryType.getFilter().getFilterClauseXNode().debugDump()); System.out.println("Serialized filter (JAXB->DOM)"); String filterAsString = DOMUtil.serializeDOMToString(filterClauseElement); System.out.println(filterAsString); - LOGGER.info(filterAsString); + logger.info(filterAsString); DomAsserts.assertElementQName(filterClauseElement, new QName(PrismConstants.NS_QUERY, "not")); assertEquals("wrong # of inOid subfilters", 1, filterClauseElement.getElementsByTagNameNS(PrismConstants.NS_QUERY, "inOid").getLength()); @@ -231,32 +222,23 @@ public void testFilterNotFullText() throws Exception { System.out.println(convertedQueryType.debugDump()); Element filterClauseElement = convertedQueryType.getFilter().getFilterClauseAsElement(getPrismContext()); - LOGGER.info(convertedQueryType.getFilter().getFilterClauseXNode().debugDump()); + logger.info(convertedQueryType.getFilter().getFilterClauseXNode().debugDump()); System.out.println("Serialized filter (JAXB->DOM)"); String filterAsString = DOMUtil.serializeDOMToString(filterClauseElement); System.out.println(filterAsString); - LOGGER.info(filterAsString); + logger.info(filterAsString); DomAsserts.assertElementQName(filterClauseElement, new QName(PrismConstants.NS_QUERY, "not")); assertEquals("wrong # of fullText subfilters", 1, filterClauseElement.getElementsByTagNameNS(PrismConstants.NS_QUERY, "fullText").getLength()); assertEquals("wrong # of value subfilters", 2, filterClauseElement.getElementsByTagNameNS(PrismConstants.NS_QUERY, "value").getLength()); } - private ObjectQuery toObjectQuery(Class type, QueryType queryType) throws Exception { - ObjectQuery query = getPrismContext().getQueryConverter().createObjectQuery(type, queryType - ); - return query; - } - private ObjectQuery toObjectQuery(Class type, SearchFilterType filterType) throws Exception { - ObjectQuery query = getPrismContext().getQueryConverter().createObjectQuery(type, filterType - ); - return query; + return getPrismContext().getQueryConverter().createObjectQuery(type, filterType); } private QueryType toQueryType(ObjectQuery query) throws Exception { return getPrismContext().getQueryConverter().createQueryType(query); } - } From b49b00a2af52f888eca66f9dc5033fd0b425a6eb Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Mon, 2 Mar 2020 13:15:30 +0100 Subject: [PATCH 85/97] Order org tree roots alphabetically Originally, the order of organization tree roots was unspecified i.e. left to particular DBMS. Here we order these roots by their name. This fixes TestPageOrg.test004testCreateChild that was failing on most databases (except for H2). --- .../page/admin/orgs/AbstractOrgTabPanel.java | 10 ++++--- .../evolveum/midpoint/gui/TestPageOrg.java | 26 +++++++++---------- .../impl/query/builder/QueryBuilder.java | 12 +-------- 3 files changed, 21 insertions(+), 27 deletions(-) diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/orgs/AbstractOrgTabPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/orgs/AbstractOrgTabPanel.java index ef6a3fec189..7bfab886422 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/orgs/AbstractOrgTabPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/orgs/AbstractOrgTabPanel.java @@ -12,6 +12,8 @@ import com.evolveum.midpoint.prism.query.ObjectFilter; import com.evolveum.midpoint.web.session.OrgStructurePanelStorage; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; + import org.apache.commons.lang3.ObjectUtils; import org.apache.wicket.ajax.AjaxEventBehavior; import org.apache.wicket.ajax.AjaxRequestTarget; @@ -30,7 +32,6 @@ import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.schema.util.ObjectQueryUtil; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.util.logging.LoggingUtils; import com.evolveum.midpoint.util.logging.Trace; @@ -165,9 +166,12 @@ private List> loadOrgRoots() { List> list = new ArrayList<>(); try { - ObjectQuery query = ObjectQueryUtil.createRootOrgQuery(getPageBase().getPrismContext()); + ObjectQuery query = getPageBase().getPrismContext().queryFor(OrgType.class) + .isRoot() + .asc(OrgType.F_NAME) + .build(); ObjectFilter assignableItemsFilter = getAssignableItemsFilter(); - if (assignableItemsFilter != null){ + if (assignableItemsFilter != null) { query.addFilter(assignableItemsFilter); } list = getPageBase().getModelService().searchObjects(OrgType.class, query, null, task, result); diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestPageOrg.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestPageOrg.java index 9f2b3e004fe..127a80f33d9 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestPageOrg.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestPageOrg.java @@ -41,10 +41,13 @@ public class TestPageOrg extends AbstractInitializedGuiIntegrationTest { private static final Trace LOGGER = TraceManager.getTrace(TestPageOrg.class); private static final String MAIN_FORM = "mainPanel:mainForm"; - private static final String FORM_INPUT_DESCRIPTION = "tabPanel:panel:basicSystemConfiguration:values:0:value:propertiesLabel:properties:1:property:values:0:valueContainer:form:input:input"; +// private static final String FORM_INPUT_DESCRIPTION = "tabPanel:panel:basicSystemConfiguration:values:0:value:propertiesLabel:properties:1:property:values:0:valueContainer:form:input:input"; private static final String PATH_FORM_NAME = "tabPanel:panel:main:values:0:value:propertiesLabel:properties:0:property:values:0:valueContainer:form:input:originValueContainer:origValueWithButton:origValue:input"; private static final String FORM_SAVE = "save"; + private static final String NEW_ORG_NAME = "A-newOrg"; // starts with "A" to be alphabetically first + private static final String NEW_ORG_CHILD_NAME = "newOrgChild"; + @Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { super.initSystem(initTask, initResult); @@ -69,12 +72,12 @@ public void test003testAddNewOrg() throws Exception { renderPage(PageOrgUnit.class); FormTester formTester = tester.newFormTester(MAIN_FORM, false); - formTester.setValue(PATH_FORM_NAME, "newOrg"); - formTester = formTester.submit(FORM_SAVE); + formTester.setValue(PATH_FORM_NAME, NEW_ORG_NAME); + formTester.submit(FORM_SAVE); Thread.sleep(5000); - PrismObject newOrg = findObjectByName(OrgType.class, "newOrg"); + PrismObject newOrg = findObjectByName(OrgType.class, NEW_ORG_NAME); assertNotNull(newOrg, "New org not created."); LOGGER.info("created org: {}", newOrg.debugDump()); } @@ -86,25 +89,22 @@ public void test004testCreateChild() throws Exception { tester.assertRenderedPage(PageOrgUnit.class); FormTester formTester = tester.newFormTester(MAIN_FORM, false); - formTester.setValue(PATH_FORM_NAME, "newOrgChild"); - formTester = formTester.submit(FORM_SAVE); + formTester.setValue(PATH_FORM_NAME, NEW_ORG_CHILD_NAME); + formTester.submit(FORM_SAVE); Thread.sleep(5000); - PrismObject newOrgChild = findObjectByName(OrgType.class, "newOrgChild"); - PrismObject newOrg = findObjectByName(OrgType.class, "newOrg"); + PrismObject newOrgChild = findObjectByName(OrgType.class, NEW_ORG_CHILD_NAME); + PrismObject newOrg = findObjectByName(OrgType.class, NEW_ORG_NAME); assertNotNull(newOrgChild, "New org not created."); assertAssignedOrg(newOrgChild, newOrg.getOid()); } - private Page renderPage(Class expectedRenderedPageClass) { + private void renderPage(Class expectedRenderedPageClass) { LOGGER.info("render page system configuration"); PageParameters params = new PageParameters(); - Page pageAccount = tester.startPage(expectedRenderedPageClass, params); + tester.startPage(expectedRenderedPageClass, params); tester.assertRenderedPage(expectedRenderedPageClass); - - return pageAccount; } - } diff --git a/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/query/builder/QueryBuilder.java b/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/query/builder/QueryBuilder.java index 33e959bd292..13b6d841740 100644 --- a/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/query/builder/QueryBuilder.java +++ b/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/query/builder/QueryBuilder.java @@ -46,13 +46,12 @@ public final class QueryBuilder { final private Class queryClass; - final private ComplexTypeDefinition containerCTD; final private PrismContext prismContext; private QueryBuilder(Class queryClass, PrismContext prismContext) { this.queryClass = queryClass; this.prismContext = prismContext; - containerCTD = prismContext.getSchemaRegistry().findComplexTypeDefinitionByCompileTimeClass(queryClass); + ComplexTypeDefinition containerCTD = prismContext.getSchemaRegistry().findComplexTypeDefinitionByCompileTimeClass(queryClass); if (containerCTD == null) { throw new IllegalArgumentException("Couldn't find definition for complex type " + queryClass); } @@ -69,13 +68,4 @@ public PrismContext getPrismContext() { public static S_FilterEntryOrEmpty queryFor(Class queryClass, PrismContext prismContext) { return R_Filter.create(new QueryBuilder(queryClass, prismContext)); } - -// ItemDefinition findItemDefinition(ItemPath itemPath) throws SchemaException { -// ItemDefinition itemDefinition = containerCTD.findItemDefinition(itemPath); -// if (itemDefinition == null) { -// throw new SchemaException("Couldn't find definition for '" + itemPath + "' in " + containerCTD); -// } -// return itemDefinition; -// } - } From 40bcca2aafaa0ebbf938c800f5822a5a703d6432 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Mon, 2 Mar 2020 13:40:19 +0100 Subject: [PATCH 86/97] Fix TestFilterSimplifier and add it to the suite --- .../midpoint/schema/TestFilterSimplifier.java | 50 +++++++++---------- infra/schema/testng-unit.xml | 1 + 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestFilterSimplifier.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestFilterSimplifier.java index 37ca4ab1a8e..c54aefea06b 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestFilterSimplifier.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestFilterSimplifier.java @@ -8,6 +8,7 @@ import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.query.*; +import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.util.ObjectQueryUtil; @@ -25,7 +26,6 @@ import static org.testng.AssertJUnit.assertTrue; /** - * @author mederly * */ public class TestFilterSimplifier { @@ -37,7 +37,7 @@ public void setup() throws SchemaException, SAXException, IOException { } @Test - public void test010All() throws Exception { + public void test010All() { System.out.println("===[ test010All ]==="); // GIVEN @@ -55,7 +55,7 @@ public void test010All() throws Exception { } @Test - public void test020None() throws Exception { + public void test020None() { System.out.println("===[ test020None ]==="); // GIVEN @@ -73,7 +73,7 @@ public void test020None() throws Exception { } @Test - public void test030Undefined() throws Exception { + public void test030Undefined() { System.out.println("===[ test030Undefined ]==="); // GIVEN @@ -91,7 +91,7 @@ public void test030Undefined() throws Exception { } @Test - public void test100AndLevel1() throws Exception { + public void test100AndLevel1() { System.out.println("===[ test100AndLevel1 ]==="); // GIVEN @@ -112,7 +112,7 @@ public void test100AndLevel1() throws Exception { } @Test - public void test110AndLevel1WithoutNone() throws Exception { + public void test110AndLevel1WithoutNone() { System.out.println("===[ test110AndLevel1WithoutNone ]==="); // GIVEN @@ -132,7 +132,7 @@ public void test110AndLevel1WithoutNone() throws Exception { } @Test - public void test120AndEmpty() throws Exception { + public void test120AndEmpty() { System.out.println("===[ test120AndEmpty ]==="); // GIVEN @@ -149,7 +149,7 @@ public void test120AndEmpty() throws Exception { } @Test - public void test150OrLevel1() throws Exception { + public void test150OrLevel1() { System.out.println("===[ test150OrLevel1 ]==="); // GIVEN @@ -170,7 +170,7 @@ public void test150OrLevel1() throws Exception { } @Test - public void test160OrLevel1WithoutAll() throws Exception { + public void test160OrLevel1WithoutAll() { System.out.println("===[ test160OrLevel1WithoutAll ]==="); // GIVEN @@ -190,7 +190,7 @@ public void test160OrLevel1WithoutAll() throws Exception { } @Test - public void test170OrLevel1Undefined() throws Exception { + public void test170OrLevel1Undefined() { System.out.println("===[ test170OrLevel1Undefined ]==="); // GIVEN @@ -207,7 +207,7 @@ public void test170OrLevel1Undefined() throws Exception { } @Test - public void test180OrEmpty() throws Exception { + public void test180OrEmpty() { System.out.println("===[ test180OrEmpty ]==="); // GIVEN @@ -224,7 +224,7 @@ public void test180OrEmpty() throws Exception { } @Test - public void test200AndLevel2() throws Exception { + public void test200AndLevel2() { System.out.println("===[ test200AndLevel2 ]==="); // GIVEN @@ -252,7 +252,7 @@ public void test200AndLevel2() throws Exception { } @Test - public void test210OrLevel2() throws Exception { + public void test210OrLevel2() { System.out.println("===[ test210OrLevel2 ]==="); // GIVEN @@ -280,7 +280,7 @@ public void test210OrLevel2() throws Exception { } @Test - public void test300NotAll() throws Exception { + public void test300NotAll() { System.out.println("===[ test300NotAll ]==="); // GIVEN @@ -299,7 +299,7 @@ public void test300NotAll() throws Exception { } @Test - public void test310NotNone() throws Exception { + public void test310NotNone() { System.out.println("===[ test310NotNone ]==="); // GIVEN @@ -318,7 +318,7 @@ public void test310NotNone() throws Exception { } @Test - public void test320NotNotAll() throws Exception { + public void test320NotNotAll() { System.out.println("===[ test320NotNotAll ]==="); // GIVEN @@ -337,7 +337,7 @@ public void test320NotNotAll() throws Exception { } @Test - public void test330NotNotNone() throws Exception { + public void test330NotNotNone() { System.out.println("===[ test330NotNotNone ]==="); // GIVEN @@ -356,7 +356,7 @@ public void test330NotNotNone() throws Exception { } @Test - public void test400TypeAll() throws Exception { + public void test400TypeAll() { System.out.println("===[ test400TypeAll ]==="); // GIVEN @@ -378,7 +378,7 @@ public void test400TypeAll() throws Exception { } @Test - public void test410TypeNone() throws Exception { + public void test410TypeNone() { System.out.println("===[ test410TypeNone ]==="); // GIVEN @@ -397,7 +397,7 @@ public void test410TypeNone() throws Exception { } @Test - public void test420TypeUndefined() throws Exception { + public void test420TypeUndefined() { System.out.println("===[ test420TypeUndefined ]==="); // GIVEN @@ -419,7 +419,7 @@ public void test420TypeUndefined() throws Exception { } @Test - public void test500ExistsAll() throws Exception { + public void test500ExistsAll() { System.out.println("===[ test500ExistsAll ]==="); // GIVEN @@ -436,12 +436,12 @@ public void test500ExistsAll() throws Exception { 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", UserType.F_ASSIGNMENT, existsSimplified.getFullPath()); + PrismAsserts.assertEquivalent("Wrong simplified filter path", UserType.F_ASSIGNMENT, existsSimplified.getFullPath()); assertTrue("Wrong simplified filter subfilter: " + existsSimplified.getFilter(), ObjectQueryUtil.isAll(existsSimplified.getFilter())); } @Test - public void test510ExistsNone() throws Exception { + public void test510ExistsNone() { System.out.println("===[ test510ExistsNone ]==="); // GIVEN @@ -460,7 +460,7 @@ public void test510ExistsNone() throws Exception { } @Test - public void test520ExistsUndefined() throws Exception { + public void test520ExistsUndefined() { System.out.println("===[ test520ExistsUndefined ]==="); // GIVEN @@ -477,7 +477,7 @@ public void test520ExistsUndefined() throws Exception { 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", UserType.F_ASSIGNMENT, existsSimplified.getFullPath()); + PrismAsserts.assertEquivalent("Wrong simplified filter path", UserType.F_ASSIGNMENT, existsSimplified.getFullPath()); assertTrue("Wrong simplified filter subfilter: " + existsSimplified.getFilter(), ObjectQueryUtil.isAll(existsSimplified.getFilter())); } diff --git a/infra/schema/testng-unit.xml b/infra/schema/testng-unit.xml index e4983261bc9..2473cbbde2f 100644 --- a/infra/schema/testng-unit.xml +++ b/infra/schema/testng-unit.xml @@ -138,6 +138,7 @@ + From 9f3e2830c6f817edaf5294eaa02b488f717af382 Mon Sep 17 00:00:00 2001 From: lskublik Date: Mon, 2 Mar 2020 13:41:49 +0100 Subject: [PATCH 87/97] adding change time tests to suite, some small changes (MID-6085) --- .../com/evolveum/midpoint/web/component/input/DatePanel.java | 1 + .../web/page/admin/configuration/InternalsClockPanel.java | 3 --- .../schrodinger/page/InternalsConfigurationPageTest.java | 4 ++-- testing/schrodingertest/testng-integration.xml | 5 +++++ .../schrodinger/component/configuration/ClockTab.java | 3 +++ 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/input/DatePanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/input/DatePanel.java index 095403e416d..75d9ebc7adc 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/input/DatePanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/input/DatePanel.java @@ -28,6 +28,7 @@ public DatePanel(String id, IModel model) { super(id); DateInput date = new DateInput(ID_INPUT, new XmlGregorianCalendarModel(model)); + date.setOutputMarkupId(true); add(date); } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/configuration/InternalsClockPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/configuration/InternalsClockPanel.java index 51fac38f711..f16800e9121 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/configuration/InternalsClockPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/configuration/InternalsClockPanel.java @@ -49,9 +49,6 @@ protected void onInitialize() { add(form); DatePanel offset = new DatePanel(ID_OFFSET, getModel()); - for (FormComponent formComponent : offset.getFormComponents()) { - formComponent.add(new EmptyOnBlurAjaxFormUpdatingBehaviour()); - } form.add(offset); AjaxSubmitButton saveButton = new AjaxSubmitButton(ID_BUTTON_SAVE, createStringResource("PageInternals.button.changeTime")) { diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/InternalsConfigurationPageTest.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/InternalsConfigurationPageTest.java index 35ed1a1be85..77af0f02a89 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/InternalsConfigurationPageTest.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/InternalsConfigurationPageTest.java @@ -34,7 +34,7 @@ private void cleanup() { } @Test - public void changeTime() { + public void test001changeTime() { ClockTab clockTab = configPage.clockTab(); clockTab.changeTime("5/15/2099", "10", "30", ClockTab.AmOrPmChoice.PM); @@ -51,7 +51,7 @@ public void changeTime() { } @Test - public void resetTime() { + public void test010resetTime() { ClockTab clockTab = configPage.clockTab(); clockTab.resetTime(); diff --git a/testing/schrodingertest/testng-integration.xml b/testing/schrodingertest/testng-integration.xml index e4598aa01d4..3711706773a 100644 --- a/testing/schrodingertest/testng-integration.xml +++ b/testing/schrodingertest/testng-integration.xml @@ -57,4 +57,9 @@ + + + + + diff --git a/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/component/configuration/ClockTab.java b/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/component/configuration/ClockTab.java index 5c1858a662a..edf76f714ac 100644 --- a/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/component/configuration/ClockTab.java +++ b/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/component/configuration/ClockTab.java @@ -7,6 +7,7 @@ package com.evolveum.midpoint.schrodinger.component.configuration; import com.codeborne.selenide.Condition; +import com.codeborne.selenide.Selenide; import com.codeborne.selenide.SelenideElement; import com.evolveum.midpoint.schrodinger.MidPoint; import com.evolveum.midpoint.schrodinger.component.Component; @@ -36,10 +37,12 @@ public void changeTime(String date, String hours, String minutes, AmOrPmChoice a SelenideElement hoursEle = findHours(); hoursEle.doubleClick(); + hoursEle.doubleClick(); hoursEle.sendKeys(hours); SelenideElement minutesEle = findMinutes(); minutesEle.doubleClick(); + minutesEle.doubleClick(); minutesEle.sendKeys(minutes); SelenideElement amOrPmChoiceEle = findAmOrPmChoice(); From 07cc7e696aa0795acbdb4f3f337aaf966b6cb024 Mon Sep 17 00:00:00 2001 From: lskublik Date: Mon, 2 Mar 2020 14:08:11 +0100 Subject: [PATCH 88/97] adding schrodinger LoginPage tests to suite --- .../schrodinger/page/AbstractLoginPageTest.java | 12 ++++++------ .../testing/schrodinger/page/LoginPageTest.java | 4 ++-- .../LoginPageWithAuthenticationConfigTest.java | 15 +++++++++------ 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/AbstractLoginPageTest.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/AbstractLoginPageTest.java index 669d5ad08ea..333bcb8bd02 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/AbstractLoginPageTest.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/AbstractLoginPageTest.java @@ -43,7 +43,7 @@ public void beforeClass() throws IOException { } @Test - public void loginLockoutUser() { + public void test001loginLockoutUser() { basicPage.loggedUser().logoutIfUserIsLogin(); open("/login"); for (int i = 0; i < 4; i++) { @@ -53,13 +53,13 @@ public void loginLockoutUser() { } @Test - public void loginDisabledUser() { + public void test002loginDisabledUser() { basicPage.loggedUser().logoutIfUserIsLogin(); unsuccessfulLogin("disabled_user", "5ecr3t"); } @Test - public void loginEnabledUserWithoutAuthorizationsUser() { + public void test003loginEnabledUserWithoutAuthorizationsUser() { basicPage.loggedUser().logoutIfUserIsLogin(); unsuccessfulLogin("enabled_user_without_authorizations", "5ecr3t"); } @@ -73,7 +73,7 @@ protected void unsuccessfulLogin(String username, String password){ } @Test - public void auditingSuccessfulLogin() { + public void test010auditingSuccessfulLogin() { basicPage.loggedUser().logoutIfUserIsLogin(); FormLoginPage login = midPoint.formLogin(); login.login("administrator", "5ecr3t"); @@ -89,7 +89,7 @@ protected void auditingSuccesfulLogin(String username) { } @Test - public void auditingFailLogin() { + public void test011auditingFailLogin() { basicPage.loggedUser().logoutIfUserIsLogin(); FormLoginPage login = midPoint.formLogin(); login.login("bad_administrator", "5ecr3t"); @@ -103,7 +103,7 @@ public void auditingFailLogin() { } @Test - public void auditingSuccessfulLogout() { + public void test012auditingSuccessfulLogout() { basicPage.loggedUser().logoutIfUserIsLogin(); FormLoginPage login = midPoint.formLogin(); login.login("administrator", "5ecr3t"); diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/LoginPageTest.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/LoginPageTest.java index 1c0dafa4af7..e2e3917b0a5 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/LoginPageTest.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/LoginPageTest.java @@ -28,7 +28,7 @@ public class LoginPageTest extends AbstractLoginPageTest { @Test - public void changeLanguageFormPage() { + public void test020changeLanguageFormPage() { basicPage.loggedUser().logoutIfUserIsLogin(); FormLoginPage login = midPoint.formLogin(); @@ -38,7 +38,7 @@ public void changeLanguageFormPage() { } @Test - public void changeLanguageSamlSelectPage() { + public void test021changeLanguageSamlSelectPage() { basicPage.loggedUser().logoutIfUserIsLogin(); SamlSelectPage login = midPoint.samlSelect(); login.goToUrl(); diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/LoginPageWithAuthenticationConfigTest.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/LoginPageWithAuthenticationConfigTest.java index a400fff05bd..f373e73343c 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/LoginPageWithAuthenticationConfigTest.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/LoginPageWithAuthenticationConfigTest.java @@ -61,7 +61,7 @@ public void beforeClass() throws IOException { SystemPage systemPage = new SystemPage(); PrismForm infrastructureForm = systemPage.infrastructureTab().form(); infrastructureForm.showEmptyAttributes("Infrastructure"); - infrastructureForm.addAttributeValue("defaultHostname", getConfiguration().getBaseUrl()); + infrastructureForm.addAttributeValue("publicHttpUrlPattern", getConfiguration().getBaseUrl()); File notificationFile = NOTIFICATION_FILE; notificationFile.createNewFile(); NotificationsTab notificationTab = systemPage.notificationsTab(); @@ -88,7 +88,7 @@ public void failWholeAuthenticationFlow() { } @Test - public void loginAndLogoutForAdministrators() { + public void test020loginAndLogoutForAdministrators() { basicPage.loggedUser().logoutIfUserIsLogin(); open("/auth/emergency/internalLoginForm"); FormLoginPage login = midPoint.formLogin(); @@ -98,14 +98,14 @@ public void loginAndLogoutForAdministrators() { } @Test - public void negativeLoginForAdministrators() { + public void test021negativeLoginForAdministrators() { basicPage.loggedUser().logoutIfUserIsLogin(); open("/auth/emergency/internalLoginForm"); unsuccessfulLogin("user_without_superuser", "5ecr3t"); } @Test - public void changePassowordMailNonce() throws IOException, InterruptedException { + public void test030changePassowordMailNonce() throws IOException, InterruptedException { basicPage.loggedUser().logoutIfUserIsLogin(); FormLoginPage login = midPoint.formLogin(); MailNoncePage mailNonce = (MailNoncePage) login.forgotPassword(); @@ -120,7 +120,7 @@ public void changePassowordMailNonce() throws IOException, InterruptedException } @Test - public void changePassowordSecurityQuestion() { + public void test031changePassowordSecurityQuestion() { basicPage.loggedUser().logoutIfUserIsLogin(); FormLoginPage login = midPoint.formLogin(); open("/login"); @@ -137,9 +137,12 @@ public void changePassowordSecurityQuestion() { } @Test - public void selfRegistration() throws IOException, InterruptedException { + public void test040selfRegistration() throws IOException, InterruptedException { basicPage.loggedUser().logoutIfUserIsLogin(); FormLoginPage login = midPoint.formLogin(); + open("/login"); + open("/"); + TimeUnit.SECONDS.sleep(2); SelfRegistrationPage registrationPage = login.register(); registrationPage.setGivenName("Test").setFamilyName("User").setEmail("test.user@evolveum.com").setPassword("5ecr3t").submit(); TimeUnit.SECONDS.sleep(4); From 938ebd982cf977bb14900d1dfd8b704a289c8d17 Mon Sep 17 00:00:00 2001 From: lskublik Date: Mon, 2 Mar 2020 14:10:39 +0100 Subject: [PATCH 89/97] adding schrodinger LoginPage tests to suite (forgotten file) --- testing/schrodingertest/testng-integration.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/testing/schrodingertest/testng-integration.xml b/testing/schrodingertest/testng-integration.xml index 3711706773a..8924df0dda8 100644 --- a/testing/schrodingertest/testng-integration.xml +++ b/testing/schrodingertest/testng-integration.xml @@ -62,4 +62,14 @@ + + + + + + + + + + From 2073c403041236b2131cdc7d2bb3c5672f2da3c0 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Mon, 2 Mar 2020 14:39:52 +0100 Subject: [PATCH 90/97] infra/schema: test review, added extends from AbstractSchemaTest --- .../midpoint/schema/AbstractSchemaTest.java | 16 +- .../midpoint/schema/TestDiffEquals.java | 106 ++---- .../midpoint/schema/TestDynamicSchema.java | 42 +-- .../midpoint/schema/TestEmptyItems.java | 61 ++-- .../evolveum/midpoint/schema/TestExport.java | 35 +- .../midpoint/schema/TestFilterSimplifier.java | 138 +++----- .../midpoint/schema/TestImmutable.java | 44 +-- .../midpoint/schema/TestJaxbConstruction.java | 121 +++---- .../midpoint/schema/TestJaxbParsing.java | 94 ++--- .../midpoint/schema/TestJaxbSanity.java | 327 ------------------ .../schema/TestLazyDumpPerformance.java | 35 +- .../midpoint/schema/TestMiscellaneous.java | 42 +-- .../schema/TestObjectConstruction.java | 30 +- .../midpoint/schema/TestOperationResult.java | 53 +-- .../midpoint/schema/TestParseDiffPatch.java | 281 +++++---------- .../midpoint/schema/TestParseFilter.java | 41 +-- .../schema/TestParseGenericObject.java | 118 ++----- .../midpoint/schema/TestParseLookupTable.java | 35 +- .../midpoint/schema/TestParseMisc.java | 35 +- .../schema/TestParseModelContext.java | 220 ------------ .../schema/TestParseObjectTemplate.java | 84 ++--- .../schema/TestParsePasswordPolicy.java | 41 +-- .../midpoint/schema/TestParseTask.java | 73 ++-- .../schema/TestParseTaskBulkAction.java | 46 +-- .../schema/TestParseTaskBulkAction2.java | 88 +---- .../midpoint/schema/TestQueryConverter.java | 3 - .../midpoint/schema/TestSchemaDelta.java | 17 - .../schema/TestSchemaImmutability.java | 32 +- .../midpoint/schema/TestSchemaRegistry.java | 67 ++-- .../midpoint/schema/TestSchemaSanity.java | 98 +----- .../midpoint/schema/TestSerialization.java | 52 +-- .../schema/processor/TestResourceSchema.java | 89 ++--- .../schema/validator/TestObjectValidator.java | 4 - .../src/test/resources/common/filter.xml | 7 +- infra/schema/testng-unit.xml | 3 +- 35 files changed, 534 insertions(+), 2044 deletions(-) delete mode 100644 infra/schema/src/test/java/com/evolveum/midpoint/schema/TestJaxbSanity.java delete mode 100644 infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseModelContext.java diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/AbstractSchemaTest.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/AbstractSchemaTest.java index 0e094501123..b8f8f2fb13e 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/AbstractSchemaTest.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/AbstractSchemaTest.java @@ -6,6 +6,8 @@ */ package com.evolveum.midpoint.schema; +import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; + import java.io.File; import java.io.IOException; @@ -16,17 +18,15 @@ import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.util.SchemaDebugUtil; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; - /** * @author semancik - * */ -public abstract class AbstractSchemaTest { +public abstract class AbstractSchemaTest extends AbstractUnitTest { protected static final File COMMON_DIR = new File("src/test/resources/common"); @@ -52,12 +52,4 @@ public void setup() throws SchemaException, SAXException, IOException { protected PrismObjectDefinition getUserDefinition() { return getPrismContext().getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class); } - - protected void displayTestTile(String TEST_NAME) { - System.out.println("===[ "+TEST_NAME+" ]===="); - } - -// protected UniformItemPath path(Object... components) { -// return getPrismContext().path(components); -// } } diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestDiffEquals.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestDiffEquals.java index 1aed9d8fb8e..44f1151fd17 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestDiffEquals.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestDiffEquals.java @@ -7,6 +7,19 @@ package com.evolveum.midpoint.schema; +import static org.testng.AssertJUnit.*; + +import static com.evolveum.midpoint.prism.equivalence.ParameterizedEquivalenceStrategy.LITERAL; +import static com.evolveum.midpoint.prism.equivalence.ParameterizedEquivalenceStrategy.NOT_LITERAL; + +import java.io.File; +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import javax.xml.namespace.QName; + +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.delta.ChangeType; import com.evolveum.midpoint.prism.delta.ObjectDelta; @@ -16,37 +29,19 @@ import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.prism.xml.XmlTypeConverter; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.util.PolicyRuleTypeUtil; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.DebugUtil; -import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import javax.xml.namespace.QName; -import java.io.File; -import java.io.IOException; -import java.util.Arrays; -import java.util.Date; -import java.util.List; - -import static com.evolveum.midpoint.prism.equivalence.ParameterizedEquivalenceStrategy.LITERAL; -import static com.evolveum.midpoint.prism.equivalence.ParameterizedEquivalenceStrategy.NOT_LITERAL; -import static org.testng.AssertJUnit.*; /** * @author lazyman */ -public class TestDiffEquals { +public class TestDiffEquals extends AbstractSchemaTest { public static final File TEST_DIR = new File("src/test/resources/diff"); private static final File ROLE_COMPARE_FILE = new File(TEST_DIR, "role-compare.xml"); @@ -56,17 +51,8 @@ public class TestDiffEquals { private static final String NS_TEST_RI = "http://midpoint.evolveum.com/xml/ns/test/ri-1"; - private static final Trace LOGGER = TraceManager.getTrace(TestDiffEquals.class); - - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } - @Test public void testUserSimplePropertyDiff() throws SchemaException { - System.out.println("\n\n===[ testUserSimplePropertyDiff ]===\n"); UserType userType1 = new UserType(); userType1.setName(PrismTestUtil.createPolyStringType("test name")); UserType userType2 = new UserType(); @@ -87,7 +73,6 @@ public void testUserSimplePropertyDiff() throws SchemaException { @Test public void testUserListSimpleDiff() throws SchemaException { - System.out.println("\n\n===[ testUserListSimpleDiff ]===\n"); UserType u1 = new UserType(); u1.setName(PrismTestUtil.createPolyStringType("test name")); UserType u2 = new UserType(); @@ -108,7 +93,6 @@ public void testUserListSimpleDiff() throws SchemaException { @Test public void testAssignmentEquals1() throws Exception { - System.out.println("\n\n===[ testAssignmentEquals1 ]===\n"); PrismContext prismContext = PrismTestUtil.getPrismContext(); AssignmentType a1a = new AssignmentType(); @@ -167,9 +151,8 @@ public void testAssignmentEquals1() throws Exception { assertTrue(a1e.equals(a1m)); } - @Test(enabled=false) // MID-3966 + @Test(enabled = false) // MID-3966 public void testAssignmentEquals2() throws Exception { - System.out.println("\n\n===[ testAssignmentEquals2 ]===\n"); PrismContext prismContext = PrismTestUtil.getPrismContext(); PrismObject roleCompare = prismContext.parseObject(ROLE_COMPARE_FILE); @@ -190,8 +173,7 @@ public void testAssignmentEquals2() throws Exception { } @Test - public void testAssignmentEquivalent() throws Exception { - System.out.println("\n\n===[ testAssignmentEquivalent ]===\n"); + public void testAssignmentEquivalent() { PrismContext prismContext = PrismTestUtil.getPrismContext(); AssignmentType a1 = new AssignmentType(prismContext); @@ -215,7 +197,6 @@ public void testAssignmentEquivalent() throws Exception { @Test public void testContextlessAssignmentEquals() throws Exception { - System.out.println("\n\n===[ testContextlessAssignmentEquals ]===\n"); AssignmentType a1 = new AssignmentType(); // no prismContext here a1.setDescription("descr1"); @@ -238,8 +219,6 @@ public void testContextlessAssignmentEquals() throws Exception { @Test public void testContextlessAssignmentEquals2() throws Exception { - System.out.println("\n\n===[ testContextlessAssignmentEquals2 ]===\n"); - // (1) user without prismContext - the functionality is reduced UserType user = new UserType(); @@ -284,8 +263,6 @@ public void testContextlessAssignmentEquals2() throws Exception { @Test public void testAssignmentHashcode() throws Exception { - LOGGER.info("\n\n===[ testAssignmentHashcode ]===\n"); - System.out.println("\n\n===[ testAssignmentHashcode ]===\n"); PrismContext prismContext = PrismTestUtil.getPrismContext(); AssignmentType a1a = new AssignmentType(); @@ -347,23 +324,21 @@ public void testAssignmentHashcode() throws Exception { // MID-4251 @Test public void testAssignmentHashcode2() { - LOGGER.info("\n\n===[ testAssignmentHashcode2 ]===\n"); - System.out.println("\n\n===[ testAssignmentHashcode2 ]===\n"); PrismContext prismContext = PrismTestUtil.getPrismContext(); AssignmentType a1a = new AssignmentType(prismContext).id(6L) .beginMetadata() - .createApprovalComment("hi") + .createApprovalComment("hi") .end() .targetRef(new ObjectReferenceType().oid("target").type(OrgType.COMPLEX_TYPE).relation(SchemaConstants.ORG_DEFAULT)) .beginActivation() - .effectiveStatus(ActivationStatusType.ENABLED) - .validTo("2018-01-01T00:00:00.000+01:00") + .effectiveStatus(ActivationStatusType.ENABLED) + .validTo("2018-01-01T00:00:00.000+01:00") .end(); AssignmentType a1b = new AssignmentType(prismContext) .targetRef(new ObjectReferenceType().oid("target").type(OrgType.COMPLEX_TYPE)) .beginActivation() - .validTo("2018-01-01T00:00:00.000+01:00") + .validTo("2018-01-01T00:00:00.000+01:00") .end(); // WHEN @@ -372,14 +347,12 @@ public void testAssignmentHashcode2() { // MID-4251 @Test - public void testAssignmentHashcode3() throws SchemaException { - LOGGER.info("\n\n===[ testAssignmentHashcode3 ]===\n"); - System.out.println("\n\n===[ testAssignmentHashcode3 ]===\n"); + public void testAssignmentHashcode3() { PrismContext prismContext = PrismTestUtil.getPrismContext(); AssignmentType a1a = new AssignmentType(prismContext) .beginActivation() - .validTo("2018-01-01T00:00:00.000+01:00") + .validTo("2018-01-01T00:00:00.000+01:00") .end(); AssignmentType a1b = a1a.clone(); @@ -397,7 +370,6 @@ public void testAssignmentHashcode3() throws SchemaException { @Test public void testDiffShadow() throws Exception { - System.out.println("\n\n===[ testDiffShadow ]===\n"); PrismContext prismContext = PrismTestUtil.getPrismContext(); PrismObject shadow1 = prismContext.getSchemaRegistry() @@ -449,7 +421,7 @@ public void testDiffShadow() throws Exception { } @Test - public void testTriggerCollectionsEqual() throws Exception { + public void testTriggerCollectionsEqual() { EvaluatedPolicyRuleTriggerType trigger1 = new EvaluatedPolicyRuleTriggerType() .triggerId(100) .ruleName("rule100"); @@ -476,7 +448,7 @@ public void testTriggerCollectionsEqual() throws Exception { .ruleName("rule1") .sourceRule(sourceRule2) .sourceRule(sourceRule1) - ); + ); List triggerListC = Arrays.asList( trigger1, trigger2, @@ -485,7 +457,7 @@ public void testTriggerCollectionsEqual() throws Exception { .ruleName("rule123") .sourceRule(sourceRule2) .sourceRule(sourceRule1) - ); + ); assertEquals("Wrong comparison A-A", true, PolicyRuleTypeUtil.triggerCollectionsEqual(triggerListA, triggerListA)); assertEquals("Wrong comparison A-B", true, PolicyRuleTypeUtil.triggerCollectionsEqual(triggerListA, triggerListB)); @@ -505,7 +477,6 @@ public void diffRoles() throws Exception { @Test // MID-4688 public void testDiffWithMetadata() { - System.out.println("\n\n===[ testDiffWithMetadata ]===\n"); PrismContext prismContext = PrismTestUtil.getPrismContext(); ProtectedStringType value = new ProtectedStringType(); @@ -513,21 +484,21 @@ public void testDiffWithMetadata() { PrismObject user1 = new UserType(prismContext) .beginCredentials() - .beginPassword() - .value(value.clone()) - .beginMetadata() - .requestorComment("hi") - .end() - .end() + .beginPassword() + .value(value.clone()) + .beginMetadata() + .requestorComment("hi") + .end() + .end() .end() .asPrismObject(); PrismObject user2 = new UserType(prismContext) .beginCredentials() - .beginPassword() - .value(value.clone()) - .beginMetadata() - .end() - .end() + .beginPassword() + .value(value.clone()) + .beginMetadata() + .end() + .end() .end() .asPrismObject(); @@ -546,8 +517,6 @@ public void testDiffWithMetadata() { // MID-5851 @Test public void testRawValuesHashCode() throws SchemaException { - LOGGER.info("\n\n===[ testRawValuesHashCode ]===\n"); - System.out.println("\n\n===[ testRawValuesHashCode ]===\n"); PrismContext prismContext = PrismTestUtil.getPrismContext(); QName extensionPropertyName = new QName(NS_TEST_RI, "extensionProperty"); @@ -559,7 +528,7 @@ public void testRawValuesHashCode() throws SchemaException { PrismProperty propertyParsed = extensionPropertyDef.instantiate(); PrismProperty propertyRaw = extensionPropertyDef.instantiate(); propertyParsed.setRealValue("value"); - propertyRaw.setValue(prismContext.itemFactory().createPropertyValue(new PrimitiveXNodeImpl("value"))); + propertyRaw.setValue(prismContext.itemFactory().createPropertyValue(new PrimitiveXNodeImpl<>("value"))); PrismObject userParsed = new UserType(prismContext) .name("user") @@ -594,5 +563,4 @@ private void assertHashAndEquals(PrismObject user1, PrismObject assignmentExtensionContainer = parseUserAssignmentContainer(); @@ -64,8 +44,6 @@ public void testAssignmentExtensionContainerProperty() throws Exception { @Test public void testAssignmentExtensionContainerItem() throws Exception { - System.out.println("===[ testAssignmentExtensionContainerItem ]==="); - // GIVEN PrismContainer assignmentExtensionContainer = parseUserAssignmentContainer(); @@ -81,8 +59,6 @@ public void testAssignmentExtensionContainerItem() throws Exception { @Test public void testAssignmentExtensionValueProperty() throws Exception { - System.out.println("===[ testAssignmentExtensionValueProperty ]==="); - // GIVEN PrismContainer assignmentExtensionContainer = parseUserAssignmentContainer(); PrismContainerValue assignmentExtensionContainerValue = assignmentExtensionContainer.getValue(); @@ -98,8 +74,6 @@ public void testAssignmentExtensionValueProperty() throws Exception { @Test public void testAssignmentExtensionValueItem() throws Exception { - System.out.println("===[ testAssignmentExtensionValueItem ]==="); - // GIVEN PrismContainer assignmentExtensionContainer = parseUserAssignmentContainer(); PrismContainerValue assignmentExtensionContainerValue = assignmentExtensionContainer.getValue(); @@ -114,9 +88,6 @@ public void testAssignmentExtensionValueItem() throws Exception { PrismAsserts.assertDefinition(assignmentExtensionStringProperty.getDefinition(), EXTENSION_STRING_TYPE_ELEMENT, DOMUtil.XSD_STRING, 0, -1); } - - - private PrismContainer parseUserAssignmentContainer() throws SchemaException, IOException { PrismContext prismContext = getPrismContext(); PrismObject user = prismContext.parseObject(USER_FILE); @@ -125,5 +96,4 @@ private PrismContainer parseUserAssignmentContainer() throws Sch return user.findContainer(ItemPath.create(UserType.F_ASSIGNMENT, USER_ASSIGNMENT_1_ID, AssignmentType.F_EXTENSION)); } - } diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestEmptyItems.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestEmptyItems.java index ed47f8482ab..735636a1ec3 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestEmptyItems.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestEmptyItems.java @@ -6,40 +6,25 @@ */ package com.evolveum.midpoint.schema; -import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; +import static org.testng.AssertJUnit.assertEquals; + +import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; + +import org.testng.annotations.Test; + import com.evolveum.midpoint.schema.constants.SchemaConstants; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; -import org.apache.commons.collections4.CollectionUtils; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import java.io.IOException; - -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; -import static org.testng.AssertJUnit.assertEquals; /** * Tests for mistakenly adding new empty items (PP, PR, PC) into PCVs. * * @author mederly */ -public class TestEmptyItems { - - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } +public class TestEmptyItems extends AbstractSchemaTest { @Test - public void testEmptyItemsOnGet() throws Exception { - System.out.println("===[ testEmptyItemsOnGet ]==="); - + public void testEmptyItemsOnGet() { // GIVEN UserType user = new UserType(getPrismContext()); System.out.println("User before:\n" + user.asPrismObject().debugDump()); @@ -57,8 +42,6 @@ public void testEmptyItemsOnGet() throws Exception { @Test public void testEmptyItemsOnParse() throws Exception { - System.out.println("===[ testEmptyItemsOnParse ]==="); - // GIVEN UserType user = new UserType(getPrismContext()); user.setName(PolyStringType.fromOrig("jack")); @@ -75,8 +58,7 @@ public void testEmptyItemsOnParse() throws Exception { } @Test - public void testEmptyItemsOnConstructed() throws Exception { - System.out.println("===[ testEmptyItemsOnConstructed ]==="); + public void testEmptyItemsOnConstructed() { UserType jack = new UserType(getPrismContext()) .oid("00000000-0000-0000-0000-000000000002").version("42") .name("jack") @@ -85,20 +67,20 @@ public void testEmptyItemsOnConstructed() throws Exception { .honorificPrefix("Cpt.") .honorificSuffix("PhD.") .beginAssignment() - .beginActivation() - .administrativeStatus(ActivationStatusType.ENABLED) - .enableTimestamp("2016-12-31T23:59:59+01:00") - .end() - .beginConstruction() - .resourceRef("00000000-1233-4443-3123-943412324212", ResourceType.COMPLEX_TYPE) - .end() + .beginActivation() + .administrativeStatus(ActivationStatusType.ENABLED) + .enableTimestamp("2016-12-31T23:59:59+01:00") + .end() + .beginConstruction() + .resourceRef("00000000-1233-4443-3123-943412324212", ResourceType.COMPLEX_TYPE) + .end() .end() .beginAssignment() - .beginActivation() - .validFrom("2017-01-01T12:00:00+01:00") - .validTo("2017-03-31T00:00:00+01:00") - .end() - .targetRef("83138913-4329-4323-3432-432432143612", RoleType.COMPLEX_TYPE, SchemaConstants.ORG_APPROVER) + .beginActivation() + .validFrom("2017-01-01T12:00:00+01:00") + .validTo("2017-03-31T00:00:00+01:00") + .end() + .targetRef("83138913-4329-4323-3432-432432143612", RoleType.COMPLEX_TYPE, SchemaConstants.ORG_APPROVER) .end() .employeeType("pirate") .employeeType("captain") @@ -116,5 +98,4 @@ public void testEmptyItemsOnConstructed() throws Exception { System.out.println("User after:\n" + jack.asPrismObject().debugDump()); assertEquals("Wrong # of user sub-items after 'get' operations", 8, jack.asPrismContainerValue().size()); } - } diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestExport.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestExport.java index 0902d80e5a7..90e68f28a88 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestExport.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestExport.java @@ -6,6 +6,15 @@ */ package com.evolveum.midpoint.schema; +import static org.testng.AssertJUnit.assertFalse; +import static org.testng.AssertJUnit.assertNotNull; + +import static com.evolveum.midpoint.prism.SerializationOptions.createSerializeForExport; + +import javax.xml.namespace.QName; + +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.util.PrismAsserts; @@ -13,36 +22,12 @@ import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.util.SchemaTestConstants; import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; -import javax.xml.namespace.QName; -import java.io.IOException; - -import static com.evolveum.midpoint.prism.SerializationOptions.createSerializeForExport; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; - -/** - * @author mederly - * - */ -public class TestExport { - - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } +public class TestExport extends AbstractSchemaTest { @Test public void testExportShadow() throws Exception { - System.out.println("===[ testExportShadow ]==="); - PrismContext prismContext = PrismTestUtil.getPrismContext(); PrismObject shadow = prismContext.createObjectable(ShadowType.class) .name("shadow1") diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestFilterSimplifier.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestFilterSimplifier.java index 37ca4ab1a8e..0efbb073344 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestFilterSimplifier.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestFilterSimplifier.java @@ -6,40 +6,25 @@ */ package com.evolveum.midpoint.schema; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertTrue; + +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.query.*; import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.util.ObjectQueryUtil; import com.evolveum.midpoint.util.DebugUtil; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import java.io.IOException; - -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertTrue; /** * @author mederly - * */ -public class TestFilterSimplifier { - - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } +public class TestFilterSimplifier extends AbstractSchemaTest { @Test - public void test010All() throws Exception { - System.out.println("===[ test010All ]==="); - + public void test010All() { // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -55,9 +40,7 @@ public void test010All() throws Exception { } @Test - public void test020None() throws Exception { - System.out.println("===[ test020None ]==="); - + public void test020None() { // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -73,9 +56,7 @@ public void test020None() throws Exception { } @Test - public void test030Undefined() throws Exception { - System.out.println("===[ test030Undefined ]==="); - + public void test030Undefined() { // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -91,9 +72,7 @@ public void test030Undefined() throws Exception { } @Test - public void test100AndLevel1() throws Exception { - System.out.println("===[ test100AndLevel1 ]==="); - + public void test100AndLevel1() { // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -112,9 +91,7 @@ public void test100AndLevel1() throws Exception { } @Test - public void test110AndLevel1WithoutNone() throws Exception { - System.out.println("===[ test110AndLevel1WithoutNone ]==="); - + public void test110AndLevel1WithoutNone() { // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -132,9 +109,7 @@ public void test110AndLevel1WithoutNone() throws Exception { } @Test - public void test120AndEmpty() throws Exception { - System.out.println("===[ test120AndEmpty ]==="); - + public void test120AndEmpty() { // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -149,9 +124,7 @@ public void test120AndEmpty() throws Exception { } @Test - public void test150OrLevel1() throws Exception { - System.out.println("===[ test150OrLevel1 ]==="); - + public void test150OrLevel1() { // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -170,9 +143,7 @@ public void test150OrLevel1() throws Exception { } @Test - public void test160OrLevel1WithoutAll() throws Exception { - System.out.println("===[ test160OrLevel1WithoutAll ]==="); - + public void test160OrLevel1WithoutAll() { // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -190,9 +161,7 @@ public void test160OrLevel1WithoutAll() throws Exception { } @Test - public void test170OrLevel1Undefined() throws Exception { - System.out.println("===[ test170OrLevel1Undefined ]==="); - + public void test170OrLevel1Undefined() { // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -207,9 +176,7 @@ public void test170OrLevel1Undefined() throws Exception { } @Test - public void test180OrEmpty() throws Exception { - System.out.println("===[ test180OrEmpty ]==="); - + public void test180OrEmpty() { // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -224,9 +191,7 @@ public void test180OrEmpty() throws Exception { } @Test - public void test200AndLevel2() throws Exception { - System.out.println("===[ test200AndLevel2 ]==="); - + public void test200AndLevel2() { // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -235,13 +200,13 @@ public void test200AndLevel2() throws Exception { .all() .and().undefined() .and() - .block() - .none().or().none() - .endBlock() + .block() + .none().or().none() + .endBlock() .and() - .block() - .none().or().none() - .endBlock() + .block() + .none().or().none() + .endBlock() .buildFilter(); System.out.println("Original filter:\n" + filter.debugDump()); @@ -252,9 +217,7 @@ public void test200AndLevel2() throws Exception { } @Test - public void test210OrLevel2() throws Exception { - System.out.println("===[ test210OrLevel2 ]==="); - + public void test210OrLevel2() { // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -263,13 +226,13 @@ public void test210OrLevel2() throws Exception { .none() .or().undefined() .or() - .block() - .none().or().none() - .endBlock() + .block() + .none().or().none() + .endBlock() .or() - .block() - .none().or().none() - .endBlock() + .block() + .none().or().none() + .endBlock() .buildFilter(); System.out.println("Original filter:\n" + filter.debugDump()); @@ -280,9 +243,7 @@ public void test210OrLevel2() throws Exception { } @Test - public void test300NotAll() throws Exception { - System.out.println("===[ test300NotAll ]==="); - + public void test300NotAll() { // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -299,9 +260,7 @@ public void test300NotAll() throws Exception { } @Test - public void test310NotNone() throws Exception { - System.out.println("===[ test310NotNone ]==="); - + public void test310NotNone() { // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -318,9 +277,7 @@ public void test310NotNone() throws Exception { } @Test - public void test320NotNotAll() throws Exception { - System.out.println("===[ test320NotNotAll ]==="); - + public void test320NotNotAll() { // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -337,9 +294,7 @@ public void test320NotNotAll() throws Exception { } @Test - public void test330NotNotNone() throws Exception { - System.out.println("===[ test330NotNotNone ]==="); - + public void test330NotNotNone() { // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -356,9 +311,7 @@ public void test330NotNotNone() throws Exception { } @Test - public void test400TypeAll() throws Exception { - System.out.println("===[ test400TypeAll ]==="); - + public void test400TypeAll() { // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -378,9 +331,7 @@ public void test400TypeAll() throws Exception { } @Test - public void test410TypeNone() throws Exception { - System.out.println("===[ test410TypeNone ]==="); - + public void test410TypeNone() { // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -397,9 +348,7 @@ public void test410TypeNone() throws Exception { } @Test - public void test420TypeUndefined() throws Exception { - System.out.println("===[ test420TypeUndefined ]==="); - + public void test420TypeUndefined() { // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -419,9 +368,7 @@ public void test420TypeUndefined() throws Exception { } @Test - public void test500ExistsAll() throws Exception { - System.out.println("===[ test500ExistsAll ]==="); - + public void test500ExistsAll() { // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -441,9 +388,7 @@ public void test500ExistsAll() throws Exception { } @Test - public void test510ExistsNone() throws Exception { - System.out.println("===[ test510ExistsNone ]==="); - + public void test510ExistsNone() { // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -460,9 +405,7 @@ public void test510ExistsNone() throws Exception { } @Test - public void test520ExistsUndefined() throws Exception { - System.out.println("===[ test520ExistsUndefined ]==="); - + public void test520ExistsUndefined() { // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -480,5 +423,4 @@ public void test520ExistsUndefined() throws Exception { assertEquals("Wrong simplified filter path", UserType.F_ASSIGNMENT, existsSimplified.getFullPath()); assertTrue("Wrong simplified filter subfilter: " + existsSimplified.getFilter(), ObjectQueryUtil.isAll(existsSimplified.getFilter())); } - } diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestImmutable.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestImmutable.java index 830e5ec7262..ba11e40ad89 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestImmutable.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestImmutable.java @@ -7,45 +7,30 @@ package com.evolveum.midpoint.schema; +import java.util.Date; +import javax.xml.datatype.XMLGregorianCalendar; +import javax.xml.namespace.QName; + +import org.testng.AssertJUnit; +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.prism.xml.XmlTypeConverter; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.constants.ObjectTypes; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.util.ObjectTypeUtil; import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; -import org.testng.AssertJUnit; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import javax.xml.datatype.XMLGregorianCalendar; -import javax.xml.namespace.QName; -import java.io.IOException; -import java.util.Date; - -import static org.testng.AssertJUnit.assertEquals; /** * @author mederly */ -public class TestImmutable { - - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } +public class TestImmutable extends AbstractSchemaTest { @Test - public void test010SimpleProperty() throws Exception { - System.out.println("===[ test010SimpleProperty ]==="); - + public void test010SimpleProperty() { // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -72,9 +57,7 @@ public void test010SimpleProperty() throws Exception { } @Test - public void test020DateProperty() throws Exception { - System.out.println("===[ test020DateProperty ]==="); - + public void test020DateProperty() { // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -83,7 +66,7 @@ public void test020DateProperty() throws Exception { new QName(SchemaConstants.NS_C, "dateTime"), DOMUtil.XSD_DATETIME); PrismProperty datePP = datePPD.instantiate(); Date now = new Date(); - Date yesterday = new Date(now.getTime()-86400000L); + Date yesterday = new Date(now.getTime() - 86400000L); datePP.setRealValue(XmlTypeConverter.createXMLGregorianCalendar(now)); datePP.freeze(); @@ -111,8 +94,6 @@ public void test020DateProperty() throws Exception { @Test public void test030Reference() throws Exception { - System.out.println("===[ test030Reference ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -140,8 +121,6 @@ public void test030Reference() throws Exception { @Test public void test100Resource() throws Exception { - System.out.println("===[ test100Resource ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -209,5 +188,4 @@ public void test100Resource() throws Exception { // } } - } diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestJaxbConstruction.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestJaxbConstruction.java index 4dec6de8226..cb70afbb2f3 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestJaxbConstruction.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestJaxbConstruction.java @@ -6,73 +6,49 @@ */ package com.evolveum.midpoint.schema; +import static org.testng.AssertJUnit.*; + import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertTrue; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; import static com.evolveum.midpoint.schema.TestConstants.*; -import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; - -import javax.xml.bind.JAXBException; import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.*; - -import com.evolveum.midpoint.prism.path.ItemName; -import com.evolveum.midpoint.prism.xnode.*; -import com.evolveum.prism.xml.ns._public.types_3.ItemPathType; import org.testng.AssertJUnit; -import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; import org.w3c.dom.Element; -import org.xml.sax.SAXException; +import com.evolveum.midpoint.prism.*; +import com.evolveum.midpoint.prism.path.ItemName; import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; +import com.evolveum.midpoint.prism.xnode.MapXNode; +import com.evolveum.midpoint.prism.xnode.PrimitiveXNode; +import com.evolveum.midpoint.prism.xnode.XNode; +import com.evolveum.midpoint.prism.xnode.XNodeFactory; import com.evolveum.midpoint.schema.util.SchemaTestConstants; import com.evolveum.midpoint.schema.util.SchemaTestUtil; import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.CachingMetadataType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ExtensionType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.XmlSchemaType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.query_3.SearchFilterType; +import com.evolveum.prism.xml.ns._public.types_3.ItemPathType; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; import com.evolveum.prism.xml.ns._public.types_3.SchemaDefinitionType; /** * @author semancik - * */ -public class TestJaxbConstruction { +public class TestJaxbConstruction extends AbstractSchemaTest { private static final String FAUX_RESOURCE_OID = "fuuuuuuuuuuu"; private static final String ACCOUNT_NAME = "jack"; - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } - @Test - public void testUserConstruction() throws JAXBException, SchemaException { - System.out.println("\n\n ===[ testUserConstruction ]===\n"); - + public void testUserConstruction() throws SchemaException { // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -93,7 +69,7 @@ public void testUserConstruction() throws JAXBException, SchemaException { // description: setting null value userType.setDescription(null); PrismProperty descriptionProperty = user.findProperty(UserType.F_DESCRIPTION); - assertNull("Unexpected description property "+descriptionProperty, descriptionProperty); + assertNull("Unexpected description property " + descriptionProperty, descriptionProperty); // description: setting null value userType.setDescription("blah blah"); @@ -103,7 +79,7 @@ public void testUserConstruction() throws JAXBException, SchemaException { // description: resetting null value userType.setDescription(null); descriptionProperty = user.findProperty(UserType.F_DESCRIPTION); - assertNull("Unexpected description property (after reset) "+descriptionProperty, descriptionProperty); + assertNull("Unexpected description property (after reset) " + descriptionProperty, descriptionProperty); // Extension ExtensionType extension = new ExtensionType(); @@ -112,8 +88,8 @@ public void testUserConstruction() throws JAXBException, SchemaException { user.checkConsistence(); PrismContainer extensionContainer = user.findContainer(GenericObjectType.F_EXTENSION); - checkExtension(extensionContainer,"user extension after setExtension"); - checkExtension(extension,"user extension after setExtension"); + checkExtension(extensionContainer, "user extension after setExtension"); + checkExtension(extension, "user extension after setExtension"); AssignmentType assignmentType = new AssignmentType(); userType.getAssignment().add(assignmentType); @@ -127,7 +103,7 @@ public void testUserConstruction() throws JAXBException, SchemaException { user.assertDefinitions(); user.checkConsistence(); - checkExtension(assignmentExtension,"assignment extension after setExtension"); + checkExtension(assignmentExtension, "assignment extension after setExtension"); user.checkConsistence(); user.assertDefinitions(); @@ -178,8 +154,6 @@ public void testUserConstruction() throws JAXBException, SchemaException { @Test public void testUserConstructionBeforeAdopt() throws Exception { - System.out.println("\n\n ===[ testUserConstructionBeforeAdopt ]===\n"); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -193,12 +167,10 @@ public void testUserConstructionBeforeAdopt() throws Exception { AssignmentType assignmentType = new AssignmentType(); userType.getAssignment().add(assignmentType); - // Assignment ExtensionType assignmentExtension = new ExtensionType(); assignmentType.setExtension(assignmentExtension); - // accountRef/account ObjectReferenceType accountRefType = new ObjectReferenceType(); accountRefType.setOid(USER_ACCOUNT_REF_1_OID); @@ -209,7 +181,6 @@ public void testUserConstructionBeforeAdopt() throws Exception { accountRefType.setFilter(filter); userType.getLinkRef().add(accountRefType); - ShadowType accountShadowType = new ShadowType(); prismContext.adopt(accountShadowType); accountShadowType.setOid(USER_ACCOUNT_REF_1_OID); @@ -234,7 +205,6 @@ public void testUserConstructionBeforeAdopt() throws Exception { user.checkConsistence(); user.assertDefinitions(); - PolyString fullName = fullNameProperty.getRealValue(); assertEquals("Wrong fullName orig", "Čučoriedka", fullName.getOrig()); assertEquals("Wrong fullName norm", "cucoriedka", fullName.getNorm()); @@ -243,8 +213,8 @@ public void testUserConstructionBeforeAdopt() throws Exception { assertEquals("Wrong description value", "blah blah", descriptionProperty.getRealValue()); PrismContainer extensionContainer = user.findContainer(GenericObjectType.F_EXTENSION); - checkExtension(extensionContainer,"user extension"); - checkExtension(extension,"user extension"); + checkExtension(extensionContainer, "user extension"); + checkExtension(extension, "user extension"); PrismReference accountRef = user.findReference(UserType.F_LINK_REF); assertEquals("Wrong accountRef values", 2, accountRef.getValues().size()); @@ -263,22 +233,21 @@ public void testUserConstructionBeforeAdopt() throws Exception { } - private void assertAccountRefs(UserType userType, String... accountOids) { List accountRefs = userType.getLinkRef(); assertEquals("Wrong number of accountRefs", accountOids.length, accountRefs.size()); - for (String expectedAccountOid: accountOids) { + for (String expectedAccountOid : accountOids) { assertAccountRef(accountRefs, expectedAccountOid); } } private void assertAccountRef(List accountRefs, String expectedAccountOid) { - for (ObjectReferenceType accountRef: accountRefs) { + for (ObjectReferenceType accountRef : accountRefs) { if (accountRef.getOid().equals(expectedAccountOid)) { return; } } - AssertJUnit.fail("acountRef for oid "+expectedAccountOid+" was not found"); + AssertJUnit.fail("acountRef for oid " + expectedAccountOid + " was not found"); } /** @@ -286,9 +255,7 @@ private void assertAccountRef(List accountRefs, String expe * e.g. assignment is filled in first then set to the user. */ @Test - public void testUserConstructionReverse() throws JAXBException, SchemaException { - System.out.println("\n\n ===[ testUserConstructionReverse ]===\n"); - + public void testUserConstructionReverse() throws SchemaException { // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -304,8 +271,8 @@ public void testUserConstructionReverse() throws JAXBException, SchemaException user.checkConsistence(); PrismContainer extensionContainer = user.findContainer(GenericObjectType.F_EXTENSION); - checkExtension(extensionContainer,"user extension after setExtension"); - checkExtension(extension,"user extension after setExtension"); + checkExtension(extensionContainer, "user extension after setExtension"); + checkExtension(extension, "user extension after setExtension"); AssignmentType assignmentType = new AssignmentType(prismContext); @@ -335,12 +302,8 @@ public void testUserConstructionReverse() throws JAXBException, SchemaException user.checkConsistence(); } - - @Test - public void testGenericConstruction() throws JAXBException, SchemaException { - System.out.println("\n\n ===[ testGenericConstruction ]===\n"); - + public void testGenericConstruction() throws SchemaException { // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -358,16 +321,14 @@ public void testGenericConstruction() throws JAXBException, SchemaException { generic.checkConsistence(); PrismContainer extensionContainer = generic.findContainer(GenericObjectType.F_EXTENSION); - checkExtension(extensionContainer,"user extension after setExtension"); - checkExtension(extension,"user extension after setExtension"); + checkExtension(extensionContainer, "user extension after setExtension"); + checkExtension(extension, "user extension after setExtension"); generic.checkConsistence(); } @Test - public void testAccountConstruction() throws JAXBException, SchemaException { - System.out.println("\n\n ===[ testAccountConstruction ]===\n"); - + public void testAccountConstruction() throws SchemaException { // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -411,8 +372,6 @@ public void testAccountConstruction() throws JAXBException, SchemaException { @Test public void testExtensionTypeConstruction() throws Exception { - System.out.println("\n\n ===[ testExtensionTypeConstruction ]===\n"); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -435,8 +394,6 @@ public void testExtensionTypeConstruction() throws Exception { @Test public void testResourceConstruction() throws Exception { - System.out.println("\n\n ===[ testResourceConstruction ]===\n"); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -456,7 +413,7 @@ public void testResourceConstruction() throws Exception { // description: setting null value resourceType.setDescription(null); PrismProperty descriptionProperty = resource.findProperty(UserType.F_DESCRIPTION); - assertNull("Unexpected description property "+descriptionProperty, descriptionProperty); + assertNull("Unexpected description property " + descriptionProperty, descriptionProperty); // description: setting null value resourceType.setDescription("blah blah"); @@ -466,7 +423,7 @@ public void testResourceConstruction() throws Exception { // description: resetting null value resourceType.setDescription(null); descriptionProperty = resource.findProperty(UserType.F_DESCRIPTION); - assertNull("Unexpected description property (after reset) "+descriptionProperty, descriptionProperty); + assertNull("Unexpected description property (after reset) " + descriptionProperty, descriptionProperty); // Extension ExtensionType extension = new ExtensionType(); @@ -475,8 +432,8 @@ public void testResourceConstruction() throws Exception { resource.checkConsistence(); PrismContainer extensionContainer = resource.findContainer(GenericObjectType.F_EXTENSION); - checkExtension(extensionContainer,"resource extension after setExtension"); - checkExtension(extension,"resource extension after setExtension"); + checkExtension(extensionContainer, "resource extension after setExtension"); + checkExtension(extension, "resource extension after setExtension"); // Schema XmlSchemaType xmlSchemaType = new XmlSchemaType(); @@ -504,16 +461,16 @@ public void testResourceConstruction() throws Exception { } private void checkExtension(PrismContainer extensionContainer, String sourceDescription) { - assertNotNull("No extension container in "+sourceDescription+" (prism)", extensionContainer); - assertNotNull("No extension definition in "+sourceDescription+" (prism)", extensionContainer.getDefinition()); - assertTrue("Not runtime in definition in "+sourceDescription+" (prism)", extensionContainer.getDefinition().isRuntimeSchema()); + assertNotNull("No extension container in " + sourceDescription + " (prism)", extensionContainer); + assertNotNull("No extension definition in " + sourceDescription + " (prism)", extensionContainer.getDefinition()); + assertTrue("Not runtime in definition in " + sourceDescription + " (prism)", extensionContainer.getDefinition().isRuntimeSchema()); } private void checkExtension(ExtensionType extension, String sourceDescription) throws SchemaException { PrismContainerValue extensionValueFromJaxb = extension.asPrismContainerValue(); - assertNotNull("No extension container in "+sourceDescription+" (jaxb)", extensionValueFromJaxb); - assertNotNull("No extension definition in "+sourceDescription+" (jaxb)", extensionValueFromJaxb.getParent().getDefinition()); - assertTrue("Not runtime in definition in "+sourceDescription+" (jaxb)", extensionValueFromJaxb.getParent().getDefinition().isRuntimeSchema()); + assertNotNull("No extension container in " + sourceDescription + " (jaxb)", extensionValueFromJaxb); + assertNotNull("No extension definition in " + sourceDescription + " (jaxb)", extensionValueFromJaxb.getParent().getDefinition()); + assertTrue("Not runtime in definition in " + sourceDescription + " (jaxb)", extensionValueFromJaxb.getParent().getDefinition().isRuntimeSchema()); PrismProperty intProperty = extensionValueFromJaxb.findOrCreateProperty(EXTENSION_INT_TYPE_ELEMENT); PrismAsserts.assertDefinition(intProperty.getDefinition(), EXTENSION_INT_TYPE_ELEMENT, DOMUtil.XSD_INT, 0, -1); diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestJaxbParsing.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestJaxbParsing.java index 4d15d9a4d90..8ca2a2f008e 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestJaxbParsing.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestJaxbParsing.java @@ -6,68 +6,47 @@ */ package com.evolveum.midpoint.schema; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertNotNull; + import static com.evolveum.midpoint.prism.util.PrismAsserts.assertPropertyValue; +import java.io.File; +import java.io.IOException; +import javax.xml.bind.JAXBElement; +import javax.xml.datatype.DatatypeFactory; +import javax.xml.datatype.XMLGregorianCalendar; +import javax.xml.namespace.QName; + +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.impl.PrismContextImpl; -import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.path.ItemName; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.util.SchemaTestConstants; -import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; -import com.evolveum.prism.xml.ns._public.types_3.ChangeTypeType; -import com.evolveum.prism.xml.ns._public.types_3.EncryptedDataType; -import com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType; -import com.evolveum.prism.xml.ns._public.types_3.ItemPathType; -import com.evolveum.prism.xml.ns._public.types_3.ModificationTypeType; -import com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType; -import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; -import com.evolveum.prism.xml.ns._public.types_3.RawType; - -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.w3c.dom.Document; -import org.xml.sax.SAXException; - -import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBException; -import javax.xml.datatype.DatatypeFactory; -import javax.xml.datatype.XMLGregorianCalendar; -import javax.xml.namespace.QName; - -import java.io.File; -import java.io.IOException; - -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; +import com.evolveum.prism.xml.ns._public.types_3.*; /** * @author Radovan Semancik */ -public class TestJaxbParsing { +public class TestJaxbParsing extends AbstractSchemaTest { private static final String NS_FOO = "http://www.example.com/foo"; - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } - @Test - public void testParseUserFromJaxb() throws SchemaException, SAXException, IOException, JAXBException { - + public void testParseUserFromJaxb() throws SchemaException, IOException { PrismContext prismContext = PrismTestUtil.getPrismContext(); // Try to use the schema to validate Jack - UserType userType = PrismTestUtil.parseObjectable(new File(TestConstants.COMMON_DIR, "user-jack.xml"), UserType.class); + UserType userType = PrismTestUtil.parseObjectable( + new File(TestConstants.COMMON_DIR, "user-jack.xml"), UserType.class); // WHEN @@ -94,22 +73,11 @@ public void testParseUserFromJaxb() throws SchemaException, SAXException, IOExce PrismProperty multi = user.findOrCreateContainer(UserType.F_EXTENSION).findProperty(new ItemName(NS_FOO, "multi")); assertEquals(3, multi.getValues().size()); - // WHEN - -// Node domNode = user.serializeToDom(); -// -// //THEN -// System.out.println("\nSerialized user:"); -// System.out.println(DOMUtil.serializeDOMToString(domNode)); -// -// Element userEl = DOMUtil.getFirstChildElement(domNode); -// assertEquals(SchemaConstants.I_USER, DOMUtil.getQName(userEl)); - // TODO: more asserts } @Test - public void testParseAccountFromJaxb() throws SchemaException, SAXException, IOException, JAXBException { + public void testParseAccountFromJaxb() throws SchemaException, IOException { PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -132,8 +100,7 @@ public void testParseAccountFromJaxb() throws SchemaException, SAXException, IOE } @Test - public void testParseModernRoleFromJaxb() throws SchemaException, SAXException, IOException, JAXBException { - System.out.println("\n\n ===[ testParseModernRoleFromJaxb ]===\n"); + public void testParseModernRoleFromJaxb() throws SchemaException, IOException { testParseRoleFromJaxb(new File(TestConstants.COMMON_DIR, "role.xml")); } @@ -141,9 +108,7 @@ public void testParseModernRoleFromJaxb() throws SchemaException, SAXException, * Test of parsing role with elements that were removed in 4.0. */ @Test - public void testParseLegacyRoleFromJaxb() throws SchemaException, SAXException, IOException, JAXBException { - System.out.println("\n\n ===[ testParseLegacyRoleFromJaxb ]===\n"); - + public void testParseLegacyRoleFromJaxb() throws SchemaException, IOException { PrismParser parser = PrismTestUtil.getPrismContext() .parserFor(new File(TestConstants.COMMON_DIR, "role-legacy.xml")) .compat(); @@ -159,9 +124,7 @@ public void testParseLegacyRoleFromJaxb() throws SchemaException, SAXException, assertPropertyValue(role, RoleType.F_NAME, PrismTestUtil.createPolyString("r3")); } - public void testParseRoleFromJaxb(File file) throws SchemaException, SAXException, IOException, JAXBException { - - PrismContext prismContext = PrismTestUtil.getPrismContext(); + public void testParseRoleFromJaxb(File file) throws SchemaException, IOException { PrismParser parser = PrismTestUtil.getPrismContext().parserFor(file); // WHEN @@ -177,11 +140,8 @@ public void testParseRoleFromJaxb(File file) throws SchemaException, SAXExceptio // TODO: more asserts? } - @Test public void testParseGenericObjectFromJaxb() throws Exception { - System.out.println("\n\n ===[ testParseGenericObjectFromJaxb ]===\n"); - PrismContext prismContext = PrismTestUtil.getPrismContext(); GenericObjectType object = PrismTestUtil.parseObjectable(new File(TestConstants.COMMON_DIR, "generic-sample-configuration.xml"), @@ -217,9 +177,6 @@ public void testMarshallObjectDeltaType() throws Exception { ItemDeltaType item1 = new ItemDeltaType(); delta.getItemDelta().add(item1); item1.setModificationType(ModificationTypeType.REPLACE); - Document document = DOMUtil.getDocument(); -// Element path = document.createElementNS(SchemaConstantsGenerated.NS_TYPES, "path"); -// path.setTextContent("c:credentials/c:password"); ItemPath path = ItemPath.create(SchemaConstantsGenerated.C_CREDENTIALS, CredentialsType.F_PASSWORD); item1.setPath(new ItemPathType(path)); ProtectedStringType protectedString = new ProtectedStringType(); @@ -228,7 +185,7 @@ public void testMarshallObjectDeltaType() throws Exception { item1.getValue().add(value); String xml = PrismTestUtil.serializeJaxbElementToString( - new JAXBElement<>(new QName("http://www.example.com", "custom"), Object.class, delta)); + new JAXBElement<>(new QName("http://www.example.com", "custom"), Object.class, delta)); assertNotNull(xml); } @@ -250,7 +207,6 @@ public void testParseAnyValue() throws Exception { JAXBElement oValue = prismContext.parserFor(dataValue).xml().parseRealValueToJaxbElement(); System.out.println(dumpResult(dataValue, oValue)); - //assertJaxbElement(oValue, SchemaConstantsGenerated.C_VALUE, String.class); assertJaxbElement(oValue, SchemaConstantsGenerated.C_VALUE, RawType.class); } @@ -261,7 +217,7 @@ private void assertJaxbElement(JAXBElement jaxbElement, QName name, Class cla } private String dumpResult(String data, JAXBElement jaxb) { - return "Parsed expression evaluator: " + data + " as " + jaxb + " (name=" + jaxb.getName() + ", declaredType=" + jaxb.getDeclaredType() + ", value=" + jaxb.getValue() + ")"; + return "Parsed expression evaluator: " + data + " as " + jaxb + " (name=" + jaxb.getName() + + ", declaredType=" + jaxb.getDeclaredType() + ", value=" + jaxb.getValue() + ")"; } - } diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestJaxbSanity.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestJaxbSanity.java deleted file mode 100644 index 5c56807711c..00000000000 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestJaxbSanity.java +++ /dev/null @@ -1,327 +0,0 @@ -/* - * Copyright (c) 2010-2019 Evolveum and contributors - * - * This work is dual-licensed under the Apache License 2.0 - * and European Union Public License. See LICENSE file for details. - */ -package com.evolveum.midpoint.schema; - -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertTrue; -import static org.testng.AssertJUnit.assertNotNull; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.lang.reflect.Method; - -import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBException; - -import com.evolveum.midpoint.prism.*; -import com.evolveum.midpoint.prism.equivalence.EquivalenceStrategy; -import com.evolveum.midpoint.prism.impl.util.JaxbTestUtil; -import com.evolveum.midpoint.xml.ns._public.common.common_3.*; - -import org.testng.AssertJUnit; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import com.evolveum.midpoint.prism.delta.ObjectDelta; -import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType; -import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; -import com.evolveum.prism.xml.ns._public.types_3.RawType; -import com.evolveum.prism.xml.ns._public.types_3.SchemaDefinitionType; - -/** - * @author semancik - * - */ -@Deprecated -public class TestJaxbSanity { - - public static final String TEST_DIR = "src/test/resources/common"; - public static final String USER_BARBOSSA_FILENAME = TEST_DIR + "/user-barbossa.xml"; - public static final String RESOURCE_OPENDJ_FILENAME = TEST_DIR + "/resource-opendj.xml"; - - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } - - @Test - public void testGeneratedEquals() throws JAXBException { - System.out.println("\n\n ===[ testGeneratedEquals ]===\n"); - - assertHasEquals(ObjectType.class); - assertHasEquals(AssignmentType.class); - assertHasEquals(MappingType.class); - assertHasEquals(ProtectedStringType.class); - - assertHasHashCode(ObjectType.class); - assertHasHashCode(AssignmentType.class); - assertHasHashCode(MappingType.class); - assertHasHashCode(ProtectedStringType.class); - } - - private void assertHasEquals(Class clazz) { - try { - Method method = clazz.getDeclaredMethod("equals", Object.class); - assertNotNull("No equals method in "+clazz.getSimpleName(), method); - } catch (SecurityException e) { - AssertJUnit.fail("No equals method in "+clazz.getSimpleName()); - } catch (NoSuchMethodException e) { - AssertJUnit.fail("No equals method in "+clazz.getSimpleName()); - } - } - - private void assertHasHashCode(Class clazz) { - try { - Method method = clazz.getDeclaredMethod("hashCode"); - assertNotNull("No hashCode method in "+clazz.getSimpleName(), method); - } catch (SecurityException e) { - AssertJUnit.fail("No hashCode method in "+clazz.getSimpleName()); - } catch (NoSuchMethodException e) { - AssertJUnit.fail("No hashCode method in "+clazz.getSimpleName()); - } - } - - @Test - public void testUnmarshallAndEqualsUserJaxb() throws Exception { - System.out.println("\n\n ===[ testUnmarshallAndEqualsUserJaxb ]===\n"); - - // GIVEN - JAXBElement userEl1 = JaxbTestUtil.getInstance().unmarshalElement(new File(USER_BARBOSSA_FILENAME),UserType.class); - UserType user1Type = userEl1.getValue(); - assertNotNull(user1Type); - PrismObject user1 = user1Type.asPrismObject(); - - JAXBElement userEl2 = JaxbTestUtil.getInstance().unmarshalElement(new File(USER_BARBOSSA_FILENAME),UserType.class); - UserType user2Type = userEl2.getValue(); - assertNotNull(user2Type); - PrismObject user2 = user2Type.asPrismObject(); - - // Compare plain JAXB objects (not backed by containers) - ConstructionType ac1 = user1Type.getAssignment().get(0).getConstruction(); - ConstructionType ac2 = user2Type.getAssignment().get(0).getConstruction(); - assertTrue("ConstructionType not equals", ac1.equals(ac2)); - - // WHEN, THEN - ObjectDelta objectDelta = user1.diff(user2); - System.out.println("User delta:"); - System.out.println(objectDelta.debugDump()); - assertTrue("User delta is not empty", objectDelta.isEmpty()); - - assertTrue("User not equals (PrismObject)", user1.equals(user2)); - assertTrue("User not equivalent (PrismObject)", user1.equivalent(user2)); - assertTrue("User not equals (Objectable)", user1Type.equals(user2Type)); - - assertTrue("HashCode does not match (PrismObject)", user1.hashCode() == user2.hashCode()); - assertTrue("HashCode does not match (Objectable)", user1Type.hashCode() == user2Type.hashCode()); - } - - @Test - public void testUnmarshallAndEqualsUserPrism() throws Exception { - System.out.println("\n\n ===[testUnmarshallAndEqualsUserPrism]===\n"); - - // GIVEN - PrismObject user1 = PrismTestUtil.parseObject(new File(USER_BARBOSSA_FILENAME)); - UserType user1Type = user1.asObjectable(); - - PrismObject user2 = PrismTestUtil.parseObject(new File(USER_BARBOSSA_FILENAME)); - UserType user2Type = user2.asObjectable(); - - // Compare plain JAXB objects (not backed by containers) - ConstructionType ac1 = user1Type.getAssignment().get(0).getConstruction(); - ConstructionType ac2 = user2Type.getAssignment().get(0).getConstruction(); - assertTrue("ConstructionType not equals (JAXB)", ac1.equals(ac2)); - assertTrue("ConstructionType hashcode does not match (JAXB)", ac1.hashCode() == ac2.hashCode()); - - AssignmentType as1Type = user1Type.getAssignment().get(0); - PrismContainerValue as1ContVal = as1Type.asPrismContainerValue(); - PrismContainer as1Cont = as1ContVal.getContainer(); - AssignmentType as2Type = user2Type.getAssignment().get(0); - PrismContainerValue as2ContVal = as2Type.asPrismContainerValue(); - PrismContainer as2Cont = as2ContVal.getContainer(); - assertTrue("Assignment not equals (ContainerValue)", as1ContVal.equals(as2ContVal)); - assertTrue("Assignment not equals (ContainerValue, ignoreMetadata)", as1ContVal.equals(as2ContVal, EquivalenceStrategy.IGNORE_METADATA)); - assertTrue("Assignment not equals (ContainerValue, not ignoreMetadata)", as1ContVal.equals(as2ContVal, EquivalenceStrategy.NOT_LITERAL)); - assertTrue("Assignment not equivalent (ContainerValue)", as1ContVal.equivalent(as2ContVal)); - assertTrue("Assignment not equals (Container)", as1Cont.equals(as2Cont)); - assertTrue("Assignment not equivalent (Container)", as1Cont.equivalent(as2Cont)); - assertTrue("AssignmentType not equals (JAXB)", as1Type.equals(as2Type)); - assertTrue("Assignment hashcode does not match (Container)", as1Cont.hashCode() == as2Cont.hashCode()); - assertTrue("Assignment hashcode does not match (Objectable)", as1Type.hashCode() == as2Type.hashCode()); - - // Compare object inner value - assertTrue("User prism values do not match", user1.getValue().equals(user2.getValue())); - - // WHEN, THEN - ObjectDelta objectDelta = user1.diff(user1); - System.out.println("User delta:"); - System.out.println(objectDelta.debugDump()); - assertTrue("User delta is not empty", objectDelta.isEmpty()); - - assertTrue("User not equals (PrismObject)", user1.equals(user2)); - assertTrue("User not equivalent (PrismObject)", user1.equivalent(user2)); - assertTrue("User not equals (Objectable)", user1Type.equals(user2Type)); - - assertTrue("User hashcode does not match (PrismObject)", user1.hashCode() == user2.hashCode()); - assertTrue("User hashcode does not match (Objectable)", user1Type.hashCode() == user2Type.hashCode()); - } - - @Test - public void testUnmarshallAndEqualsUserMixed() throws Exception { - System.out.println("\n\n ===[testUnmarshallAndEqualsUserMixed]===\n"); - - // GIVEN - PrismObject user1 = PrismTestUtil.parseObject(new File(USER_BARBOSSA_FILENAME)); - UserType user1Type = user1.asObjectable(); - - JAXBElement userEl2 = JaxbTestUtil.getInstance().unmarshalElement(new File(USER_BARBOSSA_FILENAME),UserType.class); - UserType user2Type = userEl2.getValue(); - assertNotNull(user2Type); - PrismObject user2 = user2Type.asPrismObject(); - - // Compare plain JAXB objects (not backed by containers) - ConstructionType ac1 = user1Type.getAssignment().get(0).getConstruction(); - ConstructionType ac2 = user2Type.getAssignment().get(0).getConstruction(); - assertTrue("ConstructionType not equals", ac1.equals(ac2)); - System.out.println(user1.debugDump()); - System.out.println(user2.debugDump()); - // WHEN, THEN - assertTrue("User not equals (PrismObject)", user1.equals(user2)); - assertTrue("User not equivalent (PrismObject)", user1.equivalent(user2)); - assertTrue("User not equals (Objectable)", user1Type.equals(user2Type)); - - assertTrue("HashCode does not match (PrismObject)", user1.hashCode() == user2.hashCode()); - assertTrue("HashCode does not match (Objectable)", user1Type.hashCode() == user2Type.hashCode()); - } - - - @Test - public void testUnmarshallAndEqualsResourceSchema() throws JAXBException, SchemaException, FileNotFoundException { - System.out.println("\n\n ===[testUnmarshallAndEqualsResourceSchema]===\n"); - - // GIVEN - ResourceType resource1Type = JaxbTestUtil.getInstance().unmarshalObject(new File(RESOURCE_OPENDJ_FILENAME), ResourceType.class); - assertNotNull(resource1Type); - SchemaDefinitionType schemaDefinition1 = resource1Type.getSchema().getDefinition(); - - ResourceType resource2Type = JaxbTestUtil.getInstance().unmarshalObject(new File(RESOURCE_OPENDJ_FILENAME), ResourceType.class); - assertNotNull(resource2Type); - SchemaDefinitionType schemaDefinition2 = resource2Type.getSchema().getDefinition(); - - // WHEN - boolean equals = schemaDefinition1.equals(schemaDefinition2); - - // THEN - assertTrue("Schema definition not equal", equals); - - assertEquals("Hashcode does not match", schemaDefinition1.hashCode(), schemaDefinition2.hashCode()); - } - - @Test - public void testUnmarshallAndEqualsResource() throws JAXBException, SchemaException, FileNotFoundException { - System.out.println("\n\n ===[testUnmarshallAndEqualsResource]===\n"); - - // GIVEN - ResourceType resource1Type = JaxbTestUtil.getInstance().unmarshalObject(new File(RESOURCE_OPENDJ_FILENAME), ResourceType.class); - assertNotNull(resource1Type); - System.out.println("Resource1 " + resource1Type.asPrismObject().debugDump()); - PrismObject resource1 = resource1Type.asPrismObject(); - - ResourceType resource2Type = JaxbTestUtil.getInstance().unmarshalObject(new File(RESOURCE_OPENDJ_FILENAME), ResourceType.class); - assertNotNull(resource2Type); - System.out.println("Resource2 " + resource2Type.asPrismObject().debugDump()); - PrismObject resource2 = resource2Type.asPrismObject(); - - // WHEN, THEN - ObjectDelta objectDelta = resource1.diff(resource2); - System.out.println("Resource delta:"); - System.out.println(objectDelta.debugDump()); - assertTrue("Resource delta is not empty", objectDelta.isEmpty()); - - assertTrue("Resource not equal", resource1Type.equals(resource2Type)); - - System.out.println("HASH"); - System.out.println(resource1Type.hashCode()); - System.out.println(resource2Type.hashCode()); - assertTrue("Resource hashcode does not match", resource1Type.hashCode() == resource2Type.hashCode()); - - PrismPropertyValue pv1 = getPrismContext().itemFactory().createPropertyValue(resource1Type.getConnectorConfiguration()); - PrismPropertyValue pv2 = getPrismContext().itemFactory().createPropertyValue(resource2Type.getConnectorConfiguration()); - - assertTrue("Real property values not equal",pv1.equals(pv2, EquivalenceStrategy.REAL_VALUE)); - } - - @Test - public void testAssignmentEquals() throws JAXBException, SchemaException, FileNotFoundException { - System.out.println("\n\n ===[testAssnignmentEquals]===\n"); - - // GIVEN - JAXBElement userEl1 = JaxbTestUtil.getInstance().unmarshalElement(new File(USER_BARBOSSA_FILENAME), UserType.class); - UserType user = userEl1.getValue(); - assertNotNull(user); - - AssignmentType userAssignmentType = user.getAssignment().get(0); - assertNotNull(userAssignmentType); - - System.out.println("\n*** user assignment"); - System.out.println(PrismTestUtil.serializeAnyDataWrapped(userAssignmentType)); - - JAXBElement modEl = JaxbTestUtil.getInstance().unmarshalElement(new File(TEST_DIR, "user-barbossa-modify-delete-assignment-account-opendj-attr.xml"),ObjectModificationType.class); - ObjectModificationType mod = modEl.getValue(); - assertNotNull(mod); - - //FIXME : modification value -> rawType... - RawType rawType = mod.getItemDelta().get(0).getValue().get(0); - ItemDefinition assignmentDefinition = getPrismContext().getSchemaRegistry().findContainerDefinitionByCompileTimeClass(AssignmentType.class); - assertNotNull(assignmentDefinition); - AssignmentType assignmentType = ((PrismContainerValue) rawType.getParsedValue(assignmentDefinition, null)).getValue(); -// was: (JAXBElement) mod.getItemDelta().get(0).getValue().get(0).getContent().get(0); - assertNotNull(assignmentType); - - System.out.println("\n*** assignment"); - System.out.println(PrismTestUtil.serializeAnyDataWrapped(assignmentType)); - - // WHEN, THEN - - assertTrue("Assignment not equals", userAssignmentType.equals(assignmentType)); - - assertTrue("HashCode does not match", userAssignmentType.hashCode() == assignmentType.hashCode()); - } - - @Test - public void testObjectReferenceNullSet() throws Exception { - System.out.println("\n\n ===[testObjectReferenceNullSet]===\n"); - - //GIVEN - SystemConfigurationType config = new SystemConfigurationType(); - getPrismContext().adopt(config); - - //WHEN - config.setGlobalSecurityPolicyRef(null); - - //THEN - SystemConfigurationType configNew = new SystemConfigurationType(); - - ObjectReferenceType ref = new ObjectReferenceType(); - ref.setOid("1234"); - ref.setType(ValuePolicyType.COMPLEX_TYPE); - - configNew.setGlobalSecurityPolicyRef(ref); - configNew.setGlobalSecurityPolicyRef(null); - - getPrismContext().adopt(configNew); - - assertTrue(config.equals(configNew)); - } -} diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestLazyDumpPerformance.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestLazyDumpPerformance.java index 88cf685de53..b11640268d1 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestLazyDumpPerformance.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestLazyDumpPerformance.java @@ -7,61 +7,44 @@ package com.evolveum.midpoint.schema; +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.util.ObjectTypeUtil; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import java.io.IOException; /** * @author mederly */ -public class TestLazyDumpPerformance { - - private static final Trace LOGGER = TraceManager.getTrace(TestLazyDumpPerformance.class); - - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } +public class TestLazyDumpPerformance extends AbstractSchemaTest { private static final long ITERATIONS = 4000000; @Test public void toShortStringLazyPerformance() { - UserType user = new UserType(PrismTestUtil.getPrismContext()).name("jack"); for (long i = 0; i < 100000; i++) { // warm-up - LOGGER.trace("{}", ObjectTypeUtil.toShortStringLazy(user)); + logger.trace("{}", ObjectTypeUtil.toShortStringLazy(user)); } long startLazy = System.currentTimeMillis(); for (long i = 0; i < ITERATIONS; i++) { - LOGGER.trace("{}", ObjectTypeUtil.toShortStringLazy(user)); + logger.trace("{}", ObjectTypeUtil.toShortStringLazy(user)); } long lazy = System.currentTimeMillis() - startLazy; System.out.println("Lazy: " + lazy + " ms = " + (lazy * 1000000) / ITERATIONS + " ns per iteration"); long startNormal = System.currentTimeMillis(); for (long i = 0; i < ITERATIONS; i++) { - LOGGER.trace("{}", user); + logger.trace("{}", user); } long normal = System.currentTimeMillis() - startNormal; System.out.println("Normal: " + normal + " ms = " + (normal * 1000000) / ITERATIONS + " ns per iteration"); long startOptimized = System.currentTimeMillis(); for (long i = 0; i < ITERATIONS; i++) { - if (LOGGER.isTraceEnabled()) { - LOGGER.trace("{}", ObjectTypeUtil.toShortString(user)); + if (logger.isTraceEnabled()) { + logger.trace("{}", ObjectTypeUtil.toShortString(user)); } } long optimized = System.currentTimeMillis() - startOptimized; @@ -69,7 +52,7 @@ public void toShortStringLazyPerformance() { long startNaive = System.currentTimeMillis(); for (long i = 0; i < ITERATIONS; i++) { - LOGGER.trace("{}", ObjectTypeUtil.toShortString(user)); + logger.trace("{}", ObjectTypeUtil.toShortString(user)); } long naive = System.currentTimeMillis() - startNaive; System.out.println("Naive: " + naive + " ms = " + (naive * 1000000) / ITERATIONS + " ns per iteration"); diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestMiscellaneous.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestMiscellaneous.java index 579269cac52..6fd16d4fa40 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestMiscellaneous.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestMiscellaneous.java @@ -6,49 +6,34 @@ */ package com.evolveum.midpoint.schema; -import com.evolveum.midpoint.prism.*; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.xml.ns._public.common.common_3.*; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; +import static org.testng.AssertJUnit.*; + +import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; import java.io.File; -import java.io.IOException; import java.util.concurrent.atomic.AtomicInteger; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.fail; +import org.testng.annotations.Test; + +import com.evolveum.midpoint.prism.*; +import com.evolveum.midpoint.prism.path.ItemPath; +import com.evolveum.midpoint.util.exception.SchemaException; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; /** * @author mederly - * */ -public class TestMiscellaneous { +public class TestMiscellaneous extends AbstractSchemaTest { public static final File TEST_DIR = new File("src/test/resources/misc"); private static final File FILE_ROLE_REMOVE_ITEMS = new File(TEST_DIR, "role-remove-items.xml"); - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } - @Test public void singleValuedItems() throws Exception { - System.out.println("===[ singleValuedItems ]==="); - UserType userBean = getPrismContext().createObjectable(UserType.class) .beginAssignment() - .id(1L) - .targetRef(new ObjectReferenceType().oid("123456").type(RoleType.COMPLEX_TYPE)) + .id(1L) + .targetRef(new ObjectReferenceType().oid("123456").type(RoleType.COMPLEX_TYPE)) .end(); //noinspection unchecked @@ -69,7 +54,6 @@ public void singleValuedItems() throws Exception { @Test public void removeOperationalItems() throws Exception { - System.out.println("===[ removeOperationalItems ]==="); PrismObject role = getPrismContext().parseObject(FILE_ROLE_REMOVE_ITEMS); AtomicInteger propertyValuesBefore = new AtomicInteger(0); @@ -99,7 +83,7 @@ public void removeOperationalItems() throws Exception { assertNull("assignment[1]/activation/effectiveStatus present", role.findProperty(ItemPath.create(RoleType.F_ASSIGNMENT, 1L, AssignmentType.F_ACTIVATION, ActivationType.F_EFFECTIVE_STATUS))); - assertEquals("Wrong property values after", propertyValuesBefore.intValue()-6, propertyValuesAfter.intValue()); + assertEquals("Wrong property values after", propertyValuesBefore.intValue() - 6, propertyValuesAfter.intValue()); } } diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestObjectConstruction.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestObjectConstruction.java index 4c66f4f64f4..7876874cd19 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestObjectConstruction.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestObjectConstruction.java @@ -6,42 +6,25 @@ */ package com.evolveum.midpoint.schema; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; -import static org.testng.AssertJUnit.fail; +import static org.testng.AssertJUnit.*; -import java.io.IOException; - -import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; -import org.xml.sax.SAXException; import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.util.SchemaTestUtil; -import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; /** * @author semancik - * */ -public class TestObjectConstruction { - - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } +public class TestObjectConstruction extends AbstractSchemaTest { @Test public void testUserConstruction() throws Exception { - System.out.println("\n\n ===[ testUserConstruction ]===\n"); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -54,23 +37,18 @@ public void testUserConstruction() throws Exception { } @Test - public void testObjectTypeConstruction() throws Exception { - System.out.println("\n\n ===[ testObjectTypeConstruction ]===\n"); - + public void testObjectTypeConstruction() { // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); try { // WHEN - PrismObject object = prismContext.createObject(ObjectType.class); + prismContext.createObject(ObjectType.class); fail("unexpected success"); } catch (SchemaException e) { // This is expected, abstract object types cannot be instantiated assertTrue(e.getMessage().contains("abstract")); } - } - - } diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestOperationResult.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestOperationResult.java index 6bed0333698..a64175a6fa4 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestOperationResult.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestOperationResult.java @@ -6,48 +6,34 @@ */ package com.evolveum.midpoint.schema; +import static org.testng.AssertJUnit.assertEquals; + +import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; +import static com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultImportanceType.MAJOR; + +import java.util.Arrays; +import java.util.List; + +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.PrismContext; -import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.result.OperationResultStatus; -import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultHandlingStrategyType; import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import java.io.IOException; -import java.util.Arrays; -import java.util.List; - -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; -import static com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultImportanceType.MAJOR; -import static org.testng.AssertJUnit.assertEquals; /** * @author mederly - * */ -public class TestOperationResult { +public class TestOperationResult extends AbstractSchemaTest { private static final String LOCAL_1 = "local1"; - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } - @Test public void testCleanup() throws Exception { - System.out.println("===[ testCleanup ]==="); - - // GIVEN (checks also conversions during result construction) - + given("checks also conversions during result construction"); OperationResult root = new OperationResult("dummy"); checkResultConversion(root, true); @@ -67,14 +53,14 @@ public void testCleanup() throws Exception { sub13.recordSuccess(); checkResultConversion(root, true); - // WHEN + when(); System.out.println("Before cleanup:\n" + root.debugDump()); sub1.computeStatus(); sub1.cleanupResult(); root.computeStatus(); root.cleanupResult(); - // THEN + then(); System.out.println("After cleanup (normal):\n" + root.debugDump()); assertEquals("Wrong overall status", OperationResultStatus.FATAL_ERROR, root.getStatus()); // because of sub2 assertEquals("Wrong status of sub1", OperationResultStatus.WARNING, sub1.getStatus()); // because of sub12 @@ -104,10 +90,7 @@ public void testCleanup() throws Exception { @Test public void testSummarizeByHiding() throws Exception { - System.out.println("===[ testSummarizeByHiding ]==="); - // GIVEN - OperationResult root = new OperationResult("dummy"); OperationResult level1 = root.createSubresult("level1"); for (int i = 1; i <= 30; i++) { @@ -137,8 +120,6 @@ public void testSummarizeByHiding() throws Exception { @Test public void testExplicitSummarization() throws Exception { - System.out.println("===[ testExplicitSummarization ]==="); - // GIVEN OperationResult root = new OperationResult("dummy"); @@ -172,8 +153,6 @@ public void testExplicitSummarization() throws Exception { @Test public void testIncrementalSummarization() throws Exception { - System.out.println("===[ testIncrementalSummarization ]==="); - OperationResult root = new OperationResult("dummy"); int b = 0; for (int a = 1; a <= 30; a++) { @@ -215,8 +194,8 @@ public void testIncrementalSummarization() throws Exception { assertEquals("Wrong operation in summary for B", "operationB", sumB.getOperation()); assertEquals("Wrong status in summary for A", OperationResultStatus.SUCCESS, sumA.getStatus()); assertEquals("Wrong status in summary for B", OperationResultStatus.WARNING, sumB.getStatus()); - assertEquals("Wrong hidden records count in summary for A", a-expectedA, sumA.getHiddenRecordsCount()); - assertEquals("Wrong hidden records count in summary for B", b-expectedB, sumB.getHiddenRecordsCount()); + assertEquals("Wrong hidden records count in summary for A", a - expectedA, sumA.getHiddenRecordsCount()); + assertEquals("Wrong hidden records count in summary for B", b - expectedB, sumB.getHiddenRecordsCount()); } } diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseDiffPatch.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseDiffPatch.java index 3deb03d73cc..c930120e94f 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseDiffPatch.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseDiffPatch.java @@ -6,45 +6,38 @@ */ package com.evolveum.midpoint.schema; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; import static org.testng.AssertJUnit.*; +import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; + import java.io.File; import java.io.IOException; import java.util.Collection; import java.util.List; - -import javax.xml.bind.JAXBException; import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.*; +import org.testng.AssertJUnit; +import org.testng.annotations.Test; + +import com.evolveum.midpoint.prism.PrismContext; +import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.delta.*; import com.evolveum.midpoint.prism.equivalence.EquivalenceStrategy; -import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.path.ItemName; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.polystring.PolyString; +import com.evolveum.midpoint.prism.util.PrismAsserts; +import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.prism.xml.XmlTypeConverter; import com.evolveum.midpoint.prism.xnode.RootXNode; import com.evolveum.midpoint.prism.xnode.XNode; -import com.evolveum.midpoint.util.QNameUtil; -import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.*; - -import com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType; -import org.testng.AssertJUnit; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.w3c.dom.Element; -import org.xml.sax.SAXException; - -import com.evolveum.midpoint.prism.util.PrismAsserts; -import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.util.SchemaTestConstants; import com.evolveum.midpoint.util.MiscUtil; -import com.evolveum.midpoint.util.PrettyPrinter; +import com.evolveum.midpoint.util.QNameUtil; import com.evolveum.midpoint.util.exception.SchemaException; +import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType; import com.evolveum.prism.xml.ns._public.types_3.ModificationTypeType; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; @@ -52,9 +45,8 @@ /** * @author semancik - * */ -public class TestParseDiffPatch { +public class TestParseDiffPatch extends AbstractSchemaTest { private static final String TEST_DIR = "src/test/resources/diff/"; @@ -70,16 +62,8 @@ public class TestParseDiffPatch { private static final File SYSTEM_CONFIGURATION_BEFORE_FILE = new File(TEST_DIR, "system-configuration-before.xml"); private static final File SYSTEM_CONFIGURATION_AFTER_FILE = new File(TEST_DIR, "system-configuration-after.xml"); - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } - @Test public void testUserCredentialsDiff() throws Exception { - System.out.println("===[ testUserCredentialsDiff ]==="); - PrismObject userBefore = PrismTestUtil.parseObject(USER_BEFORE_FILE); userBefore.checkConsistence(); PrismObject userAfter = PrismTestUtil.parseObject(USER_AFTER_FILE); @@ -100,14 +84,13 @@ public void testUserCredentialsDiff() throws Exception { path = ItemPath.create(SchemaConstantsGenerated.C_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_FAILED_LOGINS); PropertyDelta propertyDelta = userDelta.findPropertyDelta(path); - assertNotNull("Property delta for "+path+" not found",propertyDelta); + assertNotNull("Property delta for " + path + " not found", propertyDelta); assertEquals(1, propertyDelta.getValuesToAdd().size()); } - //@Test + // was commented from 2014 to 2020, but it seem to work - now what? + @Test public void testAssignmentActivationDiff() throws Exception { - System.out.println("===[ testUserCredentialsDiff ]==="); - PrismObject userBefore = PrismTestUtil.parseObject(USER_BEFORE_FILE); PrismObject userAfter = userBefore.clone(); AssignmentType assignmentBefore = new AssignmentType(); @@ -122,84 +105,49 @@ public void testAssignmentActivationDiff() throws Exception { assignmentAfter.setActivation(activation); userAfter.asObjectable().getAssignment().add(assignmentAfter); + Collection userDeltas = + assignmentBefore.asPrismContainerValue().diff(assignmentAfter.asPrismContainerValue()); + userBefore.checkConsistence(); + userAfter.checkConsistence(); - Collection userDelta = assignmentBefore.asPrismContainerValue().diff(assignmentAfter.asPrismContainerValue()); -// ObjectDelta userDelta = userBefore.diff(userAfter); - System.out.println("DELTA:"); -// System.out.println(userDelta.debugDump()); - -// userBefore.checkConsistence(); -// userAfter.checkConsistence(); -// userDelta.checkConsistence(); -// userDelta.assertDefinitions(); - - ItemDelta assignmentDelta = userDelta.iterator().next(); + ItemDelta assignmentDelta = userDeltas.iterator().next(); System.out.println("Assignment delta: " + assignmentDelta); System.out.println("Assignment delta: " + assignmentDelta.debugDump()); ItemPath path = ItemPath.create(SchemaConstantsGenerated.C_ASSIGNMENT, AssignmentType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS); -// PrismAsserts.assertPropertyAdd(assignmentDelta, path, 1); -// path = ItemPath.create(SchemaConstantsGenerated.C_CREDENTIALS, -// CredentialsType.F_PASSWORD, PasswordType.F_FAILED_LOGINS); - PropertyDelta propertyDelta = ItemDeltaCollectionsUtil.findPropertyDelta(userDelta, path); - assertNotNull("Property delta for "+path+" not found",propertyDelta); -// assertEquals(1, propertyDelta.getValuesToAdd().size()); + assertNotNull("Property delta for " + path + " not found", + ItemDeltaCollectionsUtil.findPropertyDelta(userDeltas, path)); assignmentAfter = new AssignmentType(); activation = new ActivationType(); activation.setAdministrativeStatus(null); assignmentAfter.setActivation(activation); - userDelta = assignmentBefore.asPrismContainerValue().diff(assignmentAfter.asPrismContainerValue()); -// ObjectDelta userDelta = userBefore.diff(userAfter); - System.out.println("DELTA:"); -// System.out.println(userDelta.debugDump()); - -// userBefore.checkConsistence(); -// userAfter.checkConsistence(); -// userDelta.checkConsistence(); -// userDelta.assertDefinitions(); - - assignmentDelta = userDelta.iterator().next(); - System.out.println("Assignment delta: " + assignmentDelta); - System.out.println("Assignment delta: " + assignmentDelta.debugDump()); - - path = ItemPath.create(SchemaConstantsGenerated.C_ASSIGNMENT, - AssignmentType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS); -// PrismAsserts.assertPropertyAdd(assignmentDelta, path, 1); -// path = ItemPath.create(SchemaConstantsGenerated.C_CREDENTIALS, -// CredentialsType.F_PASSWORD, PasswordType.F_FAILED_LOGINS); - propertyDelta = ItemDeltaCollectionsUtil.findPropertyDelta(userDelta, path); - - - - userDelta = assignmentAfter.asPrismContainerValue().diff(assignmentBefore.asPrismContainerValue()); -// ObjectDelta userDelta = userBefore.diff(userAfter); - System.out.println("DELTA:"); -// System.out.println(userDelta.debugDump()); - -// userBefore.checkConsistence(); -// userAfter.checkConsistence(); -// userDelta.checkConsistence(); -// userDelta.assertDefinitions(); - - assignmentDelta = userDelta.iterator().next(); - System.out.println("Assignment delta: " + assignmentDelta); - System.out.println("Assignment delta: " + assignmentDelta.debugDump()); - - path = ItemPath.create(SchemaConstantsGenerated.C_ASSIGNMENT, - AssignmentType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS); -// PrismAsserts.assertPropertyAdd(assignmentDelta, path, 1); -// path = ItemPath.create(SchemaConstantsGenerated.C_CREDENTIALS, -// CredentialsType.F_PASSWORD, PasswordType.F_FAILED_LOGINS); - propertyDelta = ItemDeltaCollectionsUtil.findPropertyDelta(userDelta, path); + userDeltas = assignmentBefore.asPrismContainerValue().diff(assignmentAfter.asPrismContainerValue()); + userBefore.checkConsistence(); + userAfter.checkConsistence(); + assignmentDelta = userDeltas.iterator().next(); + System.out.println("Assignment delta: " + assignmentDelta); + System.out.println("Assignment delta: " + assignmentDelta.debugDump()); + + assertNotNull("Property delta for " + path + " not found", + ItemDeltaCollectionsUtil.findPropertyDelta(userDeltas, path)); + + userDeltas = assignmentAfter.asPrismContainerValue().diff(assignmentBefore.asPrismContainerValue()); + userBefore.checkConsistence(); + userAfter.checkConsistence(); + + assignmentDelta = userDeltas.iterator().next(); + System.out.println("Assignment delta: " + assignmentDelta); + System.out.println("Assignment delta: " + assignmentDelta.debugDump()); + + assertNotNull("Property delta for " + path + " not found", + ItemDeltaCollectionsUtil.findPropertyDelta(userDeltas, path)); } @Test - public void testUser() throws SchemaException, SAXException, IOException, JAXBException { - System.out.println("===[ testUser ]==="); - + public void testUser() throws SchemaException, IOException { PrismObject userBefore = PrismTestUtil.parseObject(new File(TEST_DIR, "user-jack-before.xml")); userBefore.checkConsistence(); PrismObject userAfter = PrismTestUtil.parseObject(new File(TEST_DIR, "user-jack-after.xml")); @@ -226,11 +174,11 @@ public void testUser() throws SchemaException, SAXException, IOException, JAXBEx assertEquals("Wrong change type", ChangeType.MODIFY, userDelta.getChangeType()); Collection modifications = userDelta.getModifications(); assertEquals("Unexpected number of modifications", 3, modifications.size()); - PrismAsserts.assertPropertyReplace(userDelta, new ItemName(SchemaConstants.NS_C,"fullName"), + PrismAsserts.assertPropertyReplace(userDelta, new ItemName(SchemaConstants.NS_C, "fullName"), new PolyString("Cpt. Jack Sparrow", "cpt jack sparrow")); - PrismAsserts.assertPropertyAdd(userDelta, new ItemName(SchemaConstants.NS_C,"honorificPrefix"), + PrismAsserts.assertPropertyAdd(userDelta, new ItemName(SchemaConstants.NS_C, "honorificPrefix"), new PolyString("Cpt.", "cpt")); - PrismAsserts.assertPropertyAdd(userDelta, new ItemName(SchemaConstants.NS_C,"locality"), + PrismAsserts.assertPropertyAdd(userDelta, new ItemName(SchemaConstants.NS_C, "locality"), new PolyString("Tortuga", "tortuga")); ObjectModificationType objectModificationType = DeltaConvertor.toObjectModificationType(userDelta); @@ -242,15 +190,15 @@ public void testUser() throws SchemaException, SAXException, IOException, JAXBEx PolyStringType polyString = new PolyStringType(); polyString.setOrig("Cpt. Jack Sparrow"); polyString.setNorm("cpt jack sparrow"); - assertXmlPolyMod(objectModificationType, new ItemName(SchemaConstants.NS_C,"fullName"), ModificationTypeType.REPLACE, polyString); + assertXmlPolyMod(objectModificationType, new ItemName(SchemaConstants.NS_C, "fullName"), ModificationTypeType.REPLACE, polyString); polyString = new PolyStringType(); polyString.setOrig("Cpt."); polyString.setNorm("cpt"); - assertXmlPolyMod(objectModificationType, new ItemName(SchemaConstants.NS_C,"honorificPrefix"), ModificationTypeType.ADD, polyString); + assertXmlPolyMod(objectModificationType, new ItemName(SchemaConstants.NS_C, "honorificPrefix"), ModificationTypeType.ADD, polyString); polyString = new PolyStringType(); polyString.setOrig("Tortuga"); polyString.setNorm("tortuga"); - assertXmlPolyMod(objectModificationType, new ItemName(SchemaConstants.NS_C,"locality"), ModificationTypeType.ADD, polyString); + assertXmlPolyMod(objectModificationType, new ItemName(SchemaConstants.NS_C, "locality"), ModificationTypeType.ADD, polyString); userBefore.checkConsistence(); userAfter.checkConsistence(); @@ -265,19 +213,17 @@ public void testUser() throws SchemaException, SAXException, IOException, JAXBEx //assertEquals("Round trip failed", userAfter, userBefore); - assertTrue("Not equivalent",userBefore.equivalent(userAfter)); + assertTrue("Not equivalent", userBefore.equivalent(userAfter)); ObjectDelta roundTripDelta = DiffUtil.diff(userBefore, userAfter); System.out.println("roundtrip DELTA:"); System.out.println(roundTripDelta.debugDump()); - assertTrue("Roundtrip delta is not empty",roundTripDelta.isEmpty()); + assertTrue("Roundtrip delta is not empty", roundTripDelta.isEmpty()); } @Test - public void testUserReal() throws SchemaException, SAXException, IOException, JAXBException { - System.out.println("===[ testUserReal ]==="); - + public void testUserReal() throws SchemaException, IOException { String userBeforeXml = MiscUtil.readFile(new File(TEST_DIR, "user-real-before.xml")); String userAfterXml = MiscUtil.readFile(new File(TEST_DIR, "user-real-after.xml")); @@ -295,20 +241,18 @@ public void testUserReal() throws SchemaException, SAXException, IOException, JA assertEquals("Wrong change type", ChangeType.MODIFY, userDelta.getChangeType()); Collection modifications = userDelta.getModifications(); assertEquals("Unexpected number of modifications", 4, modifications.size()); - PrismAsserts.assertPropertyReplace(userDelta, new ItemName(SchemaConstants.NS_C,"emailAddress"), "jack@blackpearl.com"); - PrismAsserts.assertPropertyReplace(userDelta, new ItemName(SchemaConstants.NS_C,"locality"), + PrismAsserts.assertPropertyReplace(userDelta, new ItemName(SchemaConstants.NS_C, "emailAddress"), "jack@blackpearl.com"); + PrismAsserts.assertPropertyReplace(userDelta, new ItemName(SchemaConstants.NS_C, "locality"), new PolyString("World's End", "worlds end")); PrismAsserts.assertPropertyReplace(userDelta, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, ActivationStatusType.DISABLED); - PrismAsserts.assertPropertyAdd(userDelta, new ItemName(SchemaConstants.NS_C,"organizationalUnit"), + PrismAsserts.assertPropertyAdd(userDelta, new ItemName(SchemaConstants.NS_C, "organizationalUnit"), new PolyString("Brethren of the Coast", "brethren of the coast")); } @Test - public void testAddDelta() throws SchemaException, SAXException, IOException { - System.out.println("===[ testAddDelta ]==="); - + public void testAddDelta() throws SchemaException, IOException { // WHEN - ObjectDelta userDelta = DiffUtil.diff(null,new File(TEST_DIR, "user-jack-after.xml"), UserType.class, getPrismContext()); + ObjectDelta userDelta = DiffUtil.diff(null, new File(TEST_DIR, "user-jack-after.xml"), UserType.class, getPrismContext()); //THEN System.out.println("DELTA:"); @@ -322,9 +266,7 @@ public void testAddDelta() throws SchemaException, SAXException, IOException { } @Test - public void testTask() throws SchemaException, SAXException, IOException, JAXBException { - System.out.println("===[ testTask ]==="); - + public void testTask() throws SchemaException, IOException { // WHEN ObjectDelta diffDelta = DiffUtil.diff(TASK_BEFORE_FILE, @@ -347,7 +289,7 @@ public void testTask() throws SchemaException, SAXException, IOException, JAXBEx // Convert to XML form. This should include xsi:type to pass the type information - ObjectModificationType objectModificationType = DeltaConvertor.toObjectModificationType(diffDelta); + ObjectModificationType objectModificationType = DeltaConvertor.toObjectModificationType(diffDelta); System.out.println("Modification XML:"); System.out.println(PrismTestUtil.serializeAnyDataWrapped(objectModificationType)); @@ -376,7 +318,7 @@ public void testTask() throws SchemaException, SAXException, IOException, JAXBEx PrismObject taskAfter = PrismTestUtil.parseObject(TASK_AFTER_FILE); taskAfter.checkConsistence(); - assertTrue("Not equivalent",taskPatch.equivalent(taskAfter)); + assertTrue("Not equivalent", taskPatch.equivalent(taskAfter)); diffDelta.checkConsistence(); taskPatch.checkConsistence(); @@ -386,7 +328,7 @@ public void testTask() throws SchemaException, SAXException, IOException, JAXBEx System.out.println("roundtrip DELTA:"); System.out.println(roundTripDelta.debugDump()); - assertTrue("Roundtrip delta is not empty",roundTripDelta.isEmpty()); + assertTrue("Roundtrip delta is not empty", roundTripDelta.isEmpty()); roundTripDelta.checkConsistence(); diffDelta.checkConsistence(); @@ -396,8 +338,6 @@ public void testTask() throws SchemaException, SAXException, IOException, JAXBEx @Test public void testResource() throws Exception { - System.out.println("===[ testResource ]==="); - PrismObject resourceBefore = PrismTestUtil.parseObject(RESOURCE_BEFORE_FILE); PrismObject resourceAfter = PrismTestUtil.parseObject(RESOURCE_AFTER_FILE); @@ -443,8 +383,6 @@ public void testResource() throws Exception { @Test public void testResourceConst() throws Exception { - System.out.println("===[ testResourceConst ]==="); - PrismObject resourceBefore = PrismTestUtil.parseObject(RESOURCE_BEFORE_FILE); PrismObject resourceAfter = PrismTestUtil.parseObject(RESOURCE_AFTER_CONST_FILE); @@ -482,8 +420,6 @@ public void testResourceConst() throws Exception { @Test public void testResourceConstLiteral() throws Exception { - System.out.println("===[ testResourceConstLiteral ]==="); - PrismObject resourceBefore = PrismTestUtil.parseObject(RESOURCE_BEFORE_FILE); PrismObject resourceAfter = PrismTestUtil.parseObject(RESOURCE_AFTER_CONST_FILE); @@ -516,7 +452,7 @@ public void testResourceConstLiteral() throws Exception { private void assertConfigurationPropertyChange(ObjectDelta resourceDelta, String propName) { resourceDelta.checkConsistence(); PropertyDelta propertyDelta = resourceDelta.findPropertyDelta(pathConfigProperties(propName)); - assertNotNull("No delta for configuration property "+propName, propertyDelta); + assertNotNull("No delta for configuration property " + propName, propertyDelta); // TODO resourceDelta.checkConsistence(); } @@ -532,9 +468,7 @@ private ItemPath pathTimeouts(String last) { } @Test - public void testResourceRoundTrip() throws SchemaException, SAXException, IOException, JAXBException { - System.out.println("===[ testResourceRoundTrip ]==="); - + public void testResourceRoundTrip() throws SchemaException, IOException { PrismObject resourceBefore = PrismTestUtil.parseObject(RESOURCE_BEFORE_FILE); PrismObject resourceAfter = PrismTestUtil.parseObject(RESOURCE_AFTER_FILE); @@ -600,9 +534,7 @@ public void testResourceRoundTrip() throws SchemaException, SAXException, IOExce } @Test - public void testResourceNsChange() throws SchemaException, SAXException, IOException, JAXBException { - System.out.println("===[ testResourceNsChange ]==="); - + public void testResourceNsChange() throws SchemaException, IOException { PrismObject resourceBefore = PrismTestUtil.parseObject(RESOURCE_BEFORE_FILE); PrismObject resourceAfter = PrismTestUtil.parseObject(RESOURCE_AFTER_NS_CHANGE_FILE); @@ -624,7 +556,7 @@ public void testResourceNsChange() throws SchemaException, SAXException, IOExcep resourceAfter.checkConsistence(); if (!resourceDelta.isEmpty()) { - AssertJUnit.fail("The delta is not empty; it is "+resourceDelta); + AssertJUnit.fail("The delta is not empty; it is " + resourceDelta); } // "post" sanity @@ -633,9 +565,7 @@ public void testResourceNsChange() throws SchemaException, SAXException, IOExcep } @Test - public void testResourceNsChangeLiteral() throws SchemaException, SAXException, IOException, JAXBException { - System.out.println("===[ testResourceNsChangeLiteral ]==="); - + public void testResourceNsChangeLiteral() throws SchemaException, IOException { PrismObject resourceBefore = PrismTestUtil.parseObject(RESOURCE_BEFORE_FILE); PrismObject resourceAfter = PrismTestUtil.parseObject(RESOURCE_AFTER_NS_CHANGE_FILE); @@ -660,9 +590,7 @@ public void testResourceNsChangeLiteral() throws SchemaException, SAXException, } @Test - public void testResourceNsFixUndeclaredPrefixes() throws SchemaException, SAXException, IOException, JAXBException { - System.out.println("===[ testResourceNsFixUndeclaredPrefixes ]==="); - + public void testResourceNsFixUndeclaredPrefixes() throws SchemaException, IOException { boolean orig = QNameUtil.isTolerateUndeclaredPrefixes(); try { QNameUtil.setTolerateUndeclaredPrefixes(true); @@ -707,23 +635,17 @@ public void testResourceNsFixUndeclaredPrefixes() throws SchemaException, SAXExc QNameUtil.setTolerateUndeclaredPrefixes(orig); } - - } - - protected PrismObject getRawShadowBefore(PrismContext prismContext) throws SchemaException, IOException { - PrismObject oldObject = prismContext.parseObject(new File(TEST_DIR, "shadow-before.xml")); - return oldObject; } private void assertXmlPolyMod(ObjectModificationType objectModificationType, QName propertyName, ModificationTypeType modType, PolyStringType... expectedValues) throws SchemaException { //FIXME: for (ItemDeltaType mod : objectModificationType.getItemDelta()) { - if (!propertyName.equals(mod.getPath().getItemPath().last())) { - continue; - } - assertEquals(modType, mod.getModificationType()); - for (RawType val : mod.getValue()){ + if (!propertyName.equals(mod.getPath().getItemPath().last())) { + continue; + } + assertEquals(modType, mod.getModificationType()); + for (RawType val : mod.getValue()) { assertModificationPolyStringValue(val, expectedValues); } } @@ -736,7 +658,7 @@ private void assertModificationPolyStringValue(RawType value, PolyStringType... RootXNode rootNode = pc.xnodeFactory().root(new ItemName("dummy"), xnode); PolyStringType valueAsPoly = pc.parserFor(rootNode).parseRealValue(PolyStringType.class); boolean found = false; - for (PolyStringType expectedValue: expectedValues) { + for (PolyStringType expectedValue : expectedValues) { if (expectedValue.getOrig().equals(valueAsPoly.getOrig()) && expectedValue.getNorm().equals(valueAsPoly.getNorm())) { found = true; } @@ -744,51 +666,10 @@ private void assertModificationPolyStringValue(RawType value, PolyStringType... assertTrue(found); } - private boolean equal(String value, Element element) { - if (value == null && element == null) { - return true; - } - - if ((value == null && element != null) || (value != null && element == null)) { - return false; - } - - return value.equals(element.getTextContent()); - } - -// private void assertXmlMod(ObjectModificationType objectModificationType, QName propertyName, -// ModificationTypeType modType, String... expectedValues) { -// for (ItemDeltaType mod: objectModificationType.getItemDelta()) { -// assertEquals(modType, mod.getModificationType()); -// for (RawType val : mod.getValue()){ -// List elements = val.getContent(); -// assertFalse(elements.isEmpty()); -// Object first = elements.get(0); -//// QName elementQName = JAXBUtil.getElementQName(first); -// if (propertyName.equals(mod.getPath().getItemPath().last())) { -// -// assertEquals(expectedValues.length, elements.size()); -// for (Object element: elements) { -// boolean found = false; -// for (String expectedValue: expectedValues) { -// Element domElement = (Element)element; -// if (expectedValue.equals(domElement.getTextContent())) { -// found = true; -// } -// } -// assertTrue(found); -// } -// } -// } -// } -// } - // this is a simple test of applying delta (don't know where to put it) // MID-3828 @Test - public void testCampaign() throws SchemaException, SAXException, IOException, JAXBException { - System.out.println("===[ testCampaign ]==="); - + public void testCampaign() throws SchemaException, IOException { PrismObject campaign = PrismTestUtil.parseObject(new File(TEST_DIR, "campaign-1.xml")); campaign.checkConsistence(); assertEquals("Wrong # of triggers", 2, campaign.asObjectable().getTrigger().size()); @@ -799,11 +680,11 @@ public void testCampaign() throws SchemaException, SAXException, IOException, JA triggerToDelete.setTimestamp(XmlTypeConverter.createXMLGregorianCalendar("2017-03-17T23:43:49.705+01:00")); triggerToDelete.setHandlerUri("http://midpoint.evolveum.com/xml/ns/public/certification/trigger/close-stage/handler-3"); - @SuppressWarnings({"unchecked", "raw"}) + @SuppressWarnings({ "raw" }) ObjectDelta delta = getPrismContext().deltaFor(AccessCertificationCampaignType.class) - .item(AccessCertificationCampaignType.F_TRIGGER).delete(triggerToDelete) - .asObjectDelta(campaign.getOid()); + .item(AccessCertificationCampaignType.F_TRIGGER).delete(triggerToDelete) + .asObjectDelta(campaign.getOid()); // THEN delta.applyTo(campaign); @@ -851,8 +732,6 @@ public void testDiffSameValues() throws Exception { */ @Test public void testSystemConfigurationDiff() throws Exception { - System.out.println("===[ testSystemConfigurationDiff ]==="); - PrismObject before = PrismTestUtil.parseObject(SYSTEM_CONFIGURATION_BEFORE_FILE); before.checkConsistence(); PrismObject after = PrismTestUtil.parseObject(SYSTEM_CONFIGURATION_AFTER_FILE); @@ -877,8 +756,6 @@ public void testSystemConfigurationDiff() throws Exception { */ @Test public void testSystemConfigurationDiffPlusNarrow() throws Exception { - System.out.println("===[ testSystemConfigurationDiffPlusNarrow ]==="); - PrismObject before = PrismTestUtil.parseObject(SYSTEM_CONFIGURATION_BEFORE_FILE); before.checkConsistence(); PrismObject after = PrismTestUtil.parseObject(SYSTEM_CONFIGURATION_AFTER_FILE); diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseFilter.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseFilter.java index 15594694924..e2ac9735d4f 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseFilter.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseFilter.java @@ -6,43 +6,25 @@ */ package com.evolveum.midpoint.schema; -import com.evolveum.midpoint.prism.PrismContext; -import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; -import com.evolveum.midpoint.schema.constants.SchemaConstants; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.prism.xml.ns._public.query_3.SearchFilterType; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; +import static org.testng.AssertJUnit.assertEquals; +import java.io.File; import javax.xml.bind.JAXBElement; import javax.xml.namespace.QName; -import java.io.File; -import java.io.IOException; -import static org.testng.AssertJUnit.assertEquals; - -/** - * @author mederly - * - */ -public class TestParseFilter { +import org.testng.annotations.Test; - public static final File FILTER_FILE = new File(TestConstants.COMMON_DIR, "filter.xml"); +import com.evolveum.midpoint.prism.PrismContext; +import com.evolveum.midpoint.prism.util.PrismTestUtil; +import com.evolveum.midpoint.schema.constants.SchemaConstants; +import com.evolveum.prism.xml.ns._public.query_3.SearchFilterType; - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } +public class TestParseFilter extends AbstractSchemaTest { + public static final File FILTER_FILE = new File(TestConstants.COMMON_DIR, "filter.xml"); @Test public void testParseFilterFile() throws Exception { - System.out.println("===[ testParseFilterFile ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -54,8 +36,8 @@ public void testParseFilterFile() throws Exception { System.out.println(filter.debugDump()); String serialized = PrismTestUtil.serializeJaxbElementToString(new JAXBElement<>( - new QName(SchemaConstants.NS_QUERY, "filter"), SearchFilterType.class, filter)); - System.out.println("JAXB serialization result:\n"+serialized); + new QName(SchemaConstants.NS_QUERY, "filter"), SearchFilterType.class, filter)); + System.out.println("JAXB serialization result:\n" + serialized); // WHEN2 @@ -68,5 +50,4 @@ public void testParseFilterFile() throws Exception { assertEquals("Parsed and serialized+parsed filters do not match", filter, filter2); } - } diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseGenericObject.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseGenericObject.java index d9ebaf93c91..25ae9ada1f4 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseGenericObject.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseGenericObject.java @@ -6,64 +6,45 @@ */ package com.evolveum.midpoint.schema; -import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.*; + +import java.io.File; +import java.io.IOException; +import java.util.Collection; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.datatype.DatatypeConfigurationException; +import javax.xml.datatype.DatatypeFactory; +import javax.xml.datatype.XMLGregorianCalendar; +import javax.xml.namespace.QName; + +import org.testng.annotations.Test; +import org.w3c.dom.Document; +import org.w3c.dom.Element; import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.delta.ObjectDelta; +import com.evolveum.midpoint.prism.impl.util.JaxbTestUtil; import com.evolveum.midpoint.prism.path.ItemName; import com.evolveum.midpoint.prism.util.PrismAsserts; -import com.evolveum.midpoint.prism.impl.util.JaxbTestUtil; import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.util.SchemaTestConstants; import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.QNameUtil; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.ExtensionType; import com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.xml.sax.SAXException; - -import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBException; -import javax.xml.datatype.DatatypeConfigurationException; -import javax.xml.datatype.DatatypeFactory; -import javax.xml.datatype.XMLGregorianCalendar; -import javax.xml.namespace.QName; - -import java.io.File; -import java.io.IOException; -import java.util.Collection; -import java.util.List; - -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; - /** * @author semancik - * */ -public class TestParseGenericObject { +public class TestParseGenericObject extends AbstractSchemaTest { public static final File GENERIC_FILE = new File("src/test/resources/common/generic-sample-configuration.xml"); - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } - - @Test public void testParseGenericFile() throws Exception { - System.out.println("===[ testParseGenericFile ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -79,8 +60,6 @@ public void testParseGenericFile() throws Exception { @Test public void testParseGenericDom() throws SchemaException, DatatypeConfigurationException { - System.out.println("===[ testParseGenericDom ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -99,11 +78,9 @@ public void testParseGenericDom() throws SchemaException, DatatypeConfigurationE @Deprecated @Test(enabled = false) - public void testPrismParseJaxb() throws JAXBException, SchemaException, SAXException, IOException, DatatypeConfigurationException { - System.out.println("===[ testPrismParseJaxb ]==="); - + public void testPrismParseJaxb() + throws JAXBException, SchemaException, IOException, DatatypeConfigurationException { // GIVEN - PrismContext prismContext = PrismTestUtil.getPrismContext(); JaxbTestUtil jaxbProcessor = JaxbTestUtil.getInstance(); // WHEN @@ -114,17 +91,14 @@ public void testPrismParseJaxb() throws JAXBException, SchemaException, SAXExcep } /** - * The definition should be set properly even if the declared type is ObjectType. The Prism should determine - * the actual type. - * @throws DatatypeConfigurationException + * The definition should be set properly even if the declared type is ObjectType. + * The Prism should determine the actual type. */ @Deprecated @Test(enabled = false) - public void testPrismParseJaxbObjectType() throws JAXBException, SchemaException, SAXException, IOException, DatatypeConfigurationException { - System.out.println("===[ testPrismParseJaxbObjectType ]==="); - + public void testPrismParseJaxbObjectType() + throws JAXBException, SchemaException, IOException, DatatypeConfigurationException { // GIVEN - PrismContext prismContext = PrismTestUtil.getPrismContext(); JaxbTestUtil jaxbProcessor = JaxbTestUtil.getInstance(); // WHEN @@ -135,16 +109,13 @@ public void testPrismParseJaxbObjectType() throws JAXBException, SchemaException } /** - * Parsing in form of JAXBELement - * @throws DatatypeConfigurationException + * Parsing in form of JAXBElement. */ @Deprecated @Test(enabled = false) - public void testPrismParseJaxbElement() throws JAXBException, SchemaException, SAXException, IOException, DatatypeConfigurationException { - System.out.println("===[ testPrismParseJaxbElement ]==="); - + public void testPrismParseJaxbElement() + throws JAXBException, SchemaException, IOException, DatatypeConfigurationException { // GIVEN - PrismContext prismContext = PrismTestUtil.getPrismContext(); JaxbTestUtil jaxbProcessor = JaxbTestUtil.getInstance(); // WHEN @@ -157,15 +128,12 @@ public void testPrismParseJaxbElement() throws JAXBException, SchemaException, S /** * Parsing in form of JAXBELement, with declared ObjectType - * @throws DatatypeConfigurationException */ @Deprecated @Test(enabled = false) - public void testPrismParseJaxbElementObjectType() throws JAXBException, SchemaException, SAXException, IOException, DatatypeConfigurationException { - System.out.println("===[ testPrismParseJaxbElementObjectType ]==="); - + public void testPrismParseJaxbElementObjectType() + throws JAXBException, SchemaException, IOException, DatatypeConfigurationException { // GIVEN - PrismContext prismContext = PrismTestUtil.getPrismContext(); JaxbTestUtil jaxbProcessor = JaxbTestUtil.getInstance(); // WHEN @@ -176,11 +144,8 @@ public void testPrismParseJaxbElementObjectType() throws JAXBException, SchemaEx assertGenericObject(genericType.asPrismObject()); } - @Test public void testParseGenericRoundtrip() throws Exception { - System.out.println("===[ testParseGenericRoundtrip ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -213,19 +178,12 @@ public void testParseGenericRoundtrip() throws Exception { assertTrue("Delta is not empty", objectDelta.isEmpty()); PrismAsserts.assertEquivalent("generic object re-parsed quivalence", generic, reparsedGeneric); - -// // Compare schema container -// -// PrismContainer originalSchemaContainer = resource.findContainer(ResourceType.F_SCHEMA); -// PrismContainer reparsedSchemaContainer = reparsedResource.findContainer(ResourceType.F_SCHEMA); } private void assertGenericObject(PrismObject generic) throws DatatypeConfigurationException { - generic.checkConsistence(); assertEquals("Wrong oid", "c0c010c0-d34d-b33f-f00d-999111111111", generic.getOid()); -// assertEquals("Wrong version", "42", resource.getVersion()); PrismObjectDefinition resourceDefinition = generic.getDefinition(); assertNotNull("No resource definition", resourceDefinition); PrismAsserts.assertObjectDefinition(resourceDefinition, new QName(SchemaConstantsGenerated.NS_COMMON, "genericObject"), @@ -245,22 +203,9 @@ private void assertGenericObject(PrismObject generic) throws PrismContainerDefinition extensionContainerDefinition = extensionContainer.getDefinition(); assertTrue("Extension container definition is NOT dynamic", extensionContainerDefinition.isDynamic()); PrismContainerValue extensionContainerValue = extensionContainer.getValue(); - Collection> extensionItems = extensionContainerValue.getItems(); + Collection> extensionItems = extensionContainerValue.getItems(); assertEquals("Wrong number of extension items", 5, extensionItems.size()); - // COMPLEX RUN TIME PROPERTIES...NOT SUPPORTED WITH NEW PARSERS.. -// Item locationsItem = extensionContainerValue.findItem(SchemaTestConstants.EXTENSION_LOCATIONS_ELEMENT); -// if (!(locationsItem instanceof PrismProperty)) { -// AssertJUnit.fail("Expected the extension item to be of type "+PrismProperty.class+ -// "but it was of type "+locationsItem.getClass()); -// } -// PrismProperty locationsProperty = (PrismProperty)locationsItem; -// assertEquals("Wrong name of ", SchemaTestConstants.EXTENSION_LOCATIONS_ELEMENT, locationsProperty.getElementName()); -// PrismPropertyDefinition locationsDefinition = locationsProperty.getDefinition(); -// assertNotNull("No definition for ", locationsDefinition); -// PrismAsserts.assertDefinition(locationsDefinition, SchemaTestConstants.EXTENSION_LOCATIONS_ELEMENT, -// SchemaTestConstants.EXTENSION_LOCATIONS_TYPE, 0, -1); - PrismAsserts.assertPropertyValue(extensionContainerValue, SchemaTestConstants.EXTENSION_STRING_TYPE_ELEMENT, "X marks the spot"); PrismAsserts.assertPropertyValue(extensionContainerValue, SchemaTestConstants.EXTENSION_INT_TYPE_ELEMENT, 1234); PrismAsserts.assertPropertyValue(extensionContainerValue, SchemaTestConstants.EXTENSION_DOUBLE_TYPE_ELEMENT, 456.789D); @@ -281,10 +226,9 @@ public static void assertPropertyValue(PrismContainer container, String propN PrismAsserts.assertPropertyValue(container, propQName, propValue); } - private void assertContainerDefinition(PrismContainer container, String contName, QName xsdType, int minOccurs, - int maxOccurs) { + private void assertContainerDefinition(PrismContainer container, + String contName, QName xsdType, int minOccurs, int maxOccurs) { QName qName = new QName(SchemaConstantsGenerated.NS_COMMON, contName); PrismAsserts.assertDefinition(container.getDefinition(), qName, xsdType, minOccurs, maxOccurs); } - } diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseLookupTable.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseLookupTable.java index 21d1ad10677..5e358669e46 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseLookupTable.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseLookupTable.java @@ -6,6 +6,14 @@ */ package com.evolveum.midpoint.schema; +import static org.testng.AssertJUnit.assertEquals; + +import java.io.File; +import javax.xml.datatype.XMLGregorianCalendar; +import javax.xml.namespace.QName; + +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.PrismContainer; import com.evolveum.midpoint.prism.PrismContainerValue; import com.evolveum.midpoint.prism.PrismContext; @@ -14,43 +22,21 @@ import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.prism.xml.XmlTypeConverter; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableRowType; import com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import javax.xml.datatype.XMLGregorianCalendar; -import javax.xml.namespace.QName; -import java.io.File; -import java.io.IOException; - -import static org.testng.AssertJUnit.assertEquals; /** * @author Viliam Repan (lazyman) */ -public class TestParseLookupTable { +public class TestParseLookupTable extends AbstractSchemaTest { public static final File LOOKUP_TABLE_FILE = new File("src/test/resources/common/lookup-table.xml"); - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } - - @Test public void testParseTableFileRoundTrip() throws Exception { - System.out.println("===[ testParseTableFileRoundTrip ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -81,7 +67,6 @@ public void testParseTableFileRoundTrip() throws Exception { PrismAsserts.assertEquals(table.asObjectable(), reparsedObject.asObjectable()); } - private void assertTable(PrismObject table) { table.checkConsistence(); @@ -113,7 +98,7 @@ private void assertRow(PrismContainerValue tableContainerVal } private void assertPropertyDefinition(PrismContainer container, String propName, QName xsdType, int minOccurs, - int maxOccurs) { + int maxOccurs) { QName propQName = new QName(SchemaConstantsGenerated.NS_COMMON, propName); PrismAsserts.assertPropertyDefinition(container, propQName, xsdType, minOccurs, maxOccurs); } diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseMisc.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseMisc.java index 59a166c9cd4..ac15c9923d6 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseMisc.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseMisc.java @@ -10,53 +10,34 @@ import static org.testng.AssertJUnit.assertNotNull; import java.io.File; -import java.io.IOException; import java.util.List; - import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.path.ItemName; -import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; -import org.xml.sax.SAXException; import com.evolveum.midpoint.prism.PrismContainer; import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.PrismObjectDefinition; +import com.evolveum.midpoint.prism.path.ItemName; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; -import com.evolveum.midpoint.schema.util.SchemaDebugUtil; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType; import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; /** * @author semancik - * */ -public class TestParseMisc { +public class TestParseMisc extends AbstractSchemaTest { public static final File TEST_DIR = new File("src/test/resources/misc"); protected static final File ROLE_FILTERS_FILE = new File(TEST_DIR, "role-filters.xml"); protected static final String ROLE_FILTERS_OID = "aad19b9a-d511-11e7-8bf7-cfecde275e59"; - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - SchemaDebugUtil.initialize(); // Make sure the pretty printer is activated - } - - @Test public void testParseRoleFilters() throws Exception { - System.out.println("\n\n===[ testParseRoleFilters ]===\n"); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -85,9 +66,8 @@ public void testParseRoleFilters() throws Exception { assertEquals("Wrong number of inducements", 2, inducements.size()); } - - private void assertPropertyDefinition(PrismContainer container, String propName, QName xsdType, int minOccurs, - int maxOccurs) { + private void assertPropertyDefinition(PrismContainer container, + String propName, QName xsdType, int minOccurs, int maxOccurs) { QName propQName = new QName(SchemaConstantsGenerated.NS_COMMON, propName); PrismAsserts.assertPropertyDefinition(container, propQName, xsdType, minOccurs, maxOccurs); } @@ -96,11 +76,4 @@ public static void assertPropertyValue(PrismContainer container, String propN ItemName propQName = new ItemName(SchemaConstantsGenerated.NS_COMMON, propName); PrismAsserts.assertPropertyValue(container, propQName, propValue); } - - public static void assertPropertyValues(PrismContainer container, String propName, T... expectedValues) { - ItemName propQName = new ItemName(SchemaConstantsGenerated.NS_COMMON, propName); - PrismAsserts.assertPropertyValue(container, propQName, expectedValues); - } - - } diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseModelContext.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseModelContext.java deleted file mode 100644 index 7f296cfa31c..00000000000 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseModelContext.java +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Copyright (c) 2010-2013 Evolveum and contributors - * - * This work is dual-licensed under the Apache License 2.0 - * and European Union Public License. See LICENSE file for details. - */ -package com.evolveum.midpoint.schema; - -import com.evolveum.midpoint.prism.PrismContext; -import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.xml.ns._public.common.common_3.LensContextType; - -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import java.io.File; -import java.io.IOException; - -/** - * @author semancik - * @author mederly - * - */ -public class TestParseModelContext { - - public static final File MODEL_CONTEXT_FILE = new File("src/test/resources/common/model-context-1.xml"); - - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } - - - @Test - public void testParseModelContextPrism() throws Exception { - System.out.println("===[ testParseModelContextPrism ]==="); - - // GIVEN - PrismContext prismContext = PrismTestUtil.getPrismContext(); - - // WHEN - LensContextType lensContextType = prismContext.parserFor(MODEL_CONTEXT_FILE).xml().parseRealValue(LensContextType.class); - - // THEN - System.out.println("Parsed LensContextType: " + lensContextType); - } - -// @Test -// public void testParseTaskDom() throws SchemaException { -// System.out.println("===[ testParseTaskDom ]==="); -// -// // GIVEN -// PrismContext prismContext = PrismTestUtil.getPrismContext(); -// -// Document document = DOMUtil.parseFile(MODEL_CONTEXT_FILE); -// Element taskElement = DOMUtil.getFirstChildElement(document); -// -// // WHEN -// PrismObject task = prismContext.parseObject(taskElement); -// -// // THEN -// System.out.println("Parsed task:"); -// System.out.println(task.dump()); -// -// assertTask(task); -// } -// -// @Test -// public void testPrismParseJaxb() throws JAXBException, SchemaException, SAXException, IOException { -// System.out.println("===[ testPrismParseJaxb ]==="); -// -// // GIVEN -// PrismContext prismContext = PrismTestUtil.getPrismContext(); -// PrismJaxbProcessor jaxbProcessor = prismContext.getPrismJaxbProcessor(); -// -// // WHEN -// TaskType taskType = jaxbProcessor.unmarshalObject(MODEL_CONTEXT_FILE, TaskType.class); -// -// // THEN -// System.out.println("Parsed task:"); -// System.out.println(taskType.asPrismObject().dump()); -// -// assertTask(taskType.asPrismObject()); -// } -// -// /** -// * The definition should be set properly even if the declared type is ObjectType. The Prism should determine -// * the actual type. -// */ -// @Test -// public void testPrismParseJaxbObjectType() throws JAXBException, SchemaException, SAXException, IOException { -// System.out.println("===[ testPrismParseJaxbObjectType ]==="); -// -// // GIVEN -// PrismContext prismContext = PrismTestUtil.getPrismContext(); -// PrismJaxbProcessor jaxbProcessor = prismContext.getPrismJaxbProcessor(); -// -// // WHEN -// ObjectType taskType = jaxbProcessor.unmarshalObject(MODEL_CONTEXT_FILE, ObjectType.class); -// -// // THEN -// System.out.println("Parsed task:"); -// System.out.println(taskType.asPrismObject().dump()); -// -// assertTask(taskType.asPrismObject()); -// } -// -// /** -// * Parsing in form of JAXBELement -// */ -// @Test -// public void testPrismParseJaxbElement() throws JAXBException, SchemaException, SAXException, IOException { -// System.out.println("===[ testPrismParseJaxbElement ]==="); -// -// // GIVEN -// PrismContext prismContext = PrismTestUtil.getPrismContext(); -// PrismJaxbProcessor jaxbProcessor = prismContext.getPrismJaxbProcessor(); -// -// // WHEN -// JAXBElement jaxbElement = jaxbProcessor.unmarshalElement(MODEL_CONTEXT_FILE, TaskType.class); -// TaskType taskType = jaxbElement.getValue(); -// -// // THEN -// System.out.println("Parsed task:"); -// System.out.println(taskType.asPrismObject().dump()); -// -// assertTask(taskType.asPrismObject()); -// } -// -// /** -// * Parsing in form of JAXBELement, with declared ObjectType -// */ -// @Test -// public void testPrismParseJaxbElementObjectType() throws JAXBException, SchemaException, SAXException, IOException { -// System.out.println("===[ testPrismParseJaxbElementObjectType ]==="); -// -// // GIVEN -// PrismContext prismContext = PrismTestUtil.getPrismContext(); -// PrismJaxbProcessor jaxbProcessor = prismContext.getPrismJaxbProcessor(); -// -// // WHEN -// JAXBElement jaxbElement = jaxbProcessor.unmarshalElement(MODEL_CONTEXT_FILE, ObjectType.class); -// ObjectType taskType = jaxbElement.getValue(); -// -// // THEN -// System.out.println("Parsed task:"); -// System.out.println(taskType.asPrismObject().dump()); -// -// assertTask(taskType.asPrismObject()); -// } -// -// -// private void assertTask(PrismObject task) { -// -// task.checkConsistence(); -// -// assertEquals("Wrong oid", "44444444-4444-4444-4444-000000001111", task.getOid()); -//// assertEquals("Wrong version", "42", user.getVersion()); -// PrismObjectDefinition usedDefinition = task.getDefinition(); -// assertNotNull("No task definition", usedDefinition); -// PrismAsserts.assertObjectDefinition(usedDefinition, new QName(SchemaConstantsGenerated.NS_COMMON, "task"), -// TaskType.COMPLEX_TYPE, TaskType.class); -// assertEquals("Wrong class in task", TaskType.class, task.getCompileTimeClass()); -// TaskType taskType = task.asObjectable(); -// assertNotNull("asObjectable resulted in null", taskType); -// -// assertPropertyValue(task, "name", PrismTestUtil.createPolyString("Example Task")); -// assertPropertyDefinition(task, "name", PolyStringType.COMPLEX_TYPE, 0, 1); -// -// assertPropertyValue(task, "taskIdentifier", "44444444-4444-4444-4444-000000001111"); -// assertPropertyDefinition(task, "taskIdentifier", DOMUtil.XSD_STRING, 0, 1); -// -// assertPropertyDefinition(task, "executionStatus", JAXBUtil.getTypeQName(TaskExecutionStatusType.class), 1, 1); -// PrismProperty executionStatusProperty = task.findProperty(TaskType.F_EXECUTION_STATUS); -// PrismPropertyValue executionStatusValue = executionStatusProperty.getValue(); -// TaskExecutionStatusType executionStatus = executionStatusValue.getValue(); -// assertEquals("Wrong execution status", TaskExecutionStatusType.RUNNABLE, executionStatus); -// -// // TODO: more tests -// -//// PrismContainer extension = user.getExtension(); -//// assertContainerDefinition(extension, "extension", DOMUtil.XSD_ANY, 0, 1); -//// PrismContainerValue extensionValue = extension.getValue(); -//// assertTrue("Extension parent", extensionValue.getParent() == extension); -//// assertNull("Extension ID", extensionValue.getId()); -// -//// PropertyPath enabledPath = new PropertyPath(UserType.F_ACTIVATION, ActivationType.F_ENABLED); -//// PrismProperty enabledProperty1 = task.findProperty(enabledPath); -//// PrismAsserts.assertDefinition(enabledProperty1.getDefinition(), ActivationType.F_ENABLED, DOMUtil.XSD_BOOLEAN, 0, 1); -//// assertNotNull("Property "+enabledPath+" not found", enabledProperty1); -//// PrismAsserts.assertPropertyValue(enabledProperty1, true); -// -//// PrismProperty validFromProperty = user.findProperty(new PropertyPath(UserType.F_ACTIVATION, ActivationType.F_VALID_FROM)); -//// assertNotNull("Property "+ActivationType.F_VALID_FROM+" not found", validFromProperty); -//// PrismAsserts.assertPropertyValue(validFromProperty, USER_JACK_VALID_FROM); -// -//// PrismReference accountRef = task.findReference(UserType.F_ACCOUNT_REF); -//// assertEquals("Wrong number of accountRef values", 3, accountRef.getValues().size()); -//// PrismAsserts.assertReferenceValue(accountRef, "2f9b9299-6f45-498f-aaaa-000000001111"); -//// PrismAsserts.assertReferenceValue(accountRef, "2f9b9299-6f45-498f-aaaa-000000002222"); -//// PrismAsserts.assertReferenceValue(accountRef, "2f9b9299-6f45-498f-aaaa-000000003333"); -// } -// -// private void assertPropertyDefinition(PrismContainer container, String propName, QName xsdType, int minOccurs, -// int maxOccurs) { -// QName propQName = new QName(SchemaConstantsGenerated.NS_COMMON, propName); -// PrismAsserts.assertPropertyDefinition(container, propQName, xsdType, minOccurs, maxOccurs); -// } -// -// public static void assertPropertyValue(PrismContainer container, String propName, Object propValue) { -// QName propQName = new QName(SchemaConstantsGenerated.NS_COMMON, propName); -// PrismAsserts.assertPropertyValue(container, propQName, propValue); -// } - -} diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseObjectTemplate.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseObjectTemplate.java index c1da02efd70..2fc8f784339 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseObjectTemplate.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseObjectTemplate.java @@ -6,69 +6,52 @@ */ package com.evolveum.midpoint.schema; +import static org.testng.AssertJUnit.*; + +import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; +import javax.xml.bind.JAXBElement; +import javax.xml.namespace.QName; + +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.path.ItemName; import com.evolveum.midpoint.prism.query.EqualFilter; import com.evolveum.midpoint.prism.query.ObjectFilter; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; -import com.evolveum.midpoint.schema.util.SchemaDebugUtil; -import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; import com.evolveum.prism.xml.ns._public.types_3.RawType; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import javax.xml.bind.JAXBElement; -import javax.xml.namespace.QName; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.atomic.AtomicInteger; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; -import static org.testng.AssertJUnit.*; - -/** - * @author semancik - * - */ -public class TestParseObjectTemplate { +public class TestParseObjectTemplate extends AbstractSchemaTest { public static final File TEST_DIR = new File("src/test/resources/object-template"); private static final File OBJECT_TEMPLATE_FILE = new File(TEST_DIR, "object-template.xml"); private static final File USER_TEMPLATE_FILE = new File(TEST_DIR, "user-template.xml"); private static final File WRONG_TEMPLATE_FILE = new File(TEST_DIR, "wrong-template.xml"); - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - SchemaDebugUtil.initialize(); // Make sure the pretty printer is activated - System.out.println("Pretty printers:\n"+PrettyPrinter.getPrettyPrinters()); - } - - @Test public void testParseObjectTemplateFileSingle() throws Exception { - single("testParseObjectTemplateFileSingle", OBJECT_TEMPLATE_FILE, + single(OBJECT_TEMPLATE_FILE, new QName(SchemaConstantsGenerated.NS_COMMON, "objectTemplate")); } @Test public void testParseUserTemplateFileSingle() throws Exception { - single("testParseUserTemplateFileSingle", USER_TEMPLATE_FILE, + single(USER_TEMPLATE_FILE, new QName(SchemaConstantsGenerated.NS_COMMON, "objectTemplate")); } @Test public void testParseObjectTemplateFileRoundTrip() throws Exception { - roundTrip("testParseObjectTemplateFileRoundTrip", OBJECT_TEMPLATE_FILE, + roundTrip(OBJECT_TEMPLATE_FILE, new QName(SchemaConstantsGenerated.NS_COMMON, "objectTemplate")); } @@ -122,17 +105,14 @@ public void testAccessObjectTemplateMultithreaded() throws Exception { @Test public void testParseUserTemplateFileRoundTrip() throws Exception { - roundTrip("testParseUserTemplateFileRoundTrip", USER_TEMPLATE_FILE, + roundTrip(USER_TEMPLATE_FILE, new QName(SchemaConstantsGenerated.NS_COMMON, "objectTemplate")); } @Test public void testParseWrongTemplateFile() throws Exception { - final String TEST_NAME = "testParseWrongTemplateFile"; File file = WRONG_TEMPLATE_FILE; - System.out.println("===[ "+TEST_NAME+" ]==="); - // GIVEN PrismContext prismContext = getPrismContext(); @@ -149,9 +129,7 @@ public void testParseWrongTemplateFile() throws Exception { } } - private void single(final String TEST_NAME, File file, QName elementName) throws Exception { - System.out.println("\n\n===[ "+TEST_NAME+" ]===\n"); - + private void single(File file, QName elementName) throws Exception { // GIVEN PrismContext prismContext = getPrismContext(); @@ -163,12 +141,10 @@ private void single(final String TEST_NAME, File file, QName elementName) throws System.out.println(object.debugDump()); assertObjectTemplate(object, elementName); - assertObjectTemplateInternals(object, elementName); + assertObjectTemplateInternals(object); } - private void roundTrip(final String TEST_NAME, File file, QName elementName) throws Exception { - System.out.println("\n\n===[ "+TEST_NAME+" ]===\n"); - + private void roundTrip(File file, QName elementName) throws Exception { // GIVEN PrismContext prismContext = getPrismContext(); @@ -190,7 +166,7 @@ private void roundTrip(final String TEST_NAME, File file, QName elementName) thr System.out.println("Serialized object:"); System.out.println(xml); - assertSerializedObject(xml, elementName); + // TODO // WHEN PrismObject reparsedObject = prismContext.parseObject(xml); @@ -200,7 +176,7 @@ private void roundTrip(final String TEST_NAME, File file, QName elementName) thr System.out.println(reparsedObject.debugDump()); assertObjectTemplate(reparsedObject, elementName); - assertObjectTemplateInternals(reparsedObject, elementName); + assertObjectTemplateInternals(reparsedObject); } private void assertObjectTemplate(PrismObject object, QName elementName) { @@ -227,7 +203,7 @@ private void assertObjectTemplatePrism(PrismObject object, Q // checks raw values of mappings // should be called only on reparsed values in order to catch some raw-data-related serialization issues (MID-2196) - private void assertObjectTemplateInternals(PrismObject object, QName elementName) throws SchemaException { + private void assertObjectTemplateInternals(PrismObject object) throws SchemaException { int assignmentValuesFound = 0; for (ObjectTemplateMappingType mappingType : object.asObjectable().getMapping()) { if (mappingType.getExpression() != null) { @@ -253,13 +229,6 @@ private void assertObjectTemplateInternals(PrismObject objec assertEquals("wrong # of assignment values found in mapping", 2, assignmentValuesFound); } - - private void assertSerializedObject(String xml, QName elementName) { - // TODO - } - - - private void assertPropertyDefinition(PrismContainer container, String propName, QName xsdType, int minOccurs, int maxOccurs) { ItemName propQName = new ItemName(SchemaConstantsGenerated.NS_COMMON, propName); @@ -271,11 +240,6 @@ public static void assertPropertyValue(PrismContainer container, String propN PrismAsserts.assertPropertyValue(container, propQName, propValue); } - public static void assertPropertyValues(PrismContainer container, String propName, T... expectedValues) { - ItemName propQName = new ItemName(SchemaConstantsGenerated.NS_COMMON, propName); - PrismAsserts.assertPropertyValue(container, propQName, expectedValues); - } - // todo deduplicate with TestUtil private static void waitForCompletion(List threads, long timeout) throws InterruptedException { long start = System.currentTimeMillis(); diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParsePasswordPolicy.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParsePasswordPolicy.java index 36aef28594e..f9427730896 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParsePasswordPolicy.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParsePasswordPolicy.java @@ -7,6 +7,13 @@ package com.evolveum.midpoint.schema; +import static org.testng.AssertJUnit.*; + +import java.io.File; +import javax.xml.namespace.QName; + +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.PrismContainer; import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.PrismObject; @@ -15,43 +22,19 @@ import com.evolveum.midpoint.prism.path.ItemName; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import javax.xml.namespace.QName; -import java.io.File; -import java.io.IOException; - -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; /** * @author semancik * @author mederly - * */ -public class TestParsePasswordPolicy { +public class TestParsePasswordPolicy extends AbstractSchemaTest { public static final File FILE = new File("src/test/resources/common/password-policy.xml"); - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } - - @Test public void testParsePasswordPolicyFile() throws Exception { - System.out.println("===[ testParsePasswordPolicyFile ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -67,8 +50,6 @@ public void testParsePasswordPolicyFile() throws Exception { @Test public void testParsePolicyRoundtrip() throws Exception { - System.out.println("===[ testParsePolicyRoundtrip ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -105,7 +86,6 @@ public void testParsePolicyRoundtrip() throws Exception { } private void assertPolicy(PrismObject policy) { - policy.checkConsistence(); assertEquals("Wrong oid", "00000000-0000-0000-0000-000000000003", policy.getOid()); @@ -123,8 +103,8 @@ private void assertPolicy(PrismObject policy) { // TODO... } - private void assertPropertyDefinition(PrismContainer container, String propName, QName xsdType, int minOccurs, - int maxOccurs) { + private void assertPropertyDefinition(PrismContainer container, + String propName, QName xsdType, int minOccurs, int maxOccurs) { ItemName propQName = new ItemName(SchemaConstantsGenerated.NS_COMMON, propName); PrismAsserts.assertPropertyDefinition(container, propQName, xsdType, minOccurs, maxOccurs); } @@ -133,5 +113,4 @@ public static void assertPropertyValue(PrismContainer container, String propN ItemName propQName = new ItemName(SchemaConstantsGenerated.NS_COMMON, propName); PrismAsserts.assertPropertyValue(container, propQName, propValue); } - } diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseTask.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseTask.java index 4a23d2970cf..093293d2de7 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseTask.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseTask.java @@ -6,59 +6,45 @@ */ package com.evolveum.midpoint.schema; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertNotNull; + +import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; +import static com.evolveum.midpoint.prism.util.PrismTestUtil.getSchemaRegistry; + +import java.io.File; +import java.io.IOException; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.namespace.QName; + +import org.testng.annotations.Test; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + import com.evolveum.midpoint.prism.*; +import com.evolveum.midpoint.prism.impl.util.JaxbTestUtil; import com.evolveum.midpoint.prism.path.ItemName; import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.prism.util.PrismAsserts; -import com.evolveum.midpoint.prism.impl.util.JaxbTestUtil; import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.JAXBUtil; -import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.query_3.QueryType; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.xml.sax.SAXException; - -import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBException; -import javax.xml.namespace.QName; - -import java.io.File; -import java.io.IOException; - -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getSchemaRegistry; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; - /** * @author semancik - * */ -public class TestParseTask { +public class TestParseTask extends AbstractSchemaTest { public static final File TASK_FILE = new File("src/test/resources/common/task-1.xml"); - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } - - @Test(enabled = false) public void testParseTaskFile() throws Exception { - System.out.println("===[ testParseTaskFile ]==="); - // GIVEN PrismContext prismContext = getPrismContext(); @@ -78,8 +64,6 @@ public void testParseTaskFile() throws Exception { @Test(enabled = false) public void testParseTaskDom() throws SchemaException { - System.out.println("===[ testParseTaskDom ]==="); - // GIVEN PrismContext prismContext = getPrismContext(); @@ -98,11 +82,8 @@ public void testParseTaskDom() throws SchemaException { @Deprecated @Test(enabled = false) - public void testPrismParseJaxb() throws JAXBException, SchemaException, SAXException, IOException { - System.out.println("===[ testPrismParseJaxb ]==="); - + public void testPrismParseJaxb() throws JAXBException, SchemaException, IOException { // GIVEN - PrismContext prismContext = getPrismContext(); JaxbTestUtil jaxbProcessor = JaxbTestUtil.getInstance(); // WHEN @@ -121,11 +102,8 @@ public void testPrismParseJaxb() throws JAXBException, SchemaException, SAXExcep */ @Deprecated @Test(enabled = false) - public void testPrismParseJaxbObjectType() throws JAXBException, SchemaException, SAXException, IOException { - System.out.println("===[ testPrismParseJaxbObjectType ]==="); - + public void testPrismParseJaxbObjectType() throws JAXBException, SchemaException, IOException { // GIVEN - PrismContext prismContext = getPrismContext(); JaxbTestUtil jaxbProcessor = JaxbTestUtil.getInstance(); // WHEN @@ -143,11 +121,8 @@ public void testPrismParseJaxbObjectType() throws JAXBException, SchemaException */ @Deprecated @Test(enabled = false) - public void testPrismParseJaxbElement() throws JAXBException, SchemaException, SAXException, IOException { - System.out.println("===[ testPrismParseJaxbElement ]==="); - + public void testPrismParseJaxbElement() throws JAXBException, SchemaException, IOException { // GIVEN - PrismContext prismContext = getPrismContext(); JaxbTestUtil jaxbProcessor = JaxbTestUtil.getInstance(); // WHEN @@ -166,11 +141,8 @@ public void testPrismParseJaxbElement() throws JAXBException, SchemaException, S */ @Deprecated @Test(enabled = false) - public void testPrismParseJaxbElementObjectType() throws JAXBException, SchemaException, SAXException, IOException { - System.out.println("===[ testPrismParseJaxbElementObjectType ]==="); - + public void testPrismParseJaxbElementObjectType() throws JAXBException, SchemaException, IOException { // GIVEN - PrismContext prismContext = getPrismContext(); JaxbTestUtil jaxbProcessor = JaxbTestUtil.getInstance(); // WHEN @@ -184,7 +156,6 @@ public void testPrismParseJaxbElementObjectType() throws JAXBException, SchemaEx assertTask(taskType.asPrismObject()); } - private void assertTask(PrismObject task) { task.checkConsistence(); diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseTaskBulkAction.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseTaskBulkAction.java index e2cd8c59bed..bae6d9805c7 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseTaskBulkAction.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseTaskBulkAction.java @@ -7,51 +7,34 @@ package com.evolveum.midpoint.schema; +import static org.testng.AssertJUnit.*; + +import java.io.File; +import javax.xml.namespace.QName; + +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.path.ItemName; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.prism.xnode.RootXNode; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.JAXBUtil; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskExecutionStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import javax.xml.namespace.QName; -import java.io.File; -import java.io.IOException; - -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertTrue; /** * @author semancik - * */ -public class TestParseTaskBulkAction { +public class TestParseTaskBulkAction extends AbstractSchemaTest { public static final File TASK_FILE = new File("src/test/resources/common/task-bulk-action-1.xml"); - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } - @Test public void testParseTaskFileToXNode() throws Exception { - System.out.println("===[ testParseTaskFileToXNode ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -68,8 +51,6 @@ public void testParseTaskFileToXNode() throws Exception { @Test public void testParseTaskFile() throws Exception { - System.out.println("===[ testParseTaskFile ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -85,8 +66,6 @@ public void testParseTaskFile() throws Exception { @Test public void testParseTaskRoundtrip() throws Exception { - System.out.println("===[ testParseTaskRoundtrip ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -128,9 +107,7 @@ public void testParseTaskRoundtrip() throws Exception { PrismAsserts.assertEquivalent("Task re-parsed equivalence", task, reparsedTask); } - private void assertTask(PrismObject task) { - task.checkConsistence(); assertEquals("Wrong oid", "44444444-4444-4444-4444-000000001111", task.getOid()); @@ -161,13 +138,14 @@ private void assertTask(PrismObject task) { } - private void assertPropertyDefinition(PrismContainer container, String propName, QName xsdType, int minOccurs, - int maxOccurs) { + private void assertPropertyDefinition( + PrismContainer container, String propName, QName xsdType, int minOccurs, int maxOccurs) { ItemName propQName = new ItemName(SchemaConstantsGenerated.NS_COMMON, propName); PrismAsserts.assertPropertyDefinition(container, propQName, xsdType, minOccurs, maxOccurs); } - public static void assertPropertyValue(PrismContainer container, String propName, Object propValue) { + public static void assertPropertyValue( + PrismContainer container, String propName, Object propValue) { ItemName propQName = new ItemName(SchemaConstantsGenerated.NS_COMMON, propName); PrismAsserts.assertPropertyValue(container, propQName, propValue); } diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseTaskBulkAction2.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseTaskBulkAction2.java index 142e2db8647..5ff3388ef86 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseTaskBulkAction2.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseTaskBulkAction2.java @@ -7,6 +7,13 @@ package com.evolveum.midpoint.schema; +import static org.testng.AssertJUnit.assertTrue; + +import java.io.File; +import javax.xml.namespace.QName; + +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.Item; import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.PrismObject; @@ -14,40 +21,16 @@ import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.prism.xnode.RootXNode; -import com.evolveum.midpoint.schema.constants.MidPointConstants; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType; import com.evolveum.midpoint.xml.ns._public.model.scripting_3.ExecuteScriptType; import com.evolveum.prism.xml.ns._public.types_3.RawType; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; -import javax.xml.namespace.QName; -import java.io.File; -import java.io.IOException; - -import static org.testng.AssertJUnit.assertTrue; - -/** - * @author semancik - * - */ -public class TestParseTaskBulkAction2 { +public class TestParseTaskBulkAction2 extends AbstractSchemaTest { public static final File TASK_FILE = new File("src/test/resources/common/task-bulk-action-2.xml"); - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } - @Test public void testParseTaskFileToXNode() throws Exception { - System.out.println("===[ testParseTaskFileToXNode ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -64,8 +47,6 @@ public void testParseTaskFileToXNode() throws Exception { @Test public void testParseTaskFile() throws Exception { - System.out.println("===[ testParseTaskFile ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -76,7 +57,7 @@ public void testParseTaskFile() throws Exception { System.out.println("Parsed task:"); System.out.println(task.debugDump()); - assertTask(task); + task.checkConsistence(); Item executeScriptItem = task.findExtensionItem(new QName("executeScript")); ExecuteScriptType executeScript = (ExecuteScriptType) executeScriptItem.getRealValue(); @@ -87,8 +68,6 @@ public void testParseTaskFile() throws Exception { @Test public void testParseTaskRoundtrip() throws Exception { - System.out.println("===[ testParseTaskRoundtrip ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -97,7 +76,7 @@ public void testParseTaskRoundtrip() throws Exception { System.out.println("Parsed task:"); System.out.println(task.debugDump()); - assertTask(task); + task.checkConsistence(); // SERIALIZE @@ -120,7 +99,7 @@ public void testParseTaskRoundtrip() throws Exception { System.out.println(reparsedTask.debugDump()); // Cannot assert here. It will cause parsing of some of the raw values and diff will fail - assertTask(reparsedTask); + reparsedTask.checkConsistence(); ObjectDelta objectDelta = task.diff(reparsedTask); System.out.println("Delta:"); @@ -135,49 +114,4 @@ public void testParseTaskRoundtrip() throws Exception { System.out.println(o); assertTrue("Raw value is not parsed", o instanceof RawType && ((RawType) o).getAlreadyParsedValue() != null); } - - - private void assertTask(PrismObject task) { - - task.checkConsistence(); - -// assertEquals("Wrong oid", "44444444-4444-4444-4444-000000001111", task.getOid()); -// PrismObjectDefinition usedDefinition = task.getDefinition(); -// assertNotNull("No task definition", usedDefinition); -// PrismAsserts.assertObjectDefinition(usedDefinition, new QName(SchemaConstantsGenerated.NS_COMMON, "task"), -// TaskType.COMPLEX_TYPE, TaskType.class); -// assertEquals("Wrong class in task", TaskType.class, task.getCompileTimeClass()); -// TaskType taskType = task.asObjectable(); -// assertNotNull("asObjectable resulted in null", taskType); -// -// assertPropertyValue(task, "name", PrismTestUtil.createPolyString("Task2")); -// assertPropertyDefinition(task, "name", PolyStringType.COMPLEX_TYPE, 0, 1); -// -// assertPropertyValue(task, "taskIdentifier", "44444444-4444-4444-4444-000000001111"); -// assertPropertyDefinition(task, "taskIdentifier", DOMUtil.XSD_STRING, 0, 1); -// -// assertPropertyDefinition(task, "executionStatus", JAXBUtil.getTypeQName(TaskExecutionStatusType.class), 1, 1); -// PrismProperty executionStatusProperty = task.findProperty(TaskType.F_EXECUTION_STATUS); -// PrismPropertyValue executionStatusValue = executionStatusProperty.getValue(); -// TaskExecutionStatusType executionStatus = executionStatusValue.getValue(); -// assertEquals("Wrong execution status", TaskExecutionStatusType.RUNNABLE, executionStatus); -// -// PrismContainer extension = task.getExtension(); -// PrismContainerValue extensionValue = extension.getValue(); -// assertTrue("Extension parent", extensionValue.getParent() == extension); -// assertNull("Extension ID", extensionValue.getId()); - - } - -// private void assertPropertyDefinition(PrismContainer container, String propName, QName xsdType, int minOccurs, -// int maxOccurs) { -// QName propQName = new QName(SchemaConstantsGenerated.NS_COMMON, propName); -// PrismAsserts.assertPropertyDefinition(container, propQName, xsdType, minOccurs, maxOccurs); -// } - -// public static void assertPropertyValue(PrismContainer container, String propName, Object propValue) { -// QName propQName = new QName(SchemaConstantsGenerated.NS_COMMON, propName); -// PrismAsserts.assertPropertyValue(container, propQName, propValue); -// } - } diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestQueryConverter.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestQueryConverter.java index cb1f54cbe0a..776d155bb27 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestQueryConverter.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestQueryConverter.java @@ -181,8 +181,6 @@ public void testAccountQueryAttributesAndResourceNoNs() throws Exception { @Test public void testAccountQueryCompositeOr() throws Exception { - displayTestTitle("testAccountQueryCompositeOr"); - SearchFilterType filterType = unmarshalFilter(FILTER_OR_COMPOSITE); ObjectQuery query = toObjectQuery(ShadowType.class, filterType); displayQuery(query); @@ -217,7 +215,6 @@ public void testAccountQueryCompositeOr() throws Exception { @Test public void testConnectorQuery() throws Exception { - displayTestTitle("testConnectorQuery"); SearchFilterType filterType = PrismTestUtil.parseAtomicValue(FILTER_CONNECTOR_BY_TYPE_FILE, SearchFilterType.COMPLEX_TYPE); ObjectQuery query; try { diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSchemaDelta.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSchemaDelta.java index adc7bc7bc24..8f1fb352996 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSchemaDelta.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSchemaDelta.java @@ -40,7 +40,6 @@ public class TestSchemaDelta extends AbstractSchemaTest { @Test public void testAssignmentNullIdApplyToObject() throws Exception { final String TEST_NAME = "testAssignmentNullIdApplyToObject"; - displayTestTile(TEST_NAME); // GIVEN PrismObject user = PrismTestUtil.parseObject(USER_JACK_FILE); @@ -67,7 +66,6 @@ public void testAssignmentNullIdApplyToObject() throws Exception { @Test public void testAddInducementNullIdApplyToObject() throws Exception { final String TEST_NAME = "testAddInducementNullIdApplyToObject"; - displayTestTile(TEST_NAME); // GIVEN PrismObject role = PrismTestUtil.parseObject(ROLE_CONSTRUCTION_FILE); @@ -94,7 +92,6 @@ public void testAddInducementNullIdApplyToObject() throws Exception { @Test public void testDeleteInducementValidIdSameValueApplyToObject() throws Exception { final String TEST_NAME = "testDeleteInducementValidIdSameValueApplyToObject"; - displayTestTile(TEST_NAME); // GIVEN PrismObject role = PrismTestUtil.parseObject(ROLE_CONSTRUCTION_FILE); @@ -126,7 +123,6 @@ public void testDeleteInducementValidIdSameValueApplyToObject() throws Exception @Test public void testDeleteInducementValidIdEmptyValueApplyToObject() throws Exception { final String TEST_NAME = "testDeleteInducementValidIdEmptyValueApplyToObject"; - displayTestTile(TEST_NAME); // GIVEN PrismObject role = PrismTestUtil.parseObject(ROLE_CONSTRUCTION_FILE); @@ -153,7 +149,6 @@ public void testDeleteInducementValidIdEmptyValueApplyToObject() throws Exceptio @Test public void testDeleteInducementValidIdEmptyValueApplyToObjectStatic() throws Exception { final String TEST_NAME = "testDeleteInducementValidIdEmptyValueApplyToObjectStatic"; - displayTestTile(TEST_NAME); // GIVEN PrismObject role = PrismTestUtil.parseObject(ROLE_CONSTRUCTION_FILE); @@ -182,7 +177,6 @@ public void testDeleteInducementValidIdEmptyValueApplyToObjectStatic() throws Ex @Test public void testDeleteInducementConstructionSameNullIdApplyToObject() throws Exception { final String TEST_NAME = "testDeleteInducementConstructionSameNullIdApplyToObject"; - displayTestTile(TEST_NAME); // GIVEN PrismObject role = PrismTestUtil.parseObject(ROLE_CONSTRUCTION_FILE); @@ -221,7 +215,6 @@ public void testDeleteInducementConstructionSameNullIdApplyToObject() throws Exc @Test public void testDeleteInducementActivationSameNullIdApplyToObject() throws Exception { final String TEST_NAME = "testDeleteInducementActivationSameNullIdApplyToObject"; - displayTestTile(TEST_NAME); // GIVEN PrismObject role = PrismTestUtil.parseObject(ROLE_CONSTRUCTION_FILE); @@ -256,7 +249,6 @@ public void testDeleteInducementActivationSameNullIdApplyToObject() throws Excep @Test public void testDeleteUserAssignmentActivationSameNullIdApplyToObject() throws Exception { final String TEST_NAME = "testDeleteUserAssignmentActivationSameNullIdApplyToObject"; - displayTestTile(TEST_NAME); // GIVEN PrismObject user = PrismTestUtil.parseObject(USER_JACK_FILE); @@ -295,7 +287,6 @@ public void testDeleteUserAssignmentActivationSameNullIdApplyToObject() throws E @Test public void testAddAssignmentSameOidDifferentTargetType() throws Exception { final String TEST_NAME = "testAddAssignmentSameOidDifferentTargetType"; - displayTestTile(TEST_NAME); // GIVEN PrismObject user = new UserType(getPrismContext()) @@ -325,7 +316,6 @@ public void testAddAssignmentSameOidDifferentTargetType() throws Exception { @Test public void testSubtractAssignmentFromAddDelta() throws Exception { final String TEST_NAME = "testSubtractAssignmentFromAddDelta"; - displayTestTile(TEST_NAME); // GIVEN PrismObject user = PrismTestUtil.parseObject(USER_BILL_FILE); @@ -359,7 +349,6 @@ public void testSubtractAssignmentFromAddDelta() throws Exception { @Test public void testSubtractAssignmentFromModifyDelta() throws Exception { final String TEST_NAME = "testSubtractAssignmentFromModifyDelta"; - displayTestTile(TEST_NAME); // GIVEN PrismObject user = PrismTestUtil.parseObject(USER_BILL_FILE); @@ -400,7 +389,6 @@ public void testSubtractAssignmentFromModifyDelta() throws Exception { @Test public void testFactorAddDeltaForItem() throws Exception { final String TEST_NAME = "testFactorAddDeltaForItem"; - displayTestTile(TEST_NAME); // GIVEN PrismObject user = PrismTestUtil.parseObject(USER_BILL_FILE); @@ -434,7 +422,6 @@ private void assertDeltaOid(ObjectDelta delta, String expectedOid) { @Test public void testFactorAddDeltaForItems() throws Exception { final String TEST_NAME = "testFactorAddDeltaForItems"; - displayTestTile(TEST_NAME); // GIVEN PrismObject user = PrismTestUtil.parseObject(USER_BILL_FILE); @@ -462,7 +449,6 @@ public void testFactorAddDeltaForItems() throws Exception { @Test public void testFactorAddDeltaForItemValues() throws Exception { final String TEST_NAME = "testFactorAddDeltaForItemValues"; - displayTestTile(TEST_NAME); // GIVEN PrismObject user = PrismTestUtil.parseObject(USER_BILL_FILE); @@ -492,7 +478,6 @@ public void testFactorAddDeltaForItemValues() throws Exception { @Test public void testFactorModifyDeltaForItem() throws Exception { final String TEST_NAME = "testFactorModifyDeltaForItem"; - displayTestTile(TEST_NAME); // GIVEN String OID = "oid1"; @@ -524,7 +509,6 @@ public void testFactorModifyDeltaForItem() throws Exception { @Test public void testFactorModifyDeltaForItemValues() throws Exception { final String TEST_NAME = "testFactorModifyDeltaForItemValues"; - displayTestTile(TEST_NAME); // GIVEN String OID = "oid1"; @@ -573,7 +557,6 @@ public void testFactorModifyDeltaForItemValues() throws Exception { @Test // MID-4690 public void testObjectDeltaUnion() throws Exception { final String TEST_NAME="testObjectDeltaUnion"; - displayTestTile(TEST_NAME); // GIVEN ProtectedStringType value = new ProtectedStringType(); diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSchemaImmutability.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSchemaImmutability.java index 8292d34c983..f284a2b5497 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSchemaImmutability.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSchemaImmutability.java @@ -6,43 +6,29 @@ */ package com.evolveum.midpoint.schema; +import static org.testng.AssertJUnit.assertNotNull; + +import java.io.File; + +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilitiesType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import java.io.File; -import java.io.IOException; - -import static org.testng.AssertJUnit.assertNotNull; /** * Various tests related to schema immutability, definition cloning, etc. - * */ -public class TestSchemaImmutability { +public class TestSchemaImmutability extends AbstractSchemaTest { private static final File TEST_DIR = new File("src/test/resources/schema-immutability"); private static final File RESOURCE_DUMMY_VAULT_FILE = new File(TEST_DIR, "resource-dummy-vault.xml"); - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } - @Test public void testUltraDeepCloning() throws Exception { - System.out.println("===[ testUltraDeepCloning ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); PrismObject resource = prismContext.parseObject(RESOURCE_DUMMY_VAULT_FILE); @@ -55,7 +41,7 @@ public void testUltraDeepCloning() throws Exception { System.out.println("schemaHandling definition:\n" + schemaHandling.getDefinition().debugDump()); PrismAsserts.assertImmutable(schemaHandling.getDefinition()); - Item testConnection = resource.findItem(ItemPath.create(ResourceType.F_CAPABILITIES, CapabilitiesType.F_NATIVE, "testConnection")); + Item testConnection = resource.findItem(ItemPath.create(ResourceType.F_CAPABILITIES, CapabilitiesType.F_NATIVE, "testConnection")); assertNotNull("No testConnection capability", testConnection); assertNotNull("No testConnection capability definition", testConnection.getDefinition()); System.out.println("testConnection capability definition:\n" + testConnection.getDefinition().debugDump()); @@ -77,7 +63,7 @@ public void testUltraDeepCloning() throws Exception { System.out.println("Updated schemaHandling definition:\n" + updatedSchemaHandling.getDefinition().debugDump()); PrismAsserts.assertMutable(updatedSchemaHandling.getDefinition()); - Item updatedTestConnection = resource.findItem(ItemPath.create(ResourceType.F_CAPABILITIES, CapabilitiesType.F_NATIVE, "testConnection")); + Item updatedTestConnection = resource.findItem(ItemPath.create(ResourceType.F_CAPABILITIES, CapabilitiesType.F_NATIVE, "testConnection")); assertNotNull("No updated testConnection capability", updatedTestConnection); assertNotNull("No updated testConnection capability definition", updatedTestConnection.getDefinition()); System.out.println("Updated testConnection capability definition:\n" + updatedTestConnection.getDefinition().debugDump()); diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSchemaRegistry.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSchemaRegistry.java index 3b3a8cfed19..194b5c23ec4 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSchemaRegistry.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSchemaRegistry.java @@ -6,47 +6,33 @@ */ package com.evolveum.midpoint.schema; +import static org.testng.AssertJUnit.*; + +import java.io.IOException; +import java.util.List; +import javax.xml.transform.dom.DOMResult; +import javax.xml.transform.dom.DOMSource; +import javax.xml.validation.Schema; +import javax.xml.validation.Validator; + +import org.testng.annotations.Test; +import org.w3c.dom.Document; +import org.xml.sax.SAXException; + import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.impl.schema.SchemaRegistryImpl; -import com.evolveum.midpoint.schema.constants.SchemaConstants; - import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.prism.schema.PrismSchema; import com.evolveum.midpoint.prism.schema.SchemaRegistry; +import com.evolveum.midpoint.schema.constants.SchemaConstants; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.DebugUtil; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemObjectsType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; - -import org.testng.annotations.Test; -import org.w3c.dom.Document; -import org.xml.sax.SAXException; - -import javax.xml.transform.dom.DOMResult; -import javax.xml.transform.dom.DOMSource; -import javax.xml.validation.Schema; -import javax.xml.validation.Validator; - -import java.io.IOException; -import java.util.List; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; - -/** - * @author Radovan Semancik - */ -public class TestSchemaRegistry { +public class TestSchemaRegistry extends AbstractUnitTest { @SuppressWarnings("unused") // for the future private static final String FOO_NAMESPACE = "http://example.com/xml/ns/foo"; @@ -78,7 +64,6 @@ public void testBasic() throws SAXException, IOException, SchemaException { // System.out.println(DOMUtil.serializeDOMToString(validationResult.getNode())); } - @Test public void testCommonSchema() throws SchemaException, SAXException, IOException { @@ -118,8 +103,6 @@ public void testReferenceInExtension() throws SchemaException, SAXException, IOE @Test public void testUserType() throws Exception { - System.out.println("===[ testUserType ]==="); - MidPointPrismContextFactory factory = getContextFactory(); PrismContext context = factory.createInitializedPrismContext(); SchemaRegistry schemaRegistry = context.getSchemaRegistry(); @@ -159,8 +142,6 @@ public void testUserType() throws Exception { @Test public void testRoleType() throws Exception { - System.out.println("\n\n===[ testRoleType ]==="); - MidPointPrismContextFactory factory = getContextFactory(); PrismContext context = factory.createInitializedPrismContext(); SchemaRegistry schemaRegistry = context.getSchemaRegistry(); @@ -195,8 +176,6 @@ public void testRoleType() throws Exception { @Test public void testAbstractRoleType() throws Exception { - System.out.println("\n\n===[ testAbstractRoleType ]==="); - MidPointPrismContextFactory factory = getContextFactory(); PrismContext context = factory.createInitializedPrismContext(); SchemaRegistry schemaRegistry = context.getSchemaRegistry(); @@ -233,8 +212,6 @@ public void testAbstractRoleType() throws Exception { @Test public void testCommonSchemaShadowType() throws SchemaException, SAXException, IOException { - System.out.println("\n\n===[ testCommonSchemaShadowType ]==="); - MidPointPrismContextFactory factory = getContextFactory(); PrismContext context = factory.createInitializedPrismContext(); SchemaRegistry schemaRegistry = context.getSchemaRegistry(); @@ -257,21 +234,19 @@ public void testCommonSchemaShadowType() throws SchemaException, SAXException, I assertTrue("'attributes' definition is not marked as runtime", attributesDef.isRuntimeSchema()); List schemaMigrations = shadowDef.getSchemaMigrations(); - System.out.println("\nshadow schema migrations ("+schemaMigrations.size()+"):"); + System.out.println("\nshadow schema migrations (" + schemaMigrations.size() + "):"); System.out.println(DebugUtil.debugDump(schemaMigrations)); assertEquals("Wrong number of schema migrations in shadow definition", 1, schemaMigrations.size()); ComplexTypeDefinition shadowTypeDef = shadowDef.getComplexTypeDefinition(); List shadowTypeSchemaMigrations = shadowTypeDef.getSchemaMigrations(); - System.out.println("\nShadowType schema migrations ("+shadowTypeSchemaMigrations.size()+"):"); + System.out.println("\nShadowType schema migrations (" + shadowTypeSchemaMigrations.size() + "):"); System.out.println(DebugUtil.debugDump(shadowTypeSchemaMigrations)); assertEquals("Wrong number of schema migrations in ShadowType definition", 4, shadowTypeSchemaMigrations.size()); } @Test public void testCommonSchemaLegacyAccount() throws SchemaException, SAXException, IOException { - System.out.println("\n\n===[ testCommonSchemaLegacyAccount ]==="); - MidPointPrismContextFactory factory = getContextFactory(); PrismContext context = factory.createInitializedPrismContext(); SchemaRegistry schemaRegistry = context.getSchemaRegistry(); @@ -280,15 +255,13 @@ public void testCommonSchemaLegacyAccount() throws SchemaException, SAXException assertNotNull("No definition for legacy account", accountDef); System.out.println("\naccount definition:"); System.out.println(accountDef.debugDump(1)); - assertTrue("Expected object definition for legacy account, but got "+accountDef, accountDef instanceof PrismObjectDefinition); + assertTrue("Expected object definition for legacy account, but got " + accountDef, accountDef instanceof PrismObjectDefinition); assertEquals("Unexpected element name in legacy account definition", SchemaConstants.C_SHADOW, accountDef.getItemName()); } @Test public void testAuditTimestampDocumentation() throws SchemaException, SAXException, IOException { - System.out.println("\n\n===[ testAuditTimestampDocumentation ]==="); - MidPointPrismContextFactory factory = getContextFactory(); PrismContext context = factory.createInitializedPrismContext(); SchemaRegistry schemaRegistry = context.getSchemaRegistry(); diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSchemaSanity.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSchemaSanity.java index 6d153fd6837..b5ca82e3199 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSchemaSanity.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSchemaSanity.java @@ -6,32 +6,16 @@ */ package com.evolveum.midpoint.schema; -import static com.evolveum.midpoint.schema.util.SchemaTestConstants.EXTENSION_LOCATIONS_ELEMENT; -import static com.evolveum.midpoint.schema.util.SchemaTestConstants.EXTENSION_LOCATIONS_TYPE; -import static com.evolveum.midpoint.schema.util.SchemaTestConstants.ICFC_CONFIGURATION_PROPERTIES; -import static com.evolveum.midpoint.schema.util.SchemaTestConstants.ICFC_CONFIGURATION_PROPERTIES_TYPE; -import static com.evolveum.midpoint.schema.util.SchemaTestConstants.NS_ICFC; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; - -import java.io.IOException; +import static org.testng.AssertJUnit.*; + +import static com.evolveum.midpoint.schema.util.SchemaTestConstants.*; import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.path.ItemName; -import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import com.evolveum.midpoint.prism.ComplexTypeDefinition; -import com.evolveum.midpoint.prism.PrismConstants; -import com.evolveum.midpoint.prism.PrismContainer; -import com.evolveum.midpoint.prism.PrismContainerDefinition; -import com.evolveum.midpoint.prism.PrismContext; -import com.evolveum.midpoint.prism.PrismObjectDefinition; -import com.evolveum.midpoint.prism.PrismPropertyDefinition; + +import com.evolveum.midpoint.prism.*; +import com.evolveum.midpoint.prism.path.ItemName; import com.evolveum.midpoint.prism.schema.PrismSchema; import com.evolveum.midpoint.prism.schema.SchemaRegistry; import com.evolveum.midpoint.prism.util.PrismAsserts; @@ -42,37 +26,17 @@ import com.evolveum.midpoint.schema.util.SchemaTestConstants; import com.evolveum.midpoint.schema.util.SchemaTestUtil; import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.xml.ns._public.common.common_3.CachingMetadataType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorConfigurationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAttributesType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.XmlSchemaType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; import com.evolveum.prism.xml.ns._public.types_3.SchemaDefinitionType; /** * @author semancik - * */ -public class TestSchemaSanity { - - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } +public class TestSchemaSanity extends AbstractSchemaTest { @Test public void testPrefixMappings() { - System.out.println("===[ testPrefixMappings ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); assertNotNull("No prism context", prismContext); @@ -95,31 +59,27 @@ public void testPrefixMappings() { assertQName("common namespace implicit", SchemaConstantsGenerated.NS_COMMON, "bar", "", cBarQNameWithPrefix); QName cBarQNameWithPrefixExplixit = prefixMapper.setQNamePrefixExplicit(cBarQName); assertQName("common namespace implicit", SchemaConstantsGenerated.NS_COMMON, "bar", "c", cBarQNameWithPrefixExplixit); - } private void assertQName(String message, String expectedNamespace, String expectedLocalName, String expectedPrefix, QName actual) { - assertEquals("Wrong qname namespace in "+message, expectedNamespace, actual.getNamespaceURI()); - assertEquals("Wrong qname local part in "+message, expectedLocalName, actual.getLocalPart()); - assertEquals("Wrong qname prefix in "+message, expectedPrefix, actual.getPrefix()); - + assertEquals("Wrong qname namespace in " + message, expectedNamespace, actual.getNamespaceURI()); + assertEquals("Wrong qname local part in " + message, expectedLocalName, actual.getLocalPart()); + assertEquals("Wrong qname prefix in " + message, expectedPrefix, actual.getPrefix()); } private void assertMapping(DynamicNamespacePrefixMapper prefixMapper, String namespace, String prefix) { - assertEquals("Wrong prefix mapping for namespace "+namespace, prefix, prefixMapper.getPrefix(namespace)); + assertEquals("Wrong prefix mapping for namespace " + namespace, prefix, prefixMapper.getPrefix(namespace)); } @Test public void testUserDefinition() { - System.out.println("===[ testUserDefinition ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); SchemaRegistry schemaRegistry = prismContext.getSchemaRegistry(); // WHEN - PrismObjectDefinition userDefinition = schemaRegistry.findObjectDefinitionByElementName(new QName(SchemaConstantsGenerated.NS_COMMON,"user")); + PrismObjectDefinition userDefinition = schemaRegistry.findObjectDefinitionByElementName(new QName(SchemaConstantsGenerated.NS_COMMON, "user")); // THEN assertNotNull("No user definition", userDefinition); @@ -134,8 +94,6 @@ public void testUserDefinition() { @Test public void testAccountDefinition() { - System.out.println("===[ testAccountDefinition ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); SchemaRegistry schemaRegistry = prismContext.getSchemaRegistry(); @@ -148,7 +106,7 @@ public void testAccountDefinition() { System.out.println(accountDefinition.debugDump()); PrismObjectDefinition accountDefinitionByClass = - schemaRegistry.findObjectDefinitionByCompileTimeClass(ShadowType.class); + schemaRegistry.findObjectDefinitionByCompileTimeClass(ShadowType.class); assertTrue("Different account def", accountDefinition == accountDefinitionByClass); assertEquals("Wrong compile-time class in account definition", ShadowType.class, accountDefinition.getCompileTimeClass()); @@ -162,11 +120,8 @@ public void testAccountDefinition() { assertEquals("Wrong attributes compile-time class", ShadowAttributesType.class, attributesContainer.getCompileTimeClass()); } - @Test public void testResourceDefinition() { - System.out.println("===[ testResourceDefinition ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); SchemaRegistry schemaRegistry = prismContext.getSchemaRegistry(); @@ -179,7 +134,7 @@ public void testResourceDefinition() { System.out.println(resourceDefinition.debugDump()); PrismObjectDefinition resourceDefinitionByClass = - schemaRegistry.findObjectDefinitionByCompileTimeClass(ResourceType.class); + schemaRegistry.findObjectDefinitionByCompileTimeClass(ResourceType.class); assertTrue("Different user def", resourceDefinition == resourceDefinitionByClass); assertEquals("Wrong compile-time class in resource definition", ResourceType.class, resourceDefinition.getCompileTimeClass()); @@ -190,7 +145,6 @@ public void testResourceDefinition() { PrismContainerDefinition connectorConfContainerDef = resourceDefinition.findContainerDefinition(ResourceType.F_CONNECTOR_CONFIGURATION); PrismAsserts.assertDefinition(connectorConfContainerDef, ResourceType.F_CONNECTOR_CONFIGURATION, ConnectorConfigurationType.COMPLEX_TYPE, 1, 1); assertTrue(" is NOT dynamic", connectorConfContainerDef.isDynamic()); -// assertFalse(" is runtime", connectorConfContainerDef.isRuntimeSchema()); assertEquals("Wrong compile-time class for in resource definition", ConnectorConfigurationType.class, connectorConfContainerDef.getCompileTimeClass()); PrismContainerDefinition schemaContainerDef = resourceDefinition.findContainerDefinition(ResourceType.F_SCHEMA); @@ -203,13 +157,10 @@ public void testResourceDefinition() { PrismAsserts.assertPropertyDefinition(schemaContainerDef, XmlSchemaType.F_DEFINITION, SchemaDefinitionType.COMPLEX_TYPE, 0, 1); PrismPropertyDefinition definitionPropertyDef = schemaContainerDef.findPropertyDefinition(XmlSchemaType.F_DEFINITION); assertNotNull("Null definition", definitionPropertyDef); -// assertFalse("schema/definition is NOT runtime", definitionPropertyDef.isRuntimeSchema()); } @Test public void testResourceConfigurationDefinition() { - System.out.println("===[ testResourceConfigurationDefinition ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); SchemaRegistry schemaRegistry = prismContext.getSchemaRegistry(); @@ -222,23 +173,16 @@ public void testResourceConfigurationDefinition() { System.out.println(configurationPropertiesDefinition.debugDump()); assertTrue("configurationProperties definition is NOT marked as runtime", configurationPropertiesDefinition.isRuntimeSchema()); -// assertNull("Unexpected compile-time class in configurationProperties definition", configurationPropertiesDefinition.getCompileTimeClass()); - -// assertTrue("configurationProperties definition is NOT marked as wildcard", configurationPropertiesDefinition.isWildcard()); - - // TODO } @Test public void testRoleDefinition() { - System.out.println("===[ testRoleDefinition ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); SchemaRegistry schemaRegistry = prismContext.getSchemaRegistry(); // WHEN - PrismObjectDefinition roleDefinition = schemaRegistry.findObjectDefinitionByElementName(new QName(SchemaConstantsGenerated.NS_COMMON,"role")); + PrismObjectDefinition roleDefinition = schemaRegistry.findObjectDefinitionByElementName(new QName(SchemaConstantsGenerated.NS_COMMON, "role")); // THEN assertNotNull("No role definition", roleDefinition); @@ -260,8 +204,6 @@ public void testRoleDefinition() { @Test public void testFocusDefinition() { - System.out.println("===[ testFocusDefinition ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); SchemaRegistry schemaRegistry = prismContext.getSchemaRegistry(); @@ -279,8 +221,6 @@ public void testFocusDefinition() { @Test public void testIcfSchema() { - System.out.println("===[ testIcfSchema ]==="); - // WHEN // The context should have parsed common schema and also other midPoint schemas PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -296,12 +236,10 @@ public void testIcfSchema() { System.out.println("ICF schema:"); System.out.println(icfSchema.debugDump()); - PrismContainerDefinition configurationPropertiesContainerDef = icfSchema.findContainerDefinitionByElementName(ICFC_CONFIGURATION_PROPERTIES); PrismAsserts.assertDefinition(configurationPropertiesContainerDef, ICFC_CONFIGURATION_PROPERTIES, ICFC_CONFIGURATION_PROPERTIES_TYPE, 0, 1); assertTrue("configurationPropertiesContainer definition is NOT marked as runtime", configurationPropertiesContainerDef.isRuntimeSchema()); assertTrue("configurationPropertiesContainer definition is NOT marked as dynamic", configurationPropertiesContainerDef.isDynamic()); - } /** @@ -309,8 +247,6 @@ public void testIcfSchema() { */ @Test public void testExtensionSchema() { - System.out.println("===[ testExtensionSchema ]==="); - // WHEN PrismContext prismContext = PrismTestUtil.getPrismContext(); assertNotNull("No prism context", prismContext); @@ -322,7 +258,6 @@ public void testExtensionSchema() { System.out.println("Extension schema:"); System.out.println(extensionSchema.debugDump()); - PrismPropertyDefinition locationsProperty = extensionSchema.findPropertyDefinitionByElementName(EXTENSION_LOCATIONS_ELEMENT); PrismAsserts.assertDefinition(locationsProperty, EXTENSION_LOCATIONS_ELEMENT, EXTENSION_LOCATIONS_TYPE, 0, -1); } @@ -331,5 +266,4 @@ public static void assertPropertyValue(PrismContainer container, String propN ItemName propQName = new ItemName(SchemaConstantsGenerated.NS_COMMON, propName); PrismAsserts.assertPropertyValue(container, propQName, propValue); } - } diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSerialization.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSerialization.java index 2d6a7b0bb49..622a631c7a6 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSerialization.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSerialization.java @@ -6,50 +6,34 @@ */ package com.evolveum.midpoint.schema; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; import static org.testng.AssertJUnit.*; +import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; + +import java.io.File; +import javax.xml.namespace.QName; + +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.impl.DefaultReferencableImpl; import com.evolveum.midpoint.prism.impl.PrismReferenceValueImpl; -import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.util.LocalizationUtil; import com.evolveum.midpoint.schema.util.ObjectTypeUtil; -import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.SerializationUtil; import com.evolveum.midpoint.util.SingleLocalizableMessage; -import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ExecuteCredentialResetResponseType; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; - import com.evolveum.prism.xml.ns._public.types_3.DeltaSetTripleType; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import javax.xml.namespace.QName; -import java.io.File; -import java.io.IOException; - /** * @author semancik - * */ -public class TestSerialization { - - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } +public class TestSerialization extends AbstractSchemaTest { @Test public void testSerializeTrace() throws Exception { - System.out.println("===[ testSerializeTrace ]==="); - PrismContext prismContext = getPrismContext(); ValueTransformationTraceType trace = new ValueTransformationTraceType(prismContext); NamedValueType input1 = new NamedValueType(); @@ -63,8 +47,6 @@ public void testSerializeTrace() throws Exception { @Test public void testSerializeDeltaSetTripleType() throws Exception { - System.out.println("===[ testSerializeDeltaSetTripleType ]==="); - PrismContext prismContext = getPrismContext(); PrismReferenceValue refValue = new PrismReferenceValueImpl("123456"); @@ -79,8 +61,6 @@ public void testSerializeDeltaSetTripleType() throws Exception { @Test public void testSerializeNamedReference() throws Exception { - System.out.println("===[ testSerializeNamedReference ]==="); - PrismContext prismContext = getPrismContext(); ObjectReferenceType reference = new ObjectReferenceType() .oid("66662a3b-76eb-4465-8374-742f6e2f54b4") @@ -93,8 +73,6 @@ public void testSerializeNamedReference() throws Exception { @Test public void testSerializeFullReference() throws Exception { - System.out.println("===[ testSerializeFullReference ]==="); - PrismContext prismContext = getPrismContext(); QName fakeQName = new QName(PrismConstants.NS_TYPES, "ref"); @@ -115,8 +93,6 @@ public void testSerializeFullReference() throws Exception { @Test public void testSerializeMessage() throws Exception { - System.out.println("===[ testSerializeMessage ]==="); - PrismContext prismContext = getPrismContext(); SingleLocalizableMessage localizableMessage = new SingleLocalizableMessage("execute.reset.credential.bad.request", null, "Failed to execute reset password. Bad request."); LocalizableMessageType localizableMessageBean = LocalizationUtil.createLocalizableMessageType(localizableMessage); @@ -127,8 +103,6 @@ public void testSerializeMessage() throws Exception { @Test public void testSerializeExecuteCredentialResetResponseType() throws Exception { - System.out.println("===[ testSerializeExecuteCredentialResetResponseType ]==="); - PrismContext prismContext = getPrismContext(); SingleLocalizableMessage localizableMessage = new SingleLocalizableMessage("execute.reset.credential.bad.request", null, "Failed to execute reset password. Bad request."); @@ -145,22 +119,16 @@ public void testSerializeExecuteCredentialResetResponseType() throws Exception { @Test public void testSerializeResource() throws Exception { - System.out.println("===[ testSerializeResource ]==="); - serializationRoundTrip(TestConstants.RESOURCE_FILE); } @Test public void testSerializeUser() throws Exception { - System.out.println("===[ testSerializeUser ]==="); - serializationRoundTrip(TestConstants.USER_FILE); } @Test public void testSerializeRole() throws Exception { - System.out.println("===[ testSerializeRole ]==="); - PrismContext prismContext = getPrismContext(); PrismObject parsedObject = prismContext.parseObject(TestConstants.ROLE_FILE); @@ -205,7 +173,7 @@ private void serializationRoundTripPrismObject(PrismObjec deserializedObject.revive(getPrismContext()); ObjectDelta diff = parsedObject.diff(deserializedObject); - assertTrue("Something changed in serialization of "+parsedObject+" (PrismObject): "+diff, diff.isEmpty()); + assertTrue("Something changed in serialization of " + parsedObject + " (PrismObject): " + diff, diff.isEmpty()); ItemDefinition nameDef = deserializedObject.getDefinition().findLocalItemDefinition(ObjectType.F_NAME); assertNotNull("No 'name' definition in deserialized object", nameDef); @@ -225,7 +193,7 @@ private void serializationRoundTripObjectType(O parsedObj System.out.println(deserializedObject.asPrismObject().debugDump()); ObjectDelta diff = parsedObject.asPrismObject().diff((PrismObject) deserializedObject.asPrismObject()); - assertTrue("Something changed in serializetion of "+parsedObject+" (ObjectType): "+diff, diff.isEmpty()); + assertTrue("Something changed in serializetion of " + parsedObject + " (ObjectType): " + diff, diff.isEmpty()); } } diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/processor/TestResourceSchema.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/processor/TestResourceSchema.java index f2e139bf1ba..77a3861be84 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/processor/TestResourceSchema.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/processor/TestResourceSchema.java @@ -11,26 +11,27 @@ */ package com.evolveum.midpoint.schema.processor; +import static org.testng.AssertJUnit.*; + import java.io.File; -import java.io.IOException; import java.util.Collection; import java.util.List; +import javax.xml.namespace.QName; + +import org.testng.annotations.Test; +import org.w3c.dom.Document; +import org.w3c.dom.Element; -import com.evolveum.midpoint.prism.PrismConstants; -import com.evolveum.midpoint.prism.PrismContext; -import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.PrismObjectDefinition; -import com.evolveum.midpoint.prism.PrismPropertyDefinition; +import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.path.ItemName; import com.evolveum.midpoint.prism.util.PrismTestUtil; +import com.evolveum.midpoint.schema.AbstractSchemaTest; import com.evolveum.midpoint.schema.CapabilityUtil; -import com.evolveum.midpoint.schema.MidPointPrismContextFactory; import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.util.ObjectTypeUtil; import com.evolveum.midpoint.schema.util.ResourceTypeUtil; import com.evolveum.midpoint.schema.util.SchemaTestConstants; import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; @@ -40,21 +41,7 @@ import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.LiveSyncCapabilityType; import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.xml.sax.SAXException; - -import javax.xml.bind.JAXBException; -import javax.xml.namespace.QName; - -import static org.testng.AssertJUnit.*; - -/** - * @author semancik - */ -public class TestResourceSchema { +public class TestResourceSchema extends AbstractSchemaTest { private static final String TEST_DIR = "src/test/resources/processor/"; @@ -63,18 +50,8 @@ public class TestResourceSchema { private static final String SCHEMA_NAMESPACE = "http://schema.foo.com/bar"; - public TestResourceSchema() { - } - - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } - @Test public void testParseSchema() throws Exception { - System.out.println("===[ testParseSchema ]==="); // GIVEN Document schemaDom = DOMUtil.parseFile(RESOURCE_SCHEMA_SIMPLE_FILENAME); @@ -90,7 +67,6 @@ public void testParseSchema() throws Exception { @Test public void testParseSchemaDeprecated() throws Exception { - System.out.println("===[ testParseSchemaDeprecated ]==="); // GIVEN Document schemaDom = DOMUtil.parseFile(RESOURCE_SCHEMA_SIMPLE_DEPRECATED_FILENAME); @@ -137,9 +113,8 @@ private void assertSimpleSchema(ResourceSchema schema, String filename) { } // The support for the xsd:any properties is missing in JAXB generator. Otherwise this test should work. - @Test(enabled=false) - public void testResourceSchemaJaxbRoundTrip() throws SchemaException, JAXBException { - System.out.println("\n===[ testResourceSchemaJaxbRoundTrip ]====="); + @Test(enabled = false) + public void testResourceSchemaJaxbRoundTrip() throws SchemaException { // GIVEN ResourceSchema schema = createResourceSchema(); @@ -179,7 +154,6 @@ public void testResourceSchemaJaxbRoundTrip() throws SchemaException, JAXBExcept @Test public void testResourceSchemaPrismRoundTrip() throws SchemaException { - System.out.println("\n===[ testResourceSchemaPrismRoundTrip ]====="); // GIVEN ResourceSchema schema = createResourceSchema(); @@ -227,26 +201,21 @@ public void testResourceSchemaPrismRoundTrip() throws SchemaException { private void assertResourceSchema(ResourceSchema unSchema) { ObjectClassComplexTypeDefinition objectClassDef = unSchema.findObjectClassDefinition(new ItemName(SCHEMA_NAMESPACE, "AccountObjectClass")); assertNotNull("No object class def", objectClassDef); - assertEquals(new ItemName(SCHEMA_NAMESPACE,"AccountObjectClass"),objectClassDef.getTypeName()); + assertEquals(new ItemName(SCHEMA_NAMESPACE, "AccountObjectClass"), objectClassDef.getTypeName()); assertEquals("AccountObjectClass class not an account", ShadowKindType.ACCOUNT, objectClassDef.getKind()); assertTrue("AccountObjectClass class not a DEFAULT account", objectClassDef.isDefaultInAKind()); - PrismPropertyDefinition loginDef = objectClassDef.findPropertyDefinition(new ItemName(SCHEMA_NAMESPACE,"login")); - assertEquals(new ItemName(SCHEMA_NAMESPACE,"login"), loginDef.getItemName()); + PrismPropertyDefinition loginDef = objectClassDef.findPropertyDefinition(new ItemName(SCHEMA_NAMESPACE, "login")); + assertEquals(new ItemName(SCHEMA_NAMESPACE, "login"), loginDef.getItemName()); assertEquals(DOMUtil.XSD_STRING, loginDef.getTypeName()); - PrismPropertyDefinition passwdDef = objectClassDef.findPropertyDefinition(new ItemName(SCHEMA_NAMESPACE,"password")); - assertEquals(new ItemName(SCHEMA_NAMESPACE,"password"), passwdDef.getItemName()); + PrismPropertyDefinition passwdDef = objectClassDef.findPropertyDefinition(new ItemName(SCHEMA_NAMESPACE, "password")); + assertEquals(new ItemName(SCHEMA_NAMESPACE, "password"), passwdDef.getItemName()); assertEquals(ProtectedStringType.COMPLEX_TYPE, passwdDef.getTypeName()); - -// PrismContainerDefinition credDef = objectClassDef.findContainerDefinition(new SingleNamePath(SchemaConstants.NS_C,"credentials")); -// assertEquals(new SingleNamePath(SchemaConstants.NS_C,"credentials"), credDef.getName()); -// assertEquals(new SingleNamePath(SchemaConstants.NS_C,"CredentialsType"), credDef.getTypeName()); } @Test - public void testResourceSchemaSerializationDom() throws SchemaException, JAXBException { - System.out.println("\n===[ testResourceSchemaSerializationDom ]====="); + public void testResourceSchemaSerializationDom() throws SchemaException { // GIVEN ResourceSchema schema = createResourceSchema(); @@ -261,8 +230,7 @@ public void testResourceSchemaSerializationDom() throws SchemaException, JAXBExc } @Test - public void testResourceSchemaSerializationInResource() throws SchemaException, JAXBException { - System.out.println("\n===[ testResourceSchemaSerializationInResource ]====="); + public void testResourceSchemaSerializationInResource() throws SchemaException { // GIVEN ResourceSchema schema = createResourceSchema(); @@ -290,10 +258,9 @@ public void testResourceSchemaSerializationInResource() throws SchemaException, assertDomSchema(reparsedXsdElement); } - private PrismObject wrapInResource(Element xsdElement) throws SchemaException { PrismObjectDefinition resourceDefinition = - PrismTestUtil.getPrismContext().getSchemaRegistry().findObjectDefinitionByCompileTimeClass(ResourceType.class); + PrismTestUtil.getPrismContext().getSchemaRegistry().findObjectDefinitionByCompileTimeClass(ResourceType.class); PrismObject resource = resourceDefinition.instantiate(); ResourceTypeUtil.setResourceXsdSchema(resource, xsdElement); return resource; @@ -332,7 +299,7 @@ private ResourceSchema createResourceSchema() { // ... in it ordinary attribute - an identifier ResourceAttributeDefinition icfUidDef = containerDefinition.createAttributeDefinition( SchemaTestConstants.ICFS_UID, DOMUtil.XSD_STRING); - ((Collection)containerDefinition.getPrimaryIdentifiers()).add(icfUidDef); + ((Collection) containerDefinition.getPrimaryIdentifiers()).add(icfUidDef); ResourceAttributeDefinitionImpl xloginDef = containerDefinition.createAttributeDefinition("login", DOMUtil.XSD_STRING); xloginDef.setNativeAttributeName("LOGIN"); containerDefinition.setDisplayNameAttribute(xloginDef.getItemName()); @@ -347,12 +314,11 @@ private ResourceSchema createResourceSchema() { } private void assertPrefix(String expectedPrefix, Element element) { - assertEquals("Wrong prefix on element "+DOMUtil.getQName(element), expectedPrefix, element.getPrefix()); + assertEquals("Wrong prefix on element " + DOMUtil.getQName(element), expectedPrefix, element.getPrefix()); } @Test public void testParseResource() throws Exception { - System.out.println("===[ testParseResource ]==="); // WHEN PrismObject resource = PrismTestUtil.parseObject(new File("src/test/resources/common/xml/ns/resource-opendj.xml")); @@ -362,7 +328,6 @@ public void testParseResource() throws Exception { @Test public void testUnmarshallResource() throws Exception { - System.out.println("===[ testUnmarshallResource ]==="); // WHEN ResourceType resourceType = (ResourceType) PrismTestUtil.parseObject(new File("src/test/resources/common/xml/ns/resource-opendj.xml")).asObjectable(); @@ -370,25 +335,24 @@ public void testUnmarshallResource() throws Exception { assertCapabilities(resourceType); } - private void assertCapabilities(ResourceType resourceType) throws SchemaException { if (resourceType.getCapabilities() != null) { if (resourceType.getCapabilities().getNative() != null) { for (Object capability : resourceType.getCapabilities().getNative().getAny()) { - System.out.println("Native Capability: "+CapabilityUtil.getCapabilityDisplayName(capability)+" : "+capability); + System.out.println("Native Capability: " + CapabilityUtil.getCapabilityDisplayName(capability) + " : " + capability); } } if (resourceType.getCapabilities().getConfigured() != null) { for (Object capability : resourceType.getCapabilities().getConfigured().getAny()) { - System.out.println("Configured Capability: "+CapabilityUtil.getCapabilityDisplayName(capability)+" : "+capability); + System.out.println("Configured Capability: " + CapabilityUtil.getCapabilityDisplayName(capability) + " : " + capability); } } } List effectiveCapabilities = ResourceTypeUtil.getEffectiveCapabilities(resourceType); for (Object capability : effectiveCapabilities) { - System.out.println("Efective Capability: "+CapabilityUtil.getCapabilityDisplayName(capability)+" : "+capability); + System.out.println("Efective Capability: " + CapabilityUtil.getCapabilityDisplayName(capability) + " : " + capability); } assertNotNull("null native capabilities", resourceType.getCapabilities().getNative()); @@ -399,7 +363,7 @@ private void assertCapabilities(ResourceType resourceType) throws SchemaExceptio assertFalse("empty configured capabilities", resourceType.getCapabilities().getConfigured().getAny().isEmpty()); assertEquals("Unexepected number of configured capabilities", 2, resourceType.getCapabilities().getConfigured().getAny().size()); - assertEquals("Unexepected number of effective capabilities", 3,effectiveCapabilities.size()); + assertEquals("Unexepected number of effective capabilities", 3, effectiveCapabilities.size()); assertNotNull("No credentials effective capability", ResourceTypeUtil.getEffectiveCapability(resourceType, CredentialsCapabilityType.class)); assertNotNull("No activation effective capability", @@ -409,5 +373,4 @@ private void assertCapabilities(ResourceType resourceType) throws SchemaExceptio } - } diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/validator/TestObjectValidator.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/validator/TestObjectValidator.java index be612404261..5e8c981d17b 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/validator/TestObjectValidator.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/validator/TestObjectValidator.java @@ -42,7 +42,6 @@ public class TestObjectValidator extends AbstractSchemaTest { @Test public void testValidateRoleOneDefault() throws Exception { final String TEST_NAME = "testValidateRoleOneDefault"; - displayTestTile(TEST_NAME); // GIVEN @@ -65,7 +64,6 @@ public void testValidateRoleOneDefault() throws Exception { @Test public void testValidateRoleOneDeprecated() throws Exception { final String TEST_NAME = "testValidateRoleOneDeprecated"; - displayTestTile(TEST_NAME); // GIVEN @@ -93,7 +91,6 @@ public void testValidateRoleOneDeprecated() throws Exception { @Test public void testValidateRoleOneLegacyCompat() throws Exception { final String TEST_NAME = "testValidateRoleOneLegacyCompat"; - displayTestTile(TEST_NAME); // GIVEN @@ -124,7 +121,6 @@ public void testValidateRoleOneLegacyCompat() throws Exception { @Test public void testValidateRoleOneLegacyStrict() throws Exception { final String TEST_NAME = "testValidateRoleOneLegacyStrict"; - displayTestTile(TEST_NAME); // GIVEN diff --git a/infra/schema/src/test/resources/common/filter.xml b/infra/schema/src/test/resources/common/filter.xml index c94276c9575..fb581089734 100644 --- a/infra/schema/src/test/resources/common/filter.xml +++ b/infra/schema/src/test/resources/common/filter.xml @@ -6,13 +6,10 @@ ~ and European Union Public License. See LICENSE file for details. --> - - + ...a filter description... connectorType - - org.identityconnectors.ldap.LdapConnector - + org.identityconnectors.ldap.LdapConnector diff --git a/infra/schema/testng-unit.xml b/infra/schema/testng-unit.xml index e4983261bc9..6684b1f1263 100644 --- a/infra/schema/testng-unit.xml +++ b/infra/schema/testng-unit.xml @@ -107,7 +107,7 @@ - + @@ -138,6 +138,7 @@ + From b6ad348b0ec25b6f888d2bbc27a9df9b82ee8d1e Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Mon, 2 Mar 2020 14:40:16 +0100 Subject: [PATCH 91/97] model/common: added test extends from AbstractUnitTest --- .../script/TestExpressionFunctions.java | 3 +- .../expression/script/TestScriptCaching.java | 15 +++---- .../common/mapping/TestMappingStatic.java | 3 +- .../TestValueConstructionAbsolute.java | 42 ------------------- 4 files changed, 10 insertions(+), 53 deletions(-) delete mode 100644 model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestValueConstructionAbsolute.java diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/TestExpressionFunctions.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/TestExpressionFunctions.java index 5373650259c..54dbfacf4cc 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/TestExpressionFunctions.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/TestExpressionFunctions.java @@ -19,6 +19,7 @@ import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.util.SchemaTestConstants; import com.evolveum.midpoint.test.util.TestUtil; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.util.MiscUtil; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; @@ -47,7 +48,7 @@ /** * @author semancik */ -public class TestExpressionFunctions { +public class TestExpressionFunctions extends AbstractUnitTest { public static final File TEST_DIR = new File("src/test/resources/expression/functions"); public static final File USER_JACK_FILE = new File(TEST_DIR, "user-jack.xml"); diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/TestScriptCaching.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/TestScriptCaching.java index da4331f5864..cbe540afa1a 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/TestScriptCaching.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/TestScriptCaching.java @@ -16,7 +16,6 @@ import java.util.Collection; import java.util.List; -import javax.xml.bind.JAXBException; import javax.xml.namespace.QName; import com.evolveum.midpoint.common.Clock; @@ -39,14 +38,13 @@ import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.repo.common.DirectoryFileObjectResolver; import com.evolveum.midpoint.repo.common.ObjectResolver; -import com.evolveum.midpoint.repo.common.expression.ExpressionSyntaxException; import com.evolveum.midpoint.repo.common.expression.ExpressionVariables; import com.evolveum.midpoint.schema.MidPointPrismContextFactory; import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.internals.InternalCounters; import com.evolveum.midpoint.schema.internals.InternalMonitor; import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.test.util.TestUtil; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.CommunicationException; @@ -60,13 +58,12 @@ /** * @author semancik */ -public class TestScriptCaching { +public class TestScriptCaching extends AbstractUnitTest { private static final File TEST_DIR = new File("src/test/resources/expression/groovy"); protected static final File OBJECTS_DIR = new File("src/test/resources/objects"); private static final QName PROPERTY_NAME = new QName(MidPointConstants.NS_MIDPOINT_TEST_PREFIX, "whatever"); - private static final String NS_WHATEVER = "http://whatever/xml/ns"; protected ScriptExpressionFactory scriptExpressionfactory; protected ScriptEvaluator evaluator; @@ -133,13 +130,13 @@ private void assertScriptMonitor(int expCompilations, int expExecutions, String assertEquals("Unexpected number of script executions after "+desc, expExecutions, InternalMonitor.getCount(InternalCounters.SCRIPT_EXECUTION_COUNT)); } - private long executeScript(String filname, String expectedResult, String desc) throws SchemaException, IOException, JAXBException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException { + private long executeScript(String filname, String expectedResult, String desc) throws SchemaException, IOException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException { // GIVEN OperationResult result = new OperationResult(desc); ScriptExpressionEvaluatorType scriptType = parseScriptType(filname); ItemDefinition outputDefinition = getPrismContext().definitionFactory().createPropertyDefinition(PROPERTY_NAME, DOMUtil.XSD_STRING); - ScriptExpression scriptExpression = createScriptExpression(scriptType, outputDefinition, desc); + ScriptExpression scriptExpression = createScriptExpression(scriptType, outputDefinition); ExpressionVariables variables = ExpressionVariables.create(getPrismContext(), "foo", "FOO", PrimitiveType.STRING, @@ -161,7 +158,7 @@ private long executeScript(String filname, String expectedResult, String desc) t return (endTime - startTime); } - private ScriptExpression createScriptExpression(ScriptExpressionEvaluatorType expressionType, ItemDefinition outputDefinition, String shortDesc) throws ExpressionSyntaxException { + private ScriptExpression createScriptExpression(ScriptExpressionEvaluatorType expressionType, ItemDefinition outputDefinition) { ScriptExpression expression = new ScriptExpression(scriptExpressionfactory.getEvaluators().get(expressionType.getLanguage()), expressionType); expression.setOutputDefinition(outputDefinition); expression.setObjectResolver(scriptExpressionfactory.getObjectResolver()); @@ -169,7 +166,7 @@ private ScriptExpression createScriptExpression(ScriptExpressionEvaluatorType ex return expression; } - private ScriptExpressionEvaluatorType parseScriptType(String fileName) throws SchemaException, IOException, JAXBException { + private ScriptExpressionEvaluatorType parseScriptType(String fileName) throws SchemaException, IOException { ScriptExpressionEvaluatorType expressionType = PrismTestUtil.parseAtomicValue( new File(TEST_DIR, fileName), ScriptExpressionEvaluatorType.COMPLEX_TYPE); return expressionType; diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingStatic.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingStatic.java index 2211aa73804..2fc67983729 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingStatic.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingStatic.java @@ -9,6 +9,7 @@ import com.evolveum.midpoint.prism.PrismPropertyValue; import com.evolveum.midpoint.prism.delta.PrismValueDeltaSetTriple; import com.evolveum.midpoint.prism.util.PrismAsserts; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.util.exception.SchemaException; import org.testng.annotations.BeforeClass; @@ -20,7 +21,7 @@ /** * @author Radovan Semancik */ -public class TestMappingStatic { +public class TestMappingStatic extends AbstractUnitTest { private MappingTestEvaluator evaluator; diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestValueConstructionAbsolute.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestValueConstructionAbsolute.java deleted file mode 100644 index d2c4b6149cf..00000000000 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestValueConstructionAbsolute.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2010-2013 Evolveum and contributors - * - * This work is dual-licensed under the Apache License 2.0 - * and European Union Public License. See LICENSE file for details. - */ -package com.evolveum.midpoint.model.common.mapping; - -import com.evolveum.midpoint.util.exception.SchemaException; -import org.testng.annotations.BeforeClass; -import org.xml.sax.SAXException; - -import java.io.IOException; - -/** - * @author Radovan Semancik - */ -public class TestValueConstructionAbsolute { - - private MappingTestEvaluator evaluator; - - @BeforeClass - public void setupFactory() throws SAXException, IOException, SchemaException { - evaluator = new MappingTestEvaluator(); - evaluator.init(); - } - - -// @Test -// public void testConstructionExpressionInputMulti() throws JAXBException, ExpressionEvaluationException, ObjectNotFoundException, SchemaException, FileNotFoundException { -// // WHEN -// PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMappingDynamicAdd(String.class, -// "absolute/construction-expression-input-multi.xml", "employeeType", "rock", null, "testConstructionExpressionSimple", -// "apple", "orange"); -// -// // THEN -// PrismAsserts.assertTripleZero(outputTriple, "apple", "orange", "rock" ); -// PrismAsserts.assertTripleNoPlus(outputTriple); -// PrismAsserts.assertTripleNoMinus(outputTriple); -// } - -} From b487e09a7c823d378c66edca39146e4a286955fe Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Mon, 2 Mar 2020 14:40:44 +0100 Subject: [PATCH 92/97] PrettyPrinter, JaxbTestUtil: code cleanup and reformat --- .../prism/impl/util/JaxbTestUtil.java | 82 +++++++------------ .../evolveum/midpoint/util/PrettyPrinter.java | 74 ++++++++--------- 2 files changed, 62 insertions(+), 94 deletions(-) diff --git a/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/util/JaxbTestUtil.java b/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/util/JaxbTestUtil.java index eb8cf9fdb34..e6e797d4b97 100644 --- a/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/util/JaxbTestUtil.java +++ b/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/util/JaxbTestUtil.java @@ -6,48 +6,28 @@ */ package com.evolveum.midpoint.prism.impl.util; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStream; -import java.io.Reader; -import java.io.StringReader; -import java.io.StringWriter; +import java.io.*; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; -import javax.xml.bind.Unmarshaller; +import javax.xml.bind.*; import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.Containerable; -import com.evolveum.midpoint.prism.PrismContainer; -import com.evolveum.midpoint.prism.PrismContainerDefinition; - -import com.evolveum.midpoint.prism.impl.schema.SchemaRegistryImpl; -import com.evolveum.midpoint.prism.util.PrismTestUtil; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.Validate; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; -import com.evolveum.midpoint.prism.Objectable; -import com.evolveum.midpoint.prism.PrismContainerValue; -import com.evolveum.midpoint.prism.PrismContext; -import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.PrismObjectDefinition; +import com.evolveum.midpoint.prism.*; +import com.evolveum.midpoint.prism.impl.schema.SchemaRegistryImpl; import com.evolveum.midpoint.prism.schema.SchemaDescription; import com.evolveum.midpoint.prism.schema.SchemaRegistry; +import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.prism.xml.DynamicNamespacePrefixMapper; import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.JAXBUtil; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.util.exception.SystemException; import com.evolveum.midpoint.util.logging.Trace; @@ -58,16 +38,15 @@ * (The last drop was the inability to hide RawType from externally-visible model service WSDL. * The solution devised, based on @Raw type, prevents JAXB from correctly parsing any structures that * contain RawType elements.) - * + *

* So, don't use JaxbTestUtil even for testing purposes. Use PrismTestUtil instead. - * - * === + *

* Original description: - * + *

* JAXB testing util. Only for use in tests. DO NOT USE IN PRODUCTION CODE. * This util is used to test the ablility of prism JAXB representation to be used by * native (Sun) JAXB code. - * + *

* Note: this is what used to be PrismJaxbProcessor. Therefore there may be still a lot of junk to clean up. * * @author Radovan Semancik @@ -143,7 +122,7 @@ public boolean isJaxbClass(Class clazz) { // not a JAXB class return false; } - for (Package jaxbPackage: getSchemaRegistry().getCompileTimePackages()) { + for (Package jaxbPackage : getSchemaRegistry().getCompileTimePackages()) { if (jaxbPackage.equals(clazz.getPackage())) { return true; } @@ -246,9 +225,9 @@ public String marshalElementToString(Object element, Map propert if (element instanceof Element) { return DOMUtil.serializeDOMToString((Element) element); } else if (element instanceof JAXBElement) { - return marshalElementToString((JAXBElement)element, properties); + return marshalElementToString((JAXBElement) element, properties); } else { - throw new IllegalArgumentException("Unsupported element type "+element.getClass().getName()); + throw new IllegalArgumentException("Unsupported element type " + element.getClass().getName()); } } @@ -262,7 +241,7 @@ public String marshalElementToString(Object element, QName elementName) throws J if (element instanceof Element) { return DOMUtil.serializeDOMToString((Element) element); } else if (element instanceof JAXBElement) { - return marshalElementToString((JAXBElement)element); + return marshalElementToString((JAXBElement) element); } else { JAXBElement jaxbElement = new JAXBElement<>(elementName, Object.class, element); return marshalElementToString(jaxbElement); @@ -309,7 +288,7 @@ public Element marshalObjectToDom(T jaxbObject, QName elementQName, Document } JAXBElement jaxbElement = new JAXBElement<>(elementQName, (Class) jaxbObject.getClass(), - jaxbObject); + jaxbObject); Element element = doc.createElementNS(elementQName.getNamespaceURI(), elementQName.getLocalPart()); marshalElementToDom(jaxbElement, element); @@ -319,7 +298,7 @@ public Element marshalObjectToDom(T jaxbObject, QName elementQName, Document public void marshalObjectToDom(T jaxbObject, QName elementQName, Element parentElement) throws JAXBException { JAXBElement jaxbElement = new JAXBElement<>(elementQName, (Class) jaxbObject.getClass(), - jaxbObject); + jaxbObject); marshalElementToDom(jaxbElement, parentElement); } @@ -328,7 +307,7 @@ public Element toDomElement(Object element) throws JAXBException { } public Element toDomElement(Object jaxbElement, Document doc) throws JAXBException { - return toDomElement(jaxbElement,doc,false,false,false); + return toDomElement(jaxbElement, doc, false, false, false); } @SuppressWarnings({ "rawtypes", "unchecked" }) @@ -356,7 +335,6 @@ public Element toDomElement(Object jaxbElement, Document doc, boolean adopt, boo } } - public JAXBElement unmarshalElement(String xmlString, Class type) throws JAXBException, SchemaException { if (xmlString == null) { return null; @@ -439,12 +417,12 @@ public T unmarshalObject(File file, Class type) throws JAXBException, Sch T value = element.getValue(); // adopt not needed, already adopted in unmarshalElement call above if (!type.isAssignableFrom(value.getClass())) { - throw new IllegalArgumentException("Unmarshalled "+value.getClass()+" from file "+file+" while "+type+" was expected"); + throw new IllegalArgumentException("Unmarshalled " + value.getClass() + " from file " + file + " while " + type + " was expected"); } return value; } - public Object unmarshalObjects(File file) throws JAXBException{ + public Object unmarshalObjects(File file) throws JAXBException { return createUnmarshaller().unmarshal(file); } @@ -488,19 +466,18 @@ private PrismContainer unmarshalSingleValueContaine return container; } - public T unmarshalObject(Object domOrJaxbElement, Class type) throws SchemaException { JAXBElement element; if (domOrJaxbElement instanceof JAXBElement) { element = (JAXBElement) domOrJaxbElement; } else if (domOrJaxbElement instanceof Node) { try { - element = unmarshalElement((Node)domOrJaxbElement, type); + element = unmarshalElement((Node) domOrJaxbElement, type); } catch (JAXBException e) { - throw new SchemaException(e.getMessage(),e); + throw new SchemaException(e.getMessage(), e); } } else { - throw new IllegalArgumentException("Unknown element type "+domOrJaxbElement); + throw new IllegalArgumentException("Unknown element type " + domOrJaxbElement); } if (element == null) { return null; @@ -521,7 +498,7 @@ public JAXBElement unmarshalElement(File file, Class type) throws Sche JAXBElement element = (JAXBElement) getUnmarshaller().unmarshal(is); adopt(element); return element; - } catch (RuntimeException ex){ + } catch (RuntimeException ex) { throw new SystemException(ex); } finally { if (is != null) { @@ -627,7 +604,6 @@ private boolean compareElement(Object a, Object b) { return DOMUtil.compareElement(ae, be, true); } - public T fromElement(Object element, Class type) throws SchemaException { if (element == null) { @@ -649,14 +625,14 @@ public T fromElement(Object element, Class type) throws SchemaException { if (element instanceof Element) { try { - JAXBElement unmarshalledElement = unmarshalElement((Element)element, type); + JAXBElement unmarshalledElement = unmarshalElement((Element) element, type); return unmarshalledElement.getValue(); } catch (JAXBException e) { - throw new IllegalArgumentException("Unmarshall failed: " + e.getMessage(),e); + throw new IllegalArgumentException("Unmarshall failed: " + e.getMessage(), e); } } - throw new IllegalArgumentException("Unknown element type "+element.getClass().getName()); + throw new IllegalArgumentException("Unknown element type " + element.getClass().getName()); } private QName determineElementQName(Objectable objectable) { @@ -670,7 +646,7 @@ private QName determineElementQName(Objectable objectable) { return definition.getItemName(); } } - throw new IllegalStateException("Cannot determine element name of "+objectable); + throw new IllegalStateException("Cannot determine element name of " + objectable); } private QName determineElementQName(Containerable containerable) { @@ -690,15 +666,15 @@ private boolean isObjectable(Class type) { private void adopt(T object, Class type) throws SchemaException { if (object instanceof Objectable) { - getPrismContext().adopt(((Objectable)object)); + getPrismContext().adopt(((Objectable) object)); } } private void adopt(Object object) throws SchemaException { if (object instanceof JAXBElement) { - adopt(((JAXBElement)object).getValue()); + adopt(((JAXBElement) object).getValue()); } else if (object instanceof Objectable) { - getPrismContext().adopt(((Objectable)(object))); + getPrismContext().adopt(((Objectable) (object))); } } diff --git a/infra/util/src/main/java/com/evolveum/midpoint/util/PrettyPrinter.java b/infra/util/src/main/java/com/evolveum/midpoint/util/PrettyPrinter.java index f3393da61a5..72fd94ecb11 100644 --- a/infra/util/src/main/java/com/evolveum/midpoint/util/PrettyPrinter.java +++ b/infra/util/src/main/java/com/evolveum/midpoint/util/PrettyPrinter.java @@ -9,14 +9,8 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Date; -import java.util.Iterator; -import java.util.List; +import java.util.*; import java.util.concurrent.CopyOnWriteArrayList; - import javax.xml.XMLConstants; import javax.xml.bind.JAXBElement; import javax.xml.namespace.QName; @@ -28,7 +22,6 @@ /** * @author semancik - * */ public class PrettyPrinter { @@ -53,7 +46,7 @@ static String prettyPrintElementAsProperty(Object element) { sb.append(prettyPrint(elementName)); sb.append(">"); if (element instanceof Element) { - Element domElement = (Element)element; + Element domElement = (Element) element; // TODO: this is too simplistic, expand later sb.append(domElement.getTextContent()); } else { @@ -94,9 +87,9 @@ public static String prettyPrint(QName qname) { } if (qname.getNamespaceURI() != null) { if (qname.getNamespaceURI().equals(XMLConstants.W3C_XML_SCHEMA_NS_URI)) { - return "{"+DOMUtil.NS_W3C_XML_SCHEMA_PREFIX+":}"+qname.getLocalPart(); + return "{" + DOMUtil.NS_W3C_XML_SCHEMA_PREFIX + ":}" + qname.getLocalPart(); } else if (defaultNamespacePrefix != null && qname.getNamespaceURI().startsWith(defaultNamespacePrefix)) { - return "{..."+qname.getNamespaceURI().substring(defaultNamespacePrefix.length())+"}"+qname.getLocalPart(); + return "{..." + qname.getNamespaceURI().substring(defaultNamespacePrefix.length()) + "}" + qname.getLocalPart(); } } return qnameToString(qname); // avoiding qname.toString because recursive call to prettyPrint from ItemName.toString @@ -216,7 +209,6 @@ public static String prettyPrint(Element element, boolean displayTag) { return sb.toString(); } - public static String prettyPrint(Date date) { if (date == null) { return "null"; @@ -235,7 +227,7 @@ public static String prettyPrint(byte[] value) { if (printlen > BYTE_ARRAY_MAX_LEN) { printlen = BYTE_ARRAY_MAX_LEN; } - for(int i=0; i < printlen; i++) { + for (int i = 0; i < printlen; i++) { sb.append(String.format("%02x", value[i] & 0xff)); } if (value.length > BYTE_ARRAY_MAX_LEN) { @@ -252,10 +244,10 @@ public static String prettyPrint(Object value) { return "null"; } if (value instanceof JAXBElement) { - Object elementValue = ((JAXBElement)value).getValue(); + Object elementValue = ((JAXBElement) value).getValue(); String attempt = tryPrettyPrint(elementValue); if (attempt != null) { - return ("JAXBElement("+((JAXBElement)value).getName()+","+attempt+")"); + return ("JAXBElement(" + ((JAXBElement) value).getName() + "," + attempt + ")"); } } String attempt = tryPrettyPrint(value); @@ -268,32 +260,32 @@ public static String prettyPrint(Object value) { private static String tryPrettyPrint(Object value) { if (value instanceof Class) { - Class c = (Class)value; + Class c = (Class) value; if (c.getPackage().getName().equals("com.evolveum.midpoint.xml.ns._public.common.common_3")) { return c.getSimpleName(); } return c.getName(); } if (value instanceof Collection) { - return PrettyPrinter.prettyPrint((Collection)value); + return PrettyPrinter.prettyPrint((Collection) value); } if (value.getClass().isArray()) { Class cclass = value.getClass().getComponentType(); if (cclass.isPrimitive()) { if (cclass == byte.class) { - return PrettyPrinter.prettyPrint((byte[])value); + return PrettyPrinter.prettyPrint((byte[]) value); } else { // TODO: something better } } else { - return PrettyPrinter.prettyPrint((Object[])value); + return PrettyPrinter.prettyPrint((Object[]) value); } } if (value instanceof Node) { // This is interface, won't catch it using reflection - return PrettyPrinter.prettyPrint((Node)value); + return PrettyPrinter.prettyPrint((Node) value); } - for (Class prettyPrinterClass: prettyPrinters) { + for (Class prettyPrinterClass : prettyPrinters) { String printerValue = tryPrettyPrint(value, prettyPrinterClass); if (printerValue != null) { return printerValue; @@ -309,15 +301,15 @@ private static String tryPrettyPrint(Object value, Class prettyPrinterClass) Class[] parameterTypes = method.getParameterTypes(); if (parameterTypes.length == 1 && parameterTypes[0].equals(value.getClass())) { try { - return (String)method.invoke(null, value); + return (String) method.invoke(null, value); } catch (IllegalArgumentException e) { - return "###INTERNAL#ERROR### Illegal argument: "+e.getMessage() + "; prettyPrint method for value "+value; + return "###INTERNAL#ERROR### Illegal argument: " + e.getMessage() + "; prettyPrint method for value " + value; } catch (IllegalAccessException e) { - return "###INTERNAL#ERROR### Illegal access: "+e.getMessage() + "; prettyPrint method for value "+value; + return "###INTERNAL#ERROR### Illegal access: " + e.getMessage() + "; prettyPrint method for value " + value; } catch (InvocationTargetException e) { - return "###INTERNAL#ERROR### Illegal target: "+e.getMessage() + "; prettyPrint method for value "+value; + return "###INTERNAL#ERROR### Illegal target: " + e.getMessage() + "; prettyPrint method for value " + value; } catch (Throwable e) { - return "###INTERNAL#ERROR### "+e.getClass().getName()+": "+e.getMessage() + "; prettyPrint method for value "+value; + return "###INTERNAL#ERROR### " + e.getClass().getName() + ": " + e.getMessage() + "; prettyPrint method for value " + value; } } } @@ -331,10 +323,10 @@ public static String debugDump(Object value, int indent) { } String out = null; if (value instanceof DebugDumpable) { - return ((DebugDumpable)value).debugDump(indent); + return ((DebugDumpable) value).debugDump(indent); } if (value instanceof Collection) { - return DebugUtil.debugDump((Collection)value, indent); + return DebugUtil.debugDump((Collection) value, indent); } out = tryDebugDumpMethod(value, indent); if (out != null) { @@ -346,7 +338,7 @@ public static String debugDump(Object value, int indent) { } private static String tryDebugDumpMethod(Object value, int indent) { - for (Class prettyPrinterClass: prettyPrinters) { + for (Class prettyPrinterClass : prettyPrinters) { String printerValue = tryDebugDumpMethod(value, indent, prettyPrinterClass); if (printerValue != null) { return printerValue; @@ -362,15 +354,15 @@ private static String tryDebugDumpMethod(Object value, int indent, Class pret Class[] parameterTypes = method.getParameterTypes(); if (parameterTypes.length == 2 && parameterTypes[0].equals(value.getClass())) { try { - return (String)method.invoke(null, value, indent); + return (String) method.invoke(null, value, indent); } catch (IllegalArgumentException e) { - return "###INTERNAL#ERROR### Illegal argument: "+e.getMessage() + "; debugDump method for value "+value; + return "###INTERNAL#ERROR### Illegal argument: " + e.getMessage() + "; debugDump method for value " + value; } catch (IllegalAccessException e) { - return "###INTERNAL#ERROR### Illegal access: "+e.getMessage() + "; debugDump method for value "+value; + return "###INTERNAL#ERROR### Illegal access: " + e.getMessage() + "; debugDump method for value " + value; } catch (InvocationTargetException e) { - return "###INTERNAL#ERROR### Illegal target: "+e.getMessage() + "; debugDump method for value "+value; + return "###INTERNAL#ERROR### Illegal target: " + e.getMessage() + "; debugDump method for value " + value; } catch (Throwable e) { - return "###INTERNAL#ERROR### "+e.getClass().getName()+": "+e.getMessage() + "; debugDump method for value "+value; + return "###INTERNAL#ERROR### " + e.getClass().getName() + ": " + e.getMessage() + "; debugDump method for value " + value; } } } @@ -384,11 +376,11 @@ public static void shortDump(StringBuilder sb, Object value) { return; } if (value instanceof ShortDumpable) { - ((ShortDumpable)value).shortDump(sb); + ((ShortDumpable) value).shortDump(sb); return; } if (value instanceof Collection) { - DebugUtil.shortDump(sb, (Collection)value); + DebugUtil.shortDump(sb, (Collection) value); return; } if (tryShortDumpMethod(sb, value)) { @@ -398,7 +390,7 @@ public static void shortDump(StringBuilder sb, Object value) { } private static boolean tryShortDumpMethod(StringBuilder sb, Object value) { - for (Class prettyPrinterClass: prettyPrinters) { + for (Class prettyPrinterClass : prettyPrinters) { if (tryShortDumpMethod(sb, value, prettyPrinterClass)) { return true; } @@ -416,13 +408,13 @@ private static boolean tryShortDumpMethod(StringBuilder sb, Object value, Class< method.invoke(null, sb, value); return true; } catch (IllegalArgumentException e) { - sb.append("###INTERNAL#ERROR### Illegal argument: "+e.getMessage() + "; shortDump method for value "+value); + sb.append("###INTERNAL#ERROR### Illegal argument: " + e.getMessage() + "; shortDump method for value " + value); } catch (IllegalAccessException e) { - sb.append("###INTERNAL#ERROR### Illegal access: "+e.getMessage() + "; shortDump method for value "+value); + sb.append("###INTERNAL#ERROR### Illegal access: " + e.getMessage() + "; shortDump method for value " + value); } catch (InvocationTargetException e) { - sb.append("###INTERNAL#ERROR### Illegal target: "+e.getMessage() + "; shortDump method for value "+value); + sb.append("###INTERNAL#ERROR### Illegal target: " + e.getMessage() + "; shortDump method for value " + value); } catch (Throwable e) { - sb.append("###INTERNAL#ERROR### "+e.getClass().getName()+": "+e.getMessage() + "; shortDump method for value "+value); + sb.append("###INTERNAL#ERROR### " + e.getClass().getName() + ": " + e.getMessage() + "; shortDump method for value " + value); } } } From 41e273645fe8d9e626d92b2ada9db0cb3694072e Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Mon, 2 Mar 2020 14:55:03 +0100 Subject: [PATCH 93/97] POM: slf4j-api is ignoredUsedUndeclaredDependency, often false alarms --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index 93a3dc9d889..5ececb26fde 100644 --- a/pom.xml +++ b/pom.xml @@ -1738,6 +1738,7 @@ org.slf4j:jcl-over-slf4j + org.slf4j:slf4j-api org.danekja:jdk-serializable-functional From 8ad3be811f8094e0f133d2424835915e86d00d2b Mon Sep 17 00:00:00 2001 From: lskublik Date: Mon, 2 Mar 2020 14:56:52 +0100 Subject: [PATCH 94/97] adding TestPageRole to suite (MID-6092) --- .../java/com/evolveum/midpoint/gui/TestPageRole.java | 10 ++++++++-- gui/admin-gui/testng-integration.xml | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestPageRole.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestPageRole.java index 041226e4219..a699bc67655 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestPageRole.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestPageRole.java @@ -16,6 +16,7 @@ import com.evolveum.midpoint.web.AbstractInitializedGuiIntegrationTest; import com.evolveum.midpoint.web.page.admin.roles.AbstractRoleMemberPanel; import com.evolveum.midpoint.web.page.admin.roles.PageRole; +import com.evolveum.midpoint.web.page.admin.users.PageOrgUnit; import com.evolveum.midpoint.web.util.OnePageParameterEncoder; import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType; @@ -56,7 +57,12 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti } @Test - public void test001testAddNewRole() throws Exception { + public void test001testPageRole() { + renderPage(PageRole.class); + } + + @Test + public void test002testAddNewRole() throws Exception { renderPage(PageRole.class); FormTester formTester = tester.newFormTester(MAIN_FORM, false); @@ -74,7 +80,7 @@ public void test001testAddNewRole() throws Exception { * MID-6092 */ @Test - public void test002testMembers() throws Exception { + public void test003testMembers() throws Exception { // GIVEN PrismObject role1 = createObject(RoleType.class, "Role0001"); PrismObject role2 = createObject(RoleType.class, "Role0002"); diff --git a/gui/admin-gui/testng-integration.xml b/gui/admin-gui/testng-integration.xml index 974b7bc2864..5b10ffe9835 100644 --- a/gui/admin-gui/testng-integration.xml +++ b/gui/admin-gui/testng-integration.xml @@ -19,6 +19,7 @@ + From 4df9c751e4c93557220005433e3e84e3569a3bc5 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Mon, 2 Mar 2020 15:57:43 +0100 Subject: [PATCH 95/97] AbstractIntegrationTest: renames of OperationResult related method - createResult -> createOperationalResult - getTestResult -> getTestOperationResult "test result" seemed vague, especially in testing context --- .../model/impl/expr/TestModelExpressions.java | 4 +- .../impl/lens/TestAssignmentProcessor2.java | 46 ++--- .../lens/TestPasswordPolicyProcessor.java | 16 +- .../model/impl/lens/TestPolicyRules.java | 28 +-- .../impl/lens/TestPolicyStateRecording.java | 49 +++-- .../model/impl/lens/TestReconScript.java | 8 +- .../model/intest/TestStrangeCases.java | 74 +++---- .../model/intest/TestUserTemplate.java | 176 ++++++++--------- .../async/TestAsyncUpdateTaskMechanics.java | 4 +- .../model/intest/mapping/TestMapping.java | 182 +++++++++--------- .../intest/sync/TestProgressReporting.java | 4 +- .../model/intest/sync/TestRecomputeTask.java | 8 +- .../AbstractTestAssignmentApproval.java | 8 +- .../TestAssignmentApprovalGlobal.java | 2 +- .../assignments/TestAssignmentsAdvanced.java | 20 +- .../impl/association/TestAddAssociation.java | 2 +- .../AbstractTestObjectLifecycleApproval.java | 2 +- .../objects/TestObjectLifecycleAdvanced.java | 10 +- .../TestObjectLifecycleApprovalGlobal.java | 2 +- .../wf/impl/other/ManualResourceTest.java | 6 +- .../wf/impl/other/TestDelegation.java | 10 +- .../wf/impl/other/TestEscalation.java | 14 +- .../midpoint/wf/impl/other/TestEvents.java | 2 +- .../wf/impl/other/TestMiscellaneous.java | 14 +- .../wf/impl/other/TestParallelApprovals.java | 4 +- .../midpoint/wf/impl/other/TestSoD.java | 6 +- .../impl/TestConnectorDiscovery.java | 4 +- .../provisioning/impl/TestDBTable.java | 7 +- .../impl/async/TestAsyncUpdate.java | 22 +-- .../impl/csv/AbstractCsvTest.java | 4 +- .../impl/dummy/AbstractBasicDummyTest.java | 24 +-- .../provisioning/impl/dummy/TestDummy.java | 2 +- .../impl/dummy/TestDummyNegative.java | 6 +- .../impl/dummy/TestDummySchemaless.java | 6 +- .../impl/dummy/TestDummySecurity.java | 8 +- .../manual/AbstractManualResourceTest.java | 8 +- .../impl/opendj/TestOpenDjNegative.java | 2 +- .../impl/opendj/TestSynchronization.java | 6 +- .../test/AbstractIntegrationTest.java | 27 ++- .../midpoint/testing/sanity/TestSanity.java | 5 +- .../story/TestConsistencyMechanism.java | 32 +-- .../midpoint/testing/story/TestDelivery.java | 12 +- .../testing/story/TestLargeGroups.java | 4 +- .../testing/story/TestManyThreads.java | 2 +- .../testing/story/TestThresholds.java | 4 +- .../story/TestThresholdsReconFull.java | 4 +- .../midpoint/testing/story/TestVillage.java | 2 +- .../story/grouper/TestGrouperAsyncUpdate.java | 32 +-- .../grouper/TestGrouperLargeGroupImport.java | 2 +- .../TestGrouperLargeGroupReconciliation.java | 4 +- 50 files changed, 468 insertions(+), 462 deletions(-) diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/expr/TestModelExpressions.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/expr/TestModelExpressions.java index 1d0a16d37e9..64381d33186 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/expr/TestModelExpressions.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/expr/TestModelExpressions.java @@ -122,7 +122,7 @@ public void testGetUserByOid() throws Exception { public void testGetManagersOids() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = createResult(); + OperationResult result = createOperationalResult(); String shortTestName = getTestNameShort(); PrismObject chef = repositoryService.getObject(UserType.class, CHEF_OID, null, result); @@ -293,7 +293,7 @@ private String executeScriptExpressionString(ExpressionVariables variables) ObjectNotFoundException, CommunicationException, ConfigurationException, IOException { // GIVEN Task task = createPlainTask("executeScriptExpressionString"); - OperationResult result = createResult(); + OperationResult result = createOperationalResult(); String shortTestName = getTestNameShort(); ScriptExpressionEvaluatorType scriptType = parseScriptType("expression-" + shortTestName + ".xml"); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor2.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor2.java index 3998139e471..b83fb7a98eb 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor2.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor2.java @@ -168,7 +168,7 @@ public void test000Sanity() throws Exception { public void test010AssignR1ToJack() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); LensContext context = createContextForRoleAssignment(USER_JACK_OID, ROLE_R1_OID, null, null, result); @@ -226,7 +226,7 @@ private void processAssignments(LensContext context, OperationResult r public void test020AssignMR1ToR1() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); LensContext context = createContextForAssignment(RoleType.class, ROLE_R1_OID, RoleType.class, ROLE_MR1_OID, null, null, result); @@ -272,7 +272,7 @@ public void test020AssignMR1ToR1() throws Exception { public void test030AssignR1ToJackProjectorDisabled() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); LensContext context = createContextForRoleAssignment(USER_JACK_OID, ROLE_R1_OID, null, a -> a.setActivation(ActivationUtil.createDisabled()), result); @@ -301,7 +301,7 @@ public void test030AssignR1ToJackProjectorDisabled() throws Exception { public void test040AssignR1ToJackAsApprover() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); LensContext context = createContextForRoleAssignment(USER_JACK_OID, ROLE_R1_OID, SchemaConstants.ORG_APPROVER, null, result); @@ -355,7 +355,7 @@ public void test040AssignR1ToJackAsApprover() throws Exception { public void test050JackDeputyOfBarbossa() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); AssignmentType policyRuleAssignment = new AssignmentType(prismContext); PolicyRuleType rule = new PolicyRuleType(prismContext); @@ -434,7 +434,7 @@ public void test050JackDeputyOfBarbossa() throws Exception { public void test060JackDeputyOfGuybrushDeputyOfBarbossa() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); AssignmentType deputyOfBarbossaAssignment = ObjectTypeUtil.createAssignmentTo(USER_BARBOSSA_OID, ObjectTypes.USER, prismContext); deputyOfBarbossaAssignment.getTargetRef().setRelation(SchemaConstants.ORG_DEPUTY); @@ -498,7 +498,7 @@ public void test060JackDeputyOfGuybrushDeputyOfBarbossa() throws Exception { public void test062JackDeputyOfGuybrushDeputyOfBarbossaInLoginMode() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject jack = getUser(USER_JACK_OID); AssignmentType jackGuybrushAssignment = new AssignmentType(prismContext) @@ -585,7 +585,7 @@ public void test062JackDeputyOfGuybrushDeputyOfBarbossaInLoginMode() throws Exce public void test070JackDeputyOfBarbossaApproverOfR1() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); unassignAllRoles(USER_JACK_OID); unassignAllRoles(USER_GUYBRUSH_OID); @@ -662,7 +662,7 @@ public void test070JackDeputyOfBarbossaApproverOfR1() throws Exception { public void test100DisableSomeRoles() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN createObjectsInFirstPart(true, task, result, () -> disableRoles("MMR1 R2 MR3 R4")); @@ -676,7 +676,7 @@ public void test100DisableSomeRoles() throws Exception { public void test110AssignR1ToJack() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); LensContext context = createContextForRoleAssignment(USER_JACK_OID, ROLE_R1_OID, null, null, result); @@ -734,7 +734,7 @@ public void test110AssignR1ToJack() throws Exception { public void test150DisableSomeAssignments() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN createObjectsInFirstPart(true, task, result, () -> disableAssignments("MR4-R6 MR1-MR3 R1-R2")); @@ -746,7 +746,7 @@ public void test150DisableSomeAssignments() throws Exception { public void test160AssignR1ToJack() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); LensContext context = createContextForRoleAssignment(USER_JACK_OID, ROLE_R1_OID, null, null, result); @@ -804,7 +804,7 @@ public void test160AssignR1ToJack() throws Exception { public void test200AddConditions() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN createObjectsInFirstPart(true, task, result, () -> { @@ -822,7 +822,7 @@ public void test200AddConditions() throws Exception { public void test210AssignR1ToJack() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); LensContext context = createContextForRoleAssignment(USER_JACK_OID, ROLE_R1_OID, null, null, result); context.getFocusContext().swallowToPrimaryDelta( @@ -885,7 +885,7 @@ public void test210AssignR1ToJack() throws Exception { public void test300AssignR7ToJack() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); createObjectsInSecondPart(false, task, result, null); @@ -1025,7 +1025,7 @@ public void test300AssignR7ToJack() throws Exception { public void test400AssignJackPirate() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); createObjectsInThirdPart(false, task, result, () -> { @@ -1488,7 +1488,7 @@ public static void finishCallback(String desc) { public void test500AssignJackOrg11() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); createObjectsInFourthPart(false, task, result, null); @@ -1546,7 +1546,7 @@ public void test500AssignJackOrg11() throws Exception { public void test505AssignJackOrg11AsManager() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); LensContext context = createContextForAssignment(UserType.class, USER_JACK_OID, OrgType.class, ORG11_OID, SchemaConstants.ORG_MANAGER, null, result); @@ -1601,7 +1601,7 @@ public void test505AssignJackOrg11AsManager() throws Exception { public void test507AssignJackOrg11AsApprover() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); LensContext context = createContextForAssignment(UserType.class, USER_JACK_OID, OrgType.class, ORG11_OID, SchemaConstants.ORG_APPROVER, null, result); @@ -1655,7 +1655,7 @@ public void test507AssignJackOrg11AsApprover() throws Exception { public void test510AssignJackOrg21() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); LensContext context = createContextForAssignment(UserType.class, USER_JACK_OID, OrgType.class, ORG21_OID, null, null, result); // intentionally unqualified @@ -1708,7 +1708,7 @@ public void test510AssignJackOrg21() throws Exception { public void test515AssignJackOrg21AsManager() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); LensContext context = createContextForAssignment(UserType.class, USER_JACK_OID, OrgType.class, ORG21_OID, new QName("manager"), null, result); // intentionally unqualified @@ -1775,7 +1775,7 @@ public void test515AssignJackOrg21AsManager() throws Exception { public void test520AssignJackOrg41AsApprover() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); LensContext context = createContextForAssignment(UserType.class, USER_JACK_OID, OrgType.class, ORG41_OID, new QName("approver"), null, result); // intentionally unqualified @@ -1839,7 +1839,7 @@ public void test520AssignJackOrg41AsApprover() throws Exception { public void test600AssignA1ToJack() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); createObjectsInFifthPart(false, task, result, null); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPasswordPolicyProcessor.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPasswordPolicyProcessor.java index d518ad75bfa..09984f0de96 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPasswordPolicyProcessor.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPasswordPolicyProcessor.java @@ -68,7 +68,7 @@ public void test000initPasswordPolicyForHistory() throws Exception { @Test public void test100CreateFocusWithPassword() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN addObject(getTestResource(), task, result); @@ -88,7 +88,7 @@ private PrismObject getFocus() throws Exception { @Test public void test110ModifyPassword() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN modifyFocusChangePassword(getType(), getOid(), PASSWORD1, task, result); @@ -111,7 +111,7 @@ public void test110ModifyPassword() throws Exception { @Test public void test120ModifyPasswordSecondTime() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN modifyFocusChangePassword(getType(), getOid(), PASSWORD2, task, result); @@ -134,7 +134,7 @@ public void test120ModifyPasswordSecondTime() throws Exception { @Test public void test130ModifyPasswordThirdTime() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN modifyFocusChangePassword(getType(), getOid(), PASSWORD3, task, result); @@ -171,7 +171,7 @@ public void test160ModifyPasswordSamePassword3() throws Exception { private void doTestModifyPasswordExpectFailure(String password) throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); try { // WHEN @@ -207,7 +207,7 @@ public void test201deleteFocus() throws Exception { @Test public void test210CreateFocusNoPasswordHistory() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN addObject(getTestResource(), task, result); @@ -238,7 +238,7 @@ public void test230ModifySamePasswordNoPasswordHistory() throws Exception { private void modifyPasswordNoHistory() throws Exception{ Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN ProtectedStringType newValue = new ProtectedStringType(); @@ -269,7 +269,7 @@ private void assertPasswords(String password, ProtectedStringType passwordAfterC private void setPasswordHistoryLength(int historyLength) throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); modifyObjectReplaceProperty(SecurityPolicyType.class, SECURITY_POLICY_OID, SchemaConstants.PATH_CREDENTIALS_PASSWORD_HISTORY_LENGTH, task, result, historyLength); } diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules.java index 8afd81626eb..5127eb3df3d 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules.java @@ -77,7 +77,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test005JackAttemptAssignRoleJudge() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -110,7 +110,7 @@ public void test005JackAttemptAssignRoleJudge() throws Exception { @Test(enabled = false) public void test007JackAttemptAssignRoleJudgeAsOwner() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -147,7 +147,7 @@ public void test007JackAttemptAssignRoleJudgeAsOwner() throws Exception { @Test public void test010JackAssignRoleJudge() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -171,7 +171,7 @@ public void test010JackAssignRoleJudge() throws Exception { @Test public void test020JackUnassignRoleJudge() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -208,7 +208,7 @@ public void test020JackUnassignRoleJudge() throws Exception { @Test public void test100AssignRoleMutinierToJack() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -241,7 +241,7 @@ public void test100AssignRoleMutinierToJack() throws Exception { @Test(enabled = false) // after MID-4797 the projector.project now raises PolicyViolationException on conflicting roles public void test110AssignRolePirateToJack() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -279,7 +279,7 @@ public void test110AssignRolePirateToJack() throws Exception { @Test public void test112AssignRolePirateWithExceptionToJack() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -323,7 +323,7 @@ public void test112AssignRolePirateWithExceptionToJack() throws Exception { @Test public void test120AssignRoleConstableToJack() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -374,7 +374,7 @@ public void test120AssignRoleConstableToJack() throws Exception { @Test public void test150AssignRoleThiefToJack() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -424,7 +424,7 @@ public void test150AssignRoleThiefToJack() throws Exception { @Test public void test200JackAssignRoleContractor() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -448,7 +448,7 @@ public void test200JackAssignRoleContractor() throws Exception { @Test public void test210AssignRoleEmployeeToJack() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -489,7 +489,7 @@ public void test210AssignRoleEmployeeToJack() throws Exception { @Test public void test220AssignRoleEngineerToJack() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -555,7 +555,7 @@ public void test220AssignRoleEngineerToJack() throws Exception { @Test public void test300DrakeChangeEmployeeType() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -591,7 +591,7 @@ public void test300DrakeChangeEmployeeType() throws Exception { @Test public void test400AssignRoleLocalized() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // GIVEN diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyStateRecording.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyStateRecording.java index fe81d19ff76..6bcab29513a 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyStateRecording.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyStateRecording.java @@ -121,13 +121,13 @@ public void test100JackAssignRoleJudge() throws Exception { public void test110JackAssignRolePirate() throws Exception { // WHEN when(); - assignRole(USER_JACK_OID, ROLE_PIRATE_OID, getTestTask(), getTestResult()); + assignRole(USER_JACK_OID, ROLE_PIRATE_OID, getTestTask(), getTestOperationResult()); // THEN then(); UserType jack = getUser(USER_JACK_OID).asObjectable(); display("jack", jack); - assertSuccess(getTestResult()); + assertSuccess(getTestOperationResult()); assertAssignedRole(jack.asPrismObject(), ROLE_PIRATE_OID); assertEquals("Wrong # of assignments", 2, jack.getAssignment().size()); @@ -147,14 +147,13 @@ public void test120RecomputeJack() throws Exception { // WHEN when(); - executeChanges(prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, USER_JACK_OID), createReconcile(), getTestTask(), getTestResult()); - //recomputeUser(USER_JACK_OID, getTestTask(), getTestResult()); + executeChanges(prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, USER_JACK_OID), createReconcile(), getTestTask(), getTestOperationResult()); // THEN then(); UserType jack = getUser(USER_JACK_OID).asObjectable(); display("jack", jack); - assertSuccess(getTestResult()); + assertSuccess(getTestOperationResult()); // TODO test that assignment IDs are filled in correctly (currently they are not) assertEquals("Wrong # of assignments", 2, jack.getAssignment().size()); @@ -181,13 +180,13 @@ public void test130JackUnassignRolePirate() throws Exception { .item(UserType.F_ASSIGNMENT) .delete(pirateAssignment.clone()) .asObjectDeltaCast(USER_JACK_OID); - executeChangesAssertSuccess(delta, null, getTestTask(), getTestResult()); + executeChangesAssertSuccess(delta, null, getTestTask(), getTestOperationResult()); // THEN then(); jack = getUser(USER_JACK_OID).asObjectable(); display("jack", jack); - assertSuccess(getTestResult()); + assertSuccess(getTestOperationResult()); assertNotAssignedRole(jack.asPrismObject(), ROLE_PIRATE_OID); assertEquals("Wrong # of assignments", 1, jack.getAssignment().size()); @@ -210,13 +209,13 @@ public void test200BobAssign2a3a() throws Exception { .add(createAssignmentTo(roleATest2aOid, ObjectTypes.ROLE, prismContext), createAssignmentTo(roleATest3aOid, ObjectTypes.ROLE, prismContext)) .asObjectDeltaCast(userBobOid); - executeChangesAssertSuccess(delta, null, getTestTask(), getTestResult()); + executeChangesAssertSuccess(delta, null, getTestTask(), getTestOperationResult()); // THEN then(); UserType bob = getUser(userBobOid).asObjectable(); display("bob", bob); - assertSuccess(getTestResult()); + assertSuccess(getTestOperationResult()); assertAssignedRole(bob.asPrismObject(), roleATest2aOid); assertAssignedRole(bob.asPrismObject(), roleATest3aOid); @@ -243,13 +242,13 @@ public void test210BobAssign2b3b() throws Exception { .add(createAssignmentTo(roleATest2bOid, ObjectTypes.ROLE, prismContext), createAssignmentTo(roleATest3bOid, ObjectTypes.ROLE, prismContext)) .asObjectDeltaCast(userBobOid); - executeChangesAssertSuccess(delta, null, getTestTask(), getTestResult()); + executeChangesAssertSuccess(delta, null, getTestTask(), getTestOperationResult()); // THEN then(); UserType bob = getUser(userBobOid).asObjectable(); display("bob", bob); - assertSuccess(getTestResult()); + assertSuccess(getTestOperationResult()); assertAssignedRole(bob.asPrismObject(), roleATest2aOid); assertAssignedRole(bob.asPrismObject(), roleATest2bOid); @@ -286,13 +285,13 @@ public void test220AliceAssign2a2b() throws Exception { // WHEN when(); - addObject(alice.asPrismObject(), getTestTask(), getTestResult()); + addObject(alice.asPrismObject(), getTestTask(), getTestOperationResult()); // THEN then(); alice = getUser(alice.getOid()).asObjectable(); display("alice", alice); - assertSuccess(getTestResult()); + assertSuccess(getTestOperationResult()); assertAssignedRole(alice.asPrismObject(), roleATest2aOid); assertAssignedRole(alice.asPrismObject(), roleATest2bOid); @@ -321,13 +320,13 @@ public void test230ChuckAssign2a2b() throws Exception { // WHEN when(); - addObject(chuck.asPrismObject(), getTestTask(), getTestResult()); + addObject(chuck.asPrismObject(), getTestTask(), getTestOperationResult()); // THEN then(); chuck = getUser(chuck.getOid()).asObjectable(); display("chuck", chuck); - assertSuccess(getTestResult()); + assertSuccess(getTestOperationResult()); assertAssignedRole(chuck.asPrismObject(), roleATest2aOid); assertAssignedRole(chuck.asPrismObject(), roleATest2bOid); @@ -357,13 +356,13 @@ public void test240DanAssign2a2b() throws Exception { // WHEN when(); - addObject(dan.asPrismObject(), getTestTask(), getTestResult()); + addObject(dan.asPrismObject(), getTestTask(), getTestOperationResult()); // THEN then(); dan = getUser(dan.getOid()).asObjectable(); display("dan", dan); - assertSuccess(getTestResult()); + assertSuccess(getTestOperationResult()); assertAssignedRole(dan.asPrismObject(), roleATest2aOid); assertAssignedRole(dan.asPrismObject(), roleATest2bOid); @@ -388,13 +387,13 @@ public void test250EveAssign2b() throws Exception { .item(UserType.F_ASSIGNMENT) .add(assignment2b) .asObjectDeltaCast(userEveOid); - executeChangesAssertSuccess(delta, null, getTestTask(), getTestResult()); + executeChangesAssertSuccess(delta, null, getTestTask(), getTestOperationResult()); // THEN then(); UserType eve = getUser(userEveOid).asObjectable(); display("alice", eve); - assertSuccess(getTestResult()); + assertSuccess(getTestOperationResult()); assertAssignedRole(eve.asPrismObject(), roleATest2aOid); assertAssignedRole(eve.asPrismObject(), roleATest2bOid); @@ -417,13 +416,13 @@ public void test300MakeRoleWrong() throws Exception { ObjectDelta delta = prismContext.deltaFor(RoleType.class) .item(RoleType.F_DESCRIPTION).replace("wrong") .asObjectDeltaCast(roleATestWrongOid); - executeChangesAssertSuccess(delta, null, getTestTask(), getTestResult()); + executeChangesAssertSuccess(delta, null, getTestTask(), getTestOperationResult()); // THEN then(); RoleType wrong = getRole(roleATestWrongOid).asObjectable(); display("role 'wrong'", wrong); - assertSuccess(getTestResult()); + assertSuccess(getTestOperationResult()); assertEquals("Wrong policy situations for role", Collections.singletonList(WRONG_URI), wrong.getPolicySituation()); @@ -441,13 +440,13 @@ public void test310CreateWrongRole() throws Exception { // WHEN when(); - addObject(wrong2.asPrismObject(), getTestTask(), getTestResult()); + addObject(wrong2.asPrismObject(), getTestTask(), getTestOperationResult()); // THEN then(); wrong2 = getRole(wrong2.getOid()).asObjectable(); display("role 'wrong-2'", wrong2); - assertSuccess(getTestResult()); + assertSuccess(getTestOperationResult()); assertEquals("Wrong policy situations for role", Collections.singletonList(WRONG_URI), wrong2.getPolicySituation()); @@ -468,13 +467,13 @@ public void test320CreateWrongRoleKnownOid() throws Exception { // WHEN when(); - addObject(wrong3.asPrismObject(), getTestTask(), getTestResult()); + addObject(wrong3.asPrismObject(), getTestTask(), getTestOperationResult()); // THEN then(); wrong3 = getRole(wrong3.getOid()).asObjectable(); display("role 'wrong-3'", wrong3); - assertSuccess(getTestResult()); + assertSuccess(getTestOperationResult()); assertEquals("Wrong policy situations for role", Collections.singletonList(WRONG_URI), wrong3.getPolicySituation()); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestReconScript.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestReconScript.java index dacc10e3118..b3961d9f706 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestReconScript.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestReconScript.java @@ -51,7 +51,7 @@ public void text001testReconcileScriptsWhenProvisioning() throws Exception{ final String TEST_NAME = "text001testReconcileScriptsWhenProvisioning"; Task task = taskManager.createTaskInstance(TEST_NAME); - OperationResult parentResult = createResult(); + OperationResult parentResult = createOperationalResult(); ObjectDelta delta = createModifyUserAddAccount(USER_JACK_OID, getDummyResourceObject()); Collection> deltas = new ArrayList<>(); @@ -124,7 +124,7 @@ public void test003testReconcileScriptsAddUserAction() throws Exception{ final String TEST_NAME = "test003testReconcileScriptsAddUserAction"; Task task = taskManager.createTaskInstance(TEST_NAME); - OperationResult parentResult = createResult(); + OperationResult parentResult = createOperationalResult(); ShadowType shadow = parseObjectType(new File(ACCOUNT_BEFORE_SCRIPT_FILENAME), ShadowType.class); @@ -169,7 +169,7 @@ public void test005TestDryRunDelete() throws Exception{ final String TEST_NAME = "test005TestDryRunDelete"; PrismObject task = getTask(TASK_RECON_DUMMY_OID); - OperationResult parentResult = createResult(); + OperationResult parentResult = createOperationalResult(); PropertyDelta dryRunDelta = prismContext.deltaFactory().property().createModificationReplaceProperty(PATH_MODEL_EXTENSION_DRY_RUN, task.getDefinition(), true); Collection modifications = new ArrayList<>(); @@ -200,7 +200,7 @@ public void test006TestReconDelete() throws Exception{ final String TEST_NAME = "test006TestReconDelete"; PrismObject task = getTask(TASK_RECON_DUMMY_OID); - OperationResult parentResult = createResult(); + OperationResult parentResult = createOperationalResult(); PropertyDelta dryRunDelta = prismContext.deltaFactory().property().createModificationReplaceProperty( PATH_MODEL_EXTENSION_DRY_RUN, task.getDefinition(), false); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestStrangeCases.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestStrangeCases.java index b3d1d4209ef..0a8d0919d3f 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestStrangeCases.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestStrangeCases.java @@ -199,7 +199,7 @@ public void test010SanityAdministrator() throws Exception { public void test050AddRoleRecursionAssignment() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -232,7 +232,7 @@ public void test050AddRoleRecursionAssignment() throws Exception { public void test060AddRoleStupidAssignment() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -255,7 +255,7 @@ public void test060AddRoleStupidAssignment() throws Exception { public void test100ModifyUserGuybrushAddAccountDummyRedNoAttributesConflict() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -358,7 +358,7 @@ public void test100ModifyUserGuybrushAddAccountDummyRedNoAttributesConflict() th public void test180DeleteHalfAssignmentFromUser() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -409,7 +409,7 @@ public void test180DeleteHalfAssignmentFromUser() throws Exception { public void test190DeleteHalfAssignedUser() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -463,7 +463,7 @@ public void test190DeleteHalfAssignedUser() throws Exception { public void test200ModifyUserJackBrokenAccountRefAndPolyString() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -507,7 +507,7 @@ public void test200ModifyUserJackBrokenAccountRefAndPolyString() throws Exceptio public void test210ModifyUserAddAccount() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -537,7 +537,7 @@ public void test210ModifyUserAddAccount() throws Exception { public void test212ModifyUserAddAccountRed() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -570,7 +570,7 @@ public void test212ModifyUserAddAccountRed() throws Exception { public void test212ModifyUserJackBrokenSchemaViolationPolyString() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); @@ -612,7 +612,7 @@ public void test212ModifyUserJackBrokenSchemaViolationPolyString() throws Except public void test214ModifyUserJackBrokenPassword() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); @@ -654,7 +654,7 @@ public void test214ModifyUserJackBrokenPassword() throws Exception { public void test220ModifyUserJackBrokenConflict() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); @@ -700,7 +700,7 @@ public void test220ModifyUserJackBrokenConflict() throws Exception { public void test230ModifyUserJackUserTemplatePolicyViolation() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); getDummyResource().setModifyBreakMode(BreakMode.NONE); dummyAuditService.clear(); @@ -753,7 +753,7 @@ public void test300ExtensionSanity() { public void test301AddUserDeGhoulash() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -829,7 +829,7 @@ public void test317SearchDeGhoulashByFuneralTimestamp() throws Exception { private void searchDeGhoulash(QName propName, T propValue) throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -881,7 +881,7 @@ private void assertBasicDeGhoulashExtension(PrismObject userDeGhoulash public void test330AssignDeGhoulashIdiot() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -907,7 +907,7 @@ public void test330AssignDeGhoulashIdiot() throws Exception { public void test332AssignDeGhoulashRecursion() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -943,7 +943,7 @@ public void test332AssignDeGhoulashRecursion() throws Exception { public void test334AssignDeGhoulashStupidAssignment() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -972,7 +972,7 @@ public void test334AssignDeGhoulashStupidAssignment() throws Exception { public void test336UnassignDeGhoulashStupidAssignment() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -993,7 +993,7 @@ public void test336UnassignDeGhoulashStupidAssignment() throws Exception { public void test340AssignDeGhoulashConstructionNonExistentResource() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -1018,7 +1018,7 @@ public void test340AssignDeGhoulashConstructionNonExistentResource() throws Exce public void test349UnAssignDeGhoulashConstructionNonExistentResource() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -1042,7 +1042,7 @@ public void test349UnAssignDeGhoulashConstructionNonExistentResource() throws Ex public void test350AssignDeGhoulashRoleBadConstructionResourceRef() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -1069,7 +1069,7 @@ public void test350AssignDeGhoulashRoleBadConstructionResourceRef() throws Excep public void test351UnAssignDeGhoulashRoleBadConstructionResourceRef() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -1096,7 +1096,7 @@ public void test351UnAssignDeGhoulashRoleBadConstructionResourceRef() throws Exc public void test355AssignDeGhoulashRoleBadConstructionResourceRefLax() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -1119,7 +1119,7 @@ public void test355AssignDeGhoulashRoleBadConstructionResourceRefLax() throws Ex public void test356UnAssignDeGhoulashRoleBadConstructionResourceRefLax() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -1142,7 +1142,7 @@ public void test356UnAssignDeGhoulashRoleBadConstructionResourceRefLax() throws public void test360AddRoleTargetBadConstructionResourceRef() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -1163,7 +1163,7 @@ public void test360AddRoleTargetBadConstructionResourceRef() throws Exception { @Test public void test400ImportJackMockTask() throws Exception { // GIVEN - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -1184,7 +1184,7 @@ public void test400ImportJackMockTask() throws Exception { public void test401ListTasks() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -1230,7 +1230,7 @@ public void test401ListTasks() throws Exception { public void test410DeleteJack() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -1283,7 +1283,7 @@ public void test410DeleteJack() throws Exception { public void test450AddApprovalCase() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); @@ -1319,7 +1319,7 @@ public void test500EnumerationExtension() { public void test502EnumerationStoreGood() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObjectDefinition userDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class); userDef.findPropertyDefinition(ItemPath.create(UserType.F_EXTENSION, PIRACY_MARK)); @@ -1359,7 +1359,7 @@ public void test510EnumerationGetBad() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); @@ -1385,7 +1385,7 @@ public void test510EnumerationGetBad() throws Exception { public void test520ShipReadBadTolerateRawData() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); @@ -1425,7 +1425,7 @@ private void changeDefinition(QName piracyShip, ItemName piracyShipBroken) { public void test522ShipReadBadRaw() { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); @@ -1448,7 +1448,7 @@ public void test522ShipReadBadRaw() { public void test524ShipReadBadPlain() { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); @@ -1475,7 +1475,7 @@ public void test529FixSchema() { public void test550AssignCircus() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); try { // WHEN @@ -1495,7 +1495,7 @@ public void test550AssignCircus() throws Exception { public void test600AddUserGuybrushAssignAccount() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1536,7 +1536,7 @@ public void test600AddUserGuybrushAssignAccount() throws Exception { public void test610GetAccountGuybrushRogueAttribute() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); getDummyResource().setEnforceSchema(false); DummyAccount dummyAccount = getDummyAccount(null, USER_GUYBRUSH_USERNAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplate.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplate.java index 3ca89f54c5f..fcdffed8f4c 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplate.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplate.java @@ -128,7 +128,7 @@ protected int getNumberOfRoles() { @Test public void test000Sanity() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN when(); @@ -170,7 +170,7 @@ private void assertObjectTemplate(List defaultObj public void test100ModifyUserGivenName() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); Collection> deltas = new ArrayList<>(); ObjectDelta userDelta = prismContext.deltaFactory().object().createModificationReplaceProperty(UserType.class, @@ -212,7 +212,7 @@ public void test100ModifyUserGivenName() throws Exception { public void test101ModifyUserEmployeeTypePirate() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); Collection> deltas = new ArrayList<>(); ObjectDelta userDelta = prismContext.deltaFactory().object().createModificationReplaceProperty(UserType.class, @@ -260,7 +260,7 @@ public void test101ModifyUserEmployeeTypePirate() throws Exception { public void test102ModifyUserEmployeeTypeBuccaneer() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); Collection> deltas = new ArrayList<>(); ObjectDelta userDelta = prismContext.deltaFactory().object().createModificationReplaceProperty(UserType.class, @@ -298,7 +298,7 @@ public void test102ModifyUserEmployeeTypeBuccaneer() throws Exception { public void test103ModifyUserEmployeeTypeBartender() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); Collection> deltas = new ArrayList<>(); ObjectDelta userDelta = prismContext.deltaFactory().object().createModificationReplaceProperty(UserType.class, @@ -338,7 +338,7 @@ public void test103ModifyUserEmployeeTypeBartender() throws Exception { public void test104ModifyUserCostCenter() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); Collection> deltas = new ArrayList<>(); ObjectDelta userDelta = prismContext.deltaFactory().object().createModificationReplaceProperty(UserType.class, @@ -374,7 +374,7 @@ public void test104ModifyUserCostCenter() throws Exception { public void test105ModifyUserTelephoneNumber() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); Collection> deltas = new ArrayList<>(); ObjectDelta userDelta = prismContext.deltaFactory().object().createModificationReplaceProperty(UserType.class, @@ -412,7 +412,7 @@ public void test105ModifyUserTelephoneNumber() throws Exception { public void test106ModifyUserRemoveTelephoneNumber() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); Collection> deltas = new ArrayList<>(); ObjectDelta userDelta = prismContext.deltaFactory().object().createModificationReplaceProperty(UserType.class, @@ -450,7 +450,7 @@ public void test106ModifyUserRemoveTelephoneNumber() throws Exception { public void test107ModifyUserSetTelephoneNumber() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN modifyUserReplace(USER_JACK_OID, UserType.F_TELEPHONE_NUMBER, task, result, "1 222 3456789"); @@ -487,7 +487,7 @@ public void test107ModifyUserSetTelephoneNumber() throws Exception { public void test120ReconcileUser() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN reconcileUser(USER_JACK_OID, task, result); @@ -527,7 +527,7 @@ public void test120ReconcileUser() throws Exception { public void test121ModifyUserReplaceLocality() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN modifyUserReplace(USER_JACK_OID, UserType.F_LOCALITY, task, result, PrismTestUtil.createPolyString("Tortuga")); @@ -563,7 +563,7 @@ public void test121ModifyUserReplaceLocality() throws Exception { public void test140AssignDummy() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); @@ -595,7 +595,7 @@ public void test140AssignDummy() throws Exception { public void test149UnAssignDummy() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); @@ -626,7 +626,7 @@ public void test149UnAssignDummy() throws Exception { public void test150ModifyJackOrganizationalUnitRum() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN modifyUserReplace(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result, PrismTestUtil.createPolyString("F0004")); @@ -660,7 +660,7 @@ public void test150ModifyJackOrganizationalUnitRum() throws Exception { public void test151ModifyJackOrganizationalUnitOffense() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN modifyUserReplace(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result, PrismTestUtil.createPolyString("F0003")); @@ -694,7 +694,7 @@ public void test151ModifyJackOrganizationalUnitOffense() throws Exception { public void test152ModifyJackOrganizationalUnitAddRum() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN modifyUserAdd(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result, PrismTestUtil.createPolyString("F0004")); @@ -731,7 +731,7 @@ public void test152ModifyJackOrganizationalUnitAddRum() throws Exception { public void test153ModifyJackOrganizationalUnitDeleteOffense() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN modifyUserDelete(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result, PrismTestUtil.createPolyString("F0003")); @@ -767,7 +767,7 @@ public void test153ModifyJackOrganizationalUnitDeleteOffense() throws Exception public void test155ModifyJackOrganizationalUnitFD001() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN modifyUserAdd(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result, PrismTestUtil.createPolyString("FD001")); @@ -806,7 +806,7 @@ public void test155ModifyJackOrganizationalUnitFD001() throws Exception { public void test156ReconcileJack() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN reconcileUser(USER_JACK_OID, task, result); @@ -844,7 +844,7 @@ public void test156ReconcileJack() throws Exception { public void test157ModifyJackOrganizationalUnitFD0023() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN modifyUserAdd(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result, @@ -884,7 +884,7 @@ public void test157ModifyJackOrganizationalUnitFD0023() throws Exception { public void test159ModifyJackDeleteOrganizationalUnitFD002() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN modifyUserDelete(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result, @@ -925,7 +925,7 @@ public void test159ModifyJackDeleteOrganizationalUnitFD002() throws Exception { public void test160ModifyUserGivenNameAgain() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); @@ -968,7 +968,7 @@ public void test160ModifyUserGivenNameAgain() throws Exception { public void test162ModifyUserGivenNameAgainPhantomChange() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result); display("User before", userBefore); @@ -1006,7 +1006,7 @@ public void test162ModifyUserGivenNameAgainPhantomChange() throws Exception { public void test165ModifyUserGivenNameAgainAgain() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result); display("User before", userBefore); @@ -1053,7 +1053,7 @@ private void assertOnDemandOrgAssigned(String orgName, PrismObject use public void test170ModifyUserGuybrushEmployeeTypeThief() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1081,7 +1081,7 @@ public void test170ModifyUserGuybrushEmployeeTypeThief() throws Exception { public void test172ModifyUserGuybrushHonorificPrefix() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1111,7 +1111,7 @@ public void test172ModifyUserGuybrushHonorificPrefix() throws Exception { public void test174ModifyUserGuybrushHonorificPrefixNone() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1140,7 +1140,7 @@ public void test174ModifyUserGuybrushHonorificPrefixNone() throws Exception { public void test180ModifyUserGuybrushEmployeeTypeMarooned() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1170,7 +1170,7 @@ public void test180ModifyUserGuybrushEmployeeTypeMarooned() throws Exception { public void test184ModifyUserGuybrushEmployeeTypeNone() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1202,7 +1202,7 @@ public void test184ModifyUserGuybrushEmployeeTypeNone() throws Exception { public void test185ModifyUserGuybrushSubtypeMarooned() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1228,7 +1228,7 @@ public void test185ModifyUserGuybrushSubtypeMarooned() throws Exception { public void test189ModifyUserGuybrushSubtypeNone() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1262,7 +1262,7 @@ public void test189ModifyUserGuybrushSubtypeNone() throws Exception { public void test190ModifyUserGuybrushOrganizationWhateveric() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1293,7 +1293,7 @@ public void test190ModifyUserGuybrushOrganizationWhateveric() throws Exception { public void test191ModifyUserGuybrushOrganizationAutomatic() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1329,7 +1329,7 @@ public void test191ModifyUserGuybrushOrganizationAutomatic() throws Exception { public void test192ModifyUserGuybrushOrganizationAddMixed() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1377,7 +1377,7 @@ public void test192ModifyUserGuybrushOrganizationAddMixed() throws Exception { public void test193ModifyUserGuybrushOrganizationAddOutOfDomain() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1425,7 +1425,7 @@ public void test193ModifyUserGuybrushOrganizationAddOutOfDomain() throws Excepti public void test194ModifyUserGuybrushOrganizationDeleteMixed() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1469,7 +1469,7 @@ public void test194ModifyUserGuybrushOrganizationDeleteMixed() throws Exception public void test195ModifyUserGuybrushOrganizationDeleteOutOfDomain() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1510,7 +1510,7 @@ public void test195ModifyUserGuybrushOrganizationDeleteOutOfDomain() throws Exce public void test196GuybrushAssignCaptain() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1549,7 +1549,7 @@ public void test196GuybrushAssignCaptain() throws Exception { public void test197ModifyGuybrushEmployeeTypePirate() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN when(); @@ -1585,7 +1585,7 @@ public void test197ModifyGuybrushEmployeeTypePirate() throws Exception { public void test198AModifyUserGuybrushOrganizationAddInDomain() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1632,7 +1632,7 @@ public void test198AModifyUserGuybrushOrganizationAddInDomain() throws Exception public void test198BModifyUserGuybrushOrganizationDeleteMixed() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1675,7 +1675,7 @@ public void test198BModifyUserGuybrushOrganizationDeleteMixed() throws Exception public void test199AGuyBrushModifyEmployeeTypeWannabe() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1714,7 +1714,7 @@ public void test199AGuyBrushModifyEmployeeTypeWannabe() throws Exception { public void test199BGuyBrushUnassignCaptain() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1752,7 +1752,7 @@ public void test199BGuyBrushUnassignCaptain() throws Exception { public void test199CModifyUserGuybrushOrganizationCleanup() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1780,7 +1780,7 @@ public void test199CModifyUserGuybrushOrganizationCleanup() throws Exception { public void test200AddUserRapp() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject user = PrismTestUtil.parseObject(USER_RAPP_FILE); Collection> deltas = new ArrayList<>(); @@ -1814,7 +1814,7 @@ public void test200AddUserRapp() throws Exception { public void test201AddUserLargo() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // This simulates IMPORT to trigger the channel-limited mapping task.setChannel(QNameUtil.qNameToUri(SchemaConstants.CHANGE_CHANNEL_IMPORT)); @@ -1859,7 +1859,7 @@ public void test201AddUserLargo() throws Exception { public void test202AddUserMonkey() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject user = PrismTestUtil.parseObject(USER_THREE_HEADED_MONKEY_FILE); Collection> deltas = new ArrayList<>(); @@ -1897,7 +1897,7 @@ public void test202AddUserMonkey() throws Exception { public void test204AddUserHerman() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject user = PrismTestUtil.parseObject(USER_HERMAN_FILE); Collection> deltas = new ArrayList<>(); @@ -1930,7 +1930,7 @@ public void test204AddUserHerman() throws Exception { public void test220AssignRoleSailorToUserRapp() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN assignRole(USER_RAPP_OID, ROLE_SAILOR_OID, task, result); @@ -1962,7 +1962,7 @@ public void test220AssignRoleSailorToUserRapp() throws Exception { public void test229UnassignRoleSailorFromUserRapp() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN unassignRole(USER_RAPP_OID, ROLE_SAILOR_OID, task, result); @@ -1996,7 +1996,7 @@ public void test229UnassignRoleSailorFromUserRapp() throws Exception { public void test230AssignRoleCaptainToUserRapp() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN assignRole(USER_RAPP_OID, ROLE_CAPTAIN_OID, task, result); @@ -2028,7 +2028,7 @@ public void test230AssignRoleCaptainToUserRapp() throws Exception { public void test232ModifyUserRappCostCenter() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN modifyUserReplace(USER_RAPP_OID, UserType.F_COST_CENTER, task, result, "CC-RAPP"); @@ -2061,7 +2061,7 @@ public void test232ModifyUserRappCostCenter() throws Exception { public void test239UnassignRoleCaptainFromUserRapp() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN unassignRole(USER_RAPP_OID, ROLE_CAPTAIN_OID, task, result); @@ -2090,7 +2090,7 @@ public void test239UnassignRoleCaptainFromUserRapp() throws Exception { public void test240ModifyUserRappLocalityScabb() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = modelService.getObject(UserType.class, USER_RAPP_OID, null, task, result); display("User before", userBefore); @@ -2135,7 +2135,7 @@ public void test240ModifyUserRappLocalityScabb() throws Exception { public void test242AssignRoleRastamanToUserRapp() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN assignRole(USER_RAPP_OID, ROLE_RASTAMAN_OID, task, result); @@ -2173,7 +2173,7 @@ public void test242AssignRoleRastamanToUserRapp() throws Exception { public void test244ModifyUserRappLocalityCoffin() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = modelService.getObject(UserType.class, USER_RAPP_OID, null, task, result); display("User before", userBefore); @@ -2211,7 +2211,7 @@ public void test244ModifyUserRappLocalityCoffin() throws Exception { public void test245ModifyUserRappLocalityUnderReconcile() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = modelService.getObject(UserType.class, USER_RAPP_OID, null, task, result); display("User before", userBefore); @@ -2256,7 +2256,7 @@ public void test245ModifyUserRappLocalityUnderReconcile() throws Exception { public void test246ModifyUserRappTimezoneMonkey() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = modelService.getObject(UserType.class, USER_RAPP_OID, null, task, result); display("User before", userBefore); @@ -2296,7 +2296,7 @@ public void test246ModifyUserRappTimezoneMonkey() throws Exception { public void test247ModifyUserRappLocaleMI() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = modelService.getObject(UserType.class, USER_RAPP_OID, null, task, result); display("User before", userBefore); @@ -2333,7 +2333,7 @@ public void test247ModifyUserRappLocaleMI() throws Exception { public void test249UnassignRoleRastamanFromUserRapp() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN unassignRole(USER_RAPP_OID, ROLE_RASTAMAN_OID, task, result); @@ -2370,7 +2370,7 @@ public void test249UnassignRoleRastamanFromUserRapp() throws Exception { public void test300ImportStanFromEmeraldResource() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); DummyAccount dummyAccountBefore = new DummyAccount(ACCOUNT_STAN_USERNAME); @@ -2412,7 +2412,7 @@ public void test300ImportStanFromEmeraldResource() throws Exception { public void test302ModifyStanAccountAndReimport() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); DummyAccount dummyAccountBefore = dummyResourceEmerald.getAccountByUsername(ACCOUNT_STAN_USERNAME); @@ -2475,7 +2475,7 @@ public void test800NullTimeFrom() throws Exception { public void test802FuneralTimestamp() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); funeralTimestamp = clock.currentTimeXMLGregorianCalendar(); modifyUserReplace(USER_JACK_OID, getExtensionPath(PIRACY_FUNERAL_TIMESTAMP), task, result, funeralTimestamp); @@ -2652,7 +2652,7 @@ public void test813TalesBoomRecompute() throws Exception { public void test820TalesUnBoom() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); modifyUserReplace(USER_JACK_OID, getExtensionPath(PIRACY_TALES), task, result /* no value */); @@ -2701,7 +2701,7 @@ public void test820TalesUnBoom() throws Exception { public void test830PreLootBoom() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); modifyUserReplace(USER_JACK_OID, UserType.F_DESCRIPTION, task, result, "Rum is gone"); @@ -2796,7 +2796,7 @@ public void test832LootBoomConditionFalse() throws Exception { public void test835LootBoom() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN modifyUserReplace(USER_JACK_OID, UserType.F_GIVEN_NAME, task, result, createPolyString("Lootjack")); @@ -2830,7 +2830,7 @@ public void test835LootBoom() throws Exception { public void test840ResetFuneralTimestamp() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); modifyUserReplace(USER_JACK_OID, getExtensionPath(PIRACY_FUNERAL_TIMESTAMP), task, result /* no value */); @@ -2858,7 +2858,7 @@ public void test840ResetFuneralTimestamp() throws Exception { public void test843UnLoot() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN modifyUserReplace(USER_JACK_OID, UserType.F_GIVEN_NAME, task, result, createPolyString("Justjack")); @@ -2893,7 +2893,7 @@ public void test843UnLoot() throws Exception { public void test845ReLoot() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN modifyUserReplace(USER_JACK_OID, UserType.F_GIVEN_NAME, task, result, createPolyString("Lootjack")); @@ -2928,7 +2928,7 @@ public void test845ReLoot() throws Exception { public void test850AddCannibalLemonhead() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN String userOid = addObject(createCannibal(CANNIBAL_LEMONHEAD_USERNAME, null, false), task, result); @@ -2956,7 +2956,7 @@ public void test850AddCannibalLemonhead() throws Exception { public void test852AddCanibalRedSkull() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN String userOid = addObject(createCannibal(CANNIBAL_REDSKULL_USERNAME, "", false), task, result); @@ -2988,7 +2988,7 @@ public void test852AddCanibalRedSkull() throws Exception { public void test854AddCanibalShaprtooth() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN String userOid = addObject(createCannibal(CANNIBAL_SHARPTOOTH_USERNAME, "-P1M1D", false), task, result); @@ -3021,7 +3021,7 @@ public void test854AddCanibalShaprtooth() throws Exception { public void test856AddCanibalOrangeskin() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN String userOid = addObject(createCannibal(CANNIBAL_ORANGESKIN_USERNAME, "-P3M1D", false), task, result); @@ -3052,7 +3052,7 @@ public void test856AddCanibalOrangeskin() throws Exception { public void test858AddCanibalCherrybrain() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN String userOid = addObject(createCannibal(CANNIBAL_CHERRYBRAIN_USERNAME, "-P1Y1D", false), task, result); @@ -3085,7 +3085,7 @@ public void test858AddCanibalCherrybrain() throws Exception { public void test859AddCanibalPineapplenose() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN String userOid = addObject( @@ -3119,7 +3119,7 @@ public void test859AddCanibalPineapplenose() throws Exception { public void test860AddCannibalRottenLemonhead() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN String userOid = addObject(createCannibal(CANNIBAL_LEMONHEAD_USERNAME, null, true), task, result); @@ -3147,7 +3147,7 @@ public void test860AddCannibalRottenLemonhead() throws Exception { public void test862AddCanibalRottenRedSkull() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN String userOid = addObject(createCannibal(CANNIBAL_REDSKULL_USERNAME, "", true), task, result); @@ -3179,7 +3179,7 @@ public void test862AddCanibalRottenRedSkull() throws Exception { public void test864AddCanibalRottenShaprtooth() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN String userOid = addObject(createCannibal(CANNIBAL_SHARPTOOTH_USERNAME, "-P1M1D", true), task, result); @@ -3222,7 +3222,7 @@ public void test864AddCanibalRottenShaprtooth() throws Exception { public void test866AddCanibalRottenOrangeskin() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN String userOid = addObject(createCannibal(CANNIBAL_ORANGESKIN_USERNAME, "-P3M1D", true), task, result); @@ -3256,7 +3256,7 @@ public void test866AddCanibalRottenOrangeskin() throws Exception { public void test868AddCanibalRottenCherrybrain() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN String userOid = addObject(createCannibal(CANNIBAL_CHERRYBRAIN_USERNAME, "-P1Y1D", true), task, result); @@ -3287,7 +3287,7 @@ public void test868AddCanibalRottenCherrybrain() throws Exception { public void test869AddCanibalRottenPineapplenose() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN String userOid = addObject( @@ -3322,7 +3322,7 @@ public void test869AddCanibalRottenPineapplenose() throws Exception { public void test870AddCanibalRottenPotatoleg() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN String userOid = addObject( @@ -3374,7 +3374,7 @@ private PrismObject createCannibal(String name, String funeralDateOffs public void test900DeleteUser() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Collection> deltas = new ArrayList<>(); @@ -3406,7 +3406,7 @@ public void test950CreateUserJackWithoutTemplate() throws Exception { setDefaultUserTemplate(null); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); // WHEN @@ -3436,7 +3436,7 @@ public void test950CreateUserJackWithoutTemplate() throws Exception { public void test952ModifyJackOrganizationalUnitFD004() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN modifyUserAdd(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result, PrismTestUtil.createPolyString("FD004")); @@ -3467,7 +3467,7 @@ public void test960ReconcileUserJackWithTemplate() throws Exception { setDefaultUserTemplate(USER_TEMPLATE_COMPLEX_OID); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); // WHEN @@ -3494,7 +3494,7 @@ public void test960ReconcileUserJackWithTemplate() throws Exception { public void test970ModifyUserGuybrushEmployeeTypeUseless() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -3522,7 +3522,7 @@ public void test970ModifyUserGuybrushEmployeeTypeUseless() throws Exception { public void test980DeleteUserGivenName() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); UserType user = new UserType(prismContext) .name("test980DeleteUserGivenName") diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateTaskMechanics.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateTaskMechanics.java index fa014a8eb28..8903595c106 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateTaskMechanics.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateTaskMechanics.java @@ -88,7 +88,7 @@ public void test000Sanity() throws ObjectNotFoundException { @Test public void test100SmallTaskNoWorkers() throws IOException, TimeoutException, CommonException { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); int usersBefore = getObjectCount(UserType.class); @@ -113,7 +113,7 @@ public void test100SmallTaskNoWorkers() throws IOException, TimeoutException, Co @Test public void test110SmallTaskOneWorker() throws IOException, TimeoutException, CommonException { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); int usersBefore = getObjectCount(UserType.class); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMapping.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMapping.java index c3b8ecb86f0..46fa677c7d8 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMapping.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMapping.java @@ -179,7 +179,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti public void test100ModifyUserAssignAccountDummyBlue() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); // WHEN @@ -233,7 +233,7 @@ public void test100ModifyUserAssignAccountDummyBlue() throws Exception { public void test101ModifyUserFullName() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); // WHEN @@ -269,7 +269,7 @@ public void test101ModifyUserFullName() throws Exception { public void test102ModifyUserFullNameRecon() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); // WHEN @@ -309,7 +309,7 @@ public void test102ModifyUserFullNameRecon() throws Exception { public void test104ModifyUserOrganizationalUnit() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); // WHEN @@ -340,7 +340,7 @@ public void test104ModifyUserOrganizationalUnit() throws Exception { public void test105ModifyAccountShip() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); PrismObject userJack = getUser(USER_JACK_OID); @@ -383,7 +383,7 @@ accountOid, getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).getAttributePat public void test106ModifyAccountShipReplaceEmpty() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); PrismObject userJack = getUser(USER_JACK_OID); @@ -422,7 +422,7 @@ accountOid, getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).getAttributePat public void test107ModifyAccountShipAgain() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); PrismObject userJack = getUser(USER_JACK_OID); @@ -465,7 +465,7 @@ accountOid, getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).getAttributePat public void test108ModifyAccountShipDelete() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); PrismObject userJack = getUser(USER_JACK_OID); @@ -509,7 +509,7 @@ accountOid, getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).getAttributePat public void test110AssignBlueTitanic() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN assignRole(USER_JACK_OID, ROLE_BLUE_TITANIC_OID, task, result); @@ -528,7 +528,7 @@ public void test110AssignBlueTitanic() throws Exception { public void test111Recompute() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN recomputeUser(USER_JACK_OID, task, result); @@ -552,7 +552,7 @@ public void test111Recompute() throws Exception { public void test112DisableBlueTitanicAssignment() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -579,7 +579,7 @@ public void test112DisableBlueTitanicAssignment() throws Exception { public void test113Recompute() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN recomputeUser(USER_JACK_OID, task, result); @@ -601,7 +601,7 @@ public void test113Recompute() throws Exception { public void test114Reconcile() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN reconcileUser(USER_JACK_OID, task, result); @@ -624,7 +624,7 @@ public void test114Reconcile() throws Exception { public void test115EnableBlueTitanicAssignment() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -648,7 +648,7 @@ public void test115EnableBlueTitanicAssignment() throws Exception { public void test118UnassignBlueTitanic() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -677,7 +677,7 @@ public void test118UnassignBlueTitanic() throws Exception { public void test120AssignBluePoetry() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assertDummyAccountAttribute(RESOURCE_DUMMY_BLUE_NAME, ACCOUNT_JACK_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_QUOTE_NAME, @@ -701,7 +701,7 @@ public void test120AssignBluePoetry() throws Exception { public void test121Recompute() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN recomputeUser(USER_JACK_OID, task, result); @@ -724,7 +724,7 @@ public void test121Recompute() throws Exception { public void test122DisableBlueTitanicAssignment() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -754,7 +754,7 @@ public void test122DisableBlueTitanicAssignment() throws Exception { public void test123Recompute() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN recomputeUser(USER_JACK_OID, task, result); @@ -778,7 +778,7 @@ public void test123Recompute() throws Exception { public void test124Reconcile() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN reconcileUser(USER_JACK_OID, task, result); @@ -803,7 +803,7 @@ public void test124Reconcile() throws Exception { public void test125EnableBluePoetryAssignment() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -829,7 +829,7 @@ public void test125EnableBluePoetryAssignment() throws Exception { public void test128UnassignBluePoetry() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -855,7 +855,7 @@ public void test128UnassignBluePoetry() throws Exception { public void test129ModifyUserUnassignAccountBlue() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); Collection> deltas = new ArrayList<>(); @@ -894,7 +894,7 @@ public void test129ModifyUserUnassignAccountBlue() throws Exception { public void test140AssignCobaltAccount() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -926,7 +926,7 @@ public void test140AssignCobaltAccount() throws Exception { public void test141DestroyAndRecompute() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_COBALT_NAME, ACCOUNT_JACK_DUMMY_USERNAME); dummyAccountBefore.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, @@ -957,7 +957,7 @@ public void test141DestroyAndRecompute() throws Exception { public void test142DestroyAndReconcile() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_COBALT_NAME, ACCOUNT_JACK_DUMMY_USERNAME); dummyAccountBefore.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, @@ -988,7 +988,7 @@ public void test142DestroyAndReconcile() throws Exception { public void test143ClearAndRecompute() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_COBALT_NAME, ACCOUNT_JACK_DUMMY_USERNAME); dummyAccountBefore.replaceAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME @@ -1022,7 +1022,7 @@ public void test143ClearAndRecompute() throws Exception { public void test150AssignCobaltNeverland() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN assignRole(USER_JACK_OID, ROLE_COBALT_NEVERLAND_OID, task, result); @@ -1043,7 +1043,7 @@ public void test150AssignCobaltNeverland() throws Exception { public void test151Recompute() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN recomputeUser(USER_JACK_OID, task, result); @@ -1066,7 +1066,7 @@ public void test151Recompute() throws Exception { public void test152DisableCobalNeverlandAssignment() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -1095,7 +1095,7 @@ public void test152DisableCobalNeverlandAssignment() throws Exception { public void test153Recompute() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN recomputeUser(USER_JACK_OID, task, result); @@ -1118,7 +1118,7 @@ public void test153Recompute() throws Exception { public void test154Reconcile() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN reconcileUser(USER_JACK_OID, task, result); @@ -1142,7 +1142,7 @@ public void test154Reconcile() throws Exception { public void test155DestroyAndRecompute() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_COBALT_NAME, ACCOUNT_JACK_DUMMY_USERNAME); dummyAccountBefore.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, @@ -1173,7 +1173,7 @@ public void test155DestroyAndRecompute() throws Exception { public void test156ClearAndRecompute() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_COBALT_NAME, ACCOUNT_JACK_DUMMY_USERNAME); dummyAccountBefore.replaceAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME @@ -1204,7 +1204,7 @@ public void test156ClearAndRecompute() throws Exception { public void test157EnableCobaltNeverlandAssignment() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -1230,7 +1230,7 @@ public void test157EnableCobaltNeverlandAssignment() throws Exception { public void test158UnassignCobaltNeverland() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -1254,7 +1254,7 @@ public void test158UnassignCobaltNeverland() throws Exception { public void test159UnassignCobaltAccount() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -1280,7 +1280,7 @@ public void test159UnassignCobaltAccount() throws Exception { public void test160ModifyUserAssignAccountDummyRed() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); Collection> deltas = new ArrayList<>(); @@ -1330,7 +1330,7 @@ public void test160ModifyUserAssignAccountDummyRed() throws Exception { public void test161ModifyUserFullName() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); // WHEN @@ -1361,7 +1361,7 @@ public void test161ModifyUserFullName() throws Exception { public void test162ModifyUserOrganizationalUnit() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); // WHEN @@ -1392,7 +1392,7 @@ public void test162ModifyUserOrganizationalUnit() throws Exception { public void test163ModifyAccountShip() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); PrismObject userJack = getUser(USER_JACK_OID); @@ -1436,7 +1436,7 @@ accountOid, getDummyResourceController(RESOURCE_DUMMY_RED_NAME).getAttributePath public void test164ModifyAccountShipReplaceEmpty() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); PrismObject userJack = getUser(USER_JACK_OID); @@ -1475,7 +1475,7 @@ accountOid, getDummyResourceController(RESOURCE_DUMMY_RED_NAME).getAttributePath public void test166ModifyAccountShipDelete() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); PrismObject userJack = getUser(USER_JACK_OID); @@ -1519,7 +1519,7 @@ accountOid, getDummyResourceController(RESOURCE_DUMMY_RED_NAME).getAttributePath public void test168ModifyUserOrganization() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); // WHEN @@ -1553,7 +1553,7 @@ public void test168ModifyUserOrganization() throws Exception { public void test178ModifyUserUnassignAccountRed() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); Collection> deltas = new ArrayList<>(); @@ -1609,7 +1609,7 @@ public void test178ModifyUserUnassignAccountRed() throws Exception { public void test179DeleteAccountRed() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); PrismObject userJack = getUser(USER_JACK_OID); @@ -1653,7 +1653,7 @@ public void test179DeleteAccountRed() throws Exception { public void test180ModifyUserAssignAccountDummyDefault() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); Collection> deltas = new ArrayList<>(); @@ -1703,7 +1703,7 @@ public void test180ModifyUserAssignAccountDummyDefault() throws Exception { public void test181ModifyUserFullName() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); // WHEN @@ -1737,7 +1737,7 @@ public void test181ModifyUserFullName() throws Exception { public void test182ModifyUserLocality() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); // WHEN @@ -1768,7 +1768,7 @@ public void test182ModifyUserLocality() throws Exception { public void test183ModifyAccountLocation() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); PrismObject userJack = getUser(USER_JACK_OID); @@ -1813,7 +1813,7 @@ public void test183ModifyAccountLocation() throws Exception { public void test184ModifyAccountLocationReplaceEmpty() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); PrismObject userJack = getUser(USER_JACK_OID); @@ -1852,7 +1852,7 @@ public void test184ModifyAccountLocationReplaceEmpty() throws Exception { public void test185ModifyAccountLocationDelete() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); PrismObject userJack = getUser(USER_JACK_OID); @@ -1891,7 +1891,7 @@ public void test185ModifyAccountLocationDelete() throws Exception { public void test188ModifyUserRename() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); // WHEN @@ -1923,7 +1923,7 @@ public void test188ModifyUserRename() throws Exception { public void test189ModifyUserUnassignAccountDummy() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); Collection> deltas = new ArrayList<>(); @@ -2019,7 +2019,7 @@ private void assertAccount(PrismObject userJack, String expectedFullNa public void test200ModifyUserAssignAccountDummyCrimson() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN when(); @@ -2050,7 +2050,7 @@ public void test200ModifyUserAssignAccountDummyCrimson() throws Exception { public void test202NativeModifyDummyCrimsonThenReconcile() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); dummyAccountBefore.replaceAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, @@ -2091,7 +2091,7 @@ public void test202NativeModifyDummyCrimsonThenReconcile() throws Exception { public void test204DummyCrimsonReconcile() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); display("Dummy account before", dummyAccountBefore); @@ -2134,7 +2134,7 @@ public void test204DummyCrimsonReconcile() throws Exception { public void test206DummyCrimsonReconcileIOError() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); display("Dummy account before", dummyAccountBefore); @@ -2183,7 +2183,7 @@ public void test206DummyCrimsonReconcileIOError() throws Exception { public void test208DummyCrimsonReconcileAgain() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); getDummyResource(RESOURCE_DUMMY_CRIMSON_NAME).resetBreakMode(); @@ -2226,7 +2226,7 @@ public void test208DummyCrimsonReconcileAgain() throws Exception { public void test210ModifyUserLocality() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); getDummyResource(RESOURCE_DUMMY_CRIMSON_NAME).resetBreakMode(); @@ -2269,7 +2269,7 @@ public void test210ModifyUserLocality() throws Exception { public void test212ModifyUserLocalityRecon() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); getDummyResource(RESOURCE_DUMMY_CRIMSON_NAME).resetBreakMode(); @@ -2316,7 +2316,7 @@ public void test212ModifyUserLocalityRecon() throws Exception { public void test214ModifyUserLocalityIOError() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); getDummyResource(RESOURCE_DUMMY_CRIMSON_NAME).resetBreakMode(); @@ -2366,7 +2366,7 @@ public void test214ModifyUserLocalityIOError() throws Exception { public void test220NativeModifyDummyCrimsonThenChangePassword() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); getDummyResource(RESOURCE_DUMMY_CRIMSON_NAME).resetBreakMode(); @@ -2417,7 +2417,7 @@ public void test220NativeModifyDummyCrimsonThenChangePassword() throws Exception public void test229ModifyUserUnassignAccountDummyCrimson() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN when(); @@ -2443,7 +2443,7 @@ public void test229ModifyUserUnassignAccountDummyCrimson() throws Exception { public void test250ModifyUserAssignAccountDummyLightCrimson() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // preconditions PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -2480,7 +2480,7 @@ public void test250ModifyUserAssignAccountDummyLightCrimson() throws Exception { public void test252NativeModifyDummyLightCrimsonThenReconcile() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); dummyAccountBefore.replaceAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, @@ -2521,7 +2521,7 @@ public void test252NativeModifyDummyLightCrimsonThenReconcile() throws Exception public void test254DummyLightCrimsonReconcile() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); display("Dummy account before", dummyAccountBefore); @@ -2565,7 +2565,7 @@ public void test254DummyLightCrimsonReconcile() throws Exception { public void test256DummyLightCrimsonReconcileIOError() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); display("Dummy account before", dummyAccountBefore); @@ -2614,7 +2614,7 @@ public void test256DummyLightCrimsonReconcileIOError() throws Exception { public void test258DummyLightCrimsonReconcileAgain() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); getDummyResource(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME).resetBreakMode(); @@ -2657,7 +2657,7 @@ public void test258DummyLightCrimsonReconcileAgain() throws Exception { public void test260ModifyUserLocality() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); getDummyResource(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME).resetBreakMode(); @@ -2700,7 +2700,7 @@ public void test260ModifyUserLocality() throws Exception { public void test262ModifyUserLocalityRecon() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); getDummyResource(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME).resetBreakMode(); @@ -2747,7 +2747,7 @@ public void test262ModifyUserLocalityRecon() throws Exception { public void test264ModifyUserLocalityIOError() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); getDummyResource(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME).resetBreakMode(); @@ -2797,7 +2797,7 @@ public void test264ModifyUserLocalityIOError() throws Exception { public void test270NativeModifyDummyLightCrimsonThenChangePassword() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); getDummyResource(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME).resetBreakMode(); @@ -2848,7 +2848,7 @@ public void test270NativeModifyDummyLightCrimsonThenChangePassword() throws Exce public void test279ModifyUserUnassignAccountDummyLightCrimson() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN when(); @@ -2878,7 +2878,7 @@ public void test279ModifyUserUnassignAccountDummyLightCrimson() throws Exception public void test300AssignGuybrushDummyYellow() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN when(); @@ -2912,7 +2912,7 @@ public void test300AssignGuybrushDummyYellow() throws Exception { public void test302ModifyGuybrushLocality() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN when(); @@ -2940,7 +2940,7 @@ public void test302ModifyGuybrushLocality() throws Exception { public void test309UnassignGuybrushDummyYellow() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN when(); @@ -2965,7 +2965,7 @@ public void test309UnassignGuybrushDummyYellow() throws Exception { public void test400ModifyUserAssignAccountDummyCrimsonCustomFunction() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN when(); @@ -2991,7 +2991,7 @@ public void test400ModifyUserAssignAccountDummyCrimsonCustomFunction() throws Ex public void test401ModifyUserLocalityDummyCrisomCustomFunction() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN when(); @@ -3018,7 +3018,7 @@ public void test401ModifyUserLocalityDummyCrisomCustomFunction() throws Exceptio public void test402ModifyDrinkDummyCustomFunctionCrimson() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN when(); @@ -3053,7 +3053,7 @@ public void test402ModifyDrinkDummyCustomFunctionCrimson() throws Exception { public void test420AssignAntinihilistToJack() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -3091,7 +3091,7 @@ public void test420AssignAntinihilistToJack() throws Exception { public void test422AssignAccountAndAntinihilistToJack() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null); @@ -3122,7 +3122,7 @@ public void test422AssignAccountAndAntinihilistToJack() throws Exception { public void test425UnassignAntinihilistFromJack() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -3151,7 +3151,7 @@ public void test425UnassignAntinihilistFromJack() throws Exception { public void test427UnassignAccountFromJack() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -3204,7 +3204,7 @@ public void test500AssignmentsCombinationSingle() throws Exception { public void test510AssignmentsCombinationCouple() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject jim = findUserByUsername(USER_JIM_NAME); @@ -3228,7 +3228,7 @@ public void test510AssignmentsCombinationCouple() throws Exception { public void test520DeleteUserAssignment() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject jim = findUserByUsername(USER_JIM_NAME); @@ -3259,7 +3259,7 @@ public void test520DeleteUserAssignment() throws Exception { public void test600AddService() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); final String PASSWORD = "pwd1234"; // WHEN @@ -3289,7 +3289,7 @@ public void test600AddService() throws Exception { public void test610ModifyServicePassword() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); final String NEW_PASSWORD = "dummy"; ProtectedStringType newPasswordProtected = new ProtectedStringType(); @@ -3326,7 +3326,7 @@ public void test610ModifyServicePassword() throws Exception { public void test650ImportFromInboundPwdCopy() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); final String PASSWORD = "secret"; @@ -3378,7 +3378,7 @@ public void test660ImportFromInboundPwdCopyModifyPassword() throws Exception { public void test670ImportFromInboundPwdGenerate() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); final String PASSWORD = "secret-gw"; @@ -3435,7 +3435,7 @@ public void test680ImportFromInboundPwdGenerateModifyPassword() throws Exception public void test700TimedOutbound() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); UserType user = new UserType(prismContext) .name("test700") diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestProgressReporting.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestProgressReporting.java index 938d07ab5af..88eebcf36c7 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestProgressReporting.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestProgressReporting.java @@ -83,7 +83,7 @@ public void test110ReconciliationSuspensionMultiNode() throws Exception { private void executeReconciliation(TestResource reconciliationTask, String accountPrefix, int workers) throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // GIVEN for (int i = 0; i < USERS; i++) { @@ -163,7 +163,7 @@ public void test160RecomputationSuspensionMultiNode() throws Exception { private void executeRecomputation(TestResource recomputationTask, String rolePrefix, int workers) throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // GIVEN System.out.println("Importing roles."); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestRecomputeTask.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestRecomputeTask.java index cf2bec31476..45d2eb41393 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestRecomputeTask.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestRecomputeTask.java @@ -93,7 +93,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti public void test100RecomputeAll() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // Preconditions assertUsers(6); @@ -254,7 +254,7 @@ private void displayRoles(Task task, OperationResult result) throws ObjectNotFou public void test110RecomputeSome() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // Preconditions assertUsers(7); @@ -310,7 +310,7 @@ public void test110RecomputeSome() throws Exception { public void test120RecomputeByExpression() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); prepareNotifications(); // Preconditions @@ -369,7 +369,7 @@ public void test120RecomputeByExpression() throws Exception { public void test130RecomputeLight() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // Preconditions assertUsers(7); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/AbstractTestAssignmentApproval.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/AbstractTestAssignmentApproval.java index 4a4e43a605d..42403a0e2ec 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/AbstractTestAssignmentApproval.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/AbstractTestAssignmentApproval.java @@ -155,7 +155,7 @@ public void test020DeleteRole1Assignment() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); LensContext context = createUserLensContext(); fillContextWithUser(context, userJackOid, result); @@ -180,7 +180,7 @@ public void test020DeleteRole1Assignment() throws Exception { public void test030AddRole1AssignmentAgain() throws Exception { login(userAdministrator); - importLead10(getTestTask(), getTestResult()); + importLead10(getTestTask(), getTestOperationResult()); executeAssignRole1ToJack(false, false, null, null, false); } @@ -271,7 +271,7 @@ public void test100AddCreateDelegation() throws Exception { Task task = getTestTask(); task.setOwner(userAdministrator); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN assignDeputy(userJackDeputyOid, userJackOid, a -> { @@ -295,7 +295,7 @@ public void test130AddRole1aAssignmentWithDeputy() throws Exception { login(userAdministrator); Task task = getTestTask(); - importLead1Deputies(task, getTestResult()); + importLead1Deputies(task, getTestOperationResult()); unassignAllRoles(userJackOid); executeAssignRole1ToJack(false, true, null, null, false); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentApprovalGlobal.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentApprovalGlobal.java index 878a7c77c25..eb8a0f7a3be 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentApprovalGlobal.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentApprovalGlobal.java @@ -64,7 +64,7 @@ public void test300ApprovalAndEnforce() throws Exception { login(userAdministrator); Task task = getTestTask(); task.setOwner(userAdministrator); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); try { assignRole(userJackOid, roleRole15Oid, task, result); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentsAdvanced.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentsAdvanced.java index 6192a06a323..adeded9a887 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentsAdvanced.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentsAdvanced.java @@ -279,7 +279,7 @@ public void test230DeleteRoles123AssignmentYById() throws Exception { public void test300ApprovalAndEnforce() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); try { assignRole(userJackOid, roleRole24Oid, task, result); @@ -327,7 +327,7 @@ public void test420AddRoles123AssignmentPreviewImmediate() throws Exception { public void test500NoApprovers() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assignRole(userJackOid, roleRole26Oid, task, result); String ref = result.findAsynchronousOperationReference(); // TODO use recompute + getAsync... when fixed @@ -353,7 +353,7 @@ public void test500NoApprovers() throws Exception { public void test600AssignRole29() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN when(); @@ -593,7 +593,7 @@ protected void afterFirstClockworkRun(CaseType rootCase, List subcases public void test630UnassignRole29() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN when(); @@ -935,7 +935,7 @@ protected void afterFirstClockworkRun(CaseType rootCase, List subcases public void test800AssignRole27() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN when(); @@ -957,7 +957,7 @@ public void test800AssignRole27() throws Exception { public void test810ModifyAssignmentOfRole27() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN when(); @@ -982,7 +982,7 @@ public void test810ModifyAssignmentOfRole27() throws Exception { public void test820UnassignRole27() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN when(); @@ -999,7 +999,7 @@ public void test820UnassignRole27() throws Exception { public void test900AssignIdempotentRole() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN when(); @@ -1039,7 +1039,7 @@ public void test900AssignIdempotentRole() throws Exception { public void test910AssignRoleWithIdempotentMetarole() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN when(); @@ -1219,7 +1219,7 @@ public List getApprovalSequence() { private void previewAssignRolesToJack(boolean immediate, boolean also24) throws Exception { String testName = getTestNameShort(); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); boolean TRACE = false; //noinspection ConstantConditions if (TRACE) { diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/association/TestAddAssociation.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/association/TestAddAssociation.java index 78c40b15193..bbb8bf2f4cd 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/association/TestAddAssociation.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/association/TestAddAssociation.java @@ -306,7 +306,7 @@ public void test100AddJackToGuests() throws Exception { final String TEST_NAME = "test100AddJackToGuests"; Task modelTask = taskManager.createTaskInstance(TEST_NAME); - OperationResult result = createResult(); + OperationResult result = createOperationalResult(); modelTask.setOwner(repositoryService.getObject(UserType.class, USER_ADMINISTRATOR_OID, null, result)); LensContext context = createUserLensContext(); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/AbstractTestObjectLifecycleApproval.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/AbstractTestObjectLifecycleApproval.java index 3562630c56f..8998eb2fb94 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/AbstractTestObjectLifecycleApproval.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/AbstractTestObjectLifecycleApproval.java @@ -94,7 +94,7 @@ public void test010CreateRolePirate() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); RoleType pirate = new RoleType(prismContext); pirate.setName(PolyStringType.fromOrig("pirate")); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/TestObjectLifecycleAdvanced.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/TestObjectLifecycleAdvanced.java index f1d95e13ee2..ddb7fd9135c 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/TestObjectLifecycleAdvanced.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/TestObjectLifecycleAdvanced.java @@ -87,7 +87,7 @@ public void test010CreateRoleEmployee() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject employee = prismContext.parseObject(ROLE_EMPLOYEE_FILE); executeTest(null, new TestDetails() { @@ -169,7 +169,7 @@ public void test020ActivateIncompleteRole() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); @SuppressWarnings({ "raw"}) ObjectDelta activateRoleDelta = prismContext.deltaFor(RoleType.class) @@ -203,7 +203,7 @@ public void test030ActivateIncompleteRoleAgain() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); @SuppressWarnings({ "raw"}) ObjectDelta activateRoleDelta = prismContext.deltaFor(RoleType.class) @@ -235,7 +235,7 @@ public void test040AddApprover() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assignRole(userEmployeeOwnerOid, roleEmployeeOid, SchemaConstants.ORG_APPROVER, task, result); result.computeStatus(); @@ -248,7 +248,7 @@ public void test045ActivateCompleteRole() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); @SuppressWarnings({ "raw"}) ObjectDelta activateRoleDelta = prismContext.deltaFor(RoleType.class) diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/TestObjectLifecycleApprovalGlobal.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/TestObjectLifecycleApprovalGlobal.java index 3d850e2f130..fda48aa143a 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/TestObjectLifecycleApprovalGlobal.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/TestObjectLifecycleApprovalGlobal.java @@ -75,7 +75,7 @@ public void test500CreateRoleJudge() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); RoleType judge = new RoleType(prismContext) .name("judge") diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/ManualResourceTest.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/ManualResourceTest.java index 2178349ac0f..c5f514b3183 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/ManualResourceTest.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/ManualResourceTest.java @@ -126,7 +126,7 @@ private PrismObject createUserWill() throws SchemaException { @Test public void test000Sanity() throws Exception { - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); ResourceType repoResource = repositoryService.getObject(ResourceType.class, RESOURCE_MANUAL_OID, null, result).asObjectable(); @@ -167,7 +167,7 @@ public void test012TestConnection() throws Exception { public void test100AssignWillRoleOne() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); dummyTransport.clearMessages(); @@ -198,7 +198,7 @@ public void test100AssignWillRoleOne() throws Exception { public void test110CloseCaseAndRecomputeWill() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); dummyTransport.clearMessages(); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestDelegation.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestDelegation.java index 87455061b2a..aec8874cfa1 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestDelegation.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestDelegation.java @@ -76,7 +76,7 @@ public void test100CreateTask() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assignRole(userJackOid, ROLE_PRINCE_OID, task, result); // should start approval process assertNotAssignedRole(userJackOid, ROLE_PRINCE_OID, task, result); @@ -96,7 +96,7 @@ public void test110DelegateToGirthUnauthorized() throws Exception { login(getUserFromRepo(USER_KEEN_OID)); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); try { WorkItemDelegationRequestType request = new WorkItemDelegationRequestType(prismContext) @@ -117,7 +117,7 @@ public void test120DelegateToGirth() throws Exception { login(getUserFromRepo(USER_LONGSHANKS_OID)); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); WorkItemDelegationRequestType request = new WorkItemDelegationRequestType(prismContext) .delegate(ort(USER_GIRTH_OID)) @@ -149,7 +149,7 @@ public void test130DelegateToKeenByReplace() throws Exception { login(getUserFromRepo(USER_LONGSHANKS_OID)); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); WorkItemDelegationRequestType request = new WorkItemDelegationRequestType(prismContext) .delegate(ort(USER_KEEN_OID)) @@ -178,7 +178,7 @@ public void test140DelegateToNoneByReplace() throws Exception { login(getUserFromRepo(USER_KEEN_OID)); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); WorkItemDelegationRequestType request = new WorkItemDelegationRequestType(prismContext) .method(REPLACE_ASSIGNEES); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestEscalation.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestEscalation.java index c61c6b2aa22..1e2a876d6c5 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestEscalation.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestEscalation.java @@ -90,7 +90,7 @@ public void test100CreateE1ApprovalCase() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assignRole(userJackOid, ROLE_E1_OID, task, result); // should start approval process assertNotAssignedRole(userJackOid, ROLE_E1_OID, task, result); @@ -118,7 +118,7 @@ public void test110NotifyAfter5Days() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); clock.overrideDuration("P5DT1H"); // at P5D there's a notify action waitForTaskNextRun(TASK_TRIGGER_SCANNER_OID, true, 20000, true); @@ -140,7 +140,7 @@ public void test120EscalateAfter12Days() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); clock.resetOverride(); clock.overrideDuration("P12DT1H"); // at -P2D (i.e. P12D) there is a delegate action @@ -162,7 +162,7 @@ public void test130CompleteAfter14Days() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); clock.resetOverride(); clock.overrideDuration("P14DT1H"); // at 0 (i.e. P14D) there is a delegate action @@ -184,7 +184,7 @@ public void test200CreateE2ApprovalCase() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); clock.resetOverride(); resetTriggerTask(TASK_TRIGGER_SCANNER_OID, TASK_TRIGGER_SCANNER_FILE, result); @@ -213,7 +213,7 @@ public void test210EscalateAfter3Days() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); dummyTransport.clearMessages(); @@ -246,7 +246,7 @@ public void test220Reject() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); dummyTransport.clearMessages(); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestEvents.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestEvents.java index 20d0089e4f4..2e37b68a388 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestEvents.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestEvents.java @@ -58,7 +58,7 @@ public void test100CreateTask() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assignRole(userJackOid, roleNoApproversOid, task, result); // should start approval process assertNotAssignedRole(userJackOid, roleNoApproversOid, task, result); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestMiscellaneous.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestMiscellaneous.java index b88911f0019..97abbe1e517 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestMiscellaneous.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestMiscellaneous.java @@ -103,7 +103,7 @@ public void test100RequesterComment() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -168,7 +168,7 @@ public void test105RequesterCommentImmediate() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -235,7 +235,7 @@ public void test110RequestPrunedRole() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -273,7 +273,7 @@ public void test200GetRoleByTemplate() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // GIVEN setDefaultUserTemplate(TEMPLATE_ASSIGNING_CAPTAIN_OID); @@ -296,7 +296,7 @@ public void test210GetRoleByTemplateAfterAssignments() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // GIVEN setDefaultUserTemplate(TEMPLATE_ASSIGNING_CAPTAIN_AFTER_OID); @@ -320,7 +320,7 @@ public void test220GetRoleByFocusMappings() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // GIVEN setDefaultUserTemplate(null); @@ -342,7 +342,7 @@ public void test250SkippingApprovals() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // GIVEN setDefaultUserTemplate(null); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestParallelApprovals.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestParallelApprovals.java index 2cd88368d46..9ae8b938a53 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestParallelApprovals.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestParallelApprovals.java @@ -118,7 +118,7 @@ public void test100ParallelApprovals() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN when(); @@ -166,7 +166,7 @@ public void test110ParallelApprovalsAdd() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); if (listener != null) { taskManager.unregisterTaskListener(listener); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestSoD.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestSoD.java index c1e72112817..36f5c215b22 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestSoD.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestSoD.java @@ -81,7 +81,7 @@ public void test010AssignRoleJudge() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN assignRole(userJackOid, roleJudgeOid, task, result); @@ -99,7 +99,7 @@ public void test020AssignRolePirate() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); PrismObject jack = getUser(userJackOid); String originalDescription = jack.asObjectable().getDescription(); @@ -213,7 +213,7 @@ public void test030AssignRoleRespectable() throws Exception { login(userAdministrator); Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // GIVEN unassignRole(userJackOid, rolePirateOid, task, result); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorDiscovery.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorDiscovery.java index 4879e39b057..d35c3548e34 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorDiscovery.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorDiscovery.java @@ -73,7 +73,7 @@ public void test001Connectors() throws Exception { @Test public void testListConnectors() throws Exception { - OperationResult result = createResult(); + OperationResult result = createOperationalResult(); List> connectors = provisioningService.searchObjects(ConnectorType.class, null, null, null, result); assertNotNull(connectors); @@ -101,7 +101,7 @@ public void testSearchConnectorSimple() throws SchemaException { @Test public void testSearchConnectorAnd() throws SchemaException { - OperationResult result = createResult(); + OperationResult result = createOperationalResult(); ObjectQuery query = prismContext.queryFor(ConnectorType.class) .item(SchemaConstants.C_CONNECTOR_FRAMEWORK).eq(SchemaConstants.ICF_FRAMEWORK_URI) diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestDBTable.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestDBTable.java index 0d1d386b9c8..bda2790957b 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestDBTable.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestDBTable.java @@ -11,7 +11,6 @@ import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.provisioning.api.ProvisioningService; -import com.evolveum.midpoint.provisioning.impl.mock.SynchronizationServiceMock; import com.evolveum.midpoint.schema.CapabilityUtil; import com.evolveum.midpoint.schema.internals.InternalsConfig; import com.evolveum.midpoint.schema.result.OperationResult; @@ -99,7 +98,7 @@ public static void stopDb() throws Exception { @Test public void test000Integrity() throws ObjectNotFoundException, SchemaException { - OperationResult result = createResult(); + OperationResult result = createOperationalResult(); ResourceType resource = repositoryService.getObject(ResourceType.class, RESOURCE_DERBY_OID, null, result).asObjectable(); String connectorOid = resource.getConnectorRef().getOid(); @@ -134,7 +133,7 @@ public void test001Connection() throws Exception { @Test public void test002AddAccount() throws Exception { // GIVEN - OperationResult result = createResult(); + OperationResult result = createOperationalResult(); ShadowType account = parseObjectType(ACCOUNT_WILL_FILE, ShadowType.class); @@ -180,7 +179,7 @@ public void test002AddAccount() throws Exception { @Test(enabled=false) public void test005GetAccount() throws Exception { // GIVEN - OperationResult result = createResult(); + OperationResult result = createOperationalResult(); Task task = taskManager.createTaskInstance(); // WHEN diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/async/TestAsyncUpdate.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/async/TestAsyncUpdate.java index 6826f485cf6..4504afa7469 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/async/TestAsyncUpdate.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/async/TestAsyncUpdate.java @@ -118,7 +118,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assertNotNull("Resource is null", resource); ResourceType repoResource = repositoryService.getObject(ResourceType.class, RESOURCE_ASYNC_OID, null, result).asObjectable(); @@ -137,7 +137,7 @@ public void test000Sanity() throws Exception { @Test public void test003Connection() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // Check that there is a schema, but no capabilities before test (pre-condition) ResourceType resourceBefore = repositoryService.getObject(ResourceType.class, RESOURCE_ASYNC_OID, @@ -183,7 +183,7 @@ public void test003Connection() throws Exception { @Test public void test004Configuration() throws Exception { - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN resource = provisioningService.getObject(ResourceType.class, RESOURCE_ASYNC_OID, null, null, result); @@ -224,7 +224,7 @@ public void test005ParsedSchema() throws Exception { @Test public void test100ListeningForShadowAdd() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -256,7 +256,7 @@ public void test100ListeningForShadowAdd() throws Exception { @Test public void test110ListeningForValueAdd() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); prepareMessage(CHANGE_110); @@ -294,7 +294,7 @@ public void test110ListeningForValueAdd() throws Exception { @Test public void test112ListeningForValueAddMore() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); prepareMessage(CHANGE_112); @@ -332,7 +332,7 @@ public void test112ListeningForValueAddMore() throws Exception { @Test // MID-5832 public void test115ListeningForValueDelete() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); prepareMessage(CHANGE_115); @@ -370,7 +370,7 @@ public void test115ListeningForValueDelete() throws Exception { @Test // MID-5832 public void test117ListeningForValueReplace() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); prepareMessage(CHANGE_117); @@ -408,7 +408,7 @@ public void test117ListeningForValueReplace() throws Exception { @Test public void test120ListeningForShadowReplace() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); prepareMessage(CHANGE_120); @@ -435,7 +435,7 @@ public void test120ListeningForShadowReplace() throws Exception { @Test public void test125ListeningForNotificationOnly() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); if (!hasReadCapability()) { System.out.println("Skipping this test because there's no real read capability"); @@ -469,7 +469,7 @@ public void test125ListeningForNotificationOnly() throws Exception { @Test public void test130ListeningForShadowDelete() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); prepareMessage(CHANGE_130); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/AbstractCsvTest.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/AbstractCsvTest.java index 59fe76b1756..b9c3d2b2fbb 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/AbstractCsvTest.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/AbstractCsvTest.java @@ -101,7 +101,7 @@ public void test000Integrity() throws Exception { assertNotNull("Resource is null", resource); assertNotNull("ResourceType is null", resourceType); - OperationResult result = createResult(); + OperationResult result = createOperationalResult(); ResourceType resource = repositoryService.getObject(ResourceType.class, getResourceOid(), null, result).asObjectable(); @@ -231,7 +231,7 @@ public void test005ParsedSchema() throws Exception { @Test public void test006Capabilities() throws Exception { // GIVEN - OperationResult result = createResult(); + OperationResult result = createOperationalResult(); // WHEN ResourceType resource = provisioningService.getObject(ResourceType.class, getResourceOid(), null, null, result).asObjectable(); 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 7757f9fff87..d7b61005b2c 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 @@ -116,7 +116,7 @@ public void test000Integrity() throws Exception { assertNotNull("Resource is null", resource); assertNotNull("ResourceType is null", resourceType); - OperationResult result = createResult(); + OperationResult result = createOperationalResult(); ResourceType resource = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, result) .asObjectable(); @@ -140,7 +140,7 @@ public void test000Integrity() throws Exception { @Test public void test010ListConnectors() throws Exception { // GIVEN - OperationResult result = createResult(); + OperationResult result = createOperationalResult(); // WHEN List> connectors = repositoryService.searchObjects(ConnectorType.class, @@ -186,7 +186,7 @@ public void test010ListConnectors() throws Exception { @Test public void test012ConnectorRediscovery() { given(); - OperationResult result = createResult(); + OperationResult result = createOperationalResult(); when(); Set discoverLocalConnectors = connectorManager.discoverLocalConnectors(result); @@ -354,7 +354,7 @@ protected void assertResourceAfterTest() { @Test public void test021Configuration() throws Exception { given(); - OperationResult result = createResult(); + OperationResult result = createOperationalResult(); when(); resource = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, null, result); @@ -534,7 +534,7 @@ public void test024ParsedSchemaAgain() throws Exception { @Test public void test028Capabilities() throws Exception { given(); - OperationResult result = createResult(); + OperationResult result = createOperationalResult(); when(); PrismObject resource = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, null, result); @@ -664,7 +664,7 @@ protected void assertNativeCredentialsCapability(CredentialsCapabilityType capCr @Test public void test029CapabilitiesRepo() throws Exception { // GIVEN - OperationResult result = createResult(); + OperationResult result = createOperationalResult(); // WHEN PrismObject resource = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, result); @@ -763,7 +763,7 @@ public void test030ResourceAndConnectorCachingTestConnection() throws Exception @Test public void test032ResourceAndConnectorCaching() throws Exception { // GIVEN - OperationResult result = createResult(); + OperationResult result = createOperationalResult(); ConnectorInstance configuredConnectorInstance = resourceManager.getConfiguredConnectorInstance( resource, ReadCapabilityType.class, false, result); assertNotNull("No configuredConnectorInstance", configuredConnectorInstance); @@ -821,7 +821,7 @@ public void test032ResourceAndConnectorCaching() throws Exception { assertTrue("Connector instance was not cached", configuredConnectorInstance == configuredConnectorInstanceAgain); // Check if the connector still works. - OperationResult testResult = createResult("test"); + OperationResult testResult = createOperationalResult("test"); configuredConnectorInstanceAgain.test(testResult); testResult.computeStatus(); TestUtil.assertSuccess("Connector test failed", testResult); @@ -877,7 +877,7 @@ public void test034ResourceAndConnectorCachingForceFresh() throws Exception { assertTrue("Connector instance was changed", configuredConnectorInstance == configuredConnectorInstanceAgain); // Check if the connector still works - OperationResult testResult = createResult("test"); + OperationResult testResult = createOperationalResult("test"); configuredConnectorInstanceAgain.test(testResult); testResult.computeStatus(); TestUtil.assertSuccess("Connector test failed", testResult); @@ -1222,7 +1222,7 @@ protected void checkRepoAccountShadowWill(PrismObject accountRepo, X @Test public void test102GetAccount() throws Exception { // GIVEN - OperationResult result = createResult(); + OperationResult result = createOperationalResult(); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); @@ -1260,7 +1260,7 @@ public void test102GetAccount() throws Exception { @Test public void test103GetAccountNoFetch() throws Exception { // GIVEN - OperationResult result = createResult(); + OperationResult result = createOperationalResult(); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); GetOperationOptions rootOptions = new GetOperationOptions(); @@ -1321,7 +1321,7 @@ public void test105ApplyDefinitionModifyDelta() throws Exception { @Test public void test106GetModifiedAccount() throws Exception { // GIVEN - OperationResult result = createResult(); + OperationResult result = createOperationalResult(); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); DummyAccount accountWill = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummy.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummy.java index d744cae6d98..27545cf345d 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummy.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummy.java @@ -2169,7 +2169,7 @@ private SearchResultMetadata testSeachIterative( ObjectFilter attrFilter, GetOperationOptions rootOptions, final boolean fullShadow, boolean useObjectClassFilter, final boolean useRepo, String... expectedAccountNames) throws Exception { - OperationResult result = createResult(); + OperationResult result = createOperationalResult(); ObjectQuery query; if (useObjectClassFilter) { diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyNegative.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyNegative.java index d75acc9e32e..7a56e106dd7 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyNegative.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyNegative.java @@ -65,7 +65,7 @@ public void test113GetResourceBrokenSchemaRuntime() throws Exception { public void testGetResourceBrokenSchema(BreakMode breakMode) throws Exception { // GIVEN - OperationResult result = createResult(); + OperationResult result = createOperationalResult(); // precondition PrismObject repoResource = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, result); @@ -150,7 +150,7 @@ public void test200AddAccountNullAttributes() throws Exception { public void test201AddAccountEmptyAttributes() throws Exception { // GIVEN Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); syncServiceMock.reset(); ShadowType accountType = parseObjectType(ACCOUNT_WILL_FILE, ShadowType.class); @@ -178,7 +178,7 @@ public void test201AddAccountEmptyAttributes() throws Exception { public void test210AddAccountNoObjectclass() throws Exception { // GIVEN Task task =getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); syncServiceMock.reset(); ShadowType accountType = parseObjectType(ACCOUNT_WILL_FILE, ShadowType.class); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySchemaless.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySchemaless.java index 9776c3ffeb7..c5058f036eb 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySchemaless.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySchemaless.java @@ -236,7 +236,7 @@ public void test005ParsedSchemaSchemaless() throws Exception { @Test public void test006GetObjectSchemaless() throws Exception { // GIVEN - OperationResult result = createResult(); + OperationResult result = createOperationalResult(); PrismObject resource = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_NO_SCHEMA_OID, null, null, result); assertNotNull("Resource is null", resource); ResourceType resourceType = resource.asObjectable(); @@ -547,7 +547,7 @@ public void test105ParsedSchemaStaticSchema() throws Exception { @Test public void test106GetObjectStaticSchema() throws Exception { // GIVEN - OperationResult result = createResult(); + OperationResult result = createOperationalResult(); PrismObject resource = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_STATIC_SCHEMA_OID, null, null, result); assertNotNull("Resource is null", resource); @@ -734,7 +734,7 @@ public void test107Capabilities() throws Exception { @Test public void test200AddAccount() throws Exception { // GIVEN - OperationResult result = createResult(); + OperationResult result = createOperationalResult(); ShadowType account = parseObjectType(ACCOUNT_WILL_FILE, ShadowType.class); account.asPrismObject().checkConsistence(); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySecurity.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySecurity.java index fd2efbd2ff7..d9a6e47601e 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySecurity.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySecurity.java @@ -53,7 +53,7 @@ public class TestDummySecurity extends AbstractDummyTest { public void test100AddAccountDrink() throws Exception { // GIVEN Task syncTask = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); syncServiceMock.reset(); PrismObject account = prismContext.parseObject(ACCOUNT_WILL_FILE); @@ -86,7 +86,7 @@ private void setAttribute(PrismObject account, String attrName, public void test199AddAccount() throws Exception { // GIVEN Task syncTask = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); syncServiceMock.reset(); PrismObject account = prismContext.parseObject(ACCOUNT_WILL_FILE); @@ -198,7 +198,7 @@ public void test210ModifyAccountQuote() throws Exception { @Test public void test300GetAccount() throws Exception { // GIVEN - OperationResult result = createResult(); + OperationResult result = createOperationalResult(); // WHEN PrismObject shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, null, result); @@ -220,7 +220,7 @@ public void test300GetAccount() throws Exception { @Test public void test310SearchAllShadows() throws Exception { // GIVEN - OperationResult result = createResult(); + OperationResult result = createOperationalResult(); ObjectQuery query = IntegrationTestTools.createAllShadowsQuery(resourceType, SchemaTestConstants.ICF_ACCOUNT_OBJECT_CLASS_LOCAL_NAME, prismContext); display("All shadows query", query); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/manual/AbstractManualResourceTest.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/manual/AbstractManualResourceTest.java index 3e7d4c05d47..9e54daa18f9 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/manual/AbstractManualResourceTest.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/manual/AbstractManualResourceTest.java @@ -55,8 +55,6 @@ import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.asserter.ShadowAsserter; import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.CachingMetadataType; import com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilitiesType; @@ -162,7 +160,7 @@ public void test000Sanity() throws Exception { assertNotNull("Resource is null", resource); assertNotNull("ResourceType is null", resourceType); - OperationResult result = createResult(); + OperationResult result = createOperationalResult(); ResourceType repoResource = repositoryService.getObject(ResourceType.class, getResourceOid(), null, result).asObjectable(); @@ -232,7 +230,7 @@ public void test003Connection() throws Exception { @Test public void test004Configuration() throws Exception { // GIVEN - OperationResult result = createResult(); + OperationResult result = createOperationalResult(); // WHEN resource = provisioningService.getObject(ResourceType.class, getResourceOid(), null, null, result); @@ -301,7 +299,7 @@ protected int getNumberOfAccountAttributeDefinitions() { @Test public void test006Capabilities() throws Exception { // GIVEN - OperationResult result = createResult(); + OperationResult result = createOperationalResult(); // WHEN ResourceType resource = provisioningService.getObject(ResourceType.class, getResourceOid(), null, null, result).asObjectable(); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjNegative.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjNegative.java index 5747529310d..6fe75b0d8a7 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjNegative.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjNegative.java @@ -138,7 +138,7 @@ public void test003Connection() throws Exception { @Test public void test004ResourceAndConnectorCaching() throws Exception { - OperationResult result = createResult(); + OperationResult result = createOperationalResult(); Task task = createPlainTask(); // WHEN // This should NOT throw an exception. It should just indicate the failure in results diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestSynchronization.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestSynchronization.java index 459461e6b42..5768e2a8d90 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestSynchronization.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestSynchronization.java @@ -102,7 +102,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test010Sanity() throws Exception { - final OperationResult result = createResult(); + final OperationResult result = createOperationalResult(); // WHEN PrismObject resource = provisioningService.getObject(ResourceType.class, resourceType.getOid(), null, taskManager.createTaskInstance(), result); @@ -126,7 +126,7 @@ public void test010Sanity() throws Exception { @Test public void test100SyncAddWill() throws Exception { - final OperationResult result = createResult(); + final OperationResult result = createOperationalResult(); Task syncTask = taskManager.getTask(SYNC_TASK_OID, result); AssertJUnit.assertNotNull(syncTask); @@ -185,7 +185,7 @@ public void test100SyncAddWill() throws Exception { @Test public void test500SyncAddProtected() throws Exception { - final OperationResult result = createResult(); + final OperationResult result = createOperationalResult(); Task syncTask = taskManager.getTask(SYNC_TASK_OID, result); AssertJUnit.assertNotNull(syncTask); 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 6e8f0d44cbb..d28d4c26ad3 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 @@ -101,7 +101,6 @@ import com.evolveum.midpoint.test.asserter.AbstractAsserter; import com.evolveum.midpoint.test.asserter.ResourceAsserter; import com.evolveum.midpoint.test.asserter.ShadowAsserter; -import com.evolveum.midpoint.test.asserter.UserAsserter; import com.evolveum.midpoint.test.asserter.prism.PolyStringAsserter; import com.evolveum.midpoint.test.asserter.prism.PrismObjectAsserter; import com.evolveum.midpoint.test.asserter.refinedschema.RefinedResourceSchemaAsserter; @@ -255,6 +254,7 @@ public void startTestContext(ITestResult testResult) { Task task = createTask(testMethodName); // TODO inttest do we need that subresult? :-) (Virgo's brave new world) + // If this exist for some "optional richer tracing", why not switch it on with some System property? // maybe it doesn't break tests, but changes traceability/maintenance? // OperationResult rootResult = task.getResult(); // TracingProfileType tracingProfile = getTestMethodTracingProfile(); @@ -344,18 +344,21 @@ protected Task getTestTask() { * {@link #createSubresult(String)} should suffice. */ protected Task createPlainTask(String operationName) { - return taskManager.createTaskInstance(contextName() + "." + operationName); + String rootOpName = operationName != null + ? contextName() + "." + operationName + : contextName(); + return taskManager.createTaskInstance(rootOpName); } /** * Creates new {@link Task} with {@link #contextName()} as root operation name. */ protected Task createPlainTask() { - return taskManager.createTaskInstance(contextName()); + return createPlainTask(null); } /** - * Just like {@link #createPlainTask} but also calls overridable {@link #customizeTask}. + * Just like {@link #createPlainTask(String)} but also calls overridable {@link #customizeTask}. */ protected Task createTask(String operationName) { Task task = createPlainTask(operationName); @@ -363,6 +366,14 @@ protected Task createTask(String operationName) { return task; } + /** + * Just like {@link #createPlainTask()} but also calls overridable {@link #customizeTask}. + */ + protected Task createTask() { + return createPlainTask(null); + } + + /** * Subclasses may override this if test task needs additional customization. * Each task used or created by the test is customized - this applies to default @@ -386,20 +397,20 @@ public String getTestNameShort() { * Creates new subresult for default pre-created test-method-scoped {@link Task}. */ protected OperationResult createSubresult(String subresultSuffix) { - return getTestResult().createSubresult(getTestNameShort() + "." + subresultSuffix); + return getTestOperationResult().createSubresult(getTestNameShort() + "." + subresultSuffix); } /** * Creates new {@link OperationResult} with name equal to {@link #contextName()}. */ - protected OperationResult createResult() { + protected OperationResult createOperationalResult() { return new OperationResult(contextName()); } /** * Creates new {@link OperationResult} with name prefixed by {@link #contextName()}. */ - protected OperationResult createResult(String nameSuffix) { + protected OperationResult createOperationalResult(String nameSuffix) { return new OperationResult(contextName() + "." + nameSuffix); } @@ -408,7 +419,7 @@ protected OperationResult createResult(String nameSuffix) { * This result can be freely used in test for some "main scope", it is not asserted in any * after method, only displayed. */ - protected OperationResult getTestResult() { + protected OperationResult getTestOperationResult() { return MidpointTestMethodContext.get().getResult(); } diff --git a/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java b/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java index b3d1da1607f..4883c30a18a 100644 --- a/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java +++ b/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java @@ -21,7 +21,6 @@ import static org.testng.AssertJUnit.assertTrue; import java.io.File; -import java.io.FileNotFoundException; import java.io.IOException; import java.sql.ResultSet; import java.sql.SQLException; @@ -3649,7 +3648,7 @@ public void test480ListResources() throws Exception { public void test485ListResourcesWithBrokenResource() throws Exception { // GIVEN Task task = getTestTask(); - final OperationResult result = getTestResult(); + final OperationResult result = getTestOperationResult(); // WHEN List> resources = modelService.searchObjects(ResourceType.class, null, null, task, result); @@ -3745,7 +3744,7 @@ public void test500NotifyChangeCreateAccount() throws Exception{ public void test501NotifyChangeModifyAccount() throws Exception{ final String TEST_NAME = "test501NotifyChangeModifyAccount"; - OperationResult parentResult = createResult(); + OperationResult parentResult = createOperationalResult(); PrismObject userAngelika = findUserByUsername(ANGELIKA_NAME); assertNotNull("User with the name angelika must exist.", userAngelika); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConsistencyMechanism.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConsistencyMechanism.java index 515a3e934c3..fb2e5e990c5 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConsistencyMechanism.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConsistencyMechanism.java @@ -732,7 +732,7 @@ public void test124AddAccountDirectAlreadyExists() throws Exception { @Test public void test130DeleteObjectNotFound() throws Exception { final String TEST_NAME = "test130DeleteObjectNotFound"; - OperationResult parentResult = createResult(); + OperationResult parentResult = createOperationalResult(); repoAddShadowFromFile(ACCOUNT_GUYBRUSH_FILE, parentResult); repoAddObjectFromFile(USER_GUYBRUSH_FILENAME, parentResult); @@ -852,7 +852,7 @@ public void test142ModifyObjectNotFoundAssignedAccount() throws Exception { final String TEST_NAME = "test142ModifyObjectNotFoundAssignedAccountq"; // GIVEN - OperationResult parentResult = createResult(); + OperationResult parentResult = createOperationalResult(); repoAddShadowFromFile(ACCOUNT_GUYBRUSH_MODIFY_DELETE_FILE, parentResult); repoAddObjectFromFile(USER_GUYBRUSH_NOT_FOUND_FILENAME, parentResult); @@ -914,7 +914,7 @@ public void test144GetObjectNotFoundAssignedAccount() throws Exception { final String TEST_NAME = "test144GetObjectNotFoundAssignedAccount"; // GIVEN - OperationResult parentResult = createResult(); + OperationResult parentResult = createOperationalResult(); repoAddShadowFromFile(ACCOUNT_HECTOR_FILE, parentResult); repoAddObjectFromFile(USER_HECTOR_NOT_FOUND_FILENAME, parentResult); @@ -1225,7 +1225,7 @@ public void test214ModifyObjectCommunicationProblem() throws Exception { // GIVEN openDJController.assumeStopped(); - OperationResult parentResult = createResult(); + OperationResult parentResult = createOperationalResult(); String accountOid = assertUserOneAccountRef(USER_JACK_OID); @@ -1339,7 +1339,7 @@ public void test230GetAccountCommunicationProblem() throws Exception { // GIVEN openDJController.assumeStopped(); - OperationResult result = createResult(); + OperationResult result = createOperationalResult(); ShadowType account = modelService.getObject(ShadowType.class, ACCOUNT_DENIELS_OID, null, null, result).asObjectable(); @@ -1374,7 +1374,7 @@ public void test240AddObjectCommunicationProblemAlreadyExists() throws Exception // GIVEN openDJController.assumeRunning(); - OperationResult parentResult = createResult(); + OperationResult parentResult = createOperationalResult(); Entry entry = openDJController.addEntryFromLdifFile(LDIF_ELAINE_FILE); Entry searchResult = openDJController.searchByUid("elaine"); @@ -1447,7 +1447,7 @@ public void test250ModifyFocusCommunicationProblem() throws Exception { // GIVEN openDJController.assumeStopped(); - OperationResult parentResult = createResult(); + OperationResult parentResult = createOperationalResult(); assertUser(USER_JACK_OID, "User before") .assertLinks(1); @@ -1530,7 +1530,7 @@ public void test251ModifyFocusCommunicationProblemSecondTime() throws Exception // GIVEN openDJController.assumeStopped(); - OperationResult parentResult = createResult(); + OperationResult parentResult = createOperationalResult(); assertUser(USER_JACKIE_OID, "User before") .assertLinks(1) @@ -1646,7 +1646,7 @@ public void test260GetDiscoveryAddCommunicationProblem() throws Exception { // GIVEN openDJController.assumeStopped(); display("OpenDJ stopped"); - OperationResult parentResult = createResult(); + OperationResult parentResult = createOperationalResult(); repoAddObjectFromFile(USER_ANGELIKA_FILENAME, parentResult); @@ -1968,7 +1968,7 @@ public void test270ModifyDiscoveryAddCommunicationProblem() throws Exception { // GIVEN openDJController.assumeStopped(); - OperationResult parentResult = createResult(); + OperationResult parentResult = createOperationalResult(); // WHEN repoAddObjectFromFile(USER_BOB_NO_GIVEN_NAME_FILENAME, parentResult); @@ -2023,7 +2023,7 @@ public void test280ModifyObjectCommunicationProblemWeakMapping() throws Exceptio // GIVEN openDJController.assumeRunning(); - OperationResult parentResult = createResult(); + OperationResult parentResult = createOperationalResult(); repoAddObjectFromFile(USER_JOHN_WEAK_FILENAME, parentResult); assertUser(USER_JOHN_WEAK_OID, "User before") @@ -2072,7 +2072,7 @@ public void test282ModifyObjectCommunicationProblemWeakAndStrongMapping() throws // GIVEN openDJController.assumeRunning(); - OperationResult parentResult = createResult(); + OperationResult parentResult = createOperationalResult(); repoAddObjectFromFile(USER_DONALD_FILENAME, parentResult); @@ -2139,7 +2139,7 @@ public void test283GetObjectNoFetchShadowAndRecompute() throws Exception { // GIVEN openDJController.assumeRunning(); - OperationResult parentResult = createResult(); + OperationResult parentResult = createOperationalResult(); assertUser(USER_DONALD_OID, "User before") .assertLinks(1); @@ -2176,7 +2176,7 @@ public void test283GetObjectNoFetchShadowAndRecompute() throws Exception { public void test284ModifyObjectAssignToGroupCommunicationProblem() throws Exception { final String TEST_NAME = "test284ModifyObjectAssignToGroupCommunicationProblem"; Task task = taskManager.createTaskInstance(); - OperationResult parentResult = createResult(); + OperationResult parentResult = createOperationalResult(); // GIVEN openDJController.addEntriesFromLdifFile(LDIF_CREATE_ADMINS_GROUP_FILE); @@ -2251,7 +2251,7 @@ public void test400GetDiscoveryAddCommunicationProblemAlreadyExists() throws Exc // GIVEN openDJController.assumeStopped(); - OperationResult parentResult = createResult(); + OperationResult parentResult = createOperationalResult(); repoAddObjectFromFile(USER_DISCOVERY_FILENAME, parentResult); @@ -2625,7 +2625,7 @@ public void test601GetDiscoveryModifyCommunicationProblemDirectAccount() throws String TEST_NAME = "test601GetDiscoveryModifyCommunicationProblemDirectAccount"; openDJController.assumeRunning(); - OperationResult parentResult = createResult(); + OperationResult parentResult = createOperationalResult(); //prepare user repoAddObjectFromFile(USER_ALICE_FILENAME, parentResult); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelivery.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelivery.java index e06f4483a81..7e11f84bc55 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelivery.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelivery.java @@ -174,7 +174,7 @@ protected PrismObject getDefaultActor() { @Test public void test100Assign_IT_2_failure() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); try { assignRole(userBobOid, roleIt2Oid, task, result); // hard constraint @@ -187,7 +187,7 @@ public void test100Assign_IT_2_failure() throws Exception { @Test public void test110Assign_IT_2_success() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assignRole(userBarkeeperOid, roleIt2Oid, task, result); // hard constraint result.computeStatus(); @@ -199,7 +199,7 @@ public void test110Assign_IT_2_success() throws Exception { @Test public void test120Assign_IT_1() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assignRole(userBobOid, roleIt1Oid, task, result); // approval constraint @@ -225,7 +225,7 @@ public void test120Assign_IT_1() throws Exception { @Test public void test130Assign_IT_3() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assignRole(userCarlaOid, roleIt3Oid, task, result); // two approval constraints @@ -260,7 +260,7 @@ public void test130Assign_IT_3() throws Exception { @Test public void test140Assign_IT_4() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assignRole(userBarkeeperOid, roleIt4Oid, task, result); // approval constraint @@ -286,7 +286,7 @@ public void test140Assign_IT_4() throws Exception { @Test public void test150Assign_IT_5() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); assignRole(userBarkeeperOid, roleIt5Oid, task, result); // approval constraint diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLargeGroups.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLargeGroups.java index ccaf8a2e55d..774dd834959 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLargeGroups.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLargeGroups.java @@ -96,7 +96,7 @@ public void test000Sanity() throws Exception { @Test public void test100GetLargeGroup(ITestContext ctx) throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); final int MEMBERS = 20000; @@ -123,7 +123,7 @@ private void assert100LargeGroupSearch( throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); ResourceAttributeDefinition nameDefinition = libraryMidpointFunctions .getAttributeDefinition(resourceDummy, dummyResourceCtl.getGroupObjectClass(), SchemaConstants.ICFS_NAME); ObjectQuery query = prismContext.queryFor(ShadowType.class) diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestManyThreads.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestManyThreads.java index 31b0ee6f658..f8d69387c9b 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestManyThreads.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestManyThreads.java @@ -73,7 +73,7 @@ public void test000Sanity() throws Exception { @Test public void test100SearchResourceObjects() throws Exception { Task globalTask = getTestTask(); - OperationResult globalResult = getTestResult(); + OperationResult globalResult = getTestOperationResult(); dummyResource.addAccount(new DummyAccount("jack")); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholds.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholds.java index 3dc5e213d21..de55f4dc2c1 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholds.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholds.java @@ -102,7 +102,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test001testImportBaseUsers() throws Exception { final String TEST_NAME = "test001testImportBaseUsers"; - OperationResult result = createResult(); + OperationResult result = createOperationalResult(); importObjectFromFile(TASK_IMPORT_BASE_USERS_FILE); @@ -230,7 +230,7 @@ public void test500chageTaskPolicyRule() throws Exception { @Test public void test520changeActivationThreeAccounts() throws Exception { final String TEST_NAME = "test520changeActivationThreeAccounts"; - OperationResult result = createResult(); + OperationResult result = createOperationalResult(); //GIVEN openDJController.executeLdifChange(LDIF_CHANGE_ACTIVATION_FILE); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsReconFull.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsReconFull.java index 90d8365c2e1..05cbf895eb6 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsReconFull.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsReconFull.java @@ -87,7 +87,7 @@ public void test600chageTaskPolicyRule() throws Exception { @Test public void test610testFullRecon() throws Exception { final String TEST_NAME = "test610testFullRecon"; - OperationResult result = createResult(); + OperationResult result = createOperationalResult(); //WHEN when(); @@ -107,7 +107,7 @@ public void test610testFullRecon() throws Exception { @Test public void test611testFullRecon() throws Exception { final String TEST_NAME = "test611testFullRecon"; - OperationResult result = createResult(); + OperationResult result = createOperationalResult(); openDJController.delete("uid=user10,ou=People,dc=example,dc=com"); openDJController.delete("uid=user11,ou=People,dc=example,dc=com"); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestVillage.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestVillage.java index 29f17288224..23cc864a102 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestVillage.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestVillage.java @@ -750,7 +750,7 @@ public void test152ModifySrcAccountHermanDeleteOrg() throws Exception { public void test200CreateUserAssignOrgPwdPolicy() throws Exception { final String TEST_NAME = "test200CreateUserAssignOrgPwdPolicy"; Task task = getTestTask(); - OperationResult result = createResult(); + OperationResult result = createOperationalResult(); //prepare password policies addObject(GLOBAL_PASSWORD_POLICY_FILE); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperAsyncUpdate.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperAsyncUpdate.java index 6e43ab21c65..f20113af21c 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperAsyncUpdate.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperAsyncUpdate.java @@ -78,7 +78,7 @@ public void test000Sanity() throws Exception { @Test public void test010CreateUsers() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); addObject(USER_BANDERSON, task, result); addObject(USER_JLEWIS685, task, result); @@ -96,7 +96,7 @@ public void test010CreateUsers() throws Exception { public void test110AddAlumni() throws Exception { Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -148,7 +148,7 @@ public void test110AddAlumni() throws Exception { public void test115AddStaff() throws Exception { Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -199,7 +199,7 @@ public void test115AddStaff() throws Exception { public void test200AddAlumniForAnderson() throws Exception { Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -235,7 +235,7 @@ public void test200AddAlumniForAnderson() throws Exception { @Test public void test202RecomputeAnderson() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN @@ -265,7 +265,7 @@ public void test202RecomputeAnderson() throws Exception { public void test210AddStaffForAnderson() throws Exception { Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -296,7 +296,7 @@ public void test210AddStaffForAnderson() throws Exception { @Test public void test212RecomputeAnderson() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN @@ -329,7 +329,7 @@ public void test212RecomputeAnderson() throws Exception { public void test220AddAlumniForLewis() throws Exception { Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -360,7 +360,7 @@ public void test220AddAlumniForLewis() throws Exception { public void test221AddStaffForLewis() throws Exception { Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -391,7 +391,7 @@ public void test221AddStaffForLewis() throws Exception { @Test public void test222RecomputeLewis() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN @@ -423,7 +423,7 @@ public void test222RecomputeLewis() throws Exception { public void test230AddAlumniForNobody() throws Exception { Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -450,7 +450,7 @@ public void test230AddAlumniForNobody() throws Exception { public void test250DeleteAlumniForAnderson() throws Exception { Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -480,7 +480,7 @@ public void test250DeleteAlumniForAnderson() throws Exception { @Test public void test252RecomputeAnderson() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // WHEN @@ -510,7 +510,7 @@ public void test252RecomputeAnderson() throws Exception { public void test305RenameStaff() throws Exception { Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -568,7 +568,7 @@ public void test305RenameStaff() throws Exception { public void test310DeleteStaff() throws Exception { Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -618,7 +618,7 @@ public void test310DeleteStaff() throws Exception { @Test public void test312ScavengeGroups() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); // GIVEN diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperLargeGroupImport.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperLargeGroupImport.java index e12b5d5ab3e..51688f94489 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperLargeGroupImport.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperLargeGroupImport.java @@ -54,7 +54,7 @@ public void test000Sanity() throws Exception { @Test public void test100ImportGroups() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); task.setOwner(userAdministrator); addObject(TASK_IMPORT_GROUPS, task, result); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperLargeGroupReconciliation.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperLargeGroupReconciliation.java index 8b7d80bf8d7..f2b93f7c357 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperLargeGroupReconciliation.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperLargeGroupReconciliation.java @@ -54,7 +54,7 @@ public void test000Sanity() throws Exception { @Test public void test100ReconcileGroups() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); task.setOwner(userAdministrator); addObject(TASK_RECONCILE_GROUPS, task, result); @@ -68,7 +68,7 @@ public void test100ReconcileGroups() throws Exception { @Test public void test110ReconcileGroupsAgain() throws Exception { Task task = getTestTask(); - OperationResult result = getTestResult(); + OperationResult result = getTestOperationResult(); task.setOwner(userAdministrator); deleteGroupMember(ALUMNI_NAME, 3); From 831bcc50bcf427dda2067d834c066f5302f4c52d Mon Sep 17 00:00:00 2001 From: kate Date: Mon, 2 Mar 2020 18:04:05 +0100 Subject: [PATCH 96/97] finish processing for task page --- .../evolveum/midpoint/web/page/admin/server/PageTask.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTask.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTask.java index 34703f4dd6b..67b0533cc02 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTask.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTask.java @@ -487,7 +487,10 @@ protected Class getRestartResponsePage() { @Override public void finishProcessing(AjaxRequestTarget target, OperationResult result, boolean returningFromAsync) { - + if (!isKeepDisplayingResults()) { + showResult(result); + redirectBack(); + } } @Override From 6458413288807a4172669453497f458d8bcdb795 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Mon, 2 Mar 2020 18:34:11 +0100 Subject: [PATCH 97/97] the rest of the tests are migrated under our test abstract superclasses --- .../evolveum/midpoint/util/TestMiscUtil.java | 15 ++--- .../midpoint/util/TestReflectionUtil.java | 14 ++--- .../util/TestStringSubstitutorUtil.java | 4 +- .../test/asserter/ResourceAsserter.java | 19 +++--- .../midpoint/init/TestConfigurationLoad.java | 38 +++++------- .../quartzimpl/AbstractTaskManagerTest.java | 61 +++++++------------ .../task/quartzimpl/TestMiscellaneous.java | 41 ++++++------- 7 files changed, 78 insertions(+), 114 deletions(-) diff --git a/infra/util/src/test/java/com/evolveum/midpoint/util/TestMiscUtil.java b/infra/util/src/test/java/com/evolveum/midpoint/util/TestMiscUtil.java index 6b275a4a43b..c82d7e0edf0 100644 --- a/infra/util/src/test/java/com/evolveum/midpoint/util/TestMiscUtil.java +++ b/infra/util/src/test/java/com/evolveum/midpoint/util/TestMiscUtil.java @@ -8,6 +8,7 @@ import static org.testng.AssertJUnit.assertTrue; import static org.testng.AssertJUnit.assertEquals; + import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; @@ -16,15 +17,12 @@ import org.testng.annotations.Test; -/** - * @author semancik - * - */ -public class TestMiscUtil { +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; + +public class TestMiscUtil extends AbstractUnitTest { @Test public void testUnion() { - System.out.println("===[ testUnion ]==="); Collection a = new HashSet<>(); a.add("A1"); a.add("X"); @@ -54,7 +52,6 @@ public void testUnion() { @Test public void testUglyXsiHack1() { - System.out.println("===[ testUglyXsiHack1 ]==="); String in = " "; String out = UglyHacks.forceXsiNsDeclaration(in); assertEquals(" ", out); @@ -62,7 +59,6 @@ public void testUglyXsiHack1() { @Test public void testUglyXsiHack2() { - System.out.println("===[ testUglyXsiHack2 ]==="); String in = ""; String out = UglyHacks.forceXsiNsDeclaration(in); assertEquals("", out); @@ -70,7 +66,6 @@ public void testUglyXsiHack2() { @Test public void testUglyXsiHack3() { - System.out.println("===[ testUglyXsiHack3 ]==="); String in = ""; String out = UglyHacks.forceXsiNsDeclaration(in); assertEquals(in, out); @@ -78,8 +73,6 @@ public void testUglyXsiHack3() { @Test public void testCarthesian() { - System.out.println("===[ testCarthesian ]==="); - // GIVEN Collection> dimensions = new ArrayList<>(); Collection dim1 = new ArrayList<>(); diff --git a/infra/util/src/test/java/com/evolveum/midpoint/util/TestReflectionUtil.java b/infra/util/src/test/java/com/evolveum/midpoint/util/TestReflectionUtil.java index 527e990f544..aa678cf7cf4 100644 --- a/infra/util/src/test/java/com/evolveum/midpoint/util/TestReflectionUtil.java +++ b/infra/util/src/test/java/com/evolveum/midpoint/util/TestReflectionUtil.java @@ -15,11 +15,9 @@ import org.testng.annotations.Test; -/** - * @author semancik - * - */ -public class TestReflectionUtil { +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; + +public class TestReflectionUtil extends AbstractUnitTest { @Test public void testFindMethodByArity3() throws Exception { @@ -87,7 +85,7 @@ public void testFindMethodByArglistVararg() throws Exception { // THEN assertNotNull("No method", method); - method.invoke(library, new Object[] { new String[] {"foo", "bar", "baz"}}); + method.invoke(library, new Object[] { new String[] { "foo", "bar", "baz" } }); assertCalled(library, "v:3"); } @@ -155,9 +153,7 @@ public void testInvokeMethodByArglistCollection() throws Exception { assertCalled(library, "lc"); } - private void assertCalled(ReflectionTestFunctionLibrary library, String methodId) { - assertTrue("The method "+methodId+" was not called. Called: "+library.getCalledIds(), library.wasCalled(methodId)); + assertTrue("The method " + methodId + " was not called. Called: " + library.getCalledIds(), library.wasCalled(methodId)); } - } diff --git a/infra/util/src/test/java/com/evolveum/midpoint/util/TestStringSubstitutorUtil.java b/infra/util/src/test/java/com/evolveum/midpoint/util/TestStringSubstitutorUtil.java index e6c96c1ee54..590620ca180 100644 --- a/infra/util/src/test/java/com/evolveum/midpoint/util/TestStringSubstitutorUtil.java +++ b/infra/util/src/test/java/com/evolveum/midpoint/util/TestStringSubstitutorUtil.java @@ -6,6 +6,7 @@ */ package com.evolveum.midpoint.util; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.util.template.*; import org.testng.annotations.Test; @@ -13,11 +14,10 @@ import static org.testng.AssertJUnit.*; -public class TestStringSubstitutorUtil { +public class TestStringSubstitutorUtil extends AbstractUnitTest { @Test public void testSimpleExpand() { - System.out.println("===[ testSimpleExpand ]==="); Map map = new HashMap<>(); map.put("t1", "TEST1"); map.put("t2", "TEST2"); diff --git a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/ResourceAsserter.java b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/ResourceAsserter.java index 52e83703e06..257403dda09 100644 --- a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/ResourceAsserter.java +++ b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/ResourceAsserter.java @@ -6,6 +6,12 @@ */ package com.evolveum.midpoint.test.asserter; +import static org.testng.AssertJUnit.assertNotNull; + +import static com.evolveum.midpoint.prism.Containerable.asPrismContainerValue; + +import org.w3c.dom.Element; + import com.evolveum.midpoint.prism.PrismContainer; import com.evolveum.midpoint.prism.PrismContainerValue; import com.evolveum.midpoint.prism.PrismObject; @@ -16,16 +22,11 @@ import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationalStateType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import org.w3c.dom.Element; - -import static com.evolveum.midpoint.prism.Containerable.asPrismContainerValue; - -import static org.testng.AssertJUnit.assertNotNull; /** * @author Radovan Semancik */ -public class ResourceAsserter extends PrismObjectAsserter { +public class ResourceAsserter extends PrismObjectAsserter { public ResourceAsserter(PrismObject resource) { super(resource); @@ -85,11 +86,10 @@ public ResourceAsserter assertActiveLifecycleState() { public ResourceAsserter assertHasSchema() { Element schemaElement = ResourceTypeUtil.getResourceXsdSchema(getObject()); - assertNotNull("No schema in "+desc(), schemaElement); + assertNotNull("No schema in " + desc(), schemaElement); return this; } - @Override public ResourceAsserter display() { super.display(); @@ -135,7 +135,8 @@ public PrismContainerValueAsserter> o } public PrismContainerAsserter> operationalStateHistory() { - PrismContainer operationalStateHistory = getObject().findContainer(ResourceType.F_OPERATIONAL_STATE_HISTORY); + PrismContainer operationalStateHistory = + getObject().findContainer(ResourceType.F_OPERATIONAL_STATE_HISTORY); PrismContainerAsserter> asserter = new PrismContainerAsserter<>(operationalStateHistory, this, getDetails()); copySetupTo(asserter); diff --git a/repo/system-init/src/test/java/com/evolveum/midpoint/init/TestConfigurationLoad.java b/repo/system-init/src/test/java/com/evolveum/midpoint/init/TestConfigurationLoad.java index f5d016c3ea1..225dccce2b9 100644 --- a/repo/system-init/src/test/java/com/evolveum/midpoint/init/TestConfigurationLoad.java +++ b/repo/system-init/src/test/java/com/evolveum/midpoint/init/TestConfigurationLoad.java @@ -7,32 +7,24 @@ package com.evolveum.midpoint.init; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; +import static org.testng.Assert.*; -import static org.testng.Assert.assertTrue; import java.io.File; import java.util.Iterator; -import com.evolveum.midpoint.common.configuration.api.MidpointConfiguration; import org.apache.commons.configuration2.Configuration; import org.testng.annotations.Test; +import com.evolveum.midpoint.common.configuration.api.MidpointConfiguration; import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; - -public class TestConfigurationLoad { +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; - private static final Trace LOGGER = TraceManager.getTrace(TestConfigurationLoad.class); +public class TestConfigurationLoad extends AbstractUnitTest { @Test public void test010SimpleConfigTest() { - LOGGER.info("---------------- test010SimpleConfigTest -----------------"); - System.clearProperty(MidpointConfiguration.MIDPOINT_HOME_PROPERTY); - LOGGER.info("midpoint.home => {}", System.getProperty(MidpointConfiguration.MIDPOINT_HOME_PROPERTY)); + logger.info("midpoint.home => {}", System.getProperty(MidpointConfiguration.MIDPOINT_HOME_PROPERTY)); assertNull(System.getProperty(MidpointConfiguration.MIDPOINT_HOME_PROPERTY), "midpoint.home"); @@ -41,15 +33,15 @@ public void test010SimpleConfigTest() { Configuration c = sc.getConfiguration(MidpointConfiguration.REPOSITORY_CONFIGURATION); assertEquals(c.getString("repositoryServiceFactoryClass"), "com.evolveum.midpoint.repo.sql.SqlRepositoryFactory"); - LOGGER.info("{}", sc); + logger.info("{}", sc); Iterator i = c.getKeys(); while (i.hasNext()) { String key = i.next(); - LOGGER.info(" " + key + " = " + c.getString(key)); + logger.info(" " + key + " = " + c.getString(key)); } - assertEquals(c.getBoolean("asServer"), true); + assertTrue(c.getBoolean("asServer")); assertEquals(c.getString("baseDir"), System.getProperty(MidpointConfiguration.MIDPOINT_HOME_PROPERTY)); } @@ -58,20 +50,18 @@ public void test010SimpleConfigTest() { */ @Test public void test020DirectoryAndExtractionTest() throws Exception { - LOGGER.info("---------------- test020DirectoryAndExtractionTest -----------------"); - File midpointHome = new File("target/midPointHome"); System.setProperty(MidpointConfiguration.MIDPOINT_HOME_PROPERTY, "target/midPointHome/"); StartupConfiguration sc = new StartupConfiguration(); sc.init(); assertNotNull(midpointHome); - assertTrue(midpointHome.exists(), "existence"); - assertTrue(midpointHome.isDirectory(), "type directory"); + assertTrue(midpointHome.exists(), "existence"); + assertTrue(midpointHome.isDirectory(), "type directory"); File configFile = new File(midpointHome, "config.xml"); - assertTrue(configFile.exists(), "existence"); - assertTrue(configFile.isFile(), "type file"); + assertTrue(configFile.exists(), "existence"); + assertTrue(configFile.isFile(), "type file"); TestUtil.assertPrivateFilePermissions(configFile); ConfigurableProtectorFactory keystoreFactory = new ConfigurableProtectorFactory(); @@ -79,8 +69,8 @@ public void test020DirectoryAndExtractionTest() throws Exception { keystoreFactory.init(); File keystoreFile = new File(midpointHome, "keystore.jceks"); - assertTrue(keystoreFile.exists(), "existence"); - assertTrue(keystoreFile.isFile(), "type file"); + assertTrue(keystoreFile.exists(), "existence"); + assertTrue(keystoreFile.isFile(), "type file"); TestUtil.assertPrivateFilePermissions(keystoreFile); //cleanup diff --git a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/AbstractTaskManagerTest.java b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/AbstractTaskManagerTest.java index 69c9b2ceb21..af26ad6c483 100644 --- a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/AbstractTaskManagerTest.java +++ b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/AbstractTaskManagerTest.java @@ -7,6 +7,21 @@ package com.evolveum.midpoint.task.quartzimpl; +import static org.apache.commons.lang3.ObjectUtils.defaultIfNull; +import static org.testng.AssertJUnit.*; + +import static com.evolveum.midpoint.test.IntegrationTestTools.display; +import static com.evolveum.midpoint.test.IntegrationTestTools.waitFor; + +import java.io.File; +import java.io.IOException; +import java.math.BigInteger; +import java.util.*; + +import org.springframework.beans.factory.annotation.Autowired; +import org.testng.annotations.BeforeSuite; +import org.xml.sax.SAXException; + import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.util.PrismTestUtil; @@ -22,31 +37,13 @@ import com.evolveum.midpoint.task.api.TaskExecutionStatus; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.util.AbstractSpringTest; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.CommonException; import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; import com.evolveum.midpoint.util.exception.ObjectNotFoundException; import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; -import org.springframework.beans.factory.annotation.Autowired; -import org.testng.annotations.BeforeSuite; -import org.xml.sax.SAXException; - -import java.io.File; -import java.io.IOException; -import java.math.BigInteger; -import java.util.*; - -import static com.evolveum.midpoint.test.IntegrationTestTools.display; -import static com.evolveum.midpoint.test.IntegrationTestTools.waitFor; -import static org.apache.commons.lang3.ObjectUtils.defaultIfNull; -import static org.testng.AssertJUnit.*; -/** - * @author mederly - */ public class AbstractTaskManagerTest extends AbstractSpringTest { protected static final String CYCLE_TASK_HANDLER_URI = "http://midpoint.evolveum.com/test/cycle-task-handler"; @@ -62,7 +59,6 @@ public class AbstractTaskManagerTest extends AbstractSpringTest { protected static final String L1_TASK_HANDLER_URI = "http://midpoint.evolveum.com/test/l1-task-handler"; protected static final String L2_TASK_HANDLER_URI = "http://midpoint.evolveum.com/test/l2-task-handler"; protected static final String L3_TASK_HANDLER_URI = "http://midpoint.evolveum.com/test/l3-task-handler"; - protected static final String WAIT_FOR_SUBTASKS_TASK_HANDLER_URI = "http://midpoint.evolveum.com/test/wait-for-subtasks-task-handler"; protected static final String PARALLEL_TASK_HANDLER_URI = "http://midpoint.evolveum.com/test/parallel-task-handler"; protected static final String LONG_TASK_HANDLER_URI = "http://midpoint.evolveum.com/test/long-task-handler"; @@ -150,7 +146,7 @@ protected PrismObject addObjectFromFile(String filePat OperationResult result = new OperationResult(TestQuartzTaskManagerContract.class.getName() + ".addObjectFromFile"); try { add(object, result); - } catch(ObjectAlreadyExistsException e) { + } catch (ObjectAlreadyExistsException e) { delete(object, result); add(object, result); } @@ -161,7 +157,7 @@ protected PrismObject addObjectFromFile(String filePat protected void add(PrismObject object, OperationResult result) throws ObjectAlreadyExistsException, SchemaException { if (object.canRepresent(TaskType.class)) { - taskManager.addTask((PrismObject)object, result); + taskManager.addTask((PrismObject) object, result); } else { repositoryService.addObject(object, null, result); } @@ -215,12 +211,12 @@ protected void waitForTaskCloseCheckingSubtasks(String taskOid, OperationResult } protected void waitForTaskStart(String oid, OperationResult result, long timeoutInterval, long sleepInterval) throws CommonException { - waitFor("Waiting for task manager to start the task", () -> { - Task task = taskManager.getTaskWithResult(oid, result); - IntegrationTestTools.display("Task while waiting for task manager to start the task", task); - return task.getLastRunStartTimestamp() != null && task.getLastRunStartTimestamp() != 0L; - }, timeoutInterval, sleepInterval); - } + waitFor("Waiting for task manager to start the task", () -> { + Task task = taskManager.getTaskWithResult(oid, result); + IntegrationTestTools.display("Task while waiting for task manager to start the task", task); + return task.getLastRunStartTimestamp() != null && task.getLastRunStartTimestamp() != 0L; + }, timeoutInterval, sleepInterval); + } protected void waitForTaskProgress(String taskOid, OperationResult result, long timeoutInterval, long sleepInterval, int threshold) throws CommonException { @@ -231,17 +227,6 @@ protected void waitForTaskProgress(String taskOid, OperationResult result, long }, timeoutInterval, sleepInterval); } - protected void waitForTaskNextRun(String taskOid, OperationResult result, long timeoutInterval, long sleepInterval) throws Exception { - TaskQuartzImpl taskBefore = taskManager.getTaskWithResult(taskOid, result); - waitFor("Waiting for task manager to execute the task", () -> { - Task task = taskManager.getTaskWithResult(taskOid, result); - IntegrationTestTools.display("Task while waiting for task manager to execute the task", task); - return task.getLastRunStartTimestamp() != null && - (taskBefore.getLastRunStartTimestamp() == null || task.getLastRunStartTimestamp() > taskBefore.getLastRunStartTimestamp()); - }, timeoutInterval, sleepInterval); - } - - protected void suspendAndDeleteTasks(String... oids) { taskManager.suspendAndDeleteTasks(Arrays.asList(oids), 20000L, true, new OperationResult("dummy")); } diff --git a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestMiscellaneous.java b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestMiscellaneous.java index 53fc7d11fbd..c315ffc22fa 100644 --- a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestMiscellaneous.java +++ b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestMiscellaneous.java @@ -6,6 +6,24 @@ */ package com.evolveum.midpoint.task.quartzimpl; +import static java.util.Collections.emptyList; +import static java.util.Collections.singletonList; +import static org.testng.AssertJUnit.assertEquals; + +import static com.evolveum.midpoint.prism.util.PrismTestUtil.display; +import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; + +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import javax.xml.namespace.QName; + +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.ContextConfiguration; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.Test; +import org.xml.sax.SAXException; + import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.schema.MidPointPrismContextFactory; import com.evolveum.midpoint.schema.constants.MidPointConstants; @@ -16,29 +34,10 @@ import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskExecutionLimitationsType; import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskGroupExecutionLimitationType; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import javax.xml.namespace.QName; -import java.io.IOException; -import java.util.Arrays; -import java.util.List; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.display; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; -import static java.util.Collections.emptyList; -import static java.util.Collections.singletonList; -import static org.testng.AssertJUnit.assertEquals; - -/** - * - */ -@ContextConfiguration(locations = {"classpath:ctx-task-test.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-task-test.xml" }) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) -public class TestMiscellaneous { +public class TestMiscellaneous extends AbstractTaskManagerTest { @BeforeSuite public void setup() throws SchemaException, SAXException, IOException {